source: trunk/libIGCM/AA_create_se @ 617

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