1 | #!/bin/bash |
---|
2 | # |
---|
3 | # Author: Patrick Brockmann |
---|
4 | # Contact: Patrick.Brockmann@cea.fr |
---|
5 | # History: |
---|
6 | # Modification: Nicolas-thierry.Martin@locean-ipsl.upmc.fr |
---|
7 | # |
---|
8 | |
---|
9 | |
---|
10 | # Set defaults |
---|
11 | #--------------------------------------------------- |
---|
12 | NEMO_TRUS=$( pwd $( dirname $0 ) ) |
---|
13 | SVN_OPT='status' |
---|
14 | DEBUG=0; PUBLISH=0; status='OK' |
---|
15 | |
---|
16 | # Get options for replacing some initials settings |
---|
17 | #--------------------------------------------------- |
---|
18 | while [ $# -ne 0 ]; do |
---|
19 | case $1 in |
---|
20 | -b|--branch ) NEMO_BRAN=$2 ; shift 2;; -d|--debug ) set -vx; DEBUG=1 ; shift ;; |
---|
21 | -e|--email ) MAIL=$2 ; shift 2;; -j|--job ) NPROC=$2 ; shift 2;; |
---|
22 | -h|--help ) cat trusting_help.txt; exit 1;; -m|--machine) CFG_ARCH=$2 ; shift 2;; |
---|
23 | -n|--newconf) TEST_CONF=$2 ; shift 2;; -r|--refconf) REFE_CONF=$2 ; shift 2;; |
---|
24 | -t|--time ) TIME_LIMI=$2 ; shift 2;; -p|--publish) PUBLISH=1 ; shift ;; |
---|
25 | -u|--user ) CFG_USER=$2 ; shift 2;; -v|--version) NEMO_VERS=$2 ; shift 2;; |
---|
26 | *) cat trusting_help.txt; exit 1;; |
---|
27 | esac |
---|
28 | done |
---|
29 | |
---|
30 | # Initialization (super-computer & user environment) |
---|
31 | #--------------------------------------------------- |
---|
32 | if [[ ! -z "${CFG_ARCH}" && ! -z "${CFG_USER}" ]]; then |
---|
33 | |
---|
34 | if [ ! $( find ${NEMO_TRUS}/cfg -name ${CFG_USER}.cfg ) ]; then |
---|
35 | echo 'No configuration file in '${NEMO_TRUS}'/cfg for '${CFG_USER}; exit 1 |
---|
36 | elif [ ! $( find ${NEMO_TRUS}/cfg -name ${CFG_ARCH}.cfg ) ]; then |
---|
37 | echo 'No configuration file in '${NEMO_TRUS}'/cfg for '${CFG_ARCH}; exit 1 |
---|
38 | else |
---|
39 | . ${NEMO_TRUS}/trusting.env |
---|
40 | fi |
---|
41 | |
---|
42 | else |
---|
43 | cat ${NEMO_TRUS}/trusting_help.txt; exit 1 |
---|
44 | fi |
---|
45 | |
---|
46 | . ./trusting_func.sh |
---|
47 | |
---|
48 | # |
---|
49 | #--------------------------------------------------- |
---|
50 | mkdir -p ${TEST_DIR} ${REFE_DIR} |
---|
51 | echo ${TEST_DIR} && cd ${TEST_DIR} |
---|
52 | datestr1=$( LC_ALL=C date -d"${DATE_STR}" +%Y-%m-%dT%H:%M ) |
---|
53 | printf "Date\n$datestr1\n" > mesg_01_date_${CFG_USER}_${CFG_ARCH}.txt |
---|
54 | # Only at end status will change to OK |
---|
55 | status='FAILED' |
---|
56 | |
---|
57 | # Check softwares versions (source arch environment) |
---|
58 | #--------------------------------------------------- |
---|
59 | pstep 'Get softwares release' |
---|
60 | . ${ARCH_ENV} > /dev/null |
---|
61 | get_soft_rel |
---|
62 | |
---|
63 | # SVN action on XIOS & NEMO essentials directories |
---|
64 | #--------------------------------------------------- |
---|
65 | pstep "Get NEMO SVN state with: ${SVN_OPT}" |
---|
66 | get_nemo_rev |
---|
67 | exit 0 |
---|
68 | # NEMO config compiled from scratch |
---|
69 | #--------------------------------------------------- |
---|
70 | pstep "Compiling ${CONF_REF} configuration" |
---|
71 | cd ${NEMO_CONF} |
---|
72 | #[ -d ${TEST_CONF} ] && ./makenemo -n ${TEST_CONF} clean |
---|
73 | ./makenemo -n ${TEST_CONF} -r ${REFE_CONF} -m $ARCH -j $NPROC >& /dev/null |
---|
74 | [ ! -e ${TEST_CONF}/BLD/bin/nemo.exe ] && get_out $step $status |
---|
75 | |
---|
76 | # Get namelists, xml & forced files for running |
---|
77 | #--------------------------------------------------- |
---|
78 | pstep 'Preparing job' |
---|
79 | find ${NEMO_CONF}/${TEST_CONF}/EXP00 -regex '.*\(cfg\|opa\|ref\|xml\)' -exec cp {} . \; |
---|
80 | |
---|
81 | if [ ! -z "${FORC_TAR}" ]; then |
---|
82 | cmd_iol="tar -tvf ${NEMO_FORC}/${FORC_TAR}"; cmd_iof="tar -vxf ${NEMO_FORC}/${FORC_TAR}" |
---|
83 | else |
---|
84 | cmd_iol="ls ${NEMO_FORC}/*" ; cmd_iof="\cp ${NEMO_FORC}/* ." |
---|
85 | fi |
---|
86 | |
---|
87 | ${cmd_iol} > inputs_list.txt && ${cmd_iof} > /dev/null |
---|
88 | [ $? -ne 0 ] && get_out $step $status |
---|
89 | [ $( find . -name '*.gz' -print -quit ) ] && gunzip *.gz |
---|
90 | |
---|
91 | # Check input files in all cases |
---|
92 | #--------------------------------------------------- |
---|
93 | pstep 'Test input files difference' |
---|
94 | diff_inputs |
---|
95 | |
---|
96 | # Job submission & computing |
---|
97 | #--------------------------------------------------- |
---|
98 | pstep 'Running' |
---|
99 | job_num=$( ${JOB_SUBM} | awk '{print $NF}' ) |
---|
100 | [ $? -ne 0 ] && get_out $step $status |
---|
101 | |
---|
102 | time_elapsed=0; time_increment=30 |
---|
103 | sleep ${time_increment} |
---|
104 | while [[ $( ${JOB_LIST} | grep ${job_num} ) && ${time_elapsed} -lt ${TIME_LIMI} ]]; do |
---|
105 | printf "\n####################################################" >> computation.log |
---|
106 | ${JOB_VIEW} ${job_num} >> computation.log |
---|
107 | sleep ${time_increment} |
---|
108 | let time_elapsed+=${time_increment} |
---|
109 | done |
---|
110 | sleep ${time_increment} |
---|
111 | |
---|
112 | # Eventual crash during computing |
---|
113 | #--------------------------------------------------- |
---|
114 | pstep 'Test if ASCII output files exist' |
---|
115 | if [[ ! -f ocean.output || $( grep 'E R R O R' ocean.output ) ]]; then |
---|
116 | ${JOB_DELE} ${job_num} &> /dev/null |
---|
117 | [ ! -f ocean.output ] && step='nemo.exe crashed at initialization' |
---|
118 | [ $( grep 'E R R O R' ocean.output ) ] && step='nemo.exe crashed' |
---|
119 | comments('E R R O R') |
---|
120 | ${JOB_DELE} ${job_num} >/dev/null 2>&1 |
---|
121 | status='FAILED' |
---|
122 | get_out $step $status |
---|
123 | else |
---|
124 | status='OK' |
---|
125 | |
---|
126 | # Inspect output text files |
---|
127 | #--------------------------------------------------- |
---|
128 | pstep 'Test ASCII output files diff' |
---|
129 | for file in ocean.output solver.stat tracer.stat; do |
---|
130 | diff $file ${REFE_DIR}/$file |
---|
131 | [ $? -ne 0 ] && status='FAILED' |
---|
132 | done |
---|
133 | |
---|
134 | # Inspect output NetCDF files |
---|
135 | #--------------------------------------------------- |
---|
136 | pstep 'Test last restart NetCDF files diff' |
---|
137 | diff_restart #2> /dev/null |
---|
138 | [ $? -ne 0 ] && status='FAILED' |
---|
139 | |
---|
140 | # Get computation duration |
---|
141 | #--------------------------------------------------- |
---|
142 | pstep 'Get real CPU time' |
---|
143 | get_cpu_time |
---|
144 | |
---|
145 | comments('W A R N I N G') |
---|
146 | fi |
---|
147 | |
---|
148 | # End |
---|
149 | #--------------------------------------------------- |
---|
150 | if [ $status == 'FAILED' ]; then step='Test outputs difference'; else step='Code is reliable'; fi |
---|
151 | get_out $step $status |
---|