Compiling and linking f90, f77 codes

Hey,
I have a module for some particle tracking stuff written in f90, and I want to couple it to a some fluid flow solver which is written in f77.

The problem I’m facing is in generating the make file .

Since the code source code is spread over various directories, the original makefile for f77 code used to create the makefile (generatiing dependencies) on the fly. This works well with f77 code but with f90 code I will have to show the path to the used modules also by -I (right?)

The makefile puts all the *.o files in a separate OBject file folder. For f90, I’m able to put the *.o files in this Object folder but *.mod files wont go there …


Just that it makes sense I’m copy pasting some part of my makefile hereunder…

Please note that the steinli_interface.f90 is the interface I want to link with my f90 module

Nom du compilateur, nom de l’editeur de liens

CC = pgf90
LINK = pgf90

Options de compilation, options a l’edition de liens

NONEC = -c
DEBUGC = -c -g -r8
OPTIMC = -c -O2 -r8
PROFLC = -c -u -O
DEBUGR8C = -c -u -xtypemap=real:64 -g
OPTIMR8C = -c -fast -stackvar -autopar -xtypemap=real:64
PROFLR8C = -c -u -xtypemap=real:64 -O

NONEL =
DEBUGL = -g -r8
OPTIML = -O2 -r8
PROFLL = -u -O
DEBUGR8L = -g
OPTIMR8L = -fast -stackvar -autopar -xtypemap=real:64
PROFLR8L = -u -xtypemap=real:64 -O

Option de redirection des objets

OPTR = -o "

MPTR = -mod "

--------------------------------------------------------

Parametres for Makefile

--------------------------------------------------------

Repertoire des fichiers sources

DSR = .

Repertoire des objets pour les fichiers sources

qui ne sont pas dans le repertoire courant

DOBJ = LINKO

Prefix pour les noms des objets

PRE = OPTIM_

Type – compilation

OPTC = $(OPTIMC)
OPTL = $(OPTIML)

Name of executable file

EXEC = runInPetto

--------------------------------------------------------

DPO = $(DOBJ)/
#/$(PRE)

List the objet files

LOBJ =

$(DPO)steinli_interface.o
$(DPO)flw_main.o
$(DPO)flw_basic_init.o
$(DPO)flw_global_init.o
$(DPO)flw_ope.o
$(DPO)flw_equ.o
$(DPO)lmn_main.o
$(DPO)mjrm_solver.o
$(DPO)iowa_solver.o
$(DPO)ctz_solver.o
$(DPO)flwP_graph.o
$(DPO)flwP_main.o
$(DPO)flwP_padetest.o
$(DPO)flwP_poissontest.o
$(DPO)fil_main.o
$(DPO)fil_share.o
$(DPO)fil_manag.o
$(DPO)grid_main.o
$(DPO)cpu.o
$(DPO)dimension.o
$(DPO)thomas.o
$(DPO)ind.o
$(DPO)surfop.o
$(DPO)minmax.o
$(DPO)tools.o
$(DPO)graphfile.o
$(DPO)der.o
$(DPO)der_sub_vec.o
$(DPO)der_subbox_vec.o
$(DPO)bound_surfop.o
$(DPO)lmn_bd_main.o
$(DPO)flwL_heat.o
$(DPO)flwL_main.o
$(DPO)flwL_turb.o
$(DPO)acc_bd_main.o
$(DPO)misc.o
$(DPO)profiles.o
$(DPO)rnd.o
$(DPO)share_fil.o
$(DPO)fft_.o
$(DPO)fft_sub.o
$(DPO)fft_spt.o
$(DPO)geneturb_tools.o
$(DPO)filter_main.o
$(DPO)les_main_anup.o
$(DPO)les_sub.o
$(DPO)flwPOI_fft.o
$(DPO)flwPOI_fsh.o
$(DPO)flwPOI_main.o
$(DPO)flwPOI_mud.o
$(DPO)comf.o
$(DPO)fftpack.o
$(DPO)genbun.o
$(DPO)gnbnaux.o
$(DPO)hw3crt.o
$(DPO)hwscrt.o
$(DPO)pois3d.o
$(DPO)cud2sp.o
$(DPO)mud2sp.o
$(DPO)mud3sp.o
$(DPO)mudcom.o

Construction of Dependencies for the executable

$(EXEC) : $(LOBJ)
$(LINK) $(OPTL) -o $(EXEC) $(LOBJ)

Dependances at compilation stage for source files

$(DPO)steinli_interface.o $(DPO)steinli_interface.mod:
$(DSR)/LINK/SOURCE/FLOW/steinli_interface.f90
$(CC) -O2 -I$(DSR)/LINK/SOURCE/STEINLI/ -I$(DSR)/LINK/SOURCE/SHARED_MODULES/
-c $(DSR)/LINK/SOURCE/FLOW/steinli_interface.f90 $(OPTR)$(DPO)steinli_interface.o"

$(DPO)flw_main.o:
$(DSR)/LINK/SOURCE/FLOW/flw_main.f90
$(DSR)/LINK/SOURCE/BOUND/bound.param
$(DSR)/LINK/SOURCE/FLOW/flw_dim.common
$(DSR)/LINK/SOURCE/FLOW/flw_dim.param
$(DSR)/LINK/SOURCE/FLOW/flw_flow.common
$(DSR)/LINK/SOURCE/FLOW/flw_lmn.common
$(DSR)/LINK/SOURCE/FLOW/flw_lmn.param
$(DSR)/LINK/SOURCE/FLOW/flw_run.common
$(DSR)/LINK/SOURCE/FLOW/lag_mod.param
$(DSR)/LINK/SOURCE/GRID/grid.common
$(DSR)/LINK/SOURCE/GRID/grid.param
$(CC) $(OPTC) $(DSR)/LINK/SOURCE/FLOW/flw_main.f90 $(OPTR)$(DPO)flw_main.o"

$(DPO)flw_basic_init.o:
$(DSR)/LINK/SOURCE/FLOW/flw_basic_init.f
$(DSR)/LINK/SOURCE/FILES/fil.common
$(DSR)/LINK/SOURCE/FILES/fil_ind.common
$(DSR)/LINK/SOURCE/FLOW/flw_dim.common
$(DSR)/LINK/SOURCE/FLOW/flw_dim.param
$(DSR)/LINK/SOURCE/FLOW/flw_flow.common
$(DSR)/LINK/SOURCE/FLOW/flw_ite.common
$(DSR)/LINK/SOURCE/FLOW/flw_lmn.common
$(DSR)/LINK/SOURCE/FLOW/flw_lmn.param
$(DSR)/LINK/SOURCE/FLOW/flw_ref.common
$(DSR)/LINK/SOURCE/FLOW/flw_run.common
$(CC) $(OPTC) $(DSR)/LINK/SOURCE/FLOW/flw_basic_init.f $(OPTR)$(DPO)flw_basic_init.o"


Any help will be appreciated
Thanks
Rahul

Hi Rahul,

The “-I” flag can be used when searching for mod files. To have a module file be put in a particular directory when it is built, use "-module ".

Hope this helps,
Mat