MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
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  end subroutine api_create
82 
83  !> @ brief Read additional options for package
84  !!
85  !! Read additional options for USR package.
86  !!
87  !<
88  subroutine api_options(this, option, found)
89  ! -- dummy variables
90  class(apitype), intent(inout) :: this
91  character(len=*), intent(inout) :: option
92  logical, intent(inout) :: found
93  !
94  ! -- process package options
95  select case (option)
96  case ('MOVER')
97  this%imover = 1
98  write (this%iout, '(4x,A)') 'MOVER OPTION ENABLED'
99  found = .true.
100  case default
101  !
102  ! -- No options found
103  found = .false.
104  end select
105  end subroutine api_options
106 
107  !> @ brief Read and prepare stress period data for package
108  !!
109  !! Method reads and prepares stress period data for the USR package.
110  !! This method overrides the base read and prepare method and does not read
111  !! any stress period data from the USR package input file.
112  !!
113  !<
114  subroutine api_rp(this)
115  ! -- dummy variables
116  class(apitype), intent(inout) :: this
117  end subroutine api_rp
118 
119  !> @ brief Fill A and r for the package
120  !!
121  !! Fill the coefficient matrix and right-hand side with the USR
122  !! package terms.
123  !!
124  !<
125  subroutine api_fc(this, rhs, ia, idxglo, matrix_sln)
126  ! -- dummy variables
127  class(apitype) :: this
128  real(DP), dimension(:), intent(inout) :: rhs !< right-hand side vector
129  integer(I4B), dimension(:), intent(in) :: ia !< pointer to the rows in A matrix
130  integer(I4B), dimension(:), intent(in) :: idxglo !< position of entries in A matrix
131  class(matrixbasetype), pointer :: matrix_sln !< A matrix for solution
132  ! -- local variables
133  integer(I4B) :: i
134  integer(I4B) :: n
135  integer(I4B) :: ipos
136  real(DP) :: qusr
137  !
138  ! -- pakmvrobj fc
139  if (this%imover == 1) then
140  call this%pakmvrobj%fc()
141  end if
142  !
143  ! -- Copy package rhs and hcof into solution rhs and amat
144  do i = 1, this%nbound
145  n = this%nodelist(i)
146  rhs(n) = rhs(n) + this%rhs(i)
147  ipos = ia(n)
148  call matrix_sln%add_value_pos(idxglo(ipos), this%hcof(i))
149  !
150  ! -- If mover is active and this boundary is discharging,
151  ! store available water (as positive value).
152  qusr = this%rhs(i) - this%hcof(i) * this%xnew(n)
153  if (this%imover == 1 .and. qusr > dzero) then
154  call this%pakmvrobj%accumulate_qformvr(i, qusr)
155  end if
156  end do
157  end subroutine api_fc
158 
159  ! -- Procedures related to observations
160 
161  !> @brief Determine if observations are supported.
162  !!
163  !! Function to determine if observations are supported by the USR package.
164  !! Observations are supported by the USR package.
165  !!
166  !<
167  logical function api_obs_supported(this)
168  ! -- dummy variables
169  class(apitype) :: this
170  !
171  ! -- set variables
172  api_obs_supported = .true.
173  end function api_obs_supported
174 
175  !> @brief Define the observation types available in the package
176  !!
177  !! Method to define the observation types available in the USR package.
178  !!
179  !<
180  subroutine api_df_obs(this)
181  ! -- dummy variables
182  class(apitype) :: this
183  ! -- local variables
184  integer(I4B) :: indx
185  !
186  ! -- initialize observations
187  call this%obs%StoreObsType('api', .true., indx)
188  this%obs%obsData(indx)%ProcessIdPtr => defaultobsidprocessor
189  !
190  ! -- Store obs type and assign procedure pointer
191  ! for to-mvr observation type.
192  call this%obs%StoreObsType('to-mvr', .true., indx)
193  this%obs%obsData(indx)%ProcessIdPtr => defaultobsidprocessor
194  end subroutine api_df_obs
195 
196 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:89
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:115
logical function api_obs_supported(this)
Determine if observations are supported.
Definition: gwf-api.f90:168
subroutine api_df_obs(this)
Define the observation types available in the package.
Definition: gwf-api.f90:181
subroutine api_fc(this, rhs, ia, idxglo, matrix_sln)
@ brief Fill A and r for the package
Definition: gwf-api.f90:126
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:23
integer(i4b), parameter lenftype
maximum length of a package type (DIS, WEL, OC, etc.)
Definition: Constants.f90:39
real(dp), parameter dzero
real constant zero
Definition: Constants.f90:65
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:246
type(timeserieslinktype) function, pointer, public gettimeserieslinkfromlist(list, indx)
Get time series link from a list.
@ brief BndType