I am tasked with changing the precision of parts of an HPC application, bearing in mind that it makes heavy reliance on auto-vectorisation. It is therefore useful for the compiler to inform me when conversions of any type of floating point conversion occurs (as this could have a serious performance impact).
The -Wconversion
flag sounds like it should suit my needs:
-Wconversion
Warn about implicit conversions between different types.
https://gcc.gnu.org/onlinedocs/gcc-4.1.0/gfortran/Warning-Options.html
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
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.