MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
ObsOutputList.f90
Go to the documentation of this file.
1 !> @brief This module defines the derived type ObsOutputListType
2 !!
3 !! This module contains a list of ObsOutputType objects and
4 !! methods needed for coordinating between an ObsType object and its
5 !! ObsOutputType objects. Like ObsOutputType, ObsOutputListType is
6 !! needed only for processing continuous observations.
7 !!
8 !<
10 
11  use kindmodule, only: dp, i4b
12  use inputoutputmodule, only: same_word
13  use listmodule, only: listtype
16 
17  implicit none
18 
19  private
20  public :: obsoutputlisttype
21 
23  ! -- Private members
24  type(listtype), private :: obsoutputs
25  contains
26  ! -- Public procedures
27  procedure, public :: add
28  procedure, public :: resetallobsemptylines
29  procedure, public :: containsfile
30  procedure, public :: count
31  procedure, public :: get
32  procedure, public :: writeallobslinereturns
33  procedure, public :: clear
34  procedure, public :: deallocobsoutputlist
35  end type obsoutputlisttype
36 
37 contains
38 
39  !> @ brief Reset empty line logical for all observations
40  !!
41  !! Subroutine to reset the empty line logical for all ObsOutputType
42  !! objects in the list.
43  !!
44  !<
45  subroutine resetallobsemptylines(this)
46  ! -- dummy
47  class(obsoutputlisttype), intent(inout) :: this
48  ! -- local
49  integer(I4B) :: i, num
50  type(obsoutputtype), pointer :: obsOutput => null()
51  !
52  num = this%Count()
53  do i = 1, num
54  obsoutput => this%Get(i)
55  call obsoutput%ResetObsEmptyLine()
56  end do
57  !
58  ! -- return
59  return
60  end subroutine resetallobsemptylines
61 
62  !> @ brief Count the number of ObsOutputType objects
63  !!
64  !! Subroutine to return the number of ObsOutputType objects in the list.
65  !!
66  !<
67  function count(this)
68  ! -- return
69  integer(I4B) :: count !< number of ObsOutputType objects
70  ! -- dummy
71  class(obsoutputlisttype), intent(inout) :: this
72  !
73  count = this%ObsOutputs%Count()
74  !
75  ! -- return
76  return
77  end function count
78 
79  !> @ brief Determine if a file name is in the list of ObsOutputType objects
80  !!
81  !! Function to determine if a file name is in the list of
82  !! ObsOutptType objects.
83  !!
84  !<
85  logical function containsfile(this, fname)
86  ! -- dummy
87  class(obsoutputlisttype), intent(inout) :: this
88  character(len=*), intent(in) :: fname !< observation output file name
89  ! -- local
90  type(obsoutputtype), pointer :: obsoutput => null()
91  integer(I4B) :: i, n
92  !
93  containsfile = .false.
94  n = this%Count()
95  loop1: do i = 1, n
96  obsoutput => this%Get(i)
97  if (same_word(obsoutput%filename, fname)) then
98  containsfile = .true.
99  exit loop1
100  end if
101  end do loop1
102  !
103  ! -- return
104  return
105  end function containsfile
106 
107  !> @ brief Add a ObsOutputType object to the list
108  !!
109  !! Subroutine to add a new ObsOutputType object to the ObsOutputList and
110  !! assign ObsOutputType members.
111  !!
112  !<
113  subroutine add(this, fname, nunit)
114  ! -- dummy
115  class(obsoutputlisttype), intent(inout) :: this
116  character(len=*), intent(in) :: fname !< observation output file name
117  integer(I4B), intent(in) :: nunit !< observation output unit number
118  ! -- local
119  type(obsoutputtype), pointer :: obsOutput => null()
120  !
121  call constructobsoutput(obsoutput, fname, nunit)
122  call addobsoutputtolist(this%ObsOutputs, obsoutput)
123  !
124  ! -- return
125  return
126  end subroutine add
127 
128  !> @ brief Write line returns for all ObsOutputListType
129  !!
130  !! Subroutine to write line returns for a time step for all observation
131  !! output files in a ObsOutputListType.
132  !!
133  !<
134  subroutine writeallobslinereturns(this)
135  ! -- dummy
136  class(obsoutputlisttype), intent(inout) :: this
137  ! -- local
138  type(obsoutputtype), pointer :: obsOutput => null()
139  integer(I4B) :: i, num
140  !
141  num = this%Count()
142  do i = 1, num
143  obsoutput => this%Get(i)
144  if (obsoutput%FormattedOutput) then
145  call obsoutput%WriteObsLineReturn()
146  end if
147  end do
148  !
149  ! -- return
150  return
151  end subroutine writeallobslinereturns
152 
153  !> @ brief Get an item from a ObsOutputListType
154  !!
155  !! Function to get a ObsOutputType from a ObsOutputListType list.
156  !!
157  !<
158  function get(this, indx) result(obsOutput)
159  ! -- dummy
160  class(obsoutputlisttype), intent(inout) :: this
161  integer(I4B), intent(in) :: indx !< index for ObsOutputType object
162  ! result
163  type(obsoutputtype), pointer :: obsoutput
164  !
165  obsoutput => getobsoutputfromlist(this%ObsOutputs, indx)
166  !
167  ! -- return
168  return
169  end function get
170 
171  !> @ brief Clear a ObsOutputListType
172  !!
173  !! Subroutine to clear a ObsOutputListType list.
174  !!
175  !<
176  subroutine clear(this)
177  ! -- dummy
178  class(obsoutputlisttype), intent(inout) :: this
179  !
180  call this%ObsOutputs%Clear()
181  !
182  ! -- return
183  return
184  end subroutine clear
185 
186  !> @ brief Deallocate a ObsOutputListType
187  !!
188  !! Subroutine to deallocate a ObsOutputListType list.
189  !!
190  !<
191  subroutine deallocobsoutputlist(this)
192  ! -- dummy
193  class(obsoutputlisttype), intent(inout) :: this
194  ! -- local
195  integer :: i, n
196  type(obsoutputtype), pointer :: obsoutput => null()
197  !
198  n = this%Count()
199  do i = 1, n
200  obsoutput => getobsoutputfromlist(this%ObsOutputs, i)
201  !call obsoutput%DeallocObsOutput()
202  end do
203  !
204  call this%ObsOutputs%Clear(.true.)
205  !
206  ! -- return
207  return
208  end subroutine deallocobsoutputlist
209 
210 end module obsoutputlistmodule
logical function, public same_word(word1, word2)
Perform a case-insensitive comparison of two words.
This module defines variable data types.
Definition: kind.f90:8
This module defines the derived type ObsOutputListType.
logical function containsfile(this, fname)
@ brief Determine if a file name is in the list of ObsOutputType objects
subroutine deallocobsoutputlist(this)
@ brief Deallocate a ObsOutputListType
subroutine clear(this)
@ brief Clear a ObsOutputListType
subroutine add(this, fname, nunit)
@ brief Add a ObsOutputType object to the list
integer(i4b) function count(this)
@ brief Count the number of ObsOutputType objects
subroutine resetallobsemptylines(this)
@ brief Reset empty line logical for all observations
type(obsoutputtype) function, pointer get(this, indx)
@ brief Get an item from a ObsOutputListType
subroutine writeallobslinereturns(this)
@ brief Write line returns for all ObsOutputListType
This module defines the derived type ObsOutputType.
Definition: ObsOutput.f90:10
subroutine, public addobsoutputtolist(list, obsOutput)
@ brief Add observation output to a list
Definition: ObsOutput.f90:125
type(obsoutputtype) function, pointer, public getobsoutputfromlist(list, idx)
@ brief Get observation output from a list
Definition: ObsOutput.f90:144
subroutine, public constructobsoutput(newObsOutput, fname, nunit)
@ brief Construct and assign ObsOutputType object
Definition: ObsOutput.f90:106
A generic heterogeneous doubly-linked list.
Definition: List.f90:10