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.
Changeset 5695 for branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting_func.sh – NEMO

Ignore:
Timestamp:
2015-08-17T20:12:12+02:00 (9 years ago)
Author:
nicolasmartin
Message:

dev_r5092_CNRS_SETTE return svn cmd to main script; add variable for CDO diff operator; correct exit sequence

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting_func.sh

    r5690 r5695  
    11#!/bin/bash 
    22 
    3  
    4 mkdir -p ${TEST_DIR} ${REFE_DIR} 
    53 
    64## Messenger filenames 
     
    4543 
    4644get_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 
    6047 
    6148    ## Loop on essential directories 
     
    7562   fi 
    7663 
    77    echo $dir 
    78    ${svn_cmd} $dir 
     64   echo $dir && ${SVN_CMD} $dir 
    7965   rev_loc=$( svn info $dir | awk '(NR == 9) {print $NF}' ) 
    8066 
     
    9177 
    9278get_soft_rel() { 
    93     local soft_rel 
     79    local soft soft_rel 
    9480 
    9581    for soft in $CDO $COMPILER $MPI $NETCDF; do 
     
    129115 
    130116get_inputs() { 
    131     # List archive content & extract by default 
     117    # List archive content & extract it by default 
    132118    local cmd_iol="tar -tvf ${NEMO_FORC}/${NEMO_TARF}" cmd_iof="tar -vxf ${NEMO_FORC}/${NEMO_TARF}" 
    133119 
    134     ## List & copy file in case of personal inputs 
     120    ## List & copy files in case of personal inputs 
    135121    [ -z "${NEMO_TARF}" ] && cmd_iol="ls ${NEMO_FORC}/*" && cmd_iof="\cp ${NEMO_FORC}/* ." 
    136122 
     
    141127 
    142128diff_inputs() { 
    143     local dif 
     129    local dif file 
    144130    local files_list='' mesg='Same'  
    145131 
     
    152138 
    153139   ## Pass over useless file omission in benckmark directory 
    154    if [ -n "$dif" && "$dif" != '0' ]; then 
     140   if [[ -n "$dif" && "$dif" != '0' ]]; then 
    155141       mesg='Different'; echo $dif; files_list+=$file' ' 
    156142   fi 
     
    186172 
    187173    ## 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 
    192175} 
    193176 
    194177 
    195178diff_results() { 
     179    local file 
    196180    local files_list='' 
    197181 
     
    215199 
    216200diff_restart() { 
    217     local base_name dif file list_comp list_tmsp nb_dom 
     201    local base_name comp dif file list_comp list_tmsp nb_dom time_step tmsp 
    218202    local files_list='' dift=0 
    219203 
    220     ## Stop if no benchmark files (time.step) 
     204    ## Stop if no benchmark files (ie time.step) 
    221205    [ ! -e ${REFE_DIR}/time.step ] && export ST='FAILED' && get_out 7 
    222  
    223206    time_step=$( cat ${REFE_DIR}/time.step | tr -d [:space:] ) 
    224     echo 'Last time step of benchmark run: '${time_step} 
    225207 
    226208    ## Find all restart files to rebuild 
     
    253235 
    254236                   ## 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 on stdout with no difference 
     237         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 
    259241         if [[ -n "$dif" && $( echo $dif | awk '{print $1}' ) -ne 0 ]]; then 
    260242             export ST='FAILED' && files_list+=$file' ' 
     
    277259   if [ $dift -ne 0 ]; then 
    278260       echo 'Restarts: '${files_list}$dift' record(s) differ<br>' | tee -a temp_${FILE_COMM} 
    279    else  
    280        echo 'No restart differ' 
    281261   fi 
    282262 
     
    297277 
    298278comments() { 
    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 
    310292    printf "$line<br>"      \ 
    311293   >> temp_${FILE_COMM} 
     
    364346 
    365347get_out() { 
     348    local time_step=0 
     349 
    366350    ERR=$1 
    367  
    368     cd ${TEST_DIR} 
     351    cd ${TEST_DIR} ## In case of compilation error 
    369352 
    370353    if [ $ST == 'FAILED' ]; then 
     354   echo 'Failure' 
    371355 
    372356        ## Error identification 
    373357   case $ERR in 
    374        ## Compilation 
    375        1) ERR='XIOS compilation failed' ;; 2) ERR='NEMO compilation failed';; 
     358            ## Compilation 
     359       '1') ERR='XIOS compilation failed' ;; '2') ERR='NEMO compilation failed';; 
    376360       ## Submission 
    377        3) ERR='Missing input files'     ;; 4) ERR='Job submission error'   ;; 
     361       '3') ERR='Missing input files'     ;; '4') ERR='Job submission error'   ;; 
    378362       ## 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'    ;; 
    380364       ## Results 
    381        7) ERR='Missing previous outputs';; 8) ERR='New outputs differ'     ;; 
     365       '7') ERR='Missing previous outputs';; '8') ERR='New outputs differ'     ;; 
    382366       ## Undefined 
    383        *) ERR='Unknown error'           ;; 
     367       "*") ERR='Unknown error'           ;; 
    384368   esac 
    385369 
    386     fi 
     370    else 
     371   ERR='Code is reliable' 
     372    fi 
     373 
     374    print_step '' 
    387375 
    388376    ## 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 
    401386    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} 
    404388 
    405389    ## Save tested configuration if trusting failed in production mode (-p|--publish) 
    406     if [[ $ST == 'FAILED' && $PUBLISH -eq 1 && $DEBUG -eq 0 ]]; then 
     390    if [[ $ST == 'FAILED' && $PUBLISH -eq 1 ]]; then 
    407391   echo 'Creating archive '${FILE_ARCH}' under '${REFE_DIR} 
    408392   tar -czf ${REFE_DIR}/${FILE_ARCH} * ${NEMO_HOME}/CONFIG/${TEST_CONF}/MY_SRC \ 
     
    410394    fi 
    411395 
    412     ##  
    413     print_step 'Trusting outcome'; mesg_make; mesg_publish 
     396    ## Share trusting result (.txt file/mail) 
     397    mesg_make 
     398    mesg_publish 
    414399 
    415400    exit 0 
Note: See TracChangeset for help on using the changeset viewer.