[UP]


Manual Reference Pages  - string_to_value (3)

NAME

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

CONTENTS

Synopsis
Description
Options
Returns
Example
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)

EXAMPLE

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


string_to_value (3) March 11, 2021
Generated by manServer 1.08 from 84956a66-4a13-4db4-a7aa-0bb702477f76 using man macros.