- Timestamp:
- 2015-08-17T20:12:12+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting_func.sh
r5690 r5695 1 1 #!/bin/bash 2 2 3 4 mkdir -p ${TEST_DIR} ${REFE_DIR}5 3 6 4 ## Messenger filenames … … 45 43 46 44 get_nemo_rev() { 47 local rev_loc svn_cmd 48 local rev=0 svn_opt='status' 49 50 ## If -v|--version option has been set, modify svn command 51 if [ $( echo ${NEMO_VERS} | grep "HEAD\|up\|update" ) ]; then 52 svn_cmd='svn update -r HEAD' 53 elif [ $( echo ${NEMO_VERS} | grep -o '{[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}}' ) ]; then 54 svn_cmd='svn update -r '$( echo ${NEMO_VERS} | grep -o '{[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}}' ) 55 elif [ $( echo ${NEMO_VERS} | grep -o '[0-9]*' ) ]; then 56 svn_cmd='svn update -r '$( echo ${NEMO_VERS} | grep -o '[0-9]*' ) 57 else 58 svn_cmd='svn '${svn_opt} 59 fi 45 local dir rev_loc 46 local rev=0 60 47 61 48 ## Loop on essential directories … … 75 62 fi 76 63 77 echo $dir 78 ${svn_cmd} $dir 64 echo $dir && ${SVN_CMD} $dir 79 65 rev_loc=$( svn info $dir | awk '(NR == 9) {print $NF}' ) 80 66 … … 91 77 92 78 get_soft_rel() { 93 local soft _rel79 local soft soft_rel 94 80 95 81 for soft in $CDO $COMPILER $MPI $NETCDF; do … … 129 115 130 116 get_inputs() { 131 # List archive content & extract by default117 # List archive content & extract it by default 132 118 local cmd_iol="tar -tvf ${NEMO_FORC}/${NEMO_TARF}" cmd_iof="tar -vxf ${NEMO_FORC}/${NEMO_TARF}" 133 119 134 ## List & copy file in case of personal inputs120 ## List & copy files in case of personal inputs 135 121 [ -z "${NEMO_TARF}" ] && cmd_iol="ls ${NEMO_FORC}/*" && cmd_iof="\cp ${NEMO_FORC}/* ." 136 122 … … 141 127 142 128 diff_inputs() { 143 local dif 129 local dif file 144 130 local files_list='' mesg='Same' 145 131 … … 152 138 153 139 ## Pass over useless file omission in benckmark directory 154 if [ -n "$dif" && "$dif" != '0']; then140 if [[ -n "$dif" && "$dif" != '0' ]]; then 155 141 mesg='Different'; echo $dif; files_list+=$file' ' 156 142 fi … … 186 172 187 173 ## Kill remaining job & stop the test if it's too long 188 if [ ${time_elapsed} -eq ${TIME_LIMI} ]; then 189 ${JOB_DELE} ${JOB_ID} &> /dev/null 190 get_out 6 191 fi 174 [ ${time_elapsed} -eq ${TIME_LIMI} ] && ${JOB_DELE} ${JOB_ID} &> /dev/null && get_out 6 192 175 } 193 176 194 177 195 178 diff_results() { 179 local file 196 180 local files_list='' 197 181 … … 215 199 216 200 diff_restart() { 217 local base_name dif file list_comp list_tmsp nb_dom201 local base_name comp dif file list_comp list_tmsp nb_dom time_step tmsp 218 202 local files_list='' dift=0 219 203 220 ## Stop if no benchmark files ( time.step)204 ## Stop if no benchmark files (ie time.step) 221 205 [ ! -e ${REFE_DIR}/time.step ] && export ST='FAILED' && get_out 7 222 223 206 time_step=$( cat ${REFE_DIR}/time.step | tr -d [:space:] ) 224 echo 'Last time step of benchmark run: '${time_step}225 207 226 208 ## Find all restart files to rebuild … … 253 235 254 236 ## UNIX `cmp` not suitable (timestamp in .nc file) 255 dif=$( $CDO diffn $file.nc ${REFE_DIR}/$file.nc 2> /dev/null\256 | awk '/records/ {print $0}' | sed '2 s/^/,/' | tr -d '\n' 257 258 ## CDO can return no output onstdout with no difference237 dif=$( $CDOD $file.nc ${REFE_DIR}/$file.nc 2> /dev/null \ 238 | awk '/records/ {print $0}' | sed '2 s/^/,/' | tr -d '\n' ) 239 240 ## CDO can return void stdout with no difference 259 241 if [[ -n "$dif" && $( echo $dif | awk '{print $1}' ) -ne 0 ]]; then 260 242 export ST='FAILED' && files_list+=$file' ' … … 277 259 if [ $dift -ne 0 ]; then 278 260 echo 'Restarts: '${files_list}$dift' record(s) differ<br>' | tee -a temp_${FILE_COMM} 279 else280 echo 'No restart differ'281 261 fi 282 262 … … 297 277 298 278 comments() { 299 local opt 300 local state=$1 301 302 ## 'W A R N I N G' by default 303 opt='-A2 "^ $state"' 304 [ "$state" == 'E R R O R' ] && opt="-A4 $state" 305 306 ## Select first occurence for web comment 307 line=$( grep -m1 $opt ocean.output | tr -d '\n' ) 308 309 echo $line 279 local opat 280 local line='' state=$1 281 282 if [ -e ocean.output ]; then 283 ## 'W A R N I N G' by default 284 opat="-A2 '^ $state'" 285 [ "$state" == 'E R R O R' ] && opat="-A4 '$state'" 286 287 ## Select first occurence for web comment 288 line=$( grep -m1 $opat ocean.output | tr -d '\n' ) 289 echo $line 290 fi 291 310 292 printf "$line<br>" \ 311 293 >> temp_${FILE_COMM} … … 364 346 365 347 get_out() { 348 local time_step=0 349 366 350 ERR=$1 367 368 cd ${TEST_DIR} 351 cd ${TEST_DIR} ## In case of compilation error 369 352 370 353 if [ $ST == 'FAILED' ]; then 354 echo 'Failure' 371 355 372 356 ## Error identification 373 357 case $ERR in 374 375 1) ERR='XIOS compilation failed' ;; 2) ERR='NEMO compilation failed';;358 ## Compilation 359 '1') ERR='XIOS compilation failed' ;; '2') ERR='NEMO compilation failed';; 376 360 ## Submission 377 3) ERR='Missing input files' ;; 4) ERR='Job submission error' ;;361 '3') ERR='Missing input files' ;; '4') ERR='Job submission error' ;; 378 362 ## Running 379 5) ERR='Crashed at time step' ;; 6) ERR='Exceeded time limit' ;;363 '5') ERR='Crashed at time step' ;; '6') ERR='Exceeded time limit' ;; 380 364 ## Results 381 7) ERR='Missing previous outputs';; 8) ERR='New outputs differ' ;;365 '7') ERR='Missing previous outputs';; '8') ERR='New outputs differ' ;; 382 366 ## Undefined 383 *) ERR='Unknown error' ;;367 "*") ERR='Unknown error' ;; 384 368 esac 385 369 386 fi 370 else 371 ERR='Code is reliable' 372 fi 373 374 print_step '' 387 375 388 376 ## Eventual comments from ocean.output 389 print_step 'Comments' 390 if [ -e ocean.output ]; then 391 if [ $ERR -eq 5 ]; then 392 comments 'E R R O R' 393 [ -e time.step ] && ERR+=' '$( cat time.step | tr -d ' ' ) 394 else 395 comments 'W A R N I N G' 396 [ $ERR -eq 6 ] && ERR+=' '$(( ${TIME_LIMIT}/3600 ))'h' 397 fi 398 fi 399 400 ## Share trusting result (locally or not) 377 if [ "$ERR" == 'Crashed at time step' ]; then 378 comments 'E R R O R' 379 [ -e time.step ] && time_step=$( cat time.step | tr -d ' ' ) 380 ERR+=' '$time_step 381 else 382 comments 'W A R N I N G' 383 [ "$ERR" == 'Exceeded time limit' ] && ERR+=' '$(( ${TIME_LIMIT}/3600 ))'h' 384 fi 385 401 386 export ERR 402 sed -i "2 s/.*/$ST/" ${FILE_STAT} 403 sed -i "2 s/.*/$ERR/" ${FILE_RESU} 387 sed -i "2 s/.*/$ST/" ${FILE_STAT}; sed -i "2 s/.*/$ERR/" ${FILE_RESU} 404 388 405 389 ## Save tested configuration if trusting failed in production mode (-p|--publish) 406 if [[ $ST == 'FAILED' && $PUBLISH -eq 1 && $DEBUG -eq 0]]; then390 if [[ $ST == 'FAILED' && $PUBLISH -eq 1 ]]; then 407 391 echo 'Creating archive '${FILE_ARCH}' under '${REFE_DIR} 408 392 tar -czf ${REFE_DIR}/${FILE_ARCH} * ${NEMO_HOME}/CONFIG/${TEST_CONF}/MY_SRC \ … … 410 394 fi 411 395 412 ## 413 print_step 'Trusting outcome'; mesg_make; mesg_publish 396 ## Share trusting result (.txt file/mail) 397 mesg_make 398 mesg_publish 414 399 415 400 exit 0
Note: See TracChangeset
for help on using the changeset viewer.