Adding a new test

To add a new test create a new cmake test file in the source directory under test/reg_test/run_tests/. Here we call it newTest.cmake for the sake of reference. In this file you need to set the following variables: TEST_NAME, TEST_TYPE, EXEC_NAME, NAMELIST_FILES and NC_OUTPUT_FILES.

  • TEST_NAME is simply the name of the test you are creating. 
  • TEST_TYPE is the type of algorithm the test will run (preqx,sweqx,primdgx,swdgx, etc.).
  • EXEC_NAME is the name of the specifically compiled executable that will be used to run the test. If what your test requires does not already exist see below under "Adding a new test executable".
  • NAMELIST_FILES is the list of namelist files to be run through EXEC_NAME. This can be a list and a separate run will be created for each namelist file.
  • NC_OUTPUT_FILES are the Netcdf output files created by this test (this is specified in the namelist file). These files will be compared to baseline results

You may also need to set variables designating other files required for this test: VCOORD_FILES, NCL_FILES, REFSOLN_FILES, and MESH_FILES. These files will get copied or linked to the correct place.

Contents of the cmake test file
# The name of this test (should be the basename of this file)
SET(TEST_NAME baro1a)

# The type of run (preqx,sweqx,swdgx,etc.)
SET(TEST_TYPE preqx)

# The specifically compiled test executable that this test uses
SET(EXEC_NAME baroA)

# Number of CPUs to use
SET(NUM_CPUS 16)

# The following paths are best specified frome HOMME_ROOT (the svn checkout directory)

# The namelist file for the test
SET(NAMELIST_FILES ${HOMME_ROOT}/test/reg_test/${NAMELIST_DIR}/${TEST_NAME}.nl)
# Additional files required by the test
SET(VCOORD_FILES "${HOMME_ROOT}/test/vcoord/*20*")
SET(NCL_FILES ${HOMME_ROOT}/test/reg_test/ncl/${TEST_NAME}.ncl)
SET(REFSOLN_FILES)
SET(MESH_FILES)

# The output files produced from this run (these will be compared to baseline results)
SET(NC_OUTPUT_FILES baroclinic1.nc)

Once this file has been created, simply add the name of the file, here newTest.cmake, to the list of tests contained in test/reg_test/run_tests/test-list.cmake.

Contents of test-list.cmake
SET(HOMME_TESTS
  baro1a.cmake
  baro1b.cmake
  baro2a.cmake
  baro2b.cmake
  baro2c.cmake
  baro2d.cmake
  swtc1.cmake
  swtc5.cmake
  swtc6.cmake
  swtc1-dg.cmake
  swtc2-dg.cmake
  swtc5-dg.cmake
  newTest.cmake
)

That's it. The next time run configure, the test files will be created in the build directory under tests/newTest. Be sure to see that everything required for the test is present in this directory.

The new test will be run with all of the tests during "make check" and can be run by itself with "make test-newTest".

Adding a new test executable

The above method for adding a test required the specification of a test executable in the variable EXEC_NAME. This represents a specifically compiled executable for the test case. This means that NP, PLEV, etc. have been set at compile time. A new test executable can be created as a subdirectory under test_execs.

Contents of test-list.cmake
jamroz@yslogin2:homme-newTrunk> pwd
/glade/scratch/jamroz/homme/homme-newTrunk
jamroz@yslogin2:homme-newTrunk> cd test_execs
jamroz@yslogin2:test_execs> ls  
baroA  baroB  baroC  CMakeLists.txt  swtcA  swtcB  swtcC  swtc-dgA
jamroz@yslogin2:test_execs> svn cp baroA newTestExec
A         newTestExec
jamroz@yslogin2:test_execs>

Now edit the CMakeLists file in the newTestExec subdirectory (newTestExec/CMakeLists.txt) to specify the compile time variables for the test executable required for your test.

Edit the CMakeList.txt file
# Set the include directories
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}
                    ${PREQX_INCLUDE_DIRS})

# Set the variables for this test as shown below
#              EXEC_NAME   EXEC_TYPE  SOURCES    NP  NC PLEV NTRAC USE_PIO  WITH_ENERGY
createTestExec(newTestExec preqx      PREQX_SRCS  5   5   12     1   FALSE        TRUE)

Finally add this subdirectory to the test_execs/CMakeLists.txt file under the appropriate section.

test_execs/CMakeLists.txt
# Add the test exec subdirs for the preqx executable
IF(${BUILD_HOMME_PREQX})
  ADD_SUBDIRECTORY(baroA)
  ADD_SUBDIRECTORY(baroB)
  ADD_SUBDIRECTORY(baroC)
  ADD_SUBDIRECTORY(newTestExec)
ENDIF()

That's it. When you reconfigure this executable will be added as a target for make. It will be build by default when compiling and you can build only this target by running "make newTestExec".

  • No labels