Fortran语言转换为C或C ++ [英] Convert Fortran to C or C++

查看:1683
本文介绍了Fortran语言转换为C或C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些数字code,我需要转换为C或C ++。我试着用F2C,但它不会对Fortran的code工作。 F2C抱怨,因为code采用C风格的preprocessor指令(#包括)。
在code的自述说,它是的Fortran77,这与fort77链接器配合工作,这将扩大这些包括

I have some numeric code that I need to convert to C or C++. I tried using f2c, but it won't work on the Fortran code. f2c complains because the code uses C style preprocessor directives (#include). The code's readme states that it is Fortran77, that works with the fort77 linker, that would expand those includes.

有谁知道如何成功地转换这个code?

Does anyone know how to successfully convert this code?

我的最后一招是编写一个简单的preprocessor扩大这些包括,然后喂code至F2C。

My last resort is to write a simple preprocessor to expand those includes and then feed the code to f2c.

请注意:I'm在Windows / Visual C ++环境在这里工作,所以任何GCC有心计很可能是更多的麻烦比他们的价值...

Note: I´m working in a Windows/Visual C++ environment here, so any gcc shenanigans would probably be more trouble than they are worth...

推荐答案

我在一个工程研究小组工作多年。我们从来没有好运气做自动转换从Fortran语言到C的code不是特别理解,这是难以维持。使用Fortran的code作为算法模板,做一个重新实施任何我们希望继续使用我们的好运了。或者,你可以更新Fortran语言使用更现代的Fortran语言的结构和得到了很多,你会移动到C / C ++得到同样的价值。我们也有一些成功的调用由C Fortran例程,尽管调用约定的差异有时使事情困难的。

I worked in an engineering research group for many years. We never had good luck doing automated conversions from Fortran to C. The code was not particularly understandable and it was hard to maintain. Our best luck was using the Fortran code as a template for the algorithm and doing a re-implementation for anything that we expected to continue using. Alternatively, you could update the Fortran to use more modern Fortran constructs and get a lot of the same value that you would get from moving to C/C++. We also had some success calling Fortran routines from C, although the calling convention differences sometimes made things difficult.

这篇关于Fortran语言转换为C或C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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