1 | #!/bin/bash |
---|
2 | |
---|
3 | |
---|
4 | # Set defaults |
---|
5 | #--------------------------------------------------- |
---|
6 | NEMO_TRUS=$( pwd $( dirname $0 ) ) |
---|
7 | DEBUG=0; PUBLISH=0 |
---|
8 | STATUS='FAILED'; STEP='' # Only at end status will change to OK |
---|
9 | |
---|
10 | # Get options for replacing some initials settings |
---|
11 | #--------------------------------------------------- |
---|
12 | while [ $# -ne 0 ]; do |
---|
13 | case $1 in |
---|
14 | -b|--branch ) NEMO_BRAN=$2 ; shift 2;; -d|--debug ) set -vx; DEBUG=1 ; shift ;; |
---|
15 | -e|--email ) EMAIL=$2 ; shift 2;; -j|--job ) NPROC=$2 ; shift 2;; |
---|
16 | -h|--help ) cat trusting_help.txt; exit 1;; -m|--machine) CFG_ARCH=$2 ; shift 2;; |
---|
17 | -n|--newconf) TEST_CONF=$2 ; shift 2;; -r|--refconf) REFE_CONF=$2 ; shift 2;; |
---|
18 | -t|--time ) TIME_LIMI=$2 ; shift 2;; -p|--publish) PUBLISH=1 ; shift ;; |
---|
19 | -u|--user ) CFG_USER=$2 ; shift 2;; -v|--version) NEMO_VERS=$2 ; shift 2;; |
---|
20 | *) cat trusting_help.txt; exit 1;; |
---|
21 | esac |
---|
22 | done |
---|
23 | |
---|
24 | # Initialization (super-computer & user environment) |
---|
25 | #--------------------------------------------------- |
---|
26 | if [[ ! -z "${CFG_ARCH}" && ! -z "${CFG_USER}" ]]; then |
---|
27 | |
---|
28 | if [ ! $( find ${NEMO_TRUS}/config -name ${CFG_USER}.cfg ) ]; then |
---|
29 | echo 'No configuration file in '${NEMO_TRUS}'/config for '${CFG_USER}; exit 1 |
---|
30 | elif [ ! $( find ${NEMO_TRUS}/config -name ${CFG_ARCH}.cfg ) ]; then |
---|
31 | echo 'No configuration file in '${NEMO_TRUS}'/config for '${CFG_ARCH}; exit 1 |
---|
32 | else |
---|
33 | . ${NEMO_TRUS}/trusting.env |
---|
34 | fi |
---|
35 | |
---|
36 | else |
---|
37 | cat ${NEMO_TRUS}/trusting_help.txt; exit 1 |
---|
38 | fi |
---|
39 | |
---|
40 | . ./trusting_func.sh |
---|
41 | |
---|
42 | # |
---|
43 | #--------------------------------------------------- |
---|
44 | mkdir -p ${TEST_DIR} ${REFE_DIR} |
---|
45 | echo ${TEST_DIR} && cd ${TEST_DIR} |
---|
46 | date_str=$( date -ud ${DATESTR} +"%F %R %Z" ) |
---|
47 | printf "Date\n${date_str}\n" > mesg_01_date_${CFG_USER}_${CFG_ARCH}.txt |
---|
48 | |
---|
49 | # SVN action on XIOS & NEMO essentials directories |
---|
50 | #--------------------------------------------------- |
---|
51 | print_step 'Get NEMO code state / repository' |
---|
52 | get_nemo_rev |
---|
53 | |
---|
54 | # Check softwares versions (source arch environment) |
---|
55 | #--------------------------------------------------- |
---|
56 | print_step 'Get softwares release' |
---|
57 | . ${ARCH_ENV} > /dev/null |
---|
58 | get_soft_rel |
---|
59 | cat model.log |
---|
60 | |
---|
61 | # XIOS compiling |
---|
62 | #--------------------------------------------------- |
---|
63 | print_step 'Compiling XIOS' |
---|
64 | cd ${DIR_XIOS} |
---|
65 | #./make_xios --full --arch $ARCH -job $NPROC >& /dev/null |
---|
66 | [ ! -e ${DIR_XIOS}/lib/libxios.a ] && get_out $STATUS $STEP |
---|
67 | |
---|
68 | # NEMO config compiled from scratch |
---|
69 | #--------------------------------------------------- |
---|
70 | print_step "Compiling ${REFE_CONF} 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 $STATUS $STEP |
---|
75 | |
---|
76 | # Get namelists, xml & forced files for running |
---|
77 | #--------------------------------------------------- |
---|
78 | print_step "Preparing job by copying ${REFE_CONF} input files" |
---|
79 | cd ${TEST_DIR} |
---|
80 | find ${NEMO_CONF}/${TEST_CONF}/EXP00 -regex '.*\(cfg\|opa\|ref\|xml\)' -exec cp {} . \; |
---|
81 | get_inputs |
---|
82 | [ $? -ne 0 ] && get_out $STATUS $STEP |
---|
83 | [ $( find . -name '*.gz' -print -quit ) ] && gunzip *.gz |
---|
84 | |
---|
85 | # Check input files in all cases |
---|
86 | #--------------------------------------------------- |
---|
87 | print_step 'Difference with standard input files list' |
---|
88 | diff_inputs |
---|
89 | |
---|
90 | # Job submission & computing |
---|
91 | #--------------------------------------------------- |
---|
92 | print_step 'Submitting job' |
---|
93 | JOB_ID=$( ${JOB_SUBM} | awk '{print $NF}' ) |
---|
94 | [ $? -ne 0 ] && get_out $STATUS $STEP |
---|
95 | print_step 'Holding-Running job' |
---|
96 | job_pending |
---|
97 | print_step 'Job finished' |
---|
98 | |
---|
99 | # Eventual crash during computing |
---|
100 | #--------------------------------------------------- |
---|
101 | print_step 'Test if job crashed' |
---|
102 | if [[ ! -e ocean.output || $( grep 'E R R O R' ocean.output ) ]]; then |
---|
103 | comments 'E R R O R' |
---|
104 | get_out $STATUS $STEP |
---|
105 | fi |
---|
106 | |
---|
107 | STATUS='OK' |
---|
108 | # Inspect output text files |
---|
109 | #--------------------------------------------------- |
---|
110 | print_step 'Test ASCII output files diff' |
---|
111 | diff_textfiles |
---|
112 | if [ "$STATUS" == 'FAILED' ] && get_out $STATUS $STEP |
---|
113 | |
---|
114 | # Inspect output NetCDF files |
---|
115 | #--------------------------------------------------- |
---|
116 | print_step 'Test last restart NetCDF files diff' |
---|
117 | diff_restart |
---|
118 | if [ "$STATUS" == 'FAILED' ] && get_out $STATUS $STEP |
---|
119 | |
---|
120 | # Get computation duration |
---|
121 | #--------------------------------------------------- |
---|
122 | print_step 'Get real CPU time' |
---|
123 | get_cpu_time |
---|
124 | |
---|
125 | # Get comments (ocean.output & diff model.log) |
---|
126 | #--------------------------------------------------- |
---|
127 | comments 'W A R N I N G' |
---|
128 | |
---|
129 | # End |
---|
130 | #--------------------------------------------------- |
---|
131 | [ "$STATUS" == 'OK' ] && STEP='Code is reliable' |
---|
132 | get_out $STATUS $STEP |
---|