FTN3000_66 Directive [ HP FORTRAN 77/iX Reference ] MPE/iX 5.0 Documentation
HP FORTRAN 77/iX Reference
FTN3000_66 Directive
The FTN3000_66 directive allows you to specify FORTRAN 66/V features for
compatibility with FORTRAN 77.
Syntax
[LOGICALS]
$FTN3000_66 [IO ] [ON ]
[CHARS ] [OFF]
Default Off.
Location The FTN3000_66 directive can appear anywhere in a
program unit.
Toggling/ Duration You cannot turn off FTN3000_66 before an entry
point if FTN3000_66 has been turned on for the
primary entry point because multiple entries into a
routine must have the same character passing method
as the primary entry for that routine.
The following example shows an illegal use of
FTN3000_66:
$FTN3000_66 CHARS ON
SUBROUTINE routine1(a,b)
CHARACTER*10 a,b,c
WRITE(6,*) a
$FTN3000_66 CHARS OFF ! ILLEGAL
ENTRY ent1(b,c)
WRITE(6,*) b,c
END
FTN3000_66 CHARS
When FORTRAN 77 passes character items as arguments to a subroutine or
function, the item is passed by descriptor. That is, the item is passed
with a byte address and a length by value. Other languages, such as HP
Pascal/iX and HP COBOL II/iX, pass character items by reference without
the length. If the FTN3000_66 CHARS directive is turned on in HP FORTRAN
77/iX, character items are passed by reference without the length by
value. This makes character passing compatible between other languages
and FORTRAN 77.
When the FTN3000_66 directive is turned on, CHARACTER*(*) types are only
permitted in the main program.
FTN3000_66 IO
The FTN3000_66 IO directive creates compatibility with FORTRAN 66/V
files. This compatibility is achieved by reading and writing CHARACTER
items in unformatted files in two-byte blocks and by performing multiple
physical I/O operations for I/O lists that request them.
When reading and writing CHARACTER items in unformatted files in two-byte
blocks, each odd-length item is padded with a trailing blank. For
example, a CHARACTER*5 item is followed by a blank before the next data
item so that the following item will begin on an even 16-bit boundary.
The default does not leave any space between data items in unformatted
files.
The following is an example of a program using the FTN3000_66 IO
directive to write CHARACTER items in an unformatted file in two-byte
blocks:
Example
$FTN3000_66 IO
CHARACTER CH*5, CH2
OPEN (1, FILE='MYFILE', STATUS='NEW', ACCESS='DIRECT',
> FORM='UNFORMATTED', RECL=8)
CH = "AZWXY"
CH2 = "B"
WRITE(1, REC=1)CH,CH2
STOP
END
The following command displays the binary output of the above program in
hexadecimal:
:fcopy from=MYFILE; to=; hex
MYFILE RECORD 0 (%0, #0)
Output:
A Z W X Y _ B _
0000: 415A 5758 5920 4220
The underscore represents the blank inserted by the FTN3000_66 IO option
to pad the first item (CH) to an even (16-bit) word boundary.
When performing multiple physical I/O operations for I/O lists that
request them, the I/O library performs unformatted sequential READs and
WRITEs of length longer than the file's record length to (or from) as
many records as necessary. These records are used in sequence until the
entire list of elements has been transferred. The default does not allow
the I/O list items' combined length to exceed the record length.
NOTE If the storage required exceeds the size of the record, transfer
continues into the next record. This usually leaves part of that
next record unused.
The following example shows the I/O library performing unformatted
sequential READs and WRITEs of length longer than the file's record
length to (and from) as many records as necessary.
Example
$FTN3000_66 IO
PROGRAM sofx1c
INTEGER*4 iarr(256)
INTEGER*4 i4(18), i5, i6, i7
OPEN (12,file='rsofx1c', FORM='UNFORMATTED', ACCESS='DIRECT',
> RECL=74) ! create file with 18.5 32-bit words long
CLOSE (12, status='KEEP')
OPEN (12,FILE='rsofx1c', FORM='UNFORMATTED', ACCESS='SEQUENTIAL')
WRITE (12) iarr
REWIND 12
READ (12) i4, i5, i6, i7 !read multiple records in pieces
REWIND 12
READ (12) iarr ! full array read
END
The following file description shows that the WRITE above has written 14
physical records to hold the data in the array iarr. Twelve bytes at the
end of the last physical record are unused:
:listf rsofx1c,2
FILENAME CODE ------------LOGICAL RECORD----------- ----SPACE----
SIZE TYP EOF LIMIT R/B SECTORS #X MX
RSOFX1C 37W FB 14 4095 3 43 1 32''
FTN3000_66 LOGICALS
FTN3000_66 LOGICALS causes the FORTRAN 77 compiler to generate and use
the same internal representations for logical data as in FORTRAN 66/V.
These specific internal representations are also used by other non-HP
machines. When FTN3000_66 LOGICALS is turned on, LOGICAL*2 is
represented by two whole bytes and LOGICAL*4 is represented by four whole
bytes. With FTN3000_66 logicals, -1 represents the value .TRUE. and zero
represents the value .FALSE..
In addition to allowing compatibility of logical data, FTN3000_66
LOGICALS allows logical data to be mixed with numeric types and be
treated as integers when they appear in a numeric context.
MPE/iX 5.0 Documentation