-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from kgerheiser/feature/cmake-tests
Build tests with CMake
- Loading branch information
Showing
96 changed files
with
932 additions
and
6,424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,43 @@ | ||
#list(APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure") | ||
|
||
execute_process(COMMAND cmake -E create_symlink | ||
"${CMAKE_SOURCE_DIR}/tests/data" | ||
"${CMAKE_CURRENT_BINARY_DIR}/data" # New name | ||
) | ||
|
||
|
||
add_pfunit_ctest (ip2_test | ||
TEST_SOURCES test_mod.pf | ||
LINK_LIBRARIES ip2::ip2_d sp::sp_d | ||
) | ||
"${CMAKE_CURRENT_SOURCE_DIR}/data" | ||
"${CMAKE_CURRENT_BINARY_DIR}/data" # New name | ||
) | ||
|
||
if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") | ||
set(CMAKE_Fortran_FLAGS "-r8 -g -traceback -assume byterecl") | ||
set(CMAKE_C_FLAGS "-std=c99") | ||
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") | ||
set(CMAKE_Fortran_FLAGS "-fdefault-real-8 -fno-range-check -g -fbacktrace -fcheck=bounds") | ||
endif() | ||
|
||
# Contains common routines used for testing such as reading and interpolating data | ||
add_library(test_library input_data_mod.f90 interp_mod.f90) | ||
target_link_libraries(test_library PUBLIC ip2::ip2_d) | ||
|
||
link_libraries(test_library) | ||
|
||
add_executable(test_gdswzd test_gdswzd.c) | ||
add_executable(test_scalar test_scalar.f90) | ||
add_executable(test_vector test_vector.f90) | ||
|
||
add_test(test_gdswzd_c test_gdswzd) | ||
|
||
# scalar tests | ||
add_test(test_lambert_biliner_scalar test_scalar 218 0) | ||
add_test(test_gaussian_neighbor_scalar test_scalar 127 2) | ||
add_test(test_latlon_bilinear_scalar test_scalar 3 0) | ||
add_test(test_mercator_bicubic_scalar test_scalar 8 1) | ||
add_test(test_polar-stereo_neighbor-budget_scalar test_scalar 212 6) | ||
add_test(test_rotatedB_spectral_scalar test_scalar 205 4) | ||
add_test(test_rotatedE_budget_scalar test_scalar 203 3) | ||
|
||
# vector tests | ||
add_test(test_lambert_biliner_vector test_vector 218 0) | ||
add_test(test_gaussian_neighbor_vector test_vector 127 2) | ||
add_test(test_latlon_bilinear_vector test_vector 3 0) | ||
add_test(test_mercator_bicubic_vector test_vector 8 1) | ||
add_test(test_polar-stereo_neighbor-budget_vector test_vector 212 6) | ||
add_test(test_rotatedB_spectral_vector test_vector 205 4) | ||
add_test(test_rotatedE_budget_vector test_vector 203 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,15 @@ | ||
## Description | ||
|
||
Unit test for the NCEP IPOLATES library (IPLIB). | ||
|
||
Please refer to README.md in the main directory for how to run tests using PFUnit. | ||
|
||
This file is kept temporarily for historical purposes until all unit tests are converted to use pfunit. | ||
|
||
## ABSTRACT: | ||
--------- | ||
|
||
This test invokes IPOLATES to interpolate scalar and | ||
vector data to several grids of various map projections | ||
using all IPOLATES interpolation options. The output | ||
is compared to baseline data and a summary of differences is | ||
sent to standard output. | ||
|
||
|
||
## HOW THE TEST WORKS: | ||
------------------- | ||
## How the Test Works | ||
|
||
There are two separate programs to test the scalar and vector interpolation. | ||
The scalar program calls routine 'ipolates' to interpolate a global field | ||
|
@@ -43,162 +36,42 @@ the baseline data are computed and sent to standard output. For this | |
unit test to pass the differences should be "small". | ||
|
||
|
||
## DIRECTORY LAYOUT: | ||
----------------- | ||
|
||
./sorc - Contains the files and scripts needed to build the | ||
unit test programs. And the programs themselves. | ||
|
||
./sorc/scalar - | ||
Contains a Fortran program to call routine 'ipolates' | ||
to interpolate a global field of albedo data to | ||
several grids and using all interpolation options. | ||
|
||
./sorc/vector - | ||
Contains a Fortran program to call routine 'ipolatev' | ||
to interpolate a global field of u/v wind data to | ||
several grids and using all interpolation options. | ||
|
||
./exec - Contains the unit test executables. There is one executable | ||
for the single ("4"), double ("8") and mixed ("d") precision | ||
versions of the IPOLATES library: | ||
|
||
scalar_4.exe scalar_8.exe scalar_d.exe | ||
vector_4.exe vector_8.exe vector_d.exe | ||
|
||
./work - The working directory for program execution. | ||
## Data | ||
|
||
./lib - The location of the IPOLATES libraries and module files as | ||
expected by the unit test programs. | ||
### Input Data | ||
Contains the input scalar and vector data. The | ||
data are in binary little endian format: | ||
|
||
./scripts - Contains scripts to run this unit test. | ||
- data/scalar/global_snoalb.bin (global snow albedo) | ||
- data/vector/global_uv_wind.bin (global 500mb u/v wind) | ||
|
||
./input_data - Contains the input scalar and vector data. The | ||
data are in binary little endian format: | ||
### Baseline Data | ||
Contains the baseline set of scalar and vector data | ||
interpolated to each target grid. Binary, little endian | ||
format. Output from each call to routine ipolates and | ||
ipolatev is compared to its baseline counterpart. There | ||
are sub-directories for the scalar and vector data. | ||
And under these sub-directories, there are sub-directories | ||
for the single (4_byte_bin) and mixed/double (8_byte_bin) | ||
versions of the IPOLATES library. The file names | ||
contain the grid number and IPOLATES interpolation | ||
option (defined below); i.e.: | ||
|
||
./scalar/global_snoalb.bin (global snow albedo) | ||
./vector/global_uv_wind.bin (global 500mb u/v wind) | ||
- grid${gridnum}.opt${ip_option}.bin_4/8 | ||
|
||
./baseline_data - Contains the baseline set of scalar and vector data | ||
interpolated to each target grid. Binary, little endian | ||
format. Output from each call to routine ipolates and | ||
ipolatev is compared to its baseline counterpart. There | ||
are sub-directories for the scalar and vector data. | ||
And under these sub-directories, there are sub-directories | ||
for the single (4_byte_bin) and mixed/double (8_byte_bin) | ||
versions of the IPOLATES library. The file names | ||
contain the grid number and IPOLATES interpolation | ||
option (defined below); i.e.: | ||
|
||
grid${gridnum}.opt${ip_option}.bin_4/8 | ||
|
||
Grads control files to view each file are located in the | ||
./grads subdirectory. These files do not account | ||
for map projection. Rather, they display the data | ||
as a 2-D field with no interpolation. So when | ||
viewing, do a "set mproj off" during your grads session. | ||
Grads control files to view each file are located in the | ||
grads subdirectory. These files do not account | ||
for map projection. Rather, they display the data | ||
as a 2-D field with no interpolation. So when | ||
viewing, do a "set mproj off" during your grads session. | ||
|
||
|
||
## How to Run | ||
|
||
## HOW TO RUN THE TEST: | ||
-------------------- | ||
|
||
1) Build the IPOLATES library. Go to $root and read the | ||
README.build file for details. | ||
|
||
|
||
2) Ensure the ./lib directory contains (or links to) the IPOLATES libraries and | ||
its module files. The ./lib directory already contains links that point to the | ||
libraries and module files as they would exist when using the "nco" install | ||
option from step (1). I.e: | ||
|
||
module file directories: | ||
incmod_4 -> $root/ip/vX.Y.Z/include/ip_vX.Y.Z_4 (single precision) | ||
incmod_d -> $root/ip/vX.Y.Z/include/ip_vX.Y.Z_d (mixed precision) | ||
incmod_8 -> $root/ip/vX.Y.Z/include/ip_vX.Y.Z_8 (double precistion) | ||
|
||
libraries: | ||
libip_4.a -> $root/ip/vX.Y.Z/libip_vX.Y.Z_4.a (single precision) | ||
libip_d.a -> $root/ip/vX.Y.Z/libip_vX.Y.Z_d.a (mixed precision) | ||
libip_8.a -> $root/ip/vX.Y.Z/libip_vX.Y.Z_8.a (double precistion) | ||
|
||
So if that is how IPOLATES was built in step (1), there is | ||
nothing more to do. | ||
|
||
However, if you want to build with another version of the library, | ||
or if you built them in step (1) using the "gnu" or "nco_cray" install option, | ||
you will need to adjust these links. Example: Suppose you want to | ||
test with the OPS version of IPOLATES on WCOSS Phase 2. You would set the | ||
links as follows: | ||
|
||
incmod_4 -> /nwprod2/lib/ip/vX.Y.Z/include/ip_vX.Y.Z_4 | ||
incmod_d -> /nwprod2/lib/ip/vX.Y.Z/include/ip_vX.Y.Z_d | ||
incmod_8 -> /nwprod2/lib/ip/vX.Y.Z/include/ip_vX.Y.Z_8 | ||
|
||
libip_4.a -> /nwprod2/lib/ip/vX.Y.Z/libip_vX.Y.Z_4.a | ||
libip_d.a -> /nwprod2/lib/ip/vX.Y.Z/libip_vX.Y.Z_d.a | ||
libip_8.a -> /nwprod2/lib/ip/vX.Y.Z/libip_vX.Y.Z_8.a | ||
|
||
|
||
3) Build the "scalar" and "vector" unit test programs | ||
by running the "make_unit_test.ksh" build script. (Use the | ||
"make_unit_test_wcoss-cray.ksh" build script on WCOSS-Cray.) | ||
|
||
The IPOLATES library is dependant on the NCEP SP | ||
(spectral) library (SPLIB). Intel compiled versions of SPLIB | ||
exist on Theia and WCOSS Phase 1/2. When running "make_unit_test.ksh" | ||
on these machines, these SP libraries are automatically located | ||
by module loads and stored in these environment variables: | ||
|
||
SP_LIB4 (single precision) | ||
SP_LIBd (mixed precision) | ||
SP_LIB8 (double precistion) | ||
|
||
On WCOSS-Cray, Intel and Cray compiled versions of SPLIB exist. | ||
And the "make_unit_test_wcoss-cray.ksh" script will locate | ||
them by module loads. | ||
|
||
If you are testing on a machine other than WCOSS or Theia, | ||
or you have compiled IPOLATES with a compiler other than Intel or Cray, | ||
you will need to locate (or build) SPLIB and set these environment | ||
varibles by editing the build script, or by exporting these | ||
variables on the command line before invoking it. | ||
Example (when using bash): | ||
|
||
$ export SP_LIB4=$directory/libsp_4.a | ||
|
||
Once the SP libraries have been located, run "make_unit_test.ksh" | ||
(or make_unit_test_wcoss-cray.ksh) from the command line. The script | ||
takes one argument: the "config-setup" file that was used to compile | ||
IPOLATES. So, if you built IPOLATES with the Intel-optimized option, | ||
you would invoke as follows: | ||
|
||
$ make_unit_test.ksh ifort.setup | ||
|
||
On WCOSS-Cray, you would do the following: | ||
|
||
$ make_unit_test_wcoss-cray.ksh ifort.setup | ||
|
||
|
||
4) Run the unit test. Go to ./scripts. To run interactively, type: | ||
|
||
$ run_unit_test.ksh | ||
|
||
You may want to pipe the output to a log fle. Check output for any | ||
"large" differences between the computed and baseline data. | ||
|
||
To run "run_unit_test.ksh" on the WCOSS or Theia compute nodes, | ||
invoke these driver scripts as follows: | ||
|
||
$ run_wcoss.ksh (WCOSS Phase 1/2) | ||
$ run_wcoss-cray.ksh (WCOSS-Cray) | ||
$ run_wcoss-dell.ksh (WCOSS-Phase 3/Dell) | ||
$ sbatch run_theia.ksh (Theia) | ||
From the build directory simply run `make test` | ||
|
||
In this case, output is sent to "unit_test.log". | ||
Alternatively, to run all tests and show stdout run `ctest --verbose` | ||
|
||
The individual test executables can be run from `<build_directory>/tests`. `test_scalar` and `test_vector` take two command-line arguments for the grid type and interpolation scheme. | ||
|
||
## QUESTIONS: | ||
---------- | ||
|
||
Contact: [email protected] |
Oops, something went wrong.