Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

how i use makefile

parastoo_s_
Beginner
1,194 Views
hello dear membrane Could someone tell me how to create and run a makefile. I have the following code I want to run.. subroutines.f90 main.f90 i have a makefile contain bellow data: # # Makefile for finite element code... # # Please adjust Fortran compiler and flags, path to netcdf # to your specific computer #=============================== # Fortran compiler and flags #================================ # INTEL COMPILER #------------------- FC = ifort ## Options optimizing for speed (on the current cpu architecture) FCFLAGS = -O3 -ipo -xHost -openmp -no-prec-div -align ## Options for debugging: #FCFLAGS = -g -xHost -openmp -traceback -fpe:0 -check all #================================= # Path to netcdf #================================= ## If given by environment variables # NC_LIB = $(NETCDF_LD) # NC_INC = -I$(NETCDF_INC) ## If in the standard path (e.g. /usr/lib), you may skip -L ## We need the Fortran bindings, too, which can come as a seperate ## lib (netcdff) or be in included in the main lib (netcdf). # NC_LIB = -lnetcdf -lnetcdff # NC_INC = ## A path at your system, here Fortran libnetcdff included in libnetcdf NC_ROOT = /uv/soft/netcdf/3.6.3-gnu NC_LIB = -L$(NC_ROOT)/lib -lnetcdf NC_INC = -I$(NC_ROOT)/include ## or no netcdf at all # NC_LIB = -DNO_NETCDF # NC_INC = #================================ # Name of the executable #================================ # Just choose whatever you like. EXE = ompTsuna.x ########################################################## # No change necessary below #-------------------------------------------------------- .SUFFIXES: .F90 .o SRC = data_types.F90 \ parameters.F90 \ mesh.F90 \ elements.F90 \ swe.F90 \ benchmark.F90 \ initial_conditions.F90 \ okada_fault_parameters.F90 \ output.F90 \ tsunami.F90 #--------------------------------------------------- $(EXE): $(SRC) make clean $(FC) $(FCFLAGS) -o $(EXE) $(SRC) $(NC_LIB) $(NC_INC) clean : rm -f *~ *.o *.mod $(EXE) please help me how i can use this makefile for run my program? thanks
0 Kudos
4 Replies
TimP
Honored Contributor III
1,194 Views

If you're simply trying to use netcdf, learning how to convert a linux Makefile for use with ifort windows may be a red herring.  I don't think you will find specific advice about using a Makefile with netcdf on Windows.  If you are actually intending to use linux, there are "offficial" posted Intel recipes for netcdf.

Some of the advice previously posted on this forum may be useful

https://software.intel.com/en-us/forums/topic/281318

and you will need to observe the advice from the ucar site about Visual Studio compatible libraries (assuming you intend to use ifort).

0 Kudos
mecej4
Honored Contributor III
1,194 Views

If you want to modify the makefile for use with IFort-Windows, you will need to contend with the fact that IFort gives the object files that it produces the extension ".OBJ".

One way of doing this is to tell IFort the name of the output object file, using the /Fo option, perhaps in a dependency rule for ".f90.o:". It would have been easier if IFort had an option to specify the file extension for all object files, which would allow building multiple objects in parallel with the nice /MP option.

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,194 Views

>> It would have been easier if IFort had an option to specify the file extension for all object files, which would allow building multiple objects in parallel with the nice /MP option.

It would be nice if you could use wild cards in /Fo and /object (e.g. "/Fo *.o")

Maybe it does. If I were to add this, I would do it this way.

Intel:

Consider a MAKE file that you wish to compile on a Windows Host to produce files for use on a Xeon Phi (running Linux) as well as on the host. And consider that you also want to use the /MP option, meaning you elect NOT to use the MAKE file means of iteratively producing compiler statements. For this you might want to use "/MP /Fo *_xphi.o".

Jim Dempsey

0 Kudos
TimP
Honored Contributor III
1,194 Views

Among the ways to use gnu make (which doesn't come with ifort Windows) with Microsoft style conventions are to include definitions such as

CC       = cl
FC       = ifort
.SUFFIXES:      .obj .f90

and build rules you will require e.g.

.f90.obj:
        $(FC) $(FFLAGS) -c $*.f90

.f.obj:
        $(FC) $(FFLAGS) -c $*.f

 

If you wish to stay with .o suffixes, you could use build rules such as

.f.o:
        $(FC) $(FFLAGS) -c $*.f

        mv $*.obj $*.o

(or whatever the shell of your choice uses for rename)

Microsoft link.exe accepts .o files but gives a verbose warning for each one.

You would also need to change your ifort options from linux to Windows style.

There are also make utilities oriented toward Microsoft compatiblity such as nmake, but I don't know any which comply with posix definition for make utility.

As it appeared that the original implied question may have been about building netcdf, and no hint was given about important considerations such as 32- vs. 64-bit and choices of shells or C compiler, all this is probably tangential.

You will note that past advice given on this forum included using the "official" Intel advice for linux builds, implying that Intel experts don't recommend running netcdf (or standard make, for that matter) on Windows.  There's a deficiency of documentation about netcdf with Windows ifort, although Microsoft C++ is covered on the ucar site.

0 Kudos
Reply