source: TOOLS/SURPACK_IPSL/showListsProgress.sh @ 3624

Last change on this file since 3624 was 2136, checked in by acosce, 11 years ago

add new tools allows packing simulation alreaddy pack (so pack with a bigger frequency)

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