CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC PROGRAM OBFUSCATE CONSTANT = 5. INVERSE = 1./CONSTANT photo1 = 5.*INVERSE + 5. pH = CONSTANT + 3. X = photo1 * pH C strange combination of pH and photolysis... GOTO 1 X = X + 17. 1 CONTINUE IF (X .LT. 60.) THEN X = X + 7. PRINT *,'RESULT=',X STOP END CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
Hopefully the formatting comes out OK; consult the original if in doubt. The question, of course, is what does the code print, and more importantly exactly why? I'm off to the Lakes for a few days to get rained on, so unless you can work out the answer for yourselves, you'll have to wait till I come back.
Obviously, C would never do anything so odd.
And the answer, as EFS found, comes in three parts:
1. The easy one is that without IMPLICIT NONE, any variable starting with I (to N) is implicitly an integer, so INVERSE is 0, not 0.2.
2. The first amusing one is that any non-blank character in column 6 is a continuation marker. Comments are discarded, so we have:
X = photo1 * pH OTO 1and since spaces are also discarded, we actually have
X = photo1 * pHOTO1So (since case is also discarded) after that X is 25. To which we add 17, getting 42, of course.
3. Then, lastly, Fortran has a block IF, but also a single-line IF, and
IF (X .LT. 60.) THEN X = X + 7can't be a block IF (despite the formatting trying to make the end-of-code "END" look like it's closing), so it's actually
IF (X .LT. 60.) THENX = X + 7And so we end up with a variable called THENX with value 49, and X with value 42.