MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
RectangularGeometry.f90
Go to the documentation of this file.
2  use kindmodule, only: dp, i4b
4  use constantsmodule, only: dzero
5  implicit none
6  private
8 
10  real(dp) :: height = dzero
11  real(dp) :: width = dzero
12 
13  contains
14 
15  procedure :: area_sat
16  procedure :: perimeter_sat
17  procedure :: area_wet
18  procedure :: perimeter_wet
19  procedure :: set_attribute
20  procedure :: print_attributes
22 
23 contains
24 
25  !> @brief Return saturated area
26  !<
27  function area_sat(this)
28  ! -- modules
29  use constantsmodule, only: dtwo, dpi
30  ! -- return
31  real(dp) :: area_sat
32  ! -- dummy
33  class(rectangulargeometrytype) :: this
34  !
35  ! -- Calculate area
36  area_sat = this%height * this%width
37  end function area_sat
38 
39  !> @brief Return saturated perimeter
40  !<
41  function perimeter_sat(this)
42  ! -- modules
43  use constantsmodule, only: dtwo, dpi
44  ! -- return
45  real(dp) :: perimeter_sat
46  ! -- dummy
47  class(rectangulargeometrytype) :: this
48  !
49  ! -- Calculate area
50  perimeter_sat = dtwo * (this%height + this%width)
51  end function perimeter_sat
52 
53  !> @brief Return wetted area
54  !<
55  function area_wet(this, depth)
56  ! -- modules
57  use constantsmodule, only: dtwo, dpi, dzero
58  ! -- return
59  real(dp) :: area_wet
60  ! -- dummy
61  class(rectangulargeometrytype) :: this
62  real(dp), intent(in) :: depth
63  !
64  ! -- Calculate area
65  if (depth <= dzero) then
66  area_wet = dzero
67  elseif (depth <= this%height) then
68  area_wet = depth * this%width
69  else
70  area_wet = this%width * this%height
71  end if
72  end function area_wet
73 
74  !> @brief Return wetted perimeter
75  !<
76  function perimeter_wet(this, depth)
77  ! -- modules
78  use constantsmodule, only: dtwo, dpi
79  ! -- return
80  real(dp) :: perimeter_wet
81  ! -- dummy
82  class(rectangulargeometrytype) :: this
83  real(dp), intent(in) :: depth
84  !
85  ! -- Calculate area
86  if (depth <= dzero) then
87  perimeter_wet = dzero
88  elseif (depth <= this%height) then
89  perimeter_wet = dtwo * (depth + this%width)
90  else
91  perimeter_wet = dtwo * (this%height + this%width)
92  end if
93  end function perimeter_wet
94 
95  !> @brief Set a parameter for this rectangular object
96  !<
97  subroutine set_attribute(this, line)
98  ! -- module
99  use inputoutputmodule, only: urword
100  use constantsmodule, only: linelength
102  ! -- dummy
103  class(rectangulargeometrytype) :: this
104  character(len=LINELENGTH) :: errmsg
105  character(len=*), intent(inout) :: line
106  ! -- local
107  integer(I4B) :: lloc, istart, istop, ival
108  real(DP) :: rval
109  !
110  ! -- should change this and set id if uninitialized or store it
111  lloc = 1
112  call urword(line, lloc, istart, istop, 2, ival, rval, 0, 0)
113  this%id = ival
114  !
115  ! -- Parse the attribute
116  call urword(line, lloc, istart, istop, 1, ival, rval, 0, 0)
117  select case (line(istart:istop))
118  case ('NAME')
119  call urword(line, lloc, istart, istop, 1, ival, rval, 0, 0)
120  this%name = line(istart:istop)
121  case ('HEIGHT')
122  call urword(line, lloc, istart, istop, 3, ival, rval, 0, 0)
123  this%height = rval
124  case ('WIDTH')
125  call urword(line, lloc, istart, istop, 3, ival, rval, 0, 0)
126  this%width = rval
127  case default
128  write (errmsg, '(a,a)') &
129  'Unknown rectangular geometry attribute: ', line(istart:istop)
130  call store_error(errmsg, terminate=.true.)
131  end select
132  end subroutine set_attribute
133 
134  !> @brief Print the attributes for this object
135  !<
136  subroutine print_attributes(this, iout)
137  ! -- dummy
138  class(rectangulargeometrytype) :: this
139  ! -- local
140  integer(I4B), intent(in) :: iout
141  ! -- formats
142  character(len=*), parameter :: fmtnm = "(4x,a,a)"
143  character(len=*), parameter :: fmttd = "(4x,a,1(1PG15.6))"
144  !
145  ! -- call parent to print parent attributes
146  call this%BaseGeometryType%print_attributes(iout)
147  !
148  ! -- Print specifics of this geometry type
149  write (iout, fmttd) 'HEIGHT = ', this%height
150  write (iout, fmttd) 'WIDTH = ', this%width
151  write (iout, fmttd) 'SATURATED AREA = ', this%area_sat()
152  write (iout, fmttd) 'SATURATED WETTED PERIMETER = ', this%perimeter_sat()
153  end subroutine print_attributes
154 
155 end module rectangulargeometrymodule
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition: Constants.f90:45
real(dp), parameter dpi
real constant
Definition: Constants.f90:128
real(dp), parameter dzero
real constant zero
Definition: Constants.f90:65
real(dp), parameter dtwo
real constant 2
Definition: Constants.f90:79
subroutine, public urword(line, icol, istart, istop, ncode, n, r, iout, in)
Extract a word from a string.
This module defines variable data types.
Definition: kind.f90:8
real(dp) function perimeter_sat(this)
Return saturated perimeter.
real(dp) function perimeter_wet(this, depth)
Return wetted perimeter.
subroutine set_attribute(this, line)
Set a parameter for this rectangular object.
subroutine print_attributes(this, iout)
Print the attributes for this object.
real(dp) function area_sat(this)
Return saturated area.
real(dp) function area_wet(this, depth)
Return wetted area.
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