我正在阅读用不同程序编写的二进制文件.开放和阅读的陈述似乎是成功的,我在之前的帖子中得到了帮助.但是,读入的数据与文件不匹配.我已经初始化了2D数组但是在读入文件之后,数组不保存数据,但看起来是一个未初始化的数组.我已经发布了下面的代码,用于读取和打印出数组.有什么想法吗?
allocate(dummy(imax,jmax))
dummy = 0.0
open(unit=io, file=trim(input), access='direct', iostat=ioer, &
status='old', action='READ', recl=imax*jmax*4)
if(ioer/=0) then
print*, 'Cannot open file'
else
print*,'success opening file'
end if
j=0
k=0
read(unit=io,rec=1,iostat=ioer) dummy!(j,k)
if(ioer/=0) then
print*, 'Cannot open file'
else
print*,'success opening file'
end if
size: do j=1, imax
do k=1, jmax
if(dummy(j,k) > 0.) print*,'i-',j,'j-',k,'frp-',dummy(j,k)
end do
end do size
print*,'j-',j,'k-',k
Run Code Online (Sandbox Code Playgroud)
这是原始写的:
out_file = trim(output_dir)//'SEVIRI_FRP_.08deg_'//trim(season)//'.bin'
print*, out_file
print*, i_max,' i_max,',j_max,' j_max'
open (io, file = out_file, access = 'direct', status = 'replace', recl …Run Code Online (Sandbox Code Playgroud)