从Java调用Fortran子例程 [英] Calling a Fortran subroutine from Java

查看:137
本文介绍了从Java调用Fortran子例程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用Fortran编写的巨大子程序,需要在Java程序中使用。我怎么称呼它?我使用的是Ubuntu 10.04.

I have a huge subroutine written in Fortran that I need to use in a Java program. How can I call it? I am using ubuntu 10.04.

推荐答案

@extraneon引用您的论文是我将Fortran子例程集成到Java计划几年前。但是,如果今天我再次尝试这样做,我会考虑使用Fortran 2003标准中定义并由最近版本的某些编译器实现的C< em>的互操作性。我希望我可以编译Fortran子程序来查看JNI,就像它用C编写的一样。这样你就可以切出C包装。

The paper that @extraneon refers you to is the way I integrated a Fortran subroutine into a Java program a couple of years ago. However, if I was trying to do it again today I would look into using the interoperability with C features which are defined in the Fortran 2003 standard and implemented by recent versions of some compilers. I hope that I could compile the Fortran subroutine to look, to JNI, like it was written in C. This way you could cut out the C wrapper.

如果你的编译器没有实现与C特性的互操作性,沟渠和获得一个。

And if your compiler doesn't implement the interoperability with C features, ditch and get one that does.

编辑:另一个想法发生在我身上:如果Fortran子程序的执行时间很长,您应该考虑通过让Java将某些输入数据放入文件并修改Fortran以从文件中获取输入来考虑将其与Java集成。然后Java程序可以调用系统来启动Fortran。以相同的方式传回结果。这是一个真正的混乱,但你可能会发现比通过JNI更容易实现。此外,您可以将此作为一个权宜之计,同时与JNI和互操作性等进行斗争。

another thought occurs to me: If the Fortran subroutine is huge in its execution time you should think about integrating it with Java by having Java put some input data into a file, and modifying the Fortran to get its inputs from the file. Then the Java program could make a call to the system to start the Fortran. Pass back the results in the same way. This is a real kludge, but you will probably find it easier to implement than going via JNI. Furthermore, you could implement this as a stop-gap while you wrestle with JNI and interoperability etc.

这篇关于从Java调用Fortran子例程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆