• Aucun résultat trouvé

The Processor Character Set The processor character set contains:

Dans le document The Fortran 2003 Handbook (Page 52-55)

• the Fortran character set of Table 3-1.

• as an extension, a processor-dependent set of control characters that have no graphic representation, such as “new line” or “escape”

• as an extension, a set of characters with graphics (such as lowercase letters, Greek letters, Japanese ideographs, or characters in the shape of a heart or a diamond) It is recommended that the programmer consult the implementor’s documentation describing the processor-dependent features of each particular Fortran implementa-tion.

3.1.1 The Fortran Character Set

Characters in the Fortran character set are shown in Table 3-1.

Rules and restrictions:

1. Lowercase letters are considered the same as uppercase letters except within a character constant, a quote or apostrophe edit descriptor, or input/output records, where uppercase and lowercase letters are different data values in character data.

The following two statements are equivalent:

PRINT *, N Print *, n

Whether uppercase and lowercase letters are distinguished in the FILE= or NAME=

specifier in an OPEN or an INQUIRE statement is processor dependent.

2. 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/out-put records corresponding to B, O, or Z edit descriptors. For example, consider the following DATA statement:

Language Elements and Source Form 45

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

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.

3. The underscore is used to make names more readable. For example, in the identifi-er NUMBER_OF_CARS, each undidentifi-erscore is used to separate the obvious English words. It is a significant character in any name. It cannot be used as the first char-acter of a name; however, it may be the last charchar-acter. An underscore is also used

Table 3-1 The Fortran character set Alphanumeric characters

Letters A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z

Digits 0 1 2 3 4 5 6 7 8 9 Underscor

e

_ Special characters

Graphic Name of character Graphic Name of character

Blank ; Semicolon

= Equals ! Exclamation point

+ Plus ʺ Quotation mark or quote

- Minus % Percent

* Asterisk & Ampersand

/ Slash ~ Tilde

\ Backslash < Less than

( Left parenthesis > Greater than

) Right parenthesis ? Question mark

[ Left square bracket ’ Apostrophe

] Right square bracket ’ Grave accent

{ Left curly bracket (brace) ^ Circumflex accent

} Right curly bracket (brace) | Vertical bar

, Comma $ Currency symbol

. Decimal point or period # Number sign

: Colon @ Commercial at

46 Chapter 3 to separate the kind value from the actual value of a literal constant (for example, 123_SHORT is a literal constant with value 123 and of integer type with kind SHORT).

4. Except for the currency symbol ($), the graphic for each character must be the same as in Table 3-1; however, any style, font, or printing convention may be used.

5. The special characters, \, {, }, ~, ?, ’, ^, |, $, #, and @, are used only in a character context or a comment.

The special characters are used for operators like multiply and add, and as separa-tors or delimiters in Fortran statements. Separasepara-tors and delimiters make the form of a statement unambiguous.

3.1.2 Other Characters

In addition to the Fortran character set, other characters may be included in the proces-sor character set. These are either control characters with no graphics or additional characters with graphics. The selection of the other characters and where they may be used is processor dependent. However, wherever they are permitted, the other charac-ters are restricted in use to character constants, quote and apostrophe edit descriptors, comment lines, and input/output records. All characters of the Fortran character set may be used in character constants, quote and apostrophe edit descriptors, comment lines, and input/output records.

A processor is required to support the Fortran character set as part of a character set referred to as the default character set. A processor is allowed to support more than one character set, each set using a different kind value of the intrinsic character type (4.3.5); each such character set is a nondefault character set. The choice of charac-ters in such sets is processor dependent except that each such set must contain a char-acter that can be used as a blank. This specially designated charchar-acter is used where blank padding is required.

The choice of the representable characters beyond the Fortran character set is ex-pected to be dependent on the particular implementation. It is recommended that the implementor’s documentation be consulted for specific details.

3.1.3 The Tab Character

The tab character is not in the Fortran character set and is an example of an optional control character that may be permitted by the processor in the source forms and typi-cally is used as a blank separator. When it appears as the first character in a fixed source form line, it often represents at least six blank characters, so that the next char-acter may begin the body of a statement that must appear in columns 7-72. However, this is not standard and its use may make it difficult to port the program; therefore, its use is not recommended.

This recommendation does not help the programmer who has code that uses tab characters. To use a Fortran file containing tabs with a compiler that accepts only stan-dard-conforming programs, replace the tab with a blank for free source form and with six blanks for fixed source form. This conversion is not fool proof; replacing a tab in

Language Elements and Source Form 47 fixed source form may extend the line beyond position 72. In either form, a tab may be used in character context for output format control; in this case, the modification may lead to an undesirable layout of data in the output.

Dans le document The Fortran 2003 Handbook (Page 52-55)