ANSI X3J3/90.4 1. INTRODUCTION 1.1 Purpose This standard specifies the form and establishes the interpretation of programs expressed in the FORTRAN language. The purpose of this standard is to promote portability of FORTRAN programs for use on a variety of data processing systems. 1.2 Processor The combination of a data processing system and the mechanism by which programs are transformed for use on that data processing system is called a processor in this standard. 1.3 Scope 1.3.1 Inclusions. This standard specifies: (1) The form of a program written in the FORTRAN language (2) Rules for interpreting the meaning of such a program and its data (3) The form of writing input data to be processed by such a program operating on data processing systems (4) The form of the output data resulting from the use of such a program on data processing systems 1.3.2 Exclusions. This standard does not specify: (1) The mechanism by which programs are transformed for use on a data processing system (2) The method of transcription of programs or their input or output data to or from a data processing medium (3) The operations required for setup and control of the use of programs on data processing systems (4) The results when the rules of this standard fail to establish an interpretation (5) The size or complexity of a program and its data that will exceed the capacity of any specific FORTRAN 77 Full Language Page 1-1 INTRODUCTION ANSI X3J3/90.4 data processing system or the capability of a particular processor (6) The range or precision of numeric quantities and the method of rounding of numeric results (7) The physical properties of input/output records, files, and units (8) The physical properties and implementation of storage 1.4 Conformance The requirements, prohibitions, and options specified in this standard generally refer to permissible forms and relationships for standard-conforming programs rather than for processors. The obvious exceptions are the optional output forms produced by a processor, which are not under the control of a program. The requirements, prohibitions, and options for a standard-conforming processor usually must be inferred from those given for programs. An executable program (2.4.2) conforms to this standard if it uses only those forms and relationships described herein and if the executable program has an interpretation according to this standard. A program unit (2.4) conforms to this standard if it can be included in an executable program in a manner that allows the executable program to be standard conforming. A processor conforms to this standard if it executes standard-conforming programs in a manner that fulfills the interpretations prescribed herein. A standard- conforming processor may allow additional forms and relationships provided that such additions do not conflict with the standard forms and relationships. However, a standard-conforming processor may allow additional intrinsic functions (15.10) even though this could cause a conflict with the name of an external function in a standard-conforming program. If such a conflict occurs, the processor is permitted to use the intrinsic function unless the name appears in an EXTERNAL statement within the program unit. A standard-conforming program must not use intrinsic functions that have been added by the processor. Note that a standard-conforming program must not use any forms or relationships that are prohibited by this standard, but a standard-conforming processor may allow FORTRAN 77 Full Language Page 1-2 INTRODUCTION ANSI X3J3/90.4 such forms and relationships if they do not change the proper interpretation of a standard-conforming program. Because a standard-conforming program may place demands on the processor that are not within the scope of this standard or may include standard items that are not portable, such as external procedures defined by means other than FORTRAN, conformance to this standard does not ensure that a standard-conforming program will execute consistently on all or any standard-conforming processors. 1.4.1 Subset_Conformance. This standard describes two levels of the FORTRAN language, referred to as FORTRAN and subset FORTRAN. FORTRAN is the full language. Subset FORTRAN is a subset of the full language. An executable program conforms to the subset level of this standard if it uses only those forms and relationships described herein for that level and if the executable program has an interpretation according to this standard at that level and would have the same interpretation in the full language. A program unit conforms to the subset level of this standard if it can be included in an executable program in a manner that allows the executable program to be standard conforming at that level. A subset level processor conforms to the subset level of this standard if it executes subset level standard- conforming programs in a manner that fulfills the interpretations prescribed herein for subset FORTRAN. A subset level processor may include an extension that has a form and would have an interpretation at the full level only if the extension has the interpretation provided by the full level. A subset level processor may also include extensions that do not have forms and interpretations in the full language. 1.5 Notation_Used_in_This_Standard In this standard, "must" is. to be interpreted as a requirement; conversely, "must not" is to be interpreted as a prohibition. In describing the form of FORTRAN statements or constructs, the following metalanguage conventions and symbols are used: (1) Special characters from the FORTRAN character set, uppercase letters, and uppercase words are FORTRAN 77 Full Language Page 1-3 INTRODUCTION ANSI X3J3/90.4 to be written as shown, except where otherwise noted. (2) Lowercase letters and lowercase words indicate general entities for which specific entities must be substituted in actual statements. Once a given lowercase letter or word is used in a syntactic specification to represent an entity, all subsequent occurrences of that letter or word represent the same entity until that letter or word is used in a subsequent syntactic specification to represent a different entity. (3) Brackets, [ ], are used to indicate optional items. (4) An ellipsis, ... , indicates that the preceding optional items may appear one or more times in succession. (5) Blanks are used to improve readability, but unless otherwise noted have no significance. (6) Words or groups of words that have special significance are underlined where their meaning is described. Titles and the metalanguage symbols described in 1.5(2) are also underlined. An example illustrates the metalanguage. Given a description of the form of a statement as: CALL sub___ [( [a_ [,a_]...] )] the following forms are allowed: CALL sub___ CALL sub___ () CALL sub___ (a_) CALL sub___ (a_, a_) CALL sub___ (a_, a_, a_) etc When an actual statement is written, specific entities are substituted for sub and each a_; for example: CALL ABCD (X,1.0) FORTRAN 77 Full Language Page 1-4 INTRODUCTION ANSI X3J3/90.4 1.6 Subset_Text The section titles in the subset description are identical to the section titles in the full language description. There are some instances in which a general situation occurs in the full language but only a restricted case applies to the subset. For example, in 3.6, the "nonexecutable statements" that may appear between executable statements may only be FORMAT statements in the subset. In most of these instances, the more general text of the full language description has been retained in the subset description, even though it is to be interpreted as covering only the restricted case. To help find differences between the full and subset languages, vertical bars have been added in the margins where the text of the full and subset languages differ. For example, this sentence does not appear in the subset language text. FORTRAN 77 Full Language Page 1-5 CONTENTS 1. INTRODUCTION.................................. 1-1 1.1 Purpose.................................. 1-1 1.2 Processor................................ 1-1 1.3 Scope.................................... 1-1 1.3.1 Inclusions........................ 1-1 1.3.2 Exclusions........................ 1-1 1.4 Conformance.............................. 1-2 1.4.1 Subset Conformance................ 1-3 1.5 Notation Used in This Standard........... 1-3 1.6 Subset Text.............................. 1-5 - i - ANSI X3J3/90.4 2. FORTRAN_TERMS_AND_CONCEPTS This section introduces basic terminology and concepts, some of which are clarified further in later sections. Many terms and concepts of more specialized meaning are also introduced in later sections. The underlined words are described here and used throughout this standard. 2.1 Sequence A sequence is a set ordered by a one-to-one correspondence with the numbers 1, 2, through n_. The number of elements in the sequence is n_. A sequence may be empty, in which case it contains no elements. The elements of a nonempty sequence are referred to as the first element, second element, etc. The n_th element, where n_ is the number of elements in the sequence, is called the last element. An empty sequence has no first or last element. 2.2 Syntactic_Items Letters, digits, and special characters of the FORTRAN character set (3.1) are used to form the syntactic items of the FORTRAN language. The basic syntactic items of the FORTRAN language are constants, symbolic names, statement labels, keywords, operators, and special characters. The form of a constant is described in Section 4. A symbolic name takes the form of a sequence of one to six letters or digits, the first of which must be a letter. Classification of symbolic names and restrictions on their use are described in Section 18. A statement label takes the form of a sequence of one to five digits, one of which must be nonzero, and is used to identify a statement (3.4). A keyword takes the form of a specified sequence of letters. The keywords that are significant in the FORTRAN language are described in Sections 7 through 16. In many instances, a keyword or a portion of a keyword also meets the requirements for a symbolic name. Whether a particular sequence of characters identifies a keyword or a symbolic name is implied by context. There is no sequence of characters that is reserved in all contexts in FORTRAN. FORTRAN 77 Full Language Page 2-1 FORTRAN TERMS AND CONCEPTS ANSI X3J3/90.4 The set of special characters is described in 3.1.4. A special character may be an operator or part of a constant or have some other special meaning. The interpretation is implied by context. 2.3 Statements,_Comments,_and_Lines A FORTRAN statement is a sequence of syntactic items, as described in Sections 7 through 16. Except for assignment and statement function statements, each statement begins with a keyword. In this standard, the keyword or keywords that begin the statement are used to identify that statement. For example, a DATA statement begins with the keyword DATA. A statement is written in one or more lines, the first of which is called an initial line (3.2.2); succeeding lines, if any, are called continuation lines (3.2.3). There is also a line called a comment line (3.2.1), which is not part of any statement and is intended to provide documentation. 2.3.1 Classes_of_Statements. Each statement is classified as executable or nonexecutable (Section 7). Executable statements specify actions. Nonexecutable statements describe the characteristics, arrangement, and initial values of data; contain editing information; specify statement functions; classify program units; and specify entry points within subprograms. 2.4 Program_Units_and_Procedures A program unit consists of a sequence of statements and optional comment lines. A program unit is either a main program or a subprogram. A main program is a program unit that does not have a FUNCTION, SUBROUTINE, or BLOCK DATA statement as its first statement; it may have a PROGRAM statement as its first statement. A subprogram is a program unit that has a FUNCTION, SUBROUTINE, or BLOCK DATA statement as its first statement. A subprogram whose first statement is a FUNCTION statement is called a function subprogram. A subprogram whose first statement is a SUBROUTINE statement is called a subroutine subprogram. Function subprograms and subroutine subprograms are called procedure subprograms. A subprogram whose first FORTRAN 77 Full Language Page 2-2 FORTRAN TERMS AND CONCEPTS ANSI X3J3/90.4 statement is a BLOCK DATA statement is called a block data subprogram. 2.4.1 Procedures. Subroutines (15.6), external functions (15.5), statement functions (15.4), and the intrinsic functions (15.3) are called procedures. Subroutines and external functions are called external procedures. Function subprograms and subroutine subprograms may specify one or more external functions and subroutines, respectively (15.7). External procedures may also be specified by means other than FORTRAN subprograms. 2.4.2 Executable_Program. An executable program is a collection of program units that consists of exactly one main program and any number, including none, of subprograms and external procedures. 2.5 Variable A variable is an entity that has both a name and a type. A variable name is a symbolic name of a datum. Such a datum may be identified, defined (2.11), and referenced (2.12). Note that the usage in this standard of the word "variable" is more restricted than its normal usage, in that it does not include array elements. The type of a variable is optionally specified by the appearance of the variable name in a type-statement (8.4). If it is not so specified, the type of a variable is implied by the first letter of the variable name to be integer or real (4.1.2), unless the initial letter type implication is changed by the use of an IMPLICIT statement (8.5). At any given time during the execution of an executable program, a variable is either defined or undefined (2.11). 2.6 Array An array is a nonempty sequence of data that has a name and a type. The name of an array is a symbolic name. 2.6.1 Array_Elements. Each of the elements of an array is called an array element. An array name qualified by a subscript is an array element name and identifies a particular element of the array (5.3). Such a datum may be identified, defined (2.11), and referenced (2.12). The number of array elements in an FORTRAN 77 Full Language Page 2-3 FORTRAN TERMS AND CONCEPTS ANSI X3J3/90.4 array is specified by an array declarator (5.1). An array element has a type. The type of all array elements within an array is the same, and is optionally specified by the appearance of the array name in a type-statement (8.4). If it is not so specified, the type of an array element is implied by the first letter of the array name to be integer or real (4.1.2), unless the initial letter type implication is changed by the use of an IMPLICIT statement (8.5). At any given time during the execution of an executable program, an array element is either defined or undefined (2.11). 2.7 Substring A character datum is a nonempty sequence of characters. A substring is a contiguous portion of a character datum. The form of a substring name used to identify, define (2.11), or reference (2.12) a substring is described in 5.7.1. At any given time during the execution of an executable program, a substring is either defined or undefined (2.11). 2.8 Dummy_Argument A dummy argument in a procedure is either a symbolic name or an asterisk. A symbolic name dummy argument identifies a variable, array, or procedure that becomes associated (2.14) with an actual argument of each reference (2.12) to the procedure (15.2, 15.4.2, 15.5.2, and 15.6.2). An asterisk dummy argument indicates that the corresponding actual argument is an alternate return specifier (15.6.2.3, 15.8.3, and 15.9.3.5). Each dummy argument name that is classified as a variable, array, or dummy procedure may appear wherever an actual name of the same class (Section 18) and type may appear, except where explicitly prohibited. 2.9 Scope_of_Symbolic_Names_and_Statement_Labels The scope of a symbolic name (18.1) is an executable program, a program unit, a statement function statement, or an implied-DO list in a DATA statement. FORTRAN 77 Full Language Page 2-4 FORTRAN TERMS AND CONCEPTS ANSI X3J3/90.4 The name of the main program and the names of block data subprograms, external functions, subroutines, and common blocks have a scope of an executable program. The names of variables, arrays, constants, statement functions, intrinsic functions, and dummy procedures have a scope of a program unit. The names of variables that appear as dummy arguments in a statement function statement have a scope of that statement. The names of variables that appear as the DO-variable of an implied-DO in a DATA statement have a scope of the implied-DO list. Statement labels have a scope of a program unit. 2.10 List A list is a nonempty sequence (2.1) of syntactic entities separated by commas. The entities in the list are called list items. 2.11 Definition_Status At any gi ven time during the execution of an executable program, the definition status of each variable, array element, or substring is either defined or undefined (Section 17). A defined entity has a value. The value of a defined !entity does not change until the entity becomes undefined or is redefined with a different value. If a variable, array element, or substring is undefined, it does not have a predictable value. A previously defined variable or array element may become undefined. Subsequent definition of a defined variable or array element is permitted, except where it is explicitly prohibited. A character variable, character array element, or character substring is defined if every substring of length one of the entity is defined. Note that if a string is defined, every substring of the string is defined, and if any substring of the string is undefined, the string is undefined. Defining any substring does not cause any other string or substring to become undefined. FORTRAN 77 Full Language Page 2-5 FORTRAN TERMS AND CONCEPTS ANSI X3J3/90.4 An entity is initially defined if it is assigned a value in a DATA statement (Section 9). Initially defined entities are in the defined state at the beginning of execution of an executable program. All variables and array elements not initially defined, or associated (2.14) with an initially defined entity, are undefined at the beginning of execution of an executable program. An entity must be defined at the time a reference to it is executed. 2.12 Reference A variable, array element, or substring reference is the appearance of a variable, array element, or substring name, respectively, in a statement in a context requiring the value of that entity to be used during the execution of the executable program. When a reference to an entity is executed, its current value is available. In this standard, the act of defining an entity is not considered a reference to that entity. A procedure reference is the appearance of a procedure name in a statement in a context that requires the actions specified by the procedure to be executed during the execution of the executable program. When a procedure reference is executed, the procedure must be available. 2.13 Storage A storage sequence is a sequence of storage units. A storage unit is either a numeric storage unit or a character storage unit. An integer, real, or logical datum has one numeric storage unit in a storage sequence. A double precision or complex datum has two numeric storage units in a storage sequence. A character datum has one character storage unit in a storage sequence for each character in the datum. This standard does not specify a relationship between a numeric storage unit and a character storage unit. If a datum requires more than one storage unit in a storage sequence, those storage units are consecutive. The concept of a storage sequence is used to describe relationships that exist among variables, array elements, arrays, substrings, and common blocks. This FORTRAN 77 Full Language Page 2-6 FORTRAN TERMS AND CONCEPTS ANSI X3J3/90.4 standard does not specify a relationship between the storage sequence concept and the physical properties or implementation of storage. 2.14 Association Association of entities exists if the same datum may be identified by different symbolic names in the same program unit, or by the same name or a different name in different program units of the same executable program (17.1). Entities may become associated by the following: (1) Common association (8.3.4) (2) Equivalence association (8.2.2) (3) Argument association (15.9.3) (4) Entry association (15.7.3) FORTRAN 77 Full Language Page 2-7 CONTENTS 2. FORTRAN TERMS AND CONCEPTS.................... 2-1 2.1 Sequence................................ 2-1 2.2 Syntactic Items......................... 2-1 2.3 Statements, Comments, and Lines......... 2-2 2.3.1 Classes of Statements............ 2-2 2.4 Program Units and Procedures............ 2-2 2.4.1 Procedures....................... 2-3 2.4.2 Executable Program............... 2-3 2.5 Variable................................ 2-3 2.6 Array................................... 2-3 2.6.1 Array Elements................... 2-3 2.7 Substring............................... 2-4 2.8 Dummy Argument.......................... 2-4 2.9 Scope of Symbolic Names and Statement Labels.................................. 2-4 2.10 List.................................... 2-5 2.11 Definition Status....................... 2-5 2.12 Reference............................... 2-6 2.13 Storage................................. 2-6 2.14 Association............................. 2-7 - i - ANSI X3J3/90.4 3. CHARACTERS,_LINES,_AND_EXECUTION_SEQUENCE 3.1 FORTRAN_Character_Set The FORTRAN character set consists of twenty-six letters, ten digits, and thirteen special characters. 3.1.1 Letters. A letter is one of the twenty-six characters: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 3.1.2 Digits. A digit is one of the ten characters: 0 1 2 3 4 5 6 7 8 9 A string of digits is interpreted in the decimal base number system when a numeric interpretation is appropriate. 3.1.3 Alphanumeric_Characters. An alphanumeric character is a letter or a digit. 3.1.4 Special_Characters. A special character is one of the thirteen characters: 8 __________________________________ Character Name of Character 8 __________________________________ Blank 8 _________________9 Equals + Plus - Minus * Asterisk / Slash ( Left Parenthesis ) Right Parenthesis , Comma $ Currency Symbol ' Apostrophe : Colon 8 __________________________________ 7 |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7| 3.1.5 Collating_Sequence_and_Graphics. The order in which the letters are listed in 3.1.1 specifies the collating sequence for the letters; A is less than Z. The order in which the digits are listed in 3.1.2 specifies the collating sequence for the digits; 0 is less than 9. The digits and letters must not be intermixed in the collating sequence; all of the digits must precede A or all of the digits must follow Z. The 9 FORTRAN 77 Full Language Page 3-1 CHARACTERS, LINES, AND EXECUTION SEQUENCEANSI X3J3/90.4 character blank is less than the letter A and less than the digit 0. The order in which the special characters are listed in 3.1.4 does not imply a collating sequence. Except for the currency symbol, the graphics used for the forty-nine characters must be as given in 3.1.1, 3.1.2, and 3.1.4. However, the style of any graphic is not specified. 3.1.6 Blank_Character. With the exception of the uses specified (3.2.2, 3.2.3, 3.3, 4.8, 4.8.1, 13.5.1, and 13.5.2), a blank character within a program unit has no meaning and may be used to improve the appearance of the program unit, subject to the restriction on the number of consecutive continuation lines (3.3). 3.2 Lines A line in a program unit is a sequence of 72 characters. All characters must be from the FORTRAN character set, except as described in 3.2.1, 4.8, 12.2.2, and 13.2.1. The character positions in a line are called columns and are numbered consecutively 1, 2, through 72. The number indicates the sequential position of a character in the line, beginning at the left and proceeding to the right. Lines are ordered by the sequence in which they are presented to the processor. Thus, a program unit consists of a totally ordered set of characters. 3.2.1 Comment_Line. A comment line is any line that contains a C or an asterisk in column 1, or contains only blank characters in columns 1 through 72. A comment line that contains a C or an asterisk in column 1 may contain any character capable of representation in the processor in columns 2 through 72. A comment line does not affect the executable program in any way and may be used to provide documentation. Comment lines may appear anywhere in the program unit. Comment lines may precede the initial line of the first statement of any program unit. Comment lines may appear between an initial line and its first continuation line or between two continuation lines. 3.2.2 Initial_Line. An initial line is any line that is not a comment line and contains the character blank or the digit 0 in column 6. Columns 1 through 5 may FORTRAN 77 Full Language Page 3-2 CHARACTERS, LINES, AND EXECUTION SEQUENCEANSI X3J3/90.4 contain a statement label (3.4), or each of the columns 1 through 5 must contain the character blank. 3.2.3 Continuation_Line. A continuation line is any line that contains any character of the FORTRAN character set other than the character blank or the digit 0 in column 6 and contains only blank characters in columns 1 through 5. A statement must not have more than nineteen continuation lines. 3.3 Statements The statements of the FORTRAN language are described in Sections 7 through 16 and are used to form program units. Each statement is written in columns 7 through 72 of an initial line and as many as nineteen continuation lines. An END statement is written only in columns 7 through 72 of an initial line. No other statement in a program unit may have an initial line that appears to be an END statement. Note that a statement must contain no more than 1320 characters. Except as part of a logical IF statement (11.5), no statement may begin on a line that contains any part of the previous statement. Blank characters preceding, within, or following a statement do not change the interpretation of the statement, except when they appear within the datum strings of character constants or the H or apostrophe edit descriptors in FORMAT statements. However, blank characters do count as characters in the limit of total characters allowed in any one statement. 3.4 Statement_Labels Statement labels provide a means of referring to individual statements. Any statement may be labeled, but only labeled executable statements and FORMAT statements may be referred to by the use of statement labels. The form of a statement label is a sequence of one to five digits, one of which must be nonzero. The statement label may be placed anywhere in columns 1 through 5 of the initial line of the statement. The same statement label must not be given to more than one statement in a program unit. Blanks and leading zeros are not significant in distinguishing between statement labels. FORTRAN 77 Full Language Page 3-3 CHARACTERS, LINES, AND EXECUTION SEQUENCEANSI X3J3/90.4 3.5 Order_of_Statements_and_Lines A PROGRAM statement may appear only as the first statement of a main program. The first statement of a subprogram must be either a FUNCTION, SUBROUTINE, or BLOCK DATA statement. Within a program unit that permits the statements: (1) FORMAT statements may appear anywhere; (2) all specification statements must precede all DATA statements, statement function statements, and executable statements; (3) all statement function statements must precede all executable statements; (4) DATA statements may appear anywhere after the specification statements; and (5) ENTRY statements may appear anywhere except between a block IF statement and its corresponding END IF statement, or between a DO statement and the terminal statement of its DO- loop. Within the specification statements of a program unit, IMPLICIT statements must precede all other specification statements except PARAMETER statements. Any specification statement that specifies the type of a symbolic name of a constant must precede the PARAMETER statement that defines that particular symbolic name of a constant; the PARAMETER statement must precede all other statements containing the symbolic names of constants that are defined in the PARAMETER statement. The last line of a program unit must be an END statement. FORTRAN 77 Full Language Page 3-4 CHARACTERS, LINES, AND EXECUTION SEQUENCEANSI X3J3/90.4 Figure 1 Required Order of Statements and Comment Lines 8 _______________________________________________________ PROGRAM, FUNCTION, SUBROUTINE, or BLOCK DATA Statement 8 _____________________________________________ IMPLICIT Statements PARAMETER8 _________________ 9 Comment FORMAT Statements Other Lines and Specification ENTRY Statements Statements8 _______________________________ 9 Statement Function DATA Statements Statements8 _________________ 9 Executable |8|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|999999999999999999999999999999999 |7|7|7|7|7|7|7|7|7|7|7|7|7|99999999999999999999999999 |7|7|7|7|7|7|7|7|7|7|7|7|7|99999999999999999999999999 Statements 8 _______________________________________________________ END Statement 8 _______________________________________________________ 7 |8|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7| 9 |8|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7| 9 Figure 1 is a diagram of the required order of statements and comment lines for a program unit. Vertical lines delineate varieties of statements that may be interspersed. For example, FORMAT statements may be interspersed with statement function statements and executable statements. Horizontal lines delineate varieties of statements that must not be interspersed. For example, statement function statements must not be interspersed with executable statements. Note that an END statement is also an executable statement and must appear only as the last statement of a program unit. 3.6 Normal_Execution_Sequence_and_Transfer_of_Control Normal execution sequence is the execution of executable statements in the order in which they appear in a program unit. Execution of an executable program begins with the execution of the first executable statement of the main program. When an external procedure specified in a subprogram is referenced, execution begins with the first executable statement that follows the FUNCTION, SUBROUTINE, or ENTRY statement that specifies the referenced procedure as the name of a procedure. FORTRAN 77 Full Language Page 3-5 CHARACTERS, LINES, AND EXECUTION SEQUENCEANSI X3J3/90.4 A transfer of control is an alteration of the normal execution sequence. Statements that may cause a transfer of control are: (1) GO TO (2) Arithmetic IF (3) RETURN (4) STOP (5) An input/output statement containing an error specifier or end-of-file specifier (6) CALL with an alternate return specifier (7) A logical IF statement containing any of the above forms (8) Block IF and ELSE IF (9) The last statement, if any, of an IF-block or ELSE IF-block (10) DO (11) The terminal statement of a DO-loop (12) END The effect of these statements on the execution sequence is described in Sections 11, 12, and 15. The normal execution sequence is not affected by the appearance of nonexecutable statements or comment lines between executable statements. Execution of a function reference or a CALL statement is not considered a transfer of control in the program unit that contains the reference, except when control is returned to a statement identified by an alternate return specifier in a CALL statement. Execution of a RETURN or END statement in a referenced procedure, or execution of a transfer of control within a referenced procedure, is not considered a transfer of control in the program unit that contains the reference. In the execution of an executable program, a procedure subprogram must not be referenced a second time without the prior execution of a RETURN or END statement in that procedure. FORTRAN 77 Full Language Page 3-6 CHARACTERS, LINES, AND EXECUTION SEQUENCEANSI X3J3/90.4 FORTRAN 77 Full Language Page 3-7 CONTENTS 3. CHARACTERS, LINES, AND EXECUTION SEQUENCE..... 3- 1 3.1 FORTRAN Character Set.................... 3-1 3.1.1 Letters........................... 3-1 3.1.2 Digits............................ 3-1 3.1.3 Alphanumeric Characters........... 3-1 3.1.4 Special Characters................ 3-1 3.1.5 Collating Sequence and Graphics.......................... 3-1 3.1.6 Blank Character................... 3-2 3.2 Lines.................................... 3-2 3.2.1 Comment Line...................... 3-2 3.2.2 Initial Line...................... 3-2 3.2.3 Continuation Line................. 3-3 3.3 Statements............................... 3-3 3.4 Statement Labels......................... 3-3 3.5 Order of Statements and Lines............ 3-4 3.6 Normal Execution Sequence and Transfer of Control............................... 3-5 - i - ANSI X3J3/90.4 4. DATA_TYPES_AND_CONSTANTS 4.1 Data_Types The six types of data are: (1) Integer (2) Real (3) Double precision (4) Complex (5) Logical (6) Character Each type is different and may have a different internal representation. The type may affect the interpretation of the operations involving the datum. 4.1.1 Data_Type_of_a_Name. The name employed to identify a datum or a function also identifies its data type. A symbolic name representing a constant, variable, array, or function (except a generic function) must have only one type for each program unit. Once a particular name is identified with a particular type in a program unit, that type is implied for any usage of the name in the program unit that requires a type. 4.1.2 Type_Rules_for_Data_and_Procedure_Identifiers. A symbolic name that identifies a constant, variable, array, external function, or statement function may have its type specified in a type-statement (8.4) as integer, real, double precision, complex, logical, or character. In the absence of an explicit declaration in a type-statement, the type is implied by the first letter of the name. A first letter of I, J, K, L, M, or N implies type integer and any other letter implies type real, unless an IMPLICIT statement (8.5) is used to change the default implied type. The data type of an array element name is the same as the type of its array name. The data type of a function name specifies the type of the datum supplied by the function reference in an expression. FORTRAN 77 Full Language Page 4-1 DATA TYPES AND CONSTANTS ANSI X3J3/90.4 A symbolic name that identifies a specific intrinsic function in a program unit has a type as specified in 15.10. An explicit type-statement is not required; however, it is permitted. A generic function name does not have a predetermined type; the result of a generic function reference assumes a type that depends on the type of the argument, as specified in 15.10. If a generic function name appears in a type-statement, such an appearance is not sufficient by itself to remove the generic properties from that function. In a program unit that contains an external function reference, the type of the function is determined in the same manner as for variables and arrays. The type of an external function is specified implicitly by its name, explicitly in a FUNCTION statement, or explicitly in a type-statement. Note that an IMPLICIT statement within a function subprogram may affect the type of the external function specified in the subprogram. A symbolic name that identifies a main program, subroutine, common block, or block data subprogram has no data type. 4.1.3 Data_Type_Properties. The mathematical and representation properties for each of the data types are specified in the following sections. For real, double precision, and integer data, the value zero is considered neither positive nor negative. The value of a signed zero is the same as the value of an unsigned zero. 4.2 Constants A constant is an arithmetic constant, logical constant, or character constant. The value of a constant does not change. Within an executable program, all constants that have the same form have the same value. 4.2.1 Data_Type_of_a_Constant. The form of the string representing a constant specifies both its value and data type. A PARAMETER statement (8.6) allows a constant to be given a symbolic name. The symbolic name of a constant must not be used to form part of another constant. 4.2.2 Blanks_in_Constants. Blank characters occurring in a constant, except in a character constant, have no effect on the value of the constant. FORTRAN 77 Full Language Page 4-2 DATA TYPES AND CONSTANTS ANSI X3J3/90.4 4.2.3 Arithmetic_Constants. Integer, real, double precision, and complex constants are arithmetic constants. 4.2.3.1 Signs_of_Constants. An unsigned constant is a constant without a leading sign. A signed constant is a constant with a leading plus or minus sign. An optionally signed constant is a constant that may be either signed or unsigned. Integer, real, and double precision constants may be optionally signed constants, except where specified otherwise. 4.3 Integer_Type An integer datum is always an exact representation of an integer value. It may assume a positive, negative, or zero value. It may assume only an integral value. An integer datum has one numeric storage unit in a storage sequence. 4.3.1 Integer_Constant. The form of an integer constant is an optional sign followed by a nonempty string of digits. The digit string is interpreted as a decimal number. 4.4 Real_Type A real datum is a processor approximation to the value of a real number. It may assume a positive, negative, or zero value. A real datum has one numeric storage unit in a storage sequence. 4.4.1 Basic_Real_Constant. The form of a basic real constant is an optional sign, an integer part, a decimal point, and a fractional part, in that order. Both the integer part and the fractional part are strings of digits; either of these parts may be omitted but not both. A basic real constant may be written with more digits than a processor will use to approximate the value of the constant. A basic real constant is interpreted as a decimal number. 4.4.2 Real_Exponent. The form of a real exponent is the letter E followed by an optionally signed integer constant. A real exponent denotes a power of ten. 4.4.3 Real_Constant. The forms of a real constant are: (1) Basic real constant FORTRAN 77 Full Language Page 4-3 DATA TYPES AND CONSTANTS ANSI X3J3/90.4 (2) Basic real constant followed by a real exponent (3) Integer constant followed by a real exponent The value of a real constant that contains a real exponent is the product of the constant that precedes the E and the power of ten indicated by the integer following the E. The integer constant part of form (3) may be written with more digits than a processor will use to approximate the value of the constant. 4.5 Double_Precision_Type A double precision datum is a processor approximation to the value of a real number. The precision, although not specified, must be greater than that of type real. A double precision datum may assume a positive, negative, or zero value. A double precision datum has two consecutive numeric storage units in a storage sequence. 4.5.1 Double_Precision_Exponent. The form of a double precision exponent is the letter D followed by an optionally signed integer constant. A double precision exponent denotes a power of ten. Note that the form and interpretation of a double precision exponent are identical to those of a real exponent, except that the letter D is used instead of the letter E. 4.5.2 Double_Precision_Constant. The forms of a double precision constant are: (1) Basic real constant followed by a double precision exponent (2) Integer constant followed by a double precision exponent The value of a double precision constant is the product of the constant that precedes the D and the power of ten indicated by the integer following the D. The integer constant part of form (2) may be written with more digits than a processor will use to approximate the value of the constant. 4.6 Complex_Type A complex datum is a processor approximation to the value of a complex number. The representation of a complex datum is in the form of an ordered pair of real data. The first of the pair represents the real part FORTRAN 77 Full Language Page 4-4 DATA TYPES AND CONSTANTS ANSI X3J3/90.4 of the complex datum and the second represents the imaginary part. Each part has the same degree of approximation as for a real datum. A complex datum has two consecutive numeric storage units in a storage sequence; the first storage unit is the real part and the second storage unit is the imaginary part. 4.6.1 Complex_Constant. The form of a complex constant is a left parenthesis followed by an ordered pair of real or integer constants separated by a comma, and followed by a right parenthesis. The first constant of the pair is the real part of the complex constant and the second is the imaginary part. 4.7 Logical_Type A logical datum may assume only the values true or false. A logical datum has one numeric storage unit in a storage sequence. 4.7.1 Logical_Constant. The forms and values of a logical constant are: 8 _________________ Form Value 8 _________________ .TRUE. true .FALSE. false 8 _________________ 7 |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| 4.8 Character_Type A character datum is a string of characters. The string may consist of any characters capable of representation in the processor. The blank character is valid and significant in a character datum. The length of a character datum is the number of characters in the string. A character datum has one character storage unit in a storage sequence for each character in the string. Each character in the string has a character position that is numbered consecutively 1, 2, 3, etc. The number indicates the sequential position of a character in the string, beginning at the left and proceeding to the right. 9 FORTRAN 77 Full Language Page 4-5 DATA TYPES AND CONSTANTS ANSI X3J3/90.4 4.8.1 Character_Constant. The form of a character constant is an apostrophe followed by a nonempty string of characters followed by an apostrophe. The string may consist of any characters capable of representation in the processor. Note that the delimiting apostrophes are not part of the datum represented by the constant. An apostrophe within the datum string is represented by two consecutive apostrophes with no intervening blanks. In a character constant, blanks embedded between the delimiting apostrophes are significant. The length of a character constant is the number of characters between the delimiting apostrophes, except that each pair of consecutive apostrophes counts as a single character. The delimiting apostrophes are not counted. The length of a character constant must be greater than zero. FORTRAN 77 Full Language Page 4-6 CONTENTS 4. DATA TYPES AND CONSTANTS...................... 4-1 4.1 Data Types............................... 4-1 4.1.1 Data Type of a Name............... 4-1 4.1.2 Type Rules for Data and Procedure Identifiers....................... 4-1 4.1.3 Data Type Properties.............. 4-2 4.2 Constants................................ 4-2 4.2.1 Data Type of a Constant........... 4-2 4.2.2 Blanks in Constants............... 4-2 4.2.3 Arithmetic Constants.............. 4-3 4.3 Integer Type............................. 4-3 4.3.1 Integer Constant.................. 4-3 4.4 Real Type................................ 4-3 4.4.1 Basic Real Constant............... 4-3 4.4.2 Real Exponent..................... 4-3 4.4.3 Real Constant..................... 4-3 4.5 Double Precision Type.................... 4-4 4.5.1 Double Precision Exponent......... 4-4 4.5.2 Double Precision Constant......... 4-4 4.6 Complex Type............................. 4-4 4.6.1 Complex Constant.................. 4-5 4.7 Logical Type............................. 4-5 4.7.1 Logical Constant.................. 4-5 4.8 Character Type........................... 4-5 4.8.1 Character Constant................ 4-6 - i - ANSI X3J3/90.4 5. ARRAYS_AND_SUBSTRINGS An array is a nonempty sequence of data. An array element is one member of the sequence of data. An array name is the symbolic name of an array. An array element name is an array name qualified by a subscript (5.3). An array name not qualified by a subscript identifies the entire sequence of elements of the array in certain forms where such use is permitted (5.6); however, in an EQUIVALENCE statement, an array name not qualified by a subscript identifies the first element of the array (8.2.4). An array element name identifies one element of the sequence. The subscript value (Table 1) specifies the element of the array being identified. A different array element may be identified by changing the subscript value of the array element name. An array name is local to a program unit (18.1.2). A substring is a contiguous portion of a character datum. 5.1 Array_Declarator An array declarator specifies a symbolic name that identifies an array within a program unit and specifies certain properties of the array. Only one array declarator for an array name is permitted in a program unit. 5.1.1 Form_of_an_Array_Declarator. The form of an array declarator is: a_ (d_ [,d_]...) where: a_ is the symbolic name of the array d_ is a dimension declarator The number of dimensions of the array is the number of dimension declarators in the array declarator. The minimum number of dimensions is one and the maximum is seven. 5.1.1.1 Form_of_a_Dimension_Declarator. The form of a dimension declarator is: FORTRAN 77 Full Language Page 5-1 ARRAYS AND SUBSTRINGS ANSI X3J3/90.4 [d_918:] d_92 9 where: d_918 is the lower dimension bound d_928 is the upper dimension bound The lower and upper dimension bounds are arithmetic expressions, called dimension bound expressions, in which all constants, symbolic names of constants, and variables are of type integer. The upper dimension bound of the last dimension may be an asterisk in assumed-size array declarators (5.1.2). A dimension bound expression must not contain a function or array element reference. Integer variables may appear in dimension bound expressions only in adjustable array declarators (5.1.2). If the symbolic name of a constant or variable that appears in a dimension bound expression is not of default implied integer type (4.1.2), it must be specified as integer by an IMPLICIT statement or a type-statement prior to its appearance in a dimension bound expression. 5.1.1.2 Value_of_Dimension_Bounds. The value of either dimension bound may be positive, negative, or zero; however, the value of the upper dimension bound must be greater than or equal to the value of the lower dimension bound. If only the upper dimension bound is specified, the value of the lower dimension bound is one. An upper dimension bound of an asterisk is always greater than or equal to the lower dimension bound. 5.1.2 Kinds_and_Occurrences_of_Array_Declarators. Each array declarator is either a constant array declarator, an adjustable array declarator, or an assumed-size array declarator. A constant array declarator is an array declarator in which each of the dimension bound expressions is an integer constant expression (6.1.3.1). An adjustable array declarator is an array declarator that contains one or more variables. An assumed-size array declarator is a constant array declarator or an adjustable array declarator, except that the upper dimension bound of the last dimension is an asterisk. Each array declarator is either an actual array declarator or a dummy array declarator. FORTRAN 77 Full Language Page 5-2 ARRAYS AND SUBSTRINGS ANSI X3J3/90.4 5.1.2.1 Actual_Array_Declarator. An actual array declarator is an array declarator in which the array name is not a dummy argument. Each actual array declarator must be a constant array declarator. An actual array declarator is permitted in a DIMENSION statement, type-statement, or COMMON statement (Section 8). 5.1.2.2 Dummy_Array_Declarator. A dummy array declarator is an array declarator in which the array name is a dummy argument. A dummy array declarator may be either a constant array declarator, an adjustable array declarator, or an assumed-size array declarator. A dummy array declarator is permitted in a DIMENSION statement or a type-statement but not in a COMMON statement. A dummy array declarator may appear only in a function or subroutine subprogram. 5.2 Properties_of_an_Array The following properties of an array are specified by the array declarator: the number of dimensions of the array, the size and bounds of each dimension, and therefore the number of array elements. The properties of an array in a program unit are specified by the array declarator for the array in that program unit. 5.2.1 Data_Type_of_an_Array_and_an_Array_Element. An array name has a data type (4.1.1). An array element name has the same data type as the array name. 5.2.2 Dimensions_of_an_Array. The number of dimensions of an array is equal to the number of dimension declarators in the array declarator. The size of a dimension is the value: d_928 - d_918 + 1 where: d_918 is the value of the lower dimension bound d_928 is the value of the upper dimension bound Note that if the value of the lower dimension bound is one, the size of the dimension is d_928. The size of a dimension whose upper bound is an asterisk is not specified. FORTRAN 77 Full Language Page 5-3 ARRAYS AND SUBSTRINGS ANSI X3J3/90.4 The number and size of dimensions in one array declarator may be different from the number and size of dimensions in another array declarator that is associated by common, equivalence, or argument association. 5.2.3 Size_of_an_Array. The size of an array is equal to the number of elements in the array. The size of an array is equal to the product of the sizes of the dimensions specified by the array declarator for that array name. The size of an assumed-size dummy array (5.5) is determined as follows: (1) If the actual argument corresponding to the dummy array is a noncharacter array name, the size of the dummy array is the size of the actual argument array. (2) If the actual argument corresponding to the dummy array name is a noncharacter array element name with a subscript value of r_ in an array of size x_, the size of the dummy array is x_ + 1 - r_ . (3) If the actual argument is a character array name, character array element name, or character array element substring name and begins at character storage unit t_ of an array with c_ character storage units, then the size of the dummy array is INT((c_ + 1 - t_) / ln__), where ln__ is the length of an element of the dummy array. If an assumed-size dummy array has n_ dimensions, the product of the sizes of the first n_ - 1 dimensions must be less than or equal to the size of the array, as determined by one of the immediately preceding rules. 5.2.4 Array_Element_Ordering. The elements of an array are ordered in a sequence (2.1). An array element name contains a subscript (5.4.1) whose subscript value (5.4.3) determines which element of the array is identified by the array element name. The first element of the array has a subscript value of one; the second element has a subscript value of two; the last element has a subscript value equal to the size of the array. Whenever an array name unqualified by a subscript is used to designate the whole array (5.6), the appearance of the array name implies that the number of values to be processed is equal to the number of elements in the FORTRAN 77 Full Language Page 5-4 ARRAYS AND SUBSTRINGS ANSI X3J3/90.4 array and that the elements of the array are to be taken in sequential order. 5.2.5 Array_Storage_Sequence. An array has a storage sequence consisting of the storage sequences of the array elements in the order determined by the array element ordering. The number of storage units in an array is x_*z_, where x_ is the number of the elements in the array and z_ is the number of storage units for each array element. 5.3 Array_Element_Name The form of an array element name is: a_ (s_ [,s_]...) where: a_ is the array name (s_ [,s_]...) is a subscript (5.4.1) s_ is a subscript expression (5.4.2) The number of subscript expressions must be equal to the number of dimensions in the array declarator for the array name. 5.4 Subscript 5.4.1 Form_of_a_Subscript. The form of a subscript is: (s_ [,s_]...) where s_ is a subscript expression. Note that the term "subscript" includes the parentheses that delimit the list of subscript expressions. 5.4.2 Subscript_Expression. A subscript expression is an integer expression. A subscript expression may contain array element references and function references. Note that a restriction in the evaluation of expressions (6.6) prohibits certain side effects. In particular, evaluation of a function must not alter the value of any other subscript expression within the same subscript. Within a program unit, the value of each subscript expression must be greater than or equal to the corresponding lower dimension bound in the array FORTRAN 77 Full Language Page 5-5 ARRAYS AND SUBSTRINGS ANSI X3J3/90.4 declarator for the array. The value of each subscript expression must not exceed the corresponding upper dimension bound declared for the array in the program unit. If the upper dimension bound is an asterisk, the value of the corresponding subscript expression must be such that the subscript value does not exceed the size of the dummy array. 5.4.3 Subscript_Value. The subscript value of a subscript is specified in Table 1. The subscript value determines which array element is identified by the array element name. Within a program unit, the subscript value depends on the values of the subscript expressions in the subscript and on the dimensions of the array specified in the array declarator for the array in the program unit. If the subscript value is r_ , the r_th element of the array is identified. FORTRAN 77 Full Language Page 5-6 ARRAYS AND SUBSTRINGS ANSI X3J3/90.4 Table 1_______ Subscript Value 8 _________________________________________________________ n Dimension Subscript Subscript Declarator Value 8 _________________________________________________________ 1 (j918:k918) (s918) 1+(s918-j918) 8 _________________________________________________________ 2 (j918:k918,j928:k928) (s918,s928) 1+(s918-j918) +(s928-j928)*d91 8 8 _________________________________________________________ 3 (j918:k918,j928:k928,j938:k938) (s918,s928,s938) 1+(s918-j918) +(s928-j928)*d91 8 +(s938-j938)*d928*d91 8 8 _________________________________________________________ 8 _________________________________________________________ n (j918:k918,...,j9n8:k9n8) (s918,...,s9n8) 1+(s918-j918) +(s928-j928)*d91 8 +(s938-j938)*d928*d91 8 +... +(s9n8-j9n8)*d9n-1 8 *d9n-28*...*d91 8 8 _________________________________________________________ 7 |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7| Notes for Table 1: (1) n is the number of dimensions, 1 < n < 7. (2) j9i8 is the value of the lower bound of the ith dimension. (3) k9i8 is the value of the upper bound of the ith dimension. (4) If only the upper bound is specified, then j9i8% = 1. (5) s9i8 is the integer value of the ith subscript expression. 9 FORTRAN 77 Full Language Page 5-7 ARRAYS AND SUBSTRINGS ANSI X3J3/90.4 (6) d9i8 = k9i8-j9i8+1 is the size of the ith dimension. If the value of the lower bound is 1, then d9i8 = k9i8. Note that a subscript of the form (j918,...j9n8) has a subscript value of one and identifies the first element of the array. A subscript of the form (k918,...,k9n8) identifies the last element of the array; its subscript value is equal to the number of elements in the array. The subscript value and the subscript expression value are not necessarily the same, even for a one- dimensional array. In the example: DIMENSION A(-1:8),B(10,10) A(2) = B(1,2) A(2) identifies the fourth element of A, the subscript is (2) with a subscript value of four, and the subscript expression is 2 with a value of two. B(1,2) identifies the eleventh element of B, the subscript is (1,2) with a subscript value of eleven, and the subscript expressions are 1 and 2 with values of one and two. 5.5 Dummy_and_Actual_Arrays A dummy array is an array for which the array declarator is a dummy array declarator. An assumed- size dummy array is a dummy array for which the array declarator is an assumed-size array declarator. A dummy array is permitted only in a function or subroutine subprogram (Section 15). An actual array is an array for which the array declarator is an actual array declarator. Each array in the main program is an actual array and must have a constant array declarator. A dummy array may be used as an actual argument. 5.5.1 Adjustable_Arrays_and_Adjustable_Dimensions. An adjustable array is an array for which the array declarator is an adjustable array declarator. In an adjustable array declarator, those dimension declarators that contain a variable name are called adjustable dimensions. An adjustable array declarator must be a dummy array declarator. At least one dummy argument list of the subprogram must contain the name of the adjustable array. A variable name that appears in a dimension FORTRAN 77 Full Language Page 5-8 ARRAYS AND SUBSTRINGS ANSI X3J3/90.4 bound expression of an array must also appear as a name either in every dummy argument list that contains the array name or in a common block in that subprogram. At the time of execution of a reference to a function or subroutine containing an adjustable array in its dummy argument list, each actual argument that corresponds to a dummy argument appearing in a dimension bound expression for the array and each variable in common appearing in a dimension bound expression for the array must be defined with an integer value. The values of those dummy arguments or variables in common, together with any constants and symbolic names of constants appearing in the dimension bound expression, determine the size of the corresponding adjustable dimension for the execution of the subprogram. The sizes of the adjustable dimensions and of any constant dimensions appearing in an adjustable array declarator determine the number of elements in the array and the array element ordering. The execution of different references to a subprogram or different executions of the same reference determine possibly different properties (size of dimensions, dimension bounds, number of elements, and array element ordering) for each adjustable array in the subprogram. These properties depend on the values of any actual arguments and variables in common that are referenced in the adjustable dimension expressions in the subprogram. During the execution of an external procedure in a subprogram containing an adjustable array, the array properties of dimension size, lower and upper dimension bounds, and array size (number of elements in the array) do not change. However, the variables involved in an adjustable dimension may be redefined or become undefined during execution of the external procedure with no effect on the above-mentioned properties. 5.6 Use_of_Array_Names In a program unit, each appearance of an array name must be in an array element name except in the following cases: (1) In a list of dummy arguments (2) In a COMMON statement (3) In a type-statement FORTRAN 77 Full Language Page 5-9 ARRAYS AND SUBSTRINGS ANSI X3J3/90.4 (4) In an array declarator. Note that although the form of an array declarator may be identical to that of an array element name, an array declarator is not an array element name. (5) In an EQUIVALENCE statement (6) In a DATA statement (7) In the list of actual arguments in a reference to an external procedure (8) In the list of an input/output statement if the array is not an assumed-size dummy array (9) As a unit identifier for an internal file in an input/output statement if the array is not an assumed-size dummy array (10) As the format identifier in an input/output statement if the array is not an assumed-size dummy array (11) In a SAVE statement 5.7 Character_Substring A character substring is a contiguous portion of a character datum and is of type character. A character substring is identified by a substring name and may be assigned values and referenced. 5.7.1 Substring_Name. The forms of a substring name are: v_ ( [e_918] : [e_928] ) a_ (s_ [,s_]...)( [e_918] : [e_928] ) where: v_ is a character variable name a_ (s_ [,s_]...) is a character array element name e_918 and e_928 are each an integer expression and are called substring expressions The value e_918 specifies the leftmost character position of the substring, and the value e_928 specifies the rightmost character position. For example, A(2:4) specifies characters in positions two through four of the character variable A, and B(4,3)(1:6) specifies FORTRAN 77 Full Language Page 5-10 ARRAYS AND SUBSTRINGS ANSI X3J3/90.4 characters in positions one through six of the character array element B(4,3). The values of e_918 and e_928 must be such that: 1 < e_918 < e_928 < len___ where len is the length of the character variable or array element (8.4.2). If e_918 is omitted, a value of one is implied for e_918. If e_928 is omitted, a value of len is implied for e_928. Both e_918 and e_928 may be omitted; for example, the form v_(:) is equivalent to v_, and the form a_ (s_ [,s_]...)(:) is equivalent to a_(s_ [,s_]...). The length of a character substring is e_928 - e_918 + 1. 5.7.2 Substring_Expression. A substring expression may be any integer expression. A substring expression may contain array element references and function references. Note that a restriction in the evaluation of expressions (6.6) prohibits certain side effects. In particular, evaluation of a function must not alter the value of any other expression within the same substring name. FORTRAN 77 Full Language Page 5-11 CONTENTS 5. ARRAYS AND SUBSTRINGS........................ 5-1 5.1 Array Declarator........................ 5-1 5.1.1 Form of an Array Declarator....................... 5-1 5.1.2 Kinds and Occurrences of Array Declarators...................... 5-2 5.2 Properties of an Array.................. 5-3 5.2.1 Data Type of an Array and an Array Element.................... 5-3 5.2.2 Dimensions of an Array........... 5-3 5.2.3 Size of an Array................. 5-4 5.2.4 Array Element Ordering........... 5-4 5.2.5 Array Storage Sequence........... 5-5 5.3 Array Element Name...................... 5-5 5.4 Subscript............................... 5-5 5.4.1 Form of a Subscript.............. 5-5 5.4.2 Subscript Expression............. 5-5 5.4.3 Subscript Value.................. 5-6 5.5 Dummy and Actual Arrays................. 5-8 5.5.1 Adjustable Arrays and Adjustable Dimensions....................... 5-8 5.6 Use of Array Names...................... 5-9 5.7 Character Substring..................... 5-10 5.7.1 Substring Name................... 5-10 5.7.2 Substring Expression............. 5-11 - i - ANSI X3J3/90.4 6. EXPRESSIONS This section describes the formation, interpretation, and evaluation rules for arithmetic, character, relational, and logical expressions. An expression is formed from operands, operators, and parentheses. 6.1 Arithmetic_Expressions An arithmetic expression is used to express a numeric computation. Evaluation of an arithmetic expression produces a numeric !value. The simplest form of an arithmetic expression is an unsigned arithmetic constant, symbolic name of an arithmetic constant, arithmetic variable reference, arithmetic array element reference, or arithmetic function reference. More complicated arithmetic expressions may be formed by using one or more arithmetic operands together with arithmetic operators and parentheses. Arithmetic operands must identify values of type integer, real, double precision, or complex. 6.1.1 Arithmetic_Operators. The five arithmetic operators are: 8 ____________________________________ Operator Representing 8 ____________________________________ ** Exponentiation / Division * Multiplication - Subtraction or Negation + Addition or Identity 8 ____________________________________ 7 |7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7| Each of the operators **, /, and * operates on a pair of operands and is written between the two operands. Each of the operators + and - either: (1) operates on a pair of operands and is written between the two operands, or (2) operates on a single operand and is written preceding that operand. 9 FORTRAN 77 Full Language Page 6-1 EXPRESSIONS ANSI X3J3/90.4 6.1.2 Form and Interpretation of Arithmetic Expressions. The interpretation of the expression formed with each of the arithmetic operators in each form of use is as follows: 8 ___________________________________________________ Use of Operator Interpretation 8 ___________________________________________________ x918 ** x928 Exponentiate x918 to the power x92 8 x918 / x928 Divide x918 by x92 8 x918 * x928 Multiply x918 and x92 8 x918 - x928 Subtract x928 from x91 8 - x928 Negate x92 8 x918 + x928 Add x918 and x92 8 + x928 Same as x92 7 ___________________________________________________ 7 |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7| where: x918 denotes the operand to the left of the operator x928 denotes the operand to the right of the operator The interpretation of a division may depend on the data types of the operands (6.1.5). A set of formation rules is used to establish the interpretation of an arithmetic expression that contains two or more operators. There is a precedence among the arithmetic operators, which determines the order in which the operands are to be combined unless the order is changed by the use of parentheses. The precedence of the arithmetic operators is as follows: 8 _________________________ Operator Precedence 8 _________________________ ** Highest * and / Intermediate + and - Lowest 8 _________________________ 7 |7|7|7|7|7|7| |7|7|7|7|7|7| |7|7|7|7|7|7| For example, in the expression FORTRAN 77 Full Language Page 6-2 EXPRESSIONS ANSI X3J3/90.4 - A ** 2 the exponentiation operator (**) has precedence over the negation operator (-); therefore, the operands of the exponentiation operator are combined to form an expression that is used as the operand of the negation operator. The interpretation of the above expression is the same as the interpretation of the expression - (A ** 2) The arithmetic operands are: (1) Primary (2) Factor (3) Term (4) Arithmetic expression The formation rules to be applied in establishing the interpretation of arithmetic expressions are in 6.1.2.1 through 6.1.2.4. 6.1.2.1 Primaries. The primaries are: (1) Unsigned arithmetic constant (4.2.3) (2) Symbolic name of an arithmetic constant (8.6) (3) Arithmetic variable reference (2.5) (4) Arithmetic array element reference (5.3) (5) Arithmetic function reference (15.2) (6) Arithmetic expression enclosed in parentheses (6.1.2.4) 6.1.2.2 Factor. The forms of a factor are: (1) Primary (2) Primary ** factor Thus, a factor is formed from a sequence of one or more primaries separated by the exponentiation operator. Form (2) indicates that in interpreting a factor containing two or more exponentiation operators, the primaries are combined from right to left. For FORTRAN 77 Full Language Page 6-3 EXPRESSIONS ANSI X3J3/90.4 example, the factor 2**3**2 has the same interpretation as the factor 2**(3**2) 6.1.2.3 Term. The forms of a term are: (1) Factor (2) Term / factor (3) Term * factor Thus, a term is formed from a sequence of one or more factors separated by either the multiplication operator or the division operator. Forms (2) and (3) indicate that in interpreting a term containing two or more multiplication or division operators, the factors are combined from left to right. 6.1.2.4 Arithmetic_Expression. The forms of an arithmetic expression are: (1) Term (2) + term (3) - term (4) Arithmetic expression + term (5) Arithmetic expression - term Thus, an arithmetic expression is formed from a sequence of one or more terms separated by either the addition operator or the subtraction operator. The first term in an arithmetic expression may be preceded by the identity or the negation operator. Forms (4) and (5) indicate that in interpreting an arithmetic expression containing two or more addition or subtraction operators, the terms are combined from left to right. Note that these formation rules do not permit expressions containing two consecutive arithmetic operators, such as A**-B or A+-B. However, expressions such as A**(-B) and A+(-B) are permitted. FORTRAN 77 Full Language Page 6-4 EXPRESSIONS ANSI X3J3/90.4 6.1.3 Arithmetic_Constant_Expression. An arithmetic constant expression is an arithmetic expression in which each primary is an arithmetic constant, the symbolic name of an arithmetic constant, or an arithmetic constant expression enclosed in parentheses. The exponentiation operator is not permitted unless the exponent is of type integer. Note that variable, array element, and function references are not allowed. 6.1.3.1 Integer_Constant_Expression. An integer constant expression is an arithmetic constant expression in which each constant or symbolic name of a constant is of type integer. Note that variable, array element, and function references are not allowed. The following are examples of integer constant expressions: 3 -3 -3+4 6.1.4 Type and Interpretation of Arithmetic Expressions. The data type of a constant is determined by the form of the constant (4.2.1). The data type of an arithmetic variable reference, symbolic name of an arithmetic constant, arithmetic array element reference, or arithmetic function reference is determined by the name of the datum or function (4.1.2). The data type of an arithmetic expression containing one or more arithmetic operators is determined from the data types of the operands. Integer expressions, real expressions, double precision expressions, and complex expressions are arithmetic expressions whose values are of type integer, real, double precision, and complex, respectively. When the operator + or - operates on a single operand, the data type of the resulting expression is the same as the data type of the operand. When an arithmetic operator operates on a pair of operands, the data type of the resulting expression is given in Tables 2 and 3. In these tables, each letter I, R, D, or C represents an operand or result of type integer, real, double precision, or complex, respectively. The type of the result is indicated by the I, R, D, or C that precedes the equals, and the interpretation is FORTRAN 77 Full Language Page 6-5 EXPRESSIONS ANSI X3J3/90.4 indicated by the expression to the right of the equals. REAL, DBLE, and CMPLX are the type-conversion functions described in 15.10. Table 2_______ Type and Interpretation of Result for x918 + x92 7 ________________________________________________________ x928 I928 R92 8 x91 7 ________________________________________________________ I918 I = I918 + I928 R = REAL(I918) + R92 8 R918 R = R918 + REAL(I928) R = R918 + R92 8 D918 D = D918 + DBLE(I928) D = D918 + DBLE(R928) C918 C=C918+CMPLX(REAL(I928),0.) C = C918 + CMPLX(R928,0.) 8 ________________________________________________________ 7 |7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7| 8 _______________________________________________________ x928 D928 C92 8 x91 7 _______________________________________________________ I918 D = DBLE(I928) + D928 C=CMPLX(REAL(I928),0.)+C92 8 R918 D = DBLE(R918) + D928 C = CMPLX(R918,0.) + C92 8 D918 D = D918 + D928 Prohibited C918 Prohibited C = C918 + C92 7 _______________________________________________________ 7 |7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7| Tables giving the type and interpretation of expressions involving -, *, and / may be obtained by replacing all occurrences of + in Table 2 by -, *, or /, respectively. FORTRAN 77 Full Language Page 6-6 EXPRESSIONS ANSI X3J3/90.4 Table 3_______ Type and Interpretation of Result for x918**x92 7 _______________________________________________________ x928 I928 R92 8 x91 7 _______________________________________________________ I918 I = I918**I928 R = REAL(I918)**R92 8 R918 R = R918**I928 R = R918**R92 8 D918 D = D918**I928 D = D918**DBLE(R928) C918 C = C918**I928 C = C918**CMPLX(R928,0.) 8 _______________________________________________________ 7 |7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7| 8 _______________________________________________________ x928 D928 C92 8 x91 7 _______________________________________________________ I928 D = DBLE(I928)**D928 C=CMPLX(REAL(I928),0.)**C92 8 R918 D = DBLE(R918)**D928 C = CMPLX(R918,0.)**C92 8 D918 D = D918**D928 Prohibited C918 Prohibited C = C918**C92 7 _______________________________________________________ 7 |7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7|7|7| Four entries in Table 3 specify an interpretation to be a complex value raised to a complex power. In these cases, the value of the expression is the "principal value" determined by x918**x928 = EXP(x928*LOG(x918)), where EXP and LOG are functions described in 15.10. Except for a value raised to an integer power, Tables 2 and 3 specify that if two operands are of different type, the operand that differs in type from the result of the operation is converted to the type of the result and then the operator operates on a pair of operands of the same type. When a primary of type real, double precision, or complex is raised to an integer power, the integer operand need not be converted. If the value of I928 is negative, the interpretation of I918**I92 8 is the same as the interpretation of 1/(I918**ABS(I928)), which is subject to the rules for integer division (6.1.5). For example, 2**(-3) has the value of 1/(2**3), which is zero. FORTRAN 77 Full Language Page 6-7 EXPRESSIONS ANSI X3J3/90.4 The type and interpretation of an expression that consists of an operator operating on either a single operand or a pair of operands are independent of the context in which the expression appears. In particular, the type and interpretation of such an expression are independent of the type of any other operand of any larger expression in which it appears. For example, if X is of type real, J is of type integer, and INT is the real-to-integer conversion function, the expression INT(X+J) is an integer expression and X+J is a real expression. 6.1.5 Integer_Division. One operand of type integer may be divided by another operand of type integer. Although the mathematical quotient of two integers is not necessarily an integer, Table 2 specifies that an expression involving the division operator with two operands of type integer is interpreted as an expression of type integer. The result of such a division is called an integer quotient and is obtained as follows: If the magnitude of the mathematical quotient is less than one, the integer quotient is zero. Otherwise, the integer quotient is the integer whose magnitude is the largest integer that does not exceed the magnitude of the mathematical quotient and whose sign is the same as the sign of the mathematical quotient. For example, the value of the expression (- 8)/3 is (-2). 6.2 Character_Expressions A character expression is used to express a character string. Evaluation of a character expression produces a result of type character. The simplest form of a character expression is a character constant, symbolic name of a character constant, character variable reference, character array element reference, character substring reference, or character function reference. More complicated character expressions may be formed by using one or more character operands together with character operators and parentheses. 6.2.1 Character_Operator. The character operator is: FORTRAN 77 Full Language Page 6-8 EXPRESSIONS ANSI X3J3/90.4 8 __________________________ Operator Representing 8 __________________________ // Concatenation 8 __________________________ 7 |7|7|7|7| |7|7|7|7| |7|7|7|7| The interpretation of the expression formed with the character operator is: 8 __________________________________________ Use of Operator Interpretation 8 __________________________________________ x918 // x928 Concatenate x918 with x92 7 __________________________________________ 7 |7|7|7|7| |7|7|7|7| |7|7|7|7| where: x918 denotes the operand to the left of the operator x928 denotes the operand to the right of the operator The result of a concatenation operation is a character string whose value is the value of x918 concatenated on the right with the value of x928 and whose length is the sum of the lengths of x918 and x928. For example, the value of 'AB' // 'CDE' is the string ABCDE. 6.2.2 Form and Interpretation of Character Expressions. A character expression and the operands of a character expression must identify values of type character. Except in a character assignment statement (10.4), a character expression must not involve concatenation of an operand whose length specification is an asterisk in parentheses (8.4.2) unless the operand is the symbolic name of a constant. 6.2.2.1 Character_Primaries. The character primaries are: (1) Character constant (4.8.1) (2) Symbolic name of a character constant (8.6) (3) Character variable reference (2.5) (4) Character array element reference (5.3) (5) Character substring reference (5.7) FORTRAN 77 Full Language Page 6-9 EXPRESSIONS ANSI X3J3/90.4 (6) Character function reference (15.2) (7) Character expression enclosed in parentheses (6.2.2.2) 6.2.2.2 Character_Expression. The forms of a character expression are: (1) Character primary (2) Character expression // character primary Thus, a character expression is a sequence of one or more character primaries separated by the concatenation operator. Form (2) indicates that in a character expression containing two or more concatenation operators, the primaries are combined from left to right to establish the interpretation of the expression. For example, the formation rules specify that the interpretation of the character expression 'AB' // 'CD' // 'EF' is the same as the interpretation of the character expression ('AB' // 'CD') // 'EF' The value of the character expression in this example is the same as that of the constant 'ABCDEF'. Note that parentheses have no effect on the value of a character expression. 6.2.3 Character_Constant_Expression. A character constant expression is a character expression in which each primary is a character constant, the symbolic name of a character constant, or a character constant expression enclosed in parentheses. Note that variable, array element, substring, and function references are not allowed. 6.3 Relational_Expressions A relational expression is used to compare the values of two arithmetic expressions or two character expressions. A relational expression may not be used to compare the value of an arithmetic expression with the value of a character expression. Relational expressions may appear only within logical expressions. Evaluation of a relational expression FORTRAN 77 Full Language Page 6-10 EXPRESSIONS ANSI X3J3/90.4 produces a result of type logical, with a value of true or false. 6.3.1 Relational_Operators. The relational operators are: 8 _____________________________________ Operator Representing 8 _____________________________________ .LT. Less than .LE. Less than or equal to .EQ. Equal to .NE. Not equal to .GT. Greater than .GE. Greater than or equal to 8 _____________________________________ 7 |7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7|7| 6.3.2 Arithmetic_Relational_Expression. The form of an arithmetic relational expression is: e_918 relop_____ e_92 9 where: e_918 and e_928 are each an integer, real, double precision, or complex expression relop_____ is a relational operator A complex operand is permitted only when the relational operator is .EQ. or .NE. 6.3.3 Interpretation of Arithmetic Relational Expressions. An arithmetic relational expression is interpreted as having the logical value true if the values of the operands satisfy the relation specified by the operator. An arithmetic relational expression is interpreted as having the logical value false if the values of the operands do not satisfy the relation specified by the operator. If the two arithmetic expressions are of different types, the value of the relational expression e_918 relop_____ e_92 9 is the value of the expression ((e_918) - (e_928)) relop_____ 0 where 0 (zero) is of the same type as the expression ((e _918) (e_928)), and relop_____ is the same relational operator in both expressions. Note that the comparison of a double 9 FORTRAN 77 Full Language Page 6-11 EXPRESSIONS ANSI X3J3/90.4 precision value and a complex value is not permitted. 6.3.4 Character_Relational_Expression. The form of a character relational expression is: e_918 relop_____ e_92 9 where: e_918 and e_928 are character expressions relop_____ is a relational operator 6.3.5 Interpretation of Character Relational Expressions. A character relational expression is interpreted as the logical value true if the values of the operands satisfy the relation specified by the operator. A character relational expression is interpreted as the logical value false if the values of the operands do not satisfy the relation specified by the operator. The character expression e_918 is considered to be less than e_928 if the value of e_918 precedes the value of e_928 in the collating sequence; e_918 is greater than e_928 if the value of e_918 follows the value of e_928 in the collating sequence (3.1.5). Note that the collating sequence depends partially on the processor; however, the result of the use of the operators .EQ. and .NE. does not depend on the collating sequence. If the operands are of unequal length, the shorter operand is considered as if it were extended on the right with blanks to the length of the longer operand. 6.4 Logical_Expressions A logical expression is used to express a logical computation. Evaluation of a logical expression produces a result of type logical, with a value of true or false. The simplest form of a logical expression is a logical constant, symbolic name of a logical constant, logical variable reference, logical array element reference, logical function reference, or relational expression. More complicated logical expressions may be formed by using one or more logical operands together with logical operators and parentheses. 6.4.1 Logical_Operators. The logical operators are: FORTRAN 77 Full Language Page 6-12 EXPRESSIONS ANSI X3J3/90.4 8 __________________________________________ Operator Representing 8 __________________________________________ .NOT. Logical Negation .AND. Logical Conjunction .OR. Logical Inclusive Disjunction .EQV. Logical Equivalence .NEQV. Logical Nonequivalence 8 __________________________________________ 7 |7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7| |7|7|7|7|7|7|7|7| 6.4.2 Form_and_Interpretation_of_Logical_Expressions. A set of formation rules is used to establish the interpretation of a logical expression that contains two or more logical operators. There is a precedence among the logical operators, which determines the order in which the operands are to be combined unless the order is changed by the use of parentheses. The precedence of the logical operators is as follows: 8 ______________________________ Operator Precedence 8 ______________________________ .NOT. Highest .AND. .OR. .EQV. or .NEQV. Lowest 8 ______________________________ 7 |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| For example, in the expression A .OR. B .AND. C the .AND. operator has higher precedence than the &'.OR. operator; therefore, the interpretation of the above expression is the same as the interpretation of the expression A .OR. (B .AND. C) The logical operands are: (1) Logical primary (2) Logical factor (3) Logical term (4) Logical disjunct FORTRAN 77 Full Language Page 6-13 EXPRESSIONS ANSI X3J3/90.4 (5) Logical expression The formation rules to be applied in establishing the interpretation of a logical expression are in 6.4.2.1 through 6.4.2.5. 6.4.2.1 Logical_Primaries. The logical primaries are: (1) Logical constant (4.7.1) (2) Symbolic name of a logical constant (8.6) (3) Logical variable reference (2.5) (4) Logical array element reference (5.3) (5) Logical function reference (15.2) (6) Relational expression (6.3) (7) Logical expression enclosed in parentheses (6.4.2.5) 6.4.2.2 Logical_Factor. The forms of a logical factor are: (1) Logical primary (2) .NOT. logical primary 6.4.2.3 Logical_Term. The forms of a logical term are: (1) Logical factor (2) Logical term .AND. logical factor Thus, a logical term is a sequence of logical factors separated by the .AND. operator. Form (2) indicates that in interpreting a logical term containing two or more .AND. operators, the logical factors are combined from left to right. 6.4.2.4 Logical_Disjunct. The forms of a logical disjunct are: (1) Logical term (2) Logical disjunct .OR. logical term FORTRAN 77 Full Language Page 6-14 EXPRESSIONS ANSI X3J3/90.4 Thus, a logical disjunct is a sequence of logical terms separated by the .OR. operator. Form (2) indicates that in interpreting a logical disjunct containing two or more .OR. operators, the logical terms are combined from left to right. 6.4.2.5 Logical_Expression. The forms of a logical expression are: (1) Logical disjunct (2) Logical expression .EQV. logical disjunct (3) Logical expression .NEQV. logical disjunct Thus, a logical expression is a sequence of logical disjuncts separated by either the .EQV. operator or the .NEQV. operator. Forms (2) and (3) indicate that in interpreting a logical expression containing two or more .EQV. or .NEQV. operators, the logical disjuncts are combined from left to right. 6.4.3 Value of Logical Factors, Terms, Disjuncts, and Expressions. The value of a logical factor involving .NOT. is shown below: 8 __________________ x928 .NOT. x92 7 __________________ true false false true 8 __________________ 7 |7|7|7|7|7| |7|7|7|7|7| |7|7|7|7|7| The value of a logical term involving .AND. is shown below: 8 _____________________________ x918 x928 x918 .AND. x92 7 _____________________________ true true true true false false false true false false false false 8 _____________________________ 7 |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| The value of a logical disjunct involving .OR. is shown below: FORTRAN 77 Full Language Page 6-15 EXPRESSIONS ANSI X3J3/90.4 8 ____________________________ x918 x928 x918 .OR. x92 7 ____________________________ true true true true false true false true true false false false 8 ____________________________ 7 |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| The value of a logical expression involving .EQV. is shown below: 8 _____________________________ x918 x928 x918 .EQV. x92 7 _____________________________ true true true true false false false true false false false true 8 _____________________________ 7 |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| The value of a logical expression involving .NEQV. is shown below: 8 ______________________________ x918 x928 x918 .NEQV. x92 7 ______________________________ true true false true false true false true true false false false 8 ______________________________ 7 |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| 6.4.4 Logical_Constant_Expression. A logical constant expression is a logical expression in which each primary is a logical constant, the symbolic name of a logical constant, a relational expression in which each primary is a constant expression, or a logical constant expression enclosed in parentheses. Note that variable, array element, and function references are not allowed. 6.5 Precedence_of_Operators In 6.1.2 and 6.4.2 precedences have been established among the arithmetic operators and the logical operators, respectively. There is only one character operator. No precedence has been established among the relational operators. The precedences among the various operators are: 9 FORTRAN 77 Full Language Page 6-16 EXPRESSIONS ANSI X3J3/90.4 8 _________________________ Operator Precedence 8 _________________________ Arithmetic Highest Character Relational Logical Lowest 8 _________________________ 7 |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| |7|7|7|7|7|7|7| An expression may contain more than one kind of operator. For example, the logical expression