FPT and WinFPT Reference Manual - Command-line Commands

| SimCon Home | Reference Manual Home |





FPT checks that every access to each sub-program argument declared with the attribute OPTIONAL is guarded by a tests that the argument is present. Thus, for example, in the subroutine write_sub:

SUBROUTINE write_sub(t1,t2,t3) CHARACTER*(*) :: t1 CHARACTER*(*),OPTIONAL :: t2,t3 WRITE(6,*) t1 IF (PRESENT(t2)) THEN WRITE(6,*) t2 ENDIF WRITE(6,*) t3 END SUBROUTINE write_sub

the argument t2 is guarded by the test IF (PRESENT(t2)) but the optional argument t3 is not guarded. The failure to guard access to t3 will be reported as an error.

Note that the test which FPT makes will not detect all mechanisms by which optional arguments may be guarded. FPT detects the use of IF (PRESENT(...)) constructs to control IF ... THEN blocks and GOTO statements. If a logical variable is set up from a test for presence, the current version of FPT will not recognise that the logical variable is used to guard access to the optional argument. This command may therefore report false positives.

FPT also checks whether or not an optional argument is always present. If the argument is never used optionally, a failure to guard access to it is reported as a warning. If it not always present, a failure to guard access is an error. FPT reports a summary of the optional arguments analysed, for example:

Check for unguarded access to OPTIONAL arguments ================================================ Optional arguments: 10 Not always present and with unguarded references (Errors): 1 Always present but with unguarded references (Warnings): 2 Arguments with possible unguarded references (Warnings): 2 Total number of unguarded references: 8

Where to use this command:

Operating system command line


Configuration file, config.fsp


Specification (FSP) files, *.fsp


Interactively, to FPT> prompt:


Interactive command files


Embedded in the Fortran code



Checks of optional arguments are not made by default (Note that defaults may be changed in the configuration file).

Related Commands

The command INSERT CHECK OF OPTIONAL ARGUMENTS modifies the code to test at run-time for accesses to unguarded optional arguments.

Copyright ©1995 to 2014 Software Validation Ltd. All rights reserved.