source: trunk/libIGCM/AA_create_ts @ 409

Last change on this file since 409 was 409, checked in by sdipsl, 13 years ago
  • correct bug with TS 3D without chunck see ticket #52
  • catch return code from all nco operator except ncrcat and exit if SpaceName? is PROD. clean error code handling. Special case for cdo command. see ticket #51
    • it means that if SpaceName?=PROD all must run absolutely perfectly ; otherwise libIGCM will stop.
  • For Smooth file, first access is always true for Period=1. Get Files when SmoothMin?<CumulPeriod?<SmoothMax? and modulo [min]:[modulo:][max] is true. see ticket #44
  • Under testing : do not use unless you are willing to help testing.
  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

    The fact that you are presently reading this means that you have had
    knowledge of the CeCILL license and that you accept its terms.
  • Property svn:keywords set to Revision Author Date
File size: 35.5 KB
Line 
1#-Q- cesium #!/bin/ksh
2#-Q- cesium ######################
3#-Q- cesium ## CESIUM   CEA ##
4#-Q- cesium ######################
5#-Q- cesium #MSUB -r TS             # Nom du job               
6#-Q- cesium #MSUB -N 1              # Reservation du noeud
7#-Q- cesium #MSUB -n 1              # Reservation du processus
8#-Q- cesium #MSUB -T 86400          # Limite de temps elapsed du job
9#-Q- cesium #MSUB -E "-j o"
10#-Q- cesium #MSUB -E "-S /bin/ksh"
11#-Q- platine #!/usr/bin/ksh
12#-Q- platine ###################
13#-Q- platine ## PLATINE   CEA ##
14#-Q- platine ###################
15#-Q- platine #BSUB -J TS                     # Nom du job
16#-Q- platine #BSUB -N                        # message a la fin du job
17#-Q- platine #BSUB -n 1                      # reservation des processeurs pour le job
18#-Q- platine #BSUB -W 1:00                   # Limite temps
19#-Q- platine #BSUB -q post                   # Passage en queue post
20#-Q- sx8brodie #!/bin/ksh
21#-Q- sx8brodie #######################
22#-Q- sx8brodie ## SX8BRODIE   IDRIS ##
23#-Q- sx8brodie #######################
24#-Q- sx8brodie # Temps Elapsed max. d'une requete hh:mm:ss
25#-Q- sx8brodie # @ wall_clock_limit = 20:00:00
26#-Q- sx8brodie # Nom du travail LoadLeveler
27#-Q- sx8brodie # @ job_name   = TS
28#-Q- sx8brodie # Fichier de sortie standard du travail       
29#-Q- sx8brodie # @ output     = $(job_name).$(jobid)
30#-Q- sx8brodie # Fichier de sortie d'erreur du travail
31#-Q- sx8brodie # @ error      =  $(job_name).$(jobid)
32#-Q- sx8brodie # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
33#-Q- sx8brodie # @ notification = error
34#-Q- sx8brodie # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $REBUILD_DIR ; $RebuildFromArchive ; $POST_DIR ; $MASTER ; $RebuildFrequency ; $PeriodDateBegin ; $PeriodDateEnd ; $NbRebuildDir ; $StandAlone ; $CompletedFlag ; $TsTask ; $CompToRead ; $FlagToRead ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_MBG ; $RESOL_SRF ; $RESOL_SBG ; $MASTER
35#-Q- sx8brodie # @ queue
36#-Q- aix6 #!/bin/ksh
37#-Q- aix6 #######################
38#-Q- aix6 ##   VARGAS   IDRIS  ##
39#-Q- aix6 #######################
40#-Q- aix6 # Temps Elapsed max. d'une requete hh:mm:ss
41#-Q- aix6 # @ wall_clock_limit = 20:00:00
42#-Q- aix6 # Nom du travail LoadLeveler
43#-Q- aix6 # @ job_name   = TS
44#-Q- aix6 # Fichier de sortie standard du travail
45#-Q- aix6 # @ output     = $(job_name).$(jobid)
46#-Q- aix6 # Fichier de sortie d'erreur du travail
47#-Q- aix6 # @ error      =  $(job_name).$(jobid)
48#-Q- aix6 # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
49#-Q- aix6 # @ notification = error
50#-Q- aix6 # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $REBUILD_DIR ; $RebuildFromArchive ; $POST_DIR ; $MASTER ; $RebuildFrequency ; $DateBegin ; $PeriodDateBegin ; $PeriodDateEnd ; $NbRebuildDir ; $StandAlone ; $CompletedFlag ; $TsTask ; $CompToRead ; $FlagToRead ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_MBG ; $RESOL_SRF ; $RESOL_SBG ; $MASTER
51#-Q- aix6 # @ queue
52#-Q- ulam #!/bin/ksh
53#-Q- ulam #######################
54#-Q- ulam ##   ULAM   IDRIS  ##
55#-Q- ulam #######################
56#-Q- ulam # Temps Elapsed max. d'une requete hh:mm:ss
57#-Q- ulam # @ wall_clock_limit = 20:00:00
58#-Q- ulam # Nom du travail LoadLeveler
59#-Q- ulam # @ job_name   = TS
60#-Q- ulam # Fichier de sortie standard du travail
61#-Q- ulam # @ output     = $(job_name).$(jobid)
62#-Q- ulam # Fichier de sortie d'erreur du travail
63#-Q- ulam # @ error      =  $(job_name).$(jobid)
64#-Q- ulam # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
65#-Q- ulam # @ notification = error
66#-Q- ulam # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $REBUILD_DIR ; $RebuildFromArchive ; $POST_DIR ; $MASTER ; $RebuildFrequency ; $DateBegin ; $PeriodDateBegin ; $PeriodDateEnd ; $NbRebuildDir ; $StandAlone ; $CompletedFlag ; $TsTask ; $CompToRead ; $FlagToRead ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_MBG ; $RESOL_SRF ; $RESOL_SBG ; $MASTER
67#-Q- ulam # @ queue
68#-Q- sx8mercure #!/bin/ksh
69#-Q- sx8mercure ######################
70#-Q- sx8mercure ## SX8MERCURE   CEA ##
71#-Q- sx8mercure ######################
72#-Q- sx8mercure #PBS -N TS                   # Nom du job
73#-Q- sx8mercure #PBS -j o                    # regroupement des stdout et stderr
74#-Q- sx8mercure #PBS -S /usr/bin/ksh         # shell de soumission
75#-Q- sx8mercure #PBS -l memsz_job=1gb        # Limite memoire a 1 Go
76#-Q- sx8mercure #PBS -l cputim_job=24:00:00   # Limite temps a 2 heures
77#-Q- sx8mercure #PBS -q scalaire
78#-Q- sx9mercure #!/bin/ksh
79#-Q- sx9mercure #########################
80#-Q- sx9mercure ## CESIUM FOR SX9  CEA ##
81#-Q- sx9mercure #########################
82#-Q- sx9mercure #MSUB -r TS             # Nom du job               
83#-Q- sx9mercure #MSUB -N 1              # Reservation du noeud
84#-Q- sx9mercure #MSUB -n 1              # Reservation du processus
85#-Q- sx9mercure #MSUB -T 86400          # Limite de temps elapsed du job
86#-Q- sx9mercure #MSUB -E "-j o"
87#-Q- sx9mercure #MSUB -E "-S /bin/ksh"
88#-Q- titane #!/bin/ksh
89#-Q- titane ######################
90#-Q- titane ## TITANE   CEA ##
91#-Q- titane ######################
92#-Q- titane #MSUB -r TS             # Nom du job               
93#-Q- titane #MSUB -N 1              # Reservation du noeud
94#-Q- titane #MSUB -n 1              # Reservation du processus
95#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job
96#-Q- titane #MSUB -E "-j o"
97#-Q- titane #MSUB -E "-S /bin/ksh"
98#-Q- titane ##MSUB -e nco.out        # Sortie standard
99#-Q- titane ##MSUB -o nco.out        # Sortie standard
100#-Q- lxiv8 ######################
101#-Q- lxiv8 ## OBELIX      LSCE ##
102#-Q- lxiv8 ######################
103#-Q- lxiv8 #PBS -N TS
104#-Q- lxiv8 #PBS -m a
105#-Q- lxiv8 #PBS -j oe
106#-Q- lxiv8 #PBS -q medium
107#-Q- lxiv8 #PBS -o TS.$$
108#-Q- lxiv8 #PBS -S /bin/ksh
109#-Q- default #!/bin/ksh
110#-Q- default ##################
111#-Q- default ## DEFAULT HOST ##
112#-Q- default ##################
113
114#**************************************************************
115# Author: Sebastien Denvil
116# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
117# $Revision::                                          $ Revision of last commit
118# $Author::                                            $ Author of last commit
119# $Date::                                              $ Date of last commit
120# IPSL (2006)
121#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
122#
123#**************************************************************
124
125#set -eu
126#set -vx
127
128date
129
130#-Q- sx8brodie export OMP_NUM_THREADS=1
131#-Q- aix6 export OMP_NUM_THREADS=1
132#-Q- ulam export OMP_NUM_THREADS=1
133
134########################################################################
135
136#D- Flag to determine if this job in a standalone mode
137#D- Default : value from AA_job if any
138StandAlone=${StandAlone:=true}
139
140#D- Low level debug : to bypass lib test checks and stack construction
141#D- Default : value from AA_job if any
142libIGCM=${libIGCM:=::modipsl::/libIGCM}
143# WARNING for StandAlone used : To run this script on some machine,
144# you must check MirrorlibIGCM variable in sys library.
145# If this variable is true, you must use libIGCM_POST path instead
146# of your running libIGCM directory.
147
148#D- Flag to determine allready produced time series. Empty if you start from the beginning
149#D- Default : Value from AA_job if any. Usefull in StandAlone case if you want to continue a time series
150CompletedFlag=${CompletedFlag:=}
151
152#D- Flag to determine task type this script will perform.
153#D- Possible Value : 2D, 3D, Chunck2D, Chunck3D
154#D- Default : Value from AA_job if any. Usefull in StandAlone case.
155TsTask=${TsTask:=2D}
156if [ X${TsTask} = Xempty ] ; then
157    TsTask=""
158fi
159
160#D- Flag to determine if rebuild process has been performed asynchronously
161#D- Possible value true or false.
162#D- If true raw files has allready been patched by rebuild job
163#D- If false create_ts will patch the raw files
164#D- Default : Value from AA_job if any. Usefull in StandAlone case.
165RebuildFrequency=${RebuildFrequency:=true}
166
167#D- Flag to determine job's output directory
168#D- Default : value from libIGCM_post.ksh if any
169POST_DIR=${POST_DIR:=${PBS_O_WORKDIR:=$(pwd)}}
170
171#D- Increased verbosity (1, 2, 3)
172#D- Default : value from AA_job if any
173Verbosity=${Verbosity:=3}
174
175#D- Low level debug : to bypass lib test checks and stack construction
176#D- Default : value from AA_job if any
177DEBUG_debug=${DEBUG_debug:=false}
178
179#D- TEMPORARY Flag to determine atmospheric resolution
180#D- Default : value from atmospheric driver if any
181RESOL_ATM=ALL
182
183#D- Flag to determine surface resolution
184#D- Default : value from surface driver if any
185RESOL_SRF=ALL
186
187#D- Flag to determine surface resolution
188#D- Default : value from surface driver if any
189RESOL_SBG=ALL
190
191#D- TEMPORARY Flag to determine ocean resolution
192#D- Default : value from ocean driver if any
193RESOL_OCE=${RESOL_OCE:=ORCA2}
194
195#D- TEMPORARY Flag to determine ice resolution
196#D- Default : value from ice driver if any
197RESOL_ICE=${RESOL_ICE:=ORCA2}
198
199#D- TEMPORARY Flag to determine marine biogeochemistry resolution
200#D- Default : value from ice driver if any
201RESOL_MBG=${RESOL_MBG:=ORCA2}
202
203########################################################################
204
205. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
206      ( ${DEBUG_debug} ) && IGCM_debug_Check
207. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
208     ( ${DEBUG_debug} ) && IGCM_card_Check
209. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
210     ( ${DEBUG_debug} ) && IGCM_date_Check
211#-------
212. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
213
214########################################################################
215
216#set -vx
217
218# Useful cleaning function
219MENAGE () 
220{
221    [ -f $3 ] && ( IGCM_sys_RshArchive rm -f $1/$2 ;)
222}
223
224########################################################################
225
226IGCM_sys_MkdirWork ${RUN_DIR_PATH}
227IGCM_sys_Cd ${RUN_DIR_PATH}
228
229if [ ${StandAlone} = true ] ; then
230    CARD_DIR=${SUBMIT_DIR}
231else
232    CARD_DIR=${RUN_DIR_PATH}/$( basename ${SUBMIT_DIR} )
233    IGCM_sys_Get_Master ${SUBMIT_DIR} ${RUN_DIR_PATH}
234fi
235
236#
237# First of all
238#
239IGCM_card_DefineArrayFromSection       ${CARD_DIR}/config.card UserChoices
240typeset option
241for option in ${config_UserChoices[*]} ; do
242    IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card UserChoices ${option}
243done
244#
245echo
246IGCM_debug_Print 1 "DefineArrayFromOption  : config_UserChoices"
247IGCM_debug_PrintVariables 3 config_UserChoices_JobName
248IGCM_debug_PrintVariables 3 config_UserChoices_LongName
249IGCM_debug_PrintVariables 3 config_UserChoices_TagName
250IGCM_debug_PrintVariables 3 config_UserChoices_SpaceName
251IGCM_debug_PrintVariables 3 config_UserChoices_ExperimentName
252IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType
253IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin
254IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd
255IGCM_debug_PrintVariables 3 config_UserChoices_PeriodLength
256echo
257
258#==================================
259#R_SAVE : Job output directory
260if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then
261    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' )
262    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
263    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
264else
265    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
266    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName}
267fi
268#
269# Determine component to take care of depending on kind of task create_ts will perform
270#
271[ ${CompToRead} ] && set -A config_ListOfComponents ${CompToRead} || IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card ListOfComponents
272#
273# Determine period for time series. Default : value from AA_job or from launch_TS if any
274#
275[ X${CompletedFlag} = X ] || CompletedFlag=$( IGCM_date_ConvertFormatToGregorian ${CompletedFlag} )
276
277DateBegin=${DateBegin:=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )}
278#
279PeriodDateEnd=${PeriodDateEnd:=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )}
280#
281# Determine Dimension of the produced time series : 2D or 3D
282if (   [ X${TsTask} = XChunck2D ] || [ X${TsTask} = X2D ] ) ; then
283    Dimension=2D
284elif ( [ X${TsTask} = XChunck3D ] || [ X${TsTask} = X3D ] ) ; then
285    Dimension=3D
286else
287    Dimension=""
288fi
289
290
291########################################################################
292#
293#      Depending on requested time series fill following variables :
294#
295#                           - LISTE_FILE_${comp}[*]
296#                           - LISTE_VARS_${file}[*]
297#                           - LISTE_AXIS_${file}[*]
298#                           - LISTE_PATCH_${file}[*]
299########################################################################
300
301#
302# For each selected component determine which files need post-processing
303#
304DoJob=false
305for comp in ${config_ListOfComponents[*]} ; do
306    #
307    ActiveComp=false
308    #
309    IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp}
310    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
311    #
312    card=${CARD_DIR}/COMP/${compname}.card
313
314    IGCM_card_DefineArrayFromOption ${card} OutputFiles List
315    #
316    ListFilesName=${compname}_OutputFiles_List
317    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
318    #
319    if [ X${FileName0} != X${NULL_STR} ] ; then
320        #
321        #IGCM_debug_Print 1 "Component      : ${compname}"
322        #
323        # INITIALISATION
324        #
325        typeset i
326        if [ ${FlagToRead} ] ; then
327            ((NbFiles=${FlagToRead}))
328            ((i=${NbFiles}))
329        else
330            eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
331            i=2
332        fi
333        #
334        until [ $i -gt $NbFiles ]; do
335            #
336            eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1
337            #
338            if [ X${flag_post} != XNONE ] ; then
339                #
340                # For each comp and each file who needs post-processing
341                # determine which variables need time series.
342                #
343                FILE=$( echo ${flag_post} | awk "-FPost_" '{print $2}' )
344                IGCM_card_DefineArrayFromOption ${card}    Post_${FILE} TimeSeriesVars${Dimension}
345                IGCM_card_DefineVariableFromOption ${card} Post_${FILE} ChunckJob${Dimension}
346                #
347                # If TimeSeriesVars list is empty we skip
348                #
349                if [ $( eval echo \${${compname}_Post_${FILE}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then
350                    #
351                    IGCM_debug_Print 3 "Nothing to do for ${FILE} according to ${card}"
352                    IGCM_debug_Print 3 "TimeSeriesVars${Dimension} for ${FILE} is empty"
353                    (( i=i+3 ))
354                    continue
355                    #
356                fi
357                #
358                # If files/variables has been switch off by ChunckJob${Dimension}=0 we skip
359                #
360                if [ X$( eval echo \${${compname}_Post_${FILE}_ChunckJob${Dimension}} ) = XOFF ] ; then
361                    IGCM_debug_Print 3 "Nothing to do for ${FILE} according to ${card}"
362                    IGCM_debug_Print 3 "ChunckJob${Dimension}=OFF for ${FILE} so it has been switched off"
363                    (( i=i+3 ))
364                    continue
365                fi
366                #
367                # If we are not a Chunck type task, we skip files/variables handled by chunck task
368                #
369                if ( [ ! X${TsTask} = XChunck${Dimension} ] && [ ! X${TsTask} = X ] && [ ! XChunck${Dimension} = XChunck ] ) ; then
370                    if [ ! $( eval echo \${${compname}_Post_${FILE}_ChunckJob${Dimension}} ) = NONE ] ; then
371                        IGCM_debug_Print 3 "Nothing to do for ${FILE} TimeSeriesVars${Dimension} according to ${card}"
372                        IGCM_debug_Print 3 "Let another chunck task do the job $( eval echo \${${compname}_Post_${FILE}_ChunckJob${Dimension}} )"
373                        (( i=i+3 ))
374                        continue
375                    fi
376                fi
377                #
378                # Now on we know we have things to do
379                #
380
381                #
382                #  We need coordinates axis to properly fill produced time series
383                #
384                IGCM_card_DefineArrayFromOption ${card} Post_${FILE} GatherWithInternal
385                #
386                if [ $( eval echo \${${compname}_Post_${FILE}_GatherWithInternal} ) = ${NULL_STR} ] ; then
387                    #
388                    IGCM_debug_Print 1 "ERROR !! We miss coordinate axis for ${FILE} according to ${card}"
389                    IGCM_debug_Print 1 "So no time series will be produced for ${FILE} !!"
390                    (( i=i+3 ))
391                    continue
392                    #
393                fi
394                #
395                # We need LIST of variables not allready produced (useful for standalone mode)
396                #
397                FlagDir=$( echo ${FILE} | awk -F "_" '{print $1}' )
398                case ${FlagDir} in
399                    *Y)  TS_Dir=TS_YE  ;;
400                    *M)  TS_Dir=TS_MO  ;;
401                    *D)  TS_Dir=TS_DA  ;;
402                    HF)  TS_Dir=TS_HF  ;;
403                    3H)  TS_Dir=TS_HF  ;;
404                    INS) TS_Dir=TS_INS ;;
405                esac
406                #
407                count=0
408                for var in $( eval echo \${${compname}_Post_${FILE}_TimeSeriesVars${Dimension}[*]} ) ; do
409                    #
410                    DIRECTORY=${R_SAVE}/${comp}/Analyse/${TS_Dir}
411                    TestedFile=${config_UserChoices_JobName}_${DateBegin}_${PeriodDateEnd}_${FlagDir}_${var}.nc
412                    #
413                    IGCM_sys_TestFileArchive ${DIRECTORY}/${TestedFile}
414                    if [ ! $? = 0 ] ; then
415                        eval set +A LISTE_VARS_${FILE} \${LISTE_VARS_${FILE}[*]} ${var}
416                        ActiveComp=true
417                        (( count = count + 1 ))
418                    fi
419                done
420                #
421                if [ ${count} -gt 0 ] ; then
422                    #
423                    eval set +A LISTE_FILE_${comp} \${LISTE_FILE_${comp}[*]} ${FILE}
424                    eval set +A LISTE_AXIS_${FILE} \${${compname}_Post_${FILE}_GatherWithInternal[*]}
425                    #
426                    if [ ! X${RebuildFrequency} = Xtrue ] ; then
427                        IGCM_card_DefineArrayFromOption ${card} Post_${FILE} Patches
428                        eval set +A LISTE_PATCHES_${FILE} \${${compname}_Post_${FILE}_Patches[*]}
429                        if [ X$( eval echo \${LISTE_PATCHES_${FILE}[0]} ) !=  X${NULL_STR} ]; then
430                            for Patch in $( eval echo \${LISTE_PATCHES_${FILE}[*]} ); do
431                                if [ Xload${Patch} != X ] ; then
432                                    . ${libIGCM}/libIGCM_post/IGCM_${Patch}.ksh
433                                    eval load${Patch}=loaded
434                                fi
435                            done
436                        fi
437                    fi
438                fi
439            fi
440            (( i=i+3 ))
441        done
442    fi
443    #
444    if [ ${ActiveComp} = true ] ; then
445        set +A ActiveListOfComponents ${ActiveListOfComponents[*]} ${comp}
446    fi
447done
448
449set -A config_ListOfComponents ${ActiveListOfComponents[*]}
450[ ! -z "${ActiveListOfComponents}" ] && DoJob=true
451
452########################################################################
453#
454#                          DEFINE DATE FUNCTIONS
455#
456########################################################################
457
458# Give the end of the next $1 period from $2 date
459function create_ts_next_date {
460    IGCM_debug_PushStack "create_ts_next_date" $@
461    typeset Length
462    case ${config_UserChoices_PeriodLength} in
463        *Y|*y) 
464            PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
465            IGCM_date_GetYearMonth ${1} year month
466            year=$( IGCM_date_SupressZeros ${year} )
467            (( Length=0 ))
468            (( i=0 ))
469            until [ $i -ge $PeriodLengthInYears ] ; do
470                (( Length = Length + $( IGCM_date_DaysInYear $(( year + i + 1 )) ) )) 
471                (( i=i+1 ))
472            done
473            ;;
474        *M|*m) 
475            PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' )
476            IGCM_date_GetYearMonth ${1} year month
477            year=$( IGCM_date_SupressZeros ${year} )
478            (( year0 = year ))
479            if [ $(( month + 1 )) -lt 13 ] ; then
480                month0=$(( month + 1 ))
481            else
482                month0=$(( month + 1 - 12 ))
483                (( year = year0 + 1 ))
484            fi
485            (( Length=0 ))
486            (( i=0 ))
487            until [ $i -ge $PeriodLengthInMonths ] ; do
488                if [ $(( month0 + i )) -lt 13 ] ; then
489                    (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i )) ) ))
490                else
491                    (( year = year0 + 1 ))
492                    (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i - 12 )) ) ))
493                fi
494                (( i=i+1 ))
495            done
496            ;;
497        *D|*d)
498            Length=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" ) ;;
499        *)
500            IGCM_debug_Exit "create_ts " ${config_UserChoices_PeriodLength} " invalid PeriodLength : choose in *Y, *M, *D."
501            IGCM_debug_Verif_Exit_Post ;;
502    esac
503    echo ${Length}
504
505    IGCM_debug_PopStack "create_ts_next_date"
506}
507
508# Give the end of the actual $1 period from $2 date
509function create_ts_begin_date {
510    IGCM_debug_PushStack "create_ts_begin_date" $@
511    typeset Length
512    case ${config_UserChoices_PeriodLength} in
513        *Y|*y) 
514            PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
515            IGCM_date_GetYearMonth ${1} year month
516            year=$( IGCM_date_SupressZeros ${year} )
517            if [ X${2} = Xend ] ; then
518                (( year = year - PeriodLengthInYears + 1))
519            fi
520            (( Length=0 ))
521            (( i=0 ))
522            until [ $i -ge $PeriodLengthInYears ] ; do
523                (( Length = Length + $( IGCM_date_DaysInYear $(( year + i )) ) )) 
524                (( i=i+1 ))
525            done
526            ;;
527        *M|*m) 
528            PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' )
529            IGCM_date_GetYearMonth ${1} year month
530            year=$( IGCM_date_SupressZeros ${year} )
531            if [ X${2} = Xend ] ; then
532                (( month = month - PeriodLengthInMonths + 1 ))
533            fi     
534            (( year0 = year ))
535            if [ $month -le 0 ] ; then
536                (( month = month + 12 ))
537                year=$( printf "%04i\n" $(( year - 1 )) )
538            fi
539            month=$( printf "%02i\n" ${month} )
540            (( Length=0 ))
541            (( i=0 ))
542            until [ $i -ge $PeriodLengthInMonths ] ; do
543                if [ $(( month + i )) -lt 13 ] ; then
544                    (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i )) ) ))
545                else
546                    (( year = year0 + 1 ))
547                    (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) ))
548                fi
549                (( i=i+1 ))
550            done
551            ;;
552        *D|*d)
553            Length=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" ) ;;
554        *)
555            IGCM_debug_Exit "create_ts " ${config_UserChoices_PeriodLength} " invalid PeriodLength : choose in *Y, *M, *D."
556            IGCM_debug_Verif_Exit_Post ;;
557    esac
558    echo ${Length}
559
560    IGCM_debug_PopStack "create_ts_begin_date"
561}
562
563########################################################################
564#
565#               IS THERE SOME ALLREADY PRODUCED TIME SERIES ?
566#                 IF SO BRING THEM IN THE WORKING DIRECTORY
567#
568# PS : Keep in mind that IGCM_sys_Get here is a weak link :
569#      - especially for IDRiS
570#      - no special protection against "command too long" !
571#      - libIGCM_sys should handle that or modify following code part
572#
573########################################################################
574
575if [ ${StandAlone} != true ] ; then
576    Running_Flag=$( IGCM_sys_RshMaster "IGCM_card_DefineVariableFromOption \
577       ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesRunning ; \
578       echo \${run_PostProcessing_TimeSeriesRunning}" )
579
580    #if [ X${Running_Flag} = Xy ] ; then
581    #    # Time Series Job allready running
582    #   IGCM_debug_Print 1 "Time Series Job allready running exit"
583    #   exit
584    #fi
585    # Now run.card know we are running
586
587
588
589
590    IGCM_sys_RshMaster IGCM_card_WriteOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesRunning "y"
591
592
593
594
595
596    # Get information from last execution
597    #CompletedFlag=$( IGCM_sys_RshMaster \
598    #   "IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted ;\
599    #        echo \${run_PostProcessing_TimeSeriesCompleted}" )
600fi
601
602# Is it the first submission or not ?
603
604if ( [ X${CompletedFlag} = X ] || [ X${CompletedFlag} = X$( IGCM_date_AddDaysToGregorianDate ${DateBegin} -1 ) ] ) ; then
605    # First Time Series Submission
606    FIRST_PASS=TRUE
607    Length=$( create_ts_begin_date ${DateBegin} begin)
608    DATE_FIN_JOB_B=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( Length - 1 )) )
609else
610    # Last Completed Time Series
611    FIRST_PASS=FALSE
612    DATE_FIN_JOB_B=${CompletedFlag}
613    date=${DateBegin}_${DATE_FIN_JOB_B}
614    for comp in ${config_ListOfComponents[*]} ; do
615        #
616        IGCM_sys_Mkdir ${RUN_DIR_PATH}/${comp}
617        #
618        IGCM_sys_Cd ${RUN_DIR_PATH}/${comp}
619        #
620        #set -A liste_file
621        unset liste_file
622        #
623        file_path=${R_SAVE}/${comp}/Analyse
624        #
625        i=0
626        file=${NULL_STR}
627        #
628        for file in $( eval echo \${LISTE_FILE_${comp}[*]} ); do
629            #
630            # Determine in which output can we find file
631            # IE : Analyse/TS or Analyse/DA2TS or ...
632            #
633            FlagDir=$( echo ${file} | awk -F "_" '{print $1}' )
634            case ${FlagDir} in
635                *Y)  TS_Dir=TS_YE  ;;
636                *M)  TS_Dir=TS_MO  ;;
637                *D)  TS_Dir=TS_DA  ;;
638                HF)  TS_Dir=TS_HF  ;;
639                3H)  TS_Dir=TS_HF  ;;
640                INS) TS_Dir=TS_INS ;;
641            esac
642            for var in $( eval echo \${LISTE_VARS_${file}[*]} ) ; do
643                #
644                #set +A liste_file ${liste_file[*]} ${file_path}/${TS_Dir}/${config_UserChoices_JobName}_${date}_${FlagDir}_${var}.nc
645                liste_file[${#liste_file[*]}]=${file_path}/${TS_Dir}/${config_UserChoices_JobName}_${date}_${FlagDir}_${var}.nc
646                #
647            done
648        done
649        if [ X${file} != X${NULL_STR} ] ; then
650            IGCM_sys_Get /l liste_file[*] ${RUN_DIR_PATH}/${comp}
651            # Even if some files are missing we tried to continue
652            # Either ListVar in compname.card are asked nut not present in original history file
653            # Either a previous TS task failed
654            ExitFlag=false
655            IGCM_debug_Verif_Exit_Post
656        fi
657    done
658    #
659    LEVEL=0
660    #
661fi
662
663########################################################################
664#
665#                          DEFINE LOOP PARAMETERS
666#
667########################################################################
668
669DATE_COUNT=${DATE_FIN_JOB_B}
670DATE_FIN_JOB_B_LOOP=${DATE_FIN_JOB_B}
671
672( [ -n "${LEVEL}" ] && [ ${LEVEL} -eq 0 ] ) && NBRE_FILE_TOT=0 || NBRE_FILE_TOT=1
673
674if [ ${DoJob} = true ] ; then
675    while [ ${DATE_COUNT} -lt ${PeriodDateEnd} ] ; do
676        (( NBRE_FILE_TOT = NBRE_FILE_TOT + 1 ))
677        Length=$( create_ts_next_date ${DATE_COUNT} )
678        DATE_COUNT=$( IGCM_date_AddDaysToGregorianDate ${DATE_COUNT} ${Length} )
679    done
680else
681    NBRE_FILE_TOT=0
682fi
683
684if [ ${NBRE_FILE_TOT} -le ${UNIX_MAX_LIMIT} ] ; then
685    NBRE_TOUR=1
686elif [ ${NBRE_FILE_TOT}%${UNIX_MAX_LIMIT} -eq 0 ] ; then
687    let NBRE_TOUR=${NBRE_FILE_TOT}/${UNIX_MAX_LIMIT} 
688else
689    let NBRE_TOUR=${NBRE_FILE_TOT}/${UNIX_MAX_LIMIT}+1
690fi
691
692CURRENT_LOOP=1
693# THIS LOOP GIVES PARAMETERS FOR THE DATE'S LOOP ie : DATE_COURANTE, DATE_FIN.
694# WE HAVE 3 LEVELS
695#    - LEVEL 1 : JUST ONE LOOP TO COMPLETE
696#    - LEVEL 2 : WE ARE IN THE "DEEP" LOOP
697#    - LEVEL 3 : WE ARE IN THE LAST LOOP
698
699while [ ${CURRENT_LOOP} -le  ${NBRE_TOUR} ] ; do
700     
701    if [ ${NBRE_FILE_TOT} -le ${UNIX_MAX_LIMIT} ] ; then 
702        # - LEVEL 1 : JUST ONE LOOP TO COMPLETE
703        NBRE_FILE_LOOP=${NBRE_FILE_TOT}
704
705        if [ ${FIRST_PASS} = TRUE ] ; then
706            DATE_COURANTE=${DATE_FIN_JOB_B_LOOP}
707        else
708            Length=$( create_ts_next_date ${DATE_FIN_JOB_B_LOOP} )
709            DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN_JOB_B_LOOP} ${Length} )
710        fi
711
712        DATE_FIN=${PeriodDateEnd}
713        DATE_FIN_JOB_B_LOOP_PREC=${DATE_FIN_JOB_B_LOOP}
714
715        [ -n "${DATE_LOOP}" ] && DATE_FIN_JOB_B_LOOP=${DATE_LOOP}
716        [ -n "${LEVEL}" ] && FLAG_B="TRUE" || FLAG_B="FALSE"
717
718        LEVEL=1
719        DEPOT="TRUE"     
720    elif [ ${CURRENT_LOOP} -ne  ${NBRE_TOUR} ] ; then
721        # - LEVEL 2 : WE ARE IN THE "DEEP" LOOP
722        NBRE_FILE_LOOP=${UNIX_MAX_LIMIT}
723
724        if [ ! ${FIRST_PASS} = TRUE ] && [ ${CURRENT_LOOP} -eq 1 ] ; then
725            Length=$( create_ts_next_date ${DATE_FIN_JOB_B_LOOP} )
726            DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN_JOB_B_LOOP} ${Length} )
727        elif [ -z "${DATE_COURANTE}" ] ; then
728            DATE_COURANTE=${DATE_FIN_JOB_B}
729        else
730            Length=$( create_ts_next_date ${DATE_FIN} )
731            DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN} ${Length} )
732        fi
733         
734        (( TotLength = 0 ))
735        COMPTEUR=1
736        DATE_LOOP=${DATE_COURANTE}
737
738        while [ ${COMPTEUR} -lt ${NBRE_FILE_LOOP} ] ; do
739            #
740            Length=$( create_ts_next_date ${DATE_LOOP} )
741            DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} ${Length} )
742            (( TotLength = TotLength + Length ))
743            (( COMPTEUR = COMPTEUR + 1 ))
744            #
745        done # while [ ${COMPTEUR} -le ${NBRE_FILE_LOOP} ] done
746        DATE_FIN=$( IGCM_date_AddDaysToGregorianDate ${DATE_COURANTE} ${TotLength} )
747
748        [ -n "${DATE_LOOP}" ] && DATE_FIN_JOB_B_LOOP_PREC=${DATE_FIN_JOB_B_LOOP} ; DATE_FIN_JOB_B_LOOP=${DATE_LOOP}
749        [ -n "${LEVEL}" ] && [ ${LEVEL} -eq 0 ] && FLAG_B="TRUE" || [ ${CURRENT_LOOP} -gt 1 ] && FLAG_B="TRUE" || FLAG_B="FALSE"
750        DEPOT="FALSE"
751        LEVEL=2
752    else
753        # - LEVEL 3 : WE ARE IN THE LAST LOOP
754        NBRE_FILE_LOOP=$(( ${NBRE_FILE_TOT} % ( ${UNIX_MAX_LIMIT} * ( ${CURRENT_LOOP} - 1 ) ) ))
755        [ ${NBRE_FILE_LOOP} -eq 0 ] && NBRE_FILE_LOOP=${UNIX_MAX_LIMIT}
756
757        Length=$( create_ts_next_date ${DATE_FIN} )
758        DATE_COURANTE=$(IGCM_date_AddDaysToGregorianDate ${DATE_FIN} ${Length} )
759        DATE_FIN=${PeriodDateEnd}
760        [ -n "${DATE_LOOP}" ] && DATE_FIN_JOB_B_LOOP_PREC=${DATE_FIN_JOB_B_LOOP} ; DATE_FIN_JOB_B_LOOP=${DATE_LOOP}
761
762        LEVEL=3
763        DEPOT="TRUE"
764        FLAG_B="TRUE"
765    fi
766
767    # THEN FOR EACH FILE TYPE WE LOOP BETWEEN DATE_COURANTE AND DATE_FIN.
768    for comp in ${config_ListOfComponents[*]} ; do
769        #
770        IGCM_sys_Mkdir ${RUN_DIR_PATH}/${comp}
771        #
772        IGCM_sys_Cd ${RUN_DIR_PATH}/${comp}
773        #
774        eval R_OUT_${comp}=${R_SAVE}/${comp}
775        #
776        i=0
777        #
778        for file in $( eval echo \${LISTE_FILE_${comp}[*]} ); do
779            #
780            # Determine in which output can we find file
781            # IE : Output/MO or Output/DA or ...
782            #
783            FlagDir=$( echo ${file} | awk -F "_" '{print $1}' )
784            case ${FlagDir} in
785                *Y)    TS_Dir=TS_YE  ; FreqDir=YE  ;;
786                *M)    TS_Dir=TS_MO  ; FreqDir=MO  ;;
787                *D)    TS_Dir=TS_DA  ; FreqDir=DA  ;;
788                HF)    TS_Dir=TS_HF  ; FreqDir=HF  ;;
789                3H)    TS_Dir=TS_HF  ; FreqDir=HF  ;;
790                INS)   TS_Dir=TS_INS ; FreqDir=INS ;;
791                *) 
792                       IGCM_debug_Print 1 "Error in FlagDir=${FlagDir} for file ${file}."
793                       IGCM_sys_Exit "Job create_ts" ;;
794            esac
795
796            # Initialize array
797            #set -A liste_file
798            #set -A liste_file_tmp
799            unset liste_file
800            unset liste_file_tmp
801            eval file_path=\${R_OUT_${comp}}/Output/${FreqDir}/
802
803            COMPTEUR=1
804            DATE_LOOP=${DATE_COURANTE}
805
806            while [ ${COMPTEUR} -le ${NBRE_FILE_LOOP} ] ; do
807                #
808                Length1=$( create_ts_begin_date ${DATE_LOOP} end)
809                DATE_TAB=$(  IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} $(( 1 - Length1 )) )_${DATE_LOOP}
810
811                Length2=$( create_ts_next_date ${DATE_LOOP} end)
812                DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} ${Length2} )
813
814                #set +A liste_file ${liste_file[*]} ${file_path}${config_UserChoices_JobName}_${DATE_TAB}_${file}.nc
815                #set +A liste_file_tmp ${liste_file_tmp[*]} ${config_UserChoices_JobName}_${DATE_TAB}_${file}.nc
816                liste_file[${#liste_file[*]}]=${file_path}${config_UserChoices_JobName}_${DATE_TAB}_${file}.nc
817                liste_file_tmp[${#liste_file_tmp[*]}]=${config_UserChoices_JobName}_${DATE_TAB}_${file}.nc
818                (( COMPTEUR = COMPTEUR + 1 ))
819                #
820            done # while [ ${COMPTEUR} -le ${NBRE_FILE_LOOP} ] done
821            DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} -${Length2} )
822
823            # Get selected files
824            IGCM_sys_Get /l liste_file[*] ${RUN_DIR_PATH}/${comp}
825            IGCM_debug_Verif_Exit_Post
826
827            # Apply IGCM_Patch if needed
828            if [ ! X${RebuildFrequency} = Xtrue ] ; then
829                if [ X$( eval echo \${LISTE_PATCHES_${file}[0]} ) !=  X${NULL_STR} ]; then
830                    for file_t in $( eval echo ${liste_file_tmp[*]} ); do               
831                        for Patch in $( eval echo \${LISTE_PATCHES_${file}[*]} ); do
832                            IGCM_${Patch} ${file_t}
833                            IGCM_debug_Verif_Exit_Post
834                        done
835                    done
836                fi
837            fi
838
839            # WE CAN CONCATENATE FILES AT THIS POINT
840            [ "${FLAG_B}" = "TRUE" ] && DATE_BUILD_B=${DateBegin}_${DATE_FIN_JOB_B_LOOP_PREC}
841            Length=$( create_ts_begin_date ${DATE_COURANTE} end)
842            DATE_BUILD1=$( IGCM_date_AddDaysToGregorianDate ${DATE_COURANTE} -$(( Length - 1 )) )
843            DATE_BUILD=${DATE_BUILD1}_${DATE_FIN}
844            DATE_BUILD_END=${DateBegin}_${DATE_FIN}
845
846            liste_coord=" "
847            for axis in $( eval echo \${LISTE_AXIS_${file}[*]} ); do
848              liste_coord=${liste_coord}${axis}","
849            done
850
851            # Time axis must be the last dimension
852            time_axis=${axis}
853
854            # SWITCH BETWEEN MODEL TO FIT PARTICULAR CASE
855            for var in $( eval echo \${LISTE_VARS_${file}[*]} ) ; do
856                #
857                IGCM_sys_ncrcat --hst -v ${liste_coord}${var} ${liste_file_tmp[*]} ${config_UserChoices_JobName}_${DATE_BUILD}_${FlagDir}_${var}.nc
858                #
859                if [ "${FLAG_B}" = "TRUE" ] ; then
860                    # WE CONCATENATE WITH EXISTING FILES
861                    file1=${config_UserChoices_JobName}_${DATE_BUILD_B}_${FlagDir}_${var}.nc
862                    file2=${config_UserChoices_JobName}_${DATE_BUILD}_${FlagDir}_${var}.nc
863                    file_out=${config_UserChoices_JobName}_${DATE_BUILD_END}_${FlagDir}_${var}.nc
864                    IGCM_sys_ncrcat --hst ${file1} ${file2} ${file_out}
865                    #
866                    IGCM_sys_Rm ${file1} ${file2}
867                fi
868
869                #
870                if [ "${DEPOT}" = "TRUE" ] ; then
871                    # WE PUT FINAL FILE ON FILE SYSTEM
872                    [ "${FLAG_B}" = "FALSE" ] && file_out=${config_UserChoices_JobName}_${DATE_BUILD}_${FlagDir}_${var}.nc
873                    file_before=${config_UserChoices_JobName}_${DateBegin}_${DATE_FIN_JOB_B}_${FlagDir}_${var}.nc
874                    #
875                    eval IGCM_sys_Put_Out ${file_out} \${R_OUT_${comp}}/Analyse/${TS_Dir}/${file_out}
876                    [ "${FLAG_B}" = "TRUE" ] && eval MENAGE \${R_OUT_${comp}}/Analyse/${TS_Dir} ${file_before} ${file_out}
877                    #
878                    if [ ${FlagDir} = "1M" ] ; then
879                        file_before_YE=${config_UserChoices_JobName}_${DateBegin}_${DATE_FIN_JOB_B}_1Y_${var}.nc
880                        file_out_YE=${config_UserChoices_JobName}_${DATE_BUILD_END}_1Y_${var}.nc
881                        #
882                        # Compute yearly average considering calendar
883                        # and set date of the mid year to 01/07 at 00:00
884                        IGCM_sys_cdo -settime,00:00 -setday,1 -setmon,7 -settunits,days -divdpy -yearsum -muldpm -selvar,${var} ${file_out} ${file_out_YE}
885                        # Extract all ancillary variables except $var, they will be appended after the cdo command
886                        # Needed because cdo applies calculs on all variables
887                        IGCM_sys_ncks -Oh -x -v ${var} ${file_out} ${file_out_YE%%.nc}_tmp1.nc
888                        # This will remove the time axis because cdo rewrites severely with only considered useful variables
889                        IGCM_sys_cdo -mulc,1 ${file_out_YE%%.nc}_tmp1.nc ${file_out_YE%%.nc}_tmp2.nc
890                        if [ $? -eq 0 ] ; then
891                                # Now append all ancillary variables if previous cdo operator ok
892                                IGCM_sys_ncks -h -A ${file_out_YE%%.nc}_tmp2.nc ${file_out_YE}
893                        fi
894
895                        # Put global history attribut
896                        IGCM_sys_ncatted -Oh -a history,global,o,c,"build by libIGCM/create_ts" ${file_out_YE}
897                        #
898                        eval IGCM_sys_Put_Out ${file_out_YE} \${R_OUT_${comp}}/Analyse/TS_MO_YE/${file_out_YE}
899                        [ "${FLAG_B}" = "TRUE" ] && eval MENAGE \${R_OUT_${comp}}/Analyse/TS_MO_YE/ ${file_before_YE} ${file_out_YE}
900                        IGCM_sys_Rm ${file_out_YE%%.nc}_tmp*.nc
901                    fi
902                    #
903                    IGCM_sys_Rm ${file_out}
904                    #
905                fi
906                #
907            done     # for var in ${liste_var} ; do
908            IGCM_sys_Rm ${liste_file_tmp[*]}
909        done         # for file in ${liste_file_brut} do
910    done             # for comp in ${config_ListOfComponents[*]} ; do
911    # GO AHEAD IN DEEPEST LOOP
912    (( CURRENT_LOOP = CURRENT_LOOP + 1 ))
913done                 # while [ ${CURRENT_LOOP} -le  ${NBRE_TOUR} ] do
914# FINISH
915
916# DODS copy
917for comp in ${config_ListOfComponents[*]} ; do
918    for TS_Dir in TS_YE TS_MO TS_MO_YE TS_DA TS_HF TS_INS ; do
919        IGCM_sys_TestDirArchive ${R_SAVE}/${comp}/Analyse/${TS_Dir}
920        [ $? = 0 ] && IGCM_sys_Put_Dods ${comp}/Analyse/${TS_Dir}
921    done
922done
923
924export POST_DIR; export SUBMIT_DIR; export libIGCM; export R_INIT; export R_BC; export StandAlone
925export RESOL_ATM; export RESOL_OCE ; export RESOL_ICE ; export RESOL_MBG ; export RESOL_SRF ; export RESOL_SBG
926
927listVarEnv="POST_DIR,SUBMIT_DIR,libIGCM,R_INIT,R_BC,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG"
928export listVarEnv
929
930#D-
931# --------------------------------------------------------------------
932#D- Test if all was right
933# --------------------------------------------------------------------
934IGCM_debug_Verif_Exit_Post
935# --------------------------------------------------------------------
936#D- Submit MONITORING
937# --------------------------------------------------------------------
938if ( [ X${TsTask} = X2D ] || [ X${TsTask} = X ] ) ; then
939    Script_Post_Output=monitoring.${PeriodDateEnd}
940    IGCM_sys_QsubPost monitoring
941fi
942
943#D-
944# --------------------------------------------------------------------
945#D- Update the run.card
946# --------------------------------------------------------------------
947if [ ${StandAlone} != true ] ; then
948    # Put in run.card end period of time series
949    [ X"${DATE_FIN}" = X ] || IGCM_sys_RshMaster IGCM_card_WriteOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted "${DATE_FIN}"
950    # We have finish the job !
951    IGCM_sys_RshMaster IGCM_card_WriteOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesRunning "n"
952fi
953
954# Clean RUN_DIR_PATH (necessary for cesium)
955IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
956
957date
Note: See TracBrowser for help on using the repository browser.