11 Porting to HP Fortran

The goal of portability is to make it possible to compile and execute a program on different vendors’ platforms, regardless of the platform on which it was written. A portable Fortran 90 program contains no language elements except those mandated by the Standard and adheres to generally accepted coding practices.

In practice, however, programming is rarely so simple. Many Fortran programs have a long history and were originally coded at a time when portability was not a concern because many programs were written to execute on one platform only. Older Fortran programs—so-called dusty-deck programs—are likely to have passed through different dialects of Fortran, picking up features from each, even after those features have become outmoded. Porting such a program may sometimes be as simple as identifying and removing the nonportable features. But more often than not, it involves finding ways to implement the functionality of the nonportable features.

To make the task of porting easier, HP Fortran includes the following features:

Language extensions—statements, data types, directives, and intrinsic functions—that are compatible with other Fortran implementations.

Compile-line options to help with the porting process.

This chapter includes the following sections:

Compatibility extensions

Using porting options

NOTE: For information about migrating HP FORTRAN 77™ programs to HP Fortran, see “Migrating to HP Fortran” (page 131).

Compatibility extensions

HP Fortran includes a variety of extensions to the Fortran 90 language. Most of these are compatibility extensions—statements, intrinsic routines, and compiler directives that are specific to nonstandard implementations of Fortran 90. For example, if you are porting a program that contains the ACCEPTstatement, you do not have to edit the part of the program that contains this nonstandard statement because it is one of the compatibility extensions of HP Fortran.

The following sections describe the compatibility extensions. For a list of all HP Fortran language extensions, see the HP Fortran Programmer’s Reference.

Except for the ON statement (see “Using the ON statement” (page 81)), all of the nonstandard statements supported by HP Fortran are provided for compatibility. These are listed by vendor in Table 11-1. Check the description of each statement in the HP Fortran Programmer’s Referenceto confirm compatibility.

Table 42 Compatibility statements

Statement

Implementation

Description

 

 

 

ACCEPT

DEC

Reads from standard input.

 

 

 

AUTOMATIC

Sun

Allocates storage on the stack.

 

 

 

BYTE

DEC

Declares entities of type integer.

 

 

 

DECODE

Earlier versions of Fortran

Inputs formatted data from internal storage.

 

 

 

DOUBLE COMPLEX

Earlier versions of Fortran

Declares entities of type double complex.

 

 

 

ENCODE

Earlier versions of Fortran

Outputs formatted data to internal storage.

 

 

 

END (structure definition)

DEC

Terminates the definition of a structure or union.

 

 

 

Compatibility extensions 141