program fkk
implicit none
character(len=512)::cRead
! character(len=20)::filename,DYfilename
character(len=20)::wwlln_date,wwlln_time
real::lat,lon
character(len=5)::timingerror
character(len=2)::station
integer::status1=0
integer::month,month1
integer::i,j
open(11,file='2014.txt',status='old',form='formatted')
open(12,file='record.txt',status='replace')
OPEN(21,file='month1.txt',status='replace',form='formatted')
OPEN(22,file='month2.txt',status='replace',form='formatted')
OPEN(23,file='month3.txt',status='replace',form='formatted')
OPEN(24,file='month4.txt',status='replace',form='formatted')
OPEN(25,file='month5.txt',status='replace',form='formatted')
OPEN(26,file='month6.txt',status='replace',form='formatted')
OPEN(27,file='month7.txt',status='replace',form='formatted')
OPEN(33,file='month8.txt',status='replace',form='formatted')
OPEN(29,file='month9.txt',status='replace',form='formatted')
OPEN(30,file='month10.txt',status='replace',form='formatted')
OPEN(31,file='month11.txt',status='replace',form='formatted')
OPEN(32,file='month12.txt',status='replace',form='formatted')
do while(.true.)
READ(11,"(A512)",iostat=status1)cRead
if (status1/=0) exit
CALL parserRead(cRead)
! write(*,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
! READ(wwlln_date(1:4),"(I4)")year
! write(*,*)year
write(*,*) LEN_TRIM(wwlln_date)
if(LEN_TRIM(wwlln_date)/=10) then !这里是因为我的文件中大部分日期格式例如:2014/08/12,但有的月份是2014/8/10或者2014/8/1
CALL specialread(wwlln_date)
write(12,*)month1
else
READ(wwlln_date(6:7),"(I2)")month
write(*,*)wwlln_date,month
end if
if(month==1) write(21,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
if(month==2) write(22,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
if(month==3) write(23,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
if(month==4) write(24,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
if(month==5) write(25,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
if(month==6) write(26,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
if(month==7) write(27,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
if(month==8) write(33,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
if(month==9) write(29,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
if(month==10) write(30,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
if(month==11) write(31,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
if(month==12) write(32,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
do i=21,32,1
j=i-20
if(month1==j) write(i,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
end do
end do
CLOSE(11)
CLOSE(12)
contains
!调用子程序
subroutine parserRead(c)
character(len=*)::c
integer::j
do j=1,LEN_TRIM(c)
if (c(j:j)=="/") c(j:j)="|"
end do
READ(c,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
do j=1,LEN_TRIM(wwlln_date)
if (wwlln_date(j:j)=="|") wwlln_date(j:j)="/"
end do
end subroutine parserRead
subroutine specialread(d)
character(LEN=*)::d
READ(d(6:6),"(I1)")month1
end subroutine specialread
end program
QQ截图20200620184536.png (53.84 KB, 下载次数: 212)
914.83 KB, 下载次数: 0
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |