Quantcast
Channel: Intel® Software - Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2746

Linking problem between modules using submodules

$
0
0

Hi,

actually I'm trying to compile a program that uses a module mod1 consisting of many submodules. Those submodules are using by themself functions from an other module mod2 that consists of module procedures (all in a single file, but using the same logic as submodules). My makefile looks something like (I'm using ifort 16.0):

...
#DIRECTORY OF MOD2
INC=-I./mod2_dir

#SUBMODULES OF MOD1
MOD1_SMOD = $(shell find mod1_*.f90)

all: program

#COMPILE MODULE MOD1
mod1.o: mod1.f90 ./mod2_dir/mod2.o
	$(FC) $(CO) -c $^ $(LIBS) $(INC)

#COMPILE SUBMODULES OF MOD1
$(MOD1_SMOD:.f90=.o): $(MOD1_SMOD) mod1.o
	$(FC) $(CO) -c $^ $(LIBS) $(INC)

#COMPILE MODULE MOD2
./mod2_dir/mod2.o:
	cd ./mod2_dir/; make

#COMPILE AND LINK PROGRAM
program: program.f90 $(MOD1_SMOD:.f90=.o) mod1.o ./mod2_dir/mod2.o
	$(FC) $(CO) -o $@ $^ $(LIBS) $(INC)
...

When linking the program I'm getting errors of undefined references to the module procedure functions of mod2.f90 that are called from submodules (MOD1_SMOD) of mod1 (like `mod2_MP_mod2_fooxy_'). Can anybody tell me where my fallacy is?

Also, I don't understand why I have to explictly state all submodule object files, since for each sobmodule exists a *,smod file within the search directories. Shouldn't they be found automatically??

I would be very grateful for any advice!


Viewing all articles
Browse latest Browse all 2746

Trending Articles