Control Edit Descriptors

/ (Slash) Editing

Purpose

The slash edit descriptor indicates the end of data transfer on the current record. The repeat specifier (r) has a default value of 1.

Syntax

Rules

When you connect a file for input using sequential access, each slash edit descriptor positions the file at the beginning of the next record.

When you connect a file for output using sequential access, each slash edit descriptor creates a new record and positions the file to write at the start of the new record.

When you connect a file for input or output using direct access, each slash edit descriptor increases the record number by one, and positions the file at the beginning of the record that has that record number.

+------------------------Fortran 2003 Draft Standard-------------------------+

When you connect a file for input using stream access, each slash edit descriptor positions the file at the beginning of the next record, skipping the remaining portion of the current record. On output to a file connected for stream access, a newly created empty record follows the current record. The new record becomes both the current and last record of the file, with the file position coming at the beginning of the new record.

+---------------------End of Fortran 2003 Draft Standard---------------------+

Examples

500   FORMAT(F6.2 / 2F6.2)
100   FORMAT(3/)

: (Colon) Editing

Purpose

The colon edit descriptor terminates format control if no more items are in the input/output list. If more items are in the input/output list when the colon is encountered, it is ignored.

Syntax

Rules

See Interaction of Input/Output Lists and Format Specifications for more information.

Examples

10    FORMAT(3(:'Array Value',F10.5)/)

+-------------------------------IBM Extension--------------------------------+

$ (Dollar) Editing

Purpose

The dollar edit descriptor inhibits an end-of-record for a sequential or formatted stream WRITE statement.

Syntax

Rules

Usually, when the end of a format specification is reached, data transmission of the current record ceases and the file is positioned so that the next input/output operation processes a new record. But, if a dollar sign occurs in the format specification, the automatic end-of-record action is suppressed. Subsequent input/output statements can continue writing to the same record.

Examples

A common use for dollar sign editing is to prompt for a response and read the answer from the same line.

      WRITE(*,FMT='($,A)')'Enter your age  '
      READ(*,FMT='(BN,I3)')IAGE
      WRITE(*,FMT=1000)
1000  FORMAT('Enter your height:  ',$)
      READ(*,FMT='(F6.2)')HEIGHT

+----------------------------End of IBM Extension----------------------------+

Apostrophe/Double Quotation Mark Editing (Character-String Edit Descriptor)

Purpose

The apostrophe/double quotation mark edit descriptor specifies a character literal constant in an output format specification.

Syntax

Rules

The width of the output field is the length of the character literal constant. See Character for additional information on character literal constants.

+-------------------------------IBM Extension--------------------------------+

Notes:

  1. A backslash is recognized, by default, as an escape sequence, and as a backslash character when the -qnoescape compiler option is specified. See escape sequences for more information.

  2. XL Fortran provides support for multibyte characters within character constants, Hollerith constants, character-string edit descriptors, and comments. This support is provided through the -qmbcs option. Assignment of a constant containing multibyte characters to a variable that is not large enough to hold the entire string may result in truncation within a multibyte character.

  3. Support is also provided for Unicode characters and filenames. If the environment variable LANG is set to UNIVERSAL and the -qmbcs compiler option is specified, the compiler can read and write Unicode characters and filenames.

+----------------------------End of IBM Extension----------------------------+

Examples

      ITIME=8
      WRITE(*,5) ITIME
5     FORMAT('The value is -- ',I2) ! The value is -- 8
      WRITE(*,10) ITIME
10    FORMAT(I2,'o''clock') ! 8o'clock
      WRITE(*,'(I2,7Ho''clock)') ITIME ! 8o'clock
      WRITE(*,15) ITIME
15    FORMAT("The value is -- ",I2) ! The value is -- 8
      WRITE(*,20) ITIME
20    FORMAT(I2,"o'clock") ! 8o'clock
      WRITE(*,'(I2,"o''clock")') ITIME ! 8o'clock 

BN (Blank Null) and BZ (Blank Zero) Editing

Purpose

The BN and BZ edit descriptors control the interpretation of nonleading blanks by subsequently processed I, F, E, EN, ES, D, G, B, O, Z, and extended precision Q edit descriptors. BN and BZ have effect only on input.

Syntax

Rules

BN specifies that blanks in numeric input fields are to be ignored, and remaining characters are to be interpreted as though they were right-justified. A field of all blanks has a value of zero.

BZ specifies that nonleading blanks in numeric input fields are to be interpreted as zeros.

The initial setting for blank interpretation is determined by the BLANK= specifier of the OPEN statement. (See OPEN.) The initial setting is determined as follows:

The initial setting for blank interpretation takes effect at the start of a formatted READ statement and stays in effect until a BN or BZ edit descriptor is encountered or until format control finishes. Whenever a BN or BZ edit descriptor is encountered, the new setting stays in effect until another BN or BZ edit descriptor is encountered, or until format control terminates.

+-------------------------------IBM Extension--------------------------------+

If you specify the oldboz suboption of the -qxlf77 compiler option, the BN and BZ edit descriptors do not affect data input edited with the B, O, or Z edit descriptors. Blanks are interpreted as zeros.

+----------------------------End of IBM Extension----------------------------+

H Editing

Purpose

The H edit descriptor specifies a character string (str) and its length (n) in an output format specification. The string can consist of any of the characters allowed in a character literal constant.

Syntax

Rules

If an H edit descriptor occurs within a character literal constant, the constant delimiter character (for example, apostrophe) can be represented within str if two such characters are consecutive. Otherwise, another delimiter must be used.

The H edit descriptor must not be used on input.

Notes:

    +-------------------------------IBM Extension--------------------------------+

  1. A backslash is recognized as an escape character by default, and as a backslash character when the -qnoescape compiler option is specified. See escape sequences for more information.

  2. XL Fortran provides support for multibyte characters within character constants, Hollerith constants, character-string edit descriptors, and comments. This support is provided through the -qmbcs option. Assignment of a constant containing multibyte characters to a variable that is not large enough to hold the entire string may result in truncation within a multibyte character.

  3. Support is also provided for Unicode characters and filenames. If the environment variable LANG is set to UNIVERSAL and the -qmbcs compiler option is specified, the compiler can read and write Unicode characters and filenames.

    +----------------------------End of IBM Extension----------------------------+

    +---------------------------------Fortran 95---------------------------------+

  4. Fortran 95 does not include the H edit descriptor, although it was part of both FORTRAN 77 and Fortran 90.

    +-----------------------------End of Fortran 95------------------------------+

Examples

50    FORMAT(16HThe value is -- ,I2)
10    FORMAT(I2,7Ho'clock)
      WRITE(*,'(I2,7Ho''clock)') ITIME

P (Scale Factor) Editing

Purpose

The scale factor, k, applies to all subsequently processed F, E, EN, ES, D, G, and extended precision Q edit descriptors until another scale factor is encountered or until format control terminates. The value of k is zero at the beginning of each input/output statement. It is an optionally signed integer value representing a power of ten.

Syntax

Rules

On input, when an input field using an F, E, EN, ES, D, G, or extended precision Q edit descriptor contains an exponent, the scale factor is ignored. Otherwise, the internal value equals the external value multiplied by 10(-k).

On output:

Examples

Examples of P Editing on Input
Input      Format      Value
98.765     3P,F8.6     .98765E-1
98.765     -3P,F8.6    98765.
.98765E+2  3P,F10.5    .98765E+2

Examples of P Editing on Output
Value      Format           Output                     Output
                     (with -qxlf77=noleadzero)  (with -qxlf77=leadzero)
5.67       -3P,F7.2         bbbb.01                    bbb0.01
12.34      -2P,F6.4         b.1234                     0.1234
12.34      2P,E10.3         b12.34E+00                 b12.34E+00

S, SP, and SS (Sign Control) Editing

Purpose

The S, SP, and SS edit descriptors control the output of plus signs by all subsequently processed I, F, E, EN, ES, D, G, and extended precision Q edit descriptors until another S, SP, or SS edit descriptor is encountered or until format control terminates.

Syntax

Rules

S and SS specify that plus signs are not to be written. (They produce identical results.) SP specifies that plus signs are to be written.

Examples

Value      Format      Output
12.3456    S,F8.4      b12.3456
12.3456    SS,F8.4     b12.3456
12.3456    SP,F8.4     +12.3456

T, TL, TR, and X (Positional) Editing

Purpose

The T, TL, TR, and X edit descriptors specify the position where the transfer of the next character to or from a record starts.

Syntax

Rules

The T and TL edit descriptors use the left tab limit for file positioning. Immediately before data transfer the definition of the left tab limit is the character position of the current record or the current position of the stream file. The T, TL, TR, and X specify the character position as follows:

The TR and X edit descriptors give identical results.

On input, a TR or X edit descriptor can specify a position beyond the last character of the record if no characters are transferred from that position.

On output, a T, TL, TR, or X edit descriptor does not by itself cause characters to be transferred. If characters are transferred to positions at or after the position specified by the edit descriptor, positions skipped and previously unfilled are filled with blanks. The result is the same as if the entire record were initially filled with blanks.

On output, a T, TL, TR, or X edit descriptor can result in repositioning so that subsequent editing with other edit descriptors causes character replacement.

+-------------------------------IBM Extension--------------------------------+

The X edit descriptor can be specified without a character position. It is treated as 1X. When the source file is compiled with -qlanglvl=90std or -qlanglvl=95std, this extension is disabled in all compile-time format specifications, and the form of oX is enforced. To disable this extension in run-time formats, the following run-time option must be set:

XLFRTEOPTS="langlvl=90std" or "langlvl=95std" ; export XLFRTEOPTS

+----------------------------End of IBM Extension----------------------------+

Examples

Examples of T, TL, and X Editing on Input
150   FORMAT(I4,T30,I4)
200   FORMAT(F6.2,5X,5(I4,TL4))

Examples of T, TL, TR, and X Editing on Output
50    FORMAT('Column 1',5X,'Column 14',TR2,'Column 25')
100   FORMAT('aaaaa',TL2,'bbbbb',5X,'ccccc',T10,'ddddd')
IBM Copyright 2003