The IMPLICIT statement specifies a type and optionally a kind or a CHARACTER length for each variable or function name beginning with the letter(s) specified in the IMPLICIT statement. Alternately, it can specify that no implicit typing is to apply in the scoping unit.
implicit-specs is a comma-separated list of type-spec (letter-specs)
type-spec isINTEGER [kind-selector] REAL [kind-selector] DOUBLE PRECISION COMPLEX [kind-selector] CHARACTER [char-selector] LOGICAL [kind-selector] TYPE (type-name)
kind-selector is ( [KIND =] kind )
char-selector is ( [LEN=] length [, ) KIND=kind])or (KIND=kind [, LEN=length]) or * char-length [,]
type-name is the name of a user-defined type.
kind is a scalar INTEGER expression that can be evaluated at compile time.
length is a scalar INTEGER expression or *
char-length is a scalar INTEGER literal constant or (*)
letter-specs is a comma-separated list of letter[-letter]
letter is one of the letters A-Z.
Any data entity that is not explicitly declared by a type or function declaration statement, is not an intrinsic function, and is not made accessible by host or use association, is declared implicitly to be of the type (and type parameters, kind and length) mapped from the first letter of its name.
Implicit typing for a range of letters can be specified by separating the beginning letter in the range and the ending letter in the range by a hyphen character. This is equivalent to writing a list containing all of the letters in alphabetical order in the alphabetic sequence from the beginning letter through the ending letter.
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.
In the absence of an implicit statement, a program unit is treated as if it had a host with the declaration
implicit integer (i-n), real (a-h, o-z)
IMPLICIT NONE specifies that no implicit typing will occur, and all data entities that are local in scope or appear in a common block within the scoping unit must be declared in a type declaration statement.
If IMPLICIT NONE is specified in a scoping unit, it must precede any other specification statements that appear, and the scoping unit cannot contain any other IMPLICIT statements.
Example 1implicit type(vowel) (a,e,i,o,u) ! if a variable name does implicit character (c) ! not appear in a type implicit integer (j,k,m,n) ! declaration statement, implicit logical (l) ! the type is determined implicit real (b, d, f-h, p-t, v-z) ! by the first letter of type vowel ! the variable name, as character :: v ! indicated by these end type vowel ! implicit statements
Example 2implicit none ! requires explicit type declarations for ! each local variable integer :: ill il1=0 ! implicit none will allow the compiler to ! catch typos. this statement will generate ! a compiler error because the number one was ! used instead of letter "l" ill=O ! this typo will also be detected. the letter ! "O" was used instead of the number zero