登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
我在Linux上跑气候模式时,想从历史数据文件中读取数据做为初始条件运行模式,有一个输入和输出历史文件,程序如下:
ior=0
DATA INHST/61/,OUTHST/62/
irec=tfind+.51
c irec=tfind+.51-120.
NS=NSEG+1
READ(INHST,rec=irec) TD,NT,NXP,NYP,NSEG,NX,NY,HEQUIV,TZERO,
A TENDD,DTD,XWD,XED,YSD,YND,TDECAY,TPLMIN,TSTPRT,CHKSUM,
A NPRINT,MASKW,MWNDGF,WMXW,WMXE,WMYS,WMYN,PERIOD,YNORTH,
A YSOUTH,XWEST,NSEG,NTAPE,NREWND,NATM,
A HEADER,(AKB(I),I=1,NXP),((UB(J,I),
A J=1,NYP),I=1,NXP),((HB(J,I),J=1,NYP),I=1,NXP),(ABC(K),
A ROSS(K),TR(K),K=1,NS),((V(J,I),J=1, NYP),I=1,NXP),((UBNDY(J,K),
A J=1,NYP),K=1,NS),((HBNDY(J,K),J=1,NYP),K=1,NS),
A Q0O,UO,VO,DO,TO,U1,V1,H1,TM,HTAU
GO TO 110
99 WRITE(6,98)
98 FORMAT(1X,'READ ERROR ON INPUT HISTORY FILE')
GO TO 110
100 WRITE(6,101)
101 FORMAT(1X,'END-OF-FILE ON HISTORY INPUT')
110 WRITE(6,111) TFIND,TD,NT
111 FORMAT(1X,'RDHST SOUGHT TIME:',1X,F10.3,5X,'FOUND TIME:'1X,
A F10.3,5X,'TIMESTEP:',1X,I6/)
RETURN
C
C
ENTRY WRHIST
C
C WRITES HISTORY TAPES
ior=ior+1
ns=nseg+1
WRITE(OUTHST,rec=ior) TD,NT,NXP,NYP,NSEG,NX,NY,HEQUIV,
A TZERO,TENDD,DTD,XWD,XED,YSD,YND,TDECAY,TPLMIN,TSTPRT,
A CHKSUM,NPRINT,MASKW,MWNDGF,WMXW,WMXE,WMYS,WMYN,PERIOD,
A YNORTH,YSOUTH,XWEST,NSEG,NTAPE,NREWND,NATM,
A HEADER,(AKB(I),I=1,NXP),((UB(J,I),
A J=1,NYP),I=1,NXP),((HB(J,I),J=1,NYP),I=1,NXP),(ABC(K),
A ROSS(K),TR(K),K=1,NS),((V(J,I),J=1, NYP),I=1,NXP),((UBNDY(J,K),
A J=1,NYP),K=1,NS),((HBNDY(J,K),J=1,NYP),K=1,NS),
A Q0O,UO,VO,DO,TO,U1,V1,H1,TM,HTAU
205 WRITE(6,201) TD,NT,ior
201 FORMAT(1X,' TIME ',F10.3, ' TIMESTEP ',I6, ' WRITTEN ', 'rec=',i3)
RETURN
END
想要读取时候用的语句:
READ(5,111) FN61
111 FORMAT(A65)
OPEN(UNIT=61, FILE=FN61, FORM='UNFORMATTED',ACCESS='direct',
c 1 recl=39375)
1 recl=157500)
REWIND 61
READ(5,111) FN62
OPEN(UNIT=62, FILE=FN62, FORM='UNFORMATTED',ACCESS='direct',
c 1 recl=39375)
1 recl=157500)
REWIND 62
编译没有出错,但是运行时候报错At line 12 of file openfl3.f (unit = 61, file = 'inhst') Fortran runtime error: Cannot REWIND a file opened for DIRECT access
如果ACCESS='direct',改为默认格式,还是报错At line 40 of file nrdhist.f (unit = 61, file = 'inhst') Fortran runtime error: Record number not allowed for sequential access data transfer
本人Fortran小白,一直没有搞定,求大佬指教!!万分感谢!!
|