试试这样,如果还有问题,给一个实际的 txt 文件的真实范例。
[Fortran] 纯文本查看 复制代码 program test
implicit none !//必须写
integer i,long,lat
real c(15)
character(512)::filename
call system('dir *.txt /b >1.dat')
open(10,file='1.dat')
open(3,file ='test.out') !根据数据中的某一个数据筛选文件
do
read(10,'(a512)',iostat=i) filename
if(i/=0) exit
open(2,file=filename)
read(2,*) c
close(2)
long = c(3)
lat =c(4)
if (2600<long .and. long<3947 .and. 7319<lat .and. lat<10447) then
write(3,*)filename !将符合条件的文件名称放入指定文件夹中
end if
end do
close(3)
close(10,status='delete')
read(*,*)
end program test |