source: trunk/libIGCM/AA_create_se @ 257

Last change on this file since 257 was 257, checked in by sdipsl, 14 years ago
  • Add mercure-new : libIGCM_sys_mercure.ksh
  • SX9 use mercure-new for post-processing
  • Few feature missing on mercure-new dmget not yet install for example
  • Properly reset all svn:keywords feature
  • Bugfix in libIGCM_post.ksh when RebuildFromArchive? was false
  • Bugfix in IGCM_Patch_20090317_histcomFillvalue.ksh when renaming _Fillvalue we now just add missing_value to be retro-compatible
  • Some more comments
  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

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

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

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

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

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

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

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