Page 6 - Demo
P. 6
Interface to C/C++%uf09f %uf09f RCP Consult 2023-2025 Page 6The user defined function without arguments can be expressed in the Symbolic language of STRUREL as shown below. DEFFUNC(1,2,CppSAO,\ {Function without arguments}=CppFunctionorDEFFUNC(1,CPP,CppSAO,\ {Function without arguments}=CppFunctionIn this case you need to prepare your source like//* Include file with internal STRUREL definitions#include \extern \{//* Export function definition for usage in STRUREL DllExport double CppFunction(long *);}double CppFunction(long *ier){/*Uses global names of Variables and Parameters to access their values.The sequence is arbitrary. Both STRUREL and C/C++ are case sensitive.*/ *ier=0; return 123.;}The last argument %u2018*ier%u2019 in each export function described above is an mandatory integer indicating an error during evaluation. It must be defined as a last argument and needs to beset to 0 if everything is Ok. Otherwise it can be set to a positive number indicating an error state for debugging purposes. This argument is hidden in the description of a DEFFUNC and will be ignored in the count of arguments.5. Global Data in the InterfaceBefore processing interface data in form of source files STRUREL pre-sets all required input variables. Three global sets will be defined: two global vectors and additionally, each stochastic variable and deterministic parameter become an assigned global name having exactly the same name as in the Stochastic Model. This allows to work in vector notation and/or direct over global names. The first global vector has a fixed name s_XP_ and contains the mean values for the stochastic X-variables followed by the values of the deterministic Parameters. The second global vector has a fixed name v_XP_ and receives all values of the current evaluation step for the X-variables followed again by the values of the deterministic Parameters.