|Fortran Language Reference Manual, Volume 1 - S-3692-51|
|Prev Section||Chapter 5. Declarations||Next Section|
Each variable, named constant, and function has a type and a name. If the type is not declared explicitly, it is assumed from the first letter of the name. This method of determining type is called implicit typing. In each scoping unit, there is in effect a mapping of each of the letters A, B, ..., Z (and corresponding lowercase letters) to one of the accessible types or to no type. IMPLICIT statements in a scoping unit can be used to specify a mapping different from the default mapping. If a new mapping for a letter is not specified in an IMPLICIT statement, the default mapping continues to apply for that letter.
An IMPLICIT NONE statement specifies that there is no mapping for any letter and thus all variables, named constants, and functions must be declared in type declaration statements. If the host of a scoping unit contains the IMPLICIT NONE statement and the scoping unit contains IMPLICIT statements for some letters, the other letters retain the null mapping. This is the only situation in which some initial letters specify an implied type and other initial letters require explicit declarations.
A program unit is treated as if it had a host with the mapping shown in Figure 5-1. That is, each undeclared variable or function whose name begins with any of the letters I, J, K, L, M, or N is of type integer and all others are of type real.
If IMPLICIT NONE appears, it must precede any PARAMETER statements and there must be no other IMPLICIT statements in the scoping unit.
If the - letter option appears in a letter specification, the second letter must follow the first alphabetically.
The same letter must not appear as a single letter or be included in a range of letters more than once in all of the IMPLICIT statements in a scoping unit.
Note: The Fortran standard does not include the IMPLICIT AUTOMATIC, IMPLICIT STATIC or IMPLICIT UNDEFINED syntax. IMPLICIT UNDEFINED is equivalent to IMPLICIT NONE. It is recommended that none of the IMPLICIT extensions be used in new code.
An IMPLICIT statement can be used to specify implicit mappings for user-defined types as well as for intrinsic types.
If IMPLICIT AUTOMATIC or IMPLICIT STATIC is specified, all non COMMON-block variables beginning with the indicated letters are assigned to automatic or static storage, respectively.
The IMPLICIT statement specifies that all variables, named constants, and functions beginning with the indicated letters are assigned the indicated data type (and type parameters) implicitly. For example, consider the following statement:
IMPLICIT COMPLEX (A-C, Z)
In this statement, all undeclared variables, named constants, and functions beginning with the letters A, B, C, and Z are of type default complex. If this is the only IMPLICIT statement, undeclared variables, named constants, and functions beginning with I through N will still be of type integer; undeclared variables, named constants, and functions beginning with D through H and O through Y will be of type real.
As another example, consider the following statement:
In this statement, there is no implicit typing in the scoping unit. Each variable and named constant local to the scoping unit, and each external function used in the scoping unit, must be declared explicitly in a type statement. This statement is useful for detecting inadvertent misspellings in a program because misspelled names become undeclared rather than implicitly declared.
The following examples show IMPLICIT statements:
IMPLICIT INTEGER (A-G), LOGICAL(KIND = WORD) (M) IMPLICIT CHARACTER*(10) (P, Q) IMPLICIT TYPE(COLOR) (X-Z)
The additional complexity that implicit typing causes in determining the scope of an undeclared variable in a nested scope is explained in the Fortran Language Reference Manual, Volume 2.