source: TOOLS/PACK_IPSL/showPackProgress.sh @ 1822

Last change on this file since 1822 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.2 KB
Line 
1#!/bin/bash
2
3export JOB_DIR=${LS_SUBCWD:-${PWD}}
4export EXE_DIR=${JOB_DIR}
5
6export INPUT_DMF_DATA=${SCRATCHDIR}/PSEUDO_DMNFS_light
7export OUTPUT_STORE=${SCRATCHDIR}/PSEUDO_DMNFS_STORE
8export OUTPUT_WORK=${SCRATCHDIR}/PSEUDO_DMNFS_WORK
9
10SCRIPT_NAME=$(basename ${0} )
11
12export IGCM_DEM=${SCRATCHDIR}/IGCM_DEM
13export IGCM_TMP=${SCRATCHDIR}/IGCM_DEM/tmp
14
15export config_card=${IGCM_DEM}/config_card.liste
16
17source ${EXE_DIR}/DEM_utilities.sh
18
19
20function getSimuName
21{   
22   config_card=$1
23   
24   baseName=$( basename $config_card )
25   simuName=`echo ${baseName} | sed 's;config_card_;;' `
26   echo $simuName
27
28}
29
30function getTimeTaken
31{
32   statFile=$1
33   if [ ! -e $statFile ]
34   then
35      echo "inconnu : pas de fichier status"
36      return
37   fi
38   
39   timeLine=`sed -n '1p' $statFile `
40   goodFormat=`echo $timeLine | grep -e '^meantime:[[:digit:]]*\.[[:digit:]]\{1,3\}$' | wc -l `
41   if [ "x$goodFormat" == "x0" ]
42   then
43       echo "inconnu : mauvais format du temps"
44       return
45   fi
46   
47   timeTaken=`echo $timeLine | sed 's;^meantime:;;' `
48   echo $timeTaken
49   
50}
51
52function progressStatus
53{
54   statFile=$1
55   echo "statFile=$1" >> showPackProgress.log
56   if [ ! -e $statFile ]
57   then
58      echo "Non traitee"
59      return
60   fi
61   echo "blabla" >> showPackProgress.log
62   echo "----------------------------------------------" >> showPackProgress.log
63   # echo "progressStatus..." # gpdebug : a virer
64   
65   # ------------------------------------------------------------------------------------------------
66   listLineNumWithKey=`grep -n -E '(COMPLETED|FAILED|DELEGATE)' $statFile | awk -F":" '{print $1}' ` 
67   # echo "listLineNumWithKey=$listLineNumWithKey" # gpdebug : a virer
68   
69  if [ "x$listLineNumWithKey" == "x" ]
70  then
71     echo "Statut illisible"
72     return
73  fi
74
75   # On trouve la derniere ligne du fichier status comportant un mot cle
76   max=0
77   for lineNum in $listLineNumWithKey
78   do
79      if [ $lineNum -gt $max ]
80      then
81          max=$lineNum
82      fi
83   done
84
85   # echo "max=$max" # gpdebug : a virer
86
87   lastLineWithKey=`sed -n "${max}p" $statFile `
88   # echo "lastLineWithKey=$lastLineWithKey" # gpdebug : a virer   
89   # ------------------------------------------------------------------------------------------------
90     
91   # lastLine=`tail -1 $statFile ` # gpdebug : a virer
92   
93   completed=`echo $lastLineWithKey | grep COMPLETED | sed 's; (.*)$;;' `
94   if [ "x${completed}" != "x" ]
95   then
96      echo $completed
97      return
98   fi
99   
100  failed=`echo $lastLineWithKey | grep FAILED | cut -d";" -f1 `
101  if [ "x${failed}" != "x" ]
102  then
103     echo $failed
104     return         
105  fi
106 
107  delegate=`echo $lastLineWithKey | grep DELEGATE `
108  if [ "x${delegate}" != "x" ]
109  then
110     echo "DELEGATE"
111     return
112  fi
113 
114}
115
116
117#################################
118####### Main script #############
119#################################
120> showPackProgress.log # vider le fichier de log
121
122totalNbOfList=0
123for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste )
124do
125   PATH_SIMU=$( dirname $CONFIG )
126   nbListInConfig=`find $PATH_SIMU -name "*list" | wc -l `
127   totalNbOfList=$(( $totalNbOfList + $nbListInConfig ))
128done
129
130# echo "totalNbOfList=$totalNbOfList"
131# exit 0 # gpdebug : a virer
132
133nbOfListsPacked=0
134nbOfListsFailed=0
135
136for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste ) ; do
137
138    DEM_state=$( DEM_read_state ${IGCM_DEM}/config_card.liste ${CONFIG} )
139
140    if [[ "${DEM_state}" != "WriteListTarDone" ]] ; then
141
142         simuName=$( getSimuName $CONFIG )
143         echo "*******************************************"
144         echo "simulation : $simuName"
145         echo "*******************************************"
146         export PATH_SIMU=$( dirname $CONFIG )
147         # echo "PATH_SIMU = $PATH_SIMU"
148       
149         listOfDir="output_ncrcat output_tar restart_tar debug_tar store_cp work_cp"
150         for dir in $listOfDir
151         do
152             echo "   ${dir} :"
153             if [ ! -d $PATH_SIMU/${dir} ]
154             then
155                echo "      ${dir} n'existe pas pour cette simu"
156                continue
157             fi
158           
159             listFilesInDir=`find $PATH_SIMU/${dir} -name "*list" | wc -l `
160             if [ "x$listFilesInDir" == "x0" ]
161             then
162                echo "       -- no list --"
163                continue           
164             fi
165           
166             setList=$( ls $PATH_SIMU/${dir}/*list )
167
168             for set in $setList
169             do
170                  listName=`echo $(basename $set) | sed 's;\.list$;;' | sed 's;\.nc$;;' `
171           
172                  statusfile=${set%%.list}.status
173                  status=$( progressStatus $statusfile ) # gpdebug : a retablir
174                  timeTaken="???"
175                  # progressStatus $statusfile # gpdebug : a virer
176                  # exit 0 # gpdebug : a virer
177               
178                  packFailed=`echo $status | grep -E '(DELEGATE|FAILED|illisible)' | wc -l `
179                  if [ "x${packFailed}" != "x0" ]
180                  then
181                     nbOfListsFailed=$(( $nbOfListsFailed + 1 ))
182                  fi
183               
184                  packSuccess=`echo $status | grep "COMPLETED" | wc -l `
185                  if [ "x${packSuccess}" != "x0" ]
186                  then
187                     timeTaken=$( getTimeTaken $statusfile )
188                     nbOfListsPacked=$(( $nbOfListsPacked + 1 ))
189                  fi
190                 
191                  echo "       $listName : $status | time : $timeTaken"
192             done
193         done
194    fi
195done
196echo
197echo "##################"
198echo "#####  BILAN #####"
199echo "##################"
200echo "nb of Lists packed with success : ${nbOfListsPacked} / ${totalNbOfList}"
201echo "nb of fails : $nbOfListsFailed"
202
203
204
205
Note: See TracBrowser for help on using the repository browser.