2.18 Modules

To use a module it must be an intrinsic module, previously compiled, or defined in the file prior to its use. When separately compiling a module the -c option should be specified.

Compiling a module creates a ‘.mod’ file and a ‘.o’ file. The ‘.mod’ file is used by the compiler at compile time to provide information about module contents, the ‘.o’ file (if generated) contains the code of any module procedures and must be specified when creating an executable file.

Note that the name of the ‘.mod’ file will be the name of the module, the ‘.o’ file will be named after the original source file.

When a previously compiled module is USEd the NAG Fortran Compiler attempts to find its source file and, if that is successful, checks the modification times producing a warning message if the ‘.mod’ file is out of date.