fpt and WinFPT Reference Manual - Command-line Commands
| SimCon Home | Ref Manual Home |
CORRECT MISSING ARGUMENTS
[DO NOT] CORRECT MISSING ARGUMENTS
fpt checks that the actual arguments passed in a subroutine or function call match the formal arguments specified in the subroutine or function definition. Arguments missing from the call are inserted.
The way in which the missing arguments are supplied is controlled separately for numeric and for character arguments, by the commands:
MISSING NUMERIC ARGUMENTS TO BE MARKED BY COMMAS
MISSING NUMERIC ARGUMENTS TO BE REPLACED BY %VAL(0)
MISSING NUMERIC ARGUMENTS TO BE REPLACED BY SYMBOLS
MISSING STRING ARGUMENTS TO BE MARKED BY COMMAS
MISSING STRING ARGUMENTS TO BE REPLACED BY %VAL(0)
MISSING STRING ARGUMENTS TO BE REPLACED BY SYMBOLS
MISSING STRING ARGUMENTS TO BE REPLACED BY SYMBOLS OF LENGTH: <integer>
DEFAULT LENGTH OF MISSING STRING ARGUMENTS: <integer>
Note that the use of commas and of the construct %VAL(0) are not standard-conforming. However they are accepted by ifort which is a common migration target for VMS.
These commands are most often used when code is migrated from systems such as VMS to Unix or Windows. Unix and Windows Fortran compilers usually pass sub-program argument addresses on the system stack. The called routine un-stacks the addresses. If the number of arguments in the call does not match the number required by the sub-program, a stack violation may occur.
Character arguments are handled as a special case because the string length is usually also placed on the stack when the routine is called, and un-stacked during sub-program execution.
%VAL(0) is used by some systems as a null pointer, to indicate an unused argument.
The changes made by fpt are best shown by example. If a subroutine code begins:
SUBROUTINE PRINTMAX(I1,I2,I3,I4) INTEGER I1,I2,I3,I4
and is invoked
fpt modifies the call site, according to the settings:
% MISSING NUMERIC ARGUMENTS TO BE MARKED BY COMMAS
% MISSING NUMERIC ARGUMENTS TO BE REPLACED BY %VAL(0)
% MISSING NUMERIC ARGUMENTS TO BE REPLACED BY SYMBOLS
INTEGER*4 I3_ARG INTEGER*4 I4_ARG : CALL PRINTMAX(KAPPA,LAMBDA,I3_ARG,I4_ARG)
Similarly, if a subroutine is written:
SUBROUTINE AXLABEL(C1,C2,C3,C4) CHARACTER*16 C1,C2,C4 CHARACTER*(*) C3
the call site is modified:
% DEFAULT SIZE FOR MISSING STRING ARGUMENTS: 32 % MISSING STRING ARGUMENTS TO BE REPLACED BY SYMBOLS
CHARACTER*32 C3_ARG CHARACTER*16 C4_ARG : CALL AXLABEL('Depth','ft',C3_ARG,C4_ARG)
Note that the CHARACTER*(*) argument receives the default string argument size. A local variable may not be declared with a variable size.
% MISSING STRING ARGUMENTS TO BE REPLACED BY SYMBOLS OF LENGTH: 0
or, for IBM AIX systems,
% MISSING STRING ARGUMENTS TO BE REPLACED BY SYMBOLS OF LENGTH: 65536
The generated code is:
INCLUDE 'fpt_missing_string_argument.fpi' : CALL AXLABEL('Depth','ft',FPT_MISSING_STRING_ARGUMENT, % FPT_MISSING_STRING_ARGUMENT)
The INCLUDE file contains:
CHARACTER*0 FPT_MISSING_STRING_ARGUMENT COMMON /FPT_MISSING_STRING_COMMON/FPT_MISSING_STRING_ARGUMENT
CHARACTER*65536 FPT_MISSING_STRING_ARGUMENT COMMON /FPT_MISSING_STRING_COMMON/FPT_MISSING_STRING_ARGUMENT
Usually, the missing string arguments are specified with a length of zero, which is recognised by Compaq Visual Fortran, and most Unix systems as a null string. The length of 65536 is used for IBM AIX systems because CHARACTER*0 does not compile under AIX, but the AIX compiler treats a length of 65536 as if it were zero. A single variable in COMMON is used to save memory.
Note that the INCLUDE file fpt_missing_string_argument.fpi is overwritten if it already exists, and the size of FPT_MISSING_STRING_ARGUMENT is changed to the current setting.
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|
No correction is made by default (Note that defaults may be changed in the configuration file).
Copyright ©1995 to 2019 Software Validation Ltd. All rights reserved.