program ping
implicit none
integer::n,m,i,j,s,cho
real h0,h1,sumw,sumlen!h0h1分别代表起始结束高程,sumw与sumlen代表高擦汗闭合差之和与线路长之和
real,allocatable,dimension(:)::w,H,cor,leng
integer,allocatable,dimension(:)::sta
print*,'请确认何种水准平差网,1.闭合水准 2.附合水准 3.支水准'
read*,cho
if(cho==1) then
open(unit=8,file="bihe.txt")!文件的名字是txt
print*,'请输入水准段数'
read*,s
allocate(sta(s))
allocate(leng(s))
allocate(w(s))
read(8,*) h0
read(8,*)(sta(i),leng(i),w(i),i=1,s)!把数据读入了,w为分段高差,leng为测段长度,sta为站号
close(8)
open(unit=9,file="output1.txt",form='formatted')
allocate(H(s))
allocate(cor(s))
sumw=0
sumlen=0
write(9,*)'起始高程',h0
do i=1,s
sumw=sumw+w(i)
sumlen=sumlen+leng(i)
end do
do i=1,s
cor(i)=-sumw*leng(i)/sumlen
do j=1,i
H(i)=w(j)+cor(j)
end do
H(i)=H(i)+h0
write(9,20)sta(i),leng(i),w(i),cor(i),H(i)!cor为分段高差改正数,H为改正后高差
end do
close(9)
else if(cho==2) then
open(unit=10,file="fuhe.txt")!文件的名字是txt
print*,'请输入水准段数'
read*,s
allocate(sta(s))
allocate(leng(s))
allocate(w(s))
read(10,*) h0,h1
read(10,*)(sta(i),leng(i),w(i),i=1,s)!把数据读入了,w为分段高差,leng为测段长度,sta为站号
close(10)
open(unit=11,file="output2.txt",form='formatted')
allocate(H(s))
allocate(cor(s))
sumw=0
sumlen=0
write(11,*)'起始高程',h0 ,'末点高程',h1
do i=1,s
sumw=sumw+w(i)
sumlen=sumlen+leng(i)
end do
do i=1,s
cor(i)=(h1-h0-sumw)*leng(i)/sumlen!-sumw即为高差改正数,此时改为h1-h0-sumw//h0+sumw+改正=h1
do j=1,i
H(i)=w(j)+cor(j)
end do
H(i)=H(i)+h0
write(11,20)sta(i),leng(i),w(i),cor(i),H(i)!cor为分段高差改正数,H为改正后高差
end do
close(11)
else
open(unit=12,file="zhi.txt")!文件的名字是txt
print*,'请输入水准测段数'
read*,s
allocate(sta(s))
allocate(leng(s))
allocate(w(s))
read(12,*) h0
read(12,*)(sta(i),leng(i),w(i),i=1,s)!把数据读入了,w为分段高差,leng为测段长度,sta为站号
close(12)
open(unit=13,file="output3.txt",form='formatted')
allocate(H(s))
write(13,*)'起始高程',h0
do i=1,s
sumw=sumw+w(i)
sumlen=sumlen+leng(i)
end do
do i=1,s
do j=1,i
H(i)=w(j)
end do
H(i)=H(i)+h0
write(13,21)sta(i),leng(i),w(i),H(i)!cor为分段高差改正数,H为改正后高差
end do
write(13,*)sumw,sumlen
close(13)
end if
20 format(i3,f5.1,f8.3,f8.3,f8.3)
21 format(i3,f5.1,f8.3,f8.3)
end program ping
Fortran实现水准网的平差运算
最新推荐文章于 2022-10-17 07:33:03 发布