real_to_string Subroutine

private subroutine real_to_string(v, fmt, str)

Real scalar to string.

Arguments

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

real values

character(len=*), intent(in) :: fmt

real format string

character(len=:), intent(out), allocatable :: str

real values stringified


Called by

proc~~real_to_string~~CalledByGraph proc~real_to_string real_to_string proc~add_sphere pyplot%add_sphere proc~add_sphere->proc~real_to_string

Source Code

    subroutine real_to_string(v, fmt, str)

    real(wp),                      intent(in)  :: v         !! real values
    character(len=*),              intent(in)  :: fmt       !! real format string
    character(len=:), allocatable, intent(out) :: str       !! real values stringified

    integer                     :: istat     !! IO status
    character(len=max_real_len) :: tmp       !! dummy string

    if (fmt=='*') then
        write(tmp, *, iostat=istat) v
    else
        write(tmp, fmt, iostat=istat) v
    end if
    if (istat/=0) then
        write(error_unit,'(A)') 'Error in real_to_string'
        str = '****'
    else
        str = trim(adjustl(tmp))
    end if

    end subroutine real_to_string