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.
| Type | Intent | Optional | 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 |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | i | ||||
| integer, | private | :: | j | ||||
| real(kind=wp), | private | :: | water |
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