Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
E77790.pdf
Скачиваний:
2
Добавлен:
16.05.2024
Размер:
1.29 Mб
Скачать

4.6 Fortran 200x Features

UNSIGNED(v [,kind] ).

Another new intrinsic function, SELECTED_UNSIGNED_KIND( var), returns the kind parameter for var.

Intrinsic functions do not allow both signed and unsigned integer operands, except for the MAX and MIN functions, which allow both signed and unsigned integer operands only if there is at least one operand of REAL type.

Unsigned arrays cannot appear as arguments to array intrinsic functions.

4.6Fortran 200x Features

A number of new features in the Fortran 2003 and Fortran 2008 standards appear in this release of the Oracle Developer Studio Fortran compiler. For details, refer to the appropriate Fortran standard.

4.6.1Interoperability with C

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.

The Fortran compiler implements the features described in Chapter 15 of the Fortran standard. All intrinsic functions defined in Chapter 15 have been implemented. Fortran also provides facilities for defining derived types and enumerations that correspond to C types, as described in Chapter 4 of the standard.

4.6.2IEEE Floating-Point Exception Handling

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:

Chapter 4 • Oracle Developer Studio Fortran Features and Extensions

181

4.6 Fortran 200x Features

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.

4.6.3Command-Line Argument Intrinsics

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.

4.6.4PROTECTED Attribute

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.

4.6.5Fortran 2003 Asynchronous I/O

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.

182 Oracle Developer Studio 12.6: Fortran User's Guide • July 2017

4.6 Fortran 200x Features

4.6.6Extended ALLOCATABLE Attribute

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

polymorphic entities in a CLASS type specifier

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.

4.6.7VALUE Attribute

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

4.6.8Fortran 2003 Stream I/O

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.

Chapter 4 • Oracle Developer Studio Fortran Features and Extensions

183

4.6 Fortran 200x Features

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.

4.6.9Fortran 2003 IMPORT Statement

The IMPORT statement specified entities in the host scoping unit that are accessible by host association. It is allowed only in an interface body.

4.6.10Fortran 2003 FLUSH I/O Statement

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.

4.6.11Fortran 2003 POINTER INTENT Feature

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

184 Oracle Developer Studio 12.6: Fortran User's Guide • July 2017

Соседние файлы в предмете Информационные и сетевые технологии