Real scalar to string.
Type | Intent | Optional | 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 |
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