Skip to content

Commit

Permalink
build(ForcingsEngineLumpedDataProviderTest): configure aorc config fi…
Browse files Browse the repository at this point in the history
…le path and scratch at configure and build time
  • Loading branch information
program-- committed Aug 14, 2024
1 parent eebc24b commit ca3d6aa
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
8 changes: 0 additions & 8 deletions data/forcing/forcings-engine/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ InputMandatory: [1]
OutputFrequency: 60
SubOutputHour: 0
SubOutFreq: 0
ScratchDir: "data/forcing/forcings-engine/scratch"
ScratchDir: "@FORCINGS_ENGINE_SCRATCH_DIR@"
Output: 1
compressOutput: 0
floatOutput: 0
Expand Down Expand Up @@ -47,7 +47,7 @@ ShortwaveDownscaling: [0]
PressureDownscaling: [0]
PrecipDownscaling: [0]
HumidityDownscaling: [0]
DownscalingParamDirs: ["data/forcing/forcings-engine/scratch"]
DownscalingParamDirs: ["@FORCINGS_ENGINE_SCRATCH_DIR@"]
SuppPcp: []
SuppPcpForcingTypes: ''
SuppPcpDirectories: ''
Expand Down
12 changes: 12 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,18 @@ ngen_add_test(
NGEN_WITH_PYTHON
)

if(TARGET test_forcings_engine)
set(FORCINGS_ENGINE_SCRATCH_DIR "${CMAKE_CURRENT_BINARY_DIR}/forcings_engine_scratch")
file(MAKE_DIRECTORY "${FORCINGS_ENGINE_SCRATCH_DIR}")
configure_file(
"${CMAKE_CURRENT_LIST_DIR}/../data/forcing/forcings-engine/config_aorc.yml.in" # Input
"${CMAKE_CURRENT_BINARY_DIR}/config_aorc.yml"
)
target_compile_definitions(test_forcings_engine
PUBLIC
-DNGEN_LUMPED_CONFIG_PATH="${CMAKE_CURRENT_BINARY_DIR}/config_aorc.yml")
endif()

########################## Series Unit Tests
ngen_add_test(
test_mdarray
Expand Down
6 changes: 5 additions & 1 deletion test/forcing/ForcingsEngineLumpedDataProvider_Test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include <gtest/gtest.h>

#ifndef NGEN_LUMPED_CONFIG_PATH
#error "Lumped config file path not defined! Set `-DNGEN_LUMPED_CONFIG_PATH`"
#endif

#include <NGenConfig.h>
#if NGEN_WITH_MPI
#include <mpi.h>
Expand All @@ -24,7 +28,7 @@ struct ForcingsEngineLumpedDataProviderTest
#endif
}

static constexpr const char* config_file = "data/forcing/forcings-engine/config_aorc.yml";
static constexpr const char* config_file = NGEN_LUMPED_CONFIG_PATH;
static const std::time_t time_start;
static const std::time_t time_end;
static std::shared_ptr<utils::ngenPy::InterpreterUtil> gil_;
Expand Down

0 comments on commit ca3d6aa

Please sign in to comment.