Fortran Programming Guide

Some Examples Using Suboptions

Example: Use -Xlistwarnnn to suppress two warnings from a preceding example:


demo% f77 -Xlistwar338  -Xlistwar348 -XlistE -silent Repeat.f
demo% cat Repeat.lst
FILE  "Repeat.f"
program  repeat
     4             CALL nwfrk ( pn1 )
                                  ^
**** ERR  #418:  argument "pn1" is real, but dummy argument is 
                 integer*4 
                 See: "Repeat.f" line #14
     4             CALL nwfrk ( pn1 )
                                  ^
**** ERR  #317:  variable "pn1" referenced as integer*4 across
                 repeat/nwfrk//prnok in line #21 but set as real 
                 by repeat in line #2
subroutine  nwfrk
    17             PRINT *, prnok ( ix ), fork ( )
                                     ^
**** ERR  #418:  argument "ix" is integer*4, but dummy argument 
                 is real
                 See: "Repeat.f" line #20

Date:     Wed Feb 24 10:40:32 1999
Files:         2 (Sources: 1; libraries: 1)
Lines:        26 (Sources: 26; Library subprograms:2)
Routines:      5 (MAIN: 1; Subroutines: 3; Functions: 1)
Messages:      5 (Errors: 3; Warnings: 2)
demo%

Example: Explain a message and find a type mismatch in program ShoGetc.f:


demo% cat ShoGetc.f 
      CHARACTER*1 c
      i = getc(c)
      END
demo% f77 -silent ShoGetc.f							   Compile program	
demo% a.out                   Program waits for input...						
Z                    Type "Z" on keyboard. This causes run-time message. Why?
 Note: IEEE floating-point exception flags raised: 
    Invalid Operation; 
 See the Numerical Computation Guide, ieee_flags(3M) 
demo% f77 -XlistE -silent ShoGetc.f  Compile with Global Program Checking
demo% cat ShoGetc.lst                and view listing
FILE  "ShoGetc.f"
program  MAIN
     2          i = getc(c)
                ^
**** WAR  #320:  variable "i" set but never referenced
     2          i = getc(c)
                       ^
**** ERR  #412:  function "getc" used as real but declared as 
                 integer*4 
        Here is the error - function must be declared INTEGER.

     2          i = getc(c)
                         ^
**** WAR  #320:  variable "c" set but never referenced
demo% cat ShoGetc.f      Modify program to declare getc INTEGER and run again.
      CHARACTER*1 c
      INTEGER getc
      i = getc(c)
      END
demo% f77 -silent ShoGetc.f
demo% a.out
Z                        Type "Z" on keyboard
demo%                    Now no error.