real(3f) - [M_strings:TYPE] overloads REAL(3f) so it can handle character arguments
(LICENSE:PD)
impure elemental function real(string)
character(len=*) :: string
integer :: real
real(3f) returns a REAL value when given a numeric representation of a
numeric value. This overloads the REAL(3f) intrinsic so that CHARACTER
arguments assumed to represent a numeric value may be input.
STRING input string to be converted to a real value
REAL real value represented by input string
Sample program:
program demo_real
use M_strings, only: real
implicit none
write(*,*)real('100'),real('20.4')
write(*,*)'real still works',real(20)
write(*,*)'elemental',&
& real([character(len=23) :: '10','20.3','20.5','20.6'])
end program demo_real
Results:
> 100.000000 20.3999996
> real still works 20.0000000
> elemental 10.0000000 20.2999992 20.5000000 20.6000004
John S. Urban
Public Domain
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | chars |