Skip to content

Commit

Permalink
EAMxx: add rrtmgp standalone to baselines tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bartgol committed Mar 15, 2024
1 parent 8bd69d1 commit ef2ca0b
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 79 deletions.
8 changes: 4 additions & 4 deletions components/eamxx/src/physics/rrtmgp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Build baseline code
add_executable(generate_baseline generate_baseline.cpp)
target_link_libraries(generate_baseline PUBLIC scream_rrtmgp rrtmgp_test_utils)

if (SCREAM_ONLY_GENERATE_BASELINES)
# Build baseline code
add_executable(generate_baseline generate_baseline.cpp)
target_link_libraries(generate_baseline PUBLIC scream_rrtmgp rrtmgp_test_utils)

# Generate allsky baseline with the usual cmake custom command-target pair pattern
# Note: these "baselines" are not to compare scream with a previous version, but
# rather to compare scream::rrtmgp with raw rrtmgp.
Expand Down
153 changes: 78 additions & 75 deletions components/eamxx/tests/uncoupled/rrtmgp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,87 +1,90 @@
INCLUDE (ScreamUtils)

# Test atmosphere processes
if (NOT SCREAM_ONLY_GENERATE_BASELINES)
# Ensure test input files are present in the data dir
GetInputFile(scream/init/${EAMxx_tests_IC_FILE_72lev})
set (TEST_BASE_NAME rrtmgp_standalone)
set (FIXTURES_BASE_NAME ${TEST_BASE_NAME}_generate_output_nc_files)

set (TEST_BASE_NAME rrtmgp_standalone)
set (FIXTURES_BASE_NAME ${TEST_BASE_NAME}_generate_output_nc_files)
# Ensure test input files are present in the data dir
GetInputFile(scream/init/${EAMxx_tests_IC_FILE_72lev})

if (SCREAM_ENABLE_BASELINE_TESTS)
# Unit test to compare against raw rrtmgp output
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/input_unit.yaml
${CMAKE_CURRENT_BINARY_DIR}/input_unit.yaml)
CreateUnitTest(${TEST_BASE_NAME}_unit rrtmgp_standalone_unit.cpp
LABELS rrtmgp physics driver
LIBS scream_rrtmgp rrtmgp scream_control yakl diagnostics rrtmgp_test_utils
EXE_ARGS "--ekat-test-params rrtmgp_inputfile=${SCREAM_DATA_DIR}/init/rrtmgp-allsky.nc,rrtmgp_baseline=${SCREAM_BASELINES_DIR}/data/rrtmgp-allsky-baseline.nc"
)
endif()

## Create rrtmgp stand alone executable
CreateUnitTestExec(${TEST_BASE_NAME} "rrtmgp_standalone.cpp"
LIBS scream_rrtmgp rrtmgp scream_control yakl diagnostics
)

# The RRTMGP stand-alone test that runs multi-step
# Set AD configurable options
SetVarDependingOnTestSize(NUM_STEPS 2 5 48)
set (ATM_TIME_STEP 1800)
set (RUN_T0 2021-10-12-45000)

# Test non-chunked version (sweep multiple ranks)
set (SUFFIX "_not_chunked")
set (COL_CHUNK_SIZE 1000)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/output.yaml
${CMAKE_CURRENT_BINARY_DIR}/output_not_chunked.yaml)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/input.yaml
${CMAKE_CURRENT_BINARY_DIR}/input_not_chunked.yaml)
CreateUnitTestFromExec(
${TEST_BASE_NAME}_not_chunked ${TEST_BASE_NAME}
if (SCREAM_ENABLE_BASELINE_TESTS AND NOT SCREAM_ONLY_GENERATE_BASELINES)
# Unit test to compare against raw rrtmgp output
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/input_unit.yaml
${CMAKE_CURRENT_BINARY_DIR}/input_unit.yaml)
CreateUnitTest(${TEST_BASE_NAME}_unit rrtmgp_standalone_unit.cpp
LABELS rrtmgp physics driver
MPI_RANKS ${TEST_RANK_START} ${TEST_RANK_END}
EXE_ARGS "--ekat-test-params inputfile=input_not_chunked.yaml"
FIXTURES_SETUP_INDIVIDUAL ${FIXTURES_BASE_NAME}_not_chunked
LIBS scream_rrtmgp rrtmgp scream_control yakl diagnostics rrtmgp_test_utils
EXE_ARGS "--ekat-test-params rrtmgp_inputfile=${SCREAM_DATA_DIR}/init/rrtmgp-allsky.nc,rrtmgp_baseline=${SCREAM_BASELINES_DIR}/data/rrtmgp-allsky-baseline.nc"
)
endif()

# Compare output files produced by npX tests, to ensure they are bfb
include (CompareNCFiles)
## Create rrtmgp stand alone executable
CreateUnitTestExec(${TEST_BASE_NAME} "rrtmgp_standalone.cpp"
LIBS scream_rrtmgp rrtmgp scream_control yakl diagnostics
)

CompareNCFilesFamilyMpi (
TEST_BASE_NAME ${TEST_BASE_NAME}_not_chunked
FILE_META_NAME ${TEST_BASE_NAME}_output_not_chunked.INSTANT.nsteps_x${NUM_STEPS}.npMPIRANKS.${RUN_T0}.nc
MPI_RANKS ${TEST_RANK_START} ${TEST_RANK_END}
LABELS rrtmgp physics
META_FIXTURES_REQUIRED ${FIXTURES_BASE_NAME}_not_chunked_npMPIRANKS_omp1
)
# The RRTMGP stand-alone test that runs multi-step
# Set AD configurable options
SetVarDependingOnTestSize(NUM_STEPS 2 5 48)
set (ATM_TIME_STEP 1800)
set (RUN_T0 2021-10-12-45000)

## Test chunked version (only for ${TEST_RANK_END}) and compare against non-chunked
set (SUFFIX "_chunked")
math (EXPR COL_PER_RANK "218 / ${TEST_RANK_END}")
math (EXPR COL_CHUNK_SIZE "${COL_PER_RANK} / 2")
if (COL_CHUNK_SIZE LESS 1)
message (FATAL_ERROR "Error! Chunk size for rrtmgp unit test is less than 1.")
endif()
# Test non-chunked version (sweep multiple ranks)
set (SUFFIX "_not_chunked")
set (COL_CHUNK_SIZE 1000)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/output.yaml
${CMAKE_CURRENT_BINARY_DIR}/output_not_chunked.yaml)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/input.yaml
${CMAKE_CURRENT_BINARY_DIR}/input_not_chunked.yaml)
CreateUnitTestFromExec(
${TEST_BASE_NAME}_not_chunked ${TEST_BASE_NAME}
LABELS rrtmgp physics driver
MPI_RANKS ${TEST_RANK_START} ${TEST_RANK_END}
EXE_ARGS "--ekat-test-params inputfile=input_not_chunked.yaml"
FIXTURES_SETUP_INDIVIDUAL ${FIXTURES_BASE_NAME}_not_chunked
)

configure_file (${CMAKE_CURRENT_SOURCE_DIR}/input.yaml
${CMAKE_CURRENT_BINARY_DIR}/input_chunked.yaml)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/output.yaml
${CMAKE_CURRENT_BINARY_DIR}/output_chunked.yaml)
CreateUnitTestFromExec(
${TEST_BASE_NAME}_chunked ${TEST_BASE_NAME}
LABELS rrtmgp physics driver
MPI_RANKS ${TEST_RANK_END}
EXE_ARGS "--ekat-test-params inputfile=input_chunked.yaml"
FIXTURES_SETUP_INDIVIDUAL ${FIXTURES_BASE_NAME}_chunked
PROPERTIES PASS_REGULAR_EXPRESSION "(beg.end: 0, ${COL_CHUNK_SIZE})"
)
# Compare output files produced by npX tests, to ensure they are bfb
include (CompareNCFiles)

CompareNCFilesFamilyMpi (
TEST_BASE_NAME ${TEST_BASE_NAME}_not_chunked
FILE_META_NAME ${TEST_BASE_NAME}_output_not_chunked.INSTANT.nsteps_x${NUM_STEPS}.npMPIRANKS.${RUN_T0}.nc
MPI_RANKS ${TEST_RANK_START} ${TEST_RANK_END}
LABELS rrtmgp physics
META_FIXTURES_REQUIRED ${FIXTURES_BASE_NAME}_not_chunked_npMPIRANKS_omp1
)

CompareNCFiles(
TEST_NAME ${TEST_BASE_NAME}_chunked_vs_not_chunked
SRC_FILE ${TEST_BASE_NAME}_output_chunked.INSTANT.nsteps_x${NUM_STEPS}.np${TEST_RANK_END}.${RUN_T0}.nc
TGT_FILE ${TEST_BASE_NAME}_output_not_chunked.INSTANT.nsteps_x${NUM_STEPS}.np${TEST_RANK_END}.${RUN_T0}.nc
LABELS rrtmgp physics
FIXTURES_REQUIRED ${FIXTURES_BASE_NAME}_chunked_np${TEST_RANK_END}_omp1
${FIXTURES_BASE_NAME}_not_chunked_np${TEST_RANK_END}_omp1)
## Test chunked version (only for ${TEST_RANK_END}) and compare against non-chunked
set (SUFFIX "_chunked")
math (EXPR COL_PER_RANK "218 / ${TEST_RANK_END}")
math (EXPR COL_CHUNK_SIZE "${COL_PER_RANK} / 2")
if (COL_CHUNK_SIZE LESS 1)
message (FATAL_ERROR "Error! Chunk size for rrtmgp unit test is less than 1.")
endif()

configure_file (${CMAKE_CURRENT_SOURCE_DIR}/input.yaml
${CMAKE_CURRENT_BINARY_DIR}/input_chunked.yaml)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/output.yaml
${CMAKE_CURRENT_BINARY_DIR}/output_chunked.yaml)
CreateUnitTestFromExec(
${TEST_BASE_NAME}_chunked ${TEST_BASE_NAME}
LABELS rrtmgp physics driver
MPI_RANKS ${TEST_RANK_END}
EXE_ARGS "--ekat-test-params inputfile=input_chunked.yaml"
FIXTURES_SETUP_INDIVIDUAL ${FIXTURES_BASE_NAME}_chunked
PROPERTIES PASS_REGULAR_EXPRESSION "(beg.end: 0, ${COL_CHUNK_SIZE})"
)

CompareNCFiles(
TEST_NAME ${TEST_BASE_NAME}_chunked_vs_not_chunked
SRC_FILE ${TEST_BASE_NAME}_output_chunked.INSTANT.nsteps_x${NUM_STEPS}.np${TEST_RANK_END}.${RUN_T0}.nc
TGT_FILE ${TEST_BASE_NAME}_output_not_chunked.INSTANT.nsteps_x${NUM_STEPS}.np${TEST_RANK_END}.${RUN_T0}.nc
LABELS rrtmgp physics
FIXTURES_REQUIRED ${FIXTURES_BASE_NAME}_chunked_np${TEST_RANK_END}_omp1
${FIXTURES_BASE_NAME}_not_chunked_np${TEST_RANK_END}_omp1)

# Compare one of the output files with the baselines.
# Note: one is enough, since we already check that np1 is BFB with npX,
# and that chunked is bfb with not_chunked
set (OUT_FILE ${TEST_BASE_NAME}_output_chunked.INSTANT.nsteps_x${NUM_STEPS}.np${TEST_RANK_END}.${RUN_T0}.nc)
CreateBaselineTest(${TEST_BASE_NAME}_chunked ${TEST_RANK_END} ${OUT_FILE} ${FIXTURES_BASE_NAME}_chunked)

0 comments on commit ef2ca0b

Please sign in to comment.