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