I'm interested in calling fortran codes in a Mathematica session. I learn that Mathlink offers a way to do that. But I have little knowledge on C and nothing on C++. Is anybody willing to give me a detailed example?
I'm using with Mathematica 8, MS Visual Studio 2008 and Intel Fortran 11. The system is Windows 7 Home Premium.
Many thanks!
The following is an explicit example which I succeeded using gfortan and gcc with the Windows system:
I found this blog Adventures in Mathlink. It is helpful with a specific example. I installed MinGW in order to use gfortran and gcc. After installation, one must set PATH in order to use gfortran and gcc without typing the path each time. A tip for adding PATH without restarting the system: After adding the PATH, open cmd, and run
set PATH=C:Then close cmd, whenyou open it again, withecho %PATH%, you will see the new path list. I followed the steps in the linked blog, adapted to Windows, with the tutorial example addtwo:The Mathematica codes writing a .bat file and running it to generate the executable
FORTRAN codes addtwo.f
C wrapper addtwo.c
The template file addtwo.tm is the same as the one in Todd Gayley's tutorial. For completeness, it is also given here: