[Fortran] 纯文本查看 复制代码
program main
implicit none
real,allocatable,dimension(:,:,:)::xyz(:,:,:)
integer npl,numbers
integer,allocatable,dimension(:)::np(:),mat(:)
character*20 aa1,aa2
real x0,y0,z0
integer i,nnn,j
800 FORMAT(A20)
write(*,*)'---------输入多段线中最多点数---------'
read*,numbers
allocate(np(numbers),xyz(100,100,100),mat(100))
npl=0
np(1:numbers)=0
open(10,FILE='shichong.dat',status='old')
do
read(10,800,end=900)aa1
if(aa1(1:8).eq.'POLYLINE')then
npl=npl+1
do
read(10,800,end=900)aa2
if(aa2(1:3).eq.' 8') then
read(10,*,end=900)nnn
mat(npl)=nnn
else if(aa2(1:3).eq.' 10')then
read(10,*)x0
xyz(np(npl),1,npl)=x0
else if(aa2(1:3).eq.' 20')then
read(10,*)y0
xyz(np(npl),2,npl)=y0
else if(aa2(1:3).eq.' 30')then
read(10,*)z0
xyz(np(npl),3,npl)=z0
else if(aa2(1:6).eq.'VERTEX')then
np(npl)=np(npl)+1
else if(aa2(1:6).eq.'SEQEND')then
exit
end if
end do
end if
end do
900 write(*,*)'--------多段线读取完毕,共',npl,'条-------'
close(10)
deallocate(np,mat,xyz)
end