global Parameters var M : int := 10, N : int := 20 body Parameters getarg(1, M); getarg(2, N) if M < 1 or N < 1 -> write("M=", M, "or N=", N, "< 1"); stop fi write("the parameters are M=", M, "and N=", N) end Parameters global Arrays import Parameters var g1[1:M,1:N] : int var g2[1:M,1:N] : int := ( [M] ( [N] -3 )) # sem mutex[1:N] := ([N] 0) ### compiler error sem mutex[1:20] := ([20] 0) # constant bound okay body Arrays fa i := 1 to M, j := 1 to N -> g1[i,j] := 1000*i+j af write("the arrays have been initialized") fa i := 1 to N -> V(mutex[i]) af end Arrays resource driver() import Parameters, Arrays g2 := g1 write("g2[M,N]=", g2[M,N], "and upper bounds g1=", ub(g1,1), ub(g1,2)) end driver /* ............... Example compile and run(s) % sr -v; sr -o nested_globals nested_globals.sr MultiSR version 2.3, October 1994 % ./nested_globals the parameters are M= 10 and N= 20 the arrays have been initialized g2[M,N]= 10020 and upper bounds g1= 10 20 % ./nested_globals 2 0 M= 2 or N= 0 < 1 % ./nested_globals 22 33 the parameters are M= 22 and N= 33 the arrays have been initialized g2[M,N]= 22033 and upper bounds g1= 22 33 */