Example
Below we show how to define constants of different types (integer, real, string, Boolean). Once this module with the name myconstants is completed, we can write a simple model to output the constants:
model "test myconstants module" uses "myconstants" writeln(MYCST_LINE) writeln("BigM value: ", MYCST_BIGM, ", tolerance value: ", MYCST_TOL) writeln("Boolean flags: ", MYCST_FLAG, " ", MYCST_NOFLAG) writeln(MYCST_LINE) end-model
The result that we expect to see printed is the following:
---- BigM value: 10000, tolerance value: 1e-05 Boolean flags: true false ----
Without the need to write such a test program, we could use the Mosel command
examine myconstants
which will list all constants and (if there were any) subroutines, types and parameters, defined by the module myconstants.
To prevent name clashes between constants that are provided by different modules, a good habit to get into is to use prefixes (e.g. based on the module name) in the names of constants, as is done in the following example.