forked from ESCOMP/CTSM
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTSMtools.sh
executable file
·117 lines (102 loc) · 3.23 KB
/
TSMtools.sh
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/sh
#
if [ $# -ne 3 ]; then
echo "TSMtools.sh: incorrect number of input arguments"
exit 1
fi
test_name=TSMtools.$1.$2.$3
if [ -z "$CLM_RERUN" ]; then
CLM_RERUN="no"
fi
if [ "$CLM_RERUN" != "yes" ] && [ -f ${CLM_TESTDIR}/${test_name}/TestStatus ]; then
if grep -c PASS ${CLM_TESTDIR}/${test_name}/TestStatus > /dev/null; then
echo "TSMtools.sh: smoke test has already passed; results are in "
echo " ${CLM_TESTDIR}/${test_name}"
exit 0
elif grep -c GEN ${CLM_TESTDIR}/${test_name}/TestStatus > /dev/null; then
echo "TSMtools.sh: test already generated"
else
read fail_msg < ${CLM_TESTDIR}/${test_name}/TestStatus
prev_jobid=${fail_msg#*job}
if [ $JOBID = $prev_jobid ]; then
echo "TSMtools.sh: smoke test has already failed for this job - will not reattempt; "
echo " results are in: ${CLM_TESTDIR}/${test_name}"
exit 2
else
echo "TSMtools.sh: this smoke test failed under job ${prev_jobid} - moving those results to "
echo " ${CLM_TESTDIR}/${test_name}_FAIL.job$prev_jobid and trying again"
cp -rp ${CLM_TESTDIR}/${test_name} ${CLM_TESTDIR}/${test_name}_FAIL.job$prev_jobid
fi
fi
fi
cfgdir=`ls -1d ${CLM_ROOT}/tools/$1`
rundir=${CLM_TESTDIR}/${test_name}
if [ -d ${rundir} ]; then
rm -r ${rundir}
fi
mkdir -p ${rundir}
if [ $? -ne 0 ]; then
echo "TSMtools.sh: error, unable to create work subdirectory"
exit 3
fi
cd ${rundir}
echo "Copy any text files over"
cp $cfgdir/*.txt $rundir
echo "TSMtools.sh: calling TCBtools.sh to prepare $1 executable"
${CLM_SCRIPTDIR}/TCBtools.sh $1 $2
rc=$?
if [ $rc -ne 0 ]; then
echo "TSMtools.sh: error from TCBtools.sh= $rc"
echo "FAIL.job${JOBID}" > TestStatus
exit 4
fi
echo "TSMtools.sh: running $1; output in ${rundir}/test.log"
if [ "$3" = "tools__o" ] || [ "$3" = "tools__do" ]; then
toolrun="env OMP_NUM_THREADS=${CLM_THREADS} ${CLM_TESTDIR}/TCBtools.$1.$2/$1"
else
toolrun="${CLM_TESTDIR}/TCBtools.$1.$2/$1"
fi
runfile="${cfgdir}/$1.$3"
if [ ! -f "${runfile}" ]; then
runfile="${CLM_SCRIPTDIR}/nl_files/$1.$3"
if [ ! -f "${runfile}" ]; then
echo "TSMtools.sh: error ${runfile} input run file not found"
echo "FAIL.job${JOBID}" > TestStatus
exit 5
fi
fi
echo "Run file type = ${3#*.}"
if [ ${3#*.} == "runoptions" ]; then
echo "$toolrun "`cat ${runfile}`
cp $cfgdir/*.nc .
if [ "$debug" != "YES" ] && [ "$compile_only" != "YES" ]; then
$toolrun `cat ${runfile}` >> test.log 2>&1
rc=$?
status="PASS"
else
echo "Successfully created file" > test.log
status="GEN"
rc=0
fi
else
echo "$toolrun < ${runfile}"
if [ "$debug" != "YES" ] && [ "$compile_only" != "YES" ]; then
$toolrun < ${runfile} >> test.log 2>&1
rc=$?
status="PASS"
else
echo "Successfully created file" > test.log
status="GEN"
rc=0
fi
fi
if [ $rc -eq 0 ] && grep -ci "Successfully created " test.log > /dev/null; then
echo "TSMtools.sh: smoke test passed"
echo "$status" > TestStatus
else
echo "TSMtools.sh: error running $1, error= $rc"
echo "TSMtools.sh: see ${CLM_TESTDIR}/${test_name}/test.log for details"
echo "FAIL.job${JOBID}" > TestStatus
exit 6
fi
exit 0