Fortran Programming Guide

f77 I/O Profiling

You can obtain a report about how much data was transferred by your program. For each Fortran unit, the report shows the file name, the number of I/O statements, the number of bytes, and some statistics on these items.

To obtain an I/O profiling report, insert calls to the library routines start_iostats and end_iostats around the parts of the program you wish to measure. (A call to end_iostats is required if the program terminates with an END or STOP statement rather than a CALL EXIT.)


Note -

The I/O statements profiled are: READ, WRITE, PRINT, OPEN, CLOSE, INQUIRE, BACKSPACE, ENDFILE, and REWIND. The runtime system opens stdin, stdout, and stderr before the first executable statement of your program, so you must explicitly reopen these units after the call to start_iostats.


Example: Profile stdin, stdout, and stderr:


      EXTERNAL start_iostats 
      ... 
      CALL start_iostats
      OPEN(5)
      OPEN(6)
      OPEN(0)

If you want to measure only part of the program, call end_iostats to stop the process. A call to end_iostats may also be required if your program terminates with an END or STOP statement rather than CALL EXIT.

The program must be compiled with the -pg option. When the program terminates, the I/O profile report is produced on the file name.io_stats, where name is the name of the executable file.

Here is an example:


demo% f77 -o myprog -pg -silent myprog.f
demo% myprog
   ... output from program
demo% cat myprog.io_stats
                   INPUT REPORT
1. unit    2. file name             3. input data             4. map
                           cnt     total       avg   std dev    (cnt)
------------------------------------------------------------------------
      0          stderr      0         0         0         0    No
                             0         0         0         0
      5           stdin      2         8         4         0    No
                             1         8         8         0
      6          stdout      0         0         0         0    No
                             0         0         0         0
     19         fort.19      8        48         6     4.276    No
                             4        48        12         0
     20         fort.20      8        48         6     4.276    No
                             4        48        12         0
     21         fort.21      8        48         6     4.276    No
                             4        48        12         0
     22         fort.22      8        48         6     4.276    No
                             4        48        12         0

                   OUTPUT REPORT
1. unit             5. output data            6. blk size  7. fmt  8. direct
           cnt     total       avg   std dev                        (rec len)
-----------------------------------------------------------------------------
      0      4        40        10         0           -1     Yes     seq
             1        40        40         0
      5      0         0         0         0           -1     Yes     seq
             0         0         0         0
      6     26       248     9.538      1.63           -1     Yes     seq
             6       248     41.33     3.266
     19      8        48         6     4.276       500548     Yes     seq
             4        48        12         0
     20      8        48         6     4.276       503116      No     seq
             4        48        12         0
     21      8        48         6     4.276       503116     Yes     dir
             4        48        12         0                        (   12)
     22      8        48         6     4.276       503116      No     dir
             4        48        12         0                        (   12)
     ...

Each pair of lines in the report displays information about an I/O unit. One section shows input operations and another shows output. The first line of a pair displays statistics on the number of data elements transferred before the unit was closed. The second row of statistics is based on the number of I/O statements processed.

In the example, there were 6 calls to write a total of 26 data elements to standard output. A total of 248 bytes was transferred. The display also shows the average and standard deviation in bytes transferred per I/O statement (9.538 and 1.63, respectively), and the average and standard deviation per I/O statement call (42.33 and 3.266, respectively).

The input report also contains a column to indicate whether a unit was memory mapped or not. If mapped, the number of mmap() calls is recorded in parentheses in the second row of the pair.

The output report indicates block sizes, formatting, and access type. A file opened for direct access shows its defined record length in parentheses in the second row of the pair.


Note -

Compiling with environment variable LD_LIBRARY_PATH set might disable I/O profiling, which relies on its profiling I/O library being in a standard location.