[Fortran] 纯文本查看 复制代码
program test
integer i,o
integer long
integer lat
real s,a
real c(15,13028),d
character(512)::filename
call system('dir *.txt /b >1.dat')
s=0.0
open(10,file='1.dat')
do
read(10,'(a)',iostat=i) filename
open(2,file=filename)
do o = 1,13028 !将文件中数据转化为二维矩阵
read(2,*)d,c(:,o)
end do
close(2)
long = c(1,3)
lat =c(1,4)
if (2600<long .and. long<3947 .and. 7319<lat .and. lat<10447) then
open(unit=3,file ='test.out') !根据数据中的某一个数据筛选文件
write(3,*)filename !将符合条件的文件名称放入指定文件夹中
close(3)
end if
if(i/=0) exit
open(11,file=filename) !获得下一个文件的名称
read(11,*) a
close(11)
s = s + a
end do
close(10,status='delete')
read(*,*)
end program
[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