-
Notifications
You must be signed in to change notification settings - Fork 6
/
gem_nml_mkref
executable file
·63 lines (53 loc) · 1.53 KB
/
gem_nml_mkref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# @Object: Create a reference nml for gem
# @Author: S.Chamberland
# @Date: Feb 2016
DESC='Create a reference nml for gem'
eval $(rpy.cclargparse \
-D " " \
${0##*/} \
"${DESC}" \
"Example: ${0##*/} -v gem_settings.${gem_version}.ref" \
"positional" 'nargs=*' "gem_settings.${gem_version}.ref" "[FILENAME]" \
"-v,--verbose" 'action=count' '0' '[verbose mode]' \
++++ $*)
myverbose=''
[[ ${verbose} -gt 0 ]] && myverbose='-v' || true
myfile="${1:-gem_settings.${gem_version}.ref}"
if [[ x"${myfile}" == x"" ]] ; then
cat 1>&2 <<EOF
ERROR: Need to provide a destination filename
EOF
exit 1
fi
if [[ x"${ATM_MODEL_VERSION}" == x"" ]] ; then
cat 1>&2 <<EOF
ERROR: GEM environment not properly set, \${gem_version} not defined.
EOF
exit 1
fi
export gemdyn_version=${gemdyn_version:-${ATM_MODEL_VERSION}}
export rpnphy_version=${rpnphy_version:-${ATM_MODEL_VERSION}}
a=$(which gemdyn_nml_mkref)
b=$(which rpnphy_nml_mkref)
if [[ x"${a}" == x"" || x"${b}" == x"" ]] ; then
cat 1>&2 <<EOF
ERROR: GEM environment not properly set, cannot find all print nml progs
gemdyn_nml_mkref
rpnphy_nml_mkref
EOF
exit 1
fi
here=$(pwd)
localtmp=$(mktemp -d ${TMPDIR:-/tmp/${USER}}/XXXXXX)
mkdir -p ${localtmp}
cd ${localtmp}
${a} ${myverbose} filea || exit 1
${b} ${myverbose} fileb || exit 1
nmlfilename='gem_settings.nml.ref'
cat filea fileb > ${nmlfilename}
[[ x${myfile} == x${myfile#/} ]] && myfile=${here}/${myfile} || true
mv ${nmlfilename} ${myfile}
cd ${here}
rm -rf ${localtmp}
exit 0