fpt and WinFPT Reference Manual - Command-line Commands

| SimCon Home | Ref Manual Home |

ARGUMENT CORRECTION TO ALLOW MEMORY REMAPPING

Syntax:

ARGUMENT CORRECTION [NOT] TO ALLOW MEMORY REMAPPING ARGUMENT CORRECTION [NOT] TO EMULATE VMS

Function:

There are some situations where mis-matched sub-program arguments cannot cause errors, and where correction of the mis-matched arguments can cause problems. The most important are:

  1. Situations where the argument address is used but the argument is neither read nor written.
  2. Integer or logical arguments of different kinds or data sizes which are passed by value.
  3. Integer or logical variables or arrays where the data organisation is remapped across the call-site.

This command controls whether argument correction is carried out in these cases. Occurrences which are not corrected are marked by errors or warnings.

Arguments which are Neither Read nor Written

The following code determines the size of a COMMON block and only uses the addresses of the arguments.

REAL*8 t INTEGER*4 linkage_end COMMON /linkage/ t,position,attitude,cart_vel_acc,polar_vel_acc : COMMON /linkage/ linkage_end : : CALL common_size(isize,t,linkage_end) : END SUBROUTINE common_size(isize,istart,iend) INTEGER*1 isize,iend INTEGER*4 isize isize = 1+%loc(iend) - %loc(istart) END

If fpt were to correct the mis-matched arguments, the original arguments would be copied to temporary variables and the addresses returned by %loc would be invalid. This occurred in a VMS migration. The command ARGUMENT CORRECTION TO EMULATE VMS suppresses the correction.

Integer or Logical Variables Passed by Value

Under VMS and (at least) Compaq Visual Fortran and Intel ifort variables passed by value are passed in a sign-extended 8-byte object regardless of the original data size. For little-endian systems no error therefore occurs if there is a data size mis-match between the actual and formal arguments. In the following code, the 1-byte actual argument is passed with the correct value to the 8-byte formal argument.

PROGRAM t INTEGER*1 :: i1 = -1 CALL s(%VAL(i1)) END PROGRAM t SUBROUTINE s(i8) INTEGER*8 i8 WRITE(*,*)loc(i8) END SUBROUTINE s

Note that the protocol %VAL causes the argument to be passed by value. The Fortran argument attribute VALUE does not do this. It causes the argument to be passed by reference but enforces the behaviour of INTENT(IN).

Memory Re-mapped Within an Array

An actual argument may be passed as an array of bytes or 2-byte componsnts to a sub-program where the formal argument is a larger object. By default, the fpt command CORRECT ARGUMENTS would cause the first object passed to be copied to a temporary variable of the size of the formal argument. This behaviour is not usually intended and is suppressed by the command ARGUMENT CORRECTION TO EMULATE VMS. This behaviour is seen in the fragment:

PROGRAM t INTEGER*1 :: i1(8) = [0,1,0,1,0,1,0,1] CALL s(i1) END PROGRAM t SUBROUTINE s(i8) INTEGER*8 i8 WRITE(*,'(Z16)')i8 END SUBROUTINE s

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

ARGUMENT CORRECTION [NOT] TO EMULATE VMS

(Note that defaults may be changed in the configuration file)

See Also

CORRECT INCONSISTENT ARGUMENTS

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