diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f04e101 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.env +.gitlab_ci.yaml +*.log +*.md +docker-compose.yml +hooks diff --git a/.gitignore b/.gitignore index 67a0b70..0906a4f 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,17 @@ libjigsaw64r.so # Misc sediments-us +# Common test output files +# (Test directories may also have their own .gitignore files) +model/tests/ems_test.log +model/tests/**/alert.* +model/tests/**/core.* +model/tests/**/diag.txt +model/tests/**/in*.nc +model/tests/**/loc*.ts +model/tests/**/obc_spec.txt +model/tests/**/out*.nc +model/tests/**/runlog +model/tests/**/setup.txt +model/tests/**/out/* +!model/tests/**/out/.empty diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..14f9871 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,69 @@ +#------------------------------------------------------------------------------ +# CSIRO EMS Image Build Script +#------------------------------------------------------------------------------ +# The recommended base image is one of the onaci/ereefs-netcdf-base variants, +# as those have been designed to include all the EMS dependencies. +# Allow it to be overridden in order to choose *which* variant, or even +# something completely different. +ARG BASE_IMAGE="onaci/ereefs-netcdf-base:python-3.11-slim-bullseye" +FROM ${BASE_IMAGE} + +# Record the actual base image used from the FROM command as a label. +ARG BASE_IMAGE +LABEL org.opencontainers.image.base.name=${BASE_IMAGE} + +# Enable Bash in RUN commands, and ensure that any commands with +# pipes exit on the first failure. +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +# Prepare a base directory for all the EMS code +ARG EMS_BASE="/usr/local/src/ems" +ENV EMS_BASE="${EMS_BASE}" +WORKDIR ${EMS_BASE} + +# Install all the EMS Source Code +COPY ./ ./ + +# Selectively remove some subdirectories that we want to omit +# (List can be overridden by a build argument) +ARG EMS_RM_DIRS="" +RUN if [ -n "${EMS_RM_DIRS}" ]; then for d in $EMS_RM_DIRS; do rm -rf "${EMS_BASE}/${d}"; done; fi + +# Compile the EMS components +# We build with OpenMP support by default for use in a docker container +# Different options can be specified by overriding the EMS_CONFIGURE_OPTS build argument +# (The base image *does* include NetCDF and HDF5 with Open MPI support, so that is an option) +ENV EMS_BUILD_LOG="${EMS_BASE}/ems_build.log" +ARG EMS_CONFIGURE_OPTS="--enable-omp" +RUN make distclean || true \ + && conf/configure ${EMS_CONFIGURE_OPTS} 2>&1 | tee -a "${EMS_BUILD_LOG}" +RUN make clean \ + && make 2>&1 | tee -a "${EMS_BUILD_LOG}" +RUN make check install 2>&1 | tee -a "${EMS_BUILD_LOG}" + +# Symlink the EMS executable(s) into the default path +# (This will fail if the executable did not build for some reason) +ENV SHOC="${EMS_BASE}/model/hd/shoc" \ + COMPAS="${EMS_BASE}/model/hd-us/compas" +RUN if [ -n "${SHOC}" ]; then chmod 0755 "${SHOC}" && ln -s "${SHOC}" /usr/local/bin/shoc; fi; \ + if [ -n "${COMPAS}" ]; then chmod 0755 "${COMPAS}" && ln -s "${COMPAS}" /usr/local/bin/compas; fi; \ + ln -s "${EMS_BASE}/model/tests/run-tests.sh" /usr/local/bin/run-ems-tests + +# Optionally run all available unit tests +# (Override the EMS_TEST_RUN build argument to have a value of 0 to skip testing at build time) +ARG EMS_TEST_RUN=1 +ARG EMS_TEST_INCLUDE="${EMS_BASE}/model/tests" +ENV EMS_TEST_INCLUDE="${EMS_TEST_INCLUDE}" +ARG EMS_TEST_EXCLUDE="" +ENV EMS_TEST_EXCLUDE="${EMS_TEST_EXCLUDE}" +ENV EMS_TEST_LOG="${EMS_BASE}/model/tests/ems_test.log" +RUN if [ $EMS_TEST_RUN -eq 1 ]; then run-ems-tests; fi + +# Encode EMS metadata in labels +LABEL au.csiro.ems.base=${EMS_BASE} \ + au.csiro.ems.shoc=${SHOC} \ + au.csiro.ems.compas=${COMPAS} + +# Configure the default entrypoint to be a default EMS executable +ENTRYPOINT ["/bin/bash", "-c" ] +CMD [ "${SHOC:-$COMPAS}", "-v"] diff --git a/docker-compose.test.yml b/docker-compose.test.yml new file mode 100644 index 0000000..a357702 --- /dev/null +++ b/docker-compose.test.yml @@ -0,0 +1,22 @@ +--- +#------------------------------------------------------------------------------- +# Docker *test* environment composition for EMS +# This exists to support the autotest option for a Dockerhub repository build +# (See: https://docs.docker.com/docker-hub/builds/automated-testing/) +# +# If this repository and rbanch are configured as Dockerhub autotest +# repositories, this will automatically build and test EMS with all default +# settings every time a push is made to the repository. +# +# The resulting image is not automatically pushed to the DockerHub registry +# unless the same respository is automatically configured for autobuild. +#------------------------------------------------------------------------------- +version: "3.8" + +services: + ems: + build: + context: . + args: + EMS_TEST_RUN: 0 + command: "run-ems-tests" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8bdb97c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +--- +#------------------------------------------------------------------------------- +# Docker development environment composition for ems +# (Not for production use!) +# +# This default compose stack is designed for use on a local development host. +#------------------------------------------------------------------------------- +version: "3.8" + +services: + ems: + build: + context: . + args: + #EMS_RM_DIRS: "ext/swan model/lib/da model/lib/exchange" + EMS_TEST_RUN: 0 + command: "run-ems-tests" + container_name: ems + environment: + EMS_TEST_INCLUDE: '/usr/local/src/ems/model/tests' + image: onaci/ereefs-ems-shoc:dev + volumes: + - ./model/tests/:/usr/local/src/ems/model/tests/ diff --git a/hooks/README.md b/hooks/README.md new file mode 100644 index 0000000..c084349 --- /dev/null +++ b/hooks/README.md @@ -0,0 +1,7 @@ +# csiro-coasts/EMS/hooks + +The files in this directory are custom build phase hooks for the automated dockerhub builder, +and are used to set up custom build configurations and docker registry push options for when +this repository is set up as a DockerHub repository with autobuild enabled. + +See for more information about how they work. diff --git a/hooks/build b/hooks/build new file mode 100644 index 0000000..df195fa --- /dev/null +++ b/hooks/build @@ -0,0 +1,62 @@ +#!/bin/bash + +# Derive useful variables from the dockerhub build environment +BUILD_TIMESTAMP="$(date --rfc-3339=seconds)" +DOCKER_TAG="${DOCKER_TAG:-}" +DOCKERFILE_PATH="${DOCKERFILE_PATH:-./Dockerfile}" +IMAGE_NAME="${IMAGE_NAME:-csiro-coasts/ems}" +SAFE_TIMESTAMP="$(echo $BUILD_TIMESTAMP | sed 's/ /T/g' | sed 's/:/-/g' | sed 's/\+.*//')" +SOURCE_URL="$(git remote get-url origin || true)" +VERSION_TAG="${SOURCE_BRANCH}_v${SAFE_TIMESTAMP}-${SOURCE_COMMIT}" + +# Ensure we have values for all required build arguments. +# These can be configured as environment variables on the dockerhub build, +# but if they are not, then we parse the defaults out of the Dockerfile. +BASE_IMAGE="${BASE_IMAGE:-}" +if [ -z "${BASE_IMAGE:-}" ]; then + BASE_IMAGE=$(grep 'ARG BASE_IMAGE=' ./Dockerfile | tr '"' ' ' | tr '=' ' ' | awk '{print $3}') +fi +EMS_CONFIGURE_OPTS="${EMS_CONFIGURE_OPTS:-}" +if [ -z "${EMS_CONFIGURE_OPTS:-}" ]; then + EMS_CONFIGURE_OPTS=$(grep 'ARG EMS_CONFIGURE_OPTS=' ./Dockerfile | tr '"' ' ' | tr '=' ' ' | awk '{print $3}') +fi +EMS_RM_DIRS="${EMS_RM_DIRS:-}" +if [ -z "${EMS_RM_DIRS:-}" ]; then + EMS_RM_DIRS=$(grep 'ARG EMS_RM_DIRS=' ./Dockerfile | tr '"' ' ' | tr '=' ' ' | awk '{print $3}') +fi +EMS_TEST_RUN="${EMS_TEST_RUN:-}" +if [ -z "${EMS_TEST_RUN:-}" ]; then + EMS_TEST_RUN=$(grep 'ARG EMS_TEST_RUN=' ./Dockerfile | tr '"' ' ' | tr '=' ' ' | awk '{print $3}') +fi + +# Treat most DOCKER_TAG values as overrides for the +# BASE_IMAGE variable sourced from the .env file +if [[ -n "${DOCKER_TAG}" ]] && [[ "${DOCKER_TAG}" != "latest" ]] && [[ "${DOCKER_TAG}" != "${SOURCE_BRANCH}" ]]; then + # Assume the custom docker tag is an override for the tag part of + # the BASE_IMAGE configured in the Dockerfile and any .env file. + BASE_IMAGE="$(echo $BASE_IMAGE | sed -E 's/^([^:]*):.*$/\1/'):${DOCKER_TAG}" + + # Override the VERSION_TAG to include it there too. + VERSION_TAG="${SOURCE_BRANCH}_${DOCKER_TAG}_v${SAFE_TIMESTAMP}-${SOURCE_COMMIT}" +fi + +# Build our customised docker image +docker build --pull \ + --build-arg "BASE_IMAGE=${BASE_IMAGE}" \ + --build-arg "EMS_CONFIGURE_OPTS=${EMS_CONFIGURE_OPTS}" \ + --build-arg "EMS_RM_DIRS=${EMS_RM_DIRS}" \ + --build-arg "EMS_TEST_RUN=${EMS_TEST_RUN}" \ + --label "org.opencontainers.image.authors=${BUILD_AUTHORS:-CSIRO Coastal Group}" \ + --label "org.opencontainers.image.branch=${SOURCE_BRANCH}" \ + --label "org.opencontainers.image.buildhost=${DOCKER_REPO}" \ + --label "org.opencontainers.image.created=${BUILD_TIMESTAMP}" \ + --label "org.opencontainers.image.licenses=https://github.com/csiro-coasts/EMS/blob/master/LICENSE.md" \ + --label "org.opencontainers.image.revision=${SOURCE_COMMIT}" \ + --label "org.opencontainers.image.source=${SOURCE_URL}" \ + --label "org.opencontainers.image.title=${DOCKER_REPO:-csiro-coasts/EMS}" \ + --label "org.opencontainers.image.url=https://github.com/csiro-coasts/EMS" \ + --label "org.opencontainers.image.vendor=CSIRO" \ + --label "org.opencontainers.image.version=${VERSION_TAG}" \ + -f ${DOCKERFILE_PATH} \ + -t ${IMAGE_NAME} \ + . diff --git a/hooks/post_push b/hooks/post_push new file mode 100644 index 0000000..4cd9186 --- /dev/null +++ b/hooks/post_push @@ -0,0 +1,8 @@ +#!/bin/bash + +VERSION_TAG="$(docker image inspect --format '{{ index .Config.Labels "org.opencontainers.image.version"}}' $IMAGE_NAME || true)" +if [ -n "${VERSION_TAG}" ]; then + IMAGE_TAGGED="${DOCKER_REPO}:${VERSION_TAG}" + docker tag $IMAGE_NAME $IMAGE_TAGGED + docker push $IMAGE_TAGGED +fi diff --git a/model/tests/hd-us/.gitignore b/model/tests/hd-us/.gitignore new file mode 100644 index 0000000..a42fa18 --- /dev/null +++ b/model/tests/hd-us/.gitignore @@ -0,0 +1,18 @@ +boundary.txt +closed*.nc +closed*.txt +closed*.us +est.nc +est_hex*.txt +est_hex*.us +est_quad*.nc +est_quad*.txt +plot_*_hex.m +in1*.txt +in1*.us +points.txt +pt.nc +s_*_quad.nc +segment.txt +test2*.txt +totals.ts diff --git a/model/tests/hd-us/cetas/.gitignore b/model/tests/hd-us/cetas/.gitignore new file mode 100644 index 0000000..367e1dc --- /dev/null +++ b/model/tests/hd-us/cetas/.gitignore @@ -0,0 +1,10 @@ +*.msh +*.txt +*.us +*.jig +*.site +in.nc +in.prm +outputs/* +!outputs/.empty +plot_auto.m diff --git a/model/tests/hd-us/cetas/run_cetas b/model/tests/hd-us/cetas/run_cetas index 36baa61..120de9b 100755 --- a/model/tests/hd-us/cetas/run_cetas +++ b/model/tests/hd-us/cetas/run_cetas @@ -1,15 +1,19 @@ -#!/bin/csh -f +#!/bin/csh -exf echo "Testing COMPAS cetas..." -rm *.msh -rm *.txt -rm *.us -rm *.jig -rm *.site -rm in.nc -../compas -ag auto.prm +if (! $?COMPAS || "$COMPAS" == "") then + set COMPAS='../compas' +endif -echo "DONE" +set nonomatch +rm -f *.msh +rm -f *.txt +rm -f *.us +rm -f *.jig +rm -f *.site +rm -f in.nc +$COMPAS -ag auto.prm +echo "DONE" diff --git a/model/tests/hd-us/closed/run_closed b/model/tests/hd-us/closed/run_closed index 48fd897..8d4cc86 100755 --- a/model/tests/hd-us/closed/run_closed +++ b/model/tests/hd-us/closed/run_closed @@ -1,8 +1,13 @@ #!/bin/csh -ef -# Set relative path to compas executable -set COMPAS='../../../hd-us/compas' -set SHOC='../../../hd/shoc' +if (! $?COMPAS || "$COMPAS" == "") then + # Set relative path to compas executable + set COMPAS='../../../hd-us/compas' +endif +if (! $?SHOC || "$SHOC" == "") then + # Set relative path to shoc executable + set SHOC='../../../hd/shoc' +endif echo "Testing SHOC..." rm -f closed.nc || true @@ -14,7 +19,7 @@ if (-f $SHOC) then else echo "SHOC not found, skipping ..." endif - + echo "DONE" echo "Testing COMPAS quad..." @@ -42,6 +47,3 @@ $COMPAS -g closed_hex.prm closed_hex.nc $COMPAS -p closed_hex.prm echo "DONE" - - - diff --git a/model/tests/hd-us/est/run_est b/model/tests/hd-us/est/run_est index 00aded8..c61eeff 100755 --- a/model/tests/hd-us/est/run_est +++ b/model/tests/hd-us/est/run_est @@ -1,47 +1,55 @@ -#!/bin/csh -f +#!/bin/csh -ef + +if (! $?SHOC || "$SHOC" == "") then + set SHOC='../shoc' +endif + +if (! $?COMPAS || "$COMPAS" == "") then + set COMPAS='../compas' +endif + echo "Testing SHOC..." -rm est.nc -rm out1.nc +rm -f est.nc +rm -f out1.nc -../shoc -g est.prm est.nc +$SHOC -g est.prm est.nc -../shoc -p est.prm +$SHOC -p est.prm echo "DONE" echo "Testing COMPAS quad..." -rm est_quad.nc -rm out1_quad.nc +rm -f est_quad.nc +rm -f out1_quad.nc +rm -f s_est_quad.nc -../compas -g est_quad.prm est_quad.nc +$COMPAS -g est_quad.prm est_quad.nc -../compas -p est_quad.prm +$COMPAS -p est_quad.prm echo "DONE" echo "Testing COMPAS quad 5 window..." -rm out1_quad5w.nc +rm -f out1_quad5w.nc -../compas -p est_quad5w.prm +$COMPAS -p est_quad5w.prm echo "DONE" echo "Testing COMPAS hex..." -rm est_hex.nc -rm out1_hex.nc +rm -f est_hex.nc +rm -f out1_hex.nc -../compas -g est_hex.prm est_hex.nc +$COMPAS -g est_hex.prm est_hex.nc -../compas -p est_hex.prm +$COMPAS -p est_hex.prm echo "DONE" echo "Testing COMPAS hex 5 window..." -rm out1_hex5w.nc +rm -f out1_hex5w.nc -../compas -p est_hex5w.prm +$COMPAS -p est_hex5w.prm echo "DONE" - - diff --git a/model/tests/hd-us/test2/closed/run_closed b/model/tests/hd-us/test2/closed/run_closed index 96a47e5..f29b010 100755 --- a/model/tests/hd-us/test2/closed/run_closed +++ b/model/tests/hd-us/test2/closed/run_closed @@ -1,46 +1,55 @@ -#!/bin/csh -f +#!/bin/csh -ef + +if (! $?SHOC || "$SHOC" == "") then + set SHOC='../../shoc' +endif + +if (! $?COMPAS || "$COMPAS" == "") then + set COMPAS='../../compas' +endif echo "Testing SHOC..." -rm in1.nc -rm out1.nc +rm -f in1.nc +rm -f out1.nc -../../shoc -g test2.prm in1.nc +$SHOC -g test2.prm in1.nc -../../shoc -p test2.prm +$SHOC -p test2.prm echo "DONE" echo "Testing COMPAS quad..." -rm in1_quad.nc -rm s_in1_quad.nc -rm out1_quad.nc +rm -f in1_quad.nc +rm -f s_in1_quad.nc +rm -f out1_quad.nc -../../compas -g test2_quad.prm in1_quad.nc +$COMPAS -g test2_quad.prm in1_quad.nc -../../compas -p test2_quad.prm +$COMPAS -p test2_quad.prm echo "DONE" echo "Testing COMPAS quad 2 window..." -rm out1_quad2w.nc -rm win2.nc +rm -f out1_quad2w.nc +rm -f win2.nc -../../compas -p test2_quad2w.prm +$COMPAS -p test2_quad2w.prm echo "DONE" echo "Testing COMPAS hex..." -rm in1_hex.nc -rm out1_hex.nc +rm -f in1_hex.nc +rm -f out1_hex.nc -../../compas -g test2_hex.prm in1_hex.nc +$COMPAS -g test2_hex.prm in1_hex.nc -../../compas -p test2_hex.prm +$COMPAS -p test2_hex.prm echo "DONE" echo "Testing COMPAS hex 2 window..." -rm out1_hex2w.nc +rm -f out1_hex2w.nc -../../compas -p test2_hex2w.prm +$COMPAS -p test2_hex2w.prm +echo "DONE" diff --git a/model/tests/hd-us/test2/open/run_open b/model/tests/hd-us/test2/open/run_open index ae7847b..52086a9 100755 --- a/model/tests/hd-us/test2/open/run_open +++ b/model/tests/hd-us/test2/open/run_open @@ -1,41 +1,47 @@ -#!/bin/csh -f +#!/bin/csh -ef + +if (! $?SHOC || "$SHOC" == "") then + set SHOC='../shoc' +endif + +if (! $?COMPAS || "$COMPAS" == "") then + set COMPAS='../compas' +endif echo "Testing SHOC..." -rm in1.nc -rm out1.nc +rm -f in1.nc +rm -f out1.nc -../../shoc -g test2.prm in1.nc +$SHOC -g test2.prm in1.nc -../../shoc -p test2.prm +$SHOC -p test2.prm echo "DONE" echo "Testing COMPAS quad..." -rm in1_quad.nc -rm s_in1_quad.nc -rm out1_quad.nc +rm -f in1_quad.nc +rm -f s_in1_quad.nc +rm -f out1_quad.nc -../../compas -g test2_quad.prm in1_quad.nc +$COMPAS -g test2_quad.prm in1_quad.nc -../../compas -p test2_quad.prm +$COMPAS -p test2_quad.prm echo "DONE" echo "Testing COMPAS quad 2 window..." -rm out1_quad2w.nc +rm -f out1_quad2w.nc -../../compas -p test2_quad2w.prm +$COMPAS -p test2_quad2w.prm echo "DONE" echo "Testing COMPAS hex..." -rm in1_hex.nc -rm out1_hex.nc +rm -f in1_hex.nc +rm -f out1_hex.nc -../../compas -g test2_hex.prm in1_hex.nc +$COMPAS -g test2_hex.prm in1_hex.nc -../../compas -p test2_hex.prm +$COMPAS -p test2_hex.prm echo "DONE" - - diff --git a/model/tests/hd/.gitignore b/model/tests/hd/.gitignore new file mode 100644 index 0000000..d9494a2 --- /dev/null +++ b/model/tests/hd/.gitignore @@ -0,0 +1,5 @@ + +flushing.ts +test7*_sed.prm +totals*.ts +zoom.points diff --git a/model/tests/hd/test1/run_test1 b/model/tests/hd/test1/run_test1 index fedc91d..b653450 100755 --- a/model/tests/hd/test1/run_test1 +++ b/model/tests/hd/test1/run_test1 @@ -1,7 +1,9 @@ #!/bin/csh -ef -# Set relative path to shoc executable -set SHOC='../../../hd/shoc' +if (! $?SHOC || "$SHOC" == "") then + # Set relative path to shoc executable + set SHOC='../../../hd/shoc' +endif echo "Testing 'z' model..." rm -f in1.nc || true diff --git a/model/tests/hd/test2/run_test2 b/model/tests/hd/test2/run_test2 index d03f54b..0f7ed33 100755 --- a/model/tests/hd/test2/run_test2 +++ b/model/tests/hd/test2/run_test2 @@ -1,7 +1,9 @@ #!/bin/csh -ef -# Set relative path to shoc executable -set SHOC='../../../hd/shoc' +if (! $?SHOC || "$SHOC" == "") then + # Set relative path to shoc executable + set SHOC='../../../hd/shoc' +endif echo "Testing 'z' model..." rm -f in2.nc || true diff --git a/model/tests/hd/test3/run_test3 b/model/tests/hd/test3/run_test3 index 9b6ce43..b8ca014 100755 --- a/model/tests/hd/test3/run_test3 +++ b/model/tests/hd/test3/run_test3 @@ -1,7 +1,9 @@ #!/bin/csh -ef -# Set relative path to shoc executable -set SHOC='../../../hd/shoc' +if (! $?SHOC || "$SHOC" == "") then + # Set relative path to shoc executable + set SHOC='../../../hd/shoc' +endif echo "Testing 'z' model..." rm -f in3.nc || true diff --git a/model/tests/hd/test4/run_test4 b/model/tests/hd/test4/run_test4 index 377c3ec..7a369ea 100755 --- a/model/tests/hd/test4/run_test4 +++ b/model/tests/hd/test4/run_test4 @@ -1,7 +1,9 @@ #!/bin/csh -ef -# Set relative path to shoc executable -set SHOC='../../../hd/shoc' +if (! $?SHOC || "$SHOC" == "") then + # Set relative path to shoc executable + set SHOC='../../../hd/shoc' +endif echo "Testing 'z' model..." rm -f in4.nc || true diff --git a/model/tests/hd/test5/run_test5 b/model/tests/hd/test5/run_test5 index 0be889c..e8bb243 100755 --- a/model/tests/hd/test5/run_test5 +++ b/model/tests/hd/test5/run_test5 @@ -1,7 +1,9 @@ #!/bin/csh -ef -# Set relative path to shoc executable -set SHOC='../../../hd/shoc' +if (! $?SHOC || "$SHOC" == "") then + # Set relative path to shoc executable + set SHOC='../../../hd/shoc' +endif echo "Testing 'z' model..." rm -f in5.nc || true diff --git a/model/tests/hd/test6/run_test6 b/model/tests/hd/test6/run_test6 index bff17c0..7dbe63c 100755 --- a/model/tests/hd/test6/run_test6 +++ b/model/tests/hd/test6/run_test6 @@ -1,7 +1,9 @@ #!/bin/csh -ef -# Set relative path to shoc executable -set SHOC='../../../hd/shoc' +if (! $?SHOC || "$SHOC" == "") then + # Set relative path to shoc executable + set SHOC='../../../hd/shoc' +endif echo "Testing 'z' model..." rm -f in6.nc || true diff --git a/model/tests/hd/test7/run_test7 b/model/tests/hd/test7/run_test7 index c1ab1ac..6099b77 100755 --- a/model/tests/hd/test7/run_test7 +++ b/model/tests/hd/test7/run_test7 @@ -1,7 +1,9 @@ #!/bin/csh -ef -# Set relative path to shoc executable -set SHOC='../../../hd/shoc' +if (! $?SHOC || "$SHOC" == "") then + # Set relative path to shoc executable + set SHOC='../../../hd/shoc' +endif echo "Testing 'z' model..." rm -f in7.nc || true diff --git a/model/tests/hd/test7/test7_sed.prm b/model/tests/hd/test7/test7_sed.prm index 97e0974..4c19750 100644 --- a/model/tests/hd/test7/test7_sed.prm +++ b/model/tests/hd/test7/test7_sed.prm @@ -1,16 +1,16 @@ -# Test 7 of model shoc: 50 by 27 by 24 closed basin with sloping -# bottom (southern hemisphere) is forced with wind stress in the +# Test 7 of model shoc: 50 by 27 by 24 closed basin with sloping +# bottom (southern hemisphere) is forced with wind stress in the # e1 ditrection having positive curl. Anti-cyclonic circulation # is set up due to topographically induced conservation of potential # vorticity, where the centre of the gyre biased to the west. -# Conservation of potential vorticity theory (e.g. Herzfeld & Tomczak +# Conservation of potential vorticity theory (e.g. Herzfeld & Tomczak # (1999), Aust. J. Marine Freshw. Res., 50, 613 - 627.) predicts that : # A poitive gradient of f/H (f < 0) results in an eastward biased gyre. # A poitive gradient of f/H (f > 0) results in an westward biased gyre. # Constant depth (BATHYMAX = 50) results in a gyre with no bias. # A change in sign of the wind curl (WIND_SPEED_SCALE = -1.0) results # in a cyclonic gyre with no change to the bias. - + CODEHEADER SHOC default version : leapfrog PARAMETERHEADER Test 7 - closed basin with +ve wind curl DESCRIPTION SHOC test 7 @@ -47,7 +47,7 @@ RAMPSTART 0 days RAMPEND 1 days MERGE_THIN YES HMIN 0.1400 -SLIP 1.0 +SLIP 1.0 SIGMA NO COMPATIBLE V4201 @@ -97,50 +97,50 @@ ALERT NONE MOM_TEND YES CALC_FLUXES NONE FLUSHING_TR NO -STERIC_HEIGHT 0.00 +STERIC_HEIGHT 0.00 TOTALS YES Sand Silt Fine tss # Grid GRIDTYPE GEOGRAPHIC_RECTANGULAR NCE1 50 NCE2 27 -X00 0.00000 -Y00 0.00000 +X00 0.00000 +Y00 0.00000 DX 25000.000 DY 25000.000 -ROTATION 0.0 +ROTATION 0.0 # Vertical grid spacing LAYERFACES 24 --110.00 --105.00 --100.00 --95.00 --90.00 --85.00 --80.00 --75.00 --70.00 --65.00 --60.00 --55.00 --50.00 --45.00 --40.00 --35.00 --30.00 --25.00 --20.00 --15.00 --10.00 --5.00 --2.00 -0.00 +-110.00 +-105.00 +-100.00 +-95.00 +-90.00 +-85.00 +-80.00 +-75.00 +-70.00 +-65.00 +-60.00 +-55.00 +-50.00 +-45.00 +-40.00 +-35.00 +-30.00 +-25.00 +-20.00 +-15.00 +-10.00 +-5.00 +-2.00 +0.00 # Bathymetry limits -BATHYMIN 50.0 -BATHYMAX 120.0 -ETAMAX 10.0 +BATHYMIN 50.0 +BATHYMAX 120.0 +ETAMAX 10.0 MIN_CELL_THICKNESS 25% # Tracers @@ -150,8 +150,8 @@ TRACER0.name salt TRACER0.long_name Salinity TRACER0.type WATER SEDIMENT TRACER0.units PSU -TRACER0.fill_value 35.0 -TRACER0.valid_range 0.0 40.0 +TRACER0.fill_value 35.0 +TRACER0.valid_range 0.0 40.0 TRACER0.advect 1 TRACER0.diffuse 1 TRACER0.diagn 0 @@ -161,8 +161,8 @@ TRACER1.name temp TRACER1.long_name Temperature TRACER1.type WATER SEDIMENT TRACER1.units degrees C -TRACER1.fill_value 20.0 -TRACER1.valid_range 0.0 40.0 +TRACER1.fill_value 20.0 +TRACER1.valid_range 0.0 40.0 TRACER1.advect 1 TRACER1.diffuse 1 TRACER1.diagn 0 @@ -277,7 +277,7 @@ TRACER5.cohesive 0 TRACER6.name depth_sed TRACER6.long_name depth_sed TRACER6.type BENTHIC -TRACER6.units +TRACER6.units TRACER6.fill_value_wc 0.0 TRACER6.fill_value_sed 0.0 TRACER6.valid_range_wc 0 10 @@ -302,7 +302,7 @@ TRACER6.cohesive 0 TRACER7.name ustrcw_skin TRACER7.long_name ustrcw_skin TRACER7.type BENTHIC -TRACER7.units +TRACER7.units TRACER7.fill_value_wc 0.0 TRACER7.fill_value_sed 0.0 TRACER7.valid_range_wc 0 30 @@ -327,11 +327,11 @@ TRACER7.cohesive 0 # Forcing WIND_TS wind_test7.nc WIND_INPUT_DT 10 days -WIND_SPEED_SCALE 1.0 -DRAG_LAW_V0 10.0 -DRAG_LAW_V1 26.0 -DRAG_LAW_CD0 0.00114 -DRAG_LAW_CD1 0.00218 +WIND_SPEED_SCALE 1.0 +DRAG_LAW_V0 10.0 +DRAG_LAW_V1 26.0 +DRAG_LAW_CD0 0.00114 +DRAG_LAW_CD1 0.00218 # Time series TSPOINTS 1 @@ -385,7 +385,7 @@ CSS_ER 0.2 # FLOCCULATION # Modes: FLOC0, FLOC1 -# Default: FLOC0 - no flocculation +# Default: FLOC0 - no flocculation FLOC_MODE FLOC0 FLOC_PRM1 0.01 FLOC_PRM2 3 @@ -1800,5 +1800,5 @@ BATHY 1350 ID_CODE SHOC grid|G1.0|H1.0|S|B -U +�U |B0.00 diff --git a/model/tests/hd/test8/run_test8 b/model/tests/hd/test8/run_test8 index fd999be..e09177b 100755 --- a/model/tests/hd/test8/run_test8 +++ b/model/tests/hd/test8/run_test8 @@ -1,7 +1,9 @@ #!/bin/csh -ef -# Set relative path to shoc executable -set SHOC='../../../hd/shoc' +if (! $?SHOC || "$SHOC" == "") then + # Set relative path to shoc executable + set SHOC='../../../hd/shoc' +endif echo "Testing 'z' model..." rm -f in8.nc || true diff --git a/model/tests/run-tests.sh b/model/tests/run-tests.sh new file mode 100755 index 0000000..675e944 --- /dev/null +++ b/model/tests/run-tests.sh @@ -0,0 +1,103 @@ +#!/bin/bash +# +# Runs the EMS test suite(s) +# + +# Don't exit for errors: we will handle (and count) those. +set +e + +# Send all output to a logfile as well as stdout / stderr +EMS_TEST_LOG="${EMS_TEST_LOG:-ems_test.log}" +if [ -f "${EMS_TEST_LOG}" ]; then + truncate -s 0 "${EMS_TEST_LOG}" +fi +exec > >(tee -a "${EMS_TEST_LOG}") +exec 2> >(tee -a "${EMS_TEST_LOG}" >&2) + +# Dump some useful information about the test environment +# (note: some of these vars are set by the base image) +echo "Testing EMS at $(date --rfc-3339=seconds)" +echo +echo "SHOC = '${SHOC}' => '$(which shoc)'" +echo "COMPAS = '${COMPAS}' => '$(which compas)'" +echo +echo "CURL_VERSION = '${CURL_VERSION:-}', curl binary = '$(which curl)' => $(curl --version | head -n 1)" +echo "DAP_VERSION = '${DAP_VERSION:-}', getdap4 binary = '$(which getdap4)' => $(getdap4 -V 2>&1)" +echo "GDAL_VERSION = '${GDAL_VERSION:-}', gdalinfo binary = '$(which gdalinfo)', => $(gdalinfo --version 2>&1)" +echo "HDF5_VERSION = '${HDF5_VERSION:-}', h5dump binary = '$(which h5dump)' => $(h5dump --version)" +echo "NETCDF_VERSION = '${NETCDF_VERSION:-}', ncdump binary = '$(which ncdump)' => $(ncdump 2>&1 | tail -n 1)" +echo "NCO_VERSION = '${NCO_VERSION:-}', ncks binary = '$(which ncks)' => $(ncks --version 2>&1 | xargs)" +echo "PROJ_VERSION = '${PROJ_VERSION:-}', proj binary = '$(which proj)' => $(proj 2>&1 | head -n 1)" +echo + +# Initialise vars to hold test result statistics +FAIL_LIST="" +FAIL_COUNT=0 +SUCCESS_LIST="" +SUCCESS_COUNT=0 +TEST_COUNT=0 + +# Parse the include and exclude variables used to select target tests +EMS_TEST_INCLUDE="${EMS_TEST_INCLUDE:-${EMS_BASE}/model/tests}" +echo "EMS_TEST_INCLUDE = '${EMS_TEST_INCLUDE}'" + +EMS_TEST_EXCLUDE="${EMS_TEST_EXCLUDE:-} ${EMS_BASE}/model/tests/run-tests.sh '${EMS_BASE}/model/tests/hd/run_tests'" +if [ ! -f "${COMPAS}" ]; then + # Valid scenario: skip the COMPAS tests + EMS_TEST_EXCLUDE="${EMS_TEST_EXCLUDE} '${EMS_BASE}/model/tests/hd-us/*'" +else + EMS_TEST_EXCLUDE="${EMS_TEST_EXCLUDE} '${EMS_BASE}/model/tests/hd-us/run_tests'" +fi +echo "EMS_TEST_EXCLUDE = '${EMS_TEST_EXCLUDE}'" + + +for ti in $EMS_TEST_INCLUDE; do + FIND_CMD="find ${ti} -type f \( -regex '^.*/run_test[0-9]*$' -o -name 'run_all.sh' -o -regex '^.*/run_[^\.]*$' \) ! -iname '.*'" + for te in $EMS_TEST_EXCLUDE; do + FIND_CMD="${FIND_CMD} ! -path ${te}" + done + echo "FIND_CMD = '${FIND_CMD}'" + TEST_FILES=$(eval "${FIND_CMD}") + if [ -z "${TEST_FILES}" ]; then + echo "There are no test files to run below include path '${ti}'" + else + echo "Test files to run below include path '${ti}':" + echo "${TEST_FILES}" + for tf in $TEST_FILES; do + chmod 0755 "${tf}" + cd $(dirname "${tf}") + echo + echo "#-----------------------------------------------------" + echo "# Running test file '${tf}'" + echo "# CWD = '$(pwd)'" + echo "#-----------------------------------------------------" + ${tf} + TEST_RESULT=$? + echo "#......................................................" + if [ $TEST_RESULT -eq 0 ]; then + echo "exitcode: ${TEST_RESULT} => Test SUCCEEDED" + SUCCESS_LIST="${SUCCESS_LIST} ${tf}" + SUCCESS_COUNT=$((SUCCESS_COUNT+1)) + else + echo "exitcode: ${TEST_RESULT} => Test FAILED" + FAIL_LIST="${FAIL_LIST} ${tf}" + FAIL_COUNT=$((FAIL_COUNT+1)) + fi + TEST_COUNT=$((TEST_COUNT+1)) + done + fi +done + +echo +echo "#-----------------------------------------------------" +echo +echo "${SUCCESS_COUNT} of ${TEST_COUNT} tests passed:" +echo "${SUCCESS_LIST}" | tr ' ' '\n' +echo +echo "${FAIL_COUNT} of ${TEST_COUNT} tests failed:" +echo "${FAIL_LIST}" | tr ' ' '\n' +if [ $TEST_COUNT -eq 0 ]; then + exit -1 +else + exit $FAIL_COUNT +fi diff --git a/model/tests/sediments/.gitignore b/model/tests/sediments/.gitignore new file mode 100644 index 0000000..785f762 --- /dev/null +++ b/model/tests/sediments/.gitignore @@ -0,0 +1,4 @@ +test_trans*.nc +sed_mass*.txt +sedlog.txt +trans.mnc diff --git a/model/tests/sediments/test1/inputs/test_d.tran b/model/tests/sediments/test1/inputs/test_d.tran index f678fdb..4c1e8e5 100644 --- a/model/tests/sediments/test1/inputs/test_d.tran +++ b/model/tests/sediments/test1/inputs/test_d.tran @@ -313,3 +313,5 @@ TS0.reference msl # Open boundaries NBOUNDARIES 0 + +ID_CODE SHOC grid|G1.0|H|S|B diff --git a/model/tests/sediments/test1/run.sh b/model/tests/sediments/test1/run.sh index 2f80ad6..80f38f6 100755 --- a/model/tests/sediments/test1/run.sh +++ b/model/tests/sediments/test1/run.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e if [ $# == 0 ] then @@ -24,26 +24,29 @@ else echo "run './run.sh' for info" fi +SHOC="${SHOC:-./shoc}" +mkdir -p outputs tran_outputs + if [ $# == 1 ] then echo "Cleaning up" - rm outputs/* - rm tran_outputs/* - rm inputs/in_test.nc - rm inputs/test_trans_1990-01.nc - rm diag.txt runlog mass.txt sedlog.txt setup.txt trans.mnc sed_mass_*.txt + rm -f outputs/* + rm -f tran_outputs/* + rm -f inputs/in_test.nc + rm -f inputs/test_trans_1990-01.nc + rm -f diag.txt runlog mass.txt sedlog.txt setup.txt trans.mnc sed_mass_*.txt echo "Running $1: hd first and then sediment transport" - ./shoc -g inputs/test.prm inputs/in_test.nc - ./shoc -p inputs/test.prm - ./shoc -t inputs/$1.tran + $SHOC -g inputs/test.prm inputs/in_test.nc + $SHOC -p inputs/test.prm + $SHOC -t inputs/$1.tran fi if [ $# == 2 ] then echo "Running $1: only sediment transport" - rm tran_outputs/* - rm mass.txt sedlog.txt sed_mass_*.txt - ./shoc -t inputs/$1.tran + rm -f tran_outputs/* + rm -f mass.txt sedlog.txt sed_mass_*.txt + $SHOC -t inputs/$1.tran fi # post-processing @@ -51,4 +54,3 @@ cat ./vars sed_mass_end.txt > mass.txt rm sed_mass_*.txt #python plot.py echo "Done" - diff --git a/model/tests/sediments/test1/run_all.sh b/model/tests/sediments/test1/run_all.sh index 8c09273..2695749 100755 --- a/model/tests/sediments/test1/run_all.sh +++ b/model/tests/sediments/test1/run_all.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e if [ $# == 1 ] then @@ -14,31 +14,34 @@ else echo "" fi +SHOC="${SHOC:-./shoc}" +mkdir -p outputs tran_outputs + echo "Cleaning up" -rm outputs/* -rm tran_outputs/* -rm inputs/in_test.nc -rm inputs/test_trans_1990-01.nc -rm diag.txt runlog mass.txt sedlog.txt setup.txt trans.mnc sed_mass_*.txt +rm -f outputs/* +rm -f tran_outputs/* +rm -f inputs/in_test.nc +rm -f inputs/test_trans_1990-01.nc +rm -f diag.txt runlog mass.txt sedlog.txt setup.txt trans.mnc sed_mass_*.txt echo "" echo "Running hd" -./shoc -g inputs/test.prm inputs/in_test.nc -./shoc -p inputs/test.prm +$SHOC -g inputs/test.prm inputs/in_test.nc +$SHOC -p inputs/test.prm echo "OK: HD forcing files complete" echo "" echo "Running Diffusion test" -./shoc -t inputs/test_d.tran +$SHOC -t inputs/test_d.tran awk 'BEGIN{a=0;} {if ($NR eq 3) a=$4;} END{if((a-$4)<0.1) \ print("OK: mass conservation of dissolved tracer"); \ else print("ERROR: mass conservation of dissolved tracer");}' sed_mass_end.txt echo "" echo "Running Resuspension test" -rm tran_outputs/* -rm sedlog.txt sed_mass_*.txt -./shoc -t inputs/test_r.tran +rm -f tran_outputs/* +rm -f sedlog.txt sed_mass_*.txt +$SHOC -t inputs/test_r.tran awk 'BEGIN{a=0;} {if ($NR eq 3) a=$5;} END{if((a-$5)<0.1) \ print("OK: mass conservation of gravel"); \ else print("ERROR: mass conservation of gravel");}' sed_mass_end.txt @@ -51,9 +54,9 @@ else print("ERROR: mass conservationof mud");}' sed_mass_end.txt echo "" echo "Running Compaction test" -rm tran_outputs/* -rm sedlog.txt sed_mass_*.txt -./shoc -t inputs/test_c.tran +rm -f tran_outputs/* +rm -f sedlog.txt sed_mass_*.txt +$SHOC -t inputs/test_c.tran awk 'BEGIN{a=0;} {if ($NR eq 3) a=$4;} END{if((a-$4)<0.1) \ print("OK: mass conservation of dissolved tracer"); \ else print("ERROR: mass conservation of dissolved tracer");}' sed_mass_end.txt @@ -63,18 +66,18 @@ else print("ERROR: mass conservation of mud");}' sed_mass_end.txt echo "" echo "Running Desorption of Pollutant test" -rm tran_outputs/* -rm sedlog.txt sed_mass_*.txt -./shoc -t inputs/test_p.tran +rm -f tran_outputs/* +rm -f sedlog.txt sed_mass_*.txt +$SHOC -t inputs/test_p.tran awk 'BEGIN{a=0;} {if ($NR eq 3) a=$4+$8;} END{if((a-$4-$8)<0.1) \ print("OK: mass conservation of pollutant"); \ else print("ERROR: mass conservation of pollutant");}' sed_mass_end.txt echo "" echo "Running Resuspension, Diffusion and Compaction together" -rm tran_outputs/* -rm sedlog.txt sed_mass_*.txt -./shoc -t inputs/test_rcd.tran +rm -f tran_outputs/* +rm -f sedlog.txt sed_mass_*.txt +$SHOC -t inputs/test_rcd.tran awk 'BEGIN{a=0;} {if ($NR eq 3) a=$4;} END{if((a-$4)<0.1) \ print("OK: mass conservation of dissolved tracer"); \ else print("ERROR: mass conservation of dissolved tracer");}' sed_mass_end.txt diff --git a/model/tests/sediments/test2/inputs/test_flat.tran b/model/tests/sediments/test2/inputs/test_flat.tran index b24c8cf..096f973 100644 --- a/model/tests/sediments/test2/inputs/test_flat.tran +++ b/model/tests/sediments/test2/inputs/test_flat.tran @@ -311,3 +311,6 @@ TS0.reference msl # Open boundaries NBOUNDARIES 0 + +ID_CODE SHOC grid|G1.0|H|S|B + diff --git a/model/tests/sediments/test2/run.sh b/model/tests/sediments/test2/run.sh index 1ddbafd..44234bc 100755 --- a/model/tests/sediments/test2/run.sh +++ b/model/tests/sediments/test2/run.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e if [ $# == 0 ] then @@ -16,26 +16,29 @@ else echo "run './run.sh' for info" fi +SHOC="${SHOC:-./shoc}" +mkdir -p outputs tran_outputs + if [ $# == 1 ] then echo "Cleaning up" - rm outputs/* - rm tran_outputs/* - rm inputs/in_test.nc - rm inputs/test_trans_1990-01.nc - rm diag.txt runlog mass.txt sedlog.txt setup.txt trans.mnc sed_mass_*.txt + rm -f outputs/* + rm -f tran_outputs/* + rm -f inputs/in_test.nc + rm -f inputs/test_trans_1990-01.nc + rm -f diag.txt runlog mass.txt sedlog.txt setup.txt trans.mnc sed_mass_*.txt echo "Running $1: hd first and then sediment transport" - ./shoc -g inputs/test.prm inputs/in_test.nc - ./shoc -p inputs/test.prm - ./shoc -t inputs/$1.tran + $SHOC -g inputs/test.prm inputs/in_test.nc + $SHOC -p inputs/test.prm + $SHOC -t inputs/$1.tran fi if [ $# == 2 ] then echo "Running $1: only sediment transport" - rm tran_outputs/* - rm mass.txt sedlog.txt sed_mass_*.txt - ./shoc -t inputs/$1.tran + rm -f tran_outputs/* + rm -f mass.txt sedlog.txt sed_mass_*.txt + $SHOC -t inputs/$1.tran fi # post-processing @@ -52,6 +55,5 @@ awk 'BEGIN{a=0;} {if ($NR eq 3) a=$7;} END{if((a-$7)<0.1) \ print("OK: mass conservation of mud"); \ else print("ERROR: mass conservation of mud");}' sed_mass_end.txt -rm sed_mass_*.txt +rm -f sed_mass_*.txt echo "Done" - diff --git a/model/tests/sediments/test2/run_all.sh b/model/tests/sediments/test2/run_all.sh index be26607..d662ca3 100755 --- a/model/tests/sediments/test2/run_all.sh +++ b/model/tests/sediments/test2/run_all.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e if [ $# == 1 ] then @@ -14,23 +14,26 @@ else echo "" fi +SHOC="${SHOC:-./shoc}" +mkdir -p outputs tran_outputs + echo "Cleaning up" -rm outputs/* -rm tran_outputs/* -rm inputs/in_test.nc -rm inputs/test_trans_1990-01.nc -rm diag.txt runlog mass.txt sedlog.txt setup.txt trans.mnc sed_mass_*.txt +rm -f outputs/* +rm -f tran_outputs/* +rm -f inputs/in_test.nc +rm -f inputs/test_trans_1990-01.nc +rm -f diag.txt runlog mass.txt sedlog.txt setup.txt trans.mnc sed_mass_*.txt echo "" echo "Simulating hd in a wind driven, closed basin" -./shoc -g inputs/test.prm inputs/in_test.nc -./shoc -p inputs/test.prm +$SHOC -g inputs/test.prm inputs/in_test.nc +$SHOC -p inputs/test.prm echo "OK: HD forcing files complete" echo "" echo "Simulating transport of particulate and dissolver tracers" -./shoc -t inputs/test_flat.tran +$SHOC -t inputs/test_flat.tran awk 'BEGIN{a=0;} {if ($NR eq 3) a=$4;} END{if((a-$4)<0.1) \ print("OK: mass conservation of dissolved tracer"); \ else print("ERROR: mass conservation of dissolved tracer");}' sed_mass_end.txt @@ -45,5 +48,5 @@ print("OK: mass conservation of mud"); \ else print("ERROR: mass conservation of mud");}' sed_mass_end.txt echo "" -rm sed_mass_*.txt +rm -f sed_mass_*.txt echo "3D TEST COMPLETE" diff --git a/model/tests/sediments/test3/inputs/test_advanced.tran b/model/tests/sediments/test3/inputs/test_advanced.tran index 1402ede..27cf50c 100644 --- a/model/tests/sediments/test3/inputs/test_advanced.tran +++ b/model/tests/sediments/test3/inputs/test_advanced.tran @@ -456,3 +456,5 @@ BOUNDARY1.POINTS 3 1 13 1 14 + +ID_CODE SHOC grid|G1.0|H|S|B diff --git a/model/tests/sediments/test3/inputs/test_basic.tran b/model/tests/sediments/test3/inputs/test_basic.tran index ba1f986..91267c0 100644 --- a/model/tests/sediments/test3/inputs/test_basic.tran +++ b/model/tests/sediments/test3/inputs/test_basic.tran @@ -407,3 +407,5 @@ BOUNDARY1.POINTS 3 1 13 1 14 + +ID_CODE SHOC grid|G1.0|H|S|B diff --git a/model/tests/sediments/test3/run.sh b/model/tests/sediments/test3/run.sh index 3976cd0..6c824ab 100755 --- a/model/tests/sediments/test3/run.sh +++ b/model/tests/sediments/test3/run.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e if [ $# == 0 ] then @@ -22,27 +22,29 @@ else echo "run './run.sh' for info" fi +SHOC="${SHOC:-./shoc}" +mkdir -p outputs tran_outputs + if [ $# == 1 ] then echo "Cleaning up" - rm outputs/* - rm tran_outputs/* - rm inputs/in_test.nc - rm inputs/test_trans_1990-01.nc - rm diag.txt runlog sedlog.txt setup.txt trans.mnc + rm -f outputs/* + rm -f tran_outputs/* + rm -f inputs/in_test.nc + rm -f inputs/test_trans_1990-01.nc + rm -f diag.txt runlog sedlog.txt setup.txt trans.mnc echo "Running $1: hd first and then sediment transport" - ./shoc -g inputs/test.prm inputs/in_test.nc - ./shoc -p inputs/test.prm - ./shoc -t inputs/$1.tran + $SHOC -g inputs/test.prm inputs/in_test.nc + $SHOC -p inputs/test.prm + $SHOC -t inputs/$1.tran fi if [ $# == 2 ] then echo "Running $1: only sediment transport" - rm tran_outputs/* - rm sedlog.txt - ./shoc -t inputs/$1.tran + rm -f tran_outputs/* + rm -f sedlog.txt + $SHOC -t inputs/$1.tran fi echo "Done" - diff --git a/model/tests/sediments/test3/run_all.sh b/model/tests/sediments/test3/run_all.sh new file mode 100755 index 0000000..1a5c03e --- /dev/null +++ b/model/tests/sediments/test3/run_all.sh @@ -0,0 +1,8 @@ +#!/bin/bash -e + +THIS_SCRIPT="${BASH_SOURCE[0]}" +THIS_DIR=$( cd "$(dirname "${THIS_SCRIPT}")" && pwd) + +"${THIS_DIR}/run.sh" "test_basic" + +"${THIS_DIR}/run.sh" "test_advanced" "sedi" diff --git a/model/tests/sediments/test4/inputs/test.prm b/model/tests/sediments/test4/inputs/test.prm index 6acd496..dabb163 100644 --- a/model/tests/sediments/test4/inputs/test.prm +++ b/model/tests/sediments/test4/inputs/test.prm @@ -499,3 +499,5 @@ BATHY 100 10.000 + +ID_CODE SHOC grid|G1.0|H1.0|S|B diff --git a/model/tests/sediments/test4/run_all.sh b/model/tests/sediments/test4/run_all.sh index 4afd2a0..ac27756 100755 --- a/model/tests/sediments/test4/run_all.sh +++ b/model/tests/sediments/test4/run_all.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e if [ $# == 1 ] then @@ -13,16 +13,19 @@ then else echo "" fi + +SHOC="${SHOC:-./shoc}" +mkdir -p outputs echo "Cleaning up" -rm outputs/* -rm inputs/in_test.nc -rm diag.txt runlog sedlog.txt setup.txt sed_mass_*.txt +rm -f outputs/* +rm -f inputs/in_test.nc +rm -f diag.txt runlog sedlog.txt setup.txt sed_mass_*.txt echo "" echo "Simulating coupled hd and sediment transport in a wind driven, closed basin" -./shoc -g inputs/test.prm inputs/in_test.nc -./shoc -p inputs/test.prm +$SHOC -g inputs/test.prm inputs/in_test.nc +$SHOC -p inputs/test.prm echo "OK: Run complete" echo "" @@ -40,5 +43,5 @@ print("OK: mass conservation of mud"); \ else print("ERROR: mass conservation of mud");}' sed_mass_end.txt echo "" -rm sed_mass_*.txt +rm -f sed_mass_*.txt echo "3D TEST COMPLETE" diff --git a/model/tests/tracerstats/basic/run_test b/model/tests/tracerstats/basic/run_test index 53d06e5..d04bdac 100755 --- a/model/tests/tracerstats/basic/run_test +++ b/model/tests/tracerstats/basic/run_test @@ -1,23 +1,25 @@ -#!/bin/csh -f +#!/bin/csh -ef # Script to run test +if (! $?SHOC || "$SHOC" == "") then + set SHOC='../../../hd/shoc' +endif + # check shoc -if (! -e ../../../hd/shoc) then +if (! -e $SHOC) then echo "cannot find the shoc executable, please build and try again" exit(0) endif -# check output dir -if (! -d out) then - mkdir out -else - rm -r out/* -endif +# Ensure output dir is empty +set nonomatch +mkdir -p out +rm -rf out/* # Kick off model echo "Starting model ..." -../../../hd/shoc -p basic.prm +$SHOC -p basic.prm if ($status) then echo ".... uh oh!" @@ -26,4 +28,3 @@ else echo " " echo "Run out.m in Matlab to see results" endif -