C H A P T E R  5

FORTRAN 77 Compatibility: Migrating to Fortran 95

The Fortran 95 compiler, f95, will compile most legacy FORTRAN 77 programs, including programs utilizing non-standard extensions previously compiled by the f77 compiler.

f95 will accept many of these FORTRAN 77 features directly. Others require compiling in FORTRAN 77 compatibility mode (f95 -f77).

This chapter describes the FORTRAN 77 features accepted by f95, and lists those f77 features that are incompatible with f95. For details on any of the non-standard FORTRAN 77 extensions that were accepted by the f77 compiler, see the FORTRAN 77 Language Reference manual at http://docs.sun.com/source/806-3594/index.html.

See Chapter 4 for other extensions to the Fortran 95 language accepted by the f95 compiler.

f95 will compile standard-conforming FORTRAN 77 programs. To ensure continued portability, programs utilizing non-standard FORTRAN 77 features should migrate to standard-conforming Fortran 95. Compiling with the -ansi option will flag all non-standard usages in your program.


5.1 Compatible f77 Features

f95 accepts the following non-standard features of the FORTRAN 77 compiler, f77, either directly or when compiling in -f77 compatibility mode:

For details on the syntax and semantics of non-standard language extensions, see the FORTRAN 77 Language Reference at http://docs.sun.com/source/806-3594/index.html.


5.2 Incompatibility Issues

The following lists known incompatibilities that arise when compiling and testing legacy f77 programs with this release of f95. These are due to either missing comparable features in f95, or differences in behavior. These items are non-standard extensions to Fortran 77 supported in f77 but not in f95.


5.3 Linking With f77-Compiled Routines

Example: f95 main calls a routine from the FORTRAN 77 library.

demo% cat tdtime.f95
        REAL e, dtime, t(2)
        e = dtime( t )
        DO i = 1, 100000
           as = as + cos(sqrt(float(i)))
        END DO
        e = dtime( t )
        PRINT *, 'elapsed:', e, ', user:', t(1), ', sys:', t(2)
        END
demo% f95 tdtime.f95
demo% a.out
elapsed: 0.14 , user: 0.14 , sys: 0.0E+0
demo% 

See dtime(3F).

5.3.1 Fortran 95 Intrinsics

The Fortran 95 standard supports intrinsic functions that FORTRAN 77 did not have. The full set of Fortran 95 intrinsics, including non-standard intrinsics, appears in the Fortran Library Reference manual.

If you use any of the intrinsic names listed in the Fortran Library Reference as a function name in your program, you must add an EXTERNAL statement for f95 to use your routine rather than the intrinsic one.

The Fortran Library Reference also lists all the intrinsics recognized by earlier releases of the f77 compiler. The f95 compiler recognizes these names as intrinsics as well.

Compiling with -f77=intrinsics limits the compiler's recognition of intrinsic functions to just those that were known to the f77 compiler, ignoring the Fortran 95 intrinsics.


5.4 Additional Notes About Migrating to the f95 Compiler

#include "floatingpoint.h"