[Fortran] 纯文本查看 复制代码 Program www_fcode_cn implicit none
Character(len=512) :: cStr
integer :: k , nUnit = 0 , nNode = 0
Character(len=*) , parameter :: C_SIZING = 'sizing' , &
C_POINTS = 'points' , &
C_CONNECTIVITY = 'connectivity' , &
C_COORDINATES = 'coordinates'
integer , allocatable :: connectivity(:,:)
real , allocatable :: coordinates(:,:)
Open(12,File="model1_job1.dat")
Do
read(12,'(a512)',ioStat=k) cStr
if(k/=0) exit
cStr = adjustl(cStr)
if( cStr(:len(C_SIZING)) == C_SIZING ) then
read(cStr,*) cStr , k , nUnit , nNode
else if( cStr(:len(C_POINTS)) == C_POINTS ) then
!//此处可读取points
else if( cStr(:len(C_CONNECTIVITY)) == C_CONNECTIVITY ) then
read(12,'(a512)',ioStat=k) cStr
if(k/=0) exit
if( nUnit <= 0 ) cycle
Allocate( connectivity(6,nUnit) )
read(12,*) connectivity
else if( cStr(:len(C_COORDINATES)) == C_COORDINATES ) then
read(12,'(a512)',ioStat=k) cStr
if(k/=0) exit
if( nNode <= 0 ) cycle
Allocate( coordinates(4,nNode) )
read(12,*) coordinates
end if
End Do
Close(12)
Open(12,File="out.txt")
Do k = 1 , size(connectivity,2)
write(12,*) connectivity(:,k)
End Do
Do k = 1 , size(coordinates,2)
write(12,*) coordinates(:,k)
End Do
Close(12)
End Program www_fcode_cn |