if I understood the manual correctly it should work to creat a file containing a fortran module in a folder, say /path/mods/test_mod.f90 i.e. :
module test_mod
i
You need to include the .o
file as well. That is, you should compile this as
gfortran -I/path/to/mods -o test_prog test_prog.f90 mods/test_mod.o
This worked and ran for me.
This
gfortran -c test_mod.f90
should produce two files: test_mod.mod
and test_mod.o
. Your other compilation statement
gfortran -I/path/mods -o test_prog test_prog.f90
correctly specifies the location in which to look for the .mod
file but omits the .o
file. The .mod
file is a bit like a compiler-generated header file, it is used for compilation of any program units which use-associate the module, but the object file is needed for linking.
The simplest (I think) fix is to write
gfortran -o test_prog -I/path/mods /path/mods/test_mod.o test_prog.f90
but you may want to fiddle around with that.