READ:matrix:UNFORMATTED
real*8 x(100,10)
do j = 1, 10
write(unit)(x(i,j),i=1,100) ! written by record ( 10 records )
end do
write(unit)x ! written as a stream ( 1 record )
Syntax: READ\MATRIX\UNFORMATTED file{\n} (frmt) matrix nr { nc }
READ\MATRIX\UNFORMATTED\FLIPPED file{\n} (frmt) matrix nc { nr }
The frmt prescription must be enclosed in parenthesis, ( and ).
The frmt codes R4, R8, I1, I2, I4, L1, L4, Xn specify that the data is
to be read by record, and indicate the data type and the number of
bytes for each value in each record. The Xn code specifies skipping
over n bytes. For example, (20R4) indicate 80 bytes per record: 20
REAL*4 values. All values are converted to REAL*8 for internal
storage. It is not necessary to enter the number of columns, ncols,
as records will be read until an end of file is reached.
Syntax: READ\MATRIX\UNFORMATTED file{\n} (frmt) matrix nr nc
READ\MATRIX\UNFORMATTED\-FLIPPED file{\n} (frmt) matrix nc nr
The frmt prescription must be enclosed in parenthesis, ( and ).
The frmt codes 1B, 2B, 4B, 8B specify that the data is to be read as a
stream, and indicate the data type only. The number of values to read
is indicated by the number of rows, nrows, and the number of columns,
ncols, both of which are required. All values are converted to REAL*8
for internal storage. For example:
READ\MATRIX\UNFORMATTED DUM.DAT (4B) M 10 100
indicate that 1000 REAL*4 values are to be stream read into matrix M
with 10 rows and 100 columns.
REAL*8 X(7,5)
INTEGER*2 NR, NC
DATA NR /7/, NC /5/
DO J = 1, 5
DO I = 1, 7
X(I,J) = 10*I+J
END DO
END DO
OPEN(UNIT=20,FILE='DUM.DAT',FORM='UNFORMATTED')
WRITE(20)NR,NC ! first record contains dimensions
WRITE(20)X ! stream write the array
...
the commands: READ\UNFORMATTED\SCALARS DUM.DAT (2I2) NR NC
READ\UNFORMATTED\MATRIX DUM.DAT\2 (8B) M NR NC
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
result in the matrix M = 41 42 43 44 45
51 52 53 54 55
61 62 63 64 65
71 72 73 74 75
REAL*8 X(7,5)
INTEGER*2 NR
DATA NR /7/
DO J = 1, 5
DO I = 1, 7
X(I,J) = 10*I+J
END DO
END DO
OPEN(UNIT=20,FILE='DUM.DAT',FORM='UNFORMATTED')
WRITE(20)NR ! first dimension, number of rows
DO J = 1, 5
WRITE(20)(X(I,J),I=1,7) ! write by records ( 5 records )
END DO
...
the commands: READ\UNFORMATTED\SCALARS DUM.DAT (I2) NR
FORMAT = `('//RCHAR(NR)//`R8)'
READ\UNFORMATTED\MATRIX DUM.DAT\2 FORMAT M NR
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
result in the matrix M = 41 42 43 44 45
51 52 53 54 55
61 62 63 64 65
71 72 73 74 75