source: trunk/libIGCM/AA_create_se @ 380

Last change on this file since 380 was 379, checked in by brocksce, 14 years ago

Correction on calendar can now be applied for any var_unlim

  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

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