MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
tsp-obs.f90
Go to the documentation of this file.
2 
3  use kindmodule, only: dp, i4b
5  use basedismodule, only: disbasetype
6  use tspicmodule, only: tspictype
7  use observemodule, only: observetype
8  use obsmodule, only: obstype
9  use simmodule, only: count_errors, store_error, &
11  implicit none
12 
13  private
14  public :: tspobstype, tsp_obs_cr
15 
16  type, extends(obstype) :: tspobstype
17  ! -- Private members
18  type(tspictype), pointer, private :: ic => null() ! initial conditions
19  real(dp), dimension(:), pointer, contiguous, private :: x => null() ! concentration
20  real(dp), dimension(:), pointer, contiguous, private :: flowja => null() ! intercell flows
21  contains
22  ! -- Public procedures
23  procedure, public :: tsp_obs_ar
24  procedure, public :: obs_bd => tsp_obs_bd
25  procedure, public :: obs_df => tsp_obs_df
26  procedure, public :: obs_rp => tsp_obs_rp
27  procedure, public :: obs_da => tsp_obs_da
28  ! -- Private procedures
29  procedure, private :: set_pointers
30  end type tspobstype
31 
32 contains
33 
34  !> @brief Create a new TspObsType object
35  !!
36  !! This routine:
37  !! - creates an observation object
38  !! - allocates pointers
39  !! - initializes values
40  !<
41  subroutine tsp_obs_cr(obs, inobs)
42  ! -- dummy
43  type(tspobstype), pointer, intent(out) :: obs
44  integer(I4B), pointer, intent(in) :: inobs
45  !
46  allocate (obs)
47  call obs%allocate_scalars()
48  obs%active = .false.
49  obs%inputFilename = ''
50  obs%inUnitObs => inobs
51  !
52  ! -- Return
53  return
54  end subroutine tsp_obs_cr
55 
56  !> @brief Allocate and read method for package
57  !!
58  !! Method to allocate and read static data for the package.
59  !<
60  subroutine tsp_obs_ar(this, ic, x, flowja)
61  ! -- dummy
62  class(tspobstype), intent(inout) :: this
63  type(tspictype), pointer, intent(in) :: ic
64  real(DP), dimension(:), pointer, contiguous, intent(in) :: x
65  real(DP), dimension(:), pointer, contiguous, intent(in) :: flowja
66  !
67  ! Call ar method of parent class
68  call this%obs_ar()
69  !
70  ! set pointers
71  call this%set_pointers(ic, x, flowja)
72  !
73  ! -- Return
74  return
75  end subroutine tsp_obs_ar
76 
77  !> @brief Define observation object
78  !<
79  subroutine tsp_obs_df(this, iout, pkgname, filtyp, dis)
80  ! -- dummy
81  class(tspobstype), intent(inout) :: this
82  integer(I4B), intent(in) :: iout
83  character(len=*), intent(in) :: pkgname
84  character(len=*), intent(in) :: filtyp
85  class(disbasetype), pointer :: dis
86  ! -- local
87  integer(I4B) :: indx
88  !
89  ! Call overridden method of parent class
90  call this%ObsType%obs_df(iout, pkgname, filtyp, dis)
91  !
92  ! -- StoreObsType arguments are: (ObserveType, cumulative, indx);
93  ! indx is returned.
94  !
95  ! -- Store obs type and assign procedure pointer for head observation type
96  call this%StoreObsType('concentration', .false., indx)
97  this%obsData(indx)%ProcessIdPtr => gwt_process_concentration_obs_id
98  !
99  ! -- Store obs type and assign procedure pointer for flow-ja-face observation type
100  call this%StoreObsType('flow-ja-face', .true., indx)
101  this%obsData(indx)%ProcessIdPtr => tsp_process_intercell_obs_id
102  !
103  ! -- Return
104  return
105  end subroutine tsp_obs_df
106 
107  !> @brief Save observations
108  !<
109  subroutine tsp_obs_bd(this)
110  ! -- dummy
111  class(tspobstype), intent(inout) :: this
112  ! -- local
113  integer(I4B) :: i, jaindex, nodenumber
114  character(len=100) :: msg
115  class(observetype), pointer :: obsrv => null()
116  !
117  call this%obs_bd_clear()
118  !
119  ! -- iterate through all GWT observations
120  if (this%npakobs > 0) then
121  do i = 1, this%npakobs
122  obsrv => this%pakobs(i)%obsrv
123  nodenumber = obsrv%NodeNumber
124  jaindex = obsrv%JaIndex
125  select case (obsrv%ObsTypeId)
126  case ('CONCENTRATION')
127  call this%SaveOneSimval(obsrv, this%x(nodenumber))
128  case ('FLOW-JA-FACE')
129  call this%SaveOneSimval(obsrv, this%flowja(jaindex))
130  case default
131  msg = ' Unrecognized observation type: '//trim(obsrv%ObsTypeId)
132  call store_error(msg)
133  call store_error_unit(this%inUnitObs)
134  end select
135  end do
136  end if
137  !
138  ! -- Return
139  return
140  end subroutine tsp_obs_bd
141 
142  !> @brief If transport model observations need checks, add them here
143  !<
144  subroutine tsp_obs_rp(this)
145  ! -- dummy
146  class(tspobstype), intent(inout) :: this
147  !
148  ! Do GWT observations need any checking? If so, add checks here
149  !
150  ! -- Return
151  return
152  end subroutine tsp_obs_rp
153 
154  !> Deallocate memory
155  !!
156  !! Deallocate memory associated with transport model
157  subroutine tsp_obs_da(this)
158  ! -- dummy
159  class(tspobstype), intent(inout) :: this
160  !
161  nullify (this%ic)
162  nullify (this%x)
163  nullify (this%flowja)
164  call this%ObsType%obs_da()
165  !
166  ! -- Return
167  return
168  end subroutine tsp_obs_da
169 
170  !> @brief Set pointers needed by the transport OBS package
171  !<
172  subroutine set_pointers(this, ic, x, flowja)
173  ! -- dummy
174  class(tspobstype), intent(inout) :: this
175  type(tspictype), pointer, intent(in) :: ic
176  real(DP), dimension(:), pointer, contiguous, intent(in) :: x
177  real(DP), dimension(:), pointer, contiguous, intent(in) :: flowja
178  !
179  this%ic => ic
180  this%x => x
181  this%flowja => flowja
182  !
183  ! -- Return
184  return
185  end subroutine set_pointers
186 
187  !> @brief Procedure related to Tsp observations (NOT type-bound)
188  !!
189  !! Process a specific observation ID
190  !<
191  subroutine gwt_process_concentration_obs_id(obsrv, dis, inunitobs, iout)
192  ! -- dummy
193  type(observetype), intent(inout) :: obsrv
194  class(disbasetype), intent(in) :: dis
195  integer(I4B), intent(in) :: inunitobs
196  integer(I4B), intent(in) :: iout
197  ! -- local
198  integer(I4B) :: nn1
199  integer(I4B) :: icol, istart, istop
200  character(len=LINELENGTH) :: ermsg, string
201  !
202  ! -- Initialize variables
203  string = obsrv%IDstring
204  icol = 1
205  !
206  ! Get node number, with option for ID string to be either node
207  ! number or lay, row, column (when dis is structured).
208  nn1 = dis%noder_from_string(icol, istart, istop, inunitobs, &
209  iout, string, .false.)
210  !
211  if (nn1 > 0) then
212  obsrv%NodeNumber = nn1
213  else
214  ermsg = 'Error reading data from ID string'
215  call store_error(ermsg)
216  call store_error_unit(inunitobs)
217  end if
218  !
219  ! -- Return
220  return
221  end subroutine gwt_process_concentration_obs_id
222 
223  !> @brief Procedure related to Tsp observations (NOT type-bound)
224  !!
225  !! Process an intercell observation requested by the user
226  !<
227  subroutine tsp_process_intercell_obs_id(obsrv, dis, inunitobs, iout)
228  ! -- dummy
229  type(observetype), intent(inout) :: obsrv
230  class(disbasetype), intent(in) :: dis
231  integer(I4B), intent(in) :: inunitobs
232  integer(I4B), intent(in) :: iout
233  ! -- local
234  integer(I4B) :: nn1, nn2
235  integer(I4B) :: icol, istart, istop, jaidx
236  character(len=LINELENGTH) :: ermsg, string
237  ! formats
238 70 format('Error: No connection exists between cells identified in text: ', a)
239  !
240  ! -- Initialize variables
241  string = obsrv%IDstring
242  icol = 1
243  !
244  ! Get node number, with option for ID string to be either node
245  ! number or lay, row, column (when dis is structured).
246  nn1 = dis%noder_from_string(icol, istart, istop, inunitobs, &
247  iout, string, .false.)
248  !
249  if (nn1 > 0) then
250  obsrv%NodeNumber = nn1
251  else
252  ermsg = 'Error reading data from ID string: '//string(istart:istop)
253  call store_error(ermsg)
254  end if
255  !
256  ! Get node number, with option for ID string to be either node
257  ! number or lay, row, column (when dis is structured).
258  nn2 = dis%noder_from_string(icol, istart, istop, inunitobs, &
259  iout, string, .false.)
260  if (nn2 > 0) then
261  obsrv%NodeNumber2 = nn2
262  else
263  ermsg = 'Error reading data from ID string: '//string(istart:istop)
264  call store_error(ermsg)
265  end if
266  !
267  ! -- store JA index
268  jaidx = dis%con%getjaindex(nn1, nn2)
269  if (jaidx == 0) then
270  write (ermsg, 70) trim(string)
271  call store_error(ermsg)
272  end if
273  obsrv%JaIndex = jaidx
274  !
275  if (count_errors() > 0) then
276  call store_error_unit(inunitobs)
277  end if
278  !
279  ! -- Return
280  return
281  end subroutine tsp_process_intercell_obs_id
282 
283 end module tspobsmodule
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition: Constants.f90:44
integer(i4b), parameter maxobstypes
maximum number of observation types
Definition: Constants.f90:47
This module defines variable data types.
Definition: kind.f90:8
This module contains the derived types ObserveType and ObsDataType.
Definition: Observe.f90:15
This module contains the derived type ObsType.
Definition: Obs.f90:127
This module contains simulation methods.
Definition: Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition: Sim.f90:92
integer(i4b) function, public count_errors()
Return number of errors.
Definition: Sim.f90:59
subroutine, public store_error_unit(iunit, terminate)
Store the file unit number.
Definition: Sim.f90:168
subroutine, public tsp_obs_cr(obs, inobs)
Create a new TspObsType object.
Definition: tsp-obs.f90:42
subroutine tsp_process_intercell_obs_id(obsrv, dis, inunitobs, iout)
Procedure related to Tsp observations (NOT type-bound)
Definition: tsp-obs.f90:228
subroutine tsp_obs_da(this)
Deallocate memory.
Definition: tsp-obs.f90:158
subroutine set_pointers(this, ic, x, flowja)
Set pointers needed by the transport OBS package.
Definition: tsp-obs.f90:173
subroutine tsp_obs_rp(this)
If transport model observations need checks, add them here.
Definition: tsp-obs.f90:145
subroutine tsp_obs_ar(this, ic, x, flowja)
Allocate and read method for package.
Definition: tsp-obs.f90:61
subroutine tsp_obs_bd(this)
Save observations.
Definition: tsp-obs.f90:110
subroutine tsp_obs_df(this, iout, pkgname, filtyp, dis)
Define observation object.
Definition: tsp-obs.f90:80
subroutine gwt_process_concentration_obs_id(obsrv, dis, inunitobs, iout)
Procedure related to Tsp observations (NOT type-bound)
Definition: tsp-obs.f90:192