HP Fortran Programmer’s Reference Eighth Edition HP Fortran Compiler for HP-UX Manufacturing Part Number: B3908-90015 Document Number: B3908-90015 September 2007
Print History Seventh Document Number: B3908-90013 Released September 2007. Sixth Document Number: B3908-90013 Released February 2007. Fifth Document Number: B3908-90008 Released December 2004. Fourth Document Number: B3908-90006 Released September 2003. Third Document Number: B3908-90004 Released June 2003. Second Document Number: B3908-90003 Released June 2001.
Document Number: B3908-90002 Released October 1998. Initial release.
Legal Notices Copyright 2007 Hewlett-Packard Development Company, L.P. Confidential computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license. The information contained in this document is subject to change without notice.
Contents 1. Introduction to HP Fortran HP Fortran features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Source format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents Explicit-shape arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Assumed-shape arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deferred-shape arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Array pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents 5. Data types and data objects Intrinsic data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Type declaration for intrinsic types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Implicit typing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents IF construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Flow control statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CONTINUE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CYCLE statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . EXIT statement. . . .
Contents Procedure dummy argument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Keyword option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Optional arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Duplicated association . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . INTENT attribute. . . . . . . . . .
Contents Unformatted I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Direct access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Nonadvancing I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I/O statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents I (Integer) edit descriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L (Logical) edit descriptor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . M and N edit descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . O (Octal) edit descriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents DEALLOCATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DECODE (extension) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DIMENSION (statement and attribute). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents MAP (extension) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MODULE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MODULE PROCEDURE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . NAMELIST. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . NULLIFY . .
Contents VIRTUAL (extension) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . VOLATILE (extension) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . WHERE (statement and construct) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . WRITE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490 491 492 496 11.
Contents ANINT(A, KIND) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ANY(MASK, DIM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ASIN(X) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ASIND(X) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ASINH(X) . . .
Contents EXIT(STATUS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . EXP(X) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . EXPONENT(X) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . FLOOR(A) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents IOMSG(N, MSG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IOR(I, J) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IQINT(A) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IRAND(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents MIN(A1, A2, A3, ...) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MINEXPONENT(X) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MINLOC(ARRAY, MASK) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MINVAL(ARRAY, DIM, MASK) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MOD(A, P) . . . . . . . . . . . . . . . . . . . .
Contents SELECTED_REAL_KIND(P, R) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SET_EXPONENT(X, I). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SHAPE(SOURCE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SIGN(A, B) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SIN(X) . . . . . . . . . . . . . . . . . .
Contents Declaring library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Declaring library routines as EXTERNAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Man pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . libU77 routines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BLAS routines . . . . . . . . .
Tables Table 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxviii Table 2-1. Fortran 90 character set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Table 2-2. Statement order in a program unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Table 2-3. Statements allowed in scoping units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Table 2-4.
Tables Table 9-9. BN and BZ edit descriptors: input examples. . . . . . . . . . . . . . . . . . . . . . Table 9-10. D, E, F, and G edit descriptors: input examples . . . . . . . . . . . . . . . . . . Table 9-11. D and E edit descriptors: output examples . . . . . . . . . . . . . . . . . . . . . . Table 9-12. EN and ES edit descriptors: output examples . . . . . . . . . . . . . . . . . . . Table 9-13. F edit descriptor: output examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . Table 9-14.
Tables Table 10-17. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Table 10-18. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Table 10-19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Table 10-20. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Tables Table 10-50. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Table 10-51. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Table 10-52. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Table 10-53. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Preface The HP Fortran Programmer’s Reference is a language reference for programmers using HP Fortran V2.0 and higher. It describes the features and requirements of the HP Fortran programming language for both PA-RISC and Itanium-based architectures.
The HP Fortran Programmer’s Reference is intended for use by experienced Fortran programmers who are interested in writing or porting HP Fortran applications. This manual includes information on the parallel concepts and directives, as well as optimization of programs that use them. You need not be familiar with the HP parallel architecture, programming models, or optimization concepts to understand the concepts introduced in this book.
Scope This guide covers programming methods for the HP Fortran compiler on machines running: • HP-UX 11i v1 and higher on HP 9000 systems • HP-UX 11i v2 and higher on Integrity systems HP Fortran supports an extensive shared-memory programming model. HP-UX 11i v1 and higher includes the required assembler, linker, and libraries.
Notational conventions This section discusses notational conventions used in this book. Table 1 bold monospace In command examples, bold monospace identifies input that must be typed exactly as shown. monospace In paragraph text, monospace identifies command names, system calls, and data structures and types. In command examples, monospace identifies command output, including error messages. italic In paragraph text, italic identifies titles of documents.
Table 1 (Continued) Curly brackets ({}), Pipe (|) In command syntax diagrams, text surrounded by curly brackets indicates a choice. The choices available are shown inside the curly brackets and separated by the pipe sign (|). The following command example indicates that you can enter either a or b: command {a | b} Horizontal ellipses (...) In command examples, horizontal ellipses show repetition of the preceding items.
Either a or b must be supplied. [output_file] indicates an optional file name.
Associated documents The following documents are listed as additional resources to help you use the compilers and associated tools: • HP aC++ Online Programmer’s Guide—Presents reference and tutorial information on aC++. This manual is only available in html format. • HP C/HP-UX Programmer’s Guide—Contains detailed discussions of selected C topics. • HP C/HP-UX Reference Manual—Presents reference information on the C programming language, as implemented by HP.
xxxii
1 Introduction to HP Fortran This chapter summarizes standard features of HP Fortran that are not found in FORTRAN 77.
Introduction to HP Fortran • Data types • Pointers • Arrays • Control constructs • Operators • Procedures • Modules • I/O features • Intrinsics 34 Chapter 1
Introduction to HP Fortran HP Fortran features HP Fortran features The following summarizes features of HP Fortran that are not in standard FORTRAN 77 and indicates where they are described in this manual. Source format The fixed source form of FORTRAN 77 is extended by the addition of the semicolon (;) statement separator and the exclamation point (!) trailing comment. HP Fortran also supports free format source code.
Introduction to HP Fortran HP Fortran features Arrays The Fortran 90 standard has defined these new array features: ❏ Array sections that permit operations for processing whole arrays or a subset of array elements; expressions, functions, and assignments can be array-valued. The WHERE construct and statement are used for masked-array assignment. ❏ Array constructors—unnamed, rank-one arrays whose elements can be constants or variables.
Introduction to HP Fortran HP Fortran features Procedures ❏ Fortran 90 includes a feature called the procedure interface block, which provides an explicit interface for external procedures. The names and properties of the dummy arguments are then available to the calling procedure, allowing the compiler to check that the dummy and actual arguments match. For information about interface blocks, see “Procedure interface” on page 181.
Introduction to HP Fortran HP Fortran features ❏ Namelist-directed I/O Namelist-directed I/O—previously available as an extension to FORTRAN 77—is a standard feature of Fortran 90. This feature enables you to perform repeated I/O operations on a named group of variables. See “Namelist-directed I/O” on page 213 for more information. Intrinsics Fortran 90 provides a large number of new intrinsic procedures for manipulating arrays. Many of them are elemental, taking either scalar or array arguments.
2 Language elements This chapter describes the basic elements of an HP Fortran program.
Language elements • Lexical tokens • Program structure • Statement labels • Statements • Source format of program file • INCLUDE line 40 Chapter 2
Language elements Character set Character set The Fortran 90 standard character set, shown in Table 2-1, consists of letters, digits, the underscore character, and special characters. The HP Fortran character set consists of the Fortran 90 character set, plus: • Control characters (Tab, Newline , and Carriage return). Carriage return and Tab are usually treated as “white space” in a source program. You can use them freely to make the source easier to read.
Language elements Lexical tokens Lexical tokens Lexical tokens consist of sequences of characters and are the building blocks of a program.
Language elements Names Names In Fortran 90, names denote entities such as variables, procedures, derived types, named constants, and COMMON blocks. A name must start with a letter but can consist of any combination of letters, digits, and underscore (_) characters. As an extension in HP Fortran, the dollar sign may also be used in a name, but not as the first character. The Fortran 90 Standard allows a maximum length of 31 characters in a name.
Language elements Program structure Program structure A complete executable Fortran program contains one and only one main program unit and may also contain one or more of the following other types of program units: • External function subprogram unit • External subroutine subprogram unit • Block data program unit • Module program unit Each program unit can be compiled separately. Execution of the program starts in the main program. Control may be passed to other program units.
Language elements Statement labels Statement labels A Fortran 90 statement may have a preceding label, composed of one to five digits. All statement labels in the same scoping unit must be unique; leading zeroes are not significant. Although most statements can be labeled, not all statements can be branched to. The FORMAT statement must have a label. The INCLUDE line, which is not a statement but a compiler directive, must not have a label.
Language elements Statements Statements All HP Fortran statements are fully described in alphabetical order in Chapter 10, “HP Fortran Statements.” The required order for statements in a standard Fortran 90 program unit is illustrated in Table 2-2. Vertical lines separate statements that can be interspersed, and horizontal lines separate statements that cannot be interspersed. For example, the DATA statement can appear among executable statements but may not be interspersed with CONTAIN statements.
Language elements Statements Table 2-3 identifies which statements may appear within a scoping unit; a check mark indicates that a statement is allowed in the specified scoping unit. For the purpose of this table, type declarations include the PARAMETER statement, the IMPLICIT statement, type declaration statements, derived-type definitions, and specification statements.
Language elements Source format of program file Source format of program file The HP Fortran compiler accepts source files in fixed form (the standard source form for FORTRAN 77 programs) or free form. The following sections describe both forms. The compiler assumes that source files whose names end in the .f90 extension are in free source form and that files whose names end in the .f or .F extension are in fixed form.
Language elements Source format of program file Statement labels Statement labels are not required to be in columns 1-5, but must be separated from the statement by at least one space. Spaces Spaces are significant: • They may not appear within a lexical token, such as a name or an operator. • In general, one or more spaces are required to separate adjacent statement keywords, names, constants, or labels. Within the keyword pairs listed in Table 2-4, however, the space is optional.
Language elements Source format of program file Comments An exclamation mark (!) indicates the beginning of a comment in free source form, except where it appears in a character context. The compiler considers the rest of the line following the exclamation mark as part of the comment. Embedding a comment inside program text within a single source line is not allowed, but it can follow program text on a source line. A statement on a line with a trailing comment can be continued on subsequent lines.
Language elements Source format of program file Spaces Spaces are not significant except within a character context. For example, the two statements RETURN R E T U R N are equivalent, but c = "abc" c = "a b c" are not. Source lines There are three types of lines in fixed source form: • Initial line • Continuation line • Comment line The following sections describe each type of source lines. Initial line An initial line has the following form: • Columns 1 to 5 may contain a statement label.
Language elements Source format of program file written in columns 1 to 72. The compiler treats a line containing only blank characters in columns 1 to 72 as a comment line. In addition, a line is considered to be a comment when there is an exclamation mark (!) in column 1 or in any column except column 6. The following are HP extensions to the comment: • A line with D or d in column 1 is by default treated as a comment.
Language elements INCLUDE line INCLUDE line The INCLUDE line is a directive to the compiler, not a Fortran 90 statement. It causes the compiler to insert text into a program before compilation. The inserted text is substituted for the INCLUDE line and becomes part of the compilable source text. The format of an INCLUDE line is: INCLUDE char-literal-const where char-literal-const is the name of a file containing the text to be included.
Language elements INCLUDE line 54 Chapter 2
3 Arrays This chapter describes arrays and the array-handling features of HP Fortran.
Arrays • Array declarations • Array-valued structure component references • Array constructors • Array expressions • Array-valued functions • Array inquiry intrinsics 56 Chapter 3
Arrays Array fundamentals Array fundamentals An array consists of a set of elements, each of which is a scalar and has the same type and type parameter as declared for the array. Elements are organized into dimensions. Fortran 90 allows arrays up to seven dimensions. The number of dimensions in an array determines its rank. Dimensions have an upper bound and a lower bound.
Arrays Array fundamentals a(1,2) a(2,2) a(3,2) The following array declarations illustrate some of the concepts presented in this section: ! The rank of a1 is 1 as it only has one dimension, the extent of ! the single dimension is 10, and the size of a1 is also 10. ! a1 has a shape represented by the vector [10]. REAL, DIMENSION(10) :: a1 ! a2 is declared with two dimensions and consequently has a rank ! of 2, the extents of the dimensions are 2 and 4 ! respectively,and the size of a2 is 8.
Arrays Array declarations Array declarations An array is a data object with the dimension attribute. Its rank—and possibly the extents—are defined by an array specification.
Arrays Array declarations For a given dimension, the values of lower-bound and upper-bound define the range of the array in that dimension. Usually, lower-bound is less than upper-bound; if lower-bound is the same as upper-bound, then the dimension contains only one element; if it is greater, then the dimension contains no elements, the extent of the dimension is zero, and the array is zero-sized.
Arrays Array declarations INTEGER, PARAMETER :: buffsize = 0 REAL :: buffer (1: buffsize) ! buffer has explicit shape, but no elements and is zero-sized . . . END SUBROUTINE sort Assumed-shape arrays An assumed-shape array is a dummy argument that assumes the shape of the corresponding actual argument. It must not have the POINTER attribute. Each dimension of an assumed-shape array has the form: [lower-bound] : where lower-bound is a specification expression. The default for lower-bound is 1.
Arrays Array declarations If a procedure has an argument that is an assumed-shape array, its interface must be explicit within the calling program unit. A procedure’s interface is explicit if it is an internal procedure within the caller procedure or if the interface is declared in an interface block within the caller.
Arrays Array declarations Deferred-shape arrays A deferred-shape array has either the POINTER attribute or the ALLOCATABLE attribute. Its shape is not specified until the array is pointer assigned or allocated. Although a deferred-shape array can have the same form as an assumed-shape array, the two are different. The assumed-shape array is a dummy argument and must not have the POINTER attribute. The array specification for a deferred-shape array has the form: : [ , : ] ...
Arrays Array declarations Allocatable arrays An allocatable array is a deferred-shape array with the ALLOCATABLE attribute. Its bounds and shape are defined when it is allocated with the ALLOCATE statement. Once allocated, the allocatable array may be used in any context in which any other array may appear. An allocatable array can also be deallocated with the DEALLOCATE statement. An allocatable array has an allocation status that can be tested with the ALLOCATED intrinsic inquiry function.
Arrays Array declarations ! will have the shape [ n, n ] ALLOCATE(matrix(n,n)) ! test allocation by assigning to array matrix(n,n) = 9.1 PRINT *, 'matrix(',n,',',n,') = ', matrix(n,n) ! sts is assigned the value .TRUE. as the allocatable array ! does exist and its allocation status is therefore allocated sts = ALLOCATED(matrix) PRINT *, 'Status of matrix after ALLOCATE: ', sts DEALLOCATE (matrix) ! sts is assigned the value .FALSE.
Arrays Array declarations subscript in the last dimension of an assumed-size array may extend from the lower bound to a value that does not cause the reference to go beyond the storage associated with the actual argument. Because the last dimension of an assumed-size array has no upper bound, the dimension has no extent and the array consequently has no shape.
Arrays Array declarations $ f90 assumed_size.f90 $ a.out main: a = 1.0 2.0 3.0 4.0 5.0 6.0 main: x(2, 2) = 4.0 returned by func: 6.0 , the value in x(2,3) An assumed-size array is a FORTRAN 77 feature that has been superseded by the assumed-shape array; see “Assumed-shape arrays” on page 61.
Arrays Array sections Array sections An array section is a selected portion of another array (the parent) that is itself an array, even if it consists of only one element, or possibly none. An array section can appear wherever an array name is allowed. The syntax for specifying an array section is: array-name (section-subscript-list)[ (substring-range) ] where: section-subscript-list is a comma-separated list of section-subscript.
Arrays Array sections Section-subscript-list must specify section-subscript for each dimension of the parent array. The rank of the array section is the number of subscript-triplets and vector -subscripts that appear in the section-subscript-list. Because an array section is also an array, at least one subscript-triplet or vector-subscript must be specified. The following sections provide more information about subscript-triplet and vector-subscript.
Arrays Array sections ! The arrays ! x ! 0 0 0 0 0 ! 0 0 0 0 0 ! 0 1 1 1 0 x, y, and z now y 0 0 0 0 0 0 0 0 2 0 2 0 0 0 0 0 0 0 have the following values: z 0 0 0 3 3 3 3 2 0 0 3 3 3 3 0 0 0 0 0 0 0 In the following example of an array substring, the variable dates(5:10) is an array section that includes elements 5 through to 10 of the parent array dates, and the variable dates(5:10)(8:11) is also an array section of the array dates but only contains the last 4 character positions of the elements 5 thr
Arrays Array sections Example 3-3 vector_sub.f90 PROGRAM main ! m is a rank-1 array that has been ! initialized with the values of an array constructor INTEGER, DIMENSION(4) :: m = (/ 2, 3, 8, 1/) INTEGER :: i ! initialize a (a rank-1 array) with the values ! 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 11.0 REAL, DIMENSION(10) :: a = (/ (i*1.1, i=1,10) /) ! b is an uninitialized 4x2 array REAL, DIMENSION(4,2) :: b ! print a section of a, using a vector subscipt PRINT *,a(m) ! assign the values 5.5, 11.
Arrays Array-valued structure component references Array-valued structure component references A structure component reference can specify an array or a scalar. If, for example, the parent in the reference is declared as an array and likewise one of the components is declared as an array, this makes possible an array-valued structure component reference. Conceptually, an array-valued structure component reference is similar to a reference to an array section (see “Array sections” on page 68).
Arrays Array-valued structure component references The next statement uses a subscript triplet in an array-valued structure component reference to assign the same score to one test of three students in one course: course(2)%student(1:3)%test(4) = 82 It would be convenient if we could initialize all tests of all students in all courses to 0. But the Standard does not allow structure component references in which more than one of the parts specifies a rank greater than 0.
Arrays Array-valued structure component references PRINT *, course(2)%student(1:3)%test(4) ! ! ! ! ! the following commented-out statement is illegal: only one part (of the combined components and parent) in a structure component reference may have a rank greater than 0. course%student%test = 0 END PROGRAM main Here are the command lines to compile and execute the program, along with the output from a sample run: $ f90 array_val_ref.f90 $ a.
Arrays Array constructors Array constructors An array constructor is used to assign values to an array. The generated values are supplied from a list of scalar values, arrays of any rank, and implied DO specifications. An array constructor may appear in any context in which a rank-one array expression is allowed. An array with a rank greater than one may be constructed by using the RESHAPE intrinsic function.
Arrays Array constructors depends on the value of the variable n; if the value of the variable is less than 10, then the constructor contains no values. If the list contains only constant values, the array constructor may initialize a named constant or a type declaration statement. An array constructor may not initialize variables in a DATA statement, which may contain scalar constants only. As an extension, HP Fortran allows the use of [ and ] in place of (/ and /).
Arrays Array expressions Array expressions Array operations areperformed in parallel. That is, an operation is performed on each element independently and in any order. The practical effect of this is that, because an assignment statement may have the same array on both the left and right-hand sides, the right-hand side is fully evaluated before any assignment takes place. This means that in some cases the compiler may create temporary space to hold intermediate results of the computation.
Arrays Array expressions ! ! ! b the effect is as if the scalar were broadcast into a temporary array, with the same shape as b; b is then assigned to theleft-hand side = 0.
Arrays Array-valued functions Array-valued functions A function may be array-valued; that is, its return value may evaluate to an array of values rather than to a scalar.
Arrays Array-valued functions PROGRAM main ! The following interface block describes the characteristics of ! the function genrand; the function inputs a single integer ! scalar and returns a real array of rank-one with an extent ! equal to the value of its argument INTERFACE FUNCTION genrand(n) INTEGER:: n REAL, DIMENSION (n)::genrand END FUNCTION genrand END INTERFACE REAL :: a(100) REAL :: b(10,10) ! set array a to the result returned by the function genrand; ! note that the left and right hand side are
Arrays Array inquiry intrinsics Array inquiry intrinsics Table 3-1 lists and briefly describes the inquiry intrinsic functions that return the properties of an array. For a full description of these intrinsics, see Chapter 11, “Intrinsic procedures,” on page 501. Table 3-1 Intrinsic Array inquiry intrinsic functions Description ALLOCATED Returns the allocation status of an allocatable array; see “Allocatable arrays” on page 64.
Arrays Array inquiry intrinsics 82 Chapter 3
4 Expressions and assignment This chapter describes expressions and assignment.
Expressions and assignment — Operands — Operators — Special forms of expression • Assignment, including the following topics: — Assignment statement — Pointer assignment — Masked array assignment NOTE 84 This chapter discusses intrinsic operators and assignment only. For information about user-defined operators and assignment, see “Defined operators” on page 185 and “Defined assignment” on page 187.
Expressions and assignment Expressions Expressions An expression is the specification of data and, possibly, a set of operations that enable the computer to evaluate the expression and produce a value. Because an expression results in a value, it has a type, kind, and shape. If an expression is of the character type, it also has a length parameter. The general form of an expression is: [operand1] operator operand2 operand1, operand2 are data objects or expressions that evaluate to data.
Expressions and assignment Expressions subscript, a section subscript with an extent for the upper bound, or a vector subscript. (Assumed-size arrays are discussed in “Assumed-size arrays” on page 65, and array sections in “Array sections” on page 68.) If two operands in an expression are arrays, they must have the same shape. If one operand is a scalar, it is treated as if it were an array of the same shape as the other operand, in which all elements have the value of the scalar.
Expressions and assignment Expressions Two operands joined by a binary operator can be of different numeric types or different kind type parameters. The type of the result is: • If the type and kind type parameters of the operands are the same, the result has the same type and kind type parameter. • If the type of the operands is the same but the kind type parameters differ, the result has the same type and the larger kind type parameter.
Expressions and assignment Expressions • Operands of logical and integer types may be combined with the arithmetic operators. The logical variable is treated as an integer of equivalent size, and the result of the operation is an integer value. When different lengths of operands are involved, the shorter is considered extended as a signed integer.
Expressions and assignment Expressions As an HP extension, the operands of a logical expression may be of type integer. Functions returning integers may appear in logical expressions, and functions returning logicals may appear in integer expressions. If the operands of a logical operation have different kind type parameters, the operand with the smaller parameter is converted to a value with the larger parameter before the operation is performed. The result has the larger kind type parameter.
Expressions and assignment Expressions j = 3 PRINT *, i .AND. j ! Output from the PRINT statement: 1 The next example shows the use of logical operators to perform bit-masking operations. INTEGER(2) mask2 INTEGER(4) mask4 DATA mask2/ -4 / DATA mask4/Z"ccc2"/ mask4 = mask4 .NEQV. mask2 !set mask4 to Z"ffff333e" mask2 = .NOT. mask4 !set mask2 to Z"ccc1" The next example makes a standard-conforming reference to a bit manipulation intrinsic: INTEGER :: mask = 65535 LOGICAL :: is_even = .FALSE.
Expressions and assignment Expressions Table 4-2 Operator precedence (Continued) Highest User defined unary operators . ** . * / . Unary + Unary - . + - . // . .EQ. .NE. .LT. .LE. .GT. .GE. == /= < <= > >= . .NOT. . .AND. . .OR. . .EQV. .NEQV. .XOR. Lowest User-defined binary operators Table 4-3 Examples of operator precedence Expression How evaluated Explanation a+b*c a + (b*c) * has a higher precedence than +.
Expressions and assignment Expressions The Standard allows the compiler to generate code that evaluates an expression by any sequence that produces a result mathematically equivalent to the sequence implied by the statement. This laxity permits code optimization, including (for example) the reordering of expressions and the promotion of common subexpressions.
Expressions and assignment Expressions ! a named integer constant coord(0.
Expressions and assignment Expressions • Values of named constants. Any entity declared with the PARAMETER attribute must be initialized with an initialization expression. • Kind parameter in a type specification statement. • The KIND dummy argument of a type conversion intrinsic function. • Initial values in type declaration statements. • Expressions in structure constructors in DATA statements. • Case values in CASE statements.
Expressions and assignment Expressions ! SUM( (/ i, 2 /) ) integer nor character type ! reference to a prohibited function For information about initializing arrays with an array constructor, see “Array constructors” on page 75. Specification expressions A specification expression has a scalar value, is of type integer, and can be evaluated on entry to the scoping unit in which it appears.
Expressions and assignment Expressions ❏ Size of the array ❏ Shape of the array The differences between specification expressions and initialization expressions are summarized in Table 4-4. Table 4-4 Initialization and specification expressions Initialization expression Specification expression Can be either scalar or array-valued. Must be scalar-valued. Can be of any type. Must be of type integer. Must be a constant expression.
Expressions and assignment Assignment Assignment An assignment operation defines a variable by giving it a value. In HP Fortran, there are four types of assignment: • Intrinsic assignment (also known as the assignment statement) • Pointer assignment • Masked-array assignment (also known as the WHERE construct) • Defined assignment The following sections describe the first three assignment types. The last—defined assignment—is defined by the programmer, using the INTERFACE statement.
Expressions and assignment Assignment Table 4-5 Conversion of variable=expression (Continued) Variable type Expression type Conversion Logical Logical LOGICAL(expression, KIND(variable)) Derived type Same derived type None As described in “Bitwise operators” on page 89, HP Fortran allows integer and logical operands to be used interchangeably. HP Fortran also allows logical expressions to be assigned to integer variables and integer expressions to logical variables.
Expressions and assignment Assignment icnt = icnt + 1 ! integer assignment circle1 = circle2 ! derived-type assignment area = pi * circle%radius**2 ! real assignment pixel(x,y) = boolx .AND.
Expressions and assignment Assignment If target-expression is a pointer already associated with a target, then pointer-object becomes associated with the target of target-expression. If target-expression is a pointer that is disassociated or undefined, then pointer-object inherits the disassociated or undefined status of target-expression. For information about pointer status, see “Pointer association status” on page 132. The following example, ptr_assign.
Expressions and assignment Assignment contents of t1 referenced through p1 through p2: 99 contents of t2(1) referenced through p1: 1 contents of t2 referenced through the array pointer p3: 1 2 3 4 5 contents of t2(2) referenced through p3 through p1: 2 p1 is disassociated. p2 is disassociated by pointer assignment. Masked array assignment In a masked array assignment, a logical expression—called a mask— controls the selection of array elements for assignment.
Expressions and assignment Assignment WHERE (a > b) a = b b = 0 ELSEWHERE b = a a = 0 END WHERE is evaluated as if it was specified as: mask = a > b WHERE (mask) a = b WHERE (mask) b = 0 WHERE (.NOT.mask) b = a WHERE (.NOT.mask) a = 0 Only assignment statements may appear in a WHERE block or an ELSEWHERE block. Within a WHERE construct, only the WHERE statement may be the target of a branch.
Expressions and assignment Assignment INTEGER :: num(:) CHARACTER :: letter(:) END SUBROUTINE convert END INTERFACE PRINT *, 'Numerical score:', test_score CALL convert(test_score, letter_grade) PRINT '(A,10A3)', ' Letter grade: ', letter_grade END PROGRAM main SUBROUTINE convert(num, letter) ! declare the dummy arguments as assumed-shape arrays INTEGER :: num(:) CHARACTER :: letter(:) ! use the WHERE statements to figure the letter grade ! equivalents WHERE (num >= 90) letter = 'A' WHERE (num >= 80 .AND.
Expressions and assignment Assignment 104 Chapter 4
5 Data types and data objects This chapter describes how data is represented and stored in HP Fortran programs, and includes the following topics: • Intrinsic data types Chapter 5 105
Data types and data objects • Derived types • Pointers • Unaligned data Arrays are described in Chapter 3, “Arrays,” on page 55. The RECORD and STRUCTURE statements—HP Fortran extensions—are fully described in Chapter 10, “HP Fortran Statements.” Intrinsics procedures are described in Chapter 11, “Intrinsic procedures,” on page 501.
Data types and data objects Intrinsic data types Intrinsic data types The intrinsic data types are the data types predefined by the HP Fortran language, in contrast with derived types, which are user-defined (see “Derived types” on page 123).
Data types and data objects Intrinsic data types Table 5-1 Intrinsic data types (Continued) INTEGER(1) -128 to 127 Not applicable 1 1 INTEGER(2) -215 to 215-1 Not applicable 2 2 INTEGER(4) (default) -231 to 231-1 Not applicable 4 4 INTEGER(8) -263 to 263-1 Not applicable 8 8 REAL(4) (default) -3.402823x1038 to 4 4 8 8 16 8 8 8 8 4 -1.175495x10-38 0.0 approximately 6 +1.175495x10-38 to +3.402823x1038 REAL(8) -1.797693x10+308 to -2.225073x10-308 0.0 approximately 15 +2.
Data types and data objects Intrinsic data types Table 5-1 Intrinsic data types (Continued) COMPLEX(8) Same as for REAL(8) Same as for REAL(8) 16 8 DOUBLE COMPLEX Same as for REAL(8) Same as for REAL(8) 16 8 CHARACTER(1) (default) ASCII character set 1 1 LOGICAL(1) .TRUE. and .FALSE. Not applicable 1 1 LOGICAL(2) .TRUE. and .FALSE. Not applicable 2 2 LOGICAL(4) (default) .TRUE. and .FALSE. 4 4 LOGICAL(8) .TRUE. and .FALSE.
Data types and data objects Intrinsic data types or +autodbl4 is used. Refer to the HP Fortran Programmer’s Guide for information about using these options to increase sizes. Refer to Chapter 10, “HP Fortran Statements” for information about each type-spec. If type-spec is present, it overrides the implicit-typing rules; see “Implicit typing” on page 113.
Data types and data objects Intrinsic data types wherearray-spec is described in “Array declarations” on page 59; char-len is described with the CHARACTER statement in Chapter 10; and init-expr is described in “Initialization expressions” on page 93. If you include init-expr in entity, you must also include the double colon (::) separator. As an extension to the Standard, HP Fortran permits the use of slashes to delimit init-expr.
Data types and data objects Intrinsic data types Table 5-2 Attributes in type declaration statement (Continued) Attribute VOLATILE Description Provides for data sharing between asynchronous processes (extension). The following are examples of type declaration statements: ! Default, KIND=4, integers i j k. INTEGER i, j, k ! Using optional separator. INTEGER :: i,j,k ! An 8-byte initialized integer. INTEGER(KIND=8) :: i=2**40 ! 10 element array of 8-byte integers.
Data types and data objects Intrinsic data types SUBROUTINE x(c) CHARACTER*(*) :: c ! c assumes the length of the actual argument. END ! A single entity, of derived type node. TYPE(node):: list_element ! Declaration and initialization of a user-defined variable TYPE(coord) :: origin = coord(0.0,0.0) Implicit typing In Fortran 90, an entity may be used without having been declared in a type declaration statement. The compiler determines the type of the entity by applying implicit typing rules.
Data types and data objects Intrinsic data types Constants Constants can be either literal or named. A literal constant is a sequence of characters that represents a value. A named constant is a variable that has been initialized and has the PARAMETER attribute. This section describes the formats of literal constants for each of the intrinsic data types. For more information about named constants and the PARAMETER statement and attribute, see Chapter 10.
Data types and data objects Intrinsic data types where leading-letter is the single character B, O, or Z, indicating binary, octal, or hexadecimal base, respectively. digit-string must consist of digits that can represent the base, namely: • Binary: 0 and 1. • Octal: 0 through 7. • Hexadecimal: 0 through 9, and A through F. The letters can be uppercase or lowercase.
Data types and data objects Intrinsic data types 5HABCbb !bb = two space characters, making the length equal to 5 Typeless constants HP Fortran extends the uses of binary, octal, and hexadecimal constants (BOZ) beyond those prescribed in the Fortran 90 Standard; see “BOZ constants” on page 114. HP Fortran allows BOZ constants to be used as typeless constants wherever an intrinsic literal constant of any numeric or logical type is permitted.
Data types and data objects Intrinsic data types • The intrinsic functions INT, LOGICAL, REAL, DBLE, DREAL, CMPLX, and DCMPLX are available to force a BOZ constant to a specific type.
Data types and data objects Intrinsic data types Following are examples of real constants: 3.4E-4 !0.00034 42.E2 !4200 1.234_8 !1.234 with approximately 15 digits precision -2.53Q-300 !-2.
Data types and data objects Intrinsic data types For compatibility with C-language syntax, HP Fortran allows the backslash character (\) as an escape character in character strings. You must use the +escape option to enable this feature. When this option is enabled, the compiler ignores the backslash character and either substitutes an alternative value for the character following, or interprets the character as a quoted value. For example: 'ISN\'T' is a valid string when compiled with the +escape option.
Data types and data objects Intrinsic data types In standard-conforming programs, a logical value of .TRUE. is represented by 1, and .FALSE. is represented by 0. In nonstandard-conforming programs involving arithmetic operators with logical operands, a logical variable may be assigned a value other than 0 or 1. In this case, any nonzero value is .TRUE., and only the value zero is .FALSE. Character substrings A character substring is a contiguous subset of a character string.
Data types and data objects Intrinsic data types For information about substring operations on an array of strings, see “Array sections” on page 68. Character strings as automatic data objects An automatic data object can be either an automatic array (see “Explicit-shape arrays” on page 59) or a character string that is local to a subprogram and whose size is nonconstant. The size of a character string is determined when the subprogram is called and can vary from call to call.
Data types and data objects Intrinsic data types Here are the command lines to compile and execute the program, along with the output from a sample run: $ f90 swap_names.f90 $ a.
Data types and data objects Derived types Derived types Derived types are user-defined types that are constructed from entities of intrinsic data types (see “Intrinsic data types” on page 107) or entities of previously defined derived types. For example, the following is a definition of a derived type for manipulating coordinates consisting of two real numbers: TYPE coord REAL :: x,y END TYPE coord x and y are the components of the derived type coord.
Data types and data objects Derived types TYPE [[, access-spec] ::] type-name [private-sequence-statement] ... comp-definition-statement [comp-definition-statement] ... END TYPE [type-name] access-spec is one of: • PRIVATE • PUBLIC access-spec is allowed only if the definition appears within a module. For more information about modules, see “Modules” on page 190. The PRIVATE and PUBLIC attributes are described in Chapter 10. type-name is the name of the type being defined.
Data types and data objects Derived types comp-name [(array-spec)][*char-len] where array-spec is an array specification, as described in “Array declarations” on page 59; and char-len is used when comp-name is of type character to specify its length. Sequence derived type As shown in “Defining a derived type” on page 123, the SEQUENCE statement may appear in the definition of a derived type.
Data types and data objects Derived types If parent-name and comp-name are arrays, each can be followed by a section-subscript-list enclosed in parentheses. See “Array sections” on page 68 for information about the syntax of section-subscript-list. The Standard imposes certain restrictions on structure component references that are array-valued, as described in “Array-valued structure component references” on page 72.
Data types and data objects Derived types • If a component is an array, an array constructor must appear in expression-list that satisfies the array. For more information about array constructors, see “Array constructors” on page 75. • If a component is a pointer, the corresponding expression in expression-list must evaluate to an allowable target. Alignment of derived-type objects Derived type objects have the same alignment as the component that has the most restrictive alignment requirement.
Data types and data objects Derived types A derived-type example The example below, traffic.f90, illustrates how to define a derived type, declare a variable of the type, specify a value for the variable using the structure constructor, pass the variable as an argument to another procedure, and reference a structure component. The derived type is defined in a module so that it can be made accessible by use association. For more information about modules and the USE statement, see “Modules” on page 190.
Data types and data objects Derived types PRINT *,’Heavy commute on rte.’, route(choice)%rte_num ELSE PRINT *,’Easy commute on rte.’, route(choice)%rte_num END IF END PROGRAM traffic LOGICAL FUNCTION busy(when) ! This function accepts a derived-type argument whose definition ! is defined in the module hours_def, made accessible here by ! use association. It returns .TRUE. or .FALSE., depending on ! on the value of the user-selected component of the argument.
Data types and data objects Derived types 1 When do you want to commute: 1. Morning 2. Evening 1 Heavy commute on rte.
Data types and data objects Pointers Pointers Pointers in Fortran 90 are more strongly typed than in other languages. While it is true that the Fortran 90 pointer holds the address of another variable (the target), it also holds additional information about the target. For this reason, declaring a pointer requires not only the POINTER attribute but also the type, kind parameter, and (if its target is an array) rank of the target it can point to.
Data types and data objects Pointers • “Pointer assignment” on page 99 for information about associating a pointer with a target by means of pointer assignment. • Chapter 10, “HP Fortran Statements” for a full description of the ALLOCATE and DEALLOCATE statements as well as the POINTER and TARGET attributes. The following section discusses pointer status and includes an example program. Pointer association status Certain pointer operations can only be performed depending on the status of the pointer.
Data types and data objects Pointers A pointer example The example below, ptr_sts.f90, illustrates different pointer operations, including calls to the ASSOCIATED intrinsic to determine pointer status. Example 5-4 ptr_sts.f90 PROGRAM main ! This program performs simple pointer operations, including ! calls to the ASSOCIATED intrinsic to determine status. ! ! Declare pointer as a deferred shape array with POINTER ! attribute. REAL, POINTER :: ptr(:) REAL, TARGET :: tgt(2) = (/ -2.2, -1.
Data types and data objects Pointers ! is explicit to the caller. Internal procedures have an ! explicit interface. If this were an external procedure, ! its interface would have to be declared in an interface ! block to be explicit. SUBROUTINE get_ptr_sts IF (ASSOCIATED(ptr, tgt)) THEN PRINT *, " Pointer is associated with target." ELSE PRINT *, " Pointer is disassociated from target.
Data types and data objects Resolving issues with unaligned data Resolving issues with unaligned data The following suggestions will aid with issues regarding unaligned data: For Itanium—based applications As a quick fix, add the following call to the main program: call allow_unaligned_data_access( ) Then, link in an additional library that fixes these alignment issues at runtime: -lunalign Longer term, try compiling with the following flag: +allow_unaligned An example would be: PROGRAM bs30 INTEGER*2 i2
Data types and data objects Resolving issues with unaligned data /opt/fortran90/bin/f90 foo.f -lunalign NOTE Nothing new is required to use the aforementioned -lunalign runtime fix approach; however, you do need the latest patch for the +allow_unaligned compile flag.
6 Execution control The normal flow of execution in a Fortran 90 program is sequential. Statements execute in the order of their appearance in the program. However, you can alter this flow.
Execution control • Control constructs and statement blocks • Flow control statements For a full description of each Fortran 90 control statement, see Chapter 10, “HP Fortran Statements.” For information about the WHERE construct, see “Masked array assignment” on page 101.
Execution control Control constructs and statement blocks Control constructs and statement blocks A control construct consists of a statement block whose execution logic is defined by one of the following control statements: • CASE statement • DO statement • IF statement A statement block is a sequence of statements delimited by a control statements and its corresponding terminal statement. A statement block consists of zero or more statements and can include nested control constructs.
Execution control Control constructs and statement blocks [construct-name :] SELECT CASE ( case-expr ) [CASE ( case-selector ) [ construct-name ] statement-block ] ... [CASE DEFAULT [construct-name] statement-block ] END SELECT [ construct-name] Notes on syntax case-selector is one of the following: • case-value • low : • : high • low : high case-selectors must be mutually exclusive and must agree in type with case-expr.
Execution control Control constructs and statement blocks Example The following CASE construct prints an error message according to the value of ios_err: INTEGER :: ios_err ... SELECT CASE (ios_err) CASE (:900) PRINT *, ”Unknown error” CASE (913) PRINT *, ”Out of free space” CASE (963:971) PRINT *, ”Format error” CASE (1100:) PRINT *, ”ISAM error” CASE DEFAULT PRINT *, ”Miscellaneous Error” END SELECT DO construct The DO construct repeatedly executes a statement block.
Execution control Control constructs and statement blocks A third form, combining elements of the other two, is also supported: [construct-name :] DO label index = init, limit [, step] Execution logic The following execution steps apply to all three syntactic forms, except as noted: 1. The loop becomes active, and index is set to init. 2. The iteration count is determined by the following expression: MAX( INT ( limit - init + step ) / step, 0 ) step is optional, with the default value of 1.
Execution control Control constructs and statement blocks END IF END DO END DO The following example uses the older syntactic form.
Execution control Control constructs and statement blocks money = 1000 invest = money interest = .04 years = 0 DO WHILE (money years = years money = money END DO PRINT *, ”Years < 2*invest) ! doubled our money? + 1 + (interest * money) =”, years Infinite DO loop The DO statement for the infinite DO loop contains no loop control logic.
Execution control Control constructs and statement blocks IF construct The IF construct selects between alternate paths of execution. The executing path is determined by testing logical expressions. At most, one statement block within the IF construct executes. Syntax [construct-name :] IF (logical-expression1) THEN statement-block1 [ELSE IF (logical-expression2) THEN [construct-name] statement-block2 ] . . . [ELSE [construct-name] statement-block3] END IF [construct-name] Execution logic 1.
Execution control Flow control statements Flow control statements Flow control statements alter the normal flow of program execution or the execution logic of a control construct. For example, the GO TO statement can be used to transfer control to another statement within a program unit, and the EXIT statement can terminate execution of a DO construct.
Execution control Flow control statements triangular_num = triangular_num + i 10 CONTINUE PRINT *, triangular_num CYCLE statement The CYCLE statement interrupts execution of the current iteration of a DO loop. Syntax CYCLE [ do-construct-name ] Execution logic 1. The current iteration of the enclosing DO loop terminates. Any statements following the CYCLE statement do not execute. 2. If do-construct-name is specified, the iteration count for the named DO loop decrements.
Execution control Flow control statements Syntax EXIT [ do-construct-name ] Execution logic If do-construct-name is specified, execution terminates for all DO loops that are within range, up to and including the DO loop with that name. If no name is specified, execution terminates for the immediately enclosing DO loop.
Execution control Flow control statements . GOTO int_label . . . 20 ... Computed GO TO statement The computed GO TO statement transfers control to one of several labeled statements, as determined by the value of an arithmetic expression. Syntax GO TO ( label-list ) [ , ] integer-expression Execution logic 1. integer-expression is evaluated. 2. The resulting integer value (the index) specifies the ordinal position of the label that is selected from label-list. 3.
Execution control Flow control statements GO TO label Execution logic Control transfers to the statement at label. Example Older, “dusty-deck” Fortran programs often combine the GO TO statement with the logical IF statement to form a kind of leap-frog logic, as in the following: IF ( num1 /= num2) GO TO 10 PRINT *, ”num1 and num2 are equal.” GO TO 30 10 IF ( num1 > num2 ) GO TO 20 PRINT *, ”num1 is smaller than num2.” GO TO 30 20 PRINT *, ”num1 is greater than num2.
Execution control Flow control statements • Any END statement • Any IF statement Syntax IF ( logical-expression ) executable-statement Execution logic 1. logical-expression is evaluated. 2. If it evaluates to true, executable-statement executes. 3. The normal flow of execution resumes with the first executable statement following the IF statement. (If executable-statement is an unconditional GO TO statement, control resumes with the statement specified by the GO TO statement.
Execution control Flow control statements To resume execution, execute a kill -15 pid command. pid is the unique process identification number of the suspended program. The kill command can be issued at any terminal at which the user is logged in. Example PAUSE 999 STOP statement The STOP statement terminates program execution. Syntax STOP [ stop-code ] where stop-code is a character constant, a named constant, or a list of up to 5 digits. Execution logic Program terminates execution.
7 Program units and procedures This chapter describes the internal structure of each type of program unit, how it is used, and how information is communicated between program units and shared by them.
Program units and procedures • Terminology and concepts • Main program • External procedures • Internal procedures • Statement functions • Arguments • Procedure interface • Modules • Block data program unit For detailed information about individual statements that can be used to build program units and procedures, see Chapter 10, “HP Fortran Statements.
Program units and procedures Terminology and concepts Terminology and concepts The following sections define the terms and explain the concepts that are mentioned throughout this chapter.
Program units and procedures Terminology and concepts Procedures A procedure is a subroutine or function that contains a sequence of statements and that may be invoked during program execution. Depending on where and how it is used, a procedure can be one of the following: • Intrinsic procedures are defined by the language and are available for use without any declaration or definition. Intrinsic procedures implement common computations that are important to scientific and engineering applications.
Program units and procedures Terminology and concepts • Host association applies to nested scoping units, where the outer scoping unit (for example, an external procedure) plays host to the inner scoping unit (for example, an internal procedure). Host association allows the host and its nested scoping units to share data. For information about internal procedures, see “Internal procedures” on page 167.
Program units and procedures Main program Main program A main program is a program unit. There must be exactly one main program in an executable program. Execution always begins with the main program. The main program can determine the overall design and structure of the complete program and often performs various computations by referencing procedures. A program may consist of the main program alone, in which case all the program logic is contained within it.
Program units and procedures Main program internal-procedure-part takes the form: CONTAINS [internal-procedure]... where internal-procedure is one or more internal procedures; see “Internal procedures” on page 167.
Program units and procedures Main program Table 7-2 DO construct Executable statements (Continued) NULLIFY The only required component of a main program unit is the END statement.
Program units and procedures External procedures External procedures External procedures are implemented as either functions or subroutines. The major difference between the two is that a function subprogram returns a value and can therefore appear as an operand in an expression.
Program units and procedures External procedures specification-part is zero or more of the statements listed in Table 7-1 as well as the AUTOMATIC statement. execution-part is zero or more of the statements listed in Table 7-2 as well as the following statements: • ENTRY statement • RETURN statement internal-procedure-part takes the form: CONTAINS [internal-procedure]...internal-procedure is the definition of an internal procedure; see “Internal procedures” on page 167.
Program units and procedures External procedures [keyword =] actual-argument keyword is the name of a dummy argument that appears in the SUBROUTINE statement. For more information about keyword, see “Keyword option” on page 175. actual-argument is one of: • Expression, including a variable name • Procedure name • Alternate return For detailed information about arguments, see “Arguments” on page 171.
Program units and procedures External procedures Recursive reference A procedure that directly or indirectly invokes itself is recursive. Such a procedure must have the word RECURSIVE added to the FUNCTION or SUBROUTINE statement. If a function calls itself directly, both RECURSIVE and a RESULT clause must be specified in the FUNCTION statement, making its interface explicit. The following is a recursive function: RECURSIVE FUNCTION factorial (n) RESULT(r) INTEGER :: n, r IF (n.ne.
Program units and procedures External procedures As a compatibility extension, HP Fortran allows the ampersand (&) as a prefix character instead of the asterisk, but only in fixed source form. Alternate returns cannot be optional, and the associated actual argument cannot have keywords. For detailed information about the syntax of the alternate return argument, refer to the descriptions of the CALL and RETURN statements in Chapter 10, “HP Fortran Statements.” The following example, alt_return.
Program units and procedures External procedures Here are the command lines to compile and execute the program, along with the output from a sample run: $ f90 alt_return.f90 $ a.out Line 25 in subr Default returning point Line 30 in subr Line 10 in main Line 35 in subr Line 15 in main Alternate entry points When a procedure is referenced, execution normally begins with the first executable statement in the procedure.
Program units and procedures Internal procedures Internal procedures An internal procedure is similar to an external procedure except that: • It must be defined within a hosting program unit—a main, external, or module program unit—following the CONTAINS statement. • It can be referenced by the host only. • It can access other entities by host association within the host. • It cannot have an ENTRY statement. • It cannot be passed as an argument. • It cannot contain an internal procedure.
Program units and procedures Internal procedures END PROGRAM main ! print_avg is an external subprogram SUBROUTINE print_avg(x) REAL :: x(:) ! an assumed-shape array ! reference the internal function get_avg PRINT *, get_avg(x) CONTAINS ! start of internal procedure part REAL FUNCTION get_avg(a) ! get_avg is an internal procedure ! The interface of an internal procedure is explicit within ! the hosting unit, so this function may declare a as an ! assumed-shape array.
Program units and procedures Statement functions Statement functions If an evaluation of a function with a scalar value can be expressed in just one Fortran assignment statement, such a definition can be included in the specification part of a main program unit or subprogram. This definition is known as a statement function. It is local to the scope in which it is defined. The syntax is: function-name (dummy-argument-list) = scalar-expression All dummy arguments must be scalars.
Program units and procedures Statement functions ! Note that the dummy arguments must be scalar, so in order ! to find the average of the elements of the array, we must ! pass each element as a separate argument get_avg(x1, x2, x3) = (x1 + x2 + x3) / 3 ! reference the statement function get_avg PRINT *, get_avg(x(1), x(2), x(3)) END SUBROUTINE print_avg Here are the command lines to compile and execute the program, along with the output from a sample run: $ f90 stmt_func.f90 $ a.out 4.
Program units and procedures Arguments Arguments Arguments data to be passed during a procedure call. Arguments are of two sorts: dummy arguments and actual arguments. Dummy arguments are specified in the argument list in a procedure definition. They define the number, type, kind, and rank of the actual arguments.
Program units and procedures Arguments • Arrays • Derived types • Pointers • Procedure names Scalar dummy argument If the dummy argument is a scalar, the corresponding actual argument must be a scalar or a scalar expression, of the same kind and type. If the dummy argument is a character variable and has assumed length, it inherits the length of the actual argument.
Program units and procedures Arguments ... d(2,3,2) <=> a(3,2) When an actual argument and the associated dummy argument are default character arrays, they may be of unequal character length. If this is the case, then the first character of the dummy and actual arguments are matched, and the successive characters—rather than array elements—are matched. The next example illustrates character sequence association.
Program units and procedures Arguments Pointer dummy argument If the dummy argument has the POINTER attribute, the actual argument must also have the POINTER attribute. Furthermore, they must match in kind, type, and rank. If the dummy argument does not have the POINTER attribute but the actual argument is a pointer, the argument association behaves as if the pointer actual argument were replaced by its target at the time of the procedure reference.
Program units and procedures Arguments ! intrinsic procedure passed as trig_func. WRITE(6, 100) i,” degrees “, trig_func(i*pi/180) END DO 100 FORMAT (I4, A9, F12.8) END SUBROUTINE call_int_arg Here are the command lines to compile and execute the program, along with the output from a sample run: $ f90 intrinsic_arg.f90 $ a.out 0 degrees 0.00000000 45 degrees 0.70710675 90 degrees 1.00000000 135 degrees 0.70710686 180 degrees 0.00000015 225 degrees -0.70710665 270 degrees -1.00000000 315 degrees -0.
Program units and procedures Arguments As an example of how to use the keyword option, consider the SUM intrinsic function. As described in “SUM(ARRAY, DIM, MASK)” on page 628, this intrinsic has three arguments: array, dim, and mask, in that order; dim and mask are optional arguments. The following are therefore valid references to SUM: SUM(a,2) SUM(a,mask=a.gt.0) SUM(dim=2,array=a) The following is an invalid reference—the mask keyword must be specified: SUM(a,dim=2,a.gt.
Program units and procedures Arguments ! use PRESENT intrinsic to see if i2 has an actual ! argument associated with it IF (PRESENT(i2)) THEN add_or_inc = i1 + i2 ! add both arguments ELSE add_or_inc = i1 + 1 ! increment required argument END IF END FUNCTION add_or_inc END PROGRAM main Here are the command lines to compile and execute the program, along with the output from a sample run: $ f90 optional_arg.f90 $ a.
Program units and procedures Arguments In the following code, the data object a is available to the subroutine as a consequence of argument association and host association. The direct reference to a in the subroutine is illegal. PROGRAM p CALL s (a,b) CONTAINS SUBROUTINE s (c,d) c = 22.01 ! valid definition of a through the dummy ! argument d = 3.0*a ! direct reference to a is ILLEGAL ...
Program units and procedures Arguments • %VAL(arg) specifies that the value of arg—rather than its address—is to be passed to the referenced procedure. arg can be a constant variable, an array element, or a derived-type component. • %REF(arg) specifies that the address of arg is to be passed to the referenced procedure. Because this is how HP Fortran normally passes all noncharacter arguments, %REF is useful only when arg is of type character.
Program units and procedures Arguments Here are the command lines to compile and link both files, and to execute the program, along with the output from a sample run: $ cc -Aa -c get_args.c $ f90 pass_args.f90 get_args.o $ a.out First argument: 20 Second argument: 3.400000 Third argument: Hi! Fourth argument: 12 For additional information about multi-language programming, refer to the HP Fortran Programmer’s Guide.
Program units and procedures Procedure interface Procedure interface A procedure interface is the information specified in a procedure reference, including the name of the procedure, the arguments, and (if the procedure is a function) the result. If the interface is explicit, all of the characteristics of the arguments and the result—type, kind, attributes, and number—are defined within the scope of the reference.
Program units and procedures Procedure interface Interface blocks An interface block is used to provide an explicit interface for external procedures or to define a generic procedure. An interface block may appear in any program unit, except a block data program unit. It is specified in the specification part of the program unit. The syntax for an interface block is: INTERFACE [generic-spec] [interface-body]...
Program units and procedures Procedure interface is a comma-separated list of names of module procedures that have generic-spec as a generic interface. Each module-procedure name must be accessible either by use association or—if this interface block is in a module that defines the module procedure—by host association. If the MODULE PROCEDURE statement is present, then generic-spec must also be present. The following example, proc_interface.
Program units and procedures Procedure interface A generic procedure is defined in an interface block that specifies its name and the interfaces of the specific procedures; see “Interface blocks” on page 182. The specific procedures within the interface block must all be subroutines or all functions. The interface for each procedure must differ from the others in one or more of the following ways: • The number of dummy arguments must differ.
Program units and procedures Procedure interface Defined operators The OPERATOR clause can be used with the INTERFACE statement either to define a new user-defined operator or to extend—or overload—the behavior of an already defined or intrinsic operator. This second use is similar to defining a generic procedure (see “Generic procedures” on page 183). The re-defined operator becomes associated with a generic operator.
Program units and procedures Procedure interface ! operands, as well as the derived types ! Define a derived type for the co-ordinates of a point ! in a graph TYPE coord_pt INTEGER :: x, y END TYPE coord_pt ! define a derived type for the co-ordinates of a rectangle TYPE rect_coords TYPE(coord_pt) :: p1, p2 END TYPE rect_coords ! Interface block to define the logical operator .inrect. ! Evaluates to .TRUE. if the point operand lies inside ! the rectangle operand INTERFACE OPERATOR (.inrect.
Program units and procedures Procedure interface PRINT *, 'The point lies inside the rectangle.' ELSE PRINT *, 'The point lies outside the rectangle.' END IF END PROGRAM main Here are the command lines to compile and execute the program, along with the output from a sample run: $ f90 def_op.f90 $ a.out Enter two co-ordinates (integers) in a graph: 4,8 The point lies inside the rectangle.
Program units and procedures Procedure interface TYPE raw_data REAL :: x(100) ! values to be averaged INTEGER :: n ! number of values assigned to x END TYPE raw_data ! output data TYPE stats_data REAL :: sum, max, min, avg END TYPE stats_data ! statistical results ! interface block to extend the assignment operator INTERFACE ASSIGNMENT (=) MODULE PROCEDURE do_stats END INTERFACE CONTAINS SUBROUTINE do_stats(lside, rside) ! define the operations that are performed when ! rside is assigned (=) to lside TYPE
Program units and procedures Procedure interface PRINT *, 'Minimum =', user_stats%min PRINT *, 'Sum =', user_stats%sum PRINT *, 'Average =', user_stats%avg END PROGRAM main SUBROUTINE get_data(data) ! this subroutine stores user-input values and the number ! of values stored in data ! make the definition of raw_data accessible USE def_assign_stats TYPE (raw_data) :: data ! the argument REAL :: val INTEGER :: i ! get user input DO i = 1, 100 PRINT *, 'Enter a positive real (negative to quit):' READ *, val IF
Program units and procedures Modules Modules A module is a nonexecutable program unit that contains—usually related—definitions and declarations that may be accessed by use association. Typically, modules are used for: • Defining and declaring derived types • Defining and declaring global data areas • Defining operators • Creating subprogram libraries The definitions within a module are made accessible to other program units through use association.
Program units and procedures Modules is zero or more of the statements listed in Table 7-1 with the exception of the FORMAT statement. Also, specification-part must not contain statement function definitions or automatic objects. (Specifying the SAVE attribute within a module is unnecessary in HP Fortran as entities declared within a module retain their values by default.
Program units and procedures Modules • Generic names • Namelist groups USE statement The USE statement provides access to module entities within the using program unit—that is, the program unit in which the statement is specified. The USE statement specifies the name of the module that the program unit wants to access. The information in the specified module is made accessible to the program unit by use association. The USE statement must appear at the head of the specification part of a program unit.
Program units and procedures Modules The renaming feature can be used to resolve name conflicts when more than one module contains an entity with the same name. Consider a program unit that has access by use association to two modules: mod_defs1 mod_defs2. The names of the entities in mod_defs1 are a, b, and c; and the names of the entities in mod_defs2 are b, c, and d.
Program units and procedures Modules The purpose of precision is to communicate a kind type parameter to the other program units in the program, for the sake of precision portability. The second module—linear_equation_solver—contains three module procedures, the first of which, solve_linear_equations, uses the other two; solve_linear_equations is itself invoked by the main program. Stated algebraically, the equations that main.
Program units and procedures Modules Example 7-12 precision.f90 MODULE precision ! The named constant adequate is a kind number of a real ! representation with at least 10 digits of precision and 99 ! digits range that normally results in 64-bit arithmetic. ! This constant ensures the same level of precision ! regardless of whether the program ! of whether the program is compiled on a 32-bit or 64-bit ! single-precision machine.
Program units and procedures Modules x = 0.
Program units and procedures Modules END DO END SUBROUTINE back_substitution END MODULE linear_equation_solver Here are the command lines to compile and execute the program, along with the output from a sample run: $ f90 precision.f90 lin_eq_slv.f90 main.f90 $ a.out The solution: 1.0 2.0 3.0 The order in which the files appear on the f90 command line is significant: files that contain modules must be compiled before files containing the program units that use the modules.
Program units and procedures Block data program unit Block data program unit A block data program unit initializes data values in common blocks. The syntax of a block data program unit is: BLOCK DATA [block-data-name] [specification-part] END [BLOCK DATA [block-data-name]] block-data-name is the name of the block data program unit. Note that the name is optional. If omitted, no more than one unnamed block data program unit may appear in an executable program.
Program units and procedures Block data program unit The block data program unit can initialize more than one common block. However, a common block can be initialized in only one block data program unit. It is not necessary to initialize every object within the common block, but the common block must be completely specified. As an extension, HP Fortran allows the initialization of objects in blank—or unnamed—common.
Program units and procedures Block data program unit 200 Chapter 7
8 I/O and file handling This chapter describes input/output and file handling as supported by HP Fortran.
I/O and file handling • Files • Connecting a file to a unit • File access methods • Nonadvancing I/O • I/O statements • Syntax of I/O statements • Binary I/O conversions • ASA carriage control • Example programs 202 Chapter 8
I/O and file handling Records Records The record is the basic unit of Fortran 90 I/O operations. It consists of either characters or binary values, depending upon whether the record is formatted or unformatted. The following sections describe both formatted and unformatted records, plus the special case of the end-of-file record. Note that nonadvancing I/O makes it possible to read and write partial records. For more information, see “Nonadvancing I/O” on page 216.
I/O and file handling Files Files A file is a collection of data, organized as a sequence of logical records. Records in a file must be either all formatted or all unformatted, except for the end-of-file record. The following sections describe the two types of files, external files and internal files. External files An external file is stored on disk, magnetic tape, or some other peripheral device. External files can be accessed sequentially or directly as described in “File access methods” on page 209.
I/O and file handling Files • An integer or real array (HP Fortran extension) • Any of the above that is either a field of a structure or a component of a derived type Note, however, that a section of a character array with a vector subscript cannot be used as an internal file. Accessing records in an internal file is analogous to accessing them in a formatted sequential file; see “Formatted I/O” on page 209. For an example program that uses an internal file, see “Internal file” on page 228.
I/O and file handling Connecting a file to a unit Connecting a file to a unit Before a program can perform any I/O operations on an external file, it must establish a logical connection between the file and a unit number. Once the connection is established, the program can reference the file by specifying the associated unit number (a nonnegative integer expression).
I/O and file handling Connecting a file to a unit OPEN (9, FILE='new_file') ... ! process file ... ! terminate connection CLOSE (9) Performing I/O on internal files An internal file is not connected to a unit number and therefore does not require an OPEN statement. It is referenced as a character variable. In the following example, the WRITE statement transfers the data from char_var to the internal file int_file, using list-directed formatting.
I/O and file handling Connecting a file to a unit Automatically opened unit numbers Unit numbers that have not been associated with a file by an OPEN statement can be automatically opened using the READ or WRITE statement. When a file is automatically opened, a string is created of the form: ftnXX where XX is replaced by the unit number in the range 01 to 99. If you have made an environment variable assignment of the form ftnXX = path, the file named in path is opened.
I/O and file handling File access methods File access methods HP Fortran allows both sequential access and direct access. You specify the access method with the OPEN statement when you connect the file to a unit number. The following example opens the file new_data for direct access: OPEN(40, ACCESS='DIRECT', RECL=128, FILE='new_data') If you do not specify an access method, the file is opened for sequential access. The following sections describe both sequential and direct methods.
I/O and file handling File access methods List-directed I/O List-directed I/O is similar to formatted I/O in that data undergoes a format conversion when it is transferred but without the use of a format specification to control formatting. Instead, data is formatted according to its data type. List-directed I/O is typically used when reading from standard input and writing to standard output.
I/O and file handling File access methods Table 8-2 outlines the rules for the format of list-directed input data. Table 8-2 Format of list-directed input data Data type Input format rules Integer Conforms to the same rules as integer constants. Real and double precision Any valid form for real and double precision. In addition, the exponent can be indicated by a signed integer constant (the Q, D, or E can be omitted), and the decimal point can be omitted for those values with no fractional part.
I/O and file handling File access methods Table 8-3 summarizes the rules governing the display of each data type. Table 8-3 Format of list-directed output data Data type Output format rules Integer Output as an integer constant. Real and Double Precision Output with or without an exponent, depending on the magnitude. Also, output with field width and decimal places appropriate to maintain the precision of the data as closely as possible.
I/O and file handling File access methods Namelist-directed I/O Namelist-directed I/O enables you to transfer a group of variables by referencing the name of the group, using the NML= specifier in the data transfer statement. The NAMELIST statement specifies the variables in the group and gives the group a name. Like list-directed I/O, namelist-directed I/O does not use a format specification when formatting data but uses default formats, as determined by the data types.
I/O and file handling File access methods b&NLbIVAR = 4 3 2 1bCVAR ='', 'QRS', '', '', 'XXX', 'ABX'bLVAR = TbRVAR = 5.75000E+25b/ The following sections describe the format of namelist-directed input and output. See “NAMELIST” on page 403 for detailed information about the NAMELIST statement. Input A namelist-directed input record takes the following form: 1. An ampersand character (&) immediately followed by a namelist group name. The group name must have been previously defined by a NAMELIST statement.
I/O and file handling File access methods • As in list-directed output, character values are output without delimiters by default, making them unsuitable for namelist-directed input. However, you can use the DELIM= specifier in the OPEN statement to specify the single or double quotation mark as the delimiter to use for character constants. • Only character and complex values may be split between two records. Unformatted I/O Unformatted I/O does not perform format conversion on data it transfers.
I/O and file handling Nonadvancing I/O Nonadvancing I/O By default, a data transfer leaves the file positioned after the last record read or written. This type of I/O is called advancing. Fortran 90 also allows nonadvancing I/O, which positions the file just after the last character read or written, without advancing to the next record. It is character-oriented and can be used only with external files opened for sequential access. It cannot be used with list-directed or namelist-directed I/O.
I/O and file handling I/O statements I/O statements HP Fortran supports three types of I/O statements: • Data transfer statements (see Table 8-4) • File positioning statements (see Table 8-5) • Auxiliary statements (see Table 8-6) For detailed information about all I/O statements, refer to Chapter 10, “HP Fortran statements,” on page 267. Table 8-4 Data transfer statements Statement Use ACCEPT Inputs data from the preconnected default input device (standard input) (extension).
I/O and file handling I/O statements ACCEPT and TYPE are also available as compatibility extensions for reading from standard input and writing to standard output. However, if you wish your program to be portable, you should use the READ and PRINT statements instead of the ACCEPT and TYPE statements. Table 8-5 File positioning statements Statement Use BACKSPACE Moves the file pointer of the connected sequential file to the start of the previous record.
I/O and file handling Syntax of I/O statements Syntax of I/O statements The general syntactic form of file-positioning and auxiliary statements is: statement-name (io-specifier-list) where statement-name is one of the statements listed in Table 8-5 or Table 8-6. io-specifier-list is a comma-separated list of I/O specifiers that control the statement’s operation.
I/O and file handling Syntax of I/O statements and TYPE statements are not listed in the table as they are nonstandard. All I/O specifiers and statements are fully described in Chapter 10, “HP Fortran statements,” on page 267. Each I/O specifier is described under the I/O statement in which it may appear.
I/O and file handling Syntax of I/O statements Table 8-7 OPENED= ✓ PAD= ✓ ✓ POSITION= ✓ ✓ READ= ✓ READWRITE= ✓ REC= RECL= ✓ SEQUENTIAL= ✓ ✓ ✓ ✓ ✓ ✓ STATUS= ✓ ✓ UNFORMATTED= WRITE= ✓ ✓ SIZE= UNIT= WRITE ✓ REWIND NUMBER= READ NML= PRINT OPEN INQUIRE ENDFILE CLOSE BACKSPACE I/O Specifiers I/O statements and specifiers (Continued) ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ I/O data list The I/O data list can be used with any data transfer statement except namelist I/O; see “Namelist-d
I/O and file handling Syntax of I/O statements Simple data elements In a read operation, the simple data element specifies a variable, which can include: • A scalar • An array • An array element or section • A character substring • A structure • A component of a structure • A record • A field of a record • A pointer In a write operation, the simple data element can include any variable that is valid for a read operation, plus most expressions.
I/O and file handling Syntax of I/O statements The following restrictions apply to the use of arrays in input and output: • Sections of character arrays that specify vector-valued subscripts cannot be used as internal files. • An assumed-size array cannot be referenced as a whole array in an input or output list.
I/O and file handling Syntax of I/O statements The implied-DO loop is generally used to transmit arrays and array elements, as in the following: INTEGER :: b(10) PRINT *, (b(i), i = 1,10) If b has been initialized with the values 1 through 10 in order, the PRINT statement will produce the following output: 1 2 3 4 5 6 7 8 9 10 If an nonsubscripted array name occurs in the list, the entire array is transmitted at each iteration.
I/O and file handling Binary I/O Conversions (for Itanium‚—based systems) Binary I/O Conversions (for Itanium—based systems) This feature enables the specification of a binary conversion to happen to all unformatted sequential data on reads and writes to various units. Both the OPEN and INQUIRE commands accept the CONVERT argument. Allowable conversions There are two types of allowable conversions: • Native—the default, and no conversions will occur. The user may also specify “Big_Endian”.
I/O and file handling Binary I/O Conversions (for Itanium‚—based systems) Typically, code is written via the CONVERT=argument to OPEN and INQUIRE. Therefore, this option was given the higher priority status to allow overriding “normal” coding via the environment variable. NOTE 226 The CONVERT parameter to OPEN is only available via f90 version 2.7 or later, and is only accepted for UNFORMATTED files.
I/O and file handling ASA carriage control ASA carriage control The program asa(1) processes the output of a Fortran 90 program that uses ASA carriage control characters so that it can be properly handled by many printers. The syntax of asa is: asa [file-names] where file-names is a list of file names to be output with carriage control characters interpreted according to ASA rules. Table 8-8 describes the ASA carriage-control characters.
I/O and file handling Example programs Example programs This section gives example programs that illustrate I/O and file-handling features of HP Fortran. Internal file The following example, int_file.f90, illustrates how internal files can use edit descriptors internally. The comments within the program explain in detail what the program does. Example 8-1 int_file.
I/O and file handling Example programs REAL (KIND=8) :: x CHARACTER (LEN=14) :: dp_val CHARACTER :: dec_digits ! Use an edit descriptor to convert the value of n to a ! character; write the result to the internal file ! dec_digits. WRITE (dec_digits, '(I1)') n ! Concatenate dec_digits to the string 'F14.'. The complete ! string forms an edit descriptor that will convert the ! binary value of x to a formatted value of x to a ! formatted character string that formats the ! value.
I/O and file handling Example programs ! until it encounters end-of-record. When the ! program encounters end-of-record, it starts a new record. ! When it encounters and end-of-file, ! the program is done. For the sake of simplicity, the ! program does no error-checking.
I/O and file handling Example programs Phil Atley Harriet Myrle Pete Hartley 9 27 35 49 84 78 93 95 97 92 84 93 67 54 58 71 93 58 Here are the command lines to compile and execute the program, along with the output from a sample run: $ f90 nonadvance.f90 $ a.out Name Average -------------------------Sandra Delford 86 Joan Arunsoelton 57 Herman Pritchard 68 Felicity Holmes 78 Anita Jayson 85 Phil Atley 30 Harriet Myrle 89 Pete Hartley 66 File access The following example, file_access.
I/O and file handling Example programs IOSTAT=ios1, ERR=99, RECL=16) ! Use nonadvancing I/O to suppress newline at the end of output ! record, thus keeping the prompt on the same line with the ! input. WRITE (6, FMT='(A)', ADVANCE='NO') & ' Enter number to insert in list: ' READ *, number_to_insert ! Read from sorted list and write to scratch file until we find ! where to insert number; then, write number_to_insert, and ! continue writing remaining sorted numbers to scratch file.
I/O and file handling Example programs END IF 100 FORMAT (F16.6) 200 FORMAT (A, 2I6) END PROGRAM main Here are the command lines to compile and execute the program, along with the output from a sample run. Output from the cat command shows the contents of the list file before and after executing the program: $ f90 file_access.f90 $ cat list 0.5 1.2 2.5 3.5 26.15 $ a.out Enter number to insert in list: STOP Inserted! $ cat list 0.5 1.2 2.5 3.5 4.7 26.15 Chapter 8 4.
I/O and file handling Example programs 234 Chapter 8
9 I/O formatting I/O formatting occurs during data transfer operations when data is converted between its machine-readable binary representation and human-readable character format.
I/O formatting transferring data between machines with different machine representations for a data type. I/O formatting can be implicit or explicit. Implicit formatting occurs during list-directed and namelist-directed I/O: data is converted without programmer intervention, based on the data types of the I/O list items; see “List-directed I/O” on page 210 and “Namelist-directed I/O” on page 213. Explicit formatting occurs under the control of the programmer, who specifies how the data is to be converted.
I/O formatting FORMAT statement FORMAT statement The function of the FORMAT statement is to specify formatting information that can be used by one or more of the following data transfer statements: • ACCEPT (extension) • DECODE (extension) • ENCODE (extension) • PRINT • READ • TYPE (extension) • WRITE The syntax of the FORMAT statement is: label FORMAT ( format-spec ) where: label is a statement label.
I/O formatting Format specification Format specification A format specification consists of a list of edit descriptors that define the format of data to be read with a READ statement, or written with a WRITE or PRINT statement. A format specification can appear either in a FORMAT statement or in a character expression in a data transfer statement. The syntax of a format specification is: [descriptor1[, descriptor2...
I/O formatting Edit descriptors Edit descriptors Edit descriptors are encoded characters that describe data conversion between an internal (binary) format and an external (character) format. There are three types of edit descriptors: • Data edit descriptors define the format of data to be read or written, such as its type and width (in characters).
I/O formatting Edit descriptors Table 9-1 Edit descriptors (Continued) Descriptor Type Repeatable? I/O use Function BN Control No Input/output Ignore blanks in numeric input data. BZ Control No Input/output Treat blanks as zeroes in numeric input data. D[w.d] Data Yes Input/output Convert real type data with exponent. E[w.d[Ee]] Data Yes Input/output Convert real type data with exponent. EN[w.d[Ee]] Data Yes Input/output Convert real type data, using engineering notation.
I/O formatting Edit descriptors Table 9-1 Edit descriptors (Continued) Descriptor Type Repeatable? I/O use Function kP Control No Input/output Set scale factor to k. Q Control No Input Return number of bytes remaining to be read in current input record. S or SP Control No Output Print optional plus sign. SS Control No Output Do not print optional plus sign. Tc Control No Input/output Move to column c. TLc Control No Input/output Move c columns to the left.
I/O formatting Edit descriptors delimiting character, it must be of the other type; or you can escape the delimiter by giving another of the same type. The width of the field is the number of characters enclosed by the character string edit descriptors, including any blanks. Table 9-2 provides examples of the character string edit descriptor on output. Note that b represents a blank.
I/O formatting Edit descriptors Slash (/) edit descriptor The slash edit descriptor terminates the current record and begins processing a new record (such as a new line on a terminal). This edit descriptor has the same result for both input and output: it terminates the current record and begins a new one. For example, on output a newline character is printed, and on input a new line is read.
I/O formatting Edit descriptors A and R (character) edit descriptors The A and R edit descriptors define fields for character data. The A edit descriptor specifies left-justification, and the R edit descriptor specifies right-justification. The R edit descriptor is an HP extension. The syntax for the character edit descriptors is: [r]A[w] [r]R[w] where: r is a positive integer constant, specifying the repeat factor. w is the field width.
I/O formatting Edit descriptors Table 9-4 Contents of character data fields on output Descriptor Width/length relationship A width <= length Data is taken from leftmost characters in the field. width > length Output the value, preceded by blanks. width <= length Data is taken from rightmost characters in the field. width > length Output the value, preceded by blanks. R Result Examples of the use of character edit descriptors on input are provided in Table 9-5.
I/O formatting Edit descriptors Table 9-6 provides examples of character edit descriptors on output. In the table, b represents a blank and z represents a Null. Table 9-6 A and R Edit descriptors: output examples Descriptor Internal characters Variable length Output A6 ABCDEF 6 ABCDEF R4 ABCDEFGH 8 EFGH A4 ABCDE 5 ABCD A8 STATUS 6 bbSTATUS R8 STATUS 6 bbSTATUS R8 STATUS 8 STATUSbb B (binary) edit descriptor The B edit descriptor defines a field for binary data.
I/O formatting Edit descriptors If the file is opened with BLANK='ZERO', nonleading blanks are treated as zeroes. For more information about the BLANK= specifier, see “OPEN” on page 410. Plus and minus signs, commas, or any other symbols are not permitted. If a nonbinary digit appears, an error occurs. The presence of too many digits for the integer variable (or I/O list item) is illegal. Table 9-7 provides examples of the binary edit descriptor on input.
I/O formatting Edit descriptors Table 9-8 B Edit descriptor: output examples (Continued) Descriptor Internal value Output B8 -27 ******** BN and BZ (blank) edit descriptors The BN and BZ edit descriptors control the interpretation of embedded and trailing blanks in numeric input fields.
I/O formatting Edit descriptors The BN and BZ edit descriptors are ignored during the execution of an output statement. D, E, EN, ES, F, G, and Q (real) edit descriptors The D, E, EN, ES, F, G, and Q edit descriptors define fields for real numbers. The I/O list item corresponding to a real descriptor must be a numeric type. (The Standard permits real and complex types only; as an extension, HP Fortran allows integers.) The syntax for these edit descriptors is: [r]D[w.d] [r]E[w.d[{E|D|Q}e]] [r]EN[w.
I/O formatting Edit descriptors • An E followed by an optionally signed integer constant • A D followed by an optionally signed integer constant • A Q followed by an optionally signed integer constant All four exponent forms are processed in the same way. Note, however, that e has no effect on input. The EN and ES edit descriptors are the same as the F edit descriptor on input. The Q edit descriptor (an HP Fortran extension) is the same as the E edit descriptor on input.
I/O formatting Edit descriptors Table 9-11 provides examples of the E and D edit descriptors on output. Table 9-11 D and E edit descriptors: output examples Descriptor Internal value Output D10.3 +12.342 b0.123D+02 E10.3E3 -12.3454 -.123E+002 E12.4 +12.34 bb0.1234E+02 D12.4 -.00456532 b-0.4565D-02 D10.10 +99.99913 ********** E11.5 +999.997 0.10000E+04 E10.3E4 +.624 x 10-30 .
I/O formatting Edit descriptors Table 9-12 EN and ES edit descriptors: output examples (Continued) Descriptor Internal value Output ES12.3 +1234.5 bbb1.235E+03 F edit descriptor The F edit descriptor defines a field for real and complex values. The value is rounded to d digits to the right of the decimal point.
I/O formatting Edit descriptors • The magnitude is less than 0.1 but not zero. • The magnitude is greater than or equal to 10**d (after rounding to d digits). If the magnitude does not fit either of these rules, the F edit descriptor is used. When F is used, the field width is reduced by either 4 when Gw.d is specified, or by e+2 when Gw.dEe is specified. It is then followed by a number of trailing spaces equal to the number that the field width was reduced by.
I/O formatting Edit descriptors Q edit descriptor The Q edit descriptor (an HP extension) has the same effect as the E edit descriptor on output, except that it outputs a Q for the exponent instead of an E. The Q edit descriptor can also be used to determine the number of bytes remaining to be read in an input record; see “Q (bytes remaining) edit descriptor” on page 260. H (Hollerith) edit descriptor The H edit descriptor outputs a specified number of characters.
I/O formatting Edit descriptors w is a positive integer constant, specifying the field width. m is a nonnegative integer constant, specifying the minimum number of digits that must be in the field and forcing leading zeroes as necessary up to the first nonzero digit. The m value is ignored on input. If m is not specified, a default value of 1 is assumed. If m is larger than w, the field is filled with w asterisks. If m = 0 and the list item is zero, only blanks are output.
I/O formatting Edit descriptors Table 9-17 provides examples of the integer edit descriptor on output. Table 9-17 I edit descriptor: output examples Descriptor Internal value Output I4 +452.25 b452 I2 +6234 ** I3 -11.92 -11 I5 -52 bb-52 I10 123456.5 bbbb123456 I6.3 3 bbb003 I3.0 0 bbb I3 0 bb0 L (Logical) edit descriptor The L edit descriptor defines a field for logical data. Its syntax is: [r]L[w] where: r is a positive integer constant, specifying the repeat factor.
I/O formatting Edit descriptors Table 9-18 provides examples of the logical edit descriptor on input. Table 9-18 L edit descriptor: input examples Descriptor Input field Value dtored L1 T .TRUE. L1 f .FALSE. L6 .TRUE. .TRUE. L7 .false. .FALSE. L2 .t .TRUE. L8 bbbbTRUE .TRUE. L3 ABC error: illegal character Output The character T or F is right-justified in the output field, depending on whether the value of the list item is true or false.
I/O formatting Edit descriptors O (Octal) edit descriptor The O edit descriptor defines a field for octal data. It provides conversion between an external octal number and its internal representation. The syntax for the octal edit descriptor is: [r]O[w[.m]] where: r is a positive integer constant, specifying the repeat factor. w is a positive integer constant, specifying the field width.
I/O formatting Edit descriptors form, their high-order bits are nonzero and cause the field to be filled with asterisks when w is less than the number of octal digits in the entire output value. If m is set to 0, a zero value is output as all blanks. Table 9-21 provides examples of the octal edit descriptors on output. Table 9-21 O edit descriptor: output examples Descriptor Internal value Output (Octal) O6 80 bbb120 O2 80 ** O14 -9 bbb37777777767 O11 32767 bbbbbb77777 O6.
I/O formatting Edit descriptors Input If the value in the input field does not have an exponent, the internal number is equal to the field value multiplied by 10-k. If the value in the input field has an exponent, the scale factor has no effect. See Table 9-22 for examples of the scale factor on input. Output The scale factor effect on the EN, ES, F, and G (interpreted as F) edit descriptors is that the externally-represented number equals the internally-represented number multiplied by 10**k.
I/O formatting Edit descriptors The Q edit descriptor is valid on input only; it is ignored on output. It can be used for reading formatted, sequential, and direct-access files. The following program segment reads variable-length strings from a sequential file: CHARACTER(LEN=80) :: string INTEGER :: n, i ... READ (11,'(Q,80A1)') n, (string (i:i), i=1, n) For information about the Qw.d edit descriptor for editing real data, see “D, E, EN, ES, F, G, and Q (real) edit descriptors” on page 249.
I/O formatting Edit descriptors [r ]Z[w [.m ]] where: r is a positive integer constant, specifying the repeat factor. w is a positive integer constant, specifying the field width. m is a nonnegative integer constant, specifying the minimum number of digits that must be in the field and forcing leading zeroes as necessary up to the first nonzero digit. The m value is ignored on input. If m is not specified, a default value of 1 is assumed. If m is larger than w, the field is filled with w asterisks.
I/O formatting Edit descriptors negative values are output in twos complement form, their high-order bits are nonzero and cause the field to be filled with asterisks when w is less than the number of hexadecimal digits in the entire output value. If m is set to 0, a zero value is output as all blanks. The field width required to fully represent the hexadecimal value of an item is twice its size in bytes. For example, a CHARACTER*12 item would require a field width of 24 characters.
I/O formatting Embedded format specification Embedded format specification A format specification can be embedded in a data transfer statement as a character expression. Parentheses are included in the expression, and the first nonblank character must be a left parenthesis. The matching right parenthesis must also be in the expression. A list of edit descriptors appears between the parentheses. Any characters appearing after the matching right parenthesis are ignored.
I/O formatting Nested format specifications Nested format specifications A format specification can include a nested format specification (another set of edit descriptors, enclosed in parentheses). You can also precede the nested format specification with a repeat factor, as in the following example: (1H , 2(I5, F10.5)) This is equivalent to: (1H , I5, F10.5, I5, F10.5) Each nested specification is known as a group at nested level n. The value of n begins at 1.
I/O formatting Format specification and I/O data list Format specification and I/O data list A formatted I/O statement references each item in an I/O list, and the corresponding format specification is scanned to find a format descriptor for each item. As long as an item is matched to an edit descriptor, normal execution continues. If there are more edit descriptors than list items, format control terminates with the last list item.
10 HP Fortran statements This chapter describes the HP Fortran statements and attributes, arranged in alphabetical order. The descriptions provide syntax information, applicable rules and restrictions, and examples.
HP Fortran statements The following descriptions for specific type declarations are located in this chapter.
HP Fortran statements Attributes Attributes Table 10-1 lists all the attributes that an HP Fortran entity can have and indicates their compatibility. If the box at the intersection of two attributes contains a check mark, the attributes are mutually compatible and can be held simultaneously by an entity. The attributes are referred to throughout this chapter as well as in the rest of the book.
HP Fortran statements Attributes Table 10-1 POINTER PRIVATE PUBLIC SAVE STATIC TARGET VOLATILE ✓ PARAMETER ✓ OPTIONAL ✓ INTRINSIC ✓ INTENT ✓ Initialization ✓ EXTERNAL DIMENSION 270 AUTOMATIC NOTE ALLOCATABLE VOLATILE Attribute compatibility (Continued) ✓ ✓ ✓ ✓ ✓ ✓ ✓ AUTOMATIC, STATIC, and VOLATILE may be specified in a statement of the same name but not as attributes in a type declaration statement.
HP Fortran statements Statements and attributes Statements and attributes The remainder of this chapter describes all of the statements and attributes that you can use in an HP Fortran program. The statement and attribute descriptions are listed in alphabetical order. For general information about statements—including the order in which statements must appear in a legal program—see “Statements” on page 46.
HP Fortran statements ACCEPT (extension) ACCEPT (extension) Reads from standard input. Syntax The syntax of the ACCEPT statement can take one of two forms: • Formatted and list-directed syntax: ACCEPT format [, input-list ] • Namelist-directed syntax: ACCEPT name format is one of the following: • An asterisk (*), specifying list-directed I/O. • The label of a FORMAT statement containing the format specification. • An integer variable that has been assigned the label of a FORMAT statement.
HP Fortran statements ACCEPT (extension) Examples The following example of the ACCEPT statement reads an integer and a floating-point value from standard input, using list-directed formatting: INTEGER :: i REAL :: x ACCEPT *, i, x Related statements FORMAT, NAMELIST, PRINT and READ Related concepts For related information, see the following: • “List-directed I/O” on page 210 • “Implied-DO loop” on page 223 • “Embedded format specification” on page 264 Chapter 10 273
HP Fortran statements ALLOCATABLE (statement and attribute) ALLOCATABLE (statement and attribute) Declares an allocatable array with deferred shape. Syntax The syntax of a type declaration statement with the ALLOCATABLE attribute is: type, attrib-list :: entity-list type is a valid type specification (INTEGER, REAL, LOGICAL, CHARACTER, TYPE(type-name), etc.), as described in Chapter 5, “Data types and data objects,” on page 105.
HP Fortran statements ALLOCATABLE (statement and attribute) If (deferred-shape-spec-list) is omitted from the ALLOCATABLE statement, it must be specified in another declaration statement, such as a type or DIMENSION statement. The ALLOCATED intrinsic inquiry function is described in “ALLOCATED(ARRAY)” on page 521. It can be used to determine whether an allocatable array is currently allocated.
HP Fortran statements ALLOCATE ALLOCATE Provides storage space for allocatable arrays and pointer targets. Syntax ALLOCATE (allocation-list[, STAT= scalar-integer-variable]) allocation-list is a comma-separated list of allocation. allocation is allocate-object [(allocate-shape-spec-list)]. allocate-object is variable-name or derived-type-component. Each allocate-object must be an allocatable array or a pointer. allocate-shape-spec-list is a comma-separated list of allocate-shape-spec.
HP Fortran statements ALLOCATE Description The ALLOCATE statement creates space for allocatable arrays and targets for variables (scalars or arrays) with the POINTER attribute. The ALLOCATE and DEALLOCATE statements give the user the ability to manage space dynamically at execution time. For allocatable arrays, an error occurs when an attempt is made to allocate an already allocated array or to deallocate an array that is not allocated.
HP Fortran statements ALLOCATE The ALLOCATE and DEALLOCATE statements and pointer variables of type node make it possible to allocate space for nodes in such a tree structure, traverse it as required, and then recover the space when it is no longer needed. TYPE node REAL val TYPE(node), POINTER :: left, right END TYPE node TYPE(node) top ALLOCATE (top % left, top % right) ! Pointer components In the final example, two CHARACTER arrays, para and key, are declared with the POINTER attribute.
HP Fortran statements ASSIGN ASSIGN Assigns statement label to integer variable. Syntax ASSIGN stmt-label TO integer-variable stmt-label is the statement label for an executable statement or a FORMAT statement in the same scoping unit as the ASSIGN statement. integer-variable is a scalar variable of the default integer type. It cannot be a field of a derived type or record, or an array element.
HP Fortran statements AUTOMATIC (extension) AUTOMATIC (extension) Makes procedure variables and arrays automatic. Syntax AUTOMATIC var-name-list var-name-list is a comma-separated list of names of variables and arrays to be declared as automatic. Array names may be followed by an optional explicit-shape-spec. Description The AUTOMATIC statement is provided as an HP extension.
HP Fortran statements AUTOMATIC (extension) Related concepts For information about automatic and static variables, refer to the HP Fortran Programmer’s Guide.
HP Fortran statements BACKSPACE BACKSPACE Positions file at preceding record. Syntax The syntax of the BACKSPACE statement can take one of two forms: • Short form: BACKSPACE integer-expression • Long form: BACKSPACE ( io-specifier-list ) integer-expression is the number of the unit connected to a sequential file. io-specifier-list is a list of the following comma-separated I/O specifiers: [UNIT=] unit specifies the unit connected to an external file opened for sequential access.
HP Fortran statements BACKSPACE Examples The following statement causes the file connected to unit 10 to be positioned just before the preceding record: BACKSPACE 10 The following statement causes the file connected to unit 17 to be positioned just before the preceding record.
HP Fortran statements BLOCK DATA BLOCK DATA Introduces a block data program unit. Syntax BLOCK DATA [block-data-name] block-data-name is an optional name. If a name is given in the END BLOCK DATA statement terminating a block data program unit, it must be the same as the block-data-name given in the BLOCK DATA statement introducing the program unit.
HP Fortran statements BUFFER IN (extension) BUFFER IN (extension) Provided for compatibility with the BUFFER IN Cray statement. NOTE Asynchronous I/O with the BUFFER IN statements is not supported. HP Fortran 90 Draft supports these statements for synchronous I/O only. Syntax BUFFER IN (unit, mode) (begin-loc, end-loc) unit is a unit identifier (integer expression). mode is ignored.
HP Fortran statements BUFFER IN (extension) PROGRAM bufferedIoTest ! buffered i/o example: compile with +autodbl INTEGER a(10) OPEN ( UNIT = 7, NAME = ’test.
HP Fortran statements BUFFER OUT (extension) BUFFER OUT (extension) Provided for compatibility with Cray BUFFER OUT statement. NOTE Asynchronous I/O with the BUFFER OUT statements is not supported. HP Fortran 90 Draft supports these statements for synchronous I/O only. Syntax BUFFER OUT (unit, mode) (begin-loc, end-loc) unit is a unit identifier (integer expression). mode is ignored.
HP Fortran statements BUFFER OUT (extension) Related statements BUFFER IN 288 Chapter 10
HP Fortran statements BYTE (extension) BYTE (extension) Declares entities of type integer. Syntax BYTE [[, attrib-list] ::] entity-list attrib-list is a comma-separated list of one or more of the following attributes: Table 10-3 ALLOCATABLE INTRINSIC PRIVATE DIMENSION OPTIONAL PUBLIC EXTERNAL PARAMETER SAVE INTENT POINTER TARGET If attrib-list is present, it must be followed by the double colon. For information about individual attributes, see the corresponding statement in this chapter.
HP Fortran statements BYTE (extension) The BYTE statement is constrained by the rules for all type declaration statements, including the requirement that it precede all executable statements. Note, however, that the BYTE statement does not have a kind parameter.
HP Fortran statements CALL CALL Invokes a subroutine. Syntax CALL subr-name[([ subr-act-arg-spec-list ])] subr-name is the name of the subroutine being invoked. actual-argument-list is a comma-separated list of entities of the form: [keyword =]actual-argument actual-argument is one of the following: • expression • variable • procedure-name • *label or &label keyword is one of the dummy argument names of the subroutine being invoked.
HP Fortran statements CALL 4. Control returns from the subroutine, normally to the statement following the CALL statement, or to a statement label indicated by an alternate return argument—*label or &label. (The & label form is provided as a compatibility extension and can be used in fixed source form only.) A subroutine can call itself, directly or indirectly; in this case the keyword RECURSIVE must be specified in the SUBROUTINE statement of the subroutine definition.
HP Fortran statements CASE CASE Marks start of statement block in a CASE construct. Syntax CASE ( case-selector ) [ construct-name ] case-selector is a comma-separated list of ranges of values that are candidates for matching against the case index specified by the SELECT CASE statement.
HP Fortran statements CASE low: For integer and character types, a match occurs if c .GE. low. :high For integer and character types, a match occurs if c .LE. high. low : high For integer and character types, a match occurs if c .GE. low .AND. c .LE. high. DEFAULT For integer, character, and logical types, a match occurs if no match is found with any other case-selector and DEFAULT is specified as a case-selector.
HP Fortran statements CASE CASE (51:) PRINT *, 'BALANCE OKAY' END SELECT Related statements SELECT CASE and END (construct) Related concepts The CASE construct is described in “CASE construct” on page 139.
HP Fortran statements CHARACTER CHARACTER Declares entities of type character. Syntax CHARACTER [char-selector] [[, attrib-list] ::] entity-list char-selector specifies the length and kind of the character variable.
HP Fortran statements CHARACTER where name is the name of a variable or function, array-spec is a comma-separated list of dimension bounds, len-spec is either an asterisk (*) or a specification expression, and initialization-expr is a character constant expression. If initialization-expr is present, entity-list must be preceded by the double colon. Description The CHARACTER statement is used to declare the length and properties of character data.
HP Fortran statements CHARACTER • “Type declaration for intrinsic types” on page 109 • “Implicit typing” on page 113 • “Character strings as automatic data objects” on page 121 • “Array declarations” on page 59 • “Array constructors” on page 75 • “Expressions” on page 85 • “LEN(STRING)” on page 579 298 Chapter 10
HP Fortran statements CLOSE CLOSE Terminates file connection. Syntax CLOSE ( io-specifier-list ) io-specifier-list is a list of the following comma-separated I/O specifiers: [UNIT=]unit specifies the unit connected to an external file. unit must be a positive integer-valued expression. If the optional keyword UNIT= is omitted, unit must be the first item in io-specifier-list.
HP Fortran statements CLOSE Description The CLOSE statement closes the file whose unit number was obtained from an OPEN statement. A CLOSE statement must contain a unit number and at most one each of the other I/O specifiers. A CLOSE statement need not be in the same program unit as the OPEN statement that connected the file to the specified unit. If a CLOSE statement specifies a unit that does not exist or has no file connected to it, no action occurs.
HP Fortran statements COMMON COMMON Specifies common blocks. Syntax COMMON [/[[common-block-name]]/] object-list [,]/[common-block-name]/ object-list]... common-block-name is the name of a labeled common block. object-list is a comma-separated list of scalar variables, arrays, records, and derived-type objects. If an array is specified, it may be followed by an explicit-shape specification expression.
HP Fortran statements COMMON COMMON a,b,c /x/y,x,d //w,r COMMON /cap/hat,visor, //tax, /x/o,t are equivalent to: COMMON a,b,c,w,r,tax COMMON /x/y,x,d,o,t COMMON /cap/hat,visor Unlike named common blocks, blank common can differ in size in different scoping units. However, blank common cannot be initialized. As an extension, HP Fortran saves all common blocks in static memory. The following restrictions apply to the use of common blocks: • All common block names must be distinct from subprogram names.
HP Fortran statements COMMON HP Fortran also allows blank—or unnamed—common to be initialized. Common block size The size of a common block is determined by the number and type of the variables it contains.
HP Fortran statements COMMON ! common declaration for program unit 1 INTEGER i, j, k COMMON /my_block/ i, j, k ! common declaration for program unit 2 INTEGER n(3) COMMON /my_block/ n(3) The variables i, j, and k in program unit 1 share the same storage with the array n in program unit 2: i in program unit 1 matches up with n(1) in program unit 2, j with n(2), and k with n(3).
HP Fortran statements COMPLEX COMPLEX Declares entities of type complex. Syntax COMPLEX [kind-spec] [[, attrib-list] ::] entity-list kind-spec is the kind type parameter that specifies the range and precision of the entities in entity-list. kind-spec takes the form: ([KIND=]kind-param) where kind-param represents the kind of both the real and imaginary parts of the complex number. It can be a named constant or a constant expression that has the integer value of 4 or 8. The size of the default type is 4.
HP Fortran statements COMPLEX where name is the name of a variable or function, array-spec is a comma-separated list of dimension bounds, and initialization-expr is a complex constant expression. If initialization-expr is present, entity-list must be preceded by the double colon. Description The COMPLEX statement is used to declare the length and properties of data that are approximations to the mathematical complex numbers. A complex number consists of a real part and an imaginary part.
HP Fortran statements COMPLEX • “Implicit typing” on page 113 • “Array declarations” on page 59 • “Array constructors” on page 75 • “Expressions” on page 85 • “KIND(X)” on page 577 Chapter 10 307
HP Fortran statements CONTAINS CONTAINS Introduces an internal procedure or a module procedure. Syntax CONTAINS Description The CONTAINS statement introduces an internal procedure or a module procedure, separating it from the program unit that contains it. The statement can be used in: • A main program, external subprogram, or module subprogram; in each case, it precedes one or more internal procedures. • A module, where it precedes any module procedures.
HP Fortran statements CONTAINS The third example is of a module that contains a module subprogram, which in turn contains an internal subprogram.
HP Fortran statements CONTINUE CONTINUE Establishes reference point within a program unit. Syntax CONTINUE Description The CONTINUE statement has no effect on program execution. Control passes to the next executable statement. The CONTINUE statement is generally used to mark a place for a statement label, especially when it occurs as the terminal statement of a FORTRAN 77-style DO loop.
HP Fortran statements CYCLE CYCLE Interrupts current iteration of a DO loop. Syntax CYCLE [ do-construct-name ] do-construct-name is the name of a DO construct that must contain this CYCLE statement. Description The CYCLE statement is used to control the execution of a DO loop. When it executes, it interrupts a currently executing loop iteration and passes control to the next iteration, making the appropriate adjustments to the loop index.
HP Fortran statements CYCLE Related concepts For related information, see the following: • “DO construct” on page 141 • “Flow control statements” on page 146 312 Chapter 10
HP Fortran statements DATA DATA Initializes program variables. Syntax DATA var-list1 / val-list1 / [[,]var-list2 / val-list2 /]...
HP Fortran statements DATA • val-list Procedure names is a list of constant values, separated by commas. Each constant in the list represents a value to be assigned to the corresponding variable in var-list. A constant value can be optionally repeated by preceding the constant with a repetition factor. The syntax of a repeated constant is: r*val where r is a positive integer specifying the number of times that val, the constant value, is to be specified.
HP Fortran statements DATA If a subscripted array element appears in var-list, then the subscript must be a specification expression. DATA statements can be interspersed among executable statements. However, they initialize prior to runtime and, therefore, cannot be used as executable assignment statements. Fortran 90 extensions A variable of type other than integer may be initialized with a binary, octal, or hexadecimal constant.
HP Fortran statements DATA • 316 “Implied-DO loop” on page 223 Chapter 10
HP Fortran statements DEALLOCATE DEALLOCATE Deallocates allocatable arrays and pointer targets. Syntax DEALLOCATE (alloc-obj-list[, STAT=scalar-int-var]) alloc-obj-list is a comma-separated list of pointers or allocatable arrays. STAT=scalar-int-var returns the error status after the statement executes. If given, it is set to a positive value if an error is detected, and to zero otherwise. If there is no status variable, the occurrence of an error causes the program to terminate.
HP Fortran statements DEALLOCATE Examples The following example declares a complex array with the POINTER attribute. The ALLOCATE statement allocates target space to the array at run-time; the amount is determined by the input values to the READ statement. Later in the program, the DEALLOCATE statement will recover the space. COMPLEX, POINTER :: hermitian (:, :) ... READ *, m, n ALLOCATE (hermitian (m, n)) ...
HP Fortran statements DECODE (extension) DECODE (extension) Inputs formatted data from internal storage. Syntax DECODE (count, format, unit, io-specifier-list) [in-list] count is an integer expression that specifies the number of characters (bytes) to translate from character format to internal (binary) format. cnt must precede format. format specifies the format specification for formatting the data.
HP Fortran statements DECODE (extension) specifies the label of the executable statement to which control passes if an error occurs during statement execution. IOSTAT=integer-variable returns the I/O status after the statement executes. If the statement successfully executes, integer-variable is set to zero. If an end-of-file record is encountered without an error condition, it is set to a negative integer.
HP Fortran statements DECODE (extension) Related concepts For related information, see the following: • “Internal files” on page 204 • “Performing I/O on internal files” on page 207 • “Implied-DO loop” on page 223 • “Embedded format specification” on page 264 Chapter 10 321
HP Fortran statements DIMENSION (statement and attribute) DIMENSION (statement and attribute) Declares a variable to be an array. Syntax A type declaration statement with the DIMENSION attribute is: type, DIMENSION ( array-spec ) [[, attrib-list ]::] entity-list type is a valid type specification (INTEGER, REAL, LOGICAL, CHARACTER, TYPE( type-name ), etc.).
HP Fortran statements DIMENSION (statement and attribute) [explicit-shape-spec-list ,] [lower-bound :] * That is, assumed-size-spec is explicit-shape-spec-list with the final upper bound specified as *.
HP Fortran statements DIMENSION (statement and attribute) • DIMENSION • ALLOCATABLE • COMMON • POINTER • TARGET The array-spec (see Syntax, above) determines the category of the array being declared. “Array declarations” on page 59, describes these categories as: • Explicit-shape array • Assumed-shape array • Assumed-size array • Deferred-shape array Examples ! These 2 declaration statements are equivalent.
HP Fortran statements DIMENSION (statement and attribute) ! overrides specifier (10,20) for tb declaration only LOGICAL, DIMENSION(10,20) :: ta, tb(10,10), tc Related statements ALLOCATABLE, COMMON, POINTER, TARGET, TYPE, and the type declaration statements Related concepts For related information, see the following: • “Type declaration for intrinsic types” on page 109 • Chapter 11, “Intrinsic procedures,” on page 501 • The following array-inquiry intrinsics described in Chapter 11: ❏ LBOUND ❏ RESH
HP Fortran statements DO DO Controls execution of DO loop. Syntax [ construct-name :] DO [ label ] [ loop-control ] construct-name is the name given to the DO construct. If construct-name is specified, an END DO statement must appear at the end of the DO construct and have the same construct-name. label is the label of an executable statement that terminates the DO loop.
HP Fortran statements DO When label is present in the DO statement, it specifies the label of the terminating statement of the DO loop. The terminating statement cannot be any of the following statements: • GO TO (unconditional) • GO TO (assigned) • IF (arithmetic) • IF (block) • ELSE or ELSE IF • END, END IF, END SELECT, or END WHERE • RETURN • STOP • DO • Any nonexecutable statement Note, however, that the terminating statement can be an IF (logical) or an END DO statement.
HP Fortran statements DO DO i = 1, 10 WRITE (*, *) i END DO The next example is a FORTRAN 77-style DO loop that does the same as the preceding example: DO 50 i = 1, 10 WRITE (*, *) i 50 CONTINUE The following DO construct iterates 5 times, decrementing the loop index from 10 to 2: DO i = 10, 1, -2 END DO The following is an example of a DO WHILE loop: DO WHILE (sum < 100.0) sum = sum + get_num(unit) END DO The following example illustrates the use of the EXIT statement to exit from a nested DO loop.
HP Fortran statements DO • “EXIT statement” on page 147 Chapter 10 329
HP Fortran statements DOUBLE COMPLEX (extension) DOUBLE COMPLEX (extension) Declares entities of type double complex. Syntax DOUBLE COMPLEX [ [, attrib-list ] ::] entity-list attrib-list is a list of one or more of the following attributes, separated by commas: Table 10-8 ALLOCATABLE INTRINSIC PRIVATE DIMENSION OPTIONAL PUBLIC EXTERNAL PARAMETER SAVE INTENT POINTER TARGET If attrib-list is present, it must be followed by the double colon.
HP Fortran statements DOUBLE COMPLEX (extension) The DOUBLE COMPLEX statement is constrained by the rules for type declaration statements, including the requirement that it precede all executable statements. Note however, that the DOUBLE COMPLEX statement does not have a kind parameter. Examples The following are valid declarations: DOUBLE COMPLEX x, y DOUBLE COMPLEX, PARAMETER :: t1(2)=(/(1.2, 0), (-1.01, 0.
HP Fortran statements DOUBLE PRECISION DOUBLE PRECISION Declares entities of type double precision. Syntax DOUBLE PRECISION [ [, attrib-list] ::] entity-list attrib-list is a list of one or more of the following attributes, separated by commas: Table 10-9 ALLOCATABLE INTRINSIC PRIVATE DIMENSION OPTIONAL PUBLIC EXTERNAL PARAMETER SAVE INTENT POINTER TARGET If attrib-list is present, it must be followed by the double colon.
HP Fortran statements DOUBLE PRECISION Description The DOUBLE PRECISION statement is used to declare the properties of real data that has greater precision than data of default type real. By default, the DOUBLE PRECISION statement is equivalent to the REAL(KIND=8) statement. The DOUBLE PRECISION statement is constrained by the rules for type declaration statements, including the requirement that it precede all executable statements.
HP Fortran statements ELSE ELSE Provides a default path of execution for IF construct. Syntax ELSE [ construct-name ] construct-name is the name given to the IF construct. If construct-name is specified, the same name must also appear in the IF statement and in the END IF statement. Description The ELSE statement is used in an IF construct to provide a statement block for execution if none of the logical expressions in the IF and ELSE IF statements in the IF construct evaluates to true.
HP Fortran statements ELSE IF ELSE IF Provides alternate path of execution for IF construct. Syntax ELSE IF (logical-expression) THEN [construct-name] logical-expression is a scalar logical expression. construct-name is the name given to the IF construct. If construct-name is specified, the same name must also appear in the IF statement and in the END IF statement.
HP Fortran statements ELSE IF Related concepts See “IF construct” on page 145.
HP Fortran statements ELSEWHERE ELSEWHERE Introduces optional ELSEWHERE block within a WHERE construct. Syntax ELSEWHERE Description The ELSEWHERE statement introduces an ELSEWHERE block, which is an optional component of the WHERE construct. The ELSEWHERE statement executes on the complement of the WHERE condition. For additional information, see “WHERE (statement and construct)” on page 492. Examples WHERE( b .GE. 0.
HP Fortran statements ENCODE (extension) ENCODE (extension) Outputs formatted data to internal storage. Syntax ENCODE (count, format, unit, io-specifier-list) [out-list] count is an integer expression that specifies the number of characters (bytes) to translate from character format to internal (binary) format. count must precede format. format specifies the format specification for formatting the data.
HP Fortran statements ENCODE (extension) specifies the label of the executable statement to which control passes if an error occurs during statement execution. IOSTAT=integer-variable returns the I/O status after the statement executes. If the statement successfully executes, integer-variable is set to zero. If an end-of-file record is encountered without an error condition, it is set to a negative integer.
HP Fortran statements ENCODE (extension) • “Internal files” on page 204 • “Performing I/O on internal files” on page 207 • “Implied-DO loop” on page 223 • “Embedded format specification” on page 264 340 Chapter 10
HP Fortran statements END END Marks the end of a program unit or procedure. Syntax END [keyword [name]] keyword is one of the keywords BLOCK DATA, FUNCTION, MODULE, PROGRAM, or SUBROUTINE. When the END statement is used for an internal procedure or module procedure, the FUNCTION or SUBROUTINE keyword is required. name is the name given to the program unit. If name is specified, keyword must also be specified.
HP Fortran statements END Related statements BLOCK DATA, FUNCTION, MODULE, PROGRAM, and SUBROUTINE Related concepts For information about program units, see “Program units” on page 155.
HP Fortran statements END (construct) END (construct) Terminates a CASE, DO, IF, or WHERE construct. Syntax END construct-keyword [construct-name] construct-keyword is one of the keywords DO, IF, SELECT CASE, or WHERE. construct-name is the name given to the construct terminated by this statement. Description The END (construct) statement terminates a CASE, DO, IF, or WHERE construct.
HP Fortran statements END (structure definition, extension) END (structure definition, extension) Terminates the definition of a structure or union. Syntax END record-keyword record-keyword is one of the keywords MAP, STRUCTURE, or UNION. Description The END (record definition) statement is an HP Fortran extension that is used to delimit the definition of a structure (END STRUCTURE) or a union within a structure (END UNION and END MAP). For more information, refer to “STRUCTURE (extension)” on page 465.
HP Fortran statements END INTERFACE END INTERFACE Terminates a procedure interface block. Syntax END INTERFACE Description In Fortran 90, external procedures may be given explicit interfaces by means of procedure interface blocks. Such a block is always terminated by the END INTERFACE statement. Examples The following makes the interface of function r_ave explicit, giving it the generic name g_ave.
HP Fortran statements END TYPE END TYPE Terminates a derived type definition. Syntax END TYPE [type-name] type-name is the name of the derived type being defined. type-name is optional. If given, it must be the same as the type-name specified in the TYPE statement introducing the derived type definition. Description The END TYPE statement terminates the definition of a derived type.
HP Fortran statements ENDFILE ENDFILE Writes end-of-file record to file. Syntax The syntax of the ENDFILE statement can take one of the following forms: • Short form: ENDFILE integer-expression • Long form: ENDFILE (io-specifier-list) integer-expression is the number of the unit connected to a sequential file. io-specifier-list is a list of the following comma-separated I/O specifiers: [UNIT=]unit specifies the unit connected to a device or external file opened for sequential access.
HP Fortran statements ENDFILE An end-of-file record can occur only as the last record of a disk file. After execution of an ENDFILE statement, the file is positioned beyond the end-of-file record; any records beyond the current position are lost—that is, the file is truncated. Some devices (for example, magnetic tape units) can have multiple end-of-file records, with or without intervening data records. An end-of-file record can be written to a sequential file only.
HP Fortran statements ENTRY ENTRY Provides an additional external or module subprogram entry point. Syntax ENTRY entry-name [([dummy-arg-list]) [RESULT (result-name)]] entry-name is the name of the entry point (subroutine or function) defined by the ENTRY statement. It must differ from the original subroutine or function name, and from other ENTRY statement entry-names specified in the subprogram in which it appears.
HP Fortran statements ENTRY • The RESULT (result-name) clause can only be specified when the ENTRY statement is included in a function subprogram. If specified, result-name must differ from entry-name, and entry-name must not appear in any specification statement in the scoping unit of the function subprogram; entry-name assumes all the attributes of result-name. The RESULT clause in an ENTRY statement has the same syntax and semantics as in a FUNCTION statement.
HP Fortran statements ENTRY name actually referenced in the current call. The same restrictions apply when you use a dummy argument in a specification expression to specify an array bound or character length. • A procedure defined by an ENTRY statement may be given an explicit interface by use of an INTERFACE block. The procedure header in the interface body must be a FUNCTION statement for an entry to a function subprogram, and a SUBROUTINE statement for an entry to a subroutine subprogram.
HP Fortran statements ENTRY Here are examples of CALL statements associated with the preceding example: CALL CALL CALL CALL push(10) push(15) pop(I) pop(J) Related statements FUNCTION, SUBROUTINE, and CALL Related concepts For information about external procedures, see “External procedures” on page 161.
HP Fortran statements EQUIVALENCE EQUIVALENCE Associates different objects with same storage area. Syntax EQUIVALENCE (equivalence-list1) [, (equivalence-list2)]... equivalence-list is a comma-separated list of two or more object names to be storage associated. Objects can include simple variables, array elements, array names, and character substrings. Description All objects in each equivalence-list share the same storage area. Such objects become storage associated and are equivalenced to each other.
HP Fortran statements EQUIVALENCE The Fortran 90 standard imposes the following type restrictions on equivalenced objects: • If one of the objects in equivalence-list is of type default integer, default real, double precision real, default complex, double complex, default logical, or numeric sequence type, then all objects in equivalence-list must be one of these types. HP Fortran relaxes this restriction and allows character and noncharacter items to be equivalenced.
HP Fortran statements EQUIVALENCE As a result of this EQUIVALENCE statement, the fourth character in a, the first character in b, and the first character in c(2) share the same storage.
HP Fortran statements EQUIVALENCE Consider the following example, which puts array i in blank common and equivalences array element j(2) to i(3): INTEGER :: i(6), j(6) COMMON i EQUIVALENCE (i(3), j(2)) The effect of the EQUIVALENCE statement is to extend blank common to include element j(6). This is entirely legal because the extension occurs at the end of the common block.
HP Fortran statements EXIT EXIT Terminates a DO loop. Syntax EXIT [do-construct-name] do-construct-name is the name given to the DO construct. If do-construct-name is specified, it must be the name of a DO construct that contains the EXIT statement. Description If you do not specify do-construct-name, the EXIT statement terminates the immediately enclosing DO loop. If you do specify it, the EXIT statement terminates the enclosing DO loop with the same name.
HP Fortran statements EXTERNAL (statement and attribute) EXTERNAL (statement and attribute) Declares a name to be external. Syntax A type declaration statement with the EXTERNAL attribute is: type , attrib-list :: function-name-list type is a valid type specification (INTEGER, REAL, LOGICAL, CHARACTER, TYPE (name), etc.).
HP Fortran statements EXTERNAL (statement and attribute) • The EXTERNAL attribute cannot be used with subroutines. To declare a subroutine as EXTERNAL, use the statement form. • If the name is a dummy argument, an EXTERNAL statement declares it to be a dummy procedure. • If a user-defined procedure or library routine has the same name as an intrinsic procedure, then it must either be declared to have the EXTERNAL attribute or have an explicit interface.
HP Fortran statements EXTERNAL (statement and attribute) • “Procedures” on page 156 • “Declaring library routines as EXTERNAL” on page 645 360 Chapter 10
HP Fortran statements FORMAT FORMAT Describes how I/O data is to be formatted. Syntax label FORMAT (format-list) label is a statement label. format-list is a comma-separated list of format items, where each item in the list can be either one of the edit descriptors described in Table 9-1 or (format-list). If format-list is a list item, it may be optionally preceded by a repeat specification—a positive integer that specifies how may times format-list is to be repeated.
HP Fortran statements FORMAT Related statements READ and WRITE Related concepts For information about I/O formatting, see Chapter 9, “I/O formatting,” on page 235.
HP Fortran statements FUNCTION FUNCTION Introduces a function subprogram. Syntax [RECURSIVE] [type-spec] FUNCTION function-name ([dummy-arg-name-list]) [RESULT (result-name)] RECURSIVE is a keyword that must be specified in the FUNCTION statement if the function is either directly or indirectly recursive. The RECURSIVE clause can appear at most once, either before or after type-spec. It is not an error to specify RECURSIVE for a nonrecursive function.
HP Fortran statements FUNCTION As noted above, a recursive function that calls itself directly must have the RESULT clause specified. For other functions, the RESULT clause is optional. Description A FUNCTION statement introduces an external, module, or internal function subprogram. Examples PROGRAM main ...
HP Fortran statements GO TO (assigned) GO TO (assigned) Transfers control to a variable that was assigned a label. Syntax GO TO integer-variable [[,] (label-list)] integer-variable is a scalar variable of default type integer. label-list is a list of statement labels, separated by commas. Description The assigned GO TO statement transfers control to the statement whose label was most recently assigned to a variable with the ASSIGN statement.
HP Fortran statements GO TO (computed) GO TO (computed) Transfers control to one of several labels. Syntax GO TO ( label-list ) [,] arithmetic-expression label-list is a list of statement labels, separated by commas. arithmetic-expression is a scalar integer expression. As an extension, HP Fortran also allows the expression to be of type real or double precision.
HP Fortran statements GO TO (unconditional) GO TO (unconditional) Transfers control to a specified label. Syntax GO TO label label is the label of an executable statement. Description The unconditional GO TO statement transfers control directly to the statement at the specified label. The executable statement with label can occur before or after the GO TO statement, but it must be within the same scoping unit.
HP Fortran statements IF (arithmetic) IF (arithmetic) Transfers control to one of three labels. Syntax IF (arithmetic-expression) labelN, labelZ, labelP arithmetic-expression is an arithmetic expression of any numeric type except complex and double complex. label is a label of an executable statement. Description The arithmetic IF statement transfers control to the statement whose label is determined by arithmetic-expression.
HP Fortran statements IF (block) IF (block) Begins an IF construct. Syntax [construct-name :] IF (logical-expression) THEN construct-name is the name given to the IF construct. If construct-name is specified, the same name must also appear in the END IF statement. logical-expression is a scalar logical expression. Description The IF statement executes the immediately following statement block if logical-expression evaluates to true.
HP Fortran statements IF (logical) IF (logical) Conditionally executes a statement. Syntax IF (logical-expression) statement logical-expression is a logical expression. statement is any executable statement other than the following: • A statement used to begin a construct • Any END statement • Any IF statement Description The logical IF statement is a two-way decision maker. If logical-expression evaluates to is true, statement executes and control passes to the next statement.
HP Fortran statements IMPLICIT IMPLICIT Changes or voids default typing rules. Syntax The IMPLICIT statement can take either of the following forms: • First form: IMPLICIT type (range-list)[, type (range-list) ,]... • Second form: IMPLICIT NONE type is the data type to be associated with the corresponding letters in range-list. range-list is a comma-separated list of letters or ranges of letters (for example, A-Z or I-N) to be associated with type.
HP Fortran statements IMPLICIT The IMPLICIT NONE statement disables the default typing rules for all variables, arrays, named constants, function subprograms, ENTRY names, and statement functions (but not intrinsic functions). All such objects must be explicitly typed. The IMPLICIT NONE statement must be the only IMPLICIT statement in the scoping unit, and it must precede any PARAMETER statement. Types of intrinsic functions are not affected.
HP Fortran statements INCLUDE INCLUDE Imports text from a specified file. Syntax INCLUDE character-literal-constant character-literal-constant is the name of the file to include. Description The keyword INCLUDE and character-literal-constant form an INCLUDE line, which is used to insert text into a program prior to compilation. The inserted text replaces the INCLUDE line; the INCLUDE line should therefore appear in your program where you want the inserted text.
HP Fortran statements INCLUDE Examples INCLUDE 'my_common_blocks' INCLUDE ”/my_stuff/declarations.
HP Fortran statements INQUIRE INQUIRE Returns information about file properties. Syntax The syntax of the INQUIRE statement has two forms: • Inquiry by output list: INQUIRE ( IOLENGTH= integer-variable) output-list • Inquiry by unit or file: INQUIRE (io-specifier-list) integer-variable is the length of the unformatted record that would result from writing output-list to a direct-access file.
HP Fortran statements INQUIRE returns the following values, indicating the method of access: Table 10-11 'SEQUENTIAL' File is connected for sequential access. 'DIRECT' File is connected for direct access. 'UNDEFINED' File is not connected. ACTION=character-variable returns the following values, indicating the direction of the transfer: Table 10-12 'READ' File is connected for reading only. 'WRITE' File is connected for writing only. 'READWRITE' File is connected for reading and writing.
HP Fortran statements INQUIRE returns the following values, indicating the character to use (if any) to delimit character values in list-directed and namelist formatting: Table 10-14 'APOSTROPHE' An apostrophe is used as the delimiter. 'QUOTE' The double quotation mark is used as the delimiter. 'NONE' There is no delimiting character. 'UNDEFINED' File is not connected for formatted I/O.
HP Fortran statements INQUIRE Table 10-16 'FALSE' (Continued) File does not exist or unit is not connected. FILE=character-expression specifies the name of a file for inquiry. The file does not have to be connected or even exist. If the FILE= specifier appears in io-specifier-list, the UNIT= specifier must not be used.
HP Fortran statements INQUIRE returns the I/O status after the statement executes. If the statement successfully executes, integer-variable is set to zero. If an error occurs, it is set to a positive integer that indicates which error occurred.. NAME=character-variable returns the name of file connected to the specified unit. If the file has no name or is not connected, NAME= returns the string UNDEFINED.
HP Fortran statements INQUIRE returns a value indicating whether or not input records are padded with blanks. For more information about padding, see the PAD= specifier for the OPEN statement. The return values are: Table 10-21 'YES' File or unit is connected with PAD='YES' in OPEN statement. 'NO' File or unit is connected with PAD='NO' in OPEN statement.
HP Fortran statements INQUIRE READWRITE=character-variable returns the following values, indicating whether or not reading and writing are allowed actions for the file: Table 10-24 'YES' Both reading and writing are allowed for file. 'NO' Reading and writing are not both allowed for file. 'UNKNOWN' It cannot be determined whether or not reading and writing are both allowed for file. RECL=integer-variable returns the record length of the specified unit or file, measured in bytes.
HP Fortran statements INQUIRE returns the following values, indicating whether or not the file is connected for formatted I/O: Table 10-26 'YES' File is connected for unformatted I/O. 'NO' File is not connected for unformatted I/O. 'UNKNOWN' It cannot be determined whether or not file is connected for unformatted I/O. WRITE=character-variable returns the following values, indicating whether or not writing is an allowed action for the file: Table 10-27 'YES' Writing is allowed for file.
HP Fortran statements INQUIRE The INQUIRE statement in this example returns the following information about the file named my_file: • The EXIST= specifier determines if the file is connected. • The DIRECT= specifier determines if it is connected for direct access. • The READWRITE= specifier determines if it can be read and written.
HP Fortran statements INQUIRE Related concepts For information about I/O concepts, see Chapter 8, “I/O and file handling,” on page 201.
HP Fortran statements INTEGER INTEGER Declares entities of type integer. Syntax INTEGER [kind-spec] [[, attrib-list] ::] entity-list kind-spec is the kind type parameter that specifies the range of the entities in entity-list. kind-spec takes the form: ([KIND=] kind-param) where kind-param can be a named constant or a constant expression that has the integer value of 1, 2, 4, or 8. The size of the default type is 4.
HP Fortran statements INTEGER array-spec is a comma-separated list of dimension bounds initialization-expr is an integer constant expression. If initialization-expr is present, entity-list must be preceded by the double colon. Description The INTEGER statement is used to declare the length and properties of data that are whole numbers. A kind parameter (if present) indicates the representation method.
HP Fortran statements INTEGER • “Implicit typing” on page 113 • “Array declarations” on page 59 • “Array constructors” on page 75 • “Expressions” on page 85 • “KIND(X)” on page 577 Chapter 10 387
HP Fortran statements INTENT (statement and attribute) INTENT (statement and attribute) Specifies the intended use of dummy arguments. Syntax A type declaration statement with the INTENT attribute is:7 type , attrib-list :: dummy-arg-name-list type is a valid type specification (INTEGER, REAL, LOGICAL, CHARACTER, TYPE (name), etc.).
HP Fortran statements INTENT (statement and attribute) If a dummy argument has intent OUT, the corresponding actual argument must be definable; that is, it cannot be a constant. When execution of the procedure begins, the dummy argument is undefined; thus it must be given a value before it is referenced. The dummy argument need not be given a value by the procedure. If a dummy argument has intent INOUT, the corresponding actual argument must be definable.
HP Fortran statements INTENT (statement and attribute) Related concepts For related information, see the following: • “Type declaration for intrinsic types” on page 109 • “INTENT attribute” on page 178 390 Chapter 10
HP Fortran statements INTERFACE INTERFACE Introduces an interface block. Syntax INTERFACE [generic-spec] generic-spec generic-name is one of: • generic-name • OPERATOR(defined-operator) • ASSIGNMENT(=) is the name of a generic procedure. defined-operator is one of: • An intrinsic operator • .operator., where operator is a user-defined name Description The INTERFACE statement is the first statement of an interface block.
HP Fortran statements INTERFACE SUBROUTINE sp2(x,z) END SUBROUTINE sp2 END INTERFACE ! Make the interface of function r_ave explicit and give ! it the generic name g_ave INTERFACE g_ave FUNCTION r_ave(x) ! Get the size of x from the module ave_stuff USE ave_stuff, ONLY: n REAL r_ave, x(n) END FUNCTION r_ave END INTERFACE ! Make the interface of external function b_or operator INTERFACE OPERATOR ( + ) FUNCTION b_or(p, q) LOGICAL b_or, p, q INTENT (IN) p, q END FUNCTION b_or END INTERFACE explicit, and use!
HP Fortran statements INTRINSIC (statement and attribute) INTRINSIC (statement and attribute) Identifies an intrinsic procedure. Syntax The syntax of the type declaration statement with the INTRINSIC attribute is: type , attrib-list :: intrinsic-function-name-list type is a valid type specification (INTEGER, REAL, LOGICAL, CHARACTER, TYPE(name), etc.).
HP Fortran statements INTRINSIC (statement and attribute) Whenever an intrinsic name is passed as an actual argument and no other appearance of the name in the same scoping unit indicates that it is a procedure, it must be specified by the calling program in an INTRINSIC statement, or (if a function name) in a type declaration statement that includes the INTRINSIC attribute. Each name can appear only once in an INTRINSIC statement and in at most one INTRINSIC statement within the same scoping unit.
HP Fortran statements LOGICAL LOGICAL Declares entities of type logical. Syntax LOGICAL [kind-spec] [[, attrib-list] ::] entity-list kind-spec specifies the size of the logical entity in bytes. kind-spec takes the form: ([KIND=] kind-param) where kind-param can be a named constant or a constant expression that has the integer value of 1, 2, 4, or 8. The size of the default type is 4. As an extension, kind-spec can take the form: *len-param where len-param is the integer 1, 2, 4, or 8 (default = 4).
HP Fortran statements LOGICAL is a comma-separated list of dimension bounds initialization-expr is a logical constant expression. If initialization-expr is present, entity-list must be preceded by the double colon. Description The LOGICAL statement is constrained by the rules for type declaration statements, including the requirement that it precede all executable statements.
HP Fortran statements LOGICAL • “Array constructors” on page 75 • “Expressions” on page 85 • “KIND(X)” on page 577 Chapter 10 397
HP Fortran statements MAP (extension) MAP (extension) Defines a union within a structure. Syntax MAP field-def ... END MAP field-def is one of the following: • A type declaration statement • Another nested structure • A nested record • A union definition Description The MAP statement is an HP compatibility extension that is used with the UNION statement to define a union within a structure. For detailed information about the MAP and UNION statements, see “STRUCTURE (extension)” on page 465.
HP Fortran statements MODULE MODULE Introduces a module. Syntax MODULE module-name module-name is a unique module name. Description Modules are nonexecutable program units that can contain type definitions, object declarations, procedure definitions (module procedures), external procedure interfaces, user-defined generic names, and user-defined operators and assignments.
HP Fortran statements MODULE ... FUNCTION addrr (. . .) ! A specific definition of + ... END MODULE rational_arithmetic Related statements CONTAINS, END, PRIVATE, PUBLIC, and USE Related concepts For more information about modules, see “Modules” on page 190.
HP Fortran statements MODULE PROCEDURE MODULE PROCEDURE Specifies module procedures in a generic interface. Syntax MODULE PROCEDURE module-procedure-name-list module-procedure-name-list is a comma-separated list of module-procedure-names. Description A MODULE PROCEDURE statement appears within an interface block. It is used when the specification is generic and a specific procedure is defined within the module rather than as an external procedure.
HP Fortran statements MODULE PROCEDURE TYPE (rational), INTENT (IN) :: x, y rational_multiply = ... ... END FUNCTION rational_multiply END MODULE path Related statements FUNCTION, SUBROUTINE, and INTERFACE Related concepts For information about module procedures, see “Module program unit” on page 190.
HP Fortran statements NAMELIST NAMELIST Names a group of variables for I/O processing. Syntax NAMELIST /group-name/var-list [ [ ,]/group-name/var-list ]... group-name is a unique namelist group name. var-list is a comma-separated list of scalar and array variable names. Description The NAMELIST statement declares var-list as a namelist group and associates the group with group-name.
HP Fortran statements NAMELIST The same variable name may appear in different NAMELIST statements within the same scoping unit.
HP Fortran statements NULLIFY NULLIFY Disassociates a pointer from a target. Syntax NULLIFY (pointer-object-list) pointer-object-list is a comma-separated list of variable names and derived-type components. Description The NULLIFY statement disassociates a pointer from any target. A NULLIFY statement is also used to change the status of a pointer from undefined to disassociated.
HP Fortran statements NULLIFY Related concepts For information about pointers, see “Pointers” on page 131.
HP Fortran statements ON (extension) ON (extension) Specifies the action to take when program execution is interrupted. Syntax ON interrupt-condition action interrupt-condition is the interrupt to be handled, either an arithmetic error or a keyboard interrupt. action is one of the following: • CALL trap-routine • ABORT • IGNORE where: trap-routine is an external subroutine name. Description The ON statement is an HP extension.
HP Fortran statements ON (extension) ON REAL(8) DIV 0 CALL trap_div_by_zero The following ON statement does the same thing, but it specifies the equivalent keywords from the third column of the table: ON DOUBLE PRECISION DIV 0 CALL trap_div_by_zero Table 10-32 Exceptions handled by the ON statement Exceptions Exception keywords Alternate keywords Division by zero REAL(4) DIV 0 REAL DIV 0 REAL(8) DIV 0 DOUBLE PRECISION DIV 0 REAL(16) DIV 0 (none) INTEGER(2) DIV 0 INTEGER*2 DIV 0 INTEGER(4) DI
HP Fortran statements ON (extension) To use the ON statement to trap for integer overflow, you must also include the $HP$ CHECK_OVERFLOW directive. This is described in the HP Fortran Programmer’s Guide. Using the ON statement at optimization levels 2 and above is restricted. When compiling at optimization level 2 or above, the optimizer makes assumptions about the program that do not take into account the behavior of procedures called by the ON statement.
HP Fortran statements OPEN OPEN Connects file to a unit. Syntax OPEN (io-specifier-list) io-specifier-list is a list of the following comma-separated I/O specifiers: [UNIT=]unit specifies the unit to connect to an external file. unit must be an integer expression that evaluates to a number greater than 0. If the optional keyword UNIT= is omitted, unit must be the first item in io-specifier-list. ACCESS=character-expression specifies the method of file access.
HP Fortran statements OPEN Table 10-34 'READWRITE' (Continued) Allow any data transfer statement (default). BLANK=character-expression specifies treatment of blanks within numeric data on input. This specifier is applicable to formatted input only. character-expression can be one of the following arguments: Table 10-35 'NULL' Ignore blanks (default). 'ZERO' Substitute zeroes for blanks.
HP Fortran statements OPEN FILE=character-expression specifies the name of the file to be connected to unit. character-expression can also be the ASCII representation of a device file. If this specifier does not appear in the OPEN statement, a temporary scratch file is created. FORM=character-expression specifies whether the file is connected for formatted or unformatted I/O. character-expression can be one of the following arguments: Table 10-37 'FORMATTED' Specify formatted I/O.
HP Fortran statements OPEN POSITION=character-expression specifies the position of an existing file to be opened for sequential access. character-expression can be one of the following arguments: Table 10-39 'ASIS' Leave file position unchanged (default). 'REWIND' Position the file at its start. 'APPEND' Position the file just before the end-of-file record. If the file to be opened does not exist, this specifier is ignored. New files are always positioned at their start.
HP Fortran statements OPEN Table 10-40 (Continued) 'REPLACE' If the file does not exist, create it with a status of OLD; if it does exist, delete it and open it with a status of NEW. If STATUS='REPLACE' is specified, FILE= must also be specified. 'SCRATCH' Create a scratch file. FILE= specifier must not be specified. For information about scratch files, see “Scratch files” on page 204. Description The OPEN statement connects a unit to a file so that data can be read from or written to that file.
HP Fortran statements OPEN OPEN(10, FILE='inv', ERR=100, I0STAT=ios, ACTION='READ', STATUS='OLD') & Opening a file for direct access The following OPEN statement opens the file whose name is contained in the variable next1, connecting it to unit 4 as a formatted, direct-access file with a record length of 50 characters: OPEN(ACCESS=”DIRECT”, UNIT=4, RECL=50, FORM=”FORMATTED”, FILE=next1) & Opening a device for I/O transfers The next example connects the system device /dev/console to unit 6; all data tra
HP Fortran statements OPTIONAL (statement and attribute) OPTIONAL (statement and attribute) Identifies optional arguments for procedures. Syntax The syntax of the type declaration statement with the OPTIONAL attribute is: type , attrib-list :: dummy-argument-name-list type is a valid type specification (INTEGER, REAL, LOGICAL, CHARACTER, TYPE ( name), etc.).
HP Fortran statements OPTIONAL (statement and attribute) • The OPTIONAL attribute may be specified only for dummy arguments. It may occur in a subprogram and in any corresponding interface body. • An optional dummy argument whose actual argument is not present may not be referenced or defined (or invoked if it is a dummy procedure), except that it may be passed to another procedure as an optional argument and will be considered not present.
HP Fortran statements OPTIONAL (statement and attribute) END IF ... END SUBROUTINE plot ! Plot points ! Some valid calls to plot. CALL plot (points) CALL plot (observed, o_xaxis = 100., o_yaxis = 1000.) CALL plot (random_pts, smooth = .TRUE.
HP Fortran statements OPTIONS (extension) OPTIONS (extension) Lowers the optimization level used by the HP Fortran compiler. Syntax OPTIONS +On where +On (or -On) specifies a level of optimization that is equal to or less than the level specified on the command line. Description The OPTIONS statement is an extension of HP Fortran and is used to specify a level of optimization that is equal to or less than the level specified on the command line.
HP Fortran statements PARAMETER (statement and attribute) PARAMETER (statement and attribute) Defines a named constant. Syntax A type declaration statement with the PARAMETER attribute is: type, attrib-list :: cname1 = cexpr1[, cname2 = cexpr2]... type is a valid type specification (INTEGER, REAL, LOGICAL, CHARACTER, TYPE (name), etc.).
HP Fortran statements PARAMETER (statement and attribute) The type of a named constant is determined by the implicit typing rules, unless its type is specified by a type declaration statement prior to its first appearance in a PARAMETER statement or by a type declaration statement that includes PARAMETER as one of its attributes.
HP Fortran statements PARAMETER (statement and attribute) If the named constant is of type character and its length is not specified, the length must be specified in a type declaration statement or IMPLICIT statement prior to the first appearance of the named constant. Its type and/or length must not be changed by subsequent statements, including IMPLICIT statements. If a symbolic name of type CHARACTER*(*) is defined in a PARAMETER statement, its length becomes the length of the expression assigned to it.
HP Fortran statements PAUSE PAUSE Temporarily stops program execution. Syntax PAUSE pause-code pause-code is a character constant or a list of up to 5 digits. Description The PAUSE statement suspends program execution and prints a message, depending on whether digits, characters, or nothing has been specified in the PAUSE statement: • If digits, the message “PAUSE digits” is written to standard error. • If a character expression, the message “PAUSE character-expression” is written to standard error.
HP Fortran statements PAUSE ! Write ”PAUSE” to standard error PAUSE Related statements STOP Related concepts For information about flow control statements, see “Flow control statements” on page 146.
HP Fortran statements POINTER (Cray-style extension) POINTER (Cray-style extension) Declares Cray-style pointers and their objects. Syntax POINTER (pointer1, pointee1) [, (pointer2, pointee2)]... pointer is a pointer. pointee is a variable name or array declarator. Description HP Fortran supports both the standard Fortran 90 POINTER statement as well as the Cray-style POINTER statement. The Cray-style POINTER statement is supported for compatibility with older, FORTRAN 77 programs.
HP Fortran statements POINTER (Cray-style extension) • Pointees that are arrays with nonconstant bounds can be used only in subroutines and functions, not in main programs. • Variables used in an array-bound expression that appears in a POINTER statement must be either subprogram formal arguments or common block variables. The value of the expression cannot change after subprogram entry. You associate memory with a pointer by assigning it the address of an object.
HP Fortran statements POINTER (Cray-style extension) IF (p.EQ.0) THEN PRINT *, 'MALLOC failed.
HP Fortran statements POINTER (statement and attribute) POINTER (statement and attribute) Specifies variables with the POINTER attribute. Syntax The syntax of a type declaration statement with the POINTER attribute is: type, attrib-list :: dummy-argument-name-list type is a valid type specification (INTEGER, REAL, LOGICAL, CHARACTER, TYPE ( name), etc.).
HP Fortran statements POINTER (statement and attribute) Description A POINTER attribute or statement specifies that the named variables may be pointers to some target object. Pointers provide a capability for creating dynamic objects, such as dynamic-sized arrays and linked lists. An object with a pointer attribute initially has no space reserved for its target.
HP Fortran statements POINTER (statement and attribute) Related statements ALLOCATE, DEALLOCATE, NULLIFY and TARGET Related concepts For related information, see the following: • “Pointers” on page 131 • “Pointer assignment” on page 99 • The description of the ASSOCIATED intrinsic in Chapter 11, “Intrinsic procedures,” on page 501.
HP Fortran statements PRINT PRINT Writes to standard output. Syntax The syntax of the PRINT statement can take one of two forms: • Formatted and list-directed syntax: PRINT format [, output-list ] • Namelist-directed syntax: PRINT name format is one of the following: • An asterisk (*), specifying list-directed I/O. • The label of a FORMAT statement containing the format specification. • An integer variable that has been assigned the label of a FORMAT statement.
HP Fortran statements PRINT Formatted output The following statement writes the contents of the variables num and des to standard output, using the format specification in the FORMAT statement at label 10: PRINT 10, num, des List-directed output The following statement uses list-directed formatting to print the literal string x= and the value of the variable x: PRINT *, 'x=', x Embedded format specification The following statement uses an embedded format specification to print the same output: PRINT '(A2,
HP Fortran statements PRIVATE (statement and attribute) PRIVATE (statement and attribute) Prevents access to module entities by use association. Syntax The syntax of a type declaration statement with the PRIVATE attribute is: type, attrib-list :: access-id-list type is a valid type specification (INTEGER, REAL, LOGICAL, CHARACTER, TYPE ( name ), etc.).
HP Fortran statements PRIVATE (statement and attribute) Description The PRIVATE attribute may appear only in the specification part of a module. The default accessibility in a module is PUBLIC; it can be changed to PRIVATE using a statement without a list. However, only one PRIVATE accessibility statement without a list is permitted in a module.
HP Fortran statements PRIVATE (statement and attribute) Related concepts For related information, see the following: • “Type declaration for intrinsic types” on page 109 • “Modules” on page 190 Chapter 10 435
HP Fortran statements PROGRAM PROGRAM Identifies the main program unit. Syntax PROGRAM name name is the name of the program. Description The optional PROGRAM statement assigns a name to the main program unit. name does not have to match the main program’s filename. However, if the corresponding END PROGRAM statement specifies a name, it must match name. If the PROGRAM statement is specified, it must be the first statement in the main program unit.
HP Fortran statements PUBLIC (statement and attribute) PUBLIC (statement and attribute) Enables access to module entities by use association. Syntax The syntax of a type declaration statement with the PUBLIC attribute is: type, attrib-list :: access-id-list type is a valid type specification (INTEGER, REAL, LOGICAL, CHARACTER, TYPE ( name), etc.).
HP Fortran statements PUBLIC (statement and attribute) Description The PUBLIC attribute may appear only in the specification part of a module. The default accessibility in a module is PUBLIC; it can be reaffirmed using a PUBLIC statement without a list. However, only one PUBLIC accessibility statement without a list is permit ted in a module.
HP Fortran statements PUBLIC (statement and attribute) • “Type declaration for intrinsic types” on page 109 • “Modules” on page 190 Chapter 10 439
HP Fortran statements READ READ Inputs data from external and internal files.
HP Fortran statements READ • An integer variable that has been assigned the label of a FORMAT statement. • A character expression that provides the format specification. If the optional keyword FMT= is omitted, format must be the second item in io-specifier-list. NOTE The NML= and FMT= specifier may not both appear in the same io-specifier-list. [NML=]name specifies the name of a namelist group for namelist-directed input. name must have been defined in a NAMELIST statement.
HP Fortran statements READ specifies the label of the executable statement to which control passes if an end-of-record condition is encountered. This specifier may appear in io-specifier-list only if ADVANCE='NO' also appears in the list. IOSTAT=integer-variable returns the I/O status after the statement executes. If the statement successfully executes, integer-variable is set to zero. If an end-of-file record is encountered without an error condition, it is set to a negative integer.
HP Fortran statements READ Description The READ statement transfers data from an external or internal file to internal storage. An external file can be opened for sequential access or direct access. If it is opened for sequential access, the READ statement can perform the following types of I/O: • Formatted • Unformatted • List-directed • Namelist-directed If the file is opened for direct access, the READ statement can perform formatted or unformatted I/O.
HP Fortran statements READ Namelist-directed I/O Each of the four READ statements in the next example uses a different style of syntax to do exactly the same thing: NAMELIST /nl/ a, b, c READ (UNIT=5, NML=nl) ! 5 = standard input READ (5, nl) READ (*, NML=nl) ! * = standard input READ nl ! assume standard input List-directed I/O The following statement takes its data from standard input, storing the converted value in int_var. The format conversion is based on the type of int_var.
HP Fortran statements REAL REAL Declares entities of type real. Syntax REAL [kind-spec] [[, attrib-list] ::] entity-list kind-spec is the kind type parameter that specifies the range and precision of the entities in entity-list. kind-spec takes the form: ([KIND=]kind-param) where kind-param can be a named constant or a constant expression that has the integer value of 4, 8, or 16. The size of the default type is 4.
HP Fortran statements REAL Description The REAL statement is used to declare the length and properties of data that approximate the mathematical real numbers. A kind parameter (if present) indicates the representation method. The REAL statement is constrained by the rules for all type declaration statements, including the requirement that it precede all executable statements.
HP Fortran statements REAL • “KIND(X)” on page 577 Chapter 10 447
HP Fortran statements RECORD (extension) RECORD (extension) Declares a record of a previously defined structure. Syntax RECORD /struct-name/rec-name [, rec-name]... [/struct-name/rec-name [, rec-name ] ]... struct-name is the name of a structure declared in a previous structure definition. rec-name is a record name. Description HP Fortran supports the RECORD statement as a compatibility extension. New programs should use the derived type, a standard feature of Fortran 90.
HP Fortran statements RECORD (extension) Given the following structure definition and record declarations: STRUCTURE /abc/ REAL a, b, c(5) STRUCTURE /xyz/ xyz, xyzs(5) INTEGER x, y, z(3) END STRUCTURE END STRUCTURE RECORD /abc/ abc, abcs(100) RECORD /xyz/ xyz the following are composite references: abc !composite record references abcs(1) xyz abcs(idx) abc.xyz !composite field references abc.xyzs(3) and the following are simple references: abc.a abc.c(1) xyz.x xyz.z(1) abc.xyz.x abcs(idx).xyz.
HP Fortran statements RECORD (extension) Simple field references can appear wherever a variable can appear. The following assigns values to the fields of record r of structure struct: STRUCTURE /struct/ INTEGER i REAL a END STRUCTURE RECORD /struct/ r r.i = r.i + 1 r.a = FLOAT(r.i) - 2.7 Composite assignment is allowed for two records or two composite fields of the same structure—that is, the record declaration statements for both records must have specified the same struct-name.
HP Fortran statements RECORD (extension) STRUCTURE /iarray/ BYTE elem_count INTEGER arr(100) END STRUCTURE RECORD /intarray/ iarray1 RECORD /iarray/ iarray2 ! The next assignment won't work. The two ! records are not of the same structure. iarray1 = iarray2 ! Invalid When performing I/O on structures and records, composite record and field references can appear only in unformatted I/O statements. They are not allowed in formatted, list-directed, or namelist-directed I/O statements.
HP Fortran statements RETURN RETURN Returns control from a subprogram. Syntax RETURN [scalar-integer-expression] scalar-integer-expression is an optional scalar integer expression that is evaluated when the RETURN statement is executed. It determines which alternate return is used. Description A RETURN statement can appear only in a subprogram.
HP Fortran statements RETURN Related concepts For more information about returning from a procedure call, see “Returning from a procedure reference” on page 164.
HP Fortran statements REWIND REWIND Positions file at its initial point. Syntax The syntax of the REWIND statement can take one of the following forms: • Short form: integer-expression • Long form: REWIND (io-specifier-list) integer-expression is the unit connected to a sequential file or device. io-specifier-list is a list of the following comma-separated I/O specifiers: [UNIT=]unit specifies the unit connected to an external file opened for sequential access.
HP Fortran statements REWIND Examples The following example of the REWIND statement repositions the file connected to unit 10 to its initial point: REWIND 10 The next example repositions to its initial point the file connected to unit 21.
HP Fortran statements SAVE (statement and attribute) SAVE (statement and attribute) Stores variables in static memory. Syntax A type declaration statement with the SAVE attribute is: type , attrib-list :: save-list type is a valid type specification (INTEGER, REAL, LOGICAL, CHARACTER, TYPE (name), etc.).
HP Fortran statements SAVE (statement and attribute) • Derived type objects • Records If the name of a common block appears in save-list, it must be delimited by slashes (for example, /my_block/); all variables in the named common block are saved. If a common block is saved in one program unit, it must be saved in all program units (except main) where it appears. HP Fortran always saves all common blocks.
HP Fortran statements SAVE (statement and attribute) Related concepts For related information, see the following: • “Type declaration for intrinsic types” on page 109 • “Recursive reference” on page 164 • Information about automatic and static variables, in the HP Fortran Programmer’s Guide 458 Chapter 10
HP Fortran statements SELECT CASE SELECT CASE Begins CASE construct. Syntax [construct-name :] SELECT CASE (case-expr) construct-name is the name given to the CASE construct. case-expr is a scalar expression of type integer, character, or logical. Description The SELECT CASE statement, the first statement of a CASE construct, causes case-expr to be evaluated, resulting in the case index. The CASE construct uses the case index to determine which of its statement blocks to execute.
HP Fortran statements SEQUENCE SEQUENCE Imposes storage sequence on components of derived type object. Syntax SEQUENCE Description The SEQUENCE statement can appear once within any derived type definition; its presence specifies that a storage sequence on the components that is the same as their definition order. A derived type that includes the SEQUENCE statement in its definition is known as a sequence derived type.
HP Fortran statements SEQUENCE INTEGER high_temp, low_temp CHARACTER(LEN=16) conditions END TYPE weather Related statements TYPE, COMMON, and EQUIVALENCE Related concepts For information about sequence derived types, see “Sequence derived type” on page 125.
HP Fortran statements STATIC (statement, attribute, extension) STATIC (statement, attribute, extension) Gives variables and arrays static storage. Syntax The syntax of a type declaration statement with the STATIC attribute is: type, attribute-list :: entity-list type is a valid type specification (INTEGER, REAL, LOGICAL, CHARACTER, TYPE ( name), etc.), as described in Chapter 5, “Data types and data objects,” on page 105.
HP Fortran statements STATIC (statement, attribute, extension) IF (first_call) ncalls = 0 ncalls = ncalls + 1 ! record how often work_out is called ...
HP Fortran statements STOP STOP Terminates program execution. Syntax STOP [stop-code] stop-code is a character constant, a named constant, or a list of up to 5 digits. Description The STOP statement terminates program execution and optionally prints a message to standard error or standard list.
HP Fortran statements STRUCTURE (extension) STRUCTURE (extension) Defines a named structure. Syntax STRUCTURE /struct-name/ field-def ... END STRUCTURE struct-name is the structure’s name, delimited by slashes. struct-name can be used later to declare a record. field-def is a field definition. Description HP Fortran supports the STRUCTURE statement as a compatibility extension.
HP Fortran statements STRUCTURE (extension) At the simplest level, field-def can be a type declaration statement. As such, field-def has the same syntax as a standard Fortran 90 type declaration statement, except that the only attribute that can be specified is the DIMENSION attribute. A variable defined with a type declaration statement is called a field.
HP Fortran statements STRUCTURE (extension) STRUCTURE /foo_bar/ REAL, DIMENSION(30, 50) :: bar END STRUCTURE The array’s dimensions must in any case appear in the type statement. The DIMENSION statement (but not the DIMENSION attribute) is illegal in a structure definition.
HP Fortran statements STRUCTURE (extension) STRUCTURE /sixbytes/ INTEGER(KIND=2) :: twobytes CHARACTER(LEN=4) :: %FILL END STRUCTURE %FILL can be of any type and may appear more than once in a structure. %FILL should not be needed in normal usage. The compiler automatically adds padding to ensure proper alignment. Nested structures A field-def can itself be a structure definition, known as a nested structure.
HP Fortran statements STRUCTURE (extension) If /struct-name/ is present in a nested structure definition, the structure struct-name can also be used in subsequent record declarations. For example, the following code defines a structure named person, which contains a nested structure named name. The structure’s field name is nm and contains three CHARACTER*10 fields: last, first, and mid. STRUCTURE /person/ INTEGER :: person_id ! Define the nested structure 'name' with the field name 'nm'.
HP Fortran statements STRUCTURE (extension) Nested records A field-def can be a record declaration, known as a nested record. See “RECORD (extension)” on page 448 for information about record declarations.) A nested record declaration must use a structure that has already been defined. The following code first defines the structure date.
HP Fortran statements STRUCTURE (extension) • A type declaration statement • Another nested structure • A nested record • A union definition Note that a structure definition allows multiple levels of nesting. For programmers who are familiar with C or Pascal, HP Fortran unions are similar to unions in C and variant records in Pascal. HP Fortran unions differ from C unions in that they must be defined inside a structure definition. The structure below contains a union with two map blocks.
HP Fortran statements STRUCTURE (extension) Once a value is assigned to a map block, all other map blocks become undefined. The reason is that all map blocks share memory space within a union; therefore, the values of one map block may become altered if you assign a value to a field in another map block.
HP Fortran statements STRUCTURE (extension) STRUCTURE /wordmask/ UNION MAP INTEGER(KIND=4) :: word END MAP MAP BYTE :: byte0, byte1, byte2, byte3 END MAP END UNION END STRUCTURE RECORD /wordmask/ maskrec If we assign a value to the word field of maskrec, we can then get the individual values of all four bytes in maskrec by looking at the fields byte0, byte1, byte2, and byte3.
HP Fortran statements SUBROUTINE SUBROUTINE Begins the definition of a subroutine subprogram. Syntax [RECURSIVE] SUBROUTINE subr-name [([dummy-arg-list])] subr-name is the name of a subroutine. dummy-arg-list is a comma-separated list of zero or more of dummy-arg-name or the asterisk character (*). As indicated by the syntax, the parentheses surrounding the dummy arguments may be omitted if there are no dummy arguments.
HP Fortran statements SUBROUTINE SUBROUTINE altitude (*, long, lat) ! asterisk (*) indicates alternate return IMPLICIT NONE INTEGER, OPTIONAL :: long, lat RETURN 1 END SUBROUTINE altitude The preceding subroutines may be referenced with the CALL statement, as in the following program: PROGRAM reject CALL exchange (a,t) ! A subroutine reference ! subroutine reference, including an alternate return label, ! missing optional argument, and an argument keyword CALL altitude (*90, lat = 49) END PROGRAM reject F
HP Fortran statements TARGET (statement and attribute) TARGET (statement and attribute) Allows variables and arrays to be pointer targets. Syntax The syntax of a type declaration statement with the TARGET attribute is: type, attrib-list :: entity-list type is a valid type specification (INTEGER, REAL, LOGICAL, CHARACTER, TYPE (name), etc.).
HP Fortran statements TARGET (statement and attribute) TARGET [::] object-name [(array-spec)] [, object-name [(array-spec)]]... array-spec Table 10-52 explicit-shape-spec is [lower-bound :] upper-bound assumed-shape-spec is [lower-bound] : deferred-shape-spec is : assumed-size-spec is [explicit-shape-spec-l ist ,] [lower-bound :] * That is, an assumed-size-spec is an explicit-shape-spec-list with the final upper bound given as *.
HP Fortran statements TARGET (statement and attribute) ! make p point to a rank-2 section of t p => t(10,1:10,2:5) REAL, POINTER :: nootka(:), talk(:) REAL, ALLOCATABLE, TARGET :: x(:) ALLOCATE (x(1:100), STAT = is) nootka => x(51:100) ! Pointer assignment statements talk => x(1:50) REAL r, p1, p2 TARGET r POINTER p1, p2 r = 4.7 ! make both p1 and p2 aliases of r p1 => r p2 => p1 ... ALLOCATE (p1) p1 = 9.
HP Fortran statements TASK COMMON (extension) TASK COMMON (extension) Declares a common block to be local to a thread during parallel execution. NOTE A program that uses the TASK COMMON statement should be compiled with the +Oparallel or +parallel option; otherwise, the compiler treats the TASK COMMON statement as a COMMON statement. NOTE In case of Fortran Version 3.2 and higher, the +Oparallel option is not available on Integrity systems.
HP Fortran statements TASK COMMON (extension) Related statements COMMON Related concepts For related information, see the following: • “Type declaration for intrinsic types” on page 109 • “Implicit typing” on page 113 • “Array declarations” on page 59 • “Array constructors” on page 75 • “Expressions” on page 85 480 Chapter 10
HP Fortran statements TYPE (declaration) TYPE (declaration) Declares a variable of derived type. Syntax TYPE (type-name) [[, attrib-list] ::] entity-list type-name is the name of a previously defined derived type. attrib-list is a comma-separated list of one or more of the following attributes: Table 10-53 ALLOCATABLE INTRINSIC PRIVATE DIMENSION OPTIONAL PUBLIC EXTERNAL PARAMETER SAVE INTENT POINTER TARGET If attrib-list is present, it must be followed by the double colon.
HP Fortran statements TYPE (declaration) must be preceded by the double colon. Description The TYPE declaration statement specifies the type and attributes of derived-type objects. A derived-type object may be an array, which may be deferred shape (pointer or allocatable), assumed shape (dummy argument), or assumed size (dummy argument). Assignment is intrinsically defined for each derived type but may be redefined by the user.
HP Fortran statements TYPE (declaration) TYPE (Point) a, b, t(100,100) ! Three variables of type Point b = Point(0.,0.,Polar(0.,0.)) ! Use of nested structure constructors. Related statements INTERFACE, PRIVATE, PUBLIC, SEQUENCE, and TYPE (definition) Related concepts For information about derived types, see “Derived types” on page 123.
HP Fortran statements TYPE (definition) TYPE (definition) The first statement of a derived type definition. Syntax TYPE [[, access-spec ] ::] derived-type-name access-spec is the keyword PUBLIC or PRIVATE. derived-type-name is a legal Fortran 90 name. Description The TYPE statement introduces the definition of a derived type.
HP Fortran statements TYPE (definition) ! operations provide all functionality. TYPE, PUBLIC :: set; PRIVATE INTEGER cardinality INTEGER element ( max_set_size ) END TYPE set ! Declare scalar and array of type set. TYPE (set) :: baker, fox(1:size(hh)) Related statements INTERFACE, PRIVATE, PUBLIC, SEQUENCE, and TYPE (declaration) Related concepts For information about derived types, see “Derived types” on page 123.
HP Fortran statements TYPE (I/O) (extension) TYPE (I/O) (extension) Writes to standard output. Description The TYPE statement is a synonym for the PRINT statement and has the same functionality and syntax. It is provided as an HP extension for compatibility with earlier versions of Fortran. For more information, see “PRINT” on page 431.
HP Fortran statements UNION (extension) UNION (extension) Defines a union within a structure. Syntax UNION map-block map-block ... END UNION map-block is one or more of the following: • A type declaration statement • Another nested structure • A nested record • A union definition Description The UNION statement is an HP Fortran extension that is used with the MAP statement to define a union within a structure.
HP Fortran statements USE USE Provides controlled access to module entities.
HP Fortran statements USE Entities made accessible by a USE statement include public entities from other modules referenced by USE statements within the referenced module. The same name or specifier may be made accessible by means of two or more USE statements. Such an entity must not be referenced in the scoping unit containing the USE statements, except where specific procedures can be distinguished by the overload rules.
HP Fortran statements VIRTUAL (extension) VIRTUAL (extension) Declares an array. Syntax VIRTUAL array-declarator-list array-declarator-list is a comma-separated list of array declarators. Description The VIRTUAL statement is an HP extension in HP Fortran for compatibility with earlier versions of Fortran. It is an alternative to the DIMENSION statement. VIRTUAL cannot be used as an attribute in type declaration statements.
HP Fortran statements VOLATILE (extension) VOLATILE (extension) Provides for data sharing between asynchronous processes. Syntax VOLATILE [::] object-name-list object-name-list is a comma-separated list of the following: • variable-name • array-name • common-block-name Description It is only necessary to declare an object as VOLATILE when its value may be altered by an independent asynchronous process or event (for example, a signal handler).
HP Fortran statements WHERE (statement and construct) WHERE (statement and construct) Performs masked array assignments. Syntax WHERE (array-logical-expr) [array-assignment-statement] If the optional array-assignment clause is present, the WHERE statement is syntactically complete and does not require the END WHERE statement. If the array-assignment clause is not present, the WHERE statement is the first statement of a WHERE construct.
HP Fortran statements WHERE (statement and construct) • array-assignment-statement must be an intrinsic array assignment statement; no defined assignment statements are permitted. • Each elemental operation in array-assignment-statement is masked by the array logical expression. • The elements of the arrays that are used in the WHERE part (the assignments after the WHERE keyword) are those corresponding to the true elements of the array logical expression.
HP Fortran statements WHERE (statement and construct) The first two assignment statements are processed for elements corresponding to true elements of the mask. The second two assignment statements are processed for elements corresponding to false elements of the mask. Unlike the ELSE clause of an IF statement, the assignment statements in both the WHERE and ELSEWHERE parts are processed. Note the different behavior of the calls to ABS.
HP Fortran statements WHERE (statement and construct) Related concepts For related information, see the following: • The discussion of arrays in Chapter 3, “Arrays,” on page 55 • “Masked array assignment” on page 101 Chapter 10 495
HP Fortran statements WRITE WRITE Outputs data to external and internal files. Syntax WRITE (io-specifier-list) [output-list] output-list is a list of comma-separated data items for output. The data items can include expressions and implied-DO. io-specifier-list is a list of the following comma-separated I/O specifiers: [UNIT=]unit specifies the unit connected to the output file.
HP Fortran statements WRITE NOTE The NML= and FMT= specifier may not both appear in the same io-specifier-list. [NML=]name specifies the name of a namelist group for namelist-directed output. name must have been defined in a NAMELIST statement. If the optional keyword NML= is omitted, name must be the second item in the list. The first item must be the unit specifier without the optional keyword UNIT=. The NML= and FMT= specifier may not both appear in the same io-specifier-list.
HP Fortran statements WRITE Description The WRITE statement transfers data from internal storage to an external or internal file. An external file can be opened for sequential access or direct access I/O. If it is opened for sequential access, the WRITE statement can perform the following types of I/O: • Formatted • Unformatted • List-directed • Namelist-directed If the file is opened for direct access, the WRITE statement can perform formatted or unformatted I/O.
HP Fortran statements WRITE In the next example, each of the four WRITE statements following the NAMELIST statement uses a different style of syntax to do exactly the same thing: NAMELIST /nl/ a, b, c WRITE (UNIT=6, NML=nl) ! 6 = standard output WRITE (6, nl) WRITE (*, NML=nl) ! * = standard output WRITE nl ! assume standard output List-directed I/O WRITE (6, *) int_var This statement converts the value of int_var to character format and outputs the character string to standard output.
HP Fortran statements WRITE 500 Chapter 10
11 Intrinsic procedures Intrinsic procedures are built-in functions and subroutines that are available by default to every Fortran 90 program and procedure. This chapter describes the intrinsic procedures provided by HP Fortran. All intrinsic procedures defined by the Fortran 90 Standard are supported in HP Fortran.
Intrinsic procedures The following topics are described in this chapter: • Basic terms and concepts • Nonstandard intrinsic procedures • Data representation models • Functional categories of intrinsic procedures • Intrinsic procedure specifications NOTE 502 HP Fortran intrinsic procedures are provided in the libraries /opt/fortran90/lib/libF90.a and /usr/lib/libcl.a. /usr/lib/libcl.2 is used instead of libcl.a if using shared libraries (the default).
Intrinsic procedures Basic terms and concepts Basic terms and concepts The following sections describe the terms and concepts that are used in this chapter to describe intrinsic procedures.
Intrinsic procedures Basic terms and concepts NOTE Some compile-line options—for example, +autodbl—change the default data type sizes and can cause different or invalid intrinsic procedure references. Classes of intrinsics Intrinsic procedures are classified as: • Elemental intrinsics • Transformational functions • Inquiry functions The following sections describe each class. The descriptions in “Intrinsic procedure specifications” on page 514 identify the class of each intrinsic.
Intrinsic procedures Basic terms and concepts Optimized intrinsic functions The following intrinsics are available in millicode versions, which are optimized for performance. To get access the millicode intrinsics, you must optimize at level 2 or higher, or compile with the +Olibcalls option. See the Fortran 90 Programmer’s Guide for information on this.
Intrinsic procedures Nonstandard intrinsic procedures Nonstandard intrinsic procedures HP Fortran 90 supports all intrinsic procedures defined by the Fortran 90 Standard. In addition, it supports the nonstandard intrinsic procedures listed in Table 11-3 on page 511. Like the standard intrinsics, the nonstandard intrinsics are part of the HP Fortran 90 language: their recognition is not enabled by compile-line options, and their generic nature, types, and dummy argument attributes are known to the compiler.
Intrinsic procedures Data representation models Data representation models The Fortran 90 Standard specifies data representation models that suggest how data are represented in the computer and how computations are performed on the data. The computations performed by some Fortran 90 intrinsic functions are described in terms of these models.
Intrinsic procedures Data representation models Table 11-2 Intrinsic functions and data representation models (Continued) Intrinsic function Description “PRECISION(X)” on page 603 Decimal precision in real model for X “RADIX(X)” on page 607 Base (radix) in integer or real model for X “RANGE(X)” on page 610 Decimal exponent range in integer or real model for X “RRSPACING(X)” on page 615 1/(relative spacing near X) “SCALE(X, I)” on page 616 X with real model exponent changed by I “SET_EXPONENT(X
Intrinsic procedures Data representation models The Integer Number System Model The integer number system is modeled by: q–1 i = s ∑ dk r k=0 k where i is the integer value. s is the sign (+1 or –1). r is the radix given by the intrinsic function RADIX (always 2 for HP systems). q is the number of digits (integer greater than 0), given by the intrinsic function DIGITS. d is the kth digit and is an integer 0 <= d< r. The digits are numbered left to right, beginning with 1.
Intrinsic procedures Data representation models s is the sign (+1 or –1). b is the base (real radix) and is an integer greater than 1, given by the intrinsic function RADIX (always 2 for HP systems). e is an integer between some minimum value (lmin) and maximum value (lmax), given by the intrinsic functions MINEXPONENT and MAXEXPONENT. p is the number of mantissa digits and is an integer greater than 1, given by the intrinsic function DIGITS.
Intrinsic procedures Functional categories of intrinsic procedures Functional categories of intrinsic procedures This section categorizes HP Fortran intrinsic procedures based on their functionality.
Intrinsic procedures Functional categories of intrinsic procedures Table 11-3 Intrinsic procedures by category (Continued) Category Intrinsic routines Array reshape RESHAPE Bit inquiry BIT_SIZE Bit manipulation BTEST, IAND, IBCLR, IBITS, IBSET, IEOR, IOR, ISHFT, ISHFTC, MVBITS, NOT Character computation ACHAR, ADJUSTL, ADJUSTR, CHAR, IACHAR, ICHAR, INDEX, LEN_TRIM, LGE, LGT, LLE, LLT, REPEAT, SCAN, TRIM, VERIFY Character inquiry LEN Floating-point manipulation EXPONENT, FRACTION, NEAREST, RRS
Intrinsic procedures Functional categories of intrinsic procedures Table 11-3 Intrinsic procedures by category (Continued) Category Intrinsic routines Pseudorandom number RANDOM_NUMBER, RANDOM_SEED Time DATE_AND_TIME, SYSTEM_CLOCK Transfer TRANSFER Vector multiply DOT_PRODUCT Chapter 11 513
Intrinsic procedures Intrinsic procedure specifications Intrinsic procedure specifications The following sections describe the HP Fortran intrinsic procedures. The descriptions are ordered alphabetically, by intrinsic name. All of the intrinsics are generic. This means that the type, kind, and rank of the actual arguments can differ for each reference to the same intrinsic. In many cases, the kind and type of intrinsic function results are the same as that of the principal argument.
Intrinsic procedures Intrinsic procedure specifications Result type/ type parameters The same as A except that if A is complex, the result is real. Result value(s) • If A is of type integer or real, the value of the result is |A|. • If A is complex with value (x, y), the result is equal to a processor-dependent approximation to the square root of (x2 + y2). Specific forms BABS, CABS, CDABS, DABS, HABS, QABS, ZABS.
Intrinsic procedures Intrinsic procedure specifications ACHAR(IACHAR(C)) must have the value C for any character C capable of representation in the processor. ACOS(X) Description Arccosine (inverse cosine) function in radians. Class Elemental function. Argument X must be of type real with a value that satisfies the inequality |X| <= 1. Result type/ type parameters Same as X. Result value The result has a value equal to a processor-dependent approximation to arccos(X), expressed in radians.
Intrinsic procedures Intrinsic procedure specifications Result type/ type parameters Same as X. Result value The result has a value equal to a processor-dependent approximation to arccos(X), expressed in degrees. It lies in the range 0 <= ACOSD(X) <= 180. Specific forms DACOSD, QACOSD. ACOSH(X) Description Hyperbolic arccosine of radians. Class Elemental nonstandard function. Argument X must be of type real with a value X >= 1. Result type/ type parameters Same as X.
Intrinsic procedures Intrinsic procedure specifications ADJUSTL(STRING) Description Adjust to the left, removing leading blanks and inserting trailing blanks. Class Elemental function. Argument STRING must be of type character. Result type Character of the same length and kind type parameter as STRING. Result value The value of the result is the same as STRING except that any leading blanks have been deleted and the same number of trailing blanks have been inserted.
Intrinsic procedures Intrinsic procedure specifications AIMAG(Z) Description Imaginary part of a complex number. Class Elemental function. Argument Z must be of type complex. Result type/ type parameters Real with the same kind type parameter as Z. Result value If Z has the value (x, y), the result has value y. AINT(A, KIND) Optional argument KIND Description Truncation to a whole number. Class Elemental function. Arguments A must be of type real.
Intrinsic procedures Intrinsic procedure specifications Result type/ type parameters The result is of type real. If KIND is present, the kind type parameter is that specified by KIND; otherwise, the kind type parameter is that of A. Result value If |A| < 1, AINT(A) has the value 0; if A >= 1, AINT(A) has a value equal to the integer whose magnitude is the largest integer that does not exceed the magnitude of A and whose sign is the same as the sign of A. Specific forms DDINT,DINT,QINT.
Intrinsic procedures Intrinsic procedure specifications Result type, type parameters, and shape The result is of type logical with the same kind type parameter as MASK. It is scalar if DIM is absent or MASK has rank one; otherwise, the result is an array of rank n-1 and of shape (d1, d2, ..., dDIM-1, dDIM+1, ..., dn) where (d1, d2, ..., dn) is the shape of MASK. Result value Case 1 The result of ALL(MASK) has the value .TRUE. if all elements of MASK are .TRUE.
Intrinsic procedures Intrinsic procedure specifications AND(I, J) Description Logical AND. Class Elemental nonstandard function. Arguments I must be of type integer. J must be of type integer with the same kind type parameter as I. Result type/ type parameters Same as I. Result value The result has the value obtained by performing a logical AND on I and J bit-by-bit according to Table 11-4.
Intrinsic procedures Intrinsic procedure specifications ANINT(A, KIND) Optional argument KIND Description Nearest whole number. Class Elemental function. Arguments A must be of type real. KIND (optional) must be a scalar integer initialization expression. Result type/ type parameters The result is of type real. If KIND is present, the kind type parameter is that specified by KIND; otherwise, the kind type parameter is that of A. Result value If A>0, ANINT(A) has the value AINT(A+0.
Intrinsic procedures Intrinsic procedure specifications Class Transformational function. Arguments MASK must be of type logical. It must not be scalar. DIM (optional) must be scalar and of type integer with a value in the range 1 <= DIM <= n, where n is the rank of MASK. The corresponding actual argument must not be an optional dummy argument. Result type, type parameters, and shape The result is of type logical with the same kind type parameter as MASK.
Intrinsic procedures Intrinsic procedure specifications Result type/ type parameters Same as X. Result value The result has a value equal to a processor-dependent approximation to arcsin(X), expressed in radians. It lies in the range -Pi/2 <= ASIN(X) <= Pi/2. Specific forms DASIN, QASIN. ASIND(X) Description Arcsine (inverse sine) function in degrees. Class Elemental nonstandard function. Argument X must be of type real. Its value must satisfy the inequality |X| <= 1.
Intrinsic procedures Intrinsic procedure specifications ASINH(X) Description Hyperbolic arcsine of radians. Class Elemental nonstandard function. Argument X must be of type real. Result type/ type parameters Same as X. Result value The result has a value equal to a processor-dependent approximation to the hyperbolic arcsine of X. Specific forms DASINH, QASINH.
Intrinsic procedures Intrinsic procedure specifications Arguments POINTER must be a pointer and may be of any type. Its pointer association status must not be undefined. TARGET (optional) must be a pointer or target. If it is a pointer, its pointer association status must not be undefined. Result type The result is scalar of type default logical. Result value Case 1 If TARGET is absent, the result is .TRUE. if POINTER is currently associated with a target and .FALSE. if it is not.
Intrinsic procedures Intrinsic procedure specifications Result value The result has a value equal to a processor-dependent approximation to arctan(X), expressed in radians, that lies in the range -Pi/2 <= ATAN(X) <= Pi/2. Specific forms DATAN, QATAN. ATAN2(Y, X) Description Arctangent (inverse tangent) function in radians. The result is the principal value of the argument of the nonzero complex number (X, Y). Class Elemental function. Arguments Y must be of type real.
Intrinsic procedures Intrinsic procedure specifications ATAN2D(Y, X) Description Arctangent (inverse tangent) function in degrees. Class Elemental nonstandard function. Arguments Y must be of type real. X must be of the same type and kind type parameter as Y. Result type/ type parameters Same as X.
Intrinsic procedures Intrinsic procedure specifications Result type/ type parameters Same as X. Result value The result has a value equal to a processor-dependent approximation to arctan(X), expressed in degrees, that lies in the range -90 < ATAND(X) < 90. Specific forms DATAND,QATAND. ATANH(X) Description Hyperbolic arctangent of radians. Class Elemental nonstandard function. Argument X must be of type real. Result type/ type parameters Same as X.
Intrinsic procedures Intrinsic procedure specifications BADDRESS(X) Description Return the address of X. Class Inquiry nonstandard function. Argument X may be of any type. Result type The result is of type default integer. BIT_SIZE(I) Description Returns the number of bits n, defined by the model described in “The Bit Model” on page 508, for integers with the kind parameter of the argument. Class Inquiry function. Argument I must be of type integer.
Intrinsic procedures Intrinsic procedure specifications BTEST(I, POS) Description Tests a bit of an integer value. Class Elemental function. Arguments I must be of type integer. POS must be of type integer. It must be nonnegative and be less than BIT_SIZE(I). Result type The result is of type default logical. Result value The result has the value .TRUE. if bit POS of I has the value 1 and has the value .FALSE. if bit POS of I has the value 0.
Intrinsic procedures Intrinsic procedure specifications Result type/ type parameters Default integer. Result value The result has a value equal to the least integer greater than or equal to A. The result is undefined if the processor cannot represent this value in the default integer type. CHAR(I, KIND) Optional argument KIND Description Returns the character in a given position of the processor collating sequence associated with the specified kind type parameter. It is the inverse of the function ICHAR.
Intrinsic procedures Intrinsic procedure specifications ICHAR(CHAR(I, KIND(C))) must have the value I for 0 <= I <= n-1 and CHAR(ICHAR(C), KIND(C)) must have the value C for any character C capable of representation in the processor. CMPLX(X, Y, KIND) Optional arguments Y, KIND Description Convert to complex type. Class Elemental function. Arguments X must be of type integer, real, or complex. Y (optional) must be of type integer or real. It must not be present if X is of type complex.
Intrinsic procedures Intrinsic procedure specifications CONJG(Z) Description Conjugate of a complex number. Class Elemental function. Argument Z must be of type complex. Result type/ type parameters Same as Z. Result value If Z has the value (x, y), the result has the value (x, -y). Specific forms DCONJG. COS(X) Description Cosine function in radians. Class Elemental function. Argument X must be of type real or complex. Result type/ type parameters Same as X.
Intrinsic procedures Intrinsic procedure specifications Result value The result has a value equal to a processor-dependent approximation to cos(X). If X is of type real, it is regarded as a value in radians. If X is of type complex, its real part is regarded as a value in radians. Specific forms CCOS, CDCOS, DCOS, QCOS, ZCOS. COSD(X) Description Cosine function in degrees. Class Elemental nonstandard function. Argument X must be of type real. Result type/ type parameters Same as X.
Intrinsic procedures Intrinsic procedure specifications Class Elemental function. Argument X must be of type real. Result type/ type parameters Same as X. Result value The result has a value equal to a processor-dependent approximation to cosh(X). Specific forms DCOSH, QCOSH. COUNT(MASK, DIM) Optional argument DIM Description Count the number of .TRUE. elements of MASK along dimension DIM. Class Transformational function. Arguments MASK must be of type logical. It must not be scalar.
Intrinsic procedures Intrinsic procedure specifications Result type, type parameters, and shape The result is of type default integer. It is scalar if DIM is absent or MASK has rank one; otherwise, the result is an array of rank n-1 and of shape (d1, d2, ..., dDIM-1, dDIM+1, ..., dn) where (d1, d2, ..., dn) is the shape of MASK. Result value Case 1 The result of COUNT(MASK) has a value equal to the number of .TRUE. elements of MASK or has the value zero if MASK has size zero.
Intrinsic procedures Intrinsic procedure specifications Arguments ARRAY may be of any type. It must not be scalar. SHIFT must be of type integer and must be scalar if ARRAY has rank one; otherwise, it must be scalar or of rank n-1 and of shape (d1, d2, ..., dDIM-1, dDIM+1, ..., dn) where (d1, d2, ..., dn) is the shape of ARRAY. DIM (optional) must be a scalar and of type integer with a value in the range 1 <= DIM <= n, where n is the rank of ARRAY.
Intrinsic procedures Intrinsic procedure specifications Argument DATESTR must be of type character. It must be a character string of length 9 or more. DATE_AND_TIME(DATE, TIME, ZONE, VALUES) Optional arguments DATE, TIME, ZONE, VALUES Description Returns data on the real-time clock and date in a form compatible with the representations defined in ISO 8601:1988 (“Data elements and interchange formats — Information interchange — Representation of dates and times”). Class Subroutine.
Intrinsic procedures Intrinsic procedure specifications VALUES (optional) must be of type default integer and of rank one. It is an INTENT(OUT) argument. Its size must be at least 8.
Intrinsic procedures Intrinsic procedure specifications Result type/ type parameters Double precision real. Result value Case 1 If A is of type double precision real, DBLE(A) = A. Case 2 If A is of type integer or real, the result is as much precision of the significant part of A as a double precision real datum can contain. Case 3 If A is of type complex, the result is as much precision of the significant part of the real part of A as a double precision real datum can contain. Specific forms DBLEQ.
Intrinsic procedures Intrinsic procedure specifications DFLOAT(A) Description Convert to double precision type. Class Elemental nonstandard function. Argument A must be of type integer. Result type/ type parameters Double precision. Specific forms DFLOTI, DFLOTJ, DFLOTK. DIGITS(X) Description Returns the number of significant digits in the model representing numbers of the same type and kind type parameter as the argument. Class Inquiry function. Argument X must be of type integer or real.
Intrinsic procedures Intrinsic procedure specifications Result value The result has the value q if X is of type integer and p if X is of type real, where q and p are as defined in “Data representation models” on page 507 for the model representing numbers of the same type and kind type parameter as X. DIM(X, Y) Description The difference X–Y if it is positive; otherwise zero. Class Elemental function. Arguments X must be of type integer or real. Y must be of the same type and kind type parameter as X.
Intrinsic procedures Intrinsic procedure specifications Argument I must be of type character. Result type Double precision. DOT_PRODUCT(VECTOR_A, VECTOR_B) Description Performs dot-product multiplication of numeric or logical vectors. Class Transformational function. Arguments VECTOR_A must be of numeric type (integer, real, or complex) or of logical type. It must be array valued and of rank one.
Intrinsic procedures Intrinsic procedure specifications Case 2 If VECTOR_A is of type complex, the result has the value SUM(CONJG(VECTOR_A)*VECTOR_B). If the vectors have size zero, the result has the value zero. Case 3 If VECTOR_A is of type logical, the result has the value ANY(VECTOR_A .AND. VECTOR_B). If the vectors have size zero, the result has the value .FALSE.. DPROD(X, Y) Description Double precision real product. Class Elemental function. Arguments X must be of type default real.
Intrinsic procedures Intrinsic procedure specifications Argument A must be of type integer, real, or complex. Result Double precision. EOSHIFT(ARRAY, SHIFT, BOUNDARY, DIM) Optional arguments BOUNDARY, DIM Description Perform an end-off shift on an array expression of rank one or perform end-off shifts on all the complete rank-one sections along a given dimension of an array expression of rank two or greater.
Intrinsic procedures Intrinsic procedure specifications must be of the same type and type parameters as ARRAY and must be scalar if ARRAY has rank one; otherwise, it must be either scalar or of rank n-1 and of shape (d1, d2, ..., dDIM-1, dDIM+1, ..., dn). BOUNDARY may be omitted for the data types listed in Table 11-5, which lists the default values of BOUNDARY for each data type. Table 11-5 Default values for the BOUNDARY argument Data type of ARRAY Default value of BOUNDARY Integer 0 Real 0.
Intrinsic procedures Intrinsic procedure specifications EPSILON(X) Description Returns a positive model number that is almost negligible compared to unity in the model representing numbers of the same type and kind type parameter as the argument. Class Inquiry function. Argument X must be of type real. It may be scalar or array valued. Result type, type parameters, and shape Scalar of the same type and kind type parameter as X.
Intrinsic procedures Intrinsic procedure specifications If STATUS is supplied, the calling program exits with a return code status of STATUS. Otherwise the return code status is indeterminate. In csh the $status environment variable holds the return code for the last executed command. In ksh, the $? environment variable holds the return code. EXP(X) Description Exponential. Class Elemental function. Argument X must be of type real or complex. Result type/ type parameters Same as X.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.
Intrinsic procedures Intrinsic procedure specifications Argument X must be of type real. Result type Default integer. Result value The result has a value equal to the exponent e of the model representation (see “The Real Number System Model” on page 509) for the value of X, provided X is nonzero and e is within the range for default integers. The result is undefined if the processor cannot represent e in the default integer type. EXPONENT(X) has the value zero if X is zero.