Page 6 - Demo
P. 6


                                    Interface to C/C++%uf09f%uf09fRCPConsult2023-2025Page 6The user definedfunction withoutargumentscan be expressed in the Symboliclanguage 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 prepareyour source like//* Include file with internal STRUREL definitions#include\extern\{//* Export function definition for usage in STRURELDllExportdoubleCppFunction(long*);}doubleCppFunction(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;return123.;}The last argument %u2018*ier%u2019in each export function described above is an mandatory integer indicating an error during evaluation. It must bedefined as a lastargument and needsto 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 sourcefiles STRUREL pre-sets all required input variables. Three global sets will be defined:twoglobal vectorsand additionally, each stochastic variable and deterministic parameter become an assigned global namehaving 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 vectorhas 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 vectorhas 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.
                                
   1   2   3   4   5   6   7   8   9   10