Inconsistent Sub-program Arguments
| SimCon Home | fpt Reference Manual Home |
What are Inconsistent Arguments?
When a sub-program is called, the actual arguments passed to it should match the formal arguments in the sub-program definition in:
Usually an error occurs if any of these conditions are violated.
Do All Inconsistent Arguments Indicate Errors?
No. There are at least three situations where they do not:
For these reasons, the automatic correction of arguments described below should be used with caution.
Are Inconsistent Arguments Still Common?
The handling of sub-program arguments is one of the greatest achievements of the Fortran 90 standard. In the extended FORTRAN 77 of the 1980's and early 1990's we expected to see large numbers of inconsistent arguments in large programs. The practice of placing sub-programs in Fortran modules has eliminated a large proportion of these errors.
However, errors of this class still occur with a frequency which is a matter of concern.
Checking for Inconsistencies
The fpt command:
Checks the consistency of all sub-program arguments. Several filters may be applied to the check. Reporting of the following situations may optionally be suppressed.
Please see the command ARGUMENT CHECK TO ... for a more detailed description.
Note that fpt checks the actual arguments of each routine against the formal arguments in the routine code. It does not rely on INTERFACE blocks to make the check. INTERFACE blocks can sometimes cause a maintenance trap because, at present, Fortran compilers do not check the INTERFACE blocks against the sub-program codes.
The end of the argument check for WRFV3.6.1 is shown below:
Inconsistent arguments to sub-program wrf_write_field1 ------------------------------------------------------ Sub-program Declaration Statement: ---------------------------------- Line: 2231, File: ... st/UCAR_clean_build_WRFV3.6.1/WRFV3/frame/module_io.F SUBROUTINE wrf_write_field1(datahandle,datestr,varname,field,fieldtype, & comm,iocomm, & domaindesc,bdy_mask,memoryorder,stagger,dimnames, & domainstart,domainend, & memorystart,memoryend, & patchstart,patchend, & status) Inconsistent References: ------------------------ Line: 2221, File: ... st/UCAR_clean_build_WRFV3.6.1/WRFV3/frame/module_io.F CALL wrf_write_field1(datahandle,datestr,varname,field,fieldtype, & comm,iocomm, & domaindesc,bdy_mask,memoryorder,stagger,dimnames, & domainstart,domainend, & memorystart,memoryend, & patchstart,patchend, & status) Argument 4 Formal argument Actual argument ---------- --------------- --------------- Argument field field Protocol By reference By reference Usage Symbol Symbol Access Read Read/Write Data type INTEGER LOGICAL *** Data size *4 df *4 df Dimensions (*) (*) ------------------------------------------------------------------------------- !!! Argument Consistency Check !!! !!! Number of routines remaining with inconsistent arguments: 122 !!! Total number of occurrences (errors): 955 !!! Number of inconsistencies corrected (Notes): 0 -------------------------------------------------------------------------------
Correcting Arguments Automatically
Many classes of inconsistent arguments may be corrected automatically. The fpt command is:
CORRECT INCONSISTENT ARGUMENTS
fpt inserts intrinsic function calls, or copies data to temporary arrays of the required type and kind to make the changes.
Copyright ©1995 to 2024 Software Validation Ltd. All rights reserved.