str_R8P Function

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

Arguments

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

Return Value character


Calls

proc~~str_r8p~4~~CallsGraph proc~str_r8p~4 str_R8P proc~compact_real_string~4 compact_real_string proc~str_r8p~4->proc~compact_real_string~4

Called by

proc~~str_r8p~4~~CalledByGraph proc~str_r8p~4 str_R8P proc~str_a_r8p~4 str_a_R8P proc~str_a_r8p~4->proc~str_r8p~4 interface~str~4 str interface~str~4->proc~str_r8p~4 interface~str~4->proc~str_a_r8p~4 proc~bctoi_i8p~4 bctoi_I8P proc~bctoi_i8p~4->interface~str~4 proc~bctoi_i4p~4 bctoi_I4P proc~bctoi_i4p~4->interface~str~4 proc~bctoi_i2p~4 bctoi_I2P proc~bctoi_i2p~4->interface~str~4 proc~bctoi_i1p~4 bctoi_I1P proc~bctoi_i1p~4->interface~str~4 interface~bcton~4 bcton interface~bcton~4->proc~bctoi_i8p~4 interface~bcton~4->proc~bctoi_i4p~4 interface~bcton~4->proc~bctoi_i2p~4 interface~bcton~4->proc~bctoi_i1p~4

Contents

Source Code


Source Code

   elemental function str_R8P(n, no_sign, compact) result(str)
   !< Convert real to string.
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=-1._R8P)
   !<```
   !=> -0.100000000000000E+001 <<<
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=-1._R8P, no_sign=.true.)
   !<```
   !=> 0.100000000000000E+001 <<<
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=-1._R8P, compact=.true.)
   !<```
   !=> -0.1E+1 <<<
   real(R8P), 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(DR8P)                 :: str     !< Returned string containing input number.

   write(str, FR8P) n                ! Casting of n to string.
   if (n>0._R8P) 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_R8P