Click here to Skip to main content
15,868,035 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 21:56
haughtonomous2-Jan-23 21:56 
GeneralRe: Classic FORTRAN Pin
lewist573-Jan-23 8:43
lewist573-Jan-23 8:43 
GeneralRe: Classic FORTRAN Pin
trønderen3-Jan-23 9:21
trønderen3-Jan-23 9:21 
GeneralRe: Classic FORTRAN Pin
lewist573-Jan-23 9:49
lewist573-Jan-23 9:49 
GeneralRe: Classic FORTRAN Pin
jsc423-Jan-23 10:53
professionaljsc423-Jan-23 10:53 
GeneralRe: Classic FORTRAN Pin
Peter_in_27803-Jan-23 11:07
professionalPeter_in_27803-Jan-23 11:07 
GeneralRe: Classic FORTRAN Pin
jsc423-Jan-23 23:25
professionaljsc423-Jan-23 23:25 
GeneralRe: Classic FORTRAN Pin
trønderen3-Jan-23 16:54
trønderen3-Jan-23 16: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 5:27
lewist574-Jan-23 5:27 
GeneralRe: Classic FORTRAN Pin
trønderen4-Jan-23 8:53
trønderen4-Jan-23 8:53 
GeneralRe: Classic FORTRAN Pin
lewist576-Jan-23 16:02
lewist576-Jan-23 16:02 
GeneralLong filename problems in 2022? Pin
honey the codewitch24-Oct-22 14:40
mvahoney the codewitch24-Oct-22 14:40 
GeneralRe: Long filename problems in 2022? Pin
MarkTJohnson25-Oct-22 7:21
professionalMarkTJohnson25-Oct-22 7:21 
GeneralRe: Long filename problems in 2022? Pin
honey the codewitch25-Oct-22 8:22
mvahoney the codewitch25-Oct-22 8:22 
GeneralRe: Long filename problems in 2022? Pin
Jörgen Andersson25-Oct-22 21:28
professionalJörgen Andersson25-Oct-22 21:28 
GeneralRe: Long filename problems in 2022? Pin
honey the codewitch26-Oct-22 0:43
mvahoney the codewitch26-Oct-22 0:43 
GeneralRe: Long filename problems in 2022? Pin
Nelek4-Nov-22 15:28
protectorNelek4-Nov-22 15:28 
GeneralRe: Long filename problems in 2022? Pin
honey the codewitch4-Nov-22 15:49
mvahoney the codewitch4-Nov-22 15:49 
GeneralRe: Long filename problems in 2022? Pin
Nelek5-Nov-22 10:26
protectorNelek5-Nov-22 10:26 
GeneralRe: Long filename problems in 2022? Pin
Gary R. Wheeler10-Dec-22 6:33
Gary R. Wheeler10-Dec-22 6:33 
GeneralRe: Long filename problems in 2022? Pin
trønderen5-Nov-22 4:44
trønderen5-Nov-22 4:44 
GeneralRe: Long filename problems in 2022? Pin
Nelek5-Nov-22 10:25
protectorNelek5-Nov-22 10:25 
GeneralRe: Long filename problems in 2022? Pin
englebart15-Jan-23 10:05
professionalenglebart15-Jan-23 10:05 
GeneralRe: Long filename problems in 2022? Pin
JohnDG523-Jan-23 3:17
JohnDG523-Jan-23 3:17 
AnswerRe: Long filename problems in 2022? Pin
Emilie Kelleher27-Nov-22 21:52
Emilie Kelleher27-Nov-22 21: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.