Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!rpi!ccnysci!phri!cmcl2!lanl!lambda!jlg From: jlg@lambda.UUCP (Jim Giles) Newsgroups: comp.lang.fortran Subject: Re: EQUIVALENCE, COMPUTED GO TO in FORTRAN 88? Message-ID: <14168@lambda.UUCP> Date: 12 Dec 89 00:54:36 GMT References: <1989Dec9.153357.25886@ux1.cso.uiuc.edu> Lines: 40 From article <1989Dec9.153357.25886@ux1.cso.uiuc.edu>, by mcdonald@aries.scs.uiuc.edu (Doug McDonald): > In article <581@unmvax.unm.edu> brainerd@unmvax.unm.edu (Walt Brainerd) writes: > >>7. DO loops with real and dp DO variables can be rewritten using an >> integer DO variables and an assignment to the replaced DO variable. > This is not true. You could not be guaranteed of getting the exact > same effect. The only way to do this is with if statements on > the previous loop variable itself and goto's, along with explicit > adding of the increment. But admittedly it is > very easy. What you have just described is _NOT_ the semantics of the existing DO loop facility. There is no test on the loop variable in each trip through the loop nor is there any adding of the increment. The trip count for the loop is computed before the loop begins and the loop mechanism usually decrements this (integer) trip count until it reaches zero. (See ANSI X3.9-1978, Section 11.10.3 on page 11-7.) Now, if you use the iteration variable within the loop, it _may_ be computed by explicit incrementation. On the other hand, it may be implemented as a linear function of the remaining trip count. The choice is at the discretion of the compiler writer - not you. By the way, the trip count is calculated as: TC=MAX(INT(M2-M1+M3)/M3),0) where M1, M2, and M3 are the loop parameters. That is: DO 10 var = M1, M2, M3 So, obviously, you could avoid using REAL or DOUBLE loop parameters by computing the above trip count yourself and using it in the DO statement: DO 10 itemp = 1, TC var=M1+(itemp-1)*M3 Now you really _DO_ have an exact replacement of the original DO. That is, unless you implementor chose the iterative incrementation method for handling the iteration variable - the world ain't perfect.