Initializing help system before first use

Structures for passing information

A static module differs from dynamic modules only in the way it is initialized. The module initialization function (see below Section Initialization function) has no special return type to make it known to Mosel, instead it is declared to Mosel in the main C program. After the initialization of Mosel, but before any model file that uses the static module meminit is compiled or loaded, we have to add the following line:

 XPRMregstatdso("meminit", meminit_init);

The function XPRMregstatdso registers the module name and its initialization function with Mosel.

List of subroutines

The module meminit only defines a single subroutine, namely the procedure meminit. This procedure takes three arguments (see Appendix List of subroutines for an explanation of the encoding of the parameter format string): AI.i: an array of integers indexed by a range (the data we want to pass to the model), s: a string (the location of the data in memory) and i: an integer (the size of the data array):

static XPRMdsofct tabfct[]=
    {
     {"meminit", 1000, XPRM_TYP_NOT, 3, "AI.isi", mi_meminit}
    };

This table of functions needs to be included into the main interface structure as shown in the previous chapters.

Initialization function

As mentioned earlier, the prototype of the initialization function for static modules is slightly different from what we have seen for DSOs, but the information exchanged between Mosel and the module is the same:

static int meminit_init(XPRMnifct nifct, int *interver, int *libver,
                        XPRMdsointer **interf)
{
 mm=nifct;                      /* Save the table of functions */
 *interver=XPRM_NIVERS;         /* The interface version we are using */
 *libver=XPRM_MKVER(0,0,1);     /* The version of the module: 0.0.1 */
 *interf=&dsointer;             /* Our interface */
 return 0;
}