代码之家  ›  专栏  ›  技术社区  ›  Qualia

我如何让gfortran或ifort告诉我它隐式地将REAL(4)提升为REAL(8)?

  •  2
  • Qualia  · 技术社区  · 11 年前

    我的任务是改变HPC应用程序部分的精度,记住它严重依赖自动矢量化。因此,编译器在发生任何类型的浮点转换时通知我是很有用的(因为这可能会严重影响性能)。

    这个 -Wconversion 旗帜听起来应该适合我的需要:

    -W转换

    警告不同类型之间的隐式转换。


    https://gcc.gnu.org/onlinedocs/gcc-4.1.0/gfortran/Warning-Options.html

    然而,在实践中,gfortran 5.2.0似乎只报告浮点降级, 例如 REAL(8) 到 REAL(4) .

    GCC具有 -Wdouble-promotion flag-正是我需要的,但不适用于gfortran。( https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html )

    我正在使用gfortran进行开发,但ifort对我来说是可用的 -warn ( https://software.intel.com/en-us/node/525184 ).

    当隐式提升REAL时,如何让这些编译器中的任何一个发出警告?

    1 回复  |  直到 11 年前
        1
  •  2
  •   francescalus    6 年前

    您指的是使用gfortran 5.2.0,所以让我们看看该版本的文档,而不是4.1.0 two relevant flags 您认为:

    -Wconversion  
        Warn about implicit conversions that are likely to change the
        value of the expression after conversion. Implied by -Wall.  
     -Wconversion-extra  
        Warn about implicit conversions between different types and
        kinds. This option does not imply -Wconversion.
    

    如果我在以下程序中使用后一个标志

      use, intrinsic :: iso_fortran_env, only : real32, real64
      real(real64) x
      x = 1._real32
    end
    

    我得到了问题标题中要求的警告信息(尽管使用了gfortran 4.8.1)

    Warning: Conversion from REAL(4) to REAL(8) at (1)
    

    而仅仅 -Wconversion 我一无所获。然而,如果我稍微改变程序,以便改变可表示的值,我会得到(不同的)警告。

    另一方面,ifort(高达19.0.5)似乎没有类似的警告。

    推荐文章