Contents - Index


$DOLAST and $ENDDOLAST

 

Equations that are placed between the $DOLAST and $ENDDOLAST directives are compiled and executed after all of the other calculations are completed.  The capability to control the order in which equations are executed is seldom needed since EES automatically orders the equations to provide the most efficient calculation.  However, EES attempts to compile all equations before the calculations begin.  Some equations, such as those involving a Duplicate statement cannot be compiled unless the limits are known apriori.  In some cases, information such as the limits can be calculated and then used in further calculations.  The $DOLAST directive is useful in these situations.  Another application of the $DOLAST directive would be to set the limits of an Integral function.

 

$DOLAST directives can only be used within the main program, i.e., not within Modules or Subprograms.  Note that each $DOLAST directive must be matched with a $ENDDOLAST directive.  More than one set of these directives can be used but they cannot be nested within each other.  However, there is no order for multiple $DOLAST statement.  All equations within the combined $DOLAST - $ENDDOLAST directives are solved simultaneously.

 

When used with a Parametric Table initiated by the Solve Table command, the equations within the $DOLAST - $ENDDOLAST are executed after ALL rows in the Parametric Table have been calculated.  The $DOLAST clause is useful in this case to provide information about the completed table.

 

The $DOLAST directive cannot be used with the Uncertainty Propagation calculation.

 

After the calculations are completed, the values of all variables (those outside and within the $DOLAST - $ENDDOLAST block) are displayed in the Solution window.  The equations within the  $DOLAST - $ENDDOLAST block are identified with 'Last' in the block number field of the Residuals window.  The tree node representing the $DOLAST - $ENDDOLAST equations in the Computational Flow window is displayed as DoLast.

 

Example

 

The program below is run with the Solve Table (F3) command.  Create a Parametric table with columsn for X, Y and Z.  Set values of Z in the Parametric table  The equations in the $DOLAST clause determine the sum of the values in z column after all of the rows in the table have been calculated.  This problem would also work without the $DOLAST clause, but the sum would be computed for each row in the table and thereby require more computing effort.

 

x^2+y^3=z

x/(y^2+1)=1.2345

 

$DOLAST

SumZ=sumParametric('Table 1','z')

$ENDDOLAST

 

 

Directives