I am working on a Fortran library that contains many different functions. To develop it and maintain it more easily, I have divided this library into several modules (e.g., part1.f90, part2.f90, part3.f90) and a main module mylib.f90 using all these individual modules:
module mylib
use part1
use part2
use part3
implicit none
end module mylib
The idea is then to use this main module in my programs with use mylib. I am however having trouble compiling and linking these modules.
The modules are all contained and compiled in a directory /mylib/src/, which therefore also contains the corresponding *.o and *.mod files. When I compile my program in a different directory using:
gfortran -I/mylib/src myprog.f90 -o myprog
I would expect the compiler to find the required modules in the specified directory. But unfortunately, I get an error message that there are undefined references to functions that are actually contained in the submodules.
What am I doing wrong here?
Thank you for your help!