Main execution loop


Detailed Description

The main execution loop sets up the main simulation, initializes the objects, and runs the simulation until it either settles to equilibrium or runs into a problem.

This program provide the same kill functionality that is available to Linux versions.

It also takes care multicore/multiprocessor parallelism when possible. Objects of the same rank will be synchronized simultaneously, resources permitting.

The main processing loop calls each object passing to it a TIMESTAMP indicating the desired synchronization time. The sync() call attempts to advance the object's internal clock to the time indicated, and if successful it returns the time of the next expected change in the object's state. An object state change is one which requires the equilibrium equations of the object to be updated. When an object's state changes, all the other objects in the simulator are given an opportunity to consider the change and possibly alter the time of their next state change. The core continues calling objects, advancing the global clock when necessary, and continuing in this way until all objects indicate that no further state changes are expected. This is the equilibrium condition and the simulation consequently ends.

Future [Chassin Oct'07]
There is some value in exploring whether it is necessary to update all objects when a particular objects implements a state change. The idea is based on the fact that updates propagate through the model based on known relations, such at the parent-child relation or the link-node relation. Consequently, it should obvious that unless a value in a related object has changed, there can be no significant change to an object that hasn't reached it's declared update time. Thus only the object that "won" the next update time and those that are immediately related to it need be updated. This change could result in a very significant improvement in performance, particularly in models with many lightly coupled objects.


Functions

int exec_init ()
 The main system initialization sequence.
STATUS exec_start (void)
 This is the main simulation loop.
STATUS exec_test (struct sync_data *data,int pass,OBJECT *obj)
 Starts the executive test loop.

Variables

int stop_now
 flag indicating that main loop needs to be step (and debugger activated if allowed)


Function Documentation

int exec_init (  ) 

The main system initialization sequence.

Returns:
1 on success, 0 on failure

Definition at line 72 of file exec.c.

References global_init(), and timestamp_set_tz().

Referenced by main().

STATUS exec_start ( void   ) 

This is the main simulation loop.

Returns:
STATUS is SUCCESS if the simulation reached equilibrium, and FAILED if a problem was encountered.

Definition at line 421 of file exec.c.

References class_get_first_class(), convert_from_timestamp(), exec_debug(), exec_sighandler(), int64, object_get_count(), output_debug(), output_error(), output_message(), output_profile(), output_raw(), output_verbose(), and stop_now.

Referenced by cmex_start(), and environment_start().

STATUS exec_test ( struct sync_data *  data,
int  pass,
OBJECT obj 
)

Starts the executive test loop.

Returns:
STATUS is SUCCESS if all test passed, FAILED is any test failed.

< the current object

Parameters:
data  the synchronization state data
pass  the pass number

Definition at line 745 of file exec.c.

References object_name(), object_sync(), output_error(), and output_verbose().


GridLAB-DTM Version 2.0
An open-source project initiated by the US Department of Energy