cavity_datum_residual Function

public pure function cavity_datum_residual(bt_H_ref, b, z_draft, h_min, nx, ny) result(resid)

Max violation of the counted-once invariant (I) in METRES of reference depth, over the WET columns: max |bt_H_ref - (b - z_draft)| where b - z_draft >= h_min.

(I) itself is rho_ref*g*z_draft + (bt_H_ref - b)*rho_ref*g == 0; dividing out the common positive factor rho_ref*g leaves exactly this length, which is the form worth asserting — it is scale-free and it does not fabricate a product that the code never forms.

GROUNDED columns are excluded on purpose, and cavity_datum_impl carries the argument: they are land, they carry no barotropic momentum equation, and their datum is deliberately 0 rather than a negative water column. Including them would assert a load-counting statement where there is no load being counted.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: bt_H_ref(nx,ny)
real(kind=wp), intent(in) :: b(nx,ny)
real(kind=wp), intent(in) :: z_draft(nx,ny)
real(kind=wp), intent(in) :: h_min
integer, intent(in) :: nx
integer, intent(in) :: ny

Return Value real(kind=wp)


Called by

proc~~cavity_datum_residual~~CalledByGraph proc~cavity_datum_residual cavity_datum_residual proc~configure_ocean_cavity configure_ocean_cavity proc~configure_ocean_cavity->proc~cavity_datum_residual proc~engine_setup engine_setup proc~engine_setup->proc~configure_ocean_cavity proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_setup proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_setup proc~driver_validate driver_validate proc~driver_validate->proc~engine_setup proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean proc~rdb_ocean_create_finalize rdb_ocean_create_finalize proc~rdb_ocean_create_finalize->proc~complete_ocean_create proc~rdb_ocean_create_from_string rdb_ocean_create_from_string proc~rdb_ocean_create_from_string->proc~complete_ocean_create

Variables

Type Visibility Attributes Name Initial
integer, private :: i
integer, private :: j
real(kind=wp), private :: water

Source Code

   pure function cavity_datum_residual(bt_H_ref, b, z_draft, h_min, nx, ny) result(resid)
      !! Max violation of the counted-once invariant (I) in METRES of
      !! reference depth, over the WET columns:
      !! `max |bt_H_ref - (b - z_draft)|` where `b - z_draft >= h_min`.
      !!
      !! (I) itself is `rho_ref*g*z_draft + (bt_H_ref - b)*rho_ref*g == 0`;
      !! dividing out the common positive factor `rho_ref*g` leaves
      !! exactly this length, which is the form worth asserting — it is
      !! scale-free and it does not fabricate a product that the code
      !! never forms.
      !!
      !! GROUNDED columns are excluded on purpose, and `cavity_datum_impl`
      !! carries the argument: they are land, they carry no barotropic
      !! momentum equation, and their datum is deliberately `0` rather
      !! than a negative water column.  Including them would assert a
      !! load-counting statement where there is no load being counted.
      integer, intent(in) :: nx, ny
      real(wp), intent(in) :: bt_H_ref(nx, ny)
      real(wp), intent(in) :: b(nx, ny)
      real(wp), intent(in) :: z_draft(nx, ny)
      real(wp), intent(in) :: h_min
      real(wp) :: resid
      real(wp) :: water
      integer :: i, j
      resid = 0.0_wp
      do j = 1, ny
         do i = 1, nx
            water = b(i, j) - z_draft(i, j)
            if (water < h_min) cycle
            resid = max(resid, abs(bt_H_ref(i, j) - water))
         end do
      end do
   end function cavity_datum_residual