1
1
module GwfIcModule
2
2
3
- use KindModule, only: DP, I4B
3
+ use KindModule, only: DP, I4B, LGP
4
+ use ConstantsModule, only: LINELENGTH
4
5
use NumericalPackageModule, only: NumericalPackageType
5
6
use BlockParserModule, only: BlockParserType
6
7
use BaseDisModule, only: DisBaseType
@@ -13,59 +14,53 @@ module GwfIcModule
13
14
type, extends(NumericalPackageType) :: GwfIcType
14
15
real (DP), dimension (:), pointer , contiguous :: strt = > null () ! starting head
15
16
contains
16
- procedure :: ic_ar
17
+ procedure :: ic_load
17
18
procedure :: ic_da
18
19
procedure , private :: allocate_arrays
19
- procedure , private :: read_options
20
- procedure :: read_data
20
+ procedure , private :: source_griddata
21
21
end type GwfIcType
22
22
23
23
contains
24
24
25
- subroutine ic_cr (ic , name_model , inunit , iout , dis )
26
- ! ******************************************************************************
27
- ! ic_cr -- Create a new initial conditions object
28
- ! ******************************************************************************
29
- !
30
- ! SPECIFICATIONS:
31
- ! ------------------------------------------------------------------------------
25
+ ! > @brief Create a new initial conditions object
26
+ subroutine ic_cr (ic , name_model , input_mempath , inunit , iout , dis )
27
+ ! -- modules
28
+ use MemoryManagerExtModule, only: mem_set_value
32
29
! -- dummy
33
30
type (GwfIcType), pointer :: ic
34
31
character (len=* ), intent (in ) :: name_model
32
+ character (len=* ), intent (in ) :: input_mempath
35
33
integer (I4B), intent (in ) :: inunit
36
34
integer (I4B), intent (in ) :: iout
37
35
class(DisBaseType), pointer , intent (in ) :: dis
38
- ! ------------------------------------------------------------------------------
36
+ ! -- formats
37
+ character (len=* ), parameter :: fmtic = &
38
+ " (1x, /1x, 'IC -- Initial Conditions Package, Version 8, 3/28/2015', &
39
+ &' input read from mempath: ', A, //)"
39
40
!
40
- ! -- Create the object
41
+ ! -- create IC object
41
42
allocate (ic)
42
43
!
43
44
! -- create name and memory path
44
- call ic% set_names(1 , name_model, ' IC' , ' IC' )
45
+ call ic% set_names(1 , name_model, ' IC' , ' IC' , input_mempath )
45
46
!
46
- ! -- Allocate scalars
47
+ ! -- allocate scalars
47
48
call ic% allocate_scalars()
48
49
!
50
+ ! -- set variables
49
51
ic% inunit = inunit
50
52
ic% iout = iout
51
53
!
52
- ! -- set pointers
54
+ ! -- set points
53
55
ic% dis = > dis
54
56
!
55
- ! -- Initialize block parser
56
- call ic% parser% Initialize(ic% inunit, ic% iout)
57
- !
58
- ! -- Return
59
- return
57
+ ! -- if package is enabled, print message identifying it
58
+ if (inunit > 0 ) &
59
+ write (ic% iout, fmtic) input_mempath
60
60
end subroutine ic_cr
61
61
62
- subroutine ic_ar (this , x )
63
- ! ******************************************************************************
64
- ! ic_ar -- Allocate and read initial conditions
65
- ! ******************************************************************************
66
- !
67
- ! SPECIFICATIONS:
68
- ! ------------------------------------------------------------------------------
62
+ ! > @brief Load initial conditions
63
+ subroutine ic_load (this , x )
69
64
! -- modules
70
65
use BaseDisModule, only: DisBaseType
71
66
use SimModule, only: store_error
@@ -74,175 +69,77 @@ subroutine ic_ar(this, x)
74
69
real (DP), dimension (:), intent (inout ) :: x
75
70
! -- locals
76
71
integer (I4B) :: n
77
- ! ------------------------------------------------------------------------------
78
72
!
79
- ! -- Print a message identifying the initial conditions package.
80
- write (this% iout, 1 ) this% inunit
81
- 1 format (1x , / 1x , ' IC -- INITIAL CONDITIONS PACKAGE, VERSION 8, 3/28/2015' , &
82
- ' INPUT READ FROM UNIT ' , i0)
83
- !
84
- ! -- Allocate arrays
73
+ ! -- allocate arrays
85
74
call this% allocate_arrays(this% dis% nodes)
86
75
!
87
- ! -- Read options
88
- call this% read_options()
89
- !
90
- ! -- Read data
91
- call this% read_data()
76
+ ! -- read grid data
77
+ call this% source_griddata()
92
78
!
93
- ! -- Assign x equal to strt
79
+ ! -- assign starting head
94
80
do n = 1 , this% dis% nodes
95
81
x(n) = this% strt(n)
96
82
end do
97
- !
98
- ! -- Return
99
- return
100
- end subroutine ic_ar
83
+ end subroutine ic_load
101
84
85
+ ! > @brief Deallocate
102
86
subroutine ic_da (this )
103
- ! ******************************************************************************
104
- ! ic_da -- Deallocate
105
- ! ******************************************************************************
106
- !
107
- ! SPECIFICATIONS:
108
- ! ------------------------------------------------------------------------------
109
87
! -- modules
110
88
use MemoryManagerModule, only: mem_deallocate
89
+ use MemoryManagerExtModule, only: memorylist_remove
90
+ use SimVariablesModule, only: idm_context
111
91
! -- dummy
112
92
class(GwfIcType) :: this
113
- ! ------------------------------------------------------------------------------
114
93
!
115
- ! -- deallocate parent
116
- call this% NumericalPackageType% da()
117
- !
118
- ! -- Scalars
94
+ ! -- deallocate IDM memory
95
+ call memorylist_remove(this% name_model, ' IC' , idm_context)
119
96
!
120
- ! -- Arrays
97
+ ! -- deallocate arrays
121
98
call mem_deallocate(this% strt)
122
99
!
123
- ! -- Return
124
- return
100
+ ! -- deallocate parent
101
+ call this % NumericalPackageType % da()
125
102
end subroutine ic_da
126
103
104
+ ! @brief Allocate arrays
127
105
subroutine allocate_arrays (this , nodes )
128
- ! ******************************************************************************
129
- ! allocate_arrays
130
- ! ******************************************************************************
131
- !
132
- ! SPECIFICATIONS:
133
- ! ------------------------------------------------------------------------------
134
106
! -- modules
135
107
use MemoryManagerModule, only: mem_allocate
136
108
! -- dummy
137
109
class(GwfIcType) :: this
138
110
integer (I4B), intent (in ) :: nodes
139
- ! -- local
140
- ! ------------------------------------------------------------------------------
141
111
!
142
112
! -- Allocate
143
113
call mem_allocate(this% strt, nodes, ' STRT' , this% memoryPath)
144
- !
145
- ! -- Return
146
- return
147
114
end subroutine allocate_arrays
148
115
149
- subroutine read_options (this )
150
- ! ******************************************************************************
151
- ! read_options
152
- ! ******************************************************************************
153
- !
154
- ! SPECIFICATIONS:
155
- ! ------------------------------------------------------------------------------
156
- ! -- modules
157
- use ConstantsModule, only: LINELENGTH
158
- use SimModule, only: store_error
159
- ! -- dummy
160
- class(GwfIcType) :: this
161
- ! -- local
162
- character (len= LINELENGTH) :: errmsg, keyword
163
- integer (I4B) :: ierr
164
- logical :: isfound, endOfBlock
165
- ! -- formats
166
- ! ------------------------------------------------------------------------------
167
- !
168
- ! -- get options block
169
- call this% parser% GetBlock(' OPTIONS' , isfound, ierr, &
170
- supportOpenClose= .true. , blockRequired= .false. )
171
- !
172
- ! -- parse options block if detected
173
- if (isfound) then
174
- write (this% iout, ' (1x,a)' ) ' PROCESSING IC OPTIONS'
175
- do
176
- call this% parser% GetNextLine(endOfBlock)
177
- if (endOfBlock) exit
178
- call this% parser% GetStringCaps(keyword)
179
- select case (keyword)
180
- case default
181
- write (errmsg, ' (a,a)' ) ' Unknown IC option: ' , trim (keyword)
182
- call store_error(errmsg)
183
- call this% parser% StoreErrorUnit()
184
- end select
185
- end do
186
- write (this% iout, ' (1x,a)' ) ' END OF IC OPTIONS'
187
- end if
188
- !
189
- ! -- Return
190
- return
191
- end subroutine read_options
192
-
193
- subroutine read_data (this )
194
- ! ******************************************************************************
195
- ! read_data
196
- ! ******************************************************************************
197
- !
198
- ! SPECIFICATIONS:
199
- ! ------------------------------------------------------------------------------
116
+ ! > @brief Copy grid data from IDM into package
117
+ subroutine source_griddata (this )
200
118
! -- modules
201
- use ConstantsModule, only: LINELENGTH
202
119
use SimModule, only: store_error
120
+ use MemoryManagerExtModule, only: mem_set_value
121
+ use GwfIcInputModule, only: GwfIcParamFoundType
203
122
! -- dummy
204
123
class(GwfIcType) :: this
205
124
! -- local
206
- character (len= LINELENGTH) :: errmsg, keyword
207
- character (len= :), allocatable :: line
208
- integer (I4B) :: istart, istop, lloc, ierr
209
- logical :: isfound, endOfBlock
210
- character (len= 24 ) :: aname(1 )
211
- ! -- formats
212
- ! ------------------------------------------------------------------------------
213
- !
214
- ! -- Setup the label
215
- aname(1 ) = ' INITIAL HEAD'
216
- !
217
- ! -- get griddata block
218
- call this% parser% GetBlock(' GRIDDATA' , isfound, ierr)
219
- if (isfound) then
220
- write (this% iout, ' (1x,a)' ) ' PROCESSING GRIDDATA'
221
- do
222
- call this% parser% GetNextLine(endOfBlock)
223
- if (endOfBlock) exit
224
- call this% parser% GetStringCaps(keyword)
225
- call this% parser% GetRemainingLine(line)
226
- lloc = 1
227
- select case (keyword)
228
- case (' STRT' )
229
- call this% dis% read_grid_array(line, lloc, istart, istop, this% iout, &
230
- this% parser% iuactive, this% strt, &
231
- aname(1 ))
232
- case default
233
- write (errmsg, ' (a,a)' ) ' Unknown GRIDDATA tag: ' , trim (keyword)
234
- call store_error(errmsg)
235
- call this% parser% StoreErrorUnit()
236
- end select
237
- end do
238
- write (this% iout, ' (1x,a)' ) ' END PROCESSING GRIDDATA'
239
- else
240
- call store_error(' Required GRIDDATA block not found.' )
241
- call this% parser% StoreErrorUnit()
125
+ character (len= LINELENGTH) :: errmsg
126
+ type (GwfIcParamFoundType) :: found
127
+ integer (I4B), dimension (:), pointer , contiguous :: map
128
+ !
129
+ ! -- set map to convert user to reduced node data
130
+ map = > null ()
131
+ if (this% dis% nodes < this% dis% nodesuser) map = > this% dis% nodeuser
132
+ !
133
+ ! -- set values
134
+ call mem_set_value(this% strt, ' STRT' , this% input_mempath, map, found% strt)
135
+ !
136
+ ! -- ensure STRT was found
137
+ if (.not. found% strt) then
138
+ write (errmsg, ' (a)' ) ' Error in GRIDDATA block: STRT not found.'
139
+ call store_error(errmsg)
140
+ else if (this% iout > 0 ) then
141
+ write (this% iout, ' (4x,a)' ) ' STRT set from input file'
242
142
end if
243
- !
244
- ! -- Return
245
- return
246
- end subroutine read_data
143
+ end subroutine source_griddata
247
144
248
145
end module GwfIcModule
0 commit comments