Skip to content

Commit

Permalink
compile with a matrix of options and cleanup arument parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenchilutti committed Apr 24, 2024
1 parent 0e6f603 commit 97e694e
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 226 deletions.
52 changes: 27 additions & 25 deletions .github/.parallelworks/checkout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,34 @@ intelVersion=2023.2.0
container=/contrib/containers/noaa-intel-prototype_2023.09.25.sif
container_env_script=/contrib/containers/load_spack_noaa-intel.sh
##############################################################################
## Set up the directories
# First argument should be $GITHUB_REF which is the reference to the PR/branch
# to be checked out for SHiELD_build
if [ -z "$1" ]
then
echo "No branch/PR supplied; using main"
branch=main
else
echo Branch is ${1}
branch=${1}
fi
# Second Argument should be $GITHUB_SHA which is the commit hash of the
# branch or PR to trigger the CI, if run manually, you do not need a 2nd
# argument. This is needed in the circumstance where a PR is created,
# then the CI triggers, and before that CI has finished, the developer
# pushes a newer commit which triggers a second round of CI. We would
# like unique directories so that both CI runs do not interfere.
if [ -z "$2" ]
then
echo "No second argument"
commit=""
else
echo Commit is ${2}
commit=${2}
fi

#Parse Arguments
branch=main
commit=""
while [[ $# -gt 0 ]]; do
case $1 in
-b|--branch)
branch="$2"
shift # past argument
shift # past value
;;
-h|--hash)
commit="$2"
shift # past argument
shift # past value
;;
*)
echo "unknown argument"
exit 1
;;
esac
done

echo "branch is $branch"
echo "commit is $commit"


## Set up the directories
testDir=${dirRoot}/${intelVersion}/SHiELD_build/${branch}/${commit}
logDir=${testDir}/log
export MODULESHOME=/usr/share/lmod/lmod
Expand Down
75 changes: 75 additions & 0 deletions .github/.parallelworks/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/sh -xe

##############################################################################
## User set up variables
## Root directory for CI
dirRoot=/contrib/fv3
## Intel version to be used
intelVersion=2023.2.0
##############################################################################
## HPC-ME container
container=/contrib/containers/noaa-intel-prototype_2023.09.25.sif
container_env_script=/contrib/containers/load_spack_noaa-intel.sh
##############################################################################

#Parse Arguments
branch=main
commit=""
while [[ $# -gt 0 ]]; do
case $1 in
-b|--branch)
branch="$2"
shift # past argument
shift # past value
;;
-h|--hash)
commit="$2"
shift # past argument
shift # past value
;;
-c|--config)
config="$2"
shift # past argument
shift # past value
-hy|--hydro)
hydro="$2"
shift # past argument
shift # past value
-b|--bit)
bit="$2"
shift # past argument
shift # past value
-m|--mode)
mode="$2"
shift # past argument
shift # past value
*)
echo "unknown argument"
exit 1
;;
esac
done

if [ -z $mode | -z $bit | -z $hydro | -b $config ]
then
echo "must specify config, hydro, bit, and mode options for compile"
exit 1
fi

echo "branch is $branch"
echo "commit is $commit"
echo "mode is $mode"
echo "bit is $bit"
echo "hydro is $hydro"
echo "config is $config"

## Set up the directories
testDir=${dirRoot}/${intelVersion}/SHiELD_build/${branch}/${commit}
logDir=${testDir}/log
# Set up build
cd ${testDir}/SHiELD_build/Build
#Define External Libs path
export EXTERNAL_LIBS=${dirRoot}/${intelVersion}/SHiELD_build/externallibs
# Build SHiELD
set -o pipefail
singularity exec -B /contrib ${container} ${container_env_script} "./COMPILE ${config} ${hydro} ${bit} ${mode} intel clean"
39 changes: 0 additions & 39 deletions .github/.parallelworks/hydrocompile.sh

This file was deleted.

39 changes: 0 additions & 39 deletions .github/.parallelworks/nhcompile.sh

This file was deleted.

71 changes: 40 additions & 31 deletions .github/.parallelworks/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,45 @@ intelVersion=2023.2.0
## HPC-ME container
container=/contrib/containers/noaa-intel-prototype_2023.09.25.sif
container_env_script=/contrib/containers/load_spack_noaa-intel.sh
##############################################################################

##Parse Arguments
#first argument should be the name of the test and is mandatory
if [ -z "$1" ]
then
echo "Please run this script with an argument indicating what test to run. For example:"
echo "./run_test.sh C128r20.solo.superC"
else
echo Test is ${1}
test=${1}
fi
#second argument is the branch name. This is optional. Default is main branch if none supplied
if [ -z "$2" ]
then
echo "No branch supplied; using main"
branch=main
else
echo Branch is ${2}
branch=${2}
fi
#third argument is the commit hash if running from CI. This is optional
if [ -z "$3" ]
#Parse Arguments
branch=main
commit=""
while [[ $# -gt 0 ]]; do
case $1 in
-b|--branch)
branch="$2"
shift # past argument
shift # past value
;;
-h|--hash)
commit="$2"
shift # past argument
shift # past value
;;
-t|--test)
testname="$2"
shift # past argument
shift # past value
;;
*)
echo "unknown argument"
exit 1
;;
esac
done

if [ -z $testname ]
then
echo "No commit being used in file path"
commit=""
else
echo Commit is ${3}
commit=${3}
echo "must specify a test name with -t"
exit 1
fi

echo "branch is $branch"
echo "commit is $commit"
echo "test is $testname"

## Set up the directories
MODULESHOME=/usr/share/lmod/lmod
testDir=${dirRoot}/${intelVersion}/SHiELD_build/${branch}/${commit}
Expand All @@ -57,24 +66,24 @@ runDir=${BUILDDIR}/CI/BATCH-CI
cd ${testscriptDir}
set -o pipefail
# Execute the test piping output to log file
./${test} " --partition=p2 --mpi=pmi2 --job-name=${commit}_${test} singularity exec -B /contrib ${container} ${container_env_script}" |& tee ${logDir}/run_${test}.log
./${testname} " --partition=p2 --mpi=pmi2 --job-name=${commit}_${testname} singularity exec -B /contrib ${container} ${container_env_script}" |& tee ${logDir}/run_${testname}.log

## Compare Restarts to Baseline
#The following tests are not expectred to have run-to-run reproducibility:
#d96_2k.solo.bubble
#d96_2k.solo.bubble.n0
#d96_2k.solo.bubble.nhK
if [[ ${test} == "d96_2k.solo.bubble" || ${test} == "d96_2k.solo.bubble.n0" || ${test} == "d96_2k.solo.bubble.nhK" ]]
if [[ ${testname} == "d96_2k.solo.bubble" || ${testname} == "d96_2k.solo.bubble.n0" || ${testname} == "d96_2k.solo.bubble.nhK" ]]
then
echo "${test} is not expected to reproduce so answers were not compared"
echo "${testname} is not expected to reproduce so answers were not compared"
else
source $MODULESHOME/init/sh
export MODULEPATH=/mnt/shared/manual_modules:/usr/share/modulefiles/Linux:/usr/share/modulefiles/Core:/usr/share/lmod/lmod/modulefiles/Core:/apps/modules/modulefiles:/apps/modules/modulefamilies/intel
module load intel/2022.1.2
module load netcdf
module load nccmp
for resFile in `ls ${baselineDir}/${test}`
for resFile in `ls ${baselineDir}/${testname}`
do
nccmp -d ${baselineDir}/${test}/${resFile} ${runDir}/${test}/RESTART/${resFile}
nccmp -d ${baselineDir}/${testname}/${resFile} ${runDir}/${testname}/RESTART/${resFile}
done
fi
40 changes: 0 additions & 40 deletions .github/.parallelworks/swcompile.sh

This file was deleted.

Loading

0 comments on commit 97e694e

Please sign in to comment.