4 |
# The file should be in one directory, where this script is run. |
# The file should be in one directory, where this script is run. |
5 |
# The resulting files will be in the same directory. |
# The resulting files will be in the same directory. |
6 |
|
|
7 |
|
DEBUG="-D 0" |
8 |
|
|
9 |
inone=$1 |
inone=$1 |
10 |
inone=${1:?"You must input an mnc filename to be xploded"} |
inone=${1:?"You must input an mnc filename to be xploded"} |
11 |
|
|
17 |
exit 1 |
exit 1 |
18 |
fi |
fi |
19 |
|
|
20 |
varls=$(ncdump -h $somefile | grep double | grep ,) |
# Finding all the multidimensional variables |
21 |
|
varls=$(ncdump -h $somefile | grep "double\|float" | grep , ) |
22 |
IFS=';' |
IFS=';' |
23 |
vars= |
vars= |
24 |
for somevar in ${varls} |
for somevar in ${varls} |
25 |
do |
do |
26 |
somevar1=${somevar%(*} |
somevar1=${somevar%(*} |
27 |
somevar1=${somevar1#*double } |
somevar1=${somevar1#*double } |
28 |
|
somevar1=${somevar1#*float } |
29 |
|
echo $somevar1 |
30 |
vars=${vars}$somevar1' ' |
vars=${vars}$somevar1' ' |
31 |
done |
done |
32 |
echo Variables to extract: $vars |
echo Variables to extract: $vars |
33 |
IFS=' ' |
IFS=' ' |
34 |
for somevar in $vars |
for somevar in $vars |
35 |
do |
do |
36 |
ncks -v $somevar $somefile $somevar.$somefile |
ncks $DEBUG -v $somevar $somefile $somevar.$somefile |
37 |
done |
done |
38 |
done |
done |