Skip to content

Commit

Permalink
Merge branch 'parflow:master' into gnu_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AGonzalezNicolas authored Nov 13, 2024
2 parents 517c796 + 95058cb commit d3f3567
Show file tree
Hide file tree
Showing 1,256 changed files with 55,448 additions and 79,916 deletions.
86 changes: 82 additions & 4 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,84 @@ name: ParFlow CI Test
on: [push, pull_request]

jobs:
style-check:
runs-on: ubuntu-22.04
name: Check Style
steps:
- name: Checkout commit
uses: actions/checkout@v4

- name: Package Install
run: |
sudo apt-get -qq update
sudo apt-get -qq install curl cmake build-essential tcl-dev tk-dev
- name: Cache dependencies
uses: actions/cache@v4
id: cache-parflow-style-dependencies
env:
cache-name: cache-parflow-style-dependencies
cache-parflow-style-hit: ${{steps.cache-parflow-style-dependencies.outputs.cache-hit}}
with:
path: "~/depend"
key: cache-check-style-${{ secrets.CACHE_VERSION }}

- name: Directory Setup
run: |
mkdir -p $HOME/install
echo "PARFLOW_DIR=$HOME/install" >> $GITHUB_ENV
echo "Setting PARFLOW_DIR=$HOME/install"
mkdir -p $HOME/depend/{include,lib}
echo "PARFLOW_DEP_DIR=$HOME/depend" >> $GITHUB_ENV
echo "Setting PARFLOW_DEP_DIR=$HOME/depend"
echo "PARFLOW_DEP_DIR=$HOME/depend" >> $GITHUB_ENV
echo "$HOME/depend/bin" >> $GITHUB_PATH
echo "$PARFLOW_DIR/bin" >> $GITHUB_PATH
export LD_LIBRARY_PATH=${PARFLOW_DEP_DIR}/lib64:${PARFLOW_DEP_DIR}/lib:${LD_LIBRARY_PATH}
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
- name: Build Uncrustify
env:
CACHE_HIT: ${{steps.cache-parflow-style-dependencies.outputs.cache-hit}}
run: |
if [[ "$CACHE_HIT" != 'true' ]]; then
echo "cache-check-style-${{ secrets.CACHE_VERSION }}" > ~/depend/cache-key
curl -L -o uncrustify-0.79.0.tar.gz https://github.com/uncrustify/uncrustify/archive/uncrustify-0.79.0.tar.gz
tar -xf uncrustify-0.79.0.tar.gz
cd uncrustify-uncrustify-0.79.0
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make -j 2 install
cd ../..
rm -fr uncrustify-uncrustify-0.79.0 uncrustify-0.79.0.tar.gz
fi
- name: CMake Install
env:
CACHE_HIT: ${{steps.cache-parflow-style-dependencies.outputs.cache-hit}}
run: |
if [[ "$CACHE_HIT" != 'true' ]]; then
echo "Installing"
mkdir -p $HOME/depend/{include,lib}
cd ~/depend
echo "cache-${{ matrix.config.os }}-${{ matrix.config.backend }}-${{ secrets.CACHE_VERSION }}" > ~/depend/cache-key
wget -nv --no-check-certificate https://github.com/Kitware/CMake/releases/download/v3.25.1/cmake-3.25.1-linux-x86_64.tar.gz
tar -xf cmake-3.25.1-linux-x86_64.tar.gz
$HOME/depend/cmake-3.25.1-linux-x86_64/bin/cmake --version
echo "$HOME/depend/cmake-3.25.1-linux-x86_64/bin" >> $GITHUB_PATH
fi
- name: ParFlow CMake Configure
run: |
cmake -Bbuild -DPARFLOW_ENABLE_PYTHON=ON -DCMAKE_INSTALL_PREFIX=$PARFLOW_DIR
- name: ParFlow CMake Build
run: (cd build; make -j 2 install)
- name: Run Uncrustify
run: |
./bin/pfformat --check
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
Expand Down Expand Up @@ -77,7 +155,7 @@ jobs:
}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Package Install 22.04
if: matrix.config.os == 'ubuntu-22.04'
Expand All @@ -102,7 +180,7 @@ jobs:
# settings for the project (using date-timestamp for secret).

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-parflow-dependencies
env:
cache-name: cache-parflow-dependencies
Expand Down Expand Up @@ -194,7 +272,7 @@ jobs:
if: matrix.config.backend == 'kokkos'
run: |
if [[ "$CACHE_HIT" != 'true' ]]; then
URL=https://github.com/kokkos/kokkos/archive/refs/tags/3.3.01.tar.gz
URL=https://github.com/kokkos/kokkos/archive/refs/tags/4.2.01.tar.gz
mkdir kokkos
cd kokkos
curl -L $URL | tar --strip-components=1 -xz
Expand Down Expand Up @@ -302,7 +380,7 @@ jobs:
gcc -v
mpicc -v
if [[ "${{ matrix.config.amps_layer }}" == "oas3" ]]; then HAVE_CLM="OFF"; else HAVE_CLM="ON"; fi
CC=mpicc CXX=mpicxx F77=mpif77 FC=mpif90 cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Wall -Werror -Wno-unused-result -Wno-unused-function" -DPARFLOW_ENABLE_TIMING=TRUE -DPARFLOW_AMPS_LAYER=${{ matrix.config.amps_layer }} -DMPIEXEC_POSTFLAGS='--oversubscribe' -DPARFLOW_ACCELERATOR_BACKEND=${{ matrix.config.backend }} -DPARFLOW_AMPS_SEQUENTIAL_IO=true -DPARFLOW_HAVE_CLM=${HAVE_CLM} -DHYPRE_ROOT=$PARFLOW_DEP_DIR -DOAS3_ROOT=$PARFLOW_DEP_DIR -DSILO_ROOT=$PARFLOW_DEP_DIR -DPARFLOW_ENABLE_PYTHON=${{ matrix.config.python }} -DPARFLOW_PYTHON_VIRTUAL_ENV=${{ matrix.config.python }} $NETCDF_FLAGS $KOKKOS_FLAGS $RMM_FLAGS -DCMAKE_INSTALL_PREFIX=$PARFLOW_DIR
CC=mpicc CXX=mpicxx F77=mpif77 FC=mpif90 cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Wall -Werror -Wno-unused-result -Wno-unused-function" -DPARFLOW_ENABLE_TIMING=TRUE -DPARFLOW_AMPS_LAYER=${{ matrix.config.amps_layer }} -DMPIEXEC_POSTFLAGS='--oversubscribe' -DPARFLOW_ACCELERATOR_BACKEND=${{ matrix.config.backend }} -DPARFLOW_AMPS_SEQUENTIAL_IO=true -DPARFLOW_HAVE_CLM=${HAVE_CLM} -DHYPRE_ROOT=$PARFLOW_DEP_DIR -DOAS3_ROOT=$PARFLOW_DEP_DIR -DSILO_ROOT=$PARFLOW_DEP_DIR -DPARFLOW_ENABLE_PYTHON=${{ matrix.config.python }} $NETCDF_FLAGS $KOKKOS_FLAGS $RMM_FLAGS -DCMAKE_INSTALL_PREFIX=$PARFLOW_DIR
- name: ParFlow CMake Build
run: (cd build; make -j 2 install)
Expand Down
155 changes: 155 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
name: ParFlow MacOS CI Test

#
# Notes
# Currently using GCC for the build rather than Clang
# Python 3.12 used rather than more current available versions since Numba library does not work with later versions

on: [push, pull_request]

jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
# fail-fast: true
matrix:
config:
- {
name: "MacOS 14",
os: macos-14,
cudaos: '',
python: "true",
backend: "none",
amps_layer: mpi1,
netcdf: "true"
}

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: fortran-lang/setup-fortran@v1
with:
compiler: gcc
- uses: mpi4py/setup-mpi@v1
with:
mpi: openmpi

- name: HDF5 Install
run: |
brew install hdf5-mpi
# Cache dependencies so don't have to rebuild on each test.
# Can flush caches by resetting the CACHE_VERSION secret on GitHub
# settings for the project (using date-timestamp for secret).

- name: Cache dependencies
uses: actions/cache@v4
id: cache-parflow-dependencies
env:
cache-name: cache-parflow-dependencies
cache-parflow-hit: ${{steps.cache-parflow-dependencies.outputs.cache-hit}}
with:
path: "~/depend"
key: cache-${{ matrix.config.os }}-${{ matrix.config.backend }}-${{ secrets.CACHE_VERSION }}

- name: Directory Setup
run: |
mkdir -p $HOME/install
echo "PARFLOW_DIR=$HOME/install" >> $GITHUB_ENV
echo "Setting PARFLOW_DIR=$HOME/install"
mkdir -p $HOME/depend/{include,lib}
echo "PARFLOW_DEP_DIR=$HOME/depend" >> $GITHUB_ENV
echo "Setting PARFLOW_DEP_DIR=$HOME/depend"
echo "PARFLOW_DEP_DIR=$HOME/depend" >> $GITHUB_ENV
echo "$HOME/depend/bin" >> $GITHUB_PATH
export LD_LIBRARY_PATH=${PARFLOW_DEP_DIR}/lib64:${PARFLOW_DEP_DIR}/lib:${LD_LIBRARY_PATH}
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
export PARFLOW_PYTHON3=/opt/homebrew/bin/python3.12
echo "PARFLOW_PYTHON3=${PARFLOW_PYTHON3}" >> $GITHUB_ENV
- name: CMake Install
if: matrix.config.os != 'macos-14'
env:
CACHE_HIT: ${{steps.cache-parflow-dependencies.outputs.cache-hit}}
run: |
if [[ "$CACHE_HIT" != 'true' ]]; then
echo "Installing"
cd ~/depend
echo "cache-${{ matrix.config.os }}-${{ matrix.config.backend }}-${{ secrets.CACHE_VERSION }}" > ~/depend/cache-key
wget -nv --no-check-certificate https://github.com/Kitware/CMake/releases/download/v3.25.1/cmake-3.25.1-linux-x86_64.tar.gz
tar -xf cmake-3.25.1-linux-x86_64.tar.gz
$HOME/depend/cmake-3.25.1-linux-x86_64/bin/cmake --version
fi
echo "$HOME/depend/cmake-3.25.1-linux-x86_64/bin" >> $GITHUB_PATH
# Package netcdf is missing features needed by the ParFlow writers, build from source
# netcdf is True when we want to build the PF NetCDF writer.
- name: NetCDF Install
env:
CACHE_HIT: ${{steps.cache-parflow-dependencies.outputs.cache-hit}}
if: matrix.config.netcdf == 'true'
run: |
if [[ "$CACHE_HIT" != 'true' ]]; then
URL=https://github.com/Unidata/netcdf-c/archive/v4.9.0.tar.gz
mkdir netcdf-c
cd netcdf-c
curl -L $URL | tar --strip-components=1 -xz
CC=mpicc CPPFLAGS=-I/opt/homebrew/include LDFLAGS=-L/opt/homebrew/lib/ ./configure --prefix=$PARFLOW_DEP_DIR
make
make install
cd ..
URL=https://github.com/Unidata/netcdf-fortran/archive/v4.5.4.tar.gz
mkdir netcdf-fortran
cd netcdf-fortran
curl -L $URL | tar --strip-components=1 -xz
CC=mpicc FC=mpifort CPPFLAGS=-I${PARFLOW_DEP_DIR}/include LDFLAGS=-L${PARFLOW_DEP_DIR}/lib ./configure --prefix=${PARFLOW_DEP_DIR}
make
make install
fi
echo "NETCDF_FLAGS=-DNETCDF_DIR=$PARFLOW_DEP_DIR -DPARFLOW_ENABLE_HDF5=TRUE" >> $GITHUB_ENV
- name: SILO Install
env:
CACHE_HIT: ${{steps.cache-parflow-dependencies.outputs.cache-hit}}
run: |
if [[ "$CACHE_HIT" != 'true' ]]; then
URL=https://github.com/LLNL/Silo/archive/refs/tags/4.11.tar.gz
mkdir silo
cd silo
curl -L $URL | tar --strip-components=1 -xz
./configure --disable-silex --disable-hzip --disable-fpzip --prefix=$PARFLOW_DEP_DIR --disable-fortran --with-readline=no
make -j 2 install
fi
- name: HYPRE Install
env:
CACHE_HIT: ${{steps.cache-parflow-dependencies.outputs.cache-hit}}
run: |
if [[ "$CACHE_HIT" != 'true' ]]; then
URL=https://github.com/hypre-space/hypre/archive/v2.26.0.tar.gz
mkdir hypre
cd hypre
curl -L $URL | tar --strip-components=1 -xz
cd src
CC=mpicc CXX=mpic++ FC=mpif77 F77=mpif90 ./configure --prefix=$PARFLOW_DEP_DIR
make -j 2 install
fi
- name: ParFlow CMake Configure
run: |
mpicc -v
if [[ "${{ matrix.config.amps_layer }}" == "oas3" ]]; then HAVE_CLM="OFF"; else HAVE_CLM="ON"; fi
CC=mpicc CXX=mpicxx F77=mpif77 FC=mpif90 cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Wall -Werror -Wno-unused-result -Wno-unused-function" -DPARFLOW_ENABLE_TIMING=TRUE -DPARFLOW_AMPS_LAYER=${{ matrix.config.amps_layer }} -DPARFLOW_ACCELERATOR_BACKEND=${{ matrix.config.backend }} -DPARFLOW_AMPS_SEQUENTIAL_IO=true -DPARFLOW_HAVE_CLM=${HAVE_CLM} -DHYPRE_ROOT=$PARFLOW_DEP_DIR -DOAS3_ROOT=$PARFLOW_DEP_DIR -DSILO_ROOT=$PARFLOW_DEP_DIR -DPARFLOW_ENABLE_PYTHON=${{ matrix.config.python }} $NETCDF_FLAGS $KOKKOS_FLAGS $RMM_FLAGS -DCMAKE_INSTALL_PREFIX=$PARFLOW_DIR -DTCL_INCLUDE_PATH=/opt/homebrew/bin/usr/include -DTCL_LIBRARY=/opt/homebrew/lib/libtcl8.6.dylib -DTCL_TCLSH=/opt/homebrew/bin/tclsh -DPython3_EXECUTABLE=$PARFLOW_PYTHON3
- name: ParFlow CMake Build
run: (cd build; make -j 2 VERBOSE=1 install)

# Can't test with GPU since have no GPU hardware on testing nodes, GPU test is build only
- name: ParFlow CTest
if: matrix.config.backend != 'cuda' && matrix.config.backend != 'kokkos'
run: |
(cd build; ctest --output-on-failure)
77 changes: 40 additions & 37 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ if ( ${PARFLOW_AMPS_LAYER} IN_LIST PARFLOW_AMPS_LAYER_REQUIRE_MPI )
if (${MPI_C_FOUND})
set(PARFLOW_HAVE_MPI "yes")
set(HAVE_MPI ${PARFLOW_HAVE_MPI})
message(STATUS "Found MPIEXEC: ${MPIEXEC}")
endif (${MPI_C_FOUND})

endif ( ${PARFLOW_AMPS_LAYER} IN_LIST PARFLOW_AMPS_LAYER_REQUIRE_MPI )
Expand Down Expand Up @@ -531,6 +532,44 @@ include_directories ("${PROJECT_SOURCE_DIR}/pfsimulator/amps/common")

include_directories ("${PROJECT_BINARY_DIR}/include")

#-----------------------------------------------------------------------------
# Building Python key library and documentation if required
#-----------------------------------------------------------------------------

option(PARFLOW_ENABLE_PYTHON "Build python module for running ParFlow" "FALSE")
if (PARFLOW_ENABLE_PYTHON)
find_package(Python3 3.6 QUIET REQUIRED COMPONENTS Interpreter)
set(PARFLOW_PYTHON_DEPENDS)
set(PARFLOW_HAVE_PYTHON)
set(PARFLOW_PYTHON "${CMAKE_INSTALL_PREFIX}/py-env/bin/python3")
message(STATUS "Found Python: ${Python3_EXECUTABLE}")
add_custom_command(
WORKING_DIRECTORY
"${CMAKE_CURRENT_BINARY_DIR}"
OUTPUT
"${PARFLOW_PYTHON}"
COMMAND
${Python3_EXECUTABLE} -m venv ${CMAKE_INSTALL_PREFIX}/py-env
COMMAND
"${CMAKE_INSTALL_PREFIX}//py-env/bin/pip3" install --upgrade pip wheel setuptools
COMMAND
"${CMAKE_INSTALL_PREFIX}/py-env/bin/pip3" install -r "${CMAKE_CURRENT_SOURCE_DIR}/pftools/python/requirements_all.txt"
COMMAND
"${CMAKE_INSTALL_PREFIX}//py-env/bin/pip3" install -r "${CMAKE_CURRENT_SOURCE_DIR}/docs/user_manual/requirements.txt"
COMMAND
"${CMAKE_INSTALL_PREFIX}//py-env/bin/pip3" install -r "${CMAKE_CURRENT_SOURCE_DIR}/pftools/python/requirements_dev.txt"
COMMENT
"Generate ParFlow virtual environment"
VERBATIM
)
add_custom_target(
BuildVirtualEnv
DEPENDS
"${PARFLOW_PYTHON}"
)
set(PARFLOW_PYTHON_DEPENDS BuildVirtualEnv)
endif ()

#-----------------------------------------------------------------------------
# Setup configure.h file for accessing configure options
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -609,46 +648,10 @@ if ( ${PARFLOW_ENABLE_DOXYGEN} )
endif()

#-----------------------------------------------------------------------------
# Building Python key library and documentation if required
# Python directories
#-----------------------------------------------------------------------------

option(PARFLOW_ENABLE_PYTHON "Build python module for running ParFlow" "FALSE")
if (PARFLOW_ENABLE_PYTHON)
find_package(Python3 3.6 QUIET REQUIRED COMPONENTS Interpreter)
set(PARFLOW_PYTHON ${Python3_EXECUTABLE})
set(PARFLOW_PYTHON_DEPENDS)
set(PARFLOW_HAVE_PYTHON)

option(PARFLOW_PYTHON_VIRTUAL_ENV "Use local Python virtual environment" "FALSE")
if (PARFLOW_PYTHON_VIRTUAL_ENV)
set(PARFLOW_PYTHON "${CMAKE_CURRENT_BINARY_DIR}/py-env/bin/python3")
add_custom_command(
WORKING_DIRECTORY
"${CMAKE_CURRENT_BINARY_DIR}"
OUTPUT
"${PARFLOW_PYTHON}"
COMMAND
${Python3_EXECUTABLE} -m venv py-env
COMMAND
"${CMAKE_CURRENT_BINARY_DIR}/py-env/bin/pip3" install --upgrade pip wheel setuptools
COMMAND
"${CMAKE_CURRENT_BINARY_DIR}/py-env/bin/pip3" install -r "${CMAKE_CURRENT_SOURCE_DIR}/pftools/python/requirements_all.txt"
COMMAND
"${CMAKE_CURRENT_BINARY_DIR}/py-env/bin/pip3" install -r "${CMAKE_CURRENT_SOURCE_DIR}/docs/user_manual/requirements.txt"
COMMAND
"${CMAKE_CURRENT_BINARY_DIR}/py-env/bin/pip3" install -r "${CMAKE_CURRENT_SOURCE_DIR}/pftools/python/requirements_dev.txt"
COMMENT
"Generate virtual environment for building Python components"
VERBATIM
)
add_custom_target(
BuildVirtualEnv
DEPENDS
"${PARFLOW_PYTHON}"
)
set(PARFLOW_PYTHON_DEPENDS BuildVirtualEnv)
endif()

add_subdirectory(pf-keys)
add_subdirectory(pftools/python)
add_subdirectory(test/python)
Expand Down
Loading

0 comments on commit d3f3567

Please sign in to comment.