MODFLOW 6  version 6.7.0.dev2
USGS Modular Hydrologic Model
apimodule Module Reference

This module contains the API package methods. More...

Data Types

type  apitype
 

Functions/Subroutines

subroutine, public api_create (packobj, id, ibcnum, inunit, iout, namemodel, pakname, mempath)
 @ brief Create a new package object More...
 
subroutine source_options (this)
 @ brief Source package options from input context More...
 
subroutine source_dimensions (this)
 @ brief Source package dimensions from input context More...
 
subroutine api_rp (this)
 @ brief Read and prepare stress period data for package More...
 
subroutine api_fc (this, rhs, ia, idxglo, matrix_sln)
 @ brief Fill A and r for the package More...
 
logical function api_obs_supported (this)
 Determine if observations are supported. More...
 
subroutine api_df_obs (this)
 Define the observation types available in the package. More...
 

Variables

character(len=lenftype) ftype = 'API'
 
character(len=lenpackagename) text = ' API'
 

Detailed Description

This module contains the overridden methods from the base model package class for the API package. The API package is designed to be used with the shared object and have period data specified using the MODFLOW API. Several methods need to be overridden since no period data are specified in the API input file. Overridden methods include:

  • bnd_rp no period data is specified
  • bnd_fc BOUND array is not filled. hcof and rhs are specified dierctly

Function/Subroutine Documentation

◆ api_create()

subroutine, public apimodule::api_create ( class(bndtype), pointer  packobj,
integer(i4b), intent(in)  id,
integer(i4b), intent(in)  ibcnum,
integer(i4b), intent(in)  inunit,
integer(i4b), intent(in)  iout,
character(len=*), intent(in)  namemodel,
character(len=*), intent(in)  pakname,
character(len=*), intent(in)  mempath 
)

Create a new USR Package object

Parameters
packobjpointer to default package type
[in]idpackage id
[in]ibcnumboundary condition number
[in]inunitunit number of USR package input file
[in]ioutunit number of model listing file
[in]namemodelmodel name
[in]paknamepackage name
[in]mempathinput mempath

Definition at line 49 of file gwf-api.f90.

51  ! -- dummy variables
52  class(BndType), pointer :: packobj !< pointer to default package type
53  integer(I4B), intent(in) :: id !< package id
54  integer(I4B), intent(in) :: ibcnum !< boundary condition number
55  integer(I4B), intent(in) :: inunit !< unit number of USR package input file
56  integer(I4B), intent(in) :: iout !< unit number of model listing file
57  character(len=*), intent(in) :: namemodel !< model name
58  character(len=*), intent(in) :: pakname !< package name
59  character(len=*), intent(in) :: mempath !< input mempath
60  ! -- local variables
61  type(ApiType), pointer :: apiobj
62  !
63  ! -- allocate the object and assign values to object variables
64  allocate (apiobj)
65  packobj => apiobj
66  !
67  ! -- create name and memory path
68  call packobj%set_names(ibcnum, namemodel, pakname, ftype, mempath)
69  packobj%text = text
70  !
71  ! -- allocate scalars
72  call packobj%allocate_scalars()
73  !
74  ! -- initialize package
75  call packobj%pack_initialize()
76  !
77  packobj%inunit = inunit
78  packobj%iout = iout
79  packobj%id = id
80  packobj%ibcnum = ibcnum
81  packobj%ncolbnd = 2
82  packobj%iscloc = 2
83  packobj%ictMemPath = create_mem_path(namemodel, 'NPF')
Here is the call graph for this function:
Here is the caller graph for this function:

◆ api_df_obs()

subroutine apimodule::api_df_obs ( class(apitype this)
private

Method to define the observation types available in the USR package.

Definition at line 244 of file gwf-api.f90.

245  ! -- dummy variables
246  class(ApiType) :: this
247  ! -- local variables
248  integer(I4B) :: indx
249  !
250  ! -- initialize observations
251  call this%obs%StoreObsType('api', .true., indx)
252  this%obs%obsData(indx)%ProcessIdPtr => defaultobsidprocessor
253  !
254  ! -- Store obs type and assign procedure pointer
255  ! for to-mvr observation type.
256  call this%obs%StoreObsType('to-mvr', .true., indx)
257  this%obs%obsData(indx)%ProcessIdPtr => defaultobsidprocessor
Here is the call graph for this function:

◆ api_fc()

subroutine apimodule::api_fc ( class(apitype this,
real(dp), dimension(:), intent(inout)  rhs,
integer(i4b), dimension(:), intent(in)  ia,
integer(i4b), dimension(:), intent(in)  idxglo,
class(matrixbasetype), pointer  matrix_sln 
)
private

Fill the coefficient matrix and right-hand side with the USR package terms.

Parameters
[in,out]rhsright-hand side vector
[in]iapointer to the rows in A matrix
[in]idxgloposition of entries in A matrix
matrix_slnA matrix for solution

Definition at line 189 of file gwf-api.f90.

190  ! -- dummy variables
191  class(ApiType) :: this
192  real(DP), dimension(:), intent(inout) :: rhs !< right-hand side vector
193  integer(I4B), dimension(:), intent(in) :: ia !< pointer to the rows in A matrix
194  integer(I4B), dimension(:), intent(in) :: idxglo !< position of entries in A matrix
195  class(MatrixBaseType), pointer :: matrix_sln !< A matrix for solution
196  ! -- local variables
197  integer(I4B) :: i
198  integer(I4B) :: n
199  integer(I4B) :: ipos
200  real(DP) :: qusr
201  !
202  ! -- pakmvrobj fc
203  if (this%imover == 1) then
204  call this%pakmvrobj%fc()
205  end if
206  !
207  ! -- Copy package rhs and hcof into solution rhs and amat
208  do i = 1, this%nbound
209  n = this%nodelist(i)
210  rhs(n) = rhs(n) + this%rhs(i)
211  ipos = ia(n)
212  call matrix_sln%add_value_pos(idxglo(ipos), this%hcof(i))
213  !
214  ! -- If mover is active and this boundary is discharging,
215  ! store available water (as positive value).
216  qusr = this%rhs(i) - this%hcof(i) * this%xnew(n)
217  if (this%imover == 1 .and. qusr > dzero) then
218  call this%pakmvrobj%accumulate_qformvr(i, qusr)
219  end if
220  end do

◆ api_obs_supported()

logical function apimodule::api_obs_supported ( class(apitype this)
private

Function to determine if observations are supported by the USR package. Observations are supported by the USR package.

Definition at line 231 of file gwf-api.f90.

232  ! -- dummy variables
233  class(ApiType) :: this
234  !
235  ! -- set variables
236  api_obs_supported = .true.

◆ api_rp()

subroutine apimodule::api_rp ( class(apitype), intent(inout)  this)

Method reads and prepares stress period data for the USR package. This method overrides the base read and prepare method and does not read any stress period data from the USR package input file.

Definition at line 178 of file gwf-api.f90.

179  ! -- dummy variables
180  class(ApiType), intent(inout) :: this

◆ source_dimensions()

subroutine apimodule::source_dimensions ( class(apitype), intent(inout)  this)

Definition at line 142 of file gwf-api.f90.

143  use simvariablesmodule, only: errmsg
147  ! -- dummy variables
148  class(ApiType), intent(inout) :: this
149  ! -- local variables
150  type(GwfApiParamFoundType) :: found
151 
152  ! update dimensions from input context
153  call mem_set_value(this%maxbound, 'MAXBOUND', this%input_mempath, &
154  found%maxbound)
155 
156  ! log dimensions
157  write (this%iout, '(/1x,a)') 'PROCESSING '//trim(adjustl(this%text))// &
158  ' DIMENSIONS'
159  write (this%iout, '(4x,a,i7)') 'MAXBOUND = ', this%maxbound
160  write (this%iout, '(1x,a)') &
161  'END OF '//trim(adjustl(this%text))//' DIMENSIONS'
162 
163  ! verify dimensions
164  if (this%maxbound <= 0) then
165  write (errmsg, '(a)') 'MAXBOUND must be an integer greater than zero.'
166  call store_error(errmsg)
167  call store_error_filename(this%input_fname)
168  end if
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=maxcharlen) errmsg
error message string
Here is the call graph for this function:

◆ source_options()

subroutine apimodule::source_options ( class(apitype), intent(inout)  this)
private

Definition at line 88 of file gwf-api.f90.

93  ! -- dummy variables
94  class(ApiType), intent(inout) :: this
95  type(GwfApiParamFoundType) :: found
96  ! -- formats
97  character(len=*), parameter :: fmtflow2 = &
98  &"(4x, 'FLOWS WILL BE SAVED TO BUDGET FILE SPECIFIED IN OUTPUT CONTROL')"
99 
100  ! update default values from input context
101  call mem_set_value(this%iprpak, 'IPRPAK', this%input_mempath, found%iprpak)
102  call mem_set_value(this%iprflow, 'IPRFLOW', this%input_mempath, found%iprflow)
103  call mem_set_value(this%ipakcb, 'IPAKCB', this%input_mempath, found%ipakcb)
104  call mem_set_value(this%inamedbound, 'BOUNDNAMES', this%input_mempath, &
105  found%boundnames)
106  call mem_set_value(this%imover, 'MOVER', this%input_mempath, found%mover)
107 
108  ! update internal state
109  if (found%ipakcb) this%ipakcb = -1
110 
111  ! enforce 0 or 1 OBS6_FILENAME entries in option block
112  if (filein_fname(this%obs%inputFilename, 'OBS6_FILENAME', &
113  this%input_mempath, this%input_fname)) then
114  this%obs%active = .true.
115  this%obs%inUnitObs = getunit()
116  call openfile(this%obs%inUnitObs, this%iout, this%obs%inputFilename, 'OBS')
117  end if
118 
119  ! log package options
120  write (this%iout, '(/1x,a)') 'PROCESSING '//trim(adjustl(this%text)) &
121  //' OPTIONS'
122  if (found%iprpak) then
123  write (this%iout, '(4x,a)') &
124  'LISTS OF '//trim(adjustl(this%text))//' CELLS WILL BE PRINTED.'
125  end if
126  if (found%iprflow) then
127  write (this%iout, '(4x,a)') trim(adjustl(this%text))// &
128  ' FLOWS WILL BE PRINTED TO LISTING FILE.'
129  end if
130  if (found%ipakcb) write (this%iout, fmtflow2)
131  if (found%boundnames) then
132  write (this%iout, '(4x,a)') trim(adjustl(this%text))// &
133  ' BOUNDARIES HAVE NAMES IN LAST COLUMN.'
134  end if
135  if (found%mover) write (this%iout, '(4x,A)') 'MOVER OPTION ENABLED'
136  write (this%iout, '(1x,a)') &
137  'END OF '//trim(adjustl(this%text))//' OPTIONS'
integer(i4b) function, public getunit()
Get a free unit number.
subroutine, public openfile(iu, iout, fname, ftype, fmtarg_opt, accarg_opt, filstat_opt, mode_opt)
Open a file.
Definition: InputOutput.f90:30
This module contains the SourceCommonModule.
Definition: SourceCommon.f90:7
logical(lgp) function, public filein_fname(filename, tagname, input_mempath, input_fname)
enforce and set a single input filename provided via FILEIN keyword
Here is the call graph for this function:

Variable Documentation

◆ ftype

character(len=lenftype) apimodule::ftype = 'API'
private

Definition at line 28 of file gwf-api.f90.

28  character(len=LENFTYPE) :: ftype = 'API'

◆ text

character(len=lenpackagename) apimodule::text = ' API'
private

Definition at line 29 of file gwf-api.f90.

29  character(len=LENPACKAGENAME) :: text = ' API'