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

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

Push modifications from functional Trusting in Curie HPC

  • Property eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Rev URL
File size: 6.6 KB
RevLine 
[5268]1#!/bin/bash
2
3
[5644]4cd $( dirname $0 )
5
[5629]6## Set defaults
7##---------------------------------------------------
[5799]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
[5788]12xios_mode='--full'; stdout_redir='>&'
[5799]13rev=$( svn info | awk '(NR == 9) {print $NF}' )
[5268]14
[5681]15
[5799]16## Get options (replacing initials settings)
[5629]17##---------------------------------------------------
[5268]18while [ $# -ne 0 ]; do
19    case $1 in
[5799]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  ;;
[5268]28    esac
29done
[5276]30
[5681]31
[5788]32## Initialization (HPC & user environment)
33##---------------------------------------------------
[8780]34if [[ ! -e cfg/${TRUS_USER}.cfg || ! -e cfg/${TRUS_HPCC}.cfg || ${TRUS_HELP} -eq 1 ]]; then
[5929]35    cat ./inc/trusting_help.txt
[5690]36
[5799]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"
[5788]42    fi
[5695]43
[5799]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"
[5788]47    exit 1
48else
[5929]49    . ./inc/trusting.env && . ./inc/trusting_func.sh
50
[5799]51    ## DEBUG option to speed up & expand verbosity of compilation
52    [ ${TRUS_DBUG} -eq 1 ] && { set -vx; xios_mode=''; stdout_redir='>'; }
[5268]53
[5788]54    ## If -v|--version option has been set, modify default SVN action on directories
[5799]55    if   [ $( echo ${TRUS_SVNV} | grep  "HEAD\|up\|update"                     ) ]; then
[5988]56   TRUS_SVNA='svn update -r HEAD --accept=theirs-conflict'
[5799]57    elif [ $( echo ${TRUS_SVNV} | grep -o '{[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}}' ) ]; then
[5809]58   TRUS_SVNA='svn update -r     '$( echo ${TRUS_SVNV} | grep -o '{[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}}' )
[5799]59    elif [ $( echo ${TRUS_SVNV} | grep -o '[0-9]*'                             ) ]; then
[5809]60   TRUS_SVNA='svn update -r     '$( echo ${TRUS_SVNV} | grep -o '[0-9]*' )
[5355]61    fi
[5268]62
[5355]63fi
[5268]64
65
[5690]66## Display contextual summary of trusting test
[5629]67##---------------------------------------------------
[5788]68echo
[5929]69if [ -t 0 ]; then cat ./inc/banner.txt; else cat ./inc/banner.html; fi
[5788]70echo
71echo '****************************************************************************************************'
72echo '*                                                                                                  *'
73echo '*                           NEMO Trusting (Continuous Integration Tool)                            *'
[5799]74echo "*                                             ver.$rev                                             *"
[5788]75echo '*                                                                                                  *'
76echo '****************************************************************************************************'
77echo
[5929]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}
[5644]83
[5681]84
[5690]85## Make timestamped directory with messenger files
[5644]86##---------------------------------------------------
[5695]87print_step 'Timestamped testing directory'
[5929]88mkdir -p ${TRUS_SCRA} ${TRUS_STOR}
89cd       ${TRUS_SCRA}
90echo     ${TRUS_SCRA}
[5695]91init_files
92get_date
[5355]93
[5681]94
[5690]95## Get SVN revision on XIOS & NEMO essentials directories
[5629]96##---------------------------------------------------
[5799]97print_step "SVN action on NEMO directories: ${TRUS_SVNA}"
[5695]98get_nemo_rev
[5444]99
[5681]100
[5690]101## Check softwares versions (after sourced arch environment)
[5629]102##---------------------------------------------------
[5788]103print_step 'Get testing environement'
[5695]104get_soft_rel
[5929]105cat model.log | awk '{printf "%-20s %s %s\n", $1, $2, $3}'
[5788]106env | sort > env.log
[5268]107
[5929]108
[5690]109## XIOS compilation from scratch
[5629]110##---------------------------------------------------
[5695]111print_step 'Compile XIOS'
[5799]112cd ${TRUS_XIOS}
[5788]113eval ./make_xios ${xios_mode} --arch ${TRUS_HPCC} --job ${TRUS_NPRO} \
114    ${stdout_redir} /dev/null
[5695]115[ ! -e lib/libxios.a ] && get_out 1 || echo 'Success'
[5444]116
[5690]117
118## NEMO compilation from scratch
[5629]119##---------------------------------------------------
[5788]120print_step "Compile ${TRUS_REFE} configuration"
[5799]121cd ${TRUS_NGCM}/CONFIG
122[[ -d ${TRUS_CONF} && ${TRUS_DBUG} -eq 0 ]] && ./makenemo -n ${TRUS_CONF} clean_config \
[5695]123    > /dev/null <<EOF
[5669]124y
125EOF
[5681]126
[5799]127eval ./makenemo -n ${TRUS_CONF} -r ${TRUS_REFE} -m ${TRUS_HPCC} -j ${TRUS_NPRO} \
128                ${TRUS_KEYA} ${TRUS_KEYD}                                       \
[5788]129    ${stdout_redir} /dev/null
[5799]130[ ! -e ${TRUS_CONF}/BLD/bin/nemo.exe ] && get_out 2 || echo 'Success'
[5268]131
[5681]132
[5690]133## Get all inputs for running
[5629]134##---------------------------------------------------
[5695]135print_step 'Set job (copying or extracting inputs)'
[5929]136cd ${TRUS_SCRA}
137get_inputs
[5799]138cp   ${TRUS_NGCM}/CONFIG/${TRUS_CONF}/cpp_* .
139find ${TRUS_NGCM}/CONFIG/${TRUS_CONF}/EXP00 -regex '.*\(_cfg\|.in\|opa\|_ref\|.xml\)' \
[5788]140                                            -exec  cp {} . \;
[5286]141
[5681]142
[5690]143## Check inputs
[5629]144##---------------------------------------------------
[5788]145print_step 'Compare inputs'
[5695]146diff_inputs
[5633]147
[5681]148
[5690]149## Job submission & computation
[5629]150##---------------------------------------------------
[5695]151print_step 'Submit job'
[5929]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}
[5695]155print_step 'Pending job'
156job_pending
[5455]157print_step 'Job finished'
158
[5681]159
[5788]160## Check job state & get computation performances if succeeded
[5629]161##---------------------------------------------------
[5472]162print_step 'Test job state'
[5929]163[[ ! -e time.step || $( grep 'E R R O R' ocean.output ) ]] && get_out 5 || echo 'Success' ## Must be reviewed
[5788]164print_step 'Get job performances'
165get_time
166get_memy
[5681]167
[5286]168
[5690]169## Check outputs
[5629]170##---------------------------------------------------
[5788]171TRUS_RSLT='OK' ## 'OK' by default
172print_step 'Compare outputs'
[5695]173diff_results
[5788]174print_step 'Compare restarts'
[5695]175diff_restart
[5788]176[ $TRUS_RSLT == 'FAILED' ] && get_out 8
[5286]177
[5268]178
[5690]179## End, at least nothing has changed ;-)
[5629]180##---------------------------------------------------
[5695]181get_out 0
Note: See TracBrowser for help on using the repository browser.