2. Using Solaris Studio Fortran
4. Solaris Studio Fortran Features and Differences
4.1.1 Continuation Line Limits
4.2.1.1 Rules Governing Boolean Type
4.2.1.2 Alternate Forms of Boolean Constants
4.2.1.3 Alternate Contexts of Boolean Constants
4.2.2 Abbreviated Size Notation for Numeric Data Types
4.2.3 Size and Alignment of Data Types
4.3.2 Purpose of Cray Pointers
4.3.3 Declaring Cray Pointers and Fortran 95 Pointers
4.3.4 Features of Cray Pointers
4.3.5 Restrictions on Cray Pointers
4.3.6 Restrictions on Cray Pointees
4.4 STRUCTURE and UNION (VAX Fortran)
4.6.1 Interoperability with C Functions
4.6.2 IEEE Floating-Point Exception Handling
4.6.3 Command-Line Argument Intrinsics
4.6.5 Fortran 2003 Asynchronous I/O
4.6.6 Extended ALLOCATABLE Attribute
4.6.9 Fortran 2003 Formatted I/O Features
4.6.10 Fortran 2003 IMPORT Statement
4.6.11 Fortran 2003 FLUSH I/O Statement
4.6.12 Fortran 2003 POINTER INTENT Feature
4.7.1 I/O Error Handling Routines
4.7.2 Variable Format Expressions
4.7.5 Miscellaneous I/O Extensions
4.8.1 Form of Special f95 Directive Lines
4.8.2 FIXED and FREE Directives
4.8.3 Parallelization Directives
4.9.2 The -use=list Option Flag
5. FORTRAN 77 Compatibility: Migrating to Solaris Studio Fortran
A number of new features in the Fortran 2003 standard appear in this release of the Solaris Studio Fortran compiler. For details, refer to the Fortran 2003 standard. Also included are some features proposed in the Fortran 2008 draft standard. For details on these, see the appropriate draft publications.
The new standard for Fortran provides:
a means of referencing C language procedures and, conversely, a means of specifying that a Fortran subprogram can be referenced from a C function, and
a means of declaring global variables that are linked with external C variables
The ISO_C_BINDING module provides access to named constants that are kind type parameters representing data that is compatible with C types.
The standard also introduces the BIND(C) attribute. A Fortran derived type is interoperable with C if it has the BIND attribute.
This release of the Fortran compiler implements these features as described in the chapter 15 of the standard. Fortran also provides facilities for defining derived types and enumerations that correspond to C types, as described in chapter 4 of the standard.
New intrinsic modules IEEE_ARITHMETIC, and IEEE_FEATURES provide support for exceptions and IEEE arithmetic in the Fortran language. Full support of these features is provided by:
USE, INTRINSIC :: IEEE_ARITHMETIC
USE, INTRINSIC :: IEEE_FEATURES
The INTRINSIC keyword is new in Fortran 2003.These modules define a set of derived types, constants, rounding modes, inquiry functions, elemental functions, kind functions, and elemental and non-elemental subroutines. The details are contained in Chapter 14 of the Fortran 2003 standard.
The Fortran 2003 standard introduces three new intrinsics for processing command-line arguments and environment variables. These are:
GET_COMMAND(command, length, status)
Returns in command the entire command line that invoked the program.
GET_COMMAND_ARGUMENT(number, value, length, status)
Returns a command-line argument in value.
GET_ENVIRONMENT_VARIABLE(name, value, length, status, trim_name)
Return the value of an environment variable.
The Fortran compiler now accepts the Fortran 2003 PROTECTED attribute. PROTECTED imposes limitations on the usage of module entities. Objects with the PROTECTED attribute are only definable within the module that declares them.
The compiler recognizes the ASYNCHRONOUS specifier on I/O statements:
ASYNCHRONOUS=[’YES’ | ’NO’]
This syntax is as proposed in the Fortran 2003 standard, Chapter 9. In combination with the WAIT statement it allows the programmer to specify I/O processes that may be overlapped with computation. While the compiler recognizes ASYNCHRONOUS=’YES’, the standard does not require actual asynchronous I/O. In this release of the compiler, I/O is always synchronous.
Fortran 2003 extends the data entities allowed for the ALLOCATABLE attribute. Previously this attribute was limited to locally stored array variables. It is now allowed with:
array components of structures
dummy arrays
array function results
Allocatable entities remain forbidden in all places where they may be storage-associated: COMMON blocks and EQUIVALENCE statements. Allocatable array components may appear in SEQUENCE types, but objects of such types are then prohibited from COMMON and EQUIVALENCE.
The f95 compiler accepts the Fortran 2003 VALUE type declaration attribute.
Specifying a subprogram dummy input argument with this attribute indicates that the actual argument is passed “by value”. The following example demonstrates the use of the VALUE attribute with a C main program calling a Fortran subprogram with a literal value as an argument:
C code: #include <stdlib.h> int main(int ac, char *av[]) { to_fortran(2); } Fortran code: subroutine to_fortran(i) integer, value :: i print *, i end
The Fortran 2003 standard defines a new “stream” I/O scheme. Stream I/O access treats a data file as a continuous sequence of bytes, addressable by a positive integer starting from 1. The data file can be connected for either formatted or unformatted access.
Declare a stream I/O file with the ACCESS=’STREAM’ specifier on the OPEN statement. File positioning to a byte address requires a POS=scalar_integer_expression specifier on a READ or WRITE statement. The INQUIRE statement accepts ACCESS=’STREAM’, a specifier STREAM=scalar_character_variable, and POS=scalar_integer_variable.
Three new Fortran 2003 formatted I/O specifiers have been implemented in f95. They may appear on OPEN, READ, WRITE, PRINT, and INQUIRE statements:
DECIMAL=[’POINT’|’COMMA’]
Change the default decimal editing mode. The default uses a period to separate the whole number and decimal parts of a floating-point number formatted with D, E, EN, ES, F, and G editing. ’COMMA’ changes the default to use comma instead of a period, to print, for example, 123,456. The default is ’POINT’, which uses a period, to print, for example, 123.456.
ROUND=[’PROCESSOR_DEFINED’ | ’COMPATIBLE’]
Set the default rounding mode for formatted I/O D, E, EN, ES, F, and G editing. With ’COMPATIBLE’, the value resulting from data conversion is the one closer to the two nearest represetnations, or the value away from zero if the value is halfway between them. With ’PROCESSOR_DEFINED’, the rounding mode is dependent on the processor’s default mode, and is the compiler default if ROUND is not specified.
As an example, WRITE(*,’(f11.4)’) 0.11115 prints 0.1111 in default mode, and 0.1112 in ’COMPATIBLE’ mode.
IOMSG=character-variable
Returns an error message as a string in the specified character variable. This is the same error message that would appear on standard output. Users should allocate a character buffer large enough to hold the longest message. (CHARACTER*256 should be sufficient.)
When used in INQUIRE statements, these specifiers declare a character variable for returning the current values.
New edit descriptors DP, DC, RP, and RC change the defaults within a single FORMAT statement to decimal point, decimal comma, processor-defined rounding, and compatible rounding respectively. For example:
WRITE(*,’(I5,DC,F10.3)’) N, W
prints a comma instead of a period in the F10.3 output item.
See also the -iorounding compiler command-line option for changing the floating-point rounding modes on formatted I/O. (3.4.45 -iorounding[={compatible|processor-defined}].)
The IMPORT statement specified entities in the host scoping unit that are accessible by host association. It is allowed only in an interface body.
The f95 compiler accepts the Fortran 2003 FLUSH statement. The FLUSH statement makes data written to an external file available to other processes, or causes data placed in an external file by means other than Fortran to be available to a READ statement.
The Fortran compiler now supports the INTENT attribute for POINTER dummy arguments: INTENT(IN), INTENT(OUT), or INTENT(INOUT) may be specified for pointer dummies.
For example,
subroutine sub(P) integer, pointer, intent(in) :: p ... end
The INTENT attribute for pointers applies to the pointer and not what it points to, so for INTENT(IN) pointers, the following are illegal because they modify the pointer:
p => t allocate(p) deallocate(p)
But the following is legal for INTENT(IN) pointers, because it modifies the pointee:
p = 400
Use of square brackets in place of (/ and /) in array constructors is allowed:
X = [ 3.2, 4.01, 6.5 ]
The Fortran 2003 standard allows the use of square brackets as array constructors. This can conflict with interval constants. When the square brackets are used without the -xia option (or similar options to enable interval arithmetic) they are treated as array constructors. When -xia option is used, they are treated as constants. Interval users should continue using (/ and /) array constructors to avoid compilation errors.
For details on the Fortran 2003 features listed below, refer to the published Fortran 2003 Standard. Fortran 2008 features are described in published Fortran 200x draft documents.
2003 extensions to allocatable arrays — reallocation on assignment, and allocatable scalars
2003 extensions to ALLOCATE/DEALLOCATE statements — ERRMSG and SOURCE
2003 extensions MOVE_ALLOC intrinsic
2003 extensions pointer assignment with remapping
2003 extensions MIN/MAX, MIN/MAXVAL and MIN/MAXLOC with character arguments.
2003 intrinsics IS_IOSTAT_END, IS_IOSTAT_EOR, NEW_LINE
2003 intrinsic SELECTED_CHAR_KIND
2003 REAL type for argument COUNT_RATE of intrinsic SYSTEM_CLOCK
2003 new restriction on complex SQRT intrinsic result
2008: Use of null pointers as missing optional arguments
IEEE intrinsic module support on x86 platforms.
2008 Bit Intrinsics: BGE, BGT, BLE, BLT, DSHIFTL, DSHIFTR, LEADZ, POPCNT, POPPAR, TRAILZ, MASKL, MASKR, SHIFTA, SHIFTL, SHIFTR, MERGE_BITS, IALL, IANY, IPARITY