3-1 COMPILER OPTIONS (FORTRAN 77)
**********************************
(Thanks to Timothy Prince for the good comment on HP-UX)
The compiler is no doubt the most important tool, you could say it's
the embodiment of FORTRAN on your machine type. Good compilers have
many useful options and you should be familiar with them.
More information on compiler options relevant to debugging can be found
in the debugging chapter.
VMS options related to selection of float types are described in the
chapter: 'Floats on different machines'.
+-------------------------------------------------------------+
| PLEASE CHECK THE OPTIONS IN YOUR COMPILER DOCUMENTATION |
+-------------------------------------------------------------+
The FORTRAN compilers on VMS, Digital UNIX and Ultrix are closely
related. VAX FORTRAN and later DEC FORTRAN became the unofficial
standards of FORTRAN compilers.
g77, the compiler made by the GNU project is unique in being the only
true multi-platform compiler. As a GNU product it's free, both in the
sense of being distributed without cost and in the sense you get the
sources and can modify them.
| OpenVMS | DEC UNIX | GNU-g77 |
| | & Ultrix | |
---------------|---------------|----------------|-----------------------|
No implicit | /WARNINGS= | -u | |
declarations | DECLARATIONS | | |
---------------|---------------|----------------|-----------------------|
Standard | /STANDARD | -std | |
violations | | | |
---------------|---------------|----------------|-----------------------|
Check array | /CHECK=BOUNDS | -C | |
bounds | | | |
---------------|---------------|----------------|-----------------------|
Produce a | /LIST | -V | |
listing file | | | |
---------------|---------------|----------------|-----------------------|
Compile | /D_LINES | -d_lines | |
d_lines | | | |
---------------|---------------|----------------|-----------------------|
Don't | /NOOPTIMIZE | -O0 | -O0 |
optimize | | | |
---------------|---------------|----------------|-----------------------|
| OpenVMS | DEC UNIX | GNU/g77 |
| | & Ultrix | |
---------------|---------------|----------------|-----------------------|
Prepare for | /DEBUG | -g | -g |
Debugging | | | |
---------------|---------------|----------------|-----------------------|
Don't link | | -c | -c |
---------------|---------------|----------------|-----------------------|
Specify object | /OBJECT= | -c -o name | -c -o name |
file name | | | |
---------------|---------------|----------------|-----------------------|
Exe file name | | -o name | -o name |
---------------|---------------|----------------|-----------------------|
Underflow | /CHECK= | -check | |
reporting | UNDERFLOW | underflow | |
---------------|---------------|----------------|-----------------------|
Longer code | /EXTEND_ | -extend_source | -ffixed-line-length-N |
lines | SOURCE | | N may be: 0,72,80,132 |
---------------|---------------|----------------|-----------------------|
Parallelize | /PARALLEL | | |
DO loops | | | |
---------------|---------------|----------------|-----------------------|
| OpenVMS | DEC UNIX | GNU/g77 |
| | & Ultrix | |
---------------|---------------|----------------|-----------------------|
Assembly | /MACHINE_CODE | -machine_code | -S |
code listing | | | |
---------------|---------------|----------------|-----------------------|
Allow | /RECURSIVE | -recursive | |
recursion | | | |
---------------|---------------|----------------|-----------------------|
No recursion | /NORECURSIVE | -norecursive | |
| | | |
---------------|---------------|----------------|-----------------------|
Static storage | Default | Default | -fnoautomatic |
SAVE all vars | | | |
---------------|---------------|----------------|-----------------------|
Case sensitive | /NAMES=AS_IS | -U | |
identifiers | for externals | | |
---------------|---------------|----------------|-----------------------|
Allow dummy | /ASSUME= | -assume dummy_ | |
aliasing | DUMMY_ | aliases | |
(in CALL) | ALIASES | | |
---------------|---------------|----------------|-----------------------|
| OpenVMS | DEC UNIX | GNU/g77 |
| | & Ultrix | |
---------------|---------------|----------------|-----------------------|
Pad source | /PAD_SOURCE | -pad_source | |
lines with | | | |
blanks | | | |
---------------|---------------|----------------|-----------------------|
Allow | /ALIGNMENT= | -align32 | |
misaligned | NONE | | |
data | | | |
---------------|---------------|----------------|-----------------------|
Append '_' to | Never done | Default | Default |
global names | | | |
---------------|---------------|----------------|-----------------------|
Treat REAL | /REAL_SIZE=64 | -r8 | |
vars as REAL*8 | | | |
---------------|---------------|----------------|-----------------------|
Vectorize | | | |
---------------|---------------|----------------|-----------------------|
UNIX derived compilers
----------------------
There was a time when most UNIX f77 compilers were derived from a
Common Origin - the original UNIX f77 command written by Stuart
Feldman, partly as a student exercise, partly as an ATT employee.
Robert Corbett (RPC) had been the UCB "keeper of the flame" from
the time Stu stopped working until about 1989.
The Cray compiler was never CO based. IBM wrote xlf from scratch
(but earlier IBM UNIX Fortrans were). HP's compiler is probably
also not CO based.
The fundamental architectural decisions of the CO were made in
order to cope with early UNIX on the PDP-11.
| SunOS | IRIX | UNICOS | HP-UX | AIX
| | | | | (xlf)
----------------|-----------|-----------|-----------|----------|--------------
No implicit | -u | -u | | |
declarations | | | | |
----------------|-----------|-----------|-----------|----------|--------------
Standard | -ansi | | | -a | langlvl=77std
violations | | | | |
----------------|-----------|-----------|-----------|----------|--------------
Check array | -C | -C | | -C | -C
bounds | | | | |
----------------|-----------|-----------|-----------|----------|--------------
Produce a | -Xlist | -listing | -r 0,1,2 | | -qsource
listing file | -sb | | -l | |
----------------|-----------|-----------|-----------|----------|--------------
Compile | | -d_lines | | -D | -D
d_lines | | | | |
----------------|-----------|-----------|-----------|----------|--------------
Don't | -O0 | -O0 | -O0 | -N |
optimize | | | | |
----------------|-----------|-----------|-----------|----------|--------------
| SunOS | IRIX | UNICOS | HP-UX | AIX
| | | | | (xlf)
----------------|-----------|-----------|-----------|----------|--------------
Prepare for | -g | -g | -g | -g |
debugging | | | | |
----------------|-----------|-----------|-----------|----------|--------------
Prepare for | -p | -p | | -p | -p
profiling | -pg | | | -G | -pg
----------------|-----------|-----------|-----------|----------|--------------
Don't link | -c | -c | -c | -c | -c
----------------|-----------|-----------|-----------|----------|--------------
Specify object | -c -o | -c -o | -c -o | -c -o |
file name | | | | |
----------------|-----------|-----------|-----------|----------|--------------
Exe file name | -o | -o | -o | -o |
----------------|-----------|-----------|-----------|----------|--------------
Underflow | system | syscall, | | |
reporting | call? | env. var | | |
----------------|-----------|-----------|-----------|----------|--------------
Longer code | -e | -extend_ | -N 80 | +es |
lines | | source | not 132! | |
----------------|-----------|-----------|-----------|----------|--------------
Parallelize | | -mp (old) | | |
DO loops | | -pfa | | |
----------------|-----------|-----------|-----------|----------|--------------
| SunOS | IRIX | UNICOS | HP-UX | AIX
| | | | | (xlf)
----------------|-----------|-----------|-----------|----------|--------------
Assembly | -S | -S | -S | -S |
code listing | | | | |
----------------|-----------|-----------|-----------|----------|--------------
Allow | Default | Default | | |
recursion | | | | |
----------------|-----------|-----------|-----------|----------|--------------
No recursion | | | | |
| | | | |
----------------|-----------|-----------|-----------|----------|--------------
Static storage | -Bstatic | -static | | -K | Default
-SAVE all vars | | | | |
----------------|-----------|-----------|-----------|----------|--------------
Case sensitive | -U | -U | | +U | -U
identifiers | | | | |
----------------|-----------|-----------|-----------|----------|--------------
Allow dummy | | | | | alias=nostd
aliasing | | | | | xflag=xalias
(in CALL) | | | | |
----------------|-----------|-----------|-----------|----------|--------------
| SunOS | IRIX | UNICOS | HP-UX | AIX
| | | | | (xlf)
----------------|-----------|-----------|-----------|----------|--------------
Pad source | | | | |
lines with | | | | |
blanks | | | | |
----------------|-----------|-----------|-----------|----------|--------------
Allow | -misalign | -alignX | | |
misaligned | (Sun-4) | X=8,16.. | | |
data | | | | |
----------------|-----------|-----------|-----------|----------|--------------
Append '_' to | Default | Default | | |
global names | | | | +ppu | -qextname
----------------|-----------|-----------|-----------|----------|--------------
Treat REAL | -r8 | -r8 | | -R8 | -realsize=8
vars as REAL*8 | | | | |
----------------|-----------|-----------|-----------|----------|--------------
Vectorize | | | | |
----------------|-----------|-----------|-----------|----------|--------------
PC Compilers
------------
| Salford | Lahey |
| | |
----------------|---------|---------|
No implicit | /dclvar | /0 |
declarations | | Not O! |
----------------|---------|---------|
Standard | /ansi | /C |
violations | | |
----------------|---------|---------|
Check array | /check | /B |
bounds | ???? | |
----------------|---------|---------|
Produce a | /list | /H |
listing file | | |
----------------|---------|---------|
Compile | | |
d_lines | | |
----------------|---------|---------|
Don't | | |
optimize | | |
----------------|---------|---------|
| Salford | Lahey |
| | |
----------------|---------|---------|
Prepare for | | |
Debugging | | |
----------------|---------|---------|
Don't link | | |
----------------|---------|---------|
Specify object | | |
file name | | |
----------------|---------|---------|
Exe file name | | |
----------------|---------|---------|
Underflow | | |
reporting | | |
----------------|---------|---------|
Longer code | | |
lines | | |
----------------|---------|---------|
Parallelize | | |
DO loops | | |
----------------|---------|---------|
| Salford | Lahey |
| | |
----------------|---------|---------|
Assembly |/explist | |
code listing | | |
----------------|---------|---------|
Allow | | |
recursion | | |
----------------|---------|---------|
No recursion | | |
| | |
----------------|---------|---------|
Static storage | /save | |
SAVE all vars | | |
----------------|---------|---------|
Case sensitive | | |
identifiers | | |
----------------|---------|---------|
Allow dummy | | |
aliasing | | |
(in CALL) | | |
----------------|---------|---------|
| Salford | Lahey |
| | |
----------------|---------|---------|
Pad source | | |
lines with | | |
blanks | | |
----------------|---------|---------|
Allow | | |
misaligned | | |
data | | |
----------------|---------|---------|
Append '_' to | | |
global names | | |
----------------|---------|---------|
Treat REAL | /dreal | |
vars as REAL*8 | | |
----------------|---------|---------|
Vectorize | | |
----------------|---------|---------|
Remarks
=======
1) When two options perform an identical function, the
shorter one was selected.
2) UNIX compilers use a driver that can compile and link
with one command, so some options are passed to the
linker and apply to the linking phase.
In practice, programs are partitioned to modules that
are compiled to produce object files (usually with the
'-c' option), the object files are then linked by the
f77 (f90) driver (a better method than using 'ld').
3) More material on compiler options relevant to debugging
can be found in the debugging chapter.
4) VMS options related to selection of float types are
described in the chapter: 'Floats on different machines'.
5) VMS options may be different (?) for VAX and Alpha versions.
UNIX compiling systems (like web browsers) use file extensions to
determine how to process input files, and to make a distinction
between different types of output files.
The VMS compiler is separate from the linker (link editor), and
doesn't support preprocessors (except the special purpose DML),
so there is no need to use file extensions to determine the method
of processing, only FORTRAN source code files are accepted.
The introduction of Fortran 90 changes this somewhat, the '.F90'
extension marks a free format source file, while '.FOR' and '.F'
are still old FORTRAN 77 sources.
The VMS FORTRAN 77 compiler allows you to drop the file extension,
in that case it tries the supplied file name, first with extension
'.FOR', then with '.F'.
Default file extensions (compilation and linking)
=================================================
| VMS | SunOS | IRIX | DUNIX | UNICOS | Comments
-----------------|-------|-------|----------|-------|----------|------------
Source code | .FOR | .for | .f | .f | .f | Input
(FORTRAN 77 or | .F | .f | .F | | |
fixed-form F90) | | .F | | | |
-----------------|-------|-------|----------|-------|----------|------------
Source code | .F90 | .f90 | .f90 | .f90 | .f90 | Input
Fortran 90 | | | | | |
free-form | | | | | |
-----------------|-------|-------|----------|-------|----------|------------
Listing file | .LIS | | | | .l | Output
assembly code | | | .s | | .s |
paralellizing | | | .m (PFA) | | .m (fpp) |
| | | .l (PFA) | | .j (fmp) |
| | | | | .m.l |
-----------------|-------|-------|----------|-------|----------|------------
Source Analysis | .ANA | .d | | | .t | Output
information | .DIA | | | | |
-----------------|-------|-------|----------|-------|----------|------------
Object code | .OBJ | .o | .o | .o | .o | Input/
| | | | | | Output
-----------------|-------|-------|----------|-------|----------|------------
Libraries | | | | | | Input
text (include) | .TLB | | | | |
object | .OLB | .a | .a | | |
shared | .EXE | | .so | | |
-----------------|-------|-------------------------------------|------------
Executable file | .EXE | usually no extension DEFAULT: a.out | Output
-----------------|-------|-------------------------------------|------------
Remark: VMS file names are in uppercase letters.
File extensions used by common FORTRAN preprocessors are a little
bit complicated:
Pre-processing file extensions (incomplete)
===========================================
Pre-processor | OS | input | output | Comments
---------------|--------|-------|--------|---------------------------------
cpp | IRIX | .r .f | .i |
| SunOS | .F | |
| | | |
| VMS | | | Invoked by: CC/PREPROCESS_ONLY
---------------|--------|-------|--------|---------------------------------
GPP | UNICOS | .F | .i | UNICOS replacement for cpp
---------------|--------|-------|--------|---------------------------------
m4 | IRIX | | .p |
| | | |
---------------|--------|-------|--------|---------------------------------
ratfor | SunOS | .r | | Outdated (FORTRAN 66)
(RATional- | IRIX | .r | | Implements a C-like language
FORtran) | | | | on top of FORTRAN
---------------|--------|-------|--------|---------------------------------
PFA | IRIX | .f .F | .m .l | Kuck & Associates
(Power Fortran | | | | DO loop paralellizer
Accelerator) | | | |
---------------|--------|-------|--------|---------------------------------
Return to contents page