2 Compiling and linking

This chapter discusses how to compile and link HP Fortran programs and covers the following topics:

Compiling with the f90 command

Linking HP Fortran programs

Special-purpose compilations

Using environment variables

Compiling with the f90 command

The default behavior of the f90 command is to compile source files listed on the command line and, if the compilation is successful, to pass the resulting object files to the linker. If the link stage is successful, the linker produces an executable program with the default name a.out.

Consider, for example, the program hello.f90:

Example 1 hello.f90

PROGRAM main

CALL hello()

END PROGRAM main

SUBROUTINE hello()

PRINT *, 'Hello, I must be going.'

END SUBROUTINE hello

When compiled with the command line:

$ f90 hello.f90

f90 produces two files, hello.o (object code) and a.out(the executable program).

If the command line contains only an object file, as in the following:

$ f90 hello.o

f90passes the object file to the linker, which (if successful produces the executable program a.out.

Here is a sample run of the executable program:

$ a.out

Hello, I must be going.

This section provides more detailed information about using the f90command, including:

Command-line syntax

Command-line options

Filenames recognized by f90

f90 command syntax

The default behavior of the f90 command is to compile source files listed on the command line and, if the compilation is successful, to pass the resulting object files to the linker. If the link stage is successful, the linker produces an executable program with the default name a.out.

Consider, for example, the program hello.f90:

18 Compiling and linking