MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
gwf-api.f90
Go to the documentation of this file.
1 !> @brief This module contains the API package methods
2 !!
3 !! This module contains the overridden methods from the base model package
4 !! class for the API package. The API package is designed to be used with the
5 !! shared object and have period data specified using the MODFLOW API. Several
6 !! methods need to be overridden since no period data are specified in the
7 !! API input file. Overridden methods include:
8 !! - bnd_rp no period data is specified
9 !! - bnd_fc BOUND array is not filled. hcof and rhs are specified dierctly
10 !!
11 !<
12 module apimodule
13  use kindmodule, only: dp, i4b
16  use bndmodule, only: bndtype
21  !
22  implicit none
23  !
24  private
25  public :: api_create
26  public :: apitype
27  !
28  character(len=LENFTYPE) :: ftype = 'API'
29  character(len=LENPACKAGENAME) :: text = ' API'
30  !
31  type, extends(bndtype) :: apitype
32  contains
33  procedure :: bnd_options => api_options
34  procedure :: bnd_rp => api_rp
35  procedure :: bnd_fc => api_fc
36  ! -- methods for observations
37  procedure, public :: bnd_obs_supported => api_obs_supported
38  procedure, public :: bnd_df_obs => api_df_obs
39  end type apitype
40 
41 contains
42 
43  !> @ brief Create a new package object
44  !!
45  !! Create a new USR Package object
46  !!
47  !<
48  subroutine api_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
49  ! -- dummy variables
50  class(bndtype), pointer :: packobj !< pointer to default package type
51  integer(I4B), intent(in) :: id !< package id
52  integer(I4B), intent(in) :: ibcnum !< boundary condition number
53  integer(I4B), intent(in) :: inunit !< unit number of USR package input file
54  integer(I4B), intent(in) :: iout !< unit number of model listing file
55  character(len=*), intent(in) :: namemodel !< model name
56  character(len=*), intent(in) :: pakname !< package name
57  ! -- local variables
58  type(apitype), pointer :: apiobj
59  !
60  ! -- allocate the object and assign values to object variables
61  allocate (apiobj)
62  packobj => apiobj
63  !
64  ! -- create name and memory path
65  call packobj%set_names(ibcnum, namemodel, pakname, ftype)
66  packobj%text = text
67  !
68  ! -- allocate scalars
69  call packobj%allocate_scalars()
70  !
71  ! -- initialize package
72  call packobj%pack_initialize()
73  !
74  packobj%inunit = inunit
75  packobj%iout = iout
76  packobj%id = id
77  packobj%ibcnum = ibcnum
78  packobj%ncolbnd = 2
79  packobj%iscloc = 2
80  packobj%ictMemPath = create_mem_path(namemodel, 'NPF')
81  !
82  ! -- return
83  return
84  end subroutine api_create
85 
86  !> @ brief Read additional options for package
87  !!
88  !! Read additional options for USR package.
89  !!
90  !<
91  subroutine api_options(this, option, found)
92  ! -- dummy variables
93  class(apitype), intent(inout) :: this
94  character(len=*), intent(inout) :: option
95  logical, intent(inout) :: found
96  !
97  ! -- process package options
98  select case (option)
99  case ('MOVER')
100  this%imover = 1
101  write (this%iout, '(4x,A)') 'MOVER OPTION ENABLED'
102  found = .true.
103  case default
104  !
105  ! -- No options found
106  found = .false.
107  end select
108  !
109  ! -- return
110  return
111  end subroutine api_options
112 
113  !> @ brief Read and prepare stress period data for package
114  !!
115  !! Method reads and prepares stress period data for the USR package.
116  !! This method overrides the base read and prepare method and does not read
117  !! any stress period data from the USR package input file.
118  !!
119  !<
120  subroutine api_rp(this)
121  ! -- dummy variables
122  class(apitype), intent(inout) :: this
123  !
124  ! -- return
125  return
126  end subroutine api_rp
127 
128  !> @ brief Fill A and r for the package
129  !!
130  !! Fill the coefficient matrix and right-hand side with the USR
131  !! package terms.
132  !!
133  !<
134  subroutine api_fc(this, rhs, ia, idxglo, matrix_sln)
135  ! -- dummy variables
136  class(apitype) :: this
137  real(DP), dimension(:), intent(inout) :: rhs !< right-hand side vector
138  integer(I4B), dimension(:), intent(in) :: ia !< pointer to the rows in A matrix
139  integer(I4B), dimension(:), intent(in) :: idxglo !< position of entries in A matrix
140  class(matrixbasetype), pointer :: matrix_sln !< A matrix for solution
141  ! -- local variables
142  integer(I4B) :: i
143  integer(I4B) :: n
144  integer(I4B) :: ipos
145  real(DP) :: qusr
146  !
147  ! -- pakmvrobj fc
148  if (this%imover == 1) then
149  call this%pakmvrobj%fc()
150  end if
151  !
152  ! -- Copy package rhs and hcof into solution rhs and amat
153  do i = 1, this%nbound
154  n = this%nodelist(i)
155  rhs(n) = rhs(n) + this%rhs(i)
156  ipos = ia(n)
157  call matrix_sln%add_value_pos(idxglo(ipos), this%hcof(i))
158  !
159  ! -- If mover is active and this boundary is discharging,
160  ! store available water (as positive value).
161  qusr = this%rhs(i) - this%hcof(i) * this%xnew(n)
162  if (this%imover == 1 .and. qusr > dzero) then
163  call this%pakmvrobj%accumulate_qformvr(i, qusr)
164  end if
165  end do
166  !
167  ! -- return
168  return
169  end subroutine api_fc
170 
171  ! -- Procedures related to observations
172 
173  !> @brief Determine if observations are supported.
174  !!
175  !! Function to determine if observations are supported by the USR package.
176  !! Observations are supported by the USR package.
177  !!
178  !<
179  logical function api_obs_supported(this)
180  ! -- dummy variables
181  class(apitype) :: this
182  !
183  ! -- set variables
184  api_obs_supported = .true.
185  !
186  ! -- return
187  return
188  end function api_obs_supported
189 
190  !> @brief Define the observation types available in the package
191  !!
192  !! Method to define the observation types available in the USR package.
193  !!
194  !<
195  subroutine api_df_obs(this)
196  ! -- dummy variables
197  class(apitype) :: this
198  ! -- local variables
199  integer(I4B) :: indx
200  !
201  ! -- initialize observations
202  call this%obs%StoreObsType('api', .true., indx)
203  this%obs%obsData(indx)%ProcessIdPtr => defaultobsidprocessor
204  !
205  ! -- Store obs type and assign procedure pointer
206  ! for to-mvr observation type.
207  call this%obs%StoreObsType('to-mvr', .true., indx)
208  this%obs%obsData(indx)%ProcessIdPtr => defaultobsidprocessor
209  !
210  ! -- return
211  return
212  end subroutine api_df_obs
213 
214 end module apimodule
This module contains the API package methods.
Definition: gwf-api.f90:12
subroutine api_options(this, option, found)
@ brief Read additional options for package
Definition: gwf-api.f90:92
character(len=lenpackagename) text
Definition: gwf-api.f90:29
subroutine, public api_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
@ brief Create a new package object
Definition: gwf-api.f90:49
character(len=lenftype) ftype
Definition: gwf-api.f90:28
subroutine api_rp(this)
@ brief Read and prepare stress period data for package
Definition: gwf-api.f90:121
logical function api_obs_supported(this)
Determine if observations are supported.
Definition: gwf-api.f90:180
subroutine api_df_obs(this)
Define the observation types available in the package.
Definition: gwf-api.f90:196
subroutine api_fc(this, rhs, ia, idxglo, matrix_sln)
@ brief Fill A and r for the package
Definition: gwf-api.f90:135
This module contains the base boundary package.
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter lenpackagename
maximum length of the package name
Definition: Constants.f90:22
integer(i4b), parameter lenftype
maximum length of a package type (DIS, WEL, OC, etc.)
Definition: Constants.f90:38
real(dp), parameter dzero
real constant zero
Definition: Constants.f90:64
This module defines variable data types.
Definition: kind.f90:8
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
This module contains the derived type ObsType.
Definition: Obs.f90:127
subroutine, public defaultobsidprocessor(obsrv, dis, inunitobs, iout)
@ brief Process IDstring provided for each observation
Definition: Obs.f90:249
type(timeserieslinktype) function, pointer, public gettimeserieslinkfromlist(list, indx)
Get time series link from a list.
@ brief BndType