NOTE: The compiler generates a.modfile for each file that defines a Fortran module. It also reads the .modfiles when compiling source files that use modules. Do not specify .mod files on the command line. If you do, the compiler will pass them to the linker, which will try (and fail) to link them into the executable. For more information about .mod files, see “Compiling programs with modules” (page 54).
Linking HP Fortran programs
This section discusses how to link object files and covers the following topics:
•The advantages of using the f90 command for linking as well as for compiling
•How to link libraries, including shared libraries
•How to establish the search rules used by the linker when it looks for libraries
For more information about the linker, see Programming on
Linking with f90 vs. ld
By default, the f90 command both compiles and links, producing an executable program. You can modify this behavior with the
In fact, we recommend that you use the f90 command whenever you link HP Fortran object files and that you use the same command line for linking as for compiling.
When you use the f90 command to compile and link in the same command line, the driver passes certain
To see what information f90passes to the linker, compile with
1 $ f90
2 /opt/fortran90/lbin/f90com
3hello.f90
4program MAIN
5external subroutine HELLO
67 Lines Compiled
7LPATH is: /opt/fortran90/lib/pa1.1:/usr/lib/pa1.1: /opt/fortran90/lib:/usr/lib:/opt/langtools/lib
8/usr/ccs/bin/ld
Line 1 is the f90 command line.
Line 2 is the information f90 passes to the compiler, including the full pathname of the compiler, the name of the source file (hello.f90), and the internal names of the option settings as determined by the defaults and the f90command line.
Lines 3 - 6 show the progress of the compilation; line 6 indicates that the compilation was successful.
Line 7 displays the value to which f90 has defined the LPATH environment variable. If you use the ld command to link hello.f90, you must defineLPATH on the command line before invoking the linker. See “LPATH environment variable” (page 65).
50 Compiling and linking