Convert a real to a string. Works for up to 256 digits.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | r |
real to convert |
string result
function real2str(r) result(s) real(wp), intent(in) :: r !! real to convert character(len=:),allocatable :: s !! string result character(len=256) :: tmp !! temp string integer :: iostat !! write `iostat` code write(tmp,fmt=*,iostat=iostat) r if (iostat/=0) then s = '****' else s = trim(adjustl(tmp)) end if end function real2str