- Timestamp:
- 2017-11-28T15:01:16+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/trusting.sh
r8826 r8834 4 4 cd $( dirname $0 ) 5 5 6 ##-------------------------------------------------------------------------------- 6 7 ## Set flags & defaults 7 8 ##-------------------------------------------------------------------------------- … … 9 10 TRUST_MAIN_DIR=$PWD 10 11 11 TRUST_FLAG_DEBUG=0; TRUST_FLAG_PROD=0; TRUST_FLAG_HELP=0 12 TRUST_FLAG_RESULT='FAILED'; TRUST_FLAG_ERROR=0 12 TRUST_FLAG_DEBUG='false' ; TRUST_FLAG_HELP='false' ; TRUST_FLAG_PROD='false' 13 13 14 ## No update on SVN directories & 'FAILED' result for 'Unknown error' )15 TRUST_SVN_ACTION='svn status'16 17 xios_mode='--full'; stdout_redir='>&'18 14 rev=$( svn info | awk '(NR == 9) {print $NF}' ) 19 15 20 16 21 ## Get options (replacing initials settings) 17 ##-------------------------------------------------------------------------------- 18 ## Get arguments from command line 22 19 ##-------------------------------------------------------------------------------- 23 20 24 while [ $# -ne 0 ]; do21 while getopts a:b:de:f:j:hm:n:r:t:pu:v:w: arg; do 25 22 26 case $1 in 27 '-a'|'--archive') TRUST_IO_FORC_TAR=$2; shift 2;; '-b'|'--branch' ) TRUST_SVN_BRANCH=$2; shift 2;; 28 '-d'|'--debug' ) TRUST_FLAG_DEBUG=1 ; shift ;; '-e'|'--email' ) TRUST_TEST_MAILING=$2; shift 2;; 29 '-f'|'--forcdir') TRUST_IO_FORC_PATH=$2; shift 2;; '-j'|'--job' ) TRUST_COMPILE_NPROC=$2; shift 2;; 30 '-h'|'--help' ) TRUST_FLAG_HELP=1 ; shift ;; '-m'|'--machine') TRUST_MAIN_HPCC=$2; shift 2;; 31 '-n'|'--newconf') TRUST_CFG_NEW=$2; shift 2;; '-r'|'--refconf') TRUST_CFG_REF=$2; shift 2;; 32 '-t'|'--time' ) TRUST_JOB_TIMEOUT=$2; shift 2;; '-p'|'--prod' ) TRUST_FLAG_PROD=1 ; shift ;; 33 '-u'|'--user' ) TRUST_MAIN_USER=$2; shift 2;; '-v'|'--version') TRUST_SVN_REV=$2; shift 2;; 34 '-w'|'--workdir') TRUST_DIR_WORK=$2; shift 2;; "*" ) TRUST_FLAG_HELP=1 ; shift ;; 23 case $arg in 24 a) TRUST_IO_FORC_TAR=$OPTARG;; b) TRUST_SVN_BRANCH=$OPTARG;; 25 d) TRUST_FLAG_DEBUG='true' ;; e) TRUST_TEST_MAILING=$OPTARG;; 26 f) TRUST_IO_FORC_PATH=$OPTARG;; j) TRUST_COMPILE_NPROC=$OPTARG;; 27 h) TRUST_FLAG_HELP='true' ;; m) TRUST_MAIN_HPCC=$OPTARG;; 28 n) TRUST_CFG_NEW=$OPTARG;; r) TRUST_CFG_REF=$OPTARG;; 29 t) TRUST_JOB_TIMEOUT=$OPTARG;; p) TRUST_FLAG_PROD='true' ;; 30 u) TRUST_MAIN_USER=$OPTARG;; v) TRUST_SVN_REV=$OPTARG;; 31 w) TRUST_DIR_WORK=$OPTARG;; 32 :) echo 'Arg. needed for '$OPTARG && TRUST_FLAG_HELP='true' ;; 33 *) TRUST_FLAG_HELP='true' ;; 35 34 esac 36 35 … … 38 37 39 38 40 ## Initialization (HPC & user environment) 39 ##-------------------------------------------------------------------------------- 40 ## Initialization (user & HPC environment) 41 41 ##-------------------------------------------------------------------------------- 42 42 43 if [[ ! -e cfg/${TRUST_MAIN_USER}.cfg || ! -e cfg/${TRUST_MAIN_HPCC}.cfg || ${TRUST_FLAG_HELP} -eq 1 ]]; then 43 if [[ ! -e cfg/${TRUST_MAIN_USER}.cfg || ! -e cfg/${TRUST_MAIN_HPCC}.cfg \ 44 || ${TRUST_FLAG_HELP} == 'true' ]]; then 44 45 cat ./inc/trusting_help.txt 45 46 46 if [ ${TRUST_FLAG_HELP} -eq 0]; then47 if [ ${TRUST_FLAG_HELP} == 'false' ]; then 47 48 printf "\n\n\033[0;33m" 48 49 printf "At least one configuration (arch or user) file is missing or misspelled:" … … 56 57 exit 1 57 58 else 58 . ./inc/trusting.env && . ./inc/trusting_func.sh 59 ## Verbose output on debug mode 60 [ ${TRUST_FLAG_DEBUG} == 'true' ] && set -vx 59 61 60 ## DEBUG option to speed up & expand verbosity of compilation 61 [ ${TRUST_FLAG_DEBUG} -eq 1 ] && { set -vx; xios_mode=''; stdout_redir='>'; } 62 63 ## If -v|--version option has been set, modify default SVN action on directories 64 if [ $( echo ${TRUST_SVN_REV} | grep "HEAD\|up\|update" ) ]; then 65 TRUST_SVN_ACTION='svn update -r HEAD' 66 elif [ $( echo ${TRUST_SVN_REV} | grep -o '{[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}}' ) ]; then 67 TRUST_SVN_ACTION='svn update -r '$( echo ${TRUST_SVN_REV} | grep -o '{[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}}' ) 68 elif [ $( echo ${TRUST_SVN_REV} | grep -o '[0-9]*' ) ]; then 69 TRUST_SVN_ACTION='svn update -r '$( echo ${TRUST_SVN_REV} | grep -o '[0-9]*' ) 70 fi 62 . ./inc/trusting.env 63 . ./inc/trusting_func.sh 71 64 72 65 fi 73 66 74 67 75 ## Display contextual summary of trusting test 68 ##-------------------------------------------------------------------------------- 69 ## Trusting workflow 76 70 ##-------------------------------------------------------------------------------- 77 71 72 ## Display summary of test 73 ##------------------------ 74 78 75 echo 79 80 76 if [ -t 0 ]; then cat ./inc/banner.txt; else cat ./inc/banner.html; fi 81 82 77 echo 83 78 echo '****************************************************************************************************' … … 91 86 printf "\t§ User installation\t\t%s\n\n" ${TRUST_MAIN_USER} 92 87 echo 93 printf "\t§ Testing configuration\t\t%s based on %s\n" ${TRUST_CFG_NEW} ${TRUST_CFG_REF} 94 printf "\t§ SVN working copy\t\t%s/%s\n" ${TRUST_DIR_WORK} ${TRUST_SVN_BRANCH} 88 printf "\t§ Testing configuration\t\t%s based on %s\n" \ 89 ${TRUST_CFG_NEW} ${TRUST_CFG_REF} 90 printf "\t§ SVN working copy\t\t%s/%s\n" \ 91 ${TRUST_DIR_WORK} ${TRUST_SVN_BRANCH} 95 92 if [ ${TRUST_TEST_BENCHMARK} ]; then 96 93 printf "\t§ Benchmark folder\t\t%s\n" ${TRUST_TEST_BENCHMARK} … … 98 95 99 96 100 ## Make timestamped directory with messenger files101 ##------------------ --------------------------------------------------------------97 ## Testing directory 98 ##------------------ 102 99 103 100 print_step 'Timestamped testing directory' 104 105 mkdir -p ${TRUST_TEST_DIR} ${TRUST_TEST_BENCHMARK} || get_out B 106 cd ${TRUST_TEST_DIR} 107 echo ${TRUST_TEST_DIR} 108 109 init_files 110 111 get_date 101 init 112 102 113 103 114 ## Get SVN revision on XIOS & NEMO essentials directories115 ##------------------- -------------------------------------------------------------104 ## Local working copy 105 ##------------------- 116 106 117 print_step "SVN action on NEMO directories: ${TRUST_SVN_ACTION}"118 107 print_step 'SVN action on NEMO directories' 108 echo "${TRUST_SVN_ACTION} on ${TRUST_SVN_NEMOGCM}:" 119 109 get_nemo_rev 120 110 121 111 122 ## Check softwares versions (after sourced arch environment)123 ##------------ --------------------------------------------------------------------112 ## Environment 113 ##------------ 124 114 125 115 print_step 'Get testing environment' 126 127 116 get_soft_rel 128 117 129 cat model.log | awk '{printf "%-20s %s %s\n", $1, $2, $3}' 130 env | sort > env.log 118 119 ## Compilation(s) 120 ##--------------- 121 122 print_step 'Compile XIOS' 123 compile_xios 124 125 print_step "Compile ${TRUST_CFG_REF} configuration" 126 compile_nemo 131 127 132 128 133 ## XIOS compilation from scratch 134 ##-------------------------------------------------------------------------------- 135 136 print_step 'Compile XIOS' 137 138 cd ${TRUST_IO_XIOS} 139 140 eval ./make_xios ${xios_mode} --arch ${TRUST_MAIN_HPCC} --job ${TRUST_COMPILE_NPROC} \ 141 ${stdout_redir} /dev/null 142 143 [ ! -e lib/libxios.a ] && get_out D || echo 'Success' 144 145 146 ## NEMO compilation from scratch 147 ##-------------------------------------------------------------------------------- 148 149 print_step "Compile ${TRUST_CFG_REF} configuration" 150 151 cd ${TRUST_SVN_NEMOGCM}/CONFIG 152 153 if [[ -d ${TRUST_CFG_NEW} && ${TRUST_FLAG_DEBUG} -eq 0 ]]; then 154 ./makenemo -n ${TRUST_CFG_NEW} clean_config \ 155 > /dev/null <<EOF 156 y 157 EOF 158 fi 159 160 eval ./makenemo -n ${TRUST_CFG_NEW} -r ${TRUST_CFG_REF} \ 161 -m ${TRUST_MAIN_HPCC} -j ${TRUST_COMPILE_NPROC} \ 162 ${TRUST_CFG_KEY_ADD} ${TRUST_CFG_KEY_DEL} \ 163 ${stdout_redir} /dev/null 164 165 [ ! -e ${TRUST_CFG_NEW}/BLD/bin/nemo.exe ] && get_out E || echo 'Success' 166 167 168 ## Get all inputs for running 169 ##-------------------------------------------------------------------------------- 129 ## Inputs 130 ##------- 170 131 171 132 print_step 'Set job (copying or extracting inputs)' 172 173 cd ${TRUST_TEST_DIR}174 175 133 get_inputs 176 134 177 cp ${TRUST_SVN_NEMOGCM}/CONFIG/${TRUST_CFG_NEW}/cpp_* .178 find ${TRUST_SVN_NEMOGCM}/CONFIG/${TRUST_CFG_NEW}/EXP00 \179 -regex '.*\(_cfg\|.in\|opa\|_ref\|.xml\)' \180 -exec cp {} . \;181 182 183 ## Check inputs184 ##--------------------------------------------------------------------------------185 186 135 print_step 'Compare inputs' 187 188 136 diff_inputs 189 137 190 138 191 ## Job submission & computation192 ##---- ----------------------------------------------------------------------------139 ## Job 140 ##---- 193 141 194 142 print_step 'Submit job' 195 196 ## Copy the submitting script to testing folder 197 cp ${TRUST_JOB_SCRIPT} ${TRUST_TEST_DIR} 198 TRUST_JOB_ID=$( eval ${TRUST_JOB_SUBMIT} ) 199 200 [ $? -ne 0 ] && get_out G || printf "Success (job ID %s)\n" ${TRUST_JOB_ID} 143 job_submit 201 144 202 145 print_step 'Pending job' 203 204 146 job_pending 205 147 206 148 print_step 'Job finished' 207 149 208 209 ## Check job state & get computation performances if succeeded210 ##--------------------------------------------------------------------------------211 212 150 print_step 'Test job state' 213 214 if [[ ! -e time.step || $( grep 'E R R O R' ocean.output ) ]]; then 215 get_out H 216 else 217 echo 'Success' ## Must be reviewed 218 fi 151 job_state 219 152 220 153 print_step 'Get job performances' 221 222 get_time 223 224 get_memy 154 job_perfs 225 155 226 156 227 ## Check outputs 228 ##-------------------------------------------------------------------------------- 229 230 TRUST_FLAG_RESULT='OK' ## 'OK' by default 157 ## Outputs 158 ##-------- 231 159 232 160 print_step 'Compare outputs' 233 234 161 diff_results 235 162 236 163 print_step 'Compare restarts' 237 238 164 diff_restarts 239 240 [ $TRUST_FLAG_RESULT= == 'FAILED' ] && get_out L241 165 242 166 243 167 ## End, at least nothing major has changed ;-) 244 ##-------------------------------------------- ------------------------------------168 ##-------------------------------------------- 245 169 246 170 get_out 0
Note: See TracChangeset
for help on using the changeset viewer.