Next: Checkoff
Up: COMMON Blocks
Previous: Different Variable Names

Different Variables

Actually, things can be made even more confusing. Take a look at ``common3.f'' (or view it directly). How does it differ from ``common1.f''?

Click here for the answer

Again, that's perfectly OK with Fortran. All it knows is that the COMMON block has room for 25 REAL numbers. If you want to view that block as a single 5x5 array in one place, and as five 5-element arrays in another place, that's your business.

But it's bad business, and should be avoided! Why?

Click here for the answer

Look carefully at the output of ``common3.f'', and compare it to the output of ``common2.f''. Are they really the same?

Click here for the answer

If you try to do tricks like this, you'll inevitably get burned since it requires knowing how Fortran organizes data in memory. If you use exactly the same variable names with exactly the same declarations for each COMMON block, you'll save yourself a lot of trouble and make your programs much more readable.


Next: Checkoff
Up: COMMON Blocks
Previous: Different Variable Names

Hamlet Project
hamlet@cs.utah.edu