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

Last change on this file since 5 was 5, checked in by mmaipsl, 16 years ago

MM: correct Date, Author and Revision svn properties.

  • 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.7 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    #================================================================#
121    #                  Test and Prepare directories                  #
122    #================================================================#
123
124    # ==> 4 kinds of input files :
125    #     1) R_INIT  : Initial State Files   (Etat0, carteveg)
126    #     2) R_BC    : Boundary Conditions   (Forcages, lai)
127    #     3) Parameters files (allready define through ${SUBMIT_DIR})
128    #     4) Restarts files   (allready define in IGCM_config_Initialize)
129
130    # Here we offer the possibility to redefine R_INIT, R_BC
131    # and PeriodNb through config.card
132    R_INIT=${config_UserChoices_R_INIT:=${R_IN}/INIT}
133    echo
134    IGCM_debug_Print 1 "(Re)Define R_INIT, R_BC and PeriodNb"
135    IGCM_debug_Print 3 "R_INIT=${R_INIT}"
136    R_BC=${config_UserChoices_R_BC:=${R_IN}/BC}
137    IGCM_debug_Print 3  "R_BC=${R_BC}"
138    PeriodNb=${config_UserChoices_PeriodNb:=${PeriodNb}}
139    IGCM_debug_Print 3  "Loop in main Job with ${PeriodNb} period(s)"
140
141    # Test Archive input/output.
142    IGCM_sys_TestDirArchive ${ARCHIVE}
143    IGCM_sys_TestDirArchive ${R_INIT}
144    IGCM_sys_TestDirArchive ${R_BC}
145
146    #====================================================
147    #R_SAVE : Job output directory
148    R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
149
150    if [ ! -f ${SUBMIT_DIR}/run.card ]; then
151        IGCM_sys_MkdirArchive ${R_SAVE}
152    else
153        #Test state of run in run.card
154        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
155        if ( [ ${run_Configuration_PeriodState} != "Start" ] && [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
156            echo
157            IGCM_debug_Print 1 "!!!! IGCM_config_Initialize Error PeriodState : " ${run_Configuration_PeriodState} "!!!!!!!!!!"
158            echo
159            IGCM_debug_Exit "IGCM_config_Initialize Error PeriodState : " ${run_Configuration_PeriodState}
160            IGCM_debug_Verif_Exit
161        fi
162    fi
163    IGCM_sys_TestDirArchive ${R_SAVE}
164
165    #====================================================
166    #R_OUT_KSH : Storage place for job output
167    #R_OUT_EXE : Storage place for binary used during simulation
168    R_OUT_KSH=${R_SAVE}/Out
169    R_OUT_EXE=${R_SAVE}/Exe
170
171    IGCM_debug_PopStack "IGCM_config_Initialize"
172}
173
174#===================================
175function IGCM_config_PeriodStart
176{
177    IGCM_debug_PushStack "IGCM_config_PeriodStart"
178
179    echo
180    IGCM_debug_Print 1 "IGCM_config_PeriodStart :"
181    echo
182
183    if [ ! -r ${SUBMIT_DIR}/run.card ]; then 
184
185        #================================================#
186        #         The file run.card doesn't exist        #
187        #================================================#
188
189        eval FirstInitialize=true
190
191        #copy initial run.card
192        IGCM_sys_Cp ${SUBMIT_DIR}/run.card.init ${SUBMIT_DIR}/run.card
193
194        IGCM_date_GetYearMonth $DateBegin year month
195
196        case ${config_UserChoices_PeriodLength} in
197            1Y|1y) 
198                (( PeriodLengthInDays = $( IGCM_date_DaysInYear $year ) )) ;;
199            1M|1m) 
200                (( PeriodLengthInDays = $( IGCM_date_DaysInMonth $year $month ) )) ;;
201            5D|5d) 
202                (( PeriodLengthInDays = 5 )) ;;
203            1D|1d) 
204                (( PeriodLengthInDays = 1 )) ;;
205            *) 
206                IGCM_debug_Exit "IGCM_config_PeriodStart " ${config_UserChoices_PeriodLength} " invalid period length :  $
207                IGCM_debug_Verif_Exit ;;
208        esac
209
210        eval PeriodDateBegin=${DateBegin} > /dev/null 2>&1
211        PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $( expr ${PeriodLengthInDays} - 1 ) )
212        eval CumulPeriod=1 > /dev/null 2>&1
213
214        #=================================================#
215        #        Creation and write updated run.card      #
216        #=================================================#
217
218        #Correct run.card Configuration for this period
219        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin}
220        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd}
221        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod}
222        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running"
223 
224    else
225        #================================================#
226        #         The file run.card allready exist       #
227        #================================================#
228
229        eval FirstInitialize=false
230
231        #Test state of run in run.card
232        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
233        if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
234            echo
235            IGCM_debug_Print 1 "!!!!!! IGCM_config_PeriodStart Error PeriodState : " ${run_Configuration_PeriodState} "!!!!!!!!!!"
236            echo
237            IGCM_debug_Exit "IGCM_config_PeriodStart Error PeriodState : " ${run_Configuration_PeriodState}
238            IGCM_debug_Verif_Exit
239        fi
240
241        #===================================#
242        #        Read updated run.card      #
243        #===================================#
244
245        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix
246        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin
247        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd
248        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod
249
250        PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} )
251        PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} )
252        eval CumulPeriod="${run_Configuration_CumulPeriod}" > /dev/null 2>&1
253
254        if [ ${Period} = 1 ]; then
255           # save last Job output
256            typeset LastPeriod Last_Script_Output_Name
257            (( LastPeriod=CumulPeriod-PeriodNb ))
258            Last_Script_Output_Name="${Script_Output_Prefix}_${config_UserChoices_JobName}.${LastPeriod}"
259            #eval ls -l ${SUBMIT_DIR}/${Last_Script_Output_Name}
260            #eval IGCM_sys_Put_Out ${SUBMIT_DIR}/${Last_Script_Output_Name} ${R_OUT_KSH}/${Last_Script_Output_Name} > /dev/null 2>&1
261            IGCM_debug_Print 1 "Try to save previous ksh job output"
262            IGCM_sys_Cd ${SUBMIT_DIR}/
263            IGCM_sys_Put_Out ${Last_Script_Output_Name} ${R_OUT_KSH}/
264            IGCM_sys_Cd ${RUN_DIR}
265        else
266            unset FileToBeDeleted
267        fi
268
269        IGCM_date_GetYearMonth $PeriodDateBegin year month
270
271        # Determine number of day(s) in PeriodLength :
272        case ${config_UserChoices_PeriodLength} in
273            1Y|1y)
274                (( PeriodLengthInDays = $( IGCM_date_DaysInYear $year ) )) ;;
275            1M|1m)
276                (( PeriodLengthInDays = $( IGCM_date_DaysInMonth $year $month ) )) ;;
277            5D|5d)
278                (( PeriodLengthInDays=5 )) ;;
279            1D|1d)
280                (( PeriodLengthInDays=1 )) ;;
281            *)
282                IGCM_debug_Exit "IGCM_config_PeriodStart " ${config_UserChoices_PeriodLength} " invalid period length : choose in 1Y, 1M, 5D, 1D."
283                IGCM_debug_Verif_Exit ;;
284        esac
285
286        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running"
287
288    fi   
289    OldPrefix=${config_UserChoices_JobName}_${PeriodDateEnd}
290 
291    #===================================================================#
292    # Prepare variables available for ${COMP}.card and ${COMP}.driver   #
293    #             But available to any son functions                    #
294    #===================================================================#
295
296    # Period Length In Days between DateBegin and DateCurrent (at end of period == PeriodDateEnd !)
297    (( SimulationLengthInDays = $( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateBegin} ) + 1 ))
298
299    # Debug Print :
300    IGCM_debug_Print 1 "IGCM_config_PeriodStart : Before Execution"
301    IGCM_debug_Print 3 "Year of simulation      : ${year}"
302    IGCM_debug_Print 3 "Month of simulation     : ${month}"
303    IGCM_debug_Print 3 "PeriodLengthInDays      : ${PeriodLengthInDays}"
304    IGCM_debug_Print 3 "PeriodDateBegin         : ${PeriodDateBegin}"
305    IGCM_debug_Print 3 "PeriodDateEnd           : ${PeriodDateEnd}"
306    IGCM_debug_Print 3 "SimulationLengthInDays  : ${SimulationLengthInDays}"
307    IGCM_debug_Print 3 "ExperienceLengthInDays  : ${ExperienceLengthInDays}"
308
309    #================================================================#
310    #         Prepare variables available for comp_finalyze          #
311    #================================================================#
312
313    # Period for save files
314    eval DatesPeriod=${PeriodDateBegin}_${PeriodDateEnd} > /dev/null 2>&1
315
316    # Prefix for save files of this period
317    eval PREFIX=${config_UserChoices_JobName}_${DatesPeriod}  > /dev/null 2>&1
318
319    # List of files that will be deleted in RUN_DIR after run
320    FileToBeDeleted[0]="stack"
321
322    # Test if the same run as already been saved :
323    if [ ${DRYRUN} -le 0 ] ; then
324        if ( IGCM_sys_TestFileArchive ${R_OUT_KSH}/${PREFIX}_${Exe_Output} ) ; then
325            IGCM_debug_Exit "IGCM_config_PeriodStart" "RErun an old job."
326            IGCM_debug_Print 1 "Because of readonly permissions, you can't RErun a job when saved files"
327            IGCM_debug_Print 1 " are still in the ARCHIVE directory. You must deleted those files, or "
328            IGCM_debug_Print 1 " the whole ${R_SAVE} tree."
329            IGCM_debug_Verif_Exit
330        fi
331    fi
332    IGCM_debug_PopStack "IGCM_config_PeriodStart"
333}
334
335#===================================
336function IGCM_config_PeriodEnd
337{
338    IGCM_debug_PushStack "IGCM_config_PeriodEnd"
339
340    echo
341    IGCM_debug_Print 1 "IGCM_config_PeriodEnd :"
342    echo
343
344    #==================================#
345    #         Save Job output          #
346    #==================================#
347    IGCM_sys_Put_Out ${Exe_Output} ${R_OUT_KSH}/${PREFIX}_${Exe_Output}
348    eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}"
349
350    typeset LS_comp LS_bin ExeDate ExeCpuLog ExeSize NextExeSize LastCompExeSize
351    typeset comp i   
352    typeset ExeNameIn ExeNameOut
353
354    #==================================#
355    #        Get last Exe Size         #
356    #==================================#
357
358    (( i=0 ))
359    if ( ${FirstInitialize} ) ; then
360        run_Log_LastExeSize=""
361        for comp in ${config_ListOfComponents[*]} ; do
362            run_Log_LastExeSize[$i]=0
363            (( i=i+1 ))
364        done
365    else
366        IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/run.card Log LastExeSize
367    fi
368
369    #==================================#
370    #         And Build ExeDate        #
371    #==================================#
372
373    # 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
374    ExeDate=""
375    NextExeSize="( "
376    (( i=0 ))
377
378    for comp in ${config_ListOfComponents[*]} ; do
379
380        IGCM_debug_Print 1 ${comp}
381
382        eval ExeNameIn=\${config_Executable_${comp}[0]}
383        eval ExeNameOut=\${config_Executable_${comp}[1]}
384        if [ X${ExeNameIn} = X\"\" ] ; then
385            # If there is no exe file for this component
386            (( ExeSize=0 ))
387        else
388            eval LS_bin=${R_EXE}/${ExeNameIn}
389            IGCM_sys_FileSize ${LS_bin} ExeSize
390
391            set +A LS_comp -- $( ls -l ${LS_bin} )
392            if [ X${ExeDate} = X ] ; then
393                # First component exe date
394                ExeDate=${comp}_${LS_comp[5]}_${LS_comp[6]}
395            else
396                ExeDate=${ExeDate}-${comp}_${LS_comp[5]}_${LS_comp[6]}
397            fi
398            ExeDate=${ExeDate}_${LS_comp[7]}
399
400            eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${ExeNameOut}
401        fi
402
403        if [ ${i} -eq 0 ] ; then
404            # First component
405            NextExeSize="( "${ExeSize}
406        else
407            NextExeSize=${NextExeSize}", "${ExeSize}
408        fi
409        eval LastCompExeSize=${run_Log_LastExeSize[$i]}
410        (( i=i+1 ))
411
412        if [ ${ExeSize} -ne ${LastCompExeSize} ] ; then
413            if ( ${FirstInitialize} ) ; then
414                IGCM_debug_Print 1 "Put first ${ExeNameIn} in ${R_OUT_EXE} !"
415            else
416                IGCM_debug_Print 1 "${ExeNameIn} has changed in ${R_EXE} !"
417            fi
418            eval IGCM_sys_Put_Out ${ExeNameOut} ${R_OUT_EXE}/${PREFIX}_${ExeNameIn}
419        fi
420    done
421
422    if [ ${DRYRUN} -le 1 ] ; then
423        typeset ExeCpuLog
424        tail -1500 ${Exe_Output} > ${Exe_Output}_tail.txt
425        ExeCpuLog=$( ${libIGCM}/libIGCM_sys/IGCM_add_out.awk ${Exe_Output}_tail.txt )
426        RET=$?
427        if [ $RET -eq 0 ] ; then
428            echo "("${CumulPeriod} " , " ${PeriodDateBegin} " , " ${PeriodDateEnd} \
429                " , " ${ExeCpuLog} " , "             ${ExeDate}") \\" >> ${SUBMIT_DIR}/run.card
430        fi
431        eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}_tail.txt"
432    fi
433
434    NextExeSize=${NextExeSize}" )"
435    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Log LastExeSize "${NextExeSize}"
436
437    # All was right ? no ? then we stop.
438    IGCM_debug_Verif_Exit
439
440    # If all was OK, we can delete all files not necessary for next Job
441    echo "Files that will be deleted before next period-run : "
442
443    if [ ${DRYRUN} -le 2 ] ; then
444        eval ls -la ${FileToBeDeleted[@]}
445        eval rm -f ${FileToBeDeleted[@]}
446    else
447        echo ${FileToBeDeleted[@]}
448    fi
449
450    #=================================================#
451    #         Determine next computed period          #
452    #=================================================#
453
454    PeriodDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} 1 )
455    IGCM_date_GetYearMonth $PeriodDateBegin year month
456
457    # Determine number of day(s) in PeriodLength :
458    case ${config_UserChoices_PeriodLength} in
459        1Y|1y) PeriodLengthInDays=$( expr $( IGCM_date_DaysInYear $year ) ) ;;
460        1M|1m) PeriodLengthInDays=$( expr $( IGCM_date_DaysInMonth $year $month ) ) ;;
461        5D|5d) PeriodLengthInDays=$( expr 5 ) ;;
462        1D|1d) PeriodLengthInDays=$( expr 1 ) ;;
463    esac
464    PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateBegin} $( expr ${PeriodLengthInDays} - 1 ) )
465
466    # Debug Print :
467    echo
468    IGCM_debug_Print 1 "IGCM_config_PeriodEnd : Preparing Next Execution"
469    IGCM_debug_Print 3 "PeriodDateBegin       : ${PeriodDateBegin}"
470    IGCM_debug_Print 3 "PeriodDateEnd         : ${PeriodDateEnd}"
471    IGCM_debug_Print 3 "PeriodLengthInDays    : ${PeriodLengthInDays}"
472
473    PeriodDateBegin=$( IGCM_date_ConvertFormatToHuman ${PeriodDateBegin} )
474    PeriodDateEnd=$( IGCM_date_ConvertFormatToHuman ${PeriodDateEnd} )
475
476    (( CumulPeriod = CumulPeriod + 1 ))
477
478    # Debug Print :
479    echo
480    IGCM_debug_Print 3 "PeriodDateBegin Human : ${PeriodDateBegin}"
481    IGCM_debug_Print 3 "PeriodDateEnd Human   : ${PeriodDateEnd}"
482    IGCM_debug_Print 3 "CumulPeriod           : ${CumulPeriod}"
483
484    #=================================================#
485    #             Write updated run.card              #
486    #=================================================#
487
488    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration OldPrefix ${OldPrefix}
489    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin}
490    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd}
491    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod}
492
493    IGCM_debug_PopStack "IGCM_config_PeriodEnd"
494}
495
496#===================================
497function IGCM_config_Finalize
498{
499    IGCM_debug_PushStack "IGCM_config_Finalize"
500
501    echo
502    IGCM_debug_Print 1 "IGCM_config_Finalize :"
503    echo
504
505    # Supress Non Deleted Boundary files
506    if [ ${DRYRUN} -le 2 ] ; then
507        IGCM_comp_DelFixeBoundaryFiles
508        ls -la
509    fi
510
511    if [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ; then
512
513        #==========================#
514        # End of entire simulation #
515        #==========================#
516
517        cat  << END_MAIL > job_atlas.mail
518Dear ${LOGIN},
519
520  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
521  Job started : ${DateBegin}
522  Job ended   : ${DateEnd}
523  Ouput files are available in ${R_SAVE}
524END_MAIL
525
526        mailx -s "${config_UserChoices_JobName} completed" ${USER} < job_atlas.mail
527        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Completed"
528        IGCM_debug_Print 1 "Normal End of computation."
529        if ( $DEBUG_debug ) ; then
530            echo
531            IGCM_debug_Print 1 "Your files on ${R_OUT} :"
532            IGCM_sys_Tree ${R_SAVE}
533        fi
534    else
535
536        #=================#
537        # Submit next job #
538        #=================#
539
540        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue"
541        typeset -x DEBUG_debug=false
542
543        # Name of next Ksh Script output :
544        eval Script_Output="${Script_Output_Prefix}_${config_UserChoices_JobName}.${CumulPeriod}"
545
546        IGCM_debug_Print 1 "Submit next job"
547        # SUBMITTED NEXT JOB
548        IGCM_sys_Cd ${SUBMIT_DIR}
549        IGCM_sys_Qsub ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}
550    fi
551
552    IGCM_debug_PopStack "IGCM_config_Finalize"
553}
554
555#===================================
Note: See TracBrowser for help on using the repository browser.