source: trunk/libIGCM/AA_create_se @ 1517

Last change on this file since 1517 was 1494, checked in by cetlod, 5 years ago

Use prepost partition to manage Pots-processing

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