本文介绍了如何让gfortran或ifort告诉我何时隐含地将REAL(4)推广到REAL(8)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务是改变HPC应用程序部件的精度,同时铭记它严重依赖于自动矢量化。因此,编译器告诉我何时发生任何类型的浮点转换转换(因为这可能会对性能造成严重影响)。



<$ c
$ b

然而,实际上,gfortran 5.2.0似乎只报告浮点降级,例如 REAL(8) 到 REAL(4)。



GCC的 -Wouble-promotion 标志 - 正是我需要的,但不适用于gfortran。 ()



我正在使用gfortran进行开发,但ifort可用于我。然而,我找不到任何类似的参数 -warn ()。



我怎样才能得到这些编译器在隐式提升REAL时发出警告?解析方案

您可以参考使用gfortran 5.2.0,所以让我们来看看该版本的文档而不是4.1.0。这有:

如果我在后面的程序中使用后面的标志

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

我在问题标题

中准确地(但使用gfortran 4.8.1) (b)
$ b

However, in practice, gfortran 5.2.0 only appears to report floating point demotions, e.g. REAL(8) to REAL(4).

GCC has the -Wdouble-promotion flag - exactly what I need, but not available for gfortran. (https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html)

I am developing with gfortran, but ifort is available to me. However, I can't find any similar arguments for -warn (https://software.intel.com/en-us/node/525184).

How can I get either of these compilers to emit a warning when implicitly promoting a REAL?

解决方案

You refer to using gfortran 5.2.0, so let's look at the documentation for that version rather than 4.1.0. This has two relevant flags for what you consider:

If I use this latter flag with the following program

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

I get exactly (albeit using gfortran 4.8.1) a warning message requested in the question title

whereas with just -Wconversion I get nothing. If I change the program slightly, however, so that the changing of representable values kicks in, I get (different) warnings with each.

这篇关于如何让gfortran或ifort告诉我何时隐含地将REAL(4)推广到REAL(8)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-15 05:50