给您带来的不便深表歉意,我现在重新提交了代码。问题:我正在尝试编写一个从二进制 (.DAT) 文件中读取沉淀的程序。它计算每个网格的降水值,并且对于每个网格,最大值月份作为输出返回。例如,如果 6 月份的最高值是 25,那么我们的输出值应该是“Jun”。
implicit none
integer,parameter :: ix=44,iy=27,nyr=12
integer :: ntot
real :: v_obs(ix,iy,nyr),TestVal,b(ix,iy,nyr),wet(ix,iy)
real:: Mon(12),Y(12),missing_obs,missing_mod,missing
integer :: ii,jj,i,j,k,ik,jk,irec,m,n
character (130) dir,jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec
data missing_obs/-999000000/
data missing/-999./
open(21,file='C:/Fortran/test-dat.dat',access='direct',recl=ix*iy*nyr,form='unformatted')
open(23,file='C:/wet-month.dat',access='direct',recl=ix*iy*nyr,form='unformatted')
irec=1
Do j=1,nyr
read(21,rec=irec) ((v_obs(ii,jj,j),ii=1,ix),jj=1,iy)
ntot=0
do ik=1,nyr
ntot=ntot+1
Y(ik)=v_obs(ii,jj,ik)
enddo
if (Y(ik) .eq. missing_obs)then
wet=-999
go to 199
endif
enddo
Mon(1)=v_obs(ii,jj,1)
Mon(2)=v_obs(ii,jj,2)
Mon(3)=v_obs(ii,jj,3)
Mon(4)=v_obs(ii,jj,4)
Mon(5)=v_obs(ii,jj,5)
Mon(6)=v_obs(ii,jj,6)
Mon(7)=v_obs(ii,jj,7)
Mon(8)=v_obs(ii,jj,8)
Mon(9)=v_obs(ii,jj,9)
Mon(10)=v_obs(ii,jj,10)
Mon(11)=v_obs(ii,jj,11)
Mon(12)=v_obs(ii,jj,12)
TestVal=MAXVAL(Mon)
If (TestVal .eq. Mon(1)) then
wet=jan
else if (TestVal .eq. Mon(2)) Then
wet=feb
else if (TestVal .eq. Mon(3)) Then
wet=mar
else if (TestVal .eq. Mon(4)) Then
wet=apr
else if (TestVal .eq. Mon(5)) Then
wet=may
else if (TestVal .eq. Mon(6)) Then
wet=jun
else if (TestVal .eq. Mon(7)) Then
wet=jul
else if (TestVal .eq. Mon(8)) Then
wet=aug
else if (TestVal .eq. Mon(9)) Then
wet=sep
else if (TestVal .eq. Mon(10)) Then
wet=oct
else if (TestVal .eq. Mon(11)) Then
wet=nov
else if (TestVal .eq. Mon(12)) Then
wet=dec
endif
199 continue
irec=1
do k=1,nyr
write(23,rec=irec)((wet(ii,jj),ii=1,ix),jj=1,iy)
irec=irec+1
enddo
close(21)
close(22)
end
编译错误说
You cannot assign an expression of type CHARACTER(LEN=130) to a variable of type REAL(KIND=1)" i.e: "wet=jan".
但我想将数据保存为每个网格点的字符。请帮助解决此错误。