The Grey Labyrinth is a collection of puzzles, riddles, mind games, paradoxes and other intellectually challenging diversions. Related topics: puzzle games, logic puzzles, lateral thinking puzzles, philosophy, mind benders, brain teasers, word problems, conundrums, 3d puzzles, spatial reasoning, intelligence tests, mathematical diversions, paradoxes, physics problems, reasoning, math, science.

Author Message
Tony Gardner
Daedalian Member

 Posted: Wed Nov 15, 2006 12:17 pm    Post subject: 1 Hello all, A short introduction on the matter at hand. I'm currently in the process of converting some Fortran programs to Matlab m-files. I found a Matlab package called f2matlab for this on sourceforge.net. Though very useful, the resulting m-files still need some debugging. That's where I'm at right now. I know absolutely nothing about Fortran, which doesn't really help my cause. Therefore, I've got a small question on Fortran syntax, just to make sure my conversion is correct. A piece of the original Fortran code reads: do 550 i=ky2,nk1y ii=i-ky1 do 550 j=1,nk1x | | [more statements] | | 550 continue In the manual I found that this construction is called a 'shared terminal statement'. Two different DO-loops use the same name ('550') and terminal statement ('continue'). Now, my question is the following. When the program is being executed, and it reaches the '550 continue' line, do both DO-loops progress, or only the innermost? In other words, do we get i=i+1 and j=j+1, or only the latter? And in case both progress, is the ii=i-ky1 statement also re-evaluated? Many thanks for any help you can give me! -TG
Jack_Ian
Big Endian

 Posted: Wed Nov 15, 2006 3:06 pm    Post subject: 2 The innermost loop will complete first, before going to the next iteration of the outer loop. It must be pretty old FORTRAN you're dealing with. Constructs such as this were used to aid compilers in optimising their code, when optimising methodologies were just in their infancy. Optimisers are much smarter now and have no need for such things (though C is still crippled by such legacy syntax).
Lepton*
Guest

Posted: Wed Nov 15, 2006 3:23 pm    Post subject: 3

I think that it will be the same as this:
 Quote: do 550 i=ky2,nk1y ii=i-ky1 do 661 j=1,nk1x | | [more statements] | | 661 continue 550 continue
Tony Gardner
Daedalian Member

 Posted: Thu Nov 16, 2006 1:55 pm    Post subject: 4 Thanks guys! I already figured the innermost loop would complete first before incrementing the outer one, but I needed to be sure. It is old code indeed (Fortran 77, written in '79), from the FITPACK package, which is a software package for computing and evaluating spline approximations on curves and surfaces.
Jack_Ian
Big Endian

 Posted: Fri Nov 17, 2006 5:14 pm    Post subject: 5 My first FORTRAN project in college was calculating cubic splines using FORTRAN IV (back in '85). We had a FORTRAN77 compiler too, but it was too newfangled for my crusty old Numerical Analysis professor, so he refused to grade any projects that used it. I don't think he liked me very much. Most of the other students got simple projects like Gaussian elimination. Just a few of us (the cocky ones), were singled out for the juicy projects. I didn't mind though, in fact I found it quite interesting. The only downer was having to deal with nasty syntax and primitive I/O of FORTRAN IV. I had quite a "heated discussion" with him, when I handed in my project, with graphs drawn using a BASIC program, from the plot-points calculated by my FORTRAN IV program. He expected me to plot the graphs by printing monospaced characters on the ancient line-printer we had. Eventually, he grudgingly accepted that plotting graphs using a line-printer was a programming challenge, that the numerical analysis was performed correctly and that drawing the graphs was just my way of validating the results and as such were not subject to the FORTRAN IV "rule". He did know his numerical analysis though, so he wasn't all bad. Eventually he had to upgrade to FORTRAN77 when the old ICL2904 was dumped for a new VAX, which didn't come with a FORTRAN IV compiler. I don't think he ever recovered. Anyway, my FORTRAN is a little rusty, but feel free to ask again if you need help with anything.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year by All usersAnonymousJack_IanTony Gardner Oldest FirstNewest First
 All times are GMT Page 1 of 1

 Jump to: Select a forum Puzzles and Games----------------Grey Labyrinth PuzzlesVisitor Submitted PuzzlesVisitor GamesMafia Games Miscellaneous----------------Off-TopicVisitor Submitted NewsScience, Art, and CulturePoll Tournaments Administration----------------Grey Labyrinth NewsFeature Requests / Site Problems
You cannot post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum