source: CMIP5/amip4xCO2/v3.amip4xCO2/COMP/orchidee.driver @ 1400

Last change on this file since 1400 was 1400, checked in by musat, 11 years ago

v3.amip4xCO2 IPSL CMIP5 simulation registration.

File size: 4.9 KB
Line 
1#!/bin/ksh
2
3#D- Driver du script pour ORCHIDEE
4
5function ORCHIDEE_sed
6{
7    IGCM_debug_PushStack "ORCHIDEE_sed"
8   
9    sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
10        orchidee.def > orchidee.def.tmp
11    RET=$?
12    echo "ORCHIDEE_sed : ${1} ${2}"
13    \mv orchidee.def.tmp orchidee.def
14   
15    IGCM_debug_PopStack "ORCHIDEE_sed"
16    return $RET
17}
18
19#-----------------------------------------------------------------
20function SRF_Initialize
21{
22    IGCM_debug_PushStack "SRF_Initialize"
23
24    RESOL_SRF=ALL
25
26    for frequency in ${config_SRF_WriteFrequency} ; do
27        case ${frequency} in
28            HF|hf) SRF_ok_hf=y ;;
29        esac
30    done
31
32    IGCM_debug_PopStack "SRF_Initialize"
33}
34
35#-----------------------------------------------------------------
36function SRF_PeriodStart
37{
38
39    IGCM_debug_PushStack "SRF_PeriodStart"
40    if [ ${year} -gt 2004 ] ; then
41
42        PFTmap="${R_BC}/SRF/${config_UserChoices_TagName}/ORCHIDEE_PFTmap_2006to2100_AR5_RCP8.5_MESSAGE.nc"
43        CO2_veget="${R_BC}/ATM/${config_UserChoices_TagName}/IPCC_AR5/RCPs/RCP85/CO2_1765_2500.txt"
44        if [ ${year} -eq 2005 ] ; then
45            IGCM_sys_Rm -f PFTmap.nc
46        fi
47
48    else
49        PFTmap="${R_BC}/SRF/${config_UserChoices_TagName}/PFTmap_1850to2005_AR5_LUHa.rc2.nc"
50        CO2_veget="${R_BC}/ATM/${config_UserChoices_TagName}/IPCC_AR5/RCPs/RCP85/CO2_1765_2500.txt"
51    fi
52
53    BC_SRF_PFTmap=${PFTmap}
54    BC_SRF_CO2=${CO2_veget}
55
56    IGCM_debug_PopStack "SRF_PeriodStart"
57
58}
59
60#-----------------------------------------------------------------
61function SRF_Update
62{
63    IGCM_debug_PushStack "SRF_Update"
64
65    typeset SECHIBA_WRITE_STEP
66
67    SRF_WriteFrequency=$( echo ${config_SRF_WriteFrequency} | sed -e 's/\([0-9]*[yYmMdDs]\).*/\1/' ) 
68    case ${SRF_WriteFrequency} in
69        *Y|*y) 
70            WriteInYears=$( echo ${SRF_WriteFrequency} | awk -F '[yY]' '{print $1}' )
71            PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
72            (( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInYears / PeriodLengthInYears * 86400 )) ;;
73        1M)
74            case ${config_UserChoices_PeriodLength} in
75            *Y|*y)
76                SECHIBA_WRITE_STEP=-1.
77                ;;
78            *M|*m)
79                SECHIBA_WRITE_STEP=-1.
80                ;;
81            *)
82                (( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 ))
83                ;;
84            esac
85            ;;
86        *M|*m) 
87            WriteInMonths=$( echo ${SRF_WriteFrequency} | awk -F '[mM]' '{print $1}' )
88            case ${config_UserChoices_PeriodLength} in
89            *Y|*y)
90                PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
91                (( SECHIBA_WRITE_STEP = PeriodLengthInDays * 86400 / PeriodLengthInYears / 12  ))
92                ;;
93            *M|*m)
94                PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' )
95                (( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInMonths  * 86400 / PeriodLengthInMonths  ))
96                ;;
97            *)
98                (( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 ))
99                ;;
100            esac
101            ;;
102        5D|5d) 
103            (( SECHIBA_WRITE_STEP = 5 * 86400 )) ;;
104        1D|1d) 
105            (( SECHIBA_WRITE_STEP = 86400 )) ;;
106        *s)
107            WriteInSeconds=$( echo ${SRF_WriteFrequency} | awk -F '[s]' '{print $1}' )
108            (( SECHIBA_WRITE_STEP = WriteInSeconds )) ;;
109        *) 
110            IGCM_debug_Exit "SRF_Update " ${SRF_WriteFrequency} " invalid WriteFrequency : choose in 1Y, 1M, 5D, 1D." 
111            IGCM_debug_Verif_Exit ;;
112    esac
113
114    # Dans le cas de test :
115    if [ ${year} -eq 1979 ] ; then
116        ORCHIDEE_sed VEGET_REINIT y
117        ORCHIDEE_sed VEGET_YEAR 131
118    fi
119   
120    # Dans le cas historique :
121    if [ ${year} -eq 2005 ] ; then
122        ORCHIDEE_sed VEGET_REINIT y
123        ORCHIDEE_sed VEGET_YEAR 1
124#       ORCHIDEE_sed VEGET_UPDATE '0Y'
125    fi
126
127#     # Dans le cas sans changement de carte aprÚs 2005
128#     if [ ${year} -gt 2005 ] ; then
129#       ORCHIDEE_sed VEGET_UPDATE '0Y'
130#     fi
131
132#IM ajout valeurs CO2_ATM
133    ##-- GHG forcing for the current year
134    #IPCC_CO2_AMIP=`grep Annee_${year} CO2_1765_2005.txt | awk -F= '{print $2}'`
135    IPCC_CO2_AMIP=`grep Annee_${year} CO2_veget.txt | awk -F= '{print $2}'`
136    ORCHIDEE_sed FORCE_CO2_VEG y
137    ORCHIDEE_sed ATM_CO2 ${IPCC_CO2_AMIP}
138 
139    ORCHIDEE_sed HYDROL_CWRR ${orchidee_UserChoices_NEWHYDROL}
140
141    ORCHIDEE_sed WRITE_STEP ${SECHIBA_WRITE_STEP}
142    ORCHIDEE_sed SECHIBA_HISTLEVEL ${orchidee_UserChoices_sechiba_LEVEL}
143
144    # Outputs HF in HISTFILE2 if required
145    [ X${SRF_ok_hf} = Xy ] && ORCHIDEE_sed SECHIBA_HISTFILE2 y
146    ORCHIDEE_sed SECHIBA_HISTLEVEL2 1
147    ORCHIDEE_sed WRITE_STEP2 10800.0
148
149    if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then
150        ORCHIDEE_sed SECHIBA_restart_in sechiba_rest_in.nc
151    fi
152
153    #IGCM_sys_Cp ${RUN_DIR}/orchidee.def ${RUN_DIR}/run.def
154    #IGCM_sys_Put_Out ${RUN_DIR}/run.def ${R_SAVE}/${PREFIX}_run.def
155
156    IGCM_debug_PopStack "SRF_Update"
157}
158
159#-----------------------------------------------------------------
160function SRF_Finalize
161{
162    IGCM_debug_PushStack "SRF_Finalize"
163
164    #IGCM_sys_Put_Out ${RUN_DIR}/used_run.def ${R_SAVE}/${PREFIX}_used_run.def
165
166    echo FINALIZE SRF !!!
167
168    IGCM_debug_PopStack "SRF_Finalize"
169}
Note: See TracBrowser for help on using the repository browser.