source: trunk/libIGCM/libIGCM_config/libIGCM_config.ksh @ 22

Last change on this file since 22 was 22, checked in by sdipsl, 16 years ago

SD : - Add the so called "rebuild déporté" or asynchronous rebuild

  • EXPERIMENTAL, work at CCRT only (for now mercure+platine)
  • Add IDRIS when new post-process machine is available
  • On SX one needs to run on $SCRATCHDIR not $LOCALTMPDIR
  • To keep it disable : RebuildFrequency?=NONE in config.card
  • To enable it : RebuildFrequency?=2Y in config.card
  • To enable it on SX8R : RUN_DIR_PATH=$SCRATCHDIR in AA_job
  • Need testing to tune empirically dependance between RebuildFrequency? and other post-processing frequency
  • Need more tests to prevent user choices' inconsitency
  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

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

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

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

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

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

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

    The fact that you are presently reading this means that you have had
    knowledge of the CeCILL license and that you accept its terms.
  • Property svn:keywords set to Date Author Revision
File size: 20.9 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil, Martial Mancip
5# Contact: Sebastien.Denvil@ipsl.jussieu.fr Martial.Mancip@ipsl.jussieu.fr
6# $Date$
7# $Author$
8# $Revision$
9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11# History:
12# Modification:
13#
14#**************************************************************
15
16#===================================
17function IGCM_config_Initialize
18{
19    IGCM_debug_PushStack "IGCM_config_Initialize"
20
21    # Debug Print :
22    echo
23    IGCM_debug_Print 1 "IGCM_config_Initialize :"
24    echo
25
26    # Test modipsl tree existence.
27    IGCM_sys_TestDir ${MODIPSL}
28    IGCM_sys_TestDir ${libIGCM}
29    IGCM_sys_TestDir ${R_EXE}
30    IGCM_sys_TestDir ${SUBMIT_DIR}
31
32    #==================================
33
34    typeset option auxprint CompatibilityTag
35    # Read libIGCM compatibility version in config.card
36    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Compatibility libIGCM
37    eval CompatibilityTag=${config_Compatibility_libIGCM} > /dev/null 2>&1     
38
39    if [ ! "${CompatibilityTag}" = "${libIGCM_CurrentTag}" ] ; then
40        IGCM_debug_Exit "config.card is not compatible with libIGCM version ${libIGCM_CurrentTag} see libIGCM FAQ http://wiki.ipsl.jussieu.fr/wiki_ipsl/IGCMG/libIGCM/DocUtilisateur/FAQ ."
41    fi
42
43    #==================================
44    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card UserChoices
45
46    for option in ${config_UserChoices[*]} ; do
47        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices ${option}
48    done
49
50    IGCM_debug_Print 1 "DefineArrayFromOption  : config_UserChoices"
51    IGCM_debug_PrintVariables 3 config_UserChoices_JobName
52    IGCM_debug_PrintVariables 3 config_UserChoices_LongName
53    IGCM_debug_PrintVariables 3 config_UserChoices_TagName
54    IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType
55    IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin
56    IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd
57    IGCM_debug_PrintVariables 3 config_UserChoices_PeriodLength
58
59    #==================================
60
61    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card ListOfComponents
62
63    echo
64    IGCM_debug_Print 1 "DefineArrayFromSection : ListOfComponents"
65    IGCM_debug_Print 3 ${config_ListOfComponents[*]}
66    echo
67
68    NbComponents=${#config_ListOfComponents[*]}
69
70    #==================================
71    # Define principal executable
72
73    IGCM_card_DefineArrayFromSection   ${SUBMIT_DIR}/config.card Executable
74    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Executable Name
75   
76    #==================================
77    # Define Outputs Name
78    IGCM_debug_Print 1 "Define Script_Output_Prefix and Exe_Output"
79    eval Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'}
80    IGCM_debug_Print 3 "Script_Output_Prefix = ${Script_Output_Prefix}"
81    eval Exe_Output=out_${config_Executable_Name}
82    IGCM_debug_Print 3 "Exe_Output           = ${Exe_Output}"
83
84    #==================================
85
86    #===================================================================#
87    # Prepare variables available for ${COMP}.card and ${COMP}.driver   #
88    #             But available to any son functions                    #
89    #===================================================================#
90
91    # Convert yyyy-mm-dd date to gregorian yyyymmdd
92    DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
93    DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )
94
95    # Period Length In Days between DateBegin and DateEnd
96    (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} )  + 1 ))
97    if [ ${ExperienceLengthInDays} -lt 0 ] ; then
98        IGCM_debug_Print 1 "Problem with dates in config.card : ${DateEnd} < ${DateBegin} ! You must check that."
99        IGCM_debug_Exit "IGCM_config_Initialize" " Wrong Dates."
100        IGCM_debug_Verif_Exit
101    fi
102
103    # Day and Year of Initial State (Given in julian format)
104    InitDay=$(  expr $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) % 1000 )
105    InitYear=$( expr $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) / 1000 )
106
107    #==================================
108    # Restarts : Gerneral rule or local for each component ?
109    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Restarts
110
111    echo
112    IGCM_debug_Print 1 "DefineArrayFromOption : config_Restarts"
113
114    for option in ${config_Restarts[*]} ; do
115        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Restarts ${option}
116        eval auxprint=\${config_Restarts_${option}}
117        IGCM_debug_Print 3 "${option} : ${auxprint}"
118    done
119
120    echo
121    IGCM_debug_Print 1 "DefineVariableFromOption : config_Post"
122    #
123    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Post RebuildFrequency
124    #
125
126    #================================================================#
127    #                  Test and Prepare directories                  #
128    #================================================================#
129
130    # ==> 4 kinds of input files :
131    #     1) R_INIT  : Initial State Files   (Etat0, carteveg)
132    #     2) R_BC    : Boundary Conditions   (Forcages, lai)
133    #     3) Parameters files (allready define through ${SUBMIT_DIR})
134    #     4) Restarts files   (allready define in IGCM_config_Initialize)
135
136    # Here we offer the possibility to redefine R_INIT, R_BC
137    # and PeriodNb through config.card
138    R_INIT=${config_UserChoices_R_INIT:=${R_IN}/INIT}
139    echo
140    IGCM_debug_Print 1 "(Re)Define R_INIT, R_BC and PeriodNb"
141    IGCM_debug_Print 3 "R_INIT=${R_INIT}"
142    R_BC=${config_UserChoices_R_BC:=${R_IN}/BC}
143    IGCM_debug_Print 3  "R_BC=${R_BC}"
144    PeriodNb=${config_UserChoices_PeriodNb:=${PeriodNb}}
145    IGCM_debug_Print 3  "Loop in main Job with ${PeriodNb} period(s)"
146
147    # Test Archive input/output.
148    IGCM_sys_TestDirArchive ${ARCHIVE}
149    IGCM_sys_TestDirArchive ${R_INIT}
150    IGCM_sys_TestDirArchive ${R_BC}
151
152    #====================================================
153    #R_SAVE : Job output directory
154    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
155
156    if [ ! -f ${SUBMIT_DIR}/run.card ]; then
157        IGCM_sys_MkdirArchive ${R_SAVE}
158    else
159        #Test state of run in run.card
160        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
161        if ( [ ${run_Configuration_PeriodState} != "Start" ] && [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
162            echo
163            IGCM_debug_Print 1 "!!!! IGCM_config_Initialize Error PeriodState : " ${run_Configuration_PeriodState} "!!!!!!!!!!"
164            echo
165            IGCM_debug_Exit "IGCM_config_Initialize Error PeriodState : " ${run_Configuration_PeriodState}
166            IGCM_debug_Verif_Exit
167        fi
168    fi
169    IGCM_sys_TestDirArchive ${R_SAVE}
170
171    #====================================================
172    #R_OUT_KSH : Storage place for job output
173    #R_OUT_EXE : Storage place for binary used during simulation
174    R_OUT_KSH=${R_SAVE}/Out
175    R_OUT_EXE=${R_SAVE}/Exe
176
177    IGCM_debug_PopStack "IGCM_config_Initialize"
178}
179
180#===================================
181function IGCM_config_PeriodStart
182{
183    IGCM_debug_PushStack "IGCM_config_PeriodStart"
184
185    echo
186    IGCM_debug_Print 1 "IGCM_config_PeriodStart :"
187    echo
188
189    if [ ! -r ${SUBMIT_DIR}/run.card ]; then 
190
191        #================================================#
192        #         The file run.card doesn't exist        #
193        #================================================#
194
195        eval FirstInitialize=true
196
197        #copy initial run.card
198        IGCM_sys_Cp ${SUBMIT_DIR}/run.card.init ${SUBMIT_DIR}/run.card
199
200        IGCM_date_GetYearMonth $DateBegin year month
201
202        case ${config_UserChoices_PeriodLength} in
203            1Y|1y) 
204                (( PeriodLengthInDays = $( IGCM_date_DaysInYear $year ) )) ;;
205            1M|1m) 
206                (( PeriodLengthInDays = $( IGCM_date_DaysInMonth $year $month ) )) ;;
207            5D|5d) 
208                (( PeriodLengthInDays = 5 )) ;;
209            1D|1d) 
210                (( PeriodLengthInDays = 1 )) ;;
211            *) 
212                IGCM_debug_Exit "IGCM_config_PeriodStart " ${config_UserChoices_PeriodLength} " invalid period length : choose in 1Y, 1M, 5D, 1D."
213                IGCM_debug_Verif_Exit ;;
214        esac
215
216        eval PeriodDateBegin=${DateBegin} > /dev/null 2>&1
217        PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $( expr ${PeriodLengthInDays} - 1 ) )
218        eval CumulPeriod=1 > /dev/null 2>&1
219
220        #=================================================#
221        #        Creation and write updated run.card      #
222        #=================================================#
223
224        #Correct run.card Configuration for this period
225        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin}
226        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd}
227        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod}
228        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running"
229 
230    else
231        #================================================#
232        #         The file run.card allready exist       #
233        #================================================#
234
235        eval FirstInitialize=false
236
237        #Test state of run in run.card
238        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
239        if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
240            echo
241            IGCM_debug_Print 1 "!!!!!! IGCM_config_PeriodStart Error PeriodState : " ${run_Configuration_PeriodState} "!!!!!!!!!!"
242            echo
243            IGCM_debug_Exit "IGCM_config_PeriodStart Error PeriodState : " ${run_Configuration_PeriodState}
244            IGCM_debug_Verif_Exit
245        fi
246
247        #===================================#
248        #        Read updated run.card      #
249        #===================================#
250
251        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix
252        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin
253        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd
254        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod
255
256        PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} )
257        PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} )
258        eval CumulPeriod="${run_Configuration_CumulPeriod}" > /dev/null 2>&1
259
260        if [ ${Period} = 1 ]; then
261           # save last Job output
262            typeset LastPeriod Last_Script_Output_Name
263            (( LastPeriod=CumulPeriod-PeriodNb ))
264            Last_Script_Output_Name="${Script_Output_Prefix}_${config_UserChoices_JobName}.${LastPeriod}"
265            #eval ls -l ${SUBMIT_DIR}/${Last_Script_Output_Name}
266            #eval IGCM_sys_Put_Out ${SUBMIT_DIR}/${Last_Script_Output_Name} ${R_OUT_KSH}/${Last_Script_Output_Name} > /dev/null 2>&1
267            IGCM_debug_Print 1 "Try to save previous ksh job output"
268            IGCM_sys_Cd ${SUBMIT_DIR}/
269            IGCM_sys_Put_Out ${Last_Script_Output_Name} ${R_OUT_KSH}/
270            IGCM_sys_Cd ${RUN_DIR}
271        else
272            unset FileToBeDeleted
273        fi
274
275        IGCM_date_GetYearMonth $PeriodDateBegin year month
276
277        # Determine number of day(s) in PeriodLength :
278        case ${config_UserChoices_PeriodLength} in
279            1Y|1y) 
280                (( PeriodLengthInDays = $( IGCM_date_DaysInYear $year ) )) ;;
281            1M|1m) 
282                (( PeriodLengthInDays = $( IGCM_date_DaysInMonth $year $month ) )) ;;
283            5D|5d) 
284                (( PeriodLengthInDays=5 )) ;;
285            1D|1d) 
286                (( PeriodLengthInDays=1 )) ;;
287            *) 
288                IGCM_debug_Exit "IGCM_config_PeriodStart " ${config_UserChoices_PeriodLength} " invalid period length : choose in 1Y, 1M, 5D, 1D."
289                IGCM_debug_Verif_Exit ;;
290        esac
291
292        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running"
293
294    fi   
295    OldPrefix=${config_UserChoices_JobName}_${PeriodDateEnd}
296 
297    #===================================================================#
298    # Prepare variables available for ${COMP}.card and ${COMP}.driver   #
299    #             But available to any son functions                    #
300    #===================================================================#
301
302    # Period Length In Days between DateBegin and DateCurrent (at end of period == PeriodDateEnd !)
303    (( SimulationLengthInDays = $( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateBegin} ) + 1 ))
304
305    # Debug Print :
306    IGCM_debug_Print 1 "IGCM_config_PeriodStart : Before Execution"
307    IGCM_debug_Print 3 "Year of simulation      : ${year}"
308    IGCM_debug_Print 3 "Month of simulation     : ${month}"
309    IGCM_debug_Print 3 "PeriodLengthInDays      : ${PeriodLengthInDays}"
310    IGCM_debug_Print 3 "PeriodDateBegin         : ${PeriodDateBegin}"
311    IGCM_debug_Print 3 "PeriodDateEnd           : ${PeriodDateEnd}"
312    IGCM_debug_Print 3 "SimulationLengthInDays  : ${SimulationLengthInDays}"
313    IGCM_debug_Print 3 "ExperienceLengthInDays  : ${ExperienceLengthInDays}"
314
315    #================================================================#
316    #         Prepare variables available for comp_finalyze          #
317    #================================================================#
318
319    # Period for save files
320    eval DatesPeriod=${PeriodDateBegin}_${PeriodDateEnd} > /dev/null 2>&1
321
322    # Prefix for save files of this period
323    eval PREFIX=${config_UserChoices_JobName}_${DatesPeriod}  > /dev/null 2>&1
324
325    # List of files that will be deleted in RUN_DIR after run
326    FileToBeDeleted[0]="stack"
327
328    # Test if the same run as already been saved :
329    if [ ${DRYRUN} -le 0 ] ; then
330        if ( IGCM_sys_TestFileArchive ${R_OUT_KSH}/${PREFIX}_${Exe_Output} ) ; then
331            IGCM_debug_Exit "IGCM_config_PeriodStart" "RErun an old job."
332            IGCM_debug_Print 1 "Because of readonly permissions, you can't RErun a job when saved files"
333            IGCM_debug_Print 1 " are still in the ARCHIVE directory. You must deleted those files, or "
334            IGCM_debug_Print 1 " the whole ${R_SAVE} tree."
335            IGCM_debug_Verif_Exit
336        fi
337    fi
338    IGCM_debug_PopStack "IGCM_config_PeriodStart"
339}
340
341#===================================
342function IGCM_config_PeriodEnd
343{
344    IGCM_debug_PushStack "IGCM_config_PeriodEnd"
345
346    echo
347    IGCM_debug_Print 1 "IGCM_config_PeriodEnd :"
348    echo
349
350    #==================================#
351    #         Save Job output          #
352    #==================================#
353    IGCM_sys_Put_Out ${Exe_Output} ${R_OUT_KSH}/${PREFIX}_${Exe_Output}
354    eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}"
355
356    typeset LS_comp LS_bin ExeDate ExeCpuLog ExeSize NextExeSize LastCompExeSize
357    typeset comp i   
358    typeset ExeNameIn ExeNameOut
359
360    #==================================#
361    #        Get last Exe Size         #
362    #==================================#
363
364    (( i=0 ))
365    if ( ${FirstInitialize} ) ; then
366        run_Log_LastExeSize=""
367        for comp in ${config_ListOfComponents[*]} ; do
368            run_Log_LastExeSize[$i]=0
369            (( i=i+1 ))
370        done
371    else
372        IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/run.card Log LastExeSize
373    fi
374
375    #==================================#
376    #         And Build ExeDate        #
377    #==================================#
378
379    # ExeDate = ATM_Jun_12_09:34-SRF_Jun_12_09:34-OCE_Jun_12_09:34-ICE_Jun_12_09:34-CPL_Jun_12_09:33
380    ExeDate=""
381    NextExeSize="( "
382    (( i=0 ))
383
384    for comp in ${config_ListOfComponents[*]} ; do
385
386        IGCM_debug_Print 1 ${comp}
387
388        eval ExeNameIn=\${config_Executable_${comp}[0]}
389        eval ExeNameOut=\${config_Executable_${comp}[1]}
390        if [ X${ExeNameIn} = X\"\" ] ; then
391            # If there is no exe file for this component
392            (( ExeSize=0 ))
393        else
394            eval LS_bin=${R_EXE}/${ExeNameIn}
395            IGCM_sys_FileSize ${LS_bin} ExeSize
396
397            set +A LS_comp -- $( ls -l ${LS_bin} )
398            if [ X${ExeDate} = X ] ; then 
399                # First component exe date
400                ExeDate=${comp}_${LS_comp[5]}_${LS_comp[6]}
401            else
402                ExeDate=${ExeDate}-${comp}_${LS_comp[5]}_${LS_comp[6]}
403            fi
404            ExeDate=${ExeDate}_${LS_comp[7]}
405
406            eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${ExeNameOut}
407        fi
408
409        if [ ${i} -eq 0 ] ; then
410            # First component
411            NextExeSize="( "${ExeSize}
412        else
413            NextExeSize=${NextExeSize}", "${ExeSize}
414        fi
415        eval LastCompExeSize=${run_Log_LastExeSize[$i]}
416        (( i=i+1 ))
417
418        if [ ${ExeSize} -ne ${LastCompExeSize} ] ; then
419            if ( ${FirstInitialize} ) ; then
420                IGCM_debug_Print 1 "Put first ${ExeNameIn} in ${R_OUT_EXE} !"
421            else
422                IGCM_debug_Print 1 "${ExeNameIn} has changed in ${R_EXE} !"
423            fi
424            eval IGCM_sys_Put_Out ${ExeNameOut} ${R_OUT_EXE}/${PREFIX}_${ExeNameIn}
425        fi
426    done
427
428    if [ ${DRYRUN} -le 1 ] ; then
429        typeset ExeCpuLog
430        tail -1500 ${Exe_Output} > ${Exe_Output}_tail.txt
431        ExeCpuLog=$( ${libIGCM}/libIGCM_sys/IGCM_add_out.awk ${Exe_Output}_tail.txt )
432        RET=$?
433        if [ $RET -eq 0 ] ; then
434            echo "("${CumulPeriod} " , " ${PeriodDateBegin} " , " ${PeriodDateEnd} \
435                " , " ${ExeCpuLog} " , "             ${ExeDate}") \\" >> ${SUBMIT_DIR}/run.card
436        fi
437        eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}_tail.txt"
438    fi
439
440    NextExeSize=${NextExeSize}" )"
441    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Log LastExeSize "${NextExeSize}"
442
443    # All was right ? no ? then we stop.
444    IGCM_debug_Verif_Exit
445
446    # If all was OK, we can delete all files not necessary for next Job
447    echo "Files that will be deleted before next period-run : "
448
449    if [ ${DRYRUN} -le 2 ] ; then
450        eval ls -la ${FileToBeDeleted[@]}
451        eval rm -f ${FileToBeDeleted[@]}
452    else
453        echo ${FileToBeDeleted[@]}
454    fi
455
456    #=================================================#
457    #         Determine next computed period          #
458    #=================================================#
459
460    PeriodDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} 1 )
461    IGCM_date_GetYearMonth $PeriodDateBegin year month
462
463    # Determine number of day(s) in PeriodLength :
464    case ${config_UserChoices_PeriodLength} in
465        1Y|1y) PeriodLengthInDays=$( expr $( IGCM_date_DaysInYear $year ) ) ;;
466        1M|1m) PeriodLengthInDays=$( expr $( IGCM_date_DaysInMonth $year $month ) ) ;;
467        5D|5d) PeriodLengthInDays=$( expr 5 ) ;;
468        1D|1d) PeriodLengthInDays=$( expr 1 ) ;;
469    esac
470    PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateBegin} $( expr ${PeriodLengthInDays} - 1 ) )
471
472    # Debug Print :
473    echo
474    IGCM_debug_Print 1 "IGCM_config_PeriodEnd : Preparing Next Execution"
475    IGCM_debug_Print 3 "PeriodDateBegin       : ${PeriodDateBegin}"
476    IGCM_debug_Print 3 "PeriodDateEnd         : ${PeriodDateEnd}"
477    IGCM_debug_Print 3 "PeriodLengthInDays    : ${PeriodLengthInDays}"
478
479    PeriodDateBegin=$( IGCM_date_ConvertFormatToHuman ${PeriodDateBegin} )
480    PeriodDateEnd=$( IGCM_date_ConvertFormatToHuman ${PeriodDateEnd} )
481
482    (( CumulPeriod = CumulPeriod + 1 ))
483
484    # Debug Print :
485    echo
486    IGCM_debug_Print 3 "PeriodDateBegin Human : ${PeriodDateBegin}"
487    IGCM_debug_Print 3 "PeriodDateEnd Human   : ${PeriodDateEnd}"
488    IGCM_debug_Print 3 "CumulPeriod           : ${CumulPeriod}"
489
490    #=================================================#
491    #             Write updated run.card              #
492    #=================================================#
493
494    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration OldPrefix ${OldPrefix}
495    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin}
496    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd}
497    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod}
498
499    IGCM_debug_PopStack "IGCM_config_PeriodEnd"
500}
501
502#===================================
503function IGCM_config_Finalize
504{
505    IGCM_debug_PushStack "IGCM_config_Finalize"
506
507    echo
508    IGCM_debug_Print 1 "IGCM_config_Finalize :"
509    echo
510
511    # Supress Non Deleted Boundary files
512    if [ ${DRYRUN} -le 2 ] ; then
513        IGCM_comp_DelFixeBoundaryFiles
514        ls -la
515    fi
516
517    if [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ; then
518
519        #==========================#
520        # End of entire simulation #
521        #==========================#
522
523        cat  << END_MAIL > job_atlas.mail
524Dear ${LOGIN},
525
526  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
527  Job started : ${DateBegin}
528  Job ended   : ${DateEnd}
529  Ouput files are available in ${R_SAVE}
530END_MAIL
531
532        mailx -s "${config_UserChoices_JobName} completed" ${USER} < job_atlas.mail
533        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Completed"
534        IGCM_debug_Print 1 "Normal End of computation."
535        if ( $DEBUG_debug ) ; then
536            echo
537            IGCM_debug_Print 1 "Your files on ${R_OUT} :"
538            IGCM_sys_Tree ${R_SAVE}
539        fi
540    else
541
542        #=================#
543        # Submit next job #
544        #=================#
545
546        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue"
547        typeset -x DEBUG_debug=false
548
549        # Name of next Ksh Script output :
550        eval Script_Output="${Script_Output_Prefix}_${config_UserChoices_JobName}.${CumulPeriod}"
551
552        IGCM_debug_Print 1 "Submit next job"
553        # SUBMITTED NEXT JOB
554        IGCM_sys_Cd ${SUBMIT_DIR}
555        IGCM_sys_Qsub ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}
556    fi
557
558    IGCM_debug_PopStack "IGCM_config_Finalize"
559}
560
561#===================================
Note: See TracBrowser for help on using the repository browser.