Compiling and Linking Multiple Fortran Source Files

The following command compiles a.for, b.for, and c.for. It creates a single temporary object file, then links the object file into an executable file named a.exe:

  DF a.for b.for c.for

If the files a.for, b.for, and c.for were the only .for files in the current directory, you could use a wildcard character to similarly compile the three source files:

  DF  *.for

If you use the /compile_only option to prevent linking, also use the /object:file option so that multiple sources files are compiled into a single object file, allowing more optimizations to occur:

  DF /compile_only /object:a.obj  a.for b.for c.for

When you use modules and compile multiple files, compile the source files that define modules before the files that reference the modules (in USE statements).

When you use a single DF command, the order in which files are placed on the command line is significant. For example, if the free-form source file moddef.f90 defines the modules referenced by the file projmain.f90, use the following DF command line:

  DF moddef.f90 projmain.f90