Next: COMMON Blocks
Up: COMMON Blocks
Previous: COMMON Blocks

Communications

Given the subset of Fortran that we have studied so far, what are all the ways of communicating information among the main program, the functions, and the subroutines of a program?

Click here for the answer

Most programming languages support the concept of ``global'' variables. A global variable is a variable that is visible in more than one unit (main program, function, subroutine) of a program. Global variables provide an alternative means of passing information among program units. The subset of Fortran that we have studied so far does not have global variables---every variable can be used in one, and exactly one, unit.

COMMON blocks are the form that global variables take in Fortran programs. By using global variables, you can share variables with other units without explicitly passing them as parameters. What is the advantage of this?

Click here for the answer

So global variables (via COMMON blocks) are a convenience, and sometimes a big convenience. But it is important that you use them with due care, because global variables also have an important disadvantage. Can you think of it is?

Click here for the answer

We do not recommend the unbridled use of global variables in Fortran or in any other language. As you proceed through this lesson, we will point out potential pitfalls as we advocate a responsible approach to harnessing the power of global variables.


Next: COMMON Blocks
Up: COMMON Blocks
Previous: COMMON Blocks

Hamlet Project
hamlet@cs.utah.edu