MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
swf-cxs.f90
Go to the documentation of this file.
1 ! The SwfCxsType package is assigned for a model
2 ! and can be used to calculate wetted area, wetted
3 ! perimeter, hydraulic radius, composite roughness, etc.
4 ! even if the user doesn't specify a CXS Package.
6 
7  use kindmodule, only: dp, i4b, lgp
14  use basedismodule, only: disbasetype
15 
16  implicit none
17  private
18  public :: swfcxstype, cxs_cr
19 
20  type, extends(numericalpackagetype) :: swfcxstype
21 
22  ! provided as input
23  integer(I4B), pointer :: nsections => null() !< number of cross section
24  integer(I4B), pointer :: npoints => null() !< total number of cross-section points
25  integer(I4B), dimension(:), pointer, contiguous :: idcxs => null() !< cross section id number, size nsections
26  integer(I4B), dimension(:), pointer, contiguous :: nxspoints => null() !< number of cross section points for section, size nsections
27  real(dp), dimension(:), pointer, contiguous :: xfraction => null() !< cross-section relative x distance, of size npoints
28  real(dp), dimension(:), pointer, contiguous :: height => null() !< cross-section heights, of size npoints
29  real(dp), dimension(:), pointer, contiguous :: manfraction => null() !< cross-section roughness data, of size npoints
30 
31  ! calculated from input
32  integer(I4B), dimension(:), pointer, contiguous :: iacross => null() !< pointers to cross-section data for each section, of size nsections + 1
33 
34  contains
35 
36  procedure :: allocate_scalars
37  procedure :: allocate_arrays
38  procedure :: source_options
39  procedure :: log_options
40  procedure :: source_dimensions
41  procedure :: log_dimensions
42  procedure :: source_packagedata
43  procedure :: log_packagedata
45  procedure :: log_crosssectiondata
46  procedure :: cxs_da
48  procedure :: get_area
49  procedure :: get_wetted_perimeter => cxs_wetted_perimeter
50  procedure :: get_roughness
51  procedure :: get_conveyance => cxs_conveyance
52  procedure :: get_hydraulic_radius
53  procedure :: write_cxs_table
54 
55  end type swfcxstype
56 
57 contains
58 
59  !> @brief create package
60  !<
61  subroutine cxs_cr(pobj, name_model, input_mempath, inunit, iout, dis)
62  ! -- modules
64  ! -- dummy
65  type(swfcxstype), pointer :: pobj
66  character(len=*), intent(in) :: name_model
67  character(len=*), intent(in) :: input_mempath
68  integer(I4B), intent(in) :: inunit
69  integer(I4B), intent(in) :: iout
70  class(disbasetype), pointer, intent(inout) :: dis !< the pointer to the discretization
71  ! -- locals
72  logical(LGP) :: found_fname
73  ! -- formats
74  character(len=*), parameter :: fmtheader = &
75  "(1x, /1x, 'CXS -- CROSS SECTION PACKAGE, VERSION 1, 5/24/2023', &
76  &' INPUT READ FROM MEMPATH: ', A, /)"
77  !
78  ! -- Create the object
79  allocate (pobj)
80 
81  ! -- create name and memory path
82  call pobj%set_names(1, name_model, 'CXS', 'CXS')
83 
84  ! -- Allocate scalars
85  call pobj%allocate_scalars()
86 
87  ! -- Set variables
88  pobj%input_mempath = input_mempath
89  pobj%inunit = inunit
90  pobj%iout = iout
91  pobj%dis => dis
92 
93  ! -- set name of input file
94  call mem_set_value(pobj%input_fname, 'INPUT_FNAME', pobj%input_mempath, &
95  found_fname)
96 
97  ! -- check if package is enabled
98  if (inunit > 0) then
99 
100  ! -- Print a message identifying the package.
101  write (iout, fmtheader) input_mempath
102 
103  ! -- source options
104  call pobj%source_options()
105 
106  ! -- source dimensions
107  call pobj%source_dimensions()
108 
109  ! -- allocate arrays
110  call pobj%allocate_arrays()
111 
112  ! -- source dimensions
113  call pobj%source_packagedata()
114 
115  ! -- source dimensions
116  call pobj%source_crosssectiondata()
117 
118  end if
119 
120  ! -- Return
121  return
122  end subroutine cxs_cr
123 
124  !> @ brief Allocate scalars
125  !!
126  !! Allocate and initialize scalars for the package. The base model
127  !! allocate scalars method is also called.
128  !!
129  !<
130  subroutine allocate_scalars(this)
131  ! -- modules
132  ! -- dummy
133  class(swfcxstype) :: this
134  !
135  ! -- allocate scalars in NumericalPackageType
136  call this%NumericalPackageType%allocate_scalars()
137  !
138  ! -- Allocate scalars
139  call mem_allocate(this%nsections, 'NSECTIONS', this%memoryPath)
140  call mem_allocate(this%npoints, 'NPOINTS', this%memoryPath)
141 
142  ! -- initialize
143  this%nsections = 0
144  this%npoints = 0
145 
146  return
147  end subroutine allocate_scalars
148 
149  !> @brief Copy options from IDM into package
150  !<
151  subroutine source_options(this)
152  ! -- modules
153  use kindmodule, only: lgp
157  ! -- dummy
158  class(swfcxstype) :: this
159  ! -- locals
160  character(len=LENMEMPATH) :: idmMemoryPath
161  type(swfcxsparamfoundtype) :: found
162  !
163  ! -- set memory path
164  idmmemorypath = create_mem_path(this%name_model, 'CXS', idm_context)
165  !
166  ! -- update defaults with idm sourced values
167  call mem_set_value(this%iprpak, 'PRINT_INPUT', idmmemorypath, &
168  found%iprpak)
169  !
170  ! -- log values to list file
171  if (this%iout > 0) then
172  call this%log_options(found)
173  end if
174  !
175  ! -- Return
176  return
177  end subroutine source_options
178 
179  !> @brief Write user options to list file
180  !<
181  subroutine log_options(this, found)
183  class(swfcxstype) :: this
184  type(swfcxsparamfoundtype), intent(in) :: found
185 
186  write (this%iout, '(1x,a)') 'Setting CXS Options'
187 
188  if (found%iprpak) then
189  write (this%iout, '(4x,a)') 'Package information will be printed.'
190  end if
191 
192  write (this%iout, '(1x,a,/)') 'End Setting CXS Options'
193 
194  end subroutine log_options
195 
196  !> @brief Copy options from IDM into package
197  !<
198  subroutine source_dimensions(this)
199  ! -- modules
200  use kindmodule, only: lgp
204  ! -- dummy
205  class(swfcxstype) :: this
206  ! -- locals
207  character(len=LENMEMPATH) :: idmMemoryPath
208  type(swfcxsparamfoundtype) :: found
209  !
210  ! -- set memory path
211  idmmemorypath = create_mem_path(this%name_model, 'CXS', idm_context)
212  !
213  ! -- update defaults with idm sourced values
214  call mem_set_value(this%nsections, 'NSECTIONS', idmmemorypath, &
215  found%nsections)
216  call mem_set_value(this%npoints, 'NPOINTS', idmmemorypath, &
217  found%npoints)
218  !
219  ! -- ensure nsections was found
220  if (.not. found%nsections) then
221  write (errmsg, '(a)') 'Error in DIMENSIONS block: NSECTIONS not found.'
222  call store_error(errmsg)
223  end if
224  !
225  ! -- ensure npoints was found
226  if (.not. found%npoints) then
227  write (errmsg, '(a)') 'Error in DIMENSIONS block: NPOINTS not found.'
228  call store_error(errmsg)
229  end if
230  !
231  ! -- log values to list file
232  if (this%iout > 0) then
233  call this%log_dimensions(found)
234  end if
235  !
236  ! -- Return
237  return
238  end subroutine source_dimensions
239 
240  !> @brief Write user options to list file
241  !<
242  subroutine log_dimensions(this, found)
244  class(swfcxstype) :: this
245  type(swfcxsparamfoundtype), intent(in) :: found
246 
247  write (this%iout, '(1x,a)') 'Setting CXS Dimensions'
248 
249  if (found%nsections) then
250  write (this%iout, '(4x,a)') 'NSECTIONS set from input file.'
251  end if
252 
253  if (found%npoints) then
254  write (this%iout, '(4x,a)') 'NPOINTS set from input file.'
255  end if
256 
257  write (this%iout, '(1x,a,/)') 'End Setting CXS Dimensions'
258 
259  end subroutine log_dimensions
260 
261  !> @brief allocate memory for arrays
262  !<
263  subroutine allocate_arrays(this)
264  ! -- dummy
265  class(swfcxstype) :: this
266  ! -- locals
267  integer(I4B) :: n
268  !
269  ! -- arrays allocation
270  call mem_allocate(this%idcxs, this%nsections, &
271  'IDCXS', this%memoryPath)
272  call mem_allocate(this%nxspoints, this%nsections, &
273  'NXSPOINTS', this%memoryPath)
274  call mem_allocate(this%xfraction, this%npoints, &
275  'XFRACTION', this%memoryPath)
276  call mem_allocate(this%height, this%npoints, &
277  'HEIGHT', this%memoryPath)
278  call mem_allocate(this%manfraction, this%npoints, &
279  'MANFRACTION', this%memoryPath)
280  call mem_allocate(this%iacross, this%nsections + 1, &
281  'IACROSS', this%memoryPath)
282 
283  ! -- initialization
284  do n = 1, this%nsections
285  this%idcxs(n) = 0
286  this%nxspoints(n) = 0
287  end do
288  do n = 1, this%npoints
289  this%xfraction(n) = dzero
290  this%height(n) = dzero
291  this%manfraction(n) = dzero
292  end do
293  do n = 1, this%nsections + 1
294  this%iacross(n) = 0
295  end do
296 
297  ! -- Return
298  return
299  end subroutine allocate_arrays
300 
301  !> @brief Copy options from IDM into package
302  !<
303  subroutine source_packagedata(this)
304  ! -- modules
305  use kindmodule, only: lgp
309  ! -- dummy
310  class(swfcxstype) :: this
311  ! -- locals
312  character(len=LENMEMPATH) :: idmMemoryPath
313  type(swfcxsparamfoundtype) :: found
314  !
315  ! -- set memory path
316  idmmemorypath = create_mem_path(this%name_model, 'CXS', idm_context)
317  !
318  ! -- update defaults with idm sourced values
319  call mem_set_value(this%idcxs, 'IDCXS', idmmemorypath, &
320  found%idcxs)
321  call mem_set_value(this%nxspoints, 'NXSPOINTS', idmmemorypath, &
322  found%nxspoints)
323  !
324  ! -- ensure idcxs was found
325  if (.not. found%idcxs) then
326  write (errmsg, '(a)') 'Error in PACKAGEDATA block: IDCXS not found.'
327  call store_error(errmsg)
328  end if
329  !
330  ! -- ensure nxspoints was found
331  if (.not. found%nxspoints) then
332  write (errmsg, '(a)') 'Error in PACKAGEDATA block: NXSPOINTS not found.'
333  call store_error(errmsg)
334  end if
335  !
336  ! -- log values to list file
337  if (this%iout > 0) then
338  call this%log_packagedata(found)
339  end if
340  !
341  ! -- Calculate the iacross index array using nxspoints
342  call calc_iacross(this%nxspoints, this%iacross)
343  !
344  ! -- Return
345  return
346  end subroutine source_packagedata
347 
348  !> @brief Calculate index pointer array iacross from nxspoints
349  !<
350  subroutine calc_iacross(nxspoints, iacross)
351  integer(I4B), dimension(:), intent(in) :: nxspoints
352  integer(I4B), dimension(:), intent(inout) :: iacross
353  integer(I4B) :: n
354  iacross(1) = 1
355  do n = 1, size(nxspoints)
356  iacross(n + 1) = iacross(n) + nxspoints(n)
357  end do
358  end subroutine calc_iacross
359 
360  !> @brief Write user packagedata to list file
361  !<
362  subroutine log_packagedata(this, found)
364  class(swfcxstype) :: this
365  type(swfcxsparamfoundtype), intent(in) :: found
366 
367  write (this%iout, '(1x,a)') 'Setting CXS Package Data'
368 
369  if (found%idcxs) then
370  write (this%iout, '(4x,a)') 'IDCXS set from input file.'
371  end if
372 
373  if (found%nxspoints) then
374  write (this%iout, '(4x,a)') 'NXSPOINTS set from input file.'
375  end if
376 
377  write (this%iout, '(1x,a,/)') 'End Setting CXS Package Data'
378 
379  end subroutine log_packagedata
380 
381  !> @brief Copy options from IDM into package
382  !<
383  subroutine source_crosssectiondata(this)
384  ! -- modules
385  use kindmodule, only: lgp
389  ! -- dummy
390  class(swfcxstype) :: this
391  ! -- locals
392  character(len=LENMEMPATH) :: idmMemoryPath
393  type(swfcxsparamfoundtype) :: found
394  !
395  ! -- set memory path
396  idmmemorypath = create_mem_path(this%name_model, 'CXS', idm_context)
397  !
398  ! -- update defaults with idm sourced values
399  call mem_set_value(this%xfraction, 'XFRACTION', idmmemorypath, &
400  found%xfraction)
401  call mem_set_value(this%height, 'HEIGHT', idmmemorypath, &
402  found%height)
403  call mem_set_value(this%manfraction, 'MANFRACTION', idmmemorypath, &
404  found%manfraction)
405  !
406  ! -- ensure xfraction was found
407  if (.not. found%xfraction) then
408  write (errmsg, '(a)') &
409  'Error in CROSSSECTIONDATA block: xfraction not found.'
410  call store_error(errmsg)
411  end if
412  !
413  ! -- ensure height was found
414  if (.not. found%height) then
415  write (errmsg, '(a)') &
416  'Error in CROSSSECTIONDATA block: HEIGHT not found.'
417  call store_error(errmsg)
418  end if
419  !
420  ! -- ensure manfraction was found
421  if (.not. found%manfraction) then
422  write (errmsg, '(a)') &
423  'Error in CROSSSECTIONDATA block: MANFRACTION not found.'
424  call store_error(errmsg)
425  end if
426  !
427  ! -- log values to list file
428  if (this%iout > 0) then
429  call this%log_crosssectiondata(found)
430  end if
431  !
432  ! -- Return
433  return
434  end subroutine source_crosssectiondata
435 
436  !> @brief Write user packagedata to list file
437  !<
438  subroutine log_crosssectiondata(this, found)
440  class(swfcxstype) :: this
441  type(swfcxsparamfoundtype), intent(in) :: found
442 
443  write (this%iout, '(1x,a)') 'Setting CXS Cross Section Data'
444 
445  if (found%xfraction) then
446  write (this%iout, '(4x,a)') 'XFRACTION set from input file.'
447  end if
448 
449  if (found%height) then
450  write (this%iout, '(4x,a)') 'HEIGHT set from input file.'
451  end if
452 
453  if (found%manfraction) then
454  write (this%iout, '(4x,a)') 'MANFRACTION set from input file.'
455  end if
456 
457  write (this%iout, '(1x,a,/)') 'End Setting CXS Cross Section Data'
458 
459  end subroutine log_crosssectiondata
460 
461  subroutine write_cxs_table(this, idcxs, width, slope, rough, unitconv)
462  ! -- module
463  use sortmodule, only: qsort, unique_values
464  ! -- dummy
465  class(swfcxstype) :: this
466  integer(I4B), intent(in) :: idcxs
467  real(DP), intent(in) :: width
468  real(DP), intent(in) :: slope
469  real(DP), intent(in) :: rough
470  real(DP), intent(in) :: unitconv
471  ! -- local
472  integer(I4B) :: ipt
473  real(DP) :: d
474  real(DP) :: a
475  real(DP) :: rh
476  real(DP) :: wp
477  real(DP) :: r
478  real(DP) :: c
479  real(DP) :: q
480  integer(I4B) :: i0
481  integer(I4B) :: i1
482  integer(I4B) :: npts
483  integer(I4B) :: icalcmeth
484  real(DP), dimension(:), allocatable :: depths
485  real(DP), dimension(:), allocatable :: depths_unique
486  integer(I4B), dimension(:), allocatable :: indx
487 
488  call this%get_cross_section_info(idcxs, i0, i1, npts, icalcmeth)
489 
490  if (npts > 0) then
491 
492  write (this%iout, *) 'Processing information for cross section ', idcxs
493  write (this%iout, *) 'Depth Area WettedP HydRad Rough Conveyance Q'
494 
495  allocate (depths(npts))
496  allocate (indx(size(depths)))
497 
498  depths(:) = this%height(:)
499  call qsort(indx, depths)
500  call unique_values(depths, depths_unique)
501 
502  do ipt = 1, size(depths_unique)
503  d = depths_unique(ipt)
504  a = this%get_area(idcxs, width, d)
505  wp = this%get_wetted_perimeter(idcxs, width, d)
506  rh = this%get_hydraulic_radius(idcxs, width, d, a)
507  r = this%get_roughness(idcxs, width, d, rough, slope)
508  c = this%get_conveyance(idcxs, width, d, rough)
509  if (slope > dzero) then
510  q = unitconv * c * sqrt(slope)
511  else
512  q = dzero
513  end if
514  write (this%iout, *) d, a, wp, rh, r, c, q
515  end do
516 
517  deallocate (depths)
518  deallocate (depths_unique)
519  write (this%iout, *) 'Done processing information for cross section ', idcxs
520 
521  end if
522 
523  return
524  end subroutine write_cxs_table
525 
526  !> @brief deallocate memory
527  !<
528  subroutine cxs_da(this)
529  ! -- modules
533  ! -- dummy
534  class(swfcxstype) :: this
535  !
536  ! -- Deallocate input memory
537  call memorylist_remove(this%name_model, 'CXS', idm_context)
538  !
539  ! -- Scalars
540  call mem_deallocate(this%nsections)
541  call mem_deallocate(this%npoints)
542  !
543  ! -- Deallocate arrays if the package was created
544  ! from an input file
545  if (this%inunit > 0) then
546  call mem_deallocate(this%idcxs)
547  call mem_deallocate(this%nxspoints)
548  call mem_deallocate(this%xfraction)
549  call mem_deallocate(this%height)
550  call mem_deallocate(this%manfraction)
551  call mem_deallocate(this%iacross)
552  end if
553  !
554  ! -- deallocate parent
555  call this%NumericalPackageType%da()
556  !
557  ! -- Return
558  return
559  end subroutine cxs_da
560 
561  subroutine get_cross_section_info(this, idcxs, i0, i1, npts, icalcmeth)
562  ! -- dummy
563  class(swfcxstype) :: this
564  integer(I4B), intent(in) :: idcxs !< cross section id number
565  integer(I4B), intent(inout) :: i0 !< starting cross section point number
566  integer(I4B), intent(inout) :: i1 !< ending cross section point number
567  integer(I4B), intent(inout) :: npts !< number of points in cross section
568  integer(I4B), intent(inout) :: icalcmeth !< calculation method for mannings roughness
569  ! -- local
570  !
571  ! -- Return npts = 0 if this package does not have input file
572  if (this%inunit == 0 .or. idcxs == 0) then
573  npts = 0
574  i0 = 1
575  i1 = 1
576  icalcmeth = 0
577  else
578  !
579  ! -- If the cross section id is 0, then it is a hydraulically wide channel,
580  ! and only width and rough are needed (not xfraction, height, and manfraction)
581  if (idcxs > 0) then
582  i0 = this%iacross(idcxs)
583  i1 = this%iacross(idcxs + 1) - 1
584  else
585  i0 = 1
586  i1 = 1
587  end if
588  ! set icalcmeth based on number of cross section points
589  npts = i1 - i0 + 1
590  icalcmeth = 0 ! linear composite mannings resistance
591  if (npts > 4) then
592  icalcmeth = 0 ! sum q by cross section segments
593  end if
594  end if
595  return
596  end subroutine get_cross_section_info
597 
598  function get_area(this, idcxs, width, depth) result(area)
599  ! -- modules
601  ! -- dummy
602  class(swfcxstype) :: this
603  integer(I4B), intent(in) :: idcxs !< cross section id
604  real(dp), intent(in) :: width !< width in reach
605  real(dp), intent(in) :: depth !< stage in reach
606  ! -- local
607  real(dp) :: area
608  integer(I4B) :: i0
609  integer(I4B) :: i1
610  integer(I4B) :: npts
611  integer(I4B) :: icalcmeth
612  call this%get_cross_section_info(idcxs, i0, i1, npts, icalcmeth)
613  if (npts == 0) then
614  area = width * depth
615  else
616  area = get_cross_section_area(npts, &
617  this%xfraction(i0:i1), &
618  this%height(i0:i1), &
619  width, depth)
620  end if
621  end function get_area
622 
623  function cxs_wetted_perimeter(this, idcxs, width, depth) result(wp)
624  ! -- modules
626  ! -- dummy
627  class(swfcxstype) :: this
628  integer(I4B), intent(in) :: idcxs !< cross section id
629  real(dp), intent(in) :: width !< width in reach
630  real(dp), intent(in) :: depth !< stage in reach
631  ! -- local
632  real(dp) :: wp
633  integer(I4B) :: i0
634  integer(I4B) :: i1
635  integer(I4B) :: npts
636  integer(I4B) :: icalcmeth
637  call this%get_cross_section_info(idcxs, i0, i1, npts, icalcmeth)
638  if (npts == 0) then
639  wp = width
640  else
641  wp = get_wetted_perimeter(npts, &
642  this%xfraction(i0:i1), &
643  this%height(i0:i1), &
644  width, depth)
645  end if
646  end function cxs_wetted_perimeter
647 
648  function get_roughness(this, idcxs, width, depth, rough, &
649  slope) result(roughc)
650  ! -- modules
652  ! -- dummy
653  class(swfcxstype) :: this
654  integer(I4B), intent(in) :: idcxs !< cross section id
655  real(dp), intent(in) :: width !< width in reach
656  real(dp), intent(in) :: depth !< stage in reach
657  real(dp), intent(in) :: rough !< mannings value provided for the reach
658  real(dp), intent(in) :: slope !< slope value provided for the reach
659  ! -- local
660  real(dp) :: roughc !< calculated composite roughness
661  integer(I4B) :: i0
662  integer(I4B) :: i1
663  integer(I4B) :: npts
664  integer(I4B) :: icalcmeth
665  call this%get_cross_section_info(idcxs, i0, i1, npts, icalcmeth)
666  if (npts == 0) then
667  roughc = rough
668  else
669  roughc = calc_composite_roughness(npts, &
670  depth, &
671  width, &
672  rough, &
673  slope, &
674  this%xfraction(i0:i1), &
675  this%height(i0:i1), &
676  this%manfraction(i0:i1), &
677  icalcmeth)
678  end if
679  end function get_roughness
680 
681  !> @brief Calculate and return conveyance
682  !!
683  !! Conveyance = area * hydraulic_radius ** (2/3) / mannings_roughness
684  !! If idcxs = 0 (no cross section specified) then reach is
685  !< hydraulically wide and hydraulic radius is equal to depth.
686  function cxs_conveyance(this, idcxs, width, depth, &
687  rough) result(conveyance)
688  ! -- modules
690  ! -- dummy
691  class(swfcxstype) :: this
692  integer(I4B), intent(in) :: idcxs !< cross section id
693  real(dp), intent(in) :: width !< width in reach
694  real(dp), intent(in) :: depth !< stage in reach
695  real(dp), intent(in) :: rough !< mannings value provided for the reach
696  ! -- return
697  real(dp) :: conveyance !< calculated composite roughness
698  ! -- local
699  real(dp) :: a
700  real(dp) :: rh
701  integer(I4B) :: i0
702  integer(I4B) :: i1
703  integer(I4B) :: npts
704  integer(I4B) :: icalcmeth
705  call this%get_cross_section_info(idcxs, i0, i1, npts, icalcmeth)
706  if (npts == 0) then
707  a = depth * width
708  rh = depth
709  conveyance = a * rh**dtwothirds / rough
710  else
711  conveyance = get_conveyance(npts, &
712  this%xfraction(i0:i1), &
713  this%height(i0:i1), &
714  this%manfraction(i0:i1), &
715  width, rough, depth)
716  end if
717  end function cxs_conveyance
718 
719  function get_hydraulic_radius(this, idcxs, width, depth, area) result(r)
720  ! -- modules
722  ! -- dummy
723  class(swfcxstype) :: this
724  integer(I4B), intent(in) :: idcxs !< cross section id
725  real(dp), intent(in) :: width !< width in reach
726  real(dp), intent(in) :: depth !< stage in reach
727  real(dp), intent(in), optional :: area !< area of the reach
728  ! -- local
729  real(dp) :: r !< calculated hydraulic radius
730  real(dp) :: a
731  integer(I4B) :: i0
732  integer(I4B) :: i1
733  integer(I4B) :: npts
734  integer(I4B) :: icalcmeth
735  call this%get_cross_section_info(idcxs, i0, i1, npts, icalcmeth)
736  if (present(area)) then
737  a = area
738  else
739  a = this%get_area(idcxs, width, depth)
740  end if
741  if (npts == 0) then
742  r = a / width
743  else
744  r = get_hydraulic_radius_xf(npts, &
745  this%xfraction(i0:i1), &
746  this%height(i0:i1), &
747  width, depth)
748  end if
749  end function get_hydraulic_radius
750 
751 end module swfcxsmodule
This module contains simulation constants.
Definition: Constants.f90:9
real(dp), parameter dtwothirds
real constant 2/3
Definition: Constants.f90:69
real(dp), parameter dzero
real constant zero
Definition: Constants.f90:64
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition: Constants.f90:26
This module defines variable data types.
Definition: kind.f90:8
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
subroutine, public memorylist_remove(component, subcomponent, context)
This module contains the base numerical package type.
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
This module contains simulation variables.
Definition: SimVariables.f90:9
character(len=maxcharlen) errmsg
error message string
character(len=linelength) idm_context
character(len=maxcharlen) warnmsg
warning message string
subroutine source_packagedata(this)
Copy options from IDM into package.
Definition: swf-cxs.f90:304
real(dp) function cxs_wetted_perimeter(this, idcxs, width, depth)
Definition: swf-cxs.f90:624
subroutine source_options(this)
Copy options from IDM into package.
Definition: swf-cxs.f90:152
real(dp) function get_roughness(this, idcxs, width, depth, rough, slope)
Definition: swf-cxs.f90:650
subroutine allocate_arrays(this)
allocate memory for arrays
Definition: swf-cxs.f90:264
subroutine log_options(this, found)
Write user options to list file.
Definition: swf-cxs.f90:182
subroutine calc_iacross(nxspoints, iacross)
Calculate index pointer array iacross from nxspoints.
Definition: swf-cxs.f90:351
real(dp) function get_hydraulic_radius(this, idcxs, width, depth, area)
Definition: swf-cxs.f90:720
subroutine log_dimensions(this, found)
Write user options to list file.
Definition: swf-cxs.f90:243
subroutine get_cross_section_info(this, idcxs, i0, i1, npts, icalcmeth)
Definition: swf-cxs.f90:562
real(dp) function get_area(this, idcxs, width, depth)
Definition: swf-cxs.f90:599
subroutine source_dimensions(this)
Copy options from IDM into package.
Definition: swf-cxs.f90:199
subroutine cxs_da(this)
deallocate memory
Definition: swf-cxs.f90:529
subroutine source_crosssectiondata(this)
Copy options from IDM into package.
Definition: swf-cxs.f90:384
real(dp) function cxs_conveyance(this, idcxs, width, depth, rough)
Calculate and return conveyance.
Definition: swf-cxs.f90:688
subroutine allocate_scalars(this)
@ brief Allocate scalars
Definition: swf-cxs.f90:131
subroutine log_crosssectiondata(this, found)
Write user packagedata to list file.
Definition: swf-cxs.f90:439
subroutine, public cxs_cr(pobj, name_model, input_mempath, inunit, iout, dis)
create package
Definition: swf-cxs.f90:62
subroutine log_packagedata(this, found)
Write user packagedata to list file.
Definition: swf-cxs.f90:363
subroutine write_cxs_table(this, idcxs, width, slope, rough, unitconv)
Definition: swf-cxs.f90:462
This module contains stateless sfr subroutines and functions.
Definition: SwfCxsUtils.f90:11
real(dp) function, public get_hydraulic_radius_xf(npts, xfraction, heights, width, d)
Calculate the hydraulic radius for a reach.
real(dp) function, public calc_composite_roughness(npts, depth, width, rough, slope, cxs_xf, cxs_h, cxs_rf, linmeth)
real(dp) function, public get_cross_section_area(npts, xfraction, heights, width, d)
Calculate the cross-sectional area for a reach.
real(dp) function, public get_conveyance(npts, xfraction, heights, cxs_rf, width, rough, d)
Calculate conveyance.
real(dp) function, public get_wetted_perimeter(npts, xfraction, heights, width, d)
Calculate the wetted perimeter for a reach.