hi,
yesterday i got a suggestion about writing column data (post named" help in reading and writing column data" Following the tip i got i looked for the previous article and i thin ki found one which was good for me. but i am still having small problem:
the code i used is exactly the same as shown in the thread:
program main
! MAXCOL is 1 more than the max expected
parameter (MAXCOL = 10, INFILE = 5)
integer info(MAXCOL)
character*80 line
integer row, col
open (INFILE, file='C:\WAMView\bnz\GlobalInputs\samsur2.txt')
row = 0
10 continue
row = row + 1
!
! Read the line containing the data
read (INFILE, '(A)', end=30) line
!
! Read the data from the line
read (line, *, err=20, end=20) (info(col), col = 1, MAXCOL, 1)
20 continue
!
! we stop at one more that what was there so subtract 1
col = col - 1
!
! print what we got
write (*, *) (info(i), i = 1, col, 1)
goto 10
30 continue
close (INFILE)
stop
end
THE INPUT FILE LOOKS LIKE
10 10 10 10 10 10 10 10 10 10
20 20 20 20 20
25 25 25 25 25 25 25
30 30 40
The output file looks like this
10 10 10 10 10 10
10 10 10 10
20 20 20 20 20 10
10 10 10 10
25 25 25 25 25 25
25 10 10 10
30 30 40 25 25 25
25 10 10 10
The problem is that after line 1 in input file (which was the longest line) for rest of the line empty spaces were filled by 10
I am wondering what to do. I tried almost whole day (i know its easy and should not take this long but i have just started writing codes in FORTRAN) but couldn't find the problem.
Please help me
Vibhava
yesterday i got a suggestion about writing column data (post named" help in reading and writing column data" Following the tip i got i looked for the previous article and i thin ki found one which was good for me. but i am still having small problem:
the code i used is exactly the same as shown in the thread:
program main
! MAXCOL is 1 more than the max expected
parameter (MAXCOL = 10, INFILE = 5)
integer info(MAXCOL)
character*80 line
integer row, col
open (INFILE, file='C:\WAMView\bnz\GlobalInputs\samsur2.txt')
row = 0
10 continue
row = row + 1
!
! Read the line containing the data
read (INFILE, '(A)', end=30) line
!
! Read the data from the line
read (line, *, err=20, end=20) (info(col), col = 1, MAXCOL, 1)
20 continue
!
! we stop at one more that what was there so subtract 1
col = col - 1
!
! print what we got
write (*, *) (info(i), i = 1, col, 1)
goto 10
30 continue
close (INFILE)
stop
end
THE INPUT FILE LOOKS LIKE
10 10 10 10 10 10 10 10 10 10
20 20 20 20 20
25 25 25 25 25 25 25
30 30 40
The output file looks like this
10 10 10 10 10 10
10 10 10 10
20 20 20 20 20 10
10 10 10 10
25 25 25 25 25 25
25 10 10 10
30 30 40 25 25 25
25 10 10 10
The problem is that after line 1 in input file (which was the longest line) for rest of the line empty spaces were filled by 10
I am wondering what to do. I tried almost whole day (i know its easy and should not take this long but i have just started writing codes in FORTRAN) but couldn't find the problem.
Please help me
Vibhava