views:

543

answers:

1

Is there is a way to put .mod files, generated by gfortran (GCC), into 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 the .mod files (which are generated by the above call) are not affected by the -o flag and placed in the current directory. Some commercial compilers have a flag like -qmoddir, but I cannot find something similar for gfortran.

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

Thanks for any hints!

+2  A: 

The GNU gfortran documentation indicates that -Mdir or its synonym -Jdir specifies the output directory for .mod files.

Jonathan Leffler