source: tags/ORCHIDEE_1_9_6/ORCHIDEE_OL/OOL_SEC_STO/COMP/stomate.driver @ 3663

Last change on this file since 3663 was 865, checked in by didier.solyga, 12 years ago

New scripts compatible the externalization done for OOL_SEC, OOL_SEC_STO, FORCESOIL, TESTSTOMATE and SPINUP configurations. These scripts use an unique empty run.def.

File size: 3.7 KB
Line 
1#!/bin/ksh
2
3#D- Driver du script pour STOMATE
4
5#-----------------------------------------------------------------
6function SBG_Initialize
7{
8    IGCM_debug_PushStack "SBG_Initialize"
9
10    RESOL_SBG=ALL
11
12    typeset frequency
13    for frequency in ${config_SBG_WriteFrequency} ; do
14        case ${frequency} in
15            HF|hf) SBG_ok_hf=y ;;
16        esac
17    done
18   
19    IGCM_debug_PopStack "SBG_Initialize"
20}
21
22#-----------------------------------------------------------------
23function SBG_PeriodStart
24{
25    IGCM_debug_PushStack "SBG_PeriodStart"
26
27    IGCM_debug_PopStack "SBG_PeriodStart"
28}
29
30#-----------------------------------------------------------------
31function SBG_Update
32{
33    IGCM_debug_PushStack "SBG_Update"
34
35    typeset STOMATE_WRITE_STEP
36
37    case ${config_SBG_WriteFrequency} in
38        *Y|*y) 
39            WriteInYears=$( echo ${config_SBG_WriteFrequency} | awk -F '[yY]' '{print $1}' )
40            PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
41            (( STOMATE_WRITE_STEP = PeriodLengthInDays * WriteInYears / PeriodLengthInYears )) ;;
42        1M|1m) 
43            case ${config_UserChoices_PeriodLength} in
44            *Y|*y)
45                STOMATE_WRITE_STEP=-1.
46                ;;
47            *M|*m)
48                STOMATE_WRITE_STEP=-1.
49                ;;
50            *)
51                (( STOMATE_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) )) ;;
52            esac
53            ;;
54        *M|*m) 
55            WriteInMonths=$( echo ${config_SBG_WriteFrequency} | awk -F '[mM]' '{print $1}' )
56            case ${config_UserChoices_PeriodLength} in
57            *Y|*y)
58                PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
59                (( STOMATE_WRITE_STEP = 30 )) ;;
60            *M|*m)
61                PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' )
62                (( STOMATE_WRITE_STEP = PeriodLengthInDays * WriteInMonths / PeriodLengthInMonths )) ;;
63            *)
64                (( STOMATE_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) )) ;;
65            esac
66            ;;
67        5D|5d) 
68            (( STOMATE_WRITE_STEP = 5 )) ;;
69        1D|1d) 
70            (( STOMATE_WRITE_STEP = 1 )) ;;
71        *s)
72            WriteInSeconds=$( echo ${config_SBG_WriteFrequency} | awk -F '[s]' '{print $1}' )
73            (( STOMATE_WRITE_STEP = 1 )) ;;
74        *) 
75            IGCM_debug_Exit "SBG_Update " ${config_SBG_WriteFrequency} " invalid WriteFrequency : choose in 1Y, 1M, 5D, 1D." 
76            IGCM_debug_Verif_Exit ;;
77    esac
78
79    ORCHIDEE_def STOMATE_OK_STOMATE y
80
81    ORCHIDEE_def STOMATE_HIST_DT ${STOMATE_WRITE_STEP}
82    ORCHIDEE_def STOMATE_HISTLEVEL ${stomate_UserChoices_stomate_LEVEL}
83    if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SBG_Restart}" = "n" ] ) ; then
84        echo "STOMATE : without restart"
85    else
86        ORCHIDEE_def STOMATE_RESTART_FILEIN stomate_rest_in.nc
87    fi
88
89    if [ X${SBG_ok_hf} = Xy ] ; then
90        ORCHIDEE_def STOMATE_IPCC_HIST_DT 1D
91    else
92        ORCHIDEE_def STOMATE_IPCC_HIST_DT ${STOMATE_WRITE_STEP}
93    fi
94
95    ORCHIDEE_def STOMATE_FORCING_NAME stomate_forcing.nc
96    ORCHIDEE_def STOMATE_CFORCING_NAME stomate_Cforcing.nc
97
98    IGCM_debug_PopStack "SBG_Update"
99}
100
101#-----------------------------------------------------------------
102function SBG_Finalize
103{
104    IGCM_debug_PushStack "SBG_Finalize"
105
106    typeset NbDaysDone NbYearsDone
107
108#     NbDaysDone=$( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateBegin} )
109#     NbYearsDone=$(( NbDaysDone / 360 ))
110   
111#     echo $NbDaysDone, $NbYearsDone, $(( NbYearsDone % 10 ))
112#    if [ $(( NbYearsDone % 10 )) = 0 ] ; then
113    if [ $( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateEnd} ) -ge 0 ] ; then
114        IGCM_sys_Put_Out stomate_Cforcing.nc ${R_OUT_SBG_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_stomate_Cforcing.nc
115        IGCM_sys_Put_Out stomate_forcing.nc  ${R_OUT_SBG_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_stomate_forcing.nc
116        rm -f stomate_Cforcing.nc
117        rm -f stomate_forcing.nc
118    fi
119
120    IGCM_debug_PopStack "SBG_Finalize"
121}
Note: See TracBrowser for help on using the repository browser.