metrics_porous_alloc Subroutine

public subroutine metrics_porous_alloc(this, grid, nz)

Grow the porous-barrier arrays from their (1,1)/(1,1,1) placeholder size to full face size. Call ONLY when &ocean_porous_nml enable is on, at configure time — i.e. after init and BEFORE ocean_state_enter_data, so the device map captures the final shapes (a realloc after enter_data would leave the device pointing at freed host memory).

The open fractions start at 1 (fully open) so that a stage which reads them before the first recompute sees an inert scheme.

Arguments

Type IntentOptional Attributes Name
type(ocean_metrics_t), intent(inout) :: this
type(hgrid_t), intent(in) :: grid
integer, intent(in) :: nz

Number of layers (multilayer%nz_ml).


Called by

proc~~metrics_porous_alloc~~CalledByGraph proc~metrics_porous_alloc metrics_porous_alloc proc~configure_ocean_porous configure_ocean_porous proc~configure_ocean_porous->proc~metrics_porous_alloc proc~engine_setup engine_setup proc~engine_setup->proc~configure_ocean_porous 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 :: nx
integer, private :: ny

Source Code

   subroutine metrics_porous_alloc(this, grid, nz)
      !! Grow the porous-barrier arrays from their `(1,1)`/`(1,1,1)`
      !! placeholder size to full face size.  Call ONLY when
      !! `&ocean_porous_nml enable` is on, at configure time — i.e. after
      !! `init` and BEFORE `ocean_state_enter_data`, so the device map
      !! captures the final shapes (a realloc after `enter_data` would
      !! leave the device pointing at freed host memory).
      !!
      !! The open fractions start at 1 (fully open) so that a stage which
      !! reads them before the first recompute sees an inert scheme.
      type(ocean_metrics_t), intent(inout) :: this
      type(hgrid_t), intent(in) :: grid
      integer, intent(in) :: nz
         !! Number of layers (`multilayer%nz_ml`).

      integer :: nx, ny

      nx = grid%nx_total
      ny = grid%ny_total

      if (allocated(this%por_bed)) deallocate (this%por_bed)
      if (allocated(this%por_dmin_u)) deallocate (this%por_dmin_u)
      if (allocated(this%por_dmax_u)) deallocate (this%por_dmax_u)
      if (allocated(this%por_davg_u)) deallocate (this%por_davg_u)
      if (allocated(this%por_dmin_v)) deallocate (this%por_dmin_v)
      if (allocated(this%por_dmax_v)) deallocate (this%por_dmax_v)
      if (allocated(this%por_davg_v)) deallocate (this%por_davg_v)
      if (allocated(this%por_face_area_u)) deallocate (this%por_face_area_u)
      if (allocated(this%por_face_area_v)) deallocate (this%por_face_area_v)

      allocate (this%por_bed(nx, ny), source=0.0_wp)
      allocate (this%por_dmin_u(nx + 1, ny), source=0.0_wp)
      allocate (this%por_dmax_u(nx + 1, ny), source=0.0_wp)
      allocate (this%por_davg_u(nx + 1, ny), source=0.0_wp)
      allocate (this%por_dmin_v(nx, ny + 1), source=0.0_wp)
      allocate (this%por_dmax_v(nx, ny + 1), source=0.0_wp)
      allocate (this%por_davg_v(nx, ny + 1), source=0.0_wp)
      allocate (this%por_face_area_u(nx + 1, ny, nz), source=1.0_wp)
      allocate (this%por_face_area_v(nx, ny + 1, nz), source=1.0_wp)
   end subroutine metrics_porous_alloc