source: trunk/libIGCM/AA_SE_Checker @ 559

Last change on this file since 559 was 554, checked in by sdipsl, 12 years ago
  • Mechanism in place to submit pack jobs.
  • Add a PackFrequency? ; default to RebuildFrequency? if not present in config.card
  • Add coherence checks between PackFrequency? and relevant dependant frequencies
  • pack_restart and pack_debug ready in batch mode. Testing in progress. Submission is still a comment in libIGCM_post
  • Move and generalize create_ts_next_date from AA_create_ts to libIGCM_date. Rename to IGCM_date_DaysInNextPeriod
  • Move and generalyze create_ts_begin_date from AA_create_ts to libIGCM_date. Rename to IGCM_date_DaysInPreviousPeriod
  • Cosmetics
  • Property svn:keywords set to Revision Author Date
File size: 8.2 KB
RevLine 
[385]1#!/bin/ksh
[271]2
3#**************************************************************
4# Author: Sebastien Denvil
[396]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
[271]9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11#
12#**************************************************************
13
[387]14# Check that everything went well during seasonal average production
[271]15# Display a short report
16# Launch what's missing
[338]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.
[271]19
[554]20#D- Path to libIGCM
21#D- Default : value from AA_job if any
22# WARNING For StandAlone use : To run this script on some machine (ulam and cesium)
23# WARNING you must check MirrorlibIGCM variable in sys library.
24# WARNING If this variable is true, you must use libIGCM_POST path instead
25# WARNING of your running libIGCM directory.
[271]26libIGCM=${libIGCM:=::modipsl::/libIGCM}
27
[344]28# Expericence class of the run
29ExperimentName=${ExperimentName:=historical}
30
31# Name of this job
[362]32JobName=${JobName:=v2.historical1}
[271]33
[338]34# répertoire courrant
[271]35CURRENT_DIR=$( pwd )
36
[338]37# Emplacement des cartes
[344]38CARD_DIR=${CARD_DIR:=${CURRENT_DIR}/${ExperimentName}/${JobName}}
[271]39
[344]40# répertoire de stockage des sorties des create_ts
[338]41POST_DIR=${POST_DIR:=${CARD_DIR}/OutScript}
42
[271]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
[362]57#set -vx
58
[271]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
[362]67IGCM_debug_Print 1 "DefineVariableFromOption  : config_UserChoices"
[271]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
[338]74
[385]75DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )
[362]76DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
[338]77
[362]78IGCM_date_GetYearMonth ${DateBegin} YearBegin MonthBegin
[338]79IGCM_date_GetYearMonth ${DateEnd}   YearEnd   MonthEnd
[362]80
[338]81echo
[385]82IGCM_debug_Print 1 "DateBegin for SE_Checker : "${DateBegin}
83IGCM_debug_Print 1 "DateEnd   for SE_Checker : "${DateEnd}
[362]84echo
[271]85
86#====================================================
87#R_SAVE : Job output directory
[546]88#R_BUFR : Job output buffered directory
[271]89if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then
90    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' )
91    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
[546]92    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
[271]93    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
94else
95    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
[546]96    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
[271]97    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName}
98fi
99
100IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card ListOfComponents
101
[385]102IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card Post SeasonalFrequency
103#
104[ X${config_Post_SeasonalFrequency} = X"NONE" ] && exit
[271]105
[385]106freq=$( echo ${config_Post_SeasonalFrequency} |  sed -e "s/[yY]//" )
[271]107
[385]108an_deb=$( IGCM_date_YearDigit $(( DateBegin / 10000 )) )
109an_fin_all=$( IGCM_date_YearDigit $(( DateEnd / 10000 )) )
110an_fin=$( IGCM_date_YearDigit $(( an_deb + freq - 1 )) )
111
112#
113while [ ${an_fin} -le ${an_fin_all} ] ; do
114
115    countTotal=0
116    countGood=0
117    countBad=0
118   
119    IGCM_debug_Print 1 " DateBegin/End for SE :  ${an_deb}_${an_fin} "
120   
121    for comp in ${config_ListOfComponents[*]} ; do
122        localcountBad=0
123        # Debug Print
124        IGCM_debug_Print 1 ${comp}
125        # Define component
126        IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp}
127        eval compname=\${config_ListOfComponents_${comp}[0]} > /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
[271]137        #
[385]138        if [ X${FileName0} != X${NULL_STR} ] ; then
[271]139            #
[385]140            # INITIALISATION
[271]141            #
[385]142            eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
143            typeset i=2
144            #
145            until [ $i -gt $NbFiles ]; do
[271]146                #
[385]147                eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1
[271]148                #
[385]149                if [ X${flag_post} != XNONE ] ; then
150                    #
151                    # Check if seasonal is required for this file
152                    #
153                    IGCM_card_DefineArrayFromSection ${card} ${flag_post}
154                    #
155                    # Seasonal case : If option Seasonal is not found (old cards) put SEASONAL ON by default
156                    #
157                    # variable option allready typeset above
158                    for option in $( eval echo \${${compname}_${flag_post}[*]} ) ; do
159                        if [ ${option} = Seasonal ] ; then
160                            FoundSeasonal=true
161                            IGCM_card_DefineVariableFromOption ${card} ${flag_post} Seasonal
[271]162                        fi
163                    done
[385]164                    #
165                    if [ ! X${FoundSeasonal} = Xtrue ] ; then
166                        eval ${compname}_${flag_post}_Seasonal=ON
167                    fi
168                    #
169                    if [ ! X$( eval echo \${${compname}_${flag_post}_Seasonal} ) = XON ] ; then
170                        (( i=i+3 ))
171                        continue
172                    fi
173                    #
174                    # CREATE LIST
175                    #
176                    FILE=$( echo ${flag_post} | awk "-FPost_" '{print $2}' )
177                    #
178                    DIRECTORY=${R_SAVE}/${comp}/Analyse/SE
179                    #
180                    TestedFile=${config_UserChoices_JobName}_SE_${an_deb}_${an_fin}_${FILE}.nc
181                    #
182                    (( countTotal = countTotal + 1 ))
183                    IGCM_sys_TestFileArchive ${DIRECTORY}/${TestedFile} >/dev/null 2>&1
184                    if [ ! $? = 0 ] ; then
185                        eval set +A LISTE_FILE_${comp}_${an_deb} \$\{LISTE_FILE_${comp}_${an_deb}[*]} ${TestedFile}
186                        (( countBad = countBad + 1 ))
187                        (( localcountBad = localcountBad + 1 ))
188                    else
189                        (( countGood = countGood + 1 ))
190                    fi
[271]191                fi
[385]192                (( i=i+3 )) # to explore file list
[387]193            done            # until [ $i -eq $NbFiles ]
194        fi                  # [ X${FileName0} != X${NULL_STR} ]
[385]195       
196        [ $localcountBad = 0 ] || IGCM_debug_Print 1 "$localcountBad file(s) missing for ${comp} : " $( eval echo \${LISTE_FILE_${comp}_${an_deb}[*]} )
197    done
198   
199    # create_se submit if files don't exist
200    if [ $countGood != $countTotal ] ; then
201        IGCM_debug_Print 2 -e "\033[1;31mSubmit create_se \033[m for period ${an_deb}-${an_fin}"
202       
203        listVarEnv="libIGCM,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,RebuildFrequency,RESOL_ATM,RESOL_SRF,RESOL_SBG,RESOL_OCE,RESOL_ICE,RESOL_MBG"
204        export libIGCM=${libIGCM}
[411]205        export SUBMIT_DIR=${CARD_DIR}
[385]206        export POST_DIR=${POST_DIR}
207        export DateBegin=${an_deb}
208        export PeriodDateEnd=${an_fin}1231
209        export RebuildFrequency=${RebuildFrequency}
210        export RESOL_ATM=${RESOL_ATM}
211        export RESOL_SRF=${RESOL_SRF}
212        export RESOL_SBG=${RESOL_SBG}
213        export RESOL_OCE=${RESOL_OCE}
214        export RESOL_ICE=${RESOL_ICE}
215        export RESOL_MBG=${RESOL_MBG}
216        export listVarEnv=${listVarEnv}
217        IGCM_sys_MkdirWork ${POST_DIR}
[436]218        IGCM_debug_Verif_Exit_Post
[387]219        Script_Post_Output=create_se.${PeriodDateEnd}
[385]220        IGCM_sys_QsubPost create_se
221
222        echo
[271]223    fi
224
[385]225    (( an_deb = an_deb + freq ))
226    (( an_fin = an_fin + freq ))
227   
228done # while
Note: See TracBrowser for help on using the repository browser.