HP 3000 Manuals

FORMAT Statement (Nonexecutable) [ HP FORTRAN 77/iX Reference ] MPE/iX 5.0 Documentation


HP FORTRAN 77/iX Reference

FORMAT Statement (Nonexecutable) 

The FORMAT statement describes how input and output information is to be
arranged.

[]
Descriptor List
[]
Variable Format Descriptor
[]
----------------------------------------------------------------------------------------------- | | | | | Item | Description/Default | Restrictions | | | | | ----------------------------------------------------------------------------------------------- | | | | | label | Statement label. | Required. | | | | | ----------------------------------------------------------------------------------------------- | | | | | repeat_spec | Repeat specification. | Must be an unsigned positive | | | | integer constant or a variable | | | | format descriptor whose value is | | | | positive. | | | | | ----------------------------------------------------------------------------------------------- | | | | | format_descriptor | Format descriptor. See the | None. | | | following Format Descriptor syntax | | | | diagram and table for details. | | | | | | ----------------------------------------------------------------------------------------------- | | | | | edit_descriptor | Edit descriptor. See the | None. | | | following Edit Descriptor syntax | | | | diagram and table for details. | | | | | | ----------------------------------------------------------------------------------------------- | | | | | descriptor_list | A list of format and edit | None. | | | descriptors. | | | | | | ----------------------------------------------------------------------------------------------- | | | | | expression | A positive integer expression. | None. | | | | | ----------------------------------------------------------------------------------------------- Format Descriptor
[]
------------------------------------------------------------------------------------------------- | | | | | Item | Description/Default | Restrictions | | | | | ------------------------------------------------------------------------------------------------- | | | | | d | Number of digits in fractional part. | Must be an unsigned positive integer | | | If omitted, the default value is based | constant or a variable format | | | on the data type of the I/O list | descriptor whose value is positive. | | | element. (Refer to Table 3-5 for | | | | default values.) | | | | | | ------------------------------------------------------------------------------------------------- | | | | | e | Number of digits in exponent part. If | Must be an unsigned positive integer | | | omitted, the default value is based on | constant or a variable format | | | the data type of the I/O list element. | descriptor whose value is positive. | | | (Refer to Table 3-5 for default | | | | values.) | | | | | | ------------------------------------------------------------------------------------------------- | | | | | m | Minimum number of digits to be output. | Must be an unsigned positive integer | | | The default is one. | constant or a variable format | | | | descriptor whose value is positive. | | | | | ------------------------------------------------------------------------------------------------- | | | | | w | Field width. If omitted, the default | Must be an unsigned positive integer | | | value is based on the data type of the | constant or a variable format | | | I/O list element. (Refer to Table 3-5 | descriptor whose value is positive. | | | for default values.) | | | | | | ------------------------------------------------------------------------------------------------- Edit Descriptor
[]
---------------------------------------------------------------------------------------------- | | | | | Item | Description/Default | Restrictions | | | | | ---------------------------------------------------------------------------------------------- | | | | | c | Column position. | Must be an unsigned positive integer constant or a | | | | variable format descriptor whose value is | | | | positive. | | | | | ---------------------------------------------------------------------------------------------- | | | | | k | Scale value. | Must be an integer constant or a variable format | | | | descriptor. | | | | | ---------------------------------------------------------------------------------------------- | | | | | n | Number of characters. | Must be an unsigned positive integer constant. | | | | | ---------------------------------------------------------------------------------------------- | | | | | string | A series of one or more | The H format has the form of a Hollerith constant. | | | ASCII characters. | The " and ' formats have the form of character | | | | constants. | | | | | ---------------------------------------------------------------------------------------------- | | | | | t | Number of columns to skip. | Must be an unsigned positive integer constant or a | | | | variable format descriptor whose value is | | | | positive. | | | | | ---------------------------------------------------------------------------------------------- | | | | | x | Number of columns to skip. | Must be an unsigned positive integer constant. | | | | | ---------------------------------------------------------------------------------------------- Table 3-5. Default Format Descriptor Field Values ----------------------------------------------------------- | | | | | | | Format Descriptor | List Element Type | w | d | e | | | | | | | ----------------------------------------------------------- | | | | | | | @, I, K, O, Z | INTEGER*2, | 7 | | | | | LOGICAL*1, | | | | | | LOGICAL*2 | | | | | | | | | | ----------------------------------------------------------- | | | | | | | @, I, K, O, Z | INTEGER*4, | 12 | | | | | LOGICAL*4 | | | | | | | | | | ----------------------------------------------------------- | | | | | | | L | LOGICAL*1, | 2 | | | | | LOGICAL*2, | | | | | | LOGICAL*4 | | | | | | | | | | ----------------------------------------------------------- | | | | | | | I | REAL*4, COMPLEX*8 | 12 | | | | | | | | | ----------------------------------------------------------- | | | | | | | I | REAL*8, | 23 | | | | | COMPLEX*16 | | | | | | | | | | ----------------------------------------------------------- | | | | | | | I | REAL*16 | 44 | | | | | | | | | ----------------------------------------------------------- | | | | | | | D, E, F, G, M, N | INTEGER*2, | 15 | 7 | 2 | | | LOGICAL*1, | | | | | | LOGICAL*2 | | | | | | | | | | ----------------------------------------------------------- | | | | | | | D, E, F, G, M, N | INTEGER*4, | 25 | 16 | 2 | | | LOGICAL*4 | | | | | | | | | | ----------------------------------------------------------- | | | | | | | D, E, F, G, M, N | REAL*4, COMPLEX*8 | 15 | 7 | 2 | | | | | | | ----------------------------------------------------------- | | | | | | | D, E, F, G, M, N | REAL*8, | 25 | 16 | 2 | | | COMPLEX*16 | | | | | | | | | | ----------------------------------------------------------- | | | | | | | D, E, F, G, M, N | REAL*16 | 42 | 33 | 3 | | | | | | | -----------------------------------------------------------
NOTE When using field descriptors without a field width value, the descriptors must be separated by commas. For example, (I4 I4) is allowed because the first field width value is present. However, (I I4) is invalid. The descriptors must be separated with a comma, as in (I,I4), because the first field width value is not present.
The format descriptors are summarized in Table 3-6 . Table 3-6. Format Descriptors ------------------------------------------- | | | | Descriptor| List Element Data Type | | | | ------------------------------------------- | | | | A[w] | Any character or Hollerith | | | | | R[w] | Any character or Hollerith | | | | | D[w.d] | Any real or complex | | | | | E[w.d[Ee]]| Any real or complex | | | | | F[w.d] | Any real or complex | | | | | G[w.d[Ee]]| Any real or complex | | | | | M[w.d] | Any real | | | | | N[w.d] | Any real | | | | | I[w[.m]] | Any integer; decimal format | | | | | @[w[.m]] | Any integer; octal format | | | | | K[w[.m]] | Any integer; octal format | | | | | O[w[.m]] | Any integer; octal format | | | | | Z[w[.m]] | Any integer; hexadecimal | | | digits | | | | | L[w] | Any logical | | | | ------------------------------------------- | | | d, e, m, and w are described above in | | the item list for the Descriptor List | | syntax. | | | ------------------------------------------- Each of the format descriptors can be preceded by a repeat specification (the 4 in 4I7, for example). See repeat_spec in the item list for the Format Descriptor syntax. Example Notes --------------------------------------------------------------------------------------- 10 FORMAT(I3,5F12.3) The specification is for an integer number with a field width of 3, and five real numbers with a field width of 12 and three significant digits to the right of the decimal point. The edit descriptors are summarized in Table 3-7 . Table 3-7. Edit Descriptors ---------------------------------------------------------- | | | | Descriptor| Function | | | | ---------------------------------------------------------- | | | | BN | Ignore blanks. | | | | | BZ | Treat blanks as zeros. | | | | | nHstring | Hollerith literal. | | | | | "string" | Literal editing. | | | | | 'string' | Literal editing. | | | | | NL | Restore newline. | | | | | NN | No newline. | | | | | $ | No newline; same as NN. | | | | | kP | Scale factor. | | | | | Q | Number of characters remaining in current | | | input record. | | | | | S | Processor determines sign output; same as | | | SS. | | | | | SP | Output optional plus signs. | | | | | SS | Inhibit optional plus sign output. | | | | | Tc | Skip to column c. | | | | | TLt | Skip t positions to the left. | | | | | TRt | Skip t positions to the right. | | | | | xX | Skip x positions to the right | | | | | / | Begin new record. | | | | | : | Terminate format if I/O list empty. | | | | ---------------------------------------------------------- | | | c, k, n, string, t, and x, are described above in | | the item list for the Edit Descriptor syntax. | | | ---------------------------------------------------------- Both apostrophes and quotation marks can be used in input/output statements and in FORMAT statements. For example: WRITE (6,'("Average is ",I5)') iaverage and: WRITE (6,'(''Average is '',I5)') iaverage are equivalent.


MPE/iX 5.0 Documentation