1 | #!/bin/bash |
---|
2 | |
---|
3 | |
---|
4 | cd $( dirname $0 ) |
---|
5 | |
---|
6 | ## Set defaults |
---|
7 | ##--------------------------------------------------- |
---|
8 | NEMO_TRUS=$PWD |
---|
9 | DEBUG=0; PUBLISH=0; |
---|
10 | I_MODULE=0; ST='FAILED' ## No 'module' command & 'FAILED' status by default |
---|
11 | xios_full='--full'; stderr_redir='>&' ## DEBUG options |
---|
12 | |
---|
13 | ## Get options for replacing some initials settings |
---|
14 | ##--------------------------------------------------- |
---|
15 | while [ $# -ne 0 ]; do |
---|
16 | case $1 in |
---|
17 | -a|--archive) NEMO_TARF=$2 ; shift 2;; -b|--branch ) NEMO_BRAN=$2 ; shift 2;; |
---|
18 | -d|--debug ) set -vx; DEBUG=1 ; shift ;; -e|--email ) EMAIL=$2 ; shift 2;; |
---|
19 | -j|--job ) NPROC=$2 ; shift 2;; -h|--help ) cat trusting_help.txt; exit 1;; |
---|
20 | -m|--machine) NEMO_HPCC=$2 ; shift 2;; -n|--newconf) TEST_CONF=$2 ; shift 2;; |
---|
21 | -r|--refconf) REFE_CONF=$2 ; shift 2;; -t|--time ) TIME_LIMI=$2 ; shift 2;; |
---|
22 | -p|--publish) PUBLISH=1 ; shift ;; -u|--user ) NEMO_USER=$2 ; shift 2;; |
---|
23 | -v|--version) NEMO_VERS=$2 ; shift 2;; *) cat trusting_help.txt; exit 1;; |
---|
24 | esac |
---|
25 | done |
---|
26 | |
---|
27 | ## Initialization (super-computer & user environment) |
---|
28 | ##--------------------------------------------------- |
---|
29 | if [[ ! -z "${NEMO_HPCC}" && ! -z "${NEMO_USER}" ]]; then |
---|
30 | |
---|
31 | if [ ! $( find ${NEMO_TRUS}/config -name ${NEMO_USER}'.cfg' ) ]; then |
---|
32 | echo 'No configuration file (.cfg) in '${NEMO_TRUS}'/config for '${NEMO_USER}; exit 1 |
---|
33 | elif [ ! $( find ${NEMO_TRUS}/config -name ${NEMO_HPCC}'.cfg' ) ]; then |
---|
34 | echo 'No configuration file (.cfg) in '${NEMO_TRUS}'/config for '${NEMO_HPCC}; exit 1 |
---|
35 | else |
---|
36 | . ${NEMO_TRUS}/trusting.env |
---|
37 | fi |
---|
38 | |
---|
39 | else |
---|
40 | cat ${NEMO_TRUS}/trusting_help.txt; exit 1 |
---|
41 | fi |
---|
42 | |
---|
43 | . ./trusting_func.sh |
---|
44 | |
---|
45 | ## Summary of trusting test context |
---|
46 | ##--------------------------------------------------- |
---|
47 | printf "\n\ |
---|
48 | NEMO Trusting test:\n\ |
---|
49 | -------------------\n\ |
---|
50 | Testing ${TEST_CONF} based on ${REFE_CONF} from ${NEMO_BRAN}\n\ |
---|
51 | NEMO installation: ${NEMO_USER}\n\ |
---|
52 | Computing architecture: ${NEMO_HPCC}\n" |
---|
53 | |
---|
54 | ## Making timestamped directory with messenger files |
---|
55 | ##--------------------------------------------------- |
---|
56 | print_step 'Time-stamp generation & testing directory creation' |
---|
57 | mkdir -p ${TEST_DIR} ${REFE_DIR} |
---|
58 | echo ${TEST_DIR} && cd ${TEST_DIR} |
---|
59 | init_files && get_date |
---|
60 | |
---|
61 | ## SVN action on XIOS & NEMO essentials directories |
---|
62 | ##--------------------------------------------------- |
---|
63 | print_step 'SVN command on NEMO directories:' |
---|
64 | get_nemo_rev |
---|
65 | |
---|
66 | ## Check softwares versions (source arch environment) |
---|
67 | ##--------------------------------------------------- |
---|
68 | print_step 'Get softwares releases' |
---|
69 | [ -e ${ARCH_ENV} ] && . ${ARCH_ENV} > /dev/null |
---|
70 | (( $? == 0 )) && export I_MODULE=1 |
---|
71 | get_soft_rel |
---|
72 | cat model.log |
---|
73 | |
---|
74 | ## XIOS compiling |
---|
75 | ##--------------------------------------------------- |
---|
76 | print_step 'Compile XIOS' |
---|
77 | cd ${DIR_XIOS} |
---|
78 | [ $DEBUG -eq 1 ] && xios_full='' && stderr_redir='>' |
---|
79 | eval ./make_xios ${xios_full} --arch ${NEMO_HPCC} --job $NPROC ${stderr_redir} /dev/null |
---|
80 | [ ! -e ${DIR_XIOS}/lib/libxios.a ] && get_out 1 |
---|
81 | |
---|
82 | ## NEMO config compiled from scratch |
---|
83 | ##--------------------------------------------------- |
---|
84 | print_step "Compile ${REFE_CONF} configuration" |
---|
85 | cd ${NEMO_CONF} |
---|
86 | [[ -d ${TEST_CONF} && $DEBUG -eq 0 ]] && eval ./makenemo -n ${TEST_CONF} clean > /dev/null |
---|
87 | eval ./makenemo -n ${TEST_CONF} -r ${REFE_CONF} -m ${NEMO_HPCC} -j $NPROC ${stderr_redir} /dev/null |
---|
88 | [ ! -e ${TEST_CONF}/BLD/bin/nemo.exe ] && get_out 2 |
---|
89 | |
---|
90 | ## Get namelists, xml & forcing files for running |
---|
91 | ##--------------------------------------------------- |
---|
92 | print_step 'Set job (copying & extracting input files)' |
---|
93 | cd ${TEST_DIR} |
---|
94 | find ${NEMO_CONF}/${TEST_CONF}/EXP00 -regex '.*\(cfg\|opa\|ref\|xml\)' -exec cp {} . \; |
---|
95 | get_inputs |
---|
96 | (( $? != 0 )) && get_out 3 |
---|
97 | [ $( find . -name '*.gz' -print -quit ) ] && gunzip *.gz |
---|
98 | |
---|
99 | ## Check input files in all cases |
---|
100 | ##--------------------------------------------------- |
---|
101 | print_step 'Compare with standard input files list' |
---|
102 | diff_inputs |
---|
103 | |
---|
104 | ## Job submission & computing |
---|
105 | ##--------------------------------------------------- |
---|
106 | print_step 'Submit job' |
---|
107 | JOB_ID=$( eval ${JOB_SUBM} ) |
---|
108 | (( $? != 0 )) && get_out 4 |
---|
109 | print_step 'Pending job' |
---|
110 | job_pending |
---|
111 | print_step 'Job finished' |
---|
112 | |
---|
113 | ## Job state |
---|
114 | ##--------------------------------------------------- |
---|
115 | print_step 'Test job state' |
---|
116 | if [[ ! -e time.step || $( grep -q 'E R R O R' ocean.output ) ]]; then |
---|
117 | echo 'Error' |
---|
118 | comments 'E R R O R' |
---|
119 | get_out 5 |
---|
120 | else |
---|
121 | echo 'Good' |
---|
122 | ## Get time computation |
---|
123 | ##--------------------------------------------------- |
---|
124 | print_step 'Get real CPU time' |
---|
125 | get_cpu_time |
---|
126 | fi |
---|
127 | |
---|
128 | ST='OK' ## 'OK' by default |
---|
129 | |
---|
130 | ## Inspect output text files |
---|
131 | ##--------------------------------------------------- |
---|
132 | print_step 'Test output files diff' |
---|
133 | diff_results |
---|
134 | |
---|
135 | ## Inspect output NetCDF files |
---|
136 | ##--------------------------------------------------- |
---|
137 | print_step 'Test last restart files diff' |
---|
138 | diff_restart |
---|
139 | [ "$ST" == 'FAILED' ] && get_out 8 |
---|
140 | |
---|
141 | ## Get comments (ocean.output & diff model.log) |
---|
142 | ##--------------------------------------------------- |
---|
143 | comments 'W A R N I N G' |
---|
144 | |
---|
145 | ## End |
---|
146 | ##--------------------------------------------------- |
---|
147 | get_out 'Code is reliable' |
---|