Skip to content

Commit e274718

Browse files
committed
update flag values and tolerance in float compare
1 parent 220de4e commit e274718

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

GEOSlandassim_GridComp/clsm_ensupd_read_obs.F90

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,6 +2209,7 @@ subroutine read_obs_sm_CYGNSS( &
22092209
integer, parameter :: max_obs = 50000 ! max number of daily obs read by subroutine (assim window <= 24 hr)
22102210
character(4), parameter :: J2000_epoch_id = 'TT12' ! see date_time_util.F90
22112211
character(len=*), parameter :: Iam = 'read_obs_sm_CYGNSS'
2212+
real, parameter :: tolerance = 1.0e-6 ! tolerance for floating point comparisons
22122213

22132214
type(date_time_type) :: date_time_obs_beg, date_time_obs_end
22142215
type(date_time_type) :: date_time_up, date_time_low
@@ -2224,7 +2225,7 @@ subroutine read_obs_sm_CYGNSS( &
22242225
integer :: sm_d_varid, sm_subd_varid, sigma_d_varid, sigma_subd_varid, timeintervals_varid, lat_varid, lon_varid
22252226
integer :: N_lon, N_lat, N_time, N_timeslices, N_startstop, N_lon_m, N_lat_m
22262227
integer :: longitudes_m_varid, latitudes_m_varid, small_SM_range_varid, poor_SMAP_varid, high_ubrmsd_varid
2227-
integer :: few_obs_varid, low_signal_varid
2228+
integer :: few_obs_varid, low_signal_varid, good_flag_value
22282229

22292230
integer :: start(3), count(3)
22302231
integer, allocatable :: small_SM_range_flag(:,:), poor_SMAP_flag(:,:), high_ubrmsd_flag(:,:), few_obs_flag(:,:), low_signal_flag(:,:)
@@ -2397,10 +2398,10 @@ subroutine read_obs_sm_CYGNSS( &
23972398

23982399
if (dt_obs == 6) then
23992400
do i = 1, N_timeslices
2400-
if ((obs_hour == 3 .and. timeintervals(1,i) == 0.0 ) .or. &
2401-
(obs_hour == 9 .and. timeintervals(1,i) == 0.25) .or. &
2402-
(obs_hour == 15 .and. timeintervals(1,i) == 0.5 ) .or. &
2403-
(obs_hour == 21 .and. timeintervals(1,i) == 0.75) ) then
2401+
if ((obs_hour == 3 .and. (abs(timeintervals(1,i) - 0.0 ) < tolerance)) .or. &
2402+
(obs_hour == 9 .and. (abs(timeintervals(1,i) - 0.25) < tolerance)) .or. &
2403+
(obs_hour == 15 .and. (abs(timeintervals(1,i) - 0.5 ) < tolerance)) .or. &
2404+
(obs_hour == 21 .and. (abs(timeintervals(1,i) - 0.75) < tolerance)) ) then
24042405
idx = i
24052406
exit
24062407
end if
@@ -2485,17 +2486,19 @@ subroutine read_obs_sm_CYGNSS( &
24852486
call ldas_abort(LDAS_GENERIC_ERROR, Iam, err_msg)
24862487
end if
24872488

2489+
good_flag_value = 255 ! should really be 0 but is 255 because of unsigned v. signed byte issues
2490+
24882491
! fill tmp arrays
24892492
N_obs = 0
24902493

24912494
do i = 1, N_lon
24922495
do j = 1, N_lat
2493-
if (tmp_sm(i,j) .ne. this_obs_param%nodata .and. &
2494-
small_SM_range_flag(i,j) .ne. 1 .and. &
2495-
poor_SMAP_flag(i,j) .ne. 1 .and. &
2496-
high_ubrmsd_flag(i,j) .ne. 1 .and. &
2497-
few_obs_flag(i,j) .ne. 1 .and. &
2498-
low_signal_flag(i,j) .ne. 1 ) then
2496+
if (tmp_sm(i,j) .ne. this_obs_param%nodata .and. &
2497+
small_SM_range_flag(i,j) == good_flag_value .and. &
2498+
poor_SMAP_flag(i,j) == good_flag_value .and. &
2499+
high_ubrmsd_flag(i,j) == good_flag_value .and. &
2500+
few_obs_flag(i,j) == good_flag_value .and. &
2501+
low_signal_flag(i,j) == good_flag_value ) then
24992502

25002503
! valid observation
25012504
N_obs = N_obs + 1

0 commit comments

Comments
 (0)