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 8834 for branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/trusting.sh – NEMO

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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.