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
258 Bytes, 下载次数: 2
Program www_fcode_cn
Implicit None
Character (Len=64) :: str
Integer :: ierr, i , j
Type NSET
Character(len=8) :: cName
Integer :: iFreed
Type(NSET) , pointer :: Next
End Type NSET
Type ( NSET ) , pointer :: lFirst => NULL() , p => NULL()
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')>0 .And. index(str,'instance')>0 ) Then
If ( Associated( lFirst ) ) then
allocate( p%Next )
p => p%Next
Else
Allocate( lFirst )
p => lFirst
End If
i = index( str , "nset=" ) + 4
j = index( str(i:) , "," ) + i - 1
p%cName = str(i+1:j-1)
Read( 10 , * ) p%iFreed
End If
If ( str(1:9) == "*Boundary" ) exit
End Do
write( 11 , '(a)' ) "*Boundary"
Do
Read (10 , * , Iostat=ierr) str , i
If (ierr/=0) Exit
p => lFirst
Do
If ( .NOT.Associated(p) ) exit
If ( str == p%cName ) Exit
p => p%Next
End Do
Write( 11 , '(g0,1x,a,g0)' ) p%iFreed , "TR" , i
End Do
Close (10)
Close (11)
End Program www_fcode_cn
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |