man f77or in the SPARCompiler FORTRAN User's Guide.
f77 Option Description Example ---------- ----------- ------- -a This causes code to be f77 -a main.f -a sub.f inserted which counts the a.out times each basic block is tcov main.f executed. After the program tcov sub.f is executed, the tcov cat main.tcov utility can be run on the cat sub.tcov source file to generate statistics about the program. Thus, while the -p option allows you to get a profile of routine usage, the -a option provides a means of profiling within a program unit (i.e.., the number of times each line within a unit is executed). See Note 3 below. -Bstatic This causes the loader to f77 -Bstatic main.f use static bindings (i.e., non-shared libraries). The resultant executable program file therefore contains all of the routines required for execution. Such a file will run on other Sun computers (e.g., your Sun workstation) running the same operating system. -c Compile only. Suppress f77 -c sub.f linking by the loader. (This command will Produces a binary ".o" produce the binary file. See FORTRAN tip output file sheet "Compiling and "sub.o"). Executing FORTRAN Programs Requiring Subprograms" for additional information. -C Check subscripts. f77 -C main.f If your program, at run time, attempts to access an array element that is out of bounds, an error message will be printed and the program aborted. -fast Selects the combination of f77 -fast main.f compilation options that optimizes for speed of execution and should provide the maximum per- formance for most applications. Selects -O2 for optimization. See Note 1 below. -fast -O3 Same as -fast but changes f77 -fast -O3 main.f the optimization level to -O3. This may be a better choice than -fast for some critical routines. See Note 1 below. -g Generates information for f77 -g main.f dbx or debugger. See the dbx a.out FORTRAN tip sheet . "Debugging FORTRAN . Programs". -help Prints and defines the f77 -help f77 compiler options. or f77 -help | less -lx The loader will link with f77 main.f -L/opt/lib -lnag object library libx.a, (on Strauss) where x is a string. See Note 2 below. Note that an -lx option must appear after any .f or .o files. When in doubt, place this option at the end of the f77 command. -o file Set the name of the f77 main.f -o main.exe executable output file. Without this option, the default name of the output file is "a.out". -O Generate optimized code. f77 -O main.f This is equivalent to -O3. See Note 1 below. Also see the man pages for a description of other levels of optimization. -p Prepare to collect data f77 -p main.f sub1.f for the prof program. The a.out prof program produces an prof execution profile of a program. See Note 3 below. -xld For debugging. Compile f77 -xld main.f statements with a "d" or "D" in column 1. -Xlist Use this option to get f77 -Xlist main.f one.f cross-references and line-numbered listings (produces the file of your source. This output main.lst). is written to a file with suffix ".lst" and prefix identical to the prefix of the first file appearing in the compilation statement. See the FORTRAN User's Guide or the man pages for a complete description including its numerous suboptions. Note that if syntax errors occur during the compilation, the .lst file is not produced. Note 1: When a floating-point arithmetic operation has no result that is universally acceptable, the system "raises an exception". By default, these exceptions are handled according to choices provided by the IEEE Standard 754. Thus, for example when two large numbers are multiplied together to produce a result that causes overflow, rather than the program aborting, the default result is "+Inf" or "-Inf". Likewise, the result of 0/0 is "NaN" (not a number). In such cases the program is not aborted. When the -fast compiler option is used, these default actions are switched off. You can get different numerical results or premature program termination. Therefore, do not use the -fast option for programs that depend on IEEE standard exception handling. However, this should not be misconstrued as advising not to use the -fast option. Usually, but not always, you will get the fastest running program with the -fast -O3 option combination, and in many instances you may not need to have the IEEE exception handling anyway. When in doubt test your program using -fast -O3 and also -O3 alone. You may also want to try -fast -O4 versus -O4. In one test case where 600 x 600 matrices were multiplied, the program compiled with -O3 actually ran slightly faster than the program compiled with -fast -O3 while in other cases the reverse was true. When in doubt, test it out! Note 2: Under Sun OS 5.x (i.e., on Strauss), the loader searches the directories /opt/SUNWspro/lib, /opt/SUNWspro/ SC2.0.1, /opt/ccs/lib and /usr/lib in that order. The FORTRAN libraries are in the /opt/SUNWspro/SC2.0.1 directory and the IMSL and NAG libraries are in directory /opt/lib. Therefore,you must provide the IMSL and/or NAG directory information to the compiler. This can be done either using the switch "-L/opt/lib" or by adding /opt/lib to the definition of the environment variable LD_LIBRARY_PATH. See the tip sheet, "Using IMSL and NAG FORTRAN Subroutine Libraries " for further details on using LD_LIBRARY_PATH.) Note 3: When improving run-time performance of large programs, it is often helpful to focus your task to those routines that are using a major proportion of the cpu. Profiling with prof (or with gprof) can assist you in this endeavor. After compiling with the -p option and executing your program, running prof will produce a listing which will include all of the subprograms and the percentage of cpu each of these used during the execution. After this is accomplished, you can recompile those routines which have been shown to utilize large proportions of the total cpu with the -a option and then use tcov to locate the code lines responsible for the large cpu usage. Alternatively, the options -p and -a can be used at the same time (see the summary chart below: "Print an Execution Profile".) Alternative procedures for profiling exist under Sun OS 5. See the tip sheet: "Introduction to the SPARCworks Analyzer". ***************************************************************** * * * Correspondence to VS FORTRAN * * * ***************************************************************** * * * VS FORTRAN UNIX * * ========== ==== * * * * * * Compiling in Link Mode * * ====================== * * * * global vsf2link cmslib * * fortvs2 main * * fortvs2 sub f77 -Bstatic main.f sub.f -o main.exe * * * * Binary File without Linking * * =========================== * * * * fortvs2 sub f77 -c sub.f * * * * * * Checking Array Bounds * * ===================== * * * * fortvs2 main sub f77 -C main.f sub.f * * * * where at the top of * * the FORTRAN files for * * main fortran and sub * * fortran are the lines: * * * * debug subchk * * enddebug * * * * * * Compile with Optimization * * ========================= * * * * fortvs2 main (opt(3) f77 -O main.f sub.f * * fortvs2 sub (opt(3) * * * * Interactive Debugging * * ===================== * * * * filedef affout disk ..... * * fortvs2 main * * load main (clear f77 -g main.f -o main.exe * * start * debug dbx main.exe * * or * * debugger main.exe * * (For further information * * on debugging see the tip * * sheet: "Debugging a * * FORTRAN Program Using * * debugger/dbx") * * * * * * Linking Libraries * * ================= * * * * global txtlib .. nagvlib .. * * fortvs2 main * * load main (clear start On Strauss: * * f77 main.f -o main.exe -L/opt/lib -lnag * * (Strauss) * * main.exe * * * * See the tip sheet "Compiling and * * Executing Programs Requiring * * Subprograms" for special option and * * environment variable requirements * * when linking in routines from the * * IMSL library. * * * * * * * * Print an Execution Profile * * ========================== * * * * filedef affout disk .... * * fortvs2 main f77 -p -a main.f -o main.exe * * load main (clear main.exe * * start * debug prof * * enddebug sample called tcov main.f * * listsamp * summary cat main.tcov * * listsamp main. (also see the tip sheet: * * "Introduction to the * * SPARCworks Analyzer") * * * * * * Produce a Listing with Cross-References * * ======================================= * * * * fortvs2 main (xref f77 -Xlist main.f * * * *****************************************************************