source: TOOLS/PACK_IPSL/showListsProgress.sh @ 1888

Last change on this file since 1888 was 1886, checked in by gpincka, 12 years ago

oups : petite correction

  • Property svn:executable set to *
File size: 5.8 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
58
59paramFile=${1}
60paramFileBasename=$(basename ${1})
61
62if [ ! -e $paramFile ] || [ "x${paramFile}" == "x" ]
63then
64    echo "Le fichier en argument n existe pas"
65    exit 0
66fi
67extSuiviListes=`echo ${paramFileBasename} | sed 's;\.[[:alnum:]]*$;;' `
68export MonitoringDir="${PWD}/SuiviListes_${extSuiviListes}"
69# echo "MonitoringDir=$MonitoringDir"
70export generalMonitorFile=${MonitoringDir}/general.txt
71export nbSimuFile=${MonitoringDir}/nbSimu.txt
72
73declare -a tabGeneralSteps=()
74tabGeneralSteps[0]="find_directory_simul.sh-->OK"
75tabGeneralSteps[1]="create_config_card.sh-->OK"
76
77declare -a tabSimuSteps=()
78tabSimuSteps[0]="calcul_size_simul.sh-->OK"
79tabSimuSteps[1]="find_size_pack.sh-->OK"
80tabSimuSteps[2]="write_liste_pack.sh-->OK"
81tabSimuSteps[3]="archive_restart.sh-->OK"
82tabSimuSteps[4]="archive_debug.sh-->OK"
83
84echo "#################################################"
85echo "###  ETAT D'AVANCEMENT DES SCRIPTS DE lISTES  ###"
86echo "#################################################"
87echo
88
89# Si le rep de suivi n'existe pas, stop.
90if [ ! -d ${MonitoringDir} ]
91then
92   echo "${MonitoringDir} n'existe pas. stop."
93   exit -1
94fi
95
96cd ${MonitoringDir}
97if [ "x$?" != "x0" ]
98then
99  echo "Pb avec cd ${MonitoringDir}"
100  exit -1
101fi
102
103# Etapes generales
104# ----------------
105echo "--------------------------------------------------"
106echo "---------------- Etapes generales ----------------"
107echo "--------------------------------------------------"
108waitingFor "${generalMonitorFile}"
109
110
111generalStepsDoneList=`cat ${generalMonitorFile} `
112for ((i = 0; i < ${#tabGeneralSteps[*]}; i += 1))
113do
114  isEltInDoneList=`echo $generalStepsDoneList | grep "${tabGeneralSteps[$i]}" | wc -l `
115  if [ "x$isEltInDoneList" == "x0" ]
116  then
117     stringKO=`echo ${tabGeneralSteps[$i]} | sed 's;OK;?? #####;' `
118     echo "$stringKO"
119  else
120     echo "${tabGeneralSteps[$i]}"
121  fi
122 
123done
124
125
126# Etapes createListing
127# --------------------
128echo
129echo "--------------------------------------------------" 
130echo "---------------- Etape createListing -------------"
131echo "--------------------------------------------------" 
132listSubDir=`ls -l | grep -e '^d' | awk '{print $NF}' `
133# echo "listSubDir=$listSubDir"
134if [ "x$listSubDir" == "x" ]
135then
136   echo "Aucune liste n'est prete."
137fi
138
139# echo "listSubDir=$listSubDir"
140for rep in $listSubDir
141do
142   cd $rep
143   if [ ! -e createListingOK.txt ]
144   then
145      echo "${rep}: createListing.sh-->?? #####"
146   else
147      echo "${rep}: createListing.sh-->OK"
148   fi
149   
150   cd ..
151done
152echo
153
154echo "--------------------------------------------------" 
155echo "---------------  Etape par simu ------------------"
156echo "--------------------------------------------------"
157if [ "x$listSubDir" == "x" ]
158then
159   echo "Aucune simu n'a ete traitee."
160fi
161
162nbSimuOK=0
163for rep in $listSubDir
164do
165   cd $rep
166   listSimu=`ls -1 | grep -v "createListingOK.txt" `
167   if [ ! -e createListingOK.txt ] || [ "x${listSimu}" == "x" ]
168   then
169      echo "${rep}: Pas de simu traitee"
170   fi
171   # echo "listSimu=$listSimu"
172   for simu in $listSimu
173   do
174       simuDone=1
175       simuName=`echo $simu | sed 's;_#_;/;g' | sed 's;\.txt;;' `
176       
177       # Cas des simu speciales ( < 1 Go ou de type etat0 ) #############
178       isSpecialSimuOK=`cat ${simu} | grep "special simu==>OK" | wc -l `
179       if [ "x${isSpecialSimuOK}" != "x0" ]
180       then
181           echo "$simuName : special simulation ==> OK"
182           nbSimuOK=$(( $nbSimuOK + 1 ))
183           continue
184       fi
185       
186       
187       # Cas des simus normales
188       echo $simuName
189       simuStepsDoneList=`cat ${simu} `
190       for ((i = 0; i < ${#tabSimuSteps[*]}; i += 1))
191       do
192           isEltInDoneList=`echo $simuStepsDoneList | grep "${tabSimuSteps[$i]}" | wc -l `
193           if [ "x$isEltInDoneList" == "x0" ]
194           then
195              stringKO=`echo ${tabSimuSteps[$i]} | sed 's;OK;?? #####;' `
196              simuDone=$(( $simuDone && 0 ))
197              echo "    $stringKO"
198           else
199              echo "    ${tabSimuSteps[$i]}"
200           fi         
201       done
202       
203       # si toutes les operations sur la simu sont OK, on incremente le nb de simu OK
204       if [ "x$simuDone" == "x1" ]
205       then
206          nbSimuOK=$(( $nbSimuOK + 1 ))
207       fi                 
208   done   
209   cd ..
210done
211
212
213waitingFor "${nbSimuFile}"
214
215nbSimuTot=`cat ${nbSimuFile} `
216nbSimuFormatOK=`echo $nbSimuTot | grep -e '^[0-9]\{1,4\}$' | wc -l`
217if [ "x$nbSimuFormatOK" == "x0" ]
218then
219   echo "Le nombre de simulation contenues dans le fichier $nbSimuFile est incorrect."
220   exit -1
221fi
222
223echo
224echo "============================================="
225echo "nbre de simu OK : $nbSimuOK / $nbSimuTot"
226echo "============================================="
227
228
229
230
231
232
233
234
235
236
Note: See TracBrowser for help on using the repository browser.