rdb_ocean_stage_metrics Function

public function rdb_ocean_stage_metrics(c_handle, x, y, dx, dy, area, nxp, nyp, nx, ny) result(status) bind(c, name="rdb_ocean_stage_metrics")

P2.5: stage in-memory MOM6-style supergrid arrays on the PENDING handle c_handle — metrics_assemble_from_supergrid_arrays’s exact layout (x/y: (nxp,nyp) degrees; dx: (nx,nyp) m; dy: (nxp,ny) m; area: (nx,ny) m^2, where nxp=2*nx_phys+1, nyp=2*ny_phys+1, nx=2*nx_phys, ny=2*ny_phys). Consumed inside rdb_ocean_create_finalize, bypassing cfg%ocean%grid%grid_config entirely — exports the SAME assembler the NetCDF supergrid reader and the analytic tripolar generator already use, so this and a mosaic-file grid produce identical metrics for the identical arrays. Shape is validated at create_finalize time (against the grid, which does not exist yet here).

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in), value :: c_handle
real(kind=c_double), intent(in) :: x(nxp,nyp)
real(kind=c_double), intent(in) :: y(nxp,nyp)
real(kind=c_double), intent(in) :: dx(nx,nyp)
real(kind=c_double), intent(in) :: dy(nxp,ny)
real(kind=c_double), intent(in) :: area(nx,ny)
integer(kind=c_int), intent(in), value :: nxp
integer(kind=c_int), intent(in), value :: nyp
integer(kind=c_int), intent(in), value :: nx
integer(kind=c_int), intent(in), value :: ny

Return Value integer(kind=c_int)


Calls

proc~~rdb_ocean_stage_metrics~~CallsGraph proc~rdb_ocean_stage_metrics rdb_ocean_stage_metrics proc~resolve_ocean_pending resolve_ocean_pending proc~rdb_ocean_stage_metrics->proc~resolve_ocean_pending proc~handle_check handle_check proc~resolve_ocean_pending->proc~handle_check

Variables

Type Visibility Attributes Name Initial
type(ocean_handle_t), private, pointer :: h

Source Code

   function rdb_ocean_stage_metrics(c_handle, x, y, dx, dy, area, nxp, nyp, nx, ny) &
      result(status) bind(c, name="rdb_ocean_stage_metrics")
      !! P2.5: stage in-memory MOM6-style supergrid arrays on the PENDING
      !! handle `c_handle` — `metrics_assemble_from_supergrid_arrays`'s
      !! exact layout (`x`/`y`: `(nxp,nyp)` degrees; `dx`: `(nx,nyp)` m;
      !! `dy`: `(nxp,ny)` m; `area`: `(nx,ny)` m^2, where
      !! `nxp=2*nx_phys+1`, `nyp=2*ny_phys+1`, `nx=2*nx_phys`,
      !! `ny=2*ny_phys`). Consumed inside `rdb_ocean_create_finalize`,
      !! bypassing `cfg%ocean%grid%grid_config` entirely — exports the
      !! SAME assembler the NetCDF supergrid reader and the analytic
      !! tripolar generator already use, so this and a mosaic-file grid
      !! produce identical metrics for the identical arrays. Shape is
      !! validated at `create_finalize` time (against the grid, which does
      !! not exist yet here).
      type(c_ptr), intent(in), value :: c_handle
      integer(c_int), intent(in), value :: nxp, nyp, nx, ny
      real(c_double), intent(in) :: x(nxp, nyp), y(nxp, nyp)
      real(c_double), intent(in) :: dx(nx, nyp), dy(nxp, ny)
      real(c_double), intent(in) :: area(nx, ny)
      integer(c_int) :: status

      type(ocean_handle_t), pointer :: h

      status = resolve_ocean_pending(c_handle, h)
      if (status /= OCEAN_STATUS_OK) return

      if (allocated(h%engine%staged_metrics_x)) then
         deallocate (h%engine%staged_metrics_x, h%engine%staged_metrics_y, &
                     h%engine%staged_metrics_dx, h%engine%staged_metrics_dy, &
                     h%engine%staged_metrics_area)
      end if
      allocate (h%engine%staged_metrics_x(nxp, nyp), source=real(x, wp))
      allocate (h%engine%staged_metrics_y(nxp, nyp), source=real(y, wp))
      allocate (h%engine%staged_metrics_dx(nx, nyp), source=real(dx, wp))
      allocate (h%engine%staged_metrics_dy(nxp, ny), source=real(dy, wp))
      allocate (h%engine%staged_metrics_area(nx, ny), source=real(area, wp))
      status = int(OCEAN_STATUS_OK, c_int)
   end function rdb_ocean_stage_metrics