Contents - Index

\$DefaultArraySize

This directive sets the default size of an array that is specified by an indeterminate variable.  Without this directive, the default array size is 100.  Further explanation follows.

Consider the following EES program that includes a function.

Function add(N, X[1..N])

add=0

i=0

Repeat

i=i+1

add=Add+X[i]

Until (i>=N)

End

N=3

Duplicate i=1,N

X[i]=i^2

End

ssq=add(N,X[1..N])

When EES compiles the function, it does not yet know the value of N.  Without knowing N, it is not possible to compile the remaining equations that use array X.  So EES sets N to a default value and proceeds to compile the equations.  The default value is normally 100.  If N is set to a value in the main program that is less than the default value, the program will work as expected.  However, if N is set to a value greater than the default value, an error will result.  Try running this program with N set to 101.

One option is to change the Function statement so that N is replaced with its maximum value, e.g., Funcgtion Add(N,X[1..120]).  Alternatively, the \$DefaultArraySize allows the default value to be changed, as shown below.  Small values result in less memory use and great compiler speed, but may result in a error message if the default value is exceeded.  Large values, e.g., 10000, will eliminate the errors but will waste memory and require more computer time.

\$DefaultArraySize 120

Function add(N, X[1..N])

add=0

i=0

Repeat

i=i+1

add=Add+X[i]

Until (i>=N)

End

N=101

Duplicate i=1,N

X[i]=i^2

End

ssq=add(N,X[1..N])