program wwlln_shiyan
implicit none
!声明变量
character(len=512)::cRead
character(len=20)::filename,DYfilename
character(len=20)::wwlln_date,wwlln_time
real::lat,lon
real::timingerror
integer::station
integer::status1=0
integer,parameter::fileid1=12,fileid2=13
integer::i
logical alive
!循环读取文件
OPEN(14,file="filename.txt",status="old")
OPEN(15,file="DYfilename.txt",status="old")
do i=20040810,20151130,1
READ(14,*)filename
READ(15,*)DYfilename
inquire(file=filename,exist=alive)
if (alive) then
!读取数据
OPEN(11,file=filename,status='old',form='formatted')
OPEN(13,file=DYfilename,status='replace')
do while(.true.)
READ(11,"(A512)",iostat=status1)cRead
if (status1/=0) exit
CALL parserRead(cRead)
if((lat>21).AND.(lat<34).AND.(lon>97).AND.(lon<111)) then
write(*,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
write(13,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
end if
end do
CLOSE(11)
CLOSE(13)
else
CYCLE
end if
end do
CLOSE(14)
CLOSE(15)
STOP
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
end program wwlln_shiyan
部分数据.png (18.89 KB, 下载次数: 304)
error.png (10.03 KB, 下载次数: 333)
fcode 发表于 2020-5-21 12:02
READ(c,*)wwlln_date,wwlln_time,lat,lon,timingerror,station
这里读取的第5项,也就是 timingerror,对 ...
Zhuming 发表于 2020-5-21 17:19
回复加不了图片 ,我复制下来,以下是命令行提示的:
......
2014/04/27 03:44:46.595573 ...
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |