[2696] | 1 | |
---|
| 2 | C~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 3 | SUBROUTINE mexFunction( nlhs, plhs, nrhs, prhs ) |
---|
| 4 | C~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 5 | C Matlab Gateway for the Derivative Function Fun |
---|
| 6 | C~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 7 | |
---|
| 8 | INTEGER nlhs, nrhs |
---|
| 9 | INTEGER plhs(*), prhs(*) |
---|
| 10 | INTEGER mxGetPr, mxCreateFull, mxGetM, mxgetN |
---|
| 11 | INTEGER VPtr, FPtr, RPtr, VdotPtr |
---|
| 12 | KPP_REAL V(KPP_NVAR), F(KPP_NFIX), RCT(KPP_NREACT) |
---|
| 13 | KPP_REAL Vdot(KPP_NVAR) |
---|
| 14 | |
---|
| 15 | C Check for the right number of input arguments |
---|
| 16 | IF ( nrhs .ne. 3 ) THEN |
---|
| 17 | CALL mexErrMsgTxt('Fun requires 3 input vectors: |
---|
| 18 | &V(KPP_NVAR), F(KPP_NFIX), RCT(KPP_NREACT)') |
---|
| 19 | END IF |
---|
| 20 | C Check for the right number of output arguments |
---|
| 21 | IF ( nlhs .ne. 1 ) THEN |
---|
| 22 | CALL mexErrMsgTxt('Fun requires 1 output vector: |
---|
| 23 | &Vdot(KPP_NVAR)') |
---|
| 24 | END IF |
---|
| 25 | |
---|
| 26 | plhs(1) = mxCreateDoubleMatrix(KPP_NVAR,1,0) |
---|
| 27 | |
---|
| 28 | VPtr = mxGetPr(prhs(1)) |
---|
| 29 | CALL mxCopyPtrToReal8(VPtr,V,KPP_NVAR) |
---|
| 30 | |
---|
| 31 | FPtr = mxGetPr(prhs(2)) |
---|
| 32 | CALL mxCopyPtrToReal8(FPtr,F,KPP_NFIX) |
---|
| 33 | |
---|
| 34 | RPtr = mxGetPr(prhs(3)) |
---|
| 35 | CALL mxCopyPtrToReal8(RPtr,RCT,KPP_NREACT) |
---|
| 36 | |
---|
| 37 | VdotPtr = mxGetPr(plhs(1)) |
---|
| 38 | |
---|
| 39 | CALL Fun( V, F, RCT, Vdot ) |
---|
| 40 | |
---|
| 41 | CALL mxCopyReal8ToPtr(Vdot, VdotPtr, KPP_NVAR) |
---|
| 42 | |
---|
| 43 | RETURN |
---|
| 44 | END |
---|