isdigit(3f) - [M_strings:COMPARE] returns .true. if character is a digit (0,1,...,9) and .false. otherwise (LICENSE:PD)
Synopsis
Description
Examples
Author
License
elemental function isdigit(onechar)
character,intent(in) :: onechar logical :: isdigit
isdigit(3f) returns .true. if character is a digit (0,1,...,9) and .false. otherwise
Sample Program:
program demo_isdigit use M_strings, only : isdigit, isspace, switch implicit none character(len=10),allocatable :: string(:) integer :: i string=[& & ’1 2 3 4 5 ’ ,& & ’letters ’ ,& & ’1234567890’ ,& & ’both 8787 ’ ] ! if string is nothing but digits and whitespace return .true. do i=1,size(string) write(*,’(a)’,advance=’no’)’For string[’//string(i)//’]’ write(*,*) & & all(isdigit(switch(string(i))).or.& & isspace(switch(string(i)))) enddo end program demo_isdigitExpected output:
For string[1 2 3 4 5 ] T For string[letters ] F For string[1234567890] T For string[both 8787 ] F
John S. Urban
Public Domain