这样做,就不需要替换逗号为空格了。
[Fortran] 纯文本查看 复制代码 program wwlln_shiyan
implicit none
!声明变量
character(len=512)::cRead
character(len=20)::filename
character(len=20)::wwlln_date,wwlln_time
real::lat,lon
real::timingerror
integer::i
!读取文件
filename='A20040810.txt'
OPEN(11,file=filename,status='old',form='formatted')
OPEN(12,file='shiyan.txt',status='replace')
READ(11,"(A512)") cRead
call parserRead(cRead)
write(*,*)wwlln_date,wwlln_time,lat,lon,timingerror
write(12,*)wwlln_date,wwlln_time,lat,lon,timingerror
CLOSE(11)
CLOSE(12)
contains
Subroutine parserRead(c)
character(len=*) :: c
integer :: i
do i = 1 , len_trim(c)
if( c(i:i) == '/' ) c(i:i) = '|'
end do
read(c,*) wwlln_date,wwlln_time,lat,lon,timingerror
do i = 1 , len_trim(wwlln_date)
if( wwlln_date(i:i) == '|' ) wwlln_date(i:i) = '/'
end do
End Subroutine parserRead
end program wwlln_shiyan |