data_input_time_scale_from_units Subroutine

public pure subroutine data_input_time_scale_from_units(units, scale, ok)

CF units attribute (“seconds since …”, “hours since …”, …) -> a multiplier converting the raw file time axis to seconds. Only the leading unit word matters (no calendar, no reference date — see module docstring). ok = .false. for an unrecognised leading word; caller decides the fallback.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: units
real(kind=wp), intent(out) :: scale
logical, intent(out) :: ok

Calls

proc~~data_input_time_scale_from_units~~CallsGraph proc~data_input_time_scale_from_units data_input_time_scale_from_units to_lower to_lower proc~data_input_time_scale_from_units->to_lower

Called by

proc~~data_input_time_scale_from_units~~CalledByGraph proc~data_input_time_scale_from_units data_input_time_scale_from_units proc~register_common register_common proc~register_common->proc~data_input_time_scale_from_units proc~ocean_data_input_register_2d ocean_data_input_register_2d proc~ocean_data_input_register_2d->proc~register_common proc~ocean_data_input_register_3d ocean_data_input_register_3d proc~ocean_data_input_register_3d->proc~register_common proc~ocean_data_input_register_segment_2d ocean_data_input_register_segment_2d proc~ocean_data_input_register_segment_2d->proc~register_common proc~ocean_data_input_register_segment_3d ocean_data_input_register_segment_3d proc~ocean_data_input_register_segment_3d->proc~register_common proc~ocean_data_input_load_static_2d ocean_data_input_load_static_2d proc~ocean_data_input_load_static_2d->proc~ocean_data_input_register_2d proc~register_tag register_tag proc~register_tag->proc~ocean_data_input_register_2d proc~ocean_data_forcing_configure ocean_data_forcing_configure proc~ocean_data_forcing_configure->proc~register_tag proc~seed_cavity_draft seed_cavity_draft proc~seed_cavity_draft->proc~ocean_data_input_load_static_2d proc~engine_setup engine_setup proc~engine_setup->proc~ocean_data_forcing_configure proc~ocean_state_seed_from_cfg ocean_state_seed_from_cfg proc~ocean_state_seed_from_cfg->proc~seed_cavity_draft

Variables

Type Visibility Attributes Name Initial
character(len=:), private, allocatable :: u

Source Code

   pure subroutine data_input_time_scale_from_units(units, scale, ok)
      !! CF `units` attribute ("seconds since ...", "hours since ...", ...)
      !! -> a multiplier converting the raw file time axis to seconds.
      !! Only the leading unit word matters (no calendar, no reference
      !! date — see module docstring).  `ok = .false.` for an
      !! unrecognised leading word; caller decides the fallback.
      character(len=*), intent(in) :: units
      real(wp), intent(out) :: scale
      logical, intent(out) :: ok

      character(len=:), allocatable :: u

      u = to_lower(adjustl(units))
      ok = .true.
      if (index(u, "second") == 1 .or. index(u, "sec") == 1) then
         scale = 1.0_wp
      else if (index(u, "minute") == 1 .or. index(u, "min") == 1) then
         scale = 60.0_wp
      else if (index(u, "hour") == 1) then
         scale = 3600.0_wp
      else if (index(u, "day") == 1) then
         scale = 86400.0_wp
      else
         scale = 1.0_wp
         ok = .false.
      end if
   end subroutine data_input_time_scale_from_units