FPT and WinFPT Reference Manual - Command-line Commands

| SimCon Home | Reference Manual Home |


CORRECT INCONSISTENT ARGUMENTS

Syntax:

CORRECT [INCONSISTENT] ARGUMENTS

CORRECT [INCONSISTENT] NUMERIC ARGUMENTS

CORRECT [INCONSISTENT] STRING ARGUMENTS

CORRECT [INCONSISTENT] HOLLERITH ARGUMENTS


DO NOT CORRECT [INCONSISTENT] ARGUMENTS

DO NOT CORRECT [INCONSISTENT] NUMERIC ARGUMENTS etc.


Function:

FPT checks that the actual arguments passed in sub-program calls are consistent with the formal arguments in the sub-program declarations. If an inconsistency is detected, the code at the call site is modified to correct it. The correction is marked in the program text. If no correction is possible, an error is reported to the terminal and list file and is marked in the code.

Inconsistencies may arise in:

Corrections are made according to the following rules:

  1. No correction is made if the formal or actual arguments are sub-program names, statement labels or records. An error is reported.

  2. No correction is made to numeric arguments which differ in protocol. String arguments passed inconsistently by reference, by address and length and by descriptor are corrected.

  3. Where the formal and actual arguments are whole arrays of different data types or different bounds, no correction is attempted and an error is reported.

  4. Where the formal and actual arguments are whole arrays which differ only in data size, a new temporary array is declared to act as the actual argument, and the original actual argument is copied to or from it as required.

  5. Where the actual argument is a scalar which differs in data type or data size from the formal argument, the correction strategy depends on the access which the sub-program called makes to the formal argument, on whether the argument is an input argument, an output argument or an input and output argument.

Formal argument an input argument only, of type:
Actual Argument
Literal Value of Type:
LogicalIntegerRealDouble precisionComplexCharacter
Logical Copy Error ErrorErrorErrorError
Integer ErrorCopy RewriteRewriteErrorError
Real ErrorRewriteRewriteRewriteErrorError
Double precisionErrorRewriteRewrite- ErrorError
Complex ErrorError ErrorError RewriteError
String %REF %REF %REF%REF %REFCopy
Hollerith - - -- -Rewrite
Parameter or Expression of Type:
Logical Copy Error ErrorErrorErrorError
Integer ErrorCopy IntrinsicIntrinsicErrorError
Real ErrorIntrinsicintrinsicIntrinsicErrorError
Double precisionErrorIntrinsicIntrinsic- ErrorError
Complex ErrorError ErrorIntrinsic CopyError
String Error Error ErrorError ErrorCopy
Hollerith - - -- -Error
Variable of Type:
Logical Copy Error ErrorErrorErrorError
Integer ErrorCopy IntrinsicIntrinsicErrorError
Real ErrorIntrinsicintrinsicIntrinsicErrorError
Double precisionErrorIntrinsicIntrinsic- ErrorError
Complex ErrorError ErrorError CopyError
Character Error Error ErrorError ErrorCopy


Formal argument an output or input-output argument of type:
Actual Argument
Literal or Expression:
LogicalIntegerRealDouble precisionComplexCharacter
Any Type ErrorErrorErrorErrorErrorError
Variable of Type:
Logical Copy Error ErrorErrorErrorError
Integer ErrorCopy CopyCopyErrorError
Real ErrorCopyCopyCopyErrorError
Double precisionErrorCopyCopy- ErrorError
Complex ErrorError ErrorError CopyError
Character Error Error ErrorError ErrorCopy


The strategies in the table are:

Rewrite: The literal actual argument is rewritten in the format appropriate to the formal argument. For example:

Actual ArgumentFormal ArgumentRewritten actual argument
1.0 REAL*8 1.0D0
256 REAL*4 256.0E0
(1.374,-22.71) COMPLEX*16 (0.1374D01,-0.2271D02)
6HRadius CHARACTER*(*) 'Radius'


Intrinsic: An intrinsic function invocation is used to convert the actual argument in situ. For example:

Actual Argument & TypeFormal ArgumentRewritten actual argument
DOUBLE PRECISION Y REAL*4 REAL(Y)
REAL*4 X REAL*8 DBLE(X)
REAL*4 X INTEGER*2 IINT(X)


Copy: The actual argument is copied to and/or copied from a temporary variable of the appropriate data type and size. If necessary, an intrinsic function call is used to make the type conversion. The temporary variable is used as the actual argument.

If no name clash occurs, the temporary variable name is taken from the name of the formal argument with the suffix _ARG. A declaration statement for the temporary variable is inserted in the sub-programs which reference it.

For example: Formal argument REAL*4, INTENT(INOUT) :: RANGE

Original statement, with actual argument INTEGER*4 K

CALL ADD_TO_TABLE(K)

Modified code:

RANGE_ARG = REAL(K) CALL ADD_TO_TABLE(RANGE_ARG) !---------------------------------^-------------------------------------- !!! FPT - 1873 Actual argument has been changed to match formal argument !------------------------------------------------------------------------ K=INT(RANGE_ARG)


%REF: Passing of a character argument by reference.

Character arguments are usually passed either by descriptor or by address and length. Descriptors are structures which contain the address and length of the character string. The call site contains, or more usually the system stack receives a single address which is the address of the descriptor. When character arguments are passed by address and length, both the address and the length of the argument are placed on the system stack.

Numeric arguments are normally passed by reference. The call site contains, or the stack receives a single address. If a character argument is passed by descriptor when a numeric is expected, the descriptor is then interpreted as if it were the numeric value and an error occurs. If a character argument is passed by address and length when a numeric value is expected, an additional item is placed on the system stack and eventually causes a stack violation. The program may crash at a site remote from the call site which caused the error.

The correction described here is made when a character argument is passed but the formal argument is numeric. It may be carried out in two ways, controlled by the FPT commands CORRECT INCONSISTENT STRING ARGUMENTS TO HOLLERITHS and CORRECT INCONSISTENT STRING ARGUMENTS BY %REF. In the first case, the string argument is rewritten as an Hollerith constant. In the second it is converted in situ to be passed by reference by the pseudo-function %REF. For example:

Formal argument REAL*8, INTENT(IN) which is used to receive an 8 character Hollerith value:

CALL HEADING('Weight ')

The modified code, converting to an Hollerith:

CALL HEADING(8HWeight ) !---------------------------^-------------------------------------------- !!! FPT - 1873 Actual argument has been changed to match formal argument !------------------------------------------------------------------------

Modified code, using %REF:

CALL HEADING(%REF('Weight ')) !----------------------------------^------------------------------------- !!! FPT - 1873 Actual argument has been changed to match formal argument !------------------------------------------------------------------------

Please note that neither Hollerith constants not the protocol pseudo-function %REF are supported by the Fortran standard. It is possible to create a standard-conforming sub-program which will copy a string to an INTEGER*1 array which may then be passed by reference. This will be implemented in a future version of FPT.


Error: No correction is attempted and an error is reported.


Correction of arguments is suppressed for all arguments, or for classes of arguments by the commands:

DO NOT CORRECT INCONSISTENT ARGUMENTS

DO NOT CORRECT INCONSISTENT NUMERIC ARGUMENTS

DO NOT CORRECT INCONSISTENT HOLLERITH ARGUMENTS

DO NOT CORRECT INCONSISTENT STRING ARGUMENTS


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


Default:

Inconsistent arguments are not corrected by default (Note that defaults may be changed in the configuration file).

Example:

The four calls to LABVAL in the program T all contain inconsistent arguments. The formal arguments expected are LAB, which is treated as an eight byte Hollerith, and VAL which is double precision. The actual arguments G and 100.0 are single precision reals, the numeric argument for height, 50, is INTEGER*4 and the argument 'Area    ' is CHARACTER*8.

SUBROUTINE LABVAL(LAB,VAL) DOUBLE PRECISION LAB,VAL WRITE(6,900)LAB,VAL 900 FORMAT(1X,A8,2X,E12.2) END PROGRAM T PARAMETER (G=32.2) CALL LABVAL(8HG ,G) CALL LABVAL(8HHeight ,100.0) CALL LABVAL(8HWidth ,50) CALL LABVAL('Area ',50.0D0*100.0D0) END

FPT corrects the code as shown below (The diagnostics marking the corrections have been suppressed):

PROGRAM T PARAMETER (G=32.2) CALL LABVAL(8HG ,DBLE(G)) CALL LABVAL(8HHeight ,100.0D0) CALL LABVAL(8HWidth ,50.0D0) CALL LABVAL(8HArea ,50.0D0*100.0D0) END

See also:

CORRECT INCONSISTENT ARGUMENTS TO ...


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