Program read_grd
character*160 cmdfile,inputfile,outputfile,str
integer line1,line2
real step,dx,dy
real,dimension(:,:),allocatable::input(:,:),output(:,:)
integer point,line
real Xmin,Xmax,Ymin,Ymax,Gmin,Gmax
cmdfile="cmd.par"
open(40,file=cmdfile,status='old')
read(40,*)
read(40,*)
read(40,*)
read(40,*)
read(40,*)
read(40,*)str,inputfile
read(40,*)str,line1,line2
read(40,*)str,step
read(40,*)str,outputfile!打开par文件读入相关的参数
close(40)
open(10,file=inputfile,status='old')
read(10,*)
read(10,*)point,line
read(10,*)Xmin,Xmax
read(10,*)Ymin,Ymax
read(10,*)Gmax,Gmin
close(10)
allocate(input(point,line),output(point,line))
write(*,"('dx=',f5.2,'dy=',f5.2)")(Xmax-Xmin)/(line-1),(Ymax-Ymin)/(point-1)!根据相关数据计算点线距dx、dy,并在屏幕上输出
open(20,file=inputfile,status='old')
read(20,*)
read(20,*)
read(20,*)
read(20,*)
read(20,*)
read(20,*)((input(i,j),i=1,point),j=1,line)
close(20)
!打开inputfile文件,并将其中的数据读入数组input
open(20,file=inputfile,status='old')
read(20,*)
read(20,*)
read(20,*)
read(20,*)
read(20,*)
read(20,*)((input(i,j),i=1,point),j=1,line)
close(20)
do j=1,line
do i=1,point
output(i,j)=input(i,j)
end do
end do
do j=line1,line2
do i=1,point
output(i,j)=input(i,j)+step
end do
end do
Gmin=HUGE(Gmin) !给Gmin赋予最大值
Gmax=-HUGE(Gmax) !给Gmax赋予最小值
Do j=1,line
Do i=1,point
Gmin=MIN(Gmin,output(i,j))
Gmax=MAX(Gmax,output(i,j))
End do
End do
!根据输入参数对数组input中某些行加入干扰值,并将最终结果存入output数组
open(30,file=outputfile,status='unknown')
write(30,'(a)')'DSAA'
write(30,*)point,line
write(30,*)Xmin,Xmax
write(30,*)Ymin,Ymax
write(30,*)Gmin,Gmax
do j=1,line
write(30,"(5F5.2)")(output(i,j),i=1,point)
end do
close(30)
!将output数组中的数据写入grd文件outputfile中
deallocate(input,output)
END program
9]PF%9]U%YXH3AX_3JQCW0S.png (33.61 KB, 下载次数: 147)
ZE$N@PL{R1IIERQXV5[_@6D.png (30.3 KB, 下载次数: 120)
fcode 发表于 2021-11-22 14:36
截图要大,要带上代码。
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |