ocean_data_input_load_static_2d Subroutine

public subroutine ocean_data_input_load_static_2d(file, var, grid, n1, n2, dest_i0, dest_j0, dest, ierr)

One-shot STATIC 2-D read: register, fill, close. The setup-time convenience wrapper over register_2d(time_mode="static") + fill_static_host for a field that is read ONCE and never updated — a prescribed, time-constant geometry rather than a forcing. &ocean_cavity_dyn_nml draft_config="file" is the first consumer.

The reader is LOCAL and destroyed on the way out: nothing is left on ocean_state_t%data_input, which exists for the per-step forcing tags and whose registry would otherwise be permanently one slot smaller for a field never read again. It also keeps the static geometry out of enter_data — the destination array is the state’s own, and IT is what gets mapped.

FILE CONTRACT (inherited from register_common, not weakened here): var must be rank 3 in FORTRAN storage order (x, y, t) — i.e. (nTime, ny, nx) as a C/Python writer or ncdump spells it — with a time COORDINATE VARIABLE, and its horizontal extents must cover this rank’s slab. Record 1 is read. There is NO horizontal interpolation: the file must already be on the model grid, exactly as bathymetry_file and &ocean_zinit_nml file require.

HOST-ONLY: runs at setup, before dest is device-mapped.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: file
character(len=*), intent(in) :: var
type(hgrid_t), intent(in) :: grid
integer, intent(in) :: n1

Shape of dest — the FULL ghosted (nx_total, ny_total).

integer, intent(in) :: n2

Shape of dest — the FULL ghosted (nx_total, ny_total).

integer, intent(in) :: dest_i0

Destination index of the first PHYSICAL cell (nghost + 1).

integer, intent(in) :: dest_j0

Destination index of the first PHYSICAL cell (nghost + 1).

real(kind=wp), intent(inout) :: dest(n1,n2)
integer, intent(out), optional :: ierr

Non-zero on a registry / file / dimension failure when present; absent behaves as the rest of the reader (error stop).


Calls

proc~~ocean_data_input_load_static_2d~~CallsGraph proc~ocean_data_input_load_static_2d ocean_data_input_load_static_2d proc~ocean_data_input_destroy ocean_data_input_t%ocean_data_input_destroy proc~ocean_data_input_load_static_2d->proc~ocean_data_input_destroy proc~ocean_data_input_fill_static_host ocean_data_input_fill_static_host proc~ocean_data_input_load_static_2d->proc~ocean_data_input_fill_static_host proc~ocean_data_input_init ocean_data_input_t%ocean_data_input_init proc~ocean_data_input_load_static_2d->proc~ocean_data_input_init proc~ocean_data_input_register_2d ocean_data_input_register_2d proc~ocean_data_input_load_static_2d->proc~ocean_data_input_register_2d proc~data_input_workspace_cleanup data_input_workspace_cleanup proc~ocean_data_input_destroy->proc~data_input_workspace_cleanup proc~nc_close nc_close proc~ocean_data_input_destroy->proc~nc_close error error proc~ocean_data_input_fill_static_host->error proc~check_registered check_registered proc~ocean_data_input_fill_static_host->proc~check_registered to_string to_string proc~ocean_data_input_fill_static_host->to_string proc~ocean_data_input_init->proc~ocean_data_input_destroy proc~register_common register_common proc~ocean_data_input_register_2d->proc~register_common proc~check_registered->error proc~check_registered->to_string nf90_close nf90_close proc~nc_close->nf90_close proc~nc_check nc_check proc~nc_close->proc~nc_check proc~register_common->error proc~register_common->proc~nc_close proc~register_common->to_string 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~fail fail proc~register_common->proc~fail proc~register_common->proc~nc_check 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 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~fail->error proc~error_ring_push error_ring_push proc~fail->proc~error_ring_push proc~nc_check->proc~fail nf90_strerror nf90_strerror proc~nc_check->nf90_strerror 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~reg_io_ok->proc~nc_close proc~resolve_time_var->nf90_inq_varid proc~resolve_time_var->nf90_inquire_dimension proc~nc_get_var_slab_3d->proc~nc_check proc~nc_get_var_slab_3d->nf90_get_var

Called by

proc~~ocean_data_input_load_static_2d~~CalledByGraph proc~ocean_data_input_load_static_2d ocean_data_input_load_static_2d proc~seed_cavity_draft seed_cavity_draft proc~seed_cavity_draft->proc~ocean_data_input_load_static_2d 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 :: id
integer, private :: local_ierr
type(ocean_data_input_t), private :: reader

Source Code

   subroutine ocean_data_input_load_static_2d(file, var, grid, n1, n2, dest_i0, dest_j0, &
                                              dest, ierr)
      !! One-shot STATIC 2-D read: register, fill, close.  The setup-time
      !! convenience wrapper over `register_2d(time_mode="static")` +
      !! `fill_static_host` for a field that is read ONCE and never
      !! updated — a prescribed, time-constant geometry rather than a
      !! forcing.  `&ocean_cavity_dyn_nml draft_config="file"` is the
      !! first consumer.
      !!
      !! The reader is LOCAL and destroyed on the way out: nothing is left
      !! on `ocean_state_t%data_input`, which exists for the per-step
      !! forcing tags and whose registry would otherwise be permanently
      !! one slot smaller for a field never read again.  It also keeps the
      !! static geometry out of `enter_data` — the destination array is
      !! the state's own, and IT is what gets mapped.
      !!
      !! FILE CONTRACT (inherited from `register_common`, not weakened
      !! here): `var` must be rank 3 in FORTRAN storage order `(x, y, t)`
      !! — i.e. `(nTime, ny, nx)` as a C/Python writer or `ncdump` spells
      !! it — with a time COORDINATE VARIABLE, and its horizontal extents
      !! must cover this rank's slab.  Record 1 is read.  There is NO
      !! horizontal interpolation: the file must already be on the model
      !! grid, exactly as `bathymetry_file` and `&ocean_zinit_nml file`
      !! require.
      !!
      !! HOST-ONLY: runs at setup, before `dest` is device-mapped.
      character(len=*), intent(in) :: file, var
      type(hgrid_t), intent(in) :: grid
      integer, intent(in) :: n1, n2
         !! Shape of `dest` — the FULL ghosted `(nx_total, ny_total)`.
      integer, intent(in) :: dest_i0, dest_j0
         !! Destination index of the first PHYSICAL cell (`nghost + 1`).
      real(wp), intent(inout) :: dest(n1, n2)
      integer, intent(out), optional :: ierr
         !! Non-zero on a registry / file / dimension failure when
         !! present; absent behaves as the rest of the reader
         !! (`error stop`).

      type(ocean_data_input_t) :: reader
      integer :: id, local_ierr

      if (present(ierr)) ierr = OCEAN_STATUS_OK

      call reader%init()
      if (present(ierr)) then
         call ocean_data_input_register_2d(reader, file, var, grid, &
                                           dest_n1=n1, dest_n2=n2, &
                                           dest_i0=dest_i0, dest_j0=dest_j0, &
                                           id=id, time_mode="static", ierr=local_ierr)
         if (local_ierr /= OCEAN_STATUS_OK) then
            call reader%destroy()
            ierr = local_ierr
            return
         end if
      else
         call ocean_data_input_register_2d(reader, file, var, grid, &
                                           dest_n1=n1, dest_n2=n2, &
                                           dest_i0=dest_i0, dest_j0=dest_j0, &
                                           id=id, time_mode="static")
      end if

      call ocean_data_input_fill_static_host(reader, id, n1, n2, dest)
      call reader%destroy()
   end subroutine ocean_data_input_load_static_2d