mem_format_bytes Function

public pure function mem_format_bytes(bytes) result(str)

Human-readable byte count: two decimals, GB at/above 1 GiB, MB below. Used for every figure in the budget log so the units stay consistent.

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: bytes

Return Value character(len=:), allocatable


Calls

proc~~mem_format_bytes~~CallsGraph proc~mem_format_bytes mem_format_bytes proc~two_dp two_dp proc~mem_format_bytes->proc~two_dp

Called by

proc~~mem_format_bytes~~CalledByGraph proc~mem_format_bytes mem_format_bytes 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
real(kind=wp), private :: gib
real(kind=wp), private :: mib

Source Code

   pure function mem_format_bytes(bytes) result(str)
      !! Human-readable byte count: two decimals, GB at/above 1 GiB,
      !! MB below.  Used for every figure in the budget log so the
      !! units stay consistent.
      integer(int64), intent(in) :: bytes
      character(len=:), allocatable :: str
      real(wp) :: gib, mib

      if (bytes >= BYTES_PER_GIB) then
         gib = real(bytes, wp)/real(BYTES_PER_GIB, wp)
         str = two_dp(gib)//" GB"
      else
         mib = real(bytes, wp)/real(BYTES_PER_MIB, wp)
         str = two_dp(mib)//" MB"
      end if
   end function mem_format_bytes