如何在 Mathematica 中使用 FORTRAN 子例程或函数?
我有兴趣在 Mathematica 会话中调用 fortran 代码。我了解到 Mathlink 提供了一种方法来做到这一点。但我对C知之甚少,对C++也一无所知。 有人愿意给我一个详细的例子吗?
我使用的是 Mathematica 8、MS Visual Studio 2008 和 Intel Fortran 11。系统是 Windows 7 Home Premium。
非常感谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面是我在Windows系统上使用gfortan和gcc成功的一个明确的例子:
我发现了这个博客Mathlink 中的冒险。
举一个具体的例子会很有帮助。我安装 MinGW 是为了使用 gfortran 和 gcc。安装后,必须设置 PATH 才能使用 gfortran 和 gcc,而无需每次都输入路径。无需重启系统即可添加PATH的小技巧:添加PATH后,打开cmd,运行
set PATH=C:
然后关闭cmd,再次打开时,用echo %PATH%< /code>,您将看到新的路径列表。我按照链接博客中的步骤进行操作,适用于 Windows,并使用教程示例 addtwo:
Mathematica 代码编写 .bat 文件并运行它以生成可执行的
FORTRAN 代码 addtwo.f
C 包装器 addtwo.c
模板文件addtwo.tm 与Todd Gayley 教程中的相同。为了完整起见,这里也给出了:
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: