登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 云一林 于 2020-4-19 22:38 编辑
请问谁知道为什么这个热源计算的程序会数组越界? 参考帖子如下: Fortran程序修改如下:修改部分已标记出来 !the yrev must be noted. implicit none integer,parameter :: NX=144,NY=71,NL=8,NT=696 real ,parameter :: PI=3.1415926,RR=6371229.0 real ,parameter :: RAD=PI/180.0,DD=RR*RAD*2.5,ck=0.286,gama=0.0065 real ,parameter :: rd=287.0,g=9.80616, dk=g/(rd*gama), WTt=0.0 real ,parameter :: DT=24*3600.0, CP=1004.0, lh=2501000.0
!INPUT logical :: yrev=.false.,smooth=.FALSE. !yrev=.true. 数据中y是反向的,如果yrev=.false.,则不改变方向 real :: pres(NX,NY) real :: u(nx,ny,nl),v(nx,ny,nl),t(nx,ny,nl),W(NX,NY,NL),q(NX,NY,NL) ! H(NX,NY,NL)
!TEMP REAL :: temp(nx,73,nl),OROG1(NX,73) REAL :: gtmp(nx,ny,nl) real :: TH(NX,NY,NL),tf(nx,ny,nl) real :: ft1(nx,ny,nl),ft3(nx,ny,nl) REAL :: FF(NX,NY),GG(NX,NY) real :: ILAY(NX,NY) REAL :: PP(NL)=(/1000., 925., 850., 700., 600., 500., 400., 300./)
!OUTPUT real :: ft(nx,ny,nl),fv(nx,ny,nl),fw(nx,ny,nl),q2(nx,ny) real :: Q1(NX,NY),HT(NX,NY,NL),ffG(nx,ny,nl) real :: wg(nx,ny,nl),ug(nx,ny,nl),tg(nx,ny,nl)
!PROCESS integer :: I,J,K,L,ip INTEGER :: IREC real :: dx,dy,dp,ss,sx,si,sj,l1
open(11,file='pres.grd',form='unformatted',access='direct',action='read',recl=nx*73) OPEN(13,FILE='uwnd.grd',FORM='UNFORMATTED',ACCESS='DIRECT',action='read',RECL=NX*73) OPEN(14,FILE='vwnd.grd',FORM='UNFORMATTED',ACCESS='DIRECT',action='read',RECL=NX*73) OPEN(15,FILE='air.grd',FORM='UNFORMATTED',ACCESS='DIRECT',action='read',RECL=NX*73) OPEN(16,FILE='q8.grd',FORM='UNFORMATTED',ACCESS='DIRECT',action='read',RECL=NX*73) OPEN(17,FILE='omega.grd',FORM='UNFORMATTED',ACCESS='DIRECT',action='read',RECL=NX*73)
!write data into: OPEN(20,FILE='Q\Q1TNWNS.grd',FORM='binary') OPEN(21,FILE='Q\q1vnwNS.grd',FORM='binary') OPEN(22,FILE='Q\q1wnwNS.grd',FORM='binary') OPEN(24,FILE='Q\q2tnwNS.grd',FORM='binary') OPEN(25,FILE='Q\q2vnwNS.grd',FORM='binary') OPEN(26,FILE='Q\q2wnwNS.grd',FORM='binary') OPEN(27,FILE='Q\q1&2nwNS.grd',FORM='binary') OPEN(28,FILE='Q\q1l17nwNS.grd',FORM='binary') OPEN(29,FILE='Q\q2l17nwNS.grd',FORM='binary')
LOOPDAY: DO K=1,nt print *,'Begin time = ',k HT =-9.99E33 !Q1 ffG =-9.99e33 !Q2 tg =-9.99e33 !(1.1) ug =-9.99e33 !(1.2) wg =-9.99e33 !(1.3) ft =-9.99e33 !(2.1) fv =-9.99e33 !(2.2) fw =-9.99e33 !(2.3) !!!!!get data from files read (11,rec=k)((orog1(i,j),i=1,nx),j=1,73) pres(:,1:71)=orog1(:,2:72) if (yrev) then pres(:,1:71)=pres(:,71:1:-1) endif LOOPLEV1: DO L=1,NL IREC=L+NL*(K-1)
READ(13,REC=IREC)((temp(I,J,L),I=1,NX),J=1,73) u(:,1:71,L)=temp(:,2:72,l)
READ(14,REC=IREC)((temp(I,J,L),I=1,NX),J=1,73) v(:,1:71,l)=temp(:,2:72,l)
READ(15,REC=irec)((temp(I,J,L),I=1,NX),J=1,73) t(:,1:71,l)=temp(:,2:72,l)
READ(17,REC=irec)((temp(I,J,L),I=1,NX),J=1,73) w(:,1:71,l)=temp(:,2:72,l)/100.0
if (yrev) then ! h(:,1:71,l) = h(:,71:1:-1,l) u(:,1:71,l) = u(:,71:1:-1,l) v(:,1:71,l) = v(:,71:1:-1,l) t(:,1:71,l) = t(:,71:1:-1,l) w(:,1:71,l) = w(:,71:1:-1,l) endif if (smooth) then FF(:,:)=u(:,:,l) call smth9(nx,ny,FF,GG) u(:,:,l)=gg(:,:)
FF(:,:)=v(:,:,l) call smth9(nx,ny,FF,GG) v(:,:,l)=GG(:,:)
FF(:,:)=t(:,:,l) call smth9(nx,ny,FF,GG) t(:,:,l)=GG(:,:)
FF(:,:)=w(:,:,l) call smth9(nx,ny,FF,GG) w(:,:,l)=GG(:,:) endif ENDDO looplev1
loopq1:do l=1,8 irec=l+(k-1)*8 READ(16,REC=irec)((temp(I,J,L),I=1,NX),J=1,73) q(:,1:71,l)=temp(:,2:72,l) if (yrev) then q(:,1:71,l) = q(:,71:1:-1,l) endif if (smooth) then FF(:,:)=q(:,:,l) call smth9(nx,ny,FF,GG) q(:,:,l)=GG(:,:) endif enddo loopq1
IF(K > 1)THEN looplev2: DO L=1,NL irec=l+nl*(k-2) READ(15,REC=irec)((temp(I,J,L),I=1,NX),J=1,73) tf(:,1:71,l)=temp(:,2:72,l)
if (yrev) then tf(:,1:71,l) = tf(:,71:1:-1,l) endif
if (smooth) then FF(:,:)=tf(:,:,l) call smth9(nx,ny,FF,GG) tf(:,:,l)=GG(:,:)
endif ENDDO looplev2 loopq2:do l=1,8 irec=l+8*(k-2) READ(16,REC=irec)((temp(I,J,L),I=1,NX),J=1,73) ft1(:,1:71,l)=temp(:,2:72,l) if (yrev) then ft1(:,1:71,l) = ft1(:,71:1:-1,l) endif if (smooth) then FF(:,:)=ft1(:,:,l) call smth9(nx,ny,FF,GG) ft1(:,:,l)=GG(:,:) endif enddo loopq2 ENDIF
IF(K < NT)THEN looplev3: DO L=1,NL irec=l+nl*k READ(15,REC=irec)((temp(I,J,L),I=1,NX),J=1,73) th(:,1:71,l)=temp(:,2:72,l)
if (yrev) then th(:,1:71,l) = th(:,71:1:-1,l) endif if (smooth) then FF(:,:)=TH(:,:,l) call smth9(nx,ny,FF,GG) th(:,:,l)=GG(:,:) endif ENDDO looplev3 loopq3:do l=1,8 irec=l+8*k READ(16,REC=irec)((temp(I,J,L),I=1,NX),J=1,73) ft3(:,1:71,l)=temp(:,2:72,l) if(yrev) then ft3(:,1:71,l) = ft3(:,71:1:-1,l) endif if (smooth) then FF(:,:)=ft3(:,:,l) call smth9(nx,ny,FF,GG) ft3(:,:,l)=GG(:,:) endif enddo loopq3 ENDIF
! write(30,rec=irec)(((gtmp(i,j,l),i=1,nx),j=2,ny-1),l=1,nl) write(20)(((tg(I,J,L),I=1,NX),J=2,NY-1),l=1,nl) write(21)(((ug(I,J,L),I=1,NX),J=2,NY-1),l=1,nl) write(22)(((wg(I,J,L),I=1,NX),J=2,NY-1),l=1,nl) write(24)(((ft(I,J,L),I=1,NX),J=2,NY-1),l=1,8) write(25)(((fv(I,J,L),I=1,NX),J=2,NY-1),l=1,8) write(26)(((fw(I,J,L),I=1,NX),J=2,NY-1),l=1,8) write(28)(((ht(I,J,L),I=1,NX),J=2,NY-1),l=1,nl) write(29)(((ffG(I,J,L),I=1,NX),J=2,NY-1),l=1,8) ! write(27)((q1(I,J),I=1,NX),J=2,NY-1) write(27)((q2(I,J),I=1,NX),J=2,NY-1)
WRITE(6,*)'end TIME=',K
ENDDO LOOPDAY
CLOSE(12);CLOSE(13);CLOSE(14);CLOSE(15);close(16) CLOSE(20);CLOSE(21);CLOSE(22);close(24);close(25) close(26);close(27);close(28);close(29) stop
end
Fortran程序说明:程序太长,数据处理过程部分删除了,删除部分只涉及到字母,不涉及到数字,出错部分应该不是出在删除部分。为了跟原程序对的上,只修改了高度层和时间层,x,y层均没有改变,所用数据有6个,其中uwnd.grd、vwnd.grd、air.grd、q8.grd、omega.grd均为8层, 其中air.grd的ctl如下: dset e:\ncep\air.grd undef -9.96921E+36 xdef 144 linear 0.0 2.5 ydef 71 linear -87.5 2.5 zdef 8 levels 1000 925 850 700 600 500 400 300 tdef 696 linear 01jan1960 1mon vars 1 air 0 99 Endvars 其余类似 Pres.grd的ctl如下: dset e:\ncep\pres.grd undef -9.96921E+36 xdef 144 linear 0.0 2.5 ydef 71 linear -87.5 2.5 zdef 1 levels 0 tdef 696 linear 01jan1960 1mon vars 1 pres 0 99 Endvars
Fortran运行结果: Begin time = 1
forrtl: severe (161): Program Exception - array bounds exceeded Image PC Routine Line Source q1.exe 00407609 Unknown Unknown Unknown
Incrementally linked image--PC correlation disabled. Press any key to continue 显示数组越界,请问谁知道问题出在哪里?越界在什么地方?
|