-
Notifications
You must be signed in to change notification settings - Fork 0
Description
@anton-seaice suggested we add module load nco in the ice concatenation script, but I wasn't keen on that, as module load can be problematic if there are clashing modules, and so can be unpredictable.
However, testing this script without a properly configured payu conda environment is fragile.
We can get the best of both worlds by checking if ncrcat is available, and if not then module load nco.
I have tested it and the following patch works if ncrcat is not available
@@ -1,4 +1,4 @@
-#!/usr/bin/bash
+#!/usr/bin/bash -i
# Copyright 2024 ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details.
# SPDX-License-Identifier: Apache-2.0
#
@@ -46,6 +46,11 @@ if [ -z $out_dir ]; then
out_dir=$(ls -drv archive/output*([0-9]) | head -1)/ice/OUTPUT
fi
+if ! command -v -- "ncrcat" > /dev/null 2>&1; then
+ echo "ncrcat not available, trying module load nco"
+ module load nco
+fi
+
for f in $out_dir/iceh.????-??-01.nc; do
#concat daily files for this month
echo doing ncrcat -O -L 5 -4 ${f/-01.nc/-??.nc} ${f/-01.nc/-daily.nc}
@@ -54,4 +59,4 @@ for f in $out_dir/iceh.????-??-01.nc; do
if [[ $? == 0 ]]; then
rm ${f/-01.nc/-??.nc} #delete individual dailys on success
fi
-done
\ No newline at end of file
+doneI am testing by adding this as a sync userscript:
userscripts:
sync: /g/data/vk83/apps/om2-scripts/concatenate_ice/concat_ice_daily.shNote that it was necessary to alter the shebang and make this an interactive shell in order to have the module shell function available. Another option is to load the function by sourcing the module bash initialisation, i.e. . $MODULESHOME/init/bash, as suggested here:
https://unix.stackexchange.com/a/194898
This works as a sync userscript.