@@ -15,44 +15,44 @@ while [ $# -ne 0 ]; do
15
15
case $1 in
16
16
-h) echo " $doc " >&2 && exit 0 ;;
17
17
-* ) raise " Unknown flag ${1} ." ;;
18
- * ) [ -z " $filename " ] && filename =" $1 " || files +=(" $1 " ) ;;
18
+ * ) [ -z " $output " ] && output =" $1 " || inputs +=(" $1 " ) ;;
19
19
esac
20
20
shift
21
21
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
24
24
25
25
# 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} ."
32
32
fi
33
- dimname=$iname
33
+ dimname=$idimname
34
34
done
35
35
36
36
# 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 \
38
38
&& unlimited=true || unlimited=false
39
39
40
- # Combine files in one of two ways
40
+ # Combine inputs in one of two ways
41
41
# Found out that mppnccombine is *slower* than ncrcat! So if possible, always
42
42
# use ncrcat and do not fix unlimited dimensions!
43
43
# ./mppncdivide -f -d=time test.nc; rm tmp.nc; time ${dir}/mppnccombine.x tmp.nc test.*.nc
44
44
# ./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
46
46
if $unlimited ; then
47
47
which ncrcat & > /dev/null \
48
48
|| 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 " \
50
50
|| raise " ncrcat failed."
51
51
# Combine with mppnccombine
52
52
else
53
53
[ -x ${dir} /mppnccombine.x ] \
54
54
|| 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 [@]} " \
56
56
|| raise " mppnccombine.x failed."
57
57
fi
58
58
exit 0
0 commit comments