Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Confused with linux makefile, ifort and mkl

Status
Not open for further replies.

econ2008

Programmer
Jul 26, 2010
9
Hello Everybody!

Well, I've got some serious problems with a code (program). I am using ubuntu 10.04 and installed the latest intel fortran composer with mkl ifort.
The program is organized in the following structure:

Folder
makefile
makefile.unix
makefile.windows
Subfolder1 (source)
fort.f90
fort2.f90
fort3.f90
fort4.f90
Subfolder2 (Model1)
Subfolder3 (Model2)
Subfolder4 (Model3)

The subfolders 2 to 3 inhibit an *.exe and a *.txt file. The makefiles refer, as far as I understood, to the source folder. But I really do not know how to run all this. I have installed ifort and the mkl library and I also have added all necessary lines to the .bahsrc file.
Here is the makefile:
Code:
##******************************************************************************
##  requires Intel Fortran compiler and Math Kernel Library
##******************************************************************************

help:
	@echo Usage: nmake {libia32^|dllia32^|libintel64^|dllintel64^}
	@echo [interface=interface_name] [threading=threading_name] [MKLROOT=MKL_root_path]
	@echo interface_name - can be lp64 or ilp64 for intel64. Default value is lp64.
	@echo threading_name - can be parallel or sequential. Default value is parallel.
	@echo MKL_root_path  - Locate MKL libraries relative to MKL_root_path.

##------------------------------------------------------------------------------
## examples of using:
##
## nmake libia32               - build  by  Intel(R) Fortran compiler
##                               for 32-bit processor, static linking
##
## nmake libintel64            - build  by  Intel(R) Fortran compiler
##                               for  Intel64(R) processor, static linking
##
## nmake dllintel64            - build  by  Intel(R) Fortran compiler
##                               for  Intel64(R) processor, dynamic linking
##------------------------------------------------------------------------------

SRCF90 = huggett+ aiyagari_crra+ aiyagari_ez+

!IFNDEF program
program = $(SRCF90)
!ENDIF

!IFNDEF interface
interface = lp64
!ENDIF

!IFNDEF threading
threading = parallel
!ENDIF

!IFNDEF MKLROOT
!ERROR *** MKLROOT is not defined in environment.
!ENDIF

EXE = $(program:+=.exe)

omp = iomp5
FC=ifort

!IF ("$(interface)"=="ilp64")
IFACE_LIB=mkl_intel_ilp64$(EXT)
FOPTS = /4I8
!ELSE
IFACE_LIB=mkl_intel_lp64$(EXT)
FOPTS =
!ENDIF

!IF ("$(_IA)" == "ia32")
IFACE_LIB=mkl_intel_c$(EXT)
FOPTS =
!ENDIF

!IF ("$(threading)"=="sequential")
THREADING_LIB=mkl_sequential$(EXT)
OMP_LIB =
OMP_EXT =
!ELSE
THREADING_LIB=mkl_intel_thread$(EXT)
OMP_LIB = /Qopenmp /Qopenmp-link:static
OMP_EXT = _iomp5
!ENDIF

CORE_LIB=mkl_core$(EXT)

MKL_LIBS=$(IFACE_LIB) $(THREADING_LIB) $(CORE_LIB) $(OMP_LIB)

!IF ("$(_IA)" == "ia32")
RES_DIR=bin\$(threading)_$(_IA)$(OMP_EXT)_$(RES_EXT)
!ELSE
RES_DIR=bin\$(interface)_$(threading)_$(_IA)$(OMP_EXT)_$(RES_EXT)
!ENDIF

FOPTS = $(FOPTS) /MT

!IF ("$(_IA)" == "ia32")
LIB95=mkl_blas95.lib mkl_lapack95.lib mkl_scalapack_core$(EXT)
!ELSE
LIB95=mkl_blas95_$(interface).lib mkl_lapack95_$(interface).lib mkl_scalapack_$(interface)$(EXT)
!ENDIF

libia32 lib32:
	set include=$(MKLROOT)\include\ia32;%%include%%
	nmake toolbox $(EXE) clean EXT=.lib _IA=ia32 RES_EXT=lib interface=$(interface) threading=$(threading) omp=$(omp)
dllia32 dll32:
	set include=$(MKLROOT)\include\ia32;%%include%%
	nmake toolbox $(EXE) clean EXT=_dll.lib _IA=ia32 RES_EXT=dll interface=$(interface) threading=$(threading) omp=$(omp)

libintel64 libem64t:
	set include=$(MKLROOT)\include\intel64\$(interface);%%include%%
	nmake toolbox $(EXE) clean EXT=.lib _IA=intel64 RES_EXT=lib interface=$(interface) threading=$(threading) omp=$(omp)
dllintel64 dllem64t:
	set include=$(MKLROOT)\include\intel64\$(interface);%%include%%
	nmake toolbox $(EXE) clean EXT=_dll.lib _IA=intel64 RES_EXT=dll interface=$(interface) threading=$(threading) omp=$(omp)

#-------------------------------------------------------------------------------

.SUFFIXES:: .f90 .exe

{source}.f90.exe:
	if not exist $(RES_DIR)\$(@B) md $(RES_DIR)\$(@B)
	$(FC) $(FOPTS) /Fo$(RES_DIR)\ /Fe$(RES_DIR)\$(@B)\ $< $(RES_DIR)\toolbox.obj $(LIB95) $(MKL_LIBS)

toolbox:
	if not exist bin md bin
	if not exist $(RES_DIR) md $(RES_DIR)
	$(FC) -c $(FOPTS) -Fo$(RES_DIR)\toolbox.obj source\toolbox.f90

clean:
	del /Q $(RES_DIR)\*.obj *.mod

#-------------------------------------------------------------------------------
and the makefile.unix:
Code:
# ============================================================================
# Name        : Makefile for Linux Intel Fortran Compiler
# Version     : v1.0
# Copyright   : GPL
# Description : Makefile for models in Fortran
# ============================================================================

ifndef $(MKLROOT)
error *** MKLROOT is not defined in environment.
endif

FOPTS = -I$(MKLROOT)/include/intel64/lp64
MKL_LIBS = -lmkl_blas95_lp64 -lmkl_lapack95_lp64 \
	$(MKLROOT)/lib/intel64/libmkl_scalapack_lp64.a \
	-Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_intel_lp64.a \
	$(MKLROOT)/lib/intel64/libmkl_intel_thread.a \
	$(MKLROOT)/lib/intel64/libmkl_core.a \
	$(MKLROOT)/lib/intel64/libmkl_blacs_intelmpi_lp64.a \
	-Wl,--end-group -openmp -lpthread

# List of executables to be built within the package
PROGRAMS = huggett aiyagari_crra aiyagari_ez

# "make" builds all
all: $(PROGRAMS)

# General rules
%: source/toolbox.f90 source/%.f90
	mkdir -p $@
	ifort $(FOPTS) $^ $(MKL_LIBS) -o $@/$@

# Utility targets
.PHONY: clean

clean:
	rm -f *.mod


But everytime I am trying to run the makefile I get errors. The guy that has written this, has not provided a readme. I know that is a lot, but I am trying to get this program started, but it seems i am obviously too stupid for this. I am not very familiar with this and I also do not know if I am right here, or if this is more a linux problem.

When I try to run those files I use make libia32 and get the error missing seperator. when i fix this, i get errors like "include not found" or some paths are not found.
I really don not know how to deal with this.

Thanks in advance!

bjoern
 
I am assuming that you are only running the unix version. If you type

make -n -f makefile.unix

It will tell you what it is trying to do. It might be that when some of the macros are expanded, they do not turn out right. If you haven't figured out what it is doing could you show us the output of make -n.

make -d -f makefile.unix

will give you even more debug information.
 
Thanks for your fast reaction.

when I first enter make -n -f makefile.unix i get:
makefile.unix:10: *** missing separator. Stop

Then I insert a tab in the line and it comes:
makefile.unix:10: *** commands commence before first target. Stop.

Entering make -n delivers:
makefile:29: *** missing separator. Stop.

And using make -d -f makefile.unix:
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i486-pc-linux-gnu
Reading make...
Reading make makefile.unix...
makefile.unix:10: *** commands commence before first target. Stop.

I had to translate the last from german to english. I hope it is right.

thanks




 
Looks like it was written for a different version of make. Comment out the following lines by putting in a leading #

ifndef $(MKLROOT)
error *** MKLROOT is not defined in environment.
endif

Also make sure MKLROOT is set (use the command env).
 
Hey!

THANK YOU! It worked, after I did that and I found by accident, a file where someone added the option --always-make. That also worked fine for me. The resulting program delivers correct solutions!

Thanks a lot!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top