Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29274 Discussions

How to put expression from Maple/Mathematica into Fortran?

leo_vortex
Beginner
1,305 Views

I need to put some symbolic expressions, computed in Maple 8(or Mathematica 5) into Fortran program. How "to hook" them?

I use Visual Compaq Fortran 6.5

Thank you

Message Edited by Leo_vortex on 07-21-2004 08:32 PM

0 Kudos
6 Replies
ArturGuzik
Valued Contributor I
1,305 Views
I'm not quite sure it's that what you mean/intend to do - in Maple you have command CodeGeneration [Fortran] with several options, which translates expressions into Fortran77 (function/subroutine) code.
A.
0 Kudos
durisinm
Novice
1,305 Views
I don't know what you mean by "to hook" them. It might help you to look at Mathematica's FortranForm command to write out an expression for Fortran. You might also check into Mathematica's MathLink facilities for communicating between Mathematica and other languages.
Mike D.
0 Kudos
leo_vortex
Beginner
1,304 Views

What I need is to compute rather bulky indefinite integral in Maple/Mathematica and then to use it in my Fortran program
for some numerical solving.
I don't want to write it in Fortran, because it's really big and complicated. SotheFortran program has to read data from
Maple/Math.
0 Kudos
ArturGuzik
Valued Contributor I
1,304 Views
Leo,
I believe you can access Maple routines via OpenMaple (API calls, in C). Take a look at examples in Maple/Samples/OpenMaple/ directory and simple in particular (evaluates an integral). The description reads:
This example program illustrates how to use the OpenMaple API to initialize the Maple kernel and compute with it.Users are encouraged to use and modify this code as a startingpoint for learning the OpenMaple API.
Or maybe you will needa simple write/save to command to save the session and results to a file and then read the values in Fortran. Depends on your applications.
A.
0 Kudos
leo_vortex
Beginner
1,304 Views
There is no such directory
X:/Program Files/ Maple/Samples/OpenMaple/ in my system.
Wehave maple 8. :robotsad:
0 Kudos
ArturGuzik
Valued Contributor I
1,304 Views
OK. Sorry for that. I overlooked that you wrote it was Maple 8. I have Maple 9 installed, and just checked that this (OpenMaple) is listed as the new feature (lots of examples and documented APIs). Well, so you're left with two options, I believe: one is to translate into Fortran source code (I used it for really complicated expressions - you don't do anything - just copy, paste, and compile)and the second tofindcommand what saves your results to the file and then read them back to your application.
A.
PS. Maybe in Maple 8 you can call external routine which would do some formatting for you and export to your code.
0 Kudos
Reply