From c63766236d6c583ee1bc1a687012c2242bd65686 Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Mon, 10 Jul 2023 09:45:27 -0400 Subject: [PATCH] bug-fix: use get_dist to calculate distances for observations with VERTISUNDEF fixes #486 Previously observations with VERTISUNDEF were given a large distance, because the verical coordinate is missing: local_array(3) == missing_r8 The location_mod::get_dist uses horizontal distance only if VERTISUNDEF for either location. --- models/wrf/model_mod.f90 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/models/wrf/model_mod.f90 b/models/wrf/model_mod.f90 index d8a5211528..8fc1592ca9 100644 --- a/models/wrf/model_mod.f90 +++ b/models/wrf/model_mod.f90 @@ -6403,6 +6403,13 @@ subroutine get_close(gc, base_loc, base_type, locs, loc_qtys, & local_loc = locs(t_ind) local_which = nint(query_location(local_loc)) + if (present(dist)) then + if (local_which == VERTISUNDEF) then + dist(k) = get_dist(base_loc, local_loc, base_type, loc_qtys(t_ind)) + cycle + endif + endif + ! Convert local vertical coordinate to requested vertical coordinate if necessary. ! This should only be necessary for obs priors, as state location information already ! contains the correct vertical coordinate (filter_assim's call to get_state_meta_data).