source: trunk/libIGCM/AA_TimeSeries_Checker @ 387

Last change on this file since 387 was 387, checked in by sdipsl, 14 years ago
  • function IGCM_sys_Get_Master on cesium will try 10 times to scp files from master machine. Hopefully the last cesium consolidation
  • function IGCM_config_Check will check chunck2D/3D consistency with TimeSeriesFrequency?.
  • change the way the output from post-processing script was named. We will now have:

-rebuild_fromWorkdir.20051231.out
-create_ts.20051231.2D.out
-create_ts.20051231.3D.out
-atlas_PISCES.19991231.out
-create_ts.20051231.Chunck2D.ATM.POST_1D_histday.out
-create_ts.20051231.Chunck2D.OCE.POST_1D_grid_T.out

  • remove modipsl headers from AA_SE_Checker, AA_TimeSeries_Checker, AA_move-and-rename
    • they check and submit job. They do not use resources and so there is no point to submit them
    • they will be rename shortly SE_Checker.ksh, TimeSeries_Checker.ksh, move-and-rename.ksh
  • cosmetics
  • Property svn:keywords set to Revision Author Date
File size: 14.3 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil
5# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
6# $Revision::                                          $ Revision of last commit
7# $Author::                                            $ Author of last commit
8# $Date::                                              $ Date of last commit
9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11#
12#**************************************************************
13
14# Check that everything went well during time series production
15# Display a short report
16# Launch what's missing
17# For use during a run (not on the end : PeriodState=Completed), it will complete
18# all TS to last PeriodDateEnd value, give by run.card->Configuration->OldPrefix string.
19
20# Chemin vers libIGCM
21libIGCM=${libIGCM:=::modipsl::/libIGCM}
22# Attention : à changer si la machine de post-traitement n'est pas la frontale du serveur de calcul !
23#             voir précence de la variable MirrorlibIGCM dans votre couche systÚme.
24
25# Name Space of this experience
26SpaceName=${SpaceName:=PROD}
27
28# Expericence class of the run
29ExperimentName=${ExperimentName:=historical}
30
31# Name of this job
32JobName=${JobName:=v2.historical1}
33
34# répertoire courrant
35CURRENT_DIR=$( pwd )
36
37# Emplacement des cartes
38CARD_DIR=${CARD_DIR:=${CURRENT_DIR}/${ExperimentName}/${JobName}}
39
40# répertoire de stockage des sorties des create_ts
41POST_DIR=${POST_DIR:=${CARD_DIR}/OutScript}
42
43if [ ! -d ${CARD_DIR} ]; then
44    echo "No ${CARD_DIR}, we stop here"
45    exit
46fi
47
48########################################################################
49
50. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh ;
51. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh     #; IGCM_debug_Check
52. ${libIGCM}/libIGCM_card/libIGCM_card.ksh   #; IGCM_card_Check
53. ${libIGCM}/libIGCM_date/libIGCM_date.ksh   #; IGCM_date_Check
54
55########################################################################
56
57#set -vx
58
59# First of all
60IGCM_card_DefineArrayFromSection       ${CARD_DIR}/config.card UserChoices
61typeset option
62for option in ${config_UserChoices[*]} ; do
63    IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card UserChoices ${option}
64done
65
66echo
67IGCM_debug_Print 1 "DefineVariableFromOption  : config_UserChoices"
68IGCM_debug_PrintVariables 3 config_UserChoices_JobName
69#IGCM_debug_PrintVariables 3 config_UserChoices_SpaceName
70#IGCM_debug_PrintVariables 3 config_UserChoices_ExperimentName
71IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType
72IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin
73IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd
74
75if [ -f ${CARD_DIR}/run.card ] ; then
76    IGCM_card_DefineVariableFromOption ${CARD_DIR}/run.card Configuration OldPrefix
77    IGCM_card_DefineVariableFromOption ${CARD_DIR}/run.card Configuration PeriodState
78    IGCM_card_DefineVariableFromOption ${CARD_DIR}/run.card PostProcessing TimeSeriesCompleted
79    IGCM_debug_Print 1 "DefineVariableFromOption  : run_Configuration"
80    IGCM_debug_PrintVariables 3 run_Configuration_OldPrefix
81    IGCM_debug_PrintVariables 3 run_Configuration_PeriodState
82    IGCM_debug_Print 1 "DefineVariableFromOption  : run_PostProcessing"
83    IGCM_debug_PrintVariables 3 run_PostProcessing_TimeSeriesCompleted
84    if [ X${run_Configuration_PeriodState} != X"Completed" ] ; then
85        DateEnd=$( IGCM_date_ConvertFormatToGregorian $( echo ${run_Configuration_OldPrefix} | awk -F'_' '{print $2}' ) )
86    else
87        DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )
88    fi
89    CompletedFlag=${run_PostProcessing_TimeSeriesCompleted}
90else
91    DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )
92    CompletedFlag=""
93fi
94SavedCompletedFlag=${CompletedFlag}
95DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
96
97IGCM_date_GetYearMonth ${DateBegin} YearBegin MonthBegin
98IGCM_date_GetYearMonth ${DateEnd}   YearEnd   MonthEnd
99
100echo
101IGCM_debug_Print 1 "DateBegin for TimeSeries_Checker : "${DateBegin}
102IGCM_debug_Print 1 "DateEnd   for TimeSeries_Checker : "${DateEnd}
103IGCM_debug_Print 1 "YearBegin MonthBegin for TimeSeries_Checker : ${YearBegin} ${MonthBegin}"
104IGCM_debug_Print 1 "YearEnd   MonthEnd   for TimeSeries_Checker : ${YearEnd} ${MonthEnd}"
105IGCM_debug_Print 1 "CompletedFlag = "${CompletedFlag}
106echo
107
108#====================================================
109#R_SAVE : Job output directory
110if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then
111    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' )
112    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
113    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
114else
115    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
116    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName}
117fi
118
119IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card ListOfComponents
120
121for comp in ${config_ListOfComponents[*]} ; do
122    # Debug Print
123    IGCM_debug_Print 1 ${comp}
124    # Define component
125    IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp}
126    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
127    eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
128
129    # Read libIGCM compatibility version in ${compname}.card
130    card=${CARD_DIR}/COMP/${compname}.card
131
132    # Read and Build Output File stuff
133    #IGCM_debug_Print 1 "DefineArrayFromOption  : ${compname}_OutputFiles ${card}"
134    IGCM_card_DefineArrayFromOption ${card} OutputFiles List
135    ListFilesName=${compname}_OutputFiles_List
136    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
137    #
138    if [ X${FileName0} != X${NULL_STR} ] ; then
139        #
140        #IGCM_debug_Print 1 "Component      : ${compname}"
141        #
142        # INITIALISATION
143        #
144        eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
145        i=2
146        #
147        until [ $i -ge $NbFiles ]; do
148            #
149            eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1
150            #
151            if [ X${flag_post} != XNONE ] ; then
152                #
153                # First of all
154                #
155                IGCM_card_DefineArrayFromSection ${card} ${flag_post}
156                #
157                IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars
158                IGCM_card_DefineArrayFromOption ${card} ${flag_post} Patches
159                if [ X"$( eval echo \${${compname}_${flag_post}_TimeSeriesVars[*]} )" = X"Option not found ${flag_post}" ] ; then
160                    # New TimeSeriesVar description, with 2D, 3D and associate ChunckJob.
161                    unset ListDimension
162                    ListDimension[0]=2D
163                    ListDimension[1]=3D
164                    TimeSeries=false
165                    TimeSeries2D=false
166                    TimeSeries3D=false
167                    chunck=false
168                    iLoop=${#ListDimension[*]}
169                    j=0
170                    until [ $j -ge ${iLoop} ]; do
171                        Dimension=${ListDimension[${j}]}
172                        IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars${Dimension}
173                        IGCM_card_DefineVariableFromOption ${card} ${flag_post} ChunckJob${Dimension}
174                        #
175                        # Time series WITHOUT chunk
176                        #
177                        if [ ! $( eval echo \${${compname}_${flag_post}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then
178                            if [ $( eval echo \${${compname}_${flag_post}_ChunckJob${Dimension}} ) = NONE ] ; then
179                                IGCM_debug_Print 2 "${Dimension} time series activated for ${flag_post}"
180                                eval TimeSeries${Dimension}=true
181                                chunck=false
182                            fi
183                        fi
184                        #
185                        # Time series WITH chunk
186                        #
187                        if [ ! $( eval echo \${${compname}_${flag_post}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then
188                            chunck_size=$( eval echo \${${compname}_${flag_post}_ChunckJob${Dimension}} )
189                            if [ ! ${chunck_size} = NONE ] &&  [ ! ${chunck_size} = OFF ] ; then
190                                IGCM_debug_Print 2 "${Dimension} time series activated with ${chunck_size} chunck for ${flag_post}"
191                                eval TimeSeriesChunck${Dimension}=true
192                                chunck=true
193                            fi
194                        fi
195                        (( j=j+1 ))
196                        #
197                        # If TimeSeriesVars list is empty or OFF we skip
198                        #
199                        if ( [ $( eval echo \${${compname}_${flag_post}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] || \
200                            [ ${chunck_size} = OFF ] ) ; then
201                            #IGCM_debug_Print 2 "Empty TS : ${compname}_Post_${FILE}_TimeSeriesVars${Dimension}"
202                            #(( i=i+3 ))
203                            continue
204                        fi
205                        #
206                        #  ICI ON TESTE QUE LES FICHIERS TS SONT LA!
207                        #
208                        #
209                        FILE=$( echo ${flag_post} | awk "-FPost_" '{print $2}' )
210                        IGCM_card_DefineArrayFromOption ${card}    Post_${FILE} TimeSeriesVars${Dimension}
211                        IGCM_card_DefineVariableFromOption ${card} Post_${FILE} ChunckJob${Dimension}
212                        #
213                        FlagDir=$( echo ${FILE} | awk -F "_" '{print $1}' )
214                        case ${FlagDir} in
215                            *Y)  TS_Dir=TS_YE  ;;
216                            *M)  TS_Dir=TS_MO  ;;
217                            *D)  TS_Dir=TS_DA  ;;
218                         3H|HF)  TS_Dir=TS_HF  ;;
219                           INS) TS_Dir=TS_INS ;;
220                        esac
221                        #
222                        # We need LIST of variables not allready produced (useful for standalone mode)
223                        #
224                        DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
225                        IGCM_date_GetYearMonth ${DateBegin} YearBegin MonthBegin
226
227                        # Si on n'a pas de chunck, dans ce cas chunck_size=la durée de la simulation en années
228                        YearsChunckLength=$( echo ${chunck_size} | sed -e "s/[yY]//" )
229                        [ ${chunck} = false ] && YearsChunckLength=$(( YearEnd - YearBegin + 1 ))
230
231                        NbYearsChunckLoop=$(( ( YearEnd - YearBegin + 1 ) / YearsChunckLength ))
232                        Reste=$(( ( YearEnd - YearBegin + 1 ) % YearsChunckLength ))
233
234                        if [ ${Reste} -ne 0 ] ; then
235                            NbYearsChunckLoop=$(( NbYearsChunckLoop + 1 ))
236                        fi
237
238                        if [ ${NbYearsChunckLoop} -eq 1 ] ; then
239                            PeriodDateEnd=${DateEnd}
240                        else
241                            DaysInYear=$( IGCM_date_DaysInYear ${YearBegin} )
242                            PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( YearsChunckLength * DaysInYear - 1 )) )
243                        fi
244                        #
245                        DIRECTORY=${R_SAVE}/${comp}/Analyse/${TS_Dir}
246                        YearsChunckLoop=1
247                        ChunckDebut=${DateBegin}
248                        ChunckFin=${PeriodDateEnd}
249                        while [ ${YearsChunckLoop} -le ${NbYearsChunckLoop} ] ; do
250                            countTotal=0
251                            countGood=0
252                            countBad=0
253                            for var in $( eval echo \${${compname}_Post_${FILE}_TimeSeriesVars${Dimension}[*]} ) ; do
254                                TestedFile=${config_UserChoices_JobName}_${ChunckDebut}_${ChunckFin}_${FlagDir}_${var}.nc
255                                #
256                                if [ ! -f ${DIRECTORY}/${TestedFile} ] ; then
257                                    (( countBad = countBad + 1 ))
258                                    [ ${countBad} = 1 ] && IGCM_debug_Print 3 "Missing time series from ${FILE} :"
259                                    IGCM_debug_Print 3 ${DIRECTORY}/${TestedFile}
260                                else
261                                    (( countGood = countGood + 1 ))
262                                fi
263                                (( countTotal = countTotal + 1 ))
264                            done
265
266                            SuccessRate=$(( countGood * 100 / countTotal ))
267                            if [ ${SuccessRate} -ne 100 ] ; then
268                                IGCM_debug_Print 2 -e "\033[1;31m${SuccessRate}% files OK.\033[m for period ${ChunckDebut}-${ChunckFin}"
269                            else
270                                IGCM_debug_Print 2 -e "\033[1;32m${SuccessRate}% files OK.\033[m for period ${ChunckDebut}-${ChunckFin}"
271                            fi
272
273                            echo
274                            if ( [ ${chunck} = true ] && [ ${SuccessRate} -ne 100 ] ) ; then
275                                ChunckCompletedFlag=""
276                                CompletedFlag=${SavedCompletedFlag}
277                                if [ X${CompletedFlag} != X ] ; then
278                                        ( [ ${CompletedFlag} -gt ${ChunckDebut} ] && [ ${CompletedFlag} -le ${ChunckFin} ] ) && ChunckCompletedFlag=${CompletedFlag}
279                                fi
280                                IGCM_debug_Print 2 -e "\033[1;31mSubmit ${FILE} chunck ${Dimension}\033[m period ${ChunckDebut}-${ChunckFin}"
281                                listVarEnv="libIGCM,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,CompletedFlag,TsTask,CompToRead,FlagToRead"
282                                export libIGCM=${libIGCM}
283                                export SUBMIT_DIR=${CARD_DIR}
284                                export POST_DIR=${POST_DIR}
285                                export DateBegin=${ChunckDebut}
286                                export PeriodDateEnd=${ChunckFin}
287                                export CompletedFlag=${ChunckCompletedFlag}
288                                export TsTask=Chunck${Dimension}
289                                export CompToRead=${comp}
290                                export FlagToRead=${i}
291                                export NameToRead=${flag_post}
292                                export listVarEnv=${listVarEnv}
293                                IGCM_sys_MkdirWork ${POST_DIR}
294                                IGCM_debug_Verif_Exit
295                                Script_Post_Output=create_ts.${PeriodDateEnd}.${TsTask}.${CompToRead}.${NameToRead}
296                                IGCM_sys_QsubPost create_ts
297                                echo
298                            fi
299
300                            if ( [ ${chunck} = false ] && [ ${SuccessRate} -ne 100 ] ) ; then
301                                eval Launch${Dimension}=true
302                            fi
303
304                            # Date update
305                            ChunckDebut=$( IGCM_date_AddDaysToGregorianDate ${ChunckFin} 1 )
306
307                            (( YearsChunckLoop = YearsChunckLoop + 1 ))
308
309                            if [ ${YearsChunckLoop} -eq ${NbYearsChunckLoop} ] ; then
310                                ChunckFin=${DateEnd}
311                            else
312                                #PeriodDateEnd=$(( YearBegin + YearsChunckLength - 1 ))
313                                ChunckFin=$( IGCM_date_AddDaysToGregorianDate ${ChunckDebut} $(( YearsChunckLength * DaysInYear - 1 )) )
314                            fi
315                        done
316                    done
317                else
318                    ListDimension[0]=""
319                    TimeSeries=true
320                    TimeSeries2D=false
321                    TimeSeries3D=false
322                    TimeSeriesChunck2D=false
323                    TimeSeriesChunck3D=false
324                fi
325            fi
326            (( i=i+3 ))
327        done
328    fi
329done # comp loop
330
331echo
332
333DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
334IGCM_date_GetYearMonth ${DateBegin} YearBegin MonthBegin
335CompletedFlag=${SavedCompletedFlag}
336
337if [ X${Launch2D} = Xtrue ] ; then
338    IGCM_debug_Print 2 -e "\033[1;31mSubmit 2D\033[m without chunck period ${DateBegin}-${DateEnd}"
339    listVarEnv="libIGCM,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,CompletedFlag,TsTask"
340    export libIGCM=${libIGCM}
341    export SUBMIT_DIR=${CARD_DIR}
342    export POST_DIR=${POST_DIR}
343    export DateBegin=${DateBegin}
344    export PeriodDateEnd=${DateEnd}
345    export CompletedFlag=${CompletedFlag}
346    export TsTask=2D
347    export listVarEnv=${listVarEnv}
348    IGCM_sys_MkdirWork ${POST_DIR}
349    IGCM_debug_Verif_Exit
350    Script_Post_Output=create_ts.${PeriodDateEnd}.${TsTask}
351    IGCM_sys_QsubPost create_ts
352    echo
353fi
354
355if [ X${Launch3D} = Xtrue ] ; then
356    IGCM_debug_Print 2 -e "\033[1;31mSubmit 3D\033[m without chunck period ${DateBegin}-${DateEnd}"
357    listVarEnv="libIGCM,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,CompletedFlag,TsTask"
358    export libIGCM=${libIGCM}
359    export SUBMIT_DIR=${CARD_DIR}
360    export POST_DIR=${POST_DIR}
361    export DateBegin=${DateBegin}
362    export PeriodDateEnd=${DateEnd}
363    export CompletedFlag=${CompletedFlag}
364    export TsTask=3D
365    export listVarEnv=${listVarEnv}
366    IGCM_sys_MkdirWork ${POST_DIR}
367    IGCM_debug_Verif_Exit
368    Script_Post_Output=create_ts.${PeriodDateEnd}.${TsTask}
369    IGCM_sys_QsubPost create_ts
370    echo
371fi
Note: See TracBrowser for help on using the repository browser.