atol(3f) - [M_strings:TYPE] function returns a 64-bit integer value from a string (LICENSE:PD)
Synopsis
Description
Options
Returns
Examples
Author
License
pure elemental function atol (string) result(val)
character(len=*),intent(in) :: string integer(kind=int64),intent(out) :: val
function atol(3f) converts a string representing an integer value to a numeric 64-bit integer value.
str holds string assumed to represent a numeric integer value
val returned INTEGER.
Sample Program:
program demo_atolResults: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
> STRING: +10 :VALUE: 10 > STRING: -3 :VALUE: -3 > STRING: :VALUE: 0 > STRING: 1 2 1 2 1 . 0 :VALUE: 1 > STRING: WHAT? :VALUE: 0
John S. Urban
Public Domain
Nemo Release 3.1 | atol (3m_strings) | January 10, 2025 |