MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
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)
 Create a new package object.
subroutine source_options (this)
 Source package options from input context.
subroutine source_dimensions (this)
 Source package dimensions from input context.
subroutine api_rp (this)
 Read and prepare stress period data for package.
subroutine api_fc (this, rhs, ia, idxglo, matrix_sln)
 Fill A and r for the package.
logical function api_obs_supported (this)
 Determine if observations are supported.
subroutine api_df_obs (this)
 Define the observation types available in the package.

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 48 of file ApiPackage.f90.

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

243 ! -- dummy variables
244 class(ApiType) :: this
245 ! -- local variables
246 integer(I4B) :: indx
247 !
248 ! -- initialize observations
249 call this%obs%StoreObsType('api', .true., indx)
250 this%obs%obsData(indx)%ProcessIdPtr => defaultobsidprocessor
251 !
252 ! -- Store obs type and assign procedure pointer
253 ! for to-mvr observation type.
254 call this%obs%StoreObsType('to-mvr', .true., indx)
255 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 187 of file ApiPackage.f90.

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

230 ! -- dummy variables
231 class(ApiType) :: this
232 !
233 ! -- set variables
234 api_obs_supported = .true.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ api_rp()

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

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 176 of file ApiPackage.f90.

177 ! -- dummy variables
178 class(ApiType), intent(inout) :: this

◆ source_dimensions()

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

Definition at line 141 of file ApiPackage.f90.

142 use simvariablesmodule, only: errmsg
145 ! -- dummy variables
146 class(ApiType), intent(inout) :: this
147 ! -- local variables
148 logical(LGP) :: found_maxbound
149
150 ! update dimensions from input context
151 call mem_set_value(this%maxbound, 'MAXBOUND', this%input_mempath, &
152 found_maxbound)
153
154 ! log dimensions
155 write (this%iout, '(/1x,a)') 'PROCESSING '//trim(adjustl(this%text))// &
156 ' DIMENSIONS'
157 write (this%iout, '(4x,a,i7)') 'MAXBOUND = ', this%maxbound
158 write (this%iout, '(1x,a)') &
159 'END OF '//trim(adjustl(this%text))//' DIMENSIONS'
160
161 ! verify dimensions
162 if (this%maxbound <= 0) then
163 write (errmsg, '(a)') 'MAXBOUND must be an integer greater than zero.'
164 call store_error(errmsg)
165 call store_error_filename(this%input_fname)
166 end if
This module contains simulation methods.
Definition Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition Sim.f90:94
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
Definition Sim.f90:208
This module contains simulation variables.
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 86 of file ApiPackage.f90.

90 ! -- dummy variables
91 class(ApiType), intent(inout) :: this
92 ! -- local variables
93 logical(LGP) :: found_iprpak, found_iprflow, found_ipakcb
94 logical(LGP) :: found_boundnames, found_mover
95 ! -- formats
96 character(len=*), parameter :: fmtflow2 = &
97 &"(4x, 'FLOWS WILL BE SAVED TO BUDGET FILE SPECIFIED IN OUTPUT CONTROL')"
98
99 ! update default values from input context
100 call mem_set_value(this%iprpak, 'IPRPAK', this%input_mempath, found_iprpak)
101 call mem_set_value(this%iprflow, 'IPRFLOW', this%input_mempath, found_iprflow)
102 call mem_set_value(this%ipakcb, 'IPAKCB', this%input_mempath, found_ipakcb)
103 call mem_set_value(this%inamedbound, 'BOUNDNAMES', this%input_mempath, &
104 found_boundnames)
105 call mem_set_value(this%imover, 'MOVER', this%input_mempath, found_mover)
106
107 ! update internal state
108 if (found_ipakcb) this%ipakcb = -1
109
110 ! enforce 0 or 1 OBS6_FILENAME entries in option block
111 if (filein_fname(this%obs%inputFilename, 'OBS6_FILENAME', &
112 this%input_mempath, this%input_fname)) then
113 this%obs%active = .true.
114 this%obs%inUnitObs = getunit()
115 call openfile(this%obs%inUnitObs, this%iout, this%obs%inputFilename, 'OBS')
116 end if
117
118 ! log package options
119 write (this%iout, '(/1x,a)') 'PROCESSING '//trim(adjustl(this%text)) &
120 //' OPTIONS'
121 if (found_iprpak) then
122 write (this%iout, '(4x,a)') &
123 'LISTS OF '//trim(adjustl(this%text))//' CELLS WILL BE PRINTED.'
124 end if
125 if (found_iprflow) then
126 write (this%iout, '(4x,a)') trim(adjustl(this%text))// &
127 ' FLOWS WILL BE PRINTED TO LISTING FILE.'
128 end if
129 if (found_ipakcb) write (this%iout, fmtflow2)
130 if (found_boundnames) then
131 write (this%iout, '(4x,a)') trim(adjustl(this%text))// &
132 ' BOUNDARIES HAVE NAMES IN LAST COLUMN.'
133 end if
134 if (found_mover) write (this%iout, '(4x,A)') 'MOVER OPTION ENABLED'
135 write (this%iout, '(1x,a)') &
136 '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.
This module contains the SourceCommonModule.
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 27 of file ApiPackage.f90.

◆ text

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

Definition at line 28 of file ApiPackage.f90.