===================================================================
@@ -102,6 +102,7 @@ one is not the default.
and register usage.
* Interoperability Options:: Options for interoperability with other
languages.
+* File Output Options:: Which files the compiler generates during compilation.
* Environment Variables:: Environment variables that affect @command{gfortran}.
@end menu
@@ -178,6 +179,10 @@ and warnings}.
@xref{Interoperability Options,,Options for interoperability}.
@gccoptlist{-fc-prototypes}
+@item File Output Options
+@xref{File Output Options,,Options for determining output of files}.
+@gccoptlist{-fwrite-module-files}
+
@item Code Generation Options
@xref{Code Gen Options,,Options for code generation conventions}.
@gccoptlist{-faggressive-function-elimination -fblas-matmul-limit=@var{n} @gol
@@ -791,9 +796,12 @@ messages produced.
@item -fsyntax-only
@opindex @code{fsyntax-only}
@cindex syntax checking
-Check the code for syntax errors, but do not actually compile it. This
-will generate module files for each module present in the code, but no
-other output file.
+Check the code for syntax errors, but do not actually compile it.
+This will generate module files for each module present in the code,
+but no other output file. Using this option, it is possible to
+generate module files much faster. Together with the
+@option{-fwrite-module-files} options, it can be used for speeding up
+compilation processes.
@item -Wpedantic
@itemx -pedantic
@@ -1865,6 +1873,44 @@ where the C code intended for interoperating with
then uses @code{#include "foo.h"}.
@end table
+@node File Output Options
+@section Which files the compiler generates during compilation
+
+@table @asis
+
+@item -fwrite-module-files
+@opindex @code{write-module-files}
+@cindex Writing out module files
+This option will write out a @file{foo.mod} file when the module
+@code{foo} has been successfully compiled. This file will be read in
+later when @code{use foo} is encountered in the code.
+Writing out the file is the default.
+
+The negative form, @option{-fno-write-module-files}, supresses writing
+of module files. This can be useful when the module files have
+previously been generated with @option{-fsyntax-only}, for example to
+support a more parallel make process. When code has been changed and
+@option{-fno-write-module-files} is used, it is possible to generate
+inconsistent module files, which will lead to hard-to-find bugs. Use
+with care.
+
+An example of how this could be used is the following Makefile
+snippet. It assumes that @file{foo.f90} contains a module @code{foo},
+which is used by module @code{bar} in @file{bar.f90}. This would
+allow parallel compilation of @file{foo.f90} and @file{bar.f90}.
+
+@smallexample
+foo.mod: foo.f90
+ gfortran -fmodule-files=only foo.f90
+
+foo.o: foo.f90
+ gfortran -fmodule-files=no foo.f90
+
+bar.o: bar.f90 foo.mod
+ gfortran -c bar.f90
+@end smallexample
+@end table
+
@node Environment Variables
@section Environment variables affecting @command{gfortran}
@cindex environment variable
===================================================================
@@ -722,6 +722,10 @@ frepack-arrays
Fortran Var(flag_repack_arrays)
Copy array sections into a contiguous block on procedure entry.
+fwrite-module-files
+Fortran Var(flag_write_module_files) Init(1)
+Write module files.
+
fcoarray=
Fortran RejectNegative Joined Enum(gfc_fcoarray) Var(flag_coarray) Init(GFC_FCOARRAY_NONE)
-fcoarray=<none|single|lib> Specify which coarray parallelization should be used.
===================================================================
@@ -6284,7 +6284,9 @@ loop:
gfc_get_errors (NULL, &errors);
if (s.state == COMP_MODULE || s.state == COMP_SUBMODULE)
{
- gfc_dump_module (s.sym->name, errors_before == errors);
+ if (flag_write_module_files)
+ gfc_dump_module (s.sym->name, errors_before == errors);
+
gfc_current_ns->derived_types = gfc_derived_types;
gfc_derived_types = NULL;
goto prog_units;