@@ -718,7 +718,12 @@ subroutine check_attribute_value_r4(ncFile, filename, ncVarID, att_string, spval
718718real (r4 ) :: ret_spvalR4
719719
720720if ( nf90_get_att(ncFile, ncVarID, att_string, ret_spvalR4 ) == NF90_NOERR ) then
721- if (ret_spvalR4 /= ret_spvalR4 ) then
721+ if (ret_spvalR4 /= ret_spvalR4 ) then ! ret_spval is NaN
722+ if (.not. (spvalR4 /= spvalR4 )) then ! spval is not NaN, so they are not the same
723+ write (msgstring,* ) ' variable attribute, ' , trim (att_string), ' in state' , spvalR4 , &
724+ ' does not match ' , trim (att_string), ' ' , ret_spvalR4 , ' in ' , trim (filename)
725+ call error_handler(E_ERR, ' check_attribute_value_r4' , msgstring, source)
726+ end if
722727 return
723728 endif
724729 if (spvalR4 /= ret_spvalR4 ) then
@@ -746,7 +751,12 @@ subroutine check_attribute_value_r8(ncFile, filename, ncVarID, att_string, spval
746751real (r8 ) :: ret_spvalR8
747752
748753if ( nf90_get_att(ncFile, ncVarID, att_string, ret_spvalR8 ) == NF90_NOERR ) then
749- if (ret_spvalR8 /= ret_spvalR8 ) then
754+ if (ret_spvalR8 /= ret_spvalR8 ) then ! ret_spval is NaN
755+ if (.not. (spvalR8 /= spvalR8 )) then ! spval is not NaN, so they are not the same
756+ write (msgstring,* ) ' variable attribute, ' , trim (att_string), ' in state' , spvalR8 , &
757+ ' does not match ' , trim (att_string), ' ' , ret_spvalR8 , ' in ' , trim (filename)
758+ call error_handler(E_ERR, ' check_attribute_value_r8' , msgstring, source)
759+ end if
750760 return
751761 endif
752762 if (spvalR8 /= ret_spvalR8 ) then
0 commit comments