Path: news.mathworks.com!not-for-mail
From: "Weijie " <mricad@yahoo.no000spppam.com>
Newsgroups: comp.soft-sys.matlab
Subject: MEX FORTRAN programming
Date: Wed, 24 Oct 2007 16:48:44 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 37
Message-ID: <ffnt1c$5fk$1@fred.mathworks.com>
Reply-To: "Weijie " <mricad@yahoo.no000spppam.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1193244524 5620 172.30.248.38 (24 Oct 2007 16:48:44 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 24 Oct 2007 16:48:44 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 544673
Xref: news.mathworks.com comp.soft-sys.matlab:434441



This is probably a least discussed/documented topic, but it
could be very useful as we have so many (old) Fortran code
in scientific computation and we have so few Fortran
programmers nowadays. I'm posting here on what I plan to do
and your experience/hints may save my time.

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.