Ignore:
Timestamp:
2015-06-18T23:02:31+02:00 (5 years ago)
Author:
nicolasmartin
Message:

dev_r5092_CNRS_SETTE Increase trusting main script clarity with new functions

File:
1 edited

Legend:

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

    r5432 r5438  
    22 
    33 
     4comments() { 
     5    echo 'Comments'      | tee    mesg_10_comments_${CFG_USER}_${CFG_ARCH}.txt 
     6    grep $1 ocean.output | tee -a mesg_10_comments_${CFG_USER}_${CFG_ARCH}.txt 
     7} 
     8 
     9get_cpu_time() { 
     10    # Portability ! 
     11    real_cpu_time=$( ${JOB_VIEW} ${job_num} | awk 'END{print $9}' ) 
     12    printf "Real CPU time\n%s\n" ${real_cpu_time} | tee mesg_08_realcputime_${CFG_USER}_${CFG_ARCH}.txt 
     13} 
     14 
    415diff_inputs() { 
     16    mesg='Same' 
     17 
    518    for file in inputs_list.txt $( ls namelist_* ) iodef.xml; do 
    619   diff $file ${REFE_DIR}/$file 
    7  
    8    if [ $? -ne 0 ]; then 
    9        printf "Input files\nDifferent" | tee mesg_09_inputfiles_${CFG_USER}_${CFG_ARCH}.txt 
    10        get_out 
    11    fi 
    12  
     20   [ $? -ne 0 ] && mesg='Different' 
    1321    done 
    1422 
    15     printf "Input files\nSame"              | tee mesg_09_inputfiles_${CFG_USER}_${CFG_ARCH}.txt 
     23    printf "Input files\n$mesg" | tee mesg_09_inputfiles_${CFG_USER}_${CFG_ARCH}.txt 
    1624} 
    1725 
    18 diff_nc() { 
    19     stat=100; file1=$1; file2=$2 
    20  
    21     $CDO diffv $file1 $file2 > out_tmp 
    22     ( [ $? -ne 0 ] && stat=100 ) || stat=$( grep -m 1 'records differ' out_tmp | awk -Fof '{print $1}' ) 
    23     [ -f out_tmp ] && rm out_tmp 
    24  
    25     return $stat 
    26 }  
    27  
    2826diff_restart() { 
    29     result=0 
    3027    last_time_step=$( cat ${REFE_DIR}/time.step | tr -d [:space:] ) 
    31     echo 'Last time step: '${last_time_step} 
     28    echo 'Last time step of standard run: '${last_time_step} 
    3229 
    3330    if [ $( find ${TEST_DIR} -name "*${last_time_step}_restart*.nc" -print -quit ) ]; then 
    34    basename=$( find ${TEST_DIR} -name "*${last_time_step}_restart*.nc" -print -quit \ 
    35                 | sed "s/^\(.*\)$last_time_step\_.*/\1$last_time_step/"              ) 
     31   base_name=$( find ${TEST_DIR} -name "*${last_time_step}_restart*.nc" -print -quit          \ 
     32                | awk -F/ '{print $NF}' | sed "s/^\(.*\)$last_time_step\_.*/\1$last_time_step/" ) 
    3633 
    3734   for comp in restart restart_ice restart_trc; do 
    38        printf "${TEST_DIR}/${basename}_${comp}*.nc: " 
     35       printf "${base_name}_${comp}.nc: " 
    3936 
    40        nb_dom=$( find ${TEST_DIR} -name "${basename}_${comp}_[0-9]*.nc" | wc -l | awk '{print $1}' ) 
     37       nb_dom=$( find ${TEST_DIR} -name "${base_name}_${comp}_[0-9]*.nc" | wc -l | awk '{print $1}' ) 
    4138       if [ ${nb_dom} -gt 1 ]; then 
    42       ${NEMO_TRBD}/rebuild_nemo -t $NPROC ${basename}_$comp ${nb_dom} >/dev/null 
     39      ${NEMO_TRBD}/rebuild_nemo -t $NPROC ${base_name}_$comp ${nb_dom} > /dev/null 
    4340       fi 
    4441 
    45        cmp ${TEST_DIR}/${basename}_$comp.nc ${REFE_DIR}/${basename}_$comp.nc 
     42       cmp ${TEST_DIR}/${base_name}_$comp.nc ${REFE_DIR}/${base_name}_$comp.nc 
    4643       if [ $? -ne 0 ]; then 
    47       result=$( diff_nc ${TEST_DIR}/${basename}_$comp.nc ${REFE_DIR}/${basename}_$comp.nc ) 
    48       printf "$CDO diffv $result\n" 
     44      status='FAILED' 
     45      printf "$CDO diffn\n" 
     46      $CDO diffn ${TEST_DIR}/${base_name}_$comp.nc ${REFE_DIR}/${base_name}_$comp.nc 2> /dev/null 
    4947       else 
    5048      printf "identical\n" 
    5149       fi 
    52 #      \rm *${last_time_step}_${comp}_[0-9]*.nc 
     50 
     51       \rm  ${TEST_DIR}/${base_name}_${comp}_[0-9]*.nc 
    5352   done 
    5453 
     
    6059get_soft_rel() { 
    6160    for rel in $CDO $COMPILER $MPI $NETCDF; do 
    62                                  arch_rel=$( echo $LOADEDMODULES | sed "s#.*$rel/\([^:]*\).*#\1#" ) 
    63    [ -z "${arch_rel}"  ] && arch_rel=$( echo $PATH          | sed "s#.*$rel/\([^/]*\).*#\1#" ) 
    64    [ $rel == $COMPILER ] && arch_rel=$( $rel --version | grep -m1 -o ' [0-9.]* ' ) 
     61                                 arch_rel=$( echo $LOADEDMODULES | sed  "s#.*$rel/\([^:]*\).*#\1#" ) 
     62   [ -z "${arch_rel}"  ] && arch_rel=$( echo $PATH          | sed  "s#.*$rel/\([^/]*\).*#\1#" ) 
     63   [ $rel == $COMPILER ] && arch_rel=$( $rel --version      | grep -m1 -o ' [0-9.]* '        ) 
    6564   echo $rel ${arch_rel} >> model.log 
    6665    done 
     66 
     67    sed -n 2p model.log | sed 'i\Compiler'    | tee mesg_05_compiler_${CFG_USER}_${CFG_ARCH}.txt 
     68    sed -n 3p model.log | sed 'i\MPI libs'    | tee mesg_06_mpi_${CFG_USER}_${CFG_ARCH}.txt 
     69    sed -n 4p model.log | sed 'i\NetCDF libs' | tee mesg_07_netcdf_${CFG_USER}_${CFG_ARCH}.txt 
    6770} 
    6871 
     
    7073    rev=0 
    7174 
     75    # If -v|--version option has been set, modify svn command 
     76    if   [ $( echo ${NEMO_VERS} | grep  "up\|update"         ) ]; then SVN_OPT='update' 
     77    elif [ $( echo ${NEMO_VERS} | tr -d '[:alpha:][:punct:]' ) ]; then SVN_OPT='checkout' 
     78   rev=$( echo ${NEMO_VERS} | tr -d '[:alpha:][:punct:]' ) 
     79    fi 
     80 
    7281    for dir in ${DIR_XIOS}  ${NEMO_ARCH} ${NEMO_CONF} ${NEMO_ENGI} ${NEMO_EIOI} \ 
    7382          ${NEMO_EFCM} ${NEMO_TRUS} ${NEMO_TCMP} ${NEMO_TRBD}               ; do 
     83 
    7484   # For time being, just get revision number from XIOS 
    75    [ $dir == ${DIR_XIOS} ] && echo 'XIOS '$( svn info $dir | awk '(NR == 9) {print $NF}' ) >> model.log && continue 
    76    ${SVN_CMD} $dir 
     85   if [ $dir == ${DIR_XIOS} ]; then 
     86       echo 'XIOS '$( svn info $dir | awk '(NR == 9) {print $NF}' ) >> model.log 
     87       continue 
     88   fi 
     89 
     90   #  
     91   if [ $( echo ${SVN_OPT} | grep 'checkout' ) ]; then 
     92       cd ../$dir  
     93       url=$( svn info $dir | grep URL | awk '{print $NF}' ) 
     94       svn ${SVN_OPT} $url -r $rev $dir && cd - 
     95   else 
     96       svn ${SVN_OPT} $dir 
     97   fi 
     98 
    7799   rev_loc=$( svn info $dir | awk '(NR == 5) {print $NF}' ) 
    78100   (( ${rev_loc} >= $rev )) && rev=${rev_loc} 
     
    80102 
    81103    echo 'NEMO '$rev >> model.log 
     104    sed -n 6p model.log | sed 'i\NEMOGCM rev.' | tee mesg_02_nemo_${CFG_USER}_${CFG_ARCH}.txt 
    82105} 
    83106 
    84107mesg_make() { 
    85108    paste -d ';' mesg_*_${CFG_USER}_${CFG_ARCH}.txt > trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt 
    86     cat trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt 
     109    cat                                               trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt 
    87110} 
    88111 
     
    115138} 
    116139 
     140pstep() { 
     141    printf "Step.....\n$1\n" 
     142} 
     143 
    117144get_out() { 
     145    step=$1; status=$2 
    118146    mesg_make; mesg_publish 
    119147 
    120148    # Save tested configuration if trusting failed 
    121149    if [ $status == 'FAILED' ]; then 
     150   touch mesg_08_realcputime_${CFG_USER}_${CFG_ARCH}.txt mesg_10_comments_${CFG_USER}_${CFG_ARCH}.txt 
    122151   cd ${REFE_DIR} 
    123152   tar -czf trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.tar.gz ${TEST_DIR}/* 
    124153   cd - 
    125154    fi 
    126     
     155 
     156    printf "Status\n$status\n"  > mesg_03_status_${CFG_USER}_${CFG_ARCH}.txt 
     157    printf "Step.....\n$step\n" > mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt 
     158 
    127159    exit 1 
    128160} 
Note: See TracChangeset for help on using the changeset viewer.