Skip to content

Commit 7a134a6

Browse files
mjs2369hkershaw-brown
authored andcommitted
Adding additional check to ensure attribute values that are NaNs are consistent across restarts
1 parent 482d18b commit 7a134a6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

assimilation_code/modules/io/io_filenames_mod.f90

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,12 @@ subroutine check_attribute_value_r4(ncFile, filename, ncVarID, att_string, spval
718718
real(r4) :: ret_spvalR4
719719

720720
if ( 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
746751
real(r8) :: ret_spvalR8
747752

748753
if ( 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

Comments
 (0)