New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
trusting.sh in branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST – NEMO

source: branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/trusting.sh @ 8818

Last change on this file since 8818 was 8818, checked in by nicolasmartin, 6 years ago

Continuation of global refactoring of the tool, set cfg files mime property and modify trusting.env trying to handle default settings

  • Property eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Rev URL
File size: 7.6 KB
Line 
1#!/bin/bash
2
3
4cd $( dirname $0 )
5
6## Set flags & defaults
7##--------------------------------------------------------------------------------
8
9TRUST_MAIN_DIR=$PWD
10
11TRUST_FLAG_DEBUG=0; TRUST_FLAG_PROD=0; TRUST_FLAG_HELP=0
12TRUST_FLAG_RESULT='FAILED'; TRUST_FLAG_ERROR=0
13
14## No update on SVN directories & 'FAILED' result for 'Unknown error' )
15TRUST_SVN_ACTION='svn status'
16
17xios_mode='--full'; stdout_redir='>&'
18rev=$( svn info | awk '(NR == 9) {print $NF}' )
19
20
21## Get options (replacing initials settings)
22##--------------------------------------------------------------------------------
23
24while [ $# -ne 0 ]; do
25
26    case $1 in
27   '-a'|'--archive') TRUST_IO_FORC_TAR=$2; shift 2;; '-b'|'--branch' ) TRUST_SVN_BRANCH=$2; shift 2;;
28   '-d'|'--debug'  ) TRUST_FLAG_DEBUG=1 ; shift  ;; '-e'|'--email'  ) TRUST_TEST_MAILING=$2; shift 2;;
29   '-f'|'--forcdir') TRUST_IO_FORC_PATH=$2; shift 2;; '-j'|'--job'    ) TRUST_COMPILE_NPROC=$2; shift 2;;
30   '-h'|'--help'   ) TRUST_FLAG_HELP=1 ; shift  ;; '-m'|'--machine') TRUST_MAIN_HPCC=$2; shift 2;;
31   '-n'|'--newconf') TRUST_CFG_NEW=$2; shift 2;; '-r'|'--refconf') TRUST_CFG_REF=$2; shift 2;;
32   '-t'|'--time'   ) TRUST_JOB_TIMEOUT=$2; shift 2;; '-p'|'--prod'   ) TRUST_FLAG_PROD=1 ; shift  ;;
33   '-u'|'--user'   ) TRUST_MAIN_USER=$2; shift 2;; '-v'|'--version') TRUST_SVN_REV=$2; shift 2;;
34   '-w'|'--workdir') TRUST_DIR_WORK=$2; shift 2;; "*"             ) TRUST_FLAG_HELP=1 ; shift  ;;
35    esac
36
37done
38
39
40## Initialization (HPC & user environment)
41##--------------------------------------------------------------------------------
42
43if [[ ! -e cfg/${TRUST_MAIN_USER}.cfg || ! -e cfg/${TRUST_MAIN_HPCC}.cfg || ${TRUST_FLAG_HELP} -eq 1 ]]; then
44    cat ./inc/trusting_help.txt
45
46    if [ ${TRUST_FLAG_HELP} -eq 0 ]; then
47   printf "\n\n\033[0;33m"
48   printf "At least one configuration (arch or user) file is missing or misspelled:"
49   printf "\t'%s'.cfg\t'%s'.cfg" ${TRUST_MAIN_USER} ${TRUST_MAIN_HPCC}
50   printf "\033[0m"
51    fi
52
53    printf "\n\nContent of 'config' folder:"
54    find config -name *.cfg | cut -d/ -f2 \
55   | xargs -n 4 printf "%-25s\t%-25s\t%-25s\n"
56    exit 1
57else
58    . ./inc/trusting.env && . ./inc/trusting_func.sh
59
60    ## DEBUG option to speed up & expand verbosity of compilation
61    [ ${TRUST_FLAG_DEBUG} -eq 1 ] && { set -vx; xios_mode=''; stdout_redir='>'; }
62
63    ## If -v|--version option has been set, modify default SVN action on directories
64    if   [ $( echo ${TRUST_SVN_REV} | grep  "HEAD\|up\|update"                     ) ]; then
65   TRUST_SVN_ACTION='svn update -r HEAD'
66    elif [ $( echo ${TRUST_SVN_REV} | grep -o '{[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}}' ) ]; then
67   TRUST_SVN_ACTION='svn update -r     '$( echo ${TRUST_SVN_REV} | grep -o '{[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}}' )
68    elif [ $( echo ${TRUST_SVN_REV} | grep -o '[0-9]*'                             ) ]; then
69   TRUST_SVN_ACTION='svn update -r     '$( echo ${TRUST_SVN_REV} | grep -o '[0-9]*' )
70    fi
71
72fi
73
74
75## Display contextual summary of trusting test
76##--------------------------------------------------------------------------------
77
78echo
79
80if [ -t 0 ]; then cat ./inc/banner.txt; else cat ./inc/banner.html; fi
81
82echo
83echo '****************************************************************************************************'
84echo '*                                                                                                  *'
85echo '*                           NEMO Trusting (Continuous Integration Tool)                            *'
86echo "*                                             ver.$rev                                             *"
87echo '*                                                                                                  *'
88echo '****************************************************************************************************'
89echo
90printf "\t§ (Super)Computer\t\t%s\n"             ${TRUST_MAIN_HPCC}
91printf "\t§ User installation\t\t%s\n\n"         ${TRUST_MAIN_USER}
92echo
93printf "\t§ Testing configuration\t\t%s based on %s\n" ${TRUST_CFG_NEW} ${TRUST_CFG_REF}
94printf "\t§ SVN working copy\t\t%s/%s\n"               ${TRUST_DIR_WORK} ${TRUST_SVN_BRANCH}
95if [ ${TRUST_TEST_BENCHMARK} ]; then
96printf "\t§ Benchmark folder\t\t%s\n"               ${TRUST_TEST_BENCHMARK}
97fi
98
99
100## Make timestamped directory with messenger files
101##--------------------------------------------------------------------------------
102
103print_step 'Timestamped testing directory'
104
105mkdir -p ${TRUST_TEST_DIR} ${TRUST_TEST_BENCHMARK}
106cd       ${TRUST_TEST_DIR}
107echo     ${TRUST_TEST_DIR}
108
109init_files
110
111get_date
112
113
114## Get SVN revision on XIOS & NEMO essentials directories
115##--------------------------------------------------------------------------------
116
117print_step "SVN action on NEMO directories: ${TRUST_SVN_ACTION}"
118
119get_nemo_rev
120
121
122## Check softwares versions (after sourced arch environment)
123##--------------------------------------------------------------------------------
124
125print_step 'Get testing environement'
126
127get_soft_rel
128
129cat model.log | awk '{printf "%-20s %s %s\n", $1, $2, $3}'
130env | sort > env.log
131
132
133## XIOS compilation from scratch
134##--------------------------------------------------------------------------------
135
136print_step 'Compile XIOS'
137
138cd ${TRUST_IO_XIOS}
139
140eval ./make_xios ${xios_mode} --arch ${TRUST_MAIN_HPCC} --job ${TRUST_COMPILE_NPROC} \
141    ${stdout_redir} /dev/null
142
143[ ! -e lib/libxios.a ] && get_out 1 || echo 'Success'
144
145
146## NEMO compilation from scratch
147##--------------------------------------------------------------------------------
148
149print_step "Compile ${TRUST_CFG_REF} configuration"
150
151cd ${TRUST_SVN_NEMOGCM}/CONFIG
152
153if [[ -d ${TRUST_CFG_NEW} && ${TRUST_FLAG_DEBUG} -eq 0 ]]; then
154    ./makenemo -n ${TRUST_CFG_NEW} clean_config \
155   > /dev/null <<EOF
156y
157EOF
158fi
159
160eval ./makenemo -n ${TRUST_CFG_NEW} -r ${TRUST_CFG_REF} \
161                -m ${TRUST_MAIN_HPCC} -j ${TRUST_COMPILE_NPROC} \
162                   ${TRUST_CFG_KEY_ADD} ${TRUST_CFG_KEY_DEL}    \
163    ${stdout_redir} /dev/null
164
165[ ! -e ${TRUST_CFG_NEW}/BLD/bin/nemo.exe ] && get_out 2 || echo 'Success'
166
167
168## Get all inputs for running
169##--------------------------------------------------------------------------------
170
171print_step 'Set job (copying or extracting inputs)'
172
173cd ${TRUST_TEST_DIR}
174
175get_inputs
176
177cp   ${TRUST_SVN_NEMOGCM}/CONFIG/${TRUST_CFG_NEW}/cpp_* .
178find ${TRUST_SVN_NEMOGCM}/CONFIG/${TRUST_CFG_NEW}/EXP00   \
179    -regex '.*\(_cfg\|.in\|opa\|_ref\|.xml\)' \
180    -exec  cp {} . \;
181
182
183## Check inputs
184##--------------------------------------------------------------------------------
185
186print_step 'Compare inputs'
187
188diff_inputs
189
190
191## Job submission & computation
192##--------------------------------------------------------------------------------
193
194print_step 'Submit job'
195
196## Copy the submitting script to testing folder
197cp ${TRUST_JOB_SCRIPT} ${TRUST_TEST_DIR}
198TRUST_JOB_ID=$( eval ${TRUST_JOB_SUBMIT} )
199
200[ $? -ne 0 ] && get_out 4 || printf "Success (job ID %s)\n" ${TRUST_JOB_ID}
201
202print_step 'Pending job'
203
204job_pending
205
206print_step 'Job finished'
207
208
209## Check job state & get computation performances if succeeded
210##--------------------------------------------------------------------------------
211
212print_step 'Test job state'
213
214if [[ ! -e time.step || $( grep 'E R R O R' ocean.output ) ]]; then
215    get_out 5
216else
217    echo 'Success' ## Must be reviewed
218fi
219
220print_step 'Get job performances'
221
222get_time
223
224get_memy
225
226
227## Check outputs
228##--------------------------------------------------------------------------------
229
230TRUST_FLAG_RESULT='OK' ## 'OK' by default
231
232print_step 'Compare outputs'
233
234diff_results
235
236print_step 'Compare restarts'
237
238diff_restarts
239
240[ $TRUST_RESULT == 'FAILED' ] && get_out 8
241
242
243## End, at least nothing major has changed ;-)
244##--------------------------------------------------------------------------------
245
246get_out 0
Note: See TracBrowser for help on using the repository browser.