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 0C C add.FC .F file needs to be preprocessed to generate .for equivalentC #endifC C add.fCC Adds two integersC C======================================================================C Gateway routine subroutine mexFunction(nlhs, plhs, nrhs, prhs)C Declarations implicit noneC mexFunction arguments: mwPointer plhs(*), prhs(*) integer nlhs, nrhsC Pointers to input/output mxArrays: mwPointer a, b mwPointer cC 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
Best Answer