Fortran文件讀寫--查找內容


program ex
implicit none
character(len=40) A(3000),B(3000),C(3000)  !A異常、B已開挖、C需標記
integer i,j,N1,N2,count   !N1是10號文件行數,N2是11號文件行數,count是計數器

open(unit=10,file="10異常焊口編號列表.txt")   !異常焊口編號列表
open(unit=11,file="11以開挖焊口列表.txt")     !以開挖焊口列表
open(unit=12,file="12異常焊口中已開挖焊口編號.txt")

read(10,*)N1   !讀取10號文件
DO i=1,N1,1
read(10,*) A(i)
end do

read(11,*)N2    !讀取11號文件
DO i=1,N2,1
read(11,*) B(i)
end do

!開始比對(從異常到全部開挖去比對)
DO i=1,N1,1
  DO j=1,N2,1
     if ( trim(A(i))==trim(B(j)) ) then
     write(*,*)A(i),"   以開挖"
     write(12,*)A(i)
     exit
     end if
  end do
end do

write(*,*)"按任意鍵結束"
read(*,*)

end program

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM