MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
swf-ic.f90
Go to the documentation of this file.
1 module swficmodule
2 
3  use kindmodule, only: dp, i4b, lgp
4  use constantsmodule, only: linelength
7  use basedismodule, only: disbasetype
8 
9  implicit none
10  private
11  public :: swfictype
12  public :: ic_cr
13 
14  type, extends(numericalpackagetype) :: swfictype
15 
16  real(dp), dimension(:), pointer, contiguous :: strt => null() ! starting head
17 
18  contains
19 
20  procedure :: ic_ar
21  procedure :: ic_da
22  procedure, private :: ic_load
23  procedure, private :: allocate_arrays
24  procedure, private :: source_griddata
25 
26  end type swfictype
27 
28 contains
29 
30  !> @brief Create a new initial conditions object
31  !<
32  subroutine ic_cr(ic, name_model, input_mempath, inunit, iout, dis)
33  ! -- modules
35  ! -- dummy
36  type(swfictype), pointer :: ic
37  character(len=*), intent(in) :: name_model
38  character(len=*), intent(in) :: input_mempath
39  integer(I4B), intent(in) :: inunit
40  integer(I4B), intent(in) :: iout
41  class(disbasetype), pointer, intent(in) :: dis
42  ! -- formats
43  character(len=*), parameter :: fmtic = &
44  "(1x, /1x, 'IC -- Initial Conditions Package, Version 8, 3/28/2015', &
45  &' input read from mempath: ', A, //)"
46  !
47  ! -- create IC object
48  allocate (ic)
49  !
50  ! -- create name and memory path
51  call ic%set_names(1, name_model, 'IC', 'IC', input_mempath)
52  !
53  ! -- allocate scalars
54  call ic%allocate_scalars()
55  !
56  ! -- set variables
57  ic%inunit = inunit
58  ic%iout = iout
59  !
60  ! -- set pointers
61  ic%dis => dis
62  !
63  ! -- check if pkg is enabled,
64  if (inunit > 0) then
65  ! print message identifying pkg
66  write (ic%iout, fmtic) input_mempath
67  end if
68  end subroutine ic_cr
69 
70  !> @brief Load data from IDM into package
71  !<
72  subroutine ic_load(this)
73  ! -- modules
74  use basedismodule, only: disbasetype
75  ! -- dummy
76  class(swfictype) :: this
77  !
78  call this%source_griddata()
79  end subroutine ic_load
80 
81  !> @brief Allocate arrays, load from IDM, and assign head
82  !<
83  subroutine ic_ar(this, x)
84  ! -- dummy
85  class(swfictype) :: this
86  real(DP), dimension(:), intent(inout) :: x
87  ! -- local
88  integer(I4B) :: n
89  !
90  ! -- allocate arrays
91  call this%allocate_arrays(this%dis%nodes)
92  !
93  ! -- load from IDM
94  call this%ic_load()
95  !
96  ! -- assign starting head
97  do n = 1, this%dis%nodes
98  x(n) = this%strt(n)
99  end do
100  end subroutine ic_ar
101 
102  !> @brief Deallocate
103  !<
104  subroutine ic_da(this)
105  ! -- modules
109  ! -- dummy
110  class(swfictype) :: this
111  !
112  ! -- deallocate IDM memory
113  call memorylist_remove(this%name_model, 'IC', idm_context)
114  !
115  ! -- deallocate arrays
116  call mem_deallocate(this%strt)
117  !
118  ! -- deallocate parent
119  call this%NumericalPackageType%da()
120  end subroutine ic_da
121 
122  !> @brief Allocate arrays
123  !<
124  subroutine allocate_arrays(this, nodes)
125  ! -- modules
127  ! -- dummy
128  class(swfictype) :: this
129  integer(I4B), intent(in) :: nodes
130  !
131  ! -- Allocate
132  call mem_allocate(this%strt, nodes, 'STRT', this%memoryPath)
133  end subroutine allocate_arrays
134 
135  !> @brief Copy grid data from IDM into package
136  !<
137  subroutine source_griddata(this)
138  ! -- modules
142  ! -- dummy
143  class(swfictype) :: this
144  ! -- local
145  character(len=LINELENGTH) :: errmsg
146  type(swficparamfoundtype) :: found
147  integer(I4B), dimension(:), pointer, contiguous :: map
148  !
149  ! -- set map to convert user to reduced node data
150  map => null()
151  if (this%dis%nodes < this%dis%nodesuser) map => this%dis%nodeuser
152  !
153  ! -- set values
154  call mem_set_value(this%strt, 'STRT', this%input_mempath, map, found%strt)
155  !
156  ! -- ensure STRT was found
157  if (.not. found%strt) then
158  write (errmsg, '(a)') 'Error in GRIDDATA block: STRT not found.'
159  call store_error(errmsg, terminate=.false.)
160  call store_error_filename(this%input_fname)
161  else if (this%iout > 0) then
162  write (this%iout, '(4x,a)') 'STRT set from input file'
163  end if
164  end subroutine source_griddata
165 
166 end module swficmodule
This module contains block parser methods.
Definition: BlockParser.f90:7
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition: Constants.f90:44
This module defines variable data types.
Definition: kind.f90:8
subroutine, public memorylist_remove(component, subcomponent, context)
This module contains the base numerical package type.
This module contains simulation methods.
Definition: Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition: Sim.f90:92
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
Definition: Sim.f90:203
This module contains simulation variables.
Definition: SimVariables.f90:9
character(len=linelength) idm_context
subroutine source_griddata(this)
Copy grid data from IDM into package.
Definition: swf-ic.f90:138
subroutine ic_load(this)
Load data from IDM into package.
Definition: swf-ic.f90:73
subroutine, public ic_cr(ic, name_model, input_mempath, inunit, iout, dis)
Create a new initial conditions object.
Definition: swf-ic.f90:33
subroutine allocate_arrays(this, nodes)
Allocate arrays.
Definition: swf-ic.f90:125
subroutine ic_da(this)
Deallocate.
Definition: swf-ic.f90:105
subroutine ic_ar(this, x)
Allocate arrays, load from IDM, and assign head.
Definition: swf-ic.f90:84