Initializing help system before first use

Static modules versus I/O drivers

The generalization of the notion `file' and the introduction of I/O drivers in Mosel replace certain uses of static user modules. In particular for transfering data in memory it is often no longer necessary to write a dedicated module. However, other uses of static modules persist, such as the compilation of a standard module as a static module for debugging purposes.

The example from Section Example may be re-written as follows using the raw and mem drivers that are available with the standard distribution of Mosel:

model "Test initialization in memory (I/O)"
 parameters
  MEMDAT=''              ! Data block in memory
 end-parameters

 declarations
  a:array(1..20) of integer
 end-declarations

 initializations from "raw:"
  a as MEMDAT
 end-initializations

 writeln("a=", a)
end-model

The complete C program to execute the Mosel program meminitio.mos printed above may look as follows:

#include <stdio.h>
#include "xprm_mc.h"

int main()
{
 XPRMmodel mod;
 int result;
 char params[80];
 static int tabinit[]= {23,78,45,90,234,111,900,68,110};

 XPRMinit();                                       /* Initialize Mosel */
 XPRMcompmod("", "meminitio.mos", NULL, NULL);     /* Compile the model */
 mod=XPRMloadmod("meminitio.bim", NULL);           /* Load the model */

 /* Parameters: the address of the data table and its size */
 sprintf(params, "MEMDAT='noindex,mem:%p/%u'", tabinit, sizeof(tabinit));

 XPRMrunmod(mod, &result, params);                 /* Run the model */
 return result;
}