1 | #!/bin/ksh |
---|
2 | |
---|
3 | #D- Driver du script pour ORCHIDEE |
---|
4 | |
---|
5 | function 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 | #----------------------------------------------------------------- |
---|
20 | function 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 | #----------------------------------------------------------------- |
---|
36 | function 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 | if [ ${year} -eq 2005 ] ; then |
---|
44 | IGCM_sys_Rm -f PFTmap.nc |
---|
45 | fi |
---|
46 | |
---|
47 | else |
---|
48 | PFTmap="${R_BC}/SRF/${config_UserChoices_TagName}/PFTmap_1850to2005_AR5_LUHa.rc2.nc" |
---|
49 | fi |
---|
50 | |
---|
51 | BC_SRF_PFTmap=${PFTmap} |
---|
52 | |
---|
53 | IGCM_debug_PopStack "SRF_PeriodStart" |
---|
54 | |
---|
55 | } |
---|
56 | |
---|
57 | #----------------------------------------------------------------- |
---|
58 | function SRF_Update |
---|
59 | { |
---|
60 | IGCM_debug_PushStack "SRF_Update" |
---|
61 | |
---|
62 | typeset SECHIBA_WRITE_STEP |
---|
63 | |
---|
64 | SRF_WriteFrequency=$( echo ${config_SRF_WriteFrequency} | sed -e 's/\([0-9]*[yYmMdDs]\).*/\1/' ) |
---|
65 | case ${SRF_WriteFrequency} in |
---|
66 | *Y|*y) |
---|
67 | WriteInYears=$( echo ${SRF_WriteFrequency} | awk -F '[yY]' '{print $1}' ) |
---|
68 | PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' ) |
---|
69 | (( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInYears / PeriodLengthInYears * 86400 )) ;; |
---|
70 | 1M) |
---|
71 | case ${config_UserChoices_PeriodLength} in |
---|
72 | *Y|*y) |
---|
73 | SECHIBA_WRITE_STEP=-1. |
---|
74 | ;; |
---|
75 | *M|*m) |
---|
76 | SECHIBA_WRITE_STEP=-1. |
---|
77 | ;; |
---|
78 | *) |
---|
79 | (( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 )) |
---|
80 | ;; |
---|
81 | esac |
---|
82 | ;; |
---|
83 | *M|*m) |
---|
84 | WriteInMonths=$( echo ${SRF_WriteFrequency} | awk -F '[mM]' '{print $1}' ) |
---|
85 | case ${config_UserChoices_PeriodLength} in |
---|
86 | *Y|*y) |
---|
87 | PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' ) |
---|
88 | (( SECHIBA_WRITE_STEP = PeriodLengthInDays * 86400 / PeriodLengthInYears / 12 )) |
---|
89 | ;; |
---|
90 | *M|*m) |
---|
91 | PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' ) |
---|
92 | (( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInMonths * 86400 / PeriodLengthInMonths )) |
---|
93 | ;; |
---|
94 | *) |
---|
95 | (( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 )) |
---|
96 | ;; |
---|
97 | esac |
---|
98 | ;; |
---|
99 | 5D|5d) |
---|
100 | (( SECHIBA_WRITE_STEP = 5 * 86400 )) ;; |
---|
101 | 1D|1d) |
---|
102 | (( SECHIBA_WRITE_STEP = 86400 )) ;; |
---|
103 | *s) |
---|
104 | WriteInSeconds=$( echo ${SRF_WriteFrequency} | awk -F '[s]' '{print $1}' ) |
---|
105 | (( SECHIBA_WRITE_STEP = WriteInSeconds )) ;; |
---|
106 | *) |
---|
107 | IGCM_debug_Exit "SRF_Update " ${SRF_WriteFrequency} " invalid WriteFrequency : choose in 1Y, 1M, 5D, 1D." |
---|
108 | IGCM_debug_Verif_Exit ;; |
---|
109 | esac |
---|
110 | |
---|
111 | # Dans le cas de test : |
---|
112 | # if [ ${year} -eq 1979 ] ; then |
---|
113 | # ORCHIDEE_sed VEGET_REINIT y |
---|
114 | # ORCHIDEE_sed VEGET_YEAR 131 |
---|
115 | # fi |
---|
116 | # |
---|
117 | # # Dans le cas historique : |
---|
118 | # if [ ${year} -eq 2005 ] ; then |
---|
119 | # ORCHIDEE_sed VEGET_REINIT y |
---|
120 | # ORCHIDEE_sed VEGET_YEAR 1 |
---|
121 | ## ORCHIDEE_sed VEGET_UPDATE '0Y' |
---|
122 | # fi |
---|
123 | |
---|
124 | # # Dans le cas sans changement de carte aprÚs 2005 |
---|
125 | # if [ ${year} -gt 2005 ] ; then |
---|
126 | # ORCHIDEE_sed VEGET_UPDATE '0Y' |
---|
127 | # fi |
---|
128 | |
---|
129 | ORCHIDEE_sed HYDROL_CWRR ${orchidee_UserChoices_NEWHYDROL} |
---|
130 | |
---|
131 | ORCHIDEE_sed WRITE_STEP ${SECHIBA_WRITE_STEP} |
---|
132 | ORCHIDEE_sed SECHIBA_HISTLEVEL ${orchidee_UserChoices_sechiba_LEVEL} |
---|
133 | |
---|
134 | # Outputs HF in HISTFILE2 if required |
---|
135 | [ X${SRF_ok_hf} = Xy ] && ORCHIDEE_sed SECHIBA_HISTFILE2 y |
---|
136 | ORCHIDEE_sed SECHIBA_HISTLEVEL2 1 |
---|
137 | ORCHIDEE_sed WRITE_STEP2 10800.0 |
---|
138 | |
---|
139 | if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then |
---|
140 | ORCHIDEE_sed SECHIBA_restart_in sechiba_rest_in.nc |
---|
141 | fi |
---|
142 | |
---|
143 | # Desactaivate river routing for high resolution or very low resolution |
---|
144 | if ( [ ${RESOL_ATM_3D} = "280x280x39-ZAf" ] || [ ${RESOL_ATM_3D} = "360x180x19-ZIn" ] || [ ${RESOL_ATM_3D} = "32x24x11" ] ) ; then |
---|
145 | ORCHIDEE_sed RIVER_ROUTING n |
---|
146 | fi |
---|
147 | |
---|
148 | # Parameters set in orchidee.card |
---|
149 | if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then |
---|
150 | ORCHIDEE_sed VEGET_UPDATE ${orchidee_UserChoices_VEGET_UPDATE} |
---|
151 | fi |
---|
152 | if [ ! X${orchidee_UserChoices_LAND_COVER_CHANGE} = X ] ; then |
---|
153 | ORCHIDEE_sed LAND_COVER_CHANGE ${orchidee_UserChoices_LAND_COVER_CHANGE} |
---|
154 | fi |
---|
155 | |
---|
156 | #IGCM_sys_Cp ${RUN_DIR}/orchidee.def ${RUN_DIR}/run.def |
---|
157 | #IGCM_sys_Put_Out ${RUN_DIR}/run.def ${R_SAVE}/${PREFIX}_run.def |
---|
158 | |
---|
159 | IGCM_debug_PopStack "SRF_Update" |
---|
160 | } |
---|
161 | |
---|
162 | #----------------------------------------------------------------- |
---|
163 | function SRF_Finalize |
---|
164 | { |
---|
165 | IGCM_debug_PushStack "SRF_Finalize" |
---|
166 | |
---|
167 | #IGCM_sys_Put_Out ${RUN_DIR}/used_run.def ${R_SAVE}/${PREFIX}_used_run.def |
---|
168 | |
---|
169 | echo FINALIZE SRF !!! |
---|
170 | |
---|
171 | IGCM_debug_PopStack "SRF_Finalize" |
---|
172 | } |
---|