Compiling and Linking for Optimization

If you omit both the /compile_only and the /keep options, the specified Fortran source files are compiled together into a single object module and then linked. (The object file is deleted after linking.) Because all the Fortran source files are compiled together into a single object module, full interprocedural optimizations can occur. With the DF command, the default optimization level is /optimize:4 (unless you specify /debug with no keyword).

If you specify the /compile_only or /keep option and you want to allow full interprocedural optimizations to occur, you should also specify the /object option. The combination of the /compile_only and /object:file options creates a single object file from multiple Fortran source files, allowing full interprocedural optimizations. The object file can be linked later.

The following command uses both the /compile_only and /object options to allow interprocedural optimization (explicitly requested by the /optimize:4 option):

  DF /compile_only /object:out.obj /optimize:4 ax.for bx.for cx.for

If you specify the /compile_only or /keep option without specifying the /object option, each source file is compiled into an object file. This is acceptable if you specified no optimization (/optimize:0) or local optimization (/optimize:1). An information message appears when you specify multiple input files and specify an option that creates multiple object files (such as /compile_only without /object) and specify or imply global optimization (/optimize:2 or higher optimization level).

If you specify the /compile_only option, you must link the object file (or files) later by using a separate DF command. You might do this using a makefile processed by the NMAKE command for incremental compilation of a large application.

However, keep in mind that either omitting the /compile_only or /keep option or using the /compile_only option with the /object:file option provides the benefit of full interprocedural optimizations for compiling multiple Fortran source files.

Other optimization options are summarized in Software Environment and Efficient Compilation.