Skip to content

Commit 279d2dc

Browse files
committed
Make nccombine variable names consistent w/ ncparallel
1 parent 0ebe953 commit 279d2dc

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

nccombine

+15-15
Original file line numberDiff line numberDiff line change
@@ -15,44 +15,44 @@ while [ $# -ne 0 ]; do
1515
case $1 in
1616
-h) echo "$doc" >&2 && exit 0 ;;
1717
-*) raise "Unknown flag ${1}." ;;
18-
*) [ -z "$filename" ] && filename="$1" || files+=("$1") ;;
18+
*) [ -z "$output" ] && output="$1" || inputs+=("$1") ;;
1919
esac
2020
shift
2121
done
22-
[ ${#files[@]} -eq 0 ] && raise "No input files found."
23-
[[ "$filename" =~ .nc$ ]] || raise "File $filename does not end in '.nc' extension." # output file
22+
[ ${#inputs[@]} -eq 0 ] && raise "No input inputs found."
23+
[[ "$output" =~ .nc$ ]] || raise "File $output does not end in '.nc' extension." # output file
2424

2525
# Get the concatenation dimension by inspecting attributes
26-
for file in "${files[@]}"; do
27-
iname=$(ncdump -h "${files[0]}" | grep domain_decomposition | cut -d: -f1 | xargs)
28-
if [ -z "$iname" ]; then
29-
raise "File $file does not have dimension with domain_decomposition attribute. Perhaps your script deleted it!"
30-
elif [ -n "$dimname" ] && [ "$dimname" != "$iname" ]; then
31-
raise "File $file has different domain_decomposition dimension, ${iname}, from dimension from previous file, ${dimname}."
26+
for input in "${inputs[@]}"; do
27+
idimname=$(ncdump -h "${inputs[0]}" | grep domain_decomposition | cut -d: -f1 | xargs)
28+
if [ -z "$idimname" ]; then
29+
raise "File $input does not have dimension with domain_decomposition attribute. Perhaps your script deleted it!"
30+
elif [ -n "$dimname" ] && [ "$dimname" != "$idimname" ]; then
31+
raise "File $input has different domain_decomposition dimension, ${idimname}, from dimension from previous file, ${dimname}."
3232
fi
33-
dimname=$iname
33+
dimname=$idimname
3434
done
3535

3636
# Test whether concatenation dimension is unlimited
37-
ncdump -h "${files[0]}" | grep 'UNLIMITED' | grep $dimname &>/dev/null \
37+
ncdump -h "${inputs[0]}" | grep 'UNLIMITED' | grep $dimname &>/dev/null \
3838
&& unlimited=true || unlimited=false
3939

40-
# Combine files in one of two ways
40+
# Combine inputs in one of two ways
4141
# Found out that mppnccombine is *slower* than ncrcat! So if possible, always
4242
# use ncrcat and do not fix unlimited dimensions!
4343
# ./mppncdivide -f -d=time test.nc; rm tmp.nc; time ${dir}/mppnccombine.x tmp.nc test.*.nc
4444
# ./mppncdivide -d=time test.nc; rm tmp.nc; time ncrcat -O test.*.nc tmp.nc
45-
rm "$filename" 2>/dev/null
45+
rm "$output" 2>/dev/null
4646
if $unlimited; then
4747
which ncrcat &>/dev/null \
4848
|| raise "ncrcat not found. Please install the NetCDF Operators (NCO) or use the '-f' flag."
49-
ncrcat -O -h "${files[@]}" "$filename" \
49+
ncrcat -O -h "${inputs[@]}" "$output" \
5050
|| raise "ncrcat failed."
5151
# Combine with mppnccombine
5252
else
5353
[ -x ${dir}/mppnccombine.x ] \
5454
|| raise "${dir}/mppnccombine.x executable not found. Please edit ${dir}/Makefile for your system, then generate mppnccombine.x by typing 'make' in the terminal."
55-
${dir}/mppnccombine.x "$filename" "${files[@]}" \
55+
${dir}/mppnccombine.x "$output" "${inputs[@]}" \
5656
|| raise "mppnccombine.x failed."
5757
fi
5858
exit 0

ncparallel

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ source $dir/header.sh
5050
while [ $# -ne 0 ]; do
5151
case "$1" in
5252
-h) echo "$doc" >&2 && exit 0 ;;
53-
-n=*) nsplit="${1#*=}" ;;
54-
-d=*) dimname="${1#*=}" ;;
55-
-p=*) pmax="${1#*=}" ;;
53+
-n=*) nsplit=${1#*=} ;;
54+
-d=*) dimname=${1#*=} ;;
55+
-p=*) pmax=${1#*=} ;;
5656
-f) fixrec=true ;;
5757
-k) keep=true ;;
5858
-r) reverse=true ;;

0 commit comments

Comments
 (0)