Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: MEX EXAMPLE not working .. URGENT please
Date: Wed, 20 Feb 2008 01:21:11 +0000 (UTC)
Organization: Boeing
Lines: 43
Message-ID: <fpfva7$1n0$1@fred.mathworks.com>
References: <fpflmf$6nl$1@fred.mathworks.com> <fpfte4$a1j$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1203470471 1760 172.30.248.35 (20 Feb 2008 01:21:11 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 20 Feb 2008 01:21:11 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:452545



"James Tursa" <aclassyguywithaknotac@hotmail.com> wrote in 
message <fpfte4$a1j$1@fred.mathworks.com>...
> 
> timestwo.F works fine for my R2007a and Intel 9.1. It 
may 
> be that you are using an older version of MATLAB where 
the 
> header file fintrf.h does not define mwpointer or mwsize 
> (they used to be just integer*4). So after the 
> #include "fintrf.h" line, add these lines:
> 
> #ifndef mwpointer
> #define mwpointer integer*4
> #endif
> 
> #ifndef mwsize
> #define mwsize integer*4
> #endif
> 
> That way, if they are not defined then your code will 
> define them before using them.
> 
> James Tursa
> 

Follow-up:  The code works, but only if the input is a 
scalar. The code has bugs for other sizes. In particular, 
this line:

      call mxCopyPtrToReal8(x_pr,x,size)

will cause memory beyond x (which is only one element with 
8 bytes) to be overwritten with whatever x_pr is pointing 
to. Something is being clobbered here, and this will cause 
unpredictable results.

Also, from a good practise standpoint, "size" should not 
be used as a variable name since it is the name of a 
Fortran intrinsic function.

James Tursa