MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
PackageMover.f90
Go to the documentation of this file.
2 
3  use kindmodule, only: dp, i4b
7 
8  implicit none
9  private
10  public :: packagemovertype
11  public :: set_packagemover_pointer
13 
15 
16  character(len=LENMEMPATH) :: memorypath !< the location in the memory manager where the variables are stored
17  integer(I4B), pointer :: nproviders
18  integer(I4B), pointer :: nreceivers
19  integer(I4B), dimension(:), pointer, contiguous :: iprmap => null() !< map between id1 and feature (needed for lake to map from outlet to lake number)
20  real(dp), dimension(:), pointer, contiguous :: qtformvr => null() !< total flow rate available for mover
21  real(dp), dimension(:), pointer, contiguous :: qformvr => null() !< currently available consumed water (changes during fc)
22  real(dp), dimension(:), pointer, contiguous :: qtomvr => null() !< actual amount of water sent to mover
23  real(dp), dimension(:), pointer, contiguous :: qfrommvr => null() !< actual amount of water received from mover
24  real(dp), dimension(:), pointer, contiguous :: qfrommvr0 => null() !< qfrommvr from previous iteration
25 
26  contains
27  procedure :: ar
28  procedure :: ad
29  procedure :: reset
30  procedure :: fc
31  procedure :: da
32  procedure :: allocate_scalars
33  procedure :: allocate_arrays
34  procedure :: get_qfrommvr
35  procedure :: get_qfrommvr0
36  procedure :: get_qtomvr
37  procedure :: accumulate_qformvr
38 
39  end type packagemovertype
40 
41 contains
42 
43  subroutine set_packagemover_pointer(packagemover, memPath)
44  type(packagemovertype), intent(inout) :: packagemover
45  character(len=*), intent(in) :: mempath
46  packagemover%memoryPath = mempath
47  call mem_setptr(packagemover%nproviders, 'NPROVIDERS', &
48  packagemover%memoryPath)
49  call mem_setptr(packagemover%nreceivers, 'NRECEIVERS', &
50  packagemover%memoryPath)
51  call mem_setptr(packagemover%iprmap, 'IPRMAP', packagemover%memoryPath)
52  call mem_setptr(packagemover%qtformvr, 'QTFORMVR', packagemover%memoryPath)
53  call mem_setptr(packagemover%qformvr, 'QFORMVR', packagemover%memoryPath)
54  call mem_setptr(packagemover%qtomvr, 'QTOMVR', packagemover%memoryPath)
55  call mem_setptr(packagemover%qfrommvr, 'QFROMMVR', packagemover%memoryPath)
56  call mem_setptr(packagemover%qfrommvr0, 'QFROMMVR0', packagemover%memoryPath)
57  end subroutine set_packagemover_pointer
58 
59  subroutine nulllify_packagemover_pointer(packagemover)
60  type(packagemovertype), intent(inout) :: packagemover
61  packagemover%memoryPath = ''
62  packagemover%nproviders => null()
63  packagemover%nreceivers => null()
64  packagemover%iprmap => null()
65  packagemover%qtformvr => null()
66  packagemover%qformvr => null()
67  packagemover%qtomvr => null()
68  packagemover%qfrommvr => null()
69  packagemover%qfrommvr0 => null()
70  end subroutine nulllify_packagemover_pointer
71 
72  subroutine ar(this, nproviders, nreceivers, memoryPath)
73  class(packagemovertype) :: this
74  integer, intent(in) :: nproviders
75  integer, intent(in) :: nreceivers
76  character(len=*), intent(in) :: memoryPath
77  !
78  this%memoryPath = memorypath
79  call this%allocate_scalars()
80  this%nproviders = nproviders
81  this%nreceivers = nreceivers
82  !
83  call this%allocate_arrays()
84  !
85  ! -- return
86  return
87  end subroutine ar
88 
89  subroutine ad(this)
90  class(packagemovertype) :: this
91  integer :: i
92  !
93  ! -- set qtomvr and qformvr to zero
94  do i = 1, this%nproviders
95  this%qtomvr(i) = dzero
96  this%qformvr(i) = dzero
97  end do
98  !
99  ! -- return
100  return
101  end subroutine ad
102 
103  subroutine reset(this)
104  class(packagemovertype) :: this
105  integer :: i
106  !
107  ! -- set frommvr and qtomvr to zero
108  do i = 1, this%nreceivers
109  this%qfrommvr0(i) = this%qfrommvr(i)
110  this%qfrommvr(i) = dzero
111  end do
112  do i = 1, this%nproviders
113  this%qtomvr(i) = dzero
114  this%qtformvr(i) = this%qformvr(i)
115  end do
116  !
117  ! -- return
118  return
119  end subroutine reset
120 
121  subroutine fc(this)
122  class(packagemovertype) :: this
123  integer :: i
124  !
125  ! -- set formvr to zero
126  do i = 1, this%nproviders
127  this%qformvr(i) = dzero
128  end do
129  !
130  ! -- return
131  return
132  end subroutine fc
133 
134  subroutine da(this)
135  class(packagemovertype) :: this
136  !
137  ! -- arrays
138  call mem_deallocate(this%iprmap)
139  call mem_deallocate(this%qtformvr)
140  call mem_deallocate(this%qformvr)
141  call mem_deallocate(this%qtomvr)
142  call mem_deallocate(this%qfrommvr)
143  call mem_deallocate(this%qfrommvr0)
144  !
145  ! -- scalars
146  call mem_deallocate(this%nproviders)
147  call mem_deallocate(this%nreceivers)
148  !
149  ! -- pointers
150  nullify (this%iprmap)
151  !
152  ! -- return
153  return
154  end subroutine da
155 
156  subroutine allocate_scalars(this)
157  class(packagemovertype) :: this
158  !
159  call mem_allocate(this%nproviders, 'NPROVIDERS', this%memoryPath)
160  call mem_allocate(this%nreceivers, 'NRECEIVERS', this%memoryPath)
161  !
162  this%nproviders = 0
163  this%nreceivers = 0
164  !
165  ! -- return
166  return
167  end subroutine allocate_scalars
168 
169  subroutine allocate_arrays(this)
170  class(packagemovertype) :: this
171  integer(I4B) :: i
172  !
173  call mem_allocate(this%iprmap, this%nproviders, 'IPRMAP', this%memoryPath)
174  call mem_allocate(this%qtformvr, this%nproviders, 'QTFORMVR', this%memoryPath)
175  call mem_allocate(this%qformvr, this%nproviders, 'QFORMVR', this%memoryPath)
176  call mem_allocate(this%qtomvr, this%nproviders, 'QTOMVR', this%memoryPath)
177  call mem_allocate(this%qfrommvr, this%nreceivers, 'QFROMMVR', this%memoryPath)
178  call mem_allocate(this%qfrommvr0, this%nreceivers, 'QFROMMVR0', &
179  this%memoryPath)
180  !
181  ! -- initialize
182  do i = 1, this%nproviders
183  this%iprmap(i) = i
184  this%qtformvr(i) = dzero
185  this%qformvr(i) = dzero
186  this%qtomvr(i) = dzero
187  end do
188  do i = 1, this%nreceivers
189  this%qfrommvr(i) = dzero
190  this%qfrommvr0(i) = dzero
191  end do
192  !
193  ! -- return
194  return
195  end subroutine allocate_arrays
196 
197  function get_qfrommvr(this, ireceiver) result(qfrommvr)
198  class(packagemovertype) :: this
199  real(dp) :: qfrommvr
200  integer, intent(in) :: ireceiver
201  qfrommvr = this%qfrommvr(ireceiver)
202  end function get_qfrommvr
203 
204  function get_qfrommvr0(this, ireceiver) result(qfrommvr0)
205  class(packagemovertype) :: this
206  real(dp) :: qfrommvr0
207  integer, intent(in) :: ireceiver
208  qfrommvr0 = this%qfrommvr0(ireceiver)
209  end function get_qfrommvr0
210 
211  function get_qtomvr(this, iprovider) result(qtomvr)
212  class(packagemovertype) :: this
213  real(dp) :: qtomvr
214  integer, intent(in) :: iprovider
215  qtomvr = this%qtomvr(iprovider)
216  end function get_qtomvr
217 
218  subroutine accumulate_qformvr(this, iprovider, qformvr)
219  class(packagemovertype) :: this
220  integer, intent(in) :: iprovider
221  real(DP), intent(in) :: qformvr
222  this%qformvr(iprovider) = this%qformvr(iprovider) + qformvr
223  end subroutine accumulate_qformvr
224 
225 end module packagemovermodule
This module contains simulation constants.
Definition: Constants.f90:9
real(dp), parameter dzero
real constant zero
Definition: Constants.f90:64
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition: Constants.f90:26
This module defines variable data types.
Definition: kind.f90:8
real(dp) function get_qtomvr(this, iprovider)
subroutine ar(this, nproviders, nreceivers, memoryPath)
subroutine ad(this)
subroutine reset(this)
subroutine da(this)
real(dp) function get_qfrommvr(this, ireceiver)
subroutine, public nulllify_packagemover_pointer(packagemover)
subroutine, public set_packagemover_pointer(packagemover, memPath)
real(dp) function get_qfrommvr0(this, ireceiver)
subroutine accumulate_qformvr(this, iprovider, qformvr)
subroutine allocate_arrays(this)
subroutine fc(this)
subroutine allocate_scalars(this)