configure_ocean_z_fixed_profile Subroutine

public subroutine configure_ocean_z_fixed_profile(cfg, ocean_state, compute_rank, log_it)

Resolve the VCOORD_Z_FIXED nominal layering onto the vcoord slot — and the VCOORD_ZSTAR one, which is the same nominal profile (MOM6 z* dilates it per column; ocean_vcoord_zstar_target): z_fixed_h_ref = &ocean_topo_nml max_depth (the uniform max_depth/nz spacing — the default, byte-identical), or, under &vcoord_nml z_fixed_profile = "list" | "tanh", the stretched per-layer tables z_fixed_zi / z_fixed_dz built by rdb_vcoord :: z_fixed_nominal_dz (z_fixed_h_ref then becomes the profile’s total depth).

The same tables are the z NOMINAL FLOOR of VCOORD_HYCOM (MOM6 HYCOM1 floors its interfaces at the z coordinateResolution its ALE_COORDINATE_CONFIG defines), so this also runs for hycom.

Idempotent (it rebuilds from cfg each call). Called twice: by engine_setup BEFORE the IC seed — the cavity z_fixed seed lays h_layer from the same target builder and must see the same profile — and from configure_ocean_lateral, which has always owned z_fixed_h_ref. Both precede ocean_state_enter_data, so the copyin captures the tables. validate_config has already refused a profile that does not build, or one on another family.

Arguments

Type IntentOptional Attributes Name
type(config_t), intent(in) :: cfg
type(ocean_state_t), intent(inout) :: ocean_state
integer, intent(in) :: compute_rank
logical, intent(in) :: log_it

Log the resolved profile (rank 0).


Calls

proc~~configure_ocean_z_fixed_profile~~CallsGraph proc~configure_ocean_z_fixed_profile configure_ocean_z_fixed_profile info info proc~configure_ocean_z_fixed_profile->info proc~ocean_vcoord_set_z_fixed_profile ocean_vcoord_set_z_fixed_profile proc~configure_ocean_z_fixed_profile->proc~ocean_vcoord_set_z_fixed_profile proc~parse_z_fixed_profile parse_z_fixed_profile proc~configure_ocean_z_fixed_profile->proc~parse_z_fixed_profile proc~z_fixed_nominal_dz z_fixed_nominal_dz proc~configure_ocean_z_fixed_profile->proc~z_fixed_nominal_dz to_string to_string proc~configure_ocean_z_fixed_profile->to_string

Called by

proc~~configure_ocean_z_fixed_profile~~CalledByGraph proc~configure_ocean_z_fixed_profile configure_ocean_z_fixed_profile proc~configure_ocean_lateral configure_ocean_lateral proc~configure_ocean_lateral->proc~configure_ocean_z_fixed_profile proc~engine_setup engine_setup proc~engine_setup->proc~configure_ocean_z_fixed_profile proc~engine_setup->proc~configure_ocean_lateral 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 :: code
real(kind=wp), private, allocatable :: dz(:)
integer, private :: ierr
integer, private :: nz

Source Code

   subroutine configure_ocean_z_fixed_profile(cfg, ocean_state, compute_rank, log_it)
      !! Resolve the `VCOORD_Z_FIXED` nominal layering onto the vcoord slot —
      !! and the `VCOORD_ZSTAR` one, which is the same nominal profile
      !! (MOM6 z* dilates it per column; `ocean_vcoord_zstar_target`):
      !! `z_fixed_h_ref = &ocean_topo_nml max_depth` (the uniform
      !! `max_depth/nz` spacing — the default, byte-identical), or, under
      !! `&vcoord_nml z_fixed_profile = "list" | "tanh"`, the stretched
      !! per-layer tables `z_fixed_zi` / `z_fixed_dz` built by
      !! `rdb_vcoord :: z_fixed_nominal_dz` (`z_fixed_h_ref` then becomes
      !! the profile's total depth).
      !!
      !! The same tables are the z* NOMINAL FLOOR of `VCOORD_HYCOM` (MOM6
      !! HYCOM1 floors its interfaces at the z* `coordinateResolution` its
      !! ALE_COORDINATE_CONFIG defines), so this also runs for `hycom`.
      !!
      !! Idempotent (it rebuilds from `cfg` each call).  Called twice: by
      !! `engine_setup` BEFORE the IC seed — the cavity `z_fixed` seed lays
      !! `h_layer` from the same target builder and must see the same
      !! profile — and from `configure_ocean_lateral`, which has always
      !! owned `z_fixed_h_ref`.  Both precede `ocean_state_enter_data`, so
      !! the copyin captures the tables.  `validate_config` has already
      !! refused a profile that does not build, or one on another family.
      type(config_t), intent(in) :: cfg
      type(ocean_state_t), intent(inout) :: ocean_state
      integer, intent(in) :: compute_rank
      logical, intent(in) :: log_it
         !! Log the resolved profile (rank 0).
      integer :: code, ierr, nz
      real(wp), allocatable :: dz(:)

      ocean_state%vcoord%z_fixed_h_ref = cfg%ocean%topo%max_depth
      ocean_state%vcoord%z_fixed_use_profile = .false.
      if (.not. ocean_state%vcoord%is_init) return
      ! Three readers of the z* nominal resolution: `z_fixed` (its levels),
      ! `zstar` (MOM6 z*, its levels) and `hycom` (its z* nominal floor,
      ! MOM6 HYCOM1 coordinateResolution).
      if (ocean_state%vcoord%coord_type /= VCOORD_Z_FIXED .and. &
          ocean_state%vcoord%coord_type /= VCOORD_ZSTAR .and. &
          ocean_state%vcoord%coord_type /= VCOORD_HYCOM) return
      code = parse_z_fixed_profile(cfg%z_fixed_profile)
      if (code == ZFIXED_PROFILE_UNIFORM .or. code == ZFIXED_PROFILE_INVALID) return
      nz = ocean_state%vcoord%nz_ml
      allocate (dz(nz))
      call z_fixed_nominal_dz(code, nz, cfg%ocean%topo%max_depth, cfg%z_fixed_dz, &
                              cfg%z_fixed_dz_top, cfg%z_fixed_tanh_center, &
                              cfg%z_fixed_tanh_width, dz, ierr)
      if (ierr /= ZFIXED_DZ_OK) return
      call ocean_vcoord_set_z_fixed_profile(ocean_state%vcoord, dz)
      if (log_it .and. compute_rank == 0) then
         call logger%info(trim(cfg%vcoord_type)//" z* profile:  "//trim(cfg%z_fixed_profile)// &
                          " — nominal dz "//to_string(dz(1))//" m (surface) … "// &
                          to_string(dz(nz))//" m (bed), total "// &
                          to_string(ocean_state%vcoord%z_fixed_h_ref)//" m over "// &
                          to_string(nz)//" layers")
      end if
   end subroutine configure_ocean_z_fixed_profile