Skip to content

Commit

Permalink
Merge pull request ESMCI#1715 from NCAR/ejh_ncint
Browse files Browse the repository at this point in the history
Getting CMake build to understand netCDF integration
  • Loading branch information
edwardhartnett authored Aug 19, 2020
2 parents a59a55b + e57c5aa commit f1a83f3
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 10 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/cmake_ncint.yml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 17 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
#==============================================================================
Expand Down Expand Up @@ -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"
)



9 changes: 7 additions & 2 deletions cmake_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
11 changes: 10 additions & 1 deletion src/clib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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})
Expand Down
5 changes: 5 additions & 0 deletions src/flib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
31 changes: 31 additions & 0 deletions tests/ncint/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit f1a83f3

Please sign in to comment.