source: trunk/libIGCM/AA_SE_Checker @ 706

Last change on this file since 706 was 658, checked in by labetoulle, 12 years ago

Add Ensemble functionality to libIGCM - First step :
modify output directories according to an option in section [Ensemble]
in config.card (modification of config.card yet to be done).

  • Property svn:keywords set to Revision Author Date
File size: 10.0 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
[637]43# project
44export BRIDGE_MSUB_PROJECT=gen2211
45
[271]46if [ ! -d ${CARD_DIR} ]; then
47    echo "No ${CARD_DIR}, we stop here"
48    exit
49fi
50
51########################################################################
52
53. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh ;
54. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh     #; IGCM_debug_Check
55. ${libIGCM}/libIGCM_card/libIGCM_card.ksh   #; IGCM_card_Check
56. ${libIGCM}/libIGCM_date/libIGCM_date.ksh   #; IGCM_date_Check
57
58########################################################################
59
[362]60#set -vx
61
[616]62#==================================
[271]63# First of all
[616]64#
65typeset option
66
67#==================================
68# Read UserChoices section:
[271]69IGCM_card_DefineArrayFromSection       ${CARD_DIR}/config.card UserChoices
[616]70echo
71IGCM_debug_Print 1 "DefineArrayFromOption  : config_UserChoices"
[271]72for option in ${config_UserChoices[*]} ; do
73    IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card UserChoices ${option}
[616]74    eval auxprint=\${config_UserChoices_${option}}
75    IGCM_debug_Print 3 "${option} : ${auxprint}"
[271]76done
[616]77#
78echo
[271]79
[616]80#==================================
[658]81# Read Ensemble section:
82IGCM_card_DefineArrayFromSection       ${CARD_DIR}/config.card Ensemble
83echo
84
85for option in ${config_Ensemble[*]} ; do
86    IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card Ensemble ${option}
87    eval auxprint=\${config_Ensemble_${option}}
88    IGCM_debug_Print 3 "${option} : ${auxprint}"
89done
90#
91echo
92
93#==================================
[616]94# Read Post section:
95IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card Post
[271]96echo
[616]97IGCM_debug_Print 1 "DefineArrayFromOption : config_Post"
[338]98
[616]99for option in ${config_Post[*]} ; do
100  IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card Post ${option}
101  eval auxprint=\${config_Post_${option}}
102  IGCM_debug_Print 3 "${option} : ${auxprint}"
103done
104#
105echo
106
[385]107DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )
[362]108DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
[338]109
[362]110IGCM_date_GetYearMonth ${DateBegin} YearBegin MonthBegin
[338]111IGCM_date_GetYearMonth ${DateEnd}   YearEnd   MonthEnd
[362]112
[385]113IGCM_debug_Print 1 "DateBegin for SE_Checker : "${DateBegin}
114IGCM_debug_Print 1 "DateEnd   for SE_Checker : "${DateEnd}
[362]115echo
[271]116
117#====================================================
118#R_SAVE : Job output directory
[546]119#R_BUFR : Job output buffered directory
[271]120if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then
[658]121  FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' )
122  if ( [ ! X${config_Ensemble_EnsembleName} = X ] && [ ! X${config_Ensemble_EnsembleDate} = X ] ) ; then
123    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${FreeName}
124    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${FreeName}
125    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${FreeName}
126  else
[271]127    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
[546]128    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
[271]129    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
[658]130  fi
[271]131else
[658]132  if ( [ ! X${config_Ensemble_EnsembleName} = X ] && [ ! X${config_Ensemble_EnsembleDate} = X ] ) ; then
133    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${config_UserChoices_JobName}
134    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${config_UserChoices_JobName}
135    R_DODS=${config_UserChoices_TagName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${config_UserChoices_JobName}
136  else
[271]137    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
[546]138    R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
[271]139    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName}
[658]140  fi
[271]141fi
142
143IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card ListOfComponents
144
[385]145IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card Post SeasonalFrequency
146#
147[ X${config_Post_SeasonalFrequency} = X"NONE" ] && exit
[271]148
[385]149freq=$( echo ${config_Post_SeasonalFrequency} |  sed -e "s/[yY]//" )
[271]150
[385]151an_deb=$( IGCM_date_YearDigit $(( DateBegin / 10000 )) )
152an_fin_all=$( IGCM_date_YearDigit $(( DateEnd / 10000 )) )
153an_fin=$( IGCM_date_YearDigit $(( an_deb + freq - 1 )) )
154
155#
156while [ ${an_fin} -le ${an_fin_all} ] ; do
157
158    countTotal=0
159    countGood=0
160    countBad=0
161   
162    IGCM_debug_Print 1 " DateBegin/End for SE :  ${an_deb}_${an_fin} "
163   
164    for comp in ${config_ListOfComponents[*]} ; do
165        localcountBad=0
166        # Debug Print
167        IGCM_debug_Print 1 ${comp}
168        # Define component
169        IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp}
170        eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
171       
172        # Read libIGCM compatibility version in ${compname}.card
173        card=${CARD_DIR}/COMP/${compname}.card
174       
175        # Read and Build Output File stuff
176        #IGCM_debug_Print 1 "DefineArrayFromOption  : ${compname}_OutputFiles ${card}"
177        IGCM_card_DefineArrayFromOption ${card} OutputFiles List
178        ListFilesName=${compname}_OutputFiles_List
179        eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
[271]180        #
[385]181        if [ X${FileName0} != X${NULL_STR} ] ; then
[271]182            #
[385]183            # INITIALISATION
[271]184            #
[385]185            eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
186            typeset i=2
187            #
188            until [ $i -gt $NbFiles ]; do
[271]189                #
[385]190                eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1
[271]191                #
[385]192                if [ X${flag_post} != XNONE ] ; then
193                    #
194                    # Check if seasonal is required for this file
195                    #
196                    IGCM_card_DefineArrayFromSection ${card} ${flag_post}
197                    #
198                    # Seasonal case : If option Seasonal is not found (old cards) put SEASONAL ON by default
199                    #
200                    # variable option allready typeset above
201                    for option in $( eval echo \${${compname}_${flag_post}[*]} ) ; do
202                        if [ ${option} = Seasonal ] ; then
203                            FoundSeasonal=true
204                            IGCM_card_DefineVariableFromOption ${card} ${flag_post} Seasonal
[271]205                        fi
206                    done
[385]207                    #
208                    if [ ! X${FoundSeasonal} = Xtrue ] ; then
209                        eval ${compname}_${flag_post}_Seasonal=ON
210                    fi
211                    #
212                    if [ ! X$( eval echo \${${compname}_${flag_post}_Seasonal} ) = XON ] ; then
213                        (( i=i+3 ))
214                        continue
215                    fi
216                    #
217                    # CREATE LIST
218                    #
219                    FILE=$( echo ${flag_post} | awk "-FPost_" '{print $2}' )
220                    #
221                    DIRECTORY=${R_SAVE}/${comp}/Analyse/SE
222                    #
223                    TestedFile=${config_UserChoices_JobName}_SE_${an_deb}_${an_fin}_${FILE}.nc
224                    #
225                    (( countTotal = countTotal + 1 ))
226                    IGCM_sys_TestFileArchive ${DIRECTORY}/${TestedFile} >/dev/null 2>&1
227                    if [ ! $? = 0 ] ; then
228                        eval set +A LISTE_FILE_${comp}_${an_deb} \$\{LISTE_FILE_${comp}_${an_deb}[*]} ${TestedFile}
229                        (( countBad = countBad + 1 ))
230                        (( localcountBad = localcountBad + 1 ))
231                    else
232                        (( countGood = countGood + 1 ))
233                    fi
[271]234                fi
[385]235                (( i=i+3 )) # to explore file list
[387]236            done            # until [ $i -eq $NbFiles ]
237        fi                  # [ X${FileName0} != X${NULL_STR} ]
[385]238       
239        [ $localcountBad = 0 ] || IGCM_debug_Print 1 "$localcountBad file(s) missing for ${comp} : " $( eval echo \${LISTE_FILE_${comp}_${an_deb}[*]} )
240    done
241   
242    # create_se submit if files don't exist
243    if [ $countGood != $countTotal ] ; then
244        IGCM_debug_Print 2 -e "\033[1;31mSubmit create_se \033[m for period ${an_deb}-${an_fin}"
245       
246        listVarEnv="libIGCM,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,RebuildFrequency,RESOL_ATM,RESOL_SRF,RESOL_SBG,RESOL_OCE,RESOL_ICE,RESOL_MBG"
247        export libIGCM=${libIGCM}
[411]248        export SUBMIT_DIR=${CARD_DIR}
[385]249        export POST_DIR=${POST_DIR}
250        export DateBegin=${an_deb}
251        export PeriodDateEnd=${an_fin}1231
252        export RebuildFrequency=${RebuildFrequency}
253        export RESOL_ATM=${RESOL_ATM}
254        export RESOL_SRF=${RESOL_SRF}
255        export RESOL_SBG=${RESOL_SBG}
256        export RESOL_OCE=${RESOL_OCE}
257        export RESOL_ICE=${RESOL_ICE}
258        export RESOL_MBG=${RESOL_MBG}
259        export listVarEnv=${listVarEnv}
260        IGCM_sys_MkdirWork ${POST_DIR}
[436]261        IGCM_debug_Verif_Exit_Post
[387]262        Script_Post_Output=create_se.${PeriodDateEnd}
[385]263        IGCM_sys_QsubPost create_se
264
265        echo
[271]266    fi
267
[385]268    (( an_deb = an_deb + freq ))
269    (( an_fin = an_fin + freq ))
270   
271done # while
Note: See TracBrowser for help on using the repository browser.