Re: Good Day
- To: mathgroup at smc.vnet.net
- Subject: [mg9671] Re: [mg9638] Good Day
- From: seanross at worldnet.att.net
- Date: Fri, 21 Nov 1997 01:31:09 -0500
- Sender: owner-wri-mathgroup at wolfram.com
hashemi at sun.iust.ac.ir wrote: > > Dear Sir: > > I would like to know if there is any way to call mathematica functions > (like Bessel Functions) from a FORTRAN program and vice-versa (i.e., to > use mathematica to compute some functions in my own FORTRAN program). > Also, is there anyway to compute Mathieu, Weber, and Spheroidal > functions of complex argument using mathematica and subsequently use > these values in our FORTRAN code? I will be very happy to hear from > you soon. > > Thank You > > S. M. Hasheminejad There are two ways: Mathlink(maybe) and by using mathematica as a shell. If your fortran compiler is one of those that is actually written in C, like Microsoft Fortran, then you can use the C protocols and use Mathlink, but you will have to rely on your Microsoft C manuals to tell you how to use the C components to call C subroutines. The C subroutines you want to call are the mathlink subroutines described in the mathlink developers kit that comes with the professional versions of Mathematica. Getting mathlink to work is not trivial and there have been many frustrated users attempting it that have posted messages to this forum. I personally have not had the need to do it yet. There is another way to "link" programs without using mathlink and that is through files. The mathematica "Run" command allows you to use mathematica like a shell and run external programs. For example, I have a Fortran program that reads in a data file. Pre-mathematica, I had to assemble the data file by hand. Now, I make a mathematica function which writes the data file for me, then calls the fortran program which writes its output to a file. The mathematica program reads in the results of the file, then computes the least squares error between my experimental data and the results of the fortran program. The whole thing is wrapped in a minimization routine to essentially get a least squares fit of my data to theory. I do this in mathematica, even though the theory was written by someone else, in Fortran. The drawback to this method is that mathematica must be your "main" program rather than the Fortran program. Just a thought: Do you have a need for speed in your application? If blinding speed is not your concern, then why not write your whole program in mathematica? There is nothing that can be done in Fortran that can't be done more conveniently in mathematica, though mathematica does execute much more slowly. -- Remove the _nospam_ in the return address to respond.