From 57f939fdfa46c3de529a2b3ab95c608715f070af Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 19 Aug 2020 07:32:44 -0600 Subject: [PATCH 1/5] only search for netcdf at top level --- CMakeLists.txt | 19 +++++++++++-------- src/clib/CMakeLists.txt | 3 ++- src/flib/CMakeLists.txt | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40e915f655e..4b1e3589e4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,6 +231,17 @@ if (PIO_ENABLE_COVERAGE) endif () endif () +# Include this so we can check values in netcdf_meta.h. +INCLUDE(CheckCSourceCompiles) +INCLUDE(FindNetCDF) +if (PIO_ENABLE_FORTRAN) + find_package (NetCDF REQUIRED COMPONENTS C Fortran) + find_package (PnetCDF COMPONENTS C Fortran) +else() + find_package (NetCDF REQUIRED COMPONENTS C) + find_package (PnetCDF COMPONENTS C) +endif() + #============================================================================== # INCLUDE SOURCE DIRECTORIES #============================================================================== @@ -265,11 +276,6 @@ if (PIO_ENABLE_DOC) add_subdirectory (doc) endif () -# Include this so we can check values in netcdf_meta.h. -INCLUDE(CheckCSourceCompiles) -INCLUDE(FindNetCDF) -find_package (NetCDF REQUIRED) -find_package (PnetCDF) SET(STATUS_PNETCDF PnetCDF_C_FOUND) @@ -425,6 +431,3 @@ configure_file ( "${PROJECT_SOURCE_DIR}/cmake_config.h.in" "${PROJECT_BINARY_DIR}/config.h" ) - - - diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index 49f772ba371..fb9bde74e8e 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -92,7 +92,8 @@ if (PIO_ENABLE_TIMING) endif () #===== NetCDF-C ===== -find_package (NetCDF "4.3.3" COMPONENTS C) + +message("NetCDF_C_FOUND has value ${NetCDF_C_FOUND}") if (NetCDF_C_FOUND) target_include_directories (pioc PUBLIC ${NetCDF_C_INCLUDE_DIRS}) diff --git a/src/flib/CMakeLists.txt b/src/flib/CMakeLists.txt index 2f4f54feacc..2e1493375aa 100644 --- a/src/flib/CMakeLists.txt +++ b/src/flib/CMakeLists.txt @@ -219,7 +219,7 @@ if (PIO_ENABLE_TIMING) endif () #===== NetCDF-Fortran ===== -find_package (NetCDF "4.3.3" COMPONENTS Fortran) +message("NetCDF_Fortran_FOUND is ${NetCDF_Fortran_FOUND}") if (NetCDF_Fortran_FOUND) target_include_directories (piof PUBLIC ${NetCDF_Fortran_INCLUDE_DIRS}) From 8b97bd5b050f63177e12f1dc46c3dd5089390cb7 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 19 Aug 2020 07:37:30 -0600 Subject: [PATCH 2/5] remove debug print statements --- src/clib/CMakeLists.txt | 2 -- src/flib/CMakeLists.txt | 1 - 2 files changed, 3 deletions(-) diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index fb9bde74e8e..b51f1c2722d 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -92,8 +92,6 @@ if (PIO_ENABLE_TIMING) endif () #===== NetCDF-C ===== - -message("NetCDF_C_FOUND has value ${NetCDF_C_FOUND}") if (NetCDF_C_FOUND) target_include_directories (pioc PUBLIC ${NetCDF_C_INCLUDE_DIRS}) diff --git a/src/flib/CMakeLists.txt b/src/flib/CMakeLists.txt index 2e1493375aa..f07ad5d5754 100644 --- a/src/flib/CMakeLists.txt +++ b/src/flib/CMakeLists.txt @@ -219,7 +219,6 @@ if (PIO_ENABLE_TIMING) endif () #===== NetCDF-Fortran ===== -message("NetCDF_Fortran_FOUND is ${NetCDF_Fortran_FOUND}") if (NetCDF_Fortran_FOUND) target_include_directories (piof PUBLIC ${NetCDF_Fortran_INCLUDE_DIRS}) From cc11af94880fb460f9e1c2079a05edd9d2d9aa47 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 19 Aug 2020 07:46:14 -0600 Subject: [PATCH 3/5] no netcdf fortran in this test --- .github/workflows/cmake.yml | 4 ++-- CMakeLists.txt | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index ab0ccc9883b..ae2d328ca0a 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -22,7 +22,7 @@ jobs: - 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 + 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 @@ -48,7 +48,7 @@ jobs: set -x mkdir build cd build - cmake -Wno-dev -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 .. + cmake -Wno-dev -DNetCDF_C_LIBRARY=/usr/lib/x86_64-linux-gnu/libnetcdf.so -DNetCDF_C_INCLUDE_DIR=/usr/include -DPnetCDF_PATH='/home/runner/pnetcdf'-DPIO_ENABLE_FORTRAN=Off -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 4b1e3589e4d..8922ec8d9c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,18 +18,18 @@ SET(PACKAGE_VERSION ${PIO_VERSION_MAJOR}.${PIO_VERSION_MINOR}.${PIO_VERSION_PATC # Determine the configure date. IF(DEFINED ENV{SOURCE_DATE_EPOCH}) - EXECUTE_PROCESS( - COMMAND "date" "-u" "-d" "@$ENV{SOURCE_DATE_EPOCH}" - OUTPUT_VARIABLE CONFIG_DATE - ) + EXECUTE_PROCESS( + COMMAND "date" "-u" "-d" "@$ENV{SOURCE_DATE_EPOCH}" + OUTPUT_VARIABLE CONFIG_DATE + ) ELSE() - EXECUTE_PROCESS( - COMMAND date - OUTPUT_VARIABLE CONFIG_DATE - ) + EXECUTE_PROCESS( + COMMAND date + OUTPUT_VARIABLE CONFIG_DATE + ) ENDIF() IF(CONFIG_DATE) - string(STRIP ${CONFIG_DATE} CONFIG_DATE) + string(STRIP ${CONFIG_DATE} CONFIG_DATE) ENDIF() # A function used to create autotools-style 'yes/no' definitions. @@ -234,6 +234,7 @@ endif () # Include this so we can check values in netcdf_meta.h. INCLUDE(CheckCSourceCompiles) INCLUDE(FindNetCDF) +message("Fortran Library build is ${PIO_ENABLE_FORTRAN}") if (PIO_ENABLE_FORTRAN) find_package (NetCDF REQUIRED COMPONENTS C Fortran) find_package (PnetCDF COMPONENTS C Fortran) From 6526724a85a38e6ca734698beb2767664aaf972b Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 19 Aug 2020 07:56:41 -0600 Subject: [PATCH 4/5] add space --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index ae2d328ca0a..d129c69c97d 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -48,7 +48,7 @@ jobs: set -x mkdir build cd build - cmake -Wno-dev -DNetCDF_C_LIBRARY=/usr/lib/x86_64-linux-gnu/libnetcdf.so -DNetCDF_C_INCLUDE_DIR=/usr/include -DPnetCDF_PATH='/home/runner/pnetcdf'-DPIO_ENABLE_FORTRAN=Off -DPIO_HDF5_LOGGING=On -DPIO_USE_MALLOC=On -DPIO_ENABLE_LOGGING=On -DPIO_ENABLE_TIMING=Off .. + cmake -Wno-dev -DNetCDF_C_LIBRARY=/usr/lib/x86_64-linux-gnu/libnetcdf.so -DNetCDF_C_INCLUDE_DIR=/usr/include -DPnetCDF_PATH='/home/runner/pnetcdf' -DPIO_ENABLE_FORTRAN=Off -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 From 43f131525e8d7d3afd8fc6c4eb191a3cc9184d51 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 19 Aug 2020 10:40:58 -0600 Subject: [PATCH 5/5] remove more redundant find_package calls --- src/clib/CMakeLists.txt | 4 ---- src/flib/CMakeLists.txt | 9 --------- src/gptl/CMakeLists.txt | 4 +--- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index b51f1c2722d..8d37fc812f3 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -75,7 +75,6 @@ endif () #===== GPTL ===== if (PIO_ENABLE_TIMING) - find_package (GPTL COMPONENTS C QUIET) if (GPTL_C_FOUND) message (STATUS "Found GPTL C: ${GPTL_C_LIBRARIES}") target_include_directories (pioc @@ -116,9 +115,6 @@ else () endif () #===== PnetCDF-C ===== -if (WITH_PNETCDF) - find_package (PnetCDF "1.7.0" COMPONENTS C) -endif () if (PnetCDF_C_FOUND) target_include_directories (pioc PUBLIC ${PnetCDF_C_INCLUDE_DIRS}) diff --git a/src/flib/CMakeLists.txt b/src/flib/CMakeLists.txt index f07ad5d5754..8ee65c77ad6 100644 --- a/src/flib/CMakeLists.txt +++ b/src/flib/CMakeLists.txt @@ -142,7 +142,6 @@ endforeach () #===== MPI ===== if (PIO_USE_MPISERIAL) - find_package (MPISERIAL COMPONENTS Fortran REQUIRED) if (MPISERIAL_Fortran_FOUND) target_compile_definitions (piof PRIVATE _MPISERIAL) @@ -154,8 +153,6 @@ if (PIO_USE_MPISERIAL) set (WITH_PNETCDF FALSE) set (MPI_Fortran_INCLUDE_PATH ${MPISERIAL_Fortran_INCLUDE_DIRS}) endif () -else () - find_package (MPI REQUIRED) endif () # Check MPI I/O capabilities @@ -184,9 +181,6 @@ endif () find_path(MPIMOD_PATH NAMES mpi.mod MPI.mod HINTS ${MPI_Fortran_INCLUDE_PATH}) -if (PIO_ENABLE_TIMING) - find_package (GPTL COMPONENTS Fortran_Perf QUIET) -endif () check_macro (MPI_HAS_Fortran_MOD NAME TryMPIMod.f90 @@ -236,9 +230,6 @@ else () endif () #===== PnetCDF ===== -if (WITH_PNETCDF) - find_package (PnetCDF "1.6" COMPONENTS Fortran REQUIRED) -endif () if (PnetCDF_Fortran_FOUND) target_include_directories (piof PUBLIC ${PnetCDF_Fortran_INCLUDE_DIRS}) diff --git a/src/gptl/CMakeLists.txt b/src/gptl/CMakeLists.txt index 5f73687f23d..7b5e977f63a 100644 --- a/src/gptl/CMakeLists.txt +++ b/src/gptl/CMakeLists.txt @@ -95,7 +95,6 @@ endif () #===== MPI ===== if (PIO_USE_MPISERIAL) - find_package (MPISERIAL COMPONENTS C Fortran REQUIRED) if (MPISERIAL_C_FOUND AND MPISERIAL_Fortran_FOUND) target_compile_definitions (gptl PRIVATE HAVE_MPI) @@ -109,8 +108,7 @@ if (PIO_USE_MPISERIAL) set (MPI_C_LIBRARIES ${MPISERIAL_C_LIBRARIES}) set (MPI_Fortran_INCLUDE_PATH ${MPISERIAL_Fortran_INCLUDE_DIRS}) endif () -else () - find_package (MPI REQUIRED) +else() if (MPI_C_FOUND AND MPI_Fortran_FOUND) target_compile_definitions (gptl PUBLIC HAVE_MPI)