[petsc-dev] NaN constant?

Adrian Croucher a.croucher at auckland.ac.nz
Wed Oct 21 17:36:58 CDT 2015


hi,

You may have looked at this before, but I was wondering if there'd be 
any merit in having a NaN constant (PETSC_NAN or similar) in PETSc?

I gather in C there is a NAN macro available, but in Fortran there isn't 
anything unless you have a compiler supporting the new(-ish) 
IEEE_ARITHMETIC module- which for gfortran means version 5.

Could PETSc perhaps just create a NaN using the C NAN macro and make it 
available, so that Fortran users could use it too?

Otherwise Fortran users have to try and make NaNs by dividing numbers by 
zero and hoping the compiler doesn't complain, or using the transfer() 
routine to get the appropriate NaN bit pattern onto a float, and I don't 
know if that is very portable or not.

Cheers, Adrian

-- 
Dr Adrian Croucher
Senior Research Fellow
Department of Engineering Science
University of Auckland, New Zealand
email: a.croucher at auckland.ac.nz
tel: +64 (0)9 923 84611




More information about the petsc-dev mailing list