MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
ObsOutput.f90
Go to the documentation of this file.
1 !> @brief This module defines the derived type ObsOutputType
2 !!
3 !! This module contains information and methods needed for writing
4 !! a line of simulated values for observations to an output file. Each
5 !! block of type continuous in an observation file is
6 !! associated with an ObsOutputType object. However, the methods are
7 !! needed only for continuous observations.
8 !!
9 !<
11 
12  use kindmodule, only: dp, i4b, lgp
14  use listmodule, only: listtype
15 
16  implicit none
17 
18  private
21 
22  type :: obsoutputtype
23  ! -- Public members
24  ! kind specified to ensure consistent binary output
25  integer(kind=4), public :: nobs = 0 !< number of observations
26  integer(I4B), public :: nunit = 0 !< observation output unit
27  character(len=500), public :: filename = '' !< observation output filename
28  logical(LGP), public :: empty_line = .true. !< logical indicating if the line for a time step is empty
29  character(len=LENOBSNAME), public :: header = '' !< observation header string
30  logical, public :: formattedoutput = .true. !< logical indicating if writing formatted output
31  contains
32  ! -- Public procedures
33  procedure, public :: resetobsemptyline
34  procedure, public :: writeobslinereturn
35  end type obsoutputtype
36 
37 contains
38 
39  ! Procedures bound to ObsOutputType
40 
41  !> @ brief Reset empty line logical
42  !!
43  !! Subroutine to reset the empty line logical.
44  !!
45  !<
46  subroutine resetobsemptyline(this)
47  ! -- dummy
48  class(obsoutputtype), intent(inout) :: this
49  !
50  this%empty_line = .true.
51  !
52  ! -- return
53  return
54  end subroutine resetobsemptyline
55 
56  !> @ brief Write line return for observation
57  !!
58  !! Subroutine to write a line return for a time step in an observation
59  !! output file.
60  !!
61  !<
62  subroutine writeobslinereturn(this)
63  ! -- dummy
64  class(obsoutputtype), intent(inout) :: this
65  ! -- write a line return to end of observation output line
66  ! for this totim
67  write (this%nunit, '(a)', advance='YES') ''
68  !
69  ! --return
70  return
71  end subroutine writeobslinereturn
72 
73  ! Non-type-bound procedures
74 
75  !> @ brief Cast as ObsOutputType
76  !!
77  !! Cast an object as an ObsOutputType.
78  !!
79  !<
80  function castasobsoutputtype(obj) result(res)
81  ! -- dummy
82  class(*), pointer, intent(inout) :: obj !< input object
83  type(obsoutputtype), pointer :: res !< ObsOutputType
84  !
85  res => null()
86  if (.not. associated(obj)) return
87  !
88  select type (obj)
89  type is (obsoutputtype)
90  res => obj
91  class default
92  continue
93  end select
94  !
95  ! -- return
96  return
97  end function castasobsoutputtype
98 
99  !> @ brief Construct and assign ObsOutputType object
100  !!
101  !! Subroutine to construct an ObsOutputType object and assign
102  !! the observation output file name and unit number.
103  !!
104  !<
105  subroutine constructobsoutput(newObsOutput, fname, nunit)
106  ! -- dummy
107  type(obsoutputtype), pointer, intent(out) :: newobsoutput
108  character(len=*), intent(in) :: fname !< observation output file name
109  integer(I4B), intent(in) :: nunit !< observation output unit number
110  !
111  allocate (newobsoutput)
112  newobsoutput%filename = fname
113  newobsoutput%nunit = nunit
114  !
115  ! -- return
116  return
117  end subroutine constructobsoutput
118 
119  !> @ brief Add observation output to a list
120  !!
121  !! Subroutine to add observation output to a observation list.
122  !!
123  !<
124  subroutine addobsoutputtolist(list, obsOutput)
125  ! -- dummy
126  type(listtype), intent(inout) :: list !< observation list
127  type(obsoutputtype), pointer, intent(inout) :: obsoutput !< observation output
128  ! -- local
129  class(*), pointer :: obj
130  !
131  obj => obsoutput
132  call list%Add(obj)
133  !
134  ! -- return
135  return
136  end subroutine addobsoutputtolist
137 
138  !> @ brief Get observation output from a list
139  !!
140  !! Subroutine to get observation output from a observation list.
141  !!
142  !<
143  function getobsoutputfromlist(list, idx) result(res)
144  implicit none
145  ! -- dummy
146  type(listtype), intent(inout) :: list !< observation list
147  integer(I4B), intent(in) :: idx !< observation index
148  type(obsoutputtype), pointer :: res !< observation output
149  ! -- local
150  class(*), pointer :: obj
151  !
152  obj => list%GetItem(idx)
153  res => castasobsoutputtype(obj)
154  !
155  ! --return
156  return
157  end function getobsoutputfromlist
158 
159 end module obsoutputmodule
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter lenbigline
maximum length of a big line
Definition: Constants.f90:15
integer(i4b), parameter lenobsname
maximum length of a observation name
Definition: Constants.f90:39
This module defines variable data types.
Definition: kind.f90:8
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
subroutine writeobslinereturn(this)
@ brief Write line return for observation
Definition: ObsOutput.f90:63
subroutine resetobsemptyline(this)
@ brief Reset empty line logical
Definition: ObsOutput.f90:47
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
type(obsoutputtype) function, pointer castasobsoutputtype(obj)
@ brief Cast as ObsOutputType
Definition: ObsOutput.f90:81
A generic heterogeneous doubly-linked list.
Definition: List.f90:10