On FORTRAN

Ryo Furue furue at HAWAII.EDU
Mon Jun 23 04:51:58 EDT 2008


Hi Niyi and Jim,

| Your attached FORTRAN program is reading from TPC1.txt line-by-line in
| the loop "DO 100 J=1,1000".  The input file, however, only has 131 lines in
| it.  So, I think the program is exiting "DO 100" after 131 reads, then
| jumping
| to line 1000 (specified in the READ statement).  So, "m" never gets
| incremented.
| I think if you change
| DO 100 J=1,1000
| to
| DO 100 J=1,131 (or some number <= the total lines in TPC1.txt)
| you'll get an output file larger than 0.

Yes, but the intention of the program seems to be that it's supposed
to work for any number of lines (up to 1000) with "m" being a counter
of the number of input lines.  So, I would suggest ALONG THE LINES OF

      m=0
      DO
        READ(20,*,end=1000)(X(I,m,K),I=1,42)
        ! . . . . . .
        m=m+1
      end do
 1000 continue
      WRITE(6,*) m

Please note that this very code may not be what you want.
It just illustrates a concept.  The idea is that if you don't
know the size of your input file, don't specify the length of
the loop (like "do j = 1, 1000") but use an infinite do
loop (as above) with an explicit counter ("m" in the above).

Regards,
Ryo



More information about the gradsusr mailing list