Compilation to memory
The default compilation of a Mosel file filename.mos generates a binary model file filename.bim. To avoid the generation of physical BIM files for submodels we may compile the submodel to memory, as shown in the following example runsubmem.mos. Working in memory usually is more efficient than accessing physical files. Furthermore, this feature will also be helpful if you do not have write access at the place where the master model is executed.
model "Run model testsub" uses "mmjobs", "mmsystem" declarations modSub: Model end-declarations ! Compile the model file if compile("", "testsub.mos", "shmem:testsubbim")<>0 then exit(1) end-if load(modSub, "shmem:testsubbim") ! Load the bim file from memory fdelete("shmem:testsubbim") ! ... and release the memory block run(modSub) ! Start model execution wait ! Wait for model termination dropnextevent ! Ignore termination event message end-model
The full version of compile takes three arguments: the compilation flags (e.g., use "g" for debugging), the model file name, and the output file name (here a label prefixed by the name of the shared memory driver). Having loaded the model we may free the memory used by the compiled model with a call to fdelete (this subroutine is provided by the module mmsystem that needs to be loaded in addition to mmjobs).