topo_length_to_grid_units Function

public pure function topo_length_to_grid_units(length_m, grid_config, rad_earth) result(len_grid)

Convert a metres length scale (slope_scale / half_width) into the GRID coordinate units the formula bathymetry setters operate in. Cartesian grids carry positions in metres, so the scale passes through unchanged. Spherical / supergrid / tripolar grids carry positions in DEGREES, so the metres scale is converted to degrees of latitude (meridional metres-per-degree = rad_earth · π/180). This keeps the seamount/spoon length scale commensurate with the grid coordinate; without it a metres scale divided by a degrees position underflows the Gaussian/exponential and the basin collapses flat. Zonal cells are narrower by cos(lat), so a degree-isotropic bump is mildly elongated zonally in physical space — acceptable for these idealised topographies; the degeneracy is what this fixes.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: length_m
character(len=*), intent(in) :: grid_config
real(kind=wp), intent(in) :: rad_earth

Return Value real(kind=wp)


Called by

proc~~topo_length_to_grid_units~~CalledByGraph proc~topo_length_to_grid_units topo_length_to_grid_units proc~ocean_state_seed_from_cfg ocean_state_seed_from_cfg proc~ocean_state_seed_from_cfg->proc~topo_length_to_grid_units proc~seed_cavity_draft seed_cavity_draft proc~ocean_state_seed_from_cfg->proc~seed_cavity_draft proc~seed_cavity_draft->proc~topo_length_to_grid_units 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

Source Code

   pure function topo_length_to_grid_units(length_m, grid_config, rad_earth) result(len_grid)
      !! Convert a metres length scale (`slope_scale` / `half_width`) into the
      !! GRID coordinate units the formula bathymetry setters operate in.
      !! Cartesian grids carry positions in metres, so the scale passes
      !! through unchanged.  Spherical / supergrid / tripolar grids carry
      !! positions in DEGREES, so the metres scale is converted to degrees of
      !! latitude (meridional metres-per-degree = `rad_earth · π/180`).  This
      !! keeps the seamount/spoon length scale commensurate with the grid
      !! coordinate; without it a metres scale divided by a degrees position
      !! underflows the Gaussian/exponential and the basin collapses flat.
      !! Zonal cells are narrower by `cos(lat)`, so a degree-isotropic bump is
      !! mildly elongated zonally in physical space — acceptable for these
      !! idealised topographies; the degeneracy is what this fixes.
      real(wp), intent(in) :: length_m, rad_earth
      character(len=*), intent(in) :: grid_config
      real(wp) :: len_grid
      select case (trim(grid_config))
      case ("spherical", "supergrid", "tripolar")
         len_grid = length_m/(rad_earth*DEG2RAD)
      case default
         len_grid = length_m
      end select
   end function topo_length_to_grid_units