Chapter 3. Language Elements and Source Form

Table of Contents
3.1. Cray Fortran Character Set
3.2. Lexical Tokens
3.3. Source Form
3.4. Portable Source Form
3.5. The INCLUDE Line
3.6. Low-level Syntax

This chapter describes the language elements that a Fortran statement can contain. Language elements consist of lexical tokens, which include names, keywords, operators, and statement labels. Rules for forming lexical tokens from the characters in the Fortran character set are also presented.

3.1. Cray Fortran Character Set

The Cray Fortran character set contains the following characters:

The following table shows the special characters of the Cray Fortran character set.

Table 3-1.

Graphic

Character name

Graphic

Character name

 

Blank

:

Colon

=

Equals

!

Exclamation point

+

Plus

"

Quotation mark

-

Minus

%

Percent

*

Asterisk

&

Ampersand

/

Slash

;

Semicolon

(

Left parenthesis

<

Less than

)

Right parenthesis

>

Great than

,

Comma

?

Question mark

'

Apostrophe

$

Currency symbol

@

At sign[1]

.

Decimal point or period

Note: The at sign (@) is not included in the Fortran character set. The newline and tab characters are not part of the graphic character set as defined by the standard, but the standard allows them as part of the processor-dependent control character set.

The 52 letters define the syntax class letter.

In most cases, the compiler is not case sensitive; lowercase letters are considered the same as uppercase letters. In the following cases, however, lowercase and uppercase letters are considered to have different data values:

Note: Hollerith data is not included in the Fortran standard.

The Cray Fortran Compiler considers the following two statements to be equivalent:

PRINT *, N
Print *, n

The Cray Fortran Compiler distinguishes between uppercase and lowercase letters in the FILE= or NAME= specifier in an OPEN or an INQUIRE statement.

The digits 0 through 9 define the syntax class digit. The digits are assumed to be decimal numbers when used to describe a numeric value, except in binary, octal, and hexadecimal (BOZ) literal constants or input/output (I/O) records corresponding to B, O, or Z edit descriptors.

For example, in the following DATA statement, the digits of the first constant are decimal digits, those of the second constant are binary digits, and those of the third are hexadecimal digits:

DATA  X, I, J / 4.89, B'1011', Z'BAC91' /

The underscore can be used to make names more readable. For example, in the identifier NUMBER_OF_CARS, each underscore is used to separate the obvious English words. It is a significant character in any name. An underscore cannot be used as the first character of a name, but it can be the last character. An underscore is also used to separate the kind value from the actual value of a literal constant (for example, 123_2).

There are 22 special characters used for operators like multiply and add. They are also used as separators or delimiters in Fortran statements. Separators and delimiters make the form of a statement unambiguous.

Note: The at sign (@) can be used in an identifier in the same way that you would use an underscore (_). The at sign cannot be used as the first character in an identifier. Using the at sign is not recommended because it is reserved for internal use.

Fortran's treatment of uppercase and lowercase letters can lead to portability problems when calling subprograms written in other languages. The problem occurs because the standard does not specify the case of letters used for external names. The following program fragment illustrates the problem:

EXTERNAL  FOO
  . . .
CALL  FOO
  . . .
END 

The Cray Fortran Compiler uses uppercase for external names, so the Cray Fortran Compiler would use FOO as the external name. If the subprogram were written in C, which is case sensitive, and if foo were written in lowercase, the external name used in C would then be different from the name produced by the Cray Fortran Compiler.

The NAME compiler directive allows you to specify a case-sensitive external name in a Fortran program. You can use this directive, for example, when writing calls to C routines. For more information on the NAME directive, see the Cray Fortran Compiler Commands and Directives Reference Manual.

The BIND(C) attribute allows you to specify case sensitive external names for Fortran and C. Refer to Section 5.6.5.

Footnotes

[1]

The compiler allows you to use the at sign (@) in certain cases; these cases are described in Section 3.2.2.