sort_real Subroutine

private pure subroutine sort_real(a)

Plain insertion sort. a is at most a few hundred cells in every realistic setup-time call (and correctness, not speed, is what matters for a diagnostic median) — no need for anything fancier.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(inout) :: a(:)

Called by

proc~~sort_real~~CalledByGraph proc~sort_real sort_real proc~bathymetry_median bathymetry_median proc~bathymetry_median->proc~sort_real proc~bathymetry_normalise_sign bathymetry_normalise_sign proc~bathymetry_normalise_sign->proc~bathymetry_median proc~ocean_state_seed_from_cfg ocean_state_seed_from_cfg proc~ocean_state_seed_from_cfg->proc~bathymetry_normalise_sign 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

Variables

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

Source Code

   pure subroutine sort_real(a)
      !! Plain insertion sort. `a` is at most a few hundred cells in every
      !! realistic setup-time call (and correctness, not speed, is what
      !! matters for a diagnostic median) — no need for anything fancier.
      real(wp), intent(inout) :: a(:)
      integer :: i, j
      real(wp) :: key

      do i = 2, size(a)
         key = a(i)
         j = i - 1
         do while (j >= 1)
            if (a(j) <= key) exit
            a(j + 1) = a(j)
            j = j - 1
         end do
         a(j + 1) = key
      end do
   end subroutine sort_real