fpt and WinFPT Reference Manual - Command-line Commands

| SimCon Home | Ref Manual Home |

ENFORCE INTENT IN AS DECLARED

Syntax:

[DO NOT] ENFORCE INTENT [(] IN [)] AS DECLARED

Function:

fpt identifies sub-program arguments which are declared INTENT(IN) but which are written to. For each of these arguments, a new local temporary variable is declared with the same data type, data kind and array shape as the argument. A statement is inserted at the start of the sub-program to copy the argument to the new local variable, and the argument is replaced by the new local variable in the body of the sub-program. This enforces the declared INTENT.

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

Example:

In the code shown below, the argument n1 is declared INTENT(IN) but is passed into the subroutine s2 where it is assigned.

PROGRAM t_intent_in n0=1 CALL s1(n0) WRITE(6,'("After s1: ",I2)')n0 END PROGRAM t_intent_in SUBROUTINE s1(n1) INTEGER,INTENT(IN) :: n1 CALL s2(n1) END SUBROUTINE s1 SUBROUTINE s2(n2) n2=2 END SUBROUTINE s2

The command ENFORCE INTENT IN AS DECLARED instructs fpt to modify the code of s1 to:

SUBROUTINE s1(n1) INTEGER,INTENT(IN)::n1 INTEGER*4 n1_copy n1_copy=n1 !---------------^-------------------------------------------------------------- ! fpt - 3517 INTENT(IN) argument copied to avoid writing to it !------------------------------------------------------------------------------ CALL s2(n1_copy) END SUBROUTINE s1

Default:

INTENT(IN) arguments which are written to are marked by diagnostics in the code, but are not changed by default (Note that defaults may be changed in the configuration file).

Related Commands

The command CHECK INTENT identifies INTENT violations and generates a summary report.

The command REMOVE INTENT removes all non-mandatory INTENT declarations from the code.

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