fpt and WinFPT Reference Manual - Command-line Commands

| SimCon Home | Ref Manual Home |





FPT checks that every access to each sub-program argument declared with the attribute OPTIONAL is guarded by a test 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(*,*) t1 IF (PRESENT(t2)) THEN WRITE(*,*) t2 ENDIF WRITE(*,*) 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 Yes
Configuration file, config.fsp Yes
Specification (fsp) files, *.fsp Yes
Interactively, to FPT> prompt Yes
Interactive command files Yes
Embedded in the Fortran code Yes


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 2024 Software Validation Ltd. All rights reserved.