source: palm/trunk/UTIL/chemistry/gasphase_preproc/kpp/util/Mex_Fun.f @ 4901

Last change on this file since 4901 was 2696, checked in by kanani, 6 years ago

Merge of branch palm4u into trunk

File size: 1.4 KB
Line 
1
2C~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3      SUBROUTINE mexFunction( nlhs, plhs, nrhs, prhs )
4C~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5C             Matlab Gateway for the Derivative Function Fun
6C~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
15C 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
20C 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
Note: See TracBrowser for help on using the repository browser.