MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
observemodule Module Reference

This module contains the derived types ObserveType and ObsDataType. More...

Data Types

type  observetype
 
type  obsdatatype
 
interface  ProcessIdSub
 @ brief Process user-provided IDstring More...
 

Functions/Subroutines

subroutine resetcurrentvalue (this)
 @ brief Reset current observation value More...
 
subroutine writeto (this, obstab, btagfound, fnamein)
 @ brief Write observation input data More...
 
subroutine resetobsindex (this)
 @ brief Reset a observation index More...
 
subroutine addobsindex (this, indx)
 @ brief Add a observation index More...
 
subroutine da (this)
 @ brief Deallocate a observation More...
 
subroutine, public constructobservation (newObservation, defLine, numunit, formatted, indx, obsData, inunit)
 @ brief Construct a new ObserveType More...
 
type(observetype) function, pointer castasobservetype (obj)
 @ brief Cast a object as a ObserveType More...
 
subroutine, public addobstolist (list, obs)
 @ brief Add a ObserveType to a list More...
 
type(observetype) function, pointer, public getobsfromlist (list, idx)
 @ brief Get an ObserveType from a list More...
 

Detailed Description

This module contains the derived types ObserveType and ObsDataType.

  • ObserveType – is designed to contain all information and functionality needed for one observation. ObserveType contains a pointer to an ObsDataType object.
  • ObsDataType – is for storing package ID, observation type, and a pointer to a subroutine that will be called to process the IDstring provided in Obs input. The ProcessIdPtr member of ObsDataType requires a pointer to an ObserveType object.

Function/Subroutine Documentation

◆ addobsindex()

subroutine observemodule::addobsindex ( class(observetype), intent(inout)  this,
integer(i4b), intent(in)  indx 
)
private

Subroutine to add the observation index to the observation index array (indxbnds). The observation index count (indxbnds_count) is also incremented by one and the observation index array is expanded, if necessary.

Parameters
[in]indxobservation index

Definition at line 201 of file Observe.f90.

202  ! -- dummy
203  class(ObserveType), intent(inout) :: this
204  integer(I4B), intent(in) :: indx !< observation index
205  !
206  ! -- Increment the index count
207  this%indxbnds_count = this%indxbnds_count + 1
208  !
209  ! -- Expand the observation index array, if necessary
210  call expandarraywrapper(this%indxbnds_count, this%indxbnds, loginc=.true.)
211  !
212  ! -- add index to observation index
213  this%indxbnds(this%indxbnds_count) = indx
214  !
215  ! -- return
216  return

◆ addobstolist()

subroutine, public observemodule::addobstolist ( type(listtype), intent(inout)  list,
type(observetype), intent(inout), pointer  obs 
)

Subroutine to add a ObserveType to a list.

Parameters
[in,out]listObserveType list
[in,out]obsObserveType

Definition at line 339 of file Observe.f90.

340  ! -- dummy
341  type(ListType), intent(inout) :: list !< ObserveType list
342  type(ObserveType), pointer, intent(inout) :: obs !< ObserveType
343  ! -- local
344  class(*), pointer :: obj
345  !
346  obj => obs
347  call list%Add(obj)
348  !
349  ! -- return
350  return
Here is the caller graph for this function:

◆ castasobservetype()

type(observetype) function, pointer observemodule::castasobservetype ( class(*), intent(inout), pointer  obj)
private

Function to cast an object as a ObserveType object.

Parameters
[in,out]objobject
Returns
returned ObserveType object

Definition at line 316 of file Observe.f90.

317  ! -- dummy
318  class(*), pointer, intent(inout) :: obj !< object
319  ! -- return
320  type(ObserveType), pointer :: res !< returned ObserveType object
321  !
322  res => null()
323  if (.not. associated(obj)) return
324  !
325  select type (obj)
326  type is (observetype)
327  res => obj
328  end select
329  !
330  ! -- return
331  return
Here is the caller graph for this function:

◆ constructobservation()

subroutine, public observemodule::constructobservation ( type(observetype), pointer  newObservation,
character(len=*), intent(in)  defLine,
integer(i4b), intent(in)  numunit,
logical, intent(in)  formatted,
integer(i4b), intent(in)  indx,
type(obsdatatype), dimension(:), intent(in), pointer  obsData,
integer(i4b), intent(in)  inunit 
)

Subroutine to construct and return an ObserveType object based on the contents of defLine.

Parameters
newobservationnew ObserveType
[in]deflinestring with observation data
[in]numunitOutput unit number
[in]formattedlogical indicating if formatted output will be written
[in]indxIndex in ObsOutput array
[in]obsdataobsData type
[in]inunitobservation input file unit

Definition at line 243 of file Observe.f90.

245  ! -- dummy variables
246  type(ObserveType), pointer :: newObservation !< new ObserveType
247  character(len=*), intent(in) :: defLine !< string with observation data
248  integer(I4B), intent(in) :: numunit !< Output unit number
249  logical, intent(in) :: formatted !< logical indicating if formatted output will be written
250  integer(I4B), intent(in) :: indx !< Index in ObsOutput array
251  type(ObsDataType), dimension(:), pointer, intent(in) :: obsData !< obsData type
252  integer(I4B), intent(in) :: inunit !< observation input file unit
253  ! -- local
254  real(DP) :: r
255  integer(I4B) :: i
256  integer(I4B) :: icol
257  integer(I4B) :: iout
258  integer(I4B) :: istart
259  integer(I4B) :: istop
260  integer(I4B) :: n
261  !
262  ! -- initialize
263  iout = 0
264  icol = 1
265  !
266  ! -- Allocate an ObserveType object.
267  allocate (newobservation)
268  allocate (newobservation%indxbnds(0))
269  !
270  ! -- Set indxbnds_count to 0
271  newobservation%indxbnds_count = 0
272  !
273  ! -- Define the contents of the ObservationSingleType object based on the
274  ! contents of defLine.
275  !
276  ! -- Get observation name and store it
277  call urword(defline, icol, istart, istop, 1, n, r, iout, inunit)
278  newobservation%Name = defline(istart:istop)
279  !
280  ! -- Get observation type, convert it to uppercase, and store it.
281  call urword(defline, icol, istart, istop, 1, n, r, iout, inunit)
282  newobservation%ObsTypeId = defline(istart:istop)
283  !
284  ! -- Look up package ID for this observation type and store it
285  do i = 1, maxobstypes
286  if (obsdata(i)%ObsTypeID == newobservation%ObsTypeId) then
287  newobservation%obsDatum => obsdata(i)
288  exit
289  elseif (obsdata(i)%ObsTypeID == '') then
290  exit
291  end if
292  end do
293  !
294  ! -- Remaining text is ID [and ID2]; store the remainder of the string
295  istart = istop + 1
296  istop = len_trim(defline)
297  if (istart > istop) then
298  istart = istop
299  end if
300  newobservation%IDstring = defline(istart:istop)
301  !
302  ! Store UnitNumber, FormattedOutput, and IndxObsOutput
303  newobservation%UnitNumber = numunit
304  newobservation%FormattedOutput = formatted
305  newobservation%IndxObsOutput = indx
306  !
307  ! -- return
308  return
Here is the call graph for this function:
Here is the caller graph for this function:

◆ da()

subroutine observemodule::da ( class(observetype), intent(inout)  this)
private

Subroutine to deallocated a observation (ObserveType).

Definition at line 224 of file Observe.f90.

225  ! -- dummy
226  class(ObserveType), intent(inout) :: this
227  if (allocated(this%indxbnds)) then
228  deallocate (this%indxbnds)
229  end if
230  !
231  ! -- return
232  return

◆ getobsfromlist()

type(observetype) function, pointer, public observemodule::getobsfromlist ( type(listtype), intent(inout)  list,
integer(i4b), intent(in)  idx 
)

Function to get an ObserveType from a list.

Parameters
[in,out]listObserveType list
[in]idxObserveType list index
Returns
returned ObserveType

Definition at line 358 of file Observe.f90.

359  ! -- dummy
360  type(ListType), intent(inout) :: list !< ObserveType list
361  integer(I4B), intent(in) :: idx !< ObserveType list index
362  ! -- return
363  type(ObserveType), pointer :: res !< returned ObserveType
364  ! -- local
365  class(*), pointer :: obj
366  !
367  obj => list%GetItem(idx)
368  res => castasobservetype(obj)
369  !
370  ! -- return
371  return
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetcurrentvalue()

subroutine observemodule::resetcurrentvalue ( class(observetype), intent(inout)  this)

Subroutine to reset the current observation value.

Definition at line 117 of file Observe.f90.

118  ! -- dummy
119  class(ObserveType), intent(inout) :: this
120  !
121  ! -- Reset current value to zero.
122  this%CurrentTimeStepEndValue = dzero
123  !
124  ! -- return
125  return

◆ resetobsindex()

subroutine observemodule::resetobsindex ( class(observetype), intent(inout)  this)
private

Subroutine to reset the observation index count and array.

Definition at line 174 of file Observe.f90.

175  ! -- dummy
176  class(ObserveType), intent(inout) :: this
177  !
178  ! -- Reset the index count
179  this%indxbnds_count = 0
180  !
181  ! -- Deallocate observation index array, if necessary
182  if (allocated(this%indxbnds)) then
183  deallocate (this%indxbnds)
184  end if
185  !
186  ! -- Allocate observation index array to size 0
187  allocate (this%indxbnds(0))
188  !
189  ! -- return
190  return

◆ writeto()

subroutine observemodule::writeto ( class(observetype), intent(inout)  this,
type(tabletype), intent(inout)  obstab,
character(len=*), intent(in)  btagfound,
character(len=*), intent(in)  fnamein 
)
private

Subroutine to write observation input data to a table in the model list file.

Parameters
[in,out]obstabobservation table
[in]btagfoundlogical indicating if boundname was found
[in]fnameinobservation input file name

Definition at line 134 of file Observe.f90.

135  ! -- dummy
136  class(ObserveType), intent(inout) :: this
137  type(TableType), intent(inout) :: obstab !< observation table
138  character(len=*), intent(in) :: btagfound !< logical indicating if boundname was found
139  character(len=*), intent(in) :: fnamein !< observation input file name
140  ! -- local
141  character(len=12) :: tag
142  character(len=80) :: fnameout
143  !
144  ! -- write btagfound to tag
145  if (len_trim(btagfound) > 12) then
146  tag = btagfound(1:12)
147  else
148  write (tag, '(a12)') btagfound
149  end if
150  !
151  ! -- write fnamein to fnameout
152  if (len_trim(fnamein) > 80) then
153  fnameout = fnamein(1:80)
154  else
155  write (fnameout, '(a80)') fnamein
156  end if
157  !
158  ! -- write data to observation table
159  call obstab%add_term(this%Name)
160  call obstab%add_term(tag//trim(this%ObsTypeId))
161  call obstab%add_term('ALL TIMES')
162  call obstab%add_term('"'//trim(this%IDstring)//'"')
163  call obstab%add_term(fnameout)
164  !
165  ! -- return
166  return