From 144d419cb239b9b6972170b3ae44bbedd0722b01 Mon Sep 17 00:00:00 2001 From: lewisn-met Date: Thu, 12 Nov 2026 14:19:34 +0000 Subject: [PATCH 1/4] Remove unnecessary warnings from flow. Test warnings are thrown appropriately. --- src/opsinputs/opsinputs_cxwriter_mod.F90 | 4 +++ src/opsinputs/opsinputs_varobswriter_mod.F90 | 8 ++--- test/CMakeLists.txt | 32 +++++++++++++++++-- test/check_writer_warnings.cmake | 18 +++++++++++ .../CxWriterNamelists_unknown/Aircraft.nl | 3 ++ .../VarObsWriterNamelists_unknown/Surface.nl | 3 ++ test/testinput/cxwriter_unknown_stash.yaml | 29 +++++++++++++++++ .../varobswriter_unknown_varfield.yaml | 23 +++++++++++++ 8 files changed, 112 insertions(+), 8 deletions(-) create mode 100644 test/check_writer_warnings.cmake create mode 100644 test/testinput/CxWriterNamelists_unknown/Aircraft.nl create mode 100644 test/testinput/VarObsWriterNamelists_unknown/Surface.nl create mode 100644 test/testinput/cxwriter_unknown_stash.yaml create mode 100644 test/testinput/varobswriter_unknown_varfield.yaml diff --git a/src/opsinputs/opsinputs_cxwriter_mod.F90 b/src/opsinputs/opsinputs_cxwriter_mod.F90 index 7bf293d1..fc2eeb16 100644 --- a/src/opsinputs/opsinputs_cxwriter_mod.F90 +++ b/src/opsinputs/opsinputs_cxwriter_mod.F90 @@ -610,6 +610,8 @@ subroutine opsinputs_cxwriter_addrequiredgeovars(self, geovars) GeoVarName = opsinputs_cxfields_unknown select case (CxField) + case (IMDI) + cycle ! Surface variables @@ -911,6 +913,8 @@ subroutine opsinputs_cxwriter_populatecx(self, ReportFlags, Cx) do iCxField = 1, size(CxFields) CxField = CxFields(iCxField) select case (CxField) + case (IMDI) + cycle ! Surface variables diff --git a/src/opsinputs/opsinputs_varobswriter_mod.F90 b/src/opsinputs/opsinputs_varobswriter_mod.F90 index 4d0dae9c..c2aba82c 100644 --- a/src/opsinputs/opsinputs_varobswriter_mod.F90 +++ b/src/opsinputs/opsinputs_varobswriter_mod.F90 @@ -606,22 +606,20 @@ subroutine opsinputs_varobswriter_addrequiredgeovars(self, geovars) ! Local declarations: integer(integer64) :: VarFields(ActualMaxVarfield) integer :: i -character(len=80) :: ErrorMessage -character(len=*), parameter :: RoutineName = "opsinputs_varobswriter_addrequiredgeovars" ! Body: call Ops_ReadVarobsControlNL(self % obsgroup, VarFields) do i = 1, size(VarFields) select case (VarFields(i)) + case (IMDI) + cycle case (VarField_modelsurface) ! TODO(someone): "land_type_index" may not be the right geoval to use. If it isn't, change it ! here and in opsinputs_varobswriter_populateobservations. call geovars % push_back("land_type_index") case default - write (ErrorMessage, '("Varfield not recognized: ",I0)') VarFields(i) - call gen_warn(RoutineName, ErrorMessage) - continue + cycle end select end do diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ae138379..3400f7e2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -25,7 +25,7 @@ include( opsinputs_functions ) function( ADD_WRITER_TEST ) set( options DONT_SET_OPS_OUTPUT_DIR_ENV_VAR ) set( single_value_args NAME YAML NAMELIST MPI ) - set( multi_value_args DATA LABELS ) + set( multi_value_args DATA LABELS EXPECTED_WARNINGS ) cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}" ${_FIRST_ARG} ${ARGN} ) if(_PAR_UNPARSED_ARGUMENTS) @@ -48,14 +48,28 @@ function( ADD_WRITER_TEST ) if(NOT _PAR_MPI) set(_PAR_MPI 1) endif() + set( test_command ${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME}_test_inputs_filters.x ) + set( test_args "testinput/${_PAR_YAML}" ) + if(_PAR_EXPECTED_WARNINGS) + set( test_command ${CMAKE_COMMAND} ) + set( test_args + "-DWRITER_EXECUTABLE=${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME}_test_inputs_filters.x" + "-DWRITER_INPUT=testinput/${_PAR_YAML}" + "-DEXPECTED_WARNINGS=${_PAR_EXPECTED_WARNINGS}" + -P ${CMAKE_CURRENT_SOURCE_DIR}/check_writer_warnings.cmake ) + endif() ecbuild_add_test( TARGET ${PROJECT_NAME}_${_PAR_NAME} LABELS ${_PAR_LABELS} - COMMAND ${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME}_test_inputs_filters.x - ARGS "testinput/${_PAR_YAML}" + COMMAND ${test_command} + ARGS ${test_args} ENVIRONMENT "${environment}" MPI ${_PAR_MPI} DEPENDS ${PROJECT_NAME}_test_inputs_filters.x ) set_tests_properties( ${PROJECT_NAME}_${_PAR_NAME} PROPERTIES FIXTURES_REQUIRED CleanOutputDir ) + if(NOT _PAR_EXPECTED_WARNINGS) + set_tests_properties( ${PROJECT_NAME}_${_PAR_NAME} PROPERTIES + FAIL_REGULAR_EXPRESSION "[Vv]ar[Ff]ield (code )?not recogni[sz]ed;Stash code not recognized" ) + endif() endfunction() set( OPSINPUTS_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/testoutput ) @@ -449,6 +463,12 @@ ADD_WRITER_TEST(NAME varobswriter_globalnamelist_aircraft YAML varobswriter_globalnamelist_aircraft.yaml NAMELIST ../../etc/global/varobs/Aircraft.nl DATA varobs_globalnamelist_aircraft.nc4) +ADD_WRITER_TEST(NAME varobswriter_unknown_varfield + LABELS varobswriter + YAML varobswriter_unknown_varfield.yaml + NAMELIST VarObsWriterNamelists_unknown/Surface.nl + DATA 003_VarField_rh_Surface.nc4 + EXPECTED_WARNINGS "opsinputs_varobswriter_populateobservations.*VarField code not recognised 13") ADD_WRITER_TEST(NAME varobswriter_globalnamelist_sternamwr LABELS varobswriter globalnamelist YAML varobswriter_globalnamelist_sternamwr.yaml @@ -874,6 +894,12 @@ ADD_WRITER_TEST(NAME cxwriter_globalnamelist_aircraft YAML cxwriter_globalnamelist_aircraft.yaml NAMELIST ../../etc/global/cx/Aircraft.nl DATA cx_globalnamelist_aircraft.nc4 dummy.nc4) +ADD_WRITER_TEST(NAME cxwriter_unknown_stash + LABELS cxwriter + YAML cxwriter_unknown_stash.yaml + NAMELIST CxWriterNamelists_unknown/Aircraft.nl + DATA cx_globalnamelist_aircraft.nc4 dummy.nc4 + EXPECTED_WARNINGS "opsinputs_cxwriter_addrequiredgeovars.*Stash code not recognized: 99999.*opsinputs_cxwriter_populatecx.*Stash code not recognized: 99999") ADD_WRITER_TEST(NAME cxwriter_globalnamelist_surface LABELS cxwriter globalnamelist YAML cxwriter_globalnamelist_surface.yaml diff --git a/test/check_writer_warnings.cmake b/test/check_writer_warnings.cmake new file mode 100644 index 00000000..57ab5819 --- /dev/null +++ b/test/check_writer_warnings.cmake @@ -0,0 +1,18 @@ +execute_process( + COMMAND "${WRITER_EXECUTABLE}" "${WRITER_INPUT}" + RESULT_VARIABLE result + OUTPUT_VARIABLE output + ERROR_VARIABLE errors ) +message("${output}${errors}") +if(NOT "${result}" STREQUAL "0") + message(FATAL_ERROR "Writer test failed: ${result}") +endif() +set( log "${output}${errors}" ) +if(log MATCHES "[Vv]ar[Ff]ield (code )?not recogni[sz]ed[: ]+-32768|Stash code not recognized: -32768") + message(FATAL_ERROR "Writer reported missing-data padding as an unknown field") +endif() +foreach(warning IN LISTS EXPECTED_WARNINGS) + if(NOT log MATCHES "${warning}") + message(FATAL_ERROR "Missing expected writer warning: ${warning}") + endif() +endforeach() diff --git a/test/testinput/CxWriterNamelists_unknown/Aircraft.nl b/test/testinput/CxWriterNamelists_unknown/Aircraft.nl new file mode 100644 index 00000000..124a96ef --- /dev/null +++ b/test/testinput/CxWriterNamelists_unknown/Aircraft.nl @@ -0,0 +1,3 @@ +&CXControlNL +CxFields=33,99999 +/ diff --git a/test/testinput/VarObsWriterNamelists_unknown/Surface.nl b/test/testinput/VarObsWriterNamelists_unknown/Surface.nl new file mode 100644 index 00000000..bd58081f --- /dev/null +++ b/test/testinput/VarObsWriterNamelists_unknown/Surface.nl @@ -0,0 +1,3 @@ +&VarobsControlNL +Varfields=3,13 +/ diff --git a/test/testinput/cxwriter_unknown_stash.yaml b/test/testinput/cxwriter_unknown_stash.yaml new file mode 100644 index 00000000..5e20392d --- /dev/null +++ b/test/testinput/cxwriter_unknown_stash.yaml @@ -0,0 +1,29 @@ +time window: + begin: 2018-01-01T00:00:00Z + end: 2018-01-01T01:00:00Z + +observations: + - obs space: + name: Aircraft + obsdatain: + engine: + type: H5File + obsfile: Data/dummy.nc4 + simulated variables: [dummy] + geovals: + filename: Data/cx_globalnamelist_aircraft.nc4 + obs filters: + - filter: Cx Writer + namelist_directory: testinput/CxWriterNamelists_unknown + general_mode: debug + - filter: Cx Checker + expected_surface_variables: ["1"] + expected_upper_air_variables: [] + expected_main_table_columns: + - - ["17.10"] + - ["**********"] + - ["17.30"] + - ["17.40"] + HofX: ObsValue + benchmarkFlag: 1000 + flaggedBenchmark: 0 diff --git a/test/testinput/varobswriter_unknown_varfield.yaml b/test/testinput/varobswriter_unknown_varfield.yaml new file mode 100644 index 00000000..837155f3 --- /dev/null +++ b/test/testinput/varobswriter_unknown_varfield.yaml @@ -0,0 +1,23 @@ +time window: + begin: 2018-01-01T00:00:00Z + end: 2018-01-01T02:00:00Z + +observations: + - obs space: + name: Surface + obsdatain: + engine: + type: H5File + obsfile: Data/003_VarField_rh_Surface.nc4 + simulated variables: [relativeHumidityAt2M] + obs filters: + - filter: VarObs Writer + namelist_directory: testinput/VarObsWriterNamelists_unknown + general_mode: debug + - filter: VarObs Checker + expected_main_table_columns: + field: [3, 3, 3, 3] + ob value: ["1.10000", "-1073741824.00000", "1.30000", "1.40000"] + HofX: ObsValue + benchmarkFlag: 1000 + flaggedBenchmark: 0 From b35c94c08143e1893e76d0d57e896ae617282b54 Mon Sep 17 00:00:00 2001 From: lewisn-met Date: Thu, 12 Nov 2026 15:31:25 +0000 Subject: [PATCH 2/4] Fix cmake linter issues --- test/CMakeLists.txt | 4 +++- test/check_writer_warnings.cmake | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3400f7e2..3ee1fb4e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -899,7 +899,9 @@ ADD_WRITER_TEST(NAME cxwriter_unknown_stash YAML cxwriter_unknown_stash.yaml NAMELIST CxWriterNamelists_unknown/Aircraft.nl DATA cx_globalnamelist_aircraft.nc4 dummy.nc4 - EXPECTED_WARNINGS "opsinputs_cxwriter_addrequiredgeovars.*Stash code not recognized: 99999.*opsinputs_cxwriter_populatecx.*Stash code not recognized: 99999") + EXPECTED_WARNINGS + "opsinputs_cxwriter_addrequiredgeovars.*Stash code not recognized: 99999" + "opsinputs_cxwriter_populatecx.*Stash code not recognized: 99999") ADD_WRITER_TEST(NAME cxwriter_globalnamelist_surface LABELS cxwriter globalnamelist YAML cxwriter_globalnamelist_surface.yaml diff --git a/test/check_writer_warnings.cmake b/test/check_writer_warnings.cmake index 57ab5819..c9f21551 100644 --- a/test/check_writer_warnings.cmake +++ b/test/check_writer_warnings.cmake @@ -2,7 +2,7 @@ execute_process( COMMAND "${WRITER_EXECUTABLE}" "${WRITER_INPUT}" RESULT_VARIABLE result OUTPUT_VARIABLE output - ERROR_VARIABLE errors ) + ERROR_VARIABLE errors) message("${output}${errors}") if(NOT "${result}" STREQUAL "0") message(FATAL_ERROR "Writer test failed: ${result}") From 280178c12a24dacf148de3e86cbbcd0f1878173b Mon Sep 17 00:00:00 2001 From: lewisn-met Date: Sat, 14 Nov 2026 23:42:55 +0000 Subject: [PATCH 3/4] Simplify regex --- src/opsinputs/opsinputs_cxwriter_mod.F90 | 14 +++++++------- src/opsinputs/opsinputs_varobswriter_mod.F90 | 14 +++++++------- test/CMakeLists.txt | 4 ++-- test/check_writer_warnings.cmake | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/opsinputs/opsinputs_cxwriter_mod.F90 b/src/opsinputs/opsinputs_cxwriter_mod.F90 index fc2eeb16..3e071da4 100644 --- a/src/opsinputs/opsinputs_cxwriter_mod.F90 +++ b/src/opsinputs/opsinputs_cxwriter_mod.F90 @@ -226,7 +226,7 @@ function opsinputs_cxwriter_create(self, f_conf, geovars) case ("verbose") GeneralMode = VerboseMode case default - write (ErrorMessage, '("GeneralMode code not recognised: ",A)') StringValue + write (ErrorMessage, '("GeneralMode not recognized: ",A)') StringValue call gen_warn(RoutineName, ErrorMessage) opsinputs_cxwriter_create = .false. return @@ -286,7 +286,7 @@ function opsinputs_cxwriter_create(self, f_conf, geovars) case ("wave") self % FH_VertCoord = FH_VertCoord_Wave case default - write (ErrorMessage, '("FH_VertCoord code not recognised: ",A)') StringValue + write (ErrorMessage, '("FH_VertCoord not recognized: ",A)') StringValue call gen_warn(RoutineName, ErrorMessage) opsinputs_cxwriter_create = .false. return @@ -311,7 +311,7 @@ function opsinputs_cxwriter_create(self, f_conf, geovars) case ("lamwrapeq") self % FH_HorizGrid = FH_HorizGrid_LamWrapEq case default - write (ErrorMessage, '("FH_HorizGrid code not recognised: ",A)') StringValue + write (ErrorMessage, '("FH_HorizGrid not recognized: ",A)') StringValue call gen_warn(RoutineName, ErrorMessage) opsinputs_cxwriter_create = .false. return @@ -326,7 +326,7 @@ function opsinputs_cxwriter_create(self, f_conf, geovars) case ("endgame") self % FH_GridStagger = FH_GridStagger_EndGame case default - write (ErrorMessage, '("FH_GridStagger code not recognised: ",A)') StringValue + write (ErrorMessage, '("FH_GridStagger not recognized: ",A)') StringValue call gen_warn(RoutineName, ErrorMessage) opsinputs_cxwriter_create = .false. return @@ -343,7 +343,7 @@ function opsinputs_cxwriter_create(self, f_conf, geovars) case ("wave") self % FH_ObsFileType = FH_ObsFileType_Wave case default - write (ErrorMessage, '("FH_ObsFileType code not recognised: ",A)') StringValue + write (ErrorMessage, '("FH_ObsFileType not recognized: ",A)') StringValue call gen_warn(RoutineName, ErrorMessage) opsinputs_cxwriter_create = .false. return @@ -357,7 +357,7 @@ function opsinputs_cxwriter_create(self, f_conf, geovars) case ("atmos") self % FH_SubModel = FH_SubModel_Atmos case default - write (ErrorMessage, '("FH_SubModel code not recognised: ",A)') StringValue + write (ErrorMessage, '("FH_SubModel not recognized: ",A)') StringValue call gen_warn(RoutineName, ErrorMessage) opsinputs_cxwriter_create = .false. return @@ -439,7 +439,7 @@ function opsinputs_cxwriter_create(self, f_conf, geovars) case ("sst") ModelType = ModelType_SST case default - write (ErrorMessage, '("model_type code not recognised: ",A)') StringValue + write (ErrorMessage, '("model_type not recognized: ",A)') StringValue call gen_warn(RoutineName, ErrorMessage) opsinputs_cxwriter_create = .false. return diff --git a/src/opsinputs/opsinputs_varobswriter_mod.F90 b/src/opsinputs/opsinputs_varobswriter_mod.F90 index c2aba82c..0eee0b09 100644 --- a/src/opsinputs/opsinputs_varobswriter_mod.F90 +++ b/src/opsinputs/opsinputs_varobswriter_mod.F90 @@ -269,7 +269,7 @@ function opsinputs_varobswriter_create(self, f_conf, comm_is_valid, comm, channe case ("verbose") GeneralMode = VerboseMode case default - write (ErrorMessage, '("GeneralMode code not recognised: ",A)') StringValue + write (ErrorMessage, '("GeneralMode not recognized: ",A)') StringValue call gen_warn(RoutineName, ErrorMessage) opsinputs_varobswriter_create = .false. return @@ -354,7 +354,7 @@ function opsinputs_varobswriter_create(self, f_conf, comm_is_valid, comm, channe case ("wave") self % FH_VertCoord = FH_VertCoord_Wave case default - write (ErrorMessage, '("FH_VertCoord code not recognised: ",A)') StringValue + write (ErrorMessage, '("FH_VertCoord not recognized: ",A)') StringValue call gen_warn(RoutineName, ErrorMessage) opsinputs_varobswriter_create = .false. return @@ -379,7 +379,7 @@ function opsinputs_varobswriter_create(self, f_conf, comm_is_valid, comm, channe case ("lamwrapeq") self % FH_HorizGrid = FH_HorizGrid_LamWrapEq case default - write (ErrorMessage, '("FH_HorizGrid code not recognised: ",A)') StringValue + write (ErrorMessage, '("FH_HorizGrid not recognized: ",A)') StringValue call gen_warn(RoutineName, ErrorMessage) opsinputs_varobswriter_create = .false. return @@ -394,7 +394,7 @@ function opsinputs_varobswriter_create(self, f_conf, comm_is_valid, comm, channe case ("endgame") self % FH_GridStagger = FH_GridStagger_EndGame case default - write (ErrorMessage, '("FH_GridStagger code not recognised: ",A)') StringValue + write (ErrorMessage, '("FH_GridStagger not recognized: ",A)') StringValue call gen_warn(RoutineName, ErrorMessage) opsinputs_varobswriter_create = .false. return @@ -412,7 +412,7 @@ function opsinputs_varobswriter_create(self, f_conf, comm_is_valid, comm, channe case ("wave") self % FH_SubModel = FH_SubModel_Wave case default - write (ErrorMessage, '("FH_SubModel code not recognised: ",A)') StringValue + write (ErrorMessage, '("FH_SubModel not recognized: ",A)') StringValue call gen_warn(RoutineName, ErrorMessage) opsinputs_varobswriter_create = .false. return @@ -436,7 +436,7 @@ function opsinputs_varobswriter_create(self, f_conf, comm_is_valid, comm, channe write (ErrorMessage, '("IC_GroundGPSOperator set to IC_GroundGPSOperatorGeneric: ",A)') StringValue call gen_warn(RoutineName, ErrorMessage) case default - write (ErrorMessage, '("IC_GroundGPSOperator code not recognised: ",A)') StringValue + write (ErrorMessage, '("IC_GroundGPSOperator not recognized: ",A)') StringValue call gen_warn(RoutineName, ErrorMessage) opsinputs_varobswriter_create = .false. return @@ -1207,7 +1207,7 @@ subroutine opsinputs_varobswriter_populateobservations( & ! TODO(someone): handle this varfield ! call Ops_Alloc(Ob % Header % HeightCOG, "HeightCOG", Ob % Header % NumObsLocal, Ob % HeightCOG) case default - write (ErrorMessage, "(A,I0)") "VarField code not recognised ", VarFields(iVarField) + write (ErrorMessage, "(A,I0)") "Varfield not recognized: ", VarFields(iVarField) call gen_warn(RoutineName, ErrorMessage) cycle end select diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3ee1fb4e..ef0635dc 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -68,7 +68,7 @@ function( ADD_WRITER_TEST ) set_tests_properties( ${PROJECT_NAME}_${_PAR_NAME} PROPERTIES FIXTURES_REQUIRED CleanOutputDir ) if(NOT _PAR_EXPECTED_WARNINGS) set_tests_properties( ${PROJECT_NAME}_${_PAR_NAME} PROPERTIES - FAIL_REGULAR_EXPRESSION "[Vv]ar[Ff]ield (code )?not recogni[sz]ed;Stash code not recognized" ) + FAIL_REGULAR_EXPRESSION "Varfield not recognized;Stash code not recognized" ) endif() endfunction() @@ -468,7 +468,7 @@ ADD_WRITER_TEST(NAME varobswriter_unknown_varfield YAML varobswriter_unknown_varfield.yaml NAMELIST VarObsWriterNamelists_unknown/Surface.nl DATA 003_VarField_rh_Surface.nc4 - EXPECTED_WARNINGS "opsinputs_varobswriter_populateobservations.*VarField code not recognised 13") + EXPECTED_WARNINGS "opsinputs_varobswriter_populateobservations.*Varfield not recognized: 13") ADD_WRITER_TEST(NAME varobswriter_globalnamelist_sternamwr LABELS varobswriter globalnamelist YAML varobswriter_globalnamelist_sternamwr.yaml diff --git a/test/check_writer_warnings.cmake b/test/check_writer_warnings.cmake index c9f21551..eae685b3 100644 --- a/test/check_writer_warnings.cmake +++ b/test/check_writer_warnings.cmake @@ -8,7 +8,7 @@ if(NOT "${result}" STREQUAL "0") message(FATAL_ERROR "Writer test failed: ${result}") endif() set( log "${output}${errors}" ) -if(log MATCHES "[Vv]ar[Ff]ield (code )?not recogni[sz]ed[: ]+-32768|Stash code not recognized: -32768") +if(log MATCHES "Varfield not recognized: -32768|Stash code not recognized: -32768") message(FATAL_ERROR "Writer reported missing-data padding as an unknown field") endif() foreach(warning IN LISTS EXPECTED_WARNINGS) From 0a645c30fe3d9179c5fd14d9156a2a1d89f3d613 Mon Sep 17 00:00:00 2001 From: ctgh Date: Mon, 23 Nov 2026 10:50:42 +0000 Subject: [PATCH 4/4] Trigger CI