Topic: Read statement issues

000600400
700003600
000091080
000000000
050180003
000306045
040200060
903000000
020000100
xxxxxxxxx
xxxxxxxxx

Above is a win10 notepad  text file read by
relevant code which follows:
! Sudoku Grid
integer, dimension (9, 9) :: grid
implicit none
    integer :: i
    integer :: j
OPEN (UNIT=5,FILE='D:\\Grid92.txt')
do i=1,9
       Read(5, '(9I1)') (grid(i,j), j=1,9)
end do

If you remove the two x lines
does the read statement  fail ?
If so, why ?
Bob

Re: Read statement issues

Bob,

I'm not having that issue with your code.  My grid file contains:

000600400
700003600
000091080
000000000
050180003
000306045
040200060
903000000
020000100

and my program is:

program sud2
implicit none

integer, dimension (9, 9) :: grid

    integer :: i
    integer :: j
    OPEN (UNIT=5,FILE='Grid92.txt')
    do i=1,9
           Read(5, '(9I1)') (grid(i,j), j=1,9)
           Print *, (grid(i,j), j=1,9)
    end do
    close(5)
        
end program sud2

When I run this code, I get:

           0           0           0           6           0           0           4           0           0
           7           0           0           0           0           3           6           0           0
           0           0           0           0           9           1           0           8           0
           0           0           0           0           0           0           0           0           0
           0           5           0           1           8           0           0           0           3
           0           0           0           3           0           6           0           4           5
           0           4           0           2           0           0           0           6           0
           9           0           3           0           0           0           0           0           0
           0           2           0           0           0           0           1           0           0

as I would expect to.  I would point out that using UNIT=5 can be dangerous, and I don't recommend it normally.  What version of Simply Fortran are you working with?

Jeff Armstrong
Approximatrix, LLC