Compaq Fortran
User Manual for
Tru64 UNIX
and Linux Alpha Systems
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:
- Major language features for compatibility with Compaq Fortran 77
for Compaq Tru64 UNIX systems ( Section A.2.1)
- Language differences between Compaq Fortran and Compaq Fortran 77,
including Compaq Fortran 77 extensions on Compaq Tru64 UNIX Systems
that are not supported by this version of Compaq Fortran on Compaq
Tru64 UNIX Systems ( Section A.2.2)
- Language features detected during compilation differently by Compaq
Fortran than Compaq Fortran 77 for Compaq Tru64 UNIX Systems
( Section A.2.3)
A.2.1 Major Language Features for Compatibility with Compaq Fortran 77 for Compaq Tru64 UNIX Systems
On Compaq Tru64 UNIX systems, to simplify porting applications from
Compaq Fortran 77 to Compaq Fortran, Compaq Fortran Version 5.3
supports the following Compaq Fortran 77 extensions that are not part
of the Fortran 95/90 standards:
- Record structures (STRUCTURE and RECORD statements)
- I/O statements, including PRINT, ACCEPT, TYPE, DELETE, and UNLOCK
- I/O statement specifiers, such as the INQUIRE statement specifiers
CARRIAGECONTROL, CONVERT, ORGANIZATION, and RECORDTYPE
- Certain data types, including 8-byte INTEGER and LOGICAL variables
and 16-byte REAL variables (available on Alpha systems)
- Size specifiers for data declaration statements, such as INTEGER*4,
in addition to the KIND type parameter
- IEEE floating-point data type in memory
- The POINTER statement and its associated data type (CRAY pointers).
- The typeless PARAMETER statement
- The VOLATILE statement
- The AUTOMATIC and STATIC statements
- Built-in functions used in argument lists, such as %VAL and %LOC
- Hollerith constants
- Variable-format expressions (VFEs)
- Certain intrinsic functions
- The tab source form (resembles fixed-source form)
- I/O formatting descriptors
- USEROPEN routines for user-defined open routines
- Additional language features, including the DEFINE FILE, ENCODE,
DECODE, and VIRTUAL statements
In addition to language extensions, Compaq Fortran Version 5.3 also
supports the following Compaq Fortran 77 features:
- Compaq Fortran 77 compilation control statements and directives
(see the Compaq Fortran Language Reference Manual), including:
- INCLUDE statement forms using /LIST and /NOLIST (requires compiling
with
-vms
)
- OPTIONS statement to override or set compiler command-line options
- General cDEC$ directives, including:
cDEC$ ALIAS
cDEC$ IDENT
cDEC$ OPTIONS
cDEC$ PSECT
cDEC$ TITLE
cDEC$ SUBTITLE
- A nearly identical set of command-line options and their associated
features (see Section A.2.4).
- The ability to call between Compaq Fortran 77 and Compaq Fortran
routines and a common run-time environment. For example, a Compaq
Fortran 77 procedure and a Compaq Fortran procedure can perform I/O to
the same unit number (see Section 11.3).
-
foriosdef.for
symbolic parameter definitions for use with run-time (IOSTAT) error
handling (see Chapter 8).
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
This section lists Compaq Fortran 77 extensions to the FORTRAN-77
standard that are not included in Compaq Fortran Version 5.3 for Compaq
Tru64 UNIX Systems. Where appropriate, this list indicates equivalent
Compaq Fortran language features.
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 FORTRAN-77 extensions provided by Compaq Fortran 77 on
Compaq Tru64 UNIX systems are not provided by Compaq Fortran
in Version 5.3:
- Octal notation for integer constants is not part of the Compaq
Fortran Language. Compaq Fortran 77 (
f77
command) only supports this feature when the
-vms
option is specified. For example:
I = "0014 ! Assigns 12 to I, not supported by Compaq Fortran
|
- The Compaq Fortran compiler discards leading zeros for "disp" in
the STOP statement. For example:
STOP 001 ! Prints 1 instead of 001
|
- When a single-precision constant is assigned to a double-precision
variable, Compaq Fortran 77 evaluates the constant in double precision.
The Fortran 95/90 standards require that the constant be evaluated in
single precision.
When a single-precision constant is assigned to a
double-precision variable with Compaq Fortran, it is evaluated in
single precision. You can, however, specify the
f90
-fpconstant
option to request that a single-precision constant assigned to a
double-precision variable be evaluated in double precision.
In the
example below, Compaq Fortran 77 assigns identical values to D1 and D2,
whereas Compaq Fortran obeys the standard and assigns a less precise
value to D1.
For example:
REAL*8 D1,D2
DATA D1 /2.71828182846182/ ! Incorrect - only REAL*4 value
DATA D2 /2.71828182846182D0/ ! Correct - REAL*8 value
|
- The names of intrinsics introduced by Compaq Fortran may conflict
with the names of existing external procedures if the procedures were
not specified in an EXTERNAL declaration. For example:
EXTERNAL SUM
REAL A(10),B(10)
S = SUM(A) ! Correct - invokes external function
T = DOT_PRODUCT(A,B) ! Incorrect - invokes intrinsic function
|
- When writing namelist external records, Compaq Fortran uses the
syntax for namelist external records specified by the Fortran 95/90
standards, rather than the Compaq Fortran 77 syntax (an extension to
the FORTRAN-77 and Fortran 95/90 standards).
Consider the following
program:
% cat test.f
INTEGER I
NAMELIST /N/ I
I = 5
PRINT N
END
|
When this program is compiled by the
f90
command and run, the following output appears:
% f90 test.f
% a.out
&N
I = 5
/
|
When this program is compiled by the
f77
command and run, the following output appears:
% f77 test.f
% a.out
$N
I = 5
$END
|
Use the
-f77rtl
option to tell Compaq Fortran to generate NAMELIST output in
Compaq Fortran 77 format.
Compaq Fortran accepts Fortran 95/90 namelist syntax and Compaq
Fortran 77 namelist syntax for reading records.
- The Compaq Fortran language does not include C-style escape
sequences. For example:
CHARACTER NL
NL = '\n' ! Incorrect
NL = CHAR(10) ! Correct
|
- Compaq Fortran inserts a leading blank when doing list-directed I/O
to an internal file. For example:
CHARACTER*10 C
WRITE(C,*) 'FOO' ! C = ' FOO'
|
- Compaq Fortran 77 and Compaq Fortran produce different output a
real value whose data magnitude is 0 with a G field descriptor. For
example:
X = 0.0
WRITE(*,100) X ! Compaq Fortran 77 prints 0.0000E+00
100 FORMAT(G12.4) ! Compaq Fortran prints 0.000
|
- Compaq Fortran does not allow certain intrinsics (such as SQRT) in
constant expressions for array bounds. For example:
- Compaq Fortran 77 returns UNKNOWN while Compaq Fortran returns
UNDEFINED when the ACCESS, BLANK, and FORM characteristics can not be
determined. For example:
INQUIRE(20,ACCESS=acc,BLANK=blk,FORM=form)
|
- Compaq Fortran does not allow an extraneous parenthesis in I/O
lists. For example:
write(*,*) ((i,i=1,1),(j,j=1,2))
|
- Compaq Fortran does not allow control characters within quoted
strings. For example, the assignment statement in the following program
is incorrect because it contains the character Ctrl/C.
character*5 c
c = 'ab^cef'
end
|
- Compaq Fortran does not recognize certain hexadecimal and octal
constants in DATA statements, such as those used in the following
program:
INTEGER I, J
DATA I/O20101/, J/Z20/
TYPE *, I, J
END
|
- Compaq Fortran, like Compaq Fortran 77, supports the use of
character literal constants (such as 'ABC' or "ABC") in numeric
contexts, where they are treated as Hollerith constants.
Compaq
Fortran 77 also allows character PARAMETER constants (typed and
untyped) and character constant expressions (using the // operator) in
numeric constants as an undocumented extension.
Compaq Fortran does
allow character PARAMETER constants in numeric contexts, but does not
allow character expressions. For example, the following is valid for
Compaq Fortran 77, but will result in an error message from Compaq
Fortran:
REAL*8 R
R = 'abc' // 'def'
WRITE (5,*) R
END
|
Compaq Fortran does allow PARAMETER constants:
PARAMETER abcdef = 'abc' // 'def'
REAL*8 R
R = abcdef
WRITE (5,*) R
END
|
- Compaq Fortran 77 namelist output formats character data delimited
with apostrophes. For example, consider:
CHARACTER CHAR4*4
NAMELIST /CN100/ CHAR4
CHAR4 = 'ABCD'
WRITE(20,CN100)
CLOSE (20)
|
This produces the following output file:
$CN100
CHAR4 = 'ABCD'
$END
|
This file is read by:
In contrast, Compaq Fortran produces the following output file by
default:
When read, this generates a
syntax error in NAMELIST input
error. To produce delimited strings from namelist output that can be
read by namelist input, use
DELIM="'"
in the OPEN statement of a Compaq Fortran program.
For More Information:
- On argument passing between Compaq Fortran and Compaq Fortran 77
for Compaq Tru64 UNIX systems, see Section 11.3.
- On compatibility between Compaq Fortran for Compaq Tru64 UNIX or
Linux Alpha systems and Compaq Fortran on OpenVMS systems, see
Section A.4.
- About the Compaq Fortran language, see the Compaq Fortran Language Reference Manual.
A.2.3 Improved Compaq Fortran Compiler Diagnostic Detection
The following language features are detected or interpreted differently
by Compaq Fortran Version 5.3 and Compaq Fortran 77:
- The Compaq Fortran compiler enforces the constraint that a function
cannot be the target of a CALL statement. For example:
REAL X
CALL X() ! Incorrect
CALL Y() ! Correct
|
- The Compaq Fortran compiler enforces the constraint that the
"nlist" in an EQUIVALENCE statement must contain at least two
variables. For example:
EQUIVALENCE (X) ! Incorrect
EQUIVALENCE (Y,Z) ! Correct
|
- The Compaq Fortran compiler enforces the constraint that entry
points in a SUBROUTINE must not be typed. For example:
SUBROUTINE ABCXYZ(I)
REAL ABC
I = I + 1
RETURN
ENTRY ABC ! Incorrect
BAR = I + 1
RETURN
ENTRY XYZ ! Correct
I = I + 2
RETURN
END SUBROUTINE
|
- The Compaq Fortran compiler enforces the constraint that a type
must appear before each list in an IMPLICIT statement. For example:
IMPLICIT REAL (A-C), (D-H) ! Incorrect
IMPLICIT REAL (O-S), REAL (T-Z) ! Correct
|
- The Compaq Fortran language disallows passing mismatched actual
arguments to intrinsics with corresponding integer formal arguments.
For example:
R = REAL(.TRUE.) ! Incorrect
R = REAL(1) ! Correct
|
- The Compaq Fortran compiler enforces the constraint that a simple
list element in an I/O list must be a variable or an expression. For
example:
READ (10,100) (I,J,K) ! Incorrect
READ (10,100) I,J,K ! Correct
|
- The Compaq Fortran compiler enforces the constraint that if two
operators are consecutive, the second operator must be a plus or a
minus. For example:
I = J -.NOT.K ! Incorrect
I = J - (.NOT.K) ! Correct
|
- The Compaq Fortran compiler enforces the constraint that character
entities with a length greater than 1 cannot be initialized with a bit
constant in a DATA statement. For example:
CHARACTER*1 C1
CHARACTER*4 C4
DATA C1/'FF'X/ ! Correct
DATA C4/'FFFFFFFF'X/ ! Incorrect
|
- The Compaq Fortran compiler enforces the requirement that edit
descriptors in the FORMAT statement must be followed by a comma or
slash separator. For example:
1 FORMAT (SSF4.1) ! Incorrect
2 FORMAT (SS,F4.1) ! Correct
|
- The Compaq Fortran compiler enforces the constraint that the number
and types of actual and formal statement function arguments must match
(such as incorrect number of arguments). For example:
CHARACTER*4 C,C4,FUNC
FUNC()=C4
C=FUNC(1) ! Incorrect
C=FUNC() ! Correct
|
- The Compaq Fortran compiler detects the use of a format of the form
Ew.dE0 at compile time. For example:
1 format(e16.8e0) ! Compaq Fortran detects error at compile time
write(*,1) 5.0 ! Compaq Fortran 77 compiles but an output
! conversion error occurs at run time
|
- Compaq Fortran detects passing of a statement function to a
routine. For example:
foo(x) = x * 2
call bar(foo)
end
|
- The Compaq Fortran compiler enforces the constraint that a branch
to a statement shared by more than one DO statements must occur from
within the innermost loop. For example:
DO 10 I = 1,10
IF (L1) GO TO 10 ! Incorrect
DO 10 J = 1,10
IF (L2) GO TO 10 ! Correct
10 CONTINUE
|
- The Compaq Fortran compiler enforces the constraint that a file
must contain at least one program unit. For example, a source file
containing only comment lines results in an error at the last line
(end-of-file).
The Compaq Fortran 77 compiler compiles files
containing less than one program unit.
- The Compaq Fortran compiler correctly detects misspellings of the
ASSOCIATEVARIABLE keyword to the OPEN statement. For example:
OPEN(1,ASSOCIATEVARIABLE = I) ! Correct
OPEN(2,ASSOCIATEDVARIABLE = J) ! Incorrect (extra D)
|
- The Compaq Fortran language enforces the constraint that the result
of an operation is determined by the data types of its operands. For
example:
INTEGER*8 I8
I8 = 2147483647 + 1 ! Incorrect. Produces less accurate
! INTEGER*4 result
I8 = 2147483647_8 + 1_8 ! Correct
|
- The Compaq Fortran compiler enforces the constraint that an object
can be typed only once. Compaq Fortran 77 issues a warning message and
uses the first type. For example:
LOGICAL B,B ! Incorrect (B multiply declared)
|
- The Compaq Fortran compiler enforces the constraint that certain
intrinsic procedures defined by the Fortran 95/90 standards cannot be
passed as actual arguments. For example, Compaq Fortran 77 allows most
intrinsic procedures to be passed as actual arguments, but the Compaq
Fortran compiler only allows those defined by the Fortran 95/90
standards (issues an error message).
Consider the following program:
program tstifx
intrinsic ifix,int,sin
call a(ifix)
call a(int)
call a(sin)
stop
end
subroutine a(f)
external f
integer f
print *, f(4.9)
return
end
|
The IFIX and INT intrinsic procedures cannot be passed as actual
arguments (the compiler issues an error message). However, the SIN
intrinsic is allowed to be passed as an actual argument by the Fortran
95/90 standards.
- Compaq Fortran reports character truncation with an error-level
message, not as a warning.
The following program produces an error
message during compilation with Compaq Fortran, whereas Compaq Fortran
77 produces a warning message.
INIT5 = 'ABCDE'
INIT4 = 'ABCD'
INITLONG = 'ABCDEFGHIJKLMNOP'
PRINT 10, INIT5, INIT4, INITLONG
10 FORMAT (' ALL 3 VALUES SHOULD BE THE SAME: ' 3I)
END
|
- If your code invokes Compaq Fortran intrinsic procedures with the
wrong number of arguments or an incorrect argument type, Compaq Fortran
reports this with an error-level message, not with a warning. Possible
causes include:
- A Compaq Fortran intrinsic has been added with the same name as a
user-defined subprogram and the user-defined subprogram needs to be
declared as EXTERNAL.
- An intrinsic that is an extension to an older Fortran standard is
incompatible with a newer standard-conforming intrinsic (for example,
the older RAN function that accepted two arguments).
The following program produces an error message during compilation
with Compaq Fortran, whereas Compaq Fortran 77 produces a warning
message.
INTEGER ANOTHERCOUNT
ICOUNT=0
100 write(6,105) (ANOTHERCOUNT(ICOUNT), INT1=1,10)
105 FORMAT(' correct if print integer values 1 through 10' /10I7)
Q = 1.
R = .23
S = SIN(Q,R)
WRITE (6,110) S
110 FORMAT(' CORRECT = 1.23 RESULT = ',f8.2)
END
!
INTEGER FUNCTION ANOTHERCOUNT(ICOUNT)
ICOUNT=ICOUNT+1
ANOTHERCOUNT=ICOUNT
RETURN
END
REAL FUNCTION SIN(FIRST, SECOND)
SIN = FIRST + SECOND
RETURN
END
|
- Compaq Fortran reports missing commas in FORMAT descriptors with an
error-level message, not as a warning.
The following program
produces an error message during compilation with Compaq Fortran,
whereas Compaq Fortran 77 produces a warning message:
LOGICAL LOG/111/
TYPE 1,LOG
1 FORMAT(' '23X,'LOG='O12)
END
|
In the preceding example, the correct coding (adding the missing
comma) for the FORMAT statement is:
1 FORMAT(' ',23X,'LOG='O12)
|
- Compaq Fortran generates an error when it encounters a 1-character
source line containing a Ctrl/Z character, whereas Compaq Fortran 77
allows such a line (which is treated as a blank line).
- Compaq Fortran does not detect an extra comma in an I/O statement
when the
-std
option is specified, whereas Compaq Fortran 77 with the
-stand
option identifies an extra comma as an extension. For example:
- Compaq Fortran detects the use of a character variable within
parentheses in an I/O statement. For example:
CHARACTER*10 CH/'(I5)'/
INTEGER I
READ CH,I ! Acceptable
READ (CH),I ! Generates error message, interpreted as an internal READ
END
|
- Compaq Fortran evaluates the exponentiation operator at compile
time only if the exponent has an integer data type. Compaq Fortran 77
evaluates the exponentiation operator even when the exponent does not
have an integer data type. For example:
PARAMETER ( X = 4.0 ** 1.1)
|
- Compaq Fortran detects an error when evaluating constants
expressions that result in an NaN or Infinity exceptional value, while
Compaq Fortran 77 allows such expressions. For example:
PARAMETER ( X = 4.0 / 0.0 )
|
- Compaq Fortran reports a warning error message when the same
variable is initialized more than once. Compaq Fortran 77 allows
multiple initializations of the same variable without a warning. For
example:
integer i
data i /1/
data i /2/
write (*,*) i
stop
end
|
For More Information:
- On passing arguments and returning function values between
Compaq Fortran and Compaq Fortran 77, see Section 11.3.
- On Compaq Fortran procedure calling and argument passing, see
Section 11.1.
- On compatibility between Compaq Fortran for Compaq Tru64 UNIX
systems and Compaq Fortran 77 on OpenVMS systems, see Section A.4.
- On the Compaq Fortran language, see the Compaq Fortran Language Reference Manual.
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):
-
-assume backslash
-
-f77
-
-ident
-
-show xref
(same as
-cross_reference
)
-
-stand keyword
-
-warn informational
-
-uncalled
-
-unused
-
-warn nounreachable
The following options are provided only by Compaq Fortran (not by
Compaq Fortran 77):
-
-align recNbyte
-
-assume buffered_io
-
-assume gfullpath
-
-assume minus0
-
-f77rtl
-
-fixed
-
-free
-
-fpconstant
-
-fuse_xref
(TU*X ONLY)
-
-hpf_matmul
(TU*X ONLY)
-
-intconstant
-
-module
-
-ladebug
-
-mp
(TU*X ONLY)
-
-omp
(TU*X ONLY) and assorted OpenMP parallel
options including
-assume pthreads_lock
and
-check omp_bindings
- (TU*X ONLY)
-wsf
and associated HPF parallel options, including
-assume bigarrays
,
-assume nozsize
,
-nearest_neighbor
,
-nowsf_main
,
-show hpf
,
-warn hpf
, and
-pprof
-
-std
(performs Fortran 95/90 standards checking, whereas the Compaq Fortran
77
-stand keyword
performs FORTRAN-77 and NTT MIA standards checking)
-
-warn granularity
Effective with Compaq Fortran V5.3, the
f77
command by default executes the Compaq Fortran 90 compiler and uses the
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:
- # Constants. Constants using a base other than 10.
- C Strings. NULL terminated strings contain C-style escape sequences.
- Conditional Compilation And Metacommand Expressions ($define,
$undefine, $if, $elseif, $else, $endif).
- $FREEFORM, $NOFREEFORM, $FIXEDFORM. Source file format
- $INTEGER, $REAL. Selects size.
- $FIXEDFORMLINESIZE. Line length for fixed form source.
- $STRICT, $NOSTRICT. F90 conformance.
- $PACK. Structure packing.
- $ATTRIBUTES ALIAS. External name for a subprogram or common block.
- $ATTRIBUTES C, STDCALL. Calling and naming conventions.
- $ATTRIBUTES VALUE, REFERENCE. Calling conventions.
- \ Descriptor. Prevents writing an end-of-record mark.
- Ew.dDe and Gw.dDe Edit Descriptors. Similar to Ew.dEe and Gw.dEe.
- 7200 Character Statement Length.
- Free form infinite line length.
- $DECLARE and $NODECLARE == IMPLICIT NONE.
- $ATTRIBUTES EXTERN. Variable allocated in another source file.
- $ATTRIBUTES VARYING. Variable number of arguments.
- $ATTRIBUTES ALLOCATABLE. Allocatable array.
- Mixing Subroutines/Functions in Generic Interfaces
- $MESSAGE. Output message during compilation.
- $LINE == C's #line
- INT1. Converts to one byte integer by truncating.
- INT2. Converts to two byte integer by truncating.
- INT4. Converts to four byte integer by truncating.
- COTAN. Returns cotangent.
- DCOTAN. Returns double precision cotangent.
- IMAG. Returns the imaginary part of complex number.
- IBCHNG. Reverses value of bit.
- ISHA. Shifts arithmetically left or right.
- ISHC. Performs a circular shift.
- ISHL. Shifts logically left or right.