HP Fortran Programmer's Guide (September 2007)
Controlling data storage
Disabling implicit typing
Chapter 3 99
Disabling implicit typing
By default, HP Fortran uses
implicit typing
to determine the type of a variable or function
that has not been declared with a type declaration statement. That is, the type of an
undeclared entity is determined by the first letter of its name: if the letter is in the range
I - N, the entity is of type integer; otherwise, it is of type real.
Although implicit typing is mandated by the Standard, its use can become a source of runtime
bugs because implicit typing allows the inadvertent use of undeclared variables or functions.
For the sake of illustration, consider a program that calls a nonintrinsic library function
named foo. Assume that:
• The default typing rules are in effect.
• foo returns an integer.
• The programmer has not declared the return type of foo and has assigned its return
value to a variable of type real.
Experience has shown that this is not an unlikely scenario and that it can produce unexpected
results.
The Standard provides the IMPLICIT NONE statement to override implicit typing. But the
IMPLICIT NONE statement is limited in scope to the program unit in which it appears. To
force explicit typing for all files specified on the command line, use the +implicit_none
option. This option disables implicit typing; that is, all variables, arrays, named constants,
function subprograms, ENTRY names, and statement functions (but not intrinsic functions)
must be explicitly declared.
Using this option is equivalent to specifying IMPLICIT NONE for each program unit in each file
specified on the f90 command line. However, the +implicit_none option does not override
any IMPLICIT statements in the source file. The HP Fortran Programmer's Reference
describes the implicit typing rules, the IMPLICIT NONE statement, and the +implicit_none
option.