!本程序主要用于网格模型的转化,2019年10月16日
program main
implicit none
integer, parameter :: FN=200,MN=200
integer counter1,counter2,counter3,dn,i
integer,allocatable :: NE(:)
integer,allocatable :: NSEQ(:)
integer,allocatable :: NADD(:)
integer,allocatable :: MA2(:)
character(len=3),allocatable :: EL(:),MA1(:)
character(len=10) title1,title2,variables,zone
real(kind=8) d,dm
real(kind=8),allocatable :: VOLX(:),AHTX(:),PMX(:),X(:),Y(:),Z(:),Xf(:),Yf(:),Zf(:),f(:)
real(kind=4),allocatable :: M(:,:)
!打开地质模型生成的岩相数据文件
open(1,file='Zone.txt',status='unknown')
!打开正演模型网格文件
open(2,file='MESH.txt',status='unknown')
read(1,*) title1
write(*,*) title1
read(1,*) variables
read(1,*) zone
read(2,*) title2
write(*,*) title2
dm=10000000.0
i=0
!开始循环读取地质模型岩相数据文件
Do counter1=1,FN
write(*,*) "good luck"
i=i+1
read(1,10) Xf(i),Yf(i),Zf(i),f(i)
10 format(E10.4,E10.4,E10.4,I2)
write(*,*) Xf(i),Yf(i),Zf(i),f(i)
end do
!开始循环读取网格模型数据文件并修改
Do counter2=1,MN
read(2,20) EL(counter2),NE(counter2),NSEQ(counter2),NADD(counter2),MA1(counter2),MA2(counter2),VOLX(counter2),AHTX(counter2),PMX(counter2),X(counter2),Y(counter2),Z(counter2)
20 format(A3,I2,I5,I5,A3,I2,E10.4,E10.4,E10.4,E10.4,E10.4,E10.4)
!开始计算最短距离
Do counter1=1,MN
d=(X(counter2)-Xf(counter1))**2+(X(counter2)-Yf(counter1))**2+(Z(counter2)-Zf(counter1))**2
if(dm>=d)then
dm=d
dn=counter1
end if
end do
MA2(counter2)=f(dn)
end do
!替换正演网格模型
write(2,*) title2
Do counter2=1,MN,1
write(2,30) EL(counter2),NE(counter2),NSEQ(counter2),NADD(counter2),MA1(counter2),MA2(counter2),VOLX(counter2),AHTX(counter2),PMX(counter2),X(counter2),Y(counter2),Z(counter2)
30 format(A3,I2,I5,I5,A3,I2,E10.4,E10.4,E10.4,E10.4,E10.4,E10.4)
end do
stop
end
13.76 KB, 下载次数: 1
30.04 KB, 下载次数: 1
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |