HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
ENCODE (extension)
Chapter 10 339
specifies the label of the executable statement to which control passes if an
error occurs during statement execution.
IOSTAT=
integer-variable
returns the I/O status after the statement executes. If the statement
successfully executes,
integer-variable
is set to zero. If an end-of-file
record is encountered without an error condition, it is set to a negative
integer. If an error occurs,
integer-variable
is set to a positive integer
that indicates which error occurred.
out-list
is a comma-separated list of data items for output. The data items can
include expressions and implied-DO lists (see “Implied-DO loop” on
page 223).
Description
The ENCODE statement is a nonstandard feature of HP Fortran and is provided for
compatibility with other versions of Fortran. The
internal-I/O capabilities of the standard WRITE statement provide similar functionality and
should be used to ensure portability.
The ENCODE statement translates data from its internal (binary) representation into
formatted character data.
Examples
The following example program uses the ENCODE statement to write to an internal file:
PROGRAM encode_example
CHARACTER(LEN=20) :: buf
ENCODE (LEN(buf), '(2X, 3I4, 1X)', buf) 1234, 45, -12
PRINT *, buf
END PROGRAM encode_example
When compiled and executed, this program outputs the following (where
b
represents a blank
character):
bb
1234
bb
45
b
-12
bbbbb
Related statements
DECODE and WRITE
Related concepts
For related information, see the following: