-
Notifications
You must be signed in to change notification settings - Fork 3
/
Grd_subs.f90
137 lines (107 loc) · 5.17 KB
/
Grd_subs.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
!! 3D oil reservoir Simulator project
!! by Mehrdad Gharib Shirangi From Spring 2010 until Fall 2010
!! Copy Right by Mehrdad Gharib Shirangi
!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Module Grd_subs
!************************************************************************************************************************************************************
use globalvar
!************************************************************************************************************************************************************
integer :: nz_num2
!ia1, ja1, a1, x1, rhs1, itr_max1, mr1, tol_abs1, tol_rel1
Real*8, Allocatable, Dimension(:) :: a2
integer*4 ,Allocatable, Dimension(:) :: ia2, ja2
contains
!!! DO WHILE (.NOT. EOF(2))
!************************************************************************************************************************************************************
!************************************************************************************************************************************************************
!************************************************************************************************************************************************************
Subroutine Read_Mtrue !! This Subroutine is used Only when True Model is Avaiable and We want to generate Observed Data from The True Model
Implicit None
integer :: i
! ***************************************
if(Nz > 1) then
ALLOCATE( m_true( 2 * Ntotal ,1 ) )
Else
ALLOCATE( m_true( Ntotal ,1 ) )
EndIf
!! True Model is already in the folder of Prior Ensembles and The
!! Program will read the true model and generate Observed data from it
Open(2,DEFAULTFILE='.\Code Input Files\' , FILE = 'true_lnkh.Dat', status='old')
Do i = 1, Ntotal
read(2,*) m_true( i , [1])
EndDO
close(2)
! reading Porosity
Open(12,DEFAULTFILE='.\Code Input Files\',file='true_poro.Dat',status='old')
ALLOCATE(phi(Ntotal))
Do i = 1 , Ntotal
Read(12, FMT=*) phi(i)
end DO
close(12)
!!#################################################
If(Nz > 1) then
Open(2,DEFAULTFILE='.\Code Input Files\' , FILE = 'True_lnkz.Dat', status='old')
Do i = 1 + Ntotal , 2 * Ntotal
read(2,*) m_true( i , [1])
EndDO
close(2)
EndIf
EndSubroutine Read_Mtrue
!************************************************************************************************************************************************************
!************************************************************************************************************************************************************
Subroutine Gen_dobs
! ***************************************
implicit none
! ***************************************
integer :: i , j , alfa , i_1 , i_2 , j_1, j_2 , iwell, i_well, j_well , i_D , j_D
integer :: i_data , j_data
Real*8 ,Allocatable, Dimension(:) :: CD , LCD, Z
character(len=30)::charac,charac1
ALLOCATE( CD( N_d ) )
ALLOCATE( d_obs( N_d , 1) )
! CD construction
Allocate(z(N_d))
CD = 0
d_obs = 0
! CD construction
j = 1
Do i = 1 , N_d
If ( diagonals(i, 1) .NE. -1 ) then
If ((diagonals(i, 1) == 0) .OR. (diagonals(i, 1) .LT. MINERROR_WOR) ) diagonals(i, 1) = MINERROR_WOR
CD(i) = diagonals(i, 1)
Else
CD(i) = diagonals(i, 1)
EndIf
EndDo
! ***************************************
! ***************************************
call random1(N_d)
Open(1,FILE='randomdev.DAT', status='old')
read(1,*) z(1:N_d)
close(1)
Do i = 1 , N_d
If ( diagonals(i, 1) .NE. -1 ) then
d_obs(i,1) = d_pre(i,1) + sqrt(CD(i)) * Z(i)
Else
d_obs(i,1) = -1
EndIf
EndDO
Open(2,DEFAULTFILE='.\sim_output\' , FILE='Observed_Data.DAT', status='unknown' , access = 'append')
Do i = 1 , N_d
If ( diagonals(i, 1) .NE. -1 ) then
write(2,'( < 3 >(F15.1 ,2x), < 2 >(F16.9 ,2x) )') time, well_No(i,1) , Data_type(i,1) , diagonals(i,1),d_obs(i,1)
EndIf
EndDo
close(2)
DeALLOCATE(d_obs)
EndSubroutine Gen_dobs
!************************************************************************************************************************************************************
!*******************************************************************************************
!*******************************************************************************************
!*******************************************************************************************
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
EndModule Grd_subs