next up previous contents
Next: Binary Data - UNIX Up: FORTRAN (f77, ld, dbx) Previous: FORTRAN (f77, ld, dbx)   Contents

Sun Fortran

For full details on options to the Sun Fortran compiler, read the man page. Only the basic ones you will need are described here.

To compile a program use the f77 command. The format is:

f77 options program_name.f

The compiler will then create an executable program called ``a.out''. To run the program just type a.out .

There are two ways to change the executable filename. You will want to do this since every time you create an executable version of any program, the system will overwrite whatever was in ``a.out'' before. To rename your new executable version use the command mv. You can also use the -o option when using f77.

malama% f77 -o myprog myprog.f

To run the program, just type the filename you gave after -o. Optimization is turned on with the -O option. Various degrees of optimization can be obtained; the default (with -O) is Global Optimization.

Debugging options are enabled with the -g option. If a few judiciously placed WRITE statements are not adequate to track your problem, you will need to specify this option, and use the Sun Debugger, dbx, to trace code execution. Read the man page and/or the Sun manual on ``Debugging Tools''. Note that -g is incompatible with -O; they cannot be used together.

When you use f77 the linker is automatically activated. To suppress linking use the option -c. This option will just create an object file (ending with ``.o'') for each source file.

malama% 1f77 -c doit.f
doit.f:
MAIN doit:
malama%

An object file ``doit.o'' is created with this command. If you wish to create an executable version of the file then use the command ld, which invokes the linker. You will have to use -o to create a file other than ``a.out'', just like with f77.

If you decide to use the linker separately then you must tell it the proper libraries to search. When invoked automatically with f77 or cc (the C compiler), it will already know them, but when it is starting just with object files it has no way of knowing what language they began as, and therefore it cannot know which libraries to use. To determine which libraries to include and the order in which to specify them, see ``Chapter 2 - Developing Fortran Programs'' in the ``Fortran Programmer's Guide''. For use of the linker, ld, see man ld. Note that you can use f77 on ``.o'' files, and on C (``.c'') or assembly language (``.s'') source. This is useful if you are mixing routines written in different languages since the default libraries will be included automatically and the various compilers will be invoked so that all files are processed correctly.

To learn more about Sun Fortran see the manual ``Fortran Programmer's Guide''.

Most of the VMS extensions dealing with file formats (e.g. access methods, etc.) will not work, since in UNIX, all files are simple sequential streams of bits. Look in man f77 for further details. Note that the latest versions of f77 actually do most of the more common VMS extensions. The Sun VMS Fortran manual is quite short, and it is recommended that you read it.


next up previous contents
Next: Binary Data - UNIX Up: FORTRAN (f77, ld, dbx) Previous: FORTRAN (f77, ld, dbx)   Contents
h.stilmack@jach.hawaii.edu