source: trunk/libIGCM/AA_create_se @ 370

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

Add AA_create_multi_se script to build SE_nnnY based on previous SE.
Use optionnal MultiSeasonalFrequency?[=50 by default] parameter in config.card Post Section.
Use climatological time axis for SE and SE_nnnY files.
Add DIR_OUT to allow atlas to work with SE_nnnY.
Add POST_DIR default value for interactive session.

  • 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.9 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 #!/bin/ksh
63#-Q- sx9mercure #########################
64#-Q- sx9mercure ## CESIUM FOR SX9  CEA ##
65#-Q- sx9mercure #########################
66#-Q- sx9mercure #MSUB -r SE             # Nom du job               
67#-Q- sx9mercure #MSUB -N 1              # Reservation du noeud
68#-Q- sx9mercure #MSUB -n 1              # Reservation du processus
69#-Q- sx9mercure #MSUB -T 86400          # Limite de temps elapsed du job
70#-Q- sx9mercure #MSUB -E "-j o"
71#-Q- sx9mercure #MSUB -E "-S /bin/ksh"
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:=$(pwd)}}
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          # detect time counter : time or time_counter ie unlimited variable
400          var_unlim=$(ncdump -h ${liste_file_se_tmp[1]}|grep UNLIMITED| cut -d ' ' -f 1)
401
402          for mois in  01 02 03 04 05 06 07 08 09 10 11 12 ; do
403          #
404              (( nb = ${mois} - 1 ))
405          #
406              OUT_SE[${nb}]=${config_UserChoices_JobName}_SE${mois}_${an_deb}_${an_fin}_${file}.nc
407              IGCM_sys_ncra -O -v ${list_var_final_ncra} -d ${var_unlim},${nb},,12 ${liste_file_se_tmp[*]} ${OUT_SE[${nb}]}
408          done
409          IGCM_sys_Rm ${liste_file_se_tmp[*]}
410          eval ExitFlag=false
411          IGCM_debug_Verif_Exit_Post
412          ;;
413        # For Monthly simulation :
414        1M|1m)
415          for mois in  01 02 03 04 05 06 07 08 09 10 11 12 ; do
416              #
417              (( nb = ${mois} - 1 ))
418              #
419              OUT_SE[${nb}]=${config_UserChoices_JobName}_SE${mois}_${an_deb}_${an_fin}_${file}.nc
420              #
421              (( an = an_deb ))
422              # Initialize array
423              #set -A liste_file_se
424              #set -A liste_file_se_tmp
425              unset liste_file_se
426              unset liste_file_se_tmp
427              while [ ${an} -le ${an_fin} ] ; do
428                  moisL=$( IGCM_date_DaysInMonth ${an} ${mois} )
429                  #
430                  an4=$(printf "%04i\n" ${an} )
431                  #
432                  date=${an4}${mois}01_${an4}${mois}${moisL}
433                  #set +A liste_file_se ${liste_file_se[*]} ${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
434                  #set +A liste_file_se_tmp ${liste_file_se_tmp[*]} ${config_UserChoices_JobName}_${date}_${file}.nc
435                  liste_file_se[${#liste_file_se[*]}]=${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
436                  liste_file_se_tmp[${#liste_file_se_tmp[*]}]=${config_UserChoices_JobName}_${date}_${file}.nc
437
438                  (( an = an + 1 ))
439              done
440              #
441              IGCM_sys_Get /l liste_file_se[*] ${RUN_DIR_PATH}
442              eval ExitFlag=false
443              IGCM_debug_Verif_Exit_Post
444             
445              # Apply IGCM_Patch if needed
446              if [ ! ${RebuildFrequency} = true ] ; then
447                  if [ X$( eval echo \${LISTE_PATCHES_${file}[0]} ) !=  X${NULL_STR} ]; then
448                      for file_t in $( eval echo ${liste_file_se_tmp[*]} ); do
449                          for Patch in $( eval echo \${LISTE_PATCHES_${file}[*]} ); do
450                              IGCM_${Patch} ${file_t}
451                          done
452                      done
453                  fi
454              fi
455             
456              # Search of common list of variables to be treated
457              nbfile=0
458              for file_common_var in ${liste_file_se_tmp[*]} ; do
459                  ncks -m ${file_common_var} | grep '# dim. =' | cut -d ':' -f 1 >> tmpfile_ncra
460                  (( nbfile = nbfile + 1 ))
461              done
462              list_var_final_ncra=`cat tmpfile_ncra | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 == nbfile) {print $2}}' | paste -s -d ','`
463              IGCM_sys_Rm tmpfile_ncra
464
465              IGCM_sys_ncra -O -v ${list_var_final_ncra} ${liste_file_se_tmp[*]} ${OUT_SE[${nb}]}
466
467              IGCM_sys_Rm ${liste_file_se_tmp[*]}
468              eval ExitFlag=false
469              IGCM_debug_Verif_Exit_Post
470          done
471          ;;
472        *D|*d)
473          for mois in  01 02 03 04 05 06 07 08 09 10 11 12 ; do
474              #
475              (( nb = ${mois} - 1 ))
476              #
477              OUT_SE[${nb}]=${config_UserChoices_JobName}_SE${mois}_${an_deb}_${an_fin}_${file}.nc
478              #
479              (( an = an_deb ))
480              # Initialize array
481              #set -A liste_file_se
482              #set -A liste_file_se_tmp
483              unset liste_file_se
484              unset liste_file_se_tmp
485              while [ ${an} -le ${an_fin} ] ; do
486                  moisL=$( IGCM_date_DaysInMonth ${an} ${mois} )
487                  #
488                  an4=$(printf "%04i\n" ${an} )
489                  #
490                  length_d=$(( ${config_UserChoices_PeriodLength} - 1 ))
491                  # for one day
492                  if [ ${length_d} -eq 1 ] ; then
493                      (( length_d = 0 ))
494                  fi
495                  (( day  = 1 ))
496                  while [ ${day} -le ${moisL} ] ; do
497                      day2=$(printf "%02i\n" ${day} )
498                      day_beg=${an4}${mois}${day2}
499                      day_end=$( IGCM_date_AddDaysToGregorianDate ${day_beg} ${length_d} )
500                      date=${an4}${mois}${day_beg}_${an4}${mois}${day_end}
501                      #set +A liste_file_se ${liste_file_se[*]} ${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
502                      #set +A liste_file_se_tmp ${liste_file_se_tmp[*]} ${config_UserChoices_JobName}_${date}_${file}.nc
503                      liste_file_se[${#liste_file_se[*]}]=${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
504                      liste_file_se_tmp[${#liste_file_se_tmp[*]}]=${config_UserChoices_JobName}_${date}_${file}.nc
505                      (( day = day + 1 ))
506                  done
507                  (( an = an + 1 ))
508              done
509              #
510              IGCM_sys_Get /l liste_file_se[*] ${RUN_DIR_PATH}
511              eval ExitFlag=false
512              IGCM_debug_Verif_Exit_Post
513             
514              # Apply IGCM_Patch if needed
515              if [ ! ${RebuildFrequency} = true ] ; then
516                  if [ X$( eval echo \${LISTE_PATCHES_${file}[0]} ) !=  X${NULL_STR} ]; then
517                      for file_t in $( eval echo ${liste_file_se_tmp[*]} ); do
518                          for Patch in $( eval echo \${LISTE_PATCHES_${file}[*]} ); do
519                              IGCM_${Patch} ${file_t}
520                          done
521                      done
522                  fi
523              fi
524
525              # Search of common list of variables to be treated
526              nbfile=0
527              for file_common_var in ${liste_file_se_tmp[*]} ; do
528                  ncks -m ${file_common_var} | grep '# dim. =' | cut -d ':' -f 1 >> tmpfile_ncra
529                  (( nbfile = nbfile + 1 ))
530              done
531              list_var_final_ncra=`cat tmpfile_ncra | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 == nbfile) {print $2}}' | paste -s -d ','`
532              IGCM_sys_Rm tmpfile_ncra
533
534              IGCM_sys_ncra -O -v ${list_var_final_ncra} ${liste_file_se_tmp[*]} ${OUT_SE[${nb}]}
535              IGCM_sys_Rm ${liste_file_se_tmp[*]}
536              eval ExitFlag=false
537              IGCM_debug_Verif_Exit_Post
538          done
539          ;;
540        esac
541        #
542
543        # Search of common list of variables to be treated
544        nbfile=0
545        for file_common_var in ${OUT_SE[*]} ; do
546           ncks -m ${file_common_var} | grep '# dim. =' | cut -d ':' -f 1 >> tmpfile_ncrcat
547           (( nbfile = nbfile + 1 ))
548        done
549        list_var_final_ncrcat=`cat tmpfile_ncrcat | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 == nbfile) {print $2}}' | paste -s -d ','`
550        IGCM_sys_Rm tmpfile_ncrcat
551
552        IGCM_sys_ncrcat -O -v ${list_var_final_ncrcat} ${OUT_SE[*]} ${RESULT_SE}
553        #
554        IGCM_sys_Rm ${OUT_SE[*]}
555        #
556        # detect time counter : time or time_counter ie unlimited variable
557        var_unlim=$(ncdump -h ${RESULT_SE}|grep UNLIMITED| cut -d ' ' -f 1)
558
559        # add modulo attribute on time axis
560        ${ncatted} -a modulo,${var_unlim},c,c," " ${RESULT_SE}
561        #
562        eval IGCM_sys_Put_Out ${RESULT_SE} \${R_OUT_${comp}}/Analyse/SE/${RESULT_SE}
563        IGCM_sys_Rm ${RESULT_SE}
564        #
565        eval ExitFlag=false
566        IGCM_debug_Verif_Exit_Post
567    done
568done
569
570# DODS copy
571for comp in ${config_ListOfComponents[*]} ; do
572    IGCM_sys_TestDirArchive ${R_SAVE}/${comp}/Analyse/SE
573    [ $? = 0 ] && IGCM_sys_Put_Dods ${comp}/Analyse/SE
574done
575
576YEARS=${an_deb}_${an_fin}
577DIR_OUT=SE
578
579export POST_DIR; export SUBMIT_DIR; export libIGCM; export R_INIT; export R_BC; export StandAlone
580export RESOL_ATM; export RESOL_OCE ; export RESOL_ICE ; export RESOL_MBG ; export RESOL_SRF ; export RESOL_SBG
581export R_SAVE; export config_UserChoices_JobName; export config_UserChoices_TagName; export YEARS; export DIR_OUT
582listVarEnv="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,DIR_OUT"
583export listVarEnv;
584
585#D-
586# --------------------------------------------------------------------
587#D- Test if all was right before ATLAS
588# --------------------------------------------------------------------
589IGCM_debug_Verif_Exit_Post
590
591if [ ${config_UserChoices_TagName} = "IPSLCM4_v1_OASIS3" ] || \
592   [ ${config_UserChoices_TagName} = "IPSLCM4_v2" ]        || \
593   [ ${config_UserChoices_TagName} = "IPSL_ESM_V1" ] ; then
594    #
595    IGCM_sys_QsubPost atlas_ORCHIDEE     ;
596    IGCM_sys_QsubPost atlas_LMDZ         ;
597    IGCM_sys_QsubPost atlas_ORCA_LIM     ;
598    IGCM_sys_QsubPost additionnal        ;
599    #
600elif [ ${config_UserChoices_TagName} = "IPSLCM5" ]  || \
601     [ ${config_UserChoices_TagName} = "IPSLCM5A" ] || \
602     [ ${config_UserChoices_TagName} = "IPSLCM5A-MR" ] ; then
603    IGCM_sys_QsubPost atlas_ORCHIDEE     ;
604    IGCM_sys_QsubPost atlas_LMDZ         ;
605    IGCM_sys_QsubPost atlas_ORCA_LIM     ;
606    IGCM_sys_QsubPost atlas_PISCES       ;
607    #
608elif [ ${config_UserChoices_TagName} = "LMDZ4OR" ]  || \
609     [ ${config_UserChoices_TagName} = "LMDZOR" ]   || \
610     [ ${config_UserChoices_TagName} = "LMDZ4OR_v2" ] ; then
611    #
612    IGCM_sys_QsubPost atlas_LMDZ         ;
613    IGCM_sys_QsubPost atlas_ORCHIDEE     ;
614    #
615elif [ ${config_UserChoices_TagName} = "LMDZ" ] ; then
616    #
617    IGCM_sys_QsubPost atlas_LMDZ         ;
618    #
619elif [ ${config_UserChoices_TagName} = "OL" ]      || \
620     [ ${config_UserChoices_TagName} = "OL2" ] ; then
621    #
622    IGCM_sys_QsubPost atlas_ORCHIDEE     ;
623    #
624elif [ ${config_UserChoices_TagName} = "ORCA2_LIM" ]       ||
625     [ ${config_UserChoices_TagName} = "ORCA2_LIM2" ] ; then
626    #
627    IGCM_sys_QsubPost atlas_ORCA_LIM     ;
628#    IGCM_sys_QsubPost additionnal        ;
629elif [ ${config_UserChoices_TagName} = "ORCA2_LIM2_PISCES" ]  ; then
630    #
631    IGCM_sys_QsubPost atlas_ORCA_LIM     ;
632    IGCM_sys_QsubPost atlas_PISCES       ;
633#    IGCM_sys_QsubPost additionnal        ;
634elif [ ${config_UserChoices_TagName} = "ORCA2_OFF_PISCES" ]  ; then
635    #
636    IGCM_sys_QsubPost atlas_PISCES       ;
637    #
638fi
639
640# Clean RUN_DIR_PATH (necessary for cesium)
641IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
Note: See TracBrowser for help on using the repository browser.