Gfortran: how to manage the output directory for .mod files

Is there a way to put .mod files generated by gfortran (GCC) in a separate output directory? I know how to place object files or other output with the -o flag, as in:

gfortran -c test.f03 -o /path/to/output/dir/test.o 

But .mod files (which are generated by the above call) are independent of the -o flag and are placed in the current directory. Some commercial compilers have the -qmoddir flag, but I can't find something like this for gfortran.

If there is no such flag, is it possible to generate .mod files in an extra step to get the -o flag?

+4
source share
1 answer

The GNU gfortran documentation indicates that -M dir or its synonym, -J dir, indicates the output directory for .mod files.

+10
source

All Articles