UNIT
READ format, list !not covered
READ(clist) [io_list]
clist
is defined as:
[UNIT=] unit-number,
[FMT=] format
[,REC= record-number]
[,IOSTAT=ios]
[,ADVANCE=adv]
[,SIZE=integer_variable]
[,EOR=label]
[,END=label]
[,ERR=label]
READ(*,*) a, b, c
READ(5,*) line
READ(5,100) x, y, z
READ (UNIT=10,FMT=100, &
ERR=10,IOSTAT=ios)
ios
will contain an integer error number (0 otherwise).
WRITE(clist) [io_list]
clist
is defined as:
[UNIT=] unit-number,
[FMT=] format-spec
[,REC= record-number]
[,IOSTAT=ios]
[ADVANCE=adv]
[,SIZE=integer-variable]
[,EOR=label]
[,ERR=label]
WRITE(*,*)
WRITE(6,*) i,j
WRITE(6,100) i
WRITE(6,*,ERR=10) line
WRITE(UNIT=file1,FMT=100,&
REC=recordnumber, ERR=10) &
newline
OPEN (unit, [olist] )
olist
, may be empty or a combination of the following options
FILE=filename
where filename is a valid filename
STATUS=st
st may be 'OLD'
, 'NEW'
, 'REPLACE'
, 'SCRATCH'
or 'UNKNOWN'
ERR=label
Go to label if an error occurs.
IOSTAT=ios
ios is an integer variable which is set to zero if the statement is executed successfully or to an implementation dependent constant otherwise.
FORM=fm
fm may be 'FORMATTED'
or 'UNFORMATTED'
, the default is 'FORMATTED'
for sequential files and 'UNFORMATTED'
for direct access files.
ACCESS=acc
acc may be 'SEQUENTIAL'
or 'DIRECT'
RECL=rl
rl is the maximum record length (positive integer) for a direct access file. For formatted files this is the number of characters and for unformatted it is usually the number of bytes or words (system dependent).
BLANK=bl
bl is either 'NULL'
or 'ZERO'
POSITION=pos
pos may be 'ASIS'
, 'REWIND'
or 'APPEND'
. Defaults to ASIS
.
PAD=pad
pad may be 'YES'
or 'NO'
DELIM=del
del may be 'APOSTROPHE'
or 'QUOTE'
or 'NONE'
. Defaults to 'NONE'
.
ACTION=act
act may be 'READ'
, 'WRITE'
or 'READWRITE'
. Default is processor dependent.
OPEN (UNIT=10,FILE='fibonacci.out')
OPEN (UNIT=11,FILE='fibonacci.out',&
STATUS='NEW',ERR=10)
.......
10 WRITE(6,*) 'Error opening file:&
&fibonacci.out.'
OPEN (UNIT=12, STATUS='OLD',&
FILE='student.records',&
ACCESS='DIRECT',RECL=200,&
FORM='FORMATTED',&
ERR=20, IOSTAT=IOS)
........
20 IF (ERR .GE. 0) THEN
WRITE(6,*) 'Error opening file:&
&student.records.'
WRITE(6,*) 'IOS = ',IOS
ENDIF
STOP
CLOSE([UNIT=]u [,IOSTAT=ios]
[,ERR=label] [,STATUS=st])
STATUS
may be given the values 'KEEP'
or 'DELETE'
but 'KEEP'
may not be used for a file opened as 'SCRATCH'
CLOSE(10)
CLOSE(UNIT=nunit, ERR=10)
CLOSE(10,STATUS='DELETE',ERR=10)
INQUIRE (inquiry-list)
where inquiry-list must contain either
FILE=fname
or
UNIT=unum
plus any of the following
EXIST=lex !true or false
OPENED=lod !true or false
NUMBER=unum !unit number
NAME=fnm !filename
ACCESS=acc !'DIRECT' or
!'SEQUENTIAL'
SEQUENTIAL=seq !'YES or 'NO'
DIRECT=dir !'YES' or 'NO'
FORMATTED=fmt !'YES' or 'NO'
UNFORMATTED=unfmt !'YES' or 'NO'
FORM=frm !'FORMATTED' or
!'UNFORMATTED'
NEXTREC=recn !number of next record
RECL=recl !record length
OPEN (UNIT=10,FILE='STAFF.RECORDS',&
RECL=200, ACCESS='DIRECT')
READ(UNIT=10,FMT=100,REC=20)&
staffrecord
WRITE(UNIT=10,FMT=100,REC=20) &
staffrecord
ERR
and IOSTAT
keywords