wide_halo_guards Subroutine

private subroutine wide_halo_guards(ng_wide, caller)

Fail-loud validation for wide halo entry points. Called at the top of every *_wide public routine.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ng_wide

Requested wide ghost width

character(len=*), intent(in) :: caller

Caller name for error messages


Calls

proc~~wide_halo_guards~~CallsGraph proc~wide_halo_guards wide_halo_guards error error proc~wide_halo_guards->error to_string to_string proc~wide_halo_guards->to_string

Called by

proc~~wide_halo_guards~~CalledByGraph proc~wide_halo_guards wide_halo_guards proc~ocean_halo_bt_group_2d_wide ocean_halo_bt_group_2d_wide proc~ocean_halo_bt_group_2d_wide->proc~wide_halo_guards proc~ocean_halo_centre_2d_wide ocean_halo_centre_2d_wide proc~ocean_halo_centre_2d_wide->proc~wide_halo_guards proc~ocean_halo_face_x_2d_wide ocean_halo_face_x_2d_wide proc~ocean_halo_face_x_2d_wide->proc~wide_halo_guards proc~ocean_halo_face_y_2d_wide ocean_halo_face_y_2d_wide proc~ocean_halo_face_y_2d_wide->proc~wide_halo_guards proc~barotropic_substep_nonlinear barotropic_substep_nonlinear proc~barotropic_substep_nonlinear->proc~ocean_halo_bt_group_2d_wide proc~bt_wide_entry_exchange_impl bt_wide_entry_exchange_impl proc~bt_wide_entry_exchange_impl->proc~ocean_halo_bt_group_2d_wide proc~bt_wide_entry_exchange_impl->proc~ocean_halo_centre_2d_wide proc~bt_wide_entry_exchange_impl->proc~ocean_halo_face_x_2d_wide proc~bt_wide_entry_exchange_impl->proc~ocean_halo_face_y_2d_wide proc~engine_enter_data engine_enter_data proc~engine_enter_data->proc~ocean_halo_bt_group_2d_wide proc~barotropic_substep_nonlinear_interior barotropic_substep_nonlinear_interior proc~barotropic_substep_nonlinear_interior->proc~barotropic_substep_nonlinear proc~bt_wide_entry_exchange bt_wide_t%bt_wide_entry_exchange proc~bt_wide_entry_exchange->proc~bt_wide_entry_exchange_impl proc~bt_wide_substep bt_wide_substep proc~bt_wide_substep->proc~barotropic_substep_nonlinear proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_enter_data proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_enter_data 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 proc~run_stage_split run_stage_split proc~run_stage_split->proc~barotropic_substep_nonlinear_interior proc~run_stage_split->proc~bt_wide_entry_exchange proc~run_stage_split->proc~bt_wide_substep proc~ocean_dyn_step_split ocean_dyn_step_split proc~ocean_dyn_step_split->proc~run_stage_split

Source Code

   subroutine wide_halo_guards(ng_wide, caller)
      !! Fail-loud validation for wide halo entry points.
      !! Called at the top of every *_wide public routine.
      integer, intent(in) :: ng_wide
         !! Requested wide ghost width
      character(len=*), intent(in) :: caller
         !! Caller name for error messages

      if (ng_wide < oh_nghost) then
         call logger%error(caller//": ng_wide="//to_string(ng_wide)// &
                           " < oh_nghost="//to_string(oh_nghost)// &
                           ". A wide exchange narrower than the base ghost band "// &
                           "would leave stale ghost cells. Use ng_wide >= oh_nghost.")
         error stop "wide halo: ng_wide < oh_nghost"
      end if
      if (oh_decomp%px > 1 .and. ng_wide > oh_nx_local) then
         call logger%error(caller//": ng_wide="//to_string(ng_wide)// &
                           " > nx_local="//to_string(oh_nx_local)// &
                           " with px="//to_string(oh_decomp%px)//". "// &
                           "Wide halo width exceeds local interior; decompose "// &
                           "less or lower bt_halo.")
         error stop "wide halo width exceeds local interior (x)"
      end if
      if (oh_decomp%py > 1 .and. ng_wide > oh_ny_local) then
         call logger%error(caller//": ng_wide="//to_string(ng_wide)// &
                           " > ny_local="//to_string(oh_ny_local)// &
                           " with py="//to_string(oh_decomp%py)//". "// &
                           "Wide halo width exceeds local interior; decompose "// &
                           "less or lower bt_halo.")
         error stop "wide halo width exceeds local interior (y)"
      end if
      ! Single-rank periodic guard: the wrap reads i + nx_phys, so ng_wide
      ! must not exceed nx_phys (= oh_nx_local).
      if (oh_decomp%px == 1 .and. oh_periodic_x .and. ng_wide > oh_nx_local) then
         call logger%error(caller//": ng_wide="//to_string(ng_wide)// &
                           " > nx_phys="//to_string(oh_nx_local)// &
                           " for single-rank periodic-x. "// &
                           "The local wrap reads i+nx_phys which would exceed "// &
                           "the array. Reduce ng_wide.")
         error stop "wide halo: ng_wide > nx_phys for single-rank periodic-x"
      end if
      if (oh_decomp%py == 1 .and. oh_periodic_y .and. ng_wide > oh_ny_local) then
         call logger%error(caller//": ng_wide="//to_string(ng_wide)// &
                           " > ny_phys="//to_string(oh_ny_local)// &
                           " for single-rank periodic-y. "// &
                           "The local wrap reads j+ny_phys which would exceed "// &
                           "the array. Reduce ng_wide.")
         error stop "wide halo: ng_wide > ny_phys for single-rank periodic-y"
      end if
   end subroutine wide_halo_guards