NAGWare Fortran Tools - f95 Tools - nag_mkintf95

 

Index

NAME
DESCRIPTION
OPTIONS
MISSING PROCEDURES
NOTES
SEE ALSO

 

NAME

nag_mkintf95 - Interface block builder

 

DESCRIPTION

This tool generates Fortran interface blocks to define the interface to external procedures. Wherever an external procedure is referenced the appropriate interface block is made visible. This allows a compiler to perform better checking of argument passage, especially if the program is made up of several files. nag_mkintf95, in the process of building interface blocks, carries out global argument passage checking (except procedure parameters) over multiple files. The interface blocks generated by nag_mkintf95 provide information to a Fortran compiler which enable it to carry out the checking of procedure parameters when the code is subsequently compiled.

By default the interface blocks are placed in a module and then appropriate USE statements placed in each scope to make the interface blocks visible. Alternatively the -inline option can be used to place interface blocks inline in the source code wherever they are needed.

The tool works best with a complete program unit, but if it is not possible to supply the source for all external procedures (e.g. if pre-compiled libraries are being used or externals are written in another language) the tool by default will build interface blocks based on the actual arguments passed in calls to the missing external procedure (see ``BUILDING INTERFACES FOR MISSING EXTERNAL PROCEDURES'' below).

If a filename with no extension is provided the tool will look for a file with the extension `.f95', and if that does not exist, for a file with the extension `.f90'.

If a file has the extension `.f90' or `.f95', it will be assumed to contain free format Fortran code. If a file has the extension `.f', `.for', `.f77', or `.ftn', the file is assumed to contain fixed format Fortran code. The options -fixed and -free may be used to override this behaviour.

The input file is backed up to infile.original and the output file replaces the input file.

Modules (and include files) are expected to exist in the current working directory or in a directory named by the -I option, see nag_modules95.

 

OPTIONS


   Main Options
"Inline interface blocks" (-inline)
Normally the interface blocks are generated in a module in a separate file, see -modfile, and appropriate USE statements inserted in the code. This option places the interface blocks ``inline'' in the source code as they are needed. -nodummy is turned on by this option.

"Interface block MODULE name" (-modname module_name)
This option allows you to specify the name to be used for the module which holds the interface blocks. The default name is ``nag_mkintf95_mod''.

"Interface block MODULE file name" (-modfile filename)
By default, if -inline is not specified, the module file is infile_ib.f90 where infile is the first source file name supplied, or infile_ib.f95 if the first source file has the suffix `.f95'. This file is written to the directory specified by the -odir option, or in the current directory.

"Analyse procedure calls" (-nocallanalysis)
This option stops the tool from generating any interface blocks based on analysis of calls made to external procedures which were not supplied or dummy procedures. This option has the same effect as setting -nodummy and -nocallproc and it also disables the -array option.
  

More Advanced Options

"Do not build interface for missing procedures from call" (-nocallproc)
By default, if an external procedure is called which has not been supplied in the source file(s), the tool will build an interface based on the arguments passed in the calls to this procedure. This option disables this behaviour (see ``BUILDING INTERFACES FOR MISSING EXTERNAL PROCEDURES'').

"Do not build interface for procedure arguments from call" (-nodummy)
By default, if an external procedure has a dummy procedure argument, the tool will build an interface block to define the arguments of the dummy procedure based on calls made to the dummy procedure from within the external procedure. This option disables this behaviour (see ``BUILDING INTERFACES FOR DUMMY PROCEDURES'').

"Assume array element dummy arguments passed as arrays" (-array)
If a reference to an array element is used as an actual argument in a call to a dummy procedure or external procedure which has not been supplied, the corresponding dummy argument may be an array or a scalar, e.g.

  REAL a(5)
  .
  .
  CALL sub_1(a(3))

sub_1's dummy argument may be a scalar of type REAL or an array of type REAL.

Because of this ambiguity the tool by default will not generate an interface block in this situation and a warning will be generated. This option causes the tool to assume that the dummy argument is an array and so enable interface block generation. This may be an incorrect assumption (a warning is generated).

  

General Options

"Source format" (-fixed, -free)
Forces the tool to assume fixed or free format for the input file. If "Automatic" is set, .f90 files will be assumed to contain free format code , .f, .for, .f77, or .ftn are assumed to contain fixed format code.

"Include and module directories" (-I)
Add pathname to the list of directories which are to be searched for include files. The current working directory is always searched first, then any directories named in -I options.

"Fixed format source line length" (-132)
Increase the length of each fixed source form input line from 72 characters to 132 characters. This has no effect on free source form input.

"Allow double complex specific intrinsics" (-dcfuns)
Enable recognition of non-standard double precision complex intrinsic functions. These act as specific versions of the standard generic intrinsics as follows:

    Non-standard      Equivalent Fortran 95 Intrinsic
     CDABS(A)            ABS(A)
     DCMPLX(X,Y)         CMPLX(X,Y,KIND=KIND(0d0))
     DCONJG(Z)           CONJG(Z)
     DIMAG(Z)            AIMAG(Z)
     DREAL(Z)            REAL(Z) or DBLE(Z)

"Downgrade legacy code errors to warning" (-dusty)
Allows the analysis of ``legacy'' software by downgrading the category of common errors found in such software from ``Error'' to ``Warning'' (which may then be suppressed entirely with the -w option).

"Suppress information messages" (-info)
Suppress output of tool analysis stages information messages.

"Kind numbers"
"Byte kinds" (-kind=byte)
Alter the kind numbering system used so that the kind numbers for INTEGER, REAL and LOGICAL match the number of bytes of storage (e.g. default REAL is 4 and DOUBLE PRECISION is 8). Note that COMPLEX kind numbers are the same as its REAL components, and thus half of the total byte length in the entity.

"Sequential kinds" (-kind=sequential)
This confirms the default kind numbering system where all datatypes are numbered sequentially from 1 and increase with precision.

This option does not affect the interpretation of byte-length specifiers (an extension to Fortran 77).

"Downgrade argument checks between routines in different files" (-mismatch)
Downgrade consistency checking of procedure argument lists so that mismatches produce warning messages instead of error messages. This only affects calls to a routine which is not in the current file; calls to a routine in the file being compiled must still be correct.

"Downgrade argument checks between routines in the same file" (-mismatch_all)
Further downgrade consistency checking of procedure argument lists so that calls to routines in the same file which are incorrect will produce warnings instead of error messages.

"Continuation line limit" (-maxcontin)
Increase the limit on the number of continuation lines to N. The default, as specified by the Fortran standard, is 19 for fixed source form and 39 for free source form. This will not decrease the limit below the standard number.

"Output strict Fortran 95 obsolescent messages" (-strict95)
Produce obsolescence warning messages for use of ``CHARACTER*'' syntax. This message is not produced by default since most programs contain this syntax.

"Suppress warning messages" (-w=all)
Switch on or off tool analysis stages warning messages.

"Suppress obsolescent feature warning messages" (-w=obs)
Switch on or off warning messages about the use of obsolescent features.

"Suppress unused entity warning messages" (-w=unused)
Suppresses warning messages about unused entities. It is equivalent to -w=uda -w=uei -w=ulv -w=usy.

"Suppress unused dummy argument warning messages" (-w=uda)
Switch on or off warning messages about unused dummy arguments.

"Suppress unused explicit import warning messages" (-w=uei)
Switch on or off warning messages about unused explicit imports.

"Suppress unused local variable warning messages" (-w=ulv)
Switch on or off warning messages about unused local variables.

"Suppress unused symbol warning messages" (-w=usy)
Switch on or off warning messages about unused symbols.

"Suppress Fortran 77 extension warning messages" (-w=x77)
Switch on or off extension warnings for common extensions to FORTRAN 77. These are TAB format, byte-length specifiers and Hollerith constants.

"Suppress Fortran 95 extension warning messages" (-w=x95)
Switch on or off extension warnings for extensions to Fortran 95.

 

MISSING PROCEDURES

BUILDING INTERFACES FOR MISSING EXTERNAL PROCEDURES

The tool works best with complete programs, however if there are missing procedures the tool, by default, will still try to generate the best interface blocks possible for the missing ones. In certain circumstances the interface blocks inferred by the tool for the missing procedure may be subject to certain limitations. These are discussed in the following sections.

If the source for an external procedure is not supplied, and an explicit interface cannot be found, by default an interface block will still be built if enough information regarding the argument structure can be inferred from calls to the external procedure.

The user should be aware that if a call to an external procedure which has not been supplied is incorrect, obviously the interface block built will be incorrect (though the tool will check that calls are consistent). There are also some cases where there is not enough information available to fully ascertain the nature of a dummy argument (detailed in ``IMPRECISE SPECIFICATION OF DUMMY ARGUMENTS''). In these situations the tool will generate the best possible.

The tool will always issue a warning if it infers an interface for a missing external procedure. The -nocallproc flag can be used to stop the tool building interfaces for missing external procedures.

In the following example the tool will generate an interface block for sub_2, where sub_2 is missing, by evaluating the overall type of each expression passed as an argument:

PROGRAM main
  EXTERNAL sub_2
  INTEGER :: a = 2
  REAL :: b = 3.4
  .
  .
  CALL sub_2(6,a*b)
  .
END

The first argument of sub_2 will be declared as a default-kind integer and the second argument as a default-kind real.

If however a missing external procedure is only passed as an argument in the source code and not called directly:

  INTEGER, EXTERNAL :: f
  .
  .
  CALL sub_3(f)

the tool cannot currently generate an interface block for the missing external procedure (a warning is generated).

BUILDING INTERFACES FOR DUMMY PROCEDURES

If an external procedure has a dummy procedure argument but there is no interface block to define the dummy procedure's argument structure, the tool by default will build an interface block based on calls to the dummy procedure from within the external procedure.
    The user should be aware that if a call to a dummy procedure is incorrect, obviously the interface block built will be incorrect (though the tool will check that calls are consistent). There are also some cases where there is not enough information available to fully ascertain the nature of a dummy argument (detailed in ``IMPRECISE SPECIFICATION OF DUMMY ARGUMENTS''). In these situations the tool will generate the best possible.

The tool will always issue a warning if it infers an interface for a dummy procedure. The -nodummy flag can be used to stop the tool building interfaces for dummy procedures.

In the following example, the tool will generate an interface block to define the arguments of dummy procedure dumproc. This will be placed inline in procedure sub_4 as well as within the interface block generated for sub_4 in the interface block module:

SUBROUTINE sub_4(dumproc)
  EXTERNAL dumproc
  .
  .
  CALL dumproc(3)
  .
END SUBROUTINE sub_4

If however a dummy procedure is only passed as an argument and not called directly:

SUBROUTINE sub_5(dumproc)
  EXTERNAL dumproc
  .
  .
  CALL next(dumproc)
  .
END SUBROUTINE sub_5

the tool cannot currently generate an interface block for the dummy procedure (a warning is generated).

IMPRECISE SPECIFICATION OF DUMMY ARGUMENTS

If the tool is building an interface for a missing external procedure or dummy procedure based on a call, enough information will usually be available to the tool to generate an accurate interface (provided the arguments passed in the call are correct). The following situations are those where the tool has incomplete information. In these cases the tool will generate the best possible.

Array arguments

If an array is passed as an argument, e.g.

REAL,DIMENSION(20,20) :: a
CALL sub_6(a)

the expressions which define the dummy argument array bounds are not available. In this case the tool will generate an assumed-size array specification:

INTERFACE
  SUBROUTINE sub_6(sub_6_0)
    REAL :: sub_6_0(*)
  END SUBROUTINE sub_6
END INTERFACE

Also if a reference to an array element is used as an actual argument the corresponding dummy argument may be an array or a scalar, e.g.

REAL a(5)
CALL sub_7(a(3))

sub_7's dummy argument may be a scalar of type REAL or an array of type REAL. The tool will not generate an interface block for sub_7 and a warning is generated. The -array flag may be used to force the tool to assume it is an array.

Character string arguments

If an actual argument is a character string the tool will generate len=* for the corresponding dummy argument in the interface block.

Dummy procedure arguments

An interface block will not be generated for a dummy procedure argument. Note this is true even if the actual procedure passed as argument has an explicit interface in the current scope.

Kind numbers

The kind number expression of an actual argument is evaluated and the result used as the kind number for the corresponding dummy argument. The kind numbers generated follow the NAGWare f95 compiler kind numbering scheme in force when the tool is invoked, see -kind.

TOOL GENERATED DUMMY ARGUMENT NAMES

If the tool generates an interface block for a missing external procedure or dummy procedure, the tool uses the following naming scheme for the dummy arguments:

The argument names take the form <procedure_name>_<num> where num is the position of the argument in any call, e.g.

EXTERNAL sub_8
CALL sub_8(6,0.5)

yields:

INTERFACE
  SUBROUTINE sub_8(sub_8_0,sub_8_1)
    INTEGER :: sub_8_0
    REAL :: sub_8_1
  END SUBROUTINE sub_8
END INTERFACE

Note that a name clash can occur if, in the above example, an argument is of a user defined type named sub_8_0 (an unlikely occurrence).

 

NOTES

CHARACTER ARGUMENT LENGTH EXPRESSIONS

If a dummy argument of an external procedure is of type character and has a constant expression defining its length, the expression is evaluated and the result used in the interface block.

ASSUMED LENGTH CHARACTER FUNCTIONS

Assumed length character functions, e.g.

CHARACTER(len=*) FUNCTION f()
END FUNCTION f

will not have an interface block generated (if the function is not supplied in the source code it is assumed to be len=*).

WARNING

When a module containing all the interfaces is created, it is possible, but unlikely, that a cyclic dependency of USE statements might result. This could happen where a module procedure calls an external procedure with a derived type argument defined in that same module. Either the -inline option must be used or all the problematic derived types can be moved to a separate module or modules.

The nag_mkintf95 tool is being improved and some of the above restrictions will be removed in subsequent releases of the tool.

 

SEE ALSO

nag_polopt95, nag_modules95.

Copyright, Numerical Algorithms Group, Oxford, 1997-2001