Fortran 90 Features and Differences |
C |
![]() |
The tab character is not converted to a blank, so the visual placement of tabbed statements depends on the utility you use to edit or display text.
Fixed-Form Source
Source Form Assumed
The source form assumed by f90 depends on options, directives, and suffixes.
|
Option |
Action |
|
-fixed |
Interpret all source files as Fortran fixed form |
|
-free |
Interpret all source files as Fortran free form |
|
Directive |
Action |
|
!DIR$ FIXED |
Interpret the rest of the source file as Fortran fixed form |
|
!DIR$ FREE |
Interpret the rest of the source file as Fortran free form |
AbcDeF is treated as if it were spelled abcdef, or abcdeF, etc. See Compatibility with FORTRAN 77 on page 145.
Boolean Type
f90 supports constants and expressions of Boolean type. There are no Boolean variables or arrays, and there is no Boolean type statement.
|
nH... |
'...'H |
"..."H |
|
nL... |
'...'L |
"..."L |
|
nR... |
'...'R |
"..."R |
|
Boolean Constant |
Internal Octal for 32-bit word |
0B |
00000000000 |
77740B |
00000077740 |
X"ABE" |
00000005276 |
X"-340" |
37777776300 |
X'1 2 3' |
00000000443 |
X'FFFFFFFFFFFFFFFF' |
37777777777 |
Examples: Octal and hexadecimal in assignment statements.
i = 1357B |
j = X"28FF" |
k = X'-5A' |
Use of an octal or hexadecimal constant in an arithmetic expression can produce undefined results and do not generate syntax errors.
|
B'bbb' |
O'ooo' |
Z'zzz' |
|
B"bbb" |
O"ooo" |
Z"zzz" |
If these are assigned to a real variable, no type conversion occurs.
Abbreviated Size Notation for Numeric Data Types
f90 allows the following nonstandard type declaration forms in declaration statements, function statements, and IMPLICIT statements.
The form in column one is nonstandard Fortran 90, though in common use. The kind numbers in column two can vary by vendor.
Note - For release 1.2 of f90, INTEGER with KIND= 1, 2, or 4, are each 4 bytes long and align on 4-byte boundaries.
Cray Pointers
A Cray pointer is a variable whose value is the address of another entity, which is called the pointee.
POINTER ( pointer_name, pointee_name [array_spec] ), ... |
Where pointer_name, pointee_name, and array_spec are as follows:
Example: Declare Cray pointers to two pointees.
POINTER ( p, b ), ( q, c ) |
POINTER ( ix, x(n, 0:m) ) |
Cray pointers allow accessing absolute memory locations.
Cray pointers do not provide convenient manipulation of linked lists because (for optimization purposes) it is assumed that no two pointers have the same value.
Cray Pointers and Fortran Pointers
Cray pointers are declared as follows:
Features of Cray Pointers
Usage of Cray Pointers
Note - Cray pointees can be of type character, but their Cray pointers are different from other Cray pointers. The two kinds cannot be mixed in the same expression.
Cray pointers can be assigned values as follows:
Remarks about the above example:
Such association could occur in either of two ways:
These kinds of association are sometimes done deliberately, such as for equivalencing arrays, but then results can differ depending on whether optimization is turned on or off.
Note - The programmer responsible for preventing such association.
Example: b and c have the same pointer.
POINTER ( p, b ), ( p, c ) REAL x, b, c p = LOC( x ) b = 1.0 c = 2.0 PRINT *, b ... |
Above, because b and c have the same pointer, assigning 2.0 to c gives the same value to b. Therefore b prints out as 2.0, even though it was assigned 1.0.
Cray Character Pointers
If a pointee is declared as a character type, its Cray pointer is a Cray character pointer.
Declaration of Cray Character Pointers
For a pointee that has been declared with an assumed length character type, the Cray pointer declaration statement declares the pointer to be a Cray character pointer.
You can use functions CLOC or FCD, both nonstandard intrinsics.
Example: Declare Ccp to be a Cray character pointer and use CLOC to make it point to character string s.
CHARACTER*(*) a POINTER ( Ccp, a ) CHARACTER*80 :: s = "abcdefgskooterwxyz" Ccp = CLOC( s ) |
Operations on Cray Character Pointers
Ccp1 + i |
Ccp1 - i |
i + Ccp1 |
Ccp1 = Ccp2 |
Ccp1 relational_operator Ccp2 |
where Ccp1 and Ccp2 are Cray character pointers and i is an integer.
Directives
A compiler directive directs the compiler to do some special action. Directives are also called pragmas. General Directives
Currently there are only two general directives, FREE and FIXED. These directives tell the compiler to assume free-form source or fixed-form source.
|
Directive |
|
TASK, NOTASK |
|
SUPPRESS( var1, var2, ... ) |
|
TASKCOMMON( cb1, cb2, ... ) |
Form of General Directive Lines
General directives have the following syntax.
!DIR$ d1, d2, ... |
A general directive line is defined as follows.
Fixed-Form Source
Scope
They apply to the rest of the file in which they appear, or until the next FREE or FIXED directive is encountered.
Uses
!DIR$ FREE DO i = 1, n a(i) = b(i) * c(i) END DO |
Parallelization Directives
A parallelization directive is a special comment that directs the compiler to attempt to parallelize the next DO loop. Currently there is only one parallel directive, DOALL.
|
Directive |
|
CASE, END CASE |
|
PARALLEL, END PARALLEL |
|
DO PARALLEL, END DO |
|
GUARD, END GUARD |
Form of Parallelization Directive Lines
Parallel directives have the following syntax.
!MIC$ DOALL [general parameters] [scheduling parameter] |
A parallelization directive line is defined as follows.
Fixed
Example: Directive with continuation lines (DOALL directive and parameters.)
C$PAR DOALL !MIC$& SHARED( a, b, c, n ) !MIC$& PRIVATE( i ) DO i = 1, n a(i) = b(i) * c(i) END DO |
Example: Same directive and parameters, with no continuation lines.
C$PAR DOALL SHARED( a, b, c, n ) PRIVATE( i ) DO i = 1, n a(i) = b(i) * c(i) END DO |
Compatibility with FORTRAN 77
Source
Standard-conforming Fortran 77 source code is compatible with Sun Fortran 90. Use of non-standard extensions, such as VMS Fortran features, are not compatible and may not compile with Sun Fortran 90.-U option to force f90 to be sensitive to both upper and lower case. This may present a problem when mixing f77 and f90 compiled routines. Since a routine compiled by f90 will treat CALL XyZ the same as CALL XYz, and treat them both as if they were CALL xyz, care must be taken to rearrange the way these calls are made. A similar situation will exist when trying to define entry points in f90 compiled routines that are diffentiated by case. The clue to potential problems would be the need to use -U with f77. Executables
Libraries compiled and linked in FORTRAN 77 under Solaris 2.x run in the Fortran 4.2 environment. Libraries
Such compatibility includes the following two situations:
If you use one of these names in your program, you must add an EXTERNAL statement to make f90 use your function rather than the intrinsic one.
The Fortran 90 standard supports the following new array intrinsic functions.
ALL |
MAXLOC |
RESHAPE |
ANY |
MAXVAL |
SPREAD |
COUNT |
MERGE |
SUM |
CSHIFT |
MINLOC |
TRANSPOSE |
DOT_PRODUCT |
MINVAL |
UNPACK |
EOSHIFT |
PACK |
|
MATMUL |
PRODUCT |
|
Forward Compatibility
The next release of f90 is intended to be source code compatible with this release.
Mixing Languages
On Solaris systems, routines written in C can be combined with Fortran programs, since these languages have common calling conventions.
Module Files
Compiling a file containing a Fortran 90 MODULE generates a module file (.M file) in addition to the .o file.