isnan warning


I’m using the PGI compilers (release 15.1) in order to install a climate simulation program. However, during the installation, I encounter this warning:

PGF90-S-0038-Symbol, isnan, has not been explicitly declared

I tried to search on the web a solution. I find two ways:

  1. Change isnan with .ne. (not equivalent), but in this case I obtain the following error:

PGF90-S-0034-Syntax error at or near .NE.

  1. Change isnan with ieee_is_nan by adding the libraries use ieee arithmetic, but in the following step I obtain the message:

PGF90-S-0091-Constant expression of wrong data type

Has anybody a solution for my problem?

Thanks a lot,


Hi Alessandro,

“isnan” is a C routine and I believe GNU supports it as an extension. We have lib3f interfaces to “isnanf” and “isnand” that you can use, but I would recommend using the F2003 ieee_arthmetic module instead.

For #2, do you have an example of the code which produces this error? What data type are you passing to “ieee_is_nan”? Did you use the ieee_arithmetic module?

Here’s a simple example:

% cat isnan.f90

program isnan
use ieee_arithmetic
real(4) a
logical lres

a = sqrt(1.0)
lres = ieee_is_nan(a)
print *, "1) A ieee_is_nan? ", lres
lres = isnanf(a)
print *, "1) A isnanf? ", lres
a = sqrt(-1.0)
lres = ieee_is_nan(a)
print *, "2) A ieee_is_nan? ", lres
lres = isnanf(a)
print *, "2) A isnanf? ", lres
% pgf90 isnan.f90
% a.out
 1) A ieee_is_nan?   F
 1) A isnanf?   F
 2) A ieee_is_nan?   T
 2) A isnanf?   T
  • Mat

Dear Mat,

thanks for your answer.
I tried to use “isnanf” and “isnand” but, unfortunately, I have the same warnings.
As I wrote previously, when I tried to substitute “isnan” with “ieee_is_nan” by adding the ieee_arithmetic module, the compiler accepted the replacement, but it doesn’t work for the subsequent warning.

Here is the code were I changed “isnan” with “ieee_is_nan”:

! Total fluxes (vegetation + ground)

eflx_sh_tot§ = eflx_sh_veg§ + eflx_sh_grnd§
qflx_evap_tot§ = qflx_evap_veg§ + qflx_evap_soi§
if ((abs(qflx_evap_tot§) < 1.e-12_r8) .or.(isnan(qflx_evap_tot§))) then
!write(6,) ‘qflx_tot is:’,qflx_evap_tot§
qflx_evap_tot§ = 0._r8
qflx_evap_veg§ = 0._r8
qflx_evap_soi§ = 0._r8
eflx_lh_tot§= (hvap
qflx_evap_veg§ + htvp©*qflx_evap_soi§) - energy_change§

For #2, I have included the ieee_arithmetic module in the script, but nothing is changed. I have still this error:

PGF90-S-0091-Constant expression of wrong data type (/root/Scrivania/cam/cam1/models/atm/cam/src/physics/cam1/carma.F90: 236)
0 inform, 0 warnings, 1 severes, 0 fatal for carma
0 inform, 0 warnings, 1 severes, 0 fatal for carma
make: *** [carma.o] Error 2

The code I’m referring to is the following:


integer, dimension(NGAS) :: icnst4gas
logical :: addedgas(NGAS)
use constituents, only: ppcnst, cnst_add, advected, cnst_get_ind, &
cnst_name, cnst_longname, cnst_type

if (icnst4gas(i) == -1) then

! Add the gas.
addedgas(i) = .true.
call cnst_add(gassname(i), advected, gwtmol(i), 1._r8, 0._r8, &
icnst4gas(i), longname=trim(gasname(i)), mixtype=carma_mixtype)

addedgas(i) = .false.

Have you any idea why it doesn’t work?

Finally, a last question: when I changed “isnan” with “.ne” many times ago, the realese 15.1 of the compilers accepted it, but now, when I try to use the same product, it doesn’t work. Is this a compiler problem or maybe I’m wrong in replying the building instruction of my software? In other words: is it possible that the same change now is not accepted by the same compilerts used before?

Thanks in advance,


Hi Alessandro,

Sorry but I still not clear on some of these issues.

For #1, you’re still getting the error that “isnanf” or “isnand” is not been explicitly defined? The lib3f routines are implicitly defined by the compiler so should be there. A reproducing example would be helpful.

For #2, I don’t see any “isnan” calls in this code so am assuming this is a different problem. What line is #236? My best guess is that “NGAS” isn’t being defined as an integer so the compiler is complaining that kind data type is wrong.

% cat test.F90
#define NGAS 8.0
program test_program
   integer(NGAS) itmp
   itmp = 1.0
   print *, itmp
end program test_program

% pgfortran test.F90
PGF90-W-0091-Constant expression of wrong data type (test.F90: 3)
  0 inform,   1 warnings,   0 severes, 0 fatal for test_program

For #3, I’ll need a reproducing example to better understand the issue with “.ne.”. I’m not clear on problem.


Dear Matt,

Thanks for you immediate answer.

At the end I managed to overcome my error. It was not concerned with the compilers but it regards the script that includes that portion of the code I sent you.

The substitution of isnan with “ieee_is_nan” by adding the ieee_arithmetic module works well and this change is corrected interpreted by the compiler.

Thanks a lot for your support.


Also, as an aside, if you have a lot of isnan’s that you don’t want to fix en masse with a sed script (to, say, minimize differences in a diff util), I have on occasion done:

use ieee_arithmetic, only: isnan => ieee_is_nan

Thus a diff utility will show one line of difference instead of many more.

Though, of course, it’s better to use the real call name instead. :)