• Aucun résultat trouvé

CHARACTER SET

Dans le document CRAY® COMPUTER SYSTEMS (Page 61-67)

LANGUAGE ELEMENTS AND STRUCTURE

2.1 ELEMENTS OF THE FORTRAN LANGUAGE

2.1.1 CHARACTER SET

CFT77 recognizes the following character set:

• The 49 characters specified by the ANSI standard: 26 capital letters, 10 digits, the space character, and the following special characters:

=

+ -

* / ( ) , .

$ ,

• The lowercase letters (non-ANSI).

2

• The quotation mark ("), exclamation point (!), underscore (_), and the tab character (ASCII HT). These characters are non-ANSI.

Appendix A shows the ASCII codes for these characters in octal, hexadecimal, and decimal. These values establish an order for the characters, called the collating sequence. In this sequence, digits precede letters, and capitals precede lowercase. An alphanumeric character is any letter or digit.

In a CFT77 program, a capital letter and the corresponding lowercase letter are considered to be the same except within character or Hollerith constants. Output listings show source programs as they are received, leaving case intact. Error messages use mixed case. Other listings, such as cross reference lists, use only uppercase, except within character or Hollerith constants, where no case conversion occurs.

The ANSI Fortran Standard does not include lowercase letters, double quotation-mark, underscore, exclamation point, or tab.

The ANSI Fortran Standard does not specify a collating sequence except among capital letters (A through Z) and digits (0 through 9).

2.1.2 SYNTACTIC ITEMS

Syntactic items are sequences of characters recognized by the CFT77 compiler and used to form statements. Except within character and

Hollerith constants, blanks are ignored. Syntactic items are as follows:

Constant: an unvarying value. See section 4 concerning constants, variables, and arrays.

Symbolic name: the name of an entity that can be any of several possible kinds (see 2.1.5).

Statement label: one to five digits, at least one nonzero.

Leading zeros are ignored. For example, 22, 022, and 2 2 are equivalent.

Keyword: a sequence of letters having special significance in Fortran statements, such as INTEGER, WRITE, and GOTO. The context in which a character sequence appears affects how i t is

interpreted; for example, in GOTO 1, GOTO is a keyword; in GOTO=3.2, GOTO is a symbolic name.

Operator: one or two special characters or a combination of

special characters and letters, used to specify an operation. See section 5.

Special character: characters used as operators; commas in lists;

and parentheses to establish precedence in expressions. See section 5.

A list is a sequence of one or more syntactic items separated, if more than one, by commas. The syntactic items appearing in a list are called

list items.

2.1.3 LINES

A line can contain up to 96 columns. Columns 73 through 96 are ignored by CFT77. A Fortran program is expressed as an ordered sequence of the following types of lines:

I

Initial

Continuation

Terminal

Comment

Compiler directive

The ANSI Fortran Standard limits line length to 72 characters.

2.1.3.1 Initial and terminal lines

An initial line contains all of, or the first part of, a single Fortran statement in columns 7 through 72. Columns 1 through 5 can include a statement label of one to five digits or blanks; the label is not part of the statement. An initial line has neither the letter C nor an asterisk in column 1, and must have either the digit 0 or a blank character in column 6.

A terminal line, not to be confused with a DO-loop's terminal statement, is an initial line containing only the END statement (see 6.5.2).

2.1.3.2 Continuation lines

A continuation line extends an initial line for expressing a single

Fortran statement; up to 19 can be used after an initial line, and comment lines can be interspersed. (The initial line of such a sequence must not be a terminal line.) A continuation line has a character other than 0 or blank in column 6 and contains a portion of a Fortran statement in columns 7 through 72; columns 1 through 5 must be blank.

2.1.3.3 Comment lines and embedded comments

A comment line has the character C, *, or ! in column 1, or only blank -characters in columns 1 through 72. (See compiler directive lines.)

Comment lines are ignored.

An embedded comment is a comment on the same line with a Fortran statement. Comments can be embedded in any statement except a FORMAT statement. When an exclamation point (!) appears outside a character constant, the remainder of the line is treated as a comment. The

exclamation point cannot appear in columns 2 through 5. An exclamation point in column 6 indicates continuation of the previous statement, not continuation of an embedded comment on the previous line.

Example:

10

x=y*z

! . +SUM

Compute the product and add i t to the sum

The exclamation point in column 6 of the second line above causes the line to be a continuation line of statement 10. The other exclamation points denote embedded comments.

The ANSI Fortran Standard does not provide for embedded comments.

2.1.3.4 Compiler directive lines

A compiler directive line is a line having the characters CDIR$ in columns 1 through 5; it can contain one or more compiler directives, provided only one contains an argument list. The C in the first column causes other compilers to treat CFT77 compiler directive lines as comments

(see 1.4).

The ANSI Fortran Standard does not provide for compiler directives.

2.1.4 STATEMENTS

A statement is a sequence of syntactic items specifying an operation to be performed, characteristics of data, or information about the program.

Except in assignment statements and statement functions, the first

syntactic item (following the statement label if any) in a statement is a keyword. A single statement comprises an initial line and up to 19

continuation lines. Blanks are ignored, except those within character or Hollerith constants. A label can precede a statement but is not a part of the statement.

The use of a statement is indicated by its keyword or by its form. A statement can have up to 1,320 characters including blanks. Aside from this limitation, blanks do not affect interpretation.

2.1.4.1 Kinds of statements

Executable statements specify actions and form an execution sequence.

They are the following. (Groupings are informal: not ANSI categories.)

Assignment:

=

(arithmetic, logical, character) ASSIGN (statement label)

Program control:

DO

CALL, RETURN

Conditional block: Block IF (IF THEN), ELSEIF, ELSE, ENDIF IF (arithmetic and logical)

GOTO (unconditional, assigned, computed) CONTINUE, PAUSE, STOP, END

Input/output:

Data transfer: READ, WRITE, PRINT, PUNCH

Sequential file positioning: REWIND, BACKSPACE, ENDFILE File access control: OPEN, CLOSE

INQUIRE

BUFFER IN and BUFFER OUT ENCODE and DECODE

Nonexecutable statements specify characteristics, arrangement, and initial values of data; specify editing information; specify statement functions; classify program units; and specify entry points within subprograms. Nonexecutable statements are not part of the execution sequence; they may be labeled but their labels cannot be used to control the execution sequence. Nonexecutable statements are the following.

(Groupings are informal: not ANSI categories.)

Program unit:

Header: PROGRAM, FUNCTION, SUBROUTINE, BLOCK DATA ENTRY

Specification:

Type declaration: INTEGER, REAL, DOUBLE PRECISION, COMPLEX, LOGICAL, CHARACTER, POINTER

IMPLICIT, IMPLICIT NONE

PARAMETER, DATA, SAVE, EQUIVALENCE COMMON, TASK COMMON, LOCAL COMMON EXTERNAL, INTRINSIC

FORMAT, NAMELIST

Statement function definition statement DIMENSION

INCLUDE

2.1.4.2 Order of statements and lines

The various kinds of statements and lines must appear in a specific order. Table 2-1 illustrates the required order of statements and lines for a program unit. The top-to-bottom order indicates the first-to-Iast

• Vertical lines divide varieties of statements that can be

interspersed. For example, FORMAT statements can be interspersed with PARAMETER, DATA, executable, and statement function definition statements.

• Horizontal lines divide varieties of statements that must not be interspersed. For example, statement function definition

statements must not be interspersed among executable statements.

An END statement must appear in the last line of a program unit and cannot be followed by a comment line intended as a part of that same program unit.

Source statement order within a program unit

Table 2-1. Required Order of Lines and Statements

~ Intermixing of statements is permitted ~

PROGRAM, FUNCTION, SUBROUTINE, or BLOCK DATA statement

IMPLICIT NONE and IMPLICITt

Comment PARAMETER

and statementst

compiler Other specification

directive ENTRY, statements

lines FORMAT, and DATAtt

statements Statement function definition statements

Other executable statements

END statement

t An IMPLICIT statement must precede a PARAMETER statement to affect the typing of constants named in the PARAMETER statement.

tt The ANSI Fortran standard specifies that DATA statements follow all specification statements.

Dans le document CRAY® COMPUTER SYSTEMS (Page 61-67)