Compiling and linking f90, f77 codes

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

DEBUGL = -g -r8
OPTIML = -O2 -r8
PROFLL = -u -O
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


Prefix pour les noms des objets


Type – compilation


Name of executable file

EXEC = runInPetto


DPO = $(DOBJ)/

List the objet files



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:
-c $(DSR)/LINK/SOURCE/FLOW/steinli_interface.f90 $(OPTR)$(DPO)steinli_interface.o"

$(CC) $(OPTC) $(DSR)/LINK/SOURCE/FLOW/flw_main.f90 $(OPTR)$(DPO)flw_main.o"

$(CC) $(OPTC) $(DSR)/LINK/SOURCE/FLOW/flw_basic_init.f $(OPTR)$(DPO)flw_basic_init.o"

Any help will be appreciated

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,