[Fortran] 纯文本查看 复制代码 program example
implicit none
character(len=64)::str
integer::a,b,ierr,i,c,d
open(10,file='test1.txt')
open(11,file='test2.txt')
do
read(10,"(a64)",iostat=ierr) str
if(ierr/=0) exit
if(index(str,'*Nset')==ierr.and.index(str,'instance')/=ierr)then
write(11,'(a)')str((index(str,'nset')+5):(index(str,'instance')-2))
read(str,*)c
write(11,*)c
else
end if
end do
! endif
! if (str(1:17)=='*Nset, nset=Set-1') then
! read(10,*) a
! end if
! if (str(1:17)=='*Nset, nset=Set-2') then
! read(10,*) b
! end if
! if(str(1:9)=='*Boundary')then
! do
! read(str(:),*,iostat=ierr)c,d
! if(ierr/=0) exit
! if(d<=3)then
! write(11,"(i1,3x,a2,i1)")a,'TR',d
! end if
! if(3<d)then
! write(11,"(i1,3x,a2,i1)")b,'TR',d
! end if
! end do
! end if
close(10)
close(11)
end program example |