source: trunk/libIGCM/AA_create_se @ 314

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

Add cesium header to facilitate post-processing on cesium directly.

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