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
RevLine 
[5268]1#!/bin/bash
2
3
[5644]4cd $( dirname $0 )
5
[5629]6## Set defaults
7##---------------------------------------------------
[8808]8TRUST_MAIN_DIR=$PWD
9TRUST_FLAG_DEBUG=0; TRUST_FLAG_PROD=0; TRUST_FLAG_HELP=0
[5799]10## No update on SVN directories & 'FAILED' result for 'Unknown error' )
[8808]11TRUST_SVN_ACTION='svn status'
12TRUST_FLAG_RESULT='FAILED'; TRUST_FLAG_ERROR=0
13
[5788]14xios_mode='--full'; stdout_redir='>&'
[5799]15rev=$( svn info | awk '(NR == 9) {print $NF}' )
[5268]16
[5681]17
[5799]18## Get options (replacing initials settings)
[5629]19##---------------------------------------------------
[5268]20while [ $# -ne 0 ]; do
[8808]21
[5268]22    case $1 in
[8808]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  ;;
[5268]31    esac
[8808]32
[5268]33done
[5276]34
[5681]35
[5788]36## Initialization (HPC & user environment)
37##---------------------------------------------------
[8808]38if [[ ! -e cfg/${TRUST_MAIN_USER}.cfg || ! -e cfg/${TRUST_MAIN_HPCC}.cfg || ${TRUST_FLAG_HELP} -eq 1 ]]; then
[5929]39    cat ./inc/trusting_help.txt
[5690]40
[8808]41    if [ ${TRUST_FLAG_HELP} -eq 0 ]; then
[5799]42   printf "\n\n\033[0;33m"
43   printf "At least one configuration (arch or user) file is missing or misspelled:"
[8808]44   printf "\t'%s'.cfg\t'%s'.cfg" ${TRUST_MAIN_USER} ${TRUST_MAIN_HPCC}
[5799]45   printf "\033[0m"
[5788]46    fi
[5695]47
[5799]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"
[5788]51    exit 1
52else
[5929]53    . ./inc/trusting.env && . ./inc/trusting_func.sh
54
[5799]55    ## DEBUG option to speed up & expand verbosity of compilation
[8808]56    [ ${TRUST_FLAG_DEBUG} -eq 1 ] && { set -vx; xios_mode=''; stdout_redir='>'; }
[5268]57
[5788]58    ## If -v|--version option has been set, modify default SVN action on directories
[8808]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]*' )
[5355]65    fi
[5268]66
[5355]67fi
[5268]68
69
[5690]70## Display contextual summary of trusting test
[5629]71##---------------------------------------------------
[5788]72echo
[8808]73
[5929]74if [ -t 0 ]; then cat ./inc/banner.txt; else cat ./inc/banner.html; fi
[8808]75
[5788]76echo
77echo '****************************************************************************************************'
78echo '*                                                                                                  *'
79echo '*                           NEMO Trusting (Continuous Integration Tool)                            *'
[5799]80echo "*                                             ver.$rev                                             *"
[5788]81echo '*                                                                                                  *'
82echo '****************************************************************************************************'
83echo
[8808]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}
[5644]89
[5681]90
[5690]91## Make timestamped directory with messenger files
[5644]92##---------------------------------------------------
[5695]93print_step 'Timestamped testing directory'
[8808]94
95mkdir -p ${TRUST_DIR_SCRATCH} ${TRUST_DIR_STORE}
96cd       ${TRUST_DIR_SCRATCH}
97echo     ${TRUST_DIR_SCRATCH}
98
[5695]99init_files
[8808]100
[5695]101get_date
[5355]102
[5681]103
[5690]104## Get SVN revision on XIOS & NEMO essentials directories
[5629]105##---------------------------------------------------
[8808]106print_step "SVN action on NEMO directories: ${TRUST_SVN_ACTION}"
107
[5695]108get_nemo_rev
[5444]109
[5681]110
[5690]111## Check softwares versions (after sourced arch environment)
[5629]112##---------------------------------------------------
[5788]113print_step 'Get testing environement'
[8808]114
[5695]115get_soft_rel
[8808]116
[5929]117cat model.log | awk '{printf "%-20s %s %s\n", $1, $2, $3}'
[5788]118env | sort > env.log
[5268]119
[5929]120
[5690]121## XIOS compilation from scratch
[5629]122##---------------------------------------------------
[5695]123print_step 'Compile XIOS'
[8808]124
125cd ${TRUST_DIR_XIOS}
126
127eval ./make_xios ${xios_mode} --arch ${TRUST_MAIN_HPCC} --job ${TRUST_COMPILE_NPROC} \
[5788]128    ${stdout_redir} /dev/null
[8808]129
[5695]130[ ! -e lib/libxios.a ] && get_out 1 || echo 'Success'
[5444]131
[5690]132
133## NEMO compilation from scratch
[5629]134##---------------------------------------------------
[8808]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
[5669]142y
143EOF
[8808]144fi
[5681]145
[8808]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}    \
[5788]149    ${stdout_redir} /dev/null
[5268]150
[8808]151[ ! -e ${TRUST_CFG_NEW}/BLD/bin/nemo.exe ] && get_out 2 || echo 'Success'
[5681]152
[8808]153
[5690]154## Get all inputs for running
[5629]155##---------------------------------------------------
[5695]156print_step 'Set job (copying or extracting inputs)'
[8808]157
158cd ${TRUST_DIR_SCRATCH}
159
[5929]160get_inputs
[5286]161
[8808]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 {} . \;
[5681]166
[8808]167
[5690]168## Check inputs
[5629]169##---------------------------------------------------
[5788]170print_step 'Compare inputs'
[8808]171
[5695]172diff_inputs
[5633]173
[5681]174
[5690]175## Job submission & computation
[5629]176##---------------------------------------------------
[5695]177print_step 'Submit job'
[8808]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
[5695]185print_step 'Pending job'
[8808]186
[5695]187job_pending
[8808]188
[5455]189print_step 'Job finished'
190
[5681]191
[5788]192## Check job state & get computation performances if succeeded
[5629]193##---------------------------------------------------
[5472]194print_step 'Test job state'
[8808]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
[5788]202print_step 'Get job performances'
[8808]203
[5788]204get_time
[8808]205
[5788]206get_memy
[5681]207
[5286]208
[5690]209## Check outputs
[5629]210##---------------------------------------------------
[8808]211TRUST_FLAG_RESULT='OK' ## 'OK' by default
212
[5788]213print_step 'Compare outputs'
[8808]214
[5695]215diff_results
[8808]216
[5788]217print_step 'Compare restarts'
[5286]218
[8808]219diff_restarts
[5268]220
[8808]221[ $TRUST_RESULT == 'FAILED' ] && get_out 8
222
223
224## End, at least nothing major has changed ;-)
[5629]225##---------------------------------------------------
[5695]226get_out 0
Note: See TracBrowser for help on using the repository browser.