apply_time_unit_cascade Subroutine

private subroutine apply_time_unit_cascade(cfg)

Post-parse time-unit fixup shared by the file + string config paths. t_end, status_interval, ocean_diag%dt_out are given in time_unit from &time_nml; multiply through to SI seconds. dt_fixed/dt_max stay in seconds; default time_unit="s" gives a 1× factor (bit-identical to before).

Arguments

Type IntentOptional Attributes Name
type(config_t), intent(inout) :: cfg

Calls

proc~~apply_time_unit_cascade~~CallsGraph proc~apply_time_unit_cascade apply_time_unit_cascade error error proc~apply_time_unit_cascade->error

Called by

proc~~apply_time_unit_cascade~~CalledByGraph proc~apply_time_unit_cascade apply_time_unit_cascade proc~read_config_from_string_impl read_config_from_string_impl proc~read_config_from_string_impl->proc~apply_time_unit_cascade proc~read_config_impl read_config_impl proc~read_config_impl->proc~apply_time_unit_cascade proc~read_config read_config proc~read_config->proc~read_config_impl proc~read_config_from_string read_config_from_string proc~read_config_from_string->proc~read_config_from_string_impl proc~build_pending_handle build_pending_handle proc~build_pending_handle->proc~read_config_from_string proc~rdb_ocean_create_from_string rdb_ocean_create_from_string proc~rdb_ocean_create_from_string->proc~build_pending_handle proc~rdb_ocean_create_pending rdb_ocean_create_pending proc~rdb_ocean_create_pending->proc~build_pending_handle

Variables

Type Visibility Attributes Name Initial
real(kind=wp), private :: time_factor

Source Code

   subroutine apply_time_unit_cascade(cfg)
      !! Post-parse time-unit fixup shared by the file + string config
      !! paths.  `t_end`, `status_interval`, `ocean_diag%dt_out` are given
      !! in `time_unit` from `&time_nml`; multiply through to SI seconds.
      !! `dt_fixed`/`dt_max` stay in seconds; default `time_unit="s"`
      !! gives a 1× factor (bit-identical to before).
      type(config_t), intent(inout) :: cfg

      real(wp) :: time_factor

      select case (trim(cfg%time_unit))
      case ("s", "sec", "second", "seconds")
         time_factor = 1.0_wp
      case ("min", "minute", "minutes")
         time_factor = 60.0_wp
      case ("hr", "hour", "hours", "h")
         time_factor = 3600.0_wp
      case ("day", "days", "d")
         time_factor = 86400.0_wp
      case ("year", "years", "yr")
         ! Julian year (365.25 d) — matches MOM6 / UDUNITS.
         time_factor = 365.25_wp*86400.0_wp
      case default
         call logger%error("Invalid time_unit = '"//trim(cfg%time_unit)// &
                           "': must be one of s/min/hr/day/year")
         time_factor = 1.0_wp  ! fallthrough so validation reports it
      end select
      cfg%t_end = cfg%t_end*time_factor
      cfg%status_interval = cfg%status_interval*time_factor
      cfg%ocean%diag%dt_out = cfg%ocean%diag%dt_out*time_factor
   end subroutine apply_time_unit_cascade