MathGroup Archive 1995

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

Search the Archive

Re: using Math Link w/FORTRAN

  • To: mathgroup at
  • Subject: [mg2386] Re: using Math Link w/FORTRAN
  • From: wagner at (Dave Wagner)
  • Date: Tue, 31 Oct 1995 23:22:58 -0500
  • Organization: University of Colorado, Boulder

In article <471hhl$gb3 at>,
peter becker <pbecker at> wrote:
>Perhaps this is a stupid question, but is there any way to
>use Math Link with a FORTRAN application on the Macintosh
>(system 7.1)?  In particular, I want to make plots within
>Mathematica using data computed externally by a FORTRAN
>application.  This involves passing parameters out to the
>FORTRAN code, and data back into Mathematica.  Any help
>would be most appreciated...

At a minimum, you need to do the following:

    1.  Transpose any matrix data before sending it across
	the link, and Transpose the results after they come
	back.  (You could do this in the MathLink code, but
	why bother when Mathematica can do it for you?

    2.  Depending on the fortran compiler that you use,
	the procedure calling convention may different than that used
	by C.  C  compilers push parameters onto a stack, whereas many
	(most?) FORTRAN compilers do not.  To get around this problem,
	if you have it, you need to declare the arguments taken by the
	Fortran routine (in the mprep template file) in the reverse
	order in which they actually are declared in the fortran code.

    3.  You'll need a main routine that calls MLMain.  It's probably
	easiest to write this in C, as you can copy it directly from
	the MathLink manual.  You're going to need a C compiler anyway,
	because mprep creates a C source file.  Of course, you can
	bypass mprep and do it all yourself in Fortran, but that would
	be a helluva lot of work.

    4.  As far as linking the Fortran object files with the C
	object files: on a UNIX system it would be no problem, but on
	the Macintosh it would depend on the particular development
	environments that you are using.  You're pretty much on your
	own here...    I believe that the MPW shell can do it, if
	you have both a Fortran and a C compiler that can be used
	from the shell.  If you don't already have this, you will
	need to "shell" out (ha-ha) quite a bit of money.

		Dave Wagner
		Principia Consulting
		(303) 786-8371
		dbwagner at

  • Prev by Date: Re: using Math Link w/FORTRAN
  • Next by Date: Comparison of MMA on Various Machines
  • Previous by thread: Re: using Math Link w/FORTRAN
  • Next by thread: Comparison of MMA on Various Machines