[Fortran] 纯文本查看 复制代码 program ex
implicit none
integer m,i
integer , allocatable :: days(:)
real , allocatable :: tMax(:) , tMin(:)
real :: srad
open(8,file="cn003830.wth")
!read(8,*)m !//m无法再文件中获取,需手动输入或获取文件行数减去3,得到。
m = 300 !//我假设是300个
allocate(days(m),tMax(m),tMin(m))
do i = 1,4
read(8,*)
end do !//跳过前4行
do i = 1,m
read(8,*) days(i) , srad , tMax(i) , tMin(i)
write(*,*) days(i) , tMax(i) , tMin(i)
enddo
end program ex |