Re: Bi-directional MathLink to Fortran
- To: mathgroup at smc.vnet.net
- Subject: [mg17440] Re: Bi-directional MathLink to Fortran
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Sun, 9 May 1999 04:43:49 -0400
- Organization: Universitaet Leipzig
- References: <7grh38$e4f@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, my first advice is: translate the FORTRAN routines to C with f2c (from www.netlib.org). This will resolve the item 2+4+5. The call back to Mathematica inside a ML-function call is with out any problems. I have a ContourPlot3D[] replacement inside a C-program that calls back to Mathematica and you may mail me if you would like to have the source code. This will help you with item 1. For item 1) I can tell you that I write typical two functions one that pass the data/parameter to the MathLink child and one that force the evaluation of something. You must be carefull, that Mathematica call the two functions in the correct order but typical you must create a "nice" Mathematica interface to the bare C-functions Mail me direct if you need additional help Regards Jens Dr Dan wrote: > > I am trying to use a Fortran routine to integrate a set of equations formed in > a Mathematica notebook (before you ask, Mathematica cannot solve these > equations by itself. Mathematica does not support Differential Algebraic Equations > [yet?]) This cannot be an unusual task, but it gets messy quickly. Can > anybody point me to an example where something like this has been done? > > Here are some reasons why the details are messy: > > 1. Since I form the equations in Mathematica, the integration routine must be > able to call Mathematica back for function evaluations. > > 2. The integration routine is in Fortran, so I need C wrappers both ways. > > 3. The integration routine is called several times; I don't want the overhead > of allocating arrays each time it is called. I also can't have memory leaks. > > 4. Linker conflicts between MS Visual C++ 5 and MS Fortran Powerstation > Windows libraries. > > 5. Here's the kicker: this is the first time I've needed to use MathLink. > > None of these are insurmountable. However, if I had an example to follow it > might save me a week or two. Any help would be appreciated. > > -----------== Posted via Deja News, The Discussion Network ==---------- > http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own