source: TOOLS/PACK_IPSL/showPackProgress.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: 8.8 KB
Line 
1#!/bin/bash
2
3export JOB_DIR=${LS_SUBCWD:-${PWD}}
4export EXE_DIR=${JOB_DIR}
5
6# gpdebug : pour titane
7# ---------------------
8# export INPUT_DMF_DATA=${SCRATCHDIR}/datasLabo/dataDMNFS_simple1
9# export OUTPUT_STORE=${SCRATCHDIR}/PSEUDO_DMNFS_STORE
10# export OUTPUT_WORK=${SCRATCHDIR}/PSEUDO_DMNFS_WORK
11
12
13# gpdebug : pour curie
14# --------------------
15export INPUT_DMF_DATA=${SCRATCHDIR}/dataDMNFS_FromTitane
16export OUTPUT_STORE=${SCRATCHDIR}/dataDMNFS_FromTitane_STORE
17export OUTPUT_WORK=${SCRATCHDIR}/dataDMNFS_FromTitane_WORK
18
19SCRIPT_NAME=$(basename ${0} )
20
21export IGCM_DEM=${SCRATCHDIR}/IGCM_DEM
22export IGCM_TMP=${SCRATCHDIR}/IGCM_DEM/tmp
23
24export config_card=${IGCM_DEM}/config_card.liste
25
26source ${EXE_DIR}/DEM_utilities.sh
27
28export timeHandlingFile="timeHandlingFile.txt"
29
30
31function getSimuName
32{   
33   config_card=$1
34   
35   baseName=$( basename $config_card )
36   simuName=`echo ${baseName} | sed 's;config_card_;;' `
37   echo $simuName
38
39}
40
41function getTimeTaken
42{
43   statFile=$1
44   if [ ! -e $statFile ]
45   then
46      echo "inconnu : pas de fichier status"
47      return
48   fi
49   
50   timeLine=`sed -n '1p' $statFile `
51   goodFormat=`echo $timeLine | grep -e '^meantime:[[:digit:]]*\.[[:digit:]]\{1,3\}$' | wc -l `
52   if [ "x$goodFormat" == "x0" ]
53   then
54       echo "inconnu : mauvais format du temps"
55       return
56   fi
57   
58   timeTaken=`echo $timeLine | sed 's;^meantime:;;' `
59   echo $timeTaken
60   
61}
62
63function progressStatus
64{
65   statFile=$1
66   echo "statFile=$1" >> showPackProgress.log
67   if [ ! -e $statFile ]
68   then
69      echo "Non traitee"
70      return
71   fi
72   echo "blabla" >> showPackProgress.log
73   echo "----------------------------------------------" >> showPackProgress.log
74   # echo "progressStatus..." # gpdebug : a virer
75   
76   # ------------------------------------------------------------------------------------------------
77   listLineNumWithKey=`grep -n -E '(COMPLETED|FAILED|DELEGATE)' $statFile | awk -F":" '{print $1}' ` 
78   # echo "listLineNumWithKey=$listLineNumWithKey" # gpdebug : a virer
79   
80  if [ "x$listLineNumWithKey" == "x" ]
81  then
82     echo "Statut illisible"
83     return
84  fi
85
86   # On trouve la derniere ligne du fichier status comportant un mot cle
87   max=0
88   for lineNum in $listLineNumWithKey
89   do
90      if [ $lineNum -gt $max ]
91      then
92          max=$lineNum
93      fi
94   done
95
96   # echo "max=$max" # gpdebug : a virer
97
98   lastLineWithKey=`sed -n "${max}p" $statFile `
99   # echo "lastLineWithKey=$lastLineWithKey" # gpdebug : a virer   
100   # ------------------------------------------------------------------------------------------------
101     
102   # lastLine=`tail -1 $statFile ` # gpdebug : a virer
103   
104   completed=`echo $lastLineWithKey | grep COMPLETED | sed 's; (.*)$;;' `
105   if [ "x${completed}" != "x" ]
106   then
107      echo $completed
108      return
109   fi
110   
111  failed=`echo $lastLineWithKey | grep FAILED | cut -d";" -f1 `
112  if [ "x${failed}" != "x" ]
113  then
114     echo $failed
115     return         
116  fi
117 
118  delegate=`echo $lastLineWithKey | grep DELEGATE `
119  if [ "x${delegate}" != "x" ]
120  then
121     echo "DELEGATE"
122     return
123  fi
124 
125}
126
127
128function getWaitingTime
129{
130    timeNow_=$1
131    stillWaiting_=1
132   
133    launchTimeString=`cat $timeHandlingFile | grep -e 'launch time:[[:digit:].]*$' `
134    if [ "x${launchTimeString}" == "x" ]
135    then
136        echo "no launch time"
137        return
138    fi
139    launchTime_=`echo $launchTimeString | awk -F":" '{print $2}' `
140   
141   
142    startExecTimeString=`cat $timeHandlingFile | grep -e 'start time:[[:digit:].]*$' `
143    if [ "x${startExecTimeString}" == "x" ]
144    then
145        execTime_=${timeNow_}   
146    else
147        execTime_=`echo $startExecTimeString | awk -F":" '{print $2}' `
148        stillWaiting_=0
149    fi
150   
151    waitingTime_=$( awk 'BEGIN { print '${execTime_}'-'${launchTime_}' }' )
152    waitingTime_=$( awk 'BEGIN { print '${waitingTime_}'/'1000' }' )
153    if [ "x$stillWaiting_" == "x1" ]
154    then
155       waitingTime_="${waitingTime_}, still waiting..."
156    fi
157   
158    echo $waitingTime_
159}
160   
161   
162function getTimeSinceExecutionStart
163{ 
164   
165    timeNow_=$1
166    stillWaiting_=1   
167   
168    execTimeString=`cat $timeHandlingFile | grep -e 'start time:[[:digit:].]*$' `
169    if [ "x${execTimeString}" == "x" ]
170    then
171        echo "no start time"
172        return
173    fi
174    execTime_=`echo $execTimeString | awk -F":" '{print $2}' `
175   
176       
177    endTimeString=`cat $timeHandlingFile | grep -e 'end time:[[:digit:].]*$' `
178    if [ "x${endTimeString}" == "x" ]
179    then
180        endTime_=${timeNow_}
181    else
182        endTime_=`echo $endTimeString | awk -F":" '{print $2}' `
183        stillWaiting_=0
184    fi
185   
186    timeSinceExec_=$( awk 'BEGIN { print '${endTime_}'-'${execTime_}' }' )
187    timeSinceExec_=$( awk 'BEGIN { print '${timeSinceExec_}'/'1000' }' )
188    if [ "x$stillWaiting_" == "x1" ]
189    then
190       timeSinceExec_="${timeSinceExec_}, still executing..."
191    fi
192   
193    echo $timeSinceExec_
194}
195
196#################################
197####### Main script #############
198#################################
199> showPackProgress.log # vider le fichier de log
200
201# Recuperation des temps d'attente et ecoule depuis de demarrage des traitements en batch
202if [ -e $timeHandlingFile ]
203then
204    timeNow=$( getDateMilliSeconds )
205    waitingTime=$( getWaitingTime $timeNow )
206    timeSinceExecutionStart=$( getTimeSinceExecutionStart $timeNow )
207else
208    waitingTime="no handling time file available."
209    timeFromExecutionStart="no handling time file available."
210fi
211
212
213totalNbOfList=0
214for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste )
215do
216   PATH_SIMU=$( dirname $CONFIG )
217   nbListInConfig=`find $PATH_SIMU -name "*list" | wc -l `
218   totalNbOfList=$(( $totalNbOfList + $nbListInConfig ))
219done
220
221# echo "totalNbOfList=$totalNbOfList"
222# exit 0 # gpdebug : a virer
223
224nbOfListsPacked=0
225nbOfListsFailed=0
226TotalNbInodes=0
227TotalSimuTar=0
228totalTime=0
229
230for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste ) ; do
231
232    DEM_state=$( DEM_read_state ${IGCM_DEM}/config_card.liste ${CONFIG} )
233
234    if [[ "${DEM_state}" != "TarDone" ]] ; then
235
236         simuName=$( getSimuName $CONFIG )
237         echo "*******************************************"
238         echo "simulation : $simuName"
239         echo "*******************************************"
240         export PATH_SIMU=$( dirname $CONFIG )
241         # echo "PATH_SIMU = $PATH_SIMU"
242       
243         listOfDir="output_ncrcat output_tar restart_tar debug_tar store_cp work_cp"
244         for dir in $listOfDir
245         do
246             echo "   ${dir} :"
247             if [ ! -d $PATH_SIMU/${dir} ]
248             then
249                echo "      ${dir} n'existe pas pour cette simu"
250                continue
251             fi
252           
253             listFilesInDir=`find $PATH_SIMU/${dir} -name "*list" | wc -l `
254             if [ "x$listFilesInDir" == "x0" ]
255             then
256                echo "       -- no list --"
257                continue           
258             fi
259           
260             setList=$( ls $PATH_SIMU/${dir}/*list )
261
262             for set in $setList
263             do
264                  listName=`echo $(basename $set) | sed 's;\.list$;;' | sed 's;\.nc$;;' `
265                  ListNbInode=`cat $set |wc -l`
266                  TotalNbInodes=$(( $TotalNbInodes + $ListNbInode ))
267                  statusfile=${set%%.list}.status
268                  status=$( progressStatus $statusfile ) # gpdebug : a retablir
269                  timeTaken="???"
270                  # progressStatus $statusfile # gpdebug : a virer
271                  # exit 0 # gpdebug : a virer
272               
273                  packFailed=`echo $status | grep -E '(DELEGATE|FAILED|illisible)' | wc -l `
274                  if [ "x${packFailed}" != "x0" ]
275                  then
276                     nbOfListsFailed=$(( $nbOfListsFailed + 1 ))
277                  fi
278               
279                  packSuccess=`echo $status | grep "COMPLETED" | wc -l `
280                  if [ "x${packSuccess}" != "x0" ]
281                  then
282                     timeTaken=$( getTimeTaken $statusfile )
283                     nbOfListsPacked=$(( $nbOfListsPacked + 1 ))
284                  fi
285                 
286                  echo "       $listName : $status | time : $timeTaken"
287                 
288                  timeInSecondsOK=`echo $timeTaken | grep -e '^[[:digit:].]*$' | wc -l `
289                  if [ "x${timeInSecondsOK}" != "x0" ]
290                  then
291                      totalTime=$(awk 'BEGIN { print '$totalTime'+'$timeTaken' }')
292                  fi
293             done
294         done
295    else
296#si "${DEM_state}" == "TarDone"
297
298         simuName=$( getSimuName $CONFIG )
299         echo "*******************************************"
300         echo "simulation : $simuName TAR"
301         echo "*******************************************"
302         TotalSimuTar=$(( $TotalSimuTar + 1 ))
303    fi
304done
305
306NbInodeBefore=`cat ${IGCM_DEM}/Listing.txt |wc -l`
307find $IGCM_DEM -printf "%y %s %p \n" >> ${IGCM_DEM}/ListingEnd.txt
308NbInodeAfter=`cat ${IGCM_DEM}/ListingEnd.txt |wc -l`
309echo
310echo "##################"
311echo "#####  BILAN #####"
312echo "##################"
313echo "nb of Lists packed with success : ${nbOfListsPacked} / ${totalNbOfList}"
314echo "nb of fails : $nbOfListsFailed"
315echo "nb of inodes packed : $TotalNbInodes"
316echo "nb simul full tared : $TotalSimuTar"
317echo "nb inode before : $NbInodeBefore"
318echo "nb inode after : $NbInodeAfter"
319echo "Total time for elementary operations : $totalTime  (sum of times on several proc)" 
320echo "waiting time : $waitingTime"
321echo "Time since execution start : $timeSinceExecutionStart" 
322
323
324
325
Note: See TracBrowser for help on using the repository browser.