Fortran Programming Guide

"Old Style" tcov Coverage Analysis

Compile the program with the -a (or -xa) option. This produces the file $TCOVDIR/file.d for each source .f file in the compilation. (If environment variable $TCOVDIR is not set at compile time, the .d files are stored in the current directory.)

Run the program (execution must complete normally). This produces updated information in the .d files. To view the coverage analysis merged with the individual source files, run tcov on the source files. The annotated source files are named $TCOVDIR/file.tcov for each source file.

The output produced by tcov shows the number of times each statement was actually executed. Statements that were not executed are marked with ####-> to the left of the statement.

Here is a simple example:


demo% f77 -a -o onetwo -silent one.f two.f
demo% onetwo
       ... output from program
demo% tcov one.f two.f
demo% cat one.tcov two.tcov
                       program one
      1 ->             do i=1,10
     10 ->                   call two(i)
                       end do
      1 ->             end

             Top 10 Blocks
             Line         Count
                3            10
                2             1
                5             1

          3       Basic blocks in this file
          3       Basic blocks executed
      100.00       Percent of the file executed
           12       Total basic block executions
         4.00       Average executions per basic block

                       subroutine two(i)
     10 ->             print*, "two called", i
                       return
                       end

             Top 10 Blocks
             Line         Count
                2            10

          1       Basic blocks in this file
          1       Basic blocks executed
      100.00       Percent of the file executed
           10       Total basic block executions
        10.00       Average executions per basic block
demo%