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 trunk/NEMOGCM/TRUST – NEMO

source: trunk/NEMOGCM/TRUST/trusting.sh @ 5936

Last change on this file since 5936 was 5936, checked in by nicolasmartin, 8 years ago

Merge dev_r5092_CNRS18_TRUST onto the trunk: add new tool Trusting (ie TRUST directory at root of NEMGOCM) for continuous integration tests on HPC centers & basic validation tests for developers

  • Property svn:executable set to *
File size: 6.6 KB
RevLine 
[5936]1#!/bin/bash
2
3
4cd $( dirname $0 )
5
6## Set defaults
7##---------------------------------------------------
8TRUS_DIRE=$PWD
9TRUS_DBUG=0; TRUS_PROD=0; TRUS_HELP=0
10## No update on SVN directories & 'FAILED' result for 'Unknown error' )
11TRUS_SVNA='svn status'; TRUS_RSLT='FAILED'; TRUS_RORR=0
12xios_mode='--full'; stdout_redir='>&'
13rev=$( svn info | awk '(NR == 9) {print $NF}' )
14
15
16## Get options (replacing initials settings)
17##---------------------------------------------------
18while [ $# -ne 0 ]; do
19    case $1 in
20   '-a'|'--archive') TRUS_TARF=$2; shift 2;; '-b'|'--branch' ) TRUS_BRAN=$2; shift 2;;
21   '-d'|'--debug'  ) TRUS_DBUG=1 ; shift  ;; '-e'|'--email'  ) TRUS_MAIL=$2; shift 2;;
22   '-f'|'--forcdir') TRUS_FORC=$2; shift 2;; '-j'|'--job'    ) TRUS_NPRO=$2; shift 2;;
23   '-h'|'--help'   ) TRUS_HELP=1 ; shift  ;; '-m'|'--machine') TRUS_HPCC=$2; shift 2;;
24   '-n'|'--newconf') TRUS_CONF=$2; shift 2;; '-r'|'--refconf') TRUS_REFE=$2; shift 2;;
25   '-t'|'--time'   ) TRUS_TOUT=$2; shift 2;; '-p'|'--prod'   ) TRUS_PROD=1 ; shift  ;;
26   '-u'|'--user'   ) TRUS_USER=$2; shift 2;; '-v'|'--version') TRUS_SVNV=$2; shift 2;;
27   '-w'|'--workdir') TRUS_WORK=$2; shift 2;; "*"             ) TRUS_HELP=1 ; shift  ;;
28    esac
29done
30
31
32## Initialization (HPC & user environment)
33##---------------------------------------------------
34if [[ ! -e config/${TRUS_USER}.cfg || ! -e config/${TRUS_HPCC}.cfg || ${TRUS_HELP} -eq 1 ]]; then
35    cat ./inc/trusting_help.txt
36
37    if [ ${TRUS_HELP} -eq 0 ]; then
38   printf "\n\n\033[0;33m"
39   printf "At least one configuration (arch or user) file is missing or misspelled:"
40   printf "\t'%s'.cfg\t'%s'.cfg" ${TRUS_USER} ${TRUS_HPCC}
41   printf "\033[0m"
42    fi
43
44    printf "\n\nContent of 'config' folder:"
45    find config -name *.cfg | cut -d/ -f2 \
46   | xargs -n 4 printf "%-25s\t%-25s\t%-25s\n"
47    exit 1
48else
49    . ./inc/trusting.env && . ./inc/trusting_func.sh
50
51    ## DEBUG option to speed up & expand verbosity of compilation
52    [ ${TRUS_DBUG} -eq 1 ] && { set -vx; xios_mode=''; stdout_redir='>'; }
53
54    ## If -v|--version option has been set, modify default SVN action on directories
55    if   [ $( echo ${TRUS_SVNV} | grep  "HEAD\|up\|update"                     ) ]; then
56   TRUS_SVNA='svn update -r HEAD'
57    elif [ $( echo ${TRUS_SVNV} | grep -o '{[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}}' ) ]; then
58   TRUS_SVNA='svn update -r     '$( echo ${TRUS_SVNV} | grep -o '{[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}}' )
59    elif [ $( echo ${TRUS_SVNV} | grep -o '[0-9]*'                             ) ]; then
60   TRUS_SVNA='svn update -r     '$( echo ${TRUS_SVNV} | grep -o '[0-9]*' )
61    fi
62
63fi
64
65
66## Display contextual summary of trusting test
67##---------------------------------------------------
68echo
69if [ -t 0 ]; then cat ./inc/banner.txt; else cat ./inc/banner.html; fi
70echo
71echo '****************************************************************************************************'
72echo '*                                                                                                  *'
73echo '*                           NEMO Trusting (Continuous Integration Tool)                            *'
74echo "*                                             ver.$rev                                             *"
75echo '*                                                                                                  *'
76echo '****************************************************************************************************'
77echo
78printf "\t§ Testing configuration\t\t%s based on %s\n" ${TRUS_CONF} ${TRUS_REFE}
79printf "\t§ SVN working copy\t\t%s/%s\n"               ${TRUS_WORK} ${TRUS_BRAN}
80printf "\t§ Benchmark folder\t\t%s\n"               ${TRUS_STOR}
81printf "\t§ (Super)Computer\t\t%s\n"             ${TRUS_HPCC}
82printf "\t§ User installation\t\t%s\n\n"         ${TRUS_USER}
83
84
85## Make timestamped directory with messenger files
86##---------------------------------------------------
87print_step 'Timestamped testing directory'
88mkdir -p ${TRUS_SCRA} ${TRUS_STOR}
89cd       ${TRUS_SCRA}
90echo     ${TRUS_SCRA}
91init_files
92get_date
93
94
95## Get SVN revision on XIOS & NEMO essentials directories
96##---------------------------------------------------
97print_step "SVN action on NEMO directories: ${TRUS_SVNA}"
98get_nemo_rev
99
100
101## Check softwares versions (after sourced arch environment)
102##---------------------------------------------------
103print_step 'Get testing environement'
104get_soft_rel
105cat model.log | awk '{printf "%-20s %s %s\n", $1, $2, $3}'
106env | sort > env.log
107
108
109## XIOS compilation from scratch
110##---------------------------------------------------
111print_step 'Compile XIOS'
112cd ${TRUS_XIOS}
113eval ./make_xios ${xios_mode} --arch ${TRUS_HPCC} --job ${TRUS_NPRO} \
114    ${stdout_redir} /dev/null
115[ ! -e lib/libxios.a ] && get_out 1 || echo 'Success'
116
117
118## NEMO compilation from scratch
119##---------------------------------------------------
120print_step "Compile ${TRUS_REFE} configuration"
121cd ${TRUS_NGCM}/CONFIG
122[[ -d ${TRUS_CONF} && ${TRUS_DBUG} -eq 0 ]] && ./makenemo -n ${TRUS_CONF} clean_config \
123    > /dev/null <<EOF
124y
125EOF
126
127eval ./makenemo -n ${TRUS_CONF} -r ${TRUS_REFE} -m ${TRUS_HPCC} -j ${TRUS_NPRO} \
128                ${TRUS_KEYA} ${TRUS_KEYD}                                       \
129    ${stdout_redir} /dev/null
130[ ! -e ${TRUS_CONF}/BLD/bin/nemo.exe ] && get_out 2 || echo 'Success'
131
132
133## Get all inputs for running
134##---------------------------------------------------
135print_step 'Set job (copying or extracting inputs)'
136cd ${TRUS_SCRA}
137get_inputs
138cp   ${TRUS_NGCM}/CONFIG/${TRUS_CONF}/cpp_* .
139find ${TRUS_NGCM}/CONFIG/${TRUS_CONF}/EXP00 -regex '.*\(_cfg\|.in\|opa\|_ref\|.xml\)' \
140                                            -exec  cp {} . \;
141
142
143## Check inputs
144##---------------------------------------------------
145print_step 'Compare inputs'
146diff_inputs
147
148
149## Job submission & computation
150##---------------------------------------------------
151print_step 'Submit job'
152cp ${TRUS_DIRE}/batch/${TRUS_JSPT} ${TRUS_SCRA} ## Copy the submitting script to testing folder
153TRUS_JIDN=$( eval ${TRUS_JSUB} )
154[ $? -ne 0 ] && get_out 4 || printf "Success (job ID %s)\n" ${TRUS_JIDN}
155print_step 'Pending job'
156job_pending
157print_step 'Job finished'
158
159
160## Check job state & get computation performances if succeeded
161##---------------------------------------------------
162print_step 'Test job state'
163[[ ! -e time.step || $( grep 'E R R O R' ocean.output ) ]] && get_out 5 || echo 'Success' ## Must be reviewed
164print_step 'Get job performances'
165get_time
166get_memy
167
168
169## Check outputs
170##---------------------------------------------------
171TRUS_RSLT='OK' ## 'OK' by default
172print_step 'Compare outputs'
173diff_results
174print_step 'Compare restarts'
175diff_restart
176[ $TRUS_RSLT == 'FAILED' ] && get_out 8
177
178
179## End, at least nothing has changed ;-)
180##---------------------------------------------------
181get_out 0
Note: See TracBrowser for help on using the repository browser.