Ignore:
Timestamp:
04/05/13 17:34:38 (11 years ago)
Author:
acosce
Message:

made some modifications to speed up archive restart and debug process

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/PACK_IPSL/archive_debug.sh

    r2027 r2045  
    9595 
    9696    ls -l ${STORE_DEBUG} > ${IGCM_TMP}/${$}.new_liste_debug_files.txt 
     97 
     98 
     99#creation des listes en fonction des suffixes 
     100   if [ "x${ON_IDRIS}" == "xno" ] 
     101   then 
     102       awk '{if (NR >1) print $9}' ${IGCM_TMP}/${$}.new_liste_debug_files.txt > ${IGCM_TMP}/${$}.new_liste_debug_files.txt_tmp 
     103   else 
     104       awk '{if (NR >1) print $8}' ${IGCM_TMP}/${$}.new_liste_debug_files.txt > ${IGCM_TMP}/${$}.new_liste_debug_files.txt_tmp        
     105   fi 
     106sort ${IGCM_TMP}/${$}.new_liste_debug_files.txt_tmp > ${IGCM_TMP}/${$}.order_new_liste_debug_files.txt 
     107ref=`awk -F_ '{if (NR==1) print $1}' ${IGCM_TMP}/${$}.order_new_liste_debug_files.txt` 
     108 
     109 
     110 
     111i=1 
     112for new_file in `awk  '{print $0}' ${IGCM_TMP}/${$}.order_new_liste_debug_files.txt`; do  
     113    new_ref=$( echo ${new_file} | sed -e "s/_.*//")  
     114 
     115    if [ ${new_ref} == ${ref} ]; then 
     116        echo ${new_file} >> ${IGCM_TMP}/${$}.debug_list_${i}.txt 
     117    else 
     118        ref=${new_ref} 
     119        (( i = $i + 1 ))  
     120        echo ${new_file} >> ${IGCM_TMP}/${$}.debug_list_${i}.txt 
     121    fi 
     122done 
     123 
     124j=1 
     125while [[ $j -le $i  ]]; do  
     126 
     127 
    97128### 2- creer les listes de fichiers par periode #### 
    98129    DEM_log -1 "Creation des listes de fichiers par periode" 
     
    100131    date_begin=${DateBegin} 
    101132    date_end=${DateEnd} 
    102  
     133     
    103134    year_begin=$(echo ${date_begin} | cut -c 1-4 ) 
    104135    month_begin=$(echo ${date_begin} | cut -c 5-6 ) 
     
    122153        month_end_pack=${month_begin_pack} 
    123154        year_end_pack=`expr ${year_begin_pack} + ${period_pack}` 
    124  
     155         
    125156        date_end_pack=${year_end_pack}${month_end_pack}01    
    126         if [ "x${ON_IDRIS}" == "xno" ] 
    127         then 
    128             for file in `awk '{print $9}' ${IGCM_TMP}/${$}.new_liste_debug_files.txt`; do  
    129                 extract_date_file=`echo ${file}  | sed -e "s/.*\${JobName}_//"` 
    130                 date_file=`echo ${extract_date_file}| sed 's/\([0-9]\{8\}\)_.*$/\1/g'` 
    131                 if [[  "x${date_file}" != "x" && ! -n ${date_file//[0-9]/} ]]; then 
    132                     if [  ${date_file} -lt ${date_end_pack} ] 
     157        for file in `awk '{print $1}' ${IGCM_TMP}/${$}.debug_list_${j}.txt`; do  
     158            extract_date_file=`echo ${file}  | sed -e "s/.*\${JobName}_//"` 
     159            date_file=`echo ${extract_date_file}| sed 's/\([0-9]\{8\}\)_.*$/\1/g'` 
     160            if [[  "x${date_file}" != "x" && ! -n ${date_file//[0-9]/} ]]; then 
     161                if [  ${date_file} -lt ${date_end_pack} ] 
     162                then  
     163                    if [ ${date_file} -ge ${date_begin_pack} ] 
    133164                    then  
    134                         if [ ${date_file} -ge ${date_begin_pack} ] 
    135                         then  
    136                             echo ${file} >> ${IGCM_TMP}/${$}.liste_pack_debug_${number_pack}.txt 
    137                         fi 
    138                     fi  
    139                 fi 
    140             done 
    141         else 
    142             for file in `awk '{print $8}' ${IGCM_TMP}/${$}.new_liste_debug_files.txt`; do  
    143                 extract_date_file=`echo ${file}  | sed -e "s/.*\${JobName}_//"` 
    144                 date_file=`echo ${extract_date_file}| sed 's/\([0-9]\{8\}\)_.*$/\1/g'` 
    145         if [[  "x${date_file}" != "x" && ! -n ${date_file//[0-9]/} ]]; then 
    146                     if [ ${date_file} -lt ${date_end_pack} ] 
    147                     then  
    148                         if [ ${date_file} -ge ${date_begin_pack} ] 
    149                         then  
    150                             echo ${file} >> ${IGCM_TMP}/${$}.liste_pack_debug_${number_pack}.txt 
    151                         fi 
    152                     fi  
    153                 fi 
    154             done   
    155         fi 
     165                        echo ${file} >> ${IGCM_TMP}/${$}.liste_pack_debug_${number_pack}.txt 
     166                        grep -v ${file} ${IGCM_TMP}/${$}.debug_list_${j}.txt > ${IGCM_TMP}/${$}.debug_list_${j}.txt.tmp 
     167                        mv ${IGCM_TMP}/${$}.debug_list_${j}.txt.tmp ${IGCM_TMP}/${$}.debug_list_${j}.txt 
     168                         
     169                    fi 
     170                fi  
     171            fi 
     172            if [  ${date_file} -gt ${date_end_pack} ] 
     173            then  
     174                break 
     175            fi 
     176             
     177        done 
     178        month_begin_pack=${month_end_pack} 
     179        year_begin_pack=${year_end_pack} 
     180 
     181        date_begin_pack=${year_begin_pack}${month_begin_pack}01 
     182 
     183        number_pack=`expr ${number_pack} + 1` 
     184    done 
     185 
     186    ((j = $j + 1 )) 
     187done 
     188 
     189compt_pack=1 
     190while [[ $compt_pack -le $number_pack ]]; do  
     191 
    156192#on archive les debug - le nom de l'archive contiendra ${yearbegin}${monthbegin}_${yearend}${monthend}  
    157193# end etant la date du dernier fichier contenu et non pas la premiere date suivant  
     
    159195#On classe par ordre alphabetique les fichiers contenus dans liste_pack_debug  
    160196#la date du dernier fichier donnera la date de fin du pack 
    161   if [[ -f ${IGCM_TMP}/${$}.liste_pack_debug_${number_pack}.txt ]] ; then 
    162    sort ${IGCM_TMP}/${$}.liste_pack_debug_${number_pack}.txt > ${IGCM_TMP}/${$}.liste_pack_debug_${number_pack}.txt.tmp 
    163  
    164    first_file=$(head -n 1 ${IGCM_TMP}/${$}.liste_pack_debug_${number_pack}.txt.tmp ) 
     197  if [[ -f ${IGCM_TMP}/${$}.liste_pack_debug_${compt_pack}.txt ]] ; then 
     198   sort ${IGCM_TMP}/${$}.liste_pack_debug_${compt_pack}.txt > ${IGCM_TMP}/${$}.liste_pack_debug_${compt_pack}.txt.tmp 
     199 
     200   first_file=$(head -n 1 ${IGCM_TMP}/${$}.liste_pack_debug_${compt_pack}.txt.tmp ) 
    165201   extract_date_file=$( echo ${first_file}  | sed -e "s/.*${JobName}_//" ) 
    166202   DateBegin_Debug=$(echo ${extract_date_file}| sed 's%\([0-9]\{8\}\)_.*$%\1%g' ) 
    167203 
    168    last_file=$(tail -n 1 ${IGCM_TMP}/${$}.liste_pack_debug_${number_pack}.txt.tmp ) 
     204   last_file=$(tail -n 1 ${IGCM_TMP}/${$}.liste_pack_debug_${compt_pack}.txt.tmp ) 
    169205   extract_date_file=$( echo ${last_file}  | sed -e "s/.*${JobName}_//" ) 
    170206   DateEnd_Debug=$(   echo ${extract_date_file}| sed 's%.*\([0-9]\{8\}\)_.*$%\1%g' ) 
    171    mv ${IGCM_TMP}/${$}.liste_pack_debug_${number_pack}.txt.tmp ${DEBUG_TAR}/${JobName}_debug_${DateBegin_Debug}_${DateEnd_Debug}.list 
     207   mv ${IGCM_TMP}/${$}.liste_pack_debug_${compt_pack}.txt.tmp ${DEBUG_TAR}/${JobName}_debug_${DateBegin_Debug}_${DateEnd_Debug}.list 
    172208  fi 
    173209 
    174 DEM_log -1 "Passage de la commande Tar pour archiver la liste creee" 
    175 #   tar -cf ${JobName}_${date_begin_pack}_${DateEnd_Debug}_debug.tar --dereference  --files-from ${DEBUG_TAR}/tar_debug_${date_begin_pack}_${DateEnd_Debug}.list 
    176 #   cat  ${DEBUG_TAR}/tar_debug_${number_pack}.list | xargs rm  
    177210 
    178211 
    179212DEM_log -1 "On definit le datebegin de la  prochaine periode pack" 
    180213#on definit la periode pack suivante 
    181    month_begin_pack=${month_end_pack} 
    182    year_begin_pack=${year_end_pack} 
    183  
    184    date_begin_pack=${year_begin_pack}${month_begin_pack}01 
    185  
    186    number_pack=`expr ${number_pack} + 1` 
    187  
     214 
     215   compt_pack=`expr ${compt_pack} + 1` 
    188216done 
    189217 
Note: See TracChangeset for help on using the changeset viewer.