Mex files crashes when run
Show older comments
Hi. I have written and compiled a mex file from a Fortran source code. However, I have problems running it as Matlab crashes whenever I run the mex file. Can anybody find out where is the problem?
My fortran source code is as follows.
#include "fintrf.h"
C======================================================================
#if 0
C
C add.F
C .F file needs to be preprocessed to generate .for equivalent
C
#endif
C
C add.f
C
C Adds two integers
C
C======================================================================
C Gateway routine
subroutine mexFunction(nlhs, plhs, nrhs, prhs)
C Declarations
implicit none
C mexFunction arguments:
mwPointer plhs(*), prhs(*)
integer nlhs, nrhs
C Pointers to input/output mxArrays:
mwPointer a, b
mwPointer c
C Function Declerations
mwPointer mxGetData
a = mxGetData(prhs(1))
b = mxGetData(prhs(2))
c = mxGetData(plhs(1))
C Call the computational subroutine.
call add(%val(a), %val(b), %val(c))
return
end
C-----------------------------------------------------------------------
C Computational subroutine
subroutine add(a, b, c)
integer*8 a, b, c
c = a + b
return
end
Accepted Answer
More Answers (0)
Categories
Find more on COM Component Integration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!