Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: mxGetNumberOfDimensions missing ?
Date: Wed, 21 Oct 2009 21:39:20 +0000 (UTC)
Organization: Boeing
Lines: 69
Message-ID: <hbnv28$c5h$1@fred.mathworks.com>
References: <2009102112385016807-spammersgohere@spaminvalid>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1256161160 12465 172.30.248.37 (21 Oct 2009 21:39:20 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 21 Oct 2009 21:39:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:579115


Geico Caveman <spammers-go-here@spam.invalid> wrote in message <2009102112385016807-spammersgohere@spaminvalid>...
> Mac OSX 10.5.6
> Matlab R2009a
> 
> gfortran/gcc
> 
> Code fragment:
> 
> subroutine mexFunction(nlhs, plhs, nrhs, prhs)
>   use matlabmex
> 
>   implicit none
>   
>   integer, intent(in) :: nlhs, nrhs
>   integer, intent(in), dimension(:), pointer :: prhs
>   integer, intent(out), dimension(:), pointer :: plhs
> 
>   integer(i4b) :: l,m,n
>   integer(i4b), pointer :: n1
>   integer(i4b), pointer :: A
>   
>   if(nrhs /= 2) then
>      call mexErrMsgTxt('Function requires four input arguments.');
>   end if
>   
>   A = mxGetData(prhs(1))       
>   n1 = mxGetDimensions(prhs(1))
>    
> end subroutine mexFunction
> 
> 
> matlabmex.f90 contains:
> 
> integer (kind=4) function mxGetData(pm)
>      use constants 
>      integer (kind=4)  :: pm
>    end function mxGetData
> 
>    integer (kind=4) function mxGetDimensions(pm)
>      use constants 
>      integer (kind=4)  :: pm
>    end function mxGetDimensions
> 
>    integer(kind=4) function mxGetNumberOfDimensions(pm)
>      use constants
>      integer(kind=4) :: pm
>    end function mxGetNumberOfDimensions
> 
> in the interface block.
> 
> Compilation:
> 
> /Applications/MATLAB2009a/MATLAB_R2009a.app/bin/mex -maci mexFunction.f90
> Undefined symbols:
>   "_mxgetdimensions_", referenced from:
>       _mexfunction_ in mexFunction.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
> 
>     mex: link of ' "mexFunction.mexmaci"' failed.
> 
> It can find mxGetData() but not mxGetNumberOfDimensions()
> 
> I have checked my matlab documentation to confirm that the function exists.

Before I make more comments, I would like a few things cleared up. I have never seen this type of mex programming before. It looks like you are attempting to define an interface for the mx functions in a module. And in that module you have functions with the same name as the MATLAB API functions. e.g., let's start with the function mxGetNumberOfDimensions. Is the code you show a function contained in the module, or is it part of an interface definition? What you have shown is not at all clear on this. How is the connection to the actual function in the MATLAB library actually made? And then there is the mxGetDimensions function. The MATLAB API function for this returns an integer*4 on a 32-bit system (used for storing a 32-bit address). You are apparently attempting to get this result, and then return it as an actual Fortran integer pointer type. Is that correct? And then there is the 
prhs and plhs definitions that you have. You declared them as pointers to integers. Is that really what you intended? What is the point (no pun intended) of this? 

James Tursa