HP Fortran Programmer Guide (766160-001, March 2014)

3 Controlling data storage
This chapter describes the use of command-line options, directives, and other language features
to control data in HP Fortran programs. In particular, it discusses the following topics:
Disabling implicit typing
Automatic and static variables
Increasing the precision of constants
Sharing data among programs
Modules vs. common blocks
NOTE: For information about how HP Fortran aligns data, see HP Fortran Programmer's Reference.
Disabling implicit typing
By default, HP Fortran uses implicit typingto 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 rangeI - 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.
fooreturns an integer.
The programmer has not declared the return type offoo 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 NONEstatement to override implicit typing. But the IMPLICIT
NONEstatement 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_noneoption. 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 specifyingIMPLICIT NONE for each program unit in each file
specified on the f90command line. However, the +implicit_noneoption does not override any
IMPLICITstatements in the source file. The HP Fortran Programmer's Reference describes the
implicit typing rules, the IMPLICIT NONE statement, and the +implicit_noneoption.
Automatic and static variables
By default, HP Fortran allocates stack storage for program variables. Such variables are called
automatic variables because they are allocated at each invocation of the program unit in which
they are declared.
Static variables are allocated storage from static memory when the program is first loaded into
memory.
They remain allocated for the life of the program.
Disabling implicit typing 67