The function str_R16P converts real to string. This function achieves casting of real to string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
logical, | intent(in), | optional | :: | no_sign | ||
real(kind=R16P), | intent(in) | :: | n |
elemental function str_R16P(no_sign,n) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
!!The function str\_R16P converts real to string. This function achieves casting of real to string.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
logical, intent(IN), optional:: no_sign ! Flag for leaving out the sign.
real(R16P), intent(IN):: n ! Real to be converted.
character(DR16P):: str ! Returned string containing input number.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
write(str,FR16P) n ! Casting of n to string.
if (n>0._R16P) str(1:1)='+' ! Prefixing plus if n>0.
if (present(no_sign)) str=str(2:) ! Leaving out the sign.
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction str_R16P