source: TOOLS/PACK_IPSL/showListsProgress.sh @ 1849

Last change on this file since 1849 was 1849, checked in by acosce, 12 years ago

Add parallel version - global double check - minor bug

  • 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
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}' `
133if [ "x$listSubDir" == "x" ]
134then
135   echo "Aucune liste n'est prete."
136fi
137
138# echo "listSubDir=$listSubDir"
139for rep in $listSubDir
140do
141   cd $rep
142   if [ ! -e createListingOK.txt ]
143   then
144      echo "${rep}: createListing.sh-->?? #####"
145   else
146      echo "${rep}: createListing.sh-->OK"
147   fi
148   
149   cd ..
150done
151echo
152
153echo "--------------------------------------------------" 
154echo "---------------  Etape par simu ------------------"
155echo "--------------------------------------------------"
156if [ "x$listSubDir" == "x" ]
157then
158   echo "Aucune simu n'a ete traitee."
159fi
160
161nbSimuOK=0
162for rep in $listSubDir
163do
164   cd $rep
165   listSimu=`ls -1 | grep -v "createListingOK.txt" `
166   if [ ! -e createListingOK.txt ] || [ "x${listSimu}" == "x" ]
167   then
168      echo "${rep}: Pas de simu traitee"
169   fi
170   # echo "listSimu=$listSimu"
171   for simu in $listSimu
172   do
173       simuDone=1
174       simuName=`echo $simu | sed 's;_#_;/;g' | sed 's;\.txt;;' `
175       echo $simuName
176       simuStepsDoneList=`cat ${simu} `
177       for ((i = 0; i < ${#tabSimuSteps[*]}; i += 1))
178       do
179           isEltInDoneList=`echo $simuStepsDoneList | grep "${tabSimuSteps[$i]}" | wc -l `
180           if [ "x$isEltInDoneList" == "x0" ]
181           then
182              stringKO=`echo ${tabSimuSteps[$i]} | sed 's;OK;?? #####;' `
183              simuDone=$(( $simuDone && 0 ))
184              echo "    $stringKO"
185           else
186              echo "    ${tabSimuSteps[$i]}"
187           fi         
188       done
189       
190       # si toutes les operations sur la simu sont OK, on incremente le nb de simu OK
191       if [ "x$simuDone" == "x1" ]
192       then
193          nbSimuOK=$(( $nbSimuOK + 1 ))
194       fi                 
195   done   
196   cd ..
197done
198
199
200waitingFor "${nbSimuFile}"
201
202nbSimuTot=`cat ${nbSimuFile} `
203nbSimuFormatOK=`echo $nbSimuTot | grep -e '^[0-9]\{1,4\}$' | wc -l`
204if [ "x$nbSimuFormatOK" == "x0" ]
205then
206   echo "Le nombre de simulation contenues dans le fichier $nbSimuFile est incorrect."
207   exit -1
208fi
209
210echo
211echo "============================================="
212echo "nbre de simu OK : $nbSimuOK / $nbSimuTot"
213echo "============================================="
214
215
216
217
218
219
220
221
222
223
Note: See TracBrowser for help on using the repository browser.