Debug Fortran Source MEX-Files error
1 view (last 30 days)
Show older comments
Dear all:
I use MATLAB 2013a,VS2010 and Intel.Visual.Fortran.Composer.XE.2011 to debug Fortran Source MEX-Files based on win7 64bit,and the Call Stack shows the follow informations:
KernelBase.dll!000007fefd193c62()
[Frames below may be incorrect and/or missing, no symbols loaded for KernelBase.dll]
mcr.dll!00000000749c4848()
libut.dll!00000000744925ff()
libmex.dll!0000000004e214df()
msvcr100.dll!00000000713a12e3()
ntdll.dll!000000007729905d()
ntdll.dll!0000000077288c0f()
ntdll.dll!00000000772bd948()
msvcr100.dll!000000007136c01d()
> readdata.mexw64!COPYREAL3DMATTOMATLAB(INTEGER(8) PTR, REAL(8) VALUE, INTEGER(8) N1, INTEGER(8) N2, INTEGER(8) N3) Line 165 Fortran
readdata.mexw64!MEXFUNCTION(INTEGER(8) NLHS, INTEGER(8) PLHS, INTEGER(8) NRHS, INTEGER(8) PRHS) Line 114 Fortran
libmex.dll!0000000004e1f720()
libmex.dll!0000000004e1e202()
libmex.dll!0000000004e1f2b4()
m_dispatcher.dll!0000000074e8c64f()
m_dispatcher.dll!0000000074e8ced2()
m_interpreter.dll!00000000046cbc7b()
m_interpreter.dll!00000000046bb091()
m_interpreter.dll!00000000046a008f()
m_interpreter.dll!00000000046b65a4()
m_interpreter.dll!00000000046ac3b0()
m_interpreter.dll!00000000046a8fe4()
m_interpreter.dll!00000000046c021f()
m_interpreter.dll!00000000046c0370()
m_interpreter.dll!000000000469f1dd()
m_interpreter.dll!00000000046a0bd0()
m_interpreter.dll!000000000468cf79()
m_dispatcher.dll!0000000074e8c64f()
m_dispatcher.dll!0000000074e8ced2()
m_interpreter.dll!00000000046cbc7b()
m_interpreter.dll!00000000046bb091()
m_interpreter.dll!00000000046a008f()
m_interpreter.dll!00000000046b65a4()
m_interpreter.dll!00000000046ac3b0()
m_interpreter.dll!00000000046a8fe4()
m_interpreter.dll!00000000046c021f()
m_interpreter.dll!00000000046c0370()
m_interpreter.dll!000000000469f1dd()
m_interpreter.dll!00000000046a0bd0()
m_interpreter.dll!000000000468cf79()
m_dispatcher.dll!0000000074e8c64f()
m_dispatcher.dll!0000000074e8ced2()
m_interpreter.dll!00000000046cbc7b()
m_interpreter.dll!00000000046bb091()
m_interpreter.dll!00000000046a008f()
m_interpreter.dll!00000000046b65a4()
m_interpreter.dll!00000000046ac3b0()
m_interpreter.dll!000000000469f112()
m_interpreter.dll!00000000046a0bd0()
m_interpreter.dll!000000000468cf79()
m_dispatcher.dll!0000000074e8c64f()
m_dispatcher.dll!0000000074e8ced2()
m_interpreter.dll!00000000046a6d48()
m_interpreter.dll!000000000461f9f7()
m_interpreter.dll!00000000046aa877()
m_interpreter.dll!00000000046c021f()
m_interpreter.dll!00000000046c0370()
m_interpreter.dll!000000000469f1dd()
m_interpreter.dll!00000000046a0bd0()
m_interpreter.dll!000000000468cf79()
m_dispatcher.dll!0000000074e8c64f()
m_dispatcher.dll!0000000074e8ced2()
m_interpreter.dll!000000000460e70e()
m_interpreter.dll!0000000004716495()
m_interpreter.dll!000000000471ca45()
m_interpreter.dll!000000000471ca12()
m_interpreter.dll!000000000471c9d7()
m_interpreter.dll!000000000470ba0e()
m_interpreter.dll!000000000460be89()
m_interpreter.dll!000000000460bdcc()
m_interpreter.dll!000000000460bd81()
libmwbridge.dll!0000000079fbbecd()
libmwbridge.dll!0000000079fbd01b()
mcr.dll!000000007499daa4()
mcr.dll!0000000074982220()
mcr.dll!0000000074982280()
uiw.dll!0000000005d5f9d6()
uiw.dll!0000000005d60095()
user32.dll!0000000076f38802()
user32.dll!0000000076f1f5e7()
user32.dll!0000000076f24869()
ntdll.dll!00000000772bd8f5()
user32.dll!0000000076f290ca()
user32.dll!0000000076f250de()
user32.dll!0000000076f23a47()
uiw.dll!0000000005d39a1b()
uiw.dll!0000000005d61532()
libmwservices.dll!0000000004368930()
libmwservices.dll!00000000043692f5()
libmwservices.dll!000000000436a100()
libmwservices.dll!00000000043728d2()
mcr.dll!000000007498329d()
mcr.dll!0000000074983562()
mcr.dll!0000000074976915()
mcr.dll!0000000074979d52()
MATLAB.exe!0000000140005591()
MATLAB.exe!0000000140005c3a()
MATLAB.exe!0000000140006103()
kernel32.dll!0000000077025a4d()
ntdll.dll!000000007729b831()
Thanks very much!
2 Comments
James Tursa
on 7 Jan 2016
We need to see the source code, and a description of what it is supposed to do.
Accepted Answer
James Tursa
on 8 Jan 2016
You only need to include fintrf.h once per file, not once per routine.
You have a typo for mxCreateStructMatrix.
You have incorrect types for nrhs and nlhs.
I changed your integer*8 to mwPointer to be more generic for 32-bit vs 64-bit.
And other type changes made to match actual API function signatures.
Here is a start. I have not made all necessary corrections because you have not shown all of your code (e.g., you have "implicit none" but you use several undeclared variables in your code). Since you have obviously cut some of your code out before posting, I can't check everything. In any event, you need to pay more attention to the variable argument types and return types for the API functions.
! The gateway routine
#include "fintrf.h"
subroutine mexFunction(nlhs, plhs, nrhs, prhs)
implicit none
mwPointer plhs(*), prhs(*)
integer*4 nlhs, nrhs
mwPointer, external :: mxCreateStructMatrix, mxCreateNumericArray
mwPointer, external :: MXGETM, MXGETN
integer*4, external :: mxClassIDFromClassName
integer*4, external :: mxGetString
mwPointer pS, i
mwPointer mlen, nlen, nivField
mwSize mnmax, m, n, mn
mwSize dims(3)
integer*4 ComplexFlag
integer*4 flag
character*128 dfile
character*128 ivField(14)
mlen = mxGetM(prhs(1))
nlen = mxGetN(prhs(1))
mnmax = max(mlen, nlen)
if( mnmax > len(dfile) ) mnmax = len(dfile)
dfile = ' '
flag = mxGetString(prhs(1),dfile,mnmax)
do i = 1,nFDTParField
ivField(i) = FDTParField(FDTParFieldNumber(i))
enddo
m = 1
plhs(m) = mxCreateStructMatrix(m, m, nFDTParField,ivField)
pS = plhs(m)
mn = 0
call CopyIntScalarToMatlabStruct (pS, mn+1,o_Mode)
call CopyRealScalarToMatlabStruct(pS,mn+2,o_Start)
call CopyRealScalarToMatlabStruct(pS,mn+3,o_Spacing)
call CopyIntScalarToMatlabStruct(pS,mn+4,o_nFreq)
call CopyIntScalarToMatlabStruct(pS,mn+5,o_nStation)
call CopyRealScalarToMatlabStruct(pS,mn+6,o_AppRMin)
call CopyRealScalarToMatlabStruct(pS,mn+7,o_AppRMax)
call CopyRealScalarToMatlabStruct(pS,mn+8,o_FreqMin)
call CopyRealScalarToMatlabStruct(pS, mn+9, o_FreqMax)
call CopyRealVectorToMatlabStruct(pS, mn+10, o_Freq,o_nFreq)
call CopyIntVectorToMatlabStruct (pS, mn+11, o_Station,o_nStation)
call CopyRealVectorToMatlabStruct(pS, mn+12, o_StationX,o_nStation)
call CopyRealVectorToMatlabStruct(pS, mn+13, o_StationDX,o_nStation-1)
call CopyRealScalarToMatlabStruct(pS, mn+14, o_AppRLogMean)
dims(1) = o_nStation
dims(2) = o_nFreq
dims(3) = 2
ComplexFlag = 0
m = 2
n = 3
plhs(m) = mxCreateNumericArray(n, dims,mxClassIDFromClassName('double'),ComplexFlag)
pS = plhs(m)
call CopyReal3DMatToMatlab(pS,o_AppR,o_nStation,o_nFreq,m)
plhs(n) = mxCreateNumericArray(n, dims,mxClassIDFromClassName('double'), ComplexFlag)
pS = plhs(n)
call CopyReal3DMatToMatlab(plhs(n),o_AppP,o_nStation,o_nFreq,m)
return
end
!*************************************************************************************
subroutine CopyReal3DMatToMatlab(ptr,value,n1,n2,n3)
mwSize n1, n2, n3
real*8 value(n1,n2,1)
real*8, allocatable::tmp(:,:,:)
mwpointer, external :: mxGetPr
mwpointer ptr
if (allocated(tmp)) deallocate(tmp)
allocate(tmp(n1,n2,n3))
tmp=0.
do i=1,n1
do j=1,n2
do k=1,n3
tmp(i,j,k) = dble(value(i,j,k))
enddo
enddo
enddo
call mxCopyReal8ToPtr(tmp,mxGetPr(ptr),n1*n2*n3)
if (allocated(tmp)) deallocate(tmp)
return
end
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!