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 @ 8808

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

Continuation of global refactoring of the tool, in particular a intelligible variables namelist

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