Stenson Matthew said:
> I want to read data from a flat text file in the format of 70 digits wide and
> as many rows as needed to make up the current length of the number.For
> example if the number is currently 100 digits long then the text file will
If your number is in IDIG(1:N), you can write it with
WRITE(output_unit,100) IDIG(:N)
100 FORMAT(70(:,I1))
To read it back in again, it depends on whether you know N in advance or
have to work it out. It's simpler if you know it in advance, i.e.
READ(input_unit,100) IDIG(:N)
will work!
(From your message it sounds like you know it in advance.)
Otherwise, you'll have to have some way of telling whether a number has
ended. Reading it one line at a time into a character string is the way
to go, something like:
CHARACTER(80) line
DO i=1,maxn,70
READ(input_unit,'(A)') line
IF (line=='END OF NUMBER') EXIT
READ(line,100) idig(i:i+len_trim(line)-1)
END DO
should work.
Cheers,
--
...........................Malcolm Cohen, NAG Ltd., Oxford, U.K.
([log in to unmask])
|