In a previous discussion, Paul advised that in general recursive IO is not permitted in FTN95, with the caveat that it is permitted in certain cases.
Now consider the following program, which executes as intended by the programmer with other compilers.
Perhaps a bug, or perhaps not? It's the discrepancy between FTN95 and gFortran (for example) that I need to explain correctly to another party.
program test
implicit none
logical, external :: is_number
print *, is_number('123.45') ! .true.
print *, is_number(' -12e-3 ') ! .true.
print *, is_number(' -12d-3 ') ! .true.
print *, is_number('abc123') ! .false.
print *, is_number('1.2.3') ! .false.
end program test
logical function is_number(str)
implicit none
character(*), intent(in) :: str
real :: tmp
integer :: ios
character(len=256) :: buffer
! Copy string into fixed-length buffer and trim it
! Try to read as a real number
! If successful (ios == 0), then it's a number so return true, otherwise false.
buffer = adjustl(str)
buffer = trim(buffer)
read(buffer, *, iostat=ios) tmp
is_number = (ios == 0)
end function is_number