Path: news.mathworks.com!newsfeed-00.mathworks.com!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!feeder.erje.net!aioe.org!not-for-mail
From: dpb <none@non.net>
Newsgroups: comp.soft-sys.matlab
Subject: Re: MEX FORTRAN programming
Date: Wed, 24 Oct 2007 14:23:32 -0500
Organization: Aioe.org NNTP Server
Lines: 40
Message-ID: <ffo69s$2pf$1@aioe.org>
References: <ffnt1c$5fk$1@fred.mathworks.com>
NNTP-Posting-Host: lZ17/14FQQm6uRHAjFTL5A.user.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Thunderbird 2.0.0.6 (Windows/20070728)
Xref: news.mathworks.com comp.soft-sys.matlab:434470



Weijie wrote:
...
> In Matlab, I would like to call
> M>[r1,r2...]=myfnc(v1,str1,str2,par1,par2,mpar1,mpar2,mpar3...)
> where myfnc is a compiled MEX function that use mexFunction
> and old Fortran code to do the computation task; v1 is a
> vector parameter, str1 and str2 are two strings representing
> the names of two Matlab functions (.m files). par1 and par2
> are other parameters to myfnc; mpar1,mpar2...are input
> arguments to str1.m and str2.m (assume they have exactly the
> same arguments). In the mex function, I'll call a Fortran
> function (previously developed and tested):
> 
> call oldfnc(n, d, x, objf, objg, iv, liv, lv, v, uip,urp,ufp)
> 
> where objf and objg are two Fortran functions and uip, urp,
> and ufp are user-defined parameters input to objf and objg.
> 
> Now, in the Fortran functions objf and objg that I define, I
> would like to use mexCallMATLAB(...) to call str1.m and
> str2.m respectively. 
> 
> It's easy to see that once I done all these, the users can
> define their own str1.m and str2.m and call myfnc to do
> thier job using the old Fortran package.
> 
> The key difficulty is that: how to transfer mpar1,
> mpar2...to uip, urp, and ufp in mes function AND then, in
> objf and objg, how to transfer uip, urp, and ufp to input
> arguments of mexCallMATLAB function?
> 
> Thanks a million! I'd share my experience once I complete
> this project.

The parameters to the called function would have to be wrapped in 
mxArray per the calling protocol as expected by mexCallMATLAB.  The user 
parameters and functions have to be aware of the expectations on both 
the caller and the callee side.  Other than that, I don't see the problem?

--