mparisi@ripple.jpl.nasa.gov (Mark Parisi) (05/18/91)
O.K., I've got to get my two cents in here: In article <23946@lanl.gov>, jlg@cochiti.lanl.gov (Jim Giles) writes: |>In article <1991May16.195328.727@casbah.acns.nwu.edu>, |>ravi@earth.ce.nwu.edu (Ravi Sinha) writes: |>|> [...] |>|> Real DO control variables allow you to have loops like: |>|> DO r = 1,100000,0.1 |>|> ... |>|> ENDDO |>|> Why not replace this with: R = 1 DO WHILE (R .LE. 100000) ... R = R + 0.1 ENDDO (Yes, I know that: R will diverge from its nominal value due to accumulated roundoff from each iteration, and it is legal to change R elsewhere in the DO WHILE loop.) |>The problem is not optimization but accurate trip count calculation. I say keep the floating point DO construct. Admittedly it is a dangerous construct, but Fortran has never been known for protecting programmers from their own mistakes. There are programming cases where you may not care about the exact trip count calculation; e.g., plotting data. I don't really care if I plot 1000 or 1001 points; I just want a simple way to specify start, stop, and step values. (I don't even care if my last point differs from the stop value by one step either way. :-) There are certainly cases where the number of iterations is critical, or where the accumulated roundoff error from millions of iterations is significant, and in these cases using an integer for loop control is required. However, nothing is going to prevent you from using an integer DO loop whether or not a floating point DO loop is available. -- Mark Parisi (mparisi@ripple.jpl.nasa.gov)