source: TOOLS/PACK_IPSL/showListsProgress.sh @ 1835

Last change on this file since 1835 was 1822, checked in by aclsce, 12 years ago

Modifications done by Guillaume P :

  • error handling for the whole script
  • check of nco version
  • restart tool for list script
  • progress visualization for both scripts
  • "force" option -f added for both scripts
  • timing information added for pack script
  • Property svn:executable set to *
File size: 5.4 KB
Line 
1#!/bin/bash
2
3
4function waitingFor
5{
6   waitedFile=$1
7   
8   # verif que la variable MonitoringDir est bien define
9   if [ "x${MonitoringDir}" == "x" ] 
10   then
11      echo "variable MonitoringDir not defined. stop."
12      exit -1
13   fi
14   
15   # Le fichier teste doit etre dans le rep de suivi
16   isWaitedFileName_In_MonitoringDir=`echo $waitedFile | grep ${MonitoringDir} | wc -l `
17   if [ "x${isWaitedFileName_In_MonitoringDir}" == "x0" ]
18   then
19      echo "The waited file name :"
20      echo "$waitedFile"
21      echo "is incorrect. The location of the file must be in the monitoring dir."
22      exit -1
23   fi
24   
25   waitedFileBasename=$(basename ${waitedFile})
26   # echo "On verifie la presence de ${waitedFileBasename}..."
27   iter=0
28   found=0
29   while [ ${iter} -lt 60 ]
30   do
31      if [ -e $waitedFile ]
32      then
33         found=1
34         break
35      fi     
36      iter=$(( $iter + 1 ))
37      echo "waiting for ${waitedFileBasename}...${iter}..."
38      sleep 1
39   done
40   
41   if [ "x${found}" == "x0"  ]
42   then
43      echo "Le fichier ${waitedFileBasename} n'a pas ete trouve. stop."
44      exit -1
45   fi
46   
47   # echo "fichier trouve !"
48
49}
50
51
52#######################
53# Main program ########
54#######################
55
56# fichier de progression d'execution
57# Le seul arg du script doit etre un fichier param
58paramFile=$(basename ${1})
59if [ ! -e $paramFile ] || [ "x${paramFile}" == "x" ]
60then
61    echo "Le repertoire en argument n existe pas"
62    exit 0
63fi
64extSuiviListes=`echo ${paramFile} | sed 's;\.[[:alnum:]]*$;;' `
65export MonitoringDir="${PWD}/SuiviListes_${extSuiviListes}"
66# echo "MonitoringDir=$MonitoringDir"
67export generalMonitorFile=${MonitoringDir}/general.txt
68export nbSimuFile=${MonitoringDir}/nbSimu.txt
69
70declare -a tabGeneralSteps=()
71tabGeneralSteps[0]="find_directory_simul.sh-->OK"
72tabGeneralSteps[1]="create_config_card.sh-->OK"
73
74declare -a tabSimuSteps=()
75tabSimuSteps[0]="calcul_size_simul.sh-->OK"
76tabSimuSteps[1]="find_size_pack.sh-->OK"
77tabSimuSteps[2]="write_liste_pack.sh-->OK"
78tabSimuSteps[3]="archive_restart.sh-->OK"
79tabSimuSteps[4]="archive_debug.sh-->OK"
80
81echo "#################################################"
82echo "###  ETAT D'AVANCEMENT DES SCRIPTS DE lISTES  ###"
83echo "#################################################"
84echo
85
86# Si le rep de suivi n'existe pas, stop.
87if [ ! -d ${MonitoringDir} ]
88then
89   echo "${MonitoringDir} n'existe pas. stop."
90   exit -1
91fi
92
93cd ${MonitoringDir}
94if [ "x$?" != "x0" ]
95then
96  echo "Pb avec cd ${MonitoringDir}"
97  exit -1
98fi
99
100# Etapes generales
101# ----------------
102echo "--------------------------------------------------"
103echo "---------------- Etapes generales ----------------"
104echo "--------------------------------------------------"
105waitingFor "${generalMonitorFile}"
106
107
108generalStepsDoneList=`cat ${generalMonitorFile} `
109for ((i = 0; i < ${#tabGeneralSteps[*]}; i += 1))
110do
111  isEltInDoneList=`echo $generalStepsDoneList | grep "${tabGeneralSteps[$i]}" | wc -l `
112  if [ "x$isEltInDoneList" == "x0" ]
113  then
114     stringKO=`echo ${tabGeneralSteps[$i]} | sed 's;OK;?? #####;' `
115     echo "$stringKO"
116  else
117     echo "${tabGeneralSteps[$i]}"
118  fi
119 
120done
121
122
123# Etapes createListing
124# --------------------
125echo
126echo "--------------------------------------------------" 
127echo "---------------- Etape createListing -------------"
128echo "--------------------------------------------------" 
129listSubDir=`ls -l | grep -e '^d' | awk '{print $NF}' `
130if [ "x$listSubDir" == "x" ]
131then
132   echo "Aucune liste n'est prete."
133fi
134
135# echo "listSubDir=$listSubDir"
136for rep in $listSubDir
137do
138   cd $rep
139   if [ ! -e createListingOK.txt ]
140   then
141      echo "${rep}: createListing.sh-->?? #####"
142   else
143      echo "${rep}: createListing.sh-->OK"
144   fi
145   
146   cd ..
147done
148echo
149
150echo "--------------------------------------------------" 
151echo "---------------  Etape par simu ------------------"
152echo "--------------------------------------------------"
153if [ "x$listSubDir" == "x" ]
154then
155   echo "Aucune simu n'a ete traitee."
156fi
157
158nbSimuOK=0
159for rep in $listSubDir
160do
161   cd $rep
162   listSimu=`ls -1 | grep -v "createListingOK.txt" `
163   if [ ! -e createListingOK.txt ] || [ "x${listSimu}" == "x" ]
164   then
165      echo "${rep}: Pas de simu traitee"
166   fi
167   # echo "listSimu=$listSimu"
168   for simu in $listSimu
169   do
170       simuDone=1
171       simuName=`echo $simu | sed 's;_#_;/;g' | sed 's;\.txt;;' `
172       echo $simuName
173       simuStepsDoneList=`cat ${simu} `
174       for ((i = 0; i < ${#tabSimuSteps[*]}; i += 1))
175       do
176           isEltInDoneList=`echo $simuStepsDoneList | grep "${tabSimuSteps[$i]}" | wc -l `
177           if [ "x$isEltInDoneList" == "x0" ]
178           then
179              stringKO=`echo ${tabSimuSteps[$i]} | sed 's;OK;?? #####;' `
180              simuDone=$(( $simuDone && 0 ))
181              echo "    $stringKO"
182           else
183              echo "    ${tabSimuSteps[$i]}"
184           fi         
185       done
186       
187       # si toutes les operations sur la simu sont OK, on incremente le nb de simu OK
188       if [ "x$simuDone" == "x1" ]
189       then
190          nbSimuOK=$(( $nbSimuOK + 1 ))
191       fi                 
192   done   
193   cd ..
194done
195
196
197waitingFor "${nbSimuFile}"
198
199nbSimuTot=`cat ${nbSimuFile} `
200nbSimuFormatOK=`echo $nbSimuTot | grep -e '^[0-9]\{1,4\}$' | wc -l`
201if [ "x$nbSimuFormatOK" == "x0" ]
202then
203   echo "Le nombre de simulation contenues dans le fichier $nbSimuFile est incorrect."
204   exit -1
205fi
206
207echo
208echo "============================================="
209echo "nbre de simu OK : $nbSimuOK / $nbSimuTot"
210echo "============================================="
211
212
213
214
215
216
217
218
219
220
Note: See TracBrowser for help on using the repository browser.