[Fortran] 纯文本查看 复制代码
PROGRAM MAIN INTEGER II,JJ,KK,LL,MM
OPEN(UNIT=15,FILE='dty.bin', ACCESS='DIRECT',
=STATUS='REPLACE',FORM='UNFORMATTED',RECL=4*4)
DO 100 II=1,4
WRITE(15,REC=II) (JJ,JJ=1+(II-1)*4,II*4)
100 CONTINUE
CLOSE(15)
PRINT*,'The original'
OPEN(UNIT=15,FILE='dty.bin',ACCESS='DIRECT',
=STATUS='OLD',FORM='UNFORMATTED',RECL=4*4)
DO 200 II=1,4
READ(15,REC=II) JJ,KK,LL,MM
WRITE(*,*) JJ,KK,LL,MM
200 CONTINUE
CLOSE(15)
PRINT*,'New'
OPEN(UNIT=15,FILE='dty.bin',ACCESS='DIRECT',
=STATUS='OLD',FORM='UNFORMATTED',RECL=2*4)
DO 300 II=1,8
READ(15,REC=II) JJ,KK
WRITE(*,*) JJ,KK
300 CONTINUE
CLOSE(15)
PRINT*,'The original'
OPEN(UNIT=15,FILE='dty.bin',ACCESS='DIRECT',
=STATUS='OLD',FORM='UNFORMATTED',RECL=4*4)
DO 400 II=1,4
READ(15,REC=II) JJ,KK,LL,MM
WRITE(*,*) JJ,KK,LL,MM
400 CONTINUE
CLOSE(15)
END