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 8883 – NEMO

Changeset 8883


Ignore:
Timestamp:
2017-12-01T18:51:27+01:00 (7 years ago)
Author:
nicolasmartin
Message:

Continuation of global refactoring of Trusting tool: modification of options list to maintain consistency with makenemo
After getting a code snippet on https://stackoverflow.com/questions/402377/using-getopts-in-bash-shell-script-to-get-long-and-short-command-line-options in order to handle short '-[a-z]' and long '[a-z]*=' options, I have modified the main trusting script to split betwwen:

  • Short options reserved shared options with makenemo ( -[hjmnr])
  • Long pattern for trusting specified options
Location:
branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST
Files:
1 deleted
2 edited
3 moved

Legend:

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

    r8859 r8883  
    7070## Source user & (super)computer configurations 
    7171##-------------------------------------------------------------------------------- 
    72 . ./cfg/${TRUST_MAIN_USER}.cfg 
     72. ./cfg/${TRUST_MAIN_SETUP}.cfg 
    7373. ./cfg/${TRUST_MAIN_HPCC}.cfg 
    7474 
     
    193193##-------------- 
    194194 
    195 export TRUST_TEST_NAME=${TRUST_MAIN_USER}'_'${TRUST_MAIN_HPCC} 
     195export TRUST_TEST_NAME=${TRUST_MAIN_SETUP}'_'${TRUST_MAIN_HPCC} 
    196196export TRUST_TEST_DATE=$( date -u +"%Y%m%d%Z%H%M" ) 
    197197 
  • branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/inc/functions.sh

    r8859 r8883  
    1717## Functions in order of use 
    1818##-------------------------------------------------------------------------------- 
     19 
     20display_help() { 
     21    cat ./inc/trusting_help.txt 
     22} 
    1923 
    2024step() { 
     
    520524 
    521525Testing configuration ${TRUST_CFG_NEW} based on ${TRUST_CFG_REF}. 
    522 User installation ${TRUST_MAIN_USER} 
     526User installation ${TRUST_MAIN_SETUP} 
    523527HPC environment ${TRUST_MAIN_HPCC} 
    524528 
  • branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/inc/help.txt

    r8859 r8883  
    1 Usage: ./trusting.sh        -u $USER -m $ARCH [OPTIONS] 
    2        ./install_new_branch -u $USER -m $ARCH [OPTIONS] 
    31 
    42./trusting.sh            Launch trusting test on $ARCH machine from $USER installation 
  • branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/install_new_branch.sh

    r8834 r8883  
    1515   '-d'|'--debug'  ) TRUST_FLAG_DEBUG=1 ; shift  ;; '-j'|'--job'    ) TRUST_COMPILE_NPROC=$2; shift 2;; 
    1616   '-m'|'--machine') TRUST_MAIN_HPCC=$2; shift 2;; '-h'|'--help'    ) TRUST_FLAG_HELP=1 ; shift  ;; 
    17    '-u'|'--user'   ) TRUST_MAIN_USER=$2; shift 2;; "*"             ) TRUST_FLAG_HELP=1 ; shift  ;; 
     17   '-u'|'--user'   ) TRUST_MAIN_SETUP=$2; shift 2;; "*"             ) TRUST_FLAG_HELP=1 ; shift  ;; 
    1818    esac 
    1919done 
     
    2222## Initialization (HPC & user environment) 
    2323##--------------------------------------------------- 
    24 if [[ ! -e cfg/${TRUST_MAIN_USER}.cfg || ! -e cfg/${TRUST_MAIN_HPCC}.cfg || ${TRUST_FLAG_HELP} -eq 1 ]]; then 
     24if [[ ! -e cfg/${TRUST_MAIN_SETUP}.cfg || ! -e cfg/${TRUST_MAIN_HPCC}.cfg || ${TRUST_FLAG_HELP} -eq 1 ]]; then 
    2525    cat ./inc/trusting_help.txt 
    2626 
     
    2828   printf "\n\n\033[0;33m" 
    2929   printf "At least one configuration (arch or user) file is missing or misspelled:" 
    30    printf "\t'%s'.cfg\t'%s'.cfg" ${TRUST_MAIN_USER} ${TRUST_MAIN_HPCC} 
     30   printf "\t'%s'.cfg\t'%s'.cfg" ${TRUST_MAIN_SETUP} ${TRUST_MAIN_HPCC} 
    3131   printf "\033[0m" 
    3232    fi 
  • branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/trusting.sh

    r8859 r8883  
    22 
    33 
     4## Possibility to call from outside 
    45cd $( dirname $0 ) 
    5  
    6 ##-------------------------------------------------------------------------------- 
    7 ## Set flags & defaults 
    8 ##-------------------------------------------------------------------------------- 
    9  
    106TRUST_MAIN_DIR=$PWD 
    11 TRUST_FLAG_HELP='false' 
    12 TRUST_FLAG_DEBUG='false'; TRUST_FLAG_DEV='false' ; TRUST_FLAG_PROD='false' 
    13  
    14 # Revision number of the tool 
     7 
     8## Tool revision in use 
    159rev=$( svn info | awk '/Last Changed Rev/ {print $NF}' ) 
    1610 
    1711 
    1812##-------------------------------------------------------------------------------- 
    19 ## Get short or long arguments from command line 
    20 ##-------------------------------------------------------------------------------- 
    21  
    22 while getopts a:b:de:f:j:hm:n:r:t:pu:v:w: arg; do 
    23  
    24     case $arg in 
    25    a)  TRUST_IO_FORC_TAR=$OPTARG;; b)    TRUST_SVN_BRANCH=$OPTARG;; 
    26    d) TRUST_FLAG_DEBUG='true'   ;; e)  TRUST_TEST_MAILING=$OPTARG;; 
    27    f) TRUST_IO_FORC_PATH=$OPTARG;; j) TRUST_COMPILE_NPROC=$OPTARG;; 
    28    h)  TRUST_FLAG_HELP='true'   ;; m)     TRUST_MAIN_HPCC=$OPTARG;; 
    29    n)      TRUST_CFG_NEW=$OPTARG;; r)       TRUST_CFG_REF=$OPTARG;; 
    30    t)  TRUST_JOB_TIMEOUT=$OPTARG;; p)   TRUST_FLAG_PROD='true'   ;; 
    31    u)    TRUST_MAIN_USER=$OPTARG;; v)       TRUST_SVN_REV=$OPTARG;; 
    32    w)     TRUST_DIR_WORK=$OPTARG;; 
    33    :) echo 'Arg. needed for '$OPTARG && TRUST_FLAG_HELP='true'   ;; 
    34    *)  TRUST_FLAG_HELP='true'                                    ;; 
     13## Flags default 
     14##-------------------------------------------------------------------------------- 
     15 
     16TRUST_FLAG_DEBUG='false'; TRUST_FLAG_DEV='false' 
     17TRUST_FLAG_HELP='false' ; TRUST_FLAG_PROD='false' 
     18 
     19 
     20##-------------------------------------------------------------------------------- 
     21## Options from command line 
     22##-------------------------------------------------------------------------------- 
     23 
     24while getopts ab:c:de:hj:lm:n:p:r:s:t:u:v:-: shortopt; do 
     25 
     26##  Attempt to maintain consistency with 'makenemo' available options 
     27##o makenemo: a d e h j k m n r s t u v 
     28##o trusting: | | | = = | = = = | | | | 
     29 
     30    case $shortopt in 
     31   ## Mandatory (HPCC environment) 
     32   'm') TRUST_MAIN_HPCC=$OPTARG    ;; 
     33 
     34   ## NEMO configuration 
     35   'n') TRUST_CFG_NEW=$OPTARG      ;; 'r') TRUST_CFG_REF=$OPTARG     ;; 
     36 
     37   ## Compilation 
     38   'j') TRUST_COMPILE_NPROC=$OPTARG;; 
     39 
     40   ## Flags 
     41   'h') TRUST_FLAG_HELP='true'     ;; 
     42 
     43   ## Implement long options for specific not to reducing further short possibilites 
     44   ## https://stackoverflow.com/questions/402377/using-getopts-in-bash-shell-script-to-get-long-and-short-command-line-options 
     45   '-') 
     46       [ $OPTIND -ge 1 ] && optind=$( expr $OPTIND - 1 ) || optind=$OPTIND 
     47            longopt=${!optind} 
     48        
     49       OPTION=${longopt/=[0-9A-Za-z_-]*/}; OPTARG=${longopt/[a-z-]*=/} 
     50 
     51            case $OPTION in 
     52      ## Mandatory (installation environment) 
     53      '--setup'   ) TRUST_MAIN_SETUP=$OPTARG   ;; 
     54 
     55      ##  Alt 'CONFIG' directory for standalone 'TRUST' to check several local branches 
     56      ##+ (default to ./../CONFIG parent) 
     57      '--cfgdir'  ) TRUST_DIR_WORK=$OPTARG     ;; 
     58 
     59      ## Local working copy 
     60      '--branch'  ) TRUST_SVN_BRANCH=$OPTARG   ;; 
     61      '--update'  ) TRUST_SVN_REV=$OPTARG      ;; 
     62 
     63      ## Compilation & Computing 
     64      '--timeout' ) TRUST_JOB_TIMEOUT=$OPTARG  ;;  
     65 
     66      ## Inputs 
     67      '--forctar' )  
     68          TRUST_IO_FORC_TAR='' 
     69 
     70          ## Set but not empty 
     71          if [ $OPTARG ]; then  
     72         TRUST_IO_FORC_TAR=$OPTARG 
     73          else 
     74         OPTARG='null' 
     75          fi 
     76                                                         ;; 
     77      '--forcpath') TRUST_IO_FORC_PATH=$OPTARG ;; 
     78 
     79      ## Mailing 
     80      '--email'   ) TRUST_TEST_MAILING=$OPTARG ;; 
     81 
     82      ## Flags (no argument needed) 
     83      '--dev'     ) TRUST_FLAG_DEV='true'  ; OPTARG='null';; 
     84      '--prod'    ) TRUST_FLAG_PROD='true' ; OPTARG='null';; 
     85      '--debug'   ) TRUST_FLAG_DEBUG='true'; OPTARG='null';; 
     86 
     87      *           ) printf "\033[0;31m%s illegal long option %s\033[0m\n" \ 
     88          $0 $OPTION;; 
     89            esac 
     90 
     91       OPTIND=1; shift             ;; 
     92 
     93   ## Illegal option 
     94   '?')  TRUST_FLAG_HELP='true'    ;; 
    3595    esac 
    3696 
     
    42102##-------------------------------------------------------------------------------- 
    43103 
    44 if [[ ! -e cfg/${TRUST_MAIN_USER}.cfg || ! -e cfg/${TRUST_MAIN_HPCC}.cfg \ 
    45       || ${TRUST_FLAG_HELP} == 'true'                                      ]]; then 
    46     cat ./inc/trusting_help.txt 
     104if [[ ! -e ./cfg/${TRUST_MAIN_SETUP}.cfg || ! -e ./cfg/${TRUST_MAIN_HPCC}.cfg ]]; then 
     105 
     106    printf "\nUsage: %s -m arch --setup cfg [OPTIONS]\n"        $0 
     107    printf "\nSee help for options description, %s -h|--help\n" $0 
    47108 
    48109    ## Color this section to part with help 
     
    53114       \nAt least 1 cfg file (arch or user) is missing or misspelled: \ 
    54115       '%s.cfg' or '%s.cfg'\n"                                        \ 
    55        ${TRUST_MAIN_USER} ${TRUST_MAIN_HPCC} 
     116       ${TRUST_MAIN_SETUP} ${TRUST_MAIN_HPCC} 
     117    else 
     118   printf "\033[0m" 
     119   cat ./inc/help.txt 
    56120    fi 
    57121 
     
    66130    [ ${TRUST_FLAG_DEBUG} == 'true' ] && set -vx 
    67131 
    68     . ./inc/trusting.env 
    69     . ./inc/trusting_func.sh 
     132    . ./inc/env.sh 
     133    . ./inc/functions.sh 
    70134 
    71135fi 
     
    80144 
    81145echo 
    82 if [ -t 0 ]; then cat ./inc/banner.txt; else cat ./inc/banner.html; fi 
     146## Formatting for email (test not in interactive mode) 
     147[ ! -t 0 ] && echo '<pre style="font: 2px/1px monospace;">' 
     148cat ./inc/banner.txt 
     149[ ! -t 0 ] && echo '</pre>' 
    83150echo 
    84151echo '****************************************************************************************************' 
     
    91158printf "\t§ Testing configuration\t\t%s on branch %s\n" \ ${TRUST_CFG_REF} ${TRUST_SVN_BRANCH} 
    92159printf "\t§ (Super)Computer\t\t%s\n"                ${TRUST_MAIN_HPCC} 
    93 printf "\t§ User installation\t\t%s\n\n"            ${TRUST_MAIN_USER} 
     160printf "\t§ User installation\t\t%s\n\n"            ${TRUST_MAIN_SETUP} 
    94161echo 
    95162if [ ${TRUST_TEST_BENCHMARK} ]; then 
     
    160227job_state 
    161228 
    162 printf "Perfs?" 
     229printf "Perfs?\n" 
    163230job_perfs 
    164231 
Note: See TracChangeset for help on using the changeset viewer.