c     Copyright (C)
c     2010-2013 Université Bordeaux 1
c     2010-2013 Ecole des Mines d'Albi
c     2014-2018 - Mesostar
c     
c     This program is free software; you can redistribute it and/or modify
c     it under the terms of the GNU General Public License as published by
c     the Free Software Foundation; either version 2, or (at your option)
c     any later version.

c     This program is distributed in the hope that it will be useful,
c     but WITHOUT ANY WARRANTY; without even the implied warranty of
c     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c     GNU General Public License for more details.

c     You should have received a copy of the GNU General Public License
c     along with this program; if not, write to the Free Software
c     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
c     USA.
c
      subroutine test_nan_dble(value,is_nan)
      implicit none
      include 'max.inc'
c
c     Purpose: to test whether the provided double-precision value is a NaN or not
c
c     Input:
c       + value: double-precision value to test
c     
c     Output:
c       + is_nan: true if 'value' is a NaN; false otherwise
c
c     I/O
      double precision value
      logical is_nan
c     temp
      integer t1,t2
c     label
      integer strlen
      character*(Nchar_mx) label
      label='subroutine test_nan_dble'
c
      
      if (value.le.0.0D+0) then
         t1=0
      else
         t1=1
      endif
      if (value.ge.0.0D+0) then
         t2=0
      else
         t2=1
      endif
      
      if ((t1.eq.1).and.(t2.eq.1)) then
         is_nan=.true.
      else
         is_nan=.false.
      endif

      return
      end
