Manual Reference Pages  - atol (3m_strings)

NAME

atol(3f) - [M_strings:TYPE] function returns a 64-bit integer value from a string (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Returns
Examples
Author
License

SYNOPSIS

pure elemental function atol (string) result(val)

    character(len=*),intent(in)      :: string
    integer(kind=int64),intent(out)  :: val

DESCRIPTION

function atol(3f) converts a string representing an integer value to a numeric 64-bit integer value.

OPTIONS

str holds string assumed to represent a numeric integer value

RETURNS

val returned INTEGER.

EXAMPLES

Sample Program:

     program demo_atol

use iso_fortran_env, only: wp => int64 use M_strings, only: atol implicit none character(len=14),allocatable :: strings(:) integer(kind=wp) :: iv integer :: i

! different strings representing whole numbers strings=[& &’+10 ’,& &’ -3 ’,& &’ ’,& ! Note: will return zero without an error message &’1 2 1 2 1 . 0 ’,& ! Note: will just read first value &’WHAT? ’] ! Note: will return zero without an error message

do i=1,size(strings) iv=atol(strings(i)) write(*,’(*(g0,1x))’)’STRING:’,strings(i),’:VALUE:’,iv enddo

end program demo_atol

Results:

 > STRING: +10            :VALUE: 10
 > STRING:     -3         :VALUE: -3
 > STRING:                :VALUE: 0
 > STRING: 1 2 1 2 1 . 0  :VALUE: 1
 > STRING: WHAT?          :VALUE: 0

AUTHOR

John S. Urban

LICENSE

Public Domain


Nemo Release 3.1 atol (3m_strings) January 10, 2025
Generated by manServer 1.08 from d6fd5667-c5d3-4df5-9794-96a065e252e6 using man macros.