str_R16P Function

private elemental function str_R16P(n, no_sign, compact) result(str)

Arguments

TypeIntentOptionalAttributesName
real(kind=R16P), intent(in) :: n
logical, intent(in), optional :: no_sign
logical, intent(in), optional :: compact

Return Value character


Calls

proc~~str_r16p~7~~CallsGraph proc~str_r16p~7 str_R16P proc~compact_real_string~7 compact_real_string proc~str_r16p~7->proc~compact_real_string~7

Called by

proc~~str_r16p~7~~CalledByGraph proc~str_r16p~7 str_R16P proc~str_a_r16p~7 str_a_R16P proc~str_a_r16p~7->proc~str_r16p~7

Contents

Source Code


Source Code

   elemental function str_R16P(n, no_sign, compact) result(str)
   !< Convert real to string.
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=-1._R16P)
   !<```
   !=> -0.100000000000000000000000000000000E+0001 <<<
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=-1._R16P, no_sign=.true.)
   !<```
   !=> 0.100000000000000000000000000000000E+0001 <<<
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=-1._R16P, compact=.true.)
   !<```
   !=> -0.1E+1 <<<
   real(R16P), intent(in)           :: n       !< Real to be converted.
   logical,    intent(in), optional :: no_sign !< Flag for leaving out the sign.
   logical,    intent(in), optional :: compact !< Flag for *compacting* string encoding.
   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.
   if (present(compact)) then
     if (compact) call compact_real_string(string=str)
   endif
   endfunction str_R16P