gfortran 如何判断我是在编译 f90 还是 f95 代码? [英] How can gfortran tell if I am compiling f90 or f95 code?

查看:95
本文介绍了gfortran 如何判断我是在编译 f90 还是 f95 代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 gfortran 可以编译 f90 或 f95 吗?它怎么知道它正在编译哪一个?它也可以编译f77代码吗?ubuntu 已经有 fortran 编译器还是需要下载 gfortran?

I understand gfortran can compile f90 or f95? How does it know which one it is compiling? Also can it compile f77 code? Does ubuntu already have a fortran compiler or do I need to download gfortran?

推荐答案

gfortran 可以从文件扩展名中猜出某些东西;如果文件具有 .f、.f90、f95、.f03 或 .f08 的扩展名,它将采用具有适当标准的固定 (.f) 或自由格式.但是您可以使用选项 -std=f2003 强制它编译(比如说)fortran2003 代码.例如,来自 文档

gfortran can guess certain things from the file extension; if the file has an extension of .f, .f90, f95, .f03, or .f08 it will assume fixed (.f) or free format with the appropriate standards. But you can force it to compile (say) fortran2003 code with the option -std=f2003. Eg, from the documentation,

-std=std

指定程序期望遵循的标准,可以是f95f2003f2008之一f2018gnulegacy.std 的默认值为 gnu,它指定了最新 Fortran 标准的超集,其中包括 GNU Fortran 支持的所有扩展,但会针对过时的扩展发出警告不建议在新代码中使用.legacy 值是等效的,但没有过时扩展的警告,并且可能对旧的非标准程序有用.f95f2003f2008f2018 值指定严格遵守 Fortran 95、Fortran 2003、Fortran分别为 2008 和 Fortran 2018 标准;超出相关语言标准的所有扩展都会出现错误,并且会为 Fortran 77 功能提供警告,这些功能在以后的标准中被允许但已过时.-std=f2008ts 允许 Fortran 2008 标准,包括添加关于 Fortran 与 C 的进一步互操作性的技术规范 (TS) 29113 和关于 Fortran 中的其他并行功能的 TS 18508.

Specify the standard to which the program is expected to conform, which may be one of f95, f2003, f2008, f2018, gnu, or legacy. The default value for std is gnu, which specifies a superset of the latest Fortran standard that includes all of the extensions supported by GNU Fortran, although warnings will be given for obsolete extensions not recommended for use in new code. The legacy value is equivalent but without the warnings for obsolete extensions, and may be useful for old non-standard programs. The f95, f2003, f2008, and f2018 values specify strict conformance to the Fortran 95, Fortran 2003, Fortran 2008 and Fortran 2018 standards, respectively; errors are given for all extensions beyond the relevant language standard, and warnings are given for the Fortran 77 features that are permitted but obsolescent in later standards. -std=f2008ts allows the Fortran 2008 standard including the additions of the Technical Specification (TS) 29113 on Further Interoperability of Fortran with C and TS 18508 on Additional Parallel Features in Fortran.

请注意,除了少数例外,fortran 标准是高度向后兼容的,因此很多不错"、符合标准的 fortran-77 代码也是有效的 fortran 2003 代码.主要问题是 80 年代及更早的许多 fortran 代码既不好"也不符合标准.

Note that, with a few exceptions, the fortran standards are highly backwards-compatable, so that much "nice", standard conforming, fortran-77 code is also valid fortran 2003 code. The main problem with that is that much fortran code from the 80s and earlier is neither "nice" nor standard-conforming.

这篇关于gfortran 如何判断我是在编译 f90 还是 f95 代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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