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

Last change on this file since 5809 was 5809, checked in by nicolasmartin, 9 years ago

dev_r5092_CNRS18_TRUST Bugfix when update SVN working copy to former version

  • Property eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Rev URL
File size: 6.5 KB
Line 
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 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    . trusting.env && . trusting_func.sh
50#echo $WRAPPER_LDFLAGS
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 banner.txt; else cat banner.html; fi
70echo
71echo '****************************************************************************************************'
72echo '*                                                                                                  *'
73echo '*                           NEMO Trusting (Continuous Integration Tool)                            *'
74echo "*                                             ver.$rev                                             *"
75echo '*                                                                                                  *'
76echo '****************************************************************************************************'
77echo
78echo '  - Testing configuration   '${TRUS_CONF}' based on '${TRUS_REFE}
79echo '  - SVN working copy        '${TRUS_WORK}/${TRUS_BRAN}
80echo '  - Benchmark folder        '${TRUS_BHMK}
81echo '  - (Super)Computer         '${TRUS_HPCC}
82echo '  - User installation       '${TRUS_USER}
83echo
84
85
86## Make timestamped directory with messenger files
87##---------------------------------------------------
88print_step 'Timestamped testing directory'
89mkdir -p ${TRUS_TEST} ${TRUS_BHMK}
90cd       ${TRUS_TEST}
91echo     ${TRUS_TEST}
92init_files
93get_date
94
95
96## Get SVN revision on XIOS & NEMO essentials directories
97##---------------------------------------------------
98print_step "SVN action on NEMO directories: ${TRUS_SVNA}"
99get_nemo_rev
100
101
102## Check softwares versions (after sourced arch environment)
103##---------------------------------------------------
104print_step 'Get testing environement'
105get_soft_rel
106cat model.log
107env | sort > env.log
108#echo $WRAPPER_LDFLAGS
109
110## XIOS compilation from scratch
111##---------------------------------------------------
112print_step 'Compile XIOS'
113cd ${TRUS_XIOS}
114eval ./make_xios ${xios_mode} --arch ${TRUS_HPCC} --job ${TRUS_NPRO} \
115    ${stdout_redir} /dev/null
116[ ! -e lib/libxios.a ] && get_out 1 || echo 'Success'
117
118
119## NEMO compilation from scratch
120##---------------------------------------------------
121print_step "Compile ${TRUS_REFE} configuration"
122cd ${TRUS_NGCM}/CONFIG
123[[ -d ${TRUS_CONF} && ${TRUS_DBUG} -eq 0 ]] && ./makenemo -n ${TRUS_CONF} clean_config \
124    > /dev/null <<EOF
125y
126EOF
127
128eval ./makenemo -n ${TRUS_CONF} -r ${TRUS_REFE} -m ${TRUS_HPCC} -j ${TRUS_NPRO} \
129                ${TRUS_KEYA} ${TRUS_KEYD}                                       \
130    ${stdout_redir} /dev/null
131[ ! -e ${TRUS_CONF}/BLD/bin/nemo.exe ] && get_out 2 || echo 'Success'
132
133
134## Get all inputs for running
135##---------------------------------------------------
136print_step 'Set job (copying or extracting inputs)'
137cd ${TRUS_TEST}
138cp   ${TRUS_NGCM}/CONFIG/${TRUS_CONF}/cpp_* .
139find ${TRUS_NGCM}/CONFIG/${TRUS_CONF}/EXP00 -regex '.*\(_cfg\|.in\|opa\|_ref\|.xml\)' \
140                                            -exec  cp {} . \;
141get_inputs
142[ $? -ne 0 ] && get_out 3 || echo 'Success'
143[ $( find . -name '*.gz' -print -quit ) ] && find . -name '*.gz' -exec gunzip {} \;
144
145
146## Check inputs
147##---------------------------------------------------
148print_step 'Compare inputs'
149diff_inputs
150
151
152## Job submission & computation
153##---------------------------------------------------
154print_step 'Submit job'
155JOB_ID=$( eval ${TRUS_JSUB} )
156[ $? -ne 0 ] && get_out 4 || echo 'Success (job ID '${JOB_ID}')'
157print_step 'Pending job'
158job_pending
159print_step 'Job finished'
160
161
162## Check job state & get computation performances if succeeded
163##---------------------------------------------------
164print_step 'Test job state'
165[[ ! -e time.step || $( grep 'E R R O R' ocean.output ) ]] && get_out 5 || echo 'Success'
166print_step 'Get job performances'
167get_time
168get_memy
169
170
171## Check outputs
172##---------------------------------------------------
173TRUS_RSLT='OK' ## 'OK' by default
174print_step 'Compare outputs'
175diff_results
176print_step 'Compare restarts'
177diff_restart
178[ $TRUS_RSLT == 'FAILED' ] && get_out 8
179
180
181## End, at least nothing has changed ;-)
182##---------------------------------------------------
183get_out 0
Note: See TracBrowser for help on using the repository browser.