source: trunk/libIGCM/AA_create_se @ 279

Last change on this file since 279 was 278, checked in by mafoipsl, 14 years ago

Add modulo attribute to time axis for CPL seasonal files.

  • 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 Date Author Revision
File size: 22.9 KB
Line 
1#-Q- platine #!/usr/bin/ksh
2#-Q- platine ###################
3#-Q- platine ## PLATINE   CEA ##
4#-Q- platine ###################
5#-Q- platine #BSUB -J SE                     # Nom du job
6#-Q- platine #BSUB -N                        # message a la fin du job
7#-Q- platine #BSUB -n 1                      # reservation des processeurs pour le job
8#-Q- platine #BSUB -W 1:00                   # Limite temps
9#-Q- platine #BSUB -q post              # Passage en queue post
10#-Q- sx8brodie #!/bin/ksh
11#-Q- sx8brodie #######################
12#-Q- sx8brodie ## SX8BRODIE   IDRIS ##
13#-Q- sx8brodie #######################
14#-Q- sx8brodie # Temps Elapsed max. d'une requete hh:mm:ss
15#-Q- sx8brodie # @ wall_clock_limit = 20:00:00
16#-Q- sx8brodie # Nom du travail LoadLeveler
17#-Q- sx8brodie # @ job_name   = SE
18#-Q- sx8brodie # Fichier de sortie standard du travail       
19#-Q- sx8brodie # @ output     = $(job_name).$(jobid)
20#-Q- sx8brodie # Fichier de sortie d'erreur du travail
21#-Q- sx8brodie # @ error      =  $(job_name).$(jobid)
22#-Q- sx8brodie # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
23#-Q- sx8brodie # @ notification = error
24#-Q- sx8brodie # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $REBUILD_DIR ; $RebuildFromArchive ; $POST_DIR ; $MASTER ; $DateBegin ; $PeriodDateBegin ; $PeriodDateEnd ; $NbRebuildDir ; $StandAlone ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_MBG ; $RESOL_SRF ; $RESOL_SBG ; $MASTER
25#-Q- sx8brodie # @ queue
26#-Q- aix6 #!/bin/ksh
27#-Q- aix6 #######################
28#-Q- aix6 ##   VARGAS   IDRIS  ##
29#-Q- aix6 #######################
30#-Q- aix6 # Temps Elapsed max. d'une requete hh:mm:ss
31#-Q- aix6 # @ wall_clock_limit = 20:00:00
32#-Q- aix6 # Nom du travail LoadLeveler
33#-Q- aix6 # @ job_name   = SE
34#-Q- aix6 # Fichier de sortie standard du travail       
35#-Q- aix6 # @ output     = $(job_name).$(jobid)
36#-Q- aix6 # Fichier de sortie d'erreur du travail
37#-Q- aix6 # @ error      =  $(job_name).$(jobid)
38#-Q- aix6 # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
39#-Q- aix6 # @ notification = error
40#-Q- aix6 # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $REBUILD_DIR ; $RebuildFromArchive ; $POST_DIR ; $MASTER ; $DateBegin ; $PeriodDateBegin ; $PeriodDateEnd ; $NbRebuildDir ; $StandAlone ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_MBG ; $RESOL_SRF ; $RESOL_SBG ; $MASTER
41#-Q- aix6 # @ queue
42#-Q- sx8mercure #!/bin/ksh
43#-Q- sx8mercure ######################
44#-Q- sx8mercure ## SX8MERCURE   CEA ##
45#-Q- sx8mercure ######################
46#-Q- sx8mercure #PBS -N SE                   # Nom du job
47#-Q- sx8mercure #PBS -j o                    # regroupement des stdout et stderr
48#-Q- sx8mercure #PBS -S /usr/bin/ksh         # shell de soumission
49#-Q- sx8mercure #PBS -l memsz_job=1gb        # Limite memoire a 1 Go
50#-Q- sx8mercure #PBS -l cputim_job=1:00:00   # Limite temps a 1 heures
51#-Q- sx8mercure #PBS -q scalaire
52#-Q- sx9mercure ######################
53#-Q- sx9mercure ## SX9MERCURE   CEA ##
54#-Q- sx9mercure ######################
55#-Q- sx9mercure #PBS -N SE                   # Nom du job
56#-Q- sx9mercure #PBS -j o                    # regroupement des stdout et stderr
57#-Q- sx9mercure #PBS -S /usr/bin/ksh         # shell de soumission
58#-Q- sx9mercure #PBS -l memsz_job=1gb        # Limite memoire a 1 Go
59#-Q- sx9mercure #PBS -l cputim_job=1:00:00   # Limite temps a 1 heures
60#-Q- sx9mercure #PBS -q scal-new
61#-Q- titane #!/bin/ksh
62#-Q- titane ######################
63#-Q- titane ## TITANE   CEA ##
64#-Q- titane ######################
65#-Q- titane #MSUB -r SE             # Nom du job               
66#-Q- titane #MSUB -N 1              # Reservation du noeud
67#-Q- titane #MSUB -n 1              # Reservation du processus
68#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job
69#-Q- titane #MSUB -E "-j o"
70#-Q- titane #MSUB -E "-S /bin/ksh"
71#-Q- titane ##MSUB -e nco.out        # Sortie standard
72#-Q- titane ##MSUB -o nco.out        # Sortie standard
73#-Q- default #!/bin/ksh
74#-Q- default ##################
75#-Q- default ## DEFAULT HOST ##
76#-Q- default ##################
77
78# $Date$
79# $Author$
80# $Revision$
81# IPSL (2006)
82#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
83
84#set -eu
85#set -vx
86
87date
88
89#-Q- sx8brodie export OMP_NUM_THREADS=1
90#-Q- aix6 export OMP_NUM_THREADS=1
91
92########################################################################
93
94#D- Flag to determine if this job in a standalone mode
95#D- Default : value from AA_job if any
96StandAlone=${StandAlone:=true}
97
98#D- Low level debug : to bypass lib test checks and stack construction
99#D- Default : value from AA_job if any
100libIGCM=${libIGCM:=::modipsl::/libIGCM}
101# WARNING for StandAlone used : To run this script on some machine,
102# you must check MirrorlibIGCM variable in sys library.
103# If this variable is true, you must use libIGCM_POST path instead
104# of your running libIGCM directory.
105
106#D- Flag to determine if rebuild process has been performed asynchronously
107#D- Possible value true or false.
108#D- If true raw files has allready been patched by rebuild job
109#D- If false create_ts will patch the raw files
110#D- Default : Value from AA_job if any. Usefull in StandAlone case.
111RebuildFrequency=${RebuildFrequency:=true}
112
113#D- Flag to determine atlas job's output directory
114#D- Default : value from libIGCM_post.ksh if any
115POST_DIR=${POST_DIR:=${PBS_O_WORKDIR}}
116
117#D- Increased verbosity (1, 2, 3)
118#D- Default : value from AA_job if any
119Verbosity=${Verbosity:=3}
120
121#D- Low level debug : to bypass lib test checks and stack construction
122#D- Default : value from AA_job if any
123DEBUG_debug=${DEBUG_debug:=false}
124
125#D- TEMPORARY Flag to determine atmospheric resolution
126#D- Default : value from atmospheric driver if any
127RESOL_ATM=${RESOL_ATM:=ALL}
128
129#D- Flag to determine surface resolution
130#D- Default : value from surface driver if any
131RESOL_SRF=ALL
132
133#D- Flag to determine surface resolution
134#D- Default : value from surface driver if any
135RESOL_SBG=ALL
136
137#D- TEMPORARY Flag to determine ocean resolution
138#D- Default : value from ocean driver if any
139RESOL_OCE=${RESOL_OCE:=ORCA2}
140
141#D- TEMPORARY Flag to determine ice resolution
142#D- Default : value from ice driver if any
143RESOL_ICE=${RESOL_ICE:=ORCA2}
144
145#D- TEMPORARY Flag to determine marine biogeochemistry resolution
146#D- Default : value from ice driver if any
147RESOL_MBG=${RESOL_MBG:=ORCA2}
148
149########################################################################
150
151. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
152      ( ${DEBUG_debug} ) && IGCM_debug_Check
153. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
154     ( ${DEBUG_debug} ) && IGCM_card_Check
155. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
156     ( ${DEBUG_debug} ) && IGCM_date_Check
157#-------
158. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
159
160########################################################################
161
162#set -vx
163
164IGCM_sys_MkdirWork ${RUN_DIR_PATH}
165IGCM_sys_Cd ${RUN_DIR_PATH}
166
167if [ ${StandAlone} = true ] ; then
168    CARD_DIR=${SUBMIT_DIR}
169else
170    CARD_DIR=${RUN_DIR_PATH}/$( basename ${SUBMIT_DIR} )
171    IGCM_sys_Get_Master ${SUBMIT_DIR} ${RUN_DIR_PATH}
172fi
173
174#
175# First of all
176#
177IGCM_card_DefineArrayFromSection   ${CARD_DIR}/config.card UserChoices
178typeset option
179for option in ${config_UserChoices[*]} ; do
180    IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card UserChoices ${option}
181done
182#
183echo
184IGCM_debug_Print 1 "DefineArrayFromOption  : config_UserChoices"
185IGCM_debug_PrintVariables 3 config_UserChoices_JobName
186IGCM_debug_PrintVariables 3 config_UserChoices_LongName
187IGCM_debug_PrintVariables 3 config_UserChoices_TagName
188IGCM_debug_PrintVariables 3 config_UserChoices_SpaceName
189IGCM_debug_PrintVariables 3 config_UserChoices_ExperimentName
190IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType
191IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin
192IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd
193IGCM_debug_PrintVariables 3 config_UserChoices_PeriodLength
194echo
195
196#==================================
197#R_SAVE : Job output directory
198if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then
199    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' )
200    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
201    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
202else
203    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
204    R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName}
205fi
206#
207IGCM_card_DefineArrayFromSection   ${CARD_DIR}/config.card ListOfComponents
208#
209IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card Post SeasonalFrequency
210#
211# Determine period for seasonnal average. Default : value from AA_job if any
212#
213DateBegin=${DateBegin:=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )}
214#
215PeriodDateEnd=${PeriodDateEnd:=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )}
216#
217freq=$( echo ${config_Post_SeasonalFrequency} |  sed -e "s/[yY]//" )
218#
219an_fin=$(( $( IGCM_date_ConvertGregorianDateToJulian ${PeriodDateEnd} ) / 1000 ))
220an_deb=$( IGCM_date_YearDigit $(( an_fin - freq + 1 )) )
221an_fin=$( IGCM_date_YearDigit ${an_fin} )
222#
223# For each component selected determine which files need post-processing
224#
225for comp in ${config_ListOfComponents[*]} ; do
226    #
227    IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp}
228    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
229    #
230    card=${CARD_DIR}/COMP/${compname}.card
231    IGCM_card_DefineArrayFromOption ${card} OutputFiles List
232    #
233    ListFilesName=${compname}_OutputFiles_List
234    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
235    #
236    if [ X${FileName0} != X${NULL_STR} ] ; then
237        #
238        # INITIALISATION
239        #
240        eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
241        typeset i=2
242        #
243        until [ $i -gt $NbFiles ]; do
244            #
245            eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1
246            #
247            if [ X${flag_post} != XNONE ] ; then
248                #
249                # Check if seasonal is required for this file
250                #
251                IGCM_card_DefineArrayFromSection ${card} ${flag_post}
252                #
253                # Seasonal case : If option Seasonal is not found (old cards) put SEASONAL ON by default
254                #
255                # variable option allready typeset above
256                for option in $( eval echo \${${compname}_${flag_post}[*]} ) ; do
257                    if [ ${option} = Seasonal ] ; then
258                        FoundSeasonal=true
259                        IGCM_card_DefineVariableFromOption ${card} ${flag_post} Seasonal
260                    fi
261                done
262                #
263                if [ ! X${FoundSeasonal} = Xtrue ] ; then
264                    eval ${compname}_${flag_post}_Seasonal=ON
265                fi
266                #
267                if [ ! X$( eval echo \${${compname}_${flag_post}_Seasonal} ) = XON ] ; then
268                    (( i=i+3 ))
269                    continue
270                fi
271                #
272                # CREATE LIST
273                #
274                FILE=$( echo ${flag_post} | awk "-FPost_" '{print $2}' )
275                #
276                DIRECTORY=${R_SAVE}/${comp}/Analyse/SE
277                #
278                TestedFile=${config_UserChoices_JobName}_SE_${an_deb}_${an_fin}_${FILE}.nc
279                #
280                IGCM_sys_TestFileArchive ${DIRECTORY}/${TestedFile}
281                if [ ! $? = 0 ] ; then
282                    eval set +A LISTE_FILE_${comp} \$\{LISTE_FILE_${comp}[*]} ${FILE}
283                    if [ ! ${RebuildFrequency} = true ] ; then
284                        IGCM_card_DefineArrayFromOption ${card} Post_${FILE} Patches
285                        eval set +A LISTE_PATCHES_${FILE} \$\{${compname}_Post_${FILE}_Patches[*]}
286                        if [ X$( eval echo \${LISTE_PATCHES_${FILE}[0]} ) !=  X${NULL_STR} ]; then
287                            for Patch in $( eval echo \${LISTE_PATCHES_${FILE}[*]} ); do
288                                if [ Xload${Patch} != X ] ; then
289                                    . ${libIGCM}/libIGCM_post/IGCM_${Patch}.ksh
290                                    eval load${Patch}=loaded
291                                fi
292                            done
293                        fi
294                    fi
295                fi
296            fi
297            (( i=i+3 ))
298        done # until [ $i -eq $NbFiles ]
299    fi
300done         # for comp
301
302for comp in ${config_ListOfComponents[*]} ; do
303    #
304    eval R_OUT_${comp}=${R_SAVE}/${comp}
305    #
306    i=0
307    for file in $( eval echo \${LISTE_FILE_${comp}[*]} ); do
308        #
309        # Determine in which output can we find file
310        # IE : Output/MO or Output/DA or ...
311        #
312        FlagDir=$( echo ${file} | awk -F "_" '{print $1}' )
313        case ${FlagDir} in
314            1Y)    FreqDir=YE  ;;
315            1M)    FreqDir=MO  ;;
316            5D|1D) FreqDir=DA  ;;
317            HF)    FreqDir=HF  ;;
318            3H)    FreqDir=HF  ;;
319            INS)   FreqDir=INS ;;
320        esac
321        #
322        RESULT_SE=${config_UserChoices_JobName}_SE_${an_deb}_${an_fin}_${file}.nc
323        # Do not redoo an existing SE
324        IGCM_sys_TestFileArchive ${R_SAVE}/${comp}/Analyse/SE/${RESULT_SE}
325        if [ $? = 0 ] ; then
326            continue
327        fi
328        #
329        eval file_path=\${R_OUT_${comp}}/Output/${FreqDir}/
330        #
331        case ${config_UserChoices_PeriodLength} in
332        # For Yearly simulation :
333        1Y|1y)
334          (( an = an_deb ))
335          # Initialize array
336          #set -A liste_file_se
337          #set -A liste_file_se_tmp
338          unset liste_file_se
339          unset liste_file_se_tmp
340          while [ ${an} -le ${an_fin} ] ; do
341              moisL=$( IGCM_date_DaysInMonth ${an} ${mois} )
342              #
343              an4=$(printf "%04i\n" ${an} )
344              #
345              diy=$( IGCM_date_DaysInYear $an4 )
346              afin=$( IGCM_date_AddDaysToGregorianDate ${an4}0101 $(( diy - 1 )) )
347              date=${an4}0101_${afin}
348              #set +A liste_file_se ${liste_file_se[*]} ${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
349              #set +A liste_file_se_tmp ${liste_file_se_tmp[*]} ${config_UserChoices_JobName}_${date}_${file}.nc
350              liste_file_se[${#liste_file_se[*]}]=${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
351              liste_file_se_tmp[${#liste_file_se_tmp[*]}]=${config_UserChoices_JobName}_${date}_${file}.nc
352              (( an = an + 1 ))
353          done
354          #
355          IGCM_sys_Get /l liste_file_se[*] ${RUN_DIR_PATH}
356          eval ExitFlag=false
357          IGCM_debug_Verif_Exit_Post
358         
359          # Apply IGCM_Patch if needed
360          if [ ! ${RebuildFrequency} = true ] ; then
361              if [ X$( eval echo \${LISTE_PATCHES_${file}[0]} ) !=  X${NULL_STR} ]; then
362                  for file_t in $( eval echo ${liste_file_se_tmp[*]} ); do
363                      for Patch in $( eval echo \${LISTE_PATCHES_${file}[*]} ); do
364                          IGCM_${Patch} ${file_t}
365                      done
366                  done
367              fi
368          fi
369                     
370          # Search of common list of variables to be treated
371          nbfile=0
372          for file_common_var in ${liste_file_se_tmp[*]} ; do
373              ncks -m ${file_common_var} | grep '# dim. =' | cut -d ':' -f 1 >> tmpfile_ncra
374              (( nbfile = nbfile + 1 ))
375          done
376          list_var_final_ncra=`cat tmpfile_ncra | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 == nbfile) {print $2}}' | paste -s -d ','`
377          IGCM_sys_Rm tmpfile_ncra
378
379          for mois in  01 02 03 04 05 06 07 08 09 10 11 12 ; do
380          #
381              (( nb = ${mois} - 1 ))
382          #
383              OUT_SE[${nb}]=${config_UserChoices_JobName}_SE${mois}_${an_deb}_${an_fin}_${file}.nc
384              IGCM_sys_ncra -O -v ${list_var_final_ncra} -d time_counter,${nb},,12 ${liste_file_se_tmp[*]} ${OUT_SE[${nb}]}
385          done
386          IGCM_sys_Rm ${liste_file_se_tmp[*]}
387          eval ExitFlag=false
388          IGCM_debug_Verif_Exit_Post
389          ;;
390        # For Monthly simulation :
391        1M|1m)
392          for mois in  01 02 03 04 05 06 07 08 09 10 11 12 ; do
393              #
394              (( nb = ${mois} - 1 ))
395              #
396              OUT_SE[${nb}]=${config_UserChoices_JobName}_SE${mois}_${an_deb}_${an_fin}_${file}.nc
397              #
398              (( an = an_deb ))
399              # Initialize array
400              #set -A liste_file_se
401              #set -A liste_file_se_tmp
402              unset liste_file_se
403              unset liste_file_se_tmp
404              while [ ${an} -le ${an_fin} ] ; do
405                  moisL=$( IGCM_date_DaysInMonth ${an} ${mois} )
406                  #
407                  an4=$(printf "%04i\n" ${an} )
408                  #
409                  date=${an4}${mois}01_${an4}${mois}${moisL}
410                  #set +A liste_file_se ${liste_file_se[*]} ${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
411                  #set +A liste_file_se_tmp ${liste_file_se_tmp[*]} ${config_UserChoices_JobName}_${date}_${file}.nc
412                  liste_file_se[${#liste_file_se[*]}]=${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
413                  liste_file_se_tmp[${#liste_file_se_tmp[*]}]=${config_UserChoices_JobName}_${date}_${file}.nc
414
415                  (( an = an + 1 ))
416              done
417              #
418              IGCM_sys_Get /l liste_file_se[*] ${RUN_DIR_PATH}
419              eval ExitFlag=false
420              IGCM_debug_Verif_Exit_Post
421             
422              # Apply IGCM_Patch if needed
423              if [ ! ${RebuildFrequency} = true ] ; then
424                  if [ X$( eval echo \${LISTE_PATCHES_${file}[0]} ) !=  X${NULL_STR} ]; then
425                      for file_t in $( eval echo ${liste_file_se_tmp[*]} ); do
426                          for Patch in $( eval echo \${LISTE_PATCHES_${file}[*]} ); do
427                              IGCM_${Patch} ${file_t}
428                          done
429                      done
430                  fi
431              fi
432             
433              # Search of common list of variables to be treated
434              nbfile=0
435              for file_common_var in ${liste_file_se_tmp[*]} ; do
436                  ncks -m ${file_common_var} | grep '# dim. =' | cut -d ':' -f 1 >> tmpfile_ncra
437                  (( nbfile = nbfile + 1 ))
438              done
439              list_var_final_ncra=`cat tmpfile_ncra | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 == nbfile) {print $2}}' | paste -s -d ','`
440              IGCM_sys_Rm tmpfile_ncra
441              IGCM_sys_ncra -O -v ${list_var_final_ncra} ${liste_file_se_tmp[*]} ${OUT_SE[${nb}]}
442
443              IGCM_sys_Rm ${liste_file_se_tmp[*]}
444              eval ExitFlag=false
445              IGCM_debug_Verif_Exit_Post
446          done
447          ;;
448        *D|*d)
449          for mois in  01 02 03 04 05 06 07 08 09 10 11 12 ; do
450              #
451              (( nb = ${mois} - 1 ))
452              #
453              OUT_SE[${nb}]=${config_UserChoices_JobName}_SE${mois}_${an_deb}_${an_fin}_${file}.nc
454              #
455              (( an = an_deb ))
456              # Initialize array
457              #set -A liste_file_se
458              #set -A liste_file_se_tmp
459              unset liste_file_se
460              unset liste_file_se_tmp
461              while [ ${an} -le ${an_fin} ] ; do
462                  moisL=$( IGCM_date_DaysInMonth ${an} ${mois} )
463                  #
464                  an4=$(printf "%04i\n" ${an} )
465                  #
466                  length_d=$(( ${config_UserChoices_PeriodLength} - 1 ))
467                  # for one day
468                  if [ ${length_d} -eq 1 ] ; then
469                      (( length_d = 0 ))
470                  fi
471                  (( day  = 1 ))
472                  while [ ${day} -le ${moisL} ] ; do
473                      day2=$(printf "%02i\n" ${day} )
474                      day_beg=${an4}${mois}${day2}
475                      day_end=$( IGCM_date_AddDaysToGregorianDate ${day_beg} ${length_d} )
476                      date=${an4}${mois}${day_beg}_${an4}${mois}${day_end}
477                      #set +A liste_file_se ${liste_file_se[*]} ${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
478                      #set +A liste_file_se_tmp ${liste_file_se_tmp[*]} ${config_UserChoices_JobName}_${date}_${file}.nc
479                      liste_file_se[${#liste_file_se[*]}]=${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
480                      liste_file_se_tmp[${#liste_file_se_tmp[*]}]=${config_UserChoices_JobName}_${date}_${file}.nc
481                      (( day = day + 1 ))
482                  done
483                  (( an = an + 1 ))
484              done
485              #
486              IGCM_sys_Get /l liste_file_se[*] ${RUN_DIR_PATH}
487              eval ExitFlag=false
488              IGCM_debug_Verif_Exit_Post
489             
490              # Apply IGCM_Patch if needed
491              if [ ! ${RebuildFrequency} = true ] ; then
492                  if [ X$( eval echo \${LISTE_PATCHES_${file}[0]} ) !=  X${NULL_STR} ]; then
493                      for file_t in $( eval echo ${liste_file_se_tmp[*]} ); do
494                          for Patch in $( eval echo \${LISTE_PATCHES_${file}[*]} ); do
495                              IGCM_${Patch} ${file_t}
496                          done
497                      done
498                  fi
499              fi
500
501              # Search of common list of variables to be treated
502              nbfile=0
503              for file_common_var in ${liste_file_se_tmp[*]} ; do
504                  ncks -m ${file_common_var} | grep '# dim. =' | cut -d ':' -f 1 >> tmpfile_ncra
505                  (( nbfile = nbfile + 1 ))
506              done
507              list_var_final_ncra=`cat tmpfile_ncra | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 == nbfile) {print $2}}' | paste -s -d ','`
508              IGCM_sys_Rm tmpfile_ncra
509
510              IGCM_sys_ncra -O -v ${list_var_final_ncra} ${liste_file_se_tmp[*]} ${OUT_SE[${nb}]}
511              IGCM_sys_Rm ${liste_file_se_tmp[*]}
512              eval ExitFlag=false
513              IGCM_debug_Verif_Exit_Post
514          done
515          ;;
516        esac
517        #
518
519        # Search of common list of variables to be treated
520        nbfile=0
521        for file_common_var in ${OUT_SE[*]} ; do
522           ncks -m ${file_common_var} | grep '# dim. =' | cut -d ':' -f 1 >> tmpfile_ncrcat
523           (( nbfile = nbfile + 1 ))
524        done
525        list_var_final_ncrcat=`cat tmpfile_ncrcat | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 == nbfile) {print $2}}' | paste -s -d ','`
526        IGCM_sys_Rm tmpfile_ncrcat
527
528        IGCM_sys_ncrcat -O -v ${list_var_final_ncrcat} ${OUT_SE[*]} ${RESULT_SE}
529        #
530        IGCM_sys_Rm ${OUT_SE[*]}
531        #
532        if [ ${comp} = "CPL" ] ; then
533              ${ncatted} -a modulo,time,c,c," " ${RESULT_SE}
534        else
535              ${ncatted} -a modulo,time_counter,c,c," " ${RESULT_SE}
536        fi
537        #
538        eval IGCM_sys_Put_Out ${RESULT_SE} \${R_OUT_${comp}}/Analyse/SE/${RESULT_SE}
539        IGCM_sys_Rm ${RESULT_SE}
540        #
541        eval ExitFlag=false
542        IGCM_debug_Verif_Exit_Post
543    done
544done
545
546# DODS copy
547for comp in ${config_ListOfComponents[*]} ; do
548    IGCM_sys_TestDirArchive ${R_SAVE}/${comp}/Analyse/SE
549    [ $? = 0 ] && IGCM_sys_Put_Dods ${comp}/Analyse/SE
550done
551
552YEARS=${an_deb}_${an_fin}
553
554export POST_DIR; export SUBMIT_DIR; export libIGCM; export R_INIT; export R_BC; export StandAlone
555export RESOL_ATM; export RESOL_OCE ; export RESOL_ICE ; export RESOL_MBG ; export RESOL_SRF ; export RESOL_SBG
556export R_SAVE; export config_UserChoices_JobName; export config_UserChoices_TagName; export YEARS;
557listVarEnv="POST_DIR,SUBMIT_DIR,libIGCM,R_INIT,R_BC,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG,R_SAVE,config_UserChoices_JobName,config_UserChoices_TagName,YEARS"
558export listVarEnv;
559
560#D-
561# --------------------------------------------------------------------
562#D- Test if all was right before ATLAS
563# --------------------------------------------------------------------
564IGCM_debug_Verif_Exit_Post
565
566if [ ${config_UserChoices_TagName} = "IPSLCM4_v1_OASIS3" ] || \
567   [ ${config_UserChoices_TagName} = "IPSLCM4_v2" ]        || \
568   [ ${config_UserChoices_TagName} = "IPSL_ESM_V1" ] ; then
569    #
570    IGCM_sys_QsubPost atlas_ORCHIDEE     ;
571    IGCM_sys_QsubPost atlas_LMDZ         ;
572    IGCM_sys_QsubPost atlas_ORCA_LIM     ;
573    IGCM_sys_QsubPost additionnal        ;
574    #
575elif [ ${config_UserChoices_TagName} = "IPSLCM5" ]  || \
576     [ ${config_UserChoices_TagName} = "IPSLCM5A" ] ; then
577    IGCM_sys_QsubPost atlas_ORCHIDEE     ;
578    IGCM_sys_QsubPost atlas_LMDZ         ;
579    IGCM_sys_QsubPost atlas_ORCA_LIM     ;
580    IGCM_sys_QsubPost atlas_PISCES       ;
581    #
582elif [ ${config_UserChoices_TagName} = "LMDZ4OR" ]  || \
583     [ ${config_UserChoices_TagName} = "LMDZOR" ]   || \
584     [ ${config_UserChoices_TagName} = "LMDZ4OR_v2" ] ; then
585    #
586    IGCM_sys_QsubPost atlas_LMDZ         ;
587    IGCM_sys_QsubPost atlas_ORCHIDEE     ;
588    #
589elif [ ${config_UserChoices_TagName} = "LMDZ" ] ; then
590    #
591    IGCM_sys_QsubPost atlas_LMDZ         ;
592    #
593elif [ ${config_UserChoices_TagName} = "OL" ]      || \
594     [ ${config_UserChoices_TagName} = "OL2" ] ; then
595    #
596    IGCM_sys_QsubPost atlas_ORCHIDEE     ;
597    #
598elif [ ${config_UserChoices_TagName} = "ORCA2_LIM" ]       ||
599     [ ${config_UserChoices_TagName} = "ORCA2_LIM2" ] ; then
600    #
601    IGCM_sys_QsubPost atlas_ORCA_LIM     ;
602#    IGCM_sys_QsubPost additionnal        ;
603elif [ ${config_UserChoices_TagName} = "ORCA2_LIM2_PISCES" ]  ; then
604    #
605    IGCM_sys_QsubPost atlas_ORCA_LIM     ;
606    IGCM_sys_QsubPost atlas_PISCES       ;
607#    IGCM_sys_QsubPost additionnal        ;
608elif [ ${config_UserChoices_TagName} = "ORCA2_OFF_PISCES" ]  ; then
609    #
610    IGCM_sys_QsubPost atlas_PISCES       ;
611    #
612fi
613
614# Clean RUN_DIR_PATH (necessary for cesium)
615IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
Note: See TracBrowser for help on using the repository browser.