[Fortran] syntaxhighlighter_viewsource syntaxhighlighter_copycode
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