[6222] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | cd $( dirname $0 ) |
---|
| 5 | |
---|
| 6 | ## Set defaults |
---|
| 7 | ##--------------------------------------------------- |
---|
| 8 | TRUS_DIRE=$PWD |
---|
| 9 | TRUS_DBUG=0; TRUS_PROD=0; TRUS_HELP=0 |
---|
| 10 | ## No update on SVN directories & 'FAILED' result for 'Unknown error' ) |
---|
| 11 | TRUS_SVNA='svn status'; TRUS_RSLT='FAILED'; TRUS_RORR=0 |
---|
| 12 | xios_mode='--full'; stdout_redir='>&' |
---|
| 13 | rev=$( svn info | awk '(NR == 9) {print $NF}' ) |
---|
| 14 | |
---|
| 15 | |
---|
| 16 | ## Get options (replacing initials settings) |
---|
| 17 | ##--------------------------------------------------- |
---|
| 18 | while [ $# -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 |
---|
| 29 | done |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | ## Initialization (HPC & user environment) |
---|
| 33 | ##--------------------------------------------------- |
---|
| 34 | if [[ ! -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 |
---|
| 48 | else |
---|
| 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 | |
---|
| 63 | fi |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | ## Display contextual summary of trusting test |
---|
| 67 | ##--------------------------------------------------- |
---|
| 68 | echo |
---|
| 69 | if [ -t 0 ]; then cat ./inc/banner.txt; else cat ./inc/banner.html; fi |
---|
| 70 | echo |
---|
| 71 | echo '****************************************************************************************************' |
---|
| 72 | echo '* *' |
---|
| 73 | echo '* NEMO Trusting (Continuous Integration Tool) *' |
---|
| 74 | echo "* ver.$rev *" |
---|
| 75 | echo '* *' |
---|
| 76 | echo '****************************************************************************************************' |
---|
| 77 | echo |
---|
| 78 | printf "\t§ Testing configuration\t\t%s based on %s\n" ${TRUS_CONF} ${TRUS_REFE} |
---|
| 79 | printf "\t§ SVN working copy\t\t%s/%s\n" ${TRUS_WORK} ${TRUS_BRAN} |
---|
| 80 | printf "\t§ Benchmark folder\t\t%s\n" ${TRUS_STOR} |
---|
| 81 | printf "\t§ (Super)Computer\t\t%s\n" ${TRUS_HPCC} |
---|
| 82 | printf "\t§ User installation\t\t%s\n\n" ${TRUS_USER} |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | ## Make timestamped directory with messenger files |
---|
| 86 | ##--------------------------------------------------- |
---|
| 87 | print_step 'Timestamped testing directory' |
---|
| 88 | mkdir -p ${TRUS_SCRA} ${TRUS_STOR} |
---|
| 89 | cd ${TRUS_SCRA} |
---|
| 90 | echo ${TRUS_SCRA} |
---|
| 91 | init_files |
---|
| 92 | get_date |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | ## Get SVN revision on XIOS & NEMO essentials directories |
---|
| 96 | ##--------------------------------------------------- |
---|
| 97 | print_step "SVN action on NEMO directories: ${TRUS_SVNA}" |
---|
| 98 | get_nemo_rev |
---|
| 99 | |
---|
| 100 | |
---|
| 101 | ## Check softwares versions (after sourced arch environment) |
---|
| 102 | ##--------------------------------------------------- |
---|
| 103 | print_step 'Get testing environement' |
---|
| 104 | get_soft_rel |
---|
| 105 | cat model.log | awk '{printf "%-20s %s %s\n", $1, $2, $3}' |
---|
| 106 | env | sort > env.log |
---|
| 107 | |
---|
| 108 | |
---|
| 109 | ## XIOS compilation from scratch |
---|
| 110 | ##--------------------------------------------------- |
---|
| 111 | print_step 'Compile XIOS' |
---|
| 112 | cd ${TRUS_XIOS} |
---|
| 113 | eval ./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 | ##--------------------------------------------------- |
---|
| 120 | print_step "Compile ${TRUS_REFE} configuration" |
---|
| 121 | cd ${TRUS_NGCM}/CONFIG |
---|
| 122 | [[ -d ${TRUS_CONF} && ${TRUS_DBUG} -eq 0 ]] && ./makenemo -n ${TRUS_CONF} clean_config \ |
---|
| 123 | > /dev/null <<EOF |
---|
| 124 | y |
---|
| 125 | EOF |
---|
| 126 | |
---|
| 127 | eval ./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 | ##--------------------------------------------------- |
---|
| 135 | print_step 'Set job (copying or extracting inputs)' |
---|
| 136 | cd ${TRUS_SCRA} |
---|
| 137 | get_inputs |
---|
| 138 | cp ${TRUS_NGCM}/CONFIG/${TRUS_CONF}/cpp_* . |
---|
| 139 | find ${TRUS_NGCM}/CONFIG/${TRUS_CONF}/EXP00 -regex '.*\(_cfg\|.in\|opa\|_ref\|.xml\)' \ |
---|
| 140 | -exec cp {} . \; |
---|
| 141 | |
---|
| 142 | |
---|
| 143 | ## Check inputs |
---|
| 144 | ##--------------------------------------------------- |
---|
| 145 | print_step 'Compare inputs' |
---|
| 146 | diff_inputs |
---|
| 147 | |
---|
| 148 | |
---|
| 149 | ## Job submission & computation |
---|
| 150 | ##--------------------------------------------------- |
---|
| 151 | print_step 'Submit job' |
---|
| 152 | cp ${TRUS_DIRE}/batch/${TRUS_JSPT} ${TRUS_SCRA} ## Copy the submitting script to testing folder |
---|
| 153 | TRUS_JIDN=$( eval ${TRUS_JSUB} ) |
---|
| 154 | [ $? -ne 0 ] && get_out 4 || printf "Success (job ID %s)\n" ${TRUS_JIDN} |
---|
| 155 | print_step 'Pending job' |
---|
| 156 | job_pending |
---|
| 157 | print_step 'Job finished' |
---|
| 158 | |
---|
| 159 | |
---|
| 160 | ## Check job state & get computation performances if succeeded |
---|
| 161 | ##--------------------------------------------------- |
---|
| 162 | print_step 'Test job state' |
---|
| 163 | [[ ! -e time.step || $( grep 'E R R O R' ocean.output ) ]] && get_out 5 || echo 'Success' ## Must be reviewed |
---|
| 164 | print_step 'Get job performances' |
---|
| 165 | get_time |
---|
| 166 | get_memy |
---|
| 167 | |
---|
| 168 | |
---|
| 169 | ## Check outputs |
---|
| 170 | ##--------------------------------------------------- |
---|
| 171 | TRUS_RSLT='OK' ## 'OK' by default |
---|
| 172 | print_step 'Compare outputs' |
---|
| 173 | diff_results |
---|
| 174 | print_step 'Compare restarts' |
---|
| 175 | diff_restart |
---|
| 176 | [ $TRUS_RSLT == 'FAILED' ] && get_out 8 |
---|
| 177 | |
---|
| 178 | |
---|
| 179 | ## End, at least nothing has changed ;-) |
---|
| 180 | ##--------------------------------------------------- |
---|
| 181 | get_out 0 |
---|