"Sudarshan " <email@example.com> wrote in message news:firstname.lastname@example.org... >> Are you running 32-bit or 64-bit? >> What version of MATLAB are you using? >> >> I see potential problems with your use of "integer" as a pointer (will >> need to be integer*8 on 64-bit systems ... i.e. should use mwPointer >> instead). >> >> Also the mxCreateFull function is deprecated, and has been for quite some >> time, so this must be very old code. >> >> Is it your intent to simply call the pr_equil function with MATLAB inputs >> & outputs? If so, this can probably be done much simpler. >> >> James Tursa > > Hi James, > > Thanks a lot for such a quick turnaround :) I am using Windows 7 32 bit, > MATLAB R2011b 32 bit, Visual Studio 2010 Professional and Intel Visual > Fortran Composer XE 2011. Yes the code is pretty old, written in 2001 and > modified in 2006. > > I have replaced mxCreateFull function with mxCreateDoubleMatrix. Also i > used mwPointer wherever appropriate. However, MATLAB still crashes. > I guess i should learn about MEX files properly to get out of this. > Anyway, if you think minor corrections could make the code work, would you > please let me know?
It might be a "minor correction" but that's a good chunk of code to dig through to locate it. This reminds me of an old joke:
If you don't have access to this online documentation, search the documentation in your installation of MATLAB for "debug Fortran MEX" and it should be one of the first few hits.
Alternately you could always go for the quick & dirty debugging method, which involves doing divide and conquer in your file with mexPrintf statements to isolate the line that's causing the crash. Write a mexPrintf statement roughly in the middle of your file, run. If it crashes before the message is printed, the line on which the crash occurs is in the first half of your code; repeat by putting a mexPrintf in the middle of that first half. Otherwise put a mexPrintf in the middle of the second half of your code. Repeat this process until you know where the crash happens. Then you get to work your way backwards and figure out why the crash occurs on that line.