Click here to Skip to main content
15,845,367 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Classic FORTRAN Pin
haughtonomous2-Jan-23 22:56
haughtonomous2-Jan-23 22:56 
GeneralRe: Classic FORTRAN Pin
lewist573-Jan-23 9:43
lewist573-Jan-23 9:43 
GeneralRe: Classic FORTRAN Pin
trønderen3-Jan-23 10:21
trønderen3-Jan-23 10:21 
GeneralRe: Classic FORTRAN Pin
lewist573-Jan-23 10:49
lewist573-Jan-23 10:49 
GeneralRe: Classic FORTRAN Pin
jsc423-Jan-23 11:53
professionaljsc423-Jan-23 11:53 
GeneralRe: Classic FORTRAN Pin
Peter_in_27803-Jan-23 12:07
professionalPeter_in_27803-Jan-23 12:07 
GeneralRe: Classic FORTRAN Pin
jsc424-Jan-23 0:25
professionaljsc424-Jan-23 0:25 
GeneralRe: Classic FORTRAN Pin
trønderen3-Jan-23 17:54
trønderen3-Jan-23 17:54 
lewist57 wrote:
1) I think only IV/66 always went though a do loop, and 77 and beyond does not
In my basement, I found the manual for one of the two F77 compilers we were using (I never owned a manual for the other), and to my surprise, you are right! The test is done at the top of the loop. I am really surprised that this didn't break thousands of old Fortran programs - changing the semantics of something as fundamental as a DO-loop is rather sensitive!

Anyway: This loop is executed once; it isn't terminated until the DO-variable is larger than the terminal value. "DO I = 0,0; ENDDO" is executed once, and I is incremented from 0 to 1.
2) I asked about the space between FOR and IF because there is not DO FOR ..... loop. I ran your code through Simply Fotran compiler set for legacy code and it thinks "FOR IF" (or "FORIF") is a variable, which does fit the syntax DO FORIF = variable, variable.
jcs42 reminded us of the Mariner crash, where a comma in a loop spec was mistyped as a decimal point, making the DO statement being compiled as an assignment. In the loop in the code I presented, a comma is used, so that DO statement would never be interpreted as an assignment.

I checked the old Fortran manual, which describes the "DO FOR ... ENDDO" with the "FOR" marked as optional. This might have been a syntax proposed for F77, but taken out a short time before the standard was nailed. Starting to use a standard before it has formally passed all formal approvals is quite common, and it took a long time for the F77 proposals to be sorted out and churning it through the mill; it did not happen in 1977! Especially if the standardization process has been plagued by fights between competing viewpoints, you may see lots of last-minute changes - and the F77 process was most definitely a war ground. So maybe both our compilers included the construct, as an extension of F77, because important customers had already started using it. With "FOR" being optional, it can simply be removed; it shouldn't affect the program behavior.

However, the manual identifies the semicolon, for putting several statements on a single line, as an extension. I came across a web page describing new features of Fortran 90, including this, so obviously both our F77 compilers were ahead of their time Smile | :)

Now that you have tried to compile the program: Will you remove the 'FOR's and tell us if the program produces a meaningful output? I suspect that the lines will be left justified (that's what we got with both compilers) - they really should be centered, symmetric around a vertical line. If you know just a little bit of math, and the output is correct, you should be able to recognize it, even when left justified!
GeneralRe: Classic FORTRAN Pin
lewist574-Jan-23 6:27
lewist574-Jan-23 6:27 
GeneralRe: Classic FORTRAN Pin
trønderen4-Jan-23 9:53
trønderen4-Jan-23 9:53 
GeneralRe: Classic FORTRAN Pin
lewist576-Jan-23 17:02
lewist576-Jan-23 17:02 
GeneralLong filename problems in 2022? Pin
honey the codewitch24-Oct-22 15:40
mvahoney the codewitch24-Oct-22 15:40 
GeneralRe: Long filename problems in 2022? Pin
MarkTJohnson25-Oct-22 8:21
professionalMarkTJohnson25-Oct-22 8:21 
GeneralRe: Long filename problems in 2022? Pin
honey the codewitch25-Oct-22 9:22
mvahoney the codewitch25-Oct-22 9:22 
GeneralRe: Long filename problems in 2022? Pin
Jörgen Andersson25-Oct-22 22:28
professionalJörgen Andersson25-Oct-22 22:28 
GeneralRe: Long filename problems in 2022? Pin
honey the codewitch26-Oct-22 1:43
mvahoney the codewitch26-Oct-22 1:43 
GeneralRe: Long filename problems in 2022? Pin
Nelek4-Nov-22 16:28
protectorNelek4-Nov-22 16:28 
GeneralRe: Long filename problems in 2022? Pin
honey the codewitch4-Nov-22 16:49
mvahoney the codewitch4-Nov-22 16:49 
GeneralRe: Long filename problems in 2022? Pin
Nelek5-Nov-22 11:26
protectorNelek5-Nov-22 11:26 
GeneralRe: Long filename problems in 2022? Pin
Gary R. Wheeler10-Dec-22 7:33
Gary R. Wheeler10-Dec-22 7:33 
GeneralRe: Long filename problems in 2022? Pin
trønderen5-Nov-22 5:44
trønderen5-Nov-22 5:44 
GeneralRe: Long filename problems in 2022? Pin
Nelek5-Nov-22 11:25
protectorNelek5-Nov-22 11:25 
GeneralRe: Long filename problems in 2022? Pin
englebart15-Jan-23 11:05
professionalenglebart15-Jan-23 11:05 
GeneralRe: Long filename problems in 2022? Pin
JohnDG523-Jan-23 4:17
JohnDG523-Jan-23 4:17 
AnswerRe: Long filename problems in 2022? Pin
Emilie Kelleher27-Nov-22 22:52
Emilie Kelleher27-Nov-22 22:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.