diff --git a/.github/workflows/cmake_ncint.yml b/.github/workflows/cmake_ncint.yml new file mode 100644 index 00000000000..bf306bef28d --- /dev/null +++ b/.github/workflows/cmake_ncint.yml @@ -0,0 +1,58 @@ +# This is the GitHub workflow file to build and test the PIO library with CMake, and netCDF integration. + +# Ed Hartnett 8/19/20 + + name: cmake_ncint + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + env: + CC: mpicc + FC: mpifort + CPPFLAGS: "-I/usr/include -I/usr/local/include -I/home/runner/pnetcdf/include" + LDFLAGS: "-L/home/runner/pnetcdf/lib" + LD_LIBRARY_PATH: "/home/runner/pnetcdf/lib" + + steps: + - uses: actions/checkout@v2 + - name: Installs + run: | + sudo apt-get install netcdf-bin libnetcdf-dev doxygen graphviz wget gfortran libjpeg-dev libz-dev openmpi-bin libopenmpi-dev + + - name: cache-pnetcdf + id: cache-pnetcdf + uses: actions/cache@v2 + with: + path: ~/pnetcdf + key: pnetcdf-${{ runner.os }}-1.12.1 + + - name: build-pnetcdf + if: steps.cache-pnetcdf.outputs.cache-hit != 'true' + run: | + set -x + wget https://parallel-netcdf.github.io/Release/pnetcdf-1.12.1.tar.gz &> /dev/null + tar -xzvf pnetcdf-1.12.1.tar.gz + pushd pnetcdf-1.12.1 + ./configure --prefix=/home/runner/pnetcdf --enable-shared --disable-cxx + make + sudo make install + popd + + - name: cmake build + run: | + set -x + mkdir build + cd build + cmake -Wno-dev -DPIO_ENABLE_NETCDF_INTEGRATION=On -DNetCDF_C_LIBRARY=/usr/lib/x86_64-linux-gnu/libnetcdf.so -DNetCDF_C_INCLUDE_DIR=/usr/include -DPnetCDF_PATH='/home/runner/pnetcdf' -DPIO_HDF5_LOGGING=On -DPIO_USE_MALLOC=On -DPIO_ENABLE_LOGGING=On -DPIO_ENABLE_TIMING=Off .. + make VERBOSE=1 + make tests VERBOSE=1 + ctest -VV diff --git a/CMakeLists.txt b/CMakeLists.txt index 473e9933237..40e915f655e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,7 @@ option (PIO_ENABLE_LOGGING "Enable debug logging (large output possible)" OFF) option (PIO_ENABLE_DOC "Enable building PIO documentation" ON) option (PIO_ENABLE_COVERAGE "Enable code coverage" OFF) option (PIO_ENABLE_EXAMPLES "Enable PIO examples" ON) +option (PIO_ENABLE_NETCDF_INTEGRATION "Enable netCDF integration" OFF) option (PIO_INTERNAL_DOC "Enable PIO developer documentation" OFF) option (PIO_TEST_BIG_ENDIAN "Enable test to see if machine is big endian" ON) option (PIO_USE_MPIIO "Enable support for MPI-IO auto detect" ON) @@ -106,6 +107,13 @@ else() set(ENABLE_LOGGING 0) endif() +# Set a variable that appears in the config.h.in file. +if(PIO_ENABLE_NETCDF_INTEGRATION) + set(NETCDF_INTEGRATION 1) +else() + set(NETCDF_INTEGRATION 0) +endif() + if(PIO_USE_MPISERIAL) set(USE_MPI_SERIAL 1) else() @@ -205,13 +213,6 @@ endif () set (CMAKE_Fortran_COMPILER_DIRECTIVE "CPR${CMAKE_Fortran_COMPILER_NAME}" CACHE STRING "Fortran compiler name preprocessor directive") -# configure a header file to pass some of the CMake settings -# to the source code -configure_file ( - "${PROJECT_SOURCE_DIR}/cmake_config.h.in" - "${PROJECT_BINARY_DIR}/config.h" - ) - #============================================================================== # SET CODE COVERAGE COMPILER FLAGS #============================================================================== @@ -418,3 +419,12 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/src/clib/pio_meta.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/clib/pio_meta.h @ONLY) +# configure a header file to pass some of the CMake settings +# to the source code +configure_file ( + "${PROJECT_SOURCE_DIR}/cmake_config.h.in" + "${PROJECT_BINARY_DIR}/config.h" + ) + + + diff --git a/cmake_config.h.in b/cmake_config.h.in index 65ccd1d4587..b7ed181b372 100644 --- a/cmake_config.h.in +++ b/cmake_config.h.in @@ -30,11 +30,16 @@ #define USE_VARD @USE_VARD@ -#define HAVE_PAR_FILTERS @HAVE_PAR_FILTERS@ - +/* Does netCDF and HDF5 support parallel I/O filters? */ #cmakedefine HAVE_PAR_FILTERS + +/* Was PIO built with netCDF integration? */ #cmakedefine NETCDF_INTEGRATION + +/* Does PIO support netCDF/HDF5 files? */ #cmakedefine _NETCDF4 + +/* Does PIO support using pnetcdf for I/O? */ #cmakedefine _PNETCDF #endif /* _PIO_CONFIG_ */ diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index d81ec2edbc4..49f772ba371 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -6,10 +6,15 @@ project (PIOC C) # DEFINE THE TARGET #============================================================================== -add_library (pioc topology.c pio_file.c pioc_support.c pio_lists.c +set (src topology.c pio_file.c pioc_support.c pio_lists.c pioc.c pioc_sc.c pio_spmd.c pio_rearrange.c pio_nc4.c bget.c pio_nc.c pio_put_nc.c pio_get_nc.c pio_getput_int.c pio_msg.c pio_darray.c pio_darray_int.c pio_get_vard.c pio_put_vard.c pio_error.c) +if (NETCDF_INTEGRATION) + set (src ${src} ../ncint/nc_get_vard.c ../ncint/ncintdispatch.c ../ncint/ncint_pio.c ../ncint/nc_put_vard.c) +endif () + +add_library (pioc ${src}) # set up include-directories include_directories( @@ -21,6 +26,10 @@ include_directories( target_include_directories (pioc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +# Include the ncint source directory +target_include_directories (pioc + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../ncint) + # System and compiler CPP directives target_compile_definitions (pioc PUBLIC ${CMAKE_SYSTEM_DIRECTIVE}) diff --git a/src/flib/CMakeLists.txt b/src/flib/CMakeLists.txt index 1e357c81e5d..2f4f54feacc 100644 --- a/src/flib/CMakeLists.txt +++ b/src/flib/CMakeLists.txt @@ -31,6 +31,11 @@ set (PIO_Fortran_MODS ${CMAKE_CURRENT_BINARY_DIR}/pio.mod ${CMAKE_CURRENT_BINARY_DIR}/pionfatt_mod.mod ${CMAKE_CURRENT_BINARY_DIR}/pionfput_mod.mod) +if (NETCDF_INTEGRATION) + set (PIO_Fortran_SRCS ${PIO_Fortran_SRCS} ncint_mod.F90) + set (PIO_Fortran_MODS ${PIO_Fortran_MODS} ${CMAKE_CURRENT_BINARY_DIR}/ncint_mod.mod) +endif () + add_library (piof ${PIO_Fortran_SRCS} ${PIO_GenF90_SRCS}) if (NOT PIO_ENABLE_FORTRAN) set_target_properties(piof PROPERTIES EXCLUDE_FROM_ALL TRUE) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 115c732b51c..ebd9878d46b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -26,3 +26,7 @@ if (PIO_ENABLE_FORTRAN) message (STATUS "Cannot build performance test without gptl timing library") endif () endif() + +if (NETCDF_INTEGRATION) + add_subdirectory(ncint) +endif () diff --git a/tests/ncint/CMakeLists.txt b/tests/ncint/CMakeLists.txt new file mode 100644 index 00000000000..69421efde0a --- /dev/null +++ b/tests/ncint/CMakeLists.txt @@ -0,0 +1,31 @@ +# This is part of the PIO library. +# +# This is the cmake file to build the test directory for netCDF integration. +# +# Ed Hartnett 8/19/20 + +include (LibMPI) + +include_directories("${CMAKE_SOURCE_DIR}/tests/ncint") +include_directories("${CMAKE_BINARY_DIR}") + +set (my_tests tst_async_multi tst_ncint_async_perf + tst_ncint_perf tst_pio_async tst_pio_udf) + +# Test Timeout in seconds. +if (PIO_VALGRIND_CHECK) + set (DEFAULT_TEST_TIMEOUT 480) +else () + set (DEFAULT_TEST_TIMEOUT 240) +endif () + +FOREACH(tst ${my_tests}) + add_executable (${tst} EXCLUDE_FROM_ALL ${tst}.c) + add_dependencies (tests ${tst}) + target_link_libraries (${tst} pioc) + add_mpi_test(${tst} + EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/${tst} + NUMPROCS 4 + TIMEOUT ${DEFAULT_TEST_TIMEOUT}) +ENDFOREACH() +