# bmi.base module¶

Interface to the basic control functions of a model.

class bmi.base.BmiBase[source]

Bases: object

Functions that control model execution.

These BMI functions are critical to plug-and-play modeling because they give a calling component fine-grained control over the model execution.

Methods

 finalize() Perform tear-down tasks for the model. initialize(filename) Perform startup tasks for the model. update() Advance model state by one time step. update_frac(time_frac) Advance model state by a fraction of a time step. update_until(time) Advance model state until the given time.
finalize()[source]

Perform tear-down tasks for the model.

Perform all tasks that take place after exiting the model’s time loop. This typically includes deallocating memory, closing files and printing reports.

Notes

/* C */
int finalize(void *self);

initialize(filename)[source]

Perform startup tasks for the model.

Perform all tasks that take place before entering the model’s time loop, including opening files and initializing the model state. Model inputs are read from a text-based configuration file, specified by filename.

Parameters: filename : str, optional The path to the model configuration file.

Notes

Models should be refactored, if necessary, to use a configuration file. CSDMS does not impose any constraint on how configuration files are formatted, although YAML is recommended. A template of a model’s configuration file with placeholder values is used by the BMI.

/* C */
int initialize(void *self, char * filename);

update()[source]

Advance model state by one time step.

Perform all tasks that take place within one pass through the model’s time loop. This typically includes incrementing all of the model’s state variables. If the model’s state variables don’t change in time, then they can be computed by the initialize() method and this method can return with no action.

Notes

/* C */
int update(void *self);

update_frac(time_frac)[source]

Advance model state by a fraction of a time step.

Parameters: time_frac : float A fraction of a model time step value.

Notes

/* C */
int update_frac(void *self, double time_frac);

update_until(time)[source]

Advance model state until the given time.

Parameters: time : float A model time value.

Notes

/* C */
int update_until(void *self, double time);