📄 fformats.gml
字号:
for true or false respectively.
The
.mono T
and
.mono F
may be followed by additional characters in the field.
.xt on
&product allows
.mono t
and
.mono f
in addition to
.mono T
and
.mono F
on input.
.xt off
.np
On output, the I/O list item must be defined with a datum of type
logical.
The output field consists of
.id w-1
blanks followed by a
.mono T
for true or
.mono F
for false.
.exam begin
PRINT '(1H<,L3,L5,1H>)',.TRUE.,.FALSE.
.exam end
.pc
The output produced by the
.kw PRINT
statement in the previous example is the string:
.millust begin
< T F>
.millust end
.*
.section A Edit Descriptor
.*
.np
The
.id A[w]
edit descriptor is used for I/O list items of type character.
.ix 'A edit descriptor'
.ix 'edit descriptor' A
On input, the I/O list item becomes defined with character data.
On output, the I/O list item must be defined with character data.
If
.id w
is specified in the edit descriptor, the field width is
.id w;
otherwise the field width is the number of characters in the I/O
list item.
.keep
.np
.xt begin
&product also permits I/O list items of non-character data types.
On input, the I/O list item becomes defined with the binary
representation of the character data.
On output, the I/O list item is assumed to be defined with character
data.
.xt end
.np
If
.id len
is the length of the I/O list item and
.id w
is specified in
.id A
input editing so that
.id w
is greater than
.id len,
the rightmost
.id len
characters of the input field will be taken.
If
.id w
is less than
.id len,
then the
.id w
characters in the input field will be taken and padded with
.id len-w
blanks.
.np
If
.id w
is specified in
.id A
output editing so that
.id w
is greater than
.id len,
then the output field will consist of
.id w-len
blanks followed by the
.id len
characters of the I/O list item.
If
.id w
is less than or equal to
.id len,
the output field will consist of the first
.id w
characters of the I/O list item.
.exam begin
PRINT '(1H<,A5,A8,1H>)','ABCDEFG','123'
.exam end
.pc
The output produced by the
.kw PRINT
statement in the previous example is the string:
.millust begin
<ABCDE 123>
.millust end
.*
.section Z Editing (Extension)
.*
.np
.xt begin
The
.id Zw
edit descriptor is used to display the hexadecimal representation of
.ix 'Z edit descriptor'
.ix 'edit descriptor' Z
data or read hexadecimal data.
It is a &product extension.
The
.id Zw
edit descriptor can be used for I/O list items of any type.
The field width is
.id w.
.xt end
.np
On output,
.id w
must be greater than or equal to twice the size (in bytes) of the
I/O list item since
each byte is represented by two hexadecimal digits.
For example, real data requires four bytes.
Hence,
.id w
must be at least eight.
.exam begin
PRINT '(1H<,Z8,1H>)', 256
.exam end
.pc
The output produced by the
.kw PRINT
statement in the previous example is the string:
.millust begin
<00000100>
.millust end
.np
If
.id w
is greater then the number of hexadecimal digits required to represent
the data, the leftmost print positions of the output field are filled
with blanks.
.exam begin
PRINT '(1H<,Z10,1H>)','ABCD'
.exam end
.pc
The output produced by the
.kw PRINT
statement in the previous example is the string
.millust begin
< C1C2C3C4>
.millust end
.pc
if the EBCDIC character set is being used or
.millust begin
< 41424344>
.millust end
.pc
if the ASCII character set is being used.
.np
On input, if
.id w
is greater than twice the size (in bytes) of the I/O list item,
the leftmost characters are truncated from the input field.
For example, if the input field contains the string
.millust begin
91A2C3D4
.millust end
.pc
and is read into a character variable whose length is two,
the character would contain the hexadecimal data
.mono C3D4.
If
.id w
is less than twice the size (in bytes) of the I/O item,
the I/O item is padded to the left with hexadecimal zeroes.
For example, if the input field contains the string
.millust begin
81C1
.millust end
.pc
and is read into a character variable whose length is four,
the character would contain the hexadecimal data
.mono 000081C1.
.endlevel
.*
.section Format-Directed Input/Output
.*
.np
.ix 'format-directed I/O'
.us Format-directed input/output
(I/O) is formatted input or output controlled by a format
specification.
The action taken during formatted input or output depends on the
next edit descriptor in the format specification and the next
item in the input/output list if one exists.
.np
A format specification is processed from left to right.
An edit descriptor or a format specification with a repeat specification
of
.id r
is processed as a list of
.id r
edit descriptors or format specifications.
A repeat specification of one is equivalent to no repeat specification.
.np
For each repeatable edit descriptor in the format specification, there
corresponds one item in the I/O list except an I/O list item of type
complex where two repeatable floating-point edit descriptors are
required.
Non-repeatable edit descriptors do not correspond to any I/O list
item; they communicate information directly with the record.
Whenever a repeatable edit descriptor is encountered in a format
specification, there must be a corresponding item in the I/O list.
The edited information is transmitted appropriately between
the item and the record.
.np
Format processing is terminated when any of the following conditions
occur.
.autopoint
.point
When an edit descriptor has no
corresponding item in the I/O list.
.point
When a colon edit descriptor is encountered and there are no more
items in the I/O list.
.point
When the right parenthesis is encountered and there are no more
items in the I/O list.
.endpoint
.np
If the right parenthesis of the complete format specification is
encountered and the I/O list has not been
exhausted, the file is positioned at the next record and
format processing resumes at the start of the format
specification terminated by the last preceding right parenthesis.
If there is no such right parenthesis, format processing resumes
at the start of the complete format specification.
The part of the format specification that is reused must contain
at least one repeatable edit descriptor.
If format processing resumes at a left parenthesis preceded by a repeat
specification, the repeat specification is also reused.
The scale factor, sign control edit descriptors and blank control
edit descriptors are not affected when part of a format specification
is reused.
.*
.section List-Directed Formatting
.*
.np
.ix 'list-directed formatting'
.us List-directed formatting
is input/output without a format specification.
.exam begin
READ( un, * ) X, Y, Z
READ( UNIT=un, FMT=* ) X, Y, Z
READ *, X, Y, Z
WRITE( un, * ) X, Y, Z
WRITE( UNIT=un, FMT=* ) X, Y, Z
PRINT *, X, Y, Z
.exam end
.pc
In the previous example, an asterisk instead of a format specification
indicates list-directed formatting.
.keep
.np
.xt begin
Omitting the asterisk and format specification also indicates
list-directed formatting.
.exam begin
READ, X, Y, Z
PRINT, X, Y, Z
.exam end
.xt end
.np
Records used during list-directed formatting are called list-directed
records.
A list-directed record is a sequence of values and value separators.
Any sequence of blanks is treated as a single blank except when
it appears in a character constant.
The end of a record has the same effect as a blank character.
.np
A
.us value
is one of the following:
.autopoint
.point
A constant.
.point
A null value.
.point
.id r*c
.point
.id r*
.endpoint
.synote
.mnote r
is an unsigned, nonzero integer constant.
.mnote c
is a constant.
.endnote
.pc
The
.id r*c
form is equivalent to
.id r
successive occurrences of
.id c.
The
.id r*
form is equivalent to
.id r
successive occurrences of the null value.
In these two forms, blanks are permitted only where they are allowed
in the constant
.id c.
.np
A
.us value separator
is one of the following:
.autopoint
.point
A comma preceded and followed by any number of blanks.
.point
A slash preceded and followed by any number of blanks.
A slash as a value separator terminates the execution of the input
statement.
The definition status of the remaining input items in the input list
remains the same as it was prior to the input statement.
.point
Any number of blanks between two values.
.endpoint
.np
A null value is specified by having no character between successive value
separators, no characters preceding the first value separator in a
record or the
.id r*
form.
It has no effect on the current value of the input item.
Note that the end of record following a value separator does not
specify a null value.
.*
.beglevel
.*
.section List-Directed Input
.*
.np
The input forms acceptable to format specifications for a given type
are also acceptable for list-directed formatting with certain exceptions.
.autonote
.note
Blanks are never used as zeroes and blanks embedded in constants are not
allowed except in character constants.
.note
An input item of type real or double precision must have an input
field suitable for F editing except that no fractional digits are assumed
unless a decimal point is present in the field.
Such a field will be called a
.us numeric input field.
.note
An input item of type complex or double precision complex
must consist of a left parenthesis followed
by two numeric input fields separated by a comma and followed by a
right parenthesis.
The numeric input fields may be preceded or followed by blanks.
The end of record can only appear between the first numeric field and the
comma or between the comma and the second numeric field.
Note that a null value must not be used as the real or imaginary part
but may represent the entire complex constant.
.note
An input item of type logical must not include either a slash or a comma
among the optional characters allowed in L editing.
.note
An input item of type character consists of a non-empty string of
characters enclosed in apostrophes.
Apostrophes in character constants are represented by two consecutive
apostrophes without a blank or end of record separating them.
Character constants may span records.
If this is the case, the end of record does cause a blanks to be inserted
into the character constant.
Note that a comma or slash in a character constant is not a value
separator.
A character input field is assigned to a character input item
as though it were a character assignment.
.endnote
.*
.section List-Directed Output
.*
.np
The form of the output field produced by list-directed output is
similar to the form required by list-directed input.
The output of a character constant does not include the enclosing
quotes and an apostrophe in a character constant is output as a
single apostrophe.
The values are separated by one or more blanks.
When printed, each record will start with a blank if the file is
a carriage-control oriented file.
For example, the source listing file produced by &product is
such a file.
.endlevel
.*
.section Namelist-Directed Formatting (Extension)
.*
.np
.xt begin
The
.kw READ,
.kw WRITE
.ct , and
.kw PRINT
statements may be used to transmit data between a file and the
variables specified in a
.kw NAMELIST
statement.
.xt end
.keep 20
.exam begin
CHARACTER*20 NAME
CHARACTER*20 STREET
CHARACTER*15 CITY
CHARACTER*20 STATE
CHARACTER*20 COUNTRY
CHARACTER*10 ZIP_CODE
INTEGER AGE
INTEGER MARKS(10)
NAMELIST /nl/ NAME, STREET, CITY, STATE,
+ COUNTRY, ZIP_CODE, AGE, MARKS
.
.
.
READ( un, nl )
READ( UNIT=un, FMT=nl )
READ nl
WRITE( un, nl )
WRITE( UNIT=un, FMT=nl )
PRINT nl
.exam end
.*
.beglevel
.*
.section Namelist-Directed Input (Extension)
.*
.np
The input data must be in a special format.
The first character in each record must be blank.
The second character in the first record of a group of data records
must be an ampersand (&) or dollar sign ($) immediately followed
by the
.kw NAMELIST
name.
The
.kw NAMELIST
name must be followed by a blank and must not contain any imbedded
blanks.
This name is followed by data items, optionally separated by commas.
The end of a data group is signaled by the character "&" or "$",
optionally followed by the string "END".
If the "&" character was used to start the group, then it must be
used to end the group.
If the "$" character was used to start the group, then it must be
used to end the group.
.millust begin
12345678901234567890...
&NL
item1, item2, item3,
item4, item5, ...
&END
.millust end
.np
The form of the data items in an input record is:
.begnote $break
.note Name = Constant
The name may be a variable name, an array element name, or a character
substring name.
The constant may be integer, real, complex, logical or character.
Logical constants may be in the form "T" or ".TRUE" and "F" or
".FALSE".
Character constants must be contained within apostrophes.
Subscripts and substring indices must be of integer type.
.note ArrayName = Set of Constants
The set of constants consists of constants of the type integer, real,
complex, logical or character.
The constants are separated by commas.
The number of constants must be less than or equal to the number of
elements in the array.
Successive occurrences of the same constant may be represented in the
form
.id r*constant,
where
.id r
is a non-zero integer constant specifying the number of times the
constant is to occur.
Consecutive commas within a list indicate that the values of the
array elements remain unchanged.
.endnote
.np
The variable and array names specified in the input file must appear
in the
.kw NAMELIST
list, but the order is not important.
A name that has been made equivalent to a name in the input data cannot
be substituted for that name in the
.kw NAMELIST
list.
The list can contain names of items in
.kw COMMON
but must not contain dummy argument names.
.np
Each data record must begin with a blank followed by a complete
variable or array name or constant.
Embedded blanks are not permitted in names or constants.
Trailing blanks after integers and exponents are treated as zeros.
.exam begin
&.PERSON
NAME = 'John Doe'
STREET = '22 Main St.' CITY = 'Smallville'
STATE = 'Texas' COUNTRY = 'U.S.A.'
ZIP_CODE = '78910-1203'
MARKS = 73, 82, 3*78, 89, 2*93, 91, 88
AGE = 23
&.END
.exam end
.np
The input forms acceptable to format specifications for a given type
are also acceptable for namelist-directed formatting with certain
exceptions.
.autonote
.note
Blanks are never used as zeroes and blanks embedded in constants are
not allowed except in character constants.
.note
An input item of type real or double precision must have an input
field suitable for F editing except that no fractional digits are
assumed unless a decimal point is present in the field.
Such a field will be called a
.us numeric input field.
.note
An input item of type complex or double precision complex must consist
of a left parenthesis followed by two numeric input fields separated
by a comma and followed by a right parenthesis.
The numeric input fields may be preceded or followed by blanks.
The end of record can only appear between the first numeric field and
the comma or between the comma and the second numeric field.
Note that a null value must not be used as the real or imaginary part
but may represent the entire complex constant.
.note
An input item of type logical must not include either a slash or a comma
among the optional characters allowed in L editing.
.note
An input item of type character consists of a non-empty string of
characters enclosed in apostrophes.
Apostrophes in character constants are represented by two consecutive
apostrophes without a blank or end of record separating them.
Character constants may span records.
If this is the case, the end of record does cause a blank to be inserted
into the character constant.
Note that a comma or slash in a character constant is not a value
separator.
A character input field is assigned to a character input item
as though it were a character assignment.
.endnote
.*
.section Namelist-Directed Output
.*
.np
The form of the data items in an output record is suitable for input
using a namelist-directed
.kw READ
statement.
.autonote
.note
Output records are written using the ampersand character (&), not
the dollar sign ($), although the dollar sign is accepted as an
alternative during input.
That is, the output data is preceded by "&.name" and is followed by
"&.END".
.note
All variable and array names specified in the
.kw NAMELIST
list and their values are written out, each according to
its type.
.note
Character data is enclosed in apostrophes.
.note
The fields for the data are made large enough to contain all
the significant digits.
.note
The values of a complete array are written out in columns.
.endnote
.endlevel
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -