NAGWare Fortran Tools - f77 Tools - nag_pfort

 

Index

NAME
DESCRIPTION
OPTIONS
STAGE 1 - FORTRAN 77 ANALYSIS
STAGE 2 - PORTABILITY ANALYSIS
BASIC PFORT-77 DIFFERENCES FROM THE ANSI STANDARD
INTER PROGRAM-UNIT COMMUNICATIONS
UNSAFE REFERENCES
SEE ALSO
 

NAME

nag_pfort - NAGWare f77 Tools Portability Verifier

 

DESCRIPTION

nag_pfort is the NAGWare f77 Tools portability verifier. nag_pfort checks for The analysis is carried out in two stages. Firstly conformance to the NAGWare f77 Tools Fortran standard is checked (see nag_Fortran77). If this preliminary check is satisfied, nag_pfort proceeds to portability analysis in which the checks include additional Fortran 77 rules, conformance to PFORT-77, inter-program-unit communications, and unsafe references. The second stage issues a portability report based on the PFORT-77 subset.

 

OPTIONS

"Check for Fortran 90 obsolescent features" (-obs90)

This option checks for features listed as Obsolescent in Fortran 90:

These constructs are reported as errors.

Please note that five of the above constructs have been deleted in Fortran 95.

"Check for Fortran 95 obsolescent features" (-obs95)

This option checks for features listed as Obsolescent in the Fortran 95 standard:

These constructs are reported as errors.

The FORTRAN 95 standard also lists CHARACTER*length declarations as obsolescent. This construct is not checked by this option because the number of occurances in code could be very large. The NAGWare f95 Tools may be used to convert this construct.

"Check for Fortran 90/95 deprecated features" (-dep)

This option checks for a number of constructs that have been identified as being features of Fortran 77 that should be avoided in Fortran 90 or 95, although these are still retained in the language for backwards compatibility. These deprecated features are:

These constructs are reported as errors.

"Suppress errors for Fortran 90 extensions" (-port90)
Allows long names up to 31 characters, IMPLICIT NONE, INCLUDE and ENDDO. Also sets -nocswarn. Please note that this option suppresses some ANSI standard checking.

"No DOUBLE COMPLEX errors" (-nodcwarn)
All DOUBLE COMPLEX data type related messages are suppressed.

"No character set warnings" (-nocswarn)
All character set related messages are suppressed.

"No lower case character set warnings" (-nolcwarn)
All lower case character set related mesages are suppressed.

"Suppress information and warning messages" (-suppress level)
Suppress warnings to level, where level is in the range 0 to 3. level 0, the default when this option is not specified, causes all warning and information messages to be output.

NOTE: All the above options apply only to the second stage of analysis, the portability report. In particular, any errors or warnings generated by the first stage analysis will still be output to standard error.

 

STAGE 1 - FORTRAN 77 ANALYSIS

This stage is preliminary to the deeper analysis carried out in Stage 2. Each Fortran source file is individually checked rigorously against the NAGWare f77 Tools Fortran standard, see nag_Fortran77. The passage of arguments within each file is checked for correctness and consistency.

 

STAGE 2 - PORTABILITY ANALYSIS

Stage 1 analysis is carried out for each source file, only if there are no errors in the Stage 1 analyses, is the Stage 2 portability analysis carried out.

Fortran 77 rules checked by nag_pfort

The following rules which apply to standard-conforming Fortran 77 are checked.

  1. Variables referenced but not set. [ERROR]
  2. Function value not set. [ERROR]
Additionally, nag_pfort reports any occurrences of variables or dummy arguments which are not used in any way whatsoever, and local variables which are only set and never referenced. [WARNING]

nag_pfort makes a small number of further checks against the ANSI Fortran 77 standard that are not carried out in the preliminary analysis. Any contraventions of the standard are reported. [ERROR]

PFORT-77 Subset Language

PFORT-77 is a portable subset of Fortran 77 loosely based on PFORT-66 (Ryder B and Hall A, The PFORT Verifier, Computing Science Technical Report #12, Bell Laboratories.) All restrictions imposed by the Fortran 77 standard apply to PFORT-77, including the lack of Hollerith constants.

There are certain non-portable usages which are not considered by nag_pfort to be as serious as other non-portable usages. The less serious non-portable usages are flagged by nag_pfort as warnings, and are indicated in this document by "[WARNING]" or "[INFORMATION]". Other messages are errors, cannot be suppressed using the -suppress option and are indicated here by "[ERROR]".

In the following, checks which are actually performed at an earlier stage of processing than nag_pfort (e.g. in the lexing, parsing or static analysis phases) are indicated by ("[Stage 1 Analysis]"). Such errors and warnings are written to stderr even when the -listing option is specified.

 

BASIC PFORT-77 DIFFERENCES FROM THE ANSI STANDARD

COMMON blocks

1. A COMMON block may not appear in more than one BLOCK DATA subprogram (this prevents duplicate initialisation of COMMON blocks). [ERROR]

2. Within a COMMON block, COMPLEX and DOUBLE PRECISION entities must precede all other entities (to prevent improper word alignment on certain machines). [WARNING]

EQUIVALENCE statements

1. Equivalences between items of differing type may not equivalence non-initial elements of arrays. [WARNING]

2. A variable which is equivalenced to a different data type and is set, is flagged as [WARNING] if that variable is used elsewhere. If this illegal equivalenced variable is only set and not used then [ERROR] is reported.

Intrinsic functions and External references

1. Intrinsic functions must be declared as INTRINSIC if used as an actual argument [ERROR].

2. Only standard intrinsic functions may be used and they must not be explicitly typed. [ERROR]

3. All external references must be declared as EXTERNAL. [INFORMATION]

4. External functions must be explicitly typed. [WARNING]

Miscellaneous

1. A data-value must be exactly the same type as the corresponding data-item. A mismatch in a double precision data-item is reported as [ERROR] and in other data types as [WARNING].

2. A variable which is used in an array-declarator (as part of an adjustable dimension) must not have its type declared following the occurrence of the array-declarator. [ERROR]

3. A variable which is used in an array-declarator should not be updated by that routine. [WARNING]

4. Hollerith constants are non standard. [ERROR]

5. US Military Standard extensions are not part of ANSI standard Fortran 77, IMPLICIT NONE, END DO, INCLUDE and DO WHILE are flagged. [ERROR]

6. Use of the DOUBLE COMPLEX data type is flagged, although this check can be optionally suppressed. [ERROR]

Executable Statements

1. A DO loop must have an INTEGER control variable. [ERROR]

2. There is no PAUSE statement. [WARNING]

3. BACKSPACE and ENDFILE are flagged as non-portable. [WARNING]

4. An assigned GOTO should not have a label list attached. [INFORMATION]

5. If a label list is attached to an assigned GOTO then all possible targets should be in the label list. [WARNING]

6. A format-specifier must not be an integer, real or logical array (which is part of the Hollerith extension to the ANSI standard). [ERROR]

7. No TL or T edit descriptor. [ERROR]

PFORT-77 Restrictions

1. In a function subprogram the function name may not be used as the control variable of a DO loop. [ERROR]

2. A DO-loop control variable must not appear in the limit expressions for that DO loop. [ERROR]

3. Common block names, statement function names, ASSIGN variables, dummy arguments and statement function dummy arguments must all be distinct. [ERROR]

4. Only the standard character set excluding the currency symbol may be used in string constants. Thus the characters allowed are; upper case letters A to Z, numbers 0 to 9 and the special characters *()-=+':/.,. Use of lower case letters and the currency symbol is reported as [INFORMATION]. Other illegal characters are flagged as [WARNING].

5. No relationals apart from .EQ. and .NE. on strings (the intrinsic functions LLE etc. must be used instead). [ERROR]

6. Only standard i/o keywords may be used. [Stage 1 Analysis (warning message)].

7. A character string variable must have length at most 255. [WARNING] String variables longer than 32767 are reported as [ERROR]

8. A character constant must be at most 64 characters long. [WARNING]

 

INTER PROGRAM-UNIT COMMUNICATIONS

nag_pfort checks that all external functions and subroutines have been called correctly. That is that the correct number of arguments have been passed and that the arguments match in type and structure. This includes subprogram names which are passed as actual arguments to other subprograms.

Subprograms which have been referenced but whose data have not been supplied to nag_pfort have their references checked for consistency only.

Common blocks which are not mentioned in SAVE statements are checked to ensure that there is a program-unit (possibly the main program) which (1) contains the common block, and (2) is always active when any other program-unit which contains the common block is active. This prevents undefinition of the common block between references to two different subprograms which are using the common block for communication.

 

UNSAFE REFERENCES

An unsafe reference is the passing of an actual argument that in combination with the dummy arguments of a subprogram could cause different results depending on the mechanism used by the compiler to pass arguments. Unsafe references are therefore not portable and may lead to wrong results.

The principle of unsafe reference checks is described in detail in the PFORT-66 documentation. PFORT-77 checks for the following types of unsafe reference:

1. Constant or expression associated with a dummy argument which may be changed.

2. Actual argument associated with two dummy arguments, at least one of which is scalar, and either or both of which are changed.

3. Actual argument in a common block which is accessed either directly or indirectly by the called subprogram and either the dummy argument or the common block are modified.

4. An actual argument is a statement function dummy argument and the associated dummy argument may be changed.

5. An actual argument is an active DO-loop index and the associated dummy argument may be changed.

It should be noted that these unsafe references are only actually deviant if the value is in fact changed at execution time; this is of course not determinable by a static checker.

nag_pfort does not attempt to evaluate array indices - it treats the entire array as one item. This leads it to produce unsafe reference messages even if the value of an array subscript means that the reference could never actually be unsafe.

Due to this limitation of treating arrays as a single item, nag_pfort distinguishes between unsafe references using arrays and unsafe references not using arrays. Unsafe references involving arrays are flagged as "Unsafe" whereas those which do not involve arrays are flagged as "Error"; this makes it easier for the user to determine whether the program is likely to be in error or not.

 

SEE ALSO

nag_Fortran77.

Copyright, Numerical Algorithms Group, Oxford, 1991-2001