Changeset 8834


Ignore:
Timestamp:
2017-11-28T15:01:16+01:00 (3 years ago)
Author:
nicolasmartin
Message:

Cleaning of main script 'trusting.sh': transfer code lines to 'trusting_func.sh' with new functions, improve overall readability

Location:
branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/inc/trusting.env

    r8826 r8834  
    22 
    33 
     4##-------------------------------------------------------------------------------- 
    45## Defaults 
    56##-------------------------------------------------------------------------------- 
    67 
     8## Trusting result: 'FAILED' result for 'Unknown error' 
     9export TRUST_FLAG_RESULT='FAILED' TRUST_FLAG_ERROR='X' 
     10 
     11## Locked options from command line (export as of now to environment)  
     12##------------------------------------------------------------------- 
     13 
     14if [ ${TRUST_FLAG_DEBUG} == 'true' ]; then 
     15    ## debug mode (verbose output and skip XIOS compilation) 
     16    TRUST_IO_XIOS_MODE='' 
     17    TRUST_MAIN_STDOUT='1> /dev/null' 
     18else 
     19    ## std mode (merge stdout & stderr to /dev/null, XIOS compilation from scratch) 
     20    TRUST_IO_XIOS_MODE='--full' 
     21    TRUST_MAIN_STDOUT='>& /dev/null' 
     22fi 
     23 
     24export TRUST_IO_XIOS_MODE TRUST_MAIN_STDOUT 
     25 
     26## If '-v' arg. has been set, modify default SVN action on working copy 
     27if [ ${TRUST_SVN_REV} ]; then 
     28 
     29    if   [ $( echo ${TRUST_SVN_REV} | grep  "HEAD\|up\|update"                     ) ]; then 
     30   TRUST_SVN_ACTION='svn update -r HEAD --accept mine-conflict' 
     31    elif [ $( echo ${TRUST_SVN_REV} | grep -o '{[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}}' ) ]; then 
     32   TRUST_SVN_ACTION='svn update -r     '$( echo ${TRUST_SVN_REV} | grep -o '{[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}}' ) 
     33    elif [ $( echo ${TRUST_SVN_REV} | grep -o '[0-9]*'                             ) ]; then 
     34   TRUST_SVN_ACTION='svn update -r     '$( echo ${TRUST_SVN_REV} | grep -o '[0-9]*' ) 
     35    fi 
     36 
     37else 
     38    ## By default, no update on SVN directories 
     39    TRUST_SVN_ACTION='svn status' 
     40fi 
     41 
     42export TRUST_SVN_ACTION 
     43 
     44 
     45## Options editable by .cfg files (no export at this time) 
     46##-------------------------------------------------------- 
     47 
     48## NEMO 'trunk' branch by default 
    749[ -z "${TRUST_SVN_BRANCH}" ] && TRUST_SVN_BRANCH='trunk' 
    850 
    951## Ref. cfg. unset or empty (mandatory) 
    10 if [[ -z "${TRUST_CFG_REF}" ]]; then 
     52if [ -z "${TRUST_CFG_REF}" ]; then 
    1153 
    1254    ## Default cfg from trunk excepting last stable 
    1355    TRUST_CFG_REF='ORCA2_LIM3_PISCES' 
    1456 
    15     if [[ ${TRUST_SVN_BRANCH} && ${TRUST_SVN_BRANCH} == 'nemo_v3_6_STABLE' ]]; then 
     57    if [[ ${TRUST_SVN_BRANCH}                          \ 
     58     && ${TRUST_SVN_BRANCH} == 'nemo_v3_6_STABLE'   ]]; then 
    1659   TRUST_CFG_REF='ORCA2_LIM_PISCES' 
    1760    fi 
     
    2063 
    2164 
     65##-------------------------------------------------------------------------------- 
    2266## Source user & (super)computer configurations 
    2367##-------------------------------------------------------------------------------- 
     
    2670 
    2771 
     72##-------------------------------------------------------------------------------- 
    2873## Checking and export environment variables 
    2974##-------------------------------------------------------------------------------- 
     
    4085##------------------------------------------ 
    4186 
    42 export TRUST_SVN_REPO='https://forge.ipsl.jussieu.fr/nemo/svn' 
     87export TRUST_SVN_REPO='https://forge.ipsl.jussieu.fr' 
    4388export TRUST_SVN_CO=( 'ARCH           CONFIG          NEMO               
    4489                       EXTERNAL/AGRIF EXTERNAL/fcm    EXTERNAL/IOIPSL    
     
    65110   [ ${TRUST_CFG_REF} == 'AMM12' ] && TRUST_IO_FORC_TAR='AMM12_v3.7.tar' 
    66111 
     112   ## Update forcing archive for stable 
    67113   if [ ${TRUST_SVN_BRANCH} == 'nemo_v3_6_STABLE' ]; then 
    68114       TRUST_IO_FORC_TAR='ORCA2_LIM_nemo_v3.6.tar' 
     
    97143##---------------------- 
    98144 
     145## Assuming the sourcing of XIOS arch .env file (modules) for setting  
    99146if [ -z "${TRUST_JOB_ENV}" ]; then 
    100147    TRUST_JOB_ENV=${TRUST_IO_XIOS}/arch/arch-${TRUST_MAIN_HPCC}.env 
     
    103150export TRUST_JOB_ENV 
    104151 
     152## Default parallel compilation on 4 procs 
    105153[ -z "${TRUST_COMPILE_NPROC}" ] && TRUST_COMPILE_NPROC='4' 
    106154export TRUST_COMPILE_NPROC 
    107155 
     156## Not mandatory 
    108157export TRUST_COMPILE_FORTRAN TRUST_COMPILE_MPI TRUST_COMPILE_NETCDF 
    109158 
     159## Assuming the job submit script is in './batch', if not  
    110160if [ -z "${TRUST_JOB_SCRIPT}" ]; then 
    111161    TRUST_JOB_SCRIPT=${TRUST_MAIN_DIR}/batch/${TRUST_MAIN_HPCC}.sh || get_out A 
     
    114164export TRUST_JOB_SCRIPT  
    115165 
    116  
     166## Mandatory job management cmds (submit, status checking and killing job) 
    117167if [[ -z "${TRUST_JOB_SUBMIT}" || -z "${TRUST_JOB_STATE}" \ 
    118168                               || -z "${TRUST_JOB_KILL}"    ]]; then 
     
    122172export TRUST_JOB_SUBMIT TRUST_JOB_STATE TRUST_JOB_KILL 
    123173 
     174## Default test timeout to 3h (pending AND running time) 
    124175[ -z "${TRUST_JOB_TIMEOUT}" ] && TRUST_JOB_TIMEOUT='10800' 
    125176export TRUST_JOB_TIMEOUT 
    126177 
     178## Job informations not mandatory 
    127179export TRUST_JOB_INFO TRUST_JOB_TIME TRUST_JOB_RAM_P TRUST_JOB_RAM_V 
    128180 
  • branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/inc/trusting_func.sh

    r8826 r8834  
    22 
    33 
     4##-------------------------------------------------------------------------------- 
    45## Messenger filenames 
    56##-------------------------------------------------------------------------------- 
     
    1314 
    1415 
     16##-------------------------------------------------------------------------------- 
    1517## Functions in order of use 
    16 ##-------------------------------------------------------------------------------- 
    17  
    18 ##  
    1918##-------------------------------------------------------------------------------- 
    2019 
     
    3029##-------------------------------------------------------------------------------- 
    3130 
    32 init_files() { 
    33     echo 'Date'                > ${file_date} 
    34     echo 'Result'              > ${file_rslt} 
    35     echo 'Status'              > ${file_stat} 
    36     echo 'NEMOGCM rev.'        > ${file_nemo} 
    37     echo 'XIOS rev.'           > ${file_xios} 
    38     echo 'Fortran compiler'    > ${file_cmpf} 
    39     echo 'MPI libs'            > ${file_lmpi} 
    40     echo 'NetCDF libs'         > ${file_ncdf} 
    41     echo 'Input files'         > ${file_inpt} 
    42     echo 'Elapsed time'        > ${file_time} 
    43     echo 'Memory (Phy./Virt.)' > ${file_memy} 
    44     echo 'Comments'            > ${file_note} 
     31init() { 
     32    mkdir -p ${TRUST_TEST_DIR} ${TRUST_TEST_BENCHMARK} || get_out B 
     33    cd       ${TRUST_TEST_DIR} 
     34    echo     ${TRUST_TEST_DIR} 
     35 
     36    echo 'Date'             > ${file_date}; echo 'Result'       > ${file_rslt} 
     37    echo 'Status'           > ${file_stat}; echo 'NEMOGCM'      > ${file_nemo} 
     38    echo 'XIOS'          > ${file_xios}; echo 'Fortran'      > ${file_cmpf} 
     39    echo 'MPI'           > ${file_lmpi}; echo 'NetCDF'       > ${file_ncdf} 
     40    echo 'Inputs'        > ${file_inpt}; echo 'Elapsed time' > ${file_time} 
     41    echo 'RAM (Phy./Virt.)' > ${file_memy}; echo 'Comments'     > ${file_note} 
    4542 
    4643    ## 'FAILED' status with 'Unknown error' by default 
     
    4946    echo 'Unknown error' \ 
    5047   >> ${file_stat} 
    51 } 
    52  
    53  
    54 ## 
    55 ##-------------------------------------------------------------------------------- 
    56  
    57 get_date() { 
     48 
    5849    ## UTC time zone for timestamping 
    5950    local dat=$( date -ud "${TRUST_TEST_DATE}" +"%F %R %Z" ) 
     
    7263 
    7364    ## Loop on essential NEMO directories 
    74     for dir in ${TRUST_SVN_UP} ${TRUST_IO_XIOS}; do 
    75  
    76    ## For time being, just get revision from XIOS with no action on directory 
    77    if [ $dir == ${TRUST_IO_XIOS} ]; then 
    78        rev_loc=$( svn info $dir | awk '/Last Changed Rev/ {print $NF}' ) 
    79        echo 'XIOS '${rev_loc} \ 
    80       >> model.log 
    81        echo "<a href=\"https://forge.ipsl.jussieu.fr/ioserver/changeset/${rev_loc}\" target=\"_blank\">${rev_loc}</a>" \ 
    82       >> ${file_xios} 
    83        continue 
    84    fi 
     65    for dir in ${TRUST_SVN_UP}; do 
    8566 
    8667   echo $dir && ${TRUST_SVN_ACTION} ${TRUST_SVN_NEMOGCM}/$dir || get_out C 
    87    rev_loc=$( svn info ${TRUST_SVN_NEMOGCM}/$dir  \ 
     68   rev_loc=$( svn info ${TRUST_SVN_NEMOGCM}/$dir     \ 
    8869              | awk '/Last Changed Rev/ {print $NF}'   ) 
    8970 
     
    9475    echo 'NEMOGCM '$rev \ 
    9576   >> model.log 
    96     echo "<a href=\"https://forge.ipsl.jussieu.fr/nemo/changeset/$rev\" target=\"_blank\">$rev</a>" \ 
     77    echo "<a href=\"${TRUST_SVN_REPO}/nemo/changeset/$rev\" target=\"_blank\">$rev</a>" \ 
    9778   >> ${file_nemo} 
    9879} 
     80 
    9981 
    10082## 
     
    123105 
    124106   ## Cleaning characters string to display proper soft name 
    125    #str=$( echo $str | sed 's|[/-]||g'  ) 
    126107   ver=$( echo $ver | sed 's|[/-]| |g' ) 
    127108 
     
    130111    done 
    131112 
     113    sed -n 2p model.log \ 
     114   >> ${file_cmpf} 
    132115    sed -n 3p model.log \ 
    133    >> ${file_cmpf} 
     116   >> ${file_lmpi} 
    134117    sed -n 4p model.log \ 
    135    >> ${file_lmpi} 
    136     sed -n 5p model.log \ 
    137118   >> ${file_ncdf} 
     119 
     120    cat model.log | awk '{printf "%-20s %s %s\n", $1, $2, $3}' 
     121    env | sort > env.log 
     122} 
     123 
     124 
     125## 
     126##-------------------------------------------------------------------------------- 
     127 
     128compile_xios() { 
     129    cd ${TRUST_IO_XIOS} 
     130 
     131    rev=$( svn info | awk '/Last Changed Rev/ {print $NF}' ) 
     132    echo 'XIOS '$rev \ 
     133   >> ${TRUST_TEST_DIR}/model.log 
     134    echo "<a href=\"${TRUST_SVN_REPO}/ioserver/changeset/$rev target=\"_blank\">$rev</a>" \ 
     135   >> ${TRUST_TEST_DIR}/${file_xios} 
     136 
     137    eval " 
     138    ./make_xios ${TRUST_IO_XIOS_MODE} --arch ${TRUST_MAIN_HPCC}     \ 
     139                                 --job  ${TRUST_COMPILE_NPROC} \ 
     140   ${TRUST_MAIN_STDOUT} 
     141    " 
     142 
     143    [ ! -e ./lib/libxios.a ] && get_out D || echo 'Success' 
     144} 
     145 
     146 
     147## 
     148##-------------------------------------------------------------------------------- 
     149 
     150compile_nemo() { 
     151    cd ${TRUST_SVN_NEMOGCM}/CONFIG 
     152 
     153    ## Recompiling from scratch if not in debug mode 
     154    if [[ -d ${TRUST_CFG_NEW} && ${TRUST_FLAG_DEBUG} == 'false' ]]; then 
     155   ./makenemo -n ${TRUST_CFG_NEW} clean_config \ 
     156       > /dev/null <<EOF 
     157y 
     158EOF 
     159    fi 
     160 
     161    eval " 
     162    ./makenemo -n ${TRUST_CFG_NEW}   -r ${TRUST_CFG_REF}       \ 
     163               -m ${TRUST_MAIN_HPCC} -j ${TRUST_COMPILE_NPROC} \ 
     164               ${TRUST_CFG_KEY_ADD} ${TRUST_CFG_KEY_DEL}       \ 
     165   ${TRUST_MAIN_STDOUT} 
     166    " 
     167 
     168    [ ! -e ./${TRUST_CFG_NEW}/BLD/bin/nemo.exe ] && get_out E || echo 'Success' 
    138169} 
    139170 
     
    144175get_inputs() { 
    145176     # List archive content & extract it by default 
    146     local inputs_list=$( eval " 
    147         for archive in ${TRUST_IO_FORC_TAR}; do 
    148             tar -tvf ${TRUST_IO_FORC_PATH}/\$archive >> inputs_list.txt; 
     177    local inputs_list=" 
     178        for archive in \${TRUST_IO_FORC_TAR}; do 
     179            tar -tvf \${TRUST_IO_FORC_PATH}/\$archive >> inputs_list.txt; 
    149180         done 
    150          " ) 
    151     local inputs_get=$( eval " 
    152         for archive in ${TRUST_IO_FORC_TAR}; do 
    153             tar -vxf ${TRUST_IO_FORC_PATH}/\$archive  >       /dev/null; 
     181         " 
     182    local inputs_get=" 
     183        for archive in \${TRUST_IO_FORC_TAR}; do 
     184            tar -vxf \${TRUST_IO_FORC_PATH}/\$archive  >       /dev/null; 
    154185         done 
    155          " ) 
    156   
     186         " 
     187 
    157188    ## List & copy files without archive 
    158189    if [ -z "${TRUST_IO_FORC_TAR}" ]; then 
    159         inputs_list=" ls -lh ${TRUST_IO_FORC_PATH}/* >> inputs_list.txt" 
    160         inputs_get=" \cp     ${TRUST_IO_FORC_PATH}/* .                 " 
    161     fi 
    162  
    163     ${inputs_list}; ${inputs_get} 
    164  
    165 #    for entry in ${TRUST_IO_FORC_PATH}; do 
    166 # 
    167    # If path to file (assuming it is an archive) 
    168 #  if   [ -e $entry ]; then 
    169 #      tar -tvf $entry >> inputs_list.txt; 
    170 #      tar -vxf $entry  >       /dev/null; 
    171    # If path to directory 
    172 #  elif [ -d $entry ]; then 
    173 #      inputs_list=" ls -lh ${TRUST_IO_FORC_PATH}/* >> inputs_list.txt" 
    174 #      inputs_get=" \cp     ${TRUST_IO_FORC_PATH}/* .                 " 
    175 #  fi     
    176  
    177 #    done 
     190        inputs_list=" ls -lh \${TRUST_IO_FORC_PATH}/* >> inputs_list.txt" 
     191        inputs_get=" \cp     \${TRUST_IO_FORC_PATH}/* .                 " 
     192    fi 
     193 
     194    cd ${TRUST_TEST_DIR} 
     195    eval ${inputs_list} 
     196    echo ${inputs_get}; eval ${inputs_get} 
    178197 
    179198    if [ $( find -name '*.gz' -print -quit ) ]; then 
    180199   find . -name '*.gz' -exec gzip -d {} \; 
    181200    fi 
     201 
     202    cp   ${TRUST_SVN_NEMOGCM}/CONFIG/${TRUST_CFG_NEW}/cpp_* . 
     203    find ${TRUST_SVN_NEMOGCM}/CONFIG/${TRUST_CFG_NEW}/EXP00 \ 
     204    -regex '.*\(_cfg\|.in\|opa\|_ref\|.xml\)'          \ 
     205    -exec  cp {} . \; 
    182206} 
    183207 
     
    221245    [ -n "${files_list}" ] && echo 'Inputs  : '${files_list}'differ<br>' \ 
    222246   >> temp_${file_note} 
     247} 
     248 
     249 
     250## 
     251##-------------------------------------------------------------------------------- 
     252 
     253job_submit() { 
     254    ## Copy the submitting script to testing folder 
     255    cp ${TRUST_JOB_SCRIPT} ${TRUST_TEST_DIR} 
     256 
     257    TRUST_JOB_ID=$( eval ${TRUST_JOB_SUBMIT} ) 
     258    [ $? -ne 0 ] && get_out G || printf "Success (job ID %s)\n" ${TRUST_JOB_ID} 
    223259} 
    224260 
     
    257293##-------------------------------------------------------------------------------- 
    258294 
     295job_perfs() { 
     296    if [ -n "${TRUST_JOB_TIME}" ]; then 
     297 
     298    ## Interest for checking unusual time computation 
     299   local time_cpu=$( eval ${TRUST_JOB_TIME} ) 
     300 
     301   printf "Elapsed time: " 
     302   echo ${time_cpu} | tee -a ${file_time} 
     303 
     304    fi 
     305 
     306    if [[ -n "${TRUST_JOB_RAM_P}" && -n "${TRUST_JOB_RAM_V}" ]]; then 
     307 
     308    ## Interest for checking unusual memory usage 
     309   local memory_pmax=$( eval ${TRUST_JOB_RAM_P} ) 
     310   local memory_vmax=$( eval ${TRUST_JOB_RAM_V} ) 
     311 
     312   printf "Memory max usage (physical/virtual): " 
     313   echo ${memory_pmax}' / '${memory_vmax} | tee -a ${file_memy} 
     314    fi 
     315} 
     316 
     317 
     318## 
     319##-------------------------------------------------------------------------------- 
     320 
     321job_state() { 
     322    if [[ ! -e time.step || $( grep 'E R R O R' ocean.output ) ]]; then 
     323   get_out H 
     324    else 
     325   echo 'Success' ## Must be reviewed 
     326    fi 
     327} 
     328 
     329 
     330## 
     331##-------------------------------------------------------------------------------- 
     332 
    259333diff_results() { 
    260334    local file 
     
    264338    ## Think of copying initial test ## 
    265339    ################################### 
     340 
     341    ## Now test is good by default ('OK') 
     342    TRUST_FLAG_RESULT='OK' 
    266343 
    267344    ## Simple diff 
     
    290367diff_restarts() { 
    291368    local dif filebase filebases ndomain out 
    292     local files_list='' dif_sum='0' #bcmk='false' 
     369    local files_list='' dif_sum='0' 
    293370 
    294371    ## Find all restart files to rebuild 
     
    352429    fi 
    353430 
    354 } 
    355  
    356  
    357 ## 
    358 ##-------------------------------------------------------------------------------- 
    359  
    360 get_time() { 
    361     [ -z "${TRUST_JOB_TIME}" ] && return 
    362  
    363     ## Interest for checking unusual time computation 
    364     local time_cpu=$( eval ${TRUST_JOB_TIME} ) 
    365  
    366     printf "Elapsed time: " 
    367     echo ${time_cpu} | tee -a ${file_time} 
    368 } 
    369  
    370  
    371 ## 
    372 ##-------------------------------------------------------------------------------- 
    373  
    374 get_memy() { 
    375     [[ -z "${TRUST_JOB_RAM_P}" && -z "${TRUST_JOB_RAM_V}" ]] && return 
    376  
    377     ## Interest for checking unusual memory usage 
    378     local memory_pmax=$( eval ${TRUST_JOB_RAM_P} ) 
    379     local memory_vmax=$( eval ${TRUST_JOB_RAM_V} ) 
    380  
    381     printf "Memory max usage (physical/virtual): " 
    382     echo ${memory_pmax}' / '${memory_vmax} | tee -a ${file_memy} 
     431    [ $TRUST_FLAG_RESULT == 'FAILED' ] && get_out L 
    383432} 
    384433 
     
    428477 
    429478    ## Production mode (-p|--prod) 
    430     if [ ${TRUST_FLAG_PROD} -eq 1 ]; then 
     479    if [ ${TRUST_FLAG_PROD} == 'true' ]; then 
    431480 
    432481   ## Create or append trusting logfile 
     
    542591 
    543592    ## Save tested configuration if trusting failed in production mode (-p|--prod) 
    544     if [[ ${TRUST_FLAG_RESULT} == 'FAILED' && ${TRUST_FLAG_PROD} -eq 1 ]]; then 
     593    if [[ ${TRUST_FLAG_RESULT} == 'FAILED' && ${TRUST_FLAG_PROD} == 'true' ]]; then 
    545594   echo 'Creating archive '${TRUST_TEST_BACKUP}' under '${TRUST_TEST_BENCHMARK} 
    546595   tar -czf ${TRUST_TEST_BENCHMARK}/${TRUST_TEST_BACKUP}                 * \ 
  • branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/install_new_branch.sh

    r8808 r8834  
    4646printf "\nWhat branch do you want to install in "${TRUST_DIR_WORK}" for trusting test ? " 
    4747echo 'Enter 0 to abort' 
    48 select branch in 'trunk' $( svn ls ${TRUST_SVN_REPO}/branches/2015 | tr -d / | sort -r ); do 
     48select branch in 'trunk' $( svn ls ${TRUST_SVN_REPO}/nemo/svn/branches/2015 | tr -d / | sort -r ); do 
    4949 
    5050    if [ $REPLY -eq 0 ]; then exit 1; else export TRUST_SVN_BRANCH=$branch; fi 
     
    7474 
    7575    if [ $elmt == 'TOOLS/maketools' ]; then 
    76    svn co -q ${TRUST_SVN_REPO}/${svn_bran}/NEMOGCM/TOOLS --depth empty 
     76   svn co -q ${TRUST_SVN_REPO}/nemo/svn/${svn_bran}/NEMOGCM/TOOLS --depth empty 
    7777   svn up -q $elmt 
    7878    else 
    79    svn co -q ${TRUST_SVN_REPO}/${svn_bran}/NEMOGCM/$elmt $elmt 
     79   svn co -q ${TRUST_SVN_REPO}/nemo/svn/${svn_bran}/NEMOGCM/$elmt $elmt 
    8080    fi 
    8181 
  • branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/trusting.sh

    r8826 r8834  
    44cd $( dirname $0 ) 
    55 
     6##-------------------------------------------------------------------------------- 
    67## Set flags & defaults 
    78##-------------------------------------------------------------------------------- 
     
    910TRUST_MAIN_DIR=$PWD 
    1011 
    11 TRUST_FLAG_DEBUG=0; TRUST_FLAG_PROD=0; TRUST_FLAG_HELP=0 
    12 TRUST_FLAG_RESULT='FAILED'; TRUST_FLAG_ERROR=0 
     12TRUST_FLAG_DEBUG='false'  ; TRUST_FLAG_HELP='false' ; TRUST_FLAG_PROD='false' 
    1313 
    14 ## No update on SVN directories & 'FAILED' result for 'Unknown error' ) 
    15 TRUST_SVN_ACTION='svn status' 
    16  
    17 xios_mode='--full'; stdout_redir='>&' 
    1814rev=$( svn info | awk '(NR == 9) {print $NF}' ) 
    1915 
    2016 
    21 ## Get options (replacing initials settings) 
     17##-------------------------------------------------------------------------------- 
     18## Get arguments from command line 
    2219##-------------------------------------------------------------------------------- 
    2320 
    24 while [ $# -ne 0 ]; do 
     21while getopts a:b:de:f:j:hm:n:r:t:pu:v:w: arg; do 
    2522 
    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'                                    ;; 
    3534    esac 
    3635 
     
    3837 
    3938 
    40 ## Initialization (HPC & user environment) 
     39##-------------------------------------------------------------------------------- 
     40## Initialization (user & HPC environment) 
    4141##-------------------------------------------------------------------------------- 
    4242 
    43 if [[ ! -e cfg/${TRUST_MAIN_USER}.cfg || ! -e cfg/${TRUST_MAIN_HPCC}.cfg || ${TRUST_FLAG_HELP} -eq 1 ]]; then 
     43if [[ ! -e cfg/${TRUST_MAIN_USER}.cfg || ! -e cfg/${TRUST_MAIN_HPCC}.cfg \ 
     44      || ${TRUST_FLAG_HELP} == 'true'                                      ]]; then 
    4445    cat ./inc/trusting_help.txt 
    4546 
    46     if [ ${TRUST_FLAG_HELP} -eq 0 ]; then 
     47    if [ ${TRUST_FLAG_HELP} == 'false' ]; then 
    4748   printf "\n\n\033[0;33m" 
    4849   printf "At least one configuration (arch or user) file is missing or misspelled:" 
     
    5657    exit 1 
    5758else 
    58     . ./inc/trusting.env && . ./inc/trusting_func.sh 
     59    ## Verbose output on debug mode 
     60    [ ${TRUST_FLAG_DEBUG} == 'true' ] && set -vx 
    5961 
    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 
    7164 
    7265fi 
    7366 
    7467 
    75 ## Display contextual summary of trusting test 
     68##-------------------------------------------------------------------------------- 
     69## Trusting workflow 
    7670##-------------------------------------------------------------------------------- 
    7771 
     72## Display summary of test 
     73##------------------------ 
     74 
    7875echo 
    79  
    8076if [ -t 0 ]; then cat ./inc/banner.txt; else cat ./inc/banner.html; fi 
    81  
    8277echo 
    8378echo '****************************************************************************************************' 
     
    9186printf "\t§ User installation\t\t%s\n\n"         ${TRUST_MAIN_USER} 
    9287echo 
    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} 
     88printf "\t§ Testing configuration\t\t%s based on %s\n" \ 
     89    ${TRUST_CFG_NEW} ${TRUST_CFG_REF} 
     90printf "\t§ SVN working copy\t\t%s/%s\n"               \ 
     91    ${TRUST_DIR_WORK} ${TRUST_SVN_BRANCH} 
    9592if [ ${TRUST_TEST_BENCHMARK} ]; then 
    9693printf "\t§ Benchmark folder\t\t%s\n"               ${TRUST_TEST_BENCHMARK} 
     
    9895 
    9996 
    100 ## Make timestamped directory with messenger files 
    101 ##-------------------------------------------------------------------------------- 
     97## Testing directory 
     98##------------------ 
    10299 
    103100print_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 
     101init 
    112102 
    113103 
    114 ## Get SVN revision on XIOS & NEMO essentials directories 
    115 ##-------------------------------------------------------------------------------- 
     104## Local working copy 
     105##------------------- 
    116106 
    117 print_step "SVN action on NEMO directories: ${TRUST_SVN_ACTION}" 
    118  
     107print_step 'SVN action on NEMO directories' 
     108echo "${TRUST_SVN_ACTION} on ${TRUST_SVN_NEMOGCM}:" 
    119109get_nemo_rev 
    120110 
    121111 
    122 ## Check softwares versions (after sourced arch environment) 
    123 ##-------------------------------------------------------------------------------- 
     112## Environment 
     113##------------ 
    124114 
    125115print_step 'Get testing environment' 
    126  
    127116get_soft_rel 
    128117 
    129 cat model.log | awk '{printf "%-20s %s %s\n", $1, $2, $3}' 
    130 env | sort > env.log 
     118 
     119## Compilation(s) 
     120##--------------- 
     121 
     122print_step 'Compile XIOS' 
     123compile_xios 
     124 
     125print_step "Compile ${TRUST_CFG_REF} configuration" 
     126compile_nemo 
    131127 
    132128 
    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##------- 
    170131 
    171132print_step 'Set job (copying or extracting inputs)' 
    172  
    173 cd ${TRUST_TEST_DIR} 
    174  
    175133get_inputs 
    176134 
    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 inputs 
    184 ##-------------------------------------------------------------------------------- 
    185  
    186135print_step 'Compare inputs' 
    187  
    188136diff_inputs 
    189137 
    190138 
    191 ## Job submission & computation 
    192 ##-------------------------------------------------------------------------------- 
     139## Job 
     140##---- 
    193141 
    194142print_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} 
     143job_submit 
    201144 
    202145print_step 'Pending job' 
    203  
    204146job_pending 
    205147 
    206148print_step 'Job finished' 
    207149 
    208  
    209 ## Check job state & get computation performances if succeeded 
    210 ##-------------------------------------------------------------------------------- 
    211  
    212150print_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 
     151job_state 
    219152 
    220153print_step 'Get job performances' 
    221  
    222 get_time 
    223  
    224 get_memy 
     154job_perfs 
    225155 
    226156 
    227 ## Check outputs 
    228 ##-------------------------------------------------------------------------------- 
    229  
    230 TRUST_FLAG_RESULT='OK' ## 'OK' by default 
     157## Outputs 
     158##-------- 
    231159 
    232160print_step 'Compare outputs' 
    233  
    234161diff_results 
    235162 
    236163print_step 'Compare restarts' 
    237  
    238164diff_restarts 
    239  
    240 [ $TRUST_FLAG_RESULT= == 'FAILED' ] && get_out L 
    241165 
    242166 
    243167## End, at least nothing major has changed ;-) 
    244 ##-------------------------------------------------------------------------------- 
     168##-------------------------------------------- 
    245169 
    246170get_out 0 
Note: See TracChangeset for help on using the changeset viewer.