to_real_R8P Function

private elemental function to_real_R8P(self, kind) result(to_number)

Arguments

TypeIntentOptionalAttributesName
class(string), intent(in) :: self
real(kind=R8P), intent(in) :: kind

Return Value real(kind=R8P)


Contents

Source Code


Source Code

   elemental function to_real_R8P(self, kind) result(to_number)
   !< Cast string to real (R8P).
   !<
   !<```fortran
   !< use penf
   !< type(string) :: astring
   !< real(R8P)    :: real_
   !< logical      :: test_passed(1)
   !< astring = '3.4e9'
   !< real_ = astring%to_number(kind=1._R8P)
   !< test_passed(1) = real_==3.4e9_R8P
   !< print '(L1)', all(test_passed)
   !<```
   !=> T <<<
   class(string), intent(in) :: self      !< The string.
   real(R8P),     intent(in) :: kind      !< Mold parameter for kind detection.
   real(R8P)                 :: to_number !< The number into the string.

   if (allocated(self%raw)) then
     if (self%is_real()) read(self%raw, *) to_number
   endif
   endfunction to_real_R8P