fpt and WinFPT Reference Manual - Command-line Commands

| SimCon Home | Ref Manual Home |

MISSING ARGUMENTS

Syntax:

MISSING ARGUMENTS TO BE REPLACED BY %VAL(0)

MISSING ARGUMENTS TO BE REPLACED BY SYMBOLS

MISSING ARGUMENTS TO BE MARKED BY COMMAS

MISSING NUMERIC ARGUMENTS TO BE REPLACED BY %VAL(0)

MISSING NUMERIC ARGUMENTS TO BE REPLACED BY SYMBOLS

MISSING NUMERIC 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>

MISSING STRING ARGUMENTS TO BE MARKED BY COMMAS

Function:

The command CORRECT MISSING ARGUMENTS instructs fpt to insert missing arguments in sub-program calls. The commands described here control the way in which the insertion is made. They do not cause the arguments to be inserted.

The commands are used primarily in migration of code between platforms. VMS, MPX and some other systems allow unused trailing arguments to be missed out of a call. Most Unix and PC compilers do not. These systems pass the arguments on the system stack. The called routine always unstacks the expected number of arguments. If arguments are missed out, too many data are removed from the stack and a stack violation occurs. Usually the program crashes.

The implications of the different settings are as follows:

Fortran numeric and logical arguments are usually passed by reference - the calling routine passes an address to the routine called. The null pointer, %VAL(0), is usually (not always) recognised as an argument which is deliberately missed out. If the argument is an input argument, the system does not attempt to read from address 0. If the argument is an output argument, the system does not attempt to write to address 0.

Many compilers embed a null pointer ( %VAL(0) ) in a call frame when missing arguments are simply marked by empty commas.

If missing arguments are replaced by symbols, fpt creates new variables with names derived from the names of the formal arguments, and inserts these into the call sites. The variables are not initialised. The names generated are of the form <formal_name>_ARG. For example, if the formal argument is IE, the actual argument is named IE_ARG. Declarations of the new variables are inserted where they are needed.

String arguments are handled as a special case. In Unix and PC systems they are usually passed by reference, but an additional argument is passed on the system stack to indicate the string length. Therefore, on most systems, simply replacing string arguments with %VAL(0) or with commas causes too few data to be stacked, and a stack violation occurs when the sub-program is called. In these cases, the strings must be passed as symbols.

If MISSING STRING ARGUMENTS TO BE REPLACED BY SYMBOLS is specified, fpt declares a new variable for each missing string argument, with the same length as the formal argument. If the length of the formal argument is specified as CHARACTER*(*), fpt uses the default length specified by the command DEFAULT LENGTH OF MISSING STRING ARGUMENTS.

The lengths of all missing string arguments may be specified explicitly by the command MISSING STRING ARGUMENTS TO BE REPLACED BY SYMBOLS OF LENGTH: <integer>. Most systems allow a string variables to be declared with length zero, and recognise a string argument of length 0 as a null string which is neither read nor written to. Some, e.g. IBM AIX Fortran, do not accept declarations of the form CHARACTER*0, but (at least under AIX) the same result can be achieved by specifying a size outside the legal string size range, for example, CHARACTER*65536.

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

By default, missing numeric arguments are replaced by a null pointer written as %VAL(0) and missing string arguments are replaced by symbols of the same length as the formal arguments. The default length for missing string arguments when the formal argument is specified as CHARACTER*(*) is 256 characters.

Examples

The subroutine OPENFILE begins:

SUBROUTINE openfile(unit,fnam,header,reclength) INTEGER*4 unit,reclength CHARACTER*(*) fnam CHARACTER*256 header

The call site:

CALL openfile(4)

is modified by the commands:

% MISSING NUMERIC ARGUMENTS TO BE REPLACED BY %VAL(0) % MISSING STRING ARGUMENTS TO BE REPLACED BY SYMBOLS OF LENGTH 0 % CORRECT MISSING ARGUMENTS

to read:

CALL openfile(4,fnam_arg,header_arg,%VAL(0))

and the declarations inserted in the calling routine are:

CHARACTER*0 fnam_arg CHARACTER*0 header_arg

See Also

DEFAULT LENGTH OF MISSING STRING ARGUMENTS

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