2 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 SUBROUTINE mexFunction( nlhs
, plhs
, nrhs
, prhs
)
4 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 ! Matlab Gateway for the Derivative Function Fun
6 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 INTEGER plhs(*), prhs(*)
12 INTEGER mxGetPr
, mxCreateFull
, mxGetM
, mxgetN
13 INTEGER VPtr
, FPtr
, RPtr
, VdotPtr
14 KPP_REAL
V(KPP_NVAR
), F(KPP_NFIX
), RCT(KPP_NREACT
)
15 KPP_REAL
Vdot(KPP_NVAR
)
17 ! Check for the right number of input arguments
18 IF ( nrhs
.ne
. 3 ) THEN
19 CALL mexErrMsgTxt('Fun requires 3 input vectors: &
20 &V(KPP_NVAR), F(KPP_NFIX), RCT(KPP_NREACT)')
22 ! Check for the right number of output arguments
23 IF ( nlhs
.ne
. 1 ) THEN
24 CALL mexErrMsgTxt('Fun requires 1 output vector: &
28 plhs(1) = mxCreateDoubleMatrix(KPP_NVAR
,1,0)
30 VPtr
= mxGetPr(prhs(1))
31 CALL mxCopyPtrToReal8(VPtr
,V
,KPP_NVAR
)
33 FPtr
= mxGetPr(prhs(2))
34 CALL mxCopyPtrToReal8(FPtr
,F
,KPP_NFIX
)
36 RPtr
= mxGetPr(prhs(3))
37 CALL mxCopyPtrToReal8(RPtr
,RCT
,KPP_NREACT
)
39 VdotPtr
= mxGetPr(plhs(1))
41 CALL Fun( V
, F
, RCT
, Vdot
)
43 CALL mxCopyReal8ToPtr(Vdot
, VdotPtr
, KPP_NVAR
)
45 END SUBROUTINE mexFunction