Download CERN UNIX User Guide

Transcript
use:
f77 -o hello hello.f
The -c option suppresses the link-edit phase. The compiler generates an object file with the
extension .o for each input file and not the a.out file. This is useful when compiling source
files that contain only subprograms, which can be linked later with other object files. The
resulting object files can then be specified on the compiler command line:
f77 -c func.f
f77 main.f func.o
7.3
Important Platform Dependent Differences
On most platforms at CERN the recommended Fortran compiler is called f77. The exception
is HP/UX where you are recommended to use fort77 rather than f77 since it allows you to
specify libraries in a way which is compatible with all the other platforms. For AIX on the RS/
6000 the Fortran compiler is called xlf, but in more recent versions of AIX the name f77 can
also be used. On DEC Ultrix systems the supported compiler is the DEC Fortran compiler
rather than the MIPS Fortran.
The table below shows the minimum command that should be used for compiling and linking
in the CERN environment.
Machine
IBM/AIX
HP/UX
Others
Compilation only
xlf -c -qextname
fort77 -c +ppu
f77 -c
Compiling and/or Linking
xlf -qextname
fort77 +ppu
f77
As we saw in the section above, by default Unix compilers generate an executable module.
The option “-c” (compile only) generates an object file but causes the linking phase to be surpressed.
The options -qextname on AIX and +ppu on HP/UX are explained in “Compiling and Linking
Options” on page 62 and are ESSENTIAL for compatibility with the CERN Program Library.
7.4
Libraries
Libraries in Unix are the same as libraries in other operating systems. They usually contain a
collection of pre-compiled routines which you can link to your routines when creating an executable. On all Unix systems, libraries can be created with the command ar(short for
archive). See “Creating and maintaining your own libraries” on page 64. Once again, it is
not necessary for a new Unix user to know this command but you can find more information in
the man pages.
Libraries in Unix follow a naming convention such that names begin with the letters lib and
have the extension .a ( for archive ) or .sl ( for shared library ). This was not a
whim of the creators of Unix but actually serves a useful purpose.
When specifying libraries to be used in linking you can use a shorthand notation. If you wish,
61