MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: mathematica & fortran ??

  • To: mathgroup at
  • Subject: [mg71479] Re: mathematica & fortran ??
  • From: "gkruger" <gkruger at>
  • Date: Mon, 20 Nov 2006 06:17:12 -0500 (EST)
  • References: <ejjvg3$l3f$><ejmkj9$gdp$>


if you want to use mathematica inside fortran, using linux you can use
scripts to execute an notebook in command line.

this in fortran code:
call system("scriptname")

run the notebook, saved in .m form, and produce output in file m2
$dir/MathKernel < $(where the .m file is)/math1.nb.m > m2

get output and just write the number in m3
grep 'Out' m2 | cut -f 2 -d' ' > m3

fortran code:
wait till the file m3 exists and read the number.

This is a little bit constructed but it works. You just have to test
wich outpur form is the best for importing in fortran with the high
precision you want.



On 18 Nov., 10:43, "Beliavsky" <beliav... at> wrote:
> fish wrote:
> > I have been using the software of Mathematica for 2 years. It is a
> > good software.
> >    Those days, I meet a difficulty. I compile a program, which is
> > written in Fortran language. In it, there is a Bessel function. I want
> > to get the high precision value of the function. Unfortunately, I
> > failed.
> >    As we know, the software of Mathematica supplies the Bessel function
> > with high precision. So I want to ask whether we can run the two
> > softwares, Mathematica and Fortran language, simultaneously? Then I can
> > directly use the Bessel function in Mathematica for my Fortran program.A Fortran solution could be to find a compiler that supports quadruple
> precision (16 byte floating point variables) or 10-byte reals. Then you
> could either change the code to use quadruple precision or (depending
> on the compiler) invoke a compiler switch that automatically promotes
> double precision variables to quadruple precision. The Lahey/Fujitsu
> compiler has the -quad option. If you want to try this route, the best
> newsgroups for follow-up questions would be comp.lang.fortran and/or
> sci.math.num-analysis.

  • Prev by Date: Re: Summations in a Text Cell
  • Next by Date: Best practice for naming of options
  • Previous by thread: Re: mathematica & fortran ??
  • Next by thread: Rectangle with Scaled (a plot inside a plot)