Previous | Contents | Index |
The output produced by the f90 command includes:
You control the production of these files by specifying the appropriate options on the f90 command line. Unless you specify the -c option, the compiler generates a single temporary object file (see Section 2.1.6.2), whether you specify one source file or multiple source files separated by blanks. The ld linker is then invoked to link the object file into one executable program file.
If fatal errors are encountered during compilation, or if you specify
certain options such as
-c
, linking does not occur.
2.1.6.1 Naming Output Files
To specify a file name for the executable program file (other than a.out ), use the -o output option, where output specifies the file name. The following command requests a file name of prog1.out for the source file test1.f :
% f90 -o prog1.out test1.f |
If you specify the -c option with the -o output option, you rename the object file (not the executable program file). If you specify -c and omit the -o output option, the compiler names the object file using the first specified file name (with a .o suffix substituted for the source file suffix).
You can also use the
mv
command to rename a file.
2.1.6.2 Temporary Files
Temporary files created by the compiler or a preprocessor reside in the /tmp directory. For example, when an f90 command requests that the compiler create an object file and pass it to the linker, the file is created in, and later deleted from, the /tmp directory (unless you specified the -K option).
You can set the environment variable TMPDIR to specify a directory to contain temporary files if /tmp is not acceptable. For performance reasons, use a local disk (rather than a NFS mounted disk) to contain the temporary files.
For information about the commands used to set and unset environment variables, see Appendix B.
To view the file name and directory where each temporary file is created, use the -v option. To create (and retain) object files in your current working directory, use the -c option. Any object files ( .o files) that you specify on the f90 command line are retained.
The TMPDIR environment variable is also used during program execution
(run-time) to specify which directory to contain any scratch files your
program creates.
2.1.7 Using Multiple Input Files: Effect on Output Files
When you specify multiple source files, the following options control the production of output files and also influence whether Compaq Fortran can apply certain levels of optimizations:
A description of the interaction of these options follows:
% f90 -c -o out.o -O4 ax.f bx.f cx.f |
When you request a listing file (
-V
option), a single listing file is created unless you specify the
-c
option. If you specify the
-c
option and the
-V
option, separate listing files are created.
2.1.8 Examples of the f90 and fort Commands
The following examples show the use of the
f90
command. On Linux systems, use the
fort
command instead of the
f90
command.
2.1.8.1 Compiling and Linking Multiple Files
The following f90 command compiles the Compaq Fortran free format source files ( aaa.f90 , bbb.f90 , ccc.f90 ) into a single temporary object file:
% f90 -V aaa.f90 bbb.f90 ccc.f90 |
This f90 command invokes the ld linker and passes the temporary object file to ld , which it uses to produce the executable file a.out . The Compaq Fortran compiler ( -V option) creates the listing file aaa.l .
The following f90 command compiles all Compaq Fortran fixed-format (or tab-format) source files with file names that end with .f into a temporary object file:
% f90 -V *.f |
The
ld
linker produces the
a.out
file. The listing file (produced when the
-V
option is specified) assumes the name of the first file,
aaa.l
.
2.1.8.2 Retaining an Object File and Preventing Linking
The following f90 command compiles, but does not link, the free-format source file typedefs_1.f90 , which contains a MODULE TYPEDEFS_1 statement:
% f90 -c typedefs_1.f90 |
This command creates files
typedefs_1.mod
and
typedefs_1.o
. Specifying the
-c
option retains the object file
typedefs_1.o
and prevents linking.
2.1.8.3 Compiling Fortran 95/90 and C Source Files and Linking an Object File
The following f90 command compiles the free-format Compaq Fortran main program ( myprog.f90 ). The main program calls a function written in C and references the module TYPEDEFS_1 with a USE TYPEDEFS_1 statement (uses the object file created in the previous example). The C routine named utilityx_ is declared in a file named utilityx.c . All sources files are compiled and the object files are passed to the linker:
% f90 myprog.f90 typedefs_1.o utilityx.c |
This command does the following:
The following f90 command compiles the free-format Compaq Fortran source files circle-calc.f90 and sub.f90 together, producing one object file named circle.o :
% f90 -c -o circle.o circle-calc.f90 sub.f90 |
The default optimization level ( -O4 ) applies to both source files during compilation and uses the default loop unrolling. Because the -c option is specified, the object file is not passed to the ld linker and is not deleted. In this case, the named output file is the object file.
Like the previous command, the following f90 command compiles multiple source files:
% f90 -o circle.out circle-calc.f90 sub.f90 |
Because the
-c
option was omitted, an executable program named
circle.out
is created.
2.1.8.5 Specifying an Additional Linker Library
The following f90 command compiles a free-format source file myprog.f90 using default optimization, and passes an additional library for the linker to search:
% f90 typedefs_1.o myprog.f90 -lcxml |
The file is processed at optimization level
-O4
and then linked with the object file
typedefs_1.o
. The
-lcxml
option instructs the linker to search in the
libcxml
library for unresolved references (in addition to the standard list of
libraries the
f90
command passes to the linker).
2.1.8.6 Requesting Additional Optimizations
The following f90 command compiles the free-format Compaq Fortran source files circle-calc.f90 and sub.f90 together using software pipelining optimizations ( -O5 ):
% f90 -O5 -unroll 3 circle-calc.f90 sub.f90 |
The loops within the program are unrolled 3 times (
-unroll 3
). Loop unrolling occurs at optimization level
-O3
or above.
2.1.9 Using Listing Files
If you expect your program to have compilation errors, you should request a separate listing file ( -V option).
For example, the following command compiles Compaq Fortran source files with file names that end with .f , and ld creates an executable file named a.out :
% f90 -V *.f |
The listing file assumes the name of the first file. If the first file was named aaa.f , the listing file is named aaa.l .
Using a listing file provides such information as the column pointer (1) that indicates the exact part of the line that caused the error (see Section 2.3.2). Especially for large files, consider obtaining a printed copy of the listing file you can reference while editing the source file.
On Tru64 UNIX Alpha systems, the
f90
driver program passes options and files not intended for the Compaq
Fortran compiler to the
cc
driver program. On Linux Alpha systems, the
fort
driver program passes options and files not intended for the Compaq
Fortran compiler to the
ccc
driver program.
2.2.1 f90 Driver Program Interaction with cc and ccc, and ld
The f90 driver program controls which software components operate on the files and options specified on the f90 command line and their order of use. After preprocessing and compilation by the Compaq Fortran compiler, certain files or options are passed to the cc or the ccc driver program. The cc or ccc driver:
Figure 2-1 shows the sequence and use of related software components for an example f90 and fort command.
Figure 2-1 f90 Driver Program and Software Components
The f90 (or fort ) driver does the following:
Upon return to the command line, the f90 driver program returns one of the following status values:
On Tru64 UNIX systems, because the f90 driver runs other software components such as the C compiler ( cc ), error messages may be returned by these other components. For instance, ld may return a message if it cannot resolve a global reference. Using the -v option on the f90 command line can help clarify which component is generating the error.
On Linux systems, the
fort
driver program interacts with the C compiler (
ccc
) and the linker (
ld
) similarly.
2.2.2 make Facility
The make facility is often used to automate building large programs. On Tru64 UNIX systems, you can also use the integrated development environment and windowing interface provided by the DEC FUSE optional product, which provides a builder facility that uses make .
Certain options are passed directly from the f90 command driver to the cc or ccc compiler driver. These options do not generally apply to compiling Compaq Fortran source files, but might be used to:
With the -W c[c...],arg1[,arg2]... option, you can pass ld options not otherwise provided by the f90 command directly to ld .
When compiling a program that contains both Compaq Fortran and C language source files, you can usually compile with a single f90 command. Any options that f90 does not recognize are passed to cc , such as the following:
Certain options recognized and used by f90 also apply to cc , such as the -On option. If needed, you can compile the C files using the cc or ccc command (instead of the f90 command) with the -c option, and then compile the Compaq Fortran files and the (C language) object files using the f90 command.
For more information on the options processed by
cc
and
ccc
, see cc(1) and ccc(1) (for most options) or ld(1).
2.3 Compiler Limits, Compiler Messages, and Linker Messages
The following sections discuss the compiler limits and error messages
from the compiler and linker. Other components can report messages, as
described in Section 2.2.1.
2.3.1 Compiler Limits
Table 2-3 lists the limits to the size and complexity of a single Compaq Fortran program unit and to individual statements contained within it.
Language Element | Limit |
---|---|
Actual number of arguments per CALL
or function reference |
Limited only by memory constraints. |
Arguments in a function reference
in a specification expression |
255 |
Array dimensions | 7 |
Array construction nesting | 20 |
Array elements per dimension | 9,223,372,036,854,775,807 1 = 2**63-1 |
Constants; character and Hollerith | 7198 characters |
Constants; characters read in list-directed I/O | 2048 characters |
Continuation lines | 511 |
Data and I/O implied DO nesting | 7 |
DO and block IF statement nesting (combined) | 128 |
DO loop index variable | 9,223,372,036,854,775,807 1 = 2**63-1 |
Format group nesting | 8 |
Format statement length | 2048 characters |
Fortran source line length |
fixed form: 72 (or 132 if
-extend_source is in effect) characters free form: 7200 characters |
INCLUDE file nesting | 20 levels |
Labels in computed or assigned GOTO list | Limited only by memory constraints. |
Lexical tokens per statement | 20000 |
Named common blocks | Limited only by memory constraints. |
Parentheses nesting in expressions | Limited only by memory constraints. |
Structure nesting | 30 |
Symbolic-name length | 63 characters |
The following are usually limited by the amount of process virtual address space available, as determined by system parameters:
For information on increasing your limits, see Section 1.1.
Previous | Next | Contents | Index |