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

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

dev_r5092_CNRS18_TRUST Establishing common environment for installing & running trusting, consolidation of scripts & continuation of templates & help section improvments

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