HP 3000 Computer Systems HP FORTRAN 77/iX Reference ABCDE HP Part No. 31501-90010 Printed in U.S.A.
The information contained in this document is subject to change without notice. HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Hewlett-Packard shall not be liable for errors contained herein or use of this material. Hewlett-Packard assumes no responsibility for the use or reliability of its software on equipment that is not furnished by Hewlett-Packard.
Printing History The following table lists the printings of this document, together with the respective release dates for each edition. The software version indicates the version of the software product at the time this document was issued. Many product releases do not require changes to the document. Therefore, do not expect a one-to-one correspondence between product releases and document editions.
Preface This is the reference manual for the HP FORTRAN 77 programming language as it is implemented on the MPE/iX operating system. This manual assumes that the reader has been trained in the FORTRAN language and knows FORTRAN programming techniques.
chapter 10 appendix A appendix B appendix C appendix D appendix E Additional Documentation Describes how HP FORTRAN 77 data types are formatted in memory. Lists and describes compile-time error messages, compiler warnings, ANSI warnings, and run-time errors. Lists the HP FORTRAN 77 intrinsic functions. Compares HP FORTRAN 77 with the ANSI 77 standard, FORTRAN 66/V, and FORTRAN 7X. Presents HP's implementation of the ASCII character set. Lists a program using indexed sequential access (ISAM).
Conventions UPPERCASE In a syntax statement, commands and keywords are shown in uppercase characters. The characters must be entered in the order shown; however, you can enter the characters in either uppercase or lowercase.
{ In a syntax statement, braces enclose required elements. When several elements are stacked within braces, you must select one. In the following example, you must select either ON or OFF: } COMMAND [ ON OFF In a syntax statement, brackets enclose optional elements. In the following example, OPTION can be omitted: ] COMMAND lename [OPTION] When several elements are stacked within brackets, you can select one or none of the elements.
Conventions | . .. | (continued) In a syntax statement, horizontal ellipses enclosed in vertical bars indicate that you can select more than one element within the immediately preceding pair of brackets or braces. However, each particular element can only be selected once. In the following example, you must select A, AB, BA, or B. The elements cannot be repeated. ... A | B ... | In an example, horizontal or vertical ellipses indicate where portions of an example have been omitted.
Contents 1. Introduction to HP FORTRAN 77 The FORTRAN 77 Compiler . . . FORTRAN Vocabulary . . . . . Sample FORTRAN Source File . FORTRAN Terms . . . . . . Source File Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 1-2 1-2 1-4 1-6 The FORTRAN 77 Character Set . Special Symbols . . . . . . . . . Keywords . . . . . . . . . . . . Comments . . . . . . . . . . . . Symbolic Names . . . . . . . . . External Names . . . . . . . .
Octal Constants as Actual Parameters . . Hexadecimal Constants . . . . . . . . . . Hexadecimal Constants in Assignments . . . Hexadecimal Constants as Actual Parameters Variables . . . . . . . . . . . . . . . . . Simple Variables . . . . . . . . . . . . . Arrays . . . . . . . . . . . . . . . . . Array Declarators . . . . . . . . . . . Adjustable Arrays . . . . . . . . . . . Dynamic Arrays . . . . . . . . . . . . Subscripts . . . . . . . . . . . . . . . Array Element Storage . . . . . . . . .
COMPLEX*8 Statement (Nonexecutable) . . . . COMPLEX*16 Statement (Nonexecutable) . . . CONTINUE Statement (Executable) . . . . . . DATA Statement (Nonexecutable) . . . . . . . Implied DO Loops in DATA Statements . . . . DECODE Statement (Executable) . . . . . . . DELETE Statement (Executable) . . . . . . . DIMENSION Statement (Nonexecutable) . . . . DO Statement (Executable) . . . . . . . . . . Labeled and Block DO Loops . . . . . . . . Labeled DO Loop . . . . . . . . . . . . Block DO Loop . . . . . . . . .
ENDIF Statement (Executable) . . . . . . . Nesting IF Statements . . . . . . . . . . . IMPLICIT Statement (Nonexecutable) . . . . . . INCLUDE Statement (Nonexecutable) . . . . . . INQUIRE Statement (Executable) . . . . . . . . INTEGER Statement (Nonexecutable) . . . . . . INTEGER*2 Statement (Nonexecutable) . . . . . INTEGER*4 Statement (Nonexecutable) . . . . . INTRINSIC Statement (Nonexecutable) . . . . . . LOGICAL Statement (Nonexecutable) . . . . . . LOGICAL*1 Statement (Nonexecutable) . . . . .
A DEFAULT PARMS Parameter . A READONLY Parameter . . . . . TYPE Statement (Executable) . . . . UNION Statement (Nonexecutable) . . UNLOCK Statement (Executable) . . VIRTUAL Statement (Nonexecutable) VOLATILE Statement (Nonexecutable) WRITE Statement (Executable) . . . 4. Input/Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Formatted Input/Output . . . . . . . . . . . . Formatted Input . . . . . . . . . . . . . . . Formatted Output . . . . . . .
List-Directed Output . . . . Namelist-Directed Input/Output Namelist Speci er . . . . . Namelist-Directed Input . . . Namelist-Directed Output . . 5. File Handling The OPEN Statement . . . . . The FNUM Procedure . . . . The FSET Procedure . . . . . The UNITCONTROL Procedure Automatically Opening Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-48 4-52 4-52 4-53 4-58 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
INIT Directive . . . . . . . . . LINES Directive . . . . . . . . LIST Directive . . . . . . . . . LIST CODE Directive . . . . . LITERAL ALIAS Directive . . . LOCALITY Directive . . . . . . LONG Directive . . . . . . . . LOWERCASE Directive . . . . MIXED FORMATS Directive . . NLS Directive . . . . . . . . . NLS SOURCE Directive . . . . NOSTANDARD Directive . . . . CHARS Option . . . . . . . LOGICALS Option . . . . . . IO Option . . . . . . . . . . SYSTEM Option . . . . . . . INTRINSICS Option . . . . .
8. Interfacing with Non-FORTRAN Subprograms Parameter Passing Methods . . . . . Use of COMMON and Labels . . . . Files . . . . . . . . . . . . . . . FORTRAN and C . . . . . . . . . Logicals . . . . . . . . . . . . . Arrays . . . . . . . . . . . . . Files . . . . . . . . . . . . . . Parameter Passing Methods . . . . Complex Numbers . . . . . . . . Character . . . . . . . . . . . . Default Character Passing Method Hollerith . . . . . . . . . . . . FORTRAN and Pascal Data Types . . Condition Codes . . . . . .
A. Diagnostic Messages Compile-Time Diagnostics Run-Time Errors . . . . Compile-Time Errors . . Compile-Time Warnings . ANSI Warnings . . . . Run-Time Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1 A-2 A-3 A-49 A-62 A-73 Invoking an Intrinsic Function . . . . . . . . Generic and Speci c Function Names . . . . . Summary of the Intrinsic Functions . . . . . . Notes for Tables B-1 through B-8 . . . . . .
IBCLR Function . . IBITS Function . . IBSET Function . . ICHAR Function . . IEOR Function . . . IMAG Function . . INDEX Function . . INT Function . . . INUM Function . . IOR Function . . . ISHFT Function . . ISHFTC Function . IXOR Function . . IZEXT . . . . . . JNUM Function . . LEN Function . . . LGE Function . . . LGT Function . . . LLE Function . . . LLT Function . . . LOG Function . . . LOG10 Function . . MAX Function . . . MIN Function . . . MOD Function . . . MVBITS Subroutine NINT Function . .
C. FORTRAN Comparisons Extensions to the Standard . . . . . . . . . . . MIL-STD-1753 Extensions . . . . . . . . . . . Other Extensions . . . . . . . . . . . . . . . Comparison of HP FORTRAN 77 and FORTRAN 66/V . . . . . . . . . . . . . . . . . . . Comparison of HP FORTRAN 77 and FORTRAN 7X C-2 C-2 C-2 C-6 C-9 D. HP Character Set E.
Figures 1-1. Sample FORTRAN Source File . 3-1. Required Order of Statements . 4-1. Output Formatting . . . . . . 4-2. Input Formatting . . . . . . . 10-1. BYTE (LOGICAL*1) Format . 10-2. INTEGER*2 Format . . . . . 10-3. INTEGER*4 Format . . . . . 10-4. REAL*4 Format . . . . . . . 10-5. REAL*8 Format . . . . . . . 10-6. REAL*16 Format . . . . . . 10-7. COMPLEX*8 Format . . . . . 10-8. COMPLEX*16 Format . . . . 10-9. LOGICAL*2 Format . . . . . 10-10. LOGICAL*4 Format . . . . . B-1. MVBITS Subroutine . . . .
Tables 2-1. 2-2. 2-3. 2-4. 2-5. 2-6. 3-1. 3-2. 3-3. 3-4. Data Type Keywords . . . . . . . . . . . . . 2-7 Data Type Speci cations . . . . . . . . . . . 2-8 Constant Data Types . . . . . . . . . . . . . 2-9 Conversion of Mixed Type Operands . . . . . . 2-52 Truth Table for Logical Operators . . . . . . . 2-57 Truth Table for Masking Operators . . . . . . . 2-58 Executable and Nonexecutable Statements . . . . 3-2 Classi cation of Statements . . . . . . . . . .
1 Introduction to HP FORTRAN 77 Note The FORTRAN language was the rst high level computer language to receive wide acceptance for application programming in the scienti c community. First implemented in 1957, FORTRAN evolved through many changes and extensions, until in 1966 the American National Standards Institute (ANSI) published a \Standard FORTRAN" (X3.9-1966). This standard provided the basic structure of most FORTRAN compilers for many years. Many compilers extended the standard.
The FORTRAN 77 Compiler FORTRAN Vocabulary Sample FORTRAN Source File 1-2 The FORTRAN 77 compiler constructs object language programs from source language les written according to the rules of the FORTRAN language described in this manual. The FORTRAN 77 compiler is executable under various operating systems. The code generated by the compiler, standard binary output les, can be loaded and executed under the speci c operating system.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 $LIST ON PROGRAM exone C This program shows program structure. C The purpose of the program is to compute C the sum of the first n integers using C a function subprogram unit. C INTEGER*4 sum,nfunc ! Specification statement. * WRITE(6,'('' Enter value-->'')') ! Prompt user. READ *,n ! Enter integer limit to sum. * Compute sum in subprogram nfunc. sum=nfunc(n) ! Invoke subprogram.
FORTRAN Terms Executable Program Program Unit Main Program Subprogram Line Initial Line Continuation Line 1-4 Introduction to HP FORTRAN 77 An executable program is one that can be used as a self-contained computing procedure. An executable program consists of one main program and its subprograms, if any. (Figure 1-1 shows an executable program in its entirety.) A program unit is a group of statements organized as a main program, a subprogram, or a block data subprogram.
Statement Directive Line Comment Line Debug Line 1. Any characters can appear in columns 2 through 5. A tab character in column 1 through 6 and immediately followed by a digit from 1 to 9 is also a continuation indicator to the compiler; there must be blanks or nothing before the tab character. A line that is longer than 72 characters must use a continuation character and be continued on the next line.
DEBUG compiler directive. (In Figure 1-1, line 22 is a debug line). Source File Structure 1-6 FORTRAN is column sensitive: Compiler directive lines (those starting with keywords preceded by a dollar sign) begin in column 1. All other FORTRAN statements can begin in columns 7 through 72. This permits indenting to improve program appearance. Statement labels appear in columns 1 through 5. Column 6 must be blank or contain a digit 0 for all lines except continuation, comment, and directive lines.
2 Language Elements A FORTRAN program is a sequence of statements that, when executed in a speci ed order, process data to produce desired results. Because each program has di erent data needs, FORTRAN provides 11 data types for constants, variables, functions, and expressions. FORTRAN also provides three additional constant formats, which are extensions to the ANSI 77 standard. All are described in \Data Types" later in this chapter.
(Note that this di ers from the C language, in which lowercase letters are distinct from uppercase letters in identi ers.) Lowercase letters can improve program readability.
In addition, any printable ASCII character can be used in character and Hollerith constants, and in comments. Blanks can be used anywhere within a statement. They are ignored except in character and Hollerith constants and in compiler directives. Special Symbols Symbol ** // .EQ. .NE. .LT. .LE. .GT. .GE. The special symbols are groups of characters that de ne speci c operators and values.
Keywords Keywords are prede ned FORTRAN entities that identify a statement or compiler directive. The statement keywords of FORTRAN are listed below. The compiler directive keywords are given in Chapter 7.
Symbolic Names Symbolic names de ne the names of any of the following: Main program Subroutine or function Block data subprogram Common block Named constant Simple variable Array Record, structure, and record eld Namelist group-name Symbolic names can be user-de ned or prede ned by FORTRAN. Each symbolic name consists of a sequence of characters, the rst of which must be a letter. The rest can be letters, digits, the underscore character (_), or the dollar sign ($).
The name that identi es a variable, named constant, or function also identi es its default data type. A rst letter of I, J, K, L, M, or N implies type INTEGER, either INTEGER*4 (default) or INTEGER*2, depending on the setting of the compiler directives LONG and SHORT. See \Data Types" for more detail. Any other letter implies type REAL. This default implied typing can be rede ned with an IMPLICIT statement. It can be overridden with an explicit type statement.
Data Types Each constant, variable, function, or expression is of one type only. The type de nes: The set of values that an entity of that type can assume. The amount of storage that variables of that type require. The operations that can be performed on an entity of that type. Warning messages are issued for duplicate data type declarations. HP FORTRAN 77 has 11 data types, falling into ve general categories, as shown in Table 2-1. Table 2-1.
Note By default, the type keywords INTEGER and LOGICAL are equivalent to INTEGER*4 and LOGICAL*4, respectively. This is the same as the e ect of the LONG compiler directive. The SHORT compiler directive may be used to make INTEGER and LOGICAL equivalent to INTEGER*2 and LOGICAL*2, respectively. See Chapter 7 for further details. In addition, compiler run-string options can have the same e ect. See Chapter 6 for further details.
Table 2-3. Constant Data Types Data Type Range of Values Hollerith One or more 8-bit ASCII characters 1 Octal Hexadecimal Dependent on context 2 Dependent on context 3 Storage 1 byte per character 16 bytes 16 bytes Notes: 1. See \Typeless Constants" and \Hollerith Constants" in this chapter. 2. See \Typeless Constants" and \Octal Constants" in this chapter. 3. See \Typeless Constants" and \Hexadecimal Constants" in this chapter.
BYTE (LOGICAL*1) Data Type The BYTE (LOGICAL*1) data type can represent: A signed 8-bit integer in the range 0128 to +127. The logical values true and false. An 8-bit ASCII character. Variables and constants of type BYTE are stored in one byte. Refer to Chapter 10 for details. LOGICAL*1 and BYTE are extensions to the ANSI 77 standard. They are equivalent. You can specify a BYTE variable explicitly by declaring it: In a LOGICAL*1 or BYTE type statement.
INTEGER*2 Data Type Note The INTEGER*2 data type represents the set of signed whole numbers in the range 032768 to +32767. Variables and constants of type INTEGER*2 are stored in two bytes. Refer to Chapter 10 for details. INTEGER*2 is an extension to the ANSI 77 standard. You can specify an INTEGER*2 variable explicitly by declaring it: In an INTEGER*2 type statement. In an INTEGER type statement when INTEGER is equivalent to INTEGER*2. In an INTEGER or INTEGER*4 type statement with a *2 length override.
-32767 2-12 Language Elements -638 30000I -4I 0 45
INTEGER*4 Data Type Note The INTEGER*4 data type represents the set of signed whole numbers in the range 02147483648 to +2147483647. Variables and constants of type INTEGER*4 are stored in four bytes. Refer to Chapter 10 for details. INTEGER*4 is an extension to the ANSI 77 standard. You can specify an INTEGER*4 variable explicitly by declaring it: In an INTEGER*4 type statement. In an INTEGER type statement when INTEGER is equivalent to INTEGER*4.
-4J 2-14 Language Elements 2147483647 0 32768
REAL*4 Data Type The REAL*4 data type, sometimes called \single precision", represents the set of real numbers whose normal range is 0.0 and 61.175494 210038 to 63.402823210+38 and whose precision is approximately seven decimal digits. Variables and constants of type REAL*4 are stored in four bytes in oating point format. Refer to Chapter 10 for details. REAL*4 is an extension to the ANSI 77 standard. It is equivalent to the ANSI standard REAL type.
-99526. 2-16 Language Elements 10. 23.
REAL*8 Data Type The REAL*8 data type, sometimes called \double precision", represents the set of real numbers whose normal range is 0.0 and 62.2250738585072022100308 to 61.797693134862315210+308 and whose precision is approximately 17 decimal digits. Variables and constants of type REAL*8 are stored in eight bytes in oating point format. Refer to Chapter 10 for details. REAL*8 is an extension to the ANSI 77 standard. It is equivalent to the ANSI standard DOUBLE PRECISION type.
REAL*16 Data Type The REAL*16 data type, sometimes called \quad precision", represents the set of real numbers whose normal range is 0.0 and 63.36210314311209350626267781732175321004932 to 61.189731495357231765085759326628007210+4932 and whose precision is approximately 34 decimal digits. Variables and constants of type REAL*16 are stored in 16 bytes in oating point format. Refer to Chapter 10 for details. REAL*16 is an extension to the ANSI 77 standard.
COMPLEX*8 Data Type The COMPLEX*8 data type de nes a set of complex numbers whose representation is an ordered pair of REAL*4 values. The rst of the pair represents the real part of the value and the second represents the imaginary part. Each part has the same range and precision as a REAL*4 value. Variables and constants of type COMPLEX*8 are stored in eight bytes as two REAL*4 values. Refer to Chapter 10 for details. COMPLEX*8 is an extension to the ANSI 77 standard.
COMPLEX*16 Data Type The COMPLEX*16 data type de nes a set of complex numbers whose representation is an ordered pair of REAL*8 values. The rst of the pair represents the real part of the value and the second represents the imaginary part. Each part has the same range and precision as a REAL*8 value. Variables and constants of type COMPLEX*16 are stored in 16 bytes as two REAL*8 values. Refer to Chapter 10 for details. COMPLEX*16 and DOUBLE COMPLEX are extensions to the ANSI 77 standard.
LOGICAL*2 Data Type Note The LOGICAL*2 data type represents the logical values true and false. Variables and constants of type LOGICAL*2 are stored in two bytes. Refer to Chapter 10 for details. LOGICAL*2 is an extension to the ANSI 77 standard. You can specify an LOGICAL*2 variable explicitly by declaring it: In a LOGICAL*2 type statement. In a LOGICAL type statement when LOGICAL is equivalent to LOGICAL*2. In a LOGICAL, LOGICAL*1, or LOGICAL*4 type statement with a *2 length override.
LOGICAL*4 Data Type Note The LOGICAL*4 data type represents the logical values true and false. Variables and constants of type LOGICAL*4 are stored in four bytes. Refer to Chapter 10 for details. LOGICAL*4 is an extension to the ANSI 77 standard. You can specify an LOGICAL*4 variable explicitly by declaring it: In a LOGICAL*4 type statement. In a LOGICAL type statement when LOGICAL is equivalent to LOGICAL*4. In a LOGICAL, LOGICAL*1, or LOGICAL*2 type statement with a *4 length override.
CHARACTER Constant The form of a character constant is an apostophe (') or quotation mark ("), optionally followed by a string of characters, and terminated with a pairing apostrope or quotation mark. The use of the quotation mark is an extension to the ANSI 77 standard. Syntax 2 32 2 32 ' character " character 3 ... ' 3 ... " The length of a character constant is the number of characters between the delimiting characters (which are not counted).
Typeless Constants Hollerith, octal, and hexadecimal constants (see following sections) are considered typeless constants. Character constants that are used in numeric expressions are handled like Hollerith constants. Typeless constants are extensions to the ANSI 77 standard. A typeless constant is a constant that does not undergo the type checking that would normally prevent you from using it in expressions. The following four assignments to INTEGER*4 variable i result in identical values for i.
Examples Notes The hexadecimal value of 'CAFE' is taken as INTEGER*4 because the other operand, 1, is an INTEGER*4. 'CAFE' becomes the integer value 51966, which is added to the value 1. The resulting integer value 51967 is assigned to r. INTEGER n The hexadecimal value of 'CAFE' is taken as n = 'CAFE'X + 0I INTEGER*2 because the other operand, 0I, is INTEGER*2. Therefore the value 013570 is assigned to n. REAL r The hexadecimal value of 'CAFE' is taken as the real r = 'CAFE'X + 1.0 value 7.
When typeless constants are passed as parameters to subprograms, the default INTEGER*4 type is assumed unless the constant is embedded in an expression. Therefore, the statement: CALL SUBROUTINE('CAFE'X) passes the INTEGER*4 value 51966 to the subroutine. However, the statement: CALL SUBROUTINE('CAFE'X+0.0) passes the real value 7.28198E041 and the statement: CALL SUBROUTINE(('CAFE'X+0)+0.0) passes the real value 51966.0. Typeless constants can be used wherever constant expressions are allowed.
Hollerith Constants Hollerith constants are an extension to the ANSI standard. They are available for compatibility with older programs and with some system routines. They can appear in arithmetic expressions representing ASCII values. A Hollerith constant consists of a positive integer constant specifying the number of characters (including blanks), followed by the letter H and the character string, which can include trailing blanks. Syntax 2 32 nHc c ...
Examples Notes These two statements are equivalent. r = 2Hab r = 4Hab11 COMPLEX c These two statement IF (c .NE. 19Hwhen the wind blows)equivalent. ... COMPLEX c IF (c .NE. 8Hwhen the) i2 = 2hxy i4 = 2hxy 2-28 Language Elements ... pairs are The resulting value of i2 is 30841 (type INTEGER*2). The resulting value of i4 is 2021204000 (type INTEGER*4).
Note Blank lling and truncation to resolve length di erences can be accomplished on Hollerith constants only, and not on arithmetic variables created from Hollerith data. On arithmetic variables, the appropriate arithmetic conversions are performed. For example, if i2 is equal to 2Hxy, and i4 is equal to i2, then i4 is not equal to 4Hxy. Hollerith literals can represent numeric constants. See \Typeless Constants" earlier in this chapter for details.
Octal Constants Octal constants are an extension to the ANSI 77 standard. They are a special format of octal values that are stored internally as hexadecimal values of up to 32 hexadecimal digits (16 bytes). Eventually they are converted to a standard type. Octal constants are left-padded with zeros. For example, O'7777' is stored internally as the hexadecimal value: 00000000000000000000000000000FFF (that is, FFF preceded by 29 zeros).
If not associated with another operand in an assignment statement, an octal constant takes the type of the entity on the left side of the equal sign. This is illustrated in the rst two assignments in the following examples. Examples INTEGER*2 I2 INTEGER*4 I4 . . . I2 = O'54131' I4 = o'54132' I2 = I4 - O'1' Notes The resulting value of I2 is 22617 (type INTEGER*2). This is the numeric equivalent of the Hollerith constant 'XX'. The resulting value of I4 is 22618 (type INTEGER*4).
Note When the data type that receives an octal constant does not have su cient space to hold all the signi cant bits, a warning is issued and the constant is left-truncated to t as many bits as possible into the variable. For example, if the following assignment is made: I2 = o'76543210' (INTEGER*2) is assigned the value o'143210', which is the maximum number of bits of that value that can t into the INTEGER*2 variable.
Hexadecimal Constants Hexadecimal (base 16) constants are an extension to the ANSI 77 standard. They are stored internally as hexadecimal values of up to 32 hexadecimal digits (16 bytes), and eventually they are converted to a standard type. The Z'n ' form is a MIL-STD-1753 extension to the ANSI 77 standard. Hexadecimal constants are left-padded with zeros. For example, Z'FFFF' is stored internally as: 0000000000000000000000000000FFFF (that is, FFFF preceded by 28 zeros).
Hexadecimal Constants in Assignments When associated with another operand in an assignment statement, a hexadecimal constant takes the type of the other operand. If no type can be taken from the other operand, INTEGER*4 is assumed. If not associated with another operand in an assignment statement, a hexadecimal constant takes the type of the entity on the left side of the equal sign. This is illustrated in the rst two assignments in the following example.
Hexadecimal Constants as Actual Parameters When used as actual parameters, hexadecimal constants are converted to INTEGER*4. To pass a hexadecimal constant as a di erent data type, the constant should be used in an expression of the desired type. Examples Notes Passes the value 4095 as data type INTEGER*4 (the default). CALL example(Z'FFF' + 0i) Passes the value 4095 as data type INTEGER*2.
A variable name is a symbolic name that represents a data element whose value can be changed during program execution by the use of assignment statements, READ statements, and so forth. A variable can represent a single value of one simple type, such as character, complex, integer, logical, or real; a collection of values of the same type, as in an array; or a collection of values of di erent types, as in a record. Refer to \Symbolic Names" earlier in this chapter for a description of valid variable names.
Item Description/Default Restrictions Symbolic name of the array. None. Dimension declarator. There must be one dimension declarator for each dimension of the array. name d Examples Notes DIMENSION xyz(4,2,4) COMMON iabc(3,4) INTEGER*2 I2(4) Three-dimensional REAL array of xyz with 32 elements. Two-dimensional INTEGER*4 array of iabc with 12 elements. One-dimensional INTEGER*2 array of I2 with 4 elements.
elements in each dimension is de ned by n - m + 1, where n is the upper bound and m is the lower bound. Examples name(4,-5:5,6) decision_table (2,3,2,2,3,4,2) m(0:0) list(10) Notes Speci es a three-dimensional array. The rst dimension can have four elements, the second 11, and the third six. Speci es a seven-dimensional array. Speci es a one-dimensional array of one element: m(0). Speci es a one-dimensional array of 10 elements: list(1) to list(10).
Examples Notes PROGRAM main Storage is allocated for array by the program main. The subprogram routine uses the variable INTEGER array(10) i only for bounds checking and subscript i = 10 CALL routine(array,i) calculation. END SUBROUTINE routine(ar,i) INTEGER ar(i) ar(1) = i END Dynamic Arrays An array that is a nonstatic local variable is called a dynamic array . For a dynamic array, storage is allocated by the current subprogram dynamically on the stack.
Examples arr(1,2) chess_board(i,j,k) arr(i+4,j-2) Notes Represents the element 1,2 of the array arr. If was declared by arr(10,20), arr would describe a two-dimensional table and arr(1,2) would describe the element in the second column of the rst row. Subscripts i, j, and k are variables that represent di erent elements of array chess_board. Subscripts i+4 and j-2 are expressions that represent speci c elements of array arr when evaluated.
arr(1,1,-4) arr(2,1,-4) Arrays as Parameters When arrays are passed as parameters, the size of the actual argument array must not exceed the size of the formal argument array. Because array bounds across separate compilation units are not checked at run-time, no warning is issued if the actual array size exceeds the formal array size. Altering these unreserved locations could yield unpredictable results.
Character Substrings A character substring is a contiguous portion of a character variable. Syntax name ( 2 3 2 3 rst : last ) 2 32 3 array ( s , s ... ) ( Item 2 3 2 3 rst : last ) Description/Default Restrictions Character variable name. array (s [,s ][...])Character array element. rst Integer expression that speci es the leftmost position of the substring. last Integer expression that speci es the rightmost position of the substring. None. None. Default value is one.
Records Structure Declarations A record is a collection of one or more data items called elds. The elds of a record can be of any type including records or structures. Like arrays, records can contain more than one data element. Unlike arrays, records can contain data elements of di erent types. An array element is identi ed with a unique index, a record element is accessed with a unique name. Structure declarations are used to de ne the form of a record.
END STRUCTURE CHARACTER*1 sex LOGICAL*1 school_yr RECORD /birth/ b_date END STRUCTURE Record Declarations Records are comparable to variables and arrays. The name of a structure is used to de ne the data type of the record. The RECORD statement is similar to a type declaration, since it can de ne record scalars and arrays. Example The following example is based on the structure student (which has the structure birth used within it), shown in the previous section.
class(15).b_date.
Expressions 2-46 Language Elements An expression can be a constant, simple or subscripted variable, function reference, substring, scalar record eld reference, or a combination of operands, joined by arithmetic, character, logical, or relational operators. There are four types of expressions: Arithmetic Character Logical Relational Arithmetic expressions return a single value of type INTEGER*2, INTEGER*4, REAL*4, REAL*8, REAL*16, COMPLEX*8, or COMPLEX*16. Character expressions return character values.
Arithmetic Expressions Arithmetic expressions perform arithmetic operations. An arithmetic expression can consist of a single operand or of one or more operands plus arithmetic operators, parentheses, or both. An arithmetic operand can be a numeric constant, the symbolic name of a numeric constant, an array element reference, scalar record eld reference, or a function reference.
Hierarchy of Arithmetic Operators The order of evaluation of an arithmetic expression is established by a precedence among the operators. This precedence determines the order in which the operands are to be combined. The precedence of the arithmetic operators is: Operator Rank Meaning ** */ +- Highest Exponentiation ... Multiplication and division Lowest Addition and subtraction, unary plus and minus Expressions within parentheses are evaluated rst.
The expression: a/b*c is evaluated in the following order: a/b is evaluated to form op1. op1*c is evaluated. The expression: i/j + c**j**d - h*d is evaluated in the following order: j**d is evaluated to form op1. c**op1 is evaluated to form op2. i/j is evaluated to form op3. h*d is evaluated to form op4. op3 + op2 is evaluated to form op5. op5 - op4 is evaluated. Parentheses can control the order of evaluation of an expression.
Consecutive Operators As an extension to the ANSI 77 standard, consecutive operators in arithmetic expressions are allowed if the second operator is a unary plus (+) or minus (-). The expression: A ** - B * C is evaluated in the following order: B is negated to form op1. A**op1 is evaluated to form op2. op2*C is evaluated. The expression: A + - B * - C is evaluated in the following order: C is negated to form op1. B*op1 is evaluated to form op2. op2 is negated to form op3. A+op3 is evaluated.
Expressions with Mixed Operands Integer, real, and complex operands can be intermixed freely in an arithmetic expression. As an extension to the ANSI 77 standard, logical operands can be intermixed with numeric operands. Before an arithmetic operation is performed, the lower type is converted to the higher type. The type of the expression is that of the highest type operand in the expression.
Table 2-4.
Character Expressions A character expression performs character operations. Evaluation of a character expression produces a result of type CHARACTER. The simplest form of a character expression is a character constant, the symbolic name of a character constant, a character variable reference, a character array element reference, a character substring reference, a scalar record eld reference of type CHARACTER, or a character function reference.
Relational Expressions Relational expressions compare the values of two arithmetic expressions or two character expressions. Evaluation of a relational expression produces a result of type logical. Syntax op1 relop op2 Item Description/Default op1 , op2 Expressions relop Relational operator Restrictions Must be either arithmetic or character None The relational operators are: Operator Meaning Equal .NE. Not equal .LT. Less than .LE. Less than or equal .GT. Greater than .GE.
o .GT. p Expressions of complex data types can be used as operands with .EQ. and .NE. relational operators only. The concept of less than or greater than is not de ned for complex numbers. Character Relational Expressions Character relational expressions compare two operands, each of which is a character expression. The character expressions are evaluated; then the two operands are compared character by character, starting from the left. The initial characters of the two operands are rst compared.
Logical Expressions Logical expressions produce results of type logical with values of true or false. A logical expression can consist of a single operand or one or more operands plus a logical operator. A logical operand can be a logical constant, the symbolic name of a logical constant, a logical variable, a logical array element reference, a scalar record eld reference of logical type, or a relational expression.
Table 2-5. Truth Table for Logical Operators a b .NOT. a True True False False True False True False False False True True a .AND. a .OR. b b True False False False a .NEQV. b a .XOR. b a .EQV. b False True True False True False False True True True True False The order of evaluation of a logical expression is established by the following precedence of the logical operators: .NOT. highest .AND. .OR. .EQV. .NEQV. .XOR.
is evaluated to form lop2. lop2 .AND. p is evaluated to form lop3. lop3 .AND. i is evaluated to form lop4. lop1 .OR. lop4 is evaluated. The expression: lsum(q,d) a .AND. (b .AND. c) is evaluated in the following order: b .AND. c is evaluated to form lop1. a .AND. lop1 is evaluated. As shown in the last example, parentheses can be used to control the order of evaluation of a logical expression.
op1: op2: result: .NEQV. 0111111111111110 (3276610) 0001011001011001 (572110 ) 0001011001011000 (572010 ) and .XOR.
3 FORTRAN Statements Statements are the fundamental building blocks of FORTRAN program units. This chapter describes the general form of a statement and then discusses the di erent categories of statements. Following the general discussions are detailed descriptions of FORTRAN statements in alphabetical order. Each description includes the statement syntax, applicable rules, and examples.
Statement Classification A FORTRAN statement can be either executable or nonexecutable. Executable statements specify the actions that the program is to take. Nonexecutable statements contain information such as the characteristics of operands, type of data, and format speci cations for input/output. Each FORTRAN statement is categorized in Table 3-1. Table 3-1.
Speci cation statements. Value assignment statements. Initialization statements. Control statements. Input/output statements. Program halt or suspension statements.
Table 3-2. Classification of Statements Program Unit Statements Description BLOCK DATA Identi es a program unit as a block data subprogram. Identi es the end of a program unit. Provides an alternative entry into a function or subroutine. Identi es a program unit as a function subprogram. Identi es a program unit as a main program. De nes a one-statement function. Identi es a program unit as a subroutine subprogram.
Table 3-2. Classification of Statements (continued) Speci cation Statements PARAMETER RECORD SAVE STRUCTURE Type Speci cation UNION VIRTUAL VOLATILE Value Assignment Statements ASSIGN Assignment Initialization Statements Description De nes named constants. De nes records declared in a previous structure declaration. Retains the value of an entity after execution of a RETURN or END statement in a subprogram. Begins a group of statements that de nes the form of a record.
Table 3-2. Classification of Statements (continued) Control Statements Arithmetic IF Block IF Logical IF RETURN Input/Output Statements ACCEPT BACKSPACE CLOSE DECODE DELETE ENCODE ENDFILE FORMAT INQUIRE OPEN PRINT READ REWIND REWRITE TYPE UNLOCK WRITE Program Halt Statements PAUSE STOP 3-6 FORTRAN Statements Description Transfers control based on a condition. Executes optional groups of statements based on one or more conditions. Conditionally executes a statement based on a logical value.
Order of Statements Statements are restricted as to where they can appear in a program unit. Within a program unit, the following rules apply: PROGRAM, SUBROUTINE, FUNCTION, and BLOCK DATA statements can appear only as the rst statement in a program unit. All speci cation statements must precede all statement function statements and executable statements. IMPLICIT statements must precede all other speci cation statements except PARAMETER statements.
ACCEPT Statement (Executable) The ACCEPT statement transfers input data from the standard input unit to an internal storage area. Input data is transferred under sequential mode access. The ACCEPT statement cannot be connected to user-speci ed logical units. Item fmt namelist group name variable array element character substring array name scalar record eld name implied do list 3-8 FORTRAN Statements Description/Default Restrictions Format designator. See \Semantics". None.
Semantics The format designator, fmt , must be one of the following: The statement label of a FORMAT statement. An INTEGER*4 variable to which the statement label of a FORMAT statement has been assigned through an ASSIGN statement. A character or noncharacter array name that contains the representation of a format speci cation (use of a noncharacter array is an extension to the ANSI 77 standard). A character expression that evaluates to the representation of a format speci cation.
ASSIGN Statement (Executable) The ASSIGN statement assigns a statement label to an INTEGER*4 variable. Item Description/Default label Statement label. variable INTEGER*4 simple variable. Restrictions Must be the label of an executable statement or a FORMAT statement. None. Semantics The variable de ned as a label by the ASSIGN statement can subsequently be used in an assigned GOTO statement or as the format speci er in an input/output statement.
Assignment Statement (Executable) The assignment statement evaluates an expression and assigns the resulting value to a data item. There are four kinds of assignment statements: Arithmetic Logical Character Aggregate Item variable1 array element scalar record eld name substring expression aggregate1 aggregate2 Description/Default Restrictions If arithmetic assignment, type must be integer, real, or complex. If logical assignment, type must be logical. If character assignment, type must be character.
Arithmetic Assignment Statement (Executable) 3-12 FORTRAN Statements Semantics If the type of the variable on the left of the equal sign di ers from that of the expression, type conversion takes place. The expression is evaluated and the result is converted to the type of the variable on the left. The converted result then replaces the current value of the variable. Conversion rules for the assignment statement are shown in Table 3-3, followed by examples in Table 3-4. See also Table 2-4.
Table 3-3. Type Conversion for Arithmetic Assignment Statements of the Form: Variable = Expression Rule Variable Type Expression Type a. INTEGER*k (or LOGICAL*k ) (see Note 3) b. INTEGER*k (or LOGICAL*k ) (see Note 3) c. INTEGER*k (or LOGICAL*k ) (see Note 3) d. INTEGER*k (or LOGICAL*k ) (see Note 3) e. REAL*k INTEGER*n If k n , assign INTEGER*k . If k < n , assign least signi cant byte or half word to variable. See Note 1. REAL*n Truncation. COMPLEX*8 Real part is REAL*4.
2. When converting from INTEGER*4 to REAL*4, the precision can be lost because INTEGER*4 holds 31 signi cant bits, while the number of signi cant bits for REAL*4 is system dependent. Refer to Chapter 10 for more details on data representation. 3. As an extension to the ANSI 77 standard, logical variables appearing in an arithmetic context may be treated as integer variables, depending upon compiler directives.
Table 3-4. Examples of Type Conversions for Arithmetic Assignment Statements of the Form: Variable = Expression Rule Variable Type Variable Value Expression Value Expression Type a. INTEGER*4 542 542 INTEGER*2 or LOGICAL*4 a. INTEGER*2 Unde ned (see 86420 INTEGER*4 or LOGI- Note 1). CAL*2 b. INTEGER*2 3 3.842 REAL*4 or INTEGER*2 373.7Q0 REAL*16 b. INTEGER*2 373 or LOGICAL*2 c. INTEGER*2 502 (5.0297E2,1.27E05) COMPLEX*8 or LOGICAL*2 d. INTEGER*4 048170 (04.817D4,1.0096D7) COMPLEX*16 or LOGICAL*4 e.
Examples total = subtotal + tally sum = sum + 1 rate(10) = new_rate * 5 Logical Assignment Statement (Executable) Notes De nes the value of total as the value of subtotal + tally. Replaces the value of sum with the value of sum + 1. De nes the 10th element of the array rate as the value of new_rate multiplied by 5. Semantics Both the variable and the expression must logical types in a logical assignment statement. Examples LOGICAL log1 i = 10 log1 = i .EQ. 10 Notes is assigned the value .TRUE.
Character Assignment Statement (Executable) Semantics If the length of the variable is greater than the length of the expression, the value of the expression is left-justi ed in the variable, and blanks are placed in the remaining positions. If the length of the variable is less than the length of the expression, the value of the expression is truncated from the right until it is the same length as the variable. Examples CHARACTER*6 name CHARACTER*4 instrument(6),k name = 'CYBELE' . . .
Aggregate Assignment Statement (Executable) Semantics The eld values of the aggregate on the left side of the equal sign are assigned to the corresponding elds of the aggregate on the right side of the equal sign. The two aggregates must be declared with the same structure name.
BACKSPACE Statement The BACKSPACE statement positions a sequential le or device at the preceding record. (Executable) Item unit variable name array element scalar record eld name label Description/Default Restrictions Expression giving the unit number of a connected le. Error code return. Must be a nonnegative integer. Statement label. Must be an executable statement in the same program unit as the BACKSPACE statement. Must be an integer type.
If the le is positioned at its beginning, a BACKSPACE statement has no e ect. As an extension to the ANSI 77 standard, BACKSPACE operations are allowed on les open for direct access. The le is positioned at the preceding record, provided it is not already at the beginning of the le. Examples Notes The sequential le connected to unit 10 is backspaced one record. BACKSPACE (UNIT=k+3,IOSTAT=j,ERR=100) The le connected to unit k+3 is backspaced one record.
BLOCK DATA Statement The BLOCK DATA statement identi es the beginning of a block data subprogram. (Nonexecutable) Item Description/Default subprogram name Subprogram name. Restrictions Must not be the same as the name of an external procedure, the main program, a common block, or any other block data subprogram in the same execution program, nor can it be the same as any local name in this block data subprogram.
Example Notes BLOCK DATA myblock myblock is the optional name of a COMMON /xxx/x(5),b(10),c block data subprogram to reserve storage locations for the named COMMON /set1/iy(10) common blocks xxx and set1. DATA iy/1,2,4,8,16,32,64,128,256,512/ Arrays iy and b are initialized in DATA b/10*1.0/ . . the DATA statements shown. The . remaining elements in the common END BLOCK DATA name1 COMMON a,b,c DATA a,b,c/10.0,20.0,30.
BYTE Statement (Nonexecutable) The BYTE type speci cation statement explicitly assigns the BYTE (LOGICAL*1) data type to symbolic names, and optionally assigns initial values to variables. See also \LOGICAL Statement (Nonexecutable)". Semantics The BYTE statement is an extension to the ANSI 77 standard. The BYTE statement has the same e ect as the LOGICAL*1 statement.
CALL Statement The CALL statement transfers control to a subroutine. (Executable) Item * & label Semantics Description/Default Restrictions Alternate return. None. Statement label of an executable statement. Must be in the same program unit as the CALL statement. When a CALL statement is executed, any expressions in the actual argument list are evaluated and control passes to the subroutine.
Examples CALL print_forms(top,lh,rh) CALL exit CALL test_data (m,n,val,*10) . . . 10 total = val + 6.34 . . . END SUBROUTINE test_data (j,k,w,*) . . . RETURN 1 . . . END Notes Calls the subroutine print_forms. Passes three arguments. Calls the subroutine exit. Passes no arguments. Calls the subroutine test_data. Passes three arguments. *10 means that the return point is the statement labeled 10 if the subroutine executes the alternate return RETURN 1.
CHARACTER Statement (Nonexecutable) The CHARACTER type speci cation statement explicitly assigns the CHARACTER data type to symbolic names, and optionally assigns initial values to the variables. Semantics If an array declarator is speci ed in a type statement, the declarator for that array must not appear in any other speci cation statement (such as DIMENSION). If only the array name is speci ed, an array declarator must appear within a DIMENSION or COMMON statement.
Note An integer constant expression with a positive value. The integer expression must be enclosed in parentheses and cannot contain variable names. Example: (-3 + 4). An asterisk enclosed in parentheses: (*). A variable enclosed in parentheses. This is an extension to the ANSI 77 standard. A length speci cation can be appended to the end of a symbolic name to designate its length.
See \DATA Statement (Nonexecutable)" for further information on initialization.
CLOSE Statement The CLOSE statement terminates the connection of a le to a unit. (Executable) Item unit dsp dsps label character expression variable name array element name scalar record eld name Description/Default Speci es the unit number of the le. See \Semantics". See \Semantics". Statement label of an executable statement. Character expression that determines the disposition of the le. Error code return. Restrictions Must be an integer expression. None. None.
If STATUS='KEEP' is speci ed, the le continues to exist after execution of the CLOSE statement. 'KEEP' is the default for named les; that is, specifying STATUS='KEEP' or not specifying the STATUS parameter has the same e ect. However, STATUS='KEEP' is an error if a scratch le is being closed. The STATUS='KEEP' speci er is not allowed on scratch les because scratch les are deleted upon execution of CLOSE or at normal program termination. In the STATUS speci er, only the rst character is signi cant.
Examples CLOSE (10) CLOSE (UNIT=6,STATUS='DELETE') CHARACTER*6 cstat cstat = 'DELETE' CLOSE (UNIT=6,STATUS=cstat) Notes Disconnects the le connected to unit 10. The le continues to exist. Disconnects the le connected to unit 6. The le no longer exists. This produces the same results as the preceding statement. CLOSE (5,IOSTAT=io_error,ERR=100)Disconnects CLOSE (5,IOSTAT=io_error) CLOSE (5,ERR=100) and keeps the le connected to unit 5.
COMMON Statement (Nonexecutable) The COMMON statement speci es a block of storage space that can be used by more than one program unit. Item block name Semantics Description/Default Restrictions Name of a labeled common Must be di erent from all intrinsic names, subroutine block. names, and the program name. The following data items cannot appear in a COMMON statement: The names of formal arguments in a subprogram. A function, subroutine, or intrinsic function name.
For example, the COMMON statements: COMMON a,b,c/x/y,z,d//w,r COMMON /cap/hat,visor,//tax,/x/o,t are equivalent to the following COMMON statement: COMMON a,b,c,w,r,tax,/x/y,z,d,o,t,/cap/hat,visor Note The length of a common block is determined by the number and type of the variables in the list associated with that block. The total size of a COMMON block must be less than one gigabyte. (A gigabyte is 1,073,741,824 (230) bytes.) Common block storage is allocated at link time.
COMPLEX Statement (Nonexecutable) The COMPLEX type speci cation statement explicitly assigns the COMPLEX*8 and COMPLEX*16 data types to symbolic names, and optionally assigns initial values to variables. The following syntax includes the COMPLEX, COMPLEX*8, COMPLEX*16, and DOUBLE COMPLEX statements. Semantics The COMPLEX*8 statement and the COMPLEX statement are equivalent. The COMPLEX*16 statement and the DOUBLE COMPLEX statement are equivalent.
As an extension to the ANSI 77 standard, a length speci er can follow the item being declared. This speci er overrides the data length implied by the type statement. If the item is an array name with a dimension declarator, the length speci er precedes the dimension declarator.
CONTINUE Statement The CONTINUE statement creates a reference point in a program unit. (Executable) Semantics The CONTINUE statement should always be written with a label; it marks a point in the program where a label is needed but the programmer does not want to associate the label with any speci c action. In programs in earlier versions of FORTRAN, the CONTINUE statement is usually the last statement in a labeled DO loop that otherwise would end in a prohibited statement such as a GOTO statement.
DATA Statement (Nonexecutable) The DATA statement assigns initial values to variables before execution begins. Item iteration constant iteration constant name * Description/Default Restrictions Nonzero unsigned integer. None. The default is one. Named constant, de ned by None. a PARAMETER statement, representing a nonzero unsigned integer. The default is one. Repeat speci er. None. Semantics The number of items in the constant list must agree with the number of variables in the variable list.
The assignment of constants in a DATA statement to their corresponding variables follows the rules of the assignment statement. (See \Assignment Statement (Executable)" for details.) If a constant has a type of character or logical, the corresponding variable must be of the same type. Character variables can be initialized with octal, hexadecimal or hollerith constants as well. If a constant is of any numeric type (integer, real, or complex), the corresponding variable can be of any numeric type.
Examples DATA a,b,c,d/3.0,3.1,3.2,3.3/ DIMENSION i(3) DATA i/3*2/ DIMENSION i(3) DATA i(1)/2/i(2)/2/i(3)/2/ DIMENSION i(3) DATA i(1),i(2),i(3)/2,2,2/ PARAMETER (init_val = -1) DIMENSION m(10) DATA m/10*init_val/ Notes The values 3.0, 3.1, 3.2, and 3.3 are assigned to a, b, c, and d, respectively. All three elements of i are assigned an initial value of 2. All three elements of i are assigned an initial value of 2. Equivalent to the previous example.
Implied DO Loops in DATA Statements The implied DO loop in a DATA statement acts like the implied DO loop in an input/output statement. It is executed at compilation time to initialize parts of arrays or generate a full variable list. The format of an implied DO loop in a DATA statement is shown below: Item Description/Default implied do list Data list index init limit step in the form of an implied DO loop.
The iteration count in an implied DO loop in a DATA statement must be positive. Examples Notes An implied DO loop assigns an initial value of 2 to all three elements of i. Equivalent to the previous three examples. CHARACTER k(10,5) Two nested implied DO loops assign the literal character x to each DATA ((k(i,j),j=1,5),i=1,10)/50*'x'/ element in an array of 50 elements, k(10,5) .
DECODE Statement (Executable) 3-42 FORTRAN Statements The DECODE statement transfers data from internal storage to variables according to a format speci cation.
Item count fmt unit ios label list Description/Default Restrictions Must be the rst item. Integer expression that speci es the number of bytes to be translated. Format designator. Must be the second item. Must be as speci ed for the PRINT Statement. Internal storage designator. Must be the third item. Must be a scalar record eld name or array name. Assumed-size and adjustable-size arrays are not permitted. None. Integer variable or array element for error code return. None.
DELETE Statement (Executable) The DELETE statement deletes a record from an indexed sequential access (ISAM) le. Item unit Description/Default Expression specifying unit Must be a nonnegative number of a connected le. integer. Error code return. Must be an integer type. variable name array element scalar record eld name label Semantics Restrictions Statement label. Must be an executable statement in the same program unit.
Examples Notes READ (10,key='111-22-333',KEYID=0) employee_rec Deletes a record with DELETE (10,ERR=555, IOSTAT=I) value 111-22-333.
DIMENSION Statement The DIMENSION statement de nes the dimensions and bounds of arrays. (Nonexecutable) Dimension Declarator Item Description/Default last Symbolic name of the array. Lower dimension bound. Defaults to 1. Upper dimension bound. * Dynamic upper bound. array name rst Semantics Restrictions None. Must be less than or equal to last . Must be greater than or equal to rst . Can only appear in the last upper bound of a formal argument of a subprogram.
Examples INTEGER*2 arri DIMENSION arri(-3:1,4) Notes The type statement speci es arri as a two-byte integer. Only the name of the array is used, not the complete array declarator. The DIMENSION statement causes 20 words of memory to be allocated for the array arri. An equivalent type speci cation would be: INTEGER*2 arri(-3:1,4) COMPLEX num(5,5) DIMENSION num(5,5) This construct is illegal because num is declared as an array twice.
DO Statement (Executable) A DO statement de nes the beginning of a DO loop. DO loops are groups of statements that are executed repeatedly zero or more times, or a list within one statement that is executed a speci ed number of times. The maximum level to which DO statements, or a mixture of IF and DO statements, can be nested is 20. Exceeding this number makes programs unnecessarily complicated and can cause internal compiler errors stating that the statement is too complicated.
Semantics DO loops are grouped into four categories: Labeled DO loops Block DO loops Implied DO loops DO-WHILE loops A labeled or block DO loop executes a group of statements a speci ed number of times. An implied DO loop is similar to a labeled DO loop, but it is used in a READ, WRITE, PRINT, or DATA statement. A DO-WHILE loop executes a group of statements while a speci ed condition is true.
Labeled DO Loop A labeled DO loop begins with a DO statement that speci es the label of the terminating statement of the loop. The terminating statement of a labeled DO loop must follow the DO statement.
Another DO statement A DO-WHILE statement An assigned GOTO statement An unconditional GOTO statement An arithmetic IF statement Any of the four statements associated with the block IF statement: IF-THEN statement ELSE statement ELSE IF statement ENDIF statement A RETURN statement A STOP statement An END statement Any nonexecutable statement The terminating statement of a labeled DO loop can be a logical IF statement. A labeled DO loop can be terminated with an END DO statement.
Examples DO. j = 10,1,-2 . . END DO DO. j = 10,1,2 . . END DO DO Loop Execution Notes Block DO loop. The group of statements terminating with the END DO statement is repeated ve times. Block DO loop. The group of statements terminating with the END DO statement is not executed. (The DO loop is skipped entirely unless the ONETRIP directive is ON.) When a DO statement is executed, the following actions occur: 1. limit and step are evaluated, then index and init are evaluated.
Upon premature exit from the DO loop, the control variable retains its value at the time of exit. Implied DO Loop Implied DO loops are found in input/output statements (READ, WRITE, and PRINT) and in DATA statements. An implied DO loop contains a list of data elements to be read, written, or initialized, and a set of indexing parameters. Inner loops can use the indexes of outer loops. For DATA statements, only integer index variables and expressions can be used.
Item index init limit step Description/Default Restrictions Loop variable that controls the number of times the preceding element list is read or written. Expression that is the initial value for index . Expression that is the termination value for index . Expression that is the increment for index after each execution of the DO loop. step can be positive or negative. Its default value is one. Must be a simple variable whose type is integer or real. Must be an integer or real expression.
DO-WHILE Statement (Executable) As a MIL-STD-1753 standard extension to the ANSI 77 standard, the DO-WHILE statement controls execution of a group of statements by causing the statements to be repeated while a logical expression is true. The DO-WHILE construct is an important element of structured programming. Each DO-WHILE loop must be terminated by a separate END DO statement, which does not require a label.
Nesting DO Loops Ranges of DO Loops DO loops can contain other DO loops. This is called nesting . The only restriction is that each level (that is, each successive loop) must be completely contained within the preceding loop. In a labeled DO loop, the last statement of an inner (nested) loop must either be the same as, or occur before, the last statement of the outer loop. (For programming clarity, always use a separate terminating statement for each loop.
Extended Range DO Loop END DO Statement (Executable) As an extension to the ANSI 77 standard, the range of a DO loop can be extended outside the loop. A control statement in the DO loop can transfer control out of the loop, and, after execution of any number of statements, control can branch back into the DO loop. The return to the DO loop must be made from a statement in the extended range of the loop. A DO loop index cannot be modi ed in the loop's extended range.
DOUBLE COMPLEX Statement (Nonexecutable) DOUBLE PRECISION Statement (Nonexecutable) ELSE Statement (Executable) ELSE IF Statement (Executable) 3-58 FORTRAN Statements The DOUBLE COMPLEX statement is the same as the COMPLEX*16 statement. For more information, refer to \COMPLEX Statement (Nonexecutable)". The DOUBLE PRECISION statement is the same as the REAL*8 statement. For more information, refer to \REAL Statement (Nonexecutable)". The ELSE statement is part of the block IF construct.
ENCODE Statement (Executable) The ENCODE statement transfers data from variables to internal storage according to a format speci cation.
Item count fmt unit ios label list Description/Default Restrictions Must be the rst item. Integer expression that speci es the number of bytes to be translated. Format designator. Must be the second item; must be as speci ed for the PRINT statement. Internal storage designator. Must be the third item; must be a scalar variable or array name; assumed-size and adjustable-size arrays are not permitted. None. Integer variable, array element, or scalar record eld for error code return. None.
END Statement (Executable) The END statement indicates the end of a program unit, that is, the end of a program, subroutine, function, or block data subprogram. Semantics If an END statement is executed in a subprogram, it has the same e ect as a RETURN statement. If an END statement is executed in a main program, the program terminates. An END statement can be labeled, but it cannot be continued. It must be the last statement in a program unit.
END DO Statement (Executable) END MAP Statement (Nonexecutable) END STRUCTURE Statement (Nonexecutable) END UNION Statement (Nonexecutable) 3-62 FORTRAN Statements The END DO statement terminates the block DO and DO-WHILE statement blocks. It is described in \DO Statement (Executable)". The END MAP statement terminates a MAP statement block. For more information, refer to \STRUCTURE Statement (Nonexecutable)". The END STRUCTURE statement terminates a STRUCTURE statement block.
ENDFILE Statement (Executable) The ENDFILE statement writes an end-of- le record to the speci ed sequential le or device. Item unit variable name array element scalar record eld name label Description/Default Restrictions Unit number of a connected le. Error code return. None. Statement label of an executable statement. Must be in the same program unit. Must be an integer data type.
As an extension to the ANSI 77 standard, ENDFILE operations are allowed on les open for direct access. Examples Notes An end-of- le record is written to the le connected to unit 10. ENDFILE (UNIT=12,IOSTAT=j,ERR=100) An end-of- le record is written to the le connected to unit 12. If an error occurs, control transfers to statement 100 and the error code is stored in variable j. If no error occurs, j is set to zero and control transfers to the next statement.
ENDIF Statement (Executable) The ENDIF statement is part of the block IF construct. For more information, refer to \IF Statement (Executable)".
ENTRY Statement (Nonexecutable) The ENTRY statement provides an alternate name, argument list, and starting point for a function or subroutine. It can appear only in a subroutine or function subprogram, not in a main program or block data subprogram. Item name * Semantics Description/Default Name for the alternate starting point. Placeholder for alternate return points. Restrictions None. Asterisk is permitted only in a subroutine.
a FUNCTION or SUBROUTINE statement, or another ENTRY statement. An entry name must not appear in an EXTERNAL statement. An ENTRY statement can appear anywhere in a subprogram after the FUNCTION or SUBROUTINE statement, with the exception that the ENTRY statement must not appear between a block IF statement and its corresponding END IF statement, or between a DO statement and the end of its DO loop. A subprogram can have zero or more ENTRY statements. An ENTRY statement is a nonexecutable statement.
Enter two numbers: 9 0 The sum of the numbers is 9. Enter two numbers: 1 2 Neither number equals 0. The sum of the numbers is 3.
EQUIVALENCE Statement The EQUIVALENCE statement associates variables so that they share the same storage space. (Nonexecutable) Semantics Function names, formal arguments, dynamic arrays, and record names must not appear in an EQUIVALENCE statement. Each array or substring subscript must be an integer constant expression. The EQUIVALENCE statement conserves storage.
Equivalence of Character Variables As an extension to the ANSI 77 standard, character and noncharacter data items can share the same storage space. Example Notes EQUIVALENCE (a,b),(c(2),d,e) Multi-Dimensioned Equivalence The variables a and b share the same storage space; c(2), d, and e share the same storage space. As an extension to the ANSI 77 standard, it is possible to indicate the element of an array with two or more dimensions by specifying its position as if it were a single dimension array.
EXTERNAL Statement (Nonexecutable) The EXTERNAL statement identi es a name as representing a subprogram name and permits the name to be used as an actual argument in subprogram calls. Item Description/Default procedure nameName of a subprogram. Restrictions Each name can appear once only in a given EXTERNAL statement, and in at most one EXTERNAL statement in a given program unit.
FORMAT Statement (Nonexecutable) The FORMAT statement describes how input and output information is to be arranged. Descriptor List Variable Format Descriptor Item label repeat spec Description/Default Statement label. Repeat speci cation. format descriptor Format descriptor. Restrictions Required. Must be an unsigned positive integer constant or a variable format descriptor whose value is positive. None. See the following Format Descriptor syntax diagram and table for details. None.
Format Descriptor Item d e m w Description/Default Number of digits in fractional part. If omitted, the default value is based on the data type of the I/O list element. (Refer to Table 3-5 for default values.) Number of digits in exponent part. If omitted, the default value is based on the data type of the I/O list element. (Refer to Table 3-5 for default values.) Minimum number of digits to be output. The default is one.
Edit Descriptor 3-74 FORTRAN Statements
Item Description/Default c Column position. k Scale value. n Number of characters. string A series of one or more ASCII characters. t Number of columns to skip. x Number of columns to skip. Restrictions Must be an unsigned positive integer constant or a variable format descriptor whose value is positive. Must be an integer constant or a variable format descriptor. Must be an unsigned positive integer constant. The H format has the form of a Hollerith constant.
Table 3-6. Format Descriptors Descriptor List Element Data Type A[ w ] Any character or Hollerith R[ w ] Any character or Hollerith Any real or complex D[ w .d ] E[w .d [Ee ]] Any real or complex Any real or complex F[ w .d ] G[w .d [Ee ]] Any real or complex Any real M[ w .d ] Any real N[ w .d ] Any integer; decimal format I[w [.m ]] Any integer; octal format @[w [.m ]] K[w [.m ]] Any integer; octal format O[w [.m ]] Any integer; octal format Z[w [.
Table 3-7. Edit Descriptors Descriptor Function Ignore blanks. BZ Treat blanks as zeros. n Hstring Hollerith literal. "string " Literal editing. 'string ' Literal editing. NL Restore newline. NN No newline. $ No newline; same as NN. kP Scale factor. Q Number of characters remaining in current input record. S Processor determines sign output; same as SS. SP Output optional plus signs. SS Inhibit optional plus sign output. Tc Skip to column c. TLt Skip t positions to the left.
FUNCTION Statement (Nonexecutable) 3-78 FORTRAN Statements The FUNCTION statement identi es a program unit as a function subprogram.
Semantics FORTRAN Statements 3-79
For more information on types, refer to the discussions of each type elsewhere in this chapter. If the type is not speci ed, the name is typed the same way as the variables. The formal arguments in a FUNCTION statement can be used as: Variables. Array names. Subprogram names. Record names. The formal arguments should be of the same type as the actual arguments that are passed to the function from the calling program unit.
GOTO Statement (Executable) Unconditional GOTO Statement (Executable) The GOTO statement transfers control to a labeled statement in the same program unit. It has three forms, which are described separately below: Unconditional GOTO Computed GOTO Assigned GOTO The unconditional GOTO statement transfers control to the speci ed statement. Item Label of an executable statement. label Computed GOTO Statement (Executable) Description/Default Restrictions None.
labels in the label list, control passes to the statement following the computed GOTO. Assigned GOTO Statement (Executable) The assigned GOTO statement transfers control to the statement whose label is stored in the variable by an ASSIGN statement. Item label variable Description/Default Label of an executable statement. Integer simple variable. Restrictions None. Must be INTEGER*4.
Examples GOTO 20 a=3 GOTO (30,60,50,100) a b = 1.5 z=1 GOTO (10,20,40,40) b + z ASSIGN 10 TO age GOTO age ASSIGN 100 TO time GOTO time (90,100,150) Notes In this unconditional GOTO statement, control passes to the statement labeled 20 when the GOTO statement is executed. Statement 20 can be before or after the GOTO statement, but must be present in the same program unit. In this computed GOTO statement, because a has a value of 3, control passes to statement 50.
IF Statement (Executable) Arithmetic IF Statement (Executable) The IF statement provides a means for decision making. There are three types of IF statements: Arithmetic IF Logical IF Block IF The maximum level to which a mixture of IF and DO statements, can be nested is 20. Exceeding this number makes programs unnecessarily complicated and can cause internal compiler errors stating that the statement is too complicated.
to the statement bearing the label, regardless of the results of the evaluation. If two of three labels are the same, and one of them indicates the next statement, the statement should be rewritten as a logical IF for improved readability. For example, these arithmetic IF statements: IF (exp) 10,10,20 ... IF (exp) 10,20,10 20 ... 10 are the same as these logical IF statements: IF (exp .GT. 0) GOTO 20 ... IF (exp .NE. 0) GOTO 10 20 ... 10 Examples testa = 0.
Logical IF Statement (Executable) The logical IF statement evaluates a logical expression and executes one statement if the expression is true. Item exp statement Description/Default Logical expression. Executable statement. Restrictions None. Cannot be a DO, END, block IF, or logical IF statement. The logical IF statement is a two-way decision maker.
Block IF Statement (Executable) The block IF statement block is an extension of the logical IF statement, allowing one of a set of blocks of statements to be executed, depending on the value of one or more logical expressions.
so, the block of statements between the ELSE and its corresponding ENDIF statement is executed. If the logical statement evaluates to true, the statements in the IF-THEN block are executed until an ELSE statement is encountered. Control then transfers to the statement following the ENDIF statement. ELSE IF Statement (Executable) The ELSE IF statement is a special case of an ELSE statement. It functions the same as an ELSE statement that has an IF-THEN statement as the rst statement of its ELSE block.
Example Nesting Level 0 1 : 2 : 2 : 2 : 1 : 1 : 0 IF (exp1 ) THEN : IF (exp2 ) THEN : ELSE IF (exp3 ) THEN : ELSE : ENDIF : ELSE IF (exp4 ) THEN : ENDIF Examples x=y IF (x.EQ.y) THEN x=x+1 ENDIF IF (x.LT.0) THEN y = SQRT (ABS(x)) z = x+1-y ELSE y = SQRT (x) z = x-1 ENDIF IF (n(i).EQ.0) THEN n (i) = n (j) j = j+1 IF (j.LT.k) THEN k = k-1 ELSE IF (j.EQ.k) THEN k = k+1 ENDIF ELSE m=i k = n(i) ENDIF Notes Because x = y, the value of x is replaced by the value of x+1.
IMPLICIT Statement (Nonexecutable) 3-90 FORTRAN Statements The IMPLICIT statement overrides or con rms the default type associated with the rst letter of a variable name.
Semantics For more information on types, refer to the discussions of each type, elsewhere in this chapter. An IMPLICIT statement speci es a default type for all variables, arrays, named constants, function subprograms, ENTRY names in function subprograms, and statement functions that begin with any letter that appears in an IMPLICIT statement and are not explicitly given a type. It does not change the type of any intrinsic functions.
Specifying a range of letters (for example, A-E) has the same e ect as writing a list of single letters (for example, A,B,C,D,E). Examples Notes IMPLICIT COMPLEX*16(i,j,k),INTEGER*2(a-c) All user-de IMPLICIT NONE INTEGER i,j,k REAL x,y,z a = x+y STOP END 3-92 FORTRAN Statements ned symbolic names beginning with i, j, or k default to type COMPLEX*16. Those beginning with a, b, or c default to type INTEGER*2. All names must be declared. An error occurs in the fourth line because a was not declared.
INCLUDE Statement (Nonexecutable) The INCLUDE statement is a MIL-STD-1753 extension to the ANSI 77 standard. It causes the compiler to include and process subsequent source statements from a speci ed le or device. When end-of- le is read from this le or device, the compiler continues processing at the line following the INCLUDE statement. Item name Description/Default File name. Restrictions None. INCLUDE statements cannot be continued.
INQUIRE Statement (Executable) 3-94 FORTRAN Statements The INQUIRE statement provides information about selected properties of a le or unit number.
FORTRAN Statements 3-95
Item unit name label ios ex opnd num nmd fn use acc seq 3-96 FORTRAN Statements dir Description/Default Unit number of a sequential le. Speci es le name for inquiry by le name. Control transfers to the speci ed executable statement if an error condition exists on the named le or unit. ios = zero if no error; ios = positive value if error condition exists. ex = true if named le exists; ex = false otherwise. od = true if named le or unit has been opened; od = false otherwise.
Item Description/Default Restrictions Character variable, array element, substring, or scalar record eld. mrec Returns 'FORMATTED' if connected for formatted data transfer, 'UNFORMATTED' if connected for unformatted data transfer, and is unde ned if the le is not connected. Returns 'YES' if connected for formatted data transfer, 'NO' if connected for unformatted data transfer, and 'UNKNOWN' if the processor is unable to determine the format of data transfer.
Semantics If the ERR speci er is present and an error occurs during the execution of the INQUIRE statement, control transfers to the speci ed statement rather than aborting the program. If the IOSTAT speci er is present and an error occurs, the error code is returned in the ios variable and the program is not aborted. Refer to Appendix A for IOSTAT error codes. Either the UNIT or FILE speci er, but not both, must be present in the speci er list.
INTEGER Statement (Nonexecutable) The INTEGER statement is a type speci cation statement that explicitly assigns the INTEGER*2 and INTEGER*4 data types to symbolic names, and optionally assigns initial values to variables. The following syntax includes the INTEGER, INTEGER*2, and INTEGER*4 statements.
Semantics Note As an extension to the ANSI 77 standard, a length speci er can follow the item being declared. This speci cation overrides the length implied by the type statement. If the item being declared is an array name with a dimension declarator, the length speci er precedes the dimension declarator. The INTEGER*2 statement, an extension to the ANSI 77 standard, declares items to be 2-byte integers.
INTEGER*2 Statement (Nonexecutable) INTEGER*4 Statement (Nonexecutable) The INTEGER*2 statement, which is an extension to the ANSI 77 standard, is a special case of the INTEGER statement. See \INTEGER Statement (Nonexecutable)" for details. The INTEGER*4 statement, which is an extension to the ANSI 77 standard, is a special case of the INTEGER statement. See \INTEGER Statement (Nonexecutable)" for details.
INTRINSIC Statement (Nonexecutable) The INTRINSIC statement identi es a name as representing an intrinsic function and permits the name to be used as an actual argument. Item function Description/Default Name of an intrinsic function. Restrictions Each name can appear once only in a given INTRINSIC statement and in at most one INTRINSIC statement within a given program unit. The INTRINSIC statement provides a means of using intrinsics as actual arguments.
LOGICAL Statement (Nonexecutable) The LOGICAL type speci cation statement explicitly assigns the LOGICAL*1, LOGICAL*2, and LOGICAL*4 data types to symbolic names, and optionally assigns initial values to variables. The following syntax includes the LOGICAL, LOGICAL*1, LOGICAL*2, and LOGICAL*4 statements. See also \BYTE Statement (Nonexecutable)".
Semantics Note The LOGICAL*1, LOGICAL*2, and LOGICAL*4 statements are extensions to the ANSI 77 standard. LOGICAL*1 declares items to be 1-byte logicals, LOGICAL*2 declares them to be 2-byte logicals, and LOGICAL*4 declares them to be 4-byte logicals. By default, the LOGICAL statement is equivalent to the LOGICAL*4 statement. This is the same as the e ect of the LONG compiler directive. The SHORT compiler directive may be used to make LOGICAL equivalent to LOGICAL*2. See Chapter 7 for further details.
LOGICAL*1 Statement (Nonexecutable) LOGICAL*2 Statement (Nonexecutable) LOGICAL*4 Statement (Nonexecutable) MAP Statement (Nonexecutable) The LOGICAL*1 statement, which is an extension to the ANSI 77 standard, is a special case of the LOGICAL statement. See \LOGICAL Statement (Nonexecutable)" for details. The LOGICAL*1 statement is equivalent to the BYTE statement, which is described in \BYTE Statement (Nonexecutable)".
NAMELIST Statement (Nonexecutable) The NAMELIST statement de nes a list of variables or array names and associates that list with a unique group-name. The group-name can then be used in namelist-directed I/O to de ne the variables or arrays to be read or written. Item Description/Default Restrictions namelist group name Symbolic name for None. variable array name Array elements, assumed-sized arrays, adjustable arrays, record references, and character substrings are not permitted.
ON Statement (Executable) The ON statement speci es the action to be taken following a subsequent interruption of program execution. The interrupt condition speci es the interrupt to be handled, such as an arithmetic error or a keyboard interrupt. Parameters Keywords specifying an interrupt condition, as given in Table 3-8. trap procedure A procedure that will be executed if the speci ed interrupt condition occurs following the execution of the ON statement.
Table 3-8.
OPEN Statement (Executable) The OPEN statement establishes a connection between a unit number and a le. It also establishes or veri es the properties of a le.
3-110 FORTRAN Statements
Item unit name label Description/Default Restrictions Speci es unit number. Character variable. Control transfers to speci ed executable statement if error encountered on OPEN. = 0 if no error; ios = positive value if error condition exists. ios ios sta mrec Speci es le as 'OLD', 'NEW', 'SCRATCH', or 'UNKNOWN' (default). See Note 1. Speci es le access to be 'DIRECT', 'KEYED' , or 'SEQUENTIAL' (default). See Note 2. Speci es data format to be 'FORMATTED' or 'UNFORMATTED' .
Item exdsz init org uopen Description/Default See \Semantics". See \Semantics". See \Semantics". See \Semantics". Restrictions Value not checked. Value not checked. Value not checked. Value not checked. Note 1 If = then the and STATUS 'OLD' 'SCRATCH' FILE speci er is required FILE speci er is required FILE speci er must not be present The le must exist. The le named must not exist. A scratch le is created.
If the IOSTAT speci er is present and an error occurs, the error code is returned in the ios variable and the program is not aborted. Refer to Appendix A for IOSTAT error codes. For the character expressions used with STATUS, ACCESS, FORM, and BLANK, only the rst character in each is signi cant. The following speci ers, extensions to the ANSI 77 standard, are included for compatibility with programs originally written in another version of FORTRAN.
ACCESS RECL RECORDTYPE 'SEQUENTIAL' Absent 'SEQUENTIAL' Present 'KEYED' Absent Present Present Variable 'KEYED' Present Fixed 'KEYED' Absent Variable 'KEYED' Absent Fixed 'DIRECT' 'DIRECT' Note Variable length le Variable length le (RECL = maximum record length) Error Fixed length le Error (RECL = maximum record length) Fixed length index sequential access le Error (Maximum record length is 2048 bytes) Error By default, les are opened for shared read/write access.
Examples Notes The le inv is connected to unit 10 as a sequential le. If an error occurs, control transfers to statement 100 and the error code is placed in the variable ios . OPEN (ACCESS='DIRECT', The character variable next1 contains the name of the le to be 1UNIT=4,RECL=50, 2FORM='FORMATTED',FILE=next1)connected to unit 4 as a formatted, direct access le with a record length of 50 characters.
99 500 continue WRITE(6,*) 'iostat value = ',ios STOP 'APPEND OPEN FAILED' FORMAT(2X,A20,I4) END subroutine OPEN_AND_WRITE(LUNIT,FNAME,STR) character*2 FNAME character*20 STR OPEN(unit=LU,file=FNAME,access='sequential',iostat=ios,err=98) DO I = 1, 25 WRITE(LU,499) STR, i END DO CLOSE(LU) 98 499 3-116 continue WRITE(6,*) 'iostat value = ',ios STOP 'OPEN FAILED' FORMAT(2X,A20,I4) END FORTRAN Statements
PARAMETER Statement (Nonexecutable) The PARAMETER statement de nes named constants. After a name is de ned in a PARAMETER statement, subsequent uses of the name are treated as if the value of the constant was used. Item Description/Default cname Symbolic name that represents a constant. cexp Constant expression or intrinsic function. Restrictions Name cannot appear in any statement before PARAMETER, except a type statement. If cexp is an intrinsic function, its arguments must be constants.
A symbolic name of a constant must not be de ned more than once in a program unit. If a symbolic name of a constant is not of the default implied type, its type must be speci ed by a type statement or IMPLICIT statement prior to its rst appearance in a PARAMETER statement.
Example The following program: PROGRAM parameters + LOGICAL CHARACTER INTEGER first_name_greater, scnd_name_greater ch*(*), name1*(*), name2*(*) length PARAMETER PARAMETER (ch = 'Guess my length') (name1 = 'William', name2 = 'David') PARAMETER (length = LEN(ch)) C Either form of lexical compare is allowed in PARAMETER + 10 PARAMETER (first_name_greater = LGT(name1, name2), scnd_name_greater = name2 .GT.
Alternate PARAMETER Statement (Nonexecutable) An alternate version of the PARAMETER statement is included for compatibility with other versions of FORTRAN. The alternate version di ers from the ANSI 77 standard in two ways: The parameter list is not bounded by parentheses. The type of the constant cexp determines the type of cname (regardless of explicit or implicit typing). Alternate PARAMETER statements must precede any executable statements in a program unit.
PAUSE Statement (Executable) The PAUSE statement causes a temporary break in program execution. Item constant Description/Default Restrictions Integer or character constant Cannot be a constant name or a constant expression. to be displayed in the PAUSE message. The PAUSE statement optionally writes a message and, if standard input is a terminal, waits for the user to request the program to continue. If constant is omitted, no message is written.
PRINT Statement (Executable) The PRINT statement only transfers data from memory to the standard output unit. (FORTRAN unit 6 is preconnected to the standard output device.) Item fmt implied do list Semantics Description/Default Format designator. An implied DO loop. Refer to \DO Statement (Executable)". Restrictions See \Semantics". None. The format designator must be one of the following: The statement label of a FORMAT statement.
An array element A substring A scalar record eld name An implied DO loop The PRINT statement is equivalent to the TYPE statement. Examples Notes and des are printed according to FORMAT statement 10. PRINT *,'x=',x 'x=' and the value of x are printed according to list-directed formatting. INTEGER fmt rat and cat are printed according to FORMAT ASSIGN 200 TO fmt statement 200.
PROGRAM Statement (Nonexecutable) The PROGRAM statement de nes the name of a program. Optionally, as an extension to the ANSI 77 standard, it also de nes the formal arguments of the main program in which the statement appears. Item name parameter Description/Default Restrictions Name of the program (and None. its main entry point). Optional program argument. Must be of type CHARACTER*N.
Examples PROGRAM main PROGRAM main() PROGRAM runit(a,b) Notes Speci es main as the name of the program. Speci es main as the name of the program, with no arguments. Speci es runit as the name of the program, and speci es its arguments as a,b. Note that one of these arguments must be an INTEGER*2 or INTEGER*4 and the other must be a CHARACTER*(*).
READ Statement (Executable) Standard Input READ Statement (Executable) The READ statement transfers data from a le to program variables. There are two kinds of READ statements: Standard input READ File READ The standard input READ statement complements the PRINT statement. The le READ statement complements the WRITE statement. A more detailed description of the READ statement is found in Chapter 4.
Semantics The format designator must be one of the following: The statement label of a FORMAT statement. An INTEGER*4 variable to which the statement label of a FORMAT statement has been assigned by an ASSIGN statement. A character or noncharacter array name that contains the representation of a format descriptor list enclosed in parentheses. The use of a noncharacter array is an extension to the ANSI 77 standard.
File READ Statement (Executable) 3-128 FORTRAN Statements The le READ statement transfers data from a le to memory.
Item unit address char variable char array element char substring integer expression * fmt namelist group name ios label rec zbf zln end key value key num Description/Default Arithmetic expression of type integer. Expression specifying unit number of a sequential le. Internal le from which input is taken. Internal le from which input is taken. Restrictions See \Semantics". Must be an integer: zero or positive. Character variable or scalar record eld.
Semantics A le READ statement must contain a unit speci er and at most one of each of the other speci ers. If the pre x UNIT= is omitted, unit must be the rst item in the list. This is the unit number for the input device or le. If the pre x FMT= is omitted, fmt must be the second item in the list and unit (without a pre x) must be the rst item. If fmt is omitted and no NML speci er is present, the access is unformatted (binary). record name and aggregate variables can only be used in unformatted reads.
If the KEYID speci er is not present, the primary key is assumed. The subsequent reads do not assume the previous KEYID value for the current read. As an extension to the ANSI 77 standard, sequential reads (without the REC speci er) are allowed on les open for direct access. If the REC speci er is omitted, a READ statement reads the next record. Examples Notes Reads the values of a, b, and c from the le connected to unit 8 according to FORMAT statement 10.
REAL Statement (Nonexecutable) 3-132 FORTRAN Statements The REAL type speci cation statement explicitly assigns the REAL*4, REAL*8, and REAL*16 data types to symbolic names, and optionally assigns initial values to variables. The following syntax includes the REAL, REAL*4, REAL*8, REAL*16, and DOUBLE PRECISION statements.
Semantics The REAL and REAL*4 statements are equivalent. The DOUBLE PRECISION and REAL*8 statements are equivalent. The REAL*16 statement has no equivalent. The REAL*4, REAL*8, and REAL*16 statements are extensions to the ANSI 77 standard. As an extension to the ANSI 77 standard, a length speci er can follow the item being declared. This speci er overrides the data length implied by the type statement.
REAL*4 Statement (Nonexecutable) REAL*8 Statement (Nonexecutable) REAL*16 Statement (Nonexecutable) 3-134 FORTRAN Statements The REAL*4 statement, which is an extension to the ANSI 77 standard, is a special case of the REAL statement. See \REAL Statement (Nonexecutable)" for details. The REAL*4 statement is equivalent to the REAL statement. The REAL*8 statement, which is an extension to the ANSI 77 standard, is a special case of the REAL statement. See \REAL Statement (Nonexecutable)" for details.
RECORD Statement (Nonexecutable) The RECORD statement declares a record variable that has the form previously declared in a STRUCTURE statement. Item Description/Default Restrictions Name of a previously declared structure. struc name Cannot be the name of a structure currently being declared. None. None. None. Variable name. array name Array name. array declaratorArray declaration. variable name Semantics Record names can be used in COMMON, DIMENSION, and SAVE statements.
RETURN Statement (Executable) The RETURN statement transfers control from a subprogram back to the calling program unit. Item rtnnum Semantics Description/Default Restrictions Integer expression specifying See \Semantics". the alternate return number. Normally, control returns from a subroutine to the calling program unit at the statement following the CALL statement. Specifying alternate return statements allows return to the calling program unit at any labeled executable statement within it.
may have any numeric data type. If rtnnum is not an integer, it will be converted to one. If the $HP1000 ARRAYS compiler directive is in e ect, rtnnum may be an array name. If rtnnum is an array name, the rst element of the array will be used. rtnnum Examples Notes The CALL statement speci es three PROGRAM main .. possible return labels, plus the . normal return point (the statement CALL matrx (*10,m,*20,n,k,*30) .. following the CALL). . 10 . ... ! executable statement . . 20 . ...
REWIND Statement (Executable) The REWIND statement positions a sequential le or device at its beginning. Item unit variable name array element scalar record eld name label Semantics Description/Default Restrictions Must be zero or Integer expression specifying unit number positive. of a connected le. Error code return. Must be an integer data type. Statement label. Must be an executable statement in the same program unit.
Examples REWIND 10 Notes The le connected to unit 10 is positioned at its beginning. REWIND (UNIT=5, IOSTAT=j, ERR=100) The le connected to unit 5 is positioned at its beginning. If an error occurs, control transfers to statement 100 and the error code is returned in j. If no error occurs, j is set to zero and control transfers to the next statement. REWIND (UNIT=62, IOSTAT=j) REWIND (UNIT=12, ERR=100) The le connected to unit 62 is positioned at its beginning.
REWRITE Statement (Executable) 3-140 FORTRAN Statements The REWRITE statement is used to update existing records in an ISAM le. The record being updated is the most recent record read from the le by a READ statement. REWRITE unlocks the record if it is locked.
Item Description/Default char variable Integer expression specifying the unit number of a le. Integer expression. Internal le written. char array element Internal le written. char substring Internal le written. Integer expression specifying the unit number of an internal le. Format designator. unit address integer expression fmt namelist group name ios label Symbolic name specifying a list of variables or arrays previously declared in a NAMELIST statement.
If the ERR speci er is present and an error occurs during execution of the REWRITE statement, control transfers to the speci ed statement rather than aborting the program. Examples Notes READ (10,KEY='111-22-333',ERR=555) Updates a record. It reads the +EMPLOYEE_REC record, changes the elds, and then updates the record by using EMPLYEE_REC.BONUS = REWRITE. +EMPLOYEE_REC.SALARY * 0.
SAVE Statement (Nonexecutable) The SAVE statement causes the speci ed variables in the program unit to maintain their values after the execution of a RETURN or END statement. Semantics The following items must not be mentioned in a SAVE statement: formal argument names, procedure names, and names of variables in a common block. A SAVE statement without a list of variable names or common block names declares that all allowable variables in the subprogram must be saved.
Statement Function The statement function statement de nes a one-statement function. Statement (Nonexecutable) Item name parm exp Description/Default Name of the function. Formal argument. Arithmetic, logical, or character expression. Restrictions None. Must be a simple variable. None. A statement function is a program-de ned, single-statement computation that applies only to the program unit in which it is de ned.
Examples Notes is a statement function with three dummy arguments, a, b, and c. disp(a,b,c)=a + b*c disp tim(t1)=t1/2 + b tim is a statement function with one dummy argument, t1. b is an actual variable that is declared elsewhere in the program unit.
STOP Statement The STOP statement terminates program execution. (Executable) Item Description/Default Restrictions Integer or character constant Cannot be a constant name to be displayed in the STOP or constant expression. message. constant The STOP statement terminates program execution immediately without allowing execution to reach the END statement of the main program unit.
STRUCTURE Statement (Nonexecutable) The STRUCTURE statement names and begins the declaration of a structure in a structure block. A structure is the \data type" of a record variable. It must be declared before a RECORD statement can refer to it. The END STRUCTURE statement terminates a structure block. A structure block has the following elements: STRUCTURE statement Begins the structure declaration.
Note 3-148 FORTRAN Statements structure. These eld declarations can be any combination of the following: Type speci cation statement Any type speci cation statement de ning variables or array declarators. Substructure declaration A substructure can be declared in two ways: 1. With a RECORD statement using a previously de ned structure. 2. As a structure declaration block having a eld name .
Field Declarations All elds declared within a structure must be explicitly typed. The IMPLICIT statement has no e ect on eld names within a structure declaration block. A eld that is an array must be speci ed as an array name with dimension declarator within the explicit type speci cation statement. The DIMENSION statement is not permitted within a structure. For example: REAL*4 field2(10) declares field2 to be an array of 10 4-byte real values.
UNION Statement (Nonexecutable) The UNION statement begins the declaration of a union block in a structure block. A union block de nes a shared data section of a structure. The END UNION statement terminates a union block. A union block has the following elements: UNION statement Begins the union declaration. Declaration body Two or more map declaration blocks. END UNION statement Ends the union declaration.
MAP Statement (Nonexecutable) The MAP statement begins the declaration of a map block in a union declaration block. The END MAP statement terminates a map block. A MAP block has the following elements: MAP statement Begins the MAP declaration. Declaration body Declares the elds of the map block, including their names, data types, order, and alignment. Fields are in the order of their declaration. END MAP statement Ends the MAP declaration.
Examples STRUCTURE /num1/ INTEGER*4 i, j END STRUCTURE STRUCTURE /num2/ UNION MAP INTEGER*4 i REAL*4 a END MAP MAP INTEGER*4 j LOGICAL*1 x(10) END MAP END UNION END STRUCTURE RECORD /num2/ overlay STRUCTURE /outer/ STRUCTURE /inner/ self INTEGER*4 ssn INTEGER*2 age CHARACTER*18 name END STRUCTURE RECORD /inner/ spouse RECORD /num1/ data END STRUCTURE RECORD /outer/ personal RECORD /inner/ someone 3-152 FORTRAN Statements Notes The structure num1 de nes two 4-byte integer elds, i and j, which occupy con
SUBROUTINE Statement The SUBROUTINE statement identi es a program unit as a subroutine subprogram. (Nonexecutable) Item Description/Default Indicates an alternate return. * Restrictions None. Semantics The formal arguments in a SUBROUTINE statement can be variables, array names, record names, or subprogram names. The formal arguments must be of the same type and structure as the actual arguments passed to the subroutine.
SYSTEM INTRINSIC Statement (Nonexecutable) The MPE/iX le SYSINTR.PUB.SYS contains information about the attributes of subprograms. These subprograms are usually user-callable system subprograms, such as FOPEN. All intrinsics mentioned in the MPE/iX manuals must be accessed through this facility.
to indicate how parameters should be passed or the routine might not even be callable because of the parameter type.) Parameter checking is performed at the highest level (level 3 of CHECK ACTUAL PARM) at compile time. * Automatic typing of SYSINTR le functions is provided. Thus, the intrinsic mechanism automatically types the function return type for you. For example, the statement SYSTEM INTRINSIC FOPEN, BINARY results in FOPEN being typed INTEGER*2 and BINARY being typed LOGICAL*2.
command = "DATE"//char(13) CALL HPCICOMMAND(command, cmderror, parmnum, 0) END The program excommand uses the system intrinsic HPCICOMMAND to execute the MPE/iX DATE command. The results from executing the program look similar to this: THU, JAN 16, 1992, 8:41 AM Note that the above example will be referenced in the sections \A Reference Parameter" and \The ANYVAR Parameter and UNCHECKABLE ANYVAR Option.
the HP Pascal/iX UNCHECKABLE ANYVAR option and no hidden parameters are passed for the ANYVAR parameter. An EXTENSIBLE Parameter EXTENSIBLE is an HP Pascal/iX procedure option that identi es a procedure that has an extensible parameter list . An extensible parameter list has a xed number of nonextension parameters and a variable number of extension parameters.
item2 = 0 ! The file "testfile" has READ access CALL HPFOPEN(filenum, status, itemnum1, item1, itemnum2, item2) PRINT PRINT PRINT PRINT END '(" File Name : " A20)',item1 '(" File Number: " I6)',filenum '(" File Status: " I6)',status *,CHAR(13) produces these results: File Name : testfile File Number: 9 File Status: 0 Note that the example in this section is referenced in the section \A DEFAULT PARMS Parameter.
TYPE Statement (Executable) The TYPE statement transfers data from memory to the standard output unit. (FORTRAN unit 6 is preconnected to the standard output unit.) Semantics The TYPE statement, which is an extension to the ANSI 77 standard, is equivalent to the PRINT statement. See \PRINT Statement (Executable)" for further information.
UNION Statement (Nonexecutable) 3-160 FORTRAN Statements The UNION statement begins a UNION statement block in a STRUCTURE statement block. For more information, refer to \STRUCTURE Statement (Nonexecutable)".
UNLOCK Statement (Executable) The UNLOCK statement unlocks a record that was locked by a READ on an ISAM le. If an ISAM le is shared by more than one process, you should unlock the records after each READ if they are not being updated. If the le is not shared, UNLOCK has no e ect. Item unit Description/Default Must be zero or positive. Integer expression specifying unit number of a connected le. Error code return. Must be an integer type.
Examples Notes This example generates a OPEN(10,file='EMP_FILE', +ACCESS='KEYED',STATUS='OLD',SHARED)report. The READ 111 READ (10,ERR=111,END=222) EMPLOY_RECstatement locks the record when it reads it. The UNLOCK (10,ERR=112) UNLOCK statement unlocks PRINT 11,EMPLOYEE_REC.SSN, the record to allow other + EMPLOYEE_REC.FIRST_NAME users to access it. If the + EMPLOYEE_REC.LAST_NAME, record is locked by another + EMPLOYEE_REC.SALARY, user, the ERR speci er + EMPLOYEE_REC.
VIRTUAL Statement (Nonexecutable) The VIRTUAL statement de nes the dimensions and bounds of arrays. Item array name dimension declarator Description/Default Symbolic name of the array. De nes the number of dimensions and the range of each dimension. Restrictions None. Same as for the DIMENSION statement. The VIRTUAL statement, which is an extension to the ANSI 77 standard, is equivalent to the DIMENSION statement. See \DIMENSION Statement (Nonexecutable)" for further information.
VOLATILE Statement (Nonexecutable) The VOLATILE statement speci es variables, arrays, and common blocks that will not be selected for global analysis and optimization by the compiler. Item Description/Default Variable, array, record, or common variable name block that is not being optimized. array name record name common block name Semantics Restrictions None. The VOLATILE statement is an extension to the ANSI 77 standard.
handler might use the incorrect value for a shared quantity because the value was kept in the registers and not updated in memory. Example INTEGER a, b, c, d INTEGER p, q, r COMMON /block1/ a, b, c VOLATILE /block1/, q, r Notes The common block block1 and variables q and r are volatile and will not be selected for global analysis or optimization. An equivalent VOLATILE statement is VOLATILE q, r, /block1/ INTEGER a, b EQUIVALENCE (a,b) VOLATILE a The variable b also becomes volatile.
WRITE Statement (Executable) 3-166 FORTRAN Statements The WRITE statement transfers data from memory to a le or device.
Item Description/Default Restrictions Must be zero or positive. char variable Integer expression specifying the unit number of a le. Arithmetic expression of type integer. Internal le written. char array element Internal le written. char substring Internal le written. Integer expression specifying the unit number of an internal le. Asterisk indicates that None. the standard output device (unit 6, usually a terminal) is to be used. Format designator. fmt must be as speci ed in the PRINT statement.
A WRITE statement must contain a unit number and at most one of each of the other options. If the pre x UNIT= is omitted, unit must be the rst item in the list. This is the unit number for the output device or le. If the pre x FMT= is omitted, fmt must be the second item in the list and unit (without a pre x) must be the rst item. If fmt is not present and a namelist group name is not speci ed, the write is unformatted (binary). record name and aggregate variables can only be used in unformatted writes.
Examples WRITE (7,10) a,b,c ASSIGN 4 TO num WRITE (UNIT=3,IOSTAT=j, +ERR=5,FMT=num) z WRITE (10) (x + y) WRITE (10,FMT=*) b Notes The values of a, b, and c are written to the le connected to unit 7 according to FORMAT statement 10. The value of z is written to the le connected to unit 3, according to FORMAT statement 4. If an error occurs, control transfers to statement 5 and the error code is returned in j. The value of the expression (x + y) is written to the le connected to unit 10.
4 Input/Output Input/output (I/O) statements allow you to enter data into a program and to transfer data between a program and a disk le, terminal, or other device. There are four types of input/output: Formatted input/output. Unformatted input/output. List-directed input/output. Namelist-directed input/output. For each type of input/output, there are one or more input statements and corresponding output statements. In the examples in this chapter, 1 represents a blank.
The format designator, fmt , must be one of the following: The statement label of a FORMAT statement. A variable name that has been assigned the statement label of a FORMAT statement. A character expression. A character array name that contains the representation of a format speci cation. An asterisk, indicating list-directed formatting. list can contain implied DO loops. For information on implied DO loops, refer to the section \DO Statement (Executable)" in Chapter 3.
You cannot use the comma to terminate the input eld or to assign values when using the A, R, M, or N format descriptors, because the comma has a meaning for these descriptors.
Formatted Output Formatted output is speci ed by the following output statements. Only the brief forms of the relevant syntax elements are shown here. For the complete syntax, refer to \PRINT Statement (Executable)" in Chapter 3 and \WRITE Statement (Executable)" in Chapter 3. Syntax PRINT fmt , list 2 3 WRITE ( unit , fmt ) , list Item fmt unit list 4-4 Input/Output Description/Default Restrictions Format designator. See \Semantics". Unit number of the le. None. See \Semantics".
Semantics Note The format designator, fmt , must be one of the following: The statement label of a FORMAT statement. A variable name that has been assigned the statement label of a FORMAT statement by an ASSIGN statement. A character expression. A character array name that contains the representation of a format speci cation. An asterisk, indicating list-directed formatting. If list is omitted, a blank line is written (unless a literal appears in the format before a repeatable format descriptor).
Carriage Control The rst character of each output record is always considered to be a carriage control character for devices that recognize carriage control. The standard carriage control characters are listed in Table 4-1. Table 4-1.
Format Specifications A format speci cation is a list of format descriptors and edit descriptors, enclosed in parentheses. It is equivalent to a FORMAT statement without the label and FORMAT keyword. Format Speci cation Syntax ( descriptor list ) Descriptor List Syntax 82 < 2 repeat 3 9 spec 3format descriptor =2 2 3 3 , ... repeat spec ( descriptor list ) ; : edit descriptor Item Description/Default Restrictions edit descriptor An edit descriptor, None. format None. as described in Table 4-3.
Figure 4-1. Output Formatting Format speci cations can be supplied in FORMAT statements or written as character expressions in input/output statements. Format Specifications in Format Statements A format speci cation can be placed in a FORMAT statement that is referenced by a corresponding READ, WRITE, or PRINT statement. For the complete syntax de nition, refer to \FORMAT Statement (Nonexecutable)" in Chapter 3.
Format Specifications in Input/Output Statements The format speci cation can be contained in the input/output statement as a character expression. Examples READ (4,'(A3,3X,F10.2)') a,z CHARACTER*6 a DATA a /'(3I3) '/ PRINT a,i,j,k WRITE (6,'(F10.2)') d Notes The variables a and z are read according to the format speci cation (A3,3X,F10.2) . The three integers i, j, and k are printed according to the format speci cation (3I3).
Format Descriptors The descriptors in a format speci cation must be separated by a comma except before and after a slash (/) edit descriptor, a colon (:) edit descriptor, or between a scaling (P) edit descriptor and an immediately following D, E, F, or G edit descriptor. For example, if a slash descriptor is used to indicate a new line of output or a new record on input, the comma that would separate the descriptors is not necessary. The speci cation: 3I,F4.0,/I5,F12.6 is equivalent to: 3I,F4.0/I5,F12.
Table 4-2. Format Descriptors Data Type Format Descriptor INTEGER*2, INTEGER*4 REAL*4, REAL*8, REAL*16 COMPLEX*8, COMPLEX*16 REAL*4, REAL*8, REAL*16 COMPLEX*8, COMPLEX*16 REAL*4, REAL*8, REAL*16 COMPLEX*8, COMPLEX*16 On input: INTEGER*2, INTEGER*4 On output: any type On input: INTEGER*2, INTEGER*4 On output: any type LOGICAL*1, LOGICAL*2, LOGICAL*4 REAL*4, REAL*8, REAL*16 I[w [.m ]] REAL*4, REAL*8, REAL*16 N[ w .
Table 4-3. Edit Descriptors Edit Descriptor BN BZ n Hstring "string " 'string ' NL NN $ kP Q SP SS S Tc TLt TRt xX / : 4-12 Input/Output Function Ignore blanks. Treat blanks as zeros. Hollerith literal editing Literal editing. Literal editing. Restore newline. No newline. No newline; same as NN. Scale factor. Number of characters remaining in current input record. Output optional plus signs. Inhibit optional plus sign output. Processor determines sign output; same as SS. Skip to column c.
Numeric Format Descriptors The numeric format descriptors specify the input/output elds of integer, real, and complex data types. The following rules apply to all numeric format descriptors: The eld width, w , speci es the total number of characters that a data eld occupies, including any leading plus or minus sign, decimal point, or exponent. On input, leading blanks are not signi cant.
Integer Format Descriptor (I) The I[w [.m ]] format descriptor de nes a eld for an integer number. The corresponding input/output list item must be a numeric type. The optional m value speci es a minimum number of digits to be output. If m is not shown, a default value of one is assumed. The m value is ignored on input.
Real Format Descriptors (D, E, F, G) The D[w .d ], E[w .d [Ee]], F[w .d ], and G[w .d [Ee ]] format descriptors de ne elds for real or complex numbers. (Note that two descriptors must be speci ed for a complex value.) The input/output list item corresponding to a D, E, F, or G descriptor must be a numeric type. On input, all of these format descriptors work identically.
Floating-Point Format Descriptors (D, E) The D[w .d ] and E[w .d [Ee ]] format descriptors de ne a oating-point eld on output for real and complex values. The value is rounded to d digits. The exponent part consists of e digits. If Ee is omitted, the exponent occupies two positions.
Fixed-Point Format Descriptor (F) The F[w .d ] format descriptor de nes a xed-point eld on output for real and complex values. The value is rounded to d digits to the right of the decimal point. The eld width, w , should be four greater than the expected length of the number, to provide positions for a leading blank, the sign, the decimal point, and a roll-over digit for rounding if needed. Output Examples Descriptor Internal Value Output Field F5.2 F3.1 F6.3 F8.2 F8.2 F7.2 F4.1 +10.567 0254.2 +5.
Fixed- or Floating-Point Format Descriptor (G) The G[w .d [Ee ]] format descriptor de nes a xed- or oating-point eld, as needed, on output for real and complex values. The G format descriptor is interpreted as an Fw .d descriptor for xed-point form or as an Ew .d [Ee ] descriptor for oating-point form according to the magnitude of the data. If the magnitude is less than 0.1 or greater than or equal to 10**d (after rounding to d digits), the Ew .d [Ee ] format descriptor is used; otherwise the Fw .
Character Format Descriptors (A, R) The A[w ] and R[w ] format descriptors de ne elds for character and noncharacter data. The size of the list variable (byte length) determines the maximum e ective value for w . If w is not speci ed, the size of the eld is equal to the size of the input/output variable. As an extension to the ANSI 77 standard, any data type can be used with the A and R descriptors.
Input Examples Value Stored Descriptor Input Field Internal Length A3 XYZ R3 XYZ A5 ABC11 R9 RIGHTMOST A5 CHAIR R8 CHAIR111 A4 ABCD 3 4 10 4 5 8 2 XYZ tXYZ ABC11111111 MOST CHAIR CHAIR111 CD Output Examples Descriptor Internal Value Internal Output Field Length A6 R4 A4 A8 A4 R8 ABCDEF ABCDEFGH ABCDE STATUS NEXT STATUS 6 4 5 6 4 6 ABCDEF EFGH ABCD STATUS11 NEXT 11STATUS Numeric Data with Character Format Descriptors The A and R character format descriptors can be used with integer an
For more information refer to \NOSTANDARD Directive" in Chapter 7.
Logical Format Descriptor (L) The L[w ] format descriptor de nes a eld for logical data. The input/output list item corresponding to a L descriptor must be a logical type. On input, the eld width is scanned for optional blanks followed by an optional decimal point, followed by a T for true or an F for false. The rst nonblank character in the input eld (excluding the optional decimal point) determines the value to be stored in the declared logical variable.
Octal Format Descriptors (@, K, O) As an extension to the ANSI 77 standard, the @[w [.m ]], K[w [.m ]], and O[w [.m ]] format descriptors de ne a eld for octal data. These descriptors provide conversion between an external octal number and its internal representation. On output, list elements may be of any type, though character variables are output only as the octal equivalent of their ASCII representation (no length descriptor). Variables to receive octal input must be integer types.
Hexadecimal Format Descriptor (Z) As an extension to the ANSI 77 standard, the Z[w [.m ]] format descriptor de nes a eld for hexadecimal data. This descriptor provides conversion between an external hexadecimal number and its internal representation. On output, list elements may be of any type, though character variables are output only as the hexadecimal equivalent of their ASCII representation (without a length descriptor). Variables to receive hexadecimal input must be an integer type.
Output Examples Descriptor Z6 Z2 Z7 Z6 Internal Value (Decimal) 99 299 01 (INTEGER*4) 32767 Output Field (Hexadecimal) 111163 ** ******* 117FFF Input/Output 4-25
Variable Format Descriptor () Variable format descriptors, having the form , allow the values of integer variables, integer constant names, and character constants to be used in format speci cations. Integer variable format descriptors may be used wherever an integer may appear, except they cannot be used to specify the number of characters in a Hollerith descriptor.
20 CONTINUE END Input/Output 4-27
Output (1 is a blank): 11 112 1113 1111.0 Format speci cation (1x,I) became (1x,I1) Format speci cation (1x,I) became (1x,I2) Format speci cation (1x,I) became (1x,I3) Format speci cation (1x,F5.1) became 1112.0115.0 Format speci cation (1x,F5.1) became (1x,1F5.1) (1x,2F5.1) 1113.0116.0119.0 Format speci cation (1x,F5.1) became (1x,3F5.
Monetary Format Descriptor (M) The M[w .d ] format descriptor de nes a eld for a real number without an exponent ( xed-point) written in monetary form. On output, the M format descriptor causes output of a numeric value in ASCII character xed-point form, right-justi ed with commas and a dollar sign. The least signi cant digit (position d ) is rounded. If needed, a leading minus sign is printed before the dollar sign.
Numeration Format Descriptor (N) The N[w .d ] eld descriptor de nes a eld for a real number without an exponent ( xed-point) written in numeration form (that is, with commas, which are then ignored, in the input eld). On output, the N eld descriptor causes output of a numeric value in ASCII character xed-point form, right-justi ed with commas. The least signi cant digit is rounded. If needed, a leading minus sign is printed before the most signi cant digit.
Edit Descriptors Blank Interpretation Edit Descriptors (BN, BZ) Edit descriptors specify editing between numeric, Hollerith, and logical elds on input and output records. There are 19 edit descriptors. BN, BZ, and Q apply only to input. NL, NN, $, S, SP, and SS apply only to output. H, "string ", 'string ', P, T, TL, TR, X, /, and : apply to both input and output. The BN and BZ edit descriptors interpret embedded and trailing blanks in numeric input elds.
End-of-Line Edit Descriptors (NL, NN, $) 4-32 Input/Output As extensions to the ANSI 77 standard, FORTRAN 77 has edit descriptors to control the action taken at the end of an output line or record. These actions include controlling the cursor position on a terminal after a write and performing multiple writes on the same output line.
Example PROGRAM test n=23 WRITE(6,100) (i, i=1,7) WRITE(6,200) (i, i=1,n) WRITE(6,*) WRITE(6,*) WRITE(6,100) (i, i=1,7) WRITE(6,300) (i, i=1,n) WRITE(6,*) WRITE(6,*) WRITE(6,100) (i, i=1,7) WRITE(6,400) (i, i=1,n) WRITE(6,*) WRITE(6,*) WRITE(6,100) (i, i=1,7) WRITE(6,500) (i, i=1,n) FORMAT (7I5) FORMAT (NN, 3I5, :, /, NL, (10I5)) FORMAT (3I5, :, /, NL, (10I5)) FORMAT (3I5, :, /, (10I5)) FORMAT (NN, 3I5, :, /, (10I5)) END 100 200 300 400 500 Output 1 4 14 2 5 15 3 6 16 4 7 17 5 8 18 6 9 19 7 10 20 1
Plus Sign Edit Descriptors (S, SP, SS) Literal Edit Descriptors ('string', \string", H) The S, SP, and SS edit descriptors control printing of optional plus signs in numeric output. A formatted output statement does not normally print optional plus signs. However, an SP edit descriptor in the format descriptor forces optional plus signs to print in any subsequent numeric output. The S and SS descriptors inhibit printing of optional plus signs in subsequent numeric output.
Input Bytes Remaining Edit Descriptor (Q) Position Edit Descriptor (X) As an extension to the ANSI 77 standard, the Q edit descriptor returns the number of bytes remaining on the current input record. The value is returned to the next item in the input list, which must be an integer variable. This is useful when the exact contents of the input record are to be read, avoiding the blank padding of further variables read. This descriptor applies to input only. It is ignored in output statements.
Tab Edit Descriptors (T, TL, TR) The tab edit descriptors position the cursor on the input or output record. The Tc edit descriptor speci es an absolute column number (c ), while the TLt and TRt descriptors specify a number of column positions to skip the left (TL) or right (TR) of the current cursor position. The TR descriptor is identical to the X descriptor.
terminates format control before the string value= can be output a third time.
Scale Factor Edit Descriptor (P) The scale factor edit descriptor, k P (k is the scale value), is a descriptor that modi es the output of the D[w .d ], E[w .d ], and G[w .d ] (interpreted as E[w .d ]) format descriptors and the xed-point output of the F[w .d ] format descriptor. The scale factor also modi es the xed-point inputs to the D[w .d ], E[w .d ], F[w .d ], and G[w .d ] format descriptors. A scale factor has no e ect on the output of the G[w .d ] (interpreted as F[w .
For E[w .d ], D[w .d ], and G[w .d ] (interpreted as E[w .d ]) format descriptors, the scale factor has the e ect of shifting the decimal point of the output number to the right k places while reducing the exponent by k (the value of the mantissa remains the same). The number of signi cant digits printed is equal to (d + k ). Output Examples for E, D, and G Descriptors Stored Value Output Field E12.4 3PE12.4 -3PD12.4 1PG11.3 12.345678 12.345678 12.345678 1234 111.1235E+02 111123.5E 001 111.0001D+05 111.
Repeat Specification The repeat speci cation is a positive integer written to the left of the format descriptor it controls. If a scale factor is needed also, it is written to the left of the repeat speci cation. The repeat speci cation allows one format descriptor to be used for several list elements. It can also be used for nested format speci cations; thus edit descriptors can be repeated by enclosing them in parentheses as shown above. Examples (L2,2(F2.0,2PE4.1),I5) Equivalent to (F10.5,F10.5,F10.
Processing a Format Specification A formatted input/output statement references each element in a series of list elements, and the corresponding format speci cation is scanned to nd a format descriptor for each list element. As long as a list element and eld descriptor pair occurs, normal execution continues.
Unformatted Input/Output Unformatted Input Unformatted input/output allows you to transfer data in internal representation (binary). Each unformatted input/output statement transfers exactly one record. Unformatted input/output to devices is done in binary mode. Unformatted input is speci ed by the following input statement. Only the brief forms of the relevant syntax elements are shown here. For the complete syntax, refer to \READ Statement (Executable)" in Chapter 3. Syntax 2 3 READ ( unit ...
Unformatted Output Unformatted output is speci ed by the following output statement. Only the brief forms of the relevant syntax elements are shown here. For the complete syntax, refer to \WRITE Statement (Executable)" in Chapter 3. Syntax 2 3 WRITE ( unit ) , list Item unit list Description/Default Restrictions Unit number of the le. None. None. List of variables or expressions that speci es the data to be transferred. The list can contain implied DO loops.
List-Directed Input/Output List-Directed Input List-directed input/output allows you to transfer data without specifying its exact format. The format of the data is determined by the data itself. List-directed input is speci ed by the following input statements: Only the brief forms of the relevant syntax elements are shown here. For the complete syntax, refer to \READ Statement (Executable)" in Chapter 3. Syntax READ * , list 2 3 READ ( unit , * ...
The r *c form means r repetitions of the constant c , and the r * form means r repetitions of null values. Neither form can contain embedded blanks, except where permitted in the constant c . Reading always starts at the beginning of a new record. As many records as required to satisfy the list are read unless a slash in the input record is encountered. Embedded blanks in input values are not allowed (they are always interpreted as value separators).
The statement: READ *,s,t,x,y,z and the input record: 11'TOTAL'11(421,11),TRUE11362111563.63D6 cause the following assignments to take place, assuming the variable is of the speci ed type: Variable s t x y z Data Type Value Assigned CHARACTER*5 COMPLEX*8 LOGICAL*4 REAL*4 REAL*8 'TOTAL' (42.,1.) .TRUE. 362. 563.632106 A null value can be speci ed in place of a constant when you do not want the value of the corresponding list item to change.
is continued on another line. (That is, character constants can be continued.
List-Directed Output List-directed output is speci ed by the following output statements: Only the brief forms of the relevant syntax elements are shown here. For the complete syntax, refer to \PRINT Statement (Executable)" in Chapter 3 and \WRITE Statement (Executable)" in Chapter 3. Syntax PRINT * , list 2 3 WRITE ( unit , * ... ) list Item unit list Semantics Description/Default Restrictions Unit number of the internal None. or external le. See \Semantics".
Table 4-6. List-Directed Output Format Data Type Output Record Format INTEGER*2 Output as integer constants. INTEGER*4 Note: LOGICAL*1 (BYTE) produces integer output, not LOGICAL*1 logical output. REAL*4 Output with or without an exponent, depending on the REAL*8 magnitude of the value. REAL*16 COMPLEX*8 Output as two REAL*4 or REAL*8 values, separated by COMPLEX*16commas and enclosed in parentheses. LOGICAL*2 Output as a T for the value true and an F for the value false.
Every value is preceded by exactly one blank, except character values. Trailing zeros after a decimal point are omitted. A blank character is also inserted at the beginning of each record to provide carriage control when the le is printed. Sample Program Data Internal Values Data Type = 11.15 b = .11145D005 c = (10 , 3.0) d = (1.582D003 , 4.9851) e = .TRUE. f = .FALSE. i = 11250 j = 032799 n = 'PROGRAM NAME' p = 'test.
The total length of each list-directed output record to an external le is 72 bytes or less, including carriage control. Items that would over ow the 72-byte record if added to the current record cause the current record to be written out and a new record started. The item that caused the over ow begins the new record. Character strings longer than 71 characters are broken into as many records as necessary, with each record given a leading blank for carriage control.
Namelist-Directed Input/Output Namelist Specifier Namelist-directed input/output statements are similar in function to formatted statements. However, they use di erent mechanisms to control the translation of data. Formatted I/O statements use explicit format speci ers; namelist-directed I/O statements use data types.
Namelist-Directed Input The namelist-directed READ statement reads external records sequentially until it nds the speci ed group name. Using the data types of the entities in the corresponding NAMELIST statement, it then translates the data from external to internal form and assigns the translated data to the speci ed namelist entities. External File Syntax 2 $group name entity1 = value1 , entity2 = value2 2 3 $ END 3 2 ,... 3 Example NAMELIST /FOO/I,J,K,/BOO/L,M,K CHARACTER*10 K INTEGER I,J,L,M .. .
You can input a question mark (?) to a namelist READ statement to print the current value of all the items on the namelist. Input is allowed from either a terminal or le and output is written to unit 6. Unit 6 must be connected to a terminal for the question mark to generate output. If unit 6 is not connected to a terminal, the question mark is ignored.
The following is a sample namelist program and its output using the query feature: PROGRAM query INTEGER lu, iu PARAMETER (lu = 6) PARAMETER (iu = 5) CHARACTER*1 i1 CHARACTER*10 j1 CHARACTER*255 k1 DATA i1 /' '/ DATA j1 /' '/ NAMELIST/n/i1,j1,k1 DO i = 1,255 k1(i:i+1) = ' ' END DO WRITE(lu,25) 'Enter ? to see current namelist values' WRITE(lu,25) 'then enter the values i1 and j1 as shown below:' WRITE(lu,25) '$N' WRITE(lu,25) 'i1=''I'' j1=''CAN''' WRITE(lu,25) '$END' READ(iu,nml=n) WRITE(lu,25) '-----------
The output is shown below. User input is underlined.
----------------------------------------------Enter ? to verify i1, j1 and k1 initialized then enter the following: $N $END ? $N I1 ='I' J1 ='CAN ' K1 ='ANSWER $END $N $END ----------------------------------------------Enter ? again to verify multiple question marks then enter the following: $N $END ? $N I1 ='I' J1 ='CAN ' K1 ='ANSWER ' ' $END $N $END Input/Output 4-57
Namelist-Directed Output The namelist-directed WRITE statement is a sequential write that translates internal storage to external records according to the speci ed namelist. Only the brief forms of the relevant syntax elements are shown here. For the complete syntax, refer to \READ Statement (Executable)" in Chapter 3. Syntax 2 3 2 3 WRITE ( unit , NML = group name ... ) Namelist-directed output is suitable for use as namelist-directed input. Namelist Output File Syntax $group name entity = value . .
5 File Handling This chapter describes the OPEN statement and the procedures used for MPE/iX le handling. The OPEN Statement Files are always referenced in FORTRAN 77 programs using unit numbers. Under MPE/iX, FORTRAN 77 preconnects two units at the beginning of every program. Unit ve is connected to $STDIN by the formal le designator FTN05 and unit six is connected to $STDLIST by the formal le designator FTN06.
The FNUM Procedure Occasionally you might want to use MPE/iX intrinsics to perform I/O directly. You can intermix FORTRAN I/O and intrinsic I/O to the same le by using the FNUM procedure. The FNUM procedure can be called from an HP FORTRAN 77 program as follows: i = FNUM(unit) Item unit Description/Default Positive integer (INTEGER*2 or INTEGER*4) that speci es the le table entry for which the MPE/iX system le is to be extracted. Restrictions Must be nonnegative.
The FSET Procedure The FSET procedure changes the MPE/iX operating system le number assigned to a given FORTRAN 77 logical unit number. The FSET procedure is called from an HP FORTRAN 77 program as follows: CALL FSET(unit, newfile, oldfile) Item unit newfile oldfile Description/Default Restrictions Must be nonnegative. Positive integer constant or variable (INTEGER*2 or INTEGER*4) that speci es the le table entry for which the change is to be made. None.
The UNITCONTROL Procedure The UNITCONTROL procedure enables a FORTRAN 77 program to request several actions for any FORTRAN logical unit. The UNITCONTROL procedure is called from an HP FORTRAN 77 program as follows: CALL UNITCONTROL(unit,opt) Item unit opt Description/Default Restrictions Must be nonnegative. Positive integer (INTEGER*2 or INTEGER*4) that specci es the unit number of the le to be used. Integer (INTEGER*2 or INTEGER*4) None. that speci es the option (see table 5-1).
Automatically Opening Files For compatibility with FORTRAN 66/V, the FORTRAN 77 I/O library automatically opens units 1 through 99 (excluding 5 and 6) to the formal le designators FTN01 throught FTN99, respectively. OPEN statements are not required for these les, though a :FILE equation is usually required. If no :FILE equation is used, and the rst executed I/O statement to that unit is not READ or WRITE, the le will be opened with direct unformatted attributes.
6 Compiling and Running HP FORTRAN 77/iX Programs Before a FORTRAN 77 program can be executed, the following must occur: 1. The FORTRAN 77 compiler translates the source code into an object le. 2. The HP Link Editor/iX (LINKEDIT.PUB.SYS) links one or more object les into a program le. 3. The MPE/iX operating system loads and executes the program le. You can advance through each of these steps independently, controlling each process along the way.
The FTNXL Command The MPE/iX command FTNiX invokes the FORTRAN 77 compiler and causes the compiler to process the speci ed source program and generate object code to an object le. Syntax 2 32 2 text le , object le FTNXL ; INFO= " text " , Item text le object le list le text 32 2 , list le Description/Default The name of the input le that the FORTRAN 77 compiler will read; the default is $STDIN.
By saving a default $OLDPASS object le with the SAVE command. By building a new le of NMOBJ or NMRL type with the BUILD command. The lecode parameter must be NMOBJ or NMRL, as in the following commands: :BUILD MYOBJ; DEV=DISC; CODE=NMOBJ :BUILD MYRL; DEV=DISC; CODE=NMRL If the object le is of type NMRL, any existing module with an entry point duplicating one in the current compilation unit will be replaced. See the RLFILE and RLINIT compiler directives in Chapter 7 for additional information.
The FTNXLLK Command The MPE/iX command FTNXLLK compiles a FORTRAN 77 program into an object le and then links this object le into a speci ed program le. Syntax 2 32 2 text le , prog le FTNXLLK ; INFO= " text " , Item text le prog le list le text 32 2 , list le Description/Default The name of the input le that the FORTRAN 77 compiler will read; the default is $STDIN. The name of the le that will contain the program after the compile and link is complete. The default is $OLDPASS.
If the object le is of type NMRL, any existing module with an entry point duplicating one in the current compilation unit will be replaced. See the RLFILE and RLINIT compiler directives in Chapter 7 for additional information. If you specify an existing program le, the system reuses this le. An error occurs if this le is too small or if the lecode parameter is not NMPRG. If list le is omitted, the system assigns the le $STDLIST as the default le.
The FTNXLGO Command The MPE/iX command FTNXLGO compiles, prepares, and executes a FORTRAN 77 program. After successful completion of FTNXLGO, the program le is the temporary le $OLDPASS, which you can save using the MPE/iX SAVE command. Syntax 2 FTNXLGO text le Item text le list le text 32 2 , list le 33 ; INFO= " text " , Description/Default The name of the input le that the FORTRAN 77 compiler will read; the default is $STDIN.
Running the Compiler The FORTRAN 77 compiler is a program le named FTNCOMP in the PUB group of the SYS account. To execute FTNCOMP, use the MPE/iX command RUN or simply enter the le name. The default source, object le, and listing les for the compiler are $STDIN, $NEWPASS, and $STDLIST, respectively. To override these default values, you must: 1. Equate the nondefault le with its formal designator using an MPE/iX FILE command. 2. Select an appropriate value for the PARM parameter of the RUN command.
The low order three bits of the PARM eld represent these three les: Bit 29 Bit 30 Bit 31 object listing source If the PARM parameter sets a bit for the text le and no FTNTEXT le equation exists, an attempt is made to use a permanent le named FTNTEXT. If the permanent le FTNTEXT does not exist, an error is generated.
Passing Run Command Parameters A maximum of two input parameters from a program's RUN command can be passed to a program. One parameter must be a CHARACTER*(*) data type and the other an INTEGER*2 or INTEGER*4 type.
The following is an example of the compiler listing format with symbol table generation speci ed. On the left side of the compiler listing, there are three columns of numbers: Column one lists the statement numbers Column two lists the line numbers Column three lists the nesting level numbers Listing Format PAGE 1 HEWLETT-PACKARD HP31501A.00.01 HP FORTRAN 77 (C) HEWLETT-PACKARD CO.
Name ---- Class ----- Type ---- Offset ------ Location -------- COUNT fibonacci FIBS I J K 10 20 30 100 Variable Program Variable Variable Variable Variable Stmt Label Stmt Label Stmt Label Stmt Label Integer*4 SP -72 Local Integer*4 Integer*4 Integer*4 Integer*4 Format Format Format Executable SP SP SP SP Local Local Local Local 20 21 22 3 NUMBER OF ERRORS = 0 PROCESSOR TIME 0: 0: 4 NUMBER OF LINES = 26 -68 -64 -60 -56 NUMBER OF WARNINGS = 0 ELAPSED TIME 0: 0:45 Compiling and Running HP FOR
7 Compiler Directives Compiler directives are commands within the source program that indicate to the compiler exactly how it (or a program it is compiling) is to function. A compiler directive must begin with a $ in column 1. A compiler directive can be continued by using a backslash (\) to terminate the line you want to continue. Each continuation line must begin with a $. A compiler directive cannot occur within a continued FORTRAN statement.
The directive name or the words ON or OFF can be written in any combination of uppercase and lowercase letters. If any directive other than those listed in this manual is used, it produces the warning message Warning: Compiler option identifier expected (724) In this manual, \program head" is any of the following statements: PROGRAM, SUBROUTINE, FUNCTION, or BLOCK DATA.
Effects of the Directives Table 7-1 lists the default condition if a compiler directive is omitted. The default condition remains in e ect until speci cally changed. Table 7-1.
Table 7-1. Default State of the Compiler Directives (continued) Compiler Directive Default State ONETRIP OPTIMIZE OFF OFF PAGE PAGEWIDTH NONE 80 RANGE RLFILE RLINIT OFF NONE NONE SAVE LOCALS SET SHORT STANDARD LEVEL SUBTITLE SYMDEBUG SYSINTR SYSTEM INTRINSIC OFF NONE (LONG) HP NONE OFF SYSINTR.PUB.
SYSTEM INTRINSIC, if placed before the PROGRAM statement, has a global e ect (that is, it declares system intrinsics throughout the program). If placed before the rst nondirective statement of a program unit, it takes e ect thereafter. This directive works exactly like the SYSTEM INTRINSIC statement, except with a global e ect. VERSION must be issued separately for each program unit; that is, it only has a local e ect.
ALIAS Directive The ALIAS directive speci es that a subroutine, function, entry, or common block name has an external name di erent from its internal name and, optionally, that a subroutine or function has a nonstandard calling sequence or parameter passing mechanism. Specifying the name of the language automatically generates the appropriate type of parameter for that language.
Toggling/ Duration A global ALIAS directive applies to all program units subsequent to its appearance. A local ALIAS directive applies only to the particular program unit and is not de ned for later program units. Attempts to rede ne ALIAS names generate a warning message.
Additional Information Note The compiler always changes external name to lower case, no matter how it is entered. If you want to pass this parameter in mixed case, use the LITERAL ALIAS directive; if you want to pass it in upper case, use the UPPERCASE directive. The language option enables the compiler to correctly pass parameters to other languages. If you make no speci cation, the compiler assumes you are calling an HP FORTRAN 77 subprogram.
Examples $ALIAS $ALIAS $ALIAS $ALIAS fun = '.
The ALIAS directive can also be used as another method of accessing some MPE/iX and library routines. However, because it is not a reliable method for accessing these, it is recommended that the interface routines be used instead whenever possible.
ALIGNMENT Directive The ALIGNMENT directive aligns COMPLEX*8 data on 4 or 8 byte boundaries as speci ed by the user. Syntax 4 $ALIGNMENT COMPLEX_8 8 4 8 Default Location Toggling/ Duration Aligns all COMPLEX*8 data on 32 bit boundaries. Aligns all COMPLEX*8 data on 64 bit boundaries. 64 bit boundaries. This directive may appear before any program or subprogram unit, but may not appear among executable statements within a program or subprogram unit.
SUBROUTINE test8 COMMON /block/ intarray INTEGER*4 intarray(4) IF (intarray(2) .EQ. 0) THEN PRINT*, "The data was 8 byte aligned this time." ELSE PRINT*, "The data was 4 byte aligned this time." ENDIF END $ALIGNMENT COMPLEX_8 4 SUBROUTINE modify4 COMMON /block/ i4, c8 INTEGER*4 i4 COMPLEX*8 c8 i4 = '7FFFFFFF'x c8 = '7FFFFFFF7FFFFFFF'x END SUBROUTINE test4 COMMON /block/ intarray INTEGER*4 intarray(4) IF (intarray(2) .EQ. 0 THEN PRINT*, "The data was 8 byte aligned this time." ELSE IF (intarray(4) .EQ.
ANSI Directive The ANSI directive turns the generation of listing information on or o in compliance with the ANSI 77 standard. ANSI tells the compiler to include warning messages in the list le when features of FORTRAN (other than compiler directives) that are not a part of the ANSI 77 standard are used. Syntax ON $ANSI OFF Default Location Toggling/ Duration O ; warnings are not included in the list le.
ASSEMBLY Directive The ASSEMBLY directive turns on or o the generation of an assembly listing. It is equivalent to the LIST CODE directive. The listing is written to a separate, temporary le named FTNASSM . Syntax ON $ASSEMBLY OFF Default Location Toggling/ Duration 7-14 Compiler Directives O ; no assembly listing is generated. The ASSEMBLY directive must appear before any nondirective statements in the program unit.
This directive speci es the level of checking the HP Link Editor/iX performs when a program calls a subroutine or function. CHECK ACTUAL PARM Directive Syntax $CHECK_ACTUAL_PARM 8 9 0> > > < > = 1 > 2> > : > ; 3 The level 0, 1, 2, or 3 determines the amount of information placed in the object le. The HP Link Editor/iX uses this information to indicate the level of checking on the parameters of the subroutine or function; the levels are listed in Table 7-2. Table 7-2.
This directive speci es the level of checking the HP Link Editor/iX performs when a subroutine or function is called. CHECK FORMAL PARM Directive Syntax $CHECK_FORMAL_PARM 8 9 0> > > < > = 1 > 2> > : > ; 3 The level 0, 1, 2, or 3 determines the amount of information placed in the object le. The HP Link Editor/iX uses this information to check the formal parameters of the declared procedure or function against the actual parameters in the calling program, subroutine, or function.
CHECK OVERFLOW Directive The CHECK OVERFLOW directive generates code that traps when an over ow occurs in integer arithmetic. You can use CHECK OVERFLOW with the ON statement to make your program branch to a trap subroutine. If this directive is not used, the ON statement will have no e ect on integer over ow errors.
CODE Directive The CODE directive turns on or o the generation of object code. Syntax ON $CODE OFF ON OFF Default Location Toggling/ Duration 7-18 Compiler Directives The compiler generates object code. The compiler checks syntax only. On; object code is generated. The CODE directive must appear before any nondirective statements in the program unit. Cannot be toggled after the appearance of nondirective statements in a program unit.
CODE OFFSETS Directive The CODE OFFSETS directive turns on or o the generation of the machine code o sets of each FORTRAN statement. Syntax $CODE_OFFSETS Default Location Toggling/ Duration ON OFF O ; no machine code o sets are generated for individual FORTRAN statements. The CODE OFFSETS directive must appear before any nondirective statements in the program unit, including the program head. Cannot be toggled after the appearance of nondirective statements in a program unit.
CONTINUATIONS Directive The CONTINUATIONS directive de nes the maximum number of continuation lines allowed in a source program statement. Syntax $CONTINUATIONS n n Default Location Toggling/ Duration 7-20 Compiler Directives is an integer from 0 to 99. 19 is the maximum number of continuation lines allowed. The CONTINUATIONS directive can appear anywhere in the source le. It must be the only directive on the line. The CONTINUATIONS directive applies to all source le lines subsequent to its appearance.
COPYRIGHT Directive The COPYRIGHT directive places a nonexecutable literal string in the binary object le. The string may be read by tools that display the object code generated. Syntax $COPYRIGHT copyright name copyright date Default Location 'copyright name' "copyright name" DATE 'copyright date' "copyright date" is a string that speci es a name that becomes part of the notice. Characters beyond 72 are truncated.
CROSSREF Directive The CROSSREF directive produces a cross reference listing of a program unit. It is equivalent to the XREF directive. Syntax ON $CROSSREF OFF Default Location Toggling/ Duration O . No cross reference listing is generated. Must appear before any nondirective statements in the program unit. It must precede an executable program unit (for example PROGRAM, FUNCTION, or SUBROUTINE.) Cannot be toggled after the appearance of nondirective statements in a program unit.
31 RETURN Compiler Directives 7-23
32 33 34 35 36 70 icp=5 RETURN 80 icp=100 RETURN END The following is the cross reference listing for the above program. The default line width is 80 columns. It can be changed using the PAGEWIDTH directive. SYMBOL -----CHARS/ EROR I IBKSLSH IBLNK ICOMMA ICP IDOLLAR IEQUAL ILETA ILETZ ILPAREN IMINUS IPERIOD IPLUS IRPAREN ISEMI LEGAL OP TYPE ---(COMMN) (PROC ) (VAR ) (VAR ) (VAR ) (VAR ) (PROC ) (VAR ) (VAR ) (VAR ) (VAR ) (VAR ) (VAR ) (VAR ) (VAR ) (VAR ) (VAR ) (VAR ) (ARGMT) FILE ---crossref.
SYMBOL TYPE FILE LINE The symbol name. The class of the symbol: ARGMT - argument passed to a procedure or function. COMMN - name of a common block. CONST - named constant in a PARAMETER statement. NMLST - NAMELIST variable. PROC - internal or external procedure or function name. VAR - variables. The le where the symbol is found. One or more rows of line numbers that indicate where the symbol is found. Each line has a su x that indicates the status of the symbol at time of access.
DEBUG Directive The DEBUG directive enables the processing of debug lines (those with a D or d in column 1) as statement lines instead of comment lines. Syntax $DEBUG Default Location Toggling/ Duration ON OFF O ; lines containing a D in column 1 are treated as comment lines by the compiler. The DEBUG directive can appear anywhere in a program unit. May be toggled. DEBUG ON remains in e ect until DEBUG OFF or the end of the program is encountered. Examples . . . D $DEBUG D $DEBUG D . . .
ELSE Directive The ELSE directive is used with the IF directive. The ELSE directive semantically parallels the FORTRAN ELSE statement. Syntax $ELSE Default Location None. The ELSE directive must be the only directive that appears on the line. The source following the $ELSE line is compiled only if the expression, which is part of an IF directive, has a value of false .
ENDIF Directive The ENDIF directive terminates the IF directive. Each IF directive requires an ENDIF, and vice-versa. Syntax $ENDIF Default Location 7-28 Compiler Directives None. The ENDIF directive must be the only directive that appears on the line. It may appear after the last FORTRAN END statement.
EXTERNAL ALIAS Directive The EXTERNAL ALIAS directive allows the user to specify a new external name for all occurrences of a given procedure or function name. Syntax $EXTERNAL_ALIAS name = 'new external name' "new external name" is a name appearing in the source code. is the name to which all references to name are to be changed. The new external name is a string which can include special characters. It must be delimited by apostrophes (') or quotation marks (").
FTN3000 66 Directive The FTN3000 66 directive allows you to specify FORTRAN 66/V features for compatibility with FORTRAN 77. Syntax 2 3 LOGICALS ON 5 $FTN3000_66 4 IO OFF CHARS Default Location Toggling/ Duration O. The FTN3000 66 directive can appear anywhere in a program unit.
FTN3000 66 IO The FTN3000 66 IO directive creates compatibility with FORTRAN 66/V les. This compatibility is achieved by reading and writing CHARACTER items in unformatted les in two-byte blocks and by performing multiple physical I/O operations for I/O lists that request them. When reading and writing CHARACTER items in unformatted les in two-byte blocks, each odd-length item is padded with a trailing blank.
The following example shows the I/O library performing unformatted sequential READs and WRITEs of length longer than the le's record length to (and from) as many records as necessary.
Example $FTN3000_66 IO PROGRAM sofx1c INTEGER*4 iarr(256) INTEGER*4 i4(18), i5, i6, i7 OPEN (12,file='rsofx1c', FORM='UNFORMATTED', ACCESS='DIRECT', > RECL=74) ! create file with 18.
HP1000 Directive The HP1000 directive speci es options for compatibility with FORTRAN 7X, which is the version of FORTRAN 77 on the HP 1000 computer. Syntax 3 2 ARRAYS 6 ALIGNMENT 7 ON 7 $HP1000 6 4 STRING_MOVE 5 OFF DO_LOOP Default Location Toggling/ Duration ARRAYS Option O. Specify OFF or do not use the directive if your program does not rely on speci c data layout or the ripple e ect of the STRING MOVE option and if it has no string array initializations in DATA statements.
In HP FORTRAN 77/iX, when you initialize an integer array with character strings, you must specify a separate string for each array element. For example: INTEGER iarray(5) DATA iarray/'abcd','efgh','ijkl','mnop','qrst'/ With the ARRAYS option, you can initialize more than one array element with a single string.
ALIGNMENT Option The ALIGNMENT option of the HP1000 directive aligns data on 16-bit boundaries, rather than on the HP FORTRAN 77/iX boundary formats shown in the following table: Alignment 8-bit 16-bit 32-bit 64-bit HP1000 Alignment Format HP FORTRAN 77/HP-UX Alignment Format Character Character LOGICAL*2, LOGICAL*4, INTEGER*2, LOGICAL*2 INTEGER*2, INTEGER*4, REAL*4, REAL*8, REAL*16, COMPLEX*8, COMPLEX*16 LOGICAL*4, INTEGER*4, REAL*4, COMPLEX*8 REAL*8, REAL*16, COMPLEX*16 Use this option when you need
STRING MOVE Option The STRING MOVE option causes assignments of character variables to be done byte-by-byte, which creates a ripple e ect when the source and target are overlapped. For example, CHARACTER*12 a a(1:1) = '*' a(2:12) = a(1:11) results in a having the value: '**11111111 11' if STRING MOVE is o .
HP3000 16 Directive The HP3000 16 directive: allows MPE/iX programs to correctly access MPE V data les that contain oating point data aligns noncharacter data on 16-bit boundaries and character data on 8-bit boundaries, as on MPE V performs character moves the same as on MPE V when there is an overlapping character substring that should ripple across Syntax 2 3 ON 6 7 6 OFF 7 6 7 $HP3000_16 6 ALIGNMENT 7 6 7 4 REALS 5 STRING_MOVE Item ON OFF ALIGNMENT REALS STRING_MOVE 7-38 Compiler Directives Des
MPE V and MPE/iX have di erent data alignments, as summarized in Table 7-3. Table 7-3. Data Alignment on MPE V and MPE/iX Alignment 8-bit 16-bit 32-bit 64-bit MPE V MPE/iX CHARACTER CHARACTER COMPLEX*8, COMPLEX*16 INTEGER*2 INTEGER*2, INTEGER*4 LOGICAL*2 LOGICAL*2, LOGICAL*4 REAL*4, REAL*8, REAL*16 COMPLEX*8 INTEGER*4 LOGICAL*4 REAL*4 COMPLEX*16 REAL*8, REAL*16 Default Location Toggling/ Duration Impact on Performance O .
The ON option turns on the ALIGNMENT, REALS, and STRING_MOVE options. The ALIGNMENT option aligns data on 16-bit boundaries, rather than on the MPE/iX boundaries shown in Table 7-3. Use this option only if you require the preceding condition and if your program does not access les containing MPE V oating point numbers or rippling overlapping character substrings is not necessary.
IF Directive The IF directive conditionally compiles blocks of source code. Syntax $IF (condition list) condition list Default Location Toggling/ Duration is a logical expression for conditional compilation. None. The IF directive can appear anywhere in the source code. It must be the only directive that appears on the line. The IF directive remains in e ect until terminated by an ENDIF directive. Additional Information The condition list is interpreted as having identi ers for operands and .NOT., .
Examples $SET (DEBUG=.TRUE.,TOGGLE=.FALSE.) $SET (SYSTEM1=.TRUE.) . . . $IF (DEBUG .AND. TOGGLE) $IF (SYSTEM1) $IF (.NOT. (DEBUG .AND. TOGGLE)) $IF (.TRUE.) . . . $ELSE . . . $ENDIF $ENDIF $ENDIF $ENDIF $IF (SYSTEM1 .OR. TOGGLE) . . . $ENDIF . . .
INCLUDE Directive The INCLUDE directive includes the contents of a le at the current position in the source. Syntax $INCLUDE lename Default Location ' lename' " lename" names a le whose contents are to be included at the current position in the source. None. The INCLUDE directive can appear anywhere within a program unit. The INCLUDE directive can also appear as a statement starting in column seven, with no initial ''$''.
INIT Directive The INIT directive turns on or o the generation of the code that initializes all variables for the program unit it immediately precedes. Syntax ON $INIT OFF Default Location Toggling/ Duration O ; no code to initialize variables for the next program unit is generated. The INIT directive must appear before any nondirective statements in the program unit. The INIT directive applies only to the program unit that immediately follows it.
LINES Directive The LINES directive sets the number of lines per page in the listing le to the given integer. Syntax $LINES number number Default Location Toggling/ Duration is an integer greater than or equal to 5, and less than 32768. 56 lines per page. The LINES directive can appear anywhere within the program unit. Applies until the next LINES directive or until the end of the program.
LIST Directive The LIST directive turns on or o inclusion of the source program in the listing le, starting with the line after the one containing the option. Syntax ON $LIST OFF ON OFF Default Location Toggling/ Duration 7-46 Compiler Directives The source program is included in the listing program. Only diagnostics go into the list le. Other list directives such as CODE OFFSETS and TABLES have no e ect until LIST is turned ON again. On; the source program is included in the listing le.
LIST CODE Directive The LIST CODE directive turns on or o the generation of an assembly listing. It is equivalent to the ASSEMBLY directive. Syntax ON $LIST_CODE OFF Default Location Toggling/ Duration O ; no assembly listing is generated. The LIST CODE directive must appear before any nondirective statements in the program unit. Once it has been turned on for a source le, it cannot be turned o . Additional Information The listing generated is written to a temporary le named FTNASSM .
LITERAL ALIAS Directive The LITERAL ALIAS directive determines whether external names appearing in the ALIAS directive and the EXTERNAL ALIAS directive are to have their case shifted or left as is. Syntax $LITERAL_ALIAS ON OFF Default Location Toggling/ Duration 7-48 Compiler Directives ON OFF Any external names in an ALIAS directive or an EXTERNAL ALIAS directive are processed just as they appear; that is, they are neither upshifted or downshifted. This permits mixed-case external names.
LOCALITY Directive The LOCALITY directive groups the generated code from a program unit together in the same general memory area as other program units having the same LOCALITY name. Syntax $LOCALITY Default Location Toggling/ Duration Impact on Performance 'name' "name" None; procedures that call each other are not necessarily grouped in the same general memory area. The LOCALITY directive must appear before any nondirective statements in the program unit.
LONG Directive The LONG directive sets the default size for integer and logical data types and constants to four bytes. The INTEGER and LOGICAL type names are set equivalent to INTEGER*4 and LOGICAL*4, respectively. Syntax 2 $LONG INTEGERS INTEGERS Default Location Toggling/ Duration 7-50 Compiler Directives 3 Optional; this word has no e ect. LONG (4 bytes) if neither the LONG nor the SHORT directive is given.
LOWERCASE Directive The LOWERCASE directive turns on or o shifting to lower case of all FORTRAN external names. This directive does not a ect the external name of the ALIAS and EXTERNAL ALIAS directives or intrinsic names if \$LITERAL ALIAS ON" has been speci ed. See \ALIAS Directive" and \LITERAL\_ALIAS Directive". Specifying $UPPERCASE ON (or $UPPERCASE) is equivalent to specifying $LOWERCASE OFF. Specifying $UPPERCASE OFF is equivalent to specifying $LOWERCASE ON (or $LOWERCASE).
MIXED FORMATS Directive The MIXED FORMATS directive allows you to cause a numeric format descriptor of a type di erent from the numeric list item to override the data type of the list item. Syntax $MIXED_FORMATS Default Location Toggling/ Duration ON OFF O. The MIXED FORMATS directive can appear anywhere in your program. Remains in e ect until another occurrence of the MIXED FORMATS directive changes it. Additional Information Note The MIXED FORMATS directive is not recommended for general use.
END Compiler Directives 7-53
NLS Directive The NLS (Native Language Support) directive supports special processing to handle foreign language text and data. Syntax LITERALS $NLS COMPARE ON OFF LITERALS COMPARE Default Location Toggling/ Duration Impact on Performance ON OFF turns on both LITERALS and COMPARE. turns o all NLS processing. By default, the Native-Computer character set and collating sequence is used.
In the example above, 221 is the JCW value for Japanese and zero is the JCW value of Native-Computer (the default value). Refer to the Native Language Programmer's Guide for a complete list of JCW values. Examples Following is a FORTRAN source le called test: $NLS ON PROGRAM testnls CHARACTER*10 st1,st2 st1 = 'coin' st2 = 'change' IF (LLT(st1,st2)) PRINT *,'This is the Spanish language.' IF (LGT(st1,st2)) PRINT *,'This is the English language.
NLS SOURCE Directive 7-56 Compiler Directives The NLS SOURCE directive was replaced by NLS LITERALS. We recommend that you replace all instances of NLS SOURCE with NLS LITERALS.
NOSTANDARD Directive The NOSTANDARD directive speci es options for compatibility with industry standard non-HP FORTRAN 77 programs. Syntax 2 3 CHARS 6 LOGICALS 7 6 7 6 7 6 IO 7 ON $NOSTANDARD 6 7 6 SYSTEM 7 OFF 6 7 4 INTRINSICS 5 OPEN Default Location Toggling/ Duration CHARS Option LOGICALS Option Note O. If NOSTANDARD is speci ed without options, all options are ON.
IO Option SYSTEM Option When using character format descriptors A[w ] or R[w ] with integer and real data types, the IO option causes data to be output in reverse order, starting at the right and progressing left. For more information, see \Character Format Descriptors (A, R)" in Chapter 4. The NOSTANDARD IO option is allowed anywhere in the program unit. Several intrinsic functions are available through the NOSTANDARD directive. They include: DATE Returns a string in the form dd-mm-yy, such as 15-09-88.
INTRINSICS Option OPEN Option This directive allows the 9000 Series 800 to return an INTEGER*2 when $SHORT is enabled, but an INTEGER*4 when $SHORT is not enabled (like on the 9000 Series 300 and other vendors' FORTRAN compilers). INT IFIX IDINT IQINT IDNINT IQNINT MAX1 MIN1 ZEXT The OPEN option allows multiple OPENs of the same le with di erent unit numbers. By default, multiple OPENs of the same le cause a run time error.
ONETRIP Directive The ONETRIP directive turns on or o the requirement that the body of each DO loop (other than DO WHILE loops) is executed at least once, in compliance with the previous ANSI 66 standard. Syntax $ONETRIP Default Location Toggling/ Duration 7-60 Compiler Directives ON OFF O ; individual DO loop bodies are not required to execute at least once. The ONETRIP directive must appear before any nondirective statements in the program unit.
OPTIMIZE Directive The OPTIMIZE directive sets up optimizer options that can improve performance. Syntax 2 3 LEVEL1 7 6 LEVEL2 7 6 7 6 7 6 LEVEL2_MIN 7 6 7 6 LEVEL2_MAX 7 6 7 6 ASSUME_NO_EXTERNAL_PARMS 7 6 7 6 $OPTIMIZE 6 ASSUME_NO_FLOATING_INVARIANT 7 7 6 ASSUME_NO_PARAMETER_OVERLAPS 7 6 7 6 7 6 ASSUME_NO_SHARED_COMMON_PARMS 7 6 7 6 ASSUME_NO_SIDE_EFFECTS 7 6 5 4 ASSUME_PARM_TYPES_MATCHED 2 3 LOOP_UNROLL COPIES=n SIZE=n STATISTICS ON OFF ON OFF LEVEL1 LEVEL2 Alone, speci es level 2 optimization.
ASSUME_NO_EXTERNAL_PARMS ASSUME_NO_FLOATING_INVARIANT ASSUME_NO_PARAMETER_OVERLAPS ASSUME_NO_SHARED_COMMON_PARMS ASSUME_NO_SIDE_EFFECTS ASSUME_PARM_TYPES_MATCHED LOOP_UNROLL Assumes that none of the parameters passed to the current procedure are from an external space, that is, di erent from the user's own data space. Parameters can come from another space if they come from operating system space or if they are in a space shared by other users.
Level 1 Level 2 minimum Level 2 normal Level 2 maximum Optimizes only within each basic block. This is obtained by specifying $OPTIMIZE LEVEL1 ON. Optimizes within each procedure with no assumptions on interactions of procedures. That is, the compiler assumes nothing, making this the most conservative level 2 optimization. This level is obtained by specifying $OPTIMIZE LEVEL2_MIN ON within each procedure.
A basic block is a set of instructions to be executed in sequence, with one entrance, the rst instruction, and one exit, the last; the block contains no branches. Parameters can come from another space if they come from the operating system or if they are in a space shared by other users.
Flagging Uninitialized Variables When the compiler is performing level 2 optimization, it will detect any uninitialized non-static simple local variables. However, it will not detect uninitialized common variables, static variables, or variables of character and complex type. For example: $OPTIMIZE FUNCTION func(type) COMMON /a/comvar SAVE statvar REAL foo,type type = 10.
Example C Start with minimum level 2 optimization. $OPTIMIZE LEVEL2_MIN PROGRAM FEQ7 INTEGER num(10), ans, calculate CHARACTER*2 option(10) C C For the next two calls, the parameter type declarations are the same in C the main program and the subroutine or function. Therefore, we can C further optimize the program by setting the following optimizer option.
C C C C C C For the next subroutine, we know that the actual parameters passed to this subroutine are not overlapped with each other, not from external space, nor from a shared common block. We can thus leave the ASSUME_NO_PARAMETER_OVERLAPS, ASSUME_NO_EXTERNAL_PARMS, and ASSUME_NO_SHARED_COMMON_PARMS settings ON. FUNCTION calculate(value,operation) INTEGER value(10),calculate,ans CHARACTER*2 operation(10) ans = 0 DO 10 i = 1,10 IF (operation(i).EQ.' ') GOTO 30 10 30 IF (operation(i).EQ.
Loop Unrolling 2 3 ON 7 6 OFF 7 6 7 $OPTIMIZE LOOP_UNROLL 6 6 COPIES = n 7 4 ,SIZE = n 5 STATISTICS ON Turns on loop unrolling. ON is the default at level 2. OFF Turns o loop unrolling. COPIES = n Tells the compiler to unroll the loop n times. The default is four times. SIZE = n Tells the compiler to unroll the loops that have less than n operations. The default is 60 operations. STATISTICS Tells the compiler to give statistics about the unrolled loops.
Note The number of operations reported by STATISTICS is approximate. Each assignment, arithmetic operation, and logical operation counts as an operation. Each subscript of a subscripted variable counts as a separate operation.
To unroll the loop two times instead of four times (which is the default), use $OPTIMIZE LOOP_UNROLL COPIES=2 To unroll a DO loop that is larger than the default, use $OPTIMIZE LOOP_UNROLL COPIES=2, SIZE=500 substituting an appropriate size for the digit 500. Example C Example to illustrate the use of LOOP_UNROLL $OPTIMIZE ON PROGRAM UNROLL_EXAMPLE DIMENSION A(10), B(10,10) DIMENSION X(10,10,10), Y(10,10,10), Z(10,10,10) . . . . C The inner loop has only one statement.
* 30 40 Z(I,J,K) = Z(I,J,K) + A1*V1 + A2*V2 + A3*V3 + S*(Z(I+1,J,K)-2.0*Z(I,J,K)+Z(I-1,J,K)) CONTINUE CONTINUE C Change the options back to the default values. $OPTIMIZE LOOP_UNROLL COPIES=4, SIZE=60 . . . .
PAGE Directive The PAGE directive sends a form feed to the list le or device, which causes a skip to a new page before continuing with the program listing. Syntax $PAGE Default Location Toggling/ Duration Page Eject with Control-L 7-72 Compiler Directives None. The PAGE directive can appear anywhere within the program unit. Cannot be toggled.
PAGEWIDTH Directive The PAGEWIDTH directive allows you to specify the length of output lines in the listing le. Syntax $PAGEWIDTH n n Default Location Toggling/ Duration is an integer constant from 79 to 150. 80. Values outside of this range will cause a warning and the value will be ignored. Output lines longer than n are broken into multiple lines as necessary so that no line has more than n columns of data on the listing le.
POSTPEND Directive The POSTPEND Directive allows C programmers to access FORTRAN routines and data as per BSD programming standards. syntax ON $POSTPEND OFF Default Location O. This directive must appear before any nondirective statement in a program unit, including the program head.
RANGE Directive The RANGE directive turns on or o compile-time bounds checking for: subscript and substring expressions bit-manipulation intrinsic functions DO loop increment counts that are not equal to zero assigned GOTOs Range checking is not performed on the nal dimension of assumed-sized arrays.
RLFILE Directive This directive causes each program unit to be compiled into its own object module. Syntax $RLFILE Default Location Impact on Performance None; the compiler creates a relocatable object le containing one module for all procedures. The RLFILE directive must occur before any nondirective statement in the program unit, including the program head.
RLINIT Directive This directive causes the compiler to initialize the RL le to empty (thus deleting all object modules) before placing any object code into it. This occurs before compilation begins. This directive provides the same functionality available with USLINIT in FORTRAN 77/V. Syntax $RLINIT Default Location None.
SAVE LOCALS Directive The SAVE LOCALS directive automatically saves any local variables encountered. This is the same as specifying SAVE in each subprogram of each source le. This directive forces static storage for all local variables in order to provide a convenient path for importing FORTRAN 66 and 77 programs that were written to depend on static allocation of memory (that is, variables retaining their values between invocations of the respective program units).
SEGMENT Directive This directive, included for compatibility with programs in earlier versions of FORTRAN, is the same as the LOCALITY directive. The SEGMENT directive produces the warning \SEGMENT has been mapped to LOCALITY on this operating system.
SET Directive The SET directive assigns values to identi ers used in IF directives. Syntax $SET ( ag1 = ag Default Location Toggling/ Duration .TRUE. .FALSE. , ag2 = $SET (TOGGLE=.TRUE.,DEBUG=.FALSE.) $SET (SYSTEM1=.TRUE.) Compiler Directives 2 3 ... ) is one or more identi ers given logical constant values. The identi ers in SET and IF compiler directives are in no way related to FORTRAN variables in the source text.
SHORT Directive The SHORT directive sets the default size for integer and logical data types and constants to two bytes. The INTEGER and LOGICAL type names are set equivalent to INTEGER*2 and LOGICAL*2, respectively. Syntax 2 $SHORT INTEGERS 3 The keyword INTEGERS in the directive is optional and has no e ect. Default Long (4 bytes) if neither the LONG nor the SHORT directive is given.
STANDARD LEVEL Directive The STANDARD LEVEL directive sets the level of syntax that the compiler processes routinely. Syntax $STANDARD_LEVEL 8 < ANSI : 9 = HP ; SYSTEM If the compiler encounters a FORTRAN language feature not legal at the speci ed level, it issues a warning message on the listing and then compiles the feature normally. ANSI refers to the ANSI 77 FORTRAN standard (ANSI X3.9-1978). Specifying the ANSI level is semantically equivalent to specifying $ANSI ON.
SUBTITLE Directive The SUBTITLE directive lists the subtitle string on the second line of each page of the program listing following the appearance of the directive in the source code. Syntax $SUBTITLE Default Location Toggling/ Duration 'subtitle string' "subtitle string" None; no subtitle string is listed. If the subtitle string is longer than 72 characters, it is truncated to 72. The SUBTITLE directive can appear anywhere within the program unit.
SYMDEBUG Directive The SYMDEBUG directive causes the compiler to include in the object le the information needed by a symbolic debugger. Syntax XDB $SYMDEBUG TOOLSET ON OFF (or $SYMDEBUG or $SYMDEBUG TOOLSET) the compiler places debug information into the object le for HP Toolset/iX to use. XDB (or $SYMDEBUG XDB) the compiler places xdb-speci c information into the object le for xdb to use. O ; no symbolic debugger information is included in the object le.
SYMTABLE Directive The SYMTABLE directive, included for compatibility with programs in earlier versions of FORTRAN, is the same as the TABLES directive. The symbol table information is printed even if an error occurs at compile time. Syntax $SYMTABLE Default Location Toggling/ Duration ON OFF O. The SYMTABLE directive must precede any nondirective statements in a program unit. Cannot be toggled after the appearance of nondirective statements in a program unit.
Name ---- Class ----- routine1 Subroutine NUMBER OF ERRORS = 7-86 Compiler Directives Type ---- 0 Offset ------ NUMBER OF WARNINGS = Location -------- 0
SYSINTR Directive The SYSINTR directive permits you to specify a Pascal intrinsic le to be searched for a subroutine or function declared with the SYSTEM INTRINSIC directive. Syntax $SYSINTR 'sysintr "sysintr sysintr lename Default Location Toggling/ Duration lename' lename" is the name of a Pascal intrinsic le. SYSINTR.PUB.SYS will be the Pascal intrinsic le searched. The SYSINTR directive can appear anywhere in a program.
SYSTEM INTRINSIC Directive The SYSTEM INTRINSIC directive functions exactly the same as the SYSTEM INTRINSIC statement. Syntax 2 $SYSTEM INTRINSIC intrinsic name ,intrinsic name intrinsic name Default Location Toggling/ Duration 7-88 Compiler Directives 32 ,... 3 is the name of a system intrinsic. None. The SYSTEM INTRINSIC directive must appear before the rst nondirective statement of the program unit in which it is to start taking e ect.
The TABLES directive turns on or o the symbol table information in the listing le. The symbol table information is printed even if an error occurs at compile time. TABLES Directive Syntax $TABLES Default Location Toggling/ Duration ON OFF O ; no symbol table information is included in the listing le. The TABLES directive must appear before any nondirective statements in the program unit. Cannot be toggled after the appearance of nondirective statements in a program unit.
Name ---- Class ----- routine1 Subroutine NUMBER OF ERRORS = 7-90 Compiler Directives Type ---- 0 Offset ------ NUMBER OF WARNINGS = Location -------- 0
TITLE Directive The TITLE directive lists the title string at the top of each page of output following the appearance of the directive in the source code. If the title string is longer than 72 characters, it is truncated to 72. Syntax $TITLE Default Location Toggling/ Duration 'title string' "title string" None; no title string is listed at the top of each page of output. The TITLE directive can appear anywhere within the program unit.
UPPERCASE Directive The UPPERCASE directive turns on or o shifting to upper case of all FORTRAN external names. This directive does not a ect the external name of the ALIAS and EXTERNAL ALIAS directives or intrinsic names if $LITERAL_ALIAS ON has been speci ed. See \ALIAS Directive" and \LITERAL\_ALIAS Directive". Specifying $LOWERCASE ON (or $LOWERCASE) is equivalent to specifying $UPPERCASE OFF. Specifying $LOWERCASE OFF is equivalent to specifying $UPPERCASE ON (or $UPPERCASE).
VERSION Directive The VERSION directive inserts a string speci ed by the user into the auxiliary record header of the executable le, for purposes of version identi cation. If the version string is longer than 72 characters, it is truncated to 72. Syntax $VERSION Default Location Toggling/ Duration 'version id' "version id" None; nothing is inserted. The VERSION directive must appear before any nondirective statement in a program unit, including the program head.
WARNINGS The WARNINGS directive turns on or o the output of warnings. Directive Syntax ON $WARNINGS OFF Default Location Toggling/ Duration 7-94 Compiler Directives On; warnings are output. The WARNINGS directive can appear anywhere within the program unit. The WARNINGS directive remains in e ect until another WARNINGS directive is encountered.
The XREF directive produces a cross reference listing of a program unit. It is equivalent to the CROSSREF directive. XREF Directive Syntax ON $XREF OFF Default Location Toggling/ Duration O ; no cross reference listing is produced. The XREF directive must appear before any nondirective statements in the program unit and it must precede an executable program unit like PROGRAM, FUNCTION, or SUBROUTINE. Cannot be toggled after the appearance of nondirective statements in the program unit.
31 32 33 34 35 36 RETURN 70 icp=5 RETURN 80 icp=100 RETURN END The following is the cross reference listing for the above program. The default line width is 80 columns. It can be changed with the PAGEWIDTH directive. SYMBOL -----CHARS/ EROR I IBKSLSH IBLNK ICOMMA ICP IDOLLAR IEQUAL ILETA ILETZ ILPAREN IMINUS IPERIOD IPLUS IRPAREN ISEMI LEGAL OP TYPE ---(COMMN) (PROC ) (VAR ) (VAR ) (VAR ) (VAR ) (PROC ) (VAR ) (VAR ) (VAR ) (VAR ) (VAR ) (VAR ) (VAR ) (VAR ) (VAR ) (VAR ) (VAR ) (ARGMT) FILE ---xref.
SYMBOL TYPE FILE LINE The symbol name. The class of the symbol: ARGMT - argument passed to a procedure or function. COMMN - name of a common block. CONST - named constant in a PARAMETER statement. NMLST - NAMELIST variable. PROC - internal or external procedure or function name. VAR - variables. The le where the symbol is found. One or more rows of line numbers that indicate where the symbol is found. Each line has a su x that indicates the status of the symbol at time of access.
8 Interfacing with Non-FORTRAN Subprograms Any non-FORTRAN program unit can be used as a part of an executable FORTRAN program if the program unit has a calling sequence and method of execution compatible with FORTRAN 77. In addition, a FORTRAN subprogram can be used by programs written in other languages if the FORTRAN subprogram is compatible with the calling program's requirements. This chapter discusses issues to consider when interfacing FORTRAN programs to other languages.
Use of COMMON and Labels Files 8-2 Non-FORTRAN program units cannot access a FORTRAN COMMON area and FORTRAN program units cannot access the global variables of non-FORTRAN programs. All data must be passed through the parameter lists. If a FORTRAN program calls a non-FORTRAN program unit, the FORTRAN program can contain COMMON areas, but the non-FORTRAN unit cannot use global variables.
This section describes how to interface with C. FORTRAN and C Logicals Arrays Files C has no logical type; it uses integers instead. A FORTRAN LOGICAL*2 is represented by a C short integer, and a LOGICAL*4 by a C long integer. FORTRAN and C do not share a common de nition of true and false. In C, zero is false, and any nonzero value is true. FORTRAN stores arrays in column-major order, while C stores them in row-major order.
Parameter Passing Methods Complex Numbers FORTRAN passes noncharacter parameters by reference, while FORTRAN character strings are \passed by descriptor." The descriptors are system-de ned and are described under \Character" later in this section.
Character When FORTRAN passes character parameters, it passes them by descriptor. The descriptor includes two items: a pointer to the rst character in the string and an integer value for the declared length of the string. When passing FORTRAN character strings to C subprograms, you must be sure to accommodate the length descriptor. Use the default character passing method to accomodate the length descriptor when passing a character string to a C subprogram.
FORTRAN and Pascal Data Types When a FORTRAN program interfaces with a Pascal program unit, be aware of the corresponding data types shown in table 8-1. In particular, note the di erences between character strings and Boolean variables between the two languages. Table 8-1.
Also note the following when a FORTRAN program interfaces with a Pascal program unit: HP FORTRAN 77 cannot pass arrays by value, so you cannot call a Pascal routine with a value parameter of a type corresponding to an HP FORTRAN 77 array type. All data must be passed through the parameter lists because HP FORTRAN 77 cannot specify global variables and Pascal cannot specify COMMON blocks.
Frequently, condition codes are returned to a FORTRAN 77 program by system intrinsics. These condition codes are listed in table 8-2. Speci c meanings depend on individual intrinsics; refer to the MPE/iX Intrinsics Reference Manual for condition codes of speci c intrinsics. Condition Codes Table 8-2. Condition Codes Condition Code CCE CCG CCL Meaning Condition code is zero. This generally indicates that the request was granted. Condition code is greater than zero.
Built-In Functions Arguments of a FORTRAN subprogram are passed by reference, except for character variables, which are passed by descriptor. To call subprograms written in another language, you might have to pass arguments that are di erent from those used by FORTRAN.
9 Managing Run-Time Errors and Exceptions This chapter describes tools and methods for managing run-time errors and exceptions. Common run-time errors and exceptions include memory violations, oating-point exceptions, and input/output errors. The input/output error messages and recommended solutions are given in Appendix A. Trapping Run-Time Errors The MPE/iX implementation of FORTRAN 77 provides a trap handling mechanism that allows you to control how a program interruption is handled.
This is a program that traps external errors: PROGRAM TEST REAL*8 A ON EXTERNAL ERROR CALL ERRORHANDLE A = 8.
This program shows how an internal error can be trapped to the user-de ned error recovery routine ERRORHANDLE. * * * * * * * * * * * * 100 * ERRORNUM is the error that is generated in function DNUM. RESULT is the result computed before the error occurs. The computation process is not yet complete. OPERAND1 is the operand that is passed to DNUM. ERRORNUM can be changed in the trap routine ERRORHANDLE.
This program shows how a divide by zero can be trapped for libf math function FTN DTOD(a,b). * * * * * * * * If ERRORNUM = 0, the program will ABORT. A non-zero value for ERRORNUM causes the function to return the value of the result. The result in the error recovery must match the parameter that was passed. This will cause Internal error 68. PROGRAM TESTING REAL *8 A, B, C INTEGER*4 I, J, K ON INTERNAL ERROR CALL ERRORHANDLE C = -2.0 A = 0.0 B = A**C PRINT *, "DtoD B= ", B PRINT *, "Main End.
Trap Actions The action taken after an interrupt is trapped depends on the speci cation in the most recently executed ON statement for that interrupt condition. If ABORT was speci ed, a standard error message is generated and the program is aborted. If IGNORE was speci ed, processing continues with the next instruction. If the condition causing the interrupt is an integer division by zero, the result is set to zero.
Basic External Function Trap Procedure The trap procedure that is called for external function errors must have four formal arguments in the following order: 1. A single integer containing the error number that is determined by the external function in which the error occurred. 2. The result. 3. The rst operand. 4. The second operand. If the trap procedure returns normally and has set the error number ( rst argument) to zero, a standard message is printed and the program aborts.
I/O Run-Time Errors During the execution of a FORTRAN 77 program, error messages may be printed on the output unit by the input/output library supplied for FORTRAN programs. The error message and a complete listing of run-time errors returned in the IOSTAT variable or printed on the output unit are listed in Appendix A.
10 Data Format in Memory HP FORTRAN 77 has the following data types: General Name Integer Real Complex Logical Character Note Note Data Type BYTE (LOGICAL*1) INTEGER*2 INTEGER*4 REAL*4 REAL*8 REAL*16 COMPLEX*8 COMPLEX*16 LOGICAL*2 LOGICAL*4 CHARACTER In addition, the Hollerith format is available for compatibility with older programs and with some system routines. This chapter describes the format of each data type when stored in memory.
Overflow Conditions 10-2 Data Format in Memory Each data type has its own format and range. An over ow condition occurs when numbers outside the range of a particular type are assigned to, or read into, the corresponding variables at run-time. For read operations, an error message is issued and the program terminates unless the ERR or IOSTAT speci er is present. For assignments, truncation occurs. For integer variables, this truncation is performed such that the high order bits are ignored.
BYTE (LOGICAL*1) Format A BYTE or LOGICAL*1 datum is always an exact representation of a one-byte integer whose values can be positive, negative, or zero. The BYTE format occupies eight bits and has a range of: 0128 to +127 Figure 10-1. BYTE (LOGICAL*1) Format A BYTE datum can also be used as a logical value, representing true or false. If bit 0 is 1, the value is true; otherwise it is false.
INTEGER*2 Format An INTEGER*2 datum is always an exact representation of an integer, whose values can be positive, negative, or zero. An INTEGER*2 datum occupies half a 32-bit word (two bytes), in two's complement format, and has a range of: 032768 to +32767 (0215 to +21501) Figure 10-2. INTEGER*2 Format INTEGER*4 Format An INTEGER*4 datum is always an exact representation of an integer, whose values can be positive, negative, or zero.
REAL*4 Format A REAL or REAL*4 datum is a processor approximation of a real number, whose values can be positive, negative, or zero. A REAL*4 datum occupies one 32-bit word in memory, in oating-point format. It has an approximate normalized range of: 0.0 and 61.175494210038 to 63.402823210+38 In addition, it has an approximate denormalized range of: 61.401298210045 to 61.175494210038 Figure 10-4. REAL*4 Format The REAL*4 format has an 8-bit exponent and a 23-bit fraction.
REAL*8 Format A REAL*8 or DOUBLE PRECISION datum is a processor approximation to a real number, whose values can be positive, negative, or zero. A REAL*8 datum occupies two consecutive 32-bit words in memory in oating-point format. It has an approximate normalized range of: 0.0 and 62.2250738585072022100308 to 61.797693134862315210+308 In addition, it has an approximate denormalized range of: 64.9406564584124662100324 to 62.2250738585072012100308 Figure 10-5.
If the exponent is all ones and the fraction is zero, the number is regarded as a signed in nity. If the exponent is all ones and the fraction is not zero, then the interpretation is \not-a-number" (NaN). Attempts to operate on denormalized numbers, in nities, and NaNs cause a system trap.
REAL*16 Format A REAL*16 datum is a processor approximation to a real number, whose values can be positive, negative, or zero. This is an extension to the ANSI 77 standard. An REAL*16 datum occupies four consecutive 32-bit words in memory, in oating-point format. It has an approximate normalized range of: 0.0 and 63.36210314311209350626267781732175321004932 to 61.189731495357231765085759326628007210+4932 In addition, it has an approximate denormalized range of: 66.
A REAL*16 datum is 64-bit-aligned; that is, its address is divisible by eight.
Note The REAL*16 format has a 15-bit exponent and a 112-bit fraction. Signi cance to the user is approximately 34 decimal digits. The sign bit is zero for plus, one for minus. The exponent eld contains 16,383 plus the actual exponent (power of 2) of the number. Exponent elds containing all zeros and all ones are \reserved." If the exponent is zero and the fraction zero, the number is interpreted as a signed zero. If the exponent is zero and the fraction not zero, the number is called \denormalized.
COMPLEX*8 Format A COMPLEX or COMPLEX*8 datum is a processor approximation to the value of a complex number. A COMPLEX*8 datum occupies two consecutive 32-bit words in memory. The real and the imaginary parts are each stored in one word, in the format of a REAL*4 datum. The value of each part is determined as for a REAL*4 datum. Figure 10-7.
COMPLEX*16 Format A COMPLEX*16 or DOUBLE COMPLEX datum is a processor approximation to the value of a complex number. A COMPLEX*16 datum occupies four consecutive 32-bit words in memory. The real and the imaginary parts are each stored in two words, in the format of a REAL*8 datum. The value of each part is determined as for a REAL*8 datum. Figure 10-8.
LOGICAL*2 Format A LOGICAL*2 datum is a representation of true or false. The LOGICAL*2 format occupies half of one 32-bit word in memory. If the least signi cant bit (8) of the most signi cant byte is 1, the value is true; otherwise it is false. Figure 10-9.
LOGICAL*4 Format A LOGICAL*4 datum is a representation of true or false. The LOGICAL*4 format occupies one 32-bit word in memory. If the least signi cant bit (24) of the most signi cant byte is 1, the value is true; otherwise it is false. Figure 10-10. LOGICAL*4 Format Character Format Hollerith Format 10-14 Data Format in Memory A character datum is a character string taken from the HP ASCII character set.
A Diagnostic Messages Note Compile-Time Errors can be detected during several stages of the program development cycle. Errors resulting from illegal FORTRAN syntax and semantics are compile-time errors, and those from logic are run-time errors. During the execution of FORTRAN programs, errors can be generated from several sources, including library routine reference errors, input/output formatter errors, and remote le access errors.
Run-Time Errors During execution of the object program, error messages may be printed on the output unit by the input/output library supplied for FORTRAN programs. The error message is printed in the form: *** FORTRAN zzz Error nnn: mmm File: f, Unit: uuu Last format: xxx where: is \I/O" or \RANGE". is the error number. is the error message. is the name of the le upon which I/O failed. is the unit number associated with the le. is the most recent format attempted or completed.
Compile-Time Errors A compile-time error is one detected by the compiler. There are two types of compile-time errors: Those that can be attributed to a speci c source statement. Those that can be detected only after processing of an entire module. 1 COMPILE-TIME ERROR CAUSE 2 COMPILE-TIME ERROR CAUSE 3 COMPILE-TIME ERROR CAUSE 4 COMPILE-TIME ERROR CAUSE 5 COMPILE-TIME ERROR CAUSE I/O control parameter expected An unrecognized word was found where an I/O control keyword is required.
6 COMPILE-TIME ERROR CAUSE 8 11 12 13 COMPILE-TIME ERROR COMPILE-TIME ERROR Expecting expression or subexpression CAUSE An expression is missing where it is required. COMPILE-TIME ERROR Logical end of statement already encountered CAUSE More input is found in the input line after the logical end of a statement. COMPILE-TIME ERROR COMPILE-TIME ERROR COMPILE-TIME ERROR CAUSE A-4 Diagnostic Messages Integer expected An integer item is missing where it is required.
16 COMPILE-TIME ERROR CAUSE 17 COMPILE-TIME ERROR CAUSE 18 COMPILE-TIME ERROR CAUSE 19 COMPILE-TIME ERROR CAUSE 20 COMPILE-TIME ERROR CAUSE 21 COMPILE-TIME ERROR CAUSE 22 COMPILE-TIME ERROR CAUSE "," expected A \," is missing where it is required. "(" or "=" expected A \(" or \=" is missing where it is required. ")" expected The number of opening and closing parentheses is unbalanced. "(" expected The number of opening and closing parentheses is unbalanced.
23 COMPILE-TIME ERROR CAUSE 25 COMPILE-TIME ERROR CAUSE 26 COMPILE-TIME ERROR Identifier expected An identi er is missing where it is required. "TO" expected The keyword \TO" is missing. "DS" expected CAUSE 28 29 30 COMPILE-TIME ERROR Expecting I/O control list or unit specifier CAUSE There is no I/O control list or unit speci er in an I/O statement. COMPILE-TIME ERROR Expecting format specifier CAUSE The format speci er in a formatted I/O statement is missing.
32 COMPILE-TIME ERROR Label or control variable expected CAUSE 33 34 COMPILE-TIME ERROR "IF" expected CAUSE The keyword \IF" is missing. COMPILE-TIME ERROR Expecting I/O control list or format specifier CAUSE 35 COMPILE-TIME ERROR Expecting identifier, "(", or label CAUSE 36 COMPILE-TIME ERROR CAUSE 37 COMPILE-TIME ERROR Expecting ":" A \:" is missing where it is required. Label expected CAUSE 38 COMPILE-TIME ERROR CAUSE "DO" expected The keyword \DO" is missing.
39 COMPILE-TIME ERROR Bad expression CAUSE 40 COMPILE-TIME ERROR "FUNCTION" or identifier expected CAUSE 41 COMPILE-TIME ERROR Expecting identifier or "(" CAUSE 42 COMPILE-TIME ERROR Expecting length specification CAUSE 44 COMPILE-TIME ERROR Expecting a type CAUSE 46 COMPILE-TIME ERROR CAUSE 48 COMPILE-TIME ERROR CAUSE A-8 Diagnostic Messages "," or "/" expected A \," or \/" is missing where it is expected.
49 COMPILE-TIME ERROR Expecting identifier or "," CAUSE 50 COMPILE-TIME ERROR Expecting letter CAUSE 51 COMPILE-TIME ERROR CAUSE 60 COMPILE-TIME ERROR Expecting constant A constant expression is missing. "ON" condition expected CAUSE 61 COMPILE-TIME ERROR "CALL" or "ABORT" expected CAUSE 101 COMPILE-TIME ERROR CAUSE Routine or array name used illegally Some unquali ed identi ers (for example, subprogram or array names) can be used only as actual arguments.
102 COMPILE-TIME ERROR CAUSE 103 COMPILE-TIME ERROR CAUSE 104 COMPILE-TIME ERROR CAUSE 105 COMPILE-TIME ERROR CAUSE 106 COMPILE-TIME ERROR CAUSE 107 COMPILE-TIME ERROR CAUSE A-10 Diagnostic Messages Constant expression required An expression that must be constant (evaluated at compile time) using literals and named constants cannot be evaluated, either because a term is not constant or an operation (for example, a function call) cannot be performed.
108 COMPILE-TIME ERROR Logical expression required CAUSE 109 COMPILE-TIME ERROR Character expression required CAUSE 110 COMPILE-TIME ERROR CAUSE 111 COMPILE-TIME ERROR CAUSE 112 COMPILE-TIME ERROR CAUSE 113 COMPILE-TIME ERROR CAUSE Types of operands incompatible with operator and/or each other The type conversions that permit the operation to occur cannot be performed. Either the operands are not compatible with each other, or one or more are not compatible with the operator.
114 115 COMPILE-TIME ERROR CAUSE An identi er used as an array is not declared as such. COMPILE-TIME ERROR This statement not allowed in this kind of module CAUSE 116 Array not declared COMPILE-TIME ERROR 1. A RETURN statement appears in a program module. 2. An executable statement appears in a block data module.
119 COMPILE-TIME ERROR Illegal to use argument here CAUSE 120 COMPILE-TIME ERROR CAUSE 121 COMPILE-TIME ERROR Illegal use of label 1. A label is inconsistently used. (The three types of labels - for formats, executable statements, and nonexecutable statements - are mutually exclusive in usage.) 2. A label is referenced but never de ned.
125 COMPILE-TIME ERROR Illegal statement function name CAUSE 126 COMPILE-TIME ERROR Number of subscripts does not match declared number CAUSE 127 COMPILE-TIME ERROR CAUSE 128 COMPILE-TIME ERROR CAUSE 129 COMPILE-TIME ERROR Number of parameters does not match declared number The declared number of parameters to a statement function does not match the number used. Illegal or inconsistent alternate return 1.
131 COMPILE-TIME ERROR CAUSE 132 COMPILE-TIME ERROR CAUSE 133 COMPILE-TIME ERROR CAUSE Illegal or duplicate SAVE statement 1. A formal argument or variable in common is saved. 2. A variable is saved more than once. 3. A SAVE statement saving all variables is encountered with SAVE statements saving individual variables. Illegal or duplicate COMMON definition 1. An identi er not representing a variable is placed in a common block. 2. A variable is declared to be in common more than once. 3.
134 COMPILE-TIME ERROR CAUSE 135 136 COMPILE-TIME ERROR Diagnostic Messages A reference to an undeclared structure in a RECORD statement. Recursive structure declaration CAUSE A reference was made to a structure inside itself. COMPILE-TIME ERROR Illegal or duplicate IMPLICIT declaration CAUSE A-16 Structure no declared 1. In an IMPLICIT statement, an illegal pre x character (that is, not a through z or A through Z) is encountered. 2. A pre x character is declared implicit more than once. 3.
137 COMPILE-TIME ERROR CAUSE 138 COMPILE-TIME ERROR CAUSE 139 COMPILE-TIME ERROR Identifier not declared An identi er does not appear in a type statement when IMPLICIT NONE is speci ed. Illegal or inconsistent EQUIVALENCE statement 1. A formal parameter or a dynamic array is equivalenced using the EQUIVALENCE statement. 2. An identi er not representing a variable is equivalenced using the EQUIVALENCE statement. 3. A variable is illegally equivalenced to more than one position. 4.
143 COMPILE-TIME ERROR CAUSE 144 COMPILE-TIME ERROR CAUSE 145 COMPILE-TIME ERROR CAUSE 146 COMPILE-TIME ERROR Missing label on FORMAT statement A FORMAT statement is used without a label. Illegal array declaration 1. A calculated dimension size has over owed the word size of the machine. 2. A zero or negative dimension size has been declared. 3. A nonconstant array dimension is improperly speci ed. No result assigned to function There is no assignment of any value to the function result.
148 COMPILE-TIME ERROR Subscript out of range CAUSE 149 COMPILE-TIME ERROR Illegal assignment to DO index CAUSE 150 COMPILE-TIME ERROR Illegal implied DO expression CAUSE 151 COMPILE-TIME ERROR Duplicate label definition CAUSE 152 COMPILE-TIME ERROR Declaration of routine as both EXTERNAL and INTRINSIC CAUSE 153 COMPILE-TIME ERROR CAUSE Inconsistent parameter type A parameter identi er and the expression to be assigned to it are not assignment compatible.
154 COMPILE-TIME ERROR Illegal parameter in option CAUSE 155 COMPILE-TIME ERROR Illegal use of string whose length is unknown CAUSE 156 COMPILE-TIME ERROR CAUSE 157 COMPILE-TIME ERROR Illegal STOP or PAUSE value The value to be written by a STOP or PAUSE statement is not an integer or character literal.
160 COMPILE-TIME ERROR CAUSE 161 COMPILE-TIME ERROR Illegal use of intrinsic function as actual argument A generic intrinsic routine name is passed as an actual argument to a subprogram. Named constant typed following definition in PARAMETER statement CAUSE 162 COMPILE-TIME ERROR CAUSE 163 164 COMPILE-TIME ERROR Illegal use of Hollerith or octal or hexadecimal constant A disallowed operation is attempted on a Hollerith, octal, or hexadecimal constant.
165 COMPILE-TIME ERROR CAUSE 166 COMPILE-TIME ERROR CAUSE 168 COMPILE-TIME ERROR Illegal typing of identifier An attempt is made to type an identi er representing an entity that cannot be typed (for example, a subroutine name or a program name). Expression does not represent a value An expression (such as an array name, external routine name, or intrinsic function name), although valid as an actual argument, does not represent a single value and is therefore meaningless in this context.
171 COMPILE-TIME ERROR This type of parameter not allowed in a system intrinsic call CAUSE 172 COMPILE-TIME ERROR CAUSE 173 COMPILE-TIME ERROR CAUSE 174 COMPILE-TIME ERROR CAUSE 175 COMPILE-TIME ERROR CAUSE 176 COMPILE-TIME ERROR Null parameter not permitted here A null parameter is passed to a system intrinsic that is not OPTION VARIABLE.
177 COMPILE-TIME ERROR Illegal identifier in namelist group CAUSE 178 COMPILE-TIME ERROR Dummy arguments not allowed in namelist CAUSE 179 COMPILE-TIME ERROR Number of parameters not compatible with system intrinsic definition CAUSE 180 181 COMPILE-TIME ERROR This statement not part of HP standard FORTRAN 77 CAUSE This statement is not available on all implementations of HP FORTRAN 77.
183 COMPILE-TIME ERROR Illegal type in ON statement CAUSE 184 COMPILE-TIME ERROR This ON condition not allowed on this operating system CAUSE 185 COMPILE-TIME ERROR Incorrect control character specified for this operating system CAUSE 186 COMPILE-TIME ERROR ABORT not allowed with this ON condition CAUSE 187 COMPILE-TIME ERROR CAUSE 188 COMPILE-TIME ERROR Initialization of shared common blocks not allowed Initialization of common blocks declared to be in shared memory cannot be initialized a
189 191 COMPILE-TIME ERROR Built-in functions %REF, %VAL used in invalid context CAUSE Illegal arguments used in built-in functions. COMPILE-TIME ERROR CAUSE 192 A-26 Diagnostic Messages Illegal structure declaration Either a eld name was given at the outermost level of a structure declaration or the use of dynamic, assumed size, or adjustable arrays. Passed length and variable length character items are also not permitted with a structure declaration.
201 COMPILE-TIME ERROR CAUSE 202 COMPILE-TIME ERROR CAUSE 203 COMPILE-TIME ERROR CAUSE 204 COMPILE-TIME ERROR No matching IF statement An ENDIF statement appears without a matching IF statement. Expecting ENDIF statement An IF statement appears without a matching ENDIF statement. Expecting DO terminator An ENDDO statement is missing.
208 COMPILE-TIME ERROR Expecting END DO for DO WHILE CAUSE 210 COMPILE-TIME ERROR CAUSE 211 COMPILE-TIME ERROR IMPLICIT not allowed in or after executable statements The IMPLICIT statement is a speci cation statement and cannot appear in or after any executable statements.
215 COMPILE-TIME ERROR CAUSE 216 COMPILE-TIME ERROR Missing END statement A program unit has no END statement. Note that this can be caused by a compiler directive appearing in the wrong location between compilation units.
221 222 COMPILE-TIME ERROR This statement is only allowed within a structure declaration CAUSE UNION or MAP statement encountered outside of a structure declaration.
301 COMPILE-TIME ERROR Undefined character(s) on line CAUSE 302 COMPILE-TIME ERROR Ill-formed number CAUSE 303 COMPILE-TIME ERROR Ill-formed FORMAT string CAUSE 304 COMPILE-TIME ERROR Error in Hollerith literal CAUSE 305 COMPILE-TIME ERROR Continuation line error CAUSE 306 COMPILE-TIME ERROR Error in label field CAUSE 307 COMPILE-TIME ERROR Unmatched quotation marks CAUSE Diagnostic Messages A-31
309 COMPILE-TIME ERROR Arithmetic overflow CAUSE 310 COMPILE-TIME ERROR Array subscript overflow CAUSE 311 COMPILE-TIME ERROR End of file encountered CAUSE 312 COMPILE-TIME ERROR End of line encountered CAUSE 313 COMPILE-TIME ERROR This character or group of characters not permitted here CAUSE 314 315 COMPILE-TIME ERROR CHARACTER*(*) is only permitted in the outermost block with the directives being used CAUSE CHARACTER*(*) COMPILE-TIME ERROR Label field of continuation line is not bla
316 COMPILE-TIME ERROR CAUSE 317 COMPILE-TIME ERROR CAUSE 318 COMPILE-TIME ERROR CAUSE 325 COMPILE-TIME ERROR Continuation limit exceeded The number of continuation lines exceeds the default or speci ed limit. The default number of continuation lines is 19. Entry points not consistent for subroutine or function with the directives being used When using directives that change the calling convention, all entry points to a program unit must be consistent.
340 COMPILE-TIME ERROR CAUSE 350 360 361 COMPILE-TIME ERROR Diagnostic Messages Data bu ers inside the compiler have been lled to capacity. No further processing can be done on this statement. The statement's data requirements must be decreased. This statement is too complicated CAUSE The expression in this statement is too complicated for the compiler to handle.
393 COMPILE-TIME ERROR CAUSE 394 COMPILE-TIME ERROR CAUSE 395 COMPILE-TIME ERROR Unbalanced quotes Missing a beginning or closing quote in a statement. Unbalanced parentheses Parentheses are not matched in a statement.
398 COMPILE-TIME ERROR Undefined character class CAUSE 399 COMPILE-TIME ERROR Undefined special character CAUSE 400 COMPILE-TIME ERROR CAUSE 401 402 COMPILE-TIME ERROR Diagnostic Messages The UNIT speci er must be an INTEGER expression. UNIT specifier not an external unit CAUSE The UNIT speci er was an internal le. COMPILE-TIME ERROR Invalid UNIT for auxiliary statement CAUSE A-36 Invalid type of UNIT specifier The UNIT speci er given was an internal le.
403 COMPILE-TIME ERROR CAUSE 404 405 Internal file requires FORMATTED or list-directed use CAUSE Attempted UNFORMATTED I/O on an internal le. COMPILE-TIME ERROR COMPILE-TIME ERROR CAUSE 407 The FMT speci er must be one of the following: 1. Statement label of a FORMAT statement. 2. Variable that has been assigned the statement label of a FORMAT statement. 3. Character or non-character array name that contains the representation of a FORMAT statement. 4. A character expression. 5. An asterisk.
410 COMPILE-TIME ERROR CAUSE 412 COMPILE-TIME ERROR CAUSE 413 COMPILE-TIME ERROR CAUSE 414 COMPILE-TIME ERROR CAUSE 415 COMPILE-TIME ERROR CAUSE 416 A-38 Diagnostic Messages COMPILE-TIME ERROR FILE specifier not character expression The FILE speci er is valid only in an INQUIRE or OPEN statement and must be a character variable, array element, or substring.
CAUSE The FILE and UNIT speci ers cannot both appear in an input/output statement.
417 COMPILE-TIME ERROR CAUSE 418 COMPILE-TIME ERROR CAUSE 419 COMPILE-TIME ERROR CAUSE 420 COMPILE-TIME ERROR CAUSE 422 COMPILE-TIME ERROR CAUSE 423 COMPILE-TIME ERROR CAUSE A-40 Diagnostic Messages EXIST not LOGICAL*4 variable or array element name The EXIT= speci er of an INQUIRE statement must be assignable and of type LOGICAL*4. OPENED not LOGICAL*4 variable or array element name The OPENED= speci er of an INQUIRE statement must be assignable and of type LOGICAL*4.
424 COMPILE-TIME ERROR CAUSE 425 COMPILE-TIME ERROR CAUSE 426 COMPILE-TIME ERROR CAUSE 427 COMPILE-TIME ERROR CAUSE 428 COMPILE-TIME ERROR CAUSE 429 COMPILE-TIME ERROR CAUSE ACCESS not character variable or array element name The ACCESS= speci er of an INQUIRE statement must be an assignable character data item. SEQUENTIAL not character variable or array element name The SEQUENTIAL= speci er of an INQUIRE statement must be an assignable character data item.
A-42 Diagnostic Messages
430 COMPILE-TIME ERROR CAUSE 434 COMPILE-TIME ERROR CAUSE 435 COMPILE-TIME ERROR CAUSE 436 437 438 COMPILE-TIME ERROR The BLANK= speci er of an INQUIRE statement must be an assignable item of type CHARACTER. Duplicate declaration of specifier A particular speci er was used twice within an I/O statement. Unit specifier required I/O statement requires a UNIT speci er. If WRITE, no END specifier allowed CAUSE The END speci er is not allowed in a WRITE statement.
447 448 449 450 451 452 A-44 Diagnostic Messages COMPILE-TIME ERROR Internal file must be sequential CAUSE Direct access I/O was attempted on an internal le. COMPILE-TIME ERROR Direct access file cannot use list directed I/O CAUSE Attempted to do list-directed I/O on a le opened for direct access. COMPILE-TIME ERROR Assumed size array not allowed CAUSE The internal les may not be assumed size arrays.
454 COMPILE-TIME ERROR CAUSE 455 COMPILE-TIME ERROR CAUSE 500 COMPILE-TIME ERROR CAUSE 501 COMPILE-TIME ERROR CAUSE 502 COMPILE-TIME ERROR CAUSE Array cannot be adjustable or assumed size in ENCODE/DECODE An adjustable or assumed size array was used as the unit parameter in an ENCODE/DECODE statement. Illegal use of aggregate reference in I/O list unformatted I/O is the only I/O that can be performed on aggregate record references.
503 504 COMPILE-TIME ERROR CAUSE The maximum level of nesting (75) for global values has been reached. COMPILE-TIME ERROR Range violation detected at compilation time CAUSE 505 506 COMPILE-TIME ERROR COMPILE-TIME ERROR Unable to open FORTRAN message catalog COMPILE-TIME ERROR COMPILE-TIME ERROR CAUSE A-46 Diagnostic Messages Unable to open file The le is not present or not readable. CAUSE 558 The compiler detected an attempt to access an array outside its declared bounds.
559 COMPILE-TIME ERROR CAUSE 561 COMPILE-TIME ERROR CAUSE 564 COMPILE-TIME ERROR CAUSE 566 COMPILE-TIME ERROR CAUSE 575 COMPILE-TIME ERROR CAUSE 576 COMPILE-TIME ERROR CAUSE Unable to open compiler communication file Unable to open UCODEOUT, a le used for communication between the two compiler processes. (On MPE/V systems only.) Create process failed: no process handling capability The second compiler process could not be created due to a lack of process handling capabilities.
577 COMPILE-TIME ERROR CAUSE 601 COMPILE-TIME ERROR CAUSE 602 COMPILE-TIME ERROR Create process failed: illegal priority class specified Error 17 is returned from CREATEPROCESS intrinsic. (On MPE/V systems only.) Unable to open system intrinsic file The system intrinsic le cannot be opened, is already opened exclusively, or is some other type of illegal le. Corrupt system intrinsic file CAUSE 603 604 COMPILE-TIME ERROR CAUSE The speci ed le is not a system intrinsic le.
Compile-Time Warnings 700 701 COMPILE-TIME WARNING Missing semantics in option: option ignored CAUSE Internal error. Please notify your HP representative. COMPILE-TIME WARNING CAUSE 703 COMPILE-TIME WARNING CAUSE 704 COMPILE-TIME WARNING CAUSE 705 COMPILE-TIME WARNING CAUSE 706 COMPILE-TIME WARNING CAUSE Arithmetic overflow The operation can cause arithmetic over ow.
708 709 COMPILE-TIME WARNING Directive continuation line not found CAUSE Next noncomment line is not a directive. COMPILE-TIME WARNING This option is allowed only at the beginning of a program unit: ignored CAUSE 710 711 COMPILE-TIME WARNING ALIAS directive improperly applied: directive ignored CAUSE Improper speci cation of the ALIAS directive.
716 COMPILE-TIME WARNING CAUSE 717 718 Short doubles not allowed by this compiler CAUSE The REAL*6 data type is not permitted. COMPILE-TIME WARNING COMPILE-TIME WARNING CAUSE 720 A dollar sign, \$", denoting a compiler directive was found in a column other than column 1. COMPILE-TIME WARNING CAUSE 719 Compiler directive does not begin in column 1 COMPILE-TIME WARNING CAUSE ")" expected in option: ignored The \) " is expected in the directive $IF (expr) or $SET (list).
722 723 724 725 726 COMPILE-TIME WARNING Illegal form of UNIT specified: ignored CAUSE The UNIT speci er in this statement was of improper form, and thus ignored. COMPILE-TIME WARNING Identifier expected in option: ignored CAUSE This option requires an identi er. COMPILE-TIME WARNING CAUSE A valid compiler directive word was expected, but none encountered. COMPILE-TIME WARNING OPTIMIZE and SYMDEBUG mutually exclusive: option ignored CAUSE The $OPTIMIZE cannot be used when $SYMDEBUG is ON.
CAUSE The speci ed error condition may not be trapped with emulated oating point programs.
730 731 732 734 735 736 COMPILE-TIME WARNING Illegal string in option or statement: ignored CAUSE An illegal date in the $COPYRIGHT directive; check the syntax. COMPILE-TIME WARNING Expecting constant in option: ignored CAUSE A .TRUE. or .FALSE. is expected in the $SET option. COMPILE-TIME WARNING Logical end of option already encountered: option ignored CAUSE Extra character found in an option that has already been processed.
740 COMPILE-TIME WARNING CAUSE 741 COMPILE-TIME WARNING This language cannot be specified on this operating system: HP FORTRAN 77 assumed Illegal language suboption was speci ed for the $ALIAS directive on host operating system. Expecting identifier or "(" in option: ignored CAUSE 742 COMPILE-TIME WARNING Expecting .AND. or .OR.
747 748 COMPILE-TIME WARNING Compiler suboption identifier expected CAUSE This suboption requires an identi er. COMPILE-TIME WARNING Expecting identifier or " / " in option: ignored CAUSE 749 COMPILE-TIME WARNING CAUSE 750 752 753 Diagnostic Messages $SEGMENT has been mapped to $LOCALITY on this operating system The $SEGMENT directive used on MPE/V is accepted as a synonym for $LOCALITY, though their memories are not identical.
754 755 COMPILE-TIME WARNING Illegal parameter in option: option ignored CAUSE This option cannot have the given parameters. COMPILE-TIME WARNING Identifier has been truncated to 32 characters CAUSE 756 757 758 Identi ers can have only 32 signi cant characters. Any identi ers longer than 32 characters are truncated to 32. COMPILE-TIME WARNING Duplicate specification of shared memory option: this option ignored CAUSE The KEY option in $SHARED_MEMORY is already speci ed.
762 COMPILE-TIME WARNING If "PFA" is specified, "SYMDEBUG" cannot be turned off CAUSE 763 764 COMPILE-TIME WARNING This option cannot be turned off on this operating system CAUSE Some options are intrinsically ON in the operating system. COMPILE-TIME WARNING This algebraic expression can be reduced CAUSE 767 768 COMPILE-TIME WARNING Duplicate declaration or definition, using first type CAUSE Redeclaration of a variable with a di erent type.
771 COMPILE-TIME WARNING DESTINATION SCHEDULER was previously specified. Directive ignored. CAUSE 772 COMPILE-TIME WARNING Attempting to pass entire array as value parameter. Arguments specified pass by value in ALIAS Directive. Unexpected results may occur. CAUSE 775 776 COMPILE-TIME WARNING "," or ")" expected in option: ignored CAUSE A comma \," or a right parenthesis \)" is expected in the directive.
778 779 781 COMPILE-TIME WARNING CAUSE The array is referenced by a subscript value that is out of the declared bounds. COMPILE-TIME WARNING Undefined conditional compilation variable: .TRUE. assumed CAUSE The indenti er(s) used within the condition list in the $IF was not $SET. COMPILE-TIME WARNING Test may fail due to floating point imprecision CAUSE 782 COMPILE-TIME WARNING CAUSE 783 COMPILE-TIME WARNING CAUSE 784 A-60 Diagnostic Messages Array reference out of bounds .EQ. and .NE.
785 COMPILE-TIME WARNING CAUSE 791 COMPILE-TIME WARNING CAUSE 792 793 COMPILE-TIME WARNING Illegal FORTRAN NLS call: FORTRAN source code must be compiled with -Y The FORTRAN source le was not compiled with the -Y option and NLS features were used. No matching IF directive: ignored An ENDIF with no matching IF. Expecting ENDIF directive: ignored CAUSE An IF with no matching ENDIF. COMPILE-TIME WARNING Missing or unsupported suboption encountered: Directive ignored.
ANSI Warnings 801 ANSI WARNING CAUSE 802 ANSI WARNING CAUSE 803 ANSI WARNING CAUSE 804 ANSI WARNING CAUSE 805 ANSI WARNING CAUSE 806 ANSI WARNING CAUSE A-62 Diagnostic Messages ANSI Warning: mixed character and noncharacter data in EQUIVALENCE To be ANSI standard, an entity of type CHARACTER may be equivalenced only with other entities of type CHARACTER.
807 ANSI WARNING CAUSE 808 809 ANSI Warning: use of IMPLICIT NONE statement CAUSE IMPLICIT NONE ANSI WARNING ANSI Warning: length specified for noncharacter data type ANSI WARNING CAUSE 811 ANSI WARNING CAUSE 812 These looping constructs are MIL-STD 1753 and HP extensions to ANSI FORTRAN 77. ANSI WARNING CAUSE 810 ANSI Warning: use of block DO, DO WHILE, or END DO statement ANSI WARNING CAUSE is a MIL-STD 1753 extension to ANSI FORTRAN 77.
813 ANSI WARNING CAUSE 814 ANSI WARNING CAUSE 815 ANSI WARNING CAUSE 816 ANSI WARNING CAUSE 817 ANSI WARNING CAUSE 818 ANSI WARNING CAUSE A-64 Diagnostic Messages ANSI Warning: FUNCTION, SUBROUTINE, or ENTRY name called recursively Allowing program units to call themselves is an HP extension to ANSI FORTRAN 77. ANSI Warning: use of INCLUDE statement The INCLUDE statement is a MIL-STD 1753 extension to ANSI FORTRAN 77.
819 ANSI WARNING CAUSE 820 ANSI WARNING CAUSE 821 ANSI WARNING CAUSE 822 ANSI WARNING ANSI Warning: use of underscore or dollar sign in identifier(s) The use of an underscore (\ ") or dollar sign (\$") in symbolic names is a non-ANSI standard feature. ANSI Warning: noncharacter array used as FORMAT specifier Use of non-character arrays as a FORMAT speci er is non-ANSI standard.
826 ANSI WARNING CAUSE 827 ANSI WARNING CAUSE 828 ANSI WARNING CAUSE 829 ANSI WARNING CAUSE 830 831 A-66 Diagnostic Messages ANSI WARNING ANSI Warning: use of nonstandard FORMAT descriptor A format descriptor was used that is an HP extension to ANSI FORTRAN 77. ANSI Warning: initialization of integer with character data Initialization of integer variables (INTEGER and BYTE) with character data is an extension to the ANSI standard.
832 833 834 835 ANSI WARNING ANSI Warning: use of ENCODE/DECODE CAUSE ENCODE/DECODE is not part of ANSI FORTRAN 77. ANSI WARNING CAUSE BYTE or LOGICAL*1 is not part of ANSI FORTRAN 77. ANSI WARNING ANSI Warning: use of dynamic array CAUSE Use of dynamic arrays is an extension to the ANSI standard.
A-68 Diagnostic Messages
839 ANSI WARNING CAUSE 840 ANSI WARNING CAUSE 841 ANSI WARNING CAUSE 842 ANSI WARNING CAUSE 843 ANSI WARNING CAUSE 844 ANSI WARNING CAUSE ANSI Warning: use of "TYPE" statement TYPE statement is a non-ANSI standard feature. The PRINT statement is the equivalent ANSI standard statement. ANSI Warning: data initialization in type declaration statement It is non-ANSI standard to initialize data in a type declaration statement.
845 ANSI WARNING CAUSE 846 ANSI WARNING ANSI Warning: COMMON variables initialized in non-BLOCK DATA subprograms It is non-ANSI standard to initialize COMMON variables in non-BLOCK DATA subprograms.
852 ANSI WARNING ANSI Warning: use of nonstandard EQUIVALENCE CAUSE 853 ANSI WARNING ANSI Warning: zero passed by value for NULL parameters CAUSE 854 ANSI WARNING ANSI Warning: use of VIRTUAL statement CAUSE 855 ANSI WARNING ANSI Warning: use of nonstandard I/O specifier CAUSE 856 ANSI WARNING ANSI Warning: use of the ACCEPT statement CAUSE 857 ANSI WARNING ANSI Warning: blank common initialized in block data subprogram CAUSE 858 ANSI WARNING ANSI Warning: use of quad precision constant
Note A-72 Diagnostic Messages Errors 5000 and above are internal errors. If you receive one of these errors, please contact your HP service representative and report the details of this message. This means more investigation is required.
Run-Time Errors 900 RUN-TIME ERROR Error in format CAUSE ACTION 901 RUN-TIME ERROR Negative unit number specified CAUSE ACTION 902 Unit number was not greater than or equal to zero. Use a nonnegative unit number. RUN-TIME ERROR Formatted I/O attempted on unformatted file CAUSE ACTION 903 Format speci cation contains unrecognizable code or string, contains an impossible format (F0.s or G2.9, for example), or a format descriptor describes a eld too wide for internal bu ers.
904 RUN-TIME ERROR Direct I/O attempted on sequential file CAUSE ACTION 905 RUN-TIME ERROR Error in list-directed read of logical data CAUSE ACTION 907 ACTION Diagnostic Messages Found repeat value, but no asterisk; characters item not delimited by quotation marks. Change input data to correspond to syntax expected by list-directed input of characters; use input statement that corresponds to syntax of input data.
ACTION Correct the name to invoke the le intended.
909 RUN-TIME ERROR Sequential I/O attempted on direct access file CAUSE ACTION 910 RUN-TIME ERROR Access past end of record attempted CAUSE ACTION 912 ACTION ACTION Diagnostic Messages Problem reading complex data: (1) no left parenthesis and no repeat value, or (2) found repeat value, but no asterisk, or (3) no comma after real part, or (4) no closing right parenthesis.
\MAXSIZE" kernel parameter to change the heap size for the Series 800.
914 RUN-TIME ERROR Access of unconnected unit attempted CAUSE ACTION 915 RUN-TIME ERROR Read unexpected character CAUSE ACTION 916 ACTION ACTION Diagnostic Messages An illegal character was read when logical data was expected. Change input data to correspond to syntax expected when reading logical data; use input statement corresponding to syntax of input data.
918 RUN-TIME ERROR Open of existing file with STATUS='NEW' attempted CAUSE ACTION 920 RUN-TIME ERROR Open of file connected to different unit attempted CAUSE ACTION 921 Executed OPEN statement with a UNIT speci er that is already associated with a di erent le name. Use an OPEN statement with a UNIT speci er that is not connected to a le name; open the connected le to the same unit name.
923 RUN-TIME ERROR Open with illegal FORM specifier attempted CAUSE ACTION 924 RUN-TIME ERROR Close of scratch file with STATUS='KEEP' attempted CAUSE ACTION 925 ACTION ACTION Diagnostic Messages STATUS speci er did not begin with \O", \o", \N", \n", \S", \s", \U", or \u". Use 'OLD', 'NEW', 'SCRATCH', or 'UNKNOWN' for the STATUS speci er in OPEN statement.
927 RUN-TIME ERROR Open with illegal ACCESS specifier attempted CAUSE ACTION 929 RUN-TIME ERROR Open of direct file with no RECL specifier attempted CAUSE ACTION 930 ACTION RECL speci er in OPEN statement was less than or equal to zero. Use a positive number for RECL speci er in OPEN statement. RUN-TIME ERROR Open with illegal BLANK specifier attempted CAUSE ACTION 933 OPEN statement had ACCESS='DIRECT', but no RECL speci er. Add RECL speci er; specify ACCESS='SEQUENTIAL'.
ACTION A-82 Diagnostic Messages Use the END= speci er to handle the EOF; check logic.
934 RUN-TIME ERROR OPEN of readonly file with ACCESS='APPEND' ATTEMPTED CAUSE ACTION 936 RUN-TIME ERROR Append I/O attempted on sequential only file/device CAUSE ACTION 937 RUN-TIME ERROR Illegal record number specified CAUSE ACTION 942 RUN-TIME ERROR Error in list-directed read character data read for assignment to noncharacter variable CAUSE ACTION 944 A character string was read for a numerical or logical variable. Check input data and input variable type.
CAUSE ACTION A-84 Diagnostic Messages More bytes of I/O were requested than exist in the current record. Match the format to the data record.
950 RUN-TIME ERROR Subscript, substring, or parameter out of bounds at statement number nnn CAUSE ACTION 951 RUN-TIME ERROR Label out of bounds in assigned GOTO at statement number nnn CAUSE ACTION 952 The value of the variable did not correspond to any of the labels in the list in an assigned GOTO statement. Check for a possible logic error in the program or an incorrect list in the assigned GOTO statement at or near the given statement number.
954 RUN-TIME ERROR Illegal use of empty format CAUSE ACTION 955 RUN-TIME ERROR Open with no FILE= and STATUS='OLD' or 'NEW' CAUSE ACTION 956 ACTION ACTION Diagnostic Messages The le system returned an error status during an I/O operation. See the associated le system error message. RUN-TIME ERROR Format descriptor incompatible with numeric item in I/O list CAUSE A-86 OPEN statement is incomplete. Change status to 'SCRATCH' or 'UNKNOWN' or add le speci er.
958 RUN-TIME ERROR Format descriptor incompatible with character item in I/O list CAUSE ACTION 959 RUN-TIME ERROR Format descriptor incompatible with logical item in I/O list CAUSE ACTION 960 A logical item in the I/O list was matched with a format descriptor other than \L". Match format descriptors to I/O list. RUN-TIME ERROR Format error: Missing starting left parenthesis CAUSE ACTION 961 A character item in the I/O list was matched with a format descriptor other than \A" or \R".
962 RUN-TIME ERROR Unexpected character found following a number in the format string CAUSE ACTION 963 RUN-TIME ERROR Format error: Trying to scale unscalable format specifier CAUSE ACTION 964 ACTION ACTION ACTION Diagnostic Messages A speci er beginning with \T" is not a correct tab speci er. Correct the speci er beginning with \T". RUN-TIME ERROR Format error: Invalid blank specifier CAUSE A-88 Too many left parentheses for the format processor to stack. Nest parentheses less deeply.
967 RUN-TIME ERROR Format error: Specifier expected but end of format found CAUSE ACTION 968 RUN-TIME ERROR Format error: Missing separator CAUSE ACTION 969 Other speci er found when /, :, or ) expected. Insert separator where needed. RUN-TIME ERROR Format error: Digit expected CAUSE ACTION 970 The end of the format was reached when another speci er was expected.
971 RUN-TIME ERROR Format error: Unbalanced parentheses CAUSE ACTION 972 RUN-TIME ERROR Format error: Invalid string in format CAUSE ACTION 973 ACTION ACTION ACTION Diagnostic Messages An attempt was made to transfer more characters than internal le length. Match READ or WRITE with internal le size. RUN-TIME ERROR Illegal new file number requested in fset function CAUSE A-90 Record length speci ed in redundant OPEN con icted with the value as opened.
Diagnostic Messages A-91
976 RUN-TIME ERROR Unexpected character in "NAMELIST" read CAUSE ACTION 977 RUN-TIME ERROR Illegal subscript or substring in "NAMELIST" read CAUSE ACTION 978 ACTION ACTION ACTION Diagnostic Messages Variable not in NAMELIST group in NAMELIST read. Read only the variables in this NAMELIST. RUN-TIME ERROR "NAMELIST" I/O attempted on unformatted file CAUSE A-92 Too many values in NAMELIST read. Supply only as many values as the length of the array.
981 RUN-TIME ERROR Value out of range in numeric read CAUSE ACTION 989 RUN-TIME ERROR Illegal FORTRAN NLS call: FORTRAN source code must be compiled with -Y CAUSE ACTION 990 Value read for numeric item is to big/small. Read only values that t in the range of the numeric type being read. The FORTRAN source le was not compiled with the -Y option and NLS features were used. The problem is critical enough that program execution cannot continue. Recompile the FORTRAN source code with -Y option.
B Intrinsic Functions and Math Subroutines An intrinsic function is a built-in function that returns a single value. A math subroutine is a prede ned subroutine that performs a particular mathematical task. Intrinsic functions and math subroutines convert values from one data type to another, perform data manipulation, and also perform basic mathematical functions, such as calculating sines, cosines, and square roots of numbers.
Generic and Specific Function Names Each of the intrinsic functions has a generic name, one or more speci c names, or both generic and speci c names. A generic name can be used with any of the valid data types for the function. A speci c name can be used with only the speci ed data type. If both a generic and a speci c name exist, either can be used to invoke the function. However, generic names are recommended because they are more exible.
Summary of the Intrinsic Functions This section lists the intrinsic functions of HP FORTRAN 77. Tables B-1 through B-6 show the de nition of each function, the number of arguments, the generic name for each group of functions, the speci c name for each function, the types of arguments allowed, and the argument and function type. Table B-7 lists the random number generator functions available in FORTRAN. Table B-8 lists the built-in functions available in FORTRAN.
Table B-1. Arithmetic Functions (continued) Function Description No. Generic Speci c Type of of Name Name Argument Args.
Table B-1. Arithmetic Functions (continued) Function Description No. Generic Speci c Type of of Name Name Argument Args. Type of Function LOGICAL*1LOGICAL*1 ---IMIN0y INTEGER*2INTEGER*2 JMIN0y INTEGER*4INTEGER*4 AMIN1 REAL*4 REAL*4 DMIN1 REAL*8 REAL*8 QMIN1y REAL*16 REAL*16 MIN0 IMIN0 INTEGER*2INTEGER*2 JMIN0 INTEGER*4INTEGER*4 MIN1 IMIN1y REAL*4 INTEGER*2 JMIN1y REAL*4 INTEGER*4 AMIN0 AIMIN0y INTEGER*2REAL*4 AJMIN0y INTEGER*4REAL*4 Choosing min smallest (a,b, . . .
Table B-2. Bit Manipulation Functions Function Description No. Generic Speci c Type of of Name Name Argument Args.
Table B-3. Character Functions Function Conversion to character Description No. Generic Speci c Type of of Name Name Argument Args.
Table B-4. Numeric Conversion Functions Function Description No. Generic Speci c Type of of Name Name Argument Args.
Table B-4. Numeric Conversion Functions (continued) Function Description No. Generic Speci c Type of of Name Name Argument Args. Type of Function LOGICAL*1REAL*8 y DBLE ---DFLOTI INTEGER*2REAL*8 DFLOTJ INTEGER*4REAL*8 REAL*4 REAL*8 ---DBLE REAL*8 REAL*8 REAL*16 REAL*8 ---DBLEQy COMPLEX*8REAL*8 COMPLEX*16 REAL*8 ---DFLOAT DREALy INTEGER*2REAL*8 DFLOTI INTEGER*4REAL*8 DFLOTJ y indicates that the function is an extension to the ANSI 77 standard.
Table B-4. Numeric Conversion Functions (continued) Function Description No. Generic Speci c Type of of Name Name Argument Args.
Table B-4. Numeric Conversion Functions (continued) Function Description No. Generic Speci c Type of of Name Name Argument Args. Truncation REAL(INT(a))1 DBLE(INT(a)) Nearest whole number INT(a+.5) if a 0 INT(a0.5) if a<0 INT(a+.5) if a 0 INT(a0.
Table B-5. Transcendental Functions Function Description No. Generic Speci c Type of of Name Name Argument Args.
Table B-5. Transcendental Functions (continued) Function Description No. Generic Speci c Type of of Name Name Argument Args.
Table B-5. Transcendental Functions (continued) Function Description No. Generic Speci c Type of of Name Name Argument Args.
Table B-5. Transcendental Functions (continued) Function Description No. Generic Speci c Type of of Name Name Argument Args.
Table B-6. Miscellaneous Functions Function DescriptionNo. of Args. Byte address Byte address Bytes of storage baddress(a) 1 1 Generic Name Speci c Type of Name Argument Type of Function BADDRESS-y--- Any INTEGER*4 %LOCy Any INTEGER*4 ---- Any except INTEGER*4 dynamic or assumed-size array. y indicates that the function is an extension to the ANSI 77 standard. SIZEOF 1 SIZEOF |- Table B-7. Built-in Functions Function Description No. Generic Speci c Type of of Name Name Argument Args.
Notes for Tables B-1 through B-8 1. For a of type INTEGER*4 or INTEGER*2, INT(a) = a. For a of type REAL*4 or REAL*8, there are two cases: A. If |a|<1, INT(a)=0. B. If |a|>1, INT(a) is the integer whose magnitude is the magnitude of a and whose sign is the same as that of a. For example: INT(-3.7) = -3 For a of type COMPLEX*8, INT(a) is the value obtained by applying the above rule to the real part of a. For a of type REAL*4, IFIX(a) is the same as INT(a).
5. A COMPLEX*8 value is expressed as an ordered pair of REAL*4s or REAL*8s (ar,ai), where ar is the real part and ai the imaginary part. ABS or CABS is de ned as: SQRT (ar^+2^- + ai^+2^-) 6. All angles in trigonometric functions are expressed in radians. 7. CONJG is de ned as (ar,ai); see note 5. 8. ISHFT(a,b) is de ned as the value of the rst argument (a) shifted by the number of bit positions designated by the second argument (b). If b>0, shift left; if b<0, shift right; if b=0, no shift.
because they always obey the ASCII collating sequence. Using the operators on another system may produce di erent results. For example: LLT('9','A') is always true. However: ('9' .LT. 'A') Note may be false on some systems. The NLS directive can change the results of these functions. See \NLS Directive" in Chapter 7.
13. As a MIL-STD-1753 standard extension to the ANSI 77 standard, ISHFTC(a,b,c) is de ned as the right-most c bits of the argument a shifted circularly b places. That is, the bits shifted out of one end are shifted into the opposite end. No bits are lost. The unshifted bits of the result are the same as the unshifted bits of the argument a. The absolute value of the argument b must be less than or equal to c.
32 (depending on whether a is a 16- or 32-bit element), the result is false. 19. The result of the function IBSET(a,b) is equal to the value of a with the bth bit set to 1. If b is greater than or equal to 16 or 32 (depending on whether a is a 16- or 32-bit element), the result is a. 20. The result of the function IBCLR(a,b) is equal to the value of a with the bth bit set to 0. If b is greater than or equal to 16 or 32 (depending on whether a is a 16- or 32-bit element), the result is a. 21.
22. The ZEXT function expands any xed-point argument to either an INTEGER*2 or INTEGER*4 without extending the sign of the argument (that is, the high-order bits are set to zero). The generic name ZEXT behaves like IZEXT when the SHORT directive is enabled. ZEXT behaves like JZEXT when SHORT is not enabled. 23. The size of the integer function returned by BADDRESS is system dependent. 24. The argument of SIN, DSIN, COS, DCOS, TAN, or DTAN must be in radians, which are treated as modulo 2* .
FORTRAN Intrinsic Functions and Following are system intrinsics accessed with the NOSTANDARD SYSTEM compiler directive. Subroutines DATE Subroutine DATE returns 15-SEP-88). DATE a string in the form dd-mmm-yy (for example, is called as follows: CHARACTER*9 DSTRING CALL DATE(DSTRING) IDATE Subroutine returns three integer values representing the current month, day, and year.
SECNDS Function returns the number of seconds elapsed since midnight minus the number of seconds passed in as an argument. SECNDS measures intervals of seconds up to 24 hours. It can handle cases where the start time is before midnight and the end time is after, as long as the interval does not exceed 24 hours. SECNDS Example $NOSTANDARD SYSTEM PROGRAM benchmark REAL*4 TIME0,TIME1 INTEGER I TIME0 = SECNDS (0.0) PRINT *,TIME0 C C code to be limited F = 0.
TIME Subroutine returns a string in the form hh:mm:ss (for example, 22:10:30). TIME is called as follows: TIME $NOSTANDARD SYSTEM PROGRAM checktime CHARACTER*8 timebuff CALL TIME(timebuff) PRINT *,timebuff END Setting the TZ Environment Variable To get the correct time, you must set the evironment variable TZ to your local time zone. To set the TZ, use the MPE/iX SETVAR command.
Table B-8. Time Zones and TZ Environment Variable Values TZ Values Time Zone Geographic Area United States: Hawaii. HST10 Hawaiian Standard Time, Hawaiian Daylight Time. AST10ADT Aleutian Standard Time, Aleutian Daylight United States: Alaska (parts). Time. YST9YDT Yukon Standard Time, Yukon Daylight Time. United States: Alaska (parts). PST3PDT Paci c Standard Time, Paci c Daylight Time. Canada: British Columbia. United States: California, Idaho(parts), Nevada, Oregon (parts), Washington.
Table B-8. Time Zones and TZ Environment Variable Values (continued) TZ Values Time Zone Geographic Area SAST-2SADT South Africa Standard Time, South Africa Daylight Time. South Africa. JST-9 Japan Standard Time Japan. WST-8:00 Australian Western Standard Time Australia: Western Australia CST-9:30 Australian Central Standard Time Australia: Northern Territory. CST-9:30CDT Australian Central Standard Time, Australian Central Daylight Time.
Function Descriptions ABS Function The FORTRAN 77 generic functions follow, in alphabetical order. The functions that do not have a generic name are listed alphabetically by speci c name. is a generic function that returns the absolute value of an INTEGER*4, REAL*4, REAL*8, REAL*16, or COMPLEX*8 argument. A complex value is expressed as an ordered pair of REAL*4 or REAL*8 numbers in the form (ar,ai ) where ar is the REAL*4 part and ai is the imaginary part.
ACOS Function is a generic function that returns the arccosine of a REAL*4, REAL*8, or REAL*16 argument. The value of arg must be less than or equal to one. The result is expressed in radians and is the same data type as the argument. ACOS(arg ) Examples Function Call Value Returned to a a = ACOS(0.0628) 1.5079550 a = ACOS(0.0) 1.5707964 a = ACOS(0.0D0) 1.570796326794897 The speci c function names are ACOS for REAL*4 arguments, DACOS for REAL*8 arguments, and QACOS for REAL*16 arguments.
ACOSH Function is a generic function that returns the hyperbolic arccosine of a REAL*4, REAL*8, or REAL*16 argument. The argument must be greater than or equal to one and less than or equal to the maximum number allowed on your system. The result is the same data type as the argument. ACOSH(arg ) Examples Function Call Value Returned to a a = ACOSH(1.2) 0.622362 a = ACOSH(1.0) 0.0 a = ACOSH(1.0D0) 0.
ANINT Function is a generic function that returns the nearest whole number. The argument can be REAL*4, REAL*8, or REAL*16. The result is INT (arg + 0.5) if arg is positive or zero, and is INT(arg - 0.5) if arg is negative. The result is the same data type as the argument. ANINT(arg ) Examples Function Call Value Returned to a a = ANINT(-678.44) -678.0 a = ANINT(678.44) 678.0 a = ANINT(0.00) 0.0 a = ANINT(6.78 D1) 68.
ASIND Function is a generic function that returns the arcsine of a REAL*4, REAL*8, or REAL*16 argument. The value of arg must be less than or equal to one. The result is expressed in degrees and is the same data type as the argument. ASIND(arg ) Examples Function Call Value Returned to a a = ASIND(0.30) 17.4576 a = ASIND(0.30D0) 17.45760312372209 The speci c function names are ASIND for REAL*4 arguments, DASIND for REAL*8 arguments, and QASIND for REAL*16 arguments.
ATAN Function is a generic function that returns the arctangent of a REAL*4, REAL*8, or REAL*16 argument. The result is expressed in radians and is the same data type as the argument. ATAN(arg ) Examples Function Call a = ATAN(1.0) Value Returned to a 0.7853982 a = 1.262627255624651 ATAN(3.141592653D0) The speci c function names are ATAN for REAL*4 arguments, DATAN for REAL*8 arguments, and QATAN for REAL*16 arguments.
ATAND Function is a generic function that returns the arctangent of a REAL*4, REAL*8, or REAL*16 argument. The result is expressed in degrees and is the same data type as the argument. ATAND(arg ) Examples Function Call Value Returned to a a = ATAND(1.0) 45.0 a = ATAND(2.5D0) 68.19859051364820 The speci c function names are ATAND for REAL*4 arguments, DATAND for REAL*8 arguments, and QATAND for REAL*16 arguments.
ATANH Function is a generic function that returns the hyperbolic arctangent of a REAL*4, REAL*8, or REAL*16 argument. The value of arg must be less than one. The result is the same data type as the argument. ATANH(arg ) Examples Function Call Value Returned to a a = ATANH(0.30) 0.3095196 a = ATANH(0.30D0) 0.309519604203112 The speci c function names are ATANH for REAL*4 arguments, DATANH for REAL*8 arguments, and QATANH for REAL*16 arguments.
BTEST Function is a generic function that tests individual bits of storage. The arguments are INTEGER*4 and the result is LOGICAL*4. If the arg2 th bit of arg1 is equal to one, the result is true. If the arg2 th bit is equal to zero, the result is false. If arg2 is greater than or equal to the bit size of arg1 , the result is false. Bit positions are numbered right to left, with the rightmost bit numbered zero. BTEST(arg1, arg2 ) Examples Function Call Value Returned to i i = BTEST(3,0) .TRUE.
CMPLX Function (or CMPLX(arg1 ,arg2 )) is a speci c function that performs type conversion to a COMPLEX*8 value. CMPLX can have one or two arguments. If you specify one argument, the argument can be INTEGER*4, REAL*4, REAL*8, REAL*16, or COMPLEX*8. If you specify two arguments, the arguments must be the same type and both must be INTEGER*4, REAL*4, REAL*8, or REAL*16.
COS Function is a generic function that returns the cosine of a REAL*4, REAL*8, REAL*16, or COMPLEX*8 argument. The argument is expressed in radians. The result is the same data type as the argument. COS(arg ) Examples Function Call Value Returned to a a = COS(0.0) 1.0 a = COS(0.0628) 0.9980288 The speci c function names are COS for REAL*4 arguments, CCOS for COMPLEX*8 arguments, DCOS for REAL*8 arguments, QCOS for REAL*16 arguments, and ZCOS and CDCOS for COMPLEX*16 arguments.
COSH Function is a generic function that returns the hyperbolic cosine of a REAL*4, REAL*8, or REAL*16 argument. The result is the same data type as the argument. COSH(arg ) Examples Function Call Value Returned to a a = COSH(1.0) 1.5430807 a = COSH(3.0) 10.06766 a = COSH(3.0D0);; 10.0676619957778 The speci c function names are COSH for REAL*4 arguments, DCOSH for REAL*8 arguments, and QCOSH for REAL*16 arguments. DBLE Function is a generic function that converts the argument to REAL*8.
DCMPLX Function DCMPLX(arg ) (or DCMPLX(arg1 ,arg2 )) is a generic function that performs type conversion to a COMPLEX*16 value. DCMPLX can have one or two REAL*8 arguments. If you specify one argument, the argument can be INTEGER*4, REAL*4, REAL*8, REAL*16, or COMPLEX*8. If you specify two arguments, the arguments must be of the same type and both must be INTEGER*4, REAL*4, REAL*8, or REAL*16.
The speci c function names are DIM for REAL*4 arguments, DDIM for REAL*8 arguments, QDIM for REAL*16 arguments, IDIM and JIDIM for INTEGER*4 arguments, and HDIM and IIDIM for INTEGER*2 arguments. IDIM can also be used as a generic name of HDIM, and accept INTEGER*2 arguments.
DNUM Function is a speci c function that returns the REAL*8 value represented in the character string arg . Blanks are not signi cant in the input string. DNUM(arg ) Examples Function Call Value Returned to d8 d8 = DNUM('123.5') 123.5D0 d8 = DNUM('-99.25') -99.25D0 d8 = DNUM('327.125E75') 327.125D75 d8 = DNUM(' ') 24 5 245D0 (blanks ignored) are There is no generic name for this function.
EXP Function is a generic function that returns an exponential result (e**arg ). The argument can be REAL*4, REAL*8, REAL*16, COMPLEX*8, or COMPLEX*16. The result is the same data type as the argument. EXP(arg ) Examples Function Call Value Returned to a a = EXP(3.0) 20.08554 a = EXP(1.5D1) (3269017.37247211) a = EXP(var) (10.85226, 16.90140), (3.0, 1.
IBCLR Function is a generic function that returns arg1 with the arg2 th bit cleared (set to zero). If arg2 is greater than or equal to the bit size of arg1 , the result is equal to arg1 . The arguments and IBCLR(arg1 ,arg2 ) result are INTEGER*4. Bit positions are numbered from right to left, with the rightmost (least signi cant) bit numbered zero.
IBSET Function is a generic function that returns the value of arg1 with the arg2 th bit set to 1. If arg2 is greater than or equal to the bit size of arg1 , the result is arg1 . The arguments and the result are INTEGER*4. Bit positions are numbered from right to left, with the rightmost (least signi cant) bit numbered zero.
IEOR Function is a generic function that returns the bitwise exclusive OR of two INTEGER*4 arguments. The result is INTEGER*4. IEOR(arg1 ,arg2 ) Examples Function Call Value Returned to i i = IEOR(1, 0) 1 i = IEOR(1, 1) 0 i = IEOR(0, 0) 0 An alternate generic function name is IXOR. The speci c function names are IEOR and JIEOR for INTEGER*4 arguments and HIEOR and IIEOR for INTEGER*2 arguments. IMAG Function is a generic function that returns the imaginary part of a complex number.
INDEX Function is a speci c function that returns the location of substring arg2 within string arg1 . Both arguments must be character strings. If string arg2 occurs as a substring within string arg1 , the result is an INTEGER*4 indicating the starting position of the substring arg2 within arg1 . The character positions are numbered from left to right with the leftmost character numbered 1. If arg2 does not occur as a substring, the result is zero.
INT Function is a generic function that converts data types to INTEGER*4. The argument can be INTEGER*4, REAL*4, REAL*8, REAL*16, or COMPLEX*8; the result is INTEGER*4. If arg2 exceeds the largest integer allowed, the result is unde ned. If arg is an INTEGER*4, INT(arg ) = arg . If arg is REAL*4, REAL*8, or REAL*16 and arg is less than one, the result is zero. If arg is greater than one, the result of INT (arg ) is the INTEGER*4 with the same sign as arg whose magnitude does not exceed arg .
INUM Function is a speci c function that returns the INTEGER*2 value represented in the character string arg . Blanks are not signi cant in the input string. INUM(arg ) Examples Function Call Value Returned to i2 i2 = INUM('123') 123 i2 = INUM('-99') -99 i2 = INUM('32767') 32767 i2 = INUM(' 24 24 ') (blanks are ignored) There is no generic name for this function IOR Function is a generic function that returns the logical (bitwise) sum (Boolean OR) of two INTEGER*4 arguments.
ISHFT Function is a generic function that returns the value of arg1 shifted by arg2 bit positions. If arg2 is greater than zero, the shift is to the left; if arg2 is less than zero, the shift is to the right; if arg2 equal zero, no shift occurs. If arg is an INTEGER*2 argument and arg2 is greater than 15 or arg2 is less than -15, the result is zero. If arg2 is an INTEGER*4 and arg2 is greater than 31 or arg2 is less than 031, the result is zero. Bits shifted out from the left or right end are lost.
The speci c function names are ISHFTC and JISHFTC for INTEGER*4 arguments and HSHFTC and IISHFTC for INTEGER*2 arguments.
IXOR Function is a generic function that returns the bitwise exclusive OR of two INTEGER*4 arguments. The result is INTEGER*4. IXOR(arg1 ,arg2 ) Function Call Value Returned to i i = IXOR(1, 0) 1 i = IXOR(1, 1) 0 i = IXOR(0, 0) 0 The alternate generic function name is IEOR. The speci c function names are IEOR and JIXOR for INTEGER*4 arguments and HIEOR and IIXOR for INTEGER*2 arguments.
LEN Function is a speci c function that returns the length of a character string. The argument is type character and the result is an INTEGER*4 indicating the length of the argument. LEN(arg ) Examples Function Call Value Returned to i i = LEN('string') 6 i = LEN('howlongami') 10 There is no generic name for this function. LGE Function is a speci c function that returns a logical result indicating whether arg1 is lexically greater than or equal to arg2 . The arguments are character strings.
LGT Function is a speci c function that returns a logical result indicating whether arg1 is lexically greater than arg2 . The arguments are character strings. The result is true if arg1 follows arg2 in the ASCII collating sequence. In all other cases, the result is false. If arg1 and arg2 have unequal lengths, the shorter operand is treated as if padded on the right with blanks to the length of the longer operand.
LLT Function is a speci c function that returns a logical result indicating whether arg1 is lexically less than arg2 . The arguments are character strings. The result is true if arg1 precedes arg2 in the ASCII collating sequence. In all other cases, the result is false. If arg1 and arg2 have unequal lengths, the shorter operand is treated as if padded on the right with blanks to the length of the longer operand.
LOG10 Function is a generic function that returns the common logarithm (logarithm base 10) of a REAL*4, REAL*8, or REAL*16 argument; the argument must be greater than zero. The result is the same data type as the argument. LOG10(arg ) Examples Function Call Value Returned to a a = LOG10(6.0) 0.7781513 a = LOG10(6.0D0) 0.778151250383644 The speci c function names are ALOG10 for REAL*4 arguments, DLOG10 for REAL*8 arguments, and QLOG10 for REAL*16 arguments. MAX Function . . .
MIN Function MIN(arg1 ,arg2 [, . . . ]) is a generic function that returns the smallest value from the list of arguments. The arguments can be INTEGER*4, REAL*4, REAL*8, or REAL*16; the number of arguments can vary, but there must be at least two. The result is the same data type as the arguments. Examples Function Call Value Returned to a a = MIN(5, -2, 54, 11, 52) -2 a = MIN(5.0, 43.24, 44.1, 78.2) 5.
MVBITS Subroutine is a subroutine that moves arg3 bits starting from position arg2 of arg1 to position arg5 of arg4 . The portion of arg4 not a ected by the movement of bits remains unchanged. All arguments are INTEGER*4 expressions, except arg4, which must be an INTEGER*4 variable or array element. Arguments arg1 and arg4 can be the same numeric storage unit. The value of arg2 + arg3 cannot exceed the bit length of arg1 and the value of (arg5 + arg3 ) cannot exceed the bit length of arg4 .
NINT Function is a generic function that returns the nearest integer. The argument can be REAL*4, REAL*8, or REAL*16; the result is INTEGER*4. If arg exceeds the largest integer allowed, the result is unde ned. If the argument is positive or zero, the result is equal to INT(arg + 0.5). If the argument is negative, the result is equal to INT(arg - 0.5). NINT(arg ) Examples Function Call Value Returned to i i = NINT(123.456) 123 i = NINT(123.987) 124 i = NINT(123.5) 124 i = NINT(-123.
QEXT Function is a generic function that converts the argument to REAL*16. The argument can be INTEGER*4, REAL*4, REAL*8, REAL*16, COMPLEX*8, or COMPLEX*16. For an INTEGER*4, REAL*4, or REAL*8 argument, the result is as much precision of the signi cant part of the argument as the argument can provide. For a REAL*16 argument, the result is the argument. For a COMPLEX*8 or COMPLEX*16 argument, the result is as much precision of the signi cant real part of the argument as the argument can provide.
QPROD Function is a speci c function that returns the REAL*16 product of two REAL*8 arguments (arg1 * arg2 ). The result is a REAL*16 number with none of the fractional portion lost and is equal to QEXT(arg1 ) * QEXT(arg2 ). QPROD(arg1 ,arg2 ) Examples Function Call Value Returned to q q = QPROD(2.2d0, 2.2d0) 4.84000000000000078159700933611024 q = QPROD(1.0d0, 2.0d0) 2.0 There is no generic name for this function.
REAL Function is a generic function that converts an argument to a REAL*4 number. The argument can be INTEGER*4, REAL*4, REAL*8, REAL*16, COMPLEX*8, or COMPLEX*16. If arg is REAL*4, the result is equal to arg . If arg is INTEGER*4, REAL*8, or REAL*16 the result is as much precision of the signi cant part of arg as a REAL*4 item can contain. For a COMPLEX*8 argument (ar,ai ), the result is ar . For a COMPLEX*16 argument (ar,ai ), the result is as much signi cance of ar as a REAL*4 data item can contain.
SIGN Function is a generic function that transfers the sign from one numeric value to another. SIGN(arg1 ,arg2 ) returns the magnitude of arg1 with the sign of arg2 . The arguments can be INTEGER*4, REAL*4, REAL*8, or REAL*16. The result is the same data type as the arguments. The result is arg1 if arg2 is positive or zero, and arg1 if arg2 is negative. SIGN(arg1 ,arg2 ) Examples Function Call Value Returned to a a = SIGN(45.84, -133.0) -45.84 a = SIGN(45.84, 133.0) 45.84 a = SIGN(-45.84, -133.
SIND Function is a generic function that returns the sine of the argument. The argument is expressed in degrees and is REAL*4, REAL*8, or REAL*16. The result is the same data type as the argument. SIND(arg ) Examples Function Call Value Returned to a a = SIND(30.0) .500000 a = SIND(20.0) .342020 a = SIND(45.0D0) .7071067811865476 The speci c function names are SIND for REAL*4 arguments, DSIND for REAL*8 arguments, and QSIND for REAL*16 arguments.
SQRT Function is a generic function that returns the square root of a REAL*4, REAL*8, REAL*16, COMPLEX*8, or COMPLEX*16 argument. The result is the same data type as the argument. The argument cannot be negative for REAL*4 and REAL*8 values. SQRT(arg ) Examples Function Call Value Returned to a a = SQRT(9.0) 3.0 a = SQRT(49.0D0) 7.0 a = SQRT(var) (5.0, 0.0), where var = (25, 0.
TAND Function is a generic function that returns the tangent of the argument. The argument is expressed in degrees, and its type is REAL*4, REAL*8, or REAL*16. The result is the same data type as the argument. TAND(arg ) Examples Function Call Value Returned to a a = TAND(3.0) 0.0524078 a = TAND(3.0D1) .5773502691896257 The speci c function names are TAND for REAL*4 arguments, DTAND for REAL*8 arguments, and QTAND for REAL*16.
ZEXT Function is a generic function that returns a xed-point argument of the same size or larger without extending the sign bit of the argument. The size of the result depends on whether the SHORT directive is enabled. If SHORT is enabled, ZEXT behaves like IZEXT and returns an INTEGER*2 result. If SHORT is not enabled, ZEXT behaves like JZEXT and returns an INTEGER*4 result. (IZEXT and JZEXT are explained below.) ZEXT behaves di erently when either NOSTANDARD INTRINSICS or HP9000 300 is on.
C FORTRAN Comparisons Note This appendix makes the following comparisons: The HP FORTRAN 77 compiler is compared with the ANSI 77 standard by listing HP FORTRAN 77 extensions to the ANSI 77 standard. The HP FORTRAN 77 compiler is compared with FORTRAN 66/V. The HP FORTRAN 77 compiler is compared with FORTRAN 7X. FORTRAN 66/V has previously been known as FORTRAN/3000.
Extensions to the Standard MIL-STD-1753 Extensions HP FORTRAN 77 fully implements the ANSI 77 standard for FORTRAN. HP FORTRAN 77 also contains many extensions to this standard. This appendix categorizes and lists these extensions. Complete descriptions are given at the point in the manual where each topic is found. The HP FORTRAN 77 compiler fully implements the Military Standard De nition (MIL-STD-1753) of extensions to the ANSI 77 standard. These extensions are as follows: DO WHILE loops.
Byte length speci ed in numeric type statements, for example, INTEGER*4. (Including the byte length in CHARACTER type statements is part of the ANSI 77 standard). Compiler directives. Integer intrinsic functions cover both two-byte (INTEGER*2) and four-byte (INTEGER*4) integers. Concatenation of an item of type CHARACTER*(*). Mixed lengths among character-typed entries. Unlimited number of array dimensions (the ANSI 77 standard speci es only seven). The logical operators|.AND., .EQV., .NEQV., .NOT., .OR.
A variable of type integer can be used as a character length speci er. Dynamic arrays. Optional label in an Arithmetic IF. A tab in column 1-6 immediately followed by a digit from 1-9, and blanks or nothing before the tab character, is a line continuation. Consecutive operators are allowed if the second operator is either a unary plus (+) or minus (-). Multi-dimensioned EQUIVALENCE. A CALL can have missing arguments, which are replaced by a zero passed by value.
The following intrinsic functions are included: %LOC %REF %VAL ACOSD ACOSH AIMAX0 AIMIN0 AJMAX0 AJMIN0 ASIND ASINH ATAN2D ATAND ATANH BABS BADDRESS BBCLR BBITS BBSET BBTEST BDIM BIAND MIEOR BIOR BITEST BIXOR BJTEST BMOD BMVBITS BNOT BSHFT BSHFTC BSIGN BTEST CDABS CDCOS CDEXP CDLOG CDSIN CDSQRT COSD DACOSD DACOSH DASIND DASINH DATAN2D DATAND DATANH DBLEQ DCMPLX DCONJG DCOSD DDINT DFLOAT DFLOTI DFLOTJ DIMAG DNUM DREAL DSIND DTAND FLOATI FLOATJ HABS HBCLR HBITS HBSET HDIM HIAND HIEOR HIOR HMOD HMVBITS HNOT H
Comparison of HP FORTRAN 77 and FORTRAN 66/V C-6 FORTRAN Comparisons FORTRAN 66/V is an implementation of ANSI FORTRAN (X3.9-1966) with several extensions to the standard. Listed below are some of the di erences between FORTRAN 66/V and HP FORTRAN 77. This is not a complete list of di erences, but most of the signi cant features are compared. For more information about di erences between FORTRAN 66/V and HP FORTRAN 77, see the FORTRAN 66/V to HP FORTRAN 77/V Migration Guide .
The order of evaluating comparisons using the logical IF statement is di erent in the two compilers. The order for evaluating arithmetic expressions with two or more operators of the same precedence is di erent in the two compilers. In HP FORTRAN 77, the evaluation is right to left for exponential and left to right for all other operations. Mixed mode expressions are evaluated di erently in the two compilers.
These compiler directives and options are part of FORTRAN 66/V but not HP FORTRAN 77: CONTROL CONTROL CONTROL CONTROL CROSSREF CONTROL ALL CROSSREF CONTROL ERRORS CONTROL CONTROL FILE FIXED FREE LABEL NOLABEL CONTROL NOSTAT CONTROL SOURCE CONTROL STAT EDIT ERRORS TRACE The syntax of many compiler directives di ers between FORTRAN 66/V and HP FORTRAN 77. Also, some FORTRAN 66/V compiler directives are system dependent in FORTRAN 77 and may not be available on all operating systems.
Comparison of HP FORTRAN 77 and FORTRAN 7X Note The FORTRAN 77 Reference Manual cited in this section is the reference manual for FORTRAN 7X (FORTRAN 77 for the HP 1000 computer system), not the manual you are reading now. One of the major di erences between FORTRAN 7X and HP FORTRAN 77 is that the former can be run in an ANSI 66 mode. This capability is not part of HP FORTRAN 77. Con icts are sometimes generated regarding program execution in the two modes of FORTRAN 7X, ANSI 66 and ANSI 77.
The CALL EXIT extension is not part of HP FORTRAN 77. The FILES directive reserves room for the DCB in FORTRAN 7X. This is not necessary in HP FORTRAN 77. The directive is agged with a warning message and ignored. The ALIAS directive in HP FORTRAN 77 does not have the DIRECT, NOABORT, and NOEMA options, but does have the parameter passing information option. In FORTRAN 7X, true is equal to any negative value and false to any nonnegative value.
Record number connected to unit number (earlier-style direct-access I/O). Statement function in EXTERNAL statements as arguments. Parentheses around simple I/O lists. $ as statement separator. Storage of Hollerith constants. Unformatted I/O and paper tape length words. Refer to the FORTRAN 77 Reference Manual for a detailed description of each of the above features. The ASSIGN and the assigned GOTO statements require a 32-bit integer variable in HP FORTRAN 77. This is not a restriction in FORTRAN 7X.
D HP Character Set HP Character Set D-1
D-2 HP Character Set
HP Character Set D-3
E Indexed Sequential Access Program The following program uses indexed sequential access (ISAM) I/O. Its operation is described in comments within the program. C************************************************************************** C This program shows different indexed sequential access operations. C This program is menu driven. It creates an ISAM file with three C keys and writes some records into the file.
C************************************************************* C ADD some records C************************************************************* phone = 1231111 buf(5:15) = 'micky' buf(16:25)= 'mouse' buf(26:) = ' DISNEYLAND' WRITE (10,err=1 ) buf ! records might already be created phone = 1232222 buf(5:15) = 'donald' buf(16:25)= 'duck' buf(26:) = ' DISNEYLAND' WRITE (10) buf phone = 1233333 buf(5:15) = 'big' buf(16:25)= 'bird' buf(26:) = ' SESAME STREET' WRITE (10) buf C************************************
C************************************************************* C ADD a record C************************************************************* 100 PRINT 12 READ *,phone PRINT 13 READ (*,'(A10)') buf(16:25) PRINT 14 READ (*,'(A11)') buf(5:15) PRINT 15 READ (*,'(A55)') buf(26:80) WRITE (10,err=101) buf GOTO 1 101 PRINT *,'error in reading, try again' GOTO 1 Indexed Sequential Access Program E-3
C************************************************************* C READ a record C************************************************************* 200 PRINT *,' 1. BY PHONE NUMBER' PRINT *,' 2. BY FIRST NAME' PRINT *,' 3. BY LAST NAME' PRINT *,' ' PRINT *,' ' PRINT 11 READ *,i IF (I .EQ. 1) THEN PRINT 12 READ *,phone READ (10,keyeq=phone,keyid=0,err=212,end=211,iostat=ii) buf PRINT *,phone,' ',buf(5:) ELSEIF (I .EQ.
C************************************************************* C MODIFY a record C************************************************************* 400 modified = .false. PRINT 12 READ *,phone READ(10,keyeq=phone,err=402) buf ! default is primary key PRINT *,phone,' ',buf(5:) 401 PRINT *,' 1. first name' PRINT *,' 2. last name',ii PRINT *,' 3. project' PRINT *,' 4. exit' PRINT *,' ' PRINT 11 READ *,i IF (I. EQ. 1) THEN PRINT 13 READ (*,'(A10)') buf(16:25) modified = .true. ELSEIF (I. EQ.
C******** MENU 500 GOTO 1 C******** EXIT 600 CLOSE (10) STOP C************************************************************* C DUMP all the records in the ISAM file C************************************************************* 700 phone = 0 READ (10,keygt=phone,err=702,iostat=ii) buf ! default is primary key PRINT *, phone,' ',buf(5:76) DO i=1,100 ! reading ISAM sequentailly READ (10,err=702,end=701,iostat=ii) buf PRINT *, phone,' ',buf(5:) ENDDO GOTO 1 701 PRINT *,' number of records in the file :',(i-1),i
Index A ABORT trap action, 9-5 ABS intrinsic function, B-28 ACCEPT statement, 3-8 ACOSD intrinsic function, B-22, B-29 ACOSH intrinsic function, B-30 ACOS intrinsic function, B-22, B-29 actual arguments EXTERNAL statement, 3-71 intrinsic function, 3-102 adjustable array, 2-38 aggregate assignment statement, 3-18 AIMAG intrinsic function, B-46 AIMAX0 intrinsic function, B-56 AIMIN0 intrinsic function, B-57 AINT intrinsic function, B-21, B-30 AJMAX0 intrinsic function, B-56 AJMIN0 intrinsic function, B-57 AL
BACKSPACE, 3-20 B form of octal constant, 2-30 block DO loop, 3-49, 3-51 BLOCKSIZE, OPEN statement, 3-113 BUFFERCOUNT, OPEN statement, 3-113 BYTE data type, 2-10 BYTE statement, 2-4, 3-23 CARRIAGECONTROL, INQUIRE statement, 3-98 CARRIAGECONTROL, OPEN statement, 3-113 character, noncharacter data items, 3-70 COMMON statement, 3-32 COMPLEX*16 statement, 3-34 COMPLEX*8 statement, 3-34 computed GOTO, 3-81 consecutive operators, 2-50 DECODE statement, 2-4 DEFAULTFILE, INQUIRE statement, 3-98 DEFAULTFILE, OPEN st
KEYED, INQUIRE statement, 3-98 KEYID, READ statement, 3-130 length of symbolic names, 2-5 length speci er after item, 3-104 length speci er following item, 3-35, 3-133 length speci er, TYPE statement, 3-100 list-directed input, internal le, 4-44 list-directed output, internal le, 4-48 LOGICAL*1 data type, 2-10 LOGICAL*1 statement, 3-103, 3-104 LOGICAL*2 data type, 2-21 LOGICAL*2 statement, 3-103, 3-104 LOGICAL*4 data type, 2-22 LOGICAL*4 statement, 3-103, 3-104 logical item as operand, 2-47 logical operands
USE, INQUIRE statement, 3-98 use of & as alternate return, 3-24 USE, OPEN statement, 3-113 USEROPEN, OPEN statement, 3-113 variable as length speci cation, 3-27 VIRTUAL statement, 2-4, 3-163 WRITE operations, 3-168 X form of hexadecimal constant, 2-33 .XOR. in place of .NEQV.
asterisk array declarator, 3-46 ENTRY statement, 3-67 ** operator, 2-47 * operator, 2-47 SUBROUTINE statement, 3-136, 3-153 upper dimension bound, 2-37 ATAN2D intrinsic function, B-22, B-34 ATAN2 intrinsic function, B-22, B-33 ATAND intrinsic function, B-22, B-34 ATANH intrinsic function, B-35 ATAN intrinsic function, B-22, B-33, B-34 B BACKSPACE statement, 3-19 BADDRESS intrinsic function, B-22, B-35 basic external function trap procedure, 9-6 B form of octal constant, 2-30 binary object program, relocata
statement, 3-23 C Index-6 C and FORTRAN, 8-3 and Hollerith, 8-5 arrays, 8-3 character representation, 8-5 character variables, 8-5 complex numbers, 8-4 default character passing, 8-5 les, 8-3 logicals, 8-3 parameter passing, 8-4 CABS intrinsic function, B-18, B-28 CALL statement, 3-24 CARRIAGECONTROL INQUIRE statement, 3-98 OPEN statement, 3-113 carriage control characters, 4-5, 4-6 case IMPLICIT statement, 3-91 signi cance, 2-5 CCODE, 8-8 CCOS intrinsic function, B-38 CDABS intrinsic function, B-28 CDCO
character string nonprintable characters, 2-23 CHAR intrinsic function, B-36 CHECK ACTUAL PARM directive, 7-15 CHECK FORMAL PARM directive, 7-16 CHECK OVERFLOW directive, 7-17 circular bit shift function, B-19 CLOG intrinsic function, B-55 CLOSE statement, 3-29 CMPLX intrinsic function, B-17, B-37 CODE directive, 7-18 CODE OFFSETS directive, 7-19 collapsed implied DO loop, 3-54 colon edit descriptor, 4-36 column-major order, 2-40 column-major storage, 8-3 column sensitivities, 1-6 comma format speci cation,
COMPLEX data type, 2-19 complex numbers, 8-4 C, 8-4 COMPLEX statement, 3-34 computed GOTO statement, 3-81 concatenation operator, 2-53 condition codes, 8-8 CONJG intrinsic function, B-18, B-37 consecutive operators, 2-50 constant BYTE, 2-10 CHARACTER, 2-23 character in numeric context, 2-24 COMPLEX, 2-19 COMPLEX*16, 2-20 COMPLEX*8, 2-19 DOUBLE COMPLEX, 2-20 DOUBLE PRECISION, 2-17 hexadecimal, 2-24, 2-33 Hollerith, 2-24, 2-27 INTEGER, 2-11, 2-13 INTEGER*2, 2-11 INTEGER*4, 2-13 LOGICAL, 2-21, 2-22 LOGICAL*1,
D DABS intrinsic function, B-28 DACOSD intrinsic function, B-22, B-29 DACOSH intrinsic function, B-30 DACOS intrinsic function, B-22, B-29 DASIND intrinsic function, B-22, B-32 DASINH intrinsic function, B-32 DASIN intrinsic function, B-22, B-31 data format in memory, 10-1 DATAN2D intrinsic function, B-22, B-34 DATAN2 intrinsic function, B-22, B-33 DATAND intrinsic function, B-22 DATANH intrinsic function, B-35 DATAN intrinsic function, B-22, B-33, B-34 DATA statement, 3-37 allowed in block data subprogram
DEBUG directive, 7-26 debugging, symbolic, 7-84 debug line, 1-5 decimal point with real constant, 2-15, 2-17, 2-18 declarator dimension, 3-46 DECODE statement, 3-42 default character passing C, 8-5 default data type, 2-6 DEFAULTFILE INQUIRE statement, 3-98 OPEN statement, 3-113 default source (on MPE/iX), 6-7 DELETE statement, 3-44 denormalized, 10-5 %DESCR, ALIAS directive, 7-8 descriptor format, 3-73 list, 3-72 variable format, 3-72 DEXP intrinsic function, B-43 DFLOAT intrinsic function, B-39 diagnostic
COPYRIGHT, 7-21 CROSSREF, 7-22 DEBUG, 7-26 ELSE, 7-27 ENDIF, 7-28 EXTERNAL ALIAS, 2-6, 7-29 FTN3000 66, 7-30 FTN3000 66 CHARS, 7-30 FTN3000 66 IO, 7-31 HP1000, 7-34 IF, 7-41 INCLUDE, 7-43 INIT, 7-44 LINES, 7-45 LIST, 7-46 LIST CODE, 7-47 LITERAL ALIAS, 7-48 LOCALITY, 7-49 LONG, 7-50 LOWERCASE, 7-51, 7-92 MIXED FORMATS, 7-52 NLS SOURCE, 7-56 NOSTANDARD, 7-57 ONETRIP, 7-60 OPTIMIZE, 7-61 PAGE, 7-72 PAGEWIDTH, 7-73 RANGE, 7-75 SAVE LOCALS, 7-78 SET, 7-80 SHORT, 7-81 STANDARD LEVEL, 7-82 SUBTITLE, 7-83 SYMDEBUG
DNUM intrinsic function, B-42 dollar sign, 2-5 DO LOOP HP1000 directive option, 7-37 DO loops, 3-48 execution, 3-52, 7-60 exiting, 3-56 implied, 3-53 nesting, 3-56 range, 3-56 transfer control into, 3-56 DO statement, 3-48 double complex. See COMPLEX*16 double precision. See REAL*8 double precision format descriptors, 4-15 double quotation mark.
END MAP statement, 3-151 allowed in block data subprogram, 3-21 end-of- le record ENDFILE statement, 3-63 end-of-line edit descriptors, 4-32 END speci er READ statement, 3-130 END statement, 3-61 END STRUCTURE statement, 3-147 allowed in block data subprogram, 3-21 END UNION statement, 3-150 allowed in block data subprogram, 3-21 ENTRY statement, 3-66 .EQ. operator, 2-3 EQUIVALENCE statement, 3-69 .EQV.
external names, 2-6 EXTERNAL statement, 3-71 not allowed in block data subprogram, 3-21 F Index-14 operator, 2-3 le handling, 8-2 les, 8-3 automatically opening, 5-5 handling, 5-1 %FILL eld name in structures, 3-149 xed-point format descriptor, 4-17, 4-18 oating-point, 2-15, 2-17, 2-18 oating-point format descriptors, 4-16, 4-18 FLOAT intrinsic function, B-17, B-62 FMT speci er READ statement, 3-130 REWRITE statement, 3-141 WRITE statement, 3-168 FNUM procedure, 5-2 formal arguments ENTRY statement, 3-66
LOGICAL*4, 10-14 REAL*16, 10-8 REAL*4, 10-5 REAL*8, 10-6 format speci cations, 4-7 input/output statements, 4-9 nesting, 4-40 processing, 4-41 FORMAT statement, 3-72, 4-8 formatted input, 4-1, 4-2 formatted output, 4-4, 4-43 format designator, 4-5 PRINT statement, 3-122, 4-4 WRITE statement, 4-4 form feed, 7-72 FORTRAN 77, 1-1 and C, 8-3 character set, 2-1 compiler, 1-2 intrinsic functions, 2-6 source le, sample listing, 1-2 statement format, 3-1 terms, 1-4 vocabulary, 1-2 FORTRAN 66/V compared to HP FORTRA
G H I Index-16 operator, 2-3 gigabyte, 3-33, 3-38, 3-143 GOTO statement, 3-81 assigned, 3-82 computed, 3-81 unconditional, 3-81 group name namelist, 4-52 .GT. operator, 2-3 .GE.
IF statement, 3-84 arithmetic, 3-84 block, 3-87 logical, 3-86 IF-THEN statement, 3-87 IGNORE trap action, 9-5 IIABS intrinsic function, B-28 IIAND intrinsic function, B-43 IIBCLR intrinsic function, B-44 IIBITS intrinsic function, B-44 IIBSET intrinsic function, B-45 IIDIM intrinsic function, B-40 IIDNNT intrinsic function, B-59 IIEOR intrinsic function, B-46 IIOR intrinsic function, B-49 IIQNNT intrinsic function, B-59 IISHFTC intrinsic function, B-50 IISHFT intrinsic function, B-50 IISIGN intrinsic functi
INITIALSIZE OPEN statement, 3-113 INOT intrinsic function, B-59 input formatted, 4-1, 4-2 list-directed, 4-44 unformatted, 4-42 input bytes remaining edit descriptor, 4-35 input/output, 4-1 list-directed, 4-44 namelist-directed, 4-52 unformatted, 4-42 input statements, 4-1 INQUIRE statement, 3-94 INTEGER*2 constant, 2-11 constant I su x, 2-11 data type, 2-11 format, 10-4 statement, 3-99 INTEGER*4 constant, 2-13 constant J su x, 2-13 data type, 2-13 format, 10-4 statement, 3-99 integer constant I su x, 2-11
AMOD, B-57 ANINT, B-21, B-31 as actual argument, 3-102 ASIN, B-22, B-31 ASIND, B-22, B-32 ASINH, B-32 ATAN, B-22, B-33, B-34 ATAN2, B-22, B-33 ATAN2D, B-22, B-34 ATAND, B-22, B-34 ATAND2, B-34 ATANH, B-35 BADDRESS, B-22, B-35 BITEST, B-36 BJTEST, B-36 BTEST, B-20, B-21, B-36 CABS, B-18, B-28 CCOS, B-38 CDABS, B-28 CDCOS, B-38 CDEXP, B-43 CDLOG, B-55 CDSIN, B-63 CDSQRT, B-65 CEXP, B-43 CHAR, B-36 CLOG, B-55 CMPLX, B-17, B-37 CONJG, B-18, B-37 COS, B-22, B-38 COSD, B-22, B-38 COSH, B-39 CSIN, B-63 CSQRT, B-65
DEXP, B-43 DFLOAT, B-39 DIM, B-40 DIMAG, B-46 DINT, B-30 DLOG, B-55 DLOG10, B-56 DMAX1, B-56 DMIN1, B-57 DMOD, B-57 DNINT, B-31 DNUM, B-42 DPROD, B-42 DSIGN, B-63 DSIN, B-22, B-63 DSIND, B-22, B-64 DSINH, B-64 DTAN, B-22, B-65 DTAND, B-22, B-66 DTANH, B-66 EXP, B-43 FLOAT, B-17, B-62 generic name, B-2 HABS, B-28 HBCLR, B-44 HBITS, B-44 HBSET, B-45 HDIM, B-40 HEIOR, B-46 HIAND, B-43 HIEOR, B-52 HIOR, B-49 HMOD, B-57 HNOT, B-59 HSHFT, B-50 HSHFTC, B-50 HSIGN, B-63 HTEST, B-36 IABS, B-28 IAND, B-43 IBCLR, B-20
IIDNNT, B-59 IIEOR, B-46 IIOR, B-49 IIQNNT, B-59 IISHFT, B-50 IISHFTC, B-50 IISIGN, B-63 IIXOR, B-52 IMAG, B-46 IMAX0, B-56 IMAX1, B-56 IMIN0, B-57 IMIN1, B-57 IMOD, B-57 INDEX, B-18, B-47 ININT, B-59 INOT, B-59 INT, B-17, B-48 INUM, B-49 invoking, B-1 IOR, B-49 IQINT, B-48 IQNINT, B-59 ISHFT, B-18, B-50 ISHFTC, B-19, B-50 ISIGN, B-63 IXOR, B-18, B-46, B-52 IZEXT, B-22, B-52, B-67 JIABS, B-28 JIAND, B-43 JIBCLR, B-44 JIBITS, B-44 JIBSET, B-45 JIDIM, B-40 JIDINT, B-48 JIDNNT, B-59 JIEOR, B-46 JIFIX, B-48 JIN
LEN, B-53 LGE, B-18, B-53 LGT, B-18, B-54 LLE, B-18, B-54 LLT, B-18, B-55 LOG, B-55 LOG10, B-56 MAX, B-56 MAX0, B-56 MAX1, B-56 MIN, B-57 MIN0, B-57 MIN1, B-57 MOD, B-57 MVBITS, B-20, B-22 NINT, B-59 NOT, B-59 QABS, B-28 QACOS, B-29 QACOSD, B-29 QACOSH, B-30 QASIND, B-32 QASINH, B-32 QATAN, B-33, B-34 QATAN2, B-33 QATAN2D, B-34 QATANH, B-35 QCOS, B-38 QCOSD, B-38 QCOSH, B-39 QDIM, B-40 QEXP, B-43 QEXT, B-60 QEXTD, B-60 QINT, B-30 QLOG, B-55 QLOG10, B-56 QMAX1, B-56 QMOD, B-57 QNINT, B-31 QNUM, B-60 QPROD, B
SIN, B-22, B-63 SIND, B-64 SINH, B-64 SIZEOF, B-64 SNGL, B-62 SNGLQ, B-62 speci c name, B-2 SQRT, B-65 TAn, B-65 TAN, B-22, B-65 TAND, B-22, B-66 TANH, B-66 ZABS, B-28 ZCOS, B-38 ZEXP, B-43 ZEXT, B-22, B-67 ZSIN, B-63 ZSQRT, B-65 ZTAN, B-65 INTRINSIC statement, 3-102 not allowed in block data subprogram, 3-21 intrinsic subroutine DATE, B-23 EXIT, B-23 IDATE, B-23 MVBITS, B-20, B-58 TIME, B-25 INUM intrinsic function, B-49 IOR intrinsic function, B-49 I/O run-time errors, 9-7 IOSTAT speci er ENDFILE statemen
J K L Index-24 JIABS intrinsic function, B-28 JIAND intrinsic function, B-43 JIBCLR intrinsic function, B-44 JIBITS intrinsic function, B-44 JIBSET intrinsic function, B-45 JIDIM intrinsic function, B-40 JIDINT intrinsic function, B-48 JIDNNT intrinsic function, B-59 JIEOR intrinsic function, B-46 JIFIX intrinsic function, B-48 JINT intrinsic function, B-48 JIOR intrinsic function, B-49 JIQINT intrinsic function, B-48 JIQNNT intrinsic function, B-59 JISHFTC intrinsic function, B-50 JISHFT intrinsic func
listing, 6-8 listing format, 6-10 LITERAL ALIAS directive, 7-48 literal edit descriptors, 4-34 LLE intrinsic function, B-18, B-54 LLT intrinsic function, B-18, B-55 LOCALITY directive, 7-49 LOG10 intrinsic function, B-56 LOGICAL*1 constant, 2-10 data type, 2-10 format, 10-3 statement, 3-103 LOGICAL*1 statement, 3-104 LOGICAL*2 constant, 2-21 data type, 2-21 format, 10-13 statement, 3-103 LOGICAL*2 statement, 3-104 LOGICAL*4 constant, 2-22 data type, 2-22 format, 10-14 statement, 3-103 LOGICAL*4 statement, 3
Military Standard De nition, C-2 MIL-STD-1753 standard extension, 1-1 bit masking operations, 2-58 BTEST bit test function, B-21 DO-WHILE statement, 3-55 END DO, 2-4 END DO statement, 3-51, 3-55 hexadecimal constants, 3-38 HP FORTRAN 77, C-2 IBCLR bit clear function, B-21 IBITS bit extraction function, B-20 IBSET bit set function, B-21 IMPLICIT NONE, 3-91 INCLUDE, 2-4 INCLUDE statement, 3-93 ISHFTC, B-19 MVBITS bit move subroutine, B-20 NONE, 2-4 octal constants, 3-38 O form of octal constant, 2-30 WHILE, 2
speci er, 4-52 namelist group-name de ned by symbolic name, 2-5 NAMELIST group-name, 3-166 namelist group name, 3-140 NAMELIST statement, 3-106 NaN (not-a-number), 10-5, 10-6, 10-10 .NE. operator, 2-3 .NEQV.
O Index-28 object le creating a new, 6-2 creating a new with the BUILD command, 6-3 creating a new with the FTNXL command, 6-2 creating a new with the SAVE command, 6-2 description, 6-1 object program, relocatable, 1-2 octal constants, 2-24, 2-30 actual parameters, 2-31 assignments, 2-30 octal format descriptors, 4-23 O form of octal constant, 2-30 $OLDPASS, 6-6 $OLDPASS,with FTNXL command, 6-2 one-dimensional array, 2-36 ONETRIP directive, 7-60 ON statement, 3-107 OPEN statement, 3-109, 5-1 operands mixe
order of statements, 3-7 ORGANIZATION INQUIRE statement, 3-98 OPEN statement, 3-113 .OR.
with FTNXLLK command, 6-4 program le creating a new, 6-4 execution, 6-7 MPE/iX operating system, 6-1 program head, 7-2 PROGRAM statement, 3-124 program termination STOP statement, 3-146 program unit, 1-4 main, 1-2 statements, listed, 3-3 program units non-FORTRAN, 8-1 Q Index-30 QABS intrinsic function, B-28 QACOSD intrinsic function, B-29 QACOSH intrinsic function, B-30 QACOS intrinsic function, B-29 QASIND intrinsic function, B-32 QASINH intrinsic function, B-32 QATAN2D intrinsic function, B-34 QATAN2 i
FORMAT statements, 3-77 single.
character, 2-55 relocatable binary object program, 1-2 repeat speci cation descriptors, 3-76 format descriptors, 4-10, 4-40 RETURN statement, 3-136 REWIND statement, 3-138 REWRITE statement, 3-140 RLFILE directive, 7-76 RLINIT directive, 7-77 RNUM intrinsic function, B-62 row-major storage, 8-3 RUN command,program le execution, 6-7 running, 6-1 running the compiler, 6-7 run-time errors, 9-1, A-73 S Index-32 sample listing FORTRAN source le, 1-2 SAVE LOCALS directive, 7-78 SAVE statement, 3-143 allowed in
standard output, 4-48 standard output unit PRINT statement, 3-122, 4-5 statement function statement, 3-144 statement keywords, 2-4 statements, 3-1 ACCEPT, 3-8 aggregate assignment, 3-18 arithmetic assignment, 3-12 ASSIGN, 3-10 assignment, 3-11 BACKSPACE, 3-19 BLOCK DATA, 3-21 BYTE, 3-23 CALL, 3-24 CHARACTER, 3-26 character assignment, 3-17 classi cation of, 3-2 CLOSE, 3-29 COMMON, 3-32 COMPLEX, 3-34 COMPLEX*16, 3-34 COMPLEX*8, 3-34 CONTINUE, 3-36 control, 3-3 DATA, 3-37 DECODE, 3-42 DELETE, 3-44 DIMENSION,
INTEGER, 3-99 INTEGER*2, 3-99 INTEGER*4, 3-99 INTRINSIC, 3-102 LOGICAL, 3-103 LOGICAL*1, 3-103 LOGICAL*2, 3-103 LOGICAL*4, 3-103 logical assignment, 3-16 MAP, 3-151 NAMELIST, 3-106 nonexecutable, 3-2 ON, 3-107 OPEN, 3-109, 5-1 order of, 3-7 PARAMETER, 3-117 PAUSE, 3-121 PRINT, 3-122 PROGRAM, 3-124 program halt, 3-3 program unit, 3-3 READ, 3-126 REAL, 3-132 REAL*16, 3-132 REAL*4, 3-132 REAL*8, 3-132 RECORD, 3-135 RETURN, 3-136 REWIND, 3-138 REWRITE, 3-140 SAVE, 3-143 speci cation, 3-3 statement function, 3-1
HP1000 directive option, 7-37 structure, 2-43 structures, 2-43 %FILL, 3-149 unnamed eld, 3-149 STRUCTURE statement, 3-147 allowed in block data subprogram, 3-21 subprogram, 1-4 subprogram name EXTERNAL statement, 3-71 subprogram unit, 1-2 subroutine de ned by symbolic name, 2-5 math, B-1 SUBROUTINE statement, 3-153 subroutine subprogram SUBROUTINE statement, 3-153 subscripted variables, 2-36 subscripts, 2-39 substrings, 2-42 SUBTITLE directive, 7-83 symbolic debugging, 7-84 symbolic names, 2-4, 2-5 array, 2
IGNORE, 9-5 trap actions, 9-5 trap exiting, 9-6 trapping run-time errors, 9-1 trap procedure arithmetic, 9-5 basic external function, 9-6 Control-Y, 9-6 external function, 9-6 internal function, 9-6 system, 9-5 user interrupt, 9-6 trigonometric functions, B-18 trip count DO loop execution, 3-52 .TRUE.
USE INQUIRE statement, 3-98 OPEN statement, 3-113 user interrupt trap procedure, 9-6 USEROPEN OPEN statement, 3-113 usl le with FTNXL command, 6-2 V W X Z %VAL, ALIAS directive, 7-8 %VAL, built-in function, 8-9 value assignment statements, 3-2 value,pass by, 8-1 variable format descriptor, 3-72 variable format descriptors, 4-26 variable name type association, 3-90 variables, 2-36 VERSION directive, 7-93 VIRTUAL statement, 3-163 vocabulary FORTRAN, 1-2 VOLATILE statement, 3-164 warning messages, A-1 WARN