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

Approaches to migration
The most direct (and painstaking) approach to migrating an HP FORTRAN 77™program so that
it will compile and execute correctly under HP Fortran is to make a clean sweep through the original
source code, removing all extensions and rewriting all nonstandard programming practices to
conform to the Fortran 90 standard. The result will be a highly portable program.
The disadvantage of the “clean-sweep” approach is that it may require a considerable expense
of time and work that may not even be necessary. Many HP FORTRAN 77 extensions are also
supported under HP Fortran. The only changes that you must make to the source are to remove or
re-code the parts of the program that use unsupported or incompatible language extensions.
Although the task of migrating an HP FORTRAN 77™program to HP Fortran can be done manually,
there are several utilities that can help to automate the search for incompatibilities. These utilities
(including sources of information about migrating to Fortran 90) are described in the following
sections.
HP-supplied migration tools
The HP migration tools include the HP FORTRAN 77 and HP Fortran compilers (f77 and f90),
lintfor, and fid.
HP FORTRAN 77 compiler
You can use the f77 command to test source code for conformance to the FORTRAN 77 standard.
The -A option causes the compiler to issue warnings when it encounters non-ANSI code.
If you use f77 for this purpose, the source code must conform to the FORTRAN 77 grammar. In
other words, f77 will flag both HP-specific extensions as well as language features that are unique
to Fortran 90. If the source code contains any Fortran 90 features (some of which are allowed in
HP FORTRAN 77 but not in standard FORTRAN 77) or if you introduce any Fortran 90 features
during the migration process, the f77 command is no longer useful.
HP Fortran compiler
Thef90 command can be used similarly to the f77 command to detect incompatibilities in HP
FORTRAN 77™ source files. The advantage of f90 over f77is that you can use it on code that
already contains Fortran 90 features or to which you are incrementally adding such features as
part of the migration process.
The main drawback of f90 as a migration tool is that a clean compilation under f90 does not
guarantee that all incompatibilities have been found; some do not manifest themselves until runtime.
Also, linking under f90withf77-generated object files may yield unexpected behavior or incorrect
results; see “Object code issues” (page 138)and “Data file issues” (page 138).
In addition, the f90command sometimes reports incompatibilities — especially in syntax—one at
a time. Needless to say, fixing incompatibilities one at a time and recompiling after each fix may
not be the most cost-effective approach to migrating a large FORTRAN 77™ program to HP Fortran.
Lintfor
The lintfortool can be used on HP FORTRAN 77™ code to detect semantic assumptions that
may not be valid for HP Fortran code. However,lintfor does not accept the Fortran 90 grammar
and therefore has the same drawbacks as the f77 command.
Fortran incompatibilities detector
The Fortran Incompatibilities Detector (fid) is an HP-supplied tool that was developed specifically
to help in migrating HP FORTRAN 77 code to HP Fortran. It is located in:
/opt/fortran90/contrib/bin/fid
Approaches to migration 139