ocean_data_forcing_configure Subroutine

public subroutine ocean_data_forcing_configure(cfg, reader, grid, ss, sf, bc, this, ierr)

Register every configured tag against the shared reader and resolve the heat/salt destinations. A no-op when enable = .false. — nothing registers, so ocean_data_input_update_all stays a no-op and the run is bit-identical.

Arguments

Type IntentOptional Attributes Name
type(ocean_dataovr_config_t), intent(in) :: cfg
type(ocean_data_input_t), intent(inout) :: reader
type(hgrid_t), intent(in) :: grid
type(ocean_surface_stress_t), intent(inout) :: ss
type(ocean_surface_flux_t), intent(inout) :: sf
type(ocean_bc_state_t), intent(in) :: bc

Periodic / north-fold topology for the configure-time seam refresh.

type(ocean_data_forcing_t), intent(out) :: this
integer, intent(out), optional :: ierr

Non-zero (OCEAN_STATUS_ERR_SETUP/OCEAN_STATUS_ERR_IO, see rdb_ocean_status) on a malformed &ocean_dataovr_nml group or a registration failure (bad file/variable/dims) when present; absent behaves as today (error stop).


Calls

proc~~ocean_data_forcing_configure~~CallsGraph proc~ocean_data_forcing_configure ocean_data_forcing_configure proc~check_time_mode check_time_mode proc~ocean_data_forcing_configure->proc~check_time_mode proc~ocean_seam_refresh_surface_stress ocean_seam_refresh_surface_stress proc~ocean_data_forcing_configure->proc~ocean_seam_refresh_surface_stress proc~register_tag register_tag proc~ocean_data_forcing_configure->proc~register_tag proc~resolve_flux_targets resolve_flux_targets proc~ocean_data_forcing_configure->proc~resolve_flux_targets warning warning proc~ocean_data_forcing_configure->warning proc~fail fail proc~check_time_mode->proc~fail interface~ocean_halo_face_x ocean_halo_face_x proc~ocean_seam_refresh_surface_stress->interface~ocean_halo_face_x interface~ocean_halo_face_y ocean_halo_face_y proc~ocean_seam_refresh_surface_stress->interface~ocean_halo_face_y proc~ocean_fold_wrap_stress ocean_fold_wrap_stress proc~ocean_seam_refresh_surface_stress->proc~ocean_fold_wrap_stress proc~ocean_halo_is_decomposed_x ocean_halo_is_decomposed_x proc~ocean_seam_refresh_surface_stress->proc~ocean_halo_is_decomposed_x proc~ocean_halo_is_decomposed_y ocean_halo_is_decomposed_y proc~ocean_seam_refresh_surface_stress->proc~ocean_halo_is_decomposed_y proc~ocean_periodic_wrap_face_x_2d ocean_periodic_wrap_face_x_2d proc~ocean_seam_refresh_surface_stress->proc~ocean_periodic_wrap_face_x_2d proc~ocean_periodic_wrap_face_y_2d ocean_periodic_wrap_face_y_2d proc~ocean_seam_refresh_surface_stress->proc~ocean_periodic_wrap_face_y_2d proc~ocean_surface_stress_set_derived ocean_surface_stress_set_derived proc~ocean_seam_refresh_surface_stress->proc~ocean_surface_stress_set_derived proc~oh_count_suppress_off oh_count_suppress_off proc~ocean_seam_refresh_surface_stress->proc~oh_count_suppress_off proc~oh_count_suppress_on oh_count_suppress_on proc~ocean_seam_refresh_surface_stress->proc~oh_count_suppress_on proc~profiler_start profiler_start proc~ocean_seam_refresh_surface_stress->proc~profiler_start proc~profiler_stop profiler_stop proc~ocean_seam_refresh_surface_stress->proc~profiler_stop info info proc~register_tag->info proc~register_tag->proc~fail proc~ocean_data_input_register_2d ocean_data_input_register_2d proc~register_tag->proc~ocean_data_input_register_2d to_string to_string proc~register_tag->to_string proc~resolve_flux_targets->proc~fail proc~ocean_halo_face_x_2d ocean_halo_face_x_2d interface~ocean_halo_face_x->proc~ocean_halo_face_x_2d proc~ocean_halo_face_x_3d ocean_halo_face_x_3d interface~ocean_halo_face_x->proc~ocean_halo_face_x_3d proc~ocean_halo_face_y_2d ocean_halo_face_y_2d interface~ocean_halo_face_y->proc~ocean_halo_face_y_2d proc~ocean_halo_face_y_3d ocean_halo_face_y_3d interface~ocean_halo_face_y->proc~ocean_halo_face_y_3d error error proc~fail->error proc~error_ring_push error_ring_push proc~fail->proc~error_ring_push proc~register_common register_common proc~ocean_data_input_register_2d->proc~register_common interface~fold_north_u_face fold_north_u_face proc~ocean_fold_wrap_stress->interface~fold_north_u_face interface~fold_north_v_face fold_north_v_face proc~ocean_fold_wrap_stress->interface~fold_north_v_face interface~ocean_fold_pack ocean_fold_pack proc~ocean_fold_wrap_stress->interface~ocean_fold_pack interface~ocean_fold_unpack ocean_fold_unpack proc~ocean_fold_wrap_stress->interface~ocean_fold_unpack proc~ocean_fold_begin ocean_fold_begin proc~ocean_fold_wrap_stress->proc~ocean_fold_begin proc~ocean_fold_end ocean_fold_end proc~ocean_fold_wrap_stress->proc~ocean_fold_end proc~ocean_fold_exchange ocean_fold_exchange proc~ocean_fold_wrap_stress->proc~ocean_fold_exchange proc~ocean_fold_is_distributed ocean_fold_is_distributed proc~ocean_fold_wrap_stress->proc~ocean_fold_is_distributed proc~ocean_surface_stress_apply_cover ocean_surface_stress_apply_cover proc~ocean_surface_stress_set_derived->proc~ocean_surface_stress_apply_cover proc~ocean_surface_stress_refresh_mag ocean_surface_stress_refresh_mag proc~ocean_surface_stress_set_derived->proc~ocean_surface_stress_refresh_mag proc~find_or_create_region find_or_create_region proc~profiler_start->proc~find_or_create_region proc~get_wall_time get_wall_time proc~profiler_start->proc~get_wall_time proc~nvtx_range_push nvtx_range_push proc~profiler_start->proc~nvtx_range_push proc~profiler_stop->proc~get_wall_time proc~nvtx_range_pop nvtx_range_pop proc~profiler_stop->proc~nvtx_range_pop proc~fold_north_u_face_2d fold_north_u_face_2d interface~fold_north_u_face->proc~fold_north_u_face_2d proc~fold_north_u_face_3d fold_north_u_face_3d interface~fold_north_u_face->proc~fold_north_u_face_3d proc~fold_north_v_face_2d fold_north_v_face_2d interface~fold_north_v_face->proc~fold_north_v_face_2d proc~fold_north_v_face_3d fold_north_v_face_3d interface~fold_north_v_face->proc~fold_north_v_face_3d proc~ocean_fold_pack_2d ocean_fold_pack_2d interface~ocean_fold_pack->proc~ocean_fold_pack_2d proc~ocean_fold_pack_3d ocean_fold_pack_3d interface~ocean_fold_pack->proc~ocean_fold_pack_3d proc~ocean_fold_unpack_2d ocean_fold_unpack_2d interface~ocean_fold_unpack->proc~ocean_fold_unpack_2d proc~ocean_fold_unpack_3d ocean_fold_unpack_3d interface~ocean_fold_unpack->proc~ocean_fold_unpack_3d proc~ocean_fold_begin->warning proc~ocean_fold_begin->to_string proc~grow_buffers grow_buffers proc~ocean_fold_begin->proc~grow_buffers comm_irecv_real_sp_array_n comm_irecv_real_sp_array_n proc~ocean_fold_exchange->comm_irecv_real_sp_array_n comm_isend_real_sp_array_n comm_isend_real_sp_array_n proc~ocean_fold_exchange->comm_isend_real_sp_array_n proc~comm_env_compute_comm comm_env_compute_comm proc~ocean_fold_exchange->proc~comm_env_compute_comm waitall waitall proc~ocean_fold_exchange->waitall proc~ocean_halo_face_x_2d_impl ocean_halo_face_x_2d_impl proc~ocean_halo_face_x_2d->proc~ocean_halo_face_x_2d_impl proc~oh_count_face_x_2d oh_count_face_x_2d proc~ocean_halo_face_x_2d->proc~oh_count_face_x_2d proc~ocean_halo_face_x_3d->comm_irecv_real_sp_array_n proc~ocean_halo_face_x_3d->comm_isend_real_sp_array_n proc~ocean_halo_face_x_3d->proc~comm_env_compute_comm proc~ew_rank_east ew_rank_east proc~ocean_halo_face_x_3d->proc~ew_rank_east proc~ew_rank_west ew_rank_west proc~ocean_halo_face_x_3d->proc~ew_rank_west proc~needs_flags needs_flags proc~ocean_halo_face_x_3d->proc~needs_flags proc~ns_rank_north ns_rank_north proc~ocean_halo_face_x_3d->proc~ns_rank_north proc~ns_rank_south ns_rank_south proc~ocean_halo_face_x_3d->proc~ns_rank_south proc~ocean_halo_buffers_ensure_nz ocean_halo_buffers_ensure_nz proc~ocean_halo_face_x_3d->proc~ocean_halo_buffers_ensure_nz proc~ocean_periodic_wrap_face_x_3d ocean_periodic_wrap_face_x_3d proc~ocean_halo_face_x_3d->proc~ocean_periodic_wrap_face_x_3d proc~oh_count_face_x_3d oh_count_face_x_3d proc~ocean_halo_face_x_3d->proc~oh_count_face_x_3d proc~oh_count_msgs oh_count_msgs proc~ocean_halo_face_x_3d->proc~oh_count_msgs proc~ocean_halo_face_x_3d->waitall proc~ocean_halo_face_y_2d_impl ocean_halo_face_y_2d_impl proc~ocean_halo_face_y_2d->proc~ocean_halo_face_y_2d_impl proc~oh_count_face_y_2d oh_count_face_y_2d proc~ocean_halo_face_y_2d->proc~oh_count_face_y_2d proc~ocean_halo_face_y_3d->comm_irecv_real_sp_array_n proc~ocean_halo_face_y_3d->comm_isend_real_sp_array_n proc~ocean_halo_face_y_3d->proc~comm_env_compute_comm proc~ocean_halo_face_y_3d->proc~ew_rank_east proc~ocean_halo_face_y_3d->proc~ew_rank_west proc~ocean_halo_face_y_3d->proc~needs_flags proc~ocean_halo_face_y_3d->proc~ns_rank_north proc~ocean_halo_face_y_3d->proc~ns_rank_south proc~ocean_halo_face_y_3d->proc~ocean_halo_buffers_ensure_nz proc~ocean_periodic_wrap_face_y_3d ocean_periodic_wrap_face_y_3d proc~ocean_halo_face_y_3d->proc~ocean_periodic_wrap_face_y_3d proc~oh_count_face_y_3d oh_count_face_y_3d proc~ocean_halo_face_y_3d->proc~oh_count_face_y_3d proc~ocean_halo_face_y_3d->proc~oh_count_msgs proc~ocean_halo_face_y_3d->waitall proc~ocean_surface_stress_apply_cover->proc~ocean_surface_stress_refresh_mag proc~ocean_surfstress_cover_impl ocean_surfstress_cover_impl proc~ocean_surface_stress_apply_cover->proc~ocean_surfstress_cover_impl proc~ocean_surfstress_derived_impl ocean_surfstress_derived_impl proc~ocean_surface_stress_refresh_mag->proc~ocean_surfstress_derived_impl proc~register_common->proc~fail proc~register_common->to_string proc~register_common->error nf90_inq_varid nf90_inq_varid proc~register_common->nf90_inq_varid nf90_inquire_dimension nf90_inquire_dimension proc~register_common->nf90_inquire_dimension nf90_inquire_variable nf90_inquire_variable proc~register_common->nf90_inquire_variable proc~data_input_read_slab_impl data_input_read_slab_impl proc~register_common->proc~data_input_read_slab_impl proc~data_input_time_mode_from_string data_input_time_mode_from_string proc~register_common->proc~data_input_time_mode_from_string proc~data_input_time_scale_from_units data_input_time_scale_from_units proc~register_common->proc~data_input_time_scale_from_units proc~dims_geometry_ok dims_geometry_ok proc~register_common->proc~dims_geometry_ok proc~nc_check nc_check proc~register_common->proc~nc_check proc~nc_close nc_close proc~register_common->proc~nc_close proc~nc_get_att_text nc_get_att_text proc~register_common->proc~nc_get_att_text proc~nc_get_var_1d nc_get_var_1d proc~register_common->proc~nc_get_var_1d proc~nc_open_read nc_open_read proc~register_common->proc~nc_open_read proc~reg_io_ok reg_io_ok proc~register_common->proc~reg_io_ok proc~resolve_time_var resolve_time_var proc~register_common->proc~resolve_time_var comm_world comm_world proc~comm_env_compute_comm->comm_world proc~data_input_workspace_ensure data_input_workspace_ensure proc~data_input_read_slab_impl->proc~data_input_workspace_ensure proc~nc_get_var_slab_3d nc_get_var_slab_3d proc~data_input_read_slab_impl->proc~nc_get_var_slab_3d proc~data_input_time_mode_from_string->error to_lower to_lower proc~data_input_time_mode_from_string->to_lower proc~data_input_time_scale_from_units->to_lower proc~decomp_rank_from_coords decomp_rank_from_coords proc~ew_rank_east->proc~decomp_rank_from_coords proc~ew_rank_west->proc~decomp_rank_from_coords local local proc~fold_north_v_face_2d->local proc~fold_north_v_face_3d->local proc~nc_check->proc~fail nf90_strerror nf90_strerror proc~nc_check->nf90_strerror proc~nc_close->proc~nc_check nf90_close nf90_close proc~nc_close->nf90_close nf90_get_att nf90_get_att proc~nc_get_att_text->nf90_get_att proc~nc_get_var_1d->proc~nc_check nf90_get_var nf90_get_var proc~nc_get_var_1d->nf90_get_var proc~nc_open_read->proc~nc_check nf90_open nf90_open proc~nc_open_read->nf90_open proc~ns_rank_north->proc~decomp_rank_from_coords proc~ns_rank_south->proc~decomp_rank_from_coords proc~ocean_fold_pack_2d->proc~ocean_fold_pack_3d proc~fold_stagger_family fold_stagger_family proc~ocean_fold_pack_3d->proc~fold_stagger_family proc~fold_stagger_nrows fold_stagger_nrows proc~ocean_fold_pack_3d->proc~fold_stagger_nrows proc~ocean_fold_unpack_2d->proc~ocean_fold_unpack_3d proc~ocean_fold_unpack_3d->proc~fold_stagger_family proc~ocean_fold_unpack_3d->proc~fold_stagger_nrows proc~ocean_halo_buffers_ensure_nz->warning proc~ocean_halo_buffers_ensure_nz->to_string proc~ocean_halo_face_x_2d_impl->proc~ocean_periodic_wrap_face_x_2d proc~ocean_halo_face_x_2d_impl->comm_irecv_real_sp_array_n proc~ocean_halo_face_x_2d_impl->comm_isend_real_sp_array_n proc~ocean_halo_face_x_2d_impl->proc~comm_env_compute_comm proc~ocean_halo_face_x_2d_impl->proc~ew_rank_east proc~ocean_halo_face_x_2d_impl->proc~ew_rank_west proc~ocean_halo_face_x_2d_impl->proc~needs_flags proc~ocean_halo_face_x_2d_impl->proc~ns_rank_north proc~ocean_halo_face_x_2d_impl->proc~ns_rank_south proc~ocean_halo_face_x_2d_impl->proc~oh_count_msgs proc~ocean_halo_face_x_2d_impl->waitall proc~ocean_halo_face_y_2d_impl->proc~ocean_periodic_wrap_face_y_2d proc~ocean_halo_face_y_2d_impl->comm_irecv_real_sp_array_n proc~ocean_halo_face_y_2d_impl->comm_isend_real_sp_array_n proc~ocean_halo_face_y_2d_impl->proc~comm_env_compute_comm proc~ocean_halo_face_y_2d_impl->proc~ew_rank_east proc~ocean_halo_face_y_2d_impl->proc~ew_rank_west proc~ocean_halo_face_y_2d_impl->proc~needs_flags proc~ocean_halo_face_y_2d_impl->proc~ns_rank_north proc~ocean_halo_face_y_2d_impl->proc~ns_rank_south proc~ocean_halo_face_y_2d_impl->proc~oh_count_msgs proc~ocean_halo_face_y_2d_impl->waitall proc~ocean_surfstress_cover_impl->local proc~ocean_surfstress_derived_impl->local proc~reg_io_ok->proc~nc_close proc~resolve_time_var->nf90_inq_varid proc~resolve_time_var->nf90_inquire_dimension

Called by

proc~~ocean_data_forcing_configure~~CalledByGraph proc~ocean_data_forcing_configure ocean_data_forcing_configure proc~engine_setup engine_setup proc~engine_setup->proc~ocean_data_forcing_configure 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 :: ng
integer, private :: nx
integer, private :: ny
integer, private :: oor

Source Code

   subroutine ocean_data_forcing_configure(cfg, reader, grid, ss, sf, bc, this, ierr)
      !! Register every configured tag against the shared reader and
      !! resolve the heat/salt destinations.  A no-op when
      !! `enable = .false.` — nothing registers, so
      !! `ocean_data_input_update_all` stays a no-op and the run is
      !! bit-identical.
      type(ocean_dataovr_config_t), intent(in) :: cfg
      type(ocean_data_input_t), intent(inout) :: reader
      type(hgrid_t), intent(in) :: grid
      type(ocean_surface_stress_t), intent(inout) :: ss
      type(ocean_surface_flux_t), intent(inout) :: sf
      type(ocean_bc_state_t), intent(in) :: bc
         !! Periodic / north-fold topology for the configure-time seam refresh.
      type(ocean_data_forcing_t), intent(out) :: this
      integer, intent(out), optional :: ierr
         !! Non-zero (`OCEAN_STATUS_ERR_SETUP`/`OCEAN_STATUS_ERR_IO`, see
         !! `rdb_ocean_status`) on a malformed `&ocean_dataovr_nml` group
         !! or a registration failure (bad file/variable/dims) when
         !! present; absent behaves as today (`error stop`).

      integer :: oor, nx, ny, ng

      if (present(ierr)) ierr = OCEAN_STATUS_OK
      if (.not. cfg%enable) return

      call check_time_mode(cfg, ierr=ierr)
      if (present(ierr)) then
         if (ierr /= OCEAN_STATUS_OK) return
      end if

      oor = DATA_OOR_ERROR
      if (cfg%oor_clamp) oor = DATA_OOR_CLAMP

      nx = grid%nx_total
      ny = grid%ny_total
      ng = grid%nghost

      ! --- wind stress: face-shaped destinations ---
      ! `tau_x` is (nx_total+1, ny_total) on east faces, `tau_y` is
      ! (nx_total, ny_total+1) on north faces, landing at (nghost+1,
      ! nghost+1).
      !
      ! The file must supply nx_phys+1 x ny_phys values for `tau_x`
      ! (ny_phys+1 in y for `tau_y`) — one MORE than the cell count in
      ! the staggered direction.  An x-face array spans nx_phys+1 faces,
      ! and the trailing face is owned by THIS rank under the
      ! west/south-owns-the-seam rule, so no exchange can fill it in.
      ! Supplying only nx_phys would silently leave that face at zero,
      ! which halves the cell-centred `stress_mag` in the last column
      ! and hands a zero to the east neighbour's seam.
      call register_tag(cfg, cfg%tau_x, "tau_x", reader, grid, oor, &
                        nx + 1, ny, ng + 1, ng + 1, this%id_tau_x, nx_extra=1, ierr=ierr)
      if (present(ierr)) then
         if (ierr /= OCEAN_STATUS_OK) return
      end if
      call register_tag(cfg, cfg%tau_y, "tau_y", reader, grid, oor, &
                        nx, ny + 1, ng + 1, ng + 1, this%id_tau_y, ny_extra=1, ierr=ierr)
      if (present(ierr)) then
         if (ierr /= OCEAN_STATUS_OK) return
      end if

      ! --- surface fluxes: cell-centred destinations ---
      call resolve_flux_targets(cfg, sf, this, ierr=ierr)
      if (present(ierr)) then
         if (ierr /= OCEAN_STATUS_OK) return
      end if

      call register_tag(cfg, cfg%heat, "heat", reader, grid, oor, &
                        nx, ny, ng + 1, ng + 1, this%id_heat, ierr=ierr)
      if (present(ierr)) then
         if (ierr /= OCEAN_STATUS_OK) return
      end if
      call register_tag(cfg, cfg%evap, "evap", reader, grid, oor, &
                        nx, ny, ng + 1, ng + 1, this%id_evap, ierr=ierr)
      if (present(ierr)) then
         if (ierr /= OCEAN_STATUS_OK) return
      end if
      call register_tag(cfg, cfg%lprec, "lprec", reader, grid, oor, &
                        nx, ny, ng + 1, ng + 1, this%id_lprec, ierr=ierr)
      if (present(ierr)) then
         if (ierr /= OCEAN_STATUS_OK) return
      end if
      call register_tag(cfg, cfg%salt, "salt", reader, grid, oor, &
                        nx, ny, ng + 1, ng + 1, this%id_salt, ierr=ierr)
      if (present(ierr)) then
         if (ierr /= OCEAN_STATUS_OK) return
      end if

      this%active = (this%id_tau_x > 0 .or. this%id_tau_y > 0 .or. &
                     this%id_heat > 0 .or. this%id_evap > 0 .or. &
                     this%id_lprec > 0 .or. this%id_salt > 0)

      if (.not. this%active) then
         call logger%warning("ocean_dataovr: enable = .true. but no tag has a file — "// &
                             "every surface slot keeps its configure-time value")
         return
      end if

      ! Latches the consuming kernels gate on.  Set HERE, not per step:
      ! they are host-side gates on a device-mapped derived type, and a
      ! host write to a mapped component never reaches the device.
      ! Registration is for the whole run, so the latch is too.
      if (this%id_heat > 0) sf%has_heat = .true.
      if (this%id_salt > 0) sf%has_salt = .true.
      if (this%id_evap > 0 .or. this%id_lprec > 0) sf%has_mass_flux = .true.

      ! `stress_mag` must be consistent with whatever the first blend
      ! writes; the first `apply` re-derives it, but configure-time
      ! consumers that read it before the first step should not see a
      ! value derived from a wind field that is about to be replaced.
      if (this%id_tau_x > 0 .or. this%id_tau_y > 0) then
         call ocean_seam_refresh_surface_stress(ss, grid, bc, device_resident=.false.)
      end if
   end subroutine ocean_data_forcing_configure