From: glen herrmannsfeldt on 12 Aug 2010 04:17 Giorgio Pastore <pastgio(a)units.it> wrote: (snip, I wrote) >> Could you be more specific on that one? > From S.J. Chapman "Fortran 95/2003 For Scientists and Engineers (3rd > edition), p.137: (snip) > ... > 4 step 2 is repeated over and over as long as index*incr <= iend*incr. > When this cndition is not longer true, execution skips to the first > statement following the end of the DO loop. (snip) > Let us see how the same information is provided by Metcalf, Reid, Cohen > (Fortran 95/2003 explained, p.60): > "The number of iterations of a do construct is given by the formula > max((expr2-expr1+expr3)/expr3,0)..." (very terse!) > You can see that neither the standard nor MRC mention the mechanism of > checking the condition index*incr <= iend*incr. Since the standard doesn't mention it, I would say that isn't a required mechanism. In fact, it isn't a very reliable mechanism, but does conveniently indicate the effect of a negative incr on the loop condition. Consider a 32 bit machine and the DO statement: DO I=1000000,4000000,1000000 The product likely overflows, such that the test could give the wrong result. As far as I know, in most cases the compiler does none of that. If the compiler determines that the DO parameters don't change in the loop, then it doesn't need to make copies. In any case, one still isn't allowed to change the DO variable inside the loop. If the increment is constant, then the sign of the comparison test is known at compile time. > Although in the past I tought Chapman's description quite useful for > pedagogical reasons, I have realized that in practice, novices may skip > the key information that "their values are calculated before the start > of the loop, and the resulting values are used to control the loop" and > may believe that the repetition count may be changed dynamically just > because Chapman's description put the emphasis on checking the condition > every time. The result may be some wasting of time to understand why a > do loop like the following repeats always only three times Well, one could misread many parts of the language descriptions and make mistakes based on that misreading. In earlier versions of Fortran you weren't allowed to change any of the DO parameters. Now, for contrast consider the C for loop: for(e1;e2;e3) s; The loops is defined in terms of evaluating three expressions and the results of those expressions. No hidden copies of the values are kept. It is legal (and not unusual) to change any of the variables using in the three expressions inside the loop, or the loop variable (if any). The same restrictions (or lack thereof) on side effect in expression evaluation apply. It is convention that e1 initialize a loop variable (if any), that e2 test the value, and that e3 generate a new value for a loop variable. The standard doesn't restrict e1, e2, or e3 to have those functions. -- glen
From: Nick Maclaren on 12 Aug 2010 05:19 In article <4c311b55-5519-45bf-8510-2c785ad73730(a)x20g2000pro.googlegroups.com>, rudra <bnrj.rudra(a)gmail.com> wrote: >On Aug 12, 11:34=A0am, Vincenzo Mercuri <c...(a)lang.c> wrote: >If you are still looking for ans, I may suggest you one thing. I have >all of them with me, and as i have realized, you better take a bottom- >top approach in your list. >Begin with Chapman's as it is most ilaborate, with lots of example and >tips(though you may not be willing to abide by them to the point) > >MRC is THE CLASSIC in my opinion, but its concise and can be best >served if you already have some experience. > >Handbook is, again in my opinion, is good, but may give a tough time >to the beginner. > >you may also look for "Computing for scientists: principles of >programming with Fortran 90 and C++" by by R. J. Barlow and A. R. >Barnett. Its not detailed....but good one. very precise description >about pointers. You might also like to look at: http://www-uxsup.csx.cam.ac.uk/courses/Fortran/ The practicals aren't brilliant, and need attention, but the course is quite popular with the people who attend it. Regards, Nick Maclaren.
From: Vincenzo Mercuri on 12 Aug 2010 05:59 Nick Maclaren wrote: > You might also like to look at: > > http://www-uxsup.csx.cam.ac.uk/courses/Fortran/ > > The practicals aren't brilliant, and need attention, but the course > is quite popular with the people who attend it. I got a first look at these slides and I think they are really well made. For now, and before having my hands on a book, that's a great starting point. (I noticed you are the author, well done!) Thank you very much. -- Vincenzo Mercuri
From: Nick Maclaren on 12 Aug 2010 06:17 In article <tIydnRbBkOJ7WP7RnZ2dnUVZ8tGdnZ2d(a)giganews.com>, Vincenzo Mercuri <comp(a)lang.c> wrote: >Nick Maclaren wrote: > >> You might also like to look at: >> >> http://www-uxsup.csx.cam.ac.uk/courses/Fortran/ >> >> The practicals aren't brilliant, and need attention, but the course >> is quite popular with the people who attend it. > >I got a first look at these slides and I think they >are really well made. For now, and before having my hands >on a book, that's a great starting point. >(I noticed you are the author, well done!) >Thank you very much. Thank you. Most of the credit is due to Steve Morgan, but I updated and extended it - and hope to do more. Regards, Nick Maclaren.
From: Tobias Burnus on 13 Aug 2010 20:17
Vincenzo Mercuri wrote: > What about the Standard 2003? is it freely available? Yes and no. The real Fortran standards are not freely available, but the final candidate drafts are which are effectively identical. Cf. the links at http://gcc.gnu.org/wiki/GFortranStandards or look directly at http://www.nag.co.uk/sc22wg5/links.html Tobias |