https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473

--- Comment #19 from harper at msor dot vuw.ac.nz ---
Thank you. To make the outputs from my test program testdecimal.f90 easier 
to compare when using different compilers, and to clarify where a reading 
error happened, I have revised the program to make its results clearer.
Below is the new version of the program. I see no point in sending its
output with my gfortran, which does not have Jerry's latest corrections,
but I do provide its output with ifort, which it is not your job to debug!

john@johns-laptop:~/Jfh$ cat testdecimal.f90
! Test list-directed reading with decimal='point' and 'comma' by
! printing one line for each of 32 cases, reading input(1:16) with each
! of 'point' or 'comma', using s(ios) to give ERR, OK or end according
! to the iostat=ios value from reading. Before reading, x=[666,999].
   implicit none
   real x(2)
   integer ios,i,j
   character(*),parameter:: punc=",; .",fmt='(1X,A,I2,1X,5A,2F7.1,1X,A)'
   integer,parameter:: lpunc =len(punc)
   character:: dec(2)*5=['point','comma'], input(lpunc**2)*4 = &
        [(("2"//punc(i:i)//"5"//punc(j:j),i=1,lpunc),j=1,lpunc)]

   do i = 1,size(input)
      do j = 1,2
         x = [666, 999]
         read(input(i),*,decimal=dec(j),iostat=ios) x
         print fmt,'i=',i,' input="',input(i),'" with ',dec(j),&
              ' x =',x,s(ios)
      end do
   end do

contains
   character(3) function s(ios) ! ERR, OK ,end if ios>0, ==0, <0
     integer,intent(in)::  ios
     s = merge('ERR',merge(' OK','end',ios==0),ios>0)
   end function s
end program

john@johns-laptop:~/Jfh$ ifort testdecimal.f90; ./a.out
Compiling "ifort testdecimal.f90"
  i= 1  input="2,5," with point x =    2.0    5.0  OK
  i= 1  input="2,5," with comma x =  666.0  999.0 ERR
  i= 2  input="2;5," with point x =  666.0  999.0 ERR
  i= 2  input="2;5," with comma x =    2.0    5.0  OK
  i= 3  input="2 5," with point x =    2.0    5.0  OK
  i= 3  input="2 5," with comma x =    2.0    5.0  OK
  i= 4  input="2.5," with point x =    2.5  999.0 end
  i= 4  input="2.5," with comma x =  666.0  999.0 ERR
  i= 5  input="2,5;" with point x =    2.0  999.0 ERR
  i= 5  input="2,5;" with comma x =    2.5  999.0 end
  i= 6  input="2;5;" with point x =  666.0  999.0 ERR
  i= 6  input="2;5;" with comma x =    2.0    5.0  OK
  i= 7  input="2 5;" with point x =    2.0  999.0 ERR
  i= 7  input="2 5;" with comma x =    2.0    5.0  OK
  i= 8  input="2.5;" with point x =  666.0  999.0 ERR
  i= 8  input="2.5;" with comma x =  666.0  999.0 ERR
  i= 9  input="2,5 " with point x =    2.0    5.0  OK
  i= 9  input="2,5 " with comma x =    2.5  999.0 end
  i=10  input="2;5 " with point x =  666.0  999.0 ERR
  i=10  input="2;5 " with comma x =    2.0    5.0  OK
  i=11  input="2 5 " with point x =    2.0    5.0  OK
  i=11  input="2 5 " with comma x =    2.0    5.0  OK
  i=12  input="2.5 " with point x =    2.5  999.0 end
  i=12  input="2.5 " with comma x =  666.0  999.0 ERR
  i=13  input="2,5." with point x =    2.0    5.0  OK
  i=13  input="2,5." with comma x =  666.0  999.0 ERR
  i=14  input="2;5." with point x =  666.0  999.0 ERR
  i=14  input="2;5." with comma x =    2.0  999.0 ERR
  i=15  input="2 5." with point x =    2.0    5.0  OK
  i=15  input="2 5." with comma x =    2.0  999.0 ERR
  i=16  input="2.5." with point x =  666.0  999.0 ERR
  i=16  input="2.5." with comma x =  666.0  999.0 ERR
john@johns-laptop:~/Jfh$


On Wed, 18 May 2022, jvdelisle at gcc dot gnu.org wrote:

> Date: Wed, 18 May 2022 02:52:26 +0000
> From: jvdelisle at gcc dot gnu.org <gcc-bugzi...@gcc.gnu.org>
> To: John Harper <john.har...@vuw.ac.nz>
> Subject: [Bug fortran/105473] semicolon allowed when list-directed read
>     integer with decimal='point'
> Resent-Date: Wed, 18 May 2022 14:52:38 +1200 (NZST)
> Resent-From: <john.har...@vuw.ac.nz>
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473
>
> --- Comment #18 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
> (In reply to harper from comment #17)
>> On comparing that with ifort's result I think that the only remaining bug
>> is that if decimal='comma' then '.' is neither a decimal symbol nor a
>> separator (see f2018 13.6).
>
> Making this easier for others to see.
>
> With gfortran I see with the 8th sub-case:
>
> i=           8 input(i) = "2.5;"
> with decimal=point x(:) =2.5 666.0  ios=5010
> with decimal=comma x(:) =2.5 666.0  ios=-1
>
> i=          12 input(i) = "2.5 "
> with decimal=point x(:) =2.5 666.0  ios=-1
> with decimal=comma x(:) =2.5 666.0  ios=-1
>
> In these cases the decimal=comma should have never seen 2.5
>
> With ifort:
>
> i=           8 input(i) = "2.5;"
> with decimal=point x(:) =   2.50000000       5.00000000      ios=        5010
> with decimal=comma x(:) =   2.50000000       666.000000      ios=          -1
>
> I don't think ifort has the decimal=point part right, as if it backed up and
> read the digit 5 a second time.
>
> Regardless, getting closer here.  I will work on the gfortran comma issue.
>
> -- 
> You are receiving this mail because:
> You reported the bug.
>


-- John Harper, School of Mathematics and Statistics
Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand.
e-mail john.har...@vuw.ac.nz phone +64(0) 4 463 5276

Reply via email to