two_dp Function

private pure function two_dp(x) result(str)

Format a real to exactly two decimal places without leading blanks (write with an f edit descriptor, then adjustl + trim).

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

Return Value character(len=:), allocatable


Called by

proc~~two_dp~~CalledByGraph proc~two_dp two_dp proc~mem_format_bytes mem_format_bytes proc~mem_format_bytes->proc~two_dp proc~mem_log_computed_budget mem_log_computed_budget proc~mem_log_computed_budget->proc~mem_format_bytes proc~mem_log_computed_line mem_log_computed_line proc~mem_log_computed_line->proc~mem_format_bytes proc~mem_log_device_actuals mem_log_device_actuals proc~mem_log_device_actuals->proc~mem_format_bytes proc~mem_log_device_growth mem_log_device_growth proc~mem_log_device_growth->proc~mem_format_bytes proc~mem_log_state_budget mem_log_state_budget proc~mem_log_state_budget->proc~mem_format_bytes proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~mem_log_computed_budget proc~driver_run_ocean->proc~mem_log_computed_line proc~driver_run_ocean->proc~mem_log_device_actuals proc~driver_run_ocean->proc~mem_log_device_growth proc~driver_run_ocean->proc~mem_log_state_budget proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean

Variables

Type Visibility Attributes Name Initial
character(len=32), private :: buf

Source Code

   pure function two_dp(x) result(str)
      !! Format a real to exactly two decimal places without leading
      !! blanks (`write` with an `f` edit descriptor, then `adjustl` +
      !! trim).
      real(wp), intent(in) :: x
      character(len=:), allocatable :: str
      character(len=32) :: buf
      write (buf, "(f0.2)") x
      ! `f0.2` of a value < 1 emits ".50" on some compilers; prefix a 0.
      if (buf(1:1) == ".") then
         str = "0"//trim(adjustl(buf))
      else
         str = trim(adjustl(buf))
      end if
   end function two_dp