FORTRAN Reference Manual Abstract This reference manual documents the HP implementation of the FORTRAN 77 language including HP extensions. Readers should already be familiar with the FORTRAN 77 language. Product Version FORTRAN D20 Supported Release Version Updates (RVUs) This manual supports D20.00 and all subsequent D-series RVUs, and G02.00 and all subsequent G-series RVUs until otherwise indicated in a new edition.
Document History Part Number Product Version Published 82515 A00 FORTRAN B40 October 1986 15546 FORTRAN C20 March 1989 065115 FORTRAN D10 January 1993 528615-001 FORTRAN D20 August 2004
FORTRAN Reference Manual Glossary Index What’s New in This Manual xvii Manual Information xvii New and Changed Information About This Manual xix Who Should Use This Manual Manual Organization xix Prerequisites xx Notation Conventions xxi Examples Figures xvii xix 1.
2. Language Elements (continued) Contents 2.
4. Program Units (continued) Contents 4. Program Units (continued) Recursion 4-10 Using Multiple Entry Points in Functions and Subroutines 4-10 Using Adjustable Dimensions for Arrays and String Variables 4-11 Assumed-Size Array Declarator 4-12 Adjustable Array Declarator 4-13 Assumed-Size Length Declarator 4-13 Using Common Blocks 4-14 The Block Data Subprogram 4-15 5.
. Introduction to Statements Contents 6. Introduction to Statements Executable and Nonexecutable Statements Statement Types 6-3 Statement Order 6-4 Statement Labels 6-5 Error Numbers 6-5 6-1 7.
. Statements (continued) Contents 7.
. Intrinsic Functions (continued) Contents 8.
. Program Compilation Contents 9.
. Compiler Directives (continued) Contents 10.
10. Compiler Directives (continued) Contents 10.
. Memory Organization Contents 12. Memory Organization Code Space 12-1 Data Space 12-2 Upper Memory 12-5 Storage Areas 12-5 Storage of Entities in Common Blocks 12-9 Extended Memory 12-11 Debugging Programs That Use Extended Memory TNS Processor Memory Organization 12-13 Accessing Data 12-14 12-13 13.
. Mixed-Language Programming (continued) Contents 13. Mixed-Language Programming (continued) Using Shared Files 13-27 14. Interprocess Communication Managing $RECEIVE 14-3 Using $RECEIVE 14-5 $RECEIVE as an Input File 14-6 $RECEIVE as an Input/Output File 14-7 $RECEIVE as Separate Input/Output Files 14-8 READ Statement With $RECEIVE 14-9 Using the READ Statement PROMPT Specifier 14-10 WRITE Statement With $RECEIVE 14-10 Message Queuing 14-11 15.
15. Utility Routines (continued) Contents 15. Utility Routines (continued) DELETEASSIGN Routine 15-35 DELETEPARAM Routine 15-37 DELETESTARTUP Routine 15-38 GETASSIGNTEXT Routine 15-39 GETASSIGNVALUE Routine 15-40 GETBACKUPCPU Routine 15-41 GETPARAMTEXT Routine 15-42 GETSTARTUPTEXT Routine 15-43 PUTASSIGNTEXT Routine 15-45 PUTASSIGNVALUE Routine 15-47 PUTPARAMTEXT Routine 15-48 PUTSTARTUPTEXT Routine 15-50 16.
G. Run-Time Diagnostic Messages Contents G.
Figures Contents Figures Figure 2-1. Figure 2-2. Figure 2-3. Figure 4-1. Figure 5-1. Figure 6-1. Figure 9-1. Figure 9-2. Figure 9-3. Figure 9-4. Figure 10-1. Figure 12-1. Figure 12-2. Figure 12-3. Figure 12-4. Figure 12-5. Figure 14-1. Figure 14-2. Figure 14-3. Figure 14-4. Figure 14-5. Figure 15-1. Figure 16-1.
Tables (continued) Contents Tables (continued) Table 4-1. Table 5-1. Table 5-2. Table 5-3. Table 5-4. Table 5-5. Table 5-6. Table 5-7. Table 5-8. Table 6-1. Table 6-2. Table 7-1. Table 7-2. Table 7-3. Table 7-4. Table 7-5. Table 7-6. Table 7-7. Table 7-8. Table 7-9. Table 7-10. Table 8-1. Table 9-1. Table 9-2. Table 9-3. Table 9-4. Table 9-5. Table 10-1. Table 10-2. Table 11-1. Table 12-1. Table 12-2. Table 14-1. Table 15-1. Table 15-2.
Tables (continued) Contents Tables (continued) Table 15-3. Table 15-4. Table 15-5. Table A-1. Table D-1. Table D-2. Table D-3. Table D-4. Table D-5. Table D-6. Table H-1. Table H-2.
What’s New in This Manual Manual Information FORTRAN Reference Manual Abstract This reference manual documents the HP implementation of the FORTRAN 77 language including HP extensions. Readers should already be familiar with the FORTRAN 77 language. Product Version FORTRAN D20 Supported Release Version Updates (RVUs) This manual supports D20.00 and all subsequent D-series RVUs, and G02.00 and all subsequent G-series RVUs until otherwise indicated in a new edition.
New and Changed Information What’s New in This Manual FORTRAN Reference Manual—528615-001 xviii
About This Manual This manual describes the HP implementation of the full ANSI FORTRAN 77 (X3.91978) language. It also describes HP extensions that optimize FORTRAN for the transaction-oriented, fault-tolerant environment. All HP extensions provide capabilities beyond those stated in the FORTRAN standard. Who Should Use This Manual This manual is for system and application programmers. Manual Organization Table i. Summary of Contents (page 1 of 2) Section Title This section . . .
Prerequisites About This Manual Table i. Summary of Contents (page 2 of 2) Section Title This section . . . D Data Type Correspondence and Return Value Sizes Lists the return value size generated by HP NonStop language compilers for each data type. E Compiler Limits Summarizes the limits of the FORTRAN compiler F Compile-Time Diagnostic Messages Lists the FORTRAN 77 compiler diagnostic messages that FORTRAN might report in the program listing.
Notation Conventions About This Manual Manual Description Spooler Programmer’s Guide Describes the HP spooler program. CRE Programmer’s Guide Explains features of the CRE, including file sharing and error handling. TACL Reference Manual Describes command interpreter commands. Inspect Manual Describes how to use Inspect, an interactive symbolic debugging utility. Binder Manual Explains the binding of object files.
General Syntax Notation About This Manual [ ] Brackets. Brackets enclose optional syntax items. For example: TERM [\system-name.]$terminal-name INT[ERRUPTS] A group of items enclosed in brackets is a list from which you can choose one item or none. The items in the list can be arranged either vertically, with aligned brackets on each side of the list, or horizontally, enclosed in a pair of brackets and separated by vertical lines. For example: FC [ num ] [ -num ] [ text ] K [ X | D ] address { } Braces.
Notation for Messages About This Manual Item Spacing. Spaces shown between items are required unless one of the items is a punctuation symbol such as a parenthesis or a comma. For example: CALL STEPMOM ( process-id ) ; If there is no space between two items, spaces are not permitted. In this example, no spaces are permitted between the period and any other items: $process-name.#su-name Line Spacing.
Notation for Messages About This Manual Bold Text. Bold text in an example indicates user input typed at the terminal. For example: ENTER RUN CODE ?123 CODE RECEIVED: 123.00 The user must press the Return key after typing the input. Nonitalic text. Nonitalic letters, numbers, and punctuation indicate text that is displayed or returned exactly as shown. For example: Backup Up. lowercase italic letters. Lowercase italic letters indicate variable items whose values are displayed or returned.
Notation for Management Programming Interfaces About This Manual % Percent Sign. A percent sign precedes a number that is not in decimal notation. The % notation precedes an octal number. The %B notation precedes a binary number. The %H notation precedes a hexadecimal number.
Change Bar Notation About This Manual FORTRAN Reference Manual—528615-001 xxvi
1 Summary of HP Extensions HP FORTRAN for NonStop systems implements the full ANSI FORTRAN 77 (X3.91978) language. In addition, HP FORTRAN extensions to the ANSI standard enable you to: • • • • • • • • • Use 31-character identifier names. Use RECORD declarations to define and reference data structures containing data of different types. Combine procedures written in C, COBOL85, FORTRAN, Pascal, and TAL into an executable program. Write fault-tolerant programs.
Character Set and Identifier Names Summary of HP Extensions Character Set and Identifier Names The HP FORTRAN character set includes the following symbols that are not part of the ANSI standard character set: • • • • • • _ for use in names % to designate octal integers ^ for use in RECORD references and section names ? to identify a line of source that contains compiler directives \ for pass-by-value parameters " for defining the string that the PAGE directive prints at the top of each page For additio
Files Summary of HP Extensions A record can be shorter than the entity specified in the I/O list. The formatter fills the remainder of a short input record with blanks. For additional information, see Section 5, Introduction to File I/O in the HP NonStop Environment. FORMAT statements can specify binary, octal, and hexadecimal numeric conversion. For additional information, see Section 7, Statements. Files Your program can use both formatted and unformatted I/O on the same file.
Mixed-Language Programming Summary of HP Extensions Mixed-Language Programming You can specify external functions and subroutines in C, COBOL85, Pascal, or TAL and bind these modules, along with your FORTRAN modules, into a single executable program using the Binder program. For additional information, see Section 9, Program Compilation, and Section 13, Mixed-Language Programming. Memory Management A FORTRAN program can have up to 32 code segments—each code segment containing up to 128KB—and up to 127.
2 Language Elements Topics covered in this section include: Topic Page The FORTRAN Character Set 2-1 Program Line Format 2-2 Symbolic Names 2-6 Data Types 2-7 Constants 2-11 Variables 2-14 Arrays 2-14 Substrings 2-19 Records 2-20 The FORTRAN Character Set The FORTRAN character set, shown in Table 2-1 on page 2-2, consists of 26 letters, 10 digits, and 19 special characters.
Program Line Format Language Elements Table 2-1. FORTRAN Character Set Alphabetic abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ Numeric 0123456789 Special = Equals , Comma + Plus .
Initial Line Language Elements FORTRAN source lines contain the following elements: Column Meaning 1 If column 1 contains the letter “C” or an asterisk, the entire source line is a comment. If column 1 contains a question mark (?), the remainder of the record contains compiler directives. If column 1 contains a blank, the record is a continuation record or an optionally labeled FORTRAN statement.
Compiler Directives Language Elements You cannot use continuation lines to continue comments. Write multi-line comments as multiple comment lines, as shown in the following example: * This is such a lengthy comment line that I am afraid * I shall have to continue it over several lines. Compiler Directives Designate compiler directives by placing a question mark (?) in column one, followed by the directive name. For example: ?SYNTAX DIMENSION A(100),B(100) COMMON A .
Treatment of Blanks in a Program Line Language Elements Example 2-1. Sample FORTRAN Program: Program Lines C This program converts Fahrenheit to Celsius. C C It reads an initial Fahrenheit value (i), a terminal C Fahrenheit value (j), and an increment value (k) from the C terminal. Then it prints a table showing the C corresponding Celsius values.
Symbolic Names Language Elements Symbolic Names You use symbolic names to represent the following entities: • • • • • • • • • • • • Main program name Common block name Block data subprogram name Subroutine name External function name Variable name Array name RECORD and RECORD-field name Symbolic constant name Intrinsic function name Statement function name Dummy procedure name Symbolic names can contain the letters A through Z, the numbers 0 through 9, and the underscore character (_).
Scope of Symbolic Names Language Elements Scope of Symbolic Names The scope of a symbolic name is the range within which the symbolic name is defined: a name’s scope can be an executable program, a program unit, a statement function statement, or an implied DO list in a DATA statement. • • • • The name of the main program and the names of block data subprograms, external functions, subroutines, and common blocks have the scope of an executable program.
Data Types Language Elements The data types INTEGER*4 and INTEGER*8, and the compiler directives INTEGER*4, INTEGER*8, and LOGICAL*4 enable you to allocate additional storage for large integers and logical type data. Table 2-2. FORTRAN Data Types Type Range/Storage Precision (digits) Integer*2 -32,768 +32,767 Integer*4 -2,147,483,648 +2,147,438,647 Integer*8 -9,223,372,036,854,775,808 +9,223,372,036,854,775,807 Real ±8.646000 E-78 ±1.579208 E+77 6.9 Double Precision\ ±8.
Implicit and Explicit Typing Language Elements Figure 2-1. FORTRAN Data Storage WORDS 1 2 3 4 INTEGER*2 INTEGER*4 INTEGER*8 REAL*4 DOUBLE PRECISION LOGICAL*2 LOGICAL*4 COMPLEX REAL IMAGINARY VST0201.vsd Implicit and Explicit Typing By default, FORTRAN interprets symbolic names that begin with the letters I, J, K, L, M, and N as type integer and interprets names that begin with any other letter as type real.
Data Storage—Standard Conformance Language Elements the LOGICAL type declaration refers to the prevailing logical type as determined by the LOGICAL*4 compiler directive. In the absence of such a directive, LOGICAL means LOGICAL*2. The general form of a type declaration statement is: type var-name [, var-name ]...
Constants Language Elements Constants A constant is an unvarying datum. A constant can be a number, a constant expression, a complex value, a logical value, or a string of characters. You can use a PARAMETER statement to create a symbolic name for a constant. See the PARAMETER Statement on page 7-79. Arithmetic Constants Integer, real, double precision, and complex constants are called arithmetic constants. Integer Constants You must express an integer constant as a whole number.
Arithmetic Constants Language Elements You can also express a real constant in “exponential” form: + + coefficient E - exponent where coefficient is a decimal integer or real constant, and exponent is a decimal integer constant. For example: Exponential Notation Value 2.5E2 250 -1E-5 -.00001 -.00028E5 -28 The number following the letter E designates a power of 10. For example: 3.2E2 is the same as 3.2 * 10**2 1.23E-3 is the same as 1.
Logical Constants Language Elements Complex Constants You express a complex constant as a pair of real or integer constants separated by a comma and enclosed in parentheses: ( real, imaginary) where real is a real or integer constant that specifies the real part, and imaginary a real or integer constant that specifies the imaginary part. For example: (1, 7.5) (5, 1) (-2.5E3, 3.67) Logical Constants There are two logical constants: .TRUE. .FALSE. You must write the enclosing decimal points.
Variables Language Elements You can use Hollerith constants to represent character data. You might need to use Hollerith data if you are working with pre-FORTRAN 77 programs. For additional details, see Appendix H, Hollerith Constants and Punch Card Codes. Variables A variable names a storage location whose contents can change during program execution. You identify a variable by a symbolic name. You can use a declaration statement to declare explicitly the data type of a variable.
Dimensioning an Array Language Elements bound. The number of elements in each dimension is one greater than the difference between the upper and lower bounds. The following statement declares and dimensions the array DICTIONARY, a one dimensional character array. The first element is DICTIONARY(1) and the last element is DICTIONARY(100). Each of the 100 elements of DICTIONARY consists of 10 characters. CHARACTER * 10 dictionary (100) The following statement declares and dimensions the array CUSTOMERS.
Array References Language Elements Array References You can reference an entire array using the array name, or you can reference a specific array element using the array name followed by a subscript. A reference to an array element takes the following form: name ( e [, e ]... ) where name is the symbolic name of the array and e is an integer subscript expression. For example: CUSTOMERS (2,3,100) You must specify a value for each dimension of an array when you reference an element of that array.
Array Size Language Elements Table 2-5. Calculating Array Element Storage Locations (page 2 of 2) Dimensions Position of Array Element ji Lower bound of dimension i. ki Upper bound of dimension i. ni Size of dimension i. If the lower bound is one, ni= ki. Otherwise, ni = (ki - ji+ 1). Value of the subscript expression specified for dimension i. si Array Size The number of elements in an array is equal to the product of the number of elements in each dimension of the array.
Storage Order Language Elements Figure 2-2. Storage Order of Array Elements Plane 1 Plane 2 Plane 3 Plane 4 1,1,1 1,2,1 1,1,3 1,1,4 2,1,1 2,1,2 2,1,3 2,1,4 1,2,1 1,2,2 1,2,3 1,2,4 2,2,1 2,2,2 2,2,3 1,2,4 1,3,1 1,3,2 1,3,3 1,3.4 2,3,1 2,3,2 2,3,3 2,3,4 VST0202.
Substrings Language Elements Second, using the array-element you just calculated, determine the byte offset of the character relative to the beginning of the array. The character storage position is equal to: 1 + (array-element -1) * character-length 1 + 102 * 10 1021 Considerations • • • • • • • Use a DIMENSION, type-declaration, or COMMON statement to declare the number of dimensions and the number of elements in each dimension of an array.
Records Language Elements last specifies the position of the last character in the substring For example, if you store the string ABRACADABRA in the variable PASSWORD, the substring password (3:6) refers to the characters RACA. If you omit first, the substring begins with the first character in var-name. If you omit last, the substring ends with the last character in var-name. For example: password (:5) refers to the characters ABRAC; password (7:) refers to the characters DABRA.
Writing a RECORD Declaration Language Elements You can use the Data Definition Language (DDL) to share FORTRAN RECORD definitions between FORTRAN modules. For more information, see the Data Definition Language (DDL) Reference Manual. Writing a RECORD Declaration A RECORD declaration must begin with a RECORD statement and end with an END RECORD statement. You can declare a dimensioned RECORD, but a dimensioned RECORD cannot have more than one dimension.
Referencing a RECORD Field Language Elements Referencing a RECORD Field In an executable statement, you refer to a field within a RECORD by appending a circumflex to the end of the RECORD name followed by the name of the field that you want to reference. You might have a succession of circumflex/field-name combinations if you reference a field of a RECORD that is nested more than one level deep. record-name^ field-name [ ^ field-name ]... record-name is the name of the outermost RECORD.
RECORD Storage Language Elements The following example includes references to fields in the employee RECORD: CHARACTER*10 emp_name REAL emp_pay INTEGER emp_dept emp_name = employee^name emp_pay = employee^pay <-- Error: Not fully qualified emp_pay = employee^salary^pay emp_dept = employee^salary^dept emp_temp = employee^filler <-- Error: Cannot refer to FILLER RECORD Storage FORTRAN allocates the fields of a RECORD in the order in which they appear in the RECORD declaration.
Equivalencing RECORD Fields Language Elements The following example shows a nested RECORD declaration that contains two equivalenced subrecords: RECORD dependent RECORD depdata1 FILLER*5 RECORD depfields CHARACTER*10 firstname CHARACTER*20 lastname CHARACTER*2 birthday CHARACTER*2 birthmonth CHARACTER*2 birthyear END RECORD END RECORD RECORD depdata2 RECORD depkey CHARACTER*5 employeenum END RECORD FILLER*36 END RECORD EQUIVALENCE (depdata1, depdata2) END RECORD Equivalencing RECORD Fields You can declar
Equivalencing RECORD Fields Language Elements RECORD. You cannot equivalence character and numeric variables in declarations outside of a RECORD. ?GUARDIAN OPEN RECORD file INTEGER*2 name(12) CHARACTER namestring * 24 EQUIVALENCE (name, namestring) END RECORD file^namestring = '$data subvol myfile ' CALL open (file^name, n, %2001) If two fields of different sizes are equivalenced within a RECORD, the next field begins after the larger of the two equivalenced fields.
Equivalencing RECORD Fields Language Elements Considerations • • • • • You cannot use a DATA statement to initialize the value of a RECORD, or a field of a RECORD. You cannot declare a RECORD within a BLOCK DATA subprogram. A common block can contain at most one RECORD. A common block that contains a RECORD cannot contain variables or arrays. The maximum size of a RECORD, or of one element of a dimensioned RECORD, is 32,767 bytes, including all of its constituent fields.
3 Expressions This section describes the syntax and semantics of FORTRAN expressions. An expression consists of operands, operators, and parentheses. The evaluation of an expression yields a single value, whose type is determined by the type of the operands. Topics covered in this section include: Topic Page Arithmetic Expressions 3-2 Character Expressions 3-6 Relational Expressions 3-7 Logical Expressions 3-9 Operator Precedence 3-11 A FORTRAN expression is either simple or compound.
Arithmetic Expressions Expressions Arithmetic Expressions The combination of arithmetic operands and operators makes up an arithmetic expression. An arithmetic expression expresses a numeric computation; the evaluation of an arithmetic expression produces a numeric value. The syntax of an arithmetic expression is: [ prefix-op ] item [ infix-op item ]...
Evaluation of Arithmetic Expressions Expressions Evaluation of Arithmetic Expressions The hierarchy of arithmetic operators determines the order in which the operands are combined: ** <-- Highest * and / + and - <-- Lowest For example, in the following expression, the exponentiation operator takes precedence over the negation operator: -A ** 5 <-- Evaluated as -(A ** 5) You can use parentheses to override the normal sequence of evaluation.
Determination of Result Type Expressions • Example 2 (5 + 3) (2 - 6) * (5 + 3) 8 * (2 - 6) * (2 - 6) * -4 -32 VST0302.vsd • Example 3 2 ** 2 ** 3 2 ** 2 ** 3 2 ** 8 256 VST0303.vsd Determination of Result Type FORTRAN determines the data type of an arithmetic expression according to the data types of its operands. If all the operands of an expression are the same type, the resulting value is also of that type.
Determination of Result Type Expressions Table 3-2. Determination of Expression Type (page 2 of 2) X2 x1 I2 R2 D2 C2 D1 D = D1 ~ DBLE(I2) D = D1 ~ DBLE(R2) D = D1 ~ D2 Illegal C1 C = C1 ~ CMPLX (REAL(I2),0.) C = C1 ~ CMPLX(R2,0.) Illegal C = C1 ~ C2 REAL, DBLE, CMPLX are type-conversion functions as described in Section 8, Intrinsic Functions ~ is +, -, *, or /. I = INTEGER, R = REAL, D = DOUBLE PRECISION, C = COMPLEX.
Character Expressions Expressions Character Expressions A character expression is composed of character elements and the concatenation operator. The evaluation of a character expression produces a result of type character. The syntax of a character expression is: char-element [ // char-element ]... char-element is a constant, symbolic constant, variable, RECORD name, array element, substring reference, function reference, or another character expression. charelement must be of type character.
Relational Expressions Expressions Relational Expressions A relational expression compares the values of two arithmetic or two character operands. Relational expressions can appear only within logical expressions. The evaluation of a relational expression produces a logical type result, whose value is either true or false. The syntax of a relational expression is: expression rel-operator expression expression is an arithmetic or character expression. rel-operator is one of .LT. .LE. .EQ. .NE. .GT. .GE.
Evaluation of Relational Expressions Expressions In the following example, if the integer variables J and K have a value of 1 and 100 respectively, the relational expressions have the indicated values: j .GT. k <-- 1 .GT. 100 is false k .GT. j <-- 100 .GT. 1 is true k .GE. j <-- 100. GE.
Logical Expressions Expressions The following examples are invalid: DOUBLE PRECISION y COMPLEX x, z LOGICAL a, b READ (*,*) x, y, z a = x .LE. y <-- Cannot compare complex and double precision values b = z .GT. x <-- Relational operator is not .EQ. or .NE. and one of the operands is a complex value. Logical Expressions A logical expression designates a logical computation whose result is either true or false. The syntax of a logical expression is: [.NOT.] logic-exp [ logic-op [.NOT.] logic-exp ]...
Logical Expressions Expressions If a logical expression contains two or more logical operators, FORTRAN uses the following hierarchy to determine the order in which the operators are evaluated: .NOT. <-- Highest .AND. .OR. .EQV. or .NEQV. <-- Lowest The following expressions are equivalent: x .OR. y .AND. z x .OR. (y .AND. z) You can use parentheses to override the normal order of precedence, as in the following example: (x .OR. y) .AND. z If an expression contains two or more adjacent .AND.
Operator Precedence Expressions Table 3-6. Evaluation of Logical Expressions (page 2 of 2) Operator Operand Operand Result .NEQV. .TRUE. .TRUE. .FALSE. .TRUE. .FALSE. .TRUE. .FALSE. .TRUE. .TRUE. .FALSE. .FALSE. .FALSE. Operator Precedence Each FORTRAN operator has a precedence relative to all other operators. When the compiler evaluates an expression, it compares the precedence of two adjacent operators.
Operator Precedence Expressions Table 3-7. Operator Precedence (page 2 of 2) Operator Class Operator Precedence Character // 4 Relational .LT. 5 .LE. 5 .EQ. 5 .NE. 5 .GE. 5 .GT. 5 .NOT. 6 .AND. 7 .OR. 8 .EQV. 9 .NEQV.
4 Program Units This section describes the format of FORTRAN external procedures and BLOCK DATA subprograms.
The Main Program and Subprograms Program Units The term external function refers to • • External functions specified in function subprograms External functions written in languages other than FORTRAN subprograms The term subroutine refers to • • Subroutines specified in subroutine subprograms Subroutines written in languages other than FORTRAN Intrinsic functions are described in Section 8, Intrinsic Functions. Statement functions are described in Section 7, Statements.
Program Units Communication Between Program Units Communication Between Program Units A calling program unit and a referenced procedure can exchange data in common blocks and in arguments to the procedure. You can specify up to 63 arguments in a statement function or external function. The calling program unit passes actual arguments to the referenced procedure. The arguments of the referenced procedure are called dummy arguments.
Function Subprograms Program Units additional information about the EXTERNAL and INTRINSIC statements, see Section 7, Statements. Because you can compile FORTRAN program units independently, you must declare the data type of arguments both in the calling and referenced program unit, unless the arguments are typed by default. Example If you call the following function subprogram: FUNCTION tinterest(principal, payment, rate, months) . END using the statement, total = tinterest(loans(cash, credit), pay, .
Function Subprograms Program Units Figure 4-1. Function Subprogram and Calling Program PROGRAM main . . READ(5,*) a, b, c . cost = rate * metric(a, b, c) . . END function reference actual arguments used in correspond to FUNCTION metric (x, y, z) . . dummy arguments . . function name metric = x * y * z . function name must be defined . within function subprogram . END VST0401.
Assigning a Value to the Function Name Program Units Assigning a Value to the Function Name The symbolic function name serves as the main entry point to the function subprogram. The function subprogram must contain a statement that stores a value in the function name. If more than one statement stores a value in the name of the function, the last value stored is the value returned to the calling program.
Subroutines Program Units In the next example, the value returned by the function is determined when subroutine SUBA returns a value for NUMBER: FUNCTION number(a,b,c) . CALL suba(number,x) . END SUBROUTINE suba(j,k) READ (5,*) k j = k*3.2 . END Subroutines A subroutine subprogram performs a procedure for a calling program unit. The calling program unit can be the main program, a function subprogram, another subroutine, or the subroutine itself.
Subroutines With Alternate Return Specifiers Program Units When a CALL statement executes, FORTRAN first evaluates any actual arguments that are expressions, and then associates the actual arguments with the dummy arguments specified in the SUBROUTINE statement. The CALL statement then transfers control to the subroutine.
Saving Values Computed in Procedure Subprograms Program Units The following statements declare a subroutine, RATE, in which the third and fourth dummy arguments are the labels of executable statements; and a CALL statement that invokes the RATE subroutine: CALL rate (tonnage, distance, *500, *600) 500 CONTINUE C -- Arrive here if more than 1000 tons . . . 600 CONTINUE C -- Arrive here if less than or equal 1000 tons END SUBROUTINE RATE( tons, dist, *, * ) IF (tons .GT. 1000) iexp = 1 iexp = 2 . . .
Recursion Program Units Recursion As an extension to the standard, HP FORTRAN permits recursive calls in subprograms. The following program, which returns the factorial of a number, uses the recursive function FACTORIAL: INTEGER factorial, j 10 CONTINUE READ (*,*, PROMPT = ' Enter argument: ', END=20) j WRITE (*,*) ' Factorial is ', factorial(j) 20 CONTINUE END INTEGER FUNCTION factorial (n) INTEGER n IF (n .GT.
Using Adjustable Dimensions for Arrays and String Variables Program Units The following subroutine, HEADING, prints a page heading. The alternate entry point, DETAIL, prints the values of four variables which comprise the data lines of the report. SUBROUTINE heading (product, price, amount, salesman) 1 WRITE (*,2) 2 FORMAT ('1',T50, 'SALES REPORT FOR MARCH'//T55, 'FREMONT') ENTRY detail (product, price, amount, salesman) 4 WRITE (*,5) product, price, amount, salesman 5 FORMAT (T5, I6, T4, F10.
Assumed-Size Array Declarator Program Units PROGRAM MAIN REAL result(100), avg READ *, n READ *, (result(j), j = 1,n) CALL mean(n, result, avg) PRINT *, avg END SUBROUTINE mean(n,data,average) REAL data(100), average, sum sum = 0 DO 10 j = 1,n sum = sum + data(j) 10 CONTINUE average = sum/n END The main program passes values for the number of students and test scores to the subroutine, which accumulates the sum of the test scores, calculates their average, and returns the value of AVERAGE to the calling
Adjustable Array Declarator Program Units In the preceding program example, the declaration would be: REAL data(*), average, sum The asterisk indicates that the size of the numeric dummy array is the same as that of the associated numeric actual array. You can use the * array declarator in associated character arrays, provided the declared element length of the associated arrays is the same.
Using Common Blocks Program Units If the actual argument is an array name, the length of the associated dummy argument is the length of an array element in the actual argument array. Using Common Blocks Common blocks define a common storage area whose contents can be referenced by two or more program units. All subprograms that contain a declaration of the same common block can define and reference the entities included in that common block.
The Block Data Subprogram Program Units For additional information on using common blocks and memory organization, see Section 12, Memory Organization. The Block Data Subprogram The BLOCK DATA subprogram is a nonexecutable declaration subprogram that assigns initial values to entities in common blocks. By using the BLOCK DATA subprogram to initialize common block entities you can save the execution time and code space that would otherwise be needed to initialize these entities.
The Block Data Subprogram Program Units The following sample program specifies that the variables COMMISSION, TAX, SHIPPING, and VAT are in the named common block COST, and that the array QUANTITY is in the named common block PRODUCT: BLOCK DATA cost data INTEGER*4 quantity REAL commission, tax, shipping COMMON /product/quantity(1000) COMMON /cost/commission, tax, shipping, vat DATA commission, tax, shipping/.20, .06, .
5 Introduction to File I/O in the HP NonStop Environment This section introduces FORTRAN I/O in the HP NonStop environment.
Introduction to File I/O in the HP NonStop Environment Records Table 5-1. FORTRAN I/O Statements (page 2 of 2) Name Action INQUIRE Ascertains properties of a file or of its connection. OPEN Connects a structured file to a unit. Creates an unstructured file and connects it to a unit. POSITION Enables random access of files. PRINT Outputs data to the preconnected output unit, unit 6. READ Inputs data from specified unit or file. REWIND Positions connected file to its initial point.
Introduction to File I/O in the HP NonStop Environment FORTRAN Files FORTRAN Files A file is a sequence of records. When a program executes, those files that are available to it are said to exist for that program. A file that exists for a program might not contain any records, as would be the case with a newly created file. A file can be known to the Guardian file system but, for security reasons, might not be visible to a program.
Introduction to File I/O in the HP NonStop Environment • • • • File Properties FORTRAN treats each element of a file that is a character array or a RECORD array as a record. The ordering of the records is the same as the ordering of the elements of the array. The length of a record equals the length of an array element. A variable, array element, substring, RECORD, or RECORD array element that is a record of an internal file is defined when you write that record.
Introduction to File I/O in the HP NonStop Environment File Properties HP File Names You can specify a file name when you connect a file to a unit as in the following example: OPEN (15, FILE='newaccts', FORM='FORMATTED', STATUS='NEW') A file name specifies the location of a file and consists of four 8-character names separated by periods. A file name consists of a: • • • • Node name (system name) Volume name Subvolume name File ID Here is an example of a fully qualified file name: \ANODE.$AVOLUME.
Introduction to File I/O in the HP NonStop Environment File Properties Considerations • • • • The first character of the node name must be a backslash (\). The first character of the volume name must be a dollar sign ($). Each component of a file name can contain up to eight characters. If ENV OLD is in effect, the volume name in a file name that references a file at a remote node can be a maximum of seven characters including the dollar sign.
Introduction to File I/O in the HP NonStop Environment File Properties When connected for sequential access, a file has the following attributes: • • • If direct access is not permitted for the file, record order corresponds to the order in which the records were written. If you can also access the file directly, the order of the records is the same as that specified for direct access. The file’s records can be formatted, unformatted, or mixed. This is an HP extension.
Introduction to File I/O in the HP NonStop Environment Units Table 5-4. FORTRAN Access Methods for HP-defined Files (page 2 of 2) Access Method File Type Sequential Direct Keyed Unstructured Y Y N Entry-sequenced Y N Y Key-sequenced Y N Y Relative Y Y Y Logical Record Length The HP Formatter software package performs all FORTRAN I/O, both formatted and unformatted.
Introduction to File I/O in the HP NonStop Environment • • File Existence Exist or not exist Be open or not open For a FORTRAN executable program, a unit can: • • • Exist or not exist Be assigned or not assigned Be connected or not connected File Existence A disk file exists if it is known to the system. It need not have any data records in it. If you do not name the file at the time of connection, FORTRAN creates a temporary file, which it purges when you close the file or your process terminates.
Introduction to File I/O in the HP NonStop Environment Unit Existence Unit Existence A unit exists for a FORTRAN executable program if and only if its unit number has been made known in one or more of the following ways: • • • The unit number appears, in the form of an integer constant or a symbolic constant whose value is an integer, as the unit number parameter in at least one FORTRAN I/O statement, of any kind, anywhere in the compilation.
Introduction to File I/O in the HP NonStop Environment Unit Assignment The ASSIGN Command The TACL ASSIGN command enables you to assign the name of an actual file to a unit specified in a program and to specify the characteristics of the file at run time. ASSIGN [ logical-unit [,[ filename ][, create-spec]... ] ] logical-unit is the unit name specified in the UNITNAME option of the UNIT compiler directive. The name can be from 1 to 31 characters including letters, digits, and hyphens.
Introduction to File I/O in the HP NonStop Environment Unit Assignment access-spec is one of the following access modes for logical-unit. Keyword Meaning I-O This process can both read from and write to the file. I-O is the default value. INPUT This process can only read the file. OUTPUT This process can only write to the file. An OPEN statement can override the value of access-spec with the MODE specifier.
Introduction to File I/O in the HP NonStop Environment Unit Connection If you entered FT002 for logical-unit, the following information would be displayed: FT002 PHYSICAL FILE: DATAFILE EXCLUSION: EXCLUSIVE ACCESS: INPUT To get a list of the assigned attributes of all logical units, enter: 1> ASSIGN For additional information on the ASSIGN command, see the TACL Reference Manual.
Introduction to File I/O in the HP NonStop Environment Specifying File Attributes If you use more than one method to specify the same file attribute, the compiler uses the following order of precedence to determine the attribute value: OPEN statement <-- highest ASSIGN TACL command UNIT compiler directive Default <-- lowest That is, an attribute value specified in an OPEN statement overrides a different value specified for the same attribute of that unit in an ASSIGN command, and so forth.
Introduction to File I/O in the HP NonStop Environment Specifying File Attributes Table 5-5. File Attribute Specification (page 2 of 2) Unit Directive Assign Command Attribute Default Open Statement num is an unsigned integer. In an OPEN statement, exp is an integer expression. access is I-O, INPUT, or OUTPUT. In an OPEN statement, cexp is a character expression whose value is one of these. exclusion is SHARED, PROTECTED, or EXCLUSIVE.
Introduction to File I/O in the HP NonStop Environment File Characteristics After you compile the program but before you run it, you might enter the following ASSIGN commands: 1> ASSIGN vector, $data.test.input, REC 400 2> ASSIGN ft003, , OUTPUT, EXT 4 When the object program runs, units 4, 5, and 6 are automatically connected to the home terminal, standard input file, and standard output file respectively.
Introduction to File I/O in the HP NonStop Environment • • • • • Unstructured Files All physical records are the same length. All logical records are the same length. You can access records sequentially or directly. You can read, write, or update any record in the file but you can never delete a record once it has been written. You cannot use alternate keys. EDIT Format Files EDIT format files are unstructured files. Each line of an EDIT format file is a record of that file.
Introduction to File I/O in the HP NonStop Environment • Structured Files ° ° ° You can read and write records sequentially. ° You can change the length of a record as long as the length does not exceed the specified record size for the file. ° You can delete records. You can backspace the file, rewind the file, or write an endfile record to the file. You can use direct access for reading and writing records in the file. The record number is the record’s EDIT line number times 1000.
Introduction to File I/O in the HP NonStop Environment Structured Files 3. Check the values of file creation parameters with the SHOW command. Note that the SHOW command displays default values for file attributes in addition to the values you specify. 4. Create the file with the CREATE command. FUP checks the values you chose with the SET command and creates a file if those values will result in a legal file. 5. Specify STATUS='OLD' in the OPEN statement for a structured file.
Introduction to File I/O in the HP NonStop Environment Structured Files The following example shows how to create the entry-sequenced file VISITORS. The default record size for the file is 80 bytes. 1> FUP File Utility Program - T6553D10 - (08JUN92) System \ASYS Copyright Tandem Computers Incorporated 1981, 1983, 1985-1992 -SET TYPE E <-- Set file type -SHOW <-- Show current values TYPE E EXT ( 1 PAGES, 1 PAGES ) REC 80 BLOCK 4096 MAXEXTENTS 16 -CREATE visitors <-- Create the file CREATED - $JUICE.BUJES.
Introduction to File I/O in the HP NonStop Environment • Structured Files If you READ the file directly with REC= specifying the nonnegative record number (including 0) of a record that does not exist, then ° If the specified record number is beyond the end of the file, you get an endoffile indication. ° Otherwise, you get the record with the smallest record number that is greater than or equal to the specified record number. FORTRAN does not consider this an error.
Introduction to File I/O in the HP NonStop Environment Structured Files The following example shows how to create the key-sequenced file VENDORS.
Introduction to File I/O in the HP NonStop Environment Structured Files Customer Name 0 Alternate Key CN Product Name 32 Alternate Key PR Quantity 64 80 VST0502.
Introduction to File I/O in the HP NonStop Environment Operations on HP-defined Files Operations on HP-defined Files Table 5-6 shows the operations that you can perform on HP-defined files. For additional information about $RECEIVE and process files, see Section 14, Interprocess Communication. Table 5-6.
Introduction to File I/O in the HP NonStop Environment Control Specifiers in I/O Statements Table 5-7. I/0 Control Specifiers (page 1 of 2) Control Specifier UNIT = unit Meaning Is an integer expression ranging from 1 through 999 that specifies the FORTRAN unit to use. unit can be an asterisk (*) implying the default input unit in a READ statement or the default output unit in a WRITE statement.
Introduction to File I/O in the HP NonStop Environment I/O Lists Table 5-7. I/0 Control Specifiers (page 2 of 2) Control Specifier Meaning END = label Specifies the label of an executable statement to which FORTRAN transfers control if an end of file is encountered during an input operation. You can use this specifier only with the READ statement. ERR = label Specifies the label of an executable statement to which FORTRAN transfers control if an error condition is encountered during I/O processing.
Introduction to File I/O in the HP NonStop Environment Using Implied DO Lists Using Implied DO Lists An implied DO list has the following form: ( [(]... ar-nam1( var1 [, var2 ]... ) [, ar-nam2( var1 [, var2 ]... ) ]... , var1 = iexp1, fexp1°[, incr1 ] ) [, var2 = iexp2, fexp2°[, incr2°] ) ]... ar-name is the name of an array. var is an integer, real, or double precision control variable. It must be a simple variable, not an array element or a RECORD component.
Introduction to File I/O in the HP NonStop Environment Unformatted I/O You can use a WRITE statement to write the elements of more than one array. The following WRITE statement writes the 100 elements in each of the three arrays A, B, and C: INTEGER a(10, 10), b(10, 10), c(10, 10) WRITE(9,10) ((a(i,j), b(i,j), c(i,j), i = 1,10), j=1,10) Unformatted I/O If a data transfer statement does not contain a format specifier in its control list, it is an unformatted I/O statement.
Introduction to File I/O in the HP NonStop Environment List-Directed I/O List-Directed Input The form of the input field must be acceptable for the type of the input list item. Input data consists of a string of values separated by one or more blanks, by a comma, or by a slash (/). If the separator is a comma or a slash, it can be preceded and/or followed by any number of blanks. The end of a record is treated as a blank character.
Introduction to File I/O in the HP NonStop Environment List-Directed I/O If you input a null in place of a constant, the value of the corresponding list entity is not changed. Indicate a null using a comma as the first character in the input string or two commas separated by blanks; for example: READ *, j, k Input: 2, 10 Value: 2 10 , 5 2 5 1, 7 1 7 , , 1 7 A slash value separator causes FORTRAN to treat the remaining list elements as nulls and to discard the remainder of the current record.
Introduction to File I/O in the HP NonStop Environment I/O Performance Logical values are output as T or F. Complex values are enclosed in parentheses with a comma separating the real from the imaginary part. The following sample program is an example of list-directed output: PROGRAM example INTEGER k(5) COMPLEX a, b REAL c DATA a, b, c, k/(6, 1), (3, -2), 1.E-3,5,10,20,40,1/ PRINT *, a, b PRINT *, c PRINT *, k END Output: (6, 1) (3, -2) .
Introduction to File I/O in the HP NonStop Environment Read-Through Locks However, your program can read a locked record, without waiting for the lock to be released, by calling the Guardian SETMODE procedure to specify use of the “readthrough locks” feature as follows: CALL SETMODE (FILENUM (u), 4, 6, 0) The SETMODE call tells the operating system to allow your program to read through locks on the specified file. Call SETMODE after you have opened the file, but before the first read from the file.
6 Introduction to Statements This section provides introductory information to Section 7, Statements. Topics covered in this section include: Topic Page Executable and Nonexecutable Statements 6-1 Statement Types 6-3 Statement Order 6-4 Statement Labels 6-5 Error Numbers 6-5 Executable and Nonexecutable Statements A FORTRAN statement is either executable or nonexecutable.
Executable and Nonexecutable Statements Introduction to Statements Table 6-1.
Statement Types Introduction to Statements Table 6-1.
Statement Order Introduction to Statements Table 6-2 lists the characteristics of each group of statements. Table 6-2. FORTRAN Statement Types Type Action Program unit Nonexecutable. Marks the beginning or end of a program unit. Specification Nonexecutable. Specifies the characteristics of the user-defined symbolic names used in the program. Assignment Executable. Defines or redefines the values of variables in a program. Control Executable.
Statement Labels Introduction to Statements Figure 6-1 on page 6-3 shows the order in which statements can appear in your program. Statement Labels A statement label uniquely identifies a statement within a program unit and must not be defined more than once in that unit. A statement label consists of from one to five digits, ranging in value from 1 to 99999. All digits must appear in columns one to five. Blanks are ignored.
Error Numbers Introduction to Statements FORTRAN Reference Manual—528615-001 6 -6
7 Statements This section describes the FORTRAN language statements. Topics covered in this section include: Topic Page Type Declaration Statements 7-1 Statement Function 7-5 Assignment Statement 7-7 For a summary of FORTRAN statements and an explanation of statement order and statement types, see Section 6, Introduction to Statements. Type Declaration Statements You use type declaration statements to override or confirm implicit typing and to specify the dimensions of arrays.
Type Declaration Statements—CHARACTER Statements Type Declaration Statements—CHARACTER The CHARACTER statement defines a variable, array, RECORD field, symbolic constant, function name, or dummy procedure as character type. CHARACTER [* len] name [ dimension ] [* len] [, name [ dimension ] [* len] ]... len is an unsigned, nonzero positive constant, an integer constant expression enclosed in parentheses, or an asterisk enclosed in parentheses that specifies the length, in bytes, of name.
Type Declaration Statements—LOGICAL Statements subroutine or function. If the actual argument is an array name, len equals the length of an array element. ° If an external function uses the (*) length specification in a function subprogram, the function name must appear as the name of a function in a FUNCTION or ENTRY statement within the same subprogram. When a calling program unit references this function, len assumes the length declared for that external function name in the calling program unit.
Type Declaration Statements—NUMERIC Statements Considerations See the description of the LOGICAL*4 directive in Section 10, Compiler Directives. For information about two-word logical types and standard conformance, see Section 2, Language Elements.
Statement Function Statements For additional information about numeric type declarations, see Section 2, Language Elements. Examples The following statement declares EXPENSE as a double precision variable: DOUBLE PRECISION expense The following statement declares the variable CURRENT as a complex variable: COMPLEX current The following statement declares the variables POPULATION and CONSUMPTION as doubleword integers.
Statement Function Statements 3. It computes a value for expression. 4. It converts the resulting value to the data type of the function name. When execution of the statement function terminates, FORTRAN assigns the resulting value to the function name in the referencing statement. In the following example, FORTRAN uses the value of (DIAMETER/2) in the referencing statement to obtain a value for the statement function: volume(radius) = 4.
Assignment Statement Statements Example The following example defines and references the statement function NETPAY to calculate the net pay of each employee: REAL netpay, salary, tax, insure netpay(salary,tax,insure) = salary-(tax*salary)-insure DO 5 j = 1,n READ (*,*) employee, s, t, x salary = netpay(s,t,x) WRITE (*,*) employee, salary 5 CONTINUE Assignment Statement An assignment statement defines the value of an arithmetic, character, or logical entity.
Assignment Statement Statements contain the value, arithmetic overflow occurs. The type of name need not be the same as the type of arithmetic-expression, but both must be arithmetic types. If either name or arithmetic-expression is type character, both must be type character. If either name or arithmetic-expression is type logical, both must be type logical.
ASSIGN Statement Statements Examples In the following example, the expression BALES * 345.87 is evaluated, converted to a double precision number, and stored in the variable WEIGHT. DOUBLE PRECISION weight weight = bales * 345.87 In the following example, the variable X is typed as a logical variable and assigned a logical value of .TRUE.. LOGICAL x x = .TRUE.
BACKSPACE Statement Statements You can use 501 ASSIGN statements within a single program unit. Example ASSIGN 10 to J GO TO 50 10 CONTINUE . ASSIGN 20 TO J GO TO 50 20 CONTINUE . 50 statement . GO TO J(10,20) BACKSPACE Statement The BACKSPACE statement backspaces by one record the file connected to a unit. If there is no preceding record in the file, FORTRAN ignores the statement. unit , IOSTAT=ios unit . . .
BACKSPACE Statement Statements lbl is the label of an executable statement in the current program unit to which FORTRAN transfers control if an error occurs while executing the BACKSPACE statement. You can write the control specifiers in any order, except that if you omit the UNIT keyword, you must write the unit specifier as the first item in the list. Considerations • • • • If the file is an unstructured disk file that does not exist, the BACKSPACE statement creates it.
BLOCK DATA Statement Statements ° In a UNIT compiler directive, as in: UNIT (5, INPUT) UNIT (6, OUTPUT) For more information about using units 5 and 6 as shared files, see the OPEN Statement on page 7-70. • • If a BACKSPACE statement causes unit 5 or unit 6 to be implicitly opened and your program is running as a NonStop process, the FORTRAN run-time library does a stack checkpoint to the backup process as a part of the implicit open.
CALL Statement Statements • • Observe the following restrictions when using the BLOCK DATA statement: ° Write the BLOCK DATA statement as the first statement of a block data subprogram. ° ° ° ° Use only one unnamed block data subprogram in an executable program. Terminate the BLOCK DATA subprogram with an END statement. You cannot initialize RECORD fields in BLOCK DATA subprograms. You can initialize variables and arrays in common blocks only in BLOCK DATA subprograms.
CALL Statement Statements Considerations • • • • • Actual arguments in a CALL statement must agree in number, order, and type with the dummy arguments specified in the SUBROUTINE statement of the called subroutine. An actual argument cannot be a character expression involving the concatenation of an operand having a length specification of (*), unless the operand is the symbolic name of a constant.
CHECKPOINT Statement Statements CHECKPOINT Statement The CHECKPOINT statement establishes a takeover point for a backup process, or transfers the data and environment information needed by the backup process to take over, or both. CHECKPOINT is an HP extension to the ANSI standard. CHECKPOINT enables you to use the HP fault-tolerant programming facility. CHECKPOINT ° ( [ UNIT= ]unit [ , UNIT=unit ]. . . [ , cpt – spec ]. . . ) ( cpt – spec [ , cpt – spec ]. . . ) [ data [, data ]...
CHECKPOINT Statement Statements CPLIST = cplist is an array that contains a checkpoint list constructed by the Saved Message Utility procedures. You can provide any number of CPLIST specifiers in one CHECKPOINT statement. See Considerations. data is a variable name, array name, array element name, RECORD name, or common block name that specifies a data item whose value is to be checkpointed by CHECKPOINT. See Considerations.
CHECKPOINT Statement Statements checkpoint large amounts of data to the backup process. For more information on this usage, see Section 16, Fault-Tolerant Programming. • CPLIST specifier The CPLIST specifier enables you to checkpoint changes to saved messages. You must provide a complete checkpoint list in the form of an INTEGER*4 array for cplist. The first element is a header for the list and each remaining element is a single entry in the checkpoint list.
CLOSE Statement Statements • For further information, see Section 16, Fault-Tolerant Programming. Examples CHECKPOINT CHECKPOINT (ERR=200, BACKUPSTATUS=ierr) accountno CHECKPOINT (6, STACK='YES') msgnum, replycode CLOSE Statement The CLOSE statement disconnects a file from a specified unit and specifies the status of the file after disconnection. CLOSE ( close-spec [, close-spec ]...
CLOSE Statement Statements Considerations • Use of the CLOSE statement You do not need to include the CLOSE statement in the program unit which opened the file. After you have disconnected a unit using the CLOSE statement, you can reconnect the unit within the same program to the same or to a different file. A CLOSE statement that refers to a unit that does not exist or that has no file connected to it has no effect.
COMMON Statement Statements unit specified in the UNIT specifier; this establishes a takeover point for the backup process. If you specify STACK = 'NO', FORTRAN does not checkpoint the memory stack and does not establish a takeover point. If failure occurs, the backup uses the takeover point established by a previous OPEN, CLOSE, or CHECKPOINT statement that specified STACK = 'YES' or did not specify a STACK option.
COMMON Statement Statements If you declare a common block name more than once in the same program unit, the compiler treats each such common block as a continuation of the first declaration.
COMMON Statement Statements block beyond its last storage location. The following examples illustrate this restriction: Illegal Legal COMMON xitem COMMON xitem REAL price(5) REAL price(5) EQUIVALENCE(xitem,price(5)) EQUIVALENCE(xitem,price(1)) You cannot equivalence fields of two different common blocks in the same program unit.
CONTINUE Statement Statements Example The following example shows how the main program unit shares data with a subroutine and function subprogram through the use of common blocks. The same area of blank common is used in the main program and in the function COST OF SALES. The common block SALES is used in the main program and in the subroutine SALESREPORT. PROGRAM main COMMON product, price COMMON /sales/salesman, commission . END SUBROUTINE salesreport(x, y) COMMON /sales/salesrep, commission due .
DATA Statement Statements Example In the following example, the PRINT statement executes when J is greater than 10: sum = 0 DO 100 j = 1, 10 sum = sum + 1 100 CONTINUE PRINT *, sum DATA Statement The DATA statement assigns initial values to variables, arrays, array elements, and substrings at compile time. DATA list / data / [ [,] list / data / ]... list is a list of entities separated by commas. An entity can be a variable name, array name, array element name, substring name, or an implied DO list.
DATA Statement Statements Considerations • • DATA statements must follow any specification statements that define the entities initialized by the DATA statement. Except for this restriction, DATA statements can appear anywhere in a program unit. list cannot include the name of a RECORD, dummy argument, function, entry point, or entity in blank common. list can include names of entities in a named common block only within a BLOCK DATA subprogram.
DIMENSION Statement Statements Examples DATA stock,rate,high,low/3500,15.25,42.75,13/ CHARACTER * 12 headings(5) DATA headings/'April','May','June','July','August'/ DIMENSION Statement The DIMENSION statement declares an array name and the number and size of its dimensions. DIMENSION name ( dimension) [, name ( dimension) ]... name is the symbolic name of an array or a RECORD. dimension is the array bounds specification in the form: [ lower:] upper [, [ lower:] upper ]...
DO Statement Statements • For additional information about array size and storage, see Section 2, Language Elements. Examples The following statements declare and dimension a 10-element array, in which each array element contains 15 characters: CHARACTER item*15 DIMENSION item(0:9) The following statement declares a two-dimensional array: DIMENSION numbers(5, 11) DO Statement The DO statement specifies a DO loop that repeats execution of one or more statements.
DO Statement Statements 1. The expressions iexp, fexp, and incr are evaluated and converted to the type of the control variable var if necessary. 2. The control variable is assigned the value of iexp. 3. The iteration count is calculated according to the following expression: MAX(INT(( fexp - iexp + incr)/ incr),0) The INT function truncates the result of the expression to an integer value; the MAX function selects the larger of that value or zero.
DO Statement Statements • ° An END statement Nested DO loops When a DO loop contains another DO loop, the arrangement is called nesting. The range of a DO statement can include other DO statements as long as the range of each inner DO is entirely within the range of the containing DO statements. The last statement of an inner DO loop must be either the same as that of its containing DO loop or occur before it. Example A shows nested DO loops that share the same terminal statement.
ELSE Statement Statements ELSE Statement The ELSE statement defines the beginning of a block of statements to execute as an alternative to the block of statements that follows an IF or ELSE IF statement. For more information about the ELSE statement, see the IF Statement—Block on page 7-60.
ENDFILE Statement Statements ENDFILE Statement The ENDFILE statement writes an endfile record as the next record of the file connected to the specified unit. You can write the ENDFILE specifiers in any order. However, if you omit the UNIT keyword when you specify unit, unit must be the first item in the list.
ENDFILE Statement Statements If you specify ios, but not lbl, and an error occurs while writing the end of file, your program continues executing with the statement that follows the ENDFILE statement. You can analyze ios to determine the error that occurred, if any. If you do not specify ios or lbl, and an error occurs, FORTRAN terminates your program and displays a run-time diagnostic message.
END IF Statement Statements Examples ENDFILE 40 ENDFILE (40, IOSTAT=error, ERR=300) END IF Statement The END IF statement defines the end of a block of statements that began with an IF, ELSE IF, or ELSE statement. For more information about the END IF statement, see the IF Statement—Block on page 7-60. ENTRY Statement The ENTRY statement provides an alternate entry point for a subprogram. It also enables you to specify an alternative dummy argument list for the subprogram.
ENTRY Statement Statements When you invoke a function specified by this form, you must reference it as name(). For example: PROGRAM main x = surcharge() END FUNCTION tax (a, b, c) ENTRY surcharge END • Dummy arguments The dummy argument list in an ENTRY statement can be different from the dummy argument list in the FUNCTION or SUBROUTINE statement of the subprogram in which it appears, or from the argument lists in other ENTRY statements in the same program.
ENTRY Statement Statements ° In a function subprogram, an entry point name must not appear in any statement other than a type declaration statement preceding the ENTRY statement for that name. ° A dummy argument name must not appear in any statement in a subprogram other than a type declaration statement prior to its first appearance as a dummy argument in a SUBROUTINE, FUNCTION, or ENTRY statement.
EQUIVALENCE Statement Statements EQUIVALENCE Statement The EQUIVALENCE statement defines the sharing of storage space by two or more entities in a program unit. EQUIVALENCE ( var-list) [, ( var-list) ]... var-list is a comma-separated list of variable names array names, array element names, character substring names, or RECORD names. Considerations • • • • • The compiler assigns the same storage location to all entities in var-list.
Equivalence With Length Differences Statements Equivalence With Length Differences You can equivalence fields of different lengths as long as the EQUIVALENCE statement does not violate the implicit alignment rules of these fields.
EXTERNAL Statement Statements EXTERNAL Statement The EXTERNAL statement declares the name of an external procedure and enables you to use the name as an actual argument. EXTERNAL proc-name [, proc-name ]... proc-name is the name of an external procedure, dummy procedure, or block data subprogram. Considerations If you use an external procedure name or dummy procedure name as an actual argument in a program unit, you must declare it in an EXTERNAL statement in the program unit.
FORMAT Statement Statements FORMAT Statement The FORMAT statement is used together with formatted I/O statements to write formatted output or read formatted input. FORMAT ( [ format-list ] ) format-list is a list of items, separated by field separators (, /): [ repeat ]ed ned [ repeat ] ( format – list ) repeat is a nonzero, unsigned, integer constant that specifies the number of successive appearances of ed or format-list. ed is a repeatable edit descriptor.
Termination of Format Control Statements as FORMAT (I6, I6, F6.2, F6.2, (I5, E3.1, I5, E3.1)) Blanks are not significant in a format specification unless they are part of a literal string. Termination of Format Control For each repeatable edit descriptor in a format specification, format control determines whether there is a corresponding I/O list item. If it finds a corresponding item, it transmits the specified edited information between the item and the record and proceeds to the next item.
Edit Descriptors Statements Table 7-1 lists the repeatable edit descriptors. Table 7-2 on page 7-42 lists the nonrepeatable edit descriptors. The following subsections provide additional information about the use of these edit descriptors. Table 7-1. Repeatable Edit Descriptors (page 1 of 2) Descriptor Type Format Example Sample Output Ew.d numeric E8.1 0.1E+03 Single precision floating-point with exponent Ew.dEe numeric E8.2E2 0.
Edit Descriptors Statements Table 7-1. Repeatable Edit Descriptors (page 2 of 2) Descriptor Format Example Type Sample Output Description w Nonzero unsigned integer constant specifying the field width in number of character positions in the external record. Depending on the edit specifier (I, E, F, D, G, B, O, Z or A), the field width can specify the number of positions necessary to accommodate digits, characters, leading blanks, + or - signs, decimal point, and exponent.
Editing Numeric Data Statements Editing Numeric Data The edit descriptors: B G D I E O F Z specify the external format of integer, real, double precision, and complex data. The following general rules apply to numeric editing: • • • • • • On input, leading blanks are not significant. The treatment of other blanks is determined either by the BLANK= specifier in an OPEN statement or by any BN or BZ specifiers for that unit. The formatter treats a field of all blanks as zero.
Editing Numeric Data Statements the format specification of F5.2 and the imaginary part has the format specification of E6.3: COMPLEX a WRITE (6, 5) a, b 5 FORMAT(F5.2,E6.3,F4.2) The I Descriptor The I w, I w. m, and I w. m. b descriptors specify that the field occupies w character positions. Optionally, they also define the number base for the output data (b) and the minimum number of digits (m). Base 10 is assumed when b is omitted; 1 is assumed when m is omitted.
Editing Numeric Data Statements The F Descriptor The F descriptor specifies conversion between an internal real or double precision number and an external floating-point number with or without an exponent. The F w. d form specifies that the field occupies w positions, the fractional part of which consists of d digits. The input field consists of an optional sign, followed by a string of digits, optionally containing a decimal point.
Editing Numeric Data Statements The E and D Descriptors The E descriptor specifies conversion between an internal real or double precision value and an external floating point number with an exponent. The D descriptor specifies conversion between an internal double precision value and an external floating point number with an exponent. The E descriptor uses one of the following forms: E w. d E w.
Editing Numeric Data Statements For example, suppose the data item is type INTEGER*4. The binary conversions produced are shown in Table 7-3 (circumflexes designate blank characters). Table 7-3. Values Converted With the B Descriptor Internal Value Format Descriptor External Value 0 I10.1.2 ^^^^^^^^^0 5 I10.1.2 ^^^^^^^101 -3 I10.1.
Editing Numeric Data Statements Table 7-4. Values Converted With the O Descriptor (page 2 of 2) Internal Value Format Descriptor External Value 0 O20 ^^^^^^^^^^^^^^^^^^^0 5 O20 ^^^^^^^^^^^^^^^^^^^5 -3 O20 ^^^^^^^^^37777777775 0 I20.6.8 ^^^^^^^^^^^^^^ 000000 5 I20.6.8 ^^^^^^^^^^^^^^ 000005 -3 I20.6.8 ^^^^^^^^^^^^^-000003 0 O20.6 ^^^^^^^^^^^^^^ 000000 5 O20.6 ^^^^^^^^^^^^^^ 000005 -3 O20.6 ^^^^^^^^^37777777775 The Z Descriptor The Z w and Z w.
Editing Numeric Data Statements Table 7-5. Values Converted With the Z Descriptor (page 2 of 2) Internal Value Format Descriptor External Value 0 Z12.8 ^^^^ 00000000 5 Z12.8 ^^^^ 00000005 -3 Z12.8 ^^^^ FFFFFFFD The G Descriptor The G w. d and G w. dE e edit descriptors indicate that the field occupies w positions, the fractional part of which consists of d digits, unless a scale factor greater than one is in effect, and the exponent consists of e digits.
Logical Editing Statements Table 7-7. Comparison of F and G Editing (page 2 of 2) Value F13.6 Editing G13.6 Editing 123.45678900 123.456789 123.457 1234.56789000 1234.567890 1234.57 12345.67890000 12345.678900 12345.7 123456.78900000 123456.789000 123457. 1234567.89000000 ************* 0.123457E+07 The P Descriptor The P descriptor has the form kP where k is an integer constant called the scale factor. If you omit this specification, FORTRAN assumes a default value of 0 for k.
Alphanumeric Editing Statements The input field consists of optional blanks, optionally followed by a decimal point, followed by an uppercase T for true or an upper-case F for false (lowercase letters are invalid). Additional characters (uppercase or lowercase) can follow the T or F. Note that the logical constants .TRUE. and .FALSE. are valid input forms. The output field consists of w-1 blanks, followed by the letter T or the letter F, depending on the logical value of the internal datum.
Positional Editing Statements Do not use an apostrophe edit descriptor on input. The H Descriptor The nH edit descriptor causes the n characters (including blanks) that immediately follow the H to be written to the output record directly from the edit descriptor itself, in the same way as the characters in an apostrophe edit descriptor are written to the output device. You cannot use an H descriptor on input.
Slash Editing Statements Slash Editing The slash edit descriptor (/) indicates the end of data transfer on the current record. On input from a file connected for sequential access, a slash descriptor causes FORTRAN to skip the remaining part of the current record and to position the file at the beginning of the next record, which becomes the current record.
FUNCTION Statement Statements output the value of 100 for I, and 20.03 for Y. Given the preceding input record, the following statements output the value of 10 for J, and 0.23 for B. READ (6, 11) j, b 11 FORMAT (BN, I3, F5.2) PRINT *, j, b FUNCTION Statement The FUNCTION statement designates the beginning of a function subprogram. [ type ] FUNCTION func-name ( [ dmy [, dmy ]... ] ) type is INTEGER, INTEGER*2, INTEGER*4, INTEGER*8, REAL, DOUBLE PRECISION, COMPLEX, LOGICAL, or CHARACTER [* len].
GO TO Statement Statements PARAMETER, SAVE, INTRINSIC, DATA, or COMMON statement, except as a common block name. FORTRAN replaces dmy with an actual argument when it executes the function. • If dmy is an array name, you must dimension the array within the function subprogram using a DIMENSION or type statement. For the use of adjustable dimension declarators and for further information about function subprograms, see Section 4, Program Units.
Unconditional GO TO Statements ivar is an integer variable previously assigned a label value in an ASSIGN statement. Considerations A GO TO statement must not transfer control to a statement within a DO loop. Unconditional GO TO An unconditional GO TO statement transfers program control directly to the statement whose label is specified by the GO TO statement. In the following example, control passes from the GO TO statement to the PRINT statement labeled 300.
Assigned GO TO Statements statement and a GO TO statement that uses the label stored by the ASSIGN statement: ASSIGN 10 to j . IF (x .GT. 0) THEN ASSIGN 20 to j END IF GO TO j,(10,20) . 10 CONTINUE . 20 CONTINUE The program branches to 20 if X is greater than 0 and to 10 if X is less than or equal to 0. Considerations FORTRAN ensures that all labels referenced in the assigned GO TO statement are in the current program unit and are associated with executable statements.
IF Statement—Arithmetic Statements The following example shows a computed GO TO: INTEGER region 5 READ (*,*) region READ (*,*) time GO TO (10, 20, 30) region 10 charge = time * .25 GO TO 40 20 charge = time * .27 GO TO 40 30 charge = time * .36 GO TO 40 40 CONTINUE The following example shows an assigned GO TO: 10 ASSIGN 20 TO k 20 I = 50 . .(main processing loop) . 250 IF (type .EQ. 'end') ASSIGN 350 TO k . 340 GO TO k, (20,350) 350 TOT = i + m . .
IF Statement—Logical Statements label1, label2, label3 are integers designating the labels of executable statements in the same program unit. The same statement label can appear more than once in the same arithmetic IF statement. Considerations The arithmetic IF statement transfers control to • • • label1 if the value of exp is negative. label2 if the value of exp is zero. label3 if the value of exp is greater than zero.
IF Statement—Block Statements Considerations The logical IF statement executes statement if exp is true, or continues to the next executable statement if exp is false. Example IF (balance .GT. 10000) account = preferred account IF Statement—Block The block IF statement is used with the END IF statement and, optionally, with the ELSE IF and ELSE statements, to select groups of statements to execute. IF ( exp) THEN if-block [ ELSE IF ( exp ) THEN if-block ]...
IF Statement—Block Statements • You can use an ELSE statement to specify a group of statements to execute if the initial condition is false: IF (loan type .EQ. 'consumer') THEN rate = normal rate premium = 1000 ELSE rate = normal rate * .9 premium = 500 END IF • If more than two conditions must be considered, you can use ELSE IF statements, each followed by an if-block: IF(loan type .EQ. 'A') THEN rate = normal rate premium = 1000 ELSE IF (loan type .EQ. 'B') THEN rate = normal rate * .
IF Statement—Block Statements • You can ensure that your program executes at least one if-block by using ELSE IF and ELSE statements: IF(loan type .EQ. 'A') THEN rate = normal rate premium = 1000 ELSE IF (loan type .EQ. 'B') THEN rate = normal rate * .9 premium = 500 ELSE IF (loan type .EQ. 'C') THEN rate = normal rate * .85 premium = 100 ELSE rate = normal rate * .75 premium = 50 END IF • You can code an empty if-block if you want to test for a specific value but not take action for that value.
IMPLICIT Statement Statements Example IF (sales .GT. 5000) THEN IF (travel .LT. 1000) THEN bonus = 100 ELSE bonus = 50 END IF ELSE bonus = 50 END IF IMPLICIT Statement The IMPLICIT statement redefines or confirms the default typing of variables, arrays, and functions, based on the first letter of the item’s name. IMPLICIT type ( char-list) [, type ( char-list) ]...
INQUIRE Statement Statements with A, X, Y, and Z are character type and represent character data that is 15 characters long. IMPLICIT CHARACTER*15 (a, x-z) • The data type of an item declared in a type declaration statement overrides the type specified in an IMPLICIT statement.
INQUIRE Statement Statements inq-spec is a keyword followed by an equal sign followed by a variable or array element in which FORTRAN returns the information specified by the keyword. You can specify inq-specs in any order. inq-spec is one of the following: IOSTAT = ios ios is an integer variable or integer array element in which FORTRAN returns an error number if an error occurs while executing the INQUIRE statement. If the INQUIRE statement is successful, ios is zero.
INQUIRE Statement Statements ACCESS = acc acc is a character variable or array element. If the file is connected for sequential access, acc returns the value 'SEQUENTIAL'; if the file is connected for direct access, acc returns the value 'DIRECT'. SEQUENTIAL = seq seq is a character variable or array element.
INQUIRE Statement Statements 'YES'. If the file can never be connected for unformatted I/O, unf returns the value 'NO'. If the system cannot determine whether unformatted I/O is permitted, unf returns the value 'UNKNOWN'. HP FORTRAN always returns 'YES' in fmt. RECL = rcl rcl is an integer variable or array element that returns the record length, specified in bytes, for the file. rcl returns a value of zero if the file is not open. NEXTREC = nr nr is an INTEGER*4 variable or array element.
INQUIRE Statement Statements name you specify in the FILE = file-name specifier for an inquiry by file. For example, after execution of the following: file id = 'myfile' INQUIRE (FILE=file id, NAME = title) TITLE contains a fully qualified file name such as $MYVOL.MYSVOL.MYFILE (if the specified file exists), while the value of FILE ID is still MYFILE (either the full name or the short form is acceptable when specifying the file name in an OPEN or INQUIRE statement).
INTRINSIC Statement Statements INTRINSIC Statement The INTRINSIC statement identifies the names of intrinsic functions, and enables you to specify intrinsic function names as actual arguments to subprograms. INTRINSIC function [, function ]... function is an intrinsic function name. Considerations • • • • • If you use an intrinsic function name as an actual argument in a CALL statement or function reference, you must declare it in an INTRINSIC statement in that program unit.
OPEN Statement Statements Example SUBROUTINE A INTRINSIC SQRT . CALL number(x, y, SQRT) . END SUBROUTINE number(a, b, c) CALL C(A) CALL C(B) END OPEN Statement The OPEN statement associates an existing file with a unit number, or creates a new file and associates it with a unit number. OPEN ( [UNIT=] unit [, open-spec ]... ) unit is an integer expression ranging from 1 through 999. Once defined, the properties of this unit are the same for all program units of the executable program.
OPEN Statement Statements FILE = fn fn is a character expression that specifies the name of the file to connect to unit. It can also be a DEFINE name. For more information about the format of file names, see the Guardian Programmer’s Guide. STATUS = stat stat is a character expression with the value of 'OLD', 'NEW', 'SCRATCH', or 'UNKNOWN'. The default is 'UNKNOWN'. ACCESS = acc acc is a character expression with the value of 'DIRECT' or 'SEQUENTIAL'. The default is 'SEQUENTIAL'.
OPEN Statement Statements The default value for sync is device dependent. For more information, see the FILE_OPEN_ procedure in the Guardian Procedure Calls Reference Manual. MODE = mode mode is a character expression with the value 'INPUT', 'OUTPUT', or 'I-O' that specifies whether the file is to be used for reading, writing, or reading and writing. The default value (in the absence of a UNIT directive or ASSIGN command specifying otherwise) is 'I-O'.
OPEN Statement Statements • Improving program performance If a file is a structured disk file (relative, entry-sequenced, or key-sequenced), your FORTRAN program runs faster if you specify the following attributes in the file’s OPEN statement. These attributes enable sequential block buffering: ACCESS = 'SEQUENTIAL' MODE = 'INPUT' PROTECT = 'PROTECTED' or 'EXCLUSIVE' • Spooler output with ENV OLD By default, your program uses level-3 spooling if the file you write to is a spooler collector.
OPEN Statement Statements If you compile your program with ENV COMMON, your program can share access to unit 5 and unit 6 with modules written in languages other than FORTRAN.
OPEN Statement Statements • ACCESS specifier The default setting is 'SEQUENTIAL'. If you open a file with ACCESS = 'SEQUENTIAL' specified or assumed: ° ° An INQUIRE statement’s ACCESS specifier returns 'SEQUENTIAL'. ° For a structured (relative, entry-sequenced, or key-sequenced) disk file, READ statements use sequential block buffering if the OPEN statement also specifies ° ° MODE = 'INPUT' and PROTECT = 'PROTECTED' or 'EXCLUSIVE' for the file.
OPEN Statement Statements The blank specifier is meaningful only when you use formatted I/O on a file. The default value for the blank specifier is 'NULL'. If you specify 'NULL', all blank characters read into formatted numeric input fields are ignored; a field of all blanks is treated as zero. If you specify 'ZERO', all blanks except leading blanks are treated as zero. If you open a file that is already connected to the specified unit, only the BLANK specifier can be different from the original open.
OPEN Statement Statements • PROTECT specifier When a process opens a Guardian file, the PROTECT option specifies to what degree the process is willing to share access to the file with other openers or potential openers of the file. The other openers might be in other processes or in the same process as the current opener. For example, if a process specifies PROTECT = 'EXCLUSIVE', the file must be closed when the process opens the file.
OPEN Statement Statements Table 7-8.
PARAMETER Statement Statements If you run your program as a NonStop process, an OPEN statement automatically checkpoints program environment information to your backup process. The effect of this specifier is the same as that in the CHECKPOINT statement, which is described in this section and in Section 14, Interprocess Communication.
PARAMETER Statement Statements ° • • If the first letter of name designates a logical type, exp must be a logical expression. If a symbolic name appears in the constant expression, it must have been previously defined in the same or a different PARAMETER statement in the same program unit. If the implicit data type of name is not the correct type for exp, you must specify the type of name in a type statement or an IMPLICIT statement before you use name in a PARAMETER statement.
PAUSE Statement Statements PAUSE Statement The PAUSE statement temporarily halts program execution. PAUSE [ message ] message is an unsigned integer constant of up to five digits or a character constant of up to 80 characters that is displayed when the program executes the PAUSE statement.
POSITION Statement Statements ios is a variable or array element of integer type that returns an error number or zero (no error) following execution of the POSITION statement. For more information about error numbers, see the Error Numbers on page 6-5. lbl is an integer expression that designates the label of an executable statement in the same program unit to which control passes if an I/O error occurs during positioning.
POSITION Statement Statements skip is a character expression whose value is either 'YES' or 'NO'. The default value is 'NO'. Considerations • • • • A POSITION statement establishes the record to access on the next READ or WRITE statement. The POSITION statement does not perform I/O operations, nor does it check for the existence of the specified record. The file is positioned to the specified record when your program executes the next data transfer statement.
POSITION Statement Statements When performing a GENERIC file search on an alternate key, the record made available to the program is the first one that satisfies the search requirements. If you want a later record, you can use the COMPARELEN specifier to include characters of the primary key in the alternate key comparison.
POSITION Statement Statements • If you position unit 5 or unit 6 and you have not already established a connection for the unit, POSITION implicitly opens the unit using default parameters. If you specify ENV COMMON and you position unit 5 or unit 6, your FORTRAN routines share access to standard input or standard output, respectively, with routines written in other languages only if the access mode for unit 5 is INPUT and for unit 6 is OUTPUT.
PRINT Statement Statements Examples POSITION(UNIT=100, IOSTAT=inerror, REC=inrecnum) POSITION(8,ERR=30,KEY=partnum,KEYID=0,KEYLEN=5,MODE='EXACT') POSITION(UNIT=12, KEY=pname, KEYID='PN', KEYLEN=20, & MODE='GENERIC', COMPARELEN=8, SKIPEXACT='YES') PRINT Statement The PRINT statement writes data to the preconnected output unit (unit 6) only.
PRINT Statement Statements ° In a FORTRAN OPEN statement, as in OPEN( 6, MODE = 'OUTPUT') ° In a TACL ASSIGN command, as in ASSIGN FT006, , OUTPUT ° In a UNIT compiler directive, as in UNIT (6, OUTPUT) For more information about using unit 6 as a shared file, see the OPEN Statement on page 7-70. • The PRINT statement uses the first character of each record to control vertical spacing if you specify ° ° SPACECONTROL = 'YES' when you open unit 6.
PROGRAM Statement Statements Examples PRINT *, 'Balance Due :$', balance PRINT 200, base squared, base cubed PROGRAM Statement The PROGRAM statement assigns a symbolic name to the main program unit. PROGRAM prog-name prog-name is a valid symbolic name Considerations • • The PROGRAM statement is optional. If you use it, it must be the first statement of the main program unit.
READ Statement Statements input-list is a list of items separated by commas. A list item is either the name of a variable, an array, an array element, a character substring, a RECORD, a RECORD field, or an implied DO list. read-spec is one of the following control specifiers. You can write these specifiers in any order unless you omit the UNIT or FMT keywords; for more information, see Considerations on page 7-91.
READ Statement Statements ERR = lbl label is the label of an executable statement in the current program unit to which FORTRAN transfers control if an error occurs while executing the READ statement. END = endlbl endlbl is an integer that specifies the label of an executable statement within the same program unit to which control passes if the READ statement encounters an end of file. LOCK = lock lock is a logical expression that specifies whether records are available to other processes.
READ Statement Statements Considerations • Order of read specifiers Entries for read-spec can be in any order, except that: ° ° • If you omit the UNIT keyword, unit must be the first item in the list. If you omit the FMT keyword, format must be the second item in the list, unit must be the first item in the list, and you must specify unit without the UNIT keyword.
READ Statement Statements READ or READLOCK procedure. For additional information about these procedures, see the Guardian Procedure Calls Reference Manual. • LENGTH specifier Use the LENGTH specifier to determine the actual length of variable-length records. If the READ statement terminates, len returns the actual length, in bytes, of the record most recently read.
READ Statement Statements ° In a UNIT compiler directive, as in UNIT (5, INPUT) For more information about using unit 5 as a shared file, see the OPEN Statement on page 7-70. • • If a READ statement causes unit 5 to be implicitly opened and your program is running as a NonStop process, the FORTRAN run-time library does a stack checkpoint to the backup process as a part of the implicit open.
RECORD Statement Statements RECORD Statement The RECORD statement defines a data structure, which can include data of different types. RECORD record-name [ ( [ lower:] upper) ] [ field-declaration ]... END RECORD record-name is a symbolic name or array declarator field-declaration is either a data type declaration, an EQUIVALENCE statement, a record declaration, or a FILLER * nnn where nnn is an unsigned integer constant in the range of 1 through 255.
RETURN Statement Statements Example RECORD employees FILLER*19 RECORD address CHARACTER*20 street CHARACTER*10 city CHARACTER*5 state INTEGER zip END RECORD RECORD grade CHARACTER*10 department REAL pay INTEGER*4 empnumber END RECORD END RECORD RETURN Statement The RETURN statement terminates execution of a subprogram and returns control to the calling program unit. RETURN [ iexp ] iexp is an integer expression that designates an alternate return from the subroutine.
RETURN Statement Statements • • • A RETURN statement without an iexp entry returns control to the first executable statement that follows the statement which called it. The iexp entry, which must be an integer expression, specifies that control return to the statement label specified in the calling statement that corresponds to the position of the alternate return expression in the actual parameter list of the calling program unit.
REWIND Statement Statements REWIND Statement The REWIND statement positions a file connected to a specified unit at its initial point. If the file is already at its initial point, or if the file is connected but does not exist, the REWIND statement has no effect. unit IOSTAT=ios unit , . . .
REWIND Statement Statements ° In a FORTRAN OPEN statement, as in OPEN( 5, MODE = 'INPUT') OPEN( 6, MODE = 'OUTPUT') ° In a TACL ASSIGN command, as in ASSIGN FT005, , INPUT ASSIGN FT006, , OUTPUT ° In a UNIT compiler directive, as in UNIT (5, INPUT) UNIT (6, OUTPUT) For more information about using units 5 and 6 as shared files, see the OPEN Statement on page 7-70.
SAVE Statement Statements SAVE Statement The SAVE statement saves the status of specified entities after the termination of a subprogram. SAVE [ name [, name ]... ] name is a common block name enclosed in slashes, a variable name, array name, or RECORD name.
START BACKUP Statement Statements START BACKUP Statement The START BACKUP statement defines control options for fault-tolerant processing. It also starts the backup process, ensures that the backup process opens all files currently open in the primary process, checks file synchronization information, and checkpoints all usable memory. START BACKUP is an extension to the ANSI standard and gives the FORTRAN user access to the HP fault-tolerant programming facility.
START BACKUP Statement Statements Table 7-9. Option Bits for START BACKUP OPTION Specifier Bit Option 0-5 Reserved; must be zero. 6 If ENV OLD, bit 6 must be zero. If ENV COMMON, bit 6 specifies whether START BACKUP should checkpoint the extended stack when a backup process is created. 0 Do not checkpoint when starting the backup. 1 Checkpoint when starting the backup. 7 Specifies whether to maintain an outstanding NOWAIT read operation on $RECEIVE: 0 Maintain a read. 1 Do not maintain a read.
START BACKUP Statement Statements Table 7-10. Status Codes Returned for CHECKPOINT and START BACKUP (page 1 of 2) Error Number Description 0 No error. 100 Takeover by backup; primary process stopped. 101 Takeover by backup; primary process ABENDed. 102 Takeover by backup; primary processor module failed. 103 Takeover by backup; primary process called the CHECKSWITCH system procedure. 1000 Backup processor module is down. 2nnn Communication error; nnn is a File System Error code.
START BACKUP Statement Statements Table 7-10.
START BACKUP Statement Statements Examples • The following example specifies ENV OLD: ?ENV OLD START BACKUP( CPU = 2, ERR = 400, OPTION = 16) A START BACKUP statement with OPTION = 16 (only bit 11 is set) specifies the following actions: • ° ° Maintain a permanent nowait read on $RECEIVE. ° The primary process ABENDs if CHECKPOINT causes a “bad checkpoint parameter” error. ° A new backup is created immediately by the FORTRAN run-time system after a takeover.
STOP Statement Statements STOP Statement The STOP statement terminates program execution. STOP [ message ] message is an unsigned integer constant up to five digits long or a character constant up to 80 characters long that FORTRAN displays when your program executes a STOP statement.
SUBROUTINE Statement Statements SUBROUTINE Statement The SUBROUTINE statement is the first statement of a subroutine. SUBROUTINE name [ ( [ dummy [, dummy ]... ] ) ] name is the symbolic name of the subroutine. It has the scope of an executable program. dummy is a variable name, an array name, a RECORD name, a dummy procedure name or an asterisk, which corresponds to an alternate return specifier in a CALL statement.
WRITE Statement Statements WRITE Statement The WRITE statement outputs data to a specified unit. WRITE ( [UNIT=] unit [ [, write-spec ]... ] ) [ output-item [, output-item ]... ] unit is one of the following: ° An integer expression from 1 through 999 that corresponds to a unit previously connected by an OPEN statement or to a preconnected unit. ° An asterisk (*), which implies unit 6. Unit 6 is preconnected for formatted sequential output. ° An internal file identifier.
WRITE Statement Statements ERR = lbl lbl is the label of an executable statement in the same program unit to which control passes if an I/O error occurs during a WRITE statement. UNLOCK = unlock unlock is a logical expression that indicates how the file is to be shared among two or more processes. UPDATE = upd upd is a logical expression that indicates whether records are to be updated, added, or deleted.
WRITE Statement Statements Execution of a WRITE statement causes values to be transferred from the output list to the specified file. The first character of each record has the effect defined by the SPACECONTROL specifier in the OPEN statement. Execution of a WRITE statement for a file that does not exist causes that file to be created. This does not apply to structured files.
WRITE Statement Statements If the value of upd is .TRUE., FORTRAN uses the WRITEUPDATE procedure to update or delete a record. If the UNLOCK specifier is also present, FORTRAN uses the WRITEUPDATEUNLOCK procedure. If you omit this specifier or specify .FALSE. for upd, FORTRAN uses the WRITE procedure to add a record to the file. For additional information about these procedures, see the ENSCRIBE Programmer’s Guide.
WRITE Statement Statements In a TACL ASSIGN command, as in ASSIGN FT006, , OUTPUT In a UNIT compiler directive, as in UNIT (6, OUTPUT) A PRINT statement also opens unit 6 implicitly. For more information about using unit 6 as a shared file, see the OPEN Statement on page 7-70. • • If a WRITE statement causes unit 6 to be implicitly opened and your program is running as a NonStop process, the FORTRAN run-time library does a stack checkpoint to the backup process as a part of the implicit open.
WRITE Statement Statements FORTRAN Reference Manual—528615-001 7 -112
8 Intrinsic Functions Intrinsic functions are compiler-defined procedures that return a single value. Topics covered in this section include: Topic Page Declaring Intrinsic Functions 8-1 Referencing an Intrinsic Function 8-2 Using Generic and Specific Function Names 8-3 Table 8-1 on page 8-2 summarizes the FORTRAN intrinsic functions described in this section.
Referencing an Intrinsic Function Intrinsic Functions Referencing an Intrinsic Function You can reference an intrinsic function in a main program or in a subprogram. You reference an intrinsic function by using it in an expression. For example, in the following assignment statement, FORTRAN evaluates the MAX function to determine the largest value in its argument list, multiplies the result of the MAX function by 5, and stores the result in X: x = MAX (dmon, tue, wed, thu, fri) * 5 Table 8-1.
Using Generic and Specific Function Names Intrinsic Functions Table 8-1.
ABS Function Intrinsic Functions the arguments and return value are shown in the entries that follow the generic name in the table. Considerations • • • • All items in the argument list of an intrinsic function must be the same type, unless the function’s description specifies otherwise. When you use an intrinsic name as an actual argument, you must use a specific function name, not a generic function name. In other contexts, you can use either a generic or specific function name.
ACOS Function Intrinsic Functions Examples of the ABS Function The following program prints a value of 530.01 for X, 530.01 for Y, and 0.5E-03 for Z: COMPLEX xnumber xnumber = (5.3e2, -3.2) realnum = -.0005 x = CABS (xnumber) y = ABS (xnumber) z = ABS (realnum) PRINT '(2F9.2, E9.1)', x, y, z END ACOS Function The ACOS function returns an arccosine expressed in radians. The table below shows the argument and function type for the generic ACOS function and its associated specific function.
AIMAG Function Intrinsic Functions AIMAG Function The AIMAG function returns the imaginary part of a complex number. AIMAG ( z) z is a complex expression Considerations The AIMAG function returns the imaginary part of a complex number. Its type is always real. That is, if z = CMPLX (x, y) then, AIMAG (z) = y Example of the AIMAG Function In the following example, if the value (4E3,-2.1) is read into XNUMBER, the value -2.1 is stored in Y.
ANINT Function Intrinsic Functions • If ABS (x) > 1.0, AINT returns the integer whose magnitude is the largest integer that does not exceed the magnitude of x and whose sign is the same as that of x. Examples of the AINT Function x = DINT (y) a = AINT (.01 * c) ANINT Function The ANINT function returns the whole number that is closest in value to its argument. The table below shows the argument and function type for the ANINT function and its associated specific function.
ASIN Function Intrinsic Functions ASIN Function The ASIN function returns an arcsine expressed in radians. The table below shows the argument and function type for the generic ASIN function and its associated specific function. Syntax Argument Type Function Type ASIN (x) Real Real DASIN (x) Double Precision Double Precision ASIN (x) x is an arithmetic expression. Considerations • • • The result type of the ASIN function is the same as the type of its argument.
ATAN2 Function Intrinsic Functions Considerations • • The result type of the ATAN function is the same as the type of its argument. The value of ATAN (x), for any x, is the angle a (in radians) such that – π ⁄ 2 ≤a ≤π ⁄ 2 and x = TAN (a) Example of the ATAN Function v = ATAN (x) ATAN2 Function The ATAN2 function returns an arctangent expressed in radians. The table below shows the argument and function type for the ATAN2 generic function and its associated specific function.
CHAR Function Intrinsic Functions CHAR Function The CHAR function returns the character value of a specified position in the ASCII collating sequence. CHAR ( n ) n is an integer expression with a value from 0 through 127. Considerations • • • • The CHAR function result is always type character*1. The value of CHAR (n) is undefined for argument values of n ≤ 0 or n > 127 The CHAR function is the inverse of the ICHAR function. The ASCII collating sequence is given in Appendix A, ASCII Character Set.
CONJG Function Intrinsic Functions Considerations • • • If you specify two arguments, they must be the same type: integer, real, or double precision. The data type of the value returned by CMPLX is always complex. For one argument of complex type, CMPLX (x) returns x. For one argument of integer, real, or double precision type, CMPLX (x) is equivalent to CMPLX (x, 0).
COS Function Intrinsic Functions COS Function The COS function returns the cosine of an angle expressed in radians. The table below shows the argument and function type for the COS generic function and its associated specific functions. Syntax Argument Type Function Type COS (x) Real Real DCOS (x) Double Precision Double Precision CCOS (x) Complex Complex COS (x) x is an arithmetic expression. Considerations • • • The result type of the COS function is the same as the type of its argument.
DBLE Function Intrinsic Functions Considerations • The result type of the COSH function is the same as the type of its argument. The value of COSH (x) is defined as (EXP (x) - EXP (- x))/2.0 • Note that for all values of x COSH (- x) = COSH (x) and COSH (x) ≥ 1.0 Example of the COSH Function y = COSH (x) DBLE Function The DBLE function returns a double precision value. DBLE ( x) x is an expression of any numeric type.
DIM Function Intrinsic Functions DIM Function The DIM function returns a positive difference. The table below shows the argument and function type for the DIM generic function and its associated specific functions. Syntax Argument Type Function Type DIM (x, y) Real Real IDIM (x, y) Integer Integer IDIM4 (x, y) Integer*4 Integer*4 IDIM8 (x, y) Integer*8 Integer*8 DDIM (x, y) Double Precision Double Precision DIM (x, y) x and y are arithmetic expressions.
EXP Function Intrinsic Functions Considerations • • Both arguments to DPROD are type real, but the DPROD function result is type double precision. The value of DPROD (x, y) is defined as: DBLE (x) * DBLE (y) Example of the DPROD Function REAL cost (100) DOUBLE PRECISION ttax, tax ttax = 0 DO 20 j = 1, 100 tax = DPROD (cost (j), .07) ttax = ttax + tax 20 CONTINUE EXP Function The EXP function returns an exponential.
FILENUM Function Intrinsic Functions Example of the EXP Function If the value 8 is stored in X, the following statement stores the value 2980.96 in Y: y = EXP (x) FILENUM Function The FILENUM function returns the Guardian open file number of the file associated with the specified unit number. FILENUM (k) k is an integer expression ranging from 1 through 999 specifying the unit number to which the file is connected.
ICHAR Function Intrinsic Functions Example of the FILENUM Function The following example uses the FILENUM function to disable the echo on a terminal: ?GUARDIAN SETMODE CHARACTER * 10 s OPEN (UNIT = 4) 10 CONTINUE C Disable echo and do a READ with PROMPT = >: CALL setmode (FILENUM (4), 20, 0) READ (UNIT = 4, FMT = 1000, PROMPT= '>', END = 20) s 1000 FORMAT (A10) .
INDEX Function Intrinsic Functions Example of the ICHAR Function The following program stores the number 35 in I and J. CHARACTER name name = '#' i = ICHAR (name) j = ICHAR ('#') PRINT *, i, j END INDEX Function The INDEX function returns an integer that points to the first character of a substring relative to the string that contains it. The table below shows the argument and function type for the INDEX generic function and its associated specific functions.
INT Function Intrinsic Functions sets N = 0, because the two variables are matched as follows: password = 'impassable^^^^^' try = 'able^^^^^^^^^^^' Example of the INDEX Function The following example returns a value of 1 for POSITION: RECORD title CHARACTER * 10 author CHARACTER * 10 name END RECORD CHARACTER * 5 sub sub = 'Ander' title^author = 'Anderson' position = INDEX (title^author, sub) PRINT *, position INT Function The INT function returns a value of integer type.
LEN Function Intrinsic Functions Considerations • • For an argument of integer type, INT (x) returns x. For an argument of real or double precision type: if | x| < 1.0 INT (x) returns 0. if | x| ≥ 1.0 INT (x) returns the integer whose magnitude is the largest integer that does not exceed the magnitude of x and whose sign is the same as that of x. For example, INT (-3.8) returns -3. • For an argument of complex type, INT (x) is the same as INT (REAL (x)).
LOG Function Intrinsic Functions LEN is particularly useful to determine the length of a character type argument to a subroutine. See the following example. Example of the LEN Function SUBROUTINE word (entry, length) CHARACTER entry * (*) length = LEN (entry) IF (length .GT. 80) THEN PRINT *, 'Your entry is too long!' END IF END LOG Function The LOG function returns a natural (or base e) logarithm.
LOG10 Function Intrinsic Functions • The value returned by the LOG function in programs that specify ENV OLD might differ slightly from the value returned by the LOG function in programs that specify ENV COMMON. The value returned by the LOG function when you specify ENV COMMON differs slightly because of rounding methods on the final result. Example of the LOG Function x = ALOG (a) + ALOG (b) LOG10 Function The LOG10 function returns a common (or base 10) logarithm.
MAX Function Intrinsic Functions MAX Function The MAX function returns the largest value in its argument list. The table below shows the argument and function type for the MAX generic function and its associated specific functions. Syntax Argument Type Function Type MAX0 (x1, ... , xn) Integer Integer MAX04 (x1, ... , xn) Integer*4 Integer*4 MAX08 (x1, ... , xn) Integer*8 Integer*8 AMAX0 (x1, ... , xn) Integer Real AMAX04 (x1, ... , xn) Integer*4 Real AMAX08 (x1, ...
MIN Function Intrinsic Functions MIN Function The MIN function returns the smallest number from its argument list. The table below shows the argument and function type for the MIN generic function and for its associated specific functions. Syntax Argument Type Function Type MIN0 (x1, ... , xn) Integer Integer MIN04 (x1, ... , xn) Integer*4 Integer*4 MIN08 (x1, ... , xn) Integer*8 Integer*8 AMIN0 (x1, ... , xn) Integer Real AMIN04 (x1, ... , xn) Integer*4 Real AMIN08 (x1, ...
MOD Function Intrinsic Functions MOD Function The MOD function returns the remainder of x divided by y. The table below shows the argument and function type for the MOD generic function and its associated specific functions. Syntax Argument Type Function Type MOD (x, y) Integer Integer MOD4 (x, y) Integer*4 Integer*4 MOD8 (x, y) Integer*8 Integer*8 AMOD (x, y) Real Real DMOD (x, y) Double Precision Double Precision MOD (x, y) x and y are arithmetic expressions.
NINT Function Intrinsic Functions NINT Function The NINT function returns the integer that is closest to the value of its argument.
SIGN Function Intrinsic Functions Considerations • • • For an argument of real type, REAL (x) returns x. For an argument of integer or double precision type, REAL (x) has as much precision of the significant part of x as a real datum can contain. For an argument of complex type, REAL (x) returns the value of the real part of x. That is, REAL(CMPLX(x, y)) returns X. • For an integer argument, FLOAT (x) returns the same value as REAL (x). Example of the REAL Function total = FLOAT (number) * 2.
SIN Function Intrinsic Functions Example of the SIGN Function z = SIGN (a, b) SIN Function The SIN function returns the sine of an angle expressed in radians. The table below shows the argument and function type for the SIN generic function and its associated specific functions. Syntax Argument Type Function Type SIN (x) Real Real DSIN (x) Double Precision Double Precision CSIN (x) Complex Complex SIN (x) x is an arithmetic expression.
SQRT Function Intrinsic Functions Considerations • • The result type of the SINH function is the same as the type of its argument. The value of SINH (x) is defined as (EXP (x) - EXP (-x))/2.0 • Note that SINH (-x) = -SINH (x) Example of the SINH Function y = SINH (x) SQRT Function The SQRT function returns the square root of a number. The table below shows the argument and function type for the SQRT generic function and its associated specific functions.
TAN Function Intrinsic Functions TAN Function The TAN function returns the tangent of an angle expressed in radians. The table below shows the argument and function type for the TAN generic function and its associated specific function. Syntax Argument Type Function Type TAN (x) Real Real DTAN (x) Double Precision Double Precision TAN (x) x is an arithmetic expression. Considerations • • The result type of the TAN function is the same as the type of its argument.
TANH Function Intrinsic Functions Note that TANH (-x) = -TANH (x) Example of the TANH Function y = TANH (x) FORTRAN Reference Manual—528615-001 8- 31
TANH Function Intrinsic Functions FORTRAN Reference Manual—528615-001 8- 32
9 Program Compilation You run the FORTRAN compiler, which resides in a file named $SYSTEM.SYSTEM.FORTRAN, by using the TACL implied RUN command. The FORTRAN compiler accepts source files containing FORTRAN statements, comment lines, and compiler directives. Source files alone or in combination with other source files and object files constitute the input to a compilation.
Compiling a Program Program Compilation Figure 9-1. The Compilation Process Source Files Fsource Prog1 Sub1 SYMSERV FORTRAN Listing Object Files Fobject Common BINSERV Object File Sub2 VST0901.vsd Compiling a Program The syntax diagram below describes the implied RUN command to compile a FORTRAN program. FORTRAN [/[IN source] [,OUT [ list] ] [, option]... /] [ object] [; directive [, directive]...
Compiling a Program Program Compilation If you omit IN source, the compiler reads from the TACL IN file, normally the home terminal. list is the name of a process (including a spooler collector), class map or spool DEFINE, printer, magnetic tape (unlabeled and unblocked only), terminal, or disk file to which FORTRAN directs its listing output. A disk file can be structured (but not key-sequenced), unstructured, or an EDIT format file. The list name uses the same form as source.
Command Line Length Program Compilation TERM terminal-name is the name of a terminal or process that acts as the home terminal for the compiler. If you omit this option, FORTRAN uses the TACL home terminal. object specifies the disk file name that BINSERV gives the compiled object program. If you omit this entry, FORTRAN uses a file named OBJECT on your current system, volume, and subvolume. If OBJECT already exists, BINSERV purges it before creating the target file.
TACL PARAM Commands Program Compilation When the list file is a magnetic tape or any kind of disk file, the compiler writes each line beginning with a control character (0 to skip a line, 1 to start a new page, and so forth) according to the FORTRAN 77 ANSI standard.
Compiling With FORTRAN and BINSERV in the Same CPU Program Compilation Compiling With FORTRAN and BINSERV in the Same CPU By default, FORTRAN, BINSERV, and SYMSERV run in different CPUs. If you want to reduce interprocessor message traffic, use the TACL PARAM SAMECPU command to run FORTRAN and BINSERV in the same CPU. The form of the command is 1> PARAM SAMECPU n where n is a nonzero integer. For example: 1> PARAM SAMECPU 3 Note that the nonzero value does not designate in which CPU the processes run.
Compiler Operation Program Compilation In the absence of PARAM OUTWIDTH, the compiler writes records of the file’s assumed record length. If PARAM OUTWIDTH number is specified, and • • • number is at least 72, but less than or equal to the file’s assumed record length, the compiler writes records of number characters. number exceeds the file’s assumed record length, the compiler formats a line of number characters and writes the line as one or more records of the file’s assumed record length.
Interpreting Compilation Listings Program Compilation BINSERV binds the appropriate object modules from FORTLIB (a library of object modules supplied by HP) into the target file. It also binds in code and data blocks located via the SEARCH directive. Any unresolved references to procedures are represented in the program file in a procedure identifier list. The operating system uses this list to resolve such references the first time you execute the object program.
Page Heading Program Compilation Table 9-2. Compiler Listing Options (page 2 of 2) Directive Action LIST NOLIST List source lines: enables CODE, CROSSREF, ICODE, LMAP, MAP, and PAGE. LMAP NOLMAP List load maps. MAP NOMAP List tables of local identifiers for each program unit; list table of entities in common storage. PAGE title Eject current page of list file (except for first occurrence). Print title at the top of next page.
Source Listing Program Compilation command when you initiated the compilation, FORTRAN lists those directives just before the first line of the source code. Tandem FORTRAN - T9252D10 - (08JUN92) Default options: on (LIST,MAP,WARN,LMAP) - off (CODE,ICODE,ANSI) Copyright Tandem Computers Incorporated 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1991 Source Listing If the LIST option is in effect, FORTRAN lists the text of the source program following the compiler heading.
Source Listing Program Compilation Example 9-1. Compiler Listing—Source Listing (page 1 of 2) 1. ? ?ICODE 2. * C Program to set up table of lot number, name, property 3. * C value and determine tax charge. 4. * C 5. * C avalue = average property value 6. * C atax = average tax 7. * C tvalue = sum of property values 8. * C ttax = total tax 9. * C 10. 40 FORMAT ('0',5x, i4, 5x,a11,5x,f6.0,f7.2) 11. 50 FORMAT ('0',5x,'Lot #',4x, 'Owner''s Name',5x,'Value',4x 12.
Source Listing Program Compilation Example 9-1. Compiler Listing—Source Listing (page 2 of 2) 38. 460 PRINT *, ' ' 39. PRINT *, ' ' 40. PRINT *, 'Sum of property values is ', tvalue 41. PRINT *, 'Total tax is ', ttax 42. PRINT *, 'Average property values is ', avalue 43. PRINT *, 'Average tax charge is ', atax 44.
Code and Data Blocks MAP Listing Program Compilation data blocks, and the symbolic name map. The maps are in addition to the entry point and data block maps that BINSERV provides after all compiler-generated output following the last program unit. Code and Data Blocks MAP Listing The MAP option provides a summary of the code and data blocks in the compiled program unit, showing the name of each block the program unit uses and the amount of memory space it occupies.
CODE Listing Program Compilation Class Specifies the type of entity represented by the identifier. Type Specifies the data type of the identifier. If the identifier does not appear in a data type statement, an exclamation point preceding the entry shows that the data type is implicitly declared. Relative Address Is the relative address of the identifier. The relative address is specified as: • • • • • • L+ nnn for variables and arrays in local storage. L- nnn for dummy arguments of a subprogram.
ICODE Listing Program Compilation Each address listed is the octal starting address for the adjacent code, expressed as an offset from the beginning of the program unit. The code is the octal representation of the instruction code emitted by the compiler. ICODE Listing The ICODE option provides a listing of the symbolic form of the instruction code for the program unit. The listing contains references to code “landmarks”; for example, START OF PROGRAM UNIT, STATEMENT LABEL 200 + 2, and so forth.
ICODE Listing Program Compilation Example 9-3.
CROSSREF Listing Program Compilation You can view the code in a running process or in an Inspect save file using the Inspect ICODE command. The following Inspect command lists in ICODE format the machine instructions for the first four FORTRAN statements in a subprogram named MYSUB: ICODE at #MYSUB FOR 4 For more information about the ICODE command, see the Inspect Manual. CROSSREF Listing If the CROSSREF option is in effect, SYMSERV collects cross reference data for FORTRAN’s output listings.
LMAP Listing Program Compilation Table 9-3. LMAP Code Block Listing (page 2 of 2) Name Meaning TIME The time of day NAME was compiled LANGUAGE The source language of NAME SOURCE FILE The name of NAME’s source file Table 9-4. Data Block Listing Name Meaning BASE Lowest address of the data block. Either the G-relative address (six octal digits) of the first word of the block, or the extended address (ten octal digits) of the first bytes of the block. LIMIT Highest address of the data block.
Completion Message Program Compilation Completion Message BINSERV and FORTRAN both print statistics after an object file is built. If the SYNTAX directive is in effect, only FORTRAN statistics are listed. Numeric values are displayed in base ten.
Compiler Termination Codes Program Compilation BINSERV does not include the XEP size in the code-area size. Also, note that FORTRAN’s global storage size might differ from BINSERV’s: FORTRAN counts only declared data; BINSERV includes run-time data structures in the global storage size. Example 9-4. Compiler Listing—Completion Message BINDER - OBJECT FILE BINDER - T9621D10 - (08JUN92) Copyright Tandem Computers Incorporated 1982-1992 Object file \USERS.$TOOLS.FTNTOOLS.
Separate Compilation Program Compilation Separate Compilation You can use Binder to bind together object files created from separate runs of the FORTRAN compiler in addition to object files created by C, COBOL85, PASCAL, and TAL compilations. Binder also allows you to examine, combine, or modify object files.
Code Blocks and Data Blocks Program Compilation sign (+) if it is in the user data segment or by an ampersand (&) if it is in the extended data segment. • • An executable program can have any number of COMMON data blocks shared by the program units that declare them in one or more source program COMMON statements. Each block name is the name that appears between slashes in COMMON statements (FORTRAN uses BLANK^ for an unnamed common block), preceded by a period (.
Compiling Programs That Use Extended Data Space Program Compilation Table 9-5. FORTRAN Data Blocks (page 2 of 2) Block Name Environment Contents #RUCB OLD The Run-Unit Control Block. It contains pointers to most other special data blocks. #MCB COMMON Global data area for run-time environment. #CRE_HEAP COMMON Global data area for run-time environment. #CRE_GLOBALS COMMON Pointers to data. #RECEIVE COMMON The buffer that holds messages received from $RECEIVE.
Program Compilation Binding Programs That Use Extended Memory LARGECOMMON directive in every compilation that includes the same common block. • • Include an EXTENDEDREF compiler directive at the beginning of every compilation that does not include a LARGECOMMON directive or a LARGEDATA directive. Use the LARGESTACK directive (or the BIND command SET LARGESTACK) if the extended stack area is too small.
Program Compilation User Library Alternatives for Utility Subprograms User Library Alternatives for Utility Subprograms The user library feature of the operating system is a convenient way to make packages of general-utility subprograms available to multiple application programs. Alternative methods are: • • Use the SEARCH directive when you compile the application programs, causing each application program’s object file to include its own copy of the utility subprograms that it needs.
Using the SEARCH Directive—Sample Program 1 Program Compilation 3. Code and compile the main program unit. The source file includes a SOURCE directive for the DUMMYS file. A SEARCH directive identifying PRINTO as the search list is included to have BINSERV include the object code from Step 1 in the program file. The program file is named MAKEONE. It contains copies of the MAIN^, PRINTARRAY, and TRANSPOSE dummy code. 4. Test run the program produced in Step 3.
Using the SEARCH Directive—Sample Program 1 Program Compilation SUBROUTINE printarray ?SOURCE global INTEGER row, column WRITE(UNIT=6,FMT='(1h )') DO 10 row = 1, asize WRITE(6,1000) (array(row,column), column=1, asize) 10 CONTINUE RETURN 1000 FORMAT(10I10) END Step 2—TRANSPOSE Dummy Subprogram The following subprogram is compiled using the SOURCE directive from the main: SUBROUTINE transpose RETURN END If separately compiled, the dummy’s object file would consist of a code block named TRANSPOSE.
Using the SEARCH Directive—Sample Program 1 Program Compilation ?SEARCH printo ?SOURCE dummys ?SOURCE global INTEGER row, column C Initialize the array -DO 20 row = 1, asize DO 10 column = 1, asize array(row, column) = asize*(row-1) + column-1 10 CONTINUE 20 CONTINUE C Display the initialized array CALL printarray C Transpose the array CALL transpose C Display the transposed array CALL printarray STOP 'End of example' END Step 4—TRANSPOSE Subprogram The object file resulting from compilation of th
Using the SEARCH Directive—Sample Program 1 Program Compilation C This is the real transpose subroutine. SUBROUTINE transpose ?SOURCE global INTEGER temp, i, j DO 20 i = 2, asize DO 10 j = 1, i-1 temp = array(j, i) array(j, i) = array(i, j) array(i, j) = temp 10 CONTINUE 20 CONTINUE RETURN END Step 5—Version One —Program Test Run the program. The output produced begins with zero (rather than one) as the first subscript value.
Using the SEARCH Directive—Sample Program 1 Program Compilation ?SEARCH makeone ?SOURCE xpose ?SOURCE global C Initialize the array -DO 20 row = 1, asize DO 10 column = 1, asize array(row, column) = asize*(row-1) + column 10 CONTINUE 20 CONTINUE C Display the initialized array CALL printarray C Transpose the array CALL transpose C Display the transposed array CALL printarray STOP 'End of example' END Alternative Development Using the Interactive Binder For the descriptions of the ADD and BUILD c
Program Compilation Using the SEARCH Directive—Sample Program 2 4. Based on the output of Step 3, alter the source code for the main routine. Recompile the main routine, and delete the old MAIN disk file. (The new MAIN^ object code will also be in a file named MAIN.) 5. Use the interactive Binder to build a new program file. Input to this step is the program file MAKEONE and the new MAIN file.
Using the SEARCH Directive—Sample Program 2 Program Compilation C Main Program -- Pen Primer ?UNIT (8) ?SEARCH fpslib COMMON/termio/kebord, icrt COMMON/zdonz/ldevzi, ldevzo CHARACTER*1 mess(16) DATA mess/'P','R','I','M','I','N','G',' ', + 'T','H','I','S',' ','P','E','N'/ kebord = 4 icrt = 4 ldevzi = 8 ldevzo = 8 OPEN(8,FILE='$S.#PLOTS',STATUS='OLD',SPACECONTROL='NO', + IOSTAT=ioerr,ERR=8888) CALL plots(53,0,8 ) CALL newpen (1) CALL symbol(2.,5.,.2,mess,0.,16) CALL symbol(2.,4.5,.2,mess,0.
Program Compilation Using the SEARCH Directive—Sample Program 2 8889 FORMAT(' FILE ERROR $PLOTS: ',I3) STOP END FORTRAN Reference Manual—528615-001 9- 33
Program Compilation Using the SEARCH Directive—Sample Program 2 FORTRAN Reference Manual—528615-001 9- 34
10 Compiler Directives You use compiler directives to specify and control many aspects of a compilation, such as: • • • • • • • • • • • To specify listing features To specify alternate source files To enable run-time bounds checking To control data allocation To specify data area size To control how the $RECEIVE file is used at run-time To control the building of object files To specify the line length for source input files To declare procedures not written in FORTRAN To specify user libraries To save
Compiler Directives Table 10-1. Summary of Compiler Directives (page 2 of 4) Directive Action ERRORFILE Stores compilation error messages in a file. ERRORS Sets the maximum number of errors for a compilation. Default is ERRORS 100. EXTENDCOMMON Uses indexed indirect addressing to access simple variables in common blocks. Default is NOEXTENDCOMMON. EXTENDEDREF Generates code that uses doubleword addresses for parameters in CALL statements and function references. Default is NOEXTENDEDREF.
Compiler Directives Table 10-1. Summary of Compiler Directives (page 3 of 4) Directive Action LINES Specifies the number of lines to write to the listing file before a page skip. LIST Controls listing of source lines; enables CODE, CROSSREF, ICODE, FMAP, LMAP, MAP, and PAGE. Default is LIST. LMAP Causes load maps to be listed after identifier map and crossreference tables. Default is LMAP ALPHA. LOGICAL Specifies the size of all subsequent logical entities in source file. Default is LOGICAL*2.
Using Compiler Directives Compiler Directives Table 10-1. Summary of Compiler Directives (page 4 of 4) Directive Action SUPPRESS Lists only error messages and compilation statistics; overrides LIST. Default is NOSUPPRESS. SYMBOLS Includes a symbol table in the object file for use by Inspect. Default is NOSYMBOLS. SYNTAX Searches source file for syntax errors; does not produce object file. UNIT Causes a unit to exist; declares the properties of the file or files connected to the unit.
Using Compiler Directives Compiler Directives • Specify the following directives as the first or only directive on a line: COLUMNS PAGE • Specify the following directives as the only directive on a line: ENDIF SECTION • Specify the following directives last on a directive line: IF IFNOT RESETTOG SETTOG SOURCE • Specify the following directives either with the FORTRAN command (after the semicolon following the object file name) or in the source input file before the first FORTRAN statement: ABORT F
ABORT Compiler Directive Compiler Directives • Specify the following directives either with the FORTRAN command (after the semicolon following the object file name) or anywhere in the source input file: COLUMNS ICODE LOWBUFFER SAVEABEND COMPACT IF PAGE SEARCH CONSULT IFNOT POP SECTION DATAPAGES INSPECT PRINTSYM SETTOG ENDIF LARGEDATA PUSH SOURCE GUARDIAN LINES RECEIVE SUPPRESS HIGHBUFFER LIST RESETTOG WARN HIGHCONTROL LMAP SAVE ABORT Compiler Directive The ABORT directive s
ANSI Compiler Directive Compiler Directives • If you specify NOABORT and the compiler cannot open a SOURCE or CONSULT file, the compiler displays the following on the home terminal: File file-name not in directory. Enter ?SAME to try same file. Enter ?ABORT to abort compile. Enter ?IGNORE to skip file. Otherwise enter another file name. Enter response: If a file system error code (including EOF) is returned or you enter ?ABORT, the compiler calls ABEND with completion code 3 (premature termination).
BOUNDSCHECK Compiler Directive Compiler Directives • • • • Specify the ANSI directive either with the FORTRAN command, or in the source input file preceding the first FORTRAN statement, or between the END line of one program unit and the first FORTRAN statement of the next program unit. The ANSI compiler directive is equivalent to COLUMNS 72, with the following exceptions: ° If you specify ANSI, the compiler truncates or pads (with blanks) each source line to make it exactly 72 characters.
CODE Compiler Directive Compiler Directives line of one program unit and the first FORTRAN statement of the next program unit. Example ?BOUNDSCHECK CODE Compiler Directive The CODE directive instructs the compiler to list the octal instruction codes generated for each program unit, following the source listing for that program unit. The default value is NOCODE. [NO]CODE Considerations The effect of the CODE directive is suspended, but not cancelled, by the NOLIST and SUPPRESS directives.
COLUMNS Compiler Directive Compiler Directives Considerations • The COLUMNS directive can appear on the FORTRAN command line following the semicolon after the object file name. It can also appear anywhere in a source input file. A compilation can have any number of COLUMNS directives. When source files contain a COLUMNS directive, it must be the first or only directive on a line, and it must appear before the first SECTION directive if there are SECTION directives in the file.
COMPACT Compiler Directive Compiler Directives • • ° In ANSI mode, the compiler truncates or pads (with blanks) each source line to make it exactly 72 characters. The COLUMNS directive makes the compiler ignore all source text beyond the specified number of characters, but it does not affect source lines shorter than that. This distinction can be important if any character constants are continued from one line to the next. ° The SOURCE and SECTION directives do not affect the ANSI mode.
CONSULT Compiler Directive Compiler Directives • If you specify COMPACT, BINSERV checks each succeeding code-space block to determine whether it will fit into either current gap. When a code-space block that fits in a gap is found, BINSERV allocates it in the gap, thereby compressing both the target file and the object program. Figure 10-1 illustrates this process. Example ?COMPACT Figure 10-1.
CONSULT Compiler Directive Compiler Directives consult-item is a Guardian file name or DEFINE name known at compile time, optionally followed by the name of one or more procedures contained in the referenced file. The procedure names, if present, are separated by commas and contained in parentheses. The syntax of a consult-item is: file – name [( proc-name [, proc-name ]... )] define – name Compile-time defaults are supplied for any missing qualifiers.
CONSULT Compiler Directive Compiler Directives • • • • • • If a consult-item names a procedure that is already defined or referenced as a FORTRAN subprogram, the source program’s description overrides the description in the file named in the CONSULT directive. If a consult-item does not include a list of procedure names, the compiler ignores the procedure without displaying a message.
CROSSREF Compiler Directive Compiler Directives • For information on calling procedures not written in FORTRAN, see Section 13, Mixed-Language Programming. Example ?CONSULT mylib CROSSREF Compiler Directive The CROSSREF directive instructs the SYMSERV process to generate crossreference information for selected identifier classes. [NO]CROSSREF identifier – class ( identifier – class [ , identifier – class ]. . .
DATAPAGES Compiler Directive Compiler Directives • • The effect of the CROSSREF directive is suspended, but not cancelled, by the NOLIST and SUPPRESS directives. Using GENERATE The compiler normally lists requested cross-reference tables at the end of the compilation. If you specify GENERATE, the compiler lists the requested crossreference tables at the end of the current program unit, and discards the accumulated references up to that point.
ENDIF Compiler Directive Compiler Directives • If you include the directive, Binder allocates precisely the number of pages you specify whether or not that number is sufficient, and displays a warning message if the number you specify is less than the compiler’s estimate. Example ?DATAPAGES 16 ENDIF Compiler Directive The ENDIF directive terminates the effect of a preceding IF or IFNOT directive that specifies the same toggle number. ENDIF toggle toggle is a number in the range 1 through 15.
ENV Compiler Directive Compiler Directives ENV Compiler Directive The ENV directive determines whether your program uses the C-series or D-series FORTRAN run-time library. The default value is ENV OLD. OLD ENV COMMON OLD specifies that this program use the C-series FORTRAN run-time library. COMMON specifies that this000 program use the D-series FORTRAN run-time library.
Using ENV COMMON Compiler Directives • • • • The run-time environment provides more consistent and complete run-time error handling for programs that specify ENV COMMON. You can specify an eight-character volume name when accessing information over a network. FORTRAN supports the NONSTOP and HIGHPIN directives. If ENV OLD is in effect, FORTRAN prints a warning if it encounters a NONSTOP or HIGHPIN directive and ignores the directive.
Using ENV COMMON Compiler Directives If you bind FORTRAN modules with modules created by other compilers, all the modules that you bind together must specify or default to ENV COMMON, ENV NEUTRAL (TAL routines only), ENV EMBEDDED (Pascal routines only), or ENV LIBSPACE (Pascal routines only). For more information, see the Binder Manual.
ERRORFILE Compiler Directive Compiler Directives Example In the following example, toggle 2 is reset if ENV OLD is specified; toggle 2 is set if ENV COMMON is specified: ?IFNOT 2 ?ENV OLD ?ENDIF 2 ?IF 2 ?ENV COMMON ?ENDIF 2 ... ?IFNOT 2 CALL FORTRANCOMPLETION( ... ) ?ENDIF 2 ?IF 2 CALL FORTRAN_COMPLETION_( ... ) ?ENDIF 2 ERRORFILE Compiler Directive The ERRORFILE directive saves the error messages from a compilation in a disk file.
ERRORFILE Compiler Directive Compiler Directives Considerations • • • • • • The ERRORFILE directive must appear either on the FORTRAN compiler command line after the semicolon following the object file name, or in the source input file preceding the first FORTRAN statement. If you include an ERRORFILE directive after the first FORTRAN statement, the compiler issues an error message and ignores the directive.
ERRORS Compiler Directive Compiler Directives PREVERR to display other error messages and their source text in the same manner. You can assign the NEXTERR and PREVERR macros to function keys instead of entering them on the TEDIT command line. For example, in the preceding FIXERRS command, the commands part could be a TEDIT USE command that references a TEDIT profile that assigns NEXTERR and PREVERR to function keys.
EXTENDCOMMON Compiler Directive Compiler Directives Example ?ERRORS 250 EXTENDCOMMON Compiler Directive The EXTENDCOMMON directive instructs the compiler to use indexed indirect addressing to access simple variables in common blocks in the user data segment. This method of addressing saves primary global storage but accessing the data in common blocks is slower than if you do not specify EXTENDCOMMON. The default value is NOEXTENDCOMMON.
EXTENDEDREF Compiler Directive Compiler Directives LARGEDATA directives. [NO]EXTENDEDREF Considerations • Use of EXTENDEDREF Directive Use the EXTENDEDREF directive when you compile program units that do not include LARGECOMMON or LARGEDATA directives but which you plan to combine with separately compiled program units that do include LARGECOMMON or LARGEDATA directives. You do not have to use the EXTENDEDREF directive in programs that include the LARGECOMMON or LARGEDATA directives.
FIXUP Compiler Directive Compiler Directives You can call a COBOL85 program unit from a FORTRAN program unit whether or not the FORTRAN program unit uses EXTENDEDREF, LARGECOMMON, or LARGEDATA, but you must code the COBOL85 program unit to specify the addressing mode. The COBOL85 program unit’s LINKAGE SECTION must specify “ACCESS MODE IS EXTENDED-STORAGE” if and only if it will be called by a program unit compiled with EXTENDEDREF, LARGECOMMON, or LARGEDATA.
FMAP Compiler Directive Compiler Directives FMAP Compiler Directive The FMAP directive causes the compiler to include a file map in the compiler listing just before the Binder load map. The file map consists of one line for each source input file used during the compilation, showing the file ordinal, the file’s fully qualified name, and the date and time the file was last modified. The default is NOFMAP.
GUARDIAN Compiler Directive Compiler Directives GUARDIAN Compiler Directive The GUARDIAN directive specifies the names of Guardian system procedures and of FORTRAN utility routines that your program calls. If you specify a procedure name in a GUARDIAN directive, FORTRAN checks the procedure definition and generates an appropriate TAL calling sequence for calls your program makes to the procedure. proc – name GUARDIAN ( proc – name [ , proc – name ]. . .
HIGHBUFFER Compiler Directive Compiler Directives FORTRAN requires that you invoke a procedure that can be called as a function only by a function reference, not with a CALL statement. • Value and Reference Parameters HP FORTRAN released before B-series systems required that value parameters in calls to Guardian routines be enclosed in backslashes. This convention is no longer necessary.
HIGHCOMMON Compiler Directive Compiler Directives If you specify ENV COMMON, HIGHBUFFER specifies the size of the #CRE_HEAP data block. #CRE_HEAP contains the private data used by the CRE. If you do not specify HIGHBUFFER, FORTRAN allocates 1,024 words in #CRE_HEAP. If you specify HIGHBUFFER in a program that specifies ENV COMMON, always specify a minimum of 1,024 bytes for size.
HIGHCONTROL Compiler Directive Compiler Directives segment, and all byte-addressed blocks in the lower half, except for blocks explicitly specified in LARGECOMMON directives. • • • • You can use more than one HIGHCOMMON directive in a compilation. The effect is the same as if you had concatenated the common block names in a single directive. As a result, if you include one HIGHCOMMON directive without a block name list and one with, the compiler ignores the directive without a block name list.
HIGHPIN Compiler Directive Compiler Directives HIGHPIN Compiler Directive The HIGHPIN directive specifies whether your program can run at a high PIN. The default value is NOHIGHPIN. [NO]HIGHPIN Considerations • The HIGHPIN directive must appear on the FORTRAN command line after the semicolon that follows the object file name, or in the source input file before the first FORTRAN source statement.
HIGHREQ Compiler Directive Compiler Directives #HIGHPIN is on. You can test the value of #HIGHPIN by entering its name on the TACL command line: 1> #HIGHPIN TACL responds with either “YES” or “NO”. You can change the value of the TACL #HIGHPIN variable by entering the following: ON 1> SET VARIABLE #HIGHPIN OFF You might not want all processes that you start from TACL to run at a high PIN.
HIGHREQ Compiler Directive Compiler Directives x is zero or more alphabetic letters or digits. For example, the following directives have the same effect: ?HIGHREQ ?HIGHREQS ?HIGHREQUESTORS ?HIGHREQUESTER ?HIGHREQ91 Considerations • The HIGHREQ directive must appear on the FORTRAN command line after the semicolon that follows the object file name, or in the source input file before the first FORTRAN source statement.
ICODE Compiler Directive Compiler Directives ° • • If you specify ENV COMMON, and do not open $RECEIVE by explicitly calling the OPEN system procedure. If your program specifies ENV COMMON, FORTRAN opens $RECEIVE with FILE_OPEN_, regardless of the value of the HIGHREQ directive. If a process running at a high PIN attempts to open your process and your process is running with NOHIGHREQ, the file system returns error code 560.
IF Compiler Directive Compiler Directives IF Compiler Directive The IF directive identifies the beginning of a sequence of source records that FORTRAN compiles only if a specified toggle is set. The compiler continues compiling source records until it encounters either an ENDIF directive that specifies the same toggle number as is specified in the IF directive or until it encounters the end of the source file.
IFNOT Compiler Directive Compiler Directives Example In the following example, if you use a SETTOG 2 directive, code A is compiled; if you use a SETTOG 3 directive, code B is compiled. ?IF 2 code A ?ENDIF 2 ?IF 3 code B ?ENDIF 3 IFNOT Compiler Directive The IFNOT directive identifies the beginning of a sequence of source records that FORTRAN compiles only if a specified toggle is reset.
IFNOT Compiler Directive Compiler Directives • Once you have initiated skipping of source text using an IFNOT directive, source lines are skipped until the next matching ENDIF.
INSPECT Compiler Directive Compiler Directives INSPECT Compiler Directive The INSPECT directive establishes the default debugger for the object file. INSPECT selects the Inspect debugger; NOINSPECT selects the Debug debugger. The default value is NOINSPECT. [NO]INSPECT Considerations • • • Specifying the SAVEABEND directive automatically selects the Inspect debugger. Make sure Inspect is available on your system if you specify INSPECT.
LARGECOMMON Compiler Directive Compiler Directives Example ?INTEGER*4 LARGECOMMON Compiler Directive The LARGECOMMON directive tells FORTRAN to allocate space for common blocks in extended memory. If you specify block names in the LARGECOMMON directive, FORTRAN uses extended memory for each common block you specify in the directive.
LARGECOMMON Compiler Directive Compiler Directives LARGECOMMON directive. Use LARGECOMMON directives, not Guardian procedure calls, if your program needs extended data space. • Executing Programs Compiled With LARGECOMMON Accessing variables in normal user data space is faster than accessing variables in extended data space. As a result, a program without LARGECOMMON directives executes faster than an otherwise equivalent program that includes LARGECOMMON directives.
LARGEDATA Compiler Directive Compiler Directives LARGEDATA Compiler Directive The LARGEDATA directive causes the compiler to allocate memory space in the object program’s extended data segment for local data. LARGEDATA item item [ , item ] . . . item is a simple variable name, an unsubscripted array name, an unsubscripted unqualified RECORD name, or an unsigned integer constant.
LARGEDATA Compiler Directive Compiler Directives • • • • Specifying LARGEDATA automatically selects EXTENDEDREF. If a LARGEDATA directive appears anywhere in the compiler’s input, at least one EXTENDEDREF, LARGECOMMON, or LARGEDATA directive must precede the first FORTRAN statement. You cannot use the LARGEDATA directive in a compilation that uses the NOEXTENDEDREF directive.
LARGESTACK Compiler Directive Compiler Directives LARGESTACK Compiler Directive The LARGESTACK directive specifies the block size to reserve for dynamically allocated variables specified in LARGEDATA directives. LARGESTACK number number is an unsigned decimal integer that specifies the number of memory pages to allocate for dynamically allocated variables specified in LARGEDATA directives.
LIBRARY Compiler Directive Compiler Directives LIBRARY Compiler Directive The LIBRARY directive establishes the default user library for the object file. When you run your program, the system consults the user library file specified in the LIBRARY directive for any unsatisfied external procedure references in the object file, before it consults the system library code space.
LINES Compiler Directive Compiler Directives LINES Compiler Directive The LINES directive specifies the number of lines the compiler writes to each page of the listing file. LINES number number is a number ranging from 10 through 32767. The default value is 60. Considerations If you use more than one LINES directive, the new value for number takes effect when the directive is scanned.
LMAP Compiler Directive Compiler Directives LMAP Compiler Directive The LMAP directive instructs BINSERV to pass load-map information to the compiler. The compiler then lists load maps after its identifier map and cross-reference tables. The default value is LMAP ALPHA. [NO]LMAP list – option ( list – option [ , list – option ]. . . ) list-option is any of the following: ALPHA specifies maps in alphabetic order. LOC specifies maps in order by base address.
LOGICAL Compiler Directive Compiler Directives LOGICAL Compiler Directive The LOGICAL directive specifies the size (in bytes) of all subsequent entities in the source file that are declared as type logical. INTEGER*2 INTEGER*4 Considerations • • • You cannot include more than one LOGICAL directive in your source program.
MAP Compiler Directive Compiler Directives • • The run-time buffer pool provides space for edit control blocks (for programs that run as NonStop processes), level-3 spooling buffers, saved messages, and $RECEIVE tables. The amount of space specified or assumed by the LOWBUFFER directive is in addition to the amounts specified or assumed by the SAVE and RECEIVE directives.
NONSTOP Compiler Directive Compiler Directives Example ?NOMAP NONSTOP Compiler Directive The NONSTOP directive specifies that you want your program to run as a NonStop process. The default value is NONONSTOP. [NO]NONSTOP If your program specifies or defaults to ENV OLD: • • • FORTRAN reports a warning if it encounters a NONSTOP directive. FORTRAN specifies in the object file that your program run as a NonStop process if your program includes either a START BACKUP or a CHECKPOINT statement.
PAGE Compiler Directive Compiler Directives FORTRAN reports an error if it encounters a NONSTOP directive after the first FORTRAN statement. Example ?NONSTOP PAGE Compiler Directive The PAGE directive ejects the current page of the list file, prints the specified character string at the top of the next page, and skips two lines before resuming the listing. PAGE [ " title" ] title is a character string.
POP Compiler Directive Compiler Directives POP Compiler Directive The POP directive restores the state of a directive that was saved by a previous PUSH directive. directive POP directive [ , directive ]. . . directive is any of the following FORTRAN compiler directives: BOUNDSCHECK CODE ICODE LIST MAP PRINTSYM WARN The PUSH and POP directives can be useful in auxiliary source input files that are referenced from other files by SOURCE directives.
PRINTSYM Compiler Directive Compiler Directives Example In a subroutine for which array subscript bounds checking is particularly important, the source file could have: ?PUSH BOUNDSCHECK ?BOUNDSCHECK < -- At its beginning . ?POP BOUNDSCHECK < -- At its end Such a source file can be incorporated into any program with a SOURCE directive without disturbing the bounds checking mode of the program using it.
PUSH Compiler Directive Compiler Directives PUSH Compiler Directive The PUSH directive causes the current state of a compiler directive to be saved in a push-down stack where it can be restored by a later POP directive specifying the same directive. The PUSH directive does not change the state of the subject directive. directive PUSH directive [ , directive ]. . .
RECEIVE Compiler Directive Compiler Directives Example In a subroutine for which array subscript bounds checking is particularly important, the source file could have: ?PUSH BOUNDSCHECK ?BOUNDSCHECK <-- At its beginning . ?POP BOUNDSCHECK <-- At its end Such a source file can be incorporated into any program with a SOURCE directive without disturbing the bounds checking mode of the program using it.
RECEIVE Compiler Directive Compiler Directives time. Your process cannot receive additional messages until you reply to at least one of the messages already received. The default value is 1. SYNCDEPTH sync sync is an integer in the range 1 through 255 that specifies the maximum number of replies this process saves for each opener. The default value is 1. SYSMSG specifies that FORTRAN return system messages received from $RECEIVE to your program. You cannot queue system messages.
RESETTOG Compiler Directive Compiler Directives Table 10-2. System Messages (page 2 of 2) C-Series D-Series Msg No. Message Text Msg No.
RUNNAMED Compiler Directive Compiler Directives Example ?RESETTOG 1,3,5 RUNNAMED Compiler Directive The RUNNAMED directive specifies that your program run as a named process. The default value is NORUNNAMED. [NO]RUNNAMED By specifying the RUNNAMED directive, your process can run at a high PIN and be accessed by processes that have not been converted to use D-series features. See, also HIGHPIN Compiler Directive on page 10-32.
SAVE Compiler Directive Compiler Directives Example ?RUNNAMED SAVE Compiler Directive The SAVE directive specifies the system messages to save during process initialization. save – spec SAVE ( save – spec [ , save – spec ]. . . ) save-spec is one of the following: STARTUP [ stup ] stup is an integer in the range 68 through 594 that specifies the number of bytes of buffer space to allocate for the saved startup message. The default value is 594.
SAVEABEND Compiler Directive Compiler Directives • • Use the ALL parameter to save the STARTUP message, PARAM message, and all ASSIGN messages. If you omit the SAVE directive, FORTRAN does not save any messages or reserve any buffer space. Example ?SAVE ALL SAVEABEND Compiler Directive The SAVEABEND directive specifies whether Inspect should automatically create a save file if the program terminates abnormally at run time. Use the SAVEABEND directive only with the INSPECT directive.
SEARCH Compiler Directive Compiler Directives SEARCH Compiler Directive The SEARCH directive specifies a list of object files for BINSERV to search for unsatisfied external references at compilation time. file – name SEARCH ( file – name [ , file – name ]. . . ) file-name is the name of a disk file that contains object code produced by the C, COBOL85, FORTRAN, Pascal, or TAL compiler. file-name can be a DEFINE name.
SETTOG Compiler Directive Compiler Directives Considerations • • The section-name identifies all source text that follows the SECTION until another SECTION directive or the end of the source file occurs. The SECTION directive must be the only directive on the directive line. Example The following example includes a file, FUNCTIONS, with a SECTION directive identifies a section called MATHROUTINES. The program called MAIN sources the text from the section MATHROUTINES in the file FUNCTIONS.
SOURCE Compiler Directive Compiler Directives Considerations • • • • Write the SETTOG directive as the last item on a directive line. If you do not specify any toggle numbers, the SETTOG directive sets all 15 toggles. The compiler initially resets all toggles. Use the SETTOG and RESETTOG directives with the IF, IFNOT, and ENDIF directives to control conditional compilation.
SOURCE Compiler Directive Compiler Directives • • • • • • You must write the SOURCE directive as the last directive if it appears on a line with other directives. You can continue the list of section names on subsequent lines. Each subsequent line must begin with a question mark (?) in column 1. At the beginning of each section, the compiler sets the COLUMNS directive value to that specified by the last COLUMNS directive preceding the first SECTION directive in that file.
SUBTYPE Compiler Directive Compiler Directives SUBTYPE Compiler Directive The SUBTYPE directive specifies a process subtype for the object file. The default is SUBTYPE 0. SUBTYPE number number is an unsigned integer in the range 0 through 63 that specifies a process subtype. Note. Do not use values 1 through 47 because they are reserved for HP products.
SYMBOLS Compiler Directive Compiler Directives Example ?SUPPRESS SYMBOLS Compiler Directive The SYMBOLS directive specifies whether to include a symbol table in the object file for use by Inspect. You must specify this directive if you intend to use Inspect for source-level debugging. The default value is NOSYMBOLS. [NO]SYMBOLS Considerations • • • • You can turn the SYMBOLS directive on and off on a procedure by procedure basis. You can delete the symbol table after you have debugged the program.
UNIT Compiler Directive Compiler Directives UNIT Compiler Directive The UNIT directive causes one or more units to exist and declares the properties of the files that will be connected to the units. u – lower [ – u – upper ] UNIT ( units [ , file ] [ , create – spec ]. . . ) u-lower u-upper is a number in the range 1 through 999. u-lower is the lower bound of the range, u-upper is the upper bound of the range.
UNIT Compiler Directive Compiler Directives exclusion-code is one of the following keywords: EXCLUSIVE, PROTECTED, or SHARED. exclusion-code specifies the file exclusion mode. The default value is SHARED. EXT pri-ext EXT ( pri-ext [, sec-ext ] ) pri-ext and sec-ext are integers in the range 0 through 32767 that specify the primary and secondary extent size, in pages. If you omit sec-ext, the compiler uses the value of pri-ext for sec-ext. The default value is (1,1).
WARN Compiler Directive Compiler Directives WARN Compiler Directive The WARN directive instructs the compiler to list compiler warning messages, regardless of the setting of the LIST directive. If you specify NOWARN, the compiler suppresses warning messages. The default value is WARN.
WARN Compiler Directive Compiler Directives FORTRAN Reference Manual—528615-001 10 -70
11 Running and Debugging Programs This section describes how to run a FORTRAN program. It also describes the debugging modes available to you in the Guardian environment.
Running and Debugging Programs Running a FORTRAN Program IN infile where infile specifies the name of your input file. If you omit this option, the TACL IN file is used; this is usually the home terminal. OUT outfile where outfile is the name of the output file. If you omit this option, TACL’s OUT file is used; this is usually the home terminal. NAME [process] is the symbolic name assigned to the new process.
Running and Debugging Programs Running a FORTRAN Program LIB library where library specifies an object file to use as a user library file for this execution of the program. The contents of this file become the library code space for the executing program. Do not specify this option if the object file containing user code space has more than 16 code segments. You can use the LIB option to override the user library file name specified in the FORTRAN LIBRARY directive when you compiled your program.
Using TACL PARAM Commands Running and Debugging Programs Using TACL PARAM Commands Table 11-1 shows the TACL PARAM commands that you can specify when you run your program. For more information, see the CRE Programmer’s Guide. Table 11-1. Run-Time TACL PARAM Commands PARAM Values Environment Effect BUFFERED-SPOOLING ON COMMON BUFFERED-SPOOLING OFF ensures that your program does not use level-3 spooling.
Running and Debugging Programs Disabling Level-3 Spooling With ENV COMMON 0 PARAM SPOOLOUT 1 To disable level-3 spooling, specify: PARAM SPOOLOUT 0 Your program uses level-1 spooling for all spooled files, except spooled files for which you explicitly set spooling parameters by calling FORTRANSPOOLSTART. The SPOOLOUT PARAM does not force those spooler files to use level-1 spooling. For more information about FORTRANSPOOLSTART, see Section 15, Utility Routines.
Running and Debugging Programs The EXECUTION-LOG PARAM and Standard Input The EXECUTION-LOG PARAM and Standard Input FORTRAN determines the file name for standard input as follows. If the INFILE name in your program’s startup message is: • • • Not the name of your program’s home terminal, FORTRAN uses the INFILE name from the startup message for standard input. Blanks, FORTRAN does not open a system file but accepts open requests and returns end of file each time your program reads from standard input.
Running and Debugging Programs The EXECUTION-LOG PARAM and Standard Output The EXECUTION-LOG PARAM and Standard Output FORTRAN determines the file name for standard output as follows. If the OUTFILE name in your program’s startup message is: • • • Not the name of your program’s home terminal, FORTRAN uses the OUTFILE name from the startup message for standard output.
Running and Debugging Programs Using Debug Facilities PARAM specifies an asterisk (*), FORTRAN does not write messages to standard log. • If an ASSIGN specifies STDERR and a PARAM specifies EXECUTION-LOG, FORTRAN uses the physical name from the ASSIGN unless the physical name specifies your home terminal, in which case FORTRAN uses the value of the EXECUTION-LOG PARAM or, if the EXECUTION-LOG PARAM value is an asterisk, FORTRAN does not open standard log.
Running and Debugging Programs Using the INSPECT TACL PARAM If you use more than one method of selecting a debugger, precedence is established as follows: A program file value (specified either in a compiler directive—INSPECT or NOINSPECT—or a Binder command—SET INSPECT ON or SET INSPECT OFF) overrides the value specified in the RUN command, which overrides the value specified in a TACL session.
Running and Debugging Programs Using Inspect Using Inspect Inspect is an interactive-symbolic debugger that lets you control program execution, display values, and modify values in terms of source-language symbols. Inspect has two basic modes: high-level and low-level. Note. Unlike FORTRAN, Inspect does not allow embedded spaces in identifier names. You must enter each identifier name as a consecutive string of nonblank characters.
Running and Debugging Programs • • • • • • • Using the NONSTOP PARAM Inquire about or set the program environment (the default system, volume, and subvolume) Use the FC command to edit a previous command Display help information Use the OBEY command to read commands from a disk file Display machine instructions expressed as ICODE Step through program execution by one or more machine instructions Exit from Inspect For additional information about Inspect commands in general, and Inspect support for FORTR
Running and Debugging Programs Using SWITCH-nn PARAM Changing the values of switches after your program begins running does not affect the switch values used by your program. You read switch values using the SSWTCH utility routine, described in Section 15, Utility Routines.
12 Memory Organization Topics covered in this section include: Topic Page Code Space 12-1 Data Space 12-2 Debugging Programs That Use Extended Memory 12-13 TNS Processor Memory Organization 12-13 The information in this section might be useful to you: • • • If you need to control where FORTRAN allocates data and data blocks If you are using Inspect or Debug to debug a program If you are combining FORTRAN programs written in languages other than FORTRAN Code Space The code area of a process co
Data Space Memory Organization The P (program) register is the program counter. It contains the 16-bit C[0]-relative address of the current instruction plus one. The contents of the P register are incremented by one at the beginning of each instruction that your program executes so that, normally, instructions are fetched (and executed) from ascending memory locations.
Data Space Memory Organization defined in the memory stack. All local data in your program is referenced relative to the L register except the dummy arguments to statement functions, which are referenced relative to the S register. Word-addressable and byte-addressable data can be stored in the memory stack area. Figure 12-1.
Data Space Memory Organization Figure 12-2.
Upper Memory Memory Organization Upper Memory The upper memory area (the “upper” 32K words of the user data segment) is optionally available for • • Common data specified by the HIGHCOMMON directive Control information specified by the HIGHCONTROL and HIGHBUFFER directives Access to upper memory is by indirect addressing only. FORTRAN stores only wordaddressable data in upper memory.
Storage Areas Memory Organization Table 12-2. Compiler Directives That Control Data Allocation (page 1 of 2) Effect Directive ENV OLD ENV COMMON DATAPAGES Specifies how many pages to allocate for data storage in the user data segment (Default: Compiler estimates) Always uses 64 EXTENDCOMMON Allocate one pointer for each common block.
Storage Areas Memory Organization Table 12-2.
Storage Areas Memory Organization proceeds, but that cannot be on top of the run-time stack because they must remain allocated after the procedure creating them has returned to its caller. The #LOWBUF area contains space for the Saved Message Utility storage area, plus the $RECEIVE file message queue area, plus a general area for file buffers.
Storage of Entities in Common Blocks Memory Organization allocated by the system if sufficient space is not available or if the program specifies a level-3 buffer area with a valid address in a call to FORTRANSPOOLSTART. The program can run correctly, though slower, without a level-3 spooling buffer area. User-written TAL subprograms can also call GET^BUFFER and PUT^BUFFER to make further use of these areas.
Storage of Entities in Common Blocks Memory Organization place entities in global storage; any program unit that makes reference to common storage can use these entities. You can also use DATA and SAVE statements to place specified entities in global storage and to store their addresses in the code area. Three compiler directives affect the addressing and storage of entities in common: • • • EXTENDCOMMON, which provides indexed indirect addressing.
Extended Memory Memory Organization entities that follow are located by indexing. Having one pointer for all scalars saves space in primary global storage, at some expense for additional processing time. Extended Memory An object program executing on an HP NonStop system always has exactly one user data segment of up to 65,536 words (addressable with 16-bit word addressing) and can also have any number of extended data segments of up to 127.5MB (addressable with 32-bit byte addressing).
Extended Memory Memory Organization These pointers are in the data blocks named EXTENDED#STACK#FRAME and EXTENDED#STACK#POINTERS. The user data segment run-time stack cannot grow past address G[32767]. If a program exceeds this limit, it is interrupted with a stack overflow trap, and the system calls Debug or Inspect unless the ARMTRAP procedure has been called. Whether you specify ENV OLD or ENV COMMON, your program always traps if it overflows the run-time stack.
Debugging Programs That Use Extended Memory Memory Organization Debugging Programs That Use Extended Memory You can use Inspect or Debug to debug programs that use extended memory. If you use high-level Inspect commands to debug your programs, you won’t notice any changes when you debug programs with extended memory. Because Inspect allows you to refer to program entities by symbolic names (rather than memory addresses), using extended memory does not affect the way you use Inspect.
Accessing Data Memory Organization Figure 12-5.
13 Mixed-Language Programming This section describes how you can combine procedures written in C, COBOL85, FORTRAN, Pascal, and TAL into an executable object file.
Sharing Files When ENV COMMON Is in Effect Mixed-Language Programming • • • • • • Manage shared access to unit 5 and unit 6 Manage NonStop process pairs Write run-time diagnostic messages Manage hardware traps Manage $RECEIVE Support intrinsic functions For more information about the CRE, see the CRE Programmer’s Guide. Sharing Files When ENV COMMON Is in Effect This subsection describes how your FORTRAN program shares access to the files connected to unit 5 and unit 6 if you specify ENV COMMON.
Module Compatibility Mixed-Language Programming Both the COBOL85 DISPLAY verb and the FORTRAN WRITE statement write to the same file open of the same Guardian file. Shared access to units 5 and 6 enables you to coordinate FORTRAN I/O to unit 5 and unit 6 with I/O statements executed in modules written in languages other than FORTRAN.
Referencing Separately-Compiled Procedures Mixed-Language Programming For further information about Binder groups, see the Binder Manual. Referencing Separately-Compiled Procedures Your FORTRAN program can call routines that are compiled in separate compilations, including the ‘main’ procedure. For example, you might write your own FORTRAN subroutine to provide the parameters to a standard application.
Using Program Libraries Mixed-Language Programming Data Areas in User Library Space FORTRAN routines in user libraries cannot directly access data items declared in: • • • • COMMON statements DATA statements SAVE statements The extended data segment Library routines can reference data in the preceding data areas only if the calling routine passes the data item as an actual parameter to the library routine.
Using Global Data in Mixed Language Programming Mixed-Language Programming Using Global Data in Mixed Language Programming FORTRAN does not have global data in the same sense as some other programming languages such as C, Pascal, and TAL. Instead, FORTRAN programs share data by placing specific data items in common blocks and declaring those common blocks in each program unit that uses them.
The FORTRAN Calling Sequence Mixed-Language Programming the TAL object file includes: • • • • Common data block “$BIG” in the extended data segment Common data block “BIG” in the global primary data area, containing doubleword pointers to A and B Common data block “.SMALL” in the user data segment Common data block “SMALL” in the global primary data area, containing pointers to C, D, and E The layout of blocks “$BIG” and “.SMALL” will be the same as those of the FORTRAN program.
The FORTRAN Calling Sequence Mixed-Language Programming When FORTRAN translates the CALL statement CALL bakerstreet (holmes, doyle) it generates object code to call a procedure named BAKERSTREET which, if it were written in FORTRAN, would be a subroutine subprogram having formal parameters with types as shown. You could write the called routine in TAL as follows: PROC bakerstreet (holmes, doyle); INT .holmes; REAL .doyle; BEGIN ...
The FORTRAN Calling Sequence Mixed-Language Programming with types as shown and return a type INTEGER*2 function value. If it were written in TAL, it would be declared as follows: INT PROC watson (holmes, doyle); INT .holmes; REAL .doyle; BEGIN INT value; ... RETURN value; END; If you specify the FORTRAN compiler directive EXTENDEDREF, the TAL code would be: INT PROC watson (holmes, doyle); INT .EXT holmes; REAL .EXT doyle; BEGIN INT value; ...
The FORTRAN Calling Sequence Mixed-Language Programming FORTRAN generates object code to call a procedure that could be declared in TAL as: PROC mycroft (holmes, doyle); INT .holmes; REAL .doyle; BEGIN STRING .result = 'L' - 5; result ':=' ... ; END; Note that you do not specify a type in the TAL procedure for the TAL return value. If you specify the FORTRAN compiler directive EXTENDEDREF: PROC mycroft (holmes, doyle); INT .EXT holmes; REAL .EXT doyle; BEGIN STRING .EXT result = 'L' - 8; result ':=' ...
The FORTRAN Calling Sequence Mixed-Language Programming of types other than CHARACTER. For an EXTENSIBLE procedure, the length words are stored in the reverse order, so that you can add formal parameters of type CHARACTER to existing procedures. FORTRAN passes the length words so that the called procedure knows the lengths of the actual arguments that correspond to the formal arguments, as well as the function return value pseudo-parameter, as type CHARACTER*(*).
Calling Other Language Procedures From FORTRAN Mixed-Language Programming because the top few words of the stack will be as follows: 'L' - 0 Caller's (L) 'L' - 1 Caller's (E) 'L' - 2 Caller's (P) 'L' - 3, 4 Extended address of DOYLE 'L' - 5, 6 Extended address of MORIARITY 'L' - 7, 8 Extended address of HOLMES 'L' - 9,10 Extended address of RESULT 'L' - 11 Length of MORIARITY 'L' - 12 Length of RESULT Calling Other Language Procedures From FORTRAN If you write a FORTRAN program that call
General Restrictions Mixed-Language Programming General Restrictions You cannot call a subprogram from FORTRAN if it: • • • Has more than 63 formal parameters Has pass-by-value parameters larger than 64 bits Is a function that returns a value that is not a simple scalar value or is of a data type that cannot be declared in FORTRAN (for example, pointers and structures are not allowed) You cannot call a function subprogram from FORTRAN with a CALL statement.
Using GUARDIAN and CONSULT Directives Mixed-Language Programming Examples of Guardian Calls 1. This example calls the FILEERROR procedure to obtain status information about a file: istatus = FILEERROR (ifilenum) 2. This example calls the FILEINFO procedure to determine the number of extents allocated to a file: CALL FILEINFO (ifilenum,,, ,,, ,,, ,,, ,,, ,inumexts) The FILEINFO procedure actually has 26 parameters but only one required parameter.
Calling Routines Without Using GUARDIAN and CONSULT Directives Mixed-Language Programming (LARGEDATA ERROR), you cannot pass its address to the FILEINFO procedure. The example passes ERROR_TEMP, which is allocated in the user data segment, instead, and then assigns the value returned in ERROR_TEMP to ERROR. The Guardian Procedure Calls Reference Manual indicates which procedures expect word addresses and which expect doubleword addresses. Parameters that specify .
Calling Routines Without Using GUARDIAN and CONSULT Directives Mixed-Language Programming • Arguments passed by reference must pass word or doubleword addresses, according to the requirements of the called procedure. All parameters passed by reference must have the same size address, either word or doubleword. If the called procedure expects word addresses, the FORTRAN program must not be compiled with any EXTENDEDREF, LARGECOMMON, or LARGEDATA compiler directives.
Calling TAL Subprograms From FORTRAN Mixed-Language Programming ° The mask must be one word for procedures with up to 16 parameters and two words for procedures with 17 to 29 parameters. ° ° The mask value must be right-justified in the word or words. ° Set the bit for each parameter whose value you supply in the call. Don’t set bits for optional parameters that you omit, although you supply “dummy” values as placeholders for them.
Mixed-Language Programming Calling TAL Subprograms From FORTRAN If you compile your FORTRAN modules with ENV OLD in effect and your TAL modules with either ENV OLD or ENV NEUTRAL in effect, routines written in both languages can open the same file but each open is independent of all other opens. You can share access to the same file open by passing the file number between routines that need to access the same file using the same file open.
Calling COBOL85 Subprograms From FORTRAN Mixed-Language Programming TAL convention, and does not stack length words for character parameters. For example, if the TAL procedure is declared by: PROC p (s: l); STRING .EXT s; INT l; EXTERNAL; the colon between S and L causes the TAL compiler to declare (to the Binder) that L is a parameter pair.
Calling C Subprograms From FORTRAN Mixed-Language Programming • • ° If the FORTRAN subprogram is compiled with any EXTENDEDREF, LARGECOMMON, or LARGEDATA directives, the ACCESS MODE IS EXTENDED-STORAGE clause must be included in each level 01 or 77 data item in the Linkage Section of the Data Division of the called COBOL85 subprogram, so that the called COBOL85 subprogram will expect the doubleword argument addresses that FORTRAN will provide.
Mixed-Language Programming • • • • • • Calling Pascal Subprograms From FORTRAN If the FORTRAN program does not declare the C subprogram with a GUARDIAN or CONSULT directive: ° If the FORTRAN program is compiled with any EXTENDEDREF, LARGECOMMON, or LARGEDATA directives, the called C subprogram must be compiled with the XMEM directive, so that the C subprogram will expect the doubleword-address arguments that FORTRAN passes.
The COBOLEXT Files Mixed-Language Programming The COBOLEXT Files Every NonStop system in which the FORTRAN compiler is installed, also includes files named COBOLEX0, COBOLEX1, and COBOLEXT in the same subvolume as the FORTRAN compiler (usually this is the $SYSTEM.SYSTEM subvolume). These files are also used by the COBOL85 compiler. The compilers use these files when translating references to Guardian procedures.
Calling FORTRAN Procedures From Other Languages Mixed-Language Programming 2. Delete dummy values used as placeholders for omitted arguments. If the omitted arguments are at the end of the argument list, delete them completely; if the omitted arguments precede other arguments that you supply in the list, use successive commas to skip them. 3. Delete the backslashes (\) that surround pass-by-value arguments.
Calling FORTRAN Subprograms From COBOL85 Mixed-Language Programming If the FORTRAN routine is not compiled with any of these directives, declare all the address parameters in the TAL external declaration as standard (that is, word) reference parameters (without .EXT) as in the following example: PROC fort_sub = "THE_SUB" (a, b, c) LANGUAGE FORTRAN; INT .a, .b, .
Calling FORTRAN Subprograms From C Mixed-Language Programming doubleword parameter addresses in either case, after examining the compiled procedure in its object file. For information about sharing files in programs that consist of COBOL85 and FORTRAN routines, see Calling COBOL85 Subprograms From FORTRAN on page 13-19.
Using ENV COMMON Mixed-Language Programming If you are writing a TAL program and you want to use any of the FORTRAN intrinsic functions, you can use TAL compiler directives to SOURCE in the FORTDECS file and SEARCH the FORTLIB file. The FORTDECS file contains a SECTION for each procedure, so that you can use it in much the same way as the $SYSTEM.SYSTEM.EXTDECS file.
Using Shared Files Mixed-Language Programming • • • • Manage traps. Provide standard math routines that support FORTRAN intrinsic functions. Manage $RECEIVE. Ensure proper initialization and graceful termination of your program. Using Shared Files The CRE provides shared access to three files: • • • Standard input Standard output Standard log Sharing File Opens A FORTRAN program accesses standard input if it reads from unit 5. It accesses standard output if it writes to unit 6.
Using Shared Files Mixed-Language Programming languages are managed by CRE routines. All such open requests to the same standard file access not only the same Guardian file, but access the file using the same file open. For your program to share access to the standard files, it does not have to take any action beyond ensuring that it opens the standard file with the proper access MODE. For more detailed information, see the CRE Programmer’s Guide.
14 Interprocess Communication Topics covered in this section include: Topic Page Managing $RECEIVE 14-3 Using $RECEIVE 14-5 Message Queuing 14-11 An application in an HP NonStop environment frequently consists of numerous communicating processes. Each process is designed to perform a particular set of tasks. Dividing an application into multiple processes enables you to more easily maintain your application because you design each process to perform a series of related functions.
Interprocess Communication The processes described in the preceding paragraphs are called server processes. A server process accepts requests from other processes, carries out the requests received, and sends replies to the requesting processes. A process that issues requests to a server process is called a requester process. A requester process is frequently referred to as a requester. A server process is frequently referred to as a server. A server process provides services to requester processes.
Managing $RECEIVE Interprocess Communication Figure 14-3. Requesters and Servers Requester A Requester B Server A Process 1 Server A Process 2 Requester C Server A Process 3 Database I Requester D Server B Requester E Server C Process 2 Server C Process 1 Database II Database III VST1403.vsd Communication between processes takes place by means of a special file called $RECEIVE. For a comprehensive description of $RECEIVE, see the Guardian Programmer’s Guide.
Managing $RECEIVE Interprocess Communication The FORTRAN run-time library checks each message it receives from a requester process to determine if it has already received and replied to the message. If it has, it locates the previously-sent reply and returns it again. Your FORTRAN program is not aware of the retransmission. • MAXREPLY reply reply specifies the maximum number of bytes in each reply message that your program must save.
Using $RECEIVE Interprocess Communication Figure 14-4. Structure Allocation to Support NonStop Requester Processes Requesters Requester A Requester B Requester C loop: . . . WRITE to server . . . WRITE to server . . . WRITE to server . . . WRITE to server CHECKPOINT loop: . . . WRITE to server . . . WRITE to server . . . WRITE to server . . . WRITE to server CHECKPOINT loop: . . . WRITE to server . . . WRITE to server . . . WRITE to server . . .
$RECEIVE as an Input File Interprocess Communication $RECEIVE as an Input File In the simplest case, the task-handling process uses $RECEIVE as an input file only. It receives request messages from originating processes via $RECEIVE and acts upon the requests. It does not generate a reply to each message, but an automatic reply is sent when the next read operation is initiated. (Note that this default reply facility is available only if QDEPTH is equal to 1.
$RECEIVE as an Input/Output File Interprocess Communication $RECEIVE as an Input/Output File In this case, the server opens $RECEIVE in the I-O mode to receive requests and reply to them through the same file. Each request is acted upon and paired with a message sent back to the requester in response to the request message: request message Requester Process reply message Server Process VST1406.vsd A requester might contain the following statements: ... CHARACTER*80 request CHARACTER*132 reply ...
$RECEIVE as Separate Input/Output Files Interprocess Communication The server receives request messages from $RECEIVE, performs the requested tasks, and replies to the message. The following code shows an example of a server: ... ?RECEIVE (OPEN 2, MAXREPLY 132) ... CHARACTER*80 request CHARACTER*132 reply ... OPEN (UNIT=1,FILE='$RECEIVE') ... 10 READ (UNIT=1,END=100) request IF (request(1:3) .EQ. 'ADD') THEN ... <-- Code to process ... <-- request and ... <-- construct reply END IF ...
READ Statement With $RECEIVE Interprocess Communication The requester is the same as in the prior example. The server code is also the same, except that there is another OPEN statement and the responding WRITE statement is changed: ?RECEIVE (OPEN 2, MAXREPLY 132) ... CHARACTER*80 request CHARACTER*132 reply ... OPEN (UNIT=1,FILE='$RECEIVE',MODE='INPUT') OPEN (UNIT=2,FILE='$RECEIVE',MODE='OUTPUT') ... 10 READ (UNIT=1,END=100) request IF (request(1:3) .EQ. 'ADD') THEN ... <-- Code to ...
Using the READ Statement PROMPT Specifier Interprocess Communication shows the contents of iarr after a read operation that specifies SOURCE (declared as SOURCE(16) for this example) completes successfully. Table 14-1.
Message Queuing Interprocess Communication Your server process returns a Guardian file-system error code in rep-exp, or zero if no error occurred. The value you store for rep-exp is the value returned to the requester if it calls the FILEINFO or FILE_GETINFO_ system procedure. Message Queuing The preceding examples of the uses of $RECEIVE show server processes that respond to each request as it is received. An advanced method of interprocess communication involves message queuing.
Message Queuing Interprocess Communication Example 14-1. Example Requesters R1 and R2 for Queued Server 1 ?PAGE "REQUESTER NUMBER 1 FOR QUEUED SERVER" 2 ?LOGICAL*2 3 PROGRAM requester1 4 IMPLICIT INTEGER*2 (a-z) 5 CHARACTER*8 prompt 6 DIMENSION records(4) 7 DIMENSION rec(2) 8 DATA records /1,3,5,7/ 9 10 11 WRITE (prompt,11) records 11 FORMAT (4A2) 12 OPEN (UNIT=5,SPACECONTROL='NO') 13 OPEN (UNIT=6) 14 WRITE (6,22) 15 22 FORMAT ('1R1 ABOUT TO MAKE FIRST REQUEST.
Message Queuing Interprocess Communication Example 14-1.
Message Queuing Interprocess Communication The server opens a disk file of two-word records (the first word is the key; the second, the associated data) and reads sequentially from it. If a requester has expressed interest in the current record, the server sends it to that requester. Since the order in which requests arrive is unpredictable, the server must save requests for records that have not yet been read, until those records become available.
Message Queuing Interprocess Communication 1> 2> 3> R1 4> R2 R1 R2 R2 R1 R2 R1 R2 R1 R2 R1 R2 R1 R2 R1 RUN QSO /NAME RUN R1O /NAME RUN R2O /NAME ABOUT TO MAKE PAUSE ABOUT TO MAKE 1 3 5 2 4 6 2 4 6 1 3 5 2 4 6 1 3 5 2 4 6 1 3 5 2 4 6 1 3 5 2 4 6 1 3 5 STOPPING STOPPING $DIST, CPU 0, IN $RECEIVE, OUT $RECEIVE/ $R1, CPU 0, IN $DIST/ $R2, CPU 0, IN $DIST/ FIRST REQUEST. FIRST REQUEST.
Message Queuing Interprocess Communication 1. The server updates its list of pending requests to show that the matching request has been satisfied. 2. The server writes the record to $RECEIVE (line 45). The MSGNUM specifier identifies the request for which this is the reply; it was obtained when the request was read (line 49). 3. Processing returns to the beginning of the main loop.
Message Queuing Interprocess Communication Example 14-2.
Message Queuing Interprocess Communication Example 14-2. Example Queued Server (Part 1 of 3) 38 39 40 10 CONTINUE READ (UNIT=7,FMT=11,END=60) record(1), record(2) 11 FORMAT (2I5) 41 rqr = matchold (record, dest, dest this rqr, no rqr) 42 IF (rqr .NE.
Message Queuing Interprocess Communication When the end of the data file is reached, control passes to statement label 60 (line 72). Here, in a loop from line 73 to line 77, the server sends an end-of-file indication (error code 1) to each requester that has an outstanding request. Example 14-3. Example Queued Server (Part 2 of 3) 48 20 CONTINUE 49 READ (UNIT=5, SOURCE=source, LENGTH=length) request 50 IF (system) THEN 51 IF (request(1) .EQ. -30 .AND. 52 + MOD(request(2),16) .GT.
Message Queuing Interprocess Communication Example 14-3. Example Queued Server (Part 2 of 3) 81 82 IF (request(1) .EQ. -30 .AND. + MOD(request(2),16) .GT.
Message Queuing Interprocess Communication Example 14-4. Example Queued Server (Part 3 of 3) 108 END IF 109 10 CONTINUE 110 20 CONTINUE 111 RETURN 112 END 113 ?PAGE "MATCHNEW FUNCTION" 114 LOGICAL FUNCTION matchnew(request, request words, record) 115 INTEGER request(1), request words, record(1) 116 LOGICAL answer 117 answer = .FALSE. 118 DO 10 I = 1, request words 119 IF (request(I) .EQ. record(1)) THEN 120 answer = .TRUE.
Message Queuing Interprocess Communication FORTRAN Reference Manual—528615-001 14 -22
15 Utility Routines The FORTRAN run-time library contains utility routines supplied by HP. These routines enable FORTRAN applications to: • • Invoke system routines that are not available through standard FORTRAN constructs. Fetch, alter, or delete the contents of PARAM, ASSIGN, and startup messages. The latter routines comprise the Saved Message Utility (SMU).
FORTRANCOMPLETION Routine Utility Routines Table 15-1. FORTRAN Run-Time Utility Routines (page 2 of 2) Routine ENV Action FORTRAN_SETMODE_ COMMON Calls the SETMODE system procedure unless buffered spooling has been successfully initiated for the file, in which case FORTRAN_SETMODE_ calls the SPOOLSETMODE spooler procedure. FORTRAN_SPOOL_OPEN_ COMMON Provides level-1, level-2, or level-3 access to the HP spooler.
Utility Routines FORTRANCOMPLETION Routine message-length is an integer expression that specifies the length of message. If you omit message-length, the actual length of message is used. message is a character expression that the FORTRAN run-time library displays on your process’s home terminal. message must be at least message-length characters if you specify message-length. If you do not specify message-length, the actual length of message is displayed.
FORTRANCOMPLETION Routine Utility Routines • Executing a FORTRAN STOP statement is equivalent to calling FORTRANCOMPLETION, with all its arguments omitted (except possibly message). For example: STOP is equivalent to CALL FORTRANCOMPLETION STOP msg is equivalent to CALL FORTRANCOMPLETION(, , msg) • • Include the spi-ssid parameter if you use termination-info or text. spissid must be a RECORD data structure or a type CHARACTER*12 variable or expression.
Utility Routines FORTRAN_COMPLETION_ Routine Then it calls the STOP or ABEND system procedure, as indicated by abend-orstop, passing its completion-code through text arguments to STOP or ABEND. • • The message argument corresponds to the message option in the FORTRAN STOP statement. If you specify message, FORTRANCOMPLETION displays message on the home terminal. The text argument is intended for a different use.
FORTRAN_COMPLETION_ Routine Utility Routines message is a character expression that the FORTRAN run-time library writes to the standard log file. message must be at least message-length characters if you specify message-length. If you do not specify message-length, the actual length of message is displayed. FORTRAN_COMPLETION_ displays a maximum of 80 characters. completion-code is an integer expression whose value is passed as the completion-code parameter to PROCESS_STOP_.
FORTRAN_COMPLETION_ Routine Utility Routines STOP msg is equivalent to CALL FORTRAN_COMPLETION_( , , msg) • • Include spi-ssid if you use termination-info or text. spi-ssid must be a RECORD data structure or a type CHARACTER*12 variable or expression. (The corresponding parameter of PROCESS_STOP_ must be a six-element type INTEGER*2 array.
FORTRAN_CONTROL_ Routine Utility Routines message to the standard log file. The text argument is intended for a different use. FORTRAN_COMPLETION_ passes text PROCESS_STOP_, which in turn stores it into the STOP or ABEND system message that is sent to the ancestor process of the terminating process. • You must ensure that the combination of parameters and their values meet the expectations of the PROCESS_STOP_ system procedure.
FORTRAN_SETMODE_ Routine Utility Routines operation is the code to send to the device referenced by unit-number. For specific operation codes, see the CONTROL procedure in the Guardian Procedure Calls Reference Manual. param specifies the value of the parameter to the CONTROL operation you specify. For specific param values for each CONTROL operation, see the CONTROL procedure in the Guardian Procedure Calls Reference Manual.
FORTRAN_SETMODE_ Routine Utility Routines If error-return is zero, FORTRAN_SETMODE_ successfully issued a SETMODE or SPOOLSETMODE operation. If error-return is less than 10000, its value is a file system error code. For information about file system errors, see the Guardian Procedure Errors and Messages Manual . For information about errors returned by the SPOOLSETMODE spooler procedure, see the Spooler Programmer’s Guide.
Utility Routines FORTRAN_SPOOL_OPEN_ Routine FORTRAN_SPOOL_OPEN_ Routine FORTRAN_SPOOL_OPEN_ provides level-1, level-2, and level-3 access to the HP spooler from a FORTRAN program. You can use FORTRAN_SPOOL_OPEN_ only in programs that specify ENV COMMON. FORTRAN attempts to use level-3 spooling for any file that opens a spooler collector if PARAM BUFFERED-SPOOLING OFF is not in effect.
Utility Routines FORTRAN_SPOOL_OPEN_ Routine For example, if error-return is 201, the error is a file system error—the file referenced by unit-number is on a node that is no longer accessible. If errorreturn is 10250, you must subtract 10000 from error-return to produce error 250: the node associated with unit-number that you specified is not currently accessible over the HP network. filename specifies the name of the spooler collector or spooler job file to open for the spooling session.
FORTRAN_SPOOL_OPEN_ Routine Utility Routines spooling-level specifies the spooling level to use for the file. You can specify the following values: Spooling Level Effect < -1 FORTRAN_SPOOL_OPEN_ returns error 10056 (error 56), invalid parameter. -1 The file uses level-3 spooling if the FORTRAN run-time library can obtain a buffer and PARAM BUFFERED-SPOOLING OFF is not specified. Otherwise, the file uses level-1 or level-2 spooling.
FORTRAN_SPOOL_OPEN_ Routine Utility Routines characters, only the first 16 characters are passed to the spooler. If report-name is less than 16 characters, the FORTRAN run-time library adds blanks on the right side of report-name when it calls SPOOLSTART. The spooler accepts any combination of letters, digits, and blanks. number-of-copies is an integer expression whose value specifies the number of copies to print. number-of-copies must be in the range 1 through 32,767. The default is 1.
FORTRAN_SPOOL_OPEN_ Routine Utility Routines max-pages is an integer expression whose value specifies the maximum number of pages for the spooler job. max-pages must be in the range 1 through 65,534. If max-pages is zero or omitted, the spooler does not impose a limit on the number of pages it writes. Considerations • • • • • Use FORTRAN_SPOOL_OPEN_ only in programs that specify an ENV COMMON directive.
Utility Routines FORTRANSPOOLSTART Routine FORTRANSPOOLSTART Routine FORTRANSPOOLSTART provides level-2 and level-3 access to the HP spooler from a FORTRAN program. FORTRAN automatically provides level-3 spooling for a file directed to the spooler when FORTRANSPOOLSTART is not used and PARAM SPOOLOUT 0 is not in effect.
FORTRANSPOOLSTART Routine Utility Routines level-3-buffer is an INTEGER*2 array that contains at least 512 elements. This array is the buffer in which to store spool file records before sending them to the spooler. It must be allocated statically (in a common block or named in a DATA or SAVE statement) and must not be allocated in the extended data segment. location is a character expression whose value specifies the location for the spooler job.
FORTRANSPOOLSTART Routine Utility Routines page-size is an integer expression whose value specifies the number of lines per page the NonStop PERUSE utility uses for its PAGE and LIST commands. page-size must be in the range 1 through 32,767. The default is 60 lines. flags is an integer expression whose value specifies certain attributes for the spooler job.
Choosing a Spooling Level Utility Routines Choosing a Spooling Level The following list describes the three levels of spooling that you can specify. • Level-1 spooling FORTRANSPOOLSTART uses level-1 spooling if options is zero and you omit all other parameters. If you want all spooled files to use level-1 spooling, you can specify PARAM SPOOLOUT 0 when you run your program, rather than using FORTRANSPOOLSTART at all.
SSWTCH Routine Utility Routines SSWTCH Routine SSWTCH returns the current value of a program switch. CALL SSWTCH ( switch-number, result) switch-number is a type INTEGER*2 variable that specifies which switch’s value to return. result is a type INTEGER*2 variable in which SSWTCH stores the current value of switch switch-number. Considerations • • Use SSWTCH only in programs compiled with ENV COMMON.
Saved Message Utility Utility Routines Saved Message Utility The Saved Message Utility (SMU) is a collection of routines that are extensions to the HP FORTRAN product. Table 15-2 lists the SMU routines. You use these routines to save and modify the messages sent to your process by the operating system. The Guardian Procedure Calls Reference Manual contains a complete description of these messages. The first part of this subsection describes how you use the SMU routines.
Saved Message Utility Utility Routines Table 15-2. Saved Message Utility Routines (page 2 of 2) Name Action GETASSIGNVALUE Retrieves a portion of an ASSIGN message as an integer and assigns it to an integer variable. GETBACKUPCPU Retrieves a backup CPU number from the PARAM message. GETPARAMTEXT Retrieves a portion of the PARAM message as text and assigns it to a string variable. GETSTARTUPTEXT Retrieves a portion of the startup message as text and assigns it to a string variable.
Using SMU Routines Utility Routines Figure 15-1. Process Messages Manipulated by the SMU STARTUP message with the names of the IN file and the OUT file, the default volume and subvolume, and the text string that follows the closing "/" of the RUN command parameter list.
Types of SMU Routines Utility Routines Each saved ASSIGN message is given a unique, serially assigned message number. This number is a positive integer from one to the greatest number of saved ASSIGN messages. It is used to specifically identify each saved ASSIGN message. SMU routines operate on specific portions of saved messages. Each portion is identified by a special string value. You must pass the string value as the portion parameter to the appropriate routine.
Changing Environment Information Utility Routines Table 15-3.
Deleting Environment Information Utility Routines The following example uses the ALTERPARAMTEXT routine to change a parameter value: ?GUARDIAN ALTERPARAMTEXT INTEGER error CHARACTER*20 oldparam, newparam READ (9,*) oldparam READ (*,*) newparam error = ALTERPARAMTEXT (oldparam, newparam, 0, 5 ) Deleting Environment Information You can delete stored values and text by using the SMU routines that begin with DELETE.
The ASSIGN Messages Utility Routines The following SMU routines operate on the PARAM message: GETPARAMTEXT DELETEPARAM GETBACKUPCPU PUTPARAMTEXT ALTERPARAMTEXT The ASSIGN Messages The ASSIGN messages contain file names and attributes that you specify using a TACL ASSIGN command. For additional information about the ASSIGN command, see Section 5, Introduction to File I/O in the HP NonStop Environment.
Checkpoint Considerations for Saved Message Utility Routines Utility Routines Table 15-5.
ALTERPARAMTEXT Routine Utility Routines You need to supply a complete checkpoint list only if a program has a backup that must be kept current. When a record of the changes to saved messages is not required, the cplist parameter is 0. For example: INTEGER*2 noncplist DATA noncplist / 0 / You can avoid saturating the checkpoint list and causing a routine failure by declaring large list arrays and checkpointing the information regularly.
ALTERPARAMTEXT Routine Utility Routines elements in cplist. For additional detail, see the Checkpoint Considerations for Saved Message Utility Routines on page 15-28. size is an integer expression whose value is the number of characters in text to use as the new PARAM parameter value. size must be a non-negative integer that is less than or equal to 255. Considerations ALTERPARAMTEXT returns the following values: Return Value Meaning ≥0 size characters of text were assigned as the new parameter value.
CHECKLOGICALNAME Routine Utility Routines CHECKLOGICALNAME Routine The CHECKLOGICALNAME routine checks whether a saved ASSIGN message with a given logical file name exists. It also returns the message serial number associated with the saved ASSIGN message. result = CHECKLOGICALNAME ( logicalname ) result is an integer variable in which CHECKLOGICALNAME returns the result of the operation. See Considerations.
CHECKMESSAGE Routine Utility Routines Example ?GUARDIAN CHECKLOGICALNAME INTEGER error error = CHECKLOGICALNAME ('*.programs') CHECKMESSAGE Routine The CHECKMESSAGE routine determines whether a specific message exists or reports the number of the highest-numbered saved ASSIGN message. result = CHECKMESSAGE ( messagenumber ) result is an integer variable in which CHECKMESSAGE stores its result. See Considerations. messagenumber is an integer expression that identifies the specific ASSIGN message to check.
CREATEPROCESS Routine Utility Routines If messagenumber is nonzero, result is zero if the specified message number does not exist, or is the value associated with messagenumber if the message does exist. Example ?GUARDIAN CHECKMESSAGE INTEGER result result = CHECKMESSAGE ( 15 ) CREATEPROCESS Routine The CREATEPROCESS routine starts a new process according to user-specified parameters. It can also send process creation messages to the new process according to the option parameter specifications.
CREATEPROCESS Routine Utility Routines processor is an integer expression that specifies the processor (0 to 15) in which to run the new process. If processor is negative, the new process executes in the same processor as the creator process. memory is an integer expression that specifies how many memory pages to allocate for the new process. If memory is zero, the number of memory pages in the new process is the value specified in the program file from which the new process is created.
DELETEASSIGN Routine Utility Routines instead of 0, 9 instead of 1, ... 11 instead of 3). CREATEPROCESS returns the class one error result although the new process is created. The value 8 indicates that undefined externals are not considered an error. • Opening an unnamed process If you omit the processname parameter or if it is all blanks, the system creates a process identification in timestamp format, and CREATEPROCESS returns this in its processid parameter if present.
DELETEASSIGN Routine Utility Routines You cannot delete the message portion value associated with LOGICALNAME. '*ALL*' specifies that FORTRAN delete the entire ASSIGN message. cplist is a checkpoint list in which DELETEASSIGN records the changes to the message storage data space. DELETEASSIGN uses a maximum of three elements in cplist. For additional detail, see the Checkpoint Considerations for Saved Message Utility Routines on page 15-28.
DELETEPARAM Routine Utility Routines DELETEPARAM Routine The DELETEPARAM routine deletes specific parts of or an entire PARAM message. ′ *ALL*′ result = DELETEPARAM , cplist portion result is an integer variable in which DELETEPARAM returns the result of the operation. See Considerations. portion is a character expression that identifies the particular part of the message to delete. The string value must be a legal parameter name defined for the PARAM message.
DELETESTARTUP Routine Utility Routines Example ?GUARDIAN DELETEPARAM INTEGER error error = DELETEPARAM ('*ALL*', 0) DELETESTARTUP Routine The DELETESTARTUP routine deletes an entire startup message. result = DELETESTARTUP ( '*ALL*' , cplist ) result is an integer variable in which DELETESTARTUP returns the result of the operation. See Considerations. '*ALL*' specifies that the entire startup message is to be deleted.
GETASSIGNTEXT Routine Utility Routines GETASSIGNTEXT Routine The GETASSIGNTEXT routine retrieves a specified part of an ASSIGN message as text and assigns it to a string variable. The assignment is done according to the FORTRAN rules for a CHARACTER variable assignment. result = GETASSIGNTEXT ( portion, text, messagenumber ) result is an integer variable in which GETASSIGNTEXT returns the result of the operation. See Considerations on page 15-40.
GETASSIGNVALUE Routine Utility Routines Considerations • Values returned by GETASSIGNTEXT Return Value Meaning ≥0 A non-negative value (zero or a positive integer) indicates a string of that many characters, before truncation or padding, is returned to text. GETASSIGNTEXT returns zero if the file name is all blanks and you request TANDEMNAME. -1 Indicates a failure due to a logic error. Nothing is returned in text. Possible logic errors are: • • • • messagenumber is not a positive integer.
GETBACKUPCPU Routine Utility Routines 'LOGICALNAME' and 'TANDEMNAME' are not acceptable portion values for GETASSIGNVALUE. val is the integer variable into which the retrieved value is placed. messagenumber is an integer expression that identifies a specific ASSIGN message from which GETASSIGNVALUE retrieves values. messagenumber must be a positive integer. Considerations Values returned by GETASSIGNVALUE Return Value Meaning 0 The specified portion value is returned to val.
GETPARAMTEXT Routine Utility Routines Example ?GUARDIAN GETBACKUPCPU INTEGER existcpu existcpu = GETBACKCPU () GETPARAMTEXT Routine The GETPARAMTEXT routine obtains a specified part of the PARAM message as text and assigns it to a string variable. The assignment is done according to the FORTRAN rules for a CHARACTER variable assignment. result = GETPARAMTEXT ( portion, text ) result is an integer variable in which GETPARAMTEXT returns the result of the operation. See Considerations.
GETSTARTUPTEXT Routine Utility Routines • PARAM message length The maximum size of the PARAM message is 1028 bytes, but a character variable in FORTRAN cannot have more than 255 characters.
GETSTARTUPTEXT Routine Utility Routines text is a character variable or RECORD into which the retrieved message text is placed. See Considerations. Considerations • Values returned by GETSTARTUPTEXT Return Value Meaning ≥0 A non-negative value (zero or positive integer) indicates a string of that many characters, before truncation or padding, is returned to text. For IN or OUT, if the file name is all blanks, a zero is returned. For STRING, if the value is a null string, a zero is returned.
PUTASSIGNTEXT Routine Utility Routines PUTASSIGNTEXT Routine The PUTASSIGNTEXT routine creates or replaces a specified text part of an ASSIGN message with text obtained from a string variable. result = PUTASSIGNTEXT( portion, text, cplist, messagenumber) result is an integer variable in which PUTASSIGNTEXT returns the result of the operation. See Considerations. portion is a character expression with a value of 'LOGICALNAME' or 'TANDEMNAME' that identifies the particular part of the message to replace.
PUTASSIGNTEXT Routine Utility Routines The following table shows the meaning of the integer return values: Return Value Meaning ≥0 A string of that many characters is assigned as the new message part value. For TANDEMNAME, PUTASSIGNTEXT returns zero if text is a null string. -1 A failure due to a logic error. The message is unchanged. Possible logic errors are: • • • • • • • • The portion value is not correct or does not identify a defined text part of the ASSIGN message.
PUTASSIGNVALUE Routine Utility Routines Example ?GUARDIAN PUTASSIGNTEXT INTEGER error CHARACTER* 20 new name READ (*,*) new name error = PUTASSIGNTEXT ('TANDEMNAME', new name, 0, 10) PUTASSIGNVALUE Routine The PUTASSIGNVALUE routine creates or replaces a specified numeric part of an ASSIGN message with the value obtained from an integer variable. result = PUTASSIGNVALUE( portion, value, cplist, messagenumber ) result is an integer variable in which PUTASSIGNVALUE returns the result of the operation.
PUTPARAMTEXT Routine Utility Routines Considerations Results returned by PUTASSIGNVALUE Return Value Meaning 0 value is assigned as the new value of the requested message portion. -1 Indicates a failure due to a logic error. The message is unchanged. Possible logic errors are: • • • • • The portion value is not correct or does not identify a defined integer part of the ASSIGN message. The integer value supplied is not acceptable for the specified part of the ASSIGN message.
PUTPARAMTEXT Routine Utility Routines message. The first unused character position of portion, if any, must be a blank. Any characters including and following a blank are ignored. text is a character variable or RECORD containing the replacement text for the PARAM message. cplist is a checkpoint list in which PUTPARAMTEXT records the changes to the message storage data space. PUTPARAMTEXT uses a maximum of six elements in cplist.
PUTSTARTUPTEXT Routine Utility Routines Example ?GUARDIAN PUTPARAMTEXT INTEGER error CHARACTER*100 new text, old text READ (9,*) new text error = PUTPARAMTEXT (old text, new text, 0 ) PUTSTARTUPTEXT Routine The PUTSTARTUPTEXT routine creates or replaces a specified part of the startup message with text obtained from a string variable. result = PUTSTARTUPTEXT ( portion , text , cplist ) result is an integer variable in which PUTSTARTUPTEXT returns the result of the operation. See Considerations.
PUTSTARTUPTEXT Routine Utility Routines Considerations • • If the startup message does not exist, PUTSTARTUPTEXT attempts to create one containing the requested text portion and default values for all other message parts. Text values for PUTSTARTUPTEXT If you specify 'VOLUME', text contains the default node, volume, and subvolume names, formatted as: \node.$volume.subvol and contains a maximum of 25 characters. If the volume part does not include the node name component, text is just $volume.subvol.
PUTSTARTUPTEXT Routine Utility Routines The startup message creation is successful if both message space and cplist space are available. The new message contains the message part assigned. All other message parts are set to their default values. The default values for VOLUME, IN, and OUT are taken from those of the current program. The default value for the message parameter string is a null string.
16 Fault-Tolerant Programming Topics covered in this section include: Topic Page Assigning a Process Name 16-2 Processes 16-3 Process Pairs 16-3 Overview of Fault- Tolerant Programs 16-4 Checkpointing 16-6 Starting a New Backup Process 16-12 When you design an application, you must decide which processes in the application need to be fault tolerant. A fault-tolerant process actually consists of two processes: a primary process and a backup process.
Assigning a Process Name Fault-Tolerant Programming even if the primary process fails. You might, however, have to reenter data, reinitialize your environment, and so forth.
Processes Fault-Tolerant Programming Processes A program is a static set of instruction codes and initialized data. It can be represented as source statements, such as a FORTRAN program, or as an object program or a run unit consisting of machine instructions and initialized data. A process is the constantly changing states of a running program. You can run multiple copies of the same program file concurrently. Each execution of the program constitutes a separate process.
Overview of Fault- Tolerant Programs Fault-Tolerant Programming Overview of Fault- Tolerant Programs The following actions occur when you run a fault-tolerant program: • • • • The primary process opens the initial set of files required for its operation. The primary process starts its backup process in another processor by executing a START BACKUP statement. START BACKUP, in addition to starting the backup process, sends the backup checkpoint information for files open in the primary process.
Fault-Tolerant Programming • • • Overview of Fault- Tolerant Programs The START BACKUP statement does not establish a takeover point. You must execute a CHECKPOINT statement that does not specify STACK = 'NO' to establish a takeover point. If the primary process, or the processor in which it runs, fails, the backup process begins executing instructions at the most recent takeover point. (Takeover points are described earlier within this subsection.) The backup process becomes the new primary process.
Checkpointing Fault-Tolerant Programming Figure 16-1. Fault-Tolerant Processing Primary Process Backup Process OPEN files monitor primary STARTBACKUP process takeover by backup READ entry from terminal READ entry from terminal READ record from disk READ record from disk update record in memory update record in memory CHECKPOINT CHECKPOINT WRITE updated record to disk WRITE updated record to disk The backup process monitors the primary process while the primary runs.
Checkpointing File Buffers Fault-Tolerant Programming The location of checkpoint statements in your program depends on the requirements of your application. As a general rule, you include a CHECKPOINT statement just before a WRITE statement to a disk file or to $RECEIVE; a server process might execute a checkpoint statement after reading from $RECEIVE.
Checkpointing File Status Information Fault-Tolerant Programming COMMON request_msg, db_record CHARACTER*132 reply_msg OPEN (UNIT=1,FILE='$RECEIVE') OPEN (UNIT=2,FILE='employee',SYNCDEPTH=5) START BACKUP (BACKUPSTATUS=ierr) ...
Checkpointing File Status Information Fault-Tolerant Programming The preceding code is easier to understand if you consider the following: • • • A process, A, that opens a second process, B, and sends requests to B is, by definition, a requester. A process, C, that receives requests for services from another process, B, is, by definition, a server. A process is often both a requester and a server.
Checkpointing $RECEIVE Fault-Tolerant Programming Managing the Disk File The new server primary might write to the disk up to five records that were already written by the former primary. Because the server specified SYNCDEPTH=5 when it opened the disk file, the disk process saves the replies to up to five write requests since the last stack checkpoint. If the disk process receives a request to which it has already responded, it returns the saved reply and does not do the actual I/O a second time.
Checkpointing Large Amounts of Data Fault-Tolerant Programming For example, the following code shows how you might checkpoint a large array A consisting of 100,000 bytes. A is allocated in extended memory: DIMENSION A(100000) 10 CHECKPOINT (STACK='YES') global-data <-- Establish a takeover pt 15 CONTINUE ...
Starting a New Backup Process Fault-Tolerant Programming Starting a New Backup Process The following list describes the possible actions of the new primary process—formerly the backup process—after a takeover from the former primary process as a result of either a failure or a call to a Guardian routine to stop the process.
A ASCII Character Set Table A-1.
ASCII Character Set Table A-1.
ASCII Character Set Table A-1.
ASCII Character Set Table A-1.
B Syntax Summary This appendix provides a syntax summary for FORTRAN Statements and Compiler Directives on page B-12. FORTRAN Statements This subsection specifies the syntax of all FORTRAN statements. arithmetic – exp r ession name = character – exp ression logical-expression Defines the value of an arithmetic, character, or logical entity. ASSIGN label TO name Assigns the value of a statement label to an integer variable. unit unit , IOSTAT=ios . . .
FORTRAN Statements Syntax Summary CHARACTER [* len] name [ dimension ] [* len] [, name [ dimension ] [* len] ]... dimension is: ( [ lower:] upper [, [ lower:] upper ]... ) Defines a variable, array, symbolic constant, RECORD field, function, or dummy procedure as character type. CHECKPOINT ° ( [ UNIT= ]unit [ , UNIT=unit ]. . . [ , cpt – spec ]. . . ) ( cpt – spec [ , cpt – spec ]. . . ) [ data [, data ]...
FORTRAN Statements Syntax Summary COMMON [ / [ cb ] / ] list [ [,] / [ cb ] / list ]... Defines one or more areas of memory in which program units can share data. COMPLEX name [ dimension ] [, name [ dimension ] ]... dimension is: ( [ lower:] upper [, [ lower:] upper ]... ) Specifies that the symbolic name of a constant, variable, array, RECORD field, function, or dummy procedure is of type complex. CONTINUE The execution of the CONTINUE statement has no effect.
FORTRAN Statements Syntax Summary DOUBLE PRECISION name [ dimension ] [, name [ dimension ] ]... dimension is: ( [ lower:] upper [, [ lower:] upper ]... ) Specifies that the symbolic name of a constant, variable, array, RECORD field, function, or dummy procedure is double precision type. ELSE Identifies the end of a block of statements that was preceded by an IF or ELSE IF statement, and the beginning of a block of statements to execute if all preceding IF and ELSE IF tests were false.
FORTRAN Statements Syntax Summary unit ENDFILE ° ( [ UNIT= ] unit [ , IOSTAT=ios ] [ , ERR=label ] ) Writes an end of file as the next record of the file connected to the specified unit. ENTRY name [ ( [ dummy [, dummy ]... ] ) ] Provides an alternate entry point to a subroutine or function subprogram and allows you to specify an alternate dummy argument list for the subprogram. EQUIVALENCE ( var-list ) [, ( var-list ) ]...
FORTRAN Statements Syntax Summary GO TO label Executes an unconditional transfer of control to the statement labeled label. GO TO ( label [, label ]... ) [,] exp Executes a computed GO TO statement. Transfers control to the label whose position in the list of labels corresponds to the value of exp. GO TO ivar [ [,] ( label [, label ]... ) ] Executes an assigned GO TO statement. Transfers control to the statement whose label was assigned to ivar in a previously executed ASSIGN statement.
FORTRAN Statements Syntax Summary IMPLICIT type ( char-list ) [, type ( char-list ) ]... Specifies the default data type associated with the first character of a variable’s name. [ UNIT= ] unit [, inq-spec ]...
FORTRAN Statements Syntax Summary INTRINSIC function [, function ]... Identifies a name as representing an intrinsic function and enables the use of an intrinsic function name as an actual argument. LOGICAL name [ dimension ] [, name [ dimension ] ]... dimension is: ( [ lower:] upper [, [ lower:] upper ]... ) Defines a variable, array, symbolic constant, RECORD field, function, or dummy procedure as logical type. OPEN ( [UNIT=] unit [, open-spec ]...
FORTRAN Statements Syntax Summary PAUSE [ message ] Temporarily halts program execution and displays message if present. POSITION ( [UNIT=] unit [, IOSTAT = ios ] [, ERR = lbl ], position ) position is a position specifier in one of the following, mutually exclusive forms: REC = recno or KEY = key, KEYLEN = exp, KEYID = kid, MODE = mode [, COMPARELEN = clen ] [, SKIPEXACT = skip ] Enables random access of structured files, either by record number or by specified primary or alternate keys.
FORTRAN Statements Syntax Summary read-spec is one of the following: END = endlbl PROMPTLENGTH = plen ERR = lbl REC = rec [FMT=] format SOURCE = receive IOSTAT = ios TIMEOUT = to LENGTH = len [UNIT=] unit LOCK = lock UPDATE = upd PROMPT = message Inputs data from a specified unit or file. REAL name [ dimension ] [, name [ dimension ] ]... dimension is: ( [ lower:] upper [, [ lower:] upper ]...
FORTRAN Statements Syntax Summary unit IOSTAT=ios unit , . . . ERR=lbl REWIND UNIT=unit UNIT=unit IOSTAT=ios , IOSTAT=ios ERR=lbl ERR=lbl . . . Positions the file connected to the specified unit at its initial point. SAVE [ name [, name ]... ] Saves the status of specified entities after the termination of a subprogram.
Compiler Directives Syntax Summary SUBROUTINE name [ ( dummy [, dummy ]... ) ] Identifies the beginning of a subroutine subprogram. WRITE ( [UNIT=] unit [ [, write-spec ]... ] ) [ output-item [, output-item ]... ] write-spec is one of the following: ERR = lbl REC = recno FMT= format REPLY = reply IOSTAT = ios TIMEOUT = to LENGTH = len UNLOCK = unlock MSGNUM = msgno UPDATE = ipd Outputs data to a specified unit.
Compiler Directives Syntax Summary [NO]BOUNDSCHECK Verifies that the subscripts in each reference to an element of array are within the bounds declared for the array. Default is NOBOUNDSCHECK. [NO]CODE Lists the octal instruction codes generated for each program unit following the source listing for that unit. Default is NOCODE. COLUMNS number Specifies that FORTRAN treat all text beyond the specified column as comments in each source line, beginning with the line that contains this directive.
Compiler Directives Syntax Summary [NO]CROSSREF identifier – class ( identifier – class [ , identifier – class ]. . . ) identifier-class is one of the following: BLOCKS FUNCTIONS PROGLABELS BLOCKDATAS GENERATE STMTFUNCSs CONSTANTS INLINES UNREF DUMMYPROCS LITERALS VARIABLES FMTLABELS PROCEDURES Generates cross-reference information for selected identifier classes. DATAPAGES number Specifies the number of virtual memory pages to allocate for data storage.
Compiler Directives Syntax Summary ERRORFILE number Sets the maximum number of errors for a compilation. Default is ERRORS 100. [NO]EXTENDCOMMON Instructs the compiler to use indexed indirect addressing to access simple variables in common blocks. Default is NOEXTENDCOMMON. [NO]EXTENDEDREF Generates code that uses doubleword addresses for parameters in CALL statements and function references. Default is NOEXTENDEDREF, unless you use the LARGECOMMON directive.
Compiler Directives Syntax Summary HIGHBUFFER size If ENV OLD is in effect, specifies the number of words to allocate for the run-time buffer pool, #HIGHBUF, in upper data memory. If ENV COMMON is in effect, specifies the size of the CRE internal buffer area, #CRE_HEAP. By default, #CRE_HEAP is 1,024 words. block – name HIGHCOMMON ° ( block – name [ , block – name ]. . . ) Allocates common storage in upper data memory for specified common blocks.
Compiler Directives Syntax Summary IF toggle If the specified toggle is set, the IF directive processes the source lines that follow, up to an ENDIF directive that specifies the same toggle number as the IF directive or to the end of the source file. IFNOT toggle If the specified toggle is reset, the IFNOT directive processes the following lines, up to an ENDIF directive that specifies the same toggle number as the IFNOT directive or to the end of the source file.
Compiler Directives Syntax Summary LARGESTACK number Specifies the block size to reserve for dynamically-allocated variables specified in LARGEDATA directives. LIBRARY file-name Establishes a default user library. LINES number Specifies the number of lines the compiler writes to the listing file before issuing a page skip. [NO]LIST Controls listing of source lines; enables the CODE, CROSSREF, ICODE, LMAP, MAP, and PAGE directives. Default is LIST.
Compiler Directives Syntax Summary LOWBUFFER size Controls space allocated for the run-time buffer pool in lower data memory. If you specify ENV COMMON, FORTRAN recognizes the LOWBUFFER directive but does not allocate a #LOWBUFFER. [NO]MAP Lists, following each program unit’s source listing, a table of local identifiers for that program unit. MAP also lists a table of entities in common storage following the last program unit’s listing. Default is MAP.
Compiler Directives Syntax Summary directive PUSH ( directive [ , directive ]. . . ) Saves the current state of a compiler directive in a push-down stack. receive – spec RECEIVE ( receive – spec [ , receive – spec ]. . .
Compiler Directives Syntax Summary [NO]SAVEABEND Specifies whether Inspect should automatically create a save file if the program terminates abnormally at run time. Default is NOSAVEABEND. file – name SEARCH ( file – name [ , file – name ]. . . ) Specifies a list of object files for BINSERV to search at compilation time for unsatisfied external references. SECTION section-name Assigns a name to a section of a source file for use in a SOURCE directive in another program.
Compiler Directives Syntax Summary [NO]SUPPRESS Overrides the effect of the LIST directive. If SUPPRESS is active, the compiler lists only error messages and compilation statistics. Default is NOSUPPRESS. [NO]SYMBOLS Specifies whether to include a symbol table in the object file for use by Inspect. You must specify SYMBOLS to use source-level debugging. Default is NOSYMBOLS. SYNTAX Compiler scans source file for syntax errors but does not produce an object file.
C Converting Programs to HP FORTRAN This appendix contains suggestions to help you convert a FORTRAN application program that was not written for HP FORTRAN to the syntax and semantics of HP FORTRAN. • Comment lines If the source program file has comments extending beyond column 72 of each line, add the directive line ? ANSI at the beginning of the file, so that HP FORTRAN will ignore all but the first 72 characters of each source line.
Converting Programs to HP FORTRAN If you convert a program that uses a combination of CHARACTER and other data types in the same common block, you can declare a RECORD in the common block, and declare all the variables in the common block as components of the RECORD. (HP FORTRAN allows mixing of CHARACTER and other data types within a RECORD, since the entire RECORD feature is an HP extension.
Converting Programs to HP FORTRAN Dynamically allocated local variables do not retain their values between successive invocations of their procedure. This can cause failure of some programs that depend on such retention of local data values.
Converting Programs to HP FORTRAN component name, almost anywhere that you can use a type CHARACTER variable. • Special characters in symbolic names Some FORTRAN implementations allow additional characters such as “$” in symbolic names, as extensions to the ANSI FORTRAN 77 standard. You can usually use an editor to replace all such characters with blanks or an underscore character, to make the program acceptable to HP FORTRAN.
Converting Programs to HP FORTRAN FORTRAN. Use an editor to find all such occurrences and replace them with forms that are acceptable to HP FORTRAN. Some FORTRAN implementations also provide octal and hexadecimal conversions in formatted I/O, again with a variety of syntaxes. HP FORTRAN provides octal and hexadecimal conversions, but the HP-defined syntax might vary from the syntax used in your program.
Converting Programs to HP FORTRAN HP FORTRAN supports the ANSI FORTRAN 77 form but not the obsolete extension. If you encounter such statements in programs you are converting, change them as shown above. • Converting programs that read blocked tapes If a program you are converting reads blocked tapes, you can either cause the tapes to be copied to an unblocked file for use by a HP FORTRAN program, or change the FORTRAN program to do its own unblocking of the tape records.
D Data Type Correspondence and Return Value Sizes The following tables contain the return value size generated by HP language compilers for each data type. Use this information when you need to specify values with the Accelerator ReturnValSize option. These tables are also useful if your programs use data from files created by programs in another language, or your programs pass parameters to programs written in callable languages.
Data Type Correspondence and Return Value Sizes Table D-1. Integer Types, Part 1 (page 2 of 2) 8-Bit Integer 16-Bit Integer 32-Bit Integer SQL CHAR NUMERIC(1)…NUMERI C(4) PIC 9(1) COMP…PIC 9(4) COMP SMALLINT NUMERIC(5)…NUMER IC(9) PIC 9(1) COMP…PIC 9(9) COMP INTEGER TAL STRING UNSIGNED(8) INT UNSIGNED(16) INT(32) Return Value Size (Words) 1 1 2 [1] Unsigned Integer. [2] Index Data Item is a 16-bit integer in COBOL 74 and a 32-bit integer in COBOL85. [3] COBOL85 only.
Data Type Correspondence and Return Value Sizes Table D-3.
Data Type Correspondence and Return Value Sizes Table D-4. Character Types (page 2 of 2) Character Character String Varying Length Character String SQL PIC X CHAR CHAR(n) PIC X(n) ARCHAR(n) TAL STRING STRING array — Return Value Size (Words) 1 1 or 2, depends on declared pointer size 1 or 2, depends on declared pointer size [1] COBOL85 only. Table D-5.
Data Type Correspondence and Return Value Sizes Table D-6.
Data Type Correspondence and Return Value Sizes FORTRAN Reference Manual—528615-001 D- 6
E Compiler Limits This appendix summarizes the limits of the FORTRAN compiler. • Symbolic names can be up to 31 characters long. FORTRAN discards characters beyond the 31st. Therefore, the following two identifiers are the same: abcdefghijklmnopqrstuvwxyz123456 abcdefghijklmnopqrstuvwxyz123457 • Executable programs An executable program must have exactly one main program.
Compiler Limits INTEGER*2 1 word INTEGER*4 2 words INTEGER*8 4 words LOGICAL mode 1 word, or 2 words if LOGICAL*4 REAL 2 words DOUBLE PRECISION 4 words COMPLEX 4 words CHARACTER 1 word, or 2 words if EXTENDEDREF mode, regardless of the number of characters • Data types Character variables, array elements, functions, constants, and expression values can be up to 255 characters in length. The total size of a RECORD, or of each element of a RECORD array, can be up to 32,767 bytes.
Compiler Limits I/O unit numbers must be in the range 1 through 999. You can declare up to 128 different unit numbers in a compilation. Data files can have record lengths up to 32,767 bytes, but for most file types the limit is 4,096 bytes. Consult the ENSCRIBE Programmer’s Guide for details. • Records in source files and listing files can be up to 132 characters long.
Compiler Limits FORTRAN Reference Manual—528615-001 E- 4
F Compile-Time Diagnostic Messages This appendix lists the FORTRAN 77 compiler diagnostic messages that FORTRAN might report in the program listing. The compiler lists a diagnostic message immediately after it detects the condition displayed; however, because an error might be the result of an internal condition or an improper relationship between statements, the message might not appear immediately following the statement that caused the condition.
Compile-Time Diagnostic Messages Error Messages Error Messages A CONSTANT IS EXPECTED HERE Cause. The PARAMETER statement requires a constant on the right of the assignment operator. Recovery. Correct the statement. ADJUSTABLE ARRAY MUST BE DUMMY ** array-name Cause. The upper or lower bound of an array that is not a dummy argument is a variable. Recovery. Change the adjustable dimension specification to a constant, or make the array a dummy argument. ADJUSTABLE LENGTH MUST BE FORMAL ** name Cause.
Compile-Time Diagnostic Messages Error Messages ARRAY HAS MORE THAN 32767 ELEMENTS ** name Cause. The EXTENDEDREF compiler directive is not specified or implied, and the total number of elements in the indicated array is too large to be indexed by an INTEGER*2 value. Recovery. Reduce the array size or use a LARGECOMMON or LARGEDATA compiler directive so that FORTRAN allocates the array in the extended data segment. ARRAY INDEX OUT OF BOUNDS IN DATA STATEMENT ** name Cause.
Compile-Time Diagnostic Messages Error Messages CHARACTER CONSTANT TOO LARGE Cause. A character constant or Hollerith constant exceeds 255 characters in length. Recovery. Shorten the constant. CHARACTER ENTRY MIXED WITH OTHER TYPES Cause. A function subprogram includes one or more ENTRY statements and the function name and the entry names are not all character type or are not all noncharacter types. Recovery. Declare all entries character type or all entries noncharacter types.
Compile-Time Diagnostic Messages Error Messages CODE SPACE OVERFLOW Cause. The program unit requires more than 32,767 words for object code, including executable instructions and read-only data such as constants and FORMAT statements. The compiler stops immediately after issuing this error message. Recovery. Reduce the size of the program unit. COMMON BLOCK SIZE EXCEEDS 65535 BYTES ** block-name Cause. The indicated common block is too large for either half of the user data segment. Recovery.
Compile-Time Diagnostic Messages Error Messages CONTROL EXPRESSION MUST BE LOGICAL Cause. The control expression of a logical IF, block IF, or ELSE IF statement is not type LOGICAL. Recovery. Correct the expression. CONTROL STATEMENT OUT OF ORDER Cause. A block IF statement sequence incorrectly overlaps a DO loop body or another block IF statement sequence. Recovery. Correct the statement sequence. CPU TNS CONFLICTS WITH EXTENDEDREF Cause.
Compile-Time Diagnostic Messages Error Messages DIRECTIVE MUST APPEAR BEFORE FORTRAN STATEMENTS ** dir Cause. The dir compiler directive must precede the first FORTRAN language statement in the compilation. FORTRAN ignores the directive. Recovery. Move the directive. DIRECTIVE MUST APPEAR BETWEEN PROGRAM UNITS ** dir Cause. The dir compiler directive must precede the first FORTRAN language statement in a program unit. FORTRAN ignores the directive. Recovery. Move the directive.
Compile-Time Diagnostic Messages Error Messages DUMMY NAME CONFLICT ** name Cause. This dummy argument name is the same as a procedure name appearing in a FUNCTION, SUBROUTINE, or ENTRY statement in the same program unit. Recovery. Change the dummy argument name. DUPLICATE DUMMY VARIABLE ** name Cause. This symbolic name appears more than once in a dummy argument list in the same FUNCTION, SUBROUTINE, or ENTRY statement. Recovery. Correct the list. DUPLICATE IMPLICIT ENTRY Cause.
Compile-Time Diagnostic Messages Error Messages ERROR IN FORMAT SPECIFICATION Cause. A FORMAT specification contains a syntax error. Recovery. Correct the format specification. ERROR IN NUMERIC CONSTANT Cause. A numeric constant contains a syntax error. Recovery. Correct the constant. ERROR IN RECORD EQUIVALENCE Cause. The program attempts to equivalence RECORDs that are declared in different common blocks. Recovery.
Compile-Time Diagnostic Messages Error Messages EXTENDED DATA ADDRESSES INVALID FOR GUARDIAN CALLS ** variable-or-array-name Cause. You specified a data item with a doubleword address as a pass-by-reference argument to a Guardian procedure that expects a word address.
Compile-Time Diagnostic Messages Error Messages FUNCTION TYPE INCONSISTENT Cause. A function has been defined as one data type and referred to as another. Recovery. Make the definition and references consistent. FUNCTIONS MAY NOT BE EQUIVALENCED ** name Cause. A function name appears in an EQUIVALENCE statement. Possibly it was intended to be an array name, but the array declaration is missing or in error.
Compile-Time Diagnostic Messages Error Messages ILLEGAL ARITHMETIC OPERAND Cause. An operand of some other data type appears in a context that requires an integer, real, double precision, or complex value. Recovery. Correct the expression. ILLEGAL ARITHMETIC OPERATOR Cause. A logical or character operator appears in a context that requires an arithmetic operator. Recovery. Correct the expression. ILLEGAL CHARACTER LENGTH Cause.
Compile-Time Diagnostic Messages Error Messages ILLEGAL COMBINATION OF ATTRIBUTES Cause. The attributes specified for an identifier are incompatible with each other. Recovery. Correct the specifications. ILLEGAL COMBINATION OF SPECIFIERS Cause. The control list of an INQUIRE statement includes both UNIT and FILE specifiers. Or, the control list of a POSITION statement includes a REC specifier and also any of KEY, KEYLEN, KEYID, MODE, COMPARELEN, and SKIPEXACT specifiers. Recovery. Correct the statement.
Compile-Time Diagnostic Messages Error Messages ILLEGAL TYPE CONVERSION Cause. The data type of a constant is not compatible with the data type required and the necessary conversion is not possible. Recovery. Correct the statement. ILLEGAL TYPE MIXING Cause. An expression contains incompatible operands. Recovery. Correct the expression. ILLEGAL USE OF ASSUMED SIZE ARRAY ** array-name Cause.
Compile-Time Diagnostic Messages Error Messages IMPLICIT STATEMENT RETYPES PARAMETER ** name Cause. An IMPLICIT statement would change the data type of a symbolic constant that was previously declared in a PARAMETER statement. Recovery. Declare the symbolic constant’s data type explicitly. IMPROPER EQUIVALENCE IN A RECORD Cause. An EQUIVALENCE statement within a RECORD declaration does not equivalence components at its own level. Recovery. Correct the statement.
Compile-Time Diagnostic Messages Error Messages INSUFFICIENT TEXT FOR HOLLERITH CONSTANT Cause. A Hollerith character string contains fewer characters than were specified. Recovery. Make the statement long enough to have the indicated number of characters following the H. INTEGER OVERFLOW Cause. An integer constant in a compiler directive that requires a value in the range 32768 through +32767 is outside this range. Recovery. Correct the constant. INVALID BOUNDS FOR SUBSTRING Cause.
Compile-Time Diagnostic Messages Error Messages INVALID FORM FOR A FILLER Cause. A FILLER specification contains a syntax error. Recovery. Correct the specification. INVALID FORTRAN CHARACTER Cause. A character was found that is not in the FORTRAN character set. Recovery. Remove or replace the character. INVALID I/O CONTROL ** keyword Cause. The indicated control specifier in an I/O statement contains a syntax error. Recovery. Correct the statement. INVALID IMPLICIT RANGE Cause.
Compile-Time Diagnostic Messages Error Messages INVALID STATEMENT NUMBER ** label Cause. The source statement references a statement label that is more than five digits. Recovery. Correct the source statement. This problem can arise when the source program has line sequence numbers to the right of column 72, which are treated as part of the statement (remember that FORTRAN ignores blanks). In this case, use the ANSI compiler directive so that the compiler scans only columns 1 through 72.
Compile-Time Diagnostic Messages Error Messages INVALID USE OF ASTERISK Cause. An assignment statement or statement function definition begins with a phrase that contains an asterisk such as INTEGER*2. Recovery. Correct the statement. ITEM MAY NOT BE BY VALUE ** keyword Cause. An I/O statement control specifier in which a result is to be stored, is a constant or expression other than a variable or an array element.
Compile-Time Diagnostic Messages Error Messages LOWER DATA SEGMENT OVERFLOW Cause. Run-time objects allocated in the lower half of the user data segment exceed 32,768 words. Recovery. One or more of the following: • • • • • • Use the HIGHCOMMON compiler directive to move some or all the program’s common blocks to the upper half of the user data segment. Use the LOWBUFFER or HIGHBUFFER directives to move some or all the runtime buffer pool to the upper half of the user data segment.
Compile-Time Diagnostic Messages Error Messages MISSING FORMAT ** label Cause. An I/O statement refers to a FORMAT statement label but no FORMAT statement with that label exists in the program unit. Recovery. Supply the missing FORMAT statement. MISSING INDEX FOR ARRAY Cause. An array element reference has too few subscripts. Recovery. Correct the reference. MISSING STATEMENT NUMBER ** label Cause. Reference has been made to a statement label that does not appear in the program unit. Recovery.
Compile-Time Diagnostic Messages Error Messages MUST BE TYPE CHARACTER TO HAVE SIZE Cause. A noncharacter entity specifies a length. Recovery. Remove the length specification or change the data type to CHARACTER. MUST START WITH ALPHABETIC CHARACTER Cause. A statement begins with a nonalphabetic character. Recovery. Correct the statement. NON EXISTENT I/O CONTROL ** keyword Cause. The indicated control specifier in an I/O statement is not one of the keywords known to HP FORTRAN. Recovery.
Compile-Time Diagnostic Messages Error Messages ONLY THE LAST DIMENSION MAY HAVE AN ASTERISK UPPER BOUND ** array-name Cause. The array declarator has an asterisk for the upper bound of one of the array’s dimensions other than the last (rightmost) dimension. Recovery. Correct the array declarator. PARAMETER MISMATCH Cause. A reference to a generic intrinsic function has an argument that is not one of the data types allowed for that generic function. Recovery.
Compile-Time Diagnostic Messages Error Messages PARENTHESIS MISMATCH Cause. The number of left parentheses in this statement is not equal to the number of right parentheses. Recovery. Make the parentheses balance. PRIMARY GLOBAL AREA OVERFLOW Cause. The program has too many common blocks in the user data segment or refers to too many entities in such common blocks. Recovery.
Compile-Time Diagnostic Messages Error Messages RECORD MAY ONLY BE EQUIVALENCED TO A RECORD Cause. An attempt has been made to equivalence a RECORD, defined by RECORD declaration statements, to an entity that is not a RECORD. Recovery. Correct the EQUIVALENCE statement. RECORDS MAY ONLY HAVE ONE DIMENSION Cause. An attempt has been made to declare a RECORD, or an array within a RECORD, with more than one dimension. Recovery. Correct the statement. RUN-TIME CONTROL BLOCK OVERFLOW Cause.
Compile-Time Diagnostic Messages Error Messages STATEMENT FUNCTION NAME NOT UNIQUE Cause. A statement function has the same name as another statement function or a variable. Note that any statement of the form name (anything) = anything is taken as a statement function definition if the name has not been declared as an array. Recovery. Rename the statement function, or correct the statement if the name is a misspelled array name. STATEMENT NOT ALLOWED IN BLOCK DATA Cause.
Compile-Time Diagnostic Messages Error Messages STATEMENT OUT OF ORDER Cause. The FORTRAN rules for statement ordering within a program unit have been violated. For example, a declarative statement or a statement function definition follows an executable statement. Note that any statement of the form name (anything) = anything is taken as a statement function definition if the name has not been declared as an array. Recovery.
Compile-Time Diagnostic Messages Error Messages SUBSCRIPT MUST BE FORMAL OR COMMON ** array-name Cause. A dummy argument array in a subprogram is declared with an upper or lower bound that is a variable but is neither another dummy argument nor an item in a common block. Recovery. Correct the source. SUBSCRIPT MUST BE INTEGER VALUE Cause.
Compile-Time Diagnostic Messages Error Messages SUBSTRING TOO LARGE FOR ITEM Cause. A substring has been specified with a length greater than that of the variable or array element. Recovery. Correct the statement. SYMBOL TABLE LOOKUP ERROR Cause. Compiler error. Recovery. Notify the GCSC. SYNTAX ERROR Cause. A source statement is syntactically incorrect. Recovery. Correct the statement. THERE CAN BE ONLY ONE RECORD PER COMMON BLOCK ** name Cause.
Compile-Time Diagnostic Messages Error Messages TOO MANY COMMON BLOCKS IN THIS PROGRAM UNIT Cause. This program unit declares more than 64 different common blocks. Recovery. Eliminate declarations of unused common blocks; combine common blocks that cannot be eliminated. TOO MANY CONCATENATED OPERANDS Cause. A character expression exceeds the HP FORTRAN limit of 64 concatenated operands. Recovery. Concatenate in two steps, or simplify the expression. TOO MANY CONTINUATION LINES Cause.
Compile-Time Diagnostic Messages Error Messages TOO MANY I/O UNIT NUMBERS Cause. The total number of different I/O unit numbers specified in the compilation exceeds the limit of 128, including units 4, 5, and 6 which are always defined. Recovery. Reduce the number of I/O unit numbers that appear in UNIT compiler directives and as constant unit numbers in I/O statements throughout the source program. TOO MANY PARAMETERS Cause. A subprogram has more than 29 arguments. Recovery.
Compile-Time Diagnostic Messages Error Messages TYPE COMPLEX VALUES CAN ONLY BE COMPARED FOR (IN)EQUALITY Cause. An expression uses one of the comparison operators .LT., .LE., .GE., or .GT. to compare two values, one or both of which is of the complex data type. Only .EQ. and .NE. can be used for comparing such values. Recovery. Correct the source program. TYPE MISMATCH IN DATA STATEMENT ** name Cause.
Compile-Time Diagnostic Messages Error Messages UPPER BOUND LESS THAN LOWER BOUND Cause. The upper bound of an array is less than its lower bound. Recovery. Correct the array declaration. UPPER DATA SEGMENT OVERFLOW Cause. Run-time objects allocated to the upper half of the user data segment have a total size exceeding 32,768 words of memory space. Recovery.
Compile-Time Diagnostic Messages Warning Messages WRONG I/O CONTROL FOR THIS STATEMENT Cause. A control specifier is not defined for the I/O statement in which it appears (for example, FMT in an OPEN statement). Recovery. Correct the statement. Warning Messages BACKSLASHES SUPERFLUOUS WITH GUARDIAN DIRECTIVE Cause. You used backslashes around a pass-by-value argument in a call to a procedure that was declared in a GUARDIAN directive. Recovery. Remove the backslashes.
Compile-Time Diagnostic Messages Warning Messages COMMON BLOCK ALREADY ALLOCATED DIFFERENTLY ** block-name Cause. You named a common block on either a HIGHCOMMON or a LARGECOMMON directive, but FORTRAN has established a different allocation for that common block when it was declared in a previous program unit in the same compilation. Recovery. Either remove the indicated common block name from the directive, or move the directive nearer to the beginning of the source input file.
Compile-Time Diagnostic Messages Warning Messages EARLIER DIRECTIVE OVERRIDES ** name Cause. A compiler directive tries to re-specify something that has already been specified by another directive that was processed earlier. The compiler ignores the current directive. Recovery. Remove the ignored directive. ERRORFILE DIRECTIVE IGNORED ** reason Cause. The ERRORFILE compiler directive specifies a file name that could not be used for this purpose, for the reason indicated.
Compile-Time Diagnostic Messages Warning Messages INCONSISTENT COMMON ALLOCATION ** block-name Cause. You named the same common block on both a HIGHCOMMON and a LARGECOMMON directive. FORTRAN allocates storage for the common block based on the first directive that named that block. Recovery. Remove the common block name from one of the two directives. INITIAL STACK MARKER AT OR NEAR OVERFLOW Cause.
Compile-Time Diagnostic Messages Warning Messages NONSTOP DIRECTIVE IGNORED UNLESS ENV=COMMON IS SPECIFIED Cause. The NONSTOP directive is only valid if ENV COMMON has been specified. Programs that specify ENV OLD are always compiled for NonStop execution if any program unit contains a CHECKPOINT or START BACKUP statement. Recovery. Add the ENV COMMON directive or remove the NONSTOP directive, as appropriate. PARAMETER MISMATCH ** number Cause.
Compile-Time Diagnostic Messages Warning Messages PROCEDURE IS NOT A GUARDIAN ROUTINE ** proc-name Cause. You used a GUARDIAN directive that named a procedure which is not a Guardian procedure, a Saved Message Utility procedure, or a FORTRAN utility routine. FORTRAN generates the normal FORTRAN calling sequence for calls to the named procedure. Recovery. Correct the procedure name or remove it from the GUARDIAN directive. PROCEDURE NOT FOUND ** proc-name Cause.
Compile-Time Diagnostic Messages Warning Messages SECTION NOT FOUND ** section-name Cause. A section name mentioned in a SOURCE directive was not found in the source file. Recovery. Check the source; check the spelling of section name. SOURCE LINE TRUNCATED Cause. A source line exceeded 132 characters in length. Characters beyond the 132nd are ignored. Recovery. Correct the source. SPECIFIED NUMBER OF DATA PAGES MAY BE INSUFFICIENT Cause.
Compile-Time Diagnostic Messages Warning Messages VALUE OUT OF RANGE Cause. A value in a compiler directive is too great or too small. The directive is ignored. Recovery. Correct the source.
Compile-Time Diagnostic Messages FORTRAN Reference Manual—528615-001 F- 42 Warning Messages
G Run-Time Diagnostic Messages FORTRAN displays run-time diagnostic messages for the following types of errors: • • • I/O errors Intrinsic function errors Common run-time environment messages Topics covered in this section include: Topic Page I/O Errors G-1 START BACKUP and CHECKPOINT Errors G-2 Intrinsic Errors G-3 Error Messages G-3 Diagnostic Messages With ENV OLD G-3 Diagnostic Messages With ENV COMMON G-6 The first part of this appendix describes the features of FORTRAN statements and
Run-Time Diagnostic Messages START BACKUP and CHECKPOINT Errors can determine if an error occurred and, if so, its error number, by analyzing the value in ios. If you specify label but not ios, your program continues executing with the statement labeled label. Although your program can detect that an error occurred— by the fact that it is now executing at a specified label—you cannot determine the specific error that occurred.
Intrinsic Errors Run-Time Diagnostic Messages Intrinsic Errors The following intrinsic functions can cause run-time errors: • • • • • • ACOS, DACOS, ASIN, and DASIN: argument value is less than -1.0 or greater than 1.0. ALOG, DLOG, ALOG10, DLOG10: argument less than or equal to zero. \ ATAN2 and DATAN2: both arguments are zero. CLOG: argument value is CMPLX (0, 0). SQRT and DSQRT: argument value is less than zero.
System Error Message Format Run-Time Diagnostic Messages p-addr is the program location, in octal, where the error was detected, as shown by the instruction address in the P-register. space is the two-letter code space identifier as follows: UC User code SC System code UL User library SL System library segment is the segment number, in octal, within space. uuu is the number of the unit specified in the READ or WRITE statement.
System Error Message Format Run-Time Diagnostic Messages operation is one of: BACKSPACE ENDFILE OPEN REWIND CHECKPOINT FORTRANSPOOLSTART POSITION STARTBACKUP CLOSE INQUIRE space is the two-letter code space identification as follows: UC User code SC System code UL User library SL System library seg is the segment number, in octal, within space. p-addr is the program location, in octal, where the error was detected, as shown by the instruction address in the P-register.
Intrinsic Error Message Format Run-Time Diagnostic Messages errno is a 5-digit number that identifies the error condition. Intrinsic Error Message Format The FORTRAN run-time-library unconditionally terminates your program and writes an error message to the log file in the following format if an intrinsic function detects an error. Run-time intrinsic function diagnostic messages have the general form: FORTRAN LIBRARY CALL ERROR: name name is the name of the intrinsic function that detected the error.
Message Format Run-Time Diagnostic Messages additional_information if present, gives more detail about message. For example, if an error occurs while accessing a file, additional_information might be the file-system error number. optional_text if present, provides additional information about the error. For example, it might show the FORTRAN unit number. optional_text helps you identify the cause of the error.
Formatter Run-Time Messages Run-Time Diagnostic Messages • If your FORTRAN program cannot create a new file, FORTRAN writes a message such as the following to the standard log file. Note that the message includes an informational line that shows the unit associated with the file and the external Guardian file name: \NODE.$TEST:8403781 - *** Run-time Error 082 *** \NODE.$TEST:8403781 - GUARDIAN I/O error 14 \NODE.$TEST:8403781 - Unit 008 = $FOO.A.B \NODE.$TEST:8403781 - From SUB2 + %111, UC.00 \NODE.
Formatter Run-Time Messages Run-Time Diagnostic Messages 256 Unknown unit value nnn Cause. A routine referenced a unit that was not specified in a UNIT compiler directive or as a constant expression in the unit specifier of an I/O statement. Effect. If the program executed an I/O statement that includes an ERR clause or an IOSTAT clause, the program retains control. Otherwise, the run-time library terminates your program. Recovery.
Formatter Run-Time Messages Run-Time Diagnostic Messages 259 OPEN for unit open with inconsistent attribute values Cause. The attributes specified in an OPEN statement that referenced an alreadyopen file were incompatible with the attributes in effect from the file’s original open. If a routine opens a file connection for an already-open file, the attributes of the second (and subsequent) opens must be the same as those of the original open except for the BLANK parameter, which can be different. Effect.
Formatter Run-Time Messages Run-Time Diagnostic Messages 267 Buffer overflow for unit nnn Cause. A routine tried to transfer a record that is larger than the maximum record length specified for the unit. The maximum record length is established at the time a unit is connected to a file. For more details, see the OPEN Statement on page 7-70. Effect. If the program executed an I/O statement that includes an ERR clause or an IOSTAT clause, the program retains control.
Formatter Run-Time Messages Run-Time Diagnostic Messages Effect. If the program executed an I/O statement that includes an ERR clause or an IOSTAT clause, the program retains control. Otherwise, the run-time library terminates the program. Recovery. Modify your FORMAT statement to specify the correct type for each data item specified in the WRITE statement. 272 Illegal input character for unit nnn Cause. A numeric field contains a character other than 0 through 9, a decimal point, a comma, or a blank.
Formatter Run-Time Messages Run-Time Diagnostic Messages Formatter Messages With ENV OLD FORTRAN displays the following diagnostic messages if a run-time error occurs and you specify ENV OLD when you compile your program. See the preceding subsection for cause, effect, and recovery information.
System Messages Run-Time Diagnostic Messages 271 EDIT ITEM MISMATCH 278 ILLEGAL INPUT CHARACTER 273 ILLEGAL FORMAT 274 NUMERIC OVERFLOW System Messages The FORTRAN run-time library displays the messages in this and the following subsections if an error occurs while executing a statement or intrinsic routine. The error might be detected by the operating system, by routines in the FORTRAN run-time environment, or by routines in common run-time environment.
Trap Messages Run-Time Diagnostic Messages System errors can occur in programs that specify ENV COMMON on the following statements and utility routines: BACKSPACE FORTRAN_SETMODE_ READ CHECKPOINT FORTRAN_SPOOL_OPEN_ REWIND CLOSE INQUIRE START BACKUP ENDFILE OPEN WRITE FORTRAN_CONTROL_ POSITION Trap Messages The run-time library reports the messages in this subsection if a trap occurs. The runtime library terminates your program.
Trap Messages Run-Time Diagnostic Messages 4 Arithmetic fault The overflow bit in the environment-register, ENV.<10>, was set to 1 for one of the following reasons: • • The result of a signed arithmetic operation could not be represented with the number of bits available for the particular data type. An division operation was attempted with a zero divisor.
Run-Time Core Messages Run-Time Diagnostic Messages 8 Not enough physical memory This fault occurs for one of the following reasons: • A page fault occurred, but there were no physical memory pages available for overlay. • Disk space could not be allocated while the program is using extensible segments. 9 Uncorrectable memory error An uncorrectable memory error occurred.
Run-Time Core Messages Run-Time Diagnostic Messages Recovery. The program might have written data in the upper 32K words of the user data segment. The upper 32K words are reserved for run-time library data. Check the program’s logic. Use Inspect to help isolate the problem or consult your system administrator. 13 MCB pointer corrupt Cause. The pointer at location G[0] of the program’s user data segment to its primary data structure—the Master Control Block (MCB)—does not point to the MCB. Effect.
Run-Time Core Messages Run-Time Diagnostic Messages 16 Checkpoint list exhausted Cause. The run-time did not have enough room to store all the checkpoint information required by the program. Effect. Program behavior is language and application dependent. Recovery. Increase the checkpoint list object’s size. For the routine that allocates your checkpoint list, see the language manual. 17 Cannot obtain control space Cause. The run-time library could not obtain heap space for all of its data. Effect.
Run-Time Core Messages Run-Time Diagnostic Messages 21 Cannot read initialization messages ( error ) Cause. During program initialization, the run-time could not read all the messages (start-up message, PARAM message, ASSIGN messages, and so forth) it expected from the file system. error is the file system error number the run-time received when it couldn’t read an initialization message. Effect. The run-time terminates the program. Recovery. Consult your system administrator.
Run-Time Core Messages Run-Time Diagnostic Messages The first ASSIGN specifies that the logical name A can appear in no more than one program file. The second assign specifies that the name A can appear in an arbitrary number of program files. The run-time cannot determine whether to use the file C.D on volume $B1 or on volume $B2. Effect. The run-time terminates the program. Recovery. Correct the ASSIGNs in your TACL environment. For more information on using ASSIGNs, see the TACL Reference Manual.
Intrinsic Error Messages Run-Time Diagnostic Messages 27 Ambiguity in application of PARAM PARAM name ' value' Cause. A PARAM specifies a value that is ambiguous in the current context. For example, the PARAM specification: PARAM PRINTER-CONTROL A is ambiguous if the program contains more than one logical file named A. Effect. The run-time terminates the program. Recovery. Correct the PARAM in your TACL environment. For more information on using PARAMs, see the TACL Reference Manual.
Intrinsic Error Messages Run-Time Diagnostic Messages Effect. Program behavior is language and application dependent. Recovery. Correct the parameter you are passing. 41 Range fault Cause. An arithmetic overflow or underflow occurred while evaluating an arithmetic function. Effect. Program behavior is language and application dependent. Recovery. Modify the program to pass values to the arithmetic functions that do not cause overflow. 42 Arccos domain fault Cause.
Intrinsic Error Messages Run-Time Diagnostic Messages 46 Logarithm function domain fault Cause. The parameter passed to a logarithm function was less than or equal to zero. The parameter to a logarithm function must be greater than zero. Effect. Program behavior is language and application dependent. Recovery. Modify the program to pass a valid value to the logarithm function. 47 Modulo function domain fault Cause. The value of the second parameter to a modulo function was zero.
Input/Output Messages Run-Time Diagnostic Messages Recovery. Modify the program to pass a nonnegative value to the square root function. 55 Missing or invalid parameter Cause. A required parameter is missing or too many parameters were passed. Effect. Program behavior depends on the function that was called and the language in which it is written. Recovery. Correct the program to pass a valid parameter. 56 Invalid parameter value Cause. The value passed as a procedure parameter was invalid. Effect.
Input/Output Messages Run-Time Diagnostic Messages 59 Standard input file error ( error ) Cause. The file system reported an error when a routine tried to access the standard input file. error is a file-system error code. Effect. The run-time can report this error when it closes your input file. All other instances are language and application dependent. Recovery. If the error was caused by a read request from your program, correct your program.
Input/Output Messages Run-Time Diagnostic Messages 62 Invalid GUARDIAN file number Cause. A value that is expected to be a Guardian file number is not the number of an open file. Effect. Program behavior is language and application dependent. Recovery. Consult your system administrator. 63 Undefined shared file Cause. A parameter was not the number of a shared file where one was expected. Effect. Program behavior is language and application dependent. Recovery. Consult your system administrator.
Input/Output Messages Run-Time Diagnostic Messages 67 Access mode not accepted Cause. The value of the access parameter to an open operation was not valid in the context in which it was used. For example, it is invalid to open a spool file for input. Effect. Program behavior is language and application dependent. Recovery. Consult your system administrator. 68 Nowait value not accepted Cause. The value of the no_wait parameter to an open operation was not valid in the context in which it was used.
Input/Output Messages Run-Time Diagnostic Messages 71 Inconsistent attribute value Cause. A routine requested a connection to a shared file that was already open, and the attributes of the new open request conflict with the attributes specified when the file was first opened. Effect. Program behavior is language and application dependent. Recovery. If your program supplied the attribute values, correct and rerun your program. Otherwise, consult your system administrator.
Input/Output Messages Run-Time Diagnostic Messages Effect. Program behavior is language and application dependent. For more information, see the Guardian Procedure Calls Reference Manual. Recovery. Recovery is language and application dependent. 78 EDITREAD failed ( error ) Cause. A call to EDITREAD failed. error, if present, gives the reason for the failure.
Input/Output Messages Run-Time Diagnostic Messages 81 End of file Cause. A routine detected an end-of-file condition. Effect. Program behavior is language and application dependent. Recovery. Correct your program to allow for an end-of-file condition or ensure that your program can determine when all the data has been read. 82 Guardian I/O error nnn Cause. An operating system routine returned error nnn.
Input/Output Messages Run-Time Diagnostic Messages Effect. If the rejected request was initiated from a FORTRAN I/O statement that includes either an IOSTAT or ERR parameter, control is returned to the FORTRAN routine. Otherwise, the FORTRAN run-time library terminates the program. Recovery. Coordinate how routines in your program use standard output.
H Hollerith Constants and Punch Card Codes Topics covered in this section include: Topic Page Editing Hollerith Data H-2 Hollerith Constants as Subprogram Arguments H-3 Hollerith Punch Card Codes H-3 A Hollerith string defines a constant character string. Hollerith data was widely used to represent character strings prior to FORTRAN 77. The form of a Hollerith constant is: nHstring n is an unsigned, nonzero integer constant that specifies the number of characters in string.
Editing Hollerith Data Hollerith Constants and Punch Card Codes dummy argument. Table H-1 shows the relationship between the data type of a dummy argument and the maximum number of characters in a Hollerith string. Table H-1.
Hollerith Constants and Punch Card Codes Hollerith Constants as Subprogram Arguments Hollerith Constants as Subprogram Arguments You can use a Hollerith constant as an actual argument in a subprogram reference. The corresponding dummy argument must be of type integer, real, or logical: SUBROUTINE example(cost,date) INTEGER*8 date . END PROGRAM Main CALL example(price,8H4-21-85 ) .
Hollerith Constants and Punch Card Codes Hollerith Punch Card Codes Table H-2.
Hollerith Constants and Punch Card Codes Hollerith Punch Card Codes Table H-2.
Hollerith Constants and Punch Card Codes Hollerith Punch Card Codes Table H-2.
Glossary ASSIGN. An HP Tandem Advanced Command Language (TACL) command you can use to associate a file name with a logical file of a program or to assign a physical device to logical entities that an application uses. BIND. A program invoked during system generation that creates TNS object (file code 100) system code files and system library files. binding.
CRE. Glossary and to the same open of that file. The CRE manages the connection. The CRE provides connection services for shared files. In FORTRAN, a connection is an association between a unit number and a file. CRE. See Common Run-Time Environment (CRE). Crossref. A stand-alone product that collects and prints cross-reference information for your program. C-series system. A system that is running a C-series version of the operating system. data block.
level-1 spooling. Glossary level-1 spooling. A method of spooling files in a HP NonStop environment. With level-1 spooling, a file uses default spooling parameters. The program writes records to a spooler collector by calling standard file system procedures such as WRITE. level-2 spooling. A method of spooling files in a HP NonStop environment.
process. Glossary process. A program that has been submitted to the operating system for execution, or a program that is currently running in the computer. process identification number (PIN). A number that uniquely identifies a process running in a processor. The same number can exist in other processors in the same system. Internally, a PIN is used as an index into the process control block (PCB) table. program file. An executable object file. It must contain an entry point with the MAIN attribute.
system. Glossary system. All the processors, controllers, firmware, peripheral devices, software, and related components that are directly connected together to form an entity that is managed by one HP NonStop™ Kernel operating system image and operated as one computer. system name. A C-series term that identifies a system on a network. A system name always begins with a backslash character. A system name in a C-series system serves the same purpose as a node name in a D-series system. system procedure.
user library.
Index A A edit descriptor 7-51 ABS function 8-4 Absolute value 8-4 access methods for HP-defined files 5-6 Accessing external files 5-3, 5-6 ACOS function 8-5 AIMAG function 8-6 AINT function 8-6 Allocating memory in extended memory 12-2 in upper memory 12-2, 12-5 local variables C-2 ALOG function 8-21 ALOG10 8-22 ALOG10 function 8-22 Alphanumeric editing 7-51 Alternate keys file access 5-22 Alternate RETURN 7-95 ALTERPARAMTEXT routine 15-29 AMAX0 function 8-23 AMAX04 function 8-23 AMAX08 function 8-23 AMAX
B Index Assign data values at compile time 7-24 ASSIGN message changing 15-45, 15-47 creating 15-45, 15-47 deleting 15-35 description 15-27 finding greatest message number 15-32 message serial number 15-31 retrieving 15-40, 15-41 ASSIGN statement 7-9, E-1 Assigned GO TO 7-56 Assigning a process name 16-2 Assigning a unit 5-10, 5-11 Assignment statement 7-7 Assumed-size arrays 4-12 ATAN function 8-8 ATAN2 function 8-9 B B edit descriptor 7-46 BACKSPACE statement and shared files 7-11 description 7-10 Back
C Index COBOLEXT files 13-22 Code address in listing file 9-15 area in memory 12-1 blocks 9-21 CODE option 9-12, 9-14 COLUMNS directive 2-2 Comments 2-4, C-1 Common blocks blank common, name 13-6 description 4-14 indexed addressing 12-10 initializing variables C-4 name in object files 13-6 total for a program E-2 with non-RECORD variables and arrays E-2 with RECORDs E-2 COMMON statement 4-14, 7-20 Compilation unit 9-21 Compiler diagnostic messages error, text of F-1/F-34 format of F-1 warning, text of F-3
D Index Compiling a program (continued) RUN command 9-2 SEARCH directive 9-21 statistics 9-19 SYMSERV 9-1 temporary files 9-6 warning messages 9-12 with extended data space 9-23 with subroutines 9-25 Completion codes from a compilation 9-20 Complex constants 2-11 COMPLEX data type C-3 Complex values 8-10 Computed GO TO 7-55 Conditionally execute a statement 7-59 Confirming variable type 7-63 CONJG function 8-11 Conjugate of complex number 8-11 Connecting a unit 5-13 Constants arithmetic complex 2-13 descr
E Index Data types (continued) mixing different types 1-2 REAL*4 C-3 REAL*8 C-3 storing 2-10 DATAN function 8-8 DATAN2 function 8-9 DBLE function 8-13 DCOS function 8-12 Debugging DEBUG with extended memory 12-13 Debug description 11-8 Decimal point position 7-42 Declaring an array 7-26 array sizes 4-11 intrinsic functions 13-25 DECODE statement C-5 Defining a data structure 7-94 file attributes 5-13 value of an entity 7-7 value of integer variable 7-9 DELETEASSIGN routine 15-35 DELETEPARAM routine 15-37
E Index Edit descriptor (continued) G 7-49 H 7-52 I 7-44 O 7-47 P 7-50 positional editing 7-52 S 7-53 sign control 7-53 SP 7-53 SS 7-53 TLn 7-52 Tn 7-52 TRn 7-52 Z 7-48 ⁄ 7-53 EDIT format files adding lines at the end of file 7-84 and BACKSPACE statement 7-10 and WRITE statement 7-107 buffer allocation 12-8 creating 5-16 deleting lines 7-32 description 5-17 ENDFILE statement 7-31 INQUIRE statement 7-64 OPEN statement 7-70 record number 5-7 REWIND statement 7-97 ELSE IF statement See IF Statement-Block ELS
F Index Error numbers 6-5 Executable statements description 6-1 Executing group of statements 7-60 EXECUTION-LOG PARAM and standard input 11-6 and standard log 11-7 and standard output 11-7 description 11-5 EXP function 8-15 Exponential numbers 8-15 Expressions intrinsic functions 8-1 EXTENDCOMMON directive 12-10 Extended data space binder 9-24 common blocks 12-9 compiling programs with 9-23 LARGECOMMON directive 9-23 local data 12-9 number of segments 12-11 run-time stack 12-11 stack overflow 12-12 using
F Index Fault-tolerant programming (continued) process pair 16-3 START BACKUP 7-100 File buffers EDIT format files 12-8 level-3 spooling 12-8 File sharing description 13-2 See ENV directive File sharing, standard and OPEN statement 7-70 and READ statement 7-88 and WRITE statement 7-107 FILENUM function 8-16 Files access methods 5-6, 5-7 ASSIGN command 5-11 assigning a unit 5-10 attributes 5-3 backing up a record 7-10 canceling automated level-3 spooling 11-4 closing 7-18 defining data 7-100 definition end
F Index FORTRAN (continued) calling sequence 13-7 character set 1-2 character set symbols 2-1 COBOL85 subprograms 13-19 code and data blocks 9-21 command line length 9-4 comments C-1 communication between programs 4-3 compiling a program 9-1, 9-2 compiling in same CPU 9-6 compiling process 9-7 connecting a unit 5-13 converting programs to HP NonStop system C-1 data types 2-7 debug program 11-8 disconnecting a unit 5-9 extended data space 9-23 external files 5-3 file attributes 5-3, 5-13 files 5-16, 5-17,
G Index G I G edit descriptor 7-49 GETASSIGNTEXT routine 15-39 GETASSIGNVALUE routine 15-40 GETBACKUPCPU routine 15-41 GETPARAMTEXT routine 15-42 GETSTARTUPTEXT routine 15-43 Global data 13-6 GO TO statement assigned 7-56 computed 7-56 description 7-55 labels E-1 unconditional 7-56 GUARDIAN directive 15-23 Guardian directive 13-12, 13-13 Guardian procedures arguments 13-14 calling 13-13 calling restrictions 13-14 old calling syntax 13-22 I edit descriptor 7-44 IABS function 8-4 IABS4 function 8-4 IABS8
I Index Input/output messages G-25/G-32 INQUIRE statement 7-64 INSPECT directive 11-8 INSPECT PARAM 11-4, 11-9 Inspect program description 11-8 high-level mode 11-10 low-level mode 11-10 using 11-10 with extended memory 12-11 INT function 8-19 INT4 function 8-19 INT8 function 8-19 Integer constants 2-11 INT function 8-19 NINT function 8-26 INTEGER directive C-1 INTEGER statement 7-4 Interactive Binder 9-25 Interactive debugger 11-8 Internal files description 5-3 Intrinsic functions ABS 8-4 ACOS 8-5 AIMAG
K Index Intrinsic functions (continued) IABS8 8-4 ICHAR 8-17 ICHAR4 8-17 ICHAR8 8-17 IDINT 8-19 IDINT4 8-19 IDINT8 8-19 IDNINT 8-26 IDNINT4 8-26 IDNINT8 8-26 IFIX 8-19 IFIX4 8-19 IFIX8 8-19 INDEX4 8-18 INDEX8 8-18 INT 8-19 INT4 8-19 ISIGN 8-27 ISIGN4 8-27 ISIGN8 8-27 LEN 8-20 LEN4 8-20 LEN8 8-20 LOG 8-21 LOG10 8-22 MAX 8-23 MAX04 8-23 MAX08 8-23 MAX1 8-23 MAX14 8-23 MAX18 8-23 MIN 8-24 MIN0 8-24 MIN04 8-24 MIN08 8-24 MIN1 8-24 MIN14 8-24 MIN18 8-24 Intrinsic functions (continued) MOD 8-25 MOD4 8-25 MOD8
L Index Language statements (continued) assignment 7-7 BACKSPACE 7-10 BLOCK DATA 7-12 CALL 7-13 CHECKPOINT 7-15 CLOSE 7-18 COMMON 7-20 CONTINUE 7-23 DATA 7-24, 12-10 DIMENSION 7-26 DO 7-27 ELSE See IF Statement— Block ELSE IF See IF Statement—Block 7-30 END 7-30 END IF See IF Statement—Block ENDFILE 7-31 ENTRY 7-33 EQUIVALENCE 7-36 executable 6-1 EXTERNAL 7-38 FORMAT description 7-39 edit descriptors 7-40 numeric data 7-43 FUNCTION 7-54 GO TO 7-55 IF 7-58 IF, block 7-60 IF, logical 7-59 IMPLICIT 7-63 INQU
M Index Listing file (continued) compile statistics 9-19 CROSSREF option 9-17 defining line length 9-6 error messages 9-12 ICODE option 9-12, 9-15 interpreting 9-8 LMAP option 9-17 MAP option 9-12, 9-13 NOLIST option 9-12 options 9-8 page heading 9-9 source program 9-10 SUPPRESS directive 9-12 to tape or disk 9-4 warning messages 9-12 List-directed input 5-29 output 5-30 LMAP option 9-17 Local data dynamically allocated 12-11 statically allocated 12-11 Log file and the EXECUTION-LOG PARAM 11-7 LOG functio
N Index Messages, compile-time error, text of F-1/F-34 format of F-1 warning, text of F-34/F-41 MIN function 8-24 MIN0 function 8-24 MIN04 function 8-24 MIN08 function 8-24 MIN1 function 8-24 MIN14 function 8-24 MIN18 function 8-24 Mixed data types C-1 MOD function 8-25 MOD4 function 8-25 MOD8 function 8-25 Move to preceding record 7-10 Multiple entry points for functions 4-10 for subroutines 4-10 N NAMELIST I/O C-5 Names a constant 7-79 a program unit 7-88 an intrinsic function 7-69 files 5-5, 5-6 Namin
R Index PARAM NONSTOP command 11-4, 11-11 PARAM OUTWIDTH command 9-5 PARAM SAMECPU command 9-5 PARAM SPOOLOUT command 11-4 PARAM SWAPVOL command 9-5 PARAM SWITCH-nn command 11-4, 11-11 PARAMETER statement 7-79 Pascal called from FORTRAN programs 13-21 calling FORTRAN subprograms 13-25 procedure interface 13-1 Passing arguments between programs 4-3 Passing information to PROCESS_STOP_ 15-5 Passing information to STOP or ABEND 15-2 Physical end of program 7-30 POSITION statement description 7-81 Positional
S Index RECORD declarations (continued) format 2-20 referring to 2-22 storing 2-23 RECORD fields referring to 2-22 Record length data files E-3 segmented records C-4 specifying 5-8 RECORD statement 7-94 Record types end-of-file 5-2 formatted 5-2, 5-6 unformatted 5-2, 5-6 Records vs.
S Index Saved Message Utility (continued) routines (continued) PUTASSIGNVALUE 15-47 PUTPARAMTEXT 15-48 PUTSTARTUPTEXT 15-50 saving messages 15-24 storage area in memory 12-8 Saving data from a subprogram 12-9 Saving process messages 15-23 SEARCH directive 9-21, 13-4 Sequential file access 5-6 Share data between programs 7-20 Sharing files 13-2 Sharing standard files and OPEN statement 7-70 and READ statement 7-88 and WRITE statement 7-107 Sharing storage space 7-36 Sign control for numbers 7-53 SIGN funct
T Index STOP statement and ENV directive 7-105 description 7-105 Stopping a program 7-105, 15-2, 15-5 Storage of a RECORD 2-23 Storing arrays 2-17 String variables adjustable dimensions 4-11 Structured files creating 5-18 description 5-18 entry-sequenced 5-19 key-sequenced 5-21 relative 5-20 using alternate keys 5-22 Subprograms alternate entry point 7-33 beginning 7-54 description 4-1 saving values 7-99 stopping 7-95 SUBROUTINE statement 7-106 Subroutines changing return point 4-8 description 4-1, 4-7 mu
U Index U V Unconditional GO TO 7-56 Unformatted records 5-2, 5-6 Unit and BACKSPACE statement 7-10 and ENDFILE statement 7-31 and OPEN statement 7-70 and POSITION statement 7-81 and READ statement 7-88 and REWIND statement 7-97 and WRITE statement 7-107 sharing access to 13-2 UNIT directive 5-8, C-1 Units ASSIGN command 5-11 assigning 5-10 connecting 5-13 description 5-8 disconnecting 5-9 maximum amount for I/O E-3 number range for I/O E-3 unit 7-5, 7-6 variables for unit numbers C-1 Unresolved referen
Special Characters Index $RECEIVE (continued) as separate input/output files 14-8 file 14-3 managing 14-3 message queuing 14-11 READ Statement 14-9 using for interprocess communication 14-5 WRITE statement 14-10 $RECEIVE (continued) & continuing a command line 9-4 * for comment lines 2-3 ? with directive names 2-4 ⁄ as edit descriptor 7-53 FORTRAN Reference Manual—528615-001 Index -21
Special Characters Index FORTRAN Reference Manual—528615-001 Index -22