Skip to content

Commit c88ee96

Browse files
nusbaumemwaxmonsky
andauthored
Add pio_reader Fortran unit tests (#403)
Tag name (required for release branches): Originator(s): @mwaxmonsky @nusbaume Description (include the issue title, and the keyword ['closes', 'fixes', 'resolves'] followed by the issue number): This PR introduces pFUnit Fortran unit tests for the `pio_reader` implementation of the `ccpp_io_reader` abstract class that is used in CAM-SIMA, which should now run automatically with any PR to CAM-SIMA as part of the Fortran unit tests Github Action. Note that although several tests are added by this PR, the code coverage is not complete, as several of the edge cases require specialized NetCDF files that will need to be created. Github issue #404 can be used to keep track of this. Describe any changes made to build system: A src/physics/utils/CMakeLists.txt M test/unit/fortran/CMakeLists.txt A test/unit/fortran/ccpp_framework_stub/CMakeLists.txt A test/unit/fortran/cmake/FindNetCDF.cmake A test/unit/fortran/cmake/FindPIO.cmake A test/unit/fortran/mock_routines/CMakeLists.txt A test/unit/fortran/src/pio_reader/CMakeLists.tx - Add files needed to build the pio_reader unit tests and their dependencies using CMake. Describe any changes made to the namelist: N/A List any changes to the defaults for the input datasets (e.g. boundary datasets): N/A List all files eliminated and why: N/A List all files added and what they do: A test/unit/fortran/ccpp_framework_stub/ccpp_kinds.F90 A test/unit/fortran/mock_routines/cam_pio_utils.F90 A test/unit/fortran/src/pio_reader/test_pio_reader.pf - Add pio_reader unit tests (and associated dependencies). List all existing files that have been modified, and describe the changes: (Helpful git command: `git diff --name-status development...<your_branch_name>`) M .github/workflows/fortran_unit_tests.yml - Add pio_reader unit tests to Github Action worfklow. M .gitignore - Have git ignore all compiled Fortran files (".o" and ".mod"). M src/physics/utils/pio_reader.F90 - Fix bugs and remove un-needed host model dependencies found during testing. M src/utils/cam_pio_utils.F90 - Add optional "errcode" variable that can be used during testing (and to ensure that pio_reader doesn't kill the host model). If there are new failures (compared to the `test/existing-test-failures.txt` file), have them OK'd by the gatekeeper, note them here, and add them to the file. If there are baseline differences, include the test and the reason for the diff. What is the nature of the change? Roundoff? derecho/intel/aux_sima: ALL PASS derecho/gnu/aux_sima: ALL PASS If this changes climate describe any run(s) done to evaluate the new climate in enough detail that it(they) could be reproduced: CAM-SIMA date used for the baseline comparison tests if different than latest: --------- Co-authored-by: Michael Waxmonsky <mwaxmonsky@ucar.edu>
1 parent 110861e commit c88ee96

File tree

14 files changed

+2283
-141
lines changed

14 files changed

+2283
-141
lines changed

.github/workflows/fortran_unit_tests.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ jobs:
2323
CXX: g++-${{ matrix.version }}
2424
FC: gfortran-${{ matrix.version }}
2525
steps:
26+
- name: install dependencies
27+
run: |
28+
sudo apt install -y libnetcdff-dev libnetcdf-mpi-dev libopenmpi-dev openmpi-bin doxygen
29+
2630
- name: Checkout cam-sima
2731
uses: actions/checkout@v4
2832

@@ -34,16 +38,45 @@ jobs:
3438
cd build
3539
make install
3640
41+
- name: Build PIO
42+
run: |
43+
git clone --depth 1 --branch pio2_6_6 https://github.com/NCAR/ParallelIO.git
44+
cd ParallelIO
45+
FC=$(which mpif90) \
46+
CC=$(which mpicc) \
47+
cmake -S./ -B./build \
48+
-DCMAKE_INSTALL_PREFIX=./install \
49+
-DPIO_ENABLE_TIMING=OFF \
50+
-DWITH_PNETCDF=OFF \
51+
-DCMAKE_PREFIX_PATH="/usr/lib/x86_64-linux-gnu/cmake/netCDF" \
52+
-DNetCDF_Fortran_LIBRARY="/usr/lib/x86_64-linux-gnu/libnetcdff.a" \
53+
-DNetCDF_C_LIBRARY="/usr/lib/x86_64-linux-gnu/libnetcdf.so" \
54+
-DCMAKE_EXE_LINKER_FLAGS="-lmpi -Wl,--no-as-needed"
55+
cd build
56+
make
57+
make install
58+
59+
- name: Checkout atmospheric_physics
60+
run: |
61+
bin/git-fleximod update ncar-physics ccpp-framework share
62+
3763
- name: Build cam-sima
3864
run: |
65+
PIO_ROOT=$GITHUB_WORKSPACE/ParallelIO/install/ \
3966
cmake \
40-
-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/pFUnit/build/installed \
67+
-DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/pFUnit/build/installed;/usr/lib/x86_64-linux-gnu/cmake/netCDF;/usr/lib/x86_64-linux-gnu/" \
4168
-DCAM_SIMA_ENABLE_CODE_COVERAGE=ON \
69+
-DCAM_SIMA_ENABLE_IO_TESTS=ON \
70+
-DCAM_SIMA_ENABLE_TESTS=ON \
4271
-B./build \
4372
-S./test/unit/fortran
4473
cd build
4574
make
4675
76+
- name: Checkout datafiles for file IO reader tests
77+
run: |
78+
git clone https://github.com/earth-system-radiation/rrtmgp-data.git
79+
4780
- name: Run fortran unit tests
4881
run: |
4982
cd build && ctest -V --output-on-failure --output-junit test_results.xml

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22
*.pyc
33
buildnmlc
44

5+
# Ignore compiled Fortran
6+
*.mod
7+
*.o
8+
59
# Ignore test output
610
test/include/*.mod
711
test/include/*.o
812
test/unit/python/tmp
913
test/system/*.log
1014
test/system/cime-tests.o*
1115
test_driver_*.sh
16+
build/
1217

1318
# Ignore editor temporaries and backups
1419
*.swp

src/physics/utils/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
set(IO_READER_SOURCE pio_reader.F90
2+
pio_reader_sub.F90
3+
${CMAKE_CURRENT_SOURCE_DIR}/../ncar_ccpp/phys_utils/ccpp_io_reader.F90
4+
${CMAKE_CURRENT_SOURCE_DIR}/../../../share/src/shr_kind_mod.F90)
5+
6+
# io_reader is not integrated into the CMake build of any top level
7+
# project yet and this CMake is for testing purposes only.
8+
# Making a change to this project's CMake will not impact the build of
9+
# a parent project at this time.
10+
add_library(io_reader ${IO_READER_SOURCE})
11+
target_link_libraries(io_reader PUBLIC
12+
MPI::MPI_Fortran
13+
MPI::MPI_C
14+
NetCDF::NetCDF_C
15+
NetCDF::NetCDF_Fortran
16+
PIO::PIO_Fortran
17+
PIO::PIO_C
18+
cam_pio_utils
19+
ccpp_framework)
20+
target_include_directories(io_reader PRIVATE ${CMAKE_BINARY_DIR}/ccpp_framework_stub
21+
${CMAKE_BINARY_DIR}/mock_routines)

0 commit comments

Comments
 (0)