If the dummy argument of a procedure is a variable and it has a value assigned to it within the procedure, then the corresponding actual argument can be:
If, however, the dummy variable preserves its initial value throughout the execution then the actual argument can be any of these three forms above or alternatively:
The reason for this restrictions is easy to see by considering the ways of calling the subroutine SILLY in the next example:
SUBROUTINE SILLY(N, M) N = N + M END
If it is called with a statement such as:
NUMBER = 10 CALL SILLY(NUMBER, 5)then the value of NUMBER will be updated to 15 as a result of the call. But it is illegal to call the function with a constant as the first argument, thus:
CALL SILLY(10, 7)because on exit the subroutine will attempt to return the value of 17 to the actual argument which was specified as the constant ten. The effects of committing such an error are system-dependent. Some systems detect the attempt to over-write a constant and issue an error message; others ignore the attempt and allow the program to continue; but some systems will actually go ahead and over-write the constant with a new value, so that if you use the constant 10 in some subsequent statement in the program you may get a value of 17. Since this can have very puzzling effects and be hard to diagnose, it is important to avoid doing this inadvertently.
If you make use of procedures written by other people you may be
worried about unintentional effects of this sort. In principle it
should be possible to prevent a procedure altering a constant
argument by turning each one into an expression, for example like
CALL SILLY(+10, +5)
CALL SILLY((10), (5))
Although either of these forms should protect the constants, it is still against the rules of Fortran for the procedure to attempt to alter the values of the corresponding dummy arguments. You will have to judge whether it is better to break the rules of the language than to risk corrupting a constant.