From f6a3f975481a804aa4ef506fb0d6a35a39e3738a Mon Sep 17 00:00:00 2001 From: DJDavies2 Date: Fri, 2 Jun 2023 15:48:12 +0100 Subject: [PATCH] Changes for ufo-2848. --- src/opsinputs/CxWriter.cc | 3 +++ src/opsinputs/VarObsWriter.cc | 3 +++ src/opsinputs/opsinputs_fill_mod.F90 | 35 ++++++++++++++-------------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/opsinputs/CxWriter.cc b/src/opsinputs/CxWriter.cc index 2c7d7204..2018f867 100644 --- a/src/opsinputs/CxWriter.cc +++ b/src/opsinputs/CxWriter.cc @@ -20,6 +20,7 @@ #include "ufo/filters/Variable.h" #include "ufo/filters/Variables.h" #include "ufo/GeoVaLs.h" +#include "ufo/ScopedDefaultGeoVaLFormatChange.h" namespace opsinputs { @@ -71,6 +72,7 @@ CxWriter::~CxWriter() { void CxWriter::priorFilter(const ufo::GeoVaLs & gv) { oops::Log::trace() << "CxWriter priorFilter" << std::endl; + ufo::ScopedDefaultGeoVaLFormatChange change(gv, ufo::GeoVaLFormat::REDUCED); LocalEnvironment localEnvironment; setupEnvironment(localEnvironment); @@ -83,6 +85,7 @@ void CxWriter::postFilter(const ufo::GeoVaLs & gv, const ufo::ObsDiagnostics &) { oops::Log::trace() << "CxWriter postFilter" << std::endl; + ufo::ScopedDefaultGeoVaLFormatChange change(gv, ufo::GeoVaLFormat::REDUCED); LocalEnvironment localEnvironment; setupEnvironment(localEnvironment); diff --git a/src/opsinputs/VarObsWriter.cc b/src/opsinputs/VarObsWriter.cc index 52644ceb..51c790f2 100644 --- a/src/opsinputs/VarObsWriter.cc +++ b/src/opsinputs/VarObsWriter.cc @@ -24,6 +24,7 @@ #include "ufo/filters/Variables.h" #include "ufo/GeoVaLs.h" #include "ufo/ObsDiagnostics.h" +#include "ufo/ScopedDefaultGeoVaLFormatChange.h" namespace opsinputs { @@ -91,6 +92,7 @@ VarObsWriter::~VarObsWriter() { void VarObsWriter::priorFilter(const ufo::GeoVaLs & gv) { oops::Log::trace() << "VarObsWriter priorFilter" << std::endl; + ufo::ScopedDefaultGeoVaLFormatChange change(gv, ufo::GeoVaLFormat::REDUCED); LocalEnvironment localEnvironment; setupEnvironment(localEnvironment); @@ -103,6 +105,7 @@ void VarObsWriter::postFilter(const ufo::GeoVaLs & gv, const ufo::ObsDiagnostics & obsdiags) { oops::Log::trace() << "VarObsWriter postFilter" << std::endl; + ufo::ScopedDefaultGeoVaLFormatChange change(gv, ufo::GeoVaLFormat::REDUCED); LocalEnvironment localEnvironment; setupEnvironment(localEnvironment); diff --git a/src/opsinputs/opsinputs_fill_mod.F90 b/src/opsinputs/opsinputs_fill_mod.F90 index 50680bef..be049e87 100644 --- a/src/opsinputs/opsinputs_fill_mod.F90 +++ b/src/opsinputs/opsinputs_fill_mod.F90 @@ -1321,13 +1321,14 @@ subroutine opsinputs_fill_fillrealfromgeoval( & Hdr, OpsVarName, JediToOpsLayoutMapping % NumOpsObs, Real1, & GeoVals, JediVarName, JediToOpsLayoutMapping) else - if (ufo_vars_getindex(GeoVals % variables, JediVarName) > 0) then - ! Retrieve GeoVal - call ufo_geovals_get_var(GeoVals, JediVarName, GeoVal) - if (GeoVal % nval /= 1) then - write (ErrorMessage, '("GeoVal ",A," contains more than one value per location. & - &Only the first of these values will be written to the VarObs file")') JediVarName - call gen_warn(RoutineName, ErrorMessage) + ! Try to retrieve GeoVal + call ufo_geovals_get_var(GeoVals, JediVarName, GeoVal, must_be_found = .false.) + if (associated(GeoVal)) then + if (GeoVal % nval /= 1) then + write (ErrorMessage, '("GeoVal ",A," contains more than one value per location. & + &Only the first of these values will be written to the VarObs file")') JediVarName + call gen_warn(RoutineName, ErrorMessage) + end if end if ! Fill the OPS data structures @@ -1335,7 +1336,6 @@ subroutine opsinputs_fill_fillrealfromgeoval( & where (GeoVal % vals(1,:) /= MissingReal) Real1 = GeoVal % vals(1,:) end where - end if end if end subroutine opsinputs_fill_fillrealfromgeoval @@ -1384,10 +1384,9 @@ subroutine opsinputs_fill_fillreal2dfromgeovalforsinglelevelobs( & MissingReal = missing_value(0.0_c_float) -if (ufo_vars_getindex(GeoVals % variables, JediVarName) > 0) then - ! Retrieve GeoVal - call ufo_geovals_get_var(GeoVals, JediVarName, GeoVal) - +! Try to retrieve GeoVal +call ufo_geovals_get_var(GeoVals, JediVarName, GeoVal, must_be_found = .false.) +if (associated(GeoVal)) then ! Fill the OPS data structures call Ops_Alloc(Hdr, OpsVarName, NumObs, Real2, num_levels = int(GeoVal % nval, kind = 8)) where (transpose(GeoVal % vals) /= MissingReal) @@ -1498,9 +1497,9 @@ subroutine opsinputs_fill_fillrealfromgeovalformultilevelobs( & MissingReal = missing_value(0.0_c_float) -if (ufo_vars_getindex(GeoVals % variables, JediVarName) > 0) then - ! Retrieve GeoVal - call ufo_geovals_get_var(GeoVals, JediVarName, GeoVal) +! Try to retrieve GeoVal +call ufo_geovals_get_var(GeoVals, JediVarName, GeoVal, must_be_found = .false.) +if (associated(GeoVal)) then ! Fill the OPS data structures call Ops_Alloc(Hdr, OpsVarName, JediToOpsLayoutMapping % NumOpsObs, Real1) ! Loop over each multi-level profile @@ -1563,9 +1562,9 @@ subroutine opsinputs_fill_fillreal2dfromgeovalformultilevelobs( & MissingReal = missing_value(0.0_c_float) -if (ufo_vars_getindex(GeoVals % variables, JediVarName) > 0) then - ! Retrieve GeoVal - call ufo_geovals_get_var(GeoVals, JediVarName, GeoVal) +! Try to retrieve GeoVal +call ufo_geovals_get_var(GeoVals, JediVarName, GeoVal, must_be_found = .false.) +if (associated(GeoVal)) then ! Determine the number of levels in this GeoVaL. This governs the number of levels in the ! output array. numLevels = GeoVal % nval