Skip to content

Commit

Permalink
Merge branch 'esmf-org:develop' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
WeirAE authored Sep 20, 2024
2 parents cada4b4 + d4d016c commit 47017b5
Show file tree
Hide file tree
Showing 96 changed files with 897 additions and 526 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/api-change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
tag1:
description: 'First ESMF Tag'
required: true
default: 'v8.6.0'
default: 'v8.7.0'
tag2:
description: 'Second ESMF Tag'
required: true
Expand Down
250 changes: 250 additions & 0 deletions .github/workflows/development-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
name: Development Tests

on:
schedule:
- cron: "15 8 * * 3"
pull_request:
branches:
- develop
workflow_dispatch:

jobs:
development-test:
name: ${{matrix.config.desc}}
runs-on: ${{matrix.config.osys}}
strategy:
fail-fast: false
matrix:
config:
- {
desc: [email protected]@11-mpiuni-netcdf,
osys: ubuntu-22.04,
cors: 4,
ropt: '',
exhs: ON,
cmpr: gfortran,
cvrs: 11,
bopt: 'O',
comm: mpiuni,
tlib: ON,
ncdf: nc-config
}
- {
desc: [email protected]@12-mpich-netcdf,
osys: ubuntu-22.04,
cors: 4,
ropt: '',
exhs: OFF,
cmpr: gfortran,
cvrs: 12,
bopt: 'O',
comm: mpich,
tlib: ON,
ncdf: nc-config
}
- {
desc: macos@14-gfortran@13-mpiuni-netcdf,
osys: macos-14,
cors: 3,
ropt: '',
exhs: OFF,
cmpr: gfortran,
cvrs: 13,
bopt: 'O',
comm: mpiuni,
tlib: OFF,
ncdf: nc-config
}
- {
desc: macos@14-clang-gfortran@14-openmpi-netcdf,
osys: macos-14,
cors: 3,
ropt: '--oversubscribe',
exhs: ON,
cmpr: gfortranclang,
cvrs: 14,
bopt: 'g',
comm: openmpi,
tlib: ON,
ncdf: nc-config
}
steps:
- name: Set up system
run: |
if [[ "${{matrix.config.osys}}" == "ubuntu-"* ]]; then
sudo apt-get -qq update
sudo apt install -qq -y autoconf automake libtool
elif [[ "${{matrix.config.osys}}" == "macos-"* ]]; then
brew install autoconf automake libtool
brew unlink libevent || true
fi
export STACK_ROOT=${HOME}/stack
mkdir -p ${STACK_ROOT}/{include,lib,lib64,bin}
export ARTIFACTS=${{runner.temp}}/esmf_tests
mkdir -p ${ARTIFACTS}
export LD_LIBRARY_PATH=${STACK_ROOT}/lib64:${STACK_ROOT}/lib:${LD_LIBRARY_PATH}
echo "STACK_ROOT=${STACK_ROOT}" >> $GITHUB_ENV
echo "ARTIFACTS=${ARTIFACTS}" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
echo "CPPFLAGS=-I${STACK_ROOT}/include" >> $GITHUB_ENV
echo "LDFLAGS=-L${STACK_ROOT}/lib" >> $GITHUB_ENV
echo "${STACK_ROOT}/bin" >> $GITHUB_PATH
- name: Cache Libraries
id: cache-libraries
uses: actions/cache@v4
with:
path: ${{env.STACK_ROOT}}
key: ${{matrix.config.desc}}
- name: Set up GFORTRAN
if: matrix.config.cmpr == 'gfortran'
run: |
command -v gcc-${{matrix.config.cvrs}} || { exit 1; }
command -v g++-${{matrix.config.cvrs}} || { exit 1; }
command -v gfortran-${{matrix.config.cvrs}} || { exit 1; }
ln -fs `which gcc-${{matrix.config.cvrs}}` /usr/local/bin/gcc
ln -fs `which g++-${{matrix.config.cvrs}}` /usr/local/bin/g++
ln -fs `which gfortran-${{matrix.config.cvrs}}` /usr/local/bin/gfortran
gcc --version; g++ --version; gfortran --version
echo "CC=gcc" >> $GITHUB_ENV
echo "CXX=g++" >> $GITHUB_ENV
echo "F77=gfortran" >> $GITHUB_ENV
echo "F90=gfortran" >> $GITHUB_ENV
echo "FC=gfortran" >> $GITHUB_ENV
- name: Set up GFORTRANCLANG
if: matrix.config.cmpr == 'gfortranclang'
run: |
command -v gfortran-${{matrix.config.cvrs}} || { exit 1; }
ln -fs `which gfortran-${{matrix.config.cvrs}}` /usr/local/bin/gfortran
clang --version; clang++ --version; gfortran --version
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
echo "F77=gfortran" >> $GITHUB_ENV
echo "F90=gfortran" >> $GITHUB_ENV
echo "FC=gfortran" >> $GITHUB_ENV
- name: Install MPICH (CACHED)
env:
CACHE_HIT: ${{steps.cache-libraries.outputs.cache-hit}}
if: matrix.config.comm == 'mpich'
run: |
if [[ "$CACHE_HIT" != 'true' ]]; then
MPICH_URL="https://www.mpich.org/static/downloads/4.2.2/mpich-4.2.2.tar.gz"
mkdir ${{runner.temp}}/mpich
cd ${{runner.temp}}/mpich
curl -L $MPICH_URL | tar --strip-components=1 -xz
./configure --prefix=${{env.STACK_ROOT}}
make -j ${{matrix.config.cors}} install
fi
mpichversion
echo "CC=mpicc" >> $GITHUB_ENV
echo "CXX=mpicxx" >> $GITHUB_ENV
echo "F77=mpifort" >> $GITHUB_ENV
echo "F90=mpifort" >> $GITHUB_ENV
echo "FC=mpifort" >> $GITHUB_ENV
- name: Install OPENMPI (CACHED)
env:
CACHE_HIT: ${{steps.cache-libraries.outputs.cache-hit}}
if: matrix.config.comm == 'openmpi'
run: |
if [[ "$CACHE_HIT" != 'true' ]]; then
OPENMPI_URL="https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.6.tar.gz"
mkdir ${{runner.temp}}/openmpi
cd ${{runner.temp}}/openmpi
curl -L $OPENMPI_URL | tar --strip-components=1 -xz
./configure --prefix=${{env.STACK_ROOT}}
make -j ${{matrix.config.cors}} install
fi
ompi_info
echo "CC=mpicc" >> $GITHUB_ENV
echo "CXX=mpicxx" >> $GITHUB_ENV
echo "F77=mpifort" >> $GITHUB_ENV
echo "F90=mpifort" >> $GITHUB_ENV
echo "FC=mpifort" >> $GITHUB_ENV
- name: Install HDF5 (CACHED)
env:
CACHE_HIT: ${{steps.cache-libraries.outputs.cache-hit}}
if: matrix.config.ncdf == 'nc-config'
run: |
if [[ "$CACHE_HIT" != 'true' ]]; then
HDF5_URL="https://github.com/HDFGroup/hdf5/archive/refs/tags/hdf5_1.14.4.3.tar.gz"
mkdir ${{runner.temp}}/hdf5
cd ${{runner.temp}}/hdf5
curl -L $HDF5_URL | tar --strip-components=1 -xz
./configure --enable-fortran --prefix=${{env.STACK_ROOT}}
make -j ${{matrix.config.cors}} install
fi
- name: Install NetCDF-C and NetCDF-Fortran (CACHED)
env:
CACHE_HIT: ${{steps.cache-libraries.outputs.cache-hit}}
if: matrix.config.ncdf == 'nc-config'
run: |
if [[ "$CACHE_HIT" != 'true' ]]; then
NETCDF_URL="https://github.com/Unidata/netcdf-c/archive/v4.9.0.tar.gz"
NETCDFF_URL="https://github.com/Unidata/netcdf-fortran/archive/v4.5.4.tar.gz"
mkdir ${{runner.temp}}/netcdf-c
cd ${{runner.temp}}/netcdf-c
curl -L $NETCDF_URL | tar --strip-components=1 -xz
./configure --enable-netcdf-4 --disable-dap --prefix=${{env.STACK_ROOT}}
make -j ${{matrix.config.cors}} install
mkdir ${{runner.temp}}/netcdf-fortran
cd ${{runner.temp}}/netcdf-fortran
curl -L $NETCDFF_URL | tar --strip-components=1 -xz
./configure --prefix=${{env.STACK_ROOT}}
make -j ${{matrix.config.cors}} install
fi
- name: Checkout ESMF
uses: actions/checkout@v4
- name: ESMF Configuration
run: |
echo "ESMF_DIR=${GITHUB_WORKSPACE}" >> $GITHUB_ENV
echo "ESMF_COMPILER=${{matrix.config.cmpr}}" >> $GITHUB_ENV
echo "ESMF_COMM=${{matrix.config.comm}}" >> $GITHUB_ENV
echo "ESMF_BOPT=${{matrix.config.bopt}}" >> $GITHUB_ENV
echo "ESMF_NETCDF=${{matrix.config.ncdf}}" >> $GITHUB_ENV
echo "ESMF_MPILAUNCHOPTIONS=${{matrix.config.ropt}}" >> $GITHUB_ENV
echo "ESMF_TESTEXHAUSTIVE=${{matrix.config.exhs}}" >> $GITHUB_ENV
echo "ESMF_TRACE_LIB_BUILD=${{matrix.config.tlib}}" >> $GITHUB_ENV
- name: ESMF Info
run: |
make info | tee ${ARTIFACTS}/info.log
- name: ESMF Build
run: |
make -j ${{matrix.config.cors}} > ${ARTIFACTS}/build.log 2>&1
- name: ESMF All Tests
timeout-minutes: 60
run: |
make all_tests > ${ARTIFACTS}/all_tests.log 2>&1
{ grep "SYSTEM TESTS SUMMARY" -A1 ${ARTIFACTS}/all_tests.log > ${ARTIFACTS}/summary.log || true; }
{ grep "EXAMPLES SUMMARY" -A1 ${ARTIFACTS}/all_tests.log >> ${ARTIFACTS}/summary.log || true; }
{ grep "UNIT TESTS SUMMARY" -A1 ${ARTIFACTS}/all_tests.log >> ${ARTIFACTS}/summary.log || true; }
echo >> ${ARTIFACTS}/summary.log
{ grep "PASS:" ${ARTIFACTS}/all_tests.log >> ${ARTIFACTS}/summary.log || true; }
echo >> ${ARTIFACTS}/summary.log
{ grep "FAIL:" ${ARTIFACTS}/all_tests.log >> ${ARTIFACTS}/summary.log || true; }
echo >> ${ARTIFACTS}/summary.log
{ grep "CRASHED:" ${ARTIFACTS}/all_tests.log >> ${ARTIFACTS}/summary.log || true; }
echo >> ${ARTIFACTS}/summary.log
cat ${ARTIFACTS}/summary.log
{ grep "FAIL:\|CRASHED:" ${ARTIFACTS}/summary.log > ${ARTIFACTS}/failures.log || true; }
if [ -f ${ARTIFACTS}/failures.log ]; then
error=$(wc -l < ${ARTIFACTS}/failures.log)
else
error=0
fi
if [ ${error} -gt 0 ]; then
mkdir -p ${ARTIFACTS}/output
find test -type f -name "*.Log" \
-exec cp '{}' ${ARTIFACTS}/output/. ';'
find test -type f -name "*.stdout" \
-exec cp '{}' ${ARTIFACTS}/output/. ';'
echo "Test Failures:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat ${ARTIFACTS}/failures.log >> $GITHUB_STEP_SUMMARY
echo '::error::${{matrix.config.desc}} failed, check artifacts.'
exit 1
fi
- name: Archive Results
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: logs-${{matrix.config.desc}}
path: ${{env.ARTIFACTS}}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Pre-built binaries for ESMF and ESMPy are available through a number of channels
```
docker run -it --rm esmf/esmf-build-release:latest
```
Replace `latest` in the above command with a valid version, like `8.6.0`, in order to access a specific ESMF version.
Replace `latest` in the above command with a valid version, like `8.8.0`, in order to access a specific ESMF version.

* [Anaconda Conda-Forge](https://anaconda.org/conda-forge/): Under [conda-forge/esmpy](https://anaconda.org/conda-forge/esmpy). To install locally (_note Windows is not supported_), run:
```
Expand Down
30 changes: 30 additions & 0 deletions build/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,16 @@ else
export ESMF_INSTALL_DOCDIR_ABSPATH = $(ESMF_INSTALL_DOCDIR)
endif

ifndef ESMF_INSTALL_CMAKEDIR
ESMF_INSTALL_CMAKEDIR := cmake
endif
pathtype := $(shell $(ESMF_DIR)/scripts/pathtype $(ESMF_INSTALL_CMAKEDIR))
ifeq ($(pathtype),rel)
export ESMF_INSTALL_CMAKEDIR_ABSPATH = $(ESMF_INSTALL_PREFIX_ABSPATH)/$(ESMF_INSTALL_CMAKEDIR)
else
export ESMF_INSTALL_CMAKEDIR_ABSPATH = $(ESMF_INSTALL_CMAKEDIR)
endif

#-------------------------------------------------------------------------------
# Set ESMFMKFILE here in order to be available for installcheck target
#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -654,6 +664,9 @@ ESMF_APPSDIR = $(ESMF_BUILD)/apps/apps$(ESMF_BOPT)/$(ESMF_OS).$(ESMF_COMPILE
# unified nuopc executable directory
ESMF_ESMXDIR = $(ESMF_BUILD)/src/addon/ESMX

# cmake modules directory
ESMF_CMAKEDIR = $(ESMF_DIR)/cmake

# include file directory
ESMF_INCDIR = $(ESMF_BUILD)/src/include

Expand Down Expand Up @@ -2806,6 +2819,10 @@ $(ESMF_TESTDIR)/ESMF_%STest : ESMF_%STest.o $(SYSTEM_TESTS_OBJ) $(addsuffix .$(E
$(ESMF_F90LINKER) $(ESMF_EXE_F90LINKOPTS) $(ESMF_F90LINKOPTS) $(ESMF_F90LINKPATHS) $(ESMF_F90LINKRPATHS) $(ESMF_EXEOUT_OPTION) $(SYSTEM_TESTS_OBJ) $< $(ESMF_F90ESMFLINKLIBS)
$(ESMF_RM) -f *.o *.mod

$(ESMF_TESTDIR)/ESMC_%STest : ESMC_%STest.o $(SYSTEM_TESTS_OBJ) $(addsuffix .$(ESMF_SL_SUFFIX), $(SYSTEM_TESTS_SHOBJ)) $(ESMFLIB)
$(MAKE) chkdir_tests
$(ESMF_CLINKER) $(ESMF_EXE_CLINKOPTS) $(ESMF_CLINKOPTS) $(ESMF_CLINKPATHS) $(ESMF_CLINKRPATHS) $(ESMF_EXEOUT_OPTION) $(SYSTEM_TESTS_OBJ) $< $(ESMF_CESMFLINKLIBS)
$(ESMF_RM) -f *.o *.mod

# debugging aid: link the executable, standard output, and log file to
# temporary names in the current directory (they are built in the test
Expand Down Expand Up @@ -2964,6 +2981,19 @@ stest:
cat ./PET*$(TNAME)STest.Log> ./ESMF_$(TNAME)STest.Log ; \
$(ESMF_RM) ./PET*$(TNAME)STest.Log

sctest:
-@cd $(ESMF_TESTDIR) ; \
$(ESMF_RM) ./PET*$(TNAME)STest.Log ; \
if [ $(ESMF_BATCHDEPRECATED) = "true" ] ; then \
echo $(ESMF_MPIRUN) -np $(NP) $(ESMF_TOOLRUN) ./ESMC_$(TNAME)STest ; \
$(ESMF_MPIRUN) -np $(NP) $(ESMF_TOOLRUN) ./ESMC_$(TNAME)STest ; \
else \
echo $(ESMF_MPIRUN) -np $(NP) $(ESMF_TOOLRUN) ./ESMC_$(TNAME)STest 1\> ./ESMC_$(TNAME)STest.stdout 2\>\&1 ; \
$(ESMF_MPIRUN) -np $(NP) $(ESMF_TOOLRUN) ./ESMC_$(TNAME)STest 1> ./ESMC_$(TNAME)STest.stdout 2>&1 ; \
fi ; \
cat ./PET*$(TNAME)STest.Log> ./ESMC_$(TNAME)STest.Log ; \
$(ESMF_RM) ./PET*$(TNAME)STest.Log

#
# this target deletes only the system test related files from the test subdir
#
Expand Down
15 changes: 15 additions & 0 deletions cmake/FindESMF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@
# Set ESMFMKFILE as defined by system env variable. If it's not explicitly set
# try to find esmf.mk file in default locations (ESMF_ROOT, CMAKE_PREFIX_PATH,
# etc)

# - Common Usage
#
# Where to look for this FindESMF.cmake file
# list(APPEND CMAKE_MODULE_PATH "<PATH_TO_THIS_FILE>")
# <PATH_TO_THIS_FILE> is to be replaced with the directory for this file
#
# How to locate ESMF libraries and create target
# find_package(ESMF <X.Y.Z> MODULE REQUIRED)
# <X.Y.Z> is to be replaced with the minimum version required
#
# How to link targets
# target_link_libraries(<CMAKE_TARGET> PUBLIC ESMF::ESMF)
# <CMAKE_TARGET> is to be replaced with your CMake target

if(NOT DEFINED ESMFMKFILE)
if(NOT DEFINED ENV{ESMFMKFILE})
find_path(ESMFMKFILE_PATH esmf.mk PATH_SUFFIXES lib lib64)
Expand Down
49 changes: 49 additions & 0 deletions cmake/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# CMake Modules Provided by ESMF

The ESMF team provides CMake[1] modules that are useful when ESMF is needed
within a CMake based build system. These modules can find libraries, create
targets, and set variables within the scope of a CMake build. They may be
used as is or customized for application specific build systems. Typically,
CMake module files are copied into a project and maintained along with the
project's build system. For more information about installing the provided
modules see the ESMF User's Guide[2].

Provided modules:

- FindESMF.cmake

### FindESMF.cmake

The FindESMF.cmake module provided by ESMF utilizes a CMake variable,
named ESMFMKFILE, to locate the esmf.mk file. The esmf.mk file is parsed to locate
ESMF libraries and create CMake targets for ESMF. If the ESMF library is not
found then ESMF_FOUND is set to FALSE, a warning is displayed, and find_package
fails (when REQUIRED is set).

If the ESMFMKFILE variable is not set then FindESMF.cmake will look for an
environment variable with the same name. If ESMFMKFILE is not set in either
context then CMake will search default paths, including ESMF_ROOT, for the
esmf.mk file.

Usage in CMake:
```
# Where to look for the FindESMF.cmake file
# <PATH_TO_FINDESMF> is to be replaced with the location of FindESMF.cmake
list(APPEND CMAKE_MODULE_PATH "<PATH_TO_FINDESMF>")
# How to locate ESMF libraries and create target
# <X.Y.Z> is to be replaced with the minimum version required
find_package(ESMF <X.Y.Z> MODULE REQUIRED)
# How to link targets
# <CMAKE_TARGET> is to be replaced with your CMake target
target_link_libraries(<CMAKE_TARGET> PUBLIC ESMF::ESMF)
```

## Links

- [1] https://cmake.org/cmake/help/book/mastering-cmake/index.html
- [2] https://earthsystemmodeling.org/doc/
Loading

0 comments on commit 47017b5

Please sign in to comment.