source: trunk/libIGCM/AA_create_ts @ 1573

Last change on this file since 1573 was 1568, checked in by jgipsl, 18 months ago

Change the variable SYSTEM=lxiv8 into SYSTEM=obelix. This is done to make the connexion easier between the variable SYSTEM and the file libIGCM_sys_XXXX.ksh which now always should be libIGCM_sys_${SYSTEM}.ksh

  • 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: 32.2 KB
RevLine 
[622]1#-Q- curie ######################
2#-Q- curie ## CURIE   TGCC/CEA ##
3#-Q- curie ######################
[906]4#-Q- curie #MSUB -r TS             # Nom du job
[1468]5#-Q- curie #MSUB -o TS.out_%I
6#-Q- curie #MSUB -e TS.out_%I
[622]7#-Q- curie #MSUB -n 1              # Reservation du processus
[880]8#-Q- curie #MSUB -T 80000          # 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
[1433]14#-Q- irene ######################
15#-Q- irene ## IRENE   TGCC/CEA ##
16#-Q- irene ######################
17#-Q- irene #MSUB -r TS            # Job name
[1468]18#-Q- irene #MSUB -o TS.out_%I
19#-Q- irene #MSUB -e TS.out_%I
[1433]20#-Q- irene #MSUB -n 1             # Number of cores
21#-Q- irene #MSUB -T 80000         # Maximum elapsed time
[1468]22#-Q- irene #MSUB -q ::default_node::
23#-Q- irene #MSUB -c ::default_core::
[1433]24#-Q- irene #MSUB -Q normal
[1468]25#-Q- irene #MSUB -A ::default_post_project::
[1460]26#-Q- irene #MSUB -m store,work,scratch
[1433]27#-Q- irene set +x
[1525]28#-Q- irene-amd ######################
29#-Q- irene-amd ## IRENE   TGCC/CEA ##
30#-Q- irene-amd ######################
31#-Q- irene-amd #MSUB -r TS            # Job name
32#-Q- irene-amd #MSUB -o TS.out_%I
33#-Q- irene-amd #MSUB -e TS.out_%I
34#-Q- irene-amd #MSUB -n 1             # Number of cores
35#-Q- irene-amd #MSUB -T 80000         # 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
[1490]42#-Q- jeanzay #!/bin/ksh
43#-Q- jeanzay ######################
44#-Q- jeanzay ## JEANZAY    IDRIS ##
45#-Q- jeanzay ######################
46#-Q- jeanzay #SBATCH --job-name=TS         # Job Name
47#-Q- jeanzay #SBATCH --output=TS.out_%I    # standard output
48#-Q- jeanzay #SBATCH --error=TS.out_%I     # error output
[1494]49#-Q- jeanzay #SBATCH -N  1                        # Number of core
50#-Q- jeanzay #SBATCH --partition=prepost          # Post-processing partition
[1490]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
[770]54#-Q- ada #!/bin/ksh
55#-Q- ada #######################
[929]56#-Q- ada ## ADA         IDRIS ##
[770]57#-Q- ada #######################
[1409]58#-Q- ada # @ job_type = mpich
[848]59#-Q- ada # @ requirements = (Feature == "prepost")
[770]60#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
61#-Q- ada # @ wall_clock_limit = 20:00:00
62#-Q- ada # Nom du travail LoadLeveler
63#-Q- ada # @ job_name   = TS
64#-Q- ada # Fichier de sortie standard du travail
65#-Q- ada # @ output     = $(job_name).$(jobid)
66#-Q- ada # Fichier de sortie d'erreur du travail
67#-Q- ada # @ error      =  $(job_name).$(jobid)
68#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
69#-Q- ada # @ notification = error
[1290]70#-Q- ada # @ environment  = $DEBUG_debug ; $BigBrother ; $postProcessingStopLevel ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $POST_DIR ; $Script_Post_Output ; $MASTER ; $RebuildFrequency ; $DateBegin ; $PeriodDateEnd ; $StandAlone ; $CompletedFlag ; $TsTask ; $CompToRead ; $FlagToRead ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_MBG ; $RESOL_SRF ; $RESOL_SBG ; wall_clock_limit=$(wall_clock_limit)
[770]71#-Q- ada # @ queue
[1568]72#-Q- obelix ######################
73#-Q- obelix ## OBELIX      LSCE ##
74#-Q- obelix ######################
75#-Q- obelix #PBS -N TS
76#-Q- obelix #PBS -m a
77#-Q- obelix #PBS -j oe
78#-Q- obelix #PBS -q medium
79#-Q- obelix #PBS -o TS.$$
80#-Q- obelix #PBS -S /bin/ksh
[1558]81#-Q- mesoipsl #!/bin/ksh
82#-Q- mesoipsl ######################
83#-Q- mesoipsl ## MESO ESPRI IPSL  ##
84#-Q- mesoipsl ######################
85#-Q- mesoipsl #SBATCH --job-name=TS         # Job Name
86#-Q- mesoipsl #SBATCH --output=TS.out_%I    # standard output
87#-Q- mesoipsl #SBATCH --error=TS.out_%I     # error output
88#-Q- mesoipsl #SBATCH -N  1                        # Number of core
89#-Q- mesoipsl #SBATCH --time=10:00:00       # Wall clock limit (seconds)
[1184]90#-Q- ifort_CICLAD ######################
91#-Q- ifort_CICLAD ##   CICLAD    IPSL ##
92#-Q- ifort_CICLAD ######################
93#-Q- ifort_CICLAD #PBS -N TS
94#-Q- ifort_CICLAD #PBS -m a
95#-Q- ifort_CICLAD #PBS -j oe
[1314]96#-Q- ifort_CICLAD ###PBS -q h12       # Queue for 12 hours at ciclad only
[1184]97#-Q- ifort_CICLAD #PBS -S /bin/ksh
[2]98#-Q- default #!/bin/ksh
99#-Q- default ##################
100#-Q- default ## DEFAULT HOST ##
101#-Q- default ##################
102
[373]103#**************************************************************
104# Author: Sebastien Denvil
105# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
106# $Revision::                                          $ Revision of last commit
107# $Author::                                            $ Author of last commit
108# $Date::                                              $ Date of last commit
[108]109# IPSL (2006)
110#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
[373]111#
112#**************************************************************
[108]113
114#set -eu
[2]115#set -vx
116
117date
118
[770]119#-Q- ada export OMP_NUM_THREADS=1
[2]120
[1356]121#D- Task type DO NOT CHANGE (computing, post-processing or checking)
[712]122TaskType=post-processing
123
[2]124########################################################################
125
126#D- Flag to determine if this job in a standalone mode
127#D- Default : value from AA_job if any
128StandAlone=${StandAlone:=true}
129
[554]130#D- Path to libIGCM
[206]131#D- Default : value from AA_job if any
[229]132libIGCM=${libIGCM:=::modipsl::/libIGCM}
[206]133
134#D- Flag to determine allready produced time series. Empty if you start from the beginning
[213]135#D- Default : Value from AA_job if any. Usefull in StandAlone case if you want to continue a time series
[209]136CompletedFlag=${CompletedFlag:=}
[135]137
[213]138#D- Flag to determine task type this script will perform.
139#D- Possible Value : 2D, 3D, Chunck2D, Chunck3D
140#D- Default : Value from AA_job if any. Usefull in StandAlone case.
[257]141TsTask=${TsTask:=2D}
[267]142if [ X${TsTask} = Xempty ] ; then
[785]143  TsTask=""
[267]144fi
[213]145
146#D- Flag to determine if rebuild process has been performed asynchronously
[906]147#D- Possible value true or false.
[213]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
[2]153#D- Flag to determine job's output directory
154#D- Default : value from libIGCM_post.ksh if any
[370]155POST_DIR=${POST_DIR:=${PBS_O_WORKDIR:=$(pwd)}}
[2]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
[1549]167RESOL_ATM=${RESOL_ATM:=ALL}
[2]168
[257]169#D- Flag to determine surface resolution
170#D- Default : value from surface driver if any
[1549]171RESOL_SRF=${RESOL_SRF:=ALL}
[257]172
173#D- Flag to determine surface resolution
174#D- Default : value from surface driver if any
[1549]175RESOL_SBG=${RESOL_SBG:=ALL}
[257]176
[2]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
[1326]183RESOL_ICE=${RESOL_OCE:=ORCA2}
[2]184
[178]185#D- TEMPORARY Flag to determine marine biogeochemistry resolution
186#D- Default : value from ice driver if any
[1326]187RESOL_MBG=${RESOL_OCE:=ORCA2}
[178]188
[2]189########################################################################
190
[108]191. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
192. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
193. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
194#-------
195. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
[731]196. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
[832]197#-------
[1192]198IGCM_sys_MkdirWork ${RUN_DIR_PATH}
199IGCM_sys_Cd ${RUN_DIR_PATH}
200#-------
[832]201( ${DEBUG_debug} ) && IGCM_debug_Check
202( ${DEBUG_debug} ) && IGCM_card_Check
203( ${DEBUG_debug} ) && IGCM_date_Check
[2]204
205########################################################################
206
207#set -vx
208
209# Useful cleaning function
[906]210MENAGE ()
[81]211{
[1306]212  typeset ExistFlag
213  ExistFlag=$( IGCM_sys_RshArchive "[ -f $1/$3 ] && echo 0 || echo 1" )
214  [ ${ExistFlag} -eq 0 ] && ( IGCM_sys_RshArchive rm -f $1/$2 ;)
[2]215}
216
217########################################################################
218
[436]219# ------------------------------------------------------------------
220# Test if all was right before proceeding further
221# ------------------------------------------------------------------
[1206]222IGCM_debug_Verif_Exit
[436]223
[2]224if [ ${StandAlone} = true ] ; then
[785]225  CARD_DIR=${SUBMIT_DIR}
[2]226else
[785]227  CARD_DIR=${RUN_DIR_PATH}
[903]228
[785]229  IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH}
[903]230
[785]231  IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card    ${RUN_DIR_PATH}
[903]232
[785]233  IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP        ${RUN_DIR_PATH}
[903]234
[785]235  IGCM_sys_Get_Master ${SUBMIT_DIR}/POST        ${RUN_DIR_PATH}
[2]236fi
237
[591]238#==================================
[2]239# First of all
240#
[727]241# Read libIGCM compatibility version in config.card
242# Read UserChoices section
243# Read Ensemble section
244# Read Post section
245# Define all netcdf output directories
[591]246#==================================
[727]247IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
[591]248
[1198]249# ------------------------------------------------------------------
250# Activate BigBrother so as to supervise this job
251# ------------------------------------------------------------------
252IGCM_debug_BigBro_Initialize
253
[591]254#==================================
[633]255# Define default value to keep compatibility with previous card: means before changes due to TGCC
256if [ X${PackDefault} = Xtrue ] ; then
257  [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency}
258else
259  config_Post_PackFrequency=NONE
260fi
[591]261
262#==================================
263# If pack is active then PackFrequency overule the config_UserChoices_PeriodLength
264if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then
265  config_UserChoices_PeriodLength=${config_Post_PackFrequency}
266fi
267
[2]268#
[149]269# Determine component to take care of depending on kind of task create_ts will perform
[2]270#
[392]271[ ${CompToRead} ] && set -A config_ListOfComponents ${CompToRead} || IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card ListOfComponents
[2]272#
[149]273# Determine period for time series. Default : value from AA_job or from launch_TS if any
274#
[309]275[ X${CompletedFlag} = X ] || CompletedFlag=$( IGCM_date_ConvertFormatToGregorian ${CompletedFlag} )
[301]276
[2]277DateBegin=${DateBegin:=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )}
278#
279PeriodDateEnd=${PeriodDateEnd:=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )}
[149]280#
281# Determine Dimension of the produced time series : 2D or 3D
282if (   [ X${TsTask} = XChunck2D ] || [ X${TsTask} = X2D ] ) ; then
[785]283  Dimension=2D
[149]284elif ( [ X${TsTask} = XChunck3D ] || [ X${TsTask} = X3D ] ) ; then
[785]285  Dimension=3D
[149]286else
[785]287  Dimension=""
[149]288fi
[2]289
[441]290# ------------------------------------------------------------------
291#D- Test if all was right before entering the loop
292# ------------------------------------------------------------------
[1206]293IGCM_debug_Verif_Exit
[149]294
[2]295########################################################################
296#      Depending on requested time series fill following variables :
297#
298#                           - LISTE_FILE_${comp}[*]
299#                           - LISTE_VARS_${file}[*]
300#                           - LISTE_AXIS_${file}[*]
301#                           - LISTE_PATCH_${file}[*]
302########################################################################
303
304#
305# For each selected component determine which files need post-processing
306#
307DoJob=false
308for comp in ${config_ListOfComponents[*]} ; do
[785]309  #
310  ActiveComp=false
311  #
312  IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp}
313  eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
314  #
315  card=${CARD_DIR}/COMP/${compname}.card
316
317  IGCM_card_DefineArrayFromOption ${card} OutputFiles List
318  #
319  ListFilesName=${compname}_OutputFiles_List
320  eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
321  #
322  if [ X${FileName0} != X${NULL_STR} ] ; then
[2]323    #
[785]324    #IGCM_debug_Print 1 "Component      : ${compname}"
[2]325    #
[785]326    # INITIALISATION
[2]327    #
[785]328    typeset i
329    if [ ${FlagToRead} ] ; then
330      ((NbFiles=${FlagToRead}))
331      ((i=${NbFiles}))
332    else
333      eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
334      i=2
335    fi
[2]336    #
[785]337    until [ $i -gt $NbFiles ]; do
338      #
339      eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1
340      #
341      if [ X${flag_post} != XNONE ] ; then
342        #
343        # For each comp and each file who needs post-processing
344        # determine which variables need time series.
345        #
346        FILE=$( echo ${flag_post} | awk "-FPost_" '{print $2}' )
347        IGCM_card_DefineArrayFromOption ${card}    Post_${FILE} TimeSeriesVars${Dimension}
348        IGCM_card_DefineVariableFromOption ${card} Post_${FILE} ChunckJob${Dimension}
349        #
350        # If TimeSeriesVars list is empty we skip
351        #
352        if [ $( eval echo \${${compname}_Post_${FILE}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then
353          #
354          IGCM_debug_Print 3 "Nothing to do for ${FILE} according to ${card}"
355          IGCM_debug_Print 3 "TimeSeriesVars${Dimension} for ${FILE} is empty"
356          (( i=i+3 ))
357          continue
358          #
359        fi
360        #
361        # If files/variables has been switch off by ChunckJob${Dimension}=0 we skip
362        #
363        if [ X$( eval echo \${${compname}_Post_${FILE}_ChunckJob${Dimension}} ) = XOFF ] ; then
364          IGCM_debug_Print 3 "Nothing to do for ${FILE} according to ${card}"
365          IGCM_debug_Print 3 "ChunckJob${Dimension}=OFF for ${FILE} so it has been switched off"
366          (( i=i+3 ))
367          continue
368        fi
369        #
370          # If we are not a Chunck type task, we skip files/variables handled by chunck task
371          #
372        if ( [ ! X${TsTask} = XChunck${Dimension} ] && [ ! X${TsTask} = X ] && [ ! XChunck${Dimension} = XChunck ] ) ; then
373          if [ ! $( eval echo \${${compname}_Post_${FILE}_ChunckJob${Dimension}} ) = NONE ] ; then
374            IGCM_debug_Print 3 "Nothing to do for ${FILE} TimeSeriesVars${Dimension} according to ${card}"
375            IGCM_debug_Print 3 "Let another chunck task do the job $( eval echo \${${compname}_Post_${FILE}_ChunckJob${Dimension}} )"
376            (( i=i+3 ))
377            continue
378          fi
379        fi
380        #
381        # Now on we know we have things to do
382        #
[236]383
[785]384        #
385        #  We need coordinates axis to properly fill produced time series
386        #
387        IGCM_card_DefineArrayFromOption ${card} Post_${FILE} GatherWithInternal
388        #
389        if [ $( eval echo \${${compname}_Post_${FILE}_GatherWithInternal} ) = ${NULL_STR} ] ; then
390          #
391          IGCM_debug_Print 1 "ERROR !! We miss coordinate axis for ${FILE} according to ${card}"
392          IGCM_debug_Print 1 "So no time series will be produced for ${FILE} !!"
393          (( i=i+3 ))
394          continue
395          #
396        fi
397        #
398        # We need LIST of variables not allready produced (useful for standalone mode)
399        #
400        FlagDir=$( echo ${FILE} | awk -F "_" '{print $1}' )
401        case ${FlagDir} in
402          *Y)  TS_Dir=TS_YE  ;;
403          *M)  TS_Dir=TS_MO  ;;
404          *D)  TS_Dir=TS_DA  ;;
405          HF)  TS_Dir=TS_HF  ;;
406          3H)  TS_Dir=TS_HF  ;;
407          INS) TS_Dir=TS_INS ;;
408        esac
409        #
410        count=0
411        for var in $( eval echo \${${compname}_Post_${FILE}_TimeSeriesVars${Dimension}[*]} ) ; do
412          #
413          DIRECTORY=${R_SAVE}/${comp}/Analyse/${TS_Dir}
414          TestedFile=${config_UserChoices_JobName}_${DateBegin}_${PeriodDateEnd}_${FlagDir}_${var}.nc
415          #
416          IGCM_sys_TestFileArchive ${DIRECTORY}/${TestedFile}
417          if [ ! $? = 0 ] ; then
418            eval set +A LISTE_VARS_${FILE} \${LISTE_VARS_${FILE}[*]} ${var}
419            ActiveComp=true
420            (( count = count + 1 ))
421          fi
422        done
423        #
424        if [ ${count} -gt 0 ] ; then
425          #
426          eval set +A LISTE_FILE_${comp} \${LISTE_FILE_${comp}[*]} ${FILE}
427          eval set +A LISTE_AXIS_${FILE} \${${compname}_Post_${FILE}_GatherWithInternal[*]}
428          #
429          if [ ! X${RebuildFrequency} = Xtrue ] ; then
430            IGCM_card_DefineArrayFromOption ${card} Post_${FILE} Patches
431            eval set +A LISTE_PATCHES_${FILE} \${${compname}_Post_${FILE}_Patches[*]}
432            if [ X$( eval echo \${LISTE_PATCHES_${FILE}[0]} ) !=  X${NULL_STR} ]; then
433              for Patch in $( eval echo \${LISTE_PATCHES_${FILE}[*]} ); do
434                if [ Xload${Patch} != X ] ; then
435                  . ${libIGCM}/libIGCM_post/IGCM_${Patch}.ksh
436                  eval load${Patch}=loaded
437                fi
438              done
439            fi
440          fi
441        fi
442      fi
443      (( i=i+3 ))
444    done
445  fi
446  #
447  if [ ${ActiveComp} = true ] ; then
448    set +A ActiveListOfComponents ${ActiveListOfComponents[*]} ${comp}
449  fi
[2]450done
451
452set -A config_ListOfComponents ${ActiveListOfComponents[*]}
453[ ! -z "${ActiveListOfComponents}" ] && DoJob=true
454
455########################################################################
456#
457#               IS THERE SOME ALLREADY PRODUCED TIME SERIES ?
458#                 IF SO BRING THEM IN THE WORKING DIRECTORY
459#
460# PS : Keep in mind that IGCM_sys_Get here is a weak link :
461#      - especially for IDRiS
462#      - no special protection against "command too long" !
463#      - libIGCM_sys should handle that or modify following code part
464#
465########################################################################
466
467if [ ${StandAlone} != true ] ; then
[785]468  Running_Flag=$( IGCM_sys_RshMaster "IGCM_card_DefineVariableFromOption \
469  ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesRunning ; \
470  echo \${run_PostProcessing_TimeSeriesRunning}" )
[2]471
[785]472  #if [ X${Running_Flag} = Xy ] ; then
473  #  # Time Series Job allready running
474  #  IGCM_debug_Print 1 "Time Series Job allready running exit"
475  #  exit
476  #fi
477  # Now run.card know we are running
[149]478
479
480
481
[785]482  IGCM_sys_RshMaster IGCM_card_WriteOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesRunning "y"
[149]483
484
485
486
487
[785]488  # Get information from last execution
489  #CompletedFlag=$( IGCM_sys_RshMaster \
490  # "IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted ;\
491  #        echo \${run_PostProcessing_TimeSeriesCompleted}" )
[2]492fi
493
494# Is it the first submission or not ?
[149]495
496if ( [ X${CompletedFlag} = X ] || [ X${CompletedFlag} = X$( IGCM_date_AddDaysToGregorianDate ${DateBegin} -1 ) ] ) ; then
[785]497  # First Time Series Submission
498  FIRST_PASS=TRUE
499  Length=$( IGCM_date_DaysInPreviousPeriod ${DateBegin} ${config_UserChoices_PeriodLength} begin)
500  DATE_FIN_JOB_B=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( Length - 1 )) )
[2]501else
[785]502  # Last Completed Time Series
503  FIRST_PASS=FALSE
504  DATE_FIN_JOB_B=${CompletedFlag}
505  date=${DateBegin}_${DATE_FIN_JOB_B}
[1038]506  #
[785]507  for comp in ${config_ListOfComponents[*]} ; do
508    #
509    IGCM_sys_Mkdir ${RUN_DIR_PATH}/${comp}
510    #
511    IGCM_sys_Cd ${RUN_DIR_PATH}/${comp}
512    #
513    unset liste_file
514    #
515    file_path=${R_SAVE}/${comp}/Analyse
516    #
517    i=0
518    file=${NULL_STR}
519    #
520    for file in $( eval echo \${LISTE_FILE_${comp}[*]} ); do
521      #
522      # Determine in which output can we find file
523      # IE : Analyse/TS or Analyse/DA2TS or ...
524      #
525      FlagDir=$( echo ${file} | awk -F "_" '{print $1}' )
526      case ${FlagDir} in
527        *Y)  TS_Dir=TS_YE  ;;
528        *M)  TS_Dir=TS_MO  ;;
529        *D)  TS_Dir=TS_DA  ;;
530        HF)  TS_Dir=TS_HF  ;;
531        3H)  TS_Dir=TS_HF  ;;
532        INS) TS_Dir=TS_INS ;;
533      esac
534      for var in $( eval echo \${LISTE_VARS_${file}[*]} ) ; do
[2]535        #
[1033]536        IGCM_sys_TestFileArchive ${file_path}/${TS_Dir}/${config_UserChoices_JobName}_${date}_${FlagDir}_${var}.nc
537        if [ $? = 0 ] ; then
538          liste_file[${#liste_file[*]}]=${file_path}/${TS_Dir}/${config_UserChoices_JobName}_${date}_${FlagDir}_${var}.nc
539        else
540          IGCM_debug_Print 1 "WARNING ${file_path}/${TS_Dir}/${config_UserChoices_JobName}_${date}_${FlagDir}_${var}.nc dont exist"
541        fi
[785]542        #
543      done
[2]544    done
[785]545    if [ X${file} != X${NULL_STR} ] ; then
546      IGCM_sys_Get /l liste_file[*] ${RUN_DIR_PATH}/${comp}
[1206]547      IGCM_debug_Verif_Exit
[785]548    fi
549  done
550  #
551  LEVEL=0
552  #
[2]553fi
554
555########################################################################
556#
557#                          DEFINE LOOP PARAMETERS
558#
559########################################################################
560
561DATE_COUNT=${DATE_FIN_JOB_B}
562DATE_FIN_JOB_B_LOOP=${DATE_FIN_JOB_B}
563
564( [ -n "${LEVEL}" ] && [ ${LEVEL} -eq 0 ] ) && NBRE_FILE_TOT=0 || NBRE_FILE_TOT=1
565
566if [ ${DoJob} = true ] ; then
[785]567  while [ ${DATE_COUNT} -lt ${PeriodDateEnd} ] ; do
568    (( NBRE_FILE_TOT = NBRE_FILE_TOT + 1 ))
569    Length=$( IGCM_date_DaysInNextPeriod ${DATE_COUNT} ${config_UserChoices_PeriodLength} )
570    DATE_COUNT=$( IGCM_date_AddDaysToGregorianDate ${DATE_COUNT} ${Length} )
571  done
[2]572else
[785]573  NBRE_FILE_TOT=0
[2]574fi
575
576if [ ${NBRE_FILE_TOT} -le ${UNIX_MAX_LIMIT} ] ; then
[906]577  NBRE_TOUR=1
[2]578elif [ ${NBRE_FILE_TOT}%${UNIX_MAX_LIMIT} -eq 0 ] ; then
[906]579  let NBRE_TOUR=${NBRE_FILE_TOT}/${UNIX_MAX_LIMIT}
[2]580else
[785]581  let NBRE_TOUR=${NBRE_FILE_TOT}/${UNIX_MAX_LIMIT}+1
[2]582fi
583
584CURRENT_LOOP=1
585# THIS LOOP GIVES PARAMETERS FOR THE DATE'S LOOP ie : DATE_COURANTE, DATE_FIN.
[906]586# WE HAVE 3 LEVELS
[2]587#    - LEVEL 1 : JUST ONE LOOP TO COMPLETE
588#    - LEVEL 2 : WE ARE IN THE "DEEP" LOOP
589#    - LEVEL 3 : WE ARE IN THE LAST LOOP
590
591while [ ${CURRENT_LOOP} -le  ${NBRE_TOUR} ] ; do
592
[906]593  if [ ${NBRE_FILE_TOT} -le ${UNIX_MAX_LIMIT} ] ; then
[785]594    # - LEVEL 1 : JUST ONE LOOP TO COMPLETE
595    NBRE_FILE_LOOP=${NBRE_FILE_TOT}
[2]596
[785]597    if [ ${FIRST_PASS} = TRUE ] ; then
598      DATE_COURANTE=${DATE_FIN_JOB_B_LOOP}
599    else
600      Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN_JOB_B_LOOP} ${config_UserChoices_PeriodLength} )
601      DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN_JOB_B_LOOP} ${Length} )
602    fi
[2]603
[785]604    DATE_FIN=${PeriodDateEnd}
605    DATE_FIN_JOB_B_LOOP_PREC=${DATE_FIN_JOB_B_LOOP}
[2]606
[785]607    [ -n "${DATE_LOOP}" ] && DATE_FIN_JOB_B_LOOP=${DATE_LOOP}
608    [ -n "${LEVEL}" ] && FLAG_B="TRUE" || FLAG_B="FALSE"
[2]609
[785]610    LEVEL=1
[906]611    DEPOT="TRUE"
[785]612  elif [ ${CURRENT_LOOP} -ne  ${NBRE_TOUR} ] ; then
613    # - LEVEL 2 : WE ARE IN THE "DEEP" LOOP
614    NBRE_FILE_LOOP=${UNIX_MAX_LIMIT}
[2]615
[785]616    if [ ! ${FIRST_PASS} = TRUE ] && [ ${CURRENT_LOOP} -eq 1 ] ; then
617      Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN_JOB_B_LOOP} ${config_UserChoices_PeriodLength} )
618      DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN_JOB_B_LOOP} ${Length} )
619    elif [ -z "${DATE_COURANTE}" ] ; then
620      DATE_COURANTE=${DATE_FIN_JOB_B}
[2]621    else
[785]622      Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN} ${config_UserChoices_PeriodLength} )
623      DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN} ${Length} )
624    fi
[2]625
[785]626    (( TotLength = 0 ))
627    COMPTEUR=1
628    DATE_LOOP=${DATE_COURANTE}
[2]629
[785]630    while [ ${COMPTEUR} -lt ${NBRE_FILE_LOOP} ] ; do
631      #
632      Length=$( IGCM_date_DaysInNextPeriod ${DATE_LOOP} ${config_UserChoices_PeriodLength} )
633      DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} ${Length} )
634      (( TotLength = TotLength + Length ))
635      (( COMPTEUR = COMPTEUR + 1 ))
636      #
637    done # while [ ${COMPTEUR} -le ${NBRE_FILE_LOOP} ] done
638    DATE_FIN=$( IGCM_date_AddDaysToGregorianDate ${DATE_COURANTE} ${TotLength} )
[2]639
[785]640    [ -n "${DATE_LOOP}" ] && DATE_FIN_JOB_B_LOOP_PREC=${DATE_FIN_JOB_B_LOOP} ; DATE_FIN_JOB_B_LOOP=${DATE_LOOP}
641    [ -n "${LEVEL}" ] && [ ${LEVEL} -eq 0 ] && FLAG_B="TRUE" || [ ${CURRENT_LOOP} -gt 1 ] && FLAG_B="TRUE" || FLAG_B="FALSE"
642    DEPOT="FALSE"
643    LEVEL=2
644  else
645    # - LEVEL 3 : WE ARE IN THE LAST LOOP
646    NBRE_FILE_LOOP=$(( ${NBRE_FILE_TOT} % ( ${UNIX_MAX_LIMIT} * ( ${CURRENT_LOOP} - 1 ) ) ))
647    [ ${NBRE_FILE_LOOP} -eq 0 ] && NBRE_FILE_LOOP=${UNIX_MAX_LIMIT}
[2]648
[785]649    Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN} ${config_UserChoices_PeriodLength} )
650    DATE_COURANTE=$(IGCM_date_AddDaysToGregorianDate ${DATE_FIN} ${Length} )
651    DATE_FIN=${PeriodDateEnd}
652    [ -n "${DATE_LOOP}" ] && DATE_FIN_JOB_B_LOOP_PREC=${DATE_FIN_JOB_B_LOOP} ; DATE_FIN_JOB_B_LOOP=${DATE_LOOP}
[2]653
[785]654    LEVEL=3
655    DEPOT="TRUE"
656    FLAG_B="TRUE"
657  fi
[2]658
[785]659  # THEN FOR EACH FILE TYPE WE LOOP BETWEEN DATE_COURANTE AND DATE_FIN.
660  for comp in ${config_ListOfComponents[*]} ; do
661    #
662    IGCM_sys_Mkdir ${RUN_DIR_PATH}/${comp}
663      #
664    IGCM_sys_Cd ${RUN_DIR_PATH}/${comp}
665    #
666    eval R_OUT_${comp}=${R_SAVE}/${comp}
667    #
668    i=0
669    #
670    for file in $( eval echo \${LISTE_FILE_${comp}[*]} ); do
671      #
672      # Determine in which output we can find file
673      # IE : Output/MO or Output/DA or ...
674      #
675      FlagDir=$( echo ${file} | awk -F "_" '{print $1}' )
676      case ${FlagDir} in
677        *Y)    TS_Dir=TS_YE  ; FreqDir=YE  ;;
678        *M)    TS_Dir=TS_MO  ; FreqDir=MO  ;;
679        *D)    TS_Dir=TS_DA  ; FreqDir=DA  ;;
680        HF)    TS_Dir=TS_HF  ; FreqDir=HF  ;;
681        3H)    TS_Dir=TS_HF  ; FreqDir=HF  ;;
682        INS)   TS_Dir=TS_INS ; FreqDir=INS ;;
683        *)     IGCM_debug_Print 1 "Error in FlagDir=${FlagDir} for file ${file}."
[1205]684               IGCM_debug_Exit "Job create_ts" ;;
[785]685      esac
[2]686
[785]687      # Initialize array
688      unset liste_file
689      unset liste_file_tmp
690      eval file_path=\${R_OUT_${comp}}/Output/${FreqDir}/
[2]691
[785]692      COMPTEUR=1
[817]693      MissingFile=FALSE
[785]694      DATE_LOOP=${DATE_COURANTE}
[2]695
[785]696      while [ ${COMPTEUR} -le ${NBRE_FILE_LOOP} ] ; do
697        #
698        Length1=$( IGCM_date_DaysInPreviousPeriod ${DATE_LOOP} ${config_UserChoices_PeriodLength} end)
699        DATE_TAB=$(  IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} $(( 1 - Length1 )) )_${DATE_LOOP}
[2]700
[785]701        Length2=$( IGCM_date_DaysInNextPeriod ${DATE_LOOP} ${config_UserChoices_PeriodLength} )
702        DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} ${Length2} )
[2]703
[817]704        IGCM_sys_TestFileArchive ${file_path}${config_UserChoices_JobName}_${DATE_TAB}_${file}.nc
705        if [ $? = 0 ] ; then
706          liste_file[${#liste_file[*]}]=${file_path}${config_UserChoices_JobName}_${DATE_TAB}_${file}.nc
707          liste_file_tmp[${#liste_file_tmp[*]}]=${config_UserChoices_JobName}_${DATE_TAB}_${file}.nc
708        else
709          IGCM_debug_Print 1 "WARNING ${file_path}${config_UserChoices_JobName}_${DATE_TAB}_${file}.nc dont exist"
710          MissingFile=TRUE
711        fi
[785]712        (( COMPTEUR = COMPTEUR + 1 ))
713        #
714      done # while [ ${COMPTEUR} -le ${NBRE_FILE_LOOP} ] done
[817]715
716      # We skip this file type if one of them is missing.
717      if [ "${MissingFile}" = "TRUE" ] ; then
718        IGCM_debug_Print 1 "WARNING We skip ${file} type processing"
719        continue
720      fi
721
[785]722      DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} -${Length2} )
[2]723
[785]724      # Get selected files
725      IGCM_sys_Get /l liste_file[*] ${RUN_DIR_PATH}/${comp}
[1206]726      IGCM_debug_Verif_Exit
[2]727
[785]728      # Apply IGCM_Patch if needed
729      if [ ! X${RebuildFrequency} = Xtrue ] ; then
730        if [ X$( eval echo \${LISTE_PATCHES_${file}[0]} ) !=  X${NULL_STR} ]; then
[906]731          for file_t in $( eval echo ${liste_file_tmp[*]} ); do
[785]732            for Patch in $( eval echo \${LISTE_PATCHES_${file}[*]} ); do
733              IGCM_${Patch} ${file_t}
[1206]734              IGCM_debug_Verif_Exit
[785]735            done
736          done
737        fi
738      fi
[2]739
[785]740      # WE CAN CONCATENATE FILES AT THIS POINT
741      [ "${FLAG_B}" = "TRUE" ] && DATE_BUILD_B=${DateBegin}_${DATE_FIN_JOB_B_LOOP_PREC}
742      Length=$( IGCM_date_DaysInPreviousPeriod ${DATE_COURANTE} ${config_UserChoices_PeriodLength} end)
743      DATE_BUILD1=$( IGCM_date_AddDaysToGregorianDate ${DATE_COURANTE} -$(( Length - 1 )) )
744      DATE_BUILD=${DATE_BUILD1}_${DATE_FIN}
745      DATE_BUILD_END=${DateBegin}_${DATE_FIN}
[514]746
[785]747      liste_coord=" "
748      for axis in $( eval echo \${LISTE_AXIS_${file}[*]} ); do
749        liste_coord=${liste_coord}${axis}","
750      done
[287]751
[785]752      # Time axis must be the last dimension
753      time_axis=${axis}
[388]754
[785]755      # SWITCH BETWEEN MODEL TO FIT PARTICULAR CASE
756      for var in $( eval echo \${LISTE_VARS_${file}[*]} ) ; do
757        #
[1033]758        # We skip variables not in the first file of the list.
759        # Seems overkill to test thel all... but will do if needed
760        ncdump -hv ${var} ${liste_file_tmp[0]} > /dev/null 2>&1
761        if [ ! $? = 0 ] ; then
762          IGCM_debug_Print 1 "WARNING We skip ${var}, not present within ${liste_file_tmp[0]}"
763          continue
764        fi
765        #
[785]766        if [ "${FLAG_B}" = "TRUE" ] ; then
767          # WE CONCATENATE WITH EXISTING FILES
768          file1=${config_UserChoices_JobName}_${DATE_BUILD_B}_${FlagDir}_${var}.nc
769          file_out=${config_UserChoices_JobName}_${DATE_BUILD_END}_${FlagDir}_${var}.nc
770          IGCM_sys_ncrcat --hst -v ${liste_coord}${var} ${file1} ${liste_file_tmp[*]} ${file_out}
[1206]771          IGCM_debug_Verif_Exit
[785]772          #
773          IGCM_sys_Rm ${file1}
774          if [ ! "${DEPOT}" = "TRUE" ] ; then
775            eval IGCM_sys_Put_Out ${file_out} \${R_OUT_${comp}}/Analyse/${TS_Dir}/${file_out}
776            # "${file1} = file_before ?
777            [ ! "${file1}" = "${config_UserChoices_JobName}_${DateBegin}_${DATE_FIN_JOB_B}_${FlagDir}_${var}.nc" ] && eval MENAGE \${R_OUT_${comp}}/Analyse/${TS_Dir} ${file1} ${file_out}
778          fi
779        else
780          # OR NOT
[1047]781          file_out=${config_UserChoices_JobName}_${DATE_BUILD}_${FlagDir}_${var}.nc
782          IGCM_sys_ncrcat --hst -v ${liste_coord}${var} ${liste_file_tmp[*]} ${file_out}
[1206]783          IGCM_debug_Verif_Exit
[785]784        fi
785
786        #
787        if [ "${DEPOT}" = "TRUE" ] ; then
[1042]788          # WE PUT FINAL FILE ON FILE SYSTEM
789          [ "${FLAG_B}" = "FALSE" ] && file_out=${config_UserChoices_JobName}_${DATE_BUILD}_${FlagDir}_${var}.nc
790          file_before=${config_UserChoices_JobName}_${DateBegin}_${DATE_FIN_JOB_B}_${FlagDir}_${var}.nc
[785]791          #
[1042]792          eval IGCM_sys_Put_Out ${file_out} \${R_OUT_${comp}}/Analyse/${TS_Dir}/${file_out}
793          [ "${FLAG_B}" = "TRUE" ] && eval MENAGE \${R_OUT_${comp}}/Analyse/${TS_Dir} ${file_before} ${file_out}
794          if [ ! "X${file1}" = "X" ] ; then
795            [ ! "${file1}" = "${config_UserChoices_JobName}_${DateBegin}_${DATE_FIN_JOB_B}_${FlagDir}_${var}.nc" ] && eval MENAGE \${R_OUT_${comp}}/Analyse/${TS_Dir} ${file1} ${file_out}
796          fi
797          #
[1039]798          [ -f ${file_out} ] && IGCM_sys_Rm ${file_out}
[785]799          #
800        fi
801        #
[1038]802      done                              # for var in ${liste_var} ; do
[785]803      IGCM_sys_Rm ${liste_file_tmp[*]}
[1038]804    done                                # for file in ${liste_file_brut} do
805  done                                  # for comp in ${config_ListOfComponents[*]} ; do
[785]806  # GO AHEAD IN DEEPEST LOOP
807  (( CURRENT_LOOP = CURRENT_LOOP + 1 ))
[1038]808done                                    # while [ ${CURRENT_LOOP} -le  ${NBRE_TOUR} ] do
[2]809# FINISH
810
811# DODS copy
812for comp in ${config_ListOfComponents[*]} ; do
[1393]813  for TS_Dir in TS_YE TS_MO TS_DA TS_HF TS_INS ; do
[785]814    IGCM_sys_TestDirArchive ${R_SAVE}/${comp}/Analyse/${TS_Dir}
815    [ $? = 0 ] && IGCM_sys_Put_Dods ${comp}/Analyse/${TS_Dir}
816  done
[2]817done
818
[1112]819export DEBUG_debug; export BigBrother ; export libIGCM; export SUBMIT_DIR; export POST_DIR; export Script_Output ;
820export StandAlone ; export RESOL_ATM; export RESOL_OCE ; export RESOL_ICE ; export RESOL_MBG ; export RESOL_SRF ;
821export RESOL_SBG
822listVarEnv="DEBUG_debug,BigBrother,libIGCM,SUBMIT_DIR,POST_DIR,Script_Post_Output,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG"
[2]823export listVarEnv
824
825#D-
826# --------------------------------------------------------------------
827#D- Test if all was right
828# --------------------------------------------------------------------
[1206]829IGCM_debug_Verif_Exit
[2]830# --------------------------------------------------------------------
831#D- Submit MONITORING
832# --------------------------------------------------------------------
[414]833if ( [ X${TsTask} = X2D ] || [ X${TsTask} = X3D ] || [ X${TsTask} = X ] ) ; then
[1439]834  # From 2D and 3D it is the last one to finish that will submit the monitoring.
835  if [ ! "X$( grep "IGCM_sys_RmRunDir" ${POST_DIR}/create_ts.${PeriodDateEnd}.[23]D.out 2> /dev/null )" = "X" ] ; then
836    Script_Post_Output=monitoring.${PeriodDateEnd}
837    IGCM_sys_QsubPost monitoring
838  fi
[387]839fi
[2]840
841#D-
842# --------------------------------------------------------------------
843#D- Update the run.card
844# --------------------------------------------------------------------
845if [ ${StandAlone} != true ] ; then
[785]846  # Put in run.card end period of time series
847  [ X"${DATE_FIN}" = X ] || IGCM_sys_RshMaster IGCM_card_WriteOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted "${DATE_FIN}"
848  # We have finish the job !
849  IGCM_sys_RshMaster IGCM_card_WriteOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesRunning "n"
[2]850fi
[203]851
[590]852# Clean RUN_DIR_PATH (necessary for cesium and titane only)
[203]853IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
854
[1198]855# ------------------------------------------------------------------
856# Finalize BigBrother to inform that the jobs end
857# ------------------------------------------------------------------
858IGCM_debug_BigBro_Finalize
859
[2]860date
Note: See TracBrowser for help on using the repository browser.