The JSim C/C++ Language API


This document describes the JSim C/C++ Application Programmer Interface (API), the specification for how to write C or C++ code so that is will successfully interface with MML functions and procedures (F&P). This document assumes the reader is familiar with MML F&P and with the C or C++ programming languages.


  • Structures & macros used in the C/C++ API are defined in JSIMHOME/JSIMOS/include/jsimapi.h, where JSIMOS is your operating system (linux, win32, ...).
  • Each argument passed to an MML function or procedure will be represented by a JSimArg structure. Each JSimArg will have an associated JSimGrid structure for each MML domain associated with the argument. A JSimArg's realVal array is a double array representing the arguments's values. realVal's length in the product of the associated JSimGrid sizes (or 1, if no grids). Multi-dimensional array ordering (row-major vs. row-minor) is not yet finalized for multi-dimensional arguments (pending Fortran implementation). At call time, input arguments will have realVal set to model calculated values, output arguments will have realVal set to NaNs.
  • Function values are returned with the JSIM_RETURN macro. Procedure output arguments are returned by setting the "realVal" array elements in a JSimArg. realVal should never be reallocated. JSIM_RETURN is required for both functions and procedures to free up local resources. Omitting JSIM_RETURN will cause memory leaks.
  • The JSIM_ERROR macro may be used when error conditions are encountered to generate run-time Exceptions that will cause the model run to terminate.
  • See comments in jsimapi.h for further details.
  • See Calling C from MML for some simple examples.

Comments or Questions?

Give feedback


Model development and archiving support at provided by the following grants: NIH U01HL122199 Analyzing the Cardiac Power Grid, 09/15/2015 - 05/31/2020, NIH/NIBIB BE08407 Software Integration, JSim and SBW 6/1/09-5/31/13; NIH/NHLBI T15 HL88516-01 Modeling for Heart, Lung and Blood: From Cell to Organ, 4/1/07-3/31/11; NSF BES-0506477 Adaptive Multi-Scale Model Simulation, 8/15/05-7/31/08; NIH/NHLBI R01 HL073598 Core 3: 3D Imaging and Computer Modeling of the Respiratory Tract, 9/1/04-8/31/09; as well as prior support from NIH/NCRR P41 RR01243 Simulation Resource in Circulatory Mass Transport and Exchange, 12/1/1980-11/30/01 and NIH/NIBIB R01 EB001973 JSim: A Simulation Analysis Platform, 3/1/02-2/28/07.