COMPILER_OPTIONS()应该在Fortran中返回什么? [英] What should COMPILER_OPTIONS() return in Fortran?

查看:213
本文介绍了COMPILER_OPTIONS()应该在Fortran中返回什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Fortran 2008添加了一个名为COMPILER_OPTIONS()的新程序,该程序根据 GNU文档

a>应该返回一个字符串,其中包含用于编译文件的选项。根据 Fortran 2003状态wiki ,几乎所有的编译器,包括GNU和PGI,都似乎支持此功能。



我创建了一个简单的程序 COMPILER_OPTIONS.f08 显示如下

 使用iso_fortran_env 
print'(4a)','这个文件是使用options'编译的,compiler_options()
end

下面是我从 gfortran 和<$ c没有编译时间选项的Gfortran 5.4


$ b

$ b

  $ gfortran COMPILER_OPTIONS.f08&& ./a.out 
这个文件是通过使用选项-mtune = generic -march = x86-64



Gfortran 5.4与-O3在编译时通过

  $ gfortran -O3 COMPILER_OPTIONS.f08&& ./a.out 
使用选项-mtune = generic -march = x86-64 -O3

$ b $编译此文件b

PGI 17.4没有在编译时通过的选项

  $ pgfortran COMPILER_OPTIONS.f08&& ./a.out 
这个文件是使用COMPILER_OPTIONS.f08

PGI 17.4 with -O3在编译时通过

  $ pgfortran -O3 COMPILER_OPTIONS.f08&& ./a.out 
使用选项COMPILER_OPTIONS.f08 -O3 -Mvect = sse -Mcache_align -Mpre

$ b编译此文件
$ b

鉴于上述输出,我有以下问题:
$ b $ ol

  • 什么是COMPILER_OPTIONS每Fortran 2008?

  • b

    编辑 strong>:从-o3(输出文件3)将标志更改为-O3(优化级别3)。感谢Pierre和francescalus的反馈。 解决方案

    Fortran 2008描述了函数(13.8.2.6):


    $ b


    描述控制程序转换阶段选项的处理器相关字符串。

    这个函数返回一个默认字符标量和处理器相关的长度。



    编译器的自由度非常大。这里提供的结果没有迹象表明任何违规行为。

    Fortran 2008 added a new procedure called COMPILER_OPTIONS() which according to GNU documentation should return a string with the options used for compiling the file. According to Fortran 2003 status wiki, almost all compilers including GNU and PGI seem to support this feature.

    I created a simple program COMPILER_OPTIONS.f08 shown below

    use iso_fortran_env
       print '(4a)', 'This file was compiled by using the options ', compiler_options()
    end
    

    Here are my results from gfortran and pgfortran

    Gfortran 5.4 with no compile time options

    $ gfortran COMPILER_OPTIONS.f08 && ./a.out 
    This file was compiled by using the options -mtune=generic -march=x86-64
    

    Gfortran 5.4 with -O3 passed at compile time

    $ gfortran -O3 COMPILER_OPTIONS.f08 && ./a.out 
    This file was compiled by using the options -mtune=generic -march=x86-64 -O3
    

    PGI 17.4 with no option passed at compile time

    $ pgfortran COMPILER_OPTIONS.f08 && ./a.out 
    This file was compiled by using the options COMPILER_OPTIONS.f08 
    

    PGI 17.4 with -O3 passed at compile time

    $ pgfortran -O3 COMPILER_OPTIONS.f08 && ./a.out 
    This file was compiled by using the options COMPILER_OPTIONS.f08 -O3 -Mvect=sse -Mcache_align -Mpre 
    

    Given the above output, I have following questions

    1. What is COMPILER_OPTIONS() procedure expected to return as per Fortran 2008?
    2. What is the status of support across different compilers?

    EDIT : Changed flag to -O3 (Optimization Level 3) from -o3 (Output file 3). Thanks to the feedback from Pierre and francescalus.

    解决方案

    Fortran 2008 describes the function as (13.8.2.6):

    Processor-dependent string describing the options that controlled the program translation phase.

    This function returns a "default character scalar with processor-dependent length."

    That's an awful lot of freedom for a compiler. There's no indication from the results presented here to suggest any non-compliance.

    这篇关于COMPILER_OPTIONS()应该在Fortran中返回什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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