The IMPLICIT
statement changes the implicit typing rules of the Fortran compiler. Not a great favourite of structured programming weenies. There are 2 syntaxes:
IMPLICIT type (letters)
,
- where
letters
is a sequence of single letters (A
) or single letter ranges (I-N
), separated by commas. This implicitly assigns the given type to all variables beginning with those letters (unless explicitly given some other type).
IMPLICIT NONE
or IMPLICIT UNDEFINED
-
- Clears all
IMPLICIT
statements.
You can also string together different
IMPLICIT
specifiers in the same statement, by separating them with
commas.
The implicit IMPLICIT
setting (for Fortran 77) is not "IMPLICIT NONE
". If you want Ada, you know where to find it. Instead, it's "IMPLICIT INTEGER (I - N)
" (though note that the language is case insensitive, so it could equally well be "IMPLICIT INTEGER (i - N)
"). To remember this, either remember that the letters i,j,k,l,m,n are commonly used in mathematics for integers, or that the word INteger starts with these bounds. Thus, undeclared variables A, beta, inertia, mass, NUMBER, telescopes_ordered
are, respectively, 2 REALs, 3 INTEGERs, and another REAL.
You can also use IMPLICIT
for type-like settings, specifically to select implicitly STATIC
or AUTOMATIC
variables beginning with those letters.
IMPLICIT
is a truly horrible language feature. Used with care, it will immediately lead to unreadable code. Used without care, the results are far worse. Unused, it will still lead to unreadable code, because of the implicit IMPLICIT
. If IMPLICIT NONE
is used, the results are still awful, because of the cargo cult programming practice that new programmers will associate with its perceived necessity in all codes.