Download An Integrated System Dynamics Model for
Transcript
APPENDIX B: EXTERNAL FUNCTIONS //#include <imsl.h> #include <stdio.h> #include <math.h> #include <time.h> #include <windows.h> #define WANT_WINDOWS_INCLUDES /* the sample implementation of this requires windows includes/libraries */ #define VENEXT_GLOBALS #include "vensim.h" #include <malloc.h> GLOB_VARS *VENGV ; /* the value for this is set by set_gv below */ /******************************************* 1 - function ids - used to swich between choices *******************************************/ #define COS_FUNC 0 #define INRANGE_FUNC 1 #define PSUM_FUNC 2 #define INVERT_FUNC 3 #define INPLACE_INVERT_FUNC 4 #define INTERNAL_ROR_FUNC 5 #define MYMESSAGE_FUNC 6 #define MYFINDZERO_FUNC 7 #define MYLOOKUP_FUNC 8 #define MYALLTYPES_FUNC 9 #define MYCONSTDEF_FUNC 10 #define MYDATADEF_FUNC 11 #define MY_FUNC 12 #define ARRAY_READ 13 #define N 32 //before it was 26 /******************************************* 2 - function prototypes ******************************************* each external function is prototyped here arguments can reasonably be doubles - for normal number manipulation, COMPREAL * for vector manipulation or int for indexing. Recasting of values takes place in Note that if you use more than 1 file for the external function definitions you should probably put these prototypes into a #include file. Also, for working with compiled simulation a # include file is helpfule, and should be nested into vensim.h Note that all the external functions are all upper case. This is required if you want to use compile simulations - since the calls in mdl.c will be upper case. Our apologies to those this offends. *********************************************/ //double writing(double a1, double a2, double a3,double a4, double a5, double a6,double a7, double a8, double a9,double a10, double a11, double a12,double a13, double a14, double a15,double a16, double a17, double a18,double a19, double a20, 119