HP 3000 Manuals

Edit Descriptors [ HP FORTRAN 77/iX Reference ] MPE/iX 5.0 Documentation


HP FORTRAN 77/iX Reference

Edit Descriptors 

Edit descriptors specify editing between numeric, Hollerith, and logical
fields on input and output records.  There are 19 edit descriptors.

          *   BN, BZ, and Q apply only to input.
          *   NL, NN, $, S, SP, and SS apply only to output.
          *   H, "string", 'string', P, T, TL, TR, X, /, and :  apply to
              both input and output.

Blank Interpretation Edit Descriptors (BN, BZ) 

The BN and BZ edit descriptors interpret embedded and trailing blanks in
numeric input fields.  At the beginning of input statement execution,
blank characters are ignored.  (An exception to this rule occurs when the
unit is connected with BLANK='ZERO' specified in the OPEN statement.)
Note that BN and BZ override the BLANK specifier for the current READ
statement.  If a BZ edit descriptor is encountered in the format
specification, trailing and embedded blanks in succeeding numeric fields
are treated as zeros.  The BZ edit descriptor remains in effect until a
BN edit descriptor or the end of the format specification is encountered.
If BN is specified or defaulted, all embedded blanks are removed and the
input number is right-justified within the field width.  The BN and BZ
edit descriptors affect the D, E, F, G, I, @, K, O, and Z format
descriptors during the execution of an input statement.  They have no
effect during execution of an output statement.  They have no effect at
any time on the A, L, M, N, and R format descriptors.

          Input Examples 

-------------------------------------------------------------------------------------------------
|                       |                       |                       |                       |
|      Descriptor       |      Input Field      |      BN Editing       |      BZ Editing       |
|                       |                       |                       |                       |
-------------------------------------------------------------------------------------------------
|                       |                       |                       |                       |
| I4                    | 1 Delta 2 Delta       | 12                    | 1020                  |
|                       |                       |                       |                       |
| F6.2                  | Delta 4 Delta .       | 4.2                   | 40.02                 |
|                       | Delta 2               |                       |                       |
|                       |                       |                       |                       |
| E7.1                  | 5 Delta .  Delta E1   | 5.*101                | 50.0*1010             |
|                       | Delta                 |                       |                       |
|                       |                       |                       |                       |
| I2                    | Delta Delta           | 0                     | 0                     |
|                       |                       |                       |                       |
| E5.0                  | 3E4 Delta Delta       | 3.*104                | 3.*10400 (overflow)   |
|                       |                       |                       |                       |
-------------------------------------------------------------------------------------------------

End-of-Line Edit Descriptors (NL, NN, $) 

As extensions to the ANSI 77 standard, FORTRAN 77 has edit descriptors to
control the action taken at the end of an output line or record.  These
actions include controlling the cursor position on a terminal after a
write and performing multiple writes on the same output line.

The NL, NN, and $ end-of-line edit descriptors (also known as prompt edit
descriptors) control the carriage-return/line-feed (newline) characters
normally appended to a sequential output record.

The NN and $ edit descriptors suppress the move to the next line before
the write operation to the terminal, giving the appearance of appending
the result of the write operation (containing the NN or $ descriptor) to
the current line.  These descriptors perform multiple write operations to
one apparent line of a carriage control output device.

The NL edit descriptor causes a newline character to be appended after
the write operation containing the NL descriptor.  The NL edit descriptor
advances to the next line after each write containing the NL descriptor.
NN (equivalent to $) is the default in HP FORTRAN 77/iX.

These descriptors apply to sequential output only.  They are ignored by
READ statements and direct access WRITE statements.

The $ edit descriptor is the same as NN and is included for compatibility
with other versions of FORTRAN. The prompt edit descriptors are an
extension to the ANSI 77 standard.

The following program shows how to use the NL and NN descriptors to
produce 50-column records.  Unless they are used together, the program
does not produce the desired effect, which, in this case, is to produce
10 fields per line.  The FORMAT statement labeled 200 produces the
desired effect, while statements 300, 400, and 500 do not.  The program
is followed by its output.

Example 

           PROGRAM test
           n=23
           WRITE(6,100) (i, i=1,7)
           WRITE(6,200) (i, i=1,n)
           WRITE(6,*)
           WRITE(6,*)
           WRITE(6,100) (i, i=1,7)
           WRITE(6,300) (i, i=1,n)
           WRITE(6,*)
           WRITE(6,*)
           WRITE(6,100) (i, i=1,7)
           WRITE(6,400) (i, i=1,n)
           WRITE(6,*)
           WRITE(6,*)
           WRITE(6,100) (i, i=1,7)
           WRITE(6,500) (i, i=1,n)
      100  FORMAT (7I5)
      200  FORMAT (NN, 3I5, :, /, NL, (10I5))
      300  FORMAT (3I5, :, /, NL, (10I5))
      400  FORMAT (3I5, :, /, (10I5))
      500  FORMAT (NN, 3I5, :, /, (10I5))
           END

Output

      1    2    3    4    5    6    7    1    2    3
      4    5    6    7    8    9   10   11   12   13
     14   15   16   17   18   19   20   21   22   23

      1    2    3    4    5    6    7
      1    2    3
      4    5    6    7    8    9   10   11   12   13
     14   15   16   17   18   19   20   21   22   23

      1    2    3    4    5    6    7
      1    2    3
      4    5    6    7    8    9   10   11   12   13
     14   15   16   17   18   19   20   21   22   23

      1    2    3    4    5    6    7    1    2    3    4    5    6    7    8    9
     10   11   12   13   14   15   16   17   18   19   20   21   22   23

Plus Sign Edit Descriptors (S, SP, SS) 

The S, SP, and SS edit descriptors control printing of optional plus
signs in numeric output.  A formatted output statement does not normally
print optional plus signs.  However, an SP edit descriptor in the format
descriptor forces optional plus signs to print in any subsequent numeric
output.  The S and SS descriptors inhibit printing of optional plus signs
in subsequent numeric output.

Literal Edit Descriptors ('string', "string", H) 

The literal edit descriptors are used to write a character constant to
the output record or to skip columns in an input record.  The 'string'
(apostrophe) and "string" (quotation mark) descriptors have the form of a
character constant.  The length of an apostrophe or quotation mark
descriptor is the number of characters between the delimiters.  As with
character constants, two consecutive apostrophes in an apostrophe
descriptor or two consecutive quotation marks in a quotation mark
descriptor count as one character.  The quotation mark edit descriptor is
an extension to the ANSI 77 standard.

The nHstring edit descriptor has the form of a Hollerith constant; n is
the number of characters in string, including any blanks.  The length of
an H descriptor is n.

On output, the character constant is written.

On input, a literal edit descriptor behaves like a right tab (TR) of the
same length as string.  The input characters are skipped.  The use of
literal edit descriptors on input is an extension to the ANSI 77
standard.

          Output Examples 

----------------------------------------------------------------------------------------------
|                              |                              |                              |
|          Descriptor          |         Field Width          |         Output Field         |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| 'BEGIN DATA INPUT'           |              16              | BEGIN DATA INPUT             |
|                              |                              |                              |
| "DAVID'S TURN"               |              12              | DAVID'S TURN                 |
|                              |                              |                              |
| "THE END Delta Delta Delta " |              10              | THE END Delta Delta Delta    |
|                              |                              |                              |
| ' Delta Delta SPACE Delta    |              10              | Delta Delta SPACE Delta      |
| Delta '                      |                              | Delta                        |
|                              |                              |                              |
| "$*[/\%<;,#!"                |              11              | $*[/\%<;,#!                  |
|                              |                              |                              |
| 'Aren''t'                    |              5               | Aren't                       |
|                              |                              |                              |
| """"                         |              1               | "                            |
|                              |                              |                              |
| '"'                          |              1               | "                            |
|                              |                              |                              |
| 7H$ Delta Help!              |              7               | $ Delta Help!                |
|                              |                              |                              |
----------------------------------------------------------------------------------------------

Input Bytes Remaining Edit Descriptor (Q) 

As an extension to the ANSI 77 standard, the Q edit descriptor returns
the number of bytes remaining on the current input record.  The value is
returned to the next item in the input list, which must be an integer
variable.  This is useful when the exact contents of the input record are
to be read, avoiding the blank padding of further variables read.

This descriptor applies to input only.  It is ignored in output
statements.

Position Edit Descriptor (X) 

The xX edit descriptor skips x positions of an input/output record.  x 
must be a positive integer.

The X descriptor is identical to the TR descriptor.

On input, the X edit descriptor causes the next x positions of the input
record to be skipped.

          Input Examples 

----------------------------------------------------------------------------------------------
|                              |                              |                              |
|         Descriptors          |         Input Record         |        Values Stored         |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| F6.2,3X,I2                   | 673 Delta 21END45            | 673.21, 45                   |
|                              |                              |                              |
| 1X,I2,A3                     | $6 Delta END                 | 6, END                       |
|                              |                              |                              |
----------------------------------------------------------------------------------------------

On output, the X edit descriptor causes x positions of the output record
to be filled with blanks.  If the positions were already defined, they
are left unchanged.  This can happen when the T or TL edit descriptor is
used.

          Output Examples 

----------------------------------------------------------------------------------------------
|                              |                              |                              |
|         Descriptors          |       Internal Values        |        Output Fields         |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| F8.2,2X,I3                   | 5.87,436                     | Delta Delta Delta Delta 5.87 |
|                              |                              | Delta Delta 436              |
|                              |                              |                              |
| F4.2,3X,"TOTAL"              | 32.4                         | 32.4 Delta Delta Delta TOTAL |
|                              |                              |                              |
----------------------------------------------------------------------------------------------

Tab Edit Descriptors (T, TL, TR) 

The tab edit descriptors position the cursor on the input or output
record.  The Tc edit descriptor specifies an absolute column number (c),
while the TLt and TRt descriptors specify a number of column positions to
skip the left (TL) or right (TR) of the current cursor position.  The TR
descriptor is identical to the X descriptor.  If the T or TL descriptor
causes subsequent format descriptors to overwrite previous fields, the
last character written for a particular column position in the output
record is the character output for that position.  On input, characters
can be reread, possibly under a different editing format.

          Input Example 

----------------------------------------------------------------------------------------------
|                              |                              |                              |
|         Descriptors          |         Input Record         |        Stored Values         |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| A4,T1,F4.0                   | 1234                         | '1234', 1234.0               |
|                              |                              |                              |
----------------------------------------------------------------------------------------------

          Output Examples 

----------------------------------------------------------------------------------------------
|                              |                              |                              |
|         Descriptors          |       Internal Values        |        Output Record         |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| T5,F3.1                      | 1.0                          | Delta Delta Delta Delta 1.0  |
|                              |                              |                              |
| F3.1,TR4,F3.2                | 1.0, .11                     | 1.0 Delta Delta Delta Delta  |
|                              |                              | .11                          |
|                              |                              |                              |
| T10,F3.1,TL12,F3.2           | 1.0, .11                     | .11 Delta Delta Delta Delta  |
|                              |                              | Delta Delta 1.0              |
|                              |                              |                              |
----------------------------------------------------------------------------------------------

Record Terminator Edit Descriptor ( / ) 

The / edit descriptor terminates processing of the current record and
begins processing of a new record (such as a new line on a line printer
or a terminal).  The / edit descriptor has the same result for both input
and output:  it terminates the current record and begins a new one.  For
example, on output, a new line is printed; on input, a new line is read.

Colon Edit Descriptor ( :  ) 

If there are no more items in the input/output list, the colon edit
descriptor (:)  terminates format control (just as if the final right
parenthesis in the format specification had been reached).  If more items
remain in the list, the colon edit descriptor has no effect.

          Output Examples 

----------------------------------------------------------------------------------------------
|                              |                              |                              |
|         Descriptors          |       Internal Values        |        Output Record         |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| (10('value=',I2))            | 1, 2                         | value= 1 value= 2 value=     |
|                              |                              |                              |

| (10(:,'value=',I2))          | 1, 2                         | value= 1 value= 2            |
|                              |                              |                              |
----------------------------------------------------------------------------------------------

In the first example, the descriptor 'value=' is repeated an extra time
because format control is not terminated until the descriptor I2 is
reached and not satisfied.  In the second example, the :  descriptor
terminates format control before the string value= can be output a third
time.

Scale Factor Edit Descriptor (P) 

The scale factor edit descriptor, kP (k is the scale value), is a
descriptor that modifies the output of the D[w.d], E[w.d], and G[w.d]
(interpreted as E[w.d]) format descriptors and the fixed-point output of
the F[w.d] format descriptor.  The scale factor also modifies the
fixed-point inputs to the D[w.d], E[w.d], F[w.d], and G[w.d] format
descriptors.  A scale factor has no effect on the output of the G[w.d]
(interpreted as F[w.d]) descriptor or on floating-point input.

For example, if a number of data items are stored without decimal points
but are supposed to be interpreted as containing an implied decimal point
two positions from the right, using a scale factor of -2 causes the items
to be printed with the decimal point.  Thus, with the format descriptor
F7.2, the value 123 is printed 123.00, and with the format descriptor
-2PF7.2, it is printed 1.23.

When a format specification is interpreted, the scale factor is set to 0.
Each time a scale factor descriptor is encountered in a format
specification, a new value is set.  This scale value remains in effect
for all subsequent affected format descriptors or until use of the format
specification ends.

      Examples                                     Notes 

--------------------------------------------------------------------------------------

(E10.3,F12.4,I9)      No scale factor change.  The default value, zero, remains in
                      effect.

(E10.3,2PF12.4,I9)    Scale factor is zero for E10.3, changes to 2 for F12.4, has no
                      effect on I9.

On input, the scale factor affects fixed-field (no exponent) input to the
D[w.d], E[w.d], F[w.d], and G[w.d] format descriptors.  The external
value is multiplied by 10 raised to the (-k)th power, as illustrated
below.

          Input Examples 

----------------------------------------------------------------------------------------------
|                              |                              |                              |
|         Descriptors          |         Input Field          |         Value Stored         |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| E10.4                        | Delta Delta 123.9678         | 123.9678                     |
|                              |                              |                              |

| 2PD10.4                      | Delta Delta 123.9678         | 1.239678                     |
|                              |                              |                              |
| -2PG11.5                     | Delta Delta 123.96785        | 12396.785                    |
|                              |                              |                              |
| -2PE12.5                     | 123967.85E02                 | 123967.85E02 (Note)          |
|                              |                              |                              |
----------------------------------------------------------------------------------------------

                     Note:  If the input includes an exponent, the scale
                     factor has no effect.

On output, the scale factor affects D[w.d], E[w.d], F[w.d], and G[w.d]
(interpreted as E[w.d]) format descriptors only.  The scale factor has no
effect on the G[w.d] (interpreted as F[w.d]) field descriptor.

For E[w.d], D[w.d], and G[w.d] (interpreted as E[w.d]) format
descriptors, the scale factor has the effect of shifting the decimal
point of the output number to the right k places while reducing the
exponent by k (the value of the mantissa remains the same).  The number
of significant digits printed is equal to (d + k).

          Output Examples for E, D, and G 

----------------------------------------------------------------------------------------------
|                              |                              |                              |
|         Descriptors          |         Stored Value         |         Output Field         |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| E12.4                        | 12.345678                    | Delta Delta Delta .1235E+02  |
|                              |                              |                              |
| 3PE12.4                      | 12.345678                    | Delta Delta Delta 123.5E-01  |
|                              |                              |                              |
| -3PD12.4                     | 12.345678                    | Delta Delta Delta .0001D+05  |
|                              |                              |                              |
| 1PG11.3                      | 1234                         | Delta Delta 1.234E+03        |
|                              |                              |                              |
----------------------------------------------------------------------------------------------

For the F[w.d] format descriptor, the internal value is multiplied by 10
raised to the (+k)th power, as illustrated below.

          Output Examples for F 

----------------------------------------------------------------------------------------------
|                              |                              |                              |
|         Descriptors          |         Input Field          |         Value Stored         |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| F11.3                        | 1234.500                     | 1234.500                     |
|                              |                              |                              |
| -2PF11.3                     | 1234.500678                  | 12.345                       |
|                              |                              |                              |
| 2PF11.3                      | 1234.500678                  | 123450.068                   |
|                              |                              |                              |
----------------------------------------------------------------------------------------------

The scale factor need not immediately precede its format descriptor.  For
example, the format specification:

     (3P,I2,F4.1,E5.2)

is equivalent to:

     (I2,3P,F4.1,E5.2)

If the scale factor does not immediately precede a D[w.d], E[w.d],
F[w.d], or G[w.d] format descriptor, it should be separated from other
descriptors by commas or slashes.  If the scale factor immediately
precedes a D, E, F, or G format descriptor, the comma or slash descriptor
is optional.

For example, the format specification:

     (I2,3PF4.1,E5.2)

is equivalent to:

     (I2,3P,F4.1,E5.2)

The scale factor affects all D, E, F, and G descriptors until either the
end of the format specification or another scale factor is encountered.



MPE/iX 5.0 Documentation