我在fortran中运行下面的代码后读出来数据的总是缺两行,怎么回事啊?
program mainimplicit none
Character*4 YEAR,INTYR
integer YROD,YYYY
integer var(4176,368)
integer d,yearday,y4,y100,y400
integer i
do YROD = 1,5
YYYY = 2004+YROD
YEAR = INTYR(YYYY)
print*,YYYY
open(21,file='t-05-10.txt')
open(3,file='inputdata_t/'//YEAR) !是不是应该是'inputdata_t//YEAR啊?
! open(4,file='inputdata_rh/'//YEAR)
!open(6,file='inputdata_p/'//YEAR)
do i = 1, 4180
read(21,*) var(i,1:d)
if (var(i,1) .eq. YYYY) then
write(3,fmt="(367I8)") var(i,1:d)
end if
end do
close(21)
end do
close(3)
End
!*----------------------------------------------------------------------*
!* FUNCTIONS *
!*----------------------------------------------------------------------*
!*----------------------------------------------------------------------*
!* Integer into character *
!*----------------------------------------------------------------------*
function INTYR(YYYY)
integer length, loc, iint, YYYY
parameter (length = 4)
character INTYR*(length)
iint = YYYY
do loc = 1, length
INTYR(loc:loc) = ' '
enddo
loc = length
30 INTYR(loc:loc) = char(ichar('0') + mod(iint,10))
iint = iint/10
loc = loc - 1
if (iint .gt. 0) goto 30
return
end
注:原来的文件是一个4176行367列的文件