source: tags/ORCHIDEE_1_9_6/ORCHIDEE_OL/OOL_SEC_STO/COMP/sechiba.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.

  • Property svn:executable set to *
File size: 5.5 KB
Line 
1#!/bin/ksh
2
3#D- Driver du script pour SECHIBA
4
5#-----------------------------------------------------------------
6function SRF_Initialize
7{
8    IGCM_debug_PushStack "SRF_Initialize"
9
10    echo "ORCHIDEE Tag : " ${config_UserChoices_TagName}
11
12    RESOL_SRF=ALL
13   
14    typeset frequency
15    for frequency in ${config_SRF_WriteFrequency} ; do
16        case ${frequency} in
17            HF|hf) SRF_ok_hf=y ;;
18        esac
19    done
20
21    if [ X${sechiba_UserChoices_LAND_USE} = Xy ] ; then
22      sed -e 's&#List=\(.*\)PFTmap\(.*\)year_p1\(.*\)&List=\1PFTmap\2year_p1\3&' ${SUBMIT_DIR}/COMP/sechiba.card > sechiba.card.tmp
23      IGCM_sys_Mv sechiba.card.tmp ${SUBMIT_DIR}/COMP/sechiba.card
24    fi
25
26    if [ X${sechiba_UserChoices_IMPOSE_VEG} = Xy ] ; then
27      sed -e 's&\(List.*=\)*\([[:space:]]*(*\).*PFTmap.*\${year}.*.nc,.*)&\1\2)&' ${SUBMIT_DIR}/COMP/sechiba.card > sechiba.card.tmp
28      IGCM_sys_Mv sechiba.card.tmp ${SUBMIT_DIR}/COMP/sechiba.card
29    fi
30
31    IGCM_debug_PopStack "SRF_Initialize"
32}
33
34#-----------------------------------------------------------------
35# Optionnal function executed at the beginning of the main loop,
36# after IGCM_config_PeriodStart see libIGCM/AA_job.
37# It may be used to set special variables used in forward lists
38function SRF_PeriodStart
39{
40    IGCM_debug_PushStack "SRF_PeriodStart"
41    IGCM_debug_PopStack "SRF_PeriodStart"
42}
43
44#-----------------------------------------------------------------
45function SRF_Update
46{
47    IGCM_debug_PushStack "SRF_Update"
48
49    typeset SECHIBA_WRITE_STEP
50
51    # Get WriteFrenquecies from config.card for SECHIBA
52    SRF_WriteFrequency=$( echo ${config_SRF_WriteFrequency} | sed -e 's/\([0-9]*[yYmMdDs]\).*/\1/' ) 
53    case ${SRF_WriteFrequency} in
54        *Y|*y) 
55            WriteInYears=$( echo ${SRF_WriteFrequency} | awk -F '[yY]' '{print $1}' )
56            PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
57            (( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInYears / PeriodLengthInYears * 86400 )) ;;
58        1M)
59            case ${config_UserChoices_PeriodLength} in
60            *Y|*y)
61                SECHIBA_WRITE_STEP=-1.
62                ;;
63            *M|*m)
64                SECHIBA_WRITE_STEP=-1.
65                ;;
66            *)
67                (( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 ))
68                ;;
69            esac
70            ;;
71        *M|*m) 
72            WriteInMonths=$( echo ${SRF_WriteFrequency} | awk -F '[mM]' '{print $1}' )
73            case ${config_UserChoices_PeriodLength} in
74            *Y|*y)
75                PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
76                (( SECHIBA_WRITE_STEP = PeriodLengthInDays * 86400 / PeriodLengthInYears / 12 ))
77                ;;
78            *M|*m)
79                PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' )
80                (( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInMonths  * 86400 / PeriodLengthInMonths  ))
81                ;;
82            *)
83                (( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 ))
84                ;;
85            esac
86            ;;
87        5D|5d) 
88            (( SECHIBA_WRITE_STEP = 5 * 86400 )) ;;
89        1D|1d) 
90            (( SECHIBA_WRITE_STEP = 86400 )) ;;
91        *s)
92            WriteInSeconds=$( echo ${SRF_WriteFrequency} | awk -F '[s]' '{print $1}' )
93            (( SECHIBA_WRITE_STEP = WriteInSeconds )) ;;
94        *) 
95            IGCM_debug_Exit "SRF_Update " ${SRF_WriteFrequency} " invalid WriteFrequency : choose in 1Y, 1M, 5D, 1D." 
96            IGCM_debug_Verif_Exit ;;
97    esac
98    ORCHIDEE_def WRITE_STEP ${SECHIBA_WRITE_STEP}
99    ORCHIDEE_def SECHIBA_HISTLEVEL ${sechiba_UserChoices_sechiba_LEVEL}
100    # Outputs HF in HISTFILE2 if required
101    if [ X${SRF_ok_hf} = Xy ] ; then
102        ORCHIDEE_def SECHIBA_HISTFILE2 y
103        ORCHIDEE_def SECHIBA_HISTLEVEL2 1
104        ORCHIDEE_def WRITE_STEP2 10800.0
105    fi
106
107    ORCHIDEE_def STOMATE_OK_CO2 ${sechiba_UserChoices_OKCO2}
108
109    ORCHIDEE_def LAI_MAP ${sechiba_UserChoices_LAIMAP}
110    ORCHIDEE_def RIVER_ROUTING ${sechiba_UserChoices_ROUTING}
111    ORCHIDEE_def HYDROL_CWRR ${sechiba_UserChoices_NEWHYDROL}
112
113    if [ X${sechiba_UserChoices_IMPOSE_VEG} = Xn ] ; then
114        if [ X${sechiba_UserChoices_LAND_USE} = Xy ] ; then
115            ORCHIDEE_def VEGET_UPDATE ${sechiba_UserChoices_VEGET_UPDATE}
116
117            ##MM : cutting PFTmaps of ORCHIDEE : for first year without restart, we must use this year map
118            ##     WARNING : the next year map must be avaible and the december month, then this device will
119            ##               only work with PeriodLength scrictly less than 1Y.
120            # If you want to come back to old BIG LAND USE file
121            # (to run on multipple years, just one time with LAND USE activated),
122            # you must
123            # comment all next 8 lines and check correct parameters in orchidee.def file
124            # for your LAND USE specific file.
125            ORCHIDEE_def VEGET_REINIT y
126            if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SRF_Restart}" = "n" ] ) ; then
127                ORCHIDEE_def VEGET_YEAR 1
128            else
129                ORCHIDEE_def VEGET_YEAR 0
130                IGCM_sys_Mv -f PFTmap_IPCC_${year_p1}.nc PFTmap.nc
131            fi
132        elif [ X${sechiba_UserChoices_OLD_VEGET} = Xy ] ; then
133            ORCHIDEE_def LAND_USE n
134        fi
135    else
136        ORCHIDEE_def IMPOSE_VEG y
137    fi
138
139    if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SRF_Restart}" = "n" ] ) ; then
140        ORCHIDEE_def SECHIBA_reset_time y
141    else
142        ORCHIDEE_def SECHIBA_restart_in sechiba_rest_in.nc
143        ORCHIDEE_def SECHIBA_reset_time y
144    fi
145    FileToBeDeleted[${#FileToBeDeleted[@]}]=run.def
146
147    IGCM_debug_PopStack "SRF_Update"
148}
149
150#-----------------------------------------------------------------
151function SRF_Finalize
152{
153    IGCM_debug_PushStack "SRF_Finalize"
154
155    #IGCM_sys_Put_Out ${RUN_DIR}/used_run.def ${R_SAVE}/${PREFIX}_used_run.def
156
157    echo FINALIZE SRF !!!
158
159    IGCM_debug_PopStack "SRF_Finalize"
160}
Note: See TracBrowser for help on using the repository browser.