Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!agate!bionet!raven.alaska.edu!milton!seymour From: seymour@milton.u.washington.edu (Richard Seymour) Newsgroups: comp.lang.fortran Subject: Re: Questions about IF Message-ID: <1991Jun24.213601.11329@milton.u.washington.edu> Date: 24 Jun 91 21:36:01 GMT Article-I.D.: milton.1991Jun24.213601.11329 References: Organization: University of Washington, Seattle Lines: 21 In article br0w+@andrew.cmu.edu (Bruno W. Repetto) writes: >Suppose there is this IF command: > IF(.AND..AND. ... .AND.)statement >My questions are about the STANDARD for executing such a command: >1) Are the expressions evaluated from "left to right"? >2)... expression i+1 evaluates to .FALSE., are the subsequent expressions > evaluated (if any remain), or is the execution of the IF command concluded > right then? DEC VAX/VMS Fortran manual babbles on about this at lenght. if you want ALL of the subexpressions evaluated, and you want the order (left-right) which you entered, use the compiler switch /NOOPTimize otherwise, all bets are off... the compiler reserves the right to cease chewing thru them if one proves .false., to re-order them for speed, to migrate some of them outside for pre-evaluation outside of a DO loop, and to completely ignore the line if the compiler knows the outcome (the if(foo.and.boo.and..FALSE.) case.) and at times i've seen the /noopt case still shuffle the order (common subexpression evaluation) (the if((a+1.gt.24).and.(a+1.lt.30)) case.. the "a+1" may happen only once.) --dick