Calling a subroutine more than once
External variables can always be changed by a subroutine whether or not they are passed as arguments. If the subroutine is called once only, call it without any arguments and then refer to the variables to be changed by name inside the routine. For example:
if (numb(c119).gt.2) call pchk
.
subroutine pchk
r sp c120'1/9&'
if (c131n'1') emit c141'1'
.
return
However, if you have a subroutine that is called more than once with different external variables, represent them with local variables in the subroutine. For example:
if (numb(c119).le.2) call pchk(c120,total)
if (numb(c119).gt.2) call pchk(c220,tot2)
.
subroutine pchk(n1,n2)
data n1
data n2
.
return
Here, n1 represents c120 or c220 and n2 represents total or tot2. n1 and n2 are local to the subroutine so they are defined after the subroutine statement.
See also