加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

批处理fortran77转fortran90格式,解决老程序不兼容问题

(2018-12-25 22:31:33)
标签:

教育

软件技术

分类: FORTRAN

由于f77不支持可变数组,导致想添加的功能不能实现,于是想把整个工程从77转成90。有同学推荐,直接在f77的模式下强行把f90的功能加进去(比如可变数组,module等),然后用gfortran编译也能通过运行。我自己做了小测试发现可变数组确实可以运行,但是不推荐,毕竟不规范!
    
说回正题,f77f90倒是有一个比较好的网站可以转,而且还能在线转,网址:http://quill.fcode.cn/ 。但是网上转有一点不方便,不能批量转换,对文件大小也有限制。所以就上google上找了,主要找到了一下几个:

1. f77tof90, a Bourne shell script for dealing with non-standard F77 code. It converts Record and Structure F77 extensions into F90 Type statements. It also converts C-preprocessed #include statements into Fortran INCLUDE statements. Written by Jack Scheible.

用于处理非标准F77代码的Bourne shell脚本。 它将RecordStructure F77扩展转换为F90 Type语句。 它还将C预处理的#include语句转换为Fortran INCLUDE语句。 Jack Scheible撰写。
网址:www.soton.ac.uk/~fortran/tools/f77tof90/f77tof90.html

2. convert.f90, written by Mike Metcalf.
网址:ftp://ftp.numerical.rl.ac.uk/pub/MandR/convert.f90

3.to_f90.f90, written by Alan Miller.
网址:users.bigpond.net.au/amiller/to_f90.f90

4.ftof90.c, for converting comments and continuation lines, written by Michael Olagnon.

ftof90.c,用于转换注释和延续线,由Michael Olagnon编写。
网址:ftp://ftp.ifremer.fr/ifremer/ditigo/fortran90/ftof90.c.gz

5.
f2f is a Perl script which does much of the tedious work of converting Fortran 77 source code into Fortran 90/95 form. There seems to be a lot of Fortran hate in the world, and I think this comes from people who have been forced to use Fortran 77 at some time or another. Hopefully, this program will make you a less hateful person.

f2f是一个Perl脚本,它完成了将Fortran 77源代码转换为Fortran 90/95格式的大量繁琐工作。 世界上似乎有很多Fortran的仇恨,我认为这来自那些在某个时间被迫使用Fortran 77的人。 希望这个程序会让你成为一个不那么讨厌的人。
网址:https://bitbucket.org/lemonlab/f2f/

6. fortran_tools-master
,一个python的项目
项目主页:https://github.com/arktools/fortran_tools

    
这六个我都试了一下,大部分的效果都不太理想(可能不同程序效果不一样,大家踊跃尝试)。其中第4个算是比较稳定的,因为它好像修改的部分最少,仅对换行符,注释符进行了修改,不改变程序原有的goto语句。所以我选用了第四个,但是目前除了python那个是批处理的,其他都不是,没办法,只能自己动手。使用的方法说明如下:
   1).
ftof90.c的源文件与read.bat的源文件放在同一个目录
   2).
编译ftof90.c,注意生成的可执行文件名一定要是ftof90.exe
   3).
把所有要转换的.f文件都复制到本目录下,!!!此一定要留.f备份
   
4). 双击read.batwindows下),会生成一个新的run.bat
   5). 
执行run.bat,大功告成!

    
以上所有提到的源程序都打包传到了网盘,

    地址:https://pan.baidu.com/s/1chZotASV344iWohMKVJayg   密码:vx5i

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有