Skip to content

Commit

Permalink
Merge pull request #842 from danielpeter/devel
Browse files Browse the repository at this point in the history
updates SIEM configuration and routines; adds github action tests for ADIOS2 and full gravity w/ PETSc
  • Loading branch information
danielpeter authored Jun 4, 2024
2 parents 66cc04e + 2048cf5 commit 0db62bb
Show file tree
Hide file tree
Showing 18 changed files with 2,491 additions and 2,120 deletions.
38 changes: 36 additions & 2 deletions .github/scripts/run_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,47 @@ echo "mpif90 --version"
mpif90 --version
echo

## ADIOS2
if [ "${ADIOS2}" == "true" ]; then
echo
echo "enabling ADIOS2"
echo
ADIOS2_CONFIG="${ADIOS2_DIR}/bin/adios2-config"
adios=(--with-adios2 ADIOS2_CONFIG="$ADIOS2_CONFIG" )
else
adios=()
fi

## NetCDF
if [ "${NETCDF}" == "true" ]; then
echo
echo "enabling NetCDF"
echo
netcdf=(--with-netcdf NETCDF_INC="/usr/include" NETCDF_LIBS="-lnetcdff" )
else
netcdf=()
fi

## PETSc
if [ "${PETSC}" == "true" ]; then
echo
echo "enabling PETSc"
echo
petsc=(--with-petsc PETSC_INC="/usr/include/petsc" )
else
petsc=()
fi

# configuration
echo
echo "configuration: default"
echo "configuration:"
echo

./configure FC=gfortran MPIFC=mpif90 CC=gcc "${TESTFLAGS}"
./configure \
${adios[@]} \
${netcdf[@]} \
${petsc[@]} \
FC=gfortran MPIFC=mpif90 CC=gcc "${TESTFLAGS}"

# checks
if [[ $? -ne 0 ]]; then echo "configuration failed:"; cat config.log; echo ""; echo "exiting..."; exit 1; fi
Expand Down
63 changes: 61 additions & 2 deletions .github/scripts/run_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,34 @@ sudo apt-get install -yq --no-install-recommends gfortran g++ openmpi-bin libope
if [[ $? -ne 0 ]]; then exit 1; fi
echo

## NetCDF
if [ "${NETCDF}" == "true" ]; then
echo
echo "NETCDF installation:"
echo
# installs fortran netcdf
sudo apt-get install -yq --no-install-recommends libnetcdff-dev
# checks exit code
if [[ $? -ne 0 ]]; then exit 1; fi
echo; echo "done netCDF"; echo
fi

## PETSc
if [ "${PETSC}" == "true" ]; then
echo
echo "PETSc installation:"
echo
# requires gfortran version 10 as default
#mv -v /usr/local/bin/gfortran /usr/local/bin/gfortran-9
#sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-10 60
#sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 60
# installs petsc
sudo apt-get install -yq --no-install-recommends petsc-dev
# checks exit code
if [[ $? -ne 0 ]]; then exit 1; fi
echo; echo "done PETSc"; echo
fi

# python3 pip upgrade might complain: "ERROR: launchpadlib 1.10.13 requires testresources"
sudo apt-get install -yq --no-install-recommends python3-testresources
# checks exit code
Expand Down Expand Up @@ -60,6 +88,39 @@ echo "mpif90 --version"
mpif90 --version
echo

## ADIOS2
if [ "${ADIOS2}" == "true" ]; then
echo
echo "ADIOS2 installation:"
echo
# installs cmake wget
sudo apt-get install -yq --no-install-recommends cmake wget
# checks exit code
if [[ $? -ne 0 ]]; then exit 1; fi
# uses /opt as installation directory
mkdir -p /opt; cd /opt
# download source
wget https://github.com/ornladios/ADIOS2/archive/refs/tags/v2.10.1.tar.gz
tar zxvf v2.10.1.tar.gz
cd ADIOS2-2.10.1/
# build source
mkdir -p build; cd build/
CC=gcc CXX=g++ FC=gfortran cmake -DADIOS2_USE_Fortran=ON \
-DADIOS2_USE_HDF5=OFF -DADIOS2_BUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF \
-DCMAKE_INSTALL_PREFIX=/opt/ADIOS2 ../
# checks exit code
if [[ $? -ne 0 ]]; then exit 1; fi
make -j4
# checks exit code
if [[ $? -ne 0 ]]; then exit 1; fi
make install
# checks exit code
if [[ $? -ne 0 ]]; then exit 1; fi
# environment for directory
echo "ADIOS2_DIR=/opt/ADIOS2" >> $GITHUB_ENV
echo; echo "done ADIOS2"; echo
fi

# MPI
# github actions uses for Linux virtual machines a 2-core CPU environment
# see: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
Expand Down Expand Up @@ -116,8 +177,6 @@ echo "OMPI_MCA_rmaps_base_inherit=1" >> $GITHUB_ENV
# exports for xterm output (for make tests)
echo "TERM=xterm" >> $GITHUB_ENV



echo
echo "exports:"
export
Expand Down
40 changes: 33 additions & 7 deletions .github/scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ my_test(){
cd $dir

# default setup
# limit number of time steps
sed -i "s:^RECORD_LENGTH_IN_MINUTES .*:RECORD_LENGTH_IN_MINUTES = 0.5:" DATA/Par_file
# shortens output interval to avoid timeouts
sed -i "s:^NTSTEP_BETWEEN_OUTPUT_INFO .*:NTSTEP_BETWEEN_OUTPUT_INFO = 50:" DATA/Par_file
if [ ! "${RUN_KERNEL}" == "true" ]; then
# limit number of time steps
sed -i "s:^RECORD_LENGTH_IN_MINUTES .*:RECORD_LENGTH_IN_MINUTES = 0.5:" DATA/Par_file
# shortens output interval to avoid timeouts
sed -i "s:^NTSTEP_BETWEEN_OUTPUT_INFO .*:NTSTEP_BETWEEN_OUTPUT_INFO = 50:" DATA/Par_file
fi

# specific example setups
if [ "${TESTDIR}" == "EXAMPLES/global_small" ]; then
Expand All @@ -50,9 +52,33 @@ if [ "${DEBUG}" == "true" ]; then
sed -i "s:^RECORD_LENGTH_IN_MINUTES .*:RECORD_LENGTH_IN_MINUTES = 0.0:" DATA/Par_file
fi

# default script
./run_this_example.sh
# full gravity
if [ "${FULL_GRAVITY}" == "true" ]; then
# turns on full gravity
sed -i "s:^FULL_GRAVITY .*:FULL_GRAVITY = .true.:" DATA/Par_file
# PETSc
if [ "${PETSC}" == "true" ]; then
# switch to PETSc Poisson solver
sed -i "s:^POISSON_SOLVER .*:POISSON_SOLVER = 1:" DATA/Par_file
fi
# set NSTEP for short checks only
echo "NSTEP = 2" >> DATA/Par_file
fi

# adios
if [ "${ADIOS2}" == "true" ]; then
# turns on ADIOS
sed -i "s:^ADIOS_ENABLED .*:ADIOS_ENABLED = .true.:" DATA/Par_file
fi

# use kernel script
if [ "${RUN_KERNEL}" == "true" ]; then
# use kernel script
./run_this_example.kernel.sh
else
# default script
./run_this_example.sh
fi
# checks exit code
if [[ $? -ne 0 ]]; then exit 1; fi

Expand All @@ -63,7 +89,7 @@ echo `date`
echo

# seismogram comparison
if [ "${DEBUG}" == "true" ]; then
if [ "${DEBUG}" == "true" ] || [ "${FULL_GRAVITY}" == "true" ] || [ "${RUN_KERNEL}" == "true" ]; then
# no comparisons
: # do nothing
else
Expand Down
110 changes: 110 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,113 @@ jobs:
TESTDIR: EXAMPLES/mars_regional
run: ./.github/scripts/run_tests.sh
shell: bash

linuxTest_7:
name: Test run example 7 - global_small
runs-on: ubuntu-latest
needs: [linuxCheck]

steps:
- uses: actions/checkout@v4

- name: Install packages
run: ./.github/scripts/run_install.sh
shell: bash

- name: Run build
env:
TESTFLAGS: --enable-vectorization
run: ./.github/scripts/run_build.sh
shell: bash

- name: Run test
env:
TESTDIR: EXAMPLES/global_small
run: ./.github/scripts/run_tests.sh
shell: bash

linuxTest_8:
name: Test run example 8 - global_small w/ FULL_GRAVITY netCDF
runs-on: ubuntu-latest
needs: [linuxCheck]

steps:
- uses: actions/checkout@v4

- name: Install packages
env:
NETCDF: true
run: ./.github/scripts/run_install.sh
shell: bash

- name: Run build
env:
TESTFLAGS: --enable-debug
NETCDF: true
run: ./.github/scripts/run_build.sh
shell: bash

- name: Run test
env:
TESTDIR: EXAMPLES/global_small
FULL_GRAVITY: true
run: ./.github/scripts/run_tests.sh
shell: bash

linuxTest_9:
name: Test run example 9 - global_small w/ FULL_GRAVITY PETSc
runs-on: ubuntu-latest
needs: [linuxCheck]

steps:
- uses: actions/checkout@v4

- name: Install packages
env:
PETSC: true
run: ./.github/scripts/run_install.sh
shell: bash

- name: Run build
env:
TESTFLAGS: # no extra flags
PETSC: true
run: ./.github/scripts/run_build.sh
shell: bash

- name: Run test
env:
TESTDIR: EXAMPLES/global_small
FULL_GRAVITY: true
PETSC: true
run: ./.github/scripts/run_tests.sh
shell: bash

linuxTest_10:
name: Test run example 10 - regional_Greece_small_LDDRK kernel ADIOS2
runs-on: ubuntu-latest
needs: [linuxCheck]

steps:
- uses: actions/checkout@v4

- name: Install packages
env:
ADIOS2: true
run: ./.github/scripts/run_install.sh
shell: bash

- name: Run build
env:
TESTFLAGS: # no extra flags
ADIOS2: true
run: ./.github/scripts/run_build.sh
shell: bash

- name: Run test
env:
TESTDIR: EXAMPLES/regional_Greece_small_LDDRK
ADIOS2: true
RUN_KERNEL: true
run: ./.github/scripts/run_tests.sh
shell: bash
30 changes: 27 additions & 3 deletions EXAMPLES/global_small/run_mesher_solver.bash
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
#!/bin/bash

# DATABASES directory
BASEMPIDIR=`grep ^LOCAL_PATH DATA/Par_file | cut -d = -f 2 `
BASEMPIDIR=`grep ^LOCAL_PATH DATA/Par_file | cut -d = -f 2`

# script to run the mesher and the solver
# read DATA/Par_file to get information about the run
# compute total number of nodes needed
NPROC_XI=`grep ^NPROC_XI DATA/Par_file | cut -d = -f 2 `
NPROC_XI=`grep ^NPROC_XI DATA/Par_file | cut -d = -f 2`
NPROC_ETA=`grep ^NPROC_ETA DATA/Par_file | cut -d = -f 2`
NCHUNKS=`grep ^NCHUNKS DATA/Par_file | cut -d = -f 2 `
NCHUNKS=`grep ^NCHUNKS DATA/Par_file | cut -d = -f 2`

# total number of nodes is the product of the values read
numnodes=$(( $NCHUNKS * $NPROC_XI * $NPROC_ETA ))

# full gravity option
FULL_GRAVITY=`grep ^FULL_GRAVITY DATA/Par_file | cut -d = -f 2 | tr -d '[:space:]'`


mkdir -p OUTPUT_FILES
mkdir -p $BASEMPIDIR

Expand Down Expand Up @@ -43,6 +47,26 @@ echo
cp OUTPUT_FILES/*.txt $BASEMPIDIR/


## full gravity
if [ "$FULL_GRAVITY" == ".true." ]; then
##
## gindex3D
##
echo
echo "running xgindex3D..."
echo
if [ ! -e $PWD/bin/xgindex3D ]; then echo "xgindex3D was not compiled, aborting..."; exit 1; fi

mpirun -np 1 $PWD/bin/xgindex3D $numnodes

# checks exit code
if [[ $? -ne 0 ]]; then exit 1; fi

echo
echo " gindex3D done: `date`"
echo
fi

##
## forward simulation
##
Expand Down
5 changes: 1 addition & 4 deletions EXAMPLES/global_small/run_this_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ fi
# copy executables
mkdir -p bin
rm -rf bin/*
cp ../../bin/xmeshfem3D ./bin/
cp ../../bin/xspecfem3D ./bin/
cp ../../bin/xcombine_vol_data ./bin/
cp ../../bin/xcombine_vol_data_vtk ./bin/
cp ../../bin/x* ./bin/

# links data directories needed to run example in this current directory with s362ani
cd DATA/
Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -11843,7 +11843,7 @@ printf %s "checking PETSc linking with PetscInitialize in -lpetsc... " >&6; }
use petscksp
implicit none
PetscErrorCode :: ierr
call PetscInitialize(ierr)
call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
call PetscFinalize(ierr)
end
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ AS_IF([test x"$want_petsc" != xno], [
use petscksp
implicit none
PetscErrorCode :: ierr
call PetscInitialize(ierr)
call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
call PetscFinalize(ierr)
]])
], [
Expand Down
Loading

0 comments on commit 0db62bb

Please sign in to comment.