source: trunk/libIGCM/AA_create_se @ 315

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

Add mail when job aborts in mercure front-end header. Correct SendMail? function on mercurex9.

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