我有一个包含以下信息的二进制文件:
ifile.dat
big_endian sequential, nx=530, ny= 427, t=1, 4 variables
我想用Fortran程序阅读它并写入文本文件。我的试用f90计划是:
bin_read.f90:
INTEGER,PARAMETER :: nx=530, ny=427
REAL :: v1(nx,ny),v2(nx,ny),v3(nx,ny),v4(nx,ny)
OPEN(10, file= 'ifile.dat', form = 'unformatted', &
&access='sequential',convert='big_endian')
OPEN(11, file= 'ofile.txt', form = 'formatted', &
&status='unknown')
DO j = 1, ny
DO i = 1, nx
READ(10,*)v1(i,j),v2(i,j),v3(i,j),v4(i,j)
WRITE(11,1)v1(i,j),v2(i,j),v3(i,j),v4(i,j)
1 FORMAT(4(1X,f8.3))
ENDDO
ENDDO
STOP
END
当我在编译后执行它时,我收到以下消息:
At line 11 of file bin_read.f90 (unit = 10, file = 'ifile.dat')
Fortran runtime error: Format present for UNFORMATTED data transfer