hirchert@uxe.cso.uiuc.edu (10/09/87)
/* Written 10:48 am Oct 6, 1987 by ed298-ak@violet.berkeley.edu in uxe.cso.uiuc.edu:comp.lang.fortran */ This is a minor point but there is a way to force FORTRAN to give you value parameters. Simply wrap the variables in the subprogram CALL with parentheses. The parentheses make the variable appear to be an expression which cannot be changed thus the compiler doesn't return the values, just as if it won't try to change the value of a constant passed to a sub-program. CALL FOO(X) # X is a variable parameter CALL FOO ( (X) ) # X is a value parameter CALL FOO (X+0) # X is here too This trick gives FORTRAN a somewhat unique feature, in that the same sub-program can have both value and variable parameters depending on the call. To bad that the concept is not very intuitive! Edouard Lagache lagache@violet.berkeley.edu /* End of text from uxe.cso.uiuc.edu:comp.lang.fortran */ Note really! The rules in the FORTRAN 77 standard say that if the actual argument is an expression, then the _program_ must not define (i.e. change) the dummy argument. I have seen compilers that, _as an extension_, copy expression values to temporary locations so the subprogram cannot possibly change anything, but such behavior is not required by the FORTRAN 77 standard and, in my experience, not that common for trivial expressions like (X) or X+0. Kurt W. Hirchert hirchert@newton.ncsa.uiuc.edu (Yes, I get e-mail on a different machine than I get news.)