Compaq Fortran
User Manual for
Tru64 UNIX and
Linux Alpha Systems


Previous Contents Index


Appendix A
Compatibility: Compaq Fortran 77 and Compaq Fortran on Multiple Platforms

This appendix provides compatibility information for those porting Compaq Fortran 77 and Compaq Fortran applications from other Compaq systems and for those designing applications for portability to multiple platforms.

This appendix contains the following topics:

A.1 Compaq Fortran and Compaq Fortran 77 Compatibility on Various Platforms

Table A-1 summarizes the compatibility of Compaq Fortran for Compaq Tru64 UNIX and Linux Alpha systems with Compaq Fortran on OpenVMS Alpha Systems, Compaq Fortran 77 on other platforms (architecture/operating system pairs), and Compaq Visual Fortran for Windows systems.

Table A-1 Summary of Language Compatibility
  Compaq Fortran 77 (CF77) or Compaq Fortran (CF95) for ... Systems
Language Feature CF95 UNIX Alpha CF95 Linux Alpha CF77 UNIX Alpha CF95 Windows CF95 OpenVMS Alpha CF77 OpenVMS Alpha CF77 OpenVMS VAX
Linking against static and shared libraries X X X X X X X
Create code for shared libraries X X X X X X X
Recursive code support X X X X X X X
AUTOMATIC and STATIC statements X X X X X X X
STRUCTURE and RECORD declarations X X X X X X X
INTEGER*1, *2, *4 X X X X X X X
LOGICAL*1, *2, *4 X X X X X X X
INTEGER*8 and LOGICAL*8 X X X X 1 X X  
REAL*4, *8 X X X X X X X
REAL*16 2 X X X   X X X
COMPLEX*8, *16 X X X X X X X
COMPLEX*32 3 X X     X    
POINTER (CRAY-style) X X X X X X X
INCLUDE statements X X X X X X X
IMPLICIT NONE statements X X X X X X X
Data initialization in type declarations X X X X X X X
Automatic arrays X X X X X X  
VOLATILE statements X X X X X X X
NAMELIST-directed I/O X X X X X X X
31-character names including $ and _ X X X X X X X
Source listing with machine code X X X X X X X
Debug statements in source X X X X X X X
Bit constants to initialize data and use in arithmetic X X X X X X X
DO WHILE and END DO statements X X X X X X X
Built-in functions %LOC, %REF, %VAL X X X X X X X
SELECT CASE construct X X X X X X  
EXIT and CYCLE statements X X X X X X  
Variable FORMAT expressions (VFEs) X X X X X X X
! marks end-of-line comment X X X X X X X
Optional run-time bounds checking for arrays and substrings X X X X X X X
Binary (unformatted) I/O in IEEE big endian, IEEE little endian, VAX, IBM, and CRAY floating-point formats X X X X X X X
Fortran 95/90 standards checking X X   X X    
FORTRAN-77 standards checking     X X   X X
IEEE exception handling X X X X X X  
VAX floating data type in memory         X X X
IEEE floating data type in memory X X X X X X  
CDD/Repository DICTIONARY support           X X
KEYED access and INDEXED files         X X X
Parallel decomposition X 5   5 5 5 5 X
OpenMP parallel directives X            
Conditional compilation using IF...DEF constructs X X   X X    
Vector code support             X
Direct inlining of Basic Linear Algebra Subroutines (BLAS) 6 6 6 6 6 6 X
DATE_AND_TIME returns 4-digit year X X X X X X X
FORALL statement and construct X X   X X    
Automatic deallocation of ALLOCATABLE arrays X X   X X    
Dim argument to MAXLOC and MINLOC X X   X X    
PURE user-defined subprograms X X   X X    
ELEMENTAL user-defined subprograms X X   X X    
Pointer initialization (initial value) X X   X X    
The NULL intrinsic to nullify a pointer X X   X X    
Derived-type structure initialization X X   X X    
CPU_TIME intrinsic subroutine X X   X X    
Kind argument to CEILING and FLOOR intrinsics X X   X X    
Nested WHERE constructs, masked ELSEWHERE statement, and named WHERE constructs X X   X X    
Comments allowed in namelist input X X   X X    
Generic identifier in END INTERFACE statements X X   X X    
Minimal FORMAT edit descriptor field width X X   X X    
Detection of Obsolescent and/or Deleted features 7 X X   X X    


1Alpha systems only.
2For REAL*16 data, OpenVMS VAX systems use H_float format, and Alpha systems use IEEE style X_float format.
3For COMPLEX*32 data, Alpha systems use IEEE style X_float format for both REAL*16 parts.
5For parallel processing, you can also use the optional KAP performance preprocessor for a shared memory multiprocessor system.
6BLAS and other routines are available with the Compaq Extended Mathematical Library (CXML) product on Alpha systems.
7Compaq Fortran flags these deleted and obsolescent features, but fully supports them.

A.2 Compatibility with Compaq Fortran 77 for Compaq Tru64 UNIX Systems

This section provides compatibility information for those porting Compaq Fortran 77 applications from Compaq Tru64 UNIX systems. It discusses the following topics:

A.2.1 Major Language Features for Compatibility with Compaq Fortran 77 for Compaq Tru64 UNIX Systems

To simplify porting applications from Compaq Fortran 77 to Compaq Fortran on Tru64 UNIX systems, Compaq Fortran supports the following Compaq Fortran 77 extensions that are not part of the Fortran 95/90 standards:

In addition to language extensions, Compaq Fortran also supports the following Compaq Fortran 77 features:

For More Information:

On the Compaq Fortran language, see the Compaq Fortran Language Reference Manual.

A.2.2 Language Features Provided Only by Compaq Fortran 77 for Compaq Tru64 UNIX Systems

Compaq Fortran conforms to the Fortran 95/90 standard, which is a superset of the FORTRAN-77 standard. Compaq Fortran provides many but not all of the FORTRAN-77 extensions provided by Compaq Fortran 77.

The following list shows FORTRAN-77 extensions provided by Compaq Fortran 77 on Compaq Tru64 UNIX systems are not provided by Compaq Fortran. Where appropriate, this list indicates equivalent Compaq Fortran language features:

For More Information:

A.2.3 Improved Compaq Fortran Compiler Diagnostic Detection

The following language features are detected or interpreted differently by Compaq Fortran and Compaq Fortran 77:

For More Information:

A.2.4 Compiler Command-Line Differences

Compaq Fortran 77 ( f77 command) and Compaq Fortran ( f90 command) share most of the same command-line options. The following options are provided only by Compaq Fortran 77 (not by Compaq Fortran):

The following options are provided only by Compaq Fortran (not by Compaq Fortran 77):

The f77 command by default executes the Compaq Fortran 90 compiler and uses the various DECF90_ environment variables. To execute the Compaq Fortran 77 compiler, use the f77 command with the -old_f77 option. This option must be the first text on the command line after f77 .

A.3 Language Compatibility with Compaq Visual Fortran

The following language features found in Compaq Visual Fortran (and Microsoft Fortran Powerstation Version 4) are now supported by Compaq Fortran:

A.4 Compatibility with Compaq Fortran 77 and Compaq Fortran for OpenVMS Systems

This section provides compatibility information for those who:

If your primary concern is the design and development of Compaq Fortran applications for only Compaq Tru64 UNIX (or other U*X) systems, consider skipping this section.

This section discusses the following topics:

A.4.1 Language Features Specific to Compaq Fortran 77 and Compaq Fortran for OpenVMS Systems

Some extensions to the FORTRAN-77 standard provided by Compaq Fortran 77 and Compaq Fortran for OpenVMS Systems are specific to the OpenVMS operating system, VAX architecture, or certain products on OpenVMS systems. Such extensions are not included in Compaq Fortran 77 or Compaq Fortran on Compaq Tru64 UNIX or Linux Alpha Systems.

For information on language compatibility between Compaq Fortran and Compaq Fortran 77 without regard to operating system or architecture differences, see Section A.2.

Compaq Fortran 77 and Compaq Fortran products for OpenVMS systems include:

Unless otherwise noted, the following list describes the Compaq Fortran 77 extensions in Compaq Fortran 77 and/or Compaq Fortran for OpenVMS systems that are not supported by Compaq Fortran for Compaq Tru64 UNIX Systems:

The following language and VAX architecture features are associated only with Compaq Fortran 77 on OpenVMS VAX Systems (previously called VAX FORTRAN) and are not supported by Compaq Fortran for Compaq Tru64 UNIX and Compaq Fortran for Linux Alpha systems:

The following language and VAX architecture features are interpretation differences between Compaq Fortran and Compaq Fortran 77 on Alpha systems and Compaq Fortran 77 on OpenVMS VAX Systems (previously called VAX FORTRAN):

For More Information:

A.4.2 OpenVMS Data Porting Considerations

When porting data between systems running the Compaq Tru64 UNIX and Linux Alpha operating systems and systems running the OpenVMS operating system, the file formats and the floating-point representations may differ.

The file and record formats of Compaq Fortran 77 on Compaq Tru64 UNIX systems are compatible with Compaq Fortran on Compaq Tru64 UNIX and Linux Alpha systems; they share the same language run-time I/O environment (see Chapter 7).

OpenVMS Fortran1 files containing only character, integer, or logical data do not need field-by-field conversion, but the record types must match. The segmented record type is the same on OpenVMS Fortran systems and Compaq Fortran on Compaq Tru64 UNIX or Linux Alpha systems. Certain other record types, such as variable-length records, differ between OpenVMS systems and Compaq Fortran on Compaq Tru64 UNIX or Linux Alpha systems.

Table A-2 summarizes the OpenVMS Fortran record types and their equivalent record types in Compaq Fortran on Compaq Tru64 UNIX or Linux Alpha systems.

Table A-2 Equivalent Record Types for OpenVMS Fortran and Compaq Fortran on Compaq Tru64 UNIX or Linux Alpha Systems
OpenVMS Fortran Record Type Compaq Tru64 UNIX Fortran Record Type Comments
Fixed-length None Equivalent (must be copied correctly) if you use sequential access and you specify the -vms option when compiling the Compaq Fortran file. Otherwise, convert the file to a different record type.
Variable-length None Not equivalent. Convert the file to a different record type.
Segmented Segmented Equivalent (must be copied correctly). Segmented data files can contain formatted or unformatted data.
Stream None Not equivalent. Convert the file to a different record type.
Stream_CR Stream_CR Equivalent (must be copied correctly).
Stream_LF Stream_LF Equivalent (must be copied correctly).

A.4.2.1 Matching Record Types

To match record types, there are several options:

A.4.2.2 Copying Files

Equivalent record types must be copied carefully to preserve control information and record characteristics. For example:

To transfer (copy) the files, choose one of the following methods:

In addition to using the correct record type and carefully transferring the files, the data inside unformatted records may need to be converted. OpenVMS Fortran data files that contain VAX binary floating-point data must be converted before they can be accessed by a Compaq Fortran program. There are several methods:

If you need to convert unformatted floating-point data, keep in mind that Compaq Fortran 77 for OpenVMS VAX programs (VAX hardware) store the following:

In contrast, Compaq Fortran programs running on the Compaq Tru64 UNIX or Linux Alpha operating system on Alpha hardware store the following:

Compaq Fortran 77 and Compaq Fortran for OpenVMS Alpha programs store floating-point data in the format specified by the /FLOAT qualifier:

For information on Compaq Fortran data types, see Chapter 9.

For More Information:

A.4.3 Nonnative VAX Floating-Point Representations

This section provides information about VAX floating-point data formats. You can convert unformatted files from OpenVMS systems by using the methods described in Chapter 10.

On OpenVMS VAX systems, single-precision data (such as REAL*4) is stored in VAX F_float format and double-precision data (such as REAL*8) data can be stored in either VAX D_float or VAX G_float formats, depending on whether the /G_FLOATING qualifier was specified on the FORTRAN command line (see the DEC Fortran User Manual for OpenVMS VAX Systems).

On OpenVMS Alpha systems, you can specify the floating-point format in memory by using the /FLOAT qualifier (see the DEC Fortran User Manual for OpenVMS AXP Systems). Single-precision data on OpenVMS Alpha systems is stored in either VAX F_float or IEEE S_float formats; double-precision data can be stored in VAX D_float, VAX G_float, or IEEE T_float formats.

REAL*16 (extended precision) data is always stored in IEEE style X_float format on Alpha systems.

With VAX floating-point data types, the binary radix point is to the left of the most-significant bit.

A.4.3.1 VAX F_float REAL (KIND=4) or REAL*4

Intrinsic REAL (KIND=4) or REAL*4 F_float data occupies four contiguous bytes. Bits are labeled from the right, 0 through 31, as shown in Figure A-1.

Figure A-1 VAX F_float REAL (KIND=4) or REAL*4 Representation


VAX F_float REAL (KIND=4) or REAL*4 Representation

The form of REAL (KIND=4) or REAL*4 F_float data is sign magnitude, where:

When converting unformatted F_float data from an OpenVMS system, the approximate range is 0.293873588E--38 to 1.7014117E38. The precision is approximately one part in 2**23, typically seven decimal digits.

A.4.3.2 VAX G_float REAL (KIND=8) or REAL*8

Intrinsic REAL (KIND=8) or REAL*8 (same as DOUBLE PRECISION) G_float data occupies eight contiguous bytes. The bits are labeled from the right, 0 through 63, as shown in Figure A-2.

Figure A-2 VAX G_float REAL (KIND=8) or REAL*8 Representation


VAX G_float REAL (KIND=8) or REAL*8 Representation

The form of REAL (KIND=8) or REAL*8 G_float data is sign magnitude, where:

When converting unformatted G_float data from an OpenVMS system, the approximate range is 0.5562684646268004D--308 to 0.89884656743115785407D308. The precision of G_float data is approximately one part in 2**52, typically 15 decimal digits.

A.4.3.3 VAX D_float REAL (KIND=8) or REAL*8

Intrinsic REAL (KIND=8) or REAL*8 (same as DOUBLE PRECISION) D_float data occupies eight contiguous bytes. Bits are labeled from the right, 0 through 63, as shown in Figure A-3.

Figure A-3 VAX D_float REAL (KIND=8) or REAL*8 Representation


VAX D_float REAL (KIND=8) or REAL*8 Representation

The form of REAL (KIND=8) or REAL*8 D_float data is identical to an F_float real number, except for an additional 32 low-significance fraction bits. The exponent conventions and approximate range of values are the similar to those for F_float.

When converting unformatted D_float data from an OpenVMS system, the approximate range is 0.2938735877055719D--38 to 1.70141183460469229D38. The precision is approximately one part in 2**55, typically 16 decimal digits.

A.4.3.4 VAX F_float COMPLEX (KIND=4) or COMPLEX*8

Intrinsic COMPLEX (KIND=4) or COMPLEX*8 (single-precision COMPLEX) data in VAX F_float format occupies eight contiguous bytes containing a pair of REAL*4 values. The low-order four bytes contain REAL*4 data that represents the real part of the complex number. The high-order four bytes contain REAL (KIND=4) or REAL*4 data that represents the imaginary part of the complex number. Figure A-4 shows a COMPLEX*8 number in F_float format.

Figure A-4 VAX F_float COMPLEX (KIND=4) or COMPLEX*8 Representation


VAX F_float COMPLEX (KIND=4) or COMPLEX*8 Representation

The limits for REAL (KIND=4) or REAL*4 apply to the two separate real and imaginary parts of a COMPLEX (KIND=4) or COMPLEX*8 number. Like REAL (KIND=4) or REAL*4 numbers, the sign bit representation is 0 (zero) for positive numbers and 1 for negative numbers.

A.4.3.5 VAX G_float and D_float COMPLEX (KIND=8) or COMPLEX*16

Intrinsic COMPLEX (KIND=8) or COMPLEX*16 (same as DOUBLE COMPLEX) data occupies 16 contiguous bytes containing a pair of REAL*8 or REAL (KIND=8) values. COMPLEX (KIND=8) or COMPLEX*16 data from an OpenVMS system is in one of the following REAL*8 or REAL (KIND=8) formats:

The low-order eight bytes contain REAL (KIND=8) or REAL*8 data that represents the real part of the complex data. The high-order eight bytes contain REAL (KIND=8) or REAL*8 data that represents the imaginary part of the complex data, as shown in Figure A-5 (for G_float) and Figure A-6 (for D_float).

Figure A-5 VAX G_float COMPLEX (KIND=8) or COMPLEX*16 Representation


VAX G_float COMPLEX (KIND=8) or COMPLEX*16 Representation

Figure A-6 VAX D_float COMPLEX (KIND=8) or COMPLEX*16 Representation


VAX D_float COMPLEX (KIND=8) or COMPLEX*16 Representation

The limits for REAL (KIND=8) or REAL*8 apply to the two separate real and imaginary parts of a COMPLEX (KIND=8) or COMPLEX*16 number. Like REAL (KIND=8) or REAL*8 numbers, the sign bit representation is 0 (zero) for positive numbers and 1 for negative numbers.

A.4.3.6 VAX H_float Representation

The REAL (KIND=16) or REAL*16 VAX H_float data format is used only on OpenVMS VAX systems. On Alpha systems, REAL (KIND=16) extended precision data is always stored in Alpha X_float format.

With VAX floating-point data types, the binary radix point is to the left of the most-significant bit.

As shown in Figure A-7, REAL*16 H_float data is 16 contiguous bytes starting on an arbitrary byte boundary. The bits are labeled from the right, 0 through 127.

Figure A-7 VAX H_float REAL*16 Representation (VAX Systems)


VAX H_float REAL*16 Representation (VAX Systems)

The form of an H_float REAL*16 data is sign magnitude with bit 15 the sign bit, bits 14:0 an excess 16384 binary exponent, and bits 127:16 a normalized 113-bit fraction with the redundant most significant fraction bit not represented.

The value of H_float data is in the approximate range 0.84*10**--4932 through 0.59*10**4932. The precision of H_float data is approximately one part in 2**112 or typically 33 decimal digits.

For More Information:

Note

1 OpenVMS Fortran refers collectively to VAX FORTRAN, Compaq Fortran 77 for OpenVMS Alpha Systems, and Compaq Fortran 77 for OpenVMS VAX Systems

A.5 Calling Between Compaq Fortran 77 and Compaq Fortran

On Compaq Tru64 UNIX systems, you can call a Compaq Fortran 77 subprogram from Compaq Fortran or call a Compaq Fortran subprogram from Compaq Fortran 77 (with a few exceptions). A Compaq Fortran 77 procedure and a Compaq Fortran procedure can also perform I/O to the same unit number.

A.5.1 Argument Passing and Function Return Values

The recommended rules for passing arguments and function return values between Compaq Fortran 77 and Compaq Fortran procedures are as follows:

Example A-1 and Example A-2 show passing an array from a Compaq Fortran program to a Compaq Fortran 77 subroutine that prints its value.

Example A-1 shows the Compaq Fortran program (file array_to_f77.f90 ). It passes the same argument as a target and a pointer. In both cases, it is received by reference by the Compaq Fortran 77 subroutine as a target (regular) argument. The interface block in Example A-1 is not needed, but does allow data type checking.

Example A-1 Compaq Fortran Program Calling a Compaq Fortran 77 Subroutine

! Pass arrays to f77 routine. File: array_to_f77.f90 
 
! this interface block is not required, but must agree 
! with actual procedure. It can be used for type checking. 
 
interface                    ! Procedure interface block 
  subroutine meg(a) 
  integer :: a(3) 
  end subroutine 
end interface 
 
integer, target :: x(3) 
integer, pointer :: xp(:) 
 
x = (/ 1,2,3 /) 
xp => x                         
 
call meg(x)                  ! Call f77 subroutine twice. 
call meg(xp)                
end 

Example A-2 shows the Compaq Fortran 77 subprogram called by the Compaq Fortran program (file array_f77.f ).

Example A-2 Compaq Fortran 77 Subroutine Called by a Compaq Fortran Program

! Get array argument from F90. File: array_f77.f 
 
 subroutine meg(a) 
 integer a(3) 
 print *,a 
 end 

These files (shown in Example A-1 and Example A-2) might be compiled, linked, and run as follows:


% f77 -c array_f77.f
% f90 -o array_to_f77 array_to_f77.f90 array_f77.o
% array_to_f77
           1           2           3 
           1           2           3 

In Example A-1, because array a is not defined as a pointer in the interface block, the Compaq Fortran pointer variable xp is passed as target data by reference (address of the target data).

However, if the interface to the dummy argument had the POINTER attribute, the variable xp would be passed by descriptor. This descriptor would not work with the Compaq Fortran 77 program shown in Example A-2.

For More Information:

A.5.2 Using Data Items in Common Blocks

To make global data available across Compaq Fortran and Compaq Fortran 77 procedures, use common blocks.

Common blocks are supported by both Compaq Fortran 77 and Compaq Fortran, but modules are not supported by Compaq Fortran 77. Some suggestions about using common blocks follow:

A.5.3 I/O to the Same Unit Number

Compaq Fortran and Compaq Fortran 77 share the same run-time system, so you can perform I/O to the same unit number with Compaq Fortran and Compaq Fortran 77 procedures. For instance, a Compaq Fortran main program can open the file, a Compaq Fortran 77 function can issue READ or WRITE statements to the same unit, and the Compaq Fortran main program can close the file.

For More Information:


Previous Next Contents Index