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/inc/trusting_func.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/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}                 * \ 
Note: See TracChangeset for help on using the changeset viewer.