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 12569 for utils/CI/sette/all_functions.sh – NEMO

Ignore:
Timestamp:
2020-03-18T12:22:56+01:00 (4 years ago)
Author:
mathiot
Message:

ticket #2304: merge branch sette_ticket2304 into sette (thank you Simon for the review and all the suggestions you made). It include synchronisation and cleaning option between the REF config and the _ST config to ease the work when the reference configurations are changed and display bug in sette_check_avail_rev

File:
1 edited

Legend:

Unmodified
Added
Removed
  • utils/CI/sette/all_functions.sh

    r11161 r12569  
    9191usage=" if value is a string ths is neede syntax : ./set_namelist namelist_name var_name \"new_value\" " 
    9292 
     93# sync MYSRC files (input CFG and CFG_ST) 
     94sync_config() { 
     95   if [ ${SYNC_CONFIGS} == "yes" ]; then 
     96 
     97      lREF=$3/$1    # reference  
     98      lCFG=$3/$2    # target 
     99 
     100      echo '-------------------------------------------------------------------------------' 
     101      echo '                    SOURCE AND CONFIG FILES SYNCHRONISATION                    ' 
     102      echo '' 
     103      echo "configuration $lCFG/MY_SRC will be synchronised with $lREF/MY_SRC" 
     104      echo '' 
     105      # synchronise MY_SRC if $lCFG directory exist 
     106      if [ -d $lREF/MY_SRC ] && [ -d $lCFG ] ; then 
     107 
     108         if [ -d $lCFG/MY_SRC ] ; then 
     109 
     110            # Manage case number of file in MY_SRC changes 
     111            # find number of file only in $lCFG/MY_SRC 
     112            FCFG=`diff -r $lREF/MY_SRC $lCFG/MY_SRC | grep "Only in $lCFG/MY_SRC" | awk '{print $4}'` 
     113 
     114            # if more than 0, trigger a cleaning as Makenemo do not properly manage this case. 
     115            if [ ! -z "$FCFG" ]; then  
     116               echo '' 
     117               echo "$lCFG contains a different file list than $lREF :" 
     118               diff -r $lREF/MY_SRC $lCFG/MY_SRC | grep "Only in $lCFG/MY_SRC" | awk '{print $4}' 
     119               echo "Synchronisation is not enough because Makenemo does not handle well case where a file in MY_SRC is removed" 
     120               echo "Therefore, we need to clean $lCFG before starting runing it" 
     121               echo '' 
     122               CLEAN_CONFIGS="yes" 
     123            fi 
     124         fi 
     125 
     126         # synchronisation $lREF/MY_SRC directory (and delete file in target location if needed) 
     127         rsync -a --delete $lREF/MY_SRC/ $lCFG/MY_SRC 
     128 
     129         # rsync keep preserve the modification time stamp. 
     130         # To avoid case where a file in MY_SRC is replace by an older file, we touch the file 
     131         touch $lCFG/MY_SRC/* 
     132      fi 
     133 
     134      echo '' 
     135      echo "configuration $lCFG/EXP00 will be synchronised with $lREF/EXPREF" 
     136      echo "(links are skipped)" 
     137      echo '' 
     138      # synchronize EXPREF 
     139      if [ -d $lREF/EXPREF ] && [ -d $lCFG/EXP00 ] ; then 
     140         rsync -a --no-links $lREF/EXPREF/ $lCFG/EXP00/. 
     141      fi 
     142      echo '-------------------------------------------------------------------------------' 
     143   fi 
     144} 
     145 
     146# clean _ST config (input CFG CFG_ST TYPE (test or ref)) 
     147clean_config() { 
     148   if [ ${CLEAN_CONFIGS} == "yes" ]; then 
     149      lREF=$1 
     150      lCFG=$2 
     151      lTYP=$3 
     152      echo '' 
     153      echo '-------------------------------------------------------------------------------' 
     154      echo '                         CLEANING CONFIGURATION                                ' 
     155      echo '' 
     156      echo "./makenemo -n $lCFG -a/-r $lREF clean" 
     157      echo '' 
     158      if [ ${lTYP} == 'tests' ]; then 
     159         ./makenemo -n $lCFG -a $lREF clean 
     160      elif [ ${lTYP} == 'cfgs' ]; then 
     161         ./makenemo -n $lCFG -r $lREF clean 
     162      else 
     163         echo 'ERROR in the cleaning process'; exit 42 
     164      fi 
     165      echo '' 
     166      echo "$lCFG configuration has been cleaned" 
     167      echo '' 
     168      echo '-------------------------------------------------------------------------------' 
     169   fi 
     170} 
     171 
    93172# define validation dir 
    94173set_valid_dir () { 
    95     LANG=en_US 
    96     REVISION_NB=`LC_MESSAGES=${LANG} ${SVN_CMD} info ${SETTE_DIR}/.. | grep "Last Changed Rev" | awk '{print $NF}'` 
     174    REVISION_NB=`${SVN_CMD} info ${SETTE_DIR}/.. | grep "Last Changed Rev" | awk '{print $NF}'` 
    97175    if [ ${#REVISION_NB} -eq 0 ] 
    98176    then 
     
    156234                LINEVAR=$( grep -s -n "$VAR_NAME" ${EXE_DIR}/$NAMREF | awk -F: '{ { print $1} }' ) 
    157235                echo " $VAR_NAME found in ${EXE_DIR}/$NAMREF at line $LINEVAR " >> ${SETTE_DIR}/output.sette 
     236 
    158237#   search for namelist group name 
    159238                NAMGRP=$( head -n$LINEVAR ${EXE_DIR}/$NAMREF | grep --line-buffered "^&nam" | tail -1 | awk -F" " '{ { print $1} }' )  
    160239                echo " variable $VAR_NAME will be added in $NAMGRP namelist-group of namelist file ${EXE_DIR}/$1 " >> ${SETTE_DIR}/output.sette 
     240 
     241# check if namelist group present in namelist_cfg 
     242# if missing group is added at the end of namelist_cfg 
     243                NGRP=$(grep ${NAMGRP} ${EXE_DIR}/$1 | wc -l ) 
     244                if [ ${NGRP} -eq 0 ]; then 
     245                   echo ''                                                                          >> ${SETTE_DIR}/output.sette 
     246                   echo "+++++ Group ${NAMGRP} containing ${2} is missing in ${EXE_DIR}/$1 +++++ "  >> ${SETTE_DIR}/output.sette 
     247                   echo "+++++ Group ${NAMGRP}                 is added   in ${EXE_DIR}/$1 +++++ "  >> ${SETTE_DIR}/output.sette 
     248                   echo ''                                                                          >> ${SETTE_DIR}/output.sette 
     249                   echo "&${NAMGRP}" >> ${EXE_DIR}/$1 
     250                   echo "/"          >> ${EXE_DIR}/$1 
     251                fi 
     252 
    161253# Add $VARNAME in namelist file ${EXE_DIR}/$1 in namelist group $NAMGRP 
    162254# on mac osx, replace sed --posix by gsed (available with mac port) 
    163255                sed --posix "/${NAMGRP} /a\ ${VAR_NAME} " ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp || gsed --posix "/${NAMGRP} /a\ ${VAR_NAME} " ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp 
     256 
    164257# if file not empty replace ${EXE_DIR}/$1 
    165                 if [ -s ${EXE_DIR}/$1.tmp ] ; then 
     258               if [ -s ${EXE_DIR}/$1.tmp ] ; then 
    166259                   mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1  
    167260                else 
Note: See TracChangeset for help on using the changeset viewer.