HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
DECODE (extension)
Chapter 10320
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.
in-list
is a comma-separated list of data items for input. The data items can
include expressions and implied-DO lists.
Description
The DECODE statement is an HP extension that is provided for compatibility with other
versions of Fortran. The internal-I/O capabilities of the standard READ statement provide
similar functionality and should be used to ensure portability.
The DECODE statement translates formatted character data into its binary (internal)
representation.
Examples
The following example program illustrates the DECODE statement:
PROGRAM decode_example
CHARACTER(LEN=20) :: buf
INTEGER i, j, k
buf = 'XX1234 45 -12XXXXXX'
DECODE (15,'(2X,3I4,1X)', buf) i, j, k
! The equivalent READ statement is:
! READ (buf, '(2X,3I4,1X)') i, j, k
PRINT *, i, j, k
END PROGRAM decode_example
When compiled and executed, this program produces the following output:
1234 45 -12
Related statements
ENCODE and READ