by Juli Rew

The CRAY Y-MP8/864 (shavano) as seen schematically from above.
Note:This article is for archive purposes only. This platform has been decommissioned.
If you have written a big Fortran program to run on the Cray, it can be a daunting task to understand the program flow and to keep track of which routines and variables cross reference each other.A variety of tools, both interactive and batch, is available on the SCD Crays for examining your Fortran program. The interactive tool discussed below will let you examine both Fortran and C programs.
A summary of the tools discussed in this article is given in Table 1. (Click here if your browser does not support tables.)
Table 1. Summary of cross-reference tools Category Type Tool Subroutine call tree Static flint -t prog.f xbrowse (interactive) cf77 -Wf"-e sx" -c prog.f (ftref)< cf77 -r0 prog.f (cflist) Dynamic cf77 -F prog.f (flowtrace) Variable cross-reference Static cf77 -Wf"-e sx" -c prog.f flint -x prog.f
The Program Browser, xbrowse, provides application programmers with an interactive environment in which to view and edit Fortran 77, Fortran 90, and standard C code. With xbrowse, you can create graphical call trees that enable you to see quickly and clearly the structure of your code. You can also:
xbrowse is an X Window-based program, so you need to set your DISPLAY environment to allow xbrowse to display to your workstation. For example, C shell (csh) users can type:
- Generate information about loops, cross-references, common blocks, include files, and macro cross-references
- Combine files into a single application in which multiple files are treated as a single entity, allowing you to trace variables, calls, callers, and other portions of code on a global basis
- Find and display compilation errors
- Save information from displays to files
setenv DISPLAY myworkstation.ucar.edu:0
Bourne shell (sh) and Korn shell (ksh) users can type:
DISPLAY=myworkstation.ucar.edu:0; export DISPLAY
You also need to give the Cray client authorization to connect to your workstation X server. For example, on your workstation type:
xhost + shavano.ucar.edu
for shavano.
To start xbrowse, type:
xbrowse &
There are several options for obtaining calling information if you are running in batch mode (such as via NQS or Internet Remote Job Entry).
Three CF77 options
- ftref: To obtain a static calling tree, you can use ftref. This works only under CF77 on the Cray. Before you invoke ftref, first compile a Fortran program specifying compiler command-line options that generate a cross-reference table and source listing. For example,
cf77 -Wf"-e sx" -c prog.f
ftref -t full prog.l > reportfile
- flowtrace: Another option is to use flowtrace and flowview. flowtrace can be used to generate a dynamic calling tree. (Dynamic means the routines that are actually called when the program runs.) This is invoked:
cf77 -F prog.f
Running the program creates a file called flow.data, which can be examined using the flowview utility. While flowview is normally used interactively (that is, by typing flowview), it can also be run in batch to generate some types of reports. In your batch job, you can use the command
./a.out
flowview -LuchkT > reportfile
to get a caller/callee report and a text-based dynamic calling tree from the information gathered into the flow.data file.
flowtrace/flowview is an excellent combination to use for optimizing your codes for increased efficiency. In the resulting list of subroutines, the relative amount of time each one takes is indicated by a row of asterisks. flowview also recommends candidates for inlining if it sees any.
- cflist: It is possible to get calling tree information by calling cflist as a CF77 option. For example, the command
cf77 -r0 prog.f
generates a listing by calling the cflist command. You can then take a look at the listing in the file called prog.l.
flint contains several options for getting static calling trees and cross references from your Fortran program. Static here means any routine that the program may call, not just routines in your program. Again, this (currently) works only under CF77 on the Cray.A calling tree may be generated and saved to a file using
flint -t prog.f > reportfile
There is also a -T option to allow you to tailor your tree.
The following commands may be given on the -T switch:
head:symbol Suppresses the full call tree and shows a call tree with the specified top node. trim Trims the tree by suppressing repeated subtrees. condensed Condenses multiple calls to the same routine. alphabetical Sorts call tree alphabetically. nolibrary Omits library routines (routines from .lbt files) noundefined Omits undefined routines squish Shrinks the tree vertically by removing excess graphics. graphics=xxx Changes the tree graphics characters. The values given are the hex codes for the following shapes: | | | ----- | --+-- +-- +-- | | | The values should be five two-digit hex codes separated by colons. An example is graphics=C4:B3:C2:C3:C0 for the IBM extended character set.To obtain information on subprogram and variable cross-references, you can type:
flint -x prog.f
The cross-reference table for a subprogram shows where it is defined (if this is known), the subprograms that call it, and the subprograms it calls.
The cross-reference table for a variable shows where it is set, where it is referenced, if it was equivalenced, if it was a dummy argument in a subroutine or function, if it was a dummy argument in a statement function, and if it was indirectly initialized by an equivalence.
A reference document on flint is available via anonymous FTP to ftp.ucar.edu. It is located under
docs/cray/fortran_lint
A PostScript version is also available, with the filename fortran_lint.ps.