source: branches/libIGCM_MPI_OpenMP/AA_create_ts @ 570

Last change on this file since 570 was 563, checked in by mafoipsl, 12 years ago

curie : first try for curie machine.

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