Convert a real value to a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=RK), | intent(in) | :: | rval | real value. |
||
character(kind=CDK,len=*), | intent(in) | :: | real_fmt | format for real numbers |
||
logical(kind=LK), | intent(in) | :: | compact_real | compact the string so that it is displayed with fewer characters |
||
character(kind=CK,len=*), | intent(out) | :: | str |
|
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
subroutine real_to_string(rval,real_fmt,compact_real,str)
implicit none
real(RK),intent(in) :: rval !! real value.
character(kind=CDK,len=*),intent(in) :: real_fmt !! format for real numbers
logical(LK),intent(in) :: compact_real !! compact the string so that it is
!! displayed with fewer characters
character(kind=CK,len=*),intent(out) :: str !! `rval` converted to a string.
integer(IK) :: istat
if (real_fmt==star) then
write(str,fmt=*,iostat=istat) rval
else
write(str,fmt=real_fmt,iostat=istat) rval
end if
if (istat==0) then
!in this case, the default string will be compacted,
! so that the same value is displayed with fewer characters.
if (compact_real) call compact_real_string(str)
else
str = repeat(star,len(str))
end if
end subroutine real_to_string