[Fortran] 纯文本查看 复制代码
program makedata
implicit none
integer::I,J,K,N,m,kkk
real(kind=8)::dkk,ddd,miny
type dmn
character(len=10)::dN
integer::pN
integer::k1,k2
integer::k11,k22
integer::k3,k4
integer::mp
real(kind=8)::mx,my
real(kind=8)::skd,kkd
real(kind=8),allocatable::x(:),y(:)
end type
type(dmn)::dm
N=41
dkk=5.0
ddd=10.0
open(11,file="BH.txt",status="old")
open(12,file="BH_new.dmn")
do I=1,N
write(*,*)I
read(11,'(a10,2f10.2,7i5)')dm%dN,dm%skd,dm%kkd,dm%pN,dm%k1,dm%k2,dm%k11,dm%k22,dm%k3,dm%k4
allocate(dm%x(dm%pN),dm%y(dm%pN))
read(11,'(10f8.2)')((dm%x(m),dm%y(m)),m=1,dm%pN)
miny=999999.0
do J=1,dm%pN
if(miny.gt.dm%y(J))then
dm%mx=dm%x(j)
dm%my=dm%y(j)
dm%mp=J
miny=dm%y(J)
endif
enddo
dm%y(dm%mp)=dm%my-ddd
j=0
do
j=j+1
dm%y(dm%mp-j)=dm%my-ddd
if(abs(dm%x(dm%mp-j-1)-dm%x(dm%mp)).gt.dkk)exit
enddo
dm%k3=dm%mp-j
j=0
do
j=j+1
dm%y(dm%mp+j)=dm%my-ddd
if(abs(dm%x(dm%mp+j+1)-dm%x(dm%mp)).gt.dkk)exit
enddo
dm%k4=dm%mp+j
write(12,'(a10,f10.2,f10.2,7i5)')dm%dN,dm%skd,dm%kkd,dm%pN,dm%k1,dm%k2,dm%k11,dm%k22,dm%k3,dm%k4
write(12,'(10f8.2)')((dm%x(m),dm%y(m)),m=1,dm%pN)
write(*,*)size(dm%x,dim=1),size(dm%y,dim=1)
deallocate(dm%x,dm%y,stat=kkk)
write(*,*)kkk
if(kkk.ne.0) then
write(*,*)kkk
stop
endif
enddo
en