cavity_draft_apply_sign Subroutine

public pure subroutine cavity_draft_apply_sign(z_draft, nx, ny, sign_code)

Normalise a freshly loaded draft field onto Roundabout’s convention (DEPTH, positive down, >= 0).

  • CAVITY_SIGN_DEPTH — identity (bit-for-bit).
  • CAVITY_SIGN_ELEVATION — z_draft = -z_d.

Open water in the ISOMIP+ file is z_d = 0, which negates to -0.0. Left as the literal negation would make a downstream z_draft /= 0 test (cavity_apply_land_exclusion) fire on a cell with no ice, so the zero is re-normalised explicitly. No clipping otherwise: a POSITIVE elevation (ice base above sea level, i.e. grounded ice or a file in the wrong convention) negates to a negative depth and is caught fail-loud by cavity_draft_is_finite_nonneg — which is the point of having an explicit knob instead of a guess.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(inout) :: z_draft(nx,ny)
integer, intent(in) :: nx
integer, intent(in) :: ny
integer, intent(in) :: sign_code

Called by

proc~~cavity_draft_apply_sign~~CalledByGraph proc~cavity_draft_apply_sign cavity_draft_apply_sign proc~seed_cavity_draft seed_cavity_draft proc~seed_cavity_draft->proc~cavity_draft_apply_sign proc~ocean_state_seed_from_cfg ocean_state_seed_from_cfg proc~ocean_state_seed_from_cfg->proc~seed_cavity_draft proc~engine_setup engine_setup proc~engine_setup->proc~ocean_state_seed_from_cfg 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

Source Code

   pure subroutine cavity_draft_apply_sign(z_draft, nx, ny, sign_code)
      !! Normalise a freshly loaded draft field onto Roundabout's
      !! convention (DEPTH, positive down, `>= 0`).
      !!
      !!   * `CAVITY_SIGN_DEPTH` — identity (bit-for-bit).
      !!   * `CAVITY_SIGN_ELEVATION` — `z_draft = -z_d`.
      !!
      !! Open water in the ISOMIP+ file is `z_d = 0`, which negates to
      !! `-0.0`.  Left as the literal negation would make a downstream
      !! `z_draft /= 0` test (`cavity_apply_land_exclusion`) fire on a
      !! cell with no ice, so the zero is re-normalised explicitly.
      !! No clipping otherwise: a POSITIVE elevation (ice base above sea
      !! level, i.e. grounded ice or a file in the wrong convention)
      !! negates to a negative depth and is caught fail-loud by
      !! `cavity_draft_is_finite_nonneg` — which is the point of having
      !! an explicit knob instead of a guess.
      integer, intent(in) :: nx, ny, sign_code
      real(wp), intent(inout) :: z_draft(nx, ny)
      integer :: i, j
      if (sign_code /= CAVITY_SIGN_ELEVATION) return
      do j = 1, ny
         do i = 1, nx
            if (z_draft(i, j) == 0.0_wp) then
               z_draft(i, j) = 0.0_wp
            else
               z_draft(i, j) = -z_draft(i, j)
            end if
         end do
      end do
   end subroutine cavity_draft_apply_sign