Manual Reference Pages  - string_to_value (3m_strings)

NAME

string_to_value(3f) - [M_strings:TYPE] subroutine returns numeric value from string (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Returns
Examples
Author
License

SYNOPSIS

subroutine string_to_value(chars,valu,ierr)

    character(len=*),intent(in)              :: chars   ! input string
    integer|real|doubleprecision,intent(out) :: valu
    integer,intent(out)                      :: ierr

DESCRIPTION

Returns a numeric value from a numeric character string.

Works with any g-format input, including integer, real, and exponential. If the input string begins with "B", "Z", or "O" and otherwise represents a positive whole number it is assumed to be a binary, hexadecimal, or octal value. If the string contains commas they are removed. If the string is of the form NN:MMM... or NN#MMM then NN is assumed to be the base of the whole number.

If an error occurs in the READ, IOSTAT is returned in IERR and value is set to zero. if no error occurs, IERR=0.

OPTIONS

CHARS input string to read numeric value from

RETURNS

VALU numeric value returned. May be INTEGER, REAL, or DOUBLEPRECISION.
IERR error flag (0 == no error)

EXAMPLES

Sample Program:

   program demo_string_to_value
    use M_strings, only: string_to_value
    implicit none
    real :: value
    integer :: ierr
    character(len=80) :: string
       string=’ -40.5e-2 ’
       call string_to_value(string,value,ierr)
       write(*,*) ’value of string [’//trim(string)//’] is ’,value
   end program demo_string_to_value

AUTHOR

John S. Urban

LICENSE

Public Domain


Nemo Release 3.1 string_to_value (3m_strings) July 20, 2024
Generated by manServer 1.08 from 9f96484a-d82e-45f0-85c1-de88e8d3723e using man macros.