source: trunk/libIGCM/AA_create_ts @ 712

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