source: branches/libIGCM_pack/AA_create_se @ 1590

Last change on this file since 1590 was 1588, checked in by aclsce, 12 months ago

Use of specific pack frequency per file
Changed behaviour in case of pb in pack_output :

  • before : if pb, removing initial files expect for PROD simulation.
  • now : if pb, exit of the job (no remonving of inital files) in all cases (DEVT, TEST, PROD).
  • 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: 30.4 KB
Line 
1#-Q- curie ######################
2#-Q- curie ## CURIE   TGCC/CEA ##
3#-Q- curie ######################
4#-Q- curie #MSUB -r SE             # Nom du job
5#-Q- curie #MSUB -o SE.out_%I
6#-Q- curie #MSUB -e SE.out_%I
7#-Q- curie #MSUB -n 1              # Reservation du processus
8#-Q- curie #MSUB -T 36000          # Limite de temps elapsed du job
9#-Q- curie #MSUB -q ::default_node::
10#-Q- curie #MSUB -c ::default_core::
11#-Q- curie #MSUB -Q normal
12#-Q- curie #MSUB -A ::default_project::
13#-Q- curie set +x
14#-Q- irene ######################
15#-Q- irene ## IRENE   TGCC/CEA ##
16#-Q- irene ######################
17#-Q- irene #MSUB -r SE            # Job name
18#-Q- irene #MSUB -o SE.out_%I
19#-Q- irene #MSUB -e SE.out_%I
20#-Q- irene #MSUB -n 1
21#-Q- irene #MSUB -T 36000         # Maximum elapsed time
22#-Q- irene #MSUB -q ::default_node::
23#-Q- irene #MSUB -c ::default_core::
24#-Q- irene #MSUB -Q normal
25#-Q- irene #MSUB -A ::default_post_project::
26#-Q- irene #MSUB -m store,work,scratch
27#-Q- irene set +x
28#-Q- irene-amd ######################
29#-Q- irene-amd ## IRENE   TGCC/CEA ##
30#-Q- irene-amd ######################
31#-Q- irene-amd #MSUB -r SE     # Job name
32#-Q- irene-amd #MSUB -o SE.out_%I
33#-Q- irene-amd #MSUB -e SE.out_%I
34#-Q- irene-amd #MSUB -n 1              # Number of cores
35#-Q- irene-amd #MSUB -T 36000          # Maximum elapsed time
36#-Q- irene-amd #MSUB -q ::default_node::
37#-Q- irene-amd #MSUB -c ::default_core::
38#-Q- irene-amd #MSUB -Q normal
39#-Q- irene-amd #MSUB -A ::default_post_project::
40#-Q- irene-amd #MSUB -m store,work,scratch
41#-Q- irene-amd set +x
42#-Q- jeanzay #!/bin/ksh
43#-Q- jeanzay ######################
44#-Q- jeanzay ## JEANZAY    IDRIS ##
45#-Q- jeanzay ######################
46#-Q- jeanzay #SBATCH --job-name=SE         # Job Name
47#-Q- jeanzay #SBATCH --output=SE.out_%I    # standard output
48#-Q- jeanzay #SBATCH --error=SE.out_%I     # error output
49#-Q- jeanzay #SBATCH -N  1                        # Number of core
50#-Q- jeanzay #SBATCH --partition=prepost          # Post-processing partition
51#-Q- jeanzay #SBATCH --time=10:00:00       # Wall clock limit (seconds)
52#-Q- jeanzay #SBATCH --account ::default_project::@cpu
53#-Q- jeanzay set +x
54#-Q- ada #!/bin/ksh
55#-Q- ada #######################
56#-Q- ada ## ADA         IDRIS ##
57#-Q- ada #######################
58#-Q- ada # @ job_type = mpich
59#-Q- ada # @ requirements = (Feature == "prepost")
60#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
61#-Q- ada # @ wall_clock_limit = 10:00:00
62#-Q- ada # Memory required for ncrcat
63#-Q- ada # @ as_limit = 30Gb
64#-Q- ada # Nom du travail LoadLeveler
65#-Q- ada # @ job_name   = SE
66#-Q- ada # Fichier de sortie standard du travail
67#-Q- ada # @ output     = $(job_name).$(jobid)
68#-Q- ada # Fichier de sortie d'erreur du travail
69#-Q- ada # @ error      =  $(job_name).$(jobid)
70#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
71#-Q- ada # @ notification = error
72#-Q- ada # @ environment  = $DEBUG_debug ; $BigBrother ; $postProcessingStopLevel ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $POST_DIR ; $Script_Post_Output ; $MASTER ; $DateBegin ; $PeriodDateEnd ; $StandAlone ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_MBG ; $RESOL_SRF ; $RESOL_SBG ; wall_clock_limit=$(wall_clock_limit)
73#-Q- ada # @ queue
74#-Q- obelix ######################
75#-Q- obelix ## OBELIX      LSCE ##
76#-Q- obelix ######################
77#-Q- obelix #PBS -N SE
78#-Q- obelix #PBS -m a
79#-Q- obelix #PBS -j oe
80#-Q- obelix #PBS -q medium
81#-Q- obelix #PBS -o SE.$$
82#-Q- obelix #PBS -S /bin/ksh
83#-Q- mesoipsl #!/bin/ksh
84#-Q- mesoipsl ######################
85#-Q- mesoipsl ## MESO ESPRI IPSL  ##
86#-Q- mesoipsl ######################
87#-Q- mesoipsl #SBATCH --job-name=TS         # Job Name
88#-Q- mesoipsl #SBATCH --output=TS.out_%I    # standard output
89#-Q- mesoipsl #SBATCH --error=TS.out_%I     # error output
90#-Q- mesoipsl #SBATCH -N  1                        # Number of core
91#-Q- mesoipsl #SBATCH --time=10:00:00       # Wall clock limit (seconds)
92#-Q- ifort_CICLAD ######################
93#-Q- ifort_CICLAD ##   CICLAD    IPSL ##
94#-Q- ifort_CICLAD ######################
95#-Q- ifort_CICLAD #PBS -N SE
96#-Q- ifort_CICLAD #PBS -m a
97#-Q- ifort_CICLAD #PBS -j oe
98#-Q- ifort_CICLAD ###PBS -q h12       # Queue for 12 hours at ciclad only
99#-Q- ifort_CICLAD #PBS -S /bin/ksh
100#-Q- default #!/bin/ksh
101#-Q- default ##################
102#-Q- default ## DEFAULT HOST ##
103#-Q- default ##################
104
105#**************************************************************
106# Author: Sebastien Denvil
107# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
108# $Revision::                                          $ Revision of last commit
109# $Author::                                            $ Author of last commit
110# $Date::                                              $ Date of last commit
111# IPSL (2006)
112#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
113#
114#**************************************************************
115
116#set -eu
117#set -vx
118
119date
120
121#-Q- ada export OMP_NUM_THREADS=1
122
123#D- Task type DO NOT CHANGE (computing, post-processing or checking)
124TaskType=post-processing
125
126########################################################################
127
128#D- Flag to determine if this job in a standalone mode
129#D- Default : value from AA_job if any
130StandAlone=${StandAlone:=true}
131
132#D- Path to libIGCM
133#D- Default : value from AA_job if any
134libIGCM=${libIGCM:=::modipsl::/libIGCM}
135
136#D- Flag to determine if rebuild process has been performed asynchronously
137#D- Possible value true or false.
138#D- If true raw files has allready been patched by rebuild job
139#D- If false create_ts will patch the raw files
140#D- Default : Value from AA_job if any. Usefull in StandAlone case.
141RebuildFrequency=${RebuildFrequency:=true}
142
143#D- Flag to determine atlas job's output directory
144#D- Default : value from libIGCM_post.ksh if any
145POST_DIR=${POST_DIR:=${PBS_O_WORKDIR:=$(pwd)}}
146
147#D- Increased verbosity (1, 2, 3)
148#D- Default : value from AA_job if any
149Verbosity=${Verbosity:=3}
150
151#D- Low level debug : to bypass lib test checks and stack construction
152#D- Default : value from AA_job if any
153DEBUG_debug=${DEBUG_debug:=false}
154
155#D- TEMPORARY Flag to determine atmospheric resolution
156#D- Default : value from atmospheric driver if any
157RESOL_ATM=${RESOL_ATM:=ALL}
158
159#D- Flag to determine surface resolution
160#D- Default : value from surface driver if any
161RESOL_SRF=ALL
162
163#D- Flag to determine surface resolution
164#D- Default : value from surface driver if any
165RESOL_SBG=ALL
166
167#D- TEMPORARY Flag to determine ocean resolution
168#D- Default : value from ocean driver if any
169RESOL_OCE=${RESOL_OCE:=ORCA2}
170
171#D- TEMPORARY Flag to determine ice resolution
172#D- Default : value from ice driver if any
173RESOL_ICE=${RESOL_OCE:=ORCA2}
174
175#D- TEMPORARY Flag to determine marine biogeochemistry resolution
176#D- Default : value from ice driver if any
177RESOL_MBG=${RESOL_OCE:=ORCA2}
178
179########################################################################
180
181. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
182. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
183. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
184#-------
185. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
186. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
187#-------
188IGCM_sys_MkdirWork ${RUN_DIR_PATH}
189IGCM_sys_Cd ${RUN_DIR_PATH}
190#-------
191( ${DEBUG_debug} ) && IGCM_debug_Check
192( ${DEBUG_debug} ) && IGCM_card_Check
193( ${DEBUG_debug} ) && IGCM_date_Check
194
195########################################################################
196
197#set -vx
198
199# ------------------------------------------------------------------
200# Test if all was right before proceeding further
201# ------------------------------------------------------------------
202IGCM_debug_Verif_Exit
203
204if [ ${StandAlone} = true ] ; then
205    CARD_DIR=${SUBMIT_DIR}
206else
207    CARD_DIR=${RUN_DIR_PATH}
208    IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH}
209    IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card    ${RUN_DIR_PATH}
210    IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP        ${RUN_DIR_PATH}
211    IGCM_sys_Get_Master ${SUBMIT_DIR}/POST        ${RUN_DIR_PATH}
212fi
213
214#==================================
215# First of all
216#
217# Read libIGCM compatibility version in config.card
218# Read UserChoices section
219# Read Ensemble section
220# Read Post section
221# Define all netcdf output directories
222#==================================
223IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
224
225# ------------------------------------------------------------------
226# Activate BigBrother so as to supervise this job
227# ------------------------------------------------------------------
228IGCM_debug_BigBro_Initialize
229
230#==================================
231# Define default value to keep compatibility with previous card: means before changes due to TGCC
232if [ X${PackDefault} = Xtrue ] ; then
233  [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency}
234else
235  config_Post_PackFrequency=NONE
236fi
237
238#==================================
239# If pack is active then PackFrequency overule the config_UserChoices_PeriodLength
240if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then
241  config_UserChoices_PeriodLength=${config_Post_PackFrequency}
242fi
243
244#==================================
245# Read ListOfComponents section:
246IGCM_card_DefineArrayFromSection   ${CARD_DIR}/config.card ListOfComponents
247
248#==================================
249# Read SeasonalFrequency:
250IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card Post SeasonalFrequency
251
252#
253# Determine period for seasonnal average. Default : value from AA_job if any
254#
255DateBegin=${DateBegin:=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )}
256#
257PeriodDateEnd=${PeriodDateEnd:=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )}
258#
259freq=$( echo ${config_Post_SeasonalFrequency} |  sed -e "s/[yY]//" )
260#
261an_fin=$(( $( IGCM_date_ConvertGregorianDateToJulian ${PeriodDateEnd} ) / 1000 ))
262an_deb=$( IGCM_date_YearDigit $(( an_fin - freq + 1 )) )
263an_fin=$( IGCM_date_YearDigit ${an_fin} )
264#
265# For each component selected determine which files need post-processing
266#
267for comp in ${config_ListOfComponents[*]} ; do
268  #
269  IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp}
270  eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
271  #
272  card=${CARD_DIR}/COMP/${compname}.card
273  IGCM_card_DefineArrayFromOption ${card} OutputFiles List
274  #
275  ListFilesName=${compname}_OutputFiles_List
276  eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
277  #
278  if [ X${FileName0} != X${NULL_STR} ] ; then
279    #
280    # INITIALISATION
281    #
282    eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
283    typeset i=2
284    #
285    until [ $i -gt $NbFiles ]; do
286      #
287      eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1
288      #
289      if [ X${flag_post} != XNONE ] ; then
290        #
291        # Check if seasonal is required for this file
292        #
293        IGCM_card_DefineArrayFromSection ${card} ${flag_post}
294        #
295        # Seasonal case : If option Seasonal is not found (old cards) put SEASONAL ON by default
296        #
297        # variable option allready typeset above
298        for option in $( eval echo \${${compname}_${flag_post}[*]} ) ; do
299          if [ ${option} = Seasonal ] ; then
300            FoundSeasonal=true
301            IGCM_card_DefineVariableFromOption ${card} ${flag_post} Seasonal
302          fi
303        done
304        #
305        if [ ! X${FoundSeasonal} = Xtrue ] ; then
306            eval ${compname}_${flag_post}_Seasonal=ON
307        fi
308        #
309        if [ ! X$( eval echo \${${compname}_${flag_post}_Seasonal} ) = XON ] ; then
310            (( i_ = i+1 ))
311            eval Testvar_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
312            eval Testvar=${Testvar_}
313            if [[ ${Testvar} =~ [0-9][DMY]$ ]] ; then
314                (( i = i+4 ))
315            else
316          (( i=i+3 ))
317            fi
318          continue
319        fi
320        #
321        # CREATE LIST
322        #
323        FILE=$( echo ${flag_post} | awk "-FPost_" '{print $2}' )
324        #
325        DIRECTORY=${R_SAVE}/${comp}/Analyse/SE
326        #
327        TestedFile=${config_UserChoices_JobName}_SE_${an_deb}_${an_fin}_${FILE}.nc
328        #
329        IGCM_sys_TestFileArchive ${DIRECTORY}/${TestedFile}
330        if [ ! $? = 0 ] ; then
331          eval set +A LISTE_FILE_${comp} \$\{LISTE_FILE_${comp}[*]} ${FILE}
332          if [ ! ${RebuildFrequency} = true ] ; then
333            IGCM_card_DefineArrayFromOption ${card} Post_${FILE} Patches
334            eval set +A LISTE_PATCHES_${FILE} \$\{${compname}_Post_${FILE}_Patches[*]}
335            if [ X$( eval echo \${LISTE_PATCHES_${FILE}[0]} ) !=  X${NULL_STR} ]; then
336              for Patch in $( eval echo \${LISTE_PATCHES_${FILE}[*]} ); do
337                if [ Xload${Patch} != X ] ; then
338                  . ${libIGCM}/libIGCM_post/IGCM_${Patch}.ksh
339                  eval load${Patch}=loaded
340                fi
341              done
342            fi
343          fi
344        fi
345      fi
346      (( i_ = i+1 ))
347      eval Testvar_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
348      eval Testvar=${Testvar_}
349      if [[ ${Testvar} =~ [0-9][DMY]$ ]] ; then
350          (( i = i+4 ))
351      else
352      (( i=i+3 ))
353      fi
354    done # until [ $i -eq $NbFiles ]
355  fi
356done         # for comp
357
358for comp in ${config_ListOfComponents[*]} ; do
359  #
360  eval R_OUT_${comp}=${R_SAVE}/${comp}
361  #
362  i=0
363  for file in $( eval echo \${LISTE_FILE_${comp}[*]} ); do
364    #
365    # Determine in which output can we find file
366    # IE : Output/MO or Output/DA or ...
367    #
368    FlagDir=$( echo ${file} | awk -F "_" '{print $1}' )
369    case ${FlagDir} in
370      1Y)    FreqDir=YE  ;;
371      1M)    FreqDir=MO  ;;
372      5D|1D) FreqDir=DA  ;;
373      HF)    FreqDir=HF  ;;
374      3H)    FreqDir=HF  ;;
375      INS)   FreqDir=INS ;;
376    esac
377    #
378    RESULT_SE=${config_UserChoices_JobName}_SE_${an_deb}_${an_fin}_${file}.nc
379    # Do not redoo an existing SE
380    IGCM_sys_TestFileArchive ${R_SAVE}/${comp}/Analyse/SE/${RESULT_SE}
381    if [ $? = 0 ] ; then
382      continue
383    fi
384    #
385    eval file_path=\${R_OUT_${comp}}/Output/${FreqDir}/
386    #
387    case ${config_UserChoices_PeriodLength} in
388      # For Yearly simulation :
389      *Y|*y)
390        PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[yY]//' )
391        (( an = an_deb ))
392        # Initialize array
393        unset liste_file_se
394        unset liste_file_se_tmp
395        while [ ${an} -le ${an_fin} ] ; do
396          #
397          an4=$(printf "%04i\n" ${an} )
398          #
399          diy=$( IGCM_date_DaysInCurrentPeriod ${an4}0101 ${config_UserChoices_PeriodLength} )
400          afin=$( IGCM_date_AddDaysToGregorianDate ${an4}0101 $(( diy - 1 )) )
401          #
402          date=${an4}0101_${afin}
403          #
404          liste_file_se[${#liste_file_se[*]}]=${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
405          liste_file_se_tmp[${#liste_file_se_tmp[*]}]=${config_UserChoices_JobName}_${date}_${file}.nc
406          (( an = an + ${PeriodLengthInYears} ))
407        done
408        #
409        IGCM_sys_Get /l liste_file_se[*] ${RUN_DIR_PATH}
410        IGCM_debug_Verif_Exit
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          ncdump -h ${file_common_var} | grep -E 'float|double' | cut -f 1 -d '(' | cut -f 2 -d ' ' >> 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
432        # detect time counter : time or time_counter ie unlimited variable
433        var_unlim=$(ncdump -h ${liste_file_se_tmp[0]}|grep UNLIMITED|awk '{print $1}')
434
435        for mois in  01 02 03 04 05 06 07 08 09 10 11 12 ; do
436          #
437          (( nb = ${mois} - 1 ))
438          #
439          OUT_SE[${nb}]=${config_UserChoices_JobName}_SE${mois}_${an_deb}_${an_fin}_${file}.nc
440          IGCM_sys_ncra -O -v ${list_var_final_ncra} -d ${var_unlim},${nb},,12 ${liste_file_se_tmp[*]} ${OUT_SE[${nb}]}
441        done
442        IGCM_sys_Rm ${liste_file_se_tmp[*]}
443        ;;
444      # For Monthly simulation :
445      1M|1m)
446        for mois in 01 02 03 04 05 06 07 08 09 10 11 12 ; do
447          #
448          (( nb = ${mois} - 1 ))
449          #
450          OUT_SE[${nb}]=${config_UserChoices_JobName}_SE${mois}_${an_deb}_${an_fin}_${file}.nc
451          #
452          (( an = an_deb ))
453          # Initialize array
454          unset liste_file_se
455          unset liste_file_se_tmp
456          while [ ${an} -le ${an_fin} ] ; do
457            moisL=$( IGCM_date_DaysInMonth ${an} ${mois} )
458            #
459            an4=$(printf "%04i\n" ${an} )
460            #
461            date=${an4}${mois}01_${an4}${mois}${moisL}
462            #
463            liste_file_se[${#liste_file_se[*]}]=${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
464            liste_file_se_tmp[${#liste_file_se_tmp[*]}]=${config_UserChoices_JobName}_${date}_${file}.nc
465
466            (( an = an + 1 ))
467          done
468          #
469          IGCM_sys_Get /l liste_file_se[*] ${RUN_DIR_PATH}
470          IGCM_debug_Verif_Exit
471
472          # Apply IGCM_Patch if needed
473          if [ ! ${RebuildFrequency} = true ] ; then
474            if [ X$( eval echo \${LISTE_PATCHES_${file}[0]} ) !=  X${NULL_STR} ]; then
475              for file_t in $( eval echo ${liste_file_se_tmp[*]} ); do
476                for Patch in $( eval echo \${LISTE_PATCHES_${file}[*]} ); do
477                  IGCM_${Patch} ${file_t}
478                done
479              done
480            fi
481          fi
482
483          # Search of common list of variables to be treated
484          nbfile=0
485          for file_common_var in ${liste_file_se_tmp[*]} ; do
486            ncdump -h ${file_common_var} | grep -E 'float|double' | cut -f 1 -d '(' | cut -f 2 -d ' ' >> tmpfile_ncra
487            (( nbfile = nbfile + 1 ))
488          done
489            list_var_final_ncra=`cat tmpfile_ncra | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 == nbfile) {print $2}}' | paste -s -d ','`
490          IGCM_sys_Rm tmpfile_ncra
491
492          IGCM_sys_ncra -O -v ${list_var_final_ncra} ${liste_file_se_tmp[*]} ${OUT_SE[${nb}]}
493
494          IGCM_sys_Rm ${liste_file_se_tmp[*]}
495        done
496        ;;
497      *D|*d)
498        for mois in 01 02 03 04 05 06 07 08 09 10 11 12 ; do
499          #
500          (( nb = ${mois} - 1 ))
501          #
502          OUT_SE[${nb}]=${config_UserChoices_JobName}_SE${mois}_${an_deb}_${an_fin}_${file}.nc
503          #
504          (( an = an_deb ))
505          # Initialize array
506          unset liste_file_se
507          unset liste_file_se_tmp
508          while [ ${an} -le ${an_fin} ] ; do
509            moisL=$( IGCM_date_DaysInMonth ${an} ${mois} )
510            #
511            an4=$(printf "%04i\n" ${an} )
512              #
513            length_d=$(( ${config_UserChoices_PeriodLength} - 1 ))
514            # for one day
515            if [ ${length_d} -eq 1 ] ; then
516              (( length_d = 0 ))
517            fi
518            (( day  = 1 ))
519            while [ ${day} -le ${moisL} ] ; do
520              day2=$(printf "%02i\n" ${day} )
521              day_beg=${an4}${mois}${day2}
522              day_end=$( IGCM_date_AddDaysToGregorianDate ${day_beg} ${length_d} )
523              date=${an4}${mois}${day_beg}_${an4}${mois}${day_end}
524              #
525              liste_file_se[${#liste_file_se[*]}]=${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
526              liste_file_se_tmp[${#liste_file_se_tmp[*]}]=${config_UserChoices_JobName}_${date}_${file}.nc
527              (( day = day + 1 ))
528            done
529            (( an = an + 1 ))
530          done
531          #
532          IGCM_sys_Get /l liste_file_se[*] ${RUN_DIR_PATH}
533          IGCM_debug_Verif_Exit
534
535          # Apply IGCM_Patch if needed
536          if [ ! ${RebuildFrequency} = true ] ; then
537            if [ X$( eval echo \${LISTE_PATCHES_${file}[0]} ) !=  X${NULL_STR} ]; then
538              for file_t in $( eval echo ${liste_file_se_tmp[*]} ); do
539                for Patch in $( eval echo \${LISTE_PATCHES_${file}[*]} ); do
540                  IGCM_${Patch} ${file_t}
541                done
542              done
543            fi
544          fi
545
546          # Search of common list of variables to be treated
547          nbfile=0
548          for file_common_var in ${liste_file_se_tmp[*]} ; do
549            ncdump -h ${file_common_var} | grep -E 'float|double' | cut -f 1 -d '(' | cut -f 2 -d ' ' >> tmpfile_ncra
550            (( nbfile = nbfile + 1 ))
551          done
552            list_var_final_ncra=`cat tmpfile_ncra | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 == nbfile) {print $2}}' | paste -s -d ','`
553          IGCM_sys_Rm tmpfile_ncra
554
555          IGCM_sys_ncra -O -v ${list_var_final_ncra} ${liste_file_se_tmp[*]} ${OUT_SE[${nb}]}
556          IGCM_sys_Rm ${liste_file_se_tmp[*]}
557        done
558        ;;
559      esac
560      #
561
562      # Search of common list of variables to be treated
563      nbfile=0
564      for file_common_var in ${OUT_SE[*]} ; do
565        ncdump -h ${file_common_var} | grep -E 'float|double' | cut -f 1 -d '(' | cut -f 2 -d ' ' >> tmpfile_ncrcat
566        (( nbfile = nbfile + 1 ))
567      done
568      list_var_final_ncrcat=`cat tmpfile_ncrcat | sort | uniq -c | grep -v ^time_ | awk -v nbfile=$nbfile '{if ($1 == nbfile) {print $2}}' | paste -s -d ','`
569      IGCM_sys_Rm tmpfile_ncrcat
570
571    IGCM_sys_ncrcat -O -v ${list_var_final_ncrcat} ${OUT_SE[*]} ${RESULT_SE}
572    #
573    IGCM_sys_Rm ${OUT_SE[*]}
574    #
575    # detect time counter : time or time_counter ie unlimited variable
576    var_unlim=$( ncdump -h ${RESULT_SE} | grep UNLIMITED |  cut -d ' ' -f 1 | sed -e 's/^[[:space:]]*//' )
577
578    # Put correct climatological axis following calendar
579    case ${config_UserChoices_CalendarType} in
580      360d|360_day)
581      # 360 days
582        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\"'"
583        ;;
584      noleap|365_day)
585      # 365 days
586        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=\"365_day\" ; ${var_unlim}@bounds=\"${var_unlim}_bnds\"'"
587        ;;
588      all_leap|366_day)
589      # 366 days
590        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=\"366_day\" ; ${var_unlim}@bounds=\"${var_unlim}_bnds\"'"
591        ;;
592      leap|gregorian|standard)
593      # 365.2425 days
594        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\"'"
595        ;;
596    esac
597    eval IGCM_sys_ncap2 -Oh -s $ncap2cmd ${RESULT_SE} tmp.nc
598    IGCM_sys_Rm ${RESULT_SE}
599    IGCM_sys_Mv tmp.nc ${RESULT_SE}
600    #
601    eval IGCM_sys_Put_Out ${RESULT_SE} \${R_OUT_${comp}}/Analyse/SE/${RESULT_SE}
602    [ -f ${RESULT_SE} ] && IGCM_sys_Rm ${RESULT_SE}
603    #
604  done
605done
606
607# DODS copy
608if [ X${config_Post_DodsCopy} = XTRUE ]  ; then
609  for comp in ${config_ListOfComponents[*]} ; do
610    IGCM_sys_TestDirArchive ${R_SAVE}/${comp}/Analyse/SE
611    [ $? = 0 ] && IGCM_sys_Put_Dods ${comp}/Analyse/SE
612  done
613fi
614
615# Temporal coverage id for atlas
616YEARS=${an_deb}_${an_fin}
617DIR_OUT=SE
618
619export DEBUG_debug; export BigBrother ; export libIGCM; export SUBMIT_DIR; export POST_DIR; export Script_Output ;
620export StandAlone ; export RESOL_ATM; export RESOL_OCE ; export RESOL_ICE ; export RESOL_MBG ; export RESOL_SRF ;
621export RESOL_SBG ; export YEARS; export DIR_OUT
622listVarEnv="DEBUG_debug,BigBrother,libIGCM,SUBMIT_DIR,POST_DIR,Script_Post_Output,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG,YEARS,DIR_OUT"
623export listVarEnv;
624
625#D-
626# --------------------------------------------------------------------
627#D- Test if all was right before ATLAS
628# --------------------------------------------------------------------
629IGCM_debug_Verif_Exit
630
631if [ ${config_UserChoices_TagName} = "IPSLCM4_v1_OASIS3" ] || \
632   [ ${config_UserChoices_TagName} = "IPSLCM4_v2" ]        || \
633   [ ${config_UserChoices_TagName} = "IPSL_ESM_V1" ] ; then
634  # ATLAS
635  if [ X${config_Post_AtlasIPSL} = XTRUE ]  ; then
636    export Script_Post_Output=atlas_ORCHIDEE.${PeriodDateEnd} ;
637    IGCM_sys_QsubPost atlas_ORCHIDEE                          ;
638    export Script_Post_Output=atlas_LMDZ.${PeriodDateEnd}     ;
639    IGCM_sys_QsubPost atlas_LMDZ                              ;
640    export Script_Post_Output=atlas_ORCA_LIM.${PeriodDateEnd} ;
641    IGCM_sys_QsubPost atlas_ORCA_LIM                          ;
642    export Script_Post_Output=additionnal.${PeriodDateEnd}    ;
643    IGCM_sys_QsubPost additionnal                             ;
644  fi
645  #
646elif [ ${config_UserChoices_TagName} = "IPSLCM5" ]         || \
647     [ ${config_UserChoices_TagName} = "IPSLCM5A" ]        || \
648     [ ${config_UserChoices_TagName} = "IPSLCM5B" ]        || \
649     [ ${config_UserChoices_TagName} = "IPSLCM5A-MR" ]     || \
650     [ ${config_UserChoices_TagName} = "IPSLCM5A2" ]       || \
651     [ ${config_UserChoices_TagName} = "IPSLCM6" ] ; then
652  # METRICS
653  if [ X${config_Post_MetricsPCMDI} = XTRUE ]  ; then
654    export Script_Post_Output=metrics_LMDZ.${PeriodDateEnd}   ;
655    IGCM_sys_QsubPost metrics_LMDZ                            ;
656    export Script_Post_Output=metrics_NEMO.${PeriodDateEnd}   ;
657    IGCM_sys_QsubPost metrics_NEMO                            ;
658  fi
659  # ATLAS
660  if [ X${config_Post_AtlasIPSL} = XTRUE ]  ; then
661    export Script_Post_Output=atlas_ORCHIDEE.${PeriodDateEnd} ;
662    IGCM_sys_QsubPost atlas_ORCHIDEE                          ;
663    export Script_Post_Output=atlas_LMDZ.${PeriodDateEnd}     ;
664    IGCM_sys_QsubPost atlas_LMDZ                              ;
665    export Script_Post_Output=atlas_ORCA_LIM.${PeriodDateEnd} ;
666    IGCM_sys_QsubPost atlas_ORCA_LIM                          ;
667    export Script_Post_Output=atlas_PISCES.${PeriodDateEnd}   ;
668    IGCM_sys_QsubPost atlas_PISCES                            ;
669  fi
670elif [ ${config_UserChoices_TagName} = "LMDZ4OR" ]         || \
671     [ ${config_UserChoices_TagName} = "LMDZOR" ]          || \
672     [ ${config_UserChoices_TagName} = "LMDZ4OR_v2" ] ; then
673  # METRICS
674  if [ X${config_Post_MetricsPCMDI} = XTRUE ]  ; then
675    export Script_Post_Output=metrics_LMDZ.${PeriodDateEnd}   ;
676    IGCM_sys_QsubPost metrics_LMDZ                            ;
677  fi
678  # ATLAS
679  if [ X${config_Post_AtlasIPSL} = XTRUE ]  ; then
680    export Script_Post_Output=atlas_LMDZ.${PeriodDateEnd}     ;
681    IGCM_sys_QsubPost atlas_LMDZ                              ;
682    export Script_Post_Output=atlas_ORCHIDEE.${PeriodDateEnd} ;
683    IGCM_sys_QsubPost atlas_ORCHIDEE                          ;
684  fi
685elif [ ${config_UserChoices_TagName} = "LMDZ" ] ; then
686  # METRICS
687  if [ X${config_Post_MetricsPCMDI} = XTRUE ]  ; then
688    export Script_Post_Output=metrics_LMDZ.${PeriodDateEnd}   ;
689    IGCM_sys_QsubPost metrics_LMDZ                            ;
690  fi
691  # ATLAS
692  if [ X${config_Post_AtlasIPSL} = XTRUE ]  ; then
693    export Script_Post_Output=atlas_LMDZ.${PeriodDateEnd}     ;
694    IGCM_sys_QsubPost atlas_LMDZ                              ;
695  fi
696elif [ ${config_UserChoices_TagName} = "OL" ]              || \
697     [ ${config_UserChoices_TagName} = "OL2" ] ; then
698  # METRICS
699  # ATLAS
700  if [ X${config_Post_AtlasIPSL} = XTRUE ]  ; then
701    export Script_Post_Output=atlas_ORCHIDEE.${PeriodDateEnd} ;
702    IGCM_sys_QsubPost atlas_ORCHIDEE                          ;
703  fi
704elif [ ${config_UserChoices_TagName} = "ORCA2_LIM" ]       || \
705     [ ${config_UserChoices_TagName} = "ORCA2_LIM2" ]      || \
706     [ ${config_UserChoices_TagName} = "ORCA2_LIM3" ]      || \
707     [ ${config_UserChoices_TagName} = "ORCA1_LIM2" ]      || \
708     [ ${config_UserChoices_TagName} = "ORCA1_LIM3" ] ; then
709  # METRICS
710  if [ X${config_Post_MetricsPCMDI} = XTRUE ]  ; then
711    export Script_Post_Output=metrics_NEMO.${PeriodDateEnd}   ;
712    IGCM_sys_QsubPost metrics_NEMO                            ;
713  fi
714  # ATLAS
715  if [ X${config_Post_AtlasIPSL} = XTRUE ]  ; then
716    export Script_Post_Output=atlas_ORCA_LIM.${PeriodDateEnd} ;
717    IGCM_sys_QsubPost atlas_ORCA_LIM                          ;
718  fi
719elif [ ${config_UserChoices_TagName} = "ORCA2_LIM2_PISCES" ] || \
720     [ ${config_UserChoices_TagName} = "ORCA2_LIM3_PISCES" ] || \
721     [ ${config_UserChoices_TagName} = "ORCA1_LIM2_PISCES" ] || \
722     [ ${config_UserChoices_TagName} = "ORCA1_LIM3_PISCES" ] ; then
723  # METRICS
724  if [ X${config_Post_MetricsPCMDI} = XTRUE ]  ; then
725    export Script_Post_Output=metrics_NEMO.${PeriodDateEnd}   ;
726    IGCM_sys_QsubPost metrics_NEMO                            ;
727  fi
728  # ATLAS
729  if [ X${config_Post_AtlasIPSL} = XTRUE ]  ; then
730    export Script_Post_Output=atlas_ORCA_LIM.${PeriodDateEnd} ;
731    IGCM_sys_QsubPost atlas_ORCA_LIM                          ;
732    export Script_Post_Output=atlas_PISCES.${PeriodDateEnd}   ;
733    IGCM_sys_QsubPost atlas_PISCES                            ;
734  fi
735elif [ ${config_UserChoices_TagName} = "ORCA2_OFF_PISCES" ] ; then
736  # METRICS
737  # ATLAS
738  if [ X${config_Post_AtlasIPSL} = XTRUE ]  ; then
739  export Script_Post_Output=atlas_PISCES.${PeriodDateEnd}   ;
740  IGCM_sys_QsubPost atlas_PISCES                            ;
741  fi
742fi
743
744# Clean RUN_DIR_PATH (necessary for cesium and titane only)
745IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
746
747# ------------------------------------------------------------------
748# Finalize BigBrother to inform that the jobs end
749# ------------------------------------------------------------------
750IGCM_debug_BigBro_Finalize
Note: See TracBrowser for help on using the repository browser.