str_R4P Function

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

Arguments

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

Return Value character


Calls

proc~~str_r4p~5~~CallsGraph proc~str_r4p~5 str_R4P proc~compact_real_string~5 compact_real_string proc~str_r4p~5->proc~compact_real_string~5

Called by

proc~~str_r4p~5~~CalledByGraph proc~str_r4p~5 str_R4P proc~str_a_r4p~5 str_a_R4P proc~str_a_r4p~5->proc~str_r4p~5 interface~str~5 str interface~str~5->proc~str_r4p~5 interface~str~5->proc~str_a_r4p~5 proc~bctoi_i8p~5 bctoi_I8P proc~bctoi_i8p~5->interface~str~5 proc~bctoi_i4p~5 bctoi_I4P proc~bctoi_i4p~5->interface~str~5 proc~bctoi_i2p~5 bctoi_I2P proc~bctoi_i2p~5->interface~str~5 proc~bctoi_i1p~5 bctoi_I1P proc~bctoi_i1p~5->interface~str~5 interface~bcton~5 bcton interface~bcton~5->proc~bctoi_i8p~5 interface~bcton~5->proc~bctoi_i4p~5 interface~bcton~5->proc~bctoi_i2p~5 interface~bcton~5->proc~bctoi_i1p~5

Contents

Source Code


Source Code

   elemental function str_R4P(n, no_sign, compact) result(str)
   !< Convert real to string.
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=-1._R4P)
   !<```
   !=> -0.100000E+01 <<<
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=-1._R4P, no_sign=.true.)
   !<```
   !=> 0.100000E+01 <<<
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=-1._R4P, compact=.true.)
   !<```
   !=> -0.1E+1 <<<
   real(R4P), 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(DR4P)                 :: str     !< Returned string containing input number.

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