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 | function LMDZ_sed |
---|
20 | { |
---|
21 | IGCM_debug_PushStack "LMDZ_sed" |
---|
22 | |
---|
23 | sed -e "s/^${2}\ *=.*/${2}= ${3}/" ${1} > ${1}.tmp |
---|
24 | RET=$? |
---|
25 | echo "LMDZ_sed : ${1} ${2} ${3}" |
---|
26 | \mv ${1}.tmp ${1} |
---|
27 | |
---|
28 | IGCM_debug_PopStack "LMDZ_sed" |
---|
29 | return $RET |
---|
30 | } |
---|
31 | |
---|
32 | #----------------------------------------------------------------- |
---|
33 | function SRF_Initialize |
---|
34 | { |
---|
35 | IGCM_debug_PushStack "SRF_Initialize" |
---|
36 | |
---|
37 | RESOL_SRF=ALL |
---|
38 | |
---|
39 | for frequency in ${config_SRF_WriteFrequency} ; do |
---|
40 | case ${frequency} in |
---|
41 | HF|hf) SRF_ok_hf=y ;; |
---|
42 | esac |
---|
43 | done |
---|
44 | |
---|
45 | IGCM_debug_PopStack "SRF_Initialize" |
---|
46 | } |
---|
47 | |
---|
48 | #----------------------------------------------------------------- |
---|
49 | function SRF_Update |
---|
50 | { |
---|
51 | IGCM_debug_PushStack "SRF_Update" |
---|
52 | |
---|
53 | typeset SECHIBA_WRITE_STEP |
---|
54 | |
---|
55 | SRF_WriteFrequency=$( echo ${config_SRF_WriteFrequency} | sed -e 's/\([0-9]*[yYmMdDs]\).*/\1/' ) |
---|
56 | case ${SRF_WriteFrequency} in |
---|
57 | *Y|*y) |
---|
58 | WriteInYears=$( echo ${SRF_WriteFrequency} | awk -F '[yY]' '{print $1}' ) |
---|
59 | PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' ) |
---|
60 | (( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInYears / PeriodLengthInYears * 86400 )) ;; |
---|
61 | 1M) |
---|
62 | case ${config_UserChoices_PeriodLength} in |
---|
63 | *Y|*y) |
---|
64 | SECHIBA_WRITE_STEP=-1. |
---|
65 | ;; |
---|
66 | *M|*m) |
---|
67 | SECHIBA_WRITE_STEP=-1. |
---|
68 | ;; |
---|
69 | *) |
---|
70 | (( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 )) |
---|
71 | ;; |
---|
72 | esac |
---|
73 | ;; |
---|
74 | *M|*m) |
---|
75 | WriteInMonths=$( echo ${SRF_WriteFrequency} | awk -F '[mM]' '{print $1}' ) |
---|
76 | case ${config_UserChoices_PeriodLength} in |
---|
77 | *Y|*y) |
---|
78 | PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' ) |
---|
79 | (( SECHIBA_WRITE_STEP = PeriodLengthInDays * 86400 / PeriodLengthInYears / 12 )) |
---|
80 | ;; |
---|
81 | *M|*m) |
---|
82 | PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' ) |
---|
83 | (( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInMonths * 86400 / PeriodLengthInMonths )) |
---|
84 | ;; |
---|
85 | *) |
---|
86 | (( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 )) |
---|
87 | ;; |
---|
88 | esac |
---|
89 | ;; |
---|
90 | 5D|5d) |
---|
91 | (( SECHIBA_WRITE_STEP = 5 * 86400 )) ;; |
---|
92 | 1D|1d) |
---|
93 | (( SECHIBA_WRITE_STEP = 86400 )) ;; |
---|
94 | *s) |
---|
95 | WriteInSeconds=$( echo ${SRF_WriteFrequency} | awk -F '[s]' '{print $1}' ) |
---|
96 | (( SECHIBA_WRITE_STEP = WriteInSeconds )) ;; |
---|
97 | *) |
---|
98 | IGCM_debug_Exit "SRF_Update " ${SRF_WriteFrequency} " invalid WriteFrequency : choose in 1Y, 1M, 5D, 1D." |
---|
99 | IGCM_debug_Verif_Exit ;; |
---|
100 | esac |
---|
101 | |
---|
102 | ORCHIDEE_sed HYDROL_CWRR ${orchidee_UserChoices_NEWHYDROL} |
---|
103 | |
---|
104 | ORCHIDEE_sed WRITE_STEP ${SECHIBA_WRITE_STEP} |
---|
105 | ORCHIDEE_sed SECHIBA_HISTLEVEL ${orchidee_UserChoices_sechiba_LEVEL} |
---|
106 | |
---|
107 | # Outputs HF in HISTFILE2 if required |
---|
108 | [ X${SRF_ok_hf} = Xy ] && ORCHIDEE_sed SECHIBA_HISTFILE2 y |
---|
109 | ORCHIDEE_sed SECHIBA_HISTLEVEL2 1 |
---|
110 | ORCHIDEE_sed WRITE_STEP2 10800.0 |
---|
111 | |
---|
112 | if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then |
---|
113 | ORCHIDEE_sed SECHIBA_restart_in sechiba_rest_in.nc |
---|
114 | fi |
---|
115 | |
---|
116 | |
---|
117 | # Modify in orchidee.def VEGET_UPDATE and LAND_COVER_CHANGE if they are set in orchidee.card section UserChoices |
---|
118 | if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then |
---|
119 | ORCHIDEE_sed VEGET_UPDATE ${orchidee_UserChoices_VEGET_UPDATE} |
---|
120 | fi |
---|
121 | if [ ! X${orchidee_UserChoices_LAND_COVER_CHANGE} = X ] ; then |
---|
122 | ORCHIDEE_sed LAND_COVER_CHANGE ${orchidee_UserChoices_LAND_COVER_CHANGE} |
---|
123 | fi |
---|
124 | |
---|
125 | #IGCM_sys_Cp ${RUN_DIR}/orchidee.def ${RUN_DIR}/run.def |
---|
126 | #IGCM_sys_Put_Out ${RUN_DIR}/run.def ${R_SAVE}/${PREFIX}_run.def |
---|
127 | |
---|
128 | |
---|
129 | # Activate vegetation model in LMDZ run.def file |
---|
130 | LMDZ_sed run.def VEGET y |
---|
131 | |
---|
132 | IGCM_debug_PopStack "SRF_Update" |
---|
133 | } |
---|
134 | |
---|
135 | #----------------------------------------------------------------- |
---|
136 | function SRF_Finalize |
---|
137 | { |
---|
138 | IGCM_debug_PushStack "SRF_Finalize" |
---|
139 | |
---|
140 | #IGCM_sys_Put_Out ${RUN_DIR}/used_run.def ${R_SAVE}/${PREFIX}_used_run.def |
---|
141 | |
---|
142 | echo FINALIZE SRF !!! |
---|
143 | |
---|
144 | IGCM_debug_PopStack "SRF_Finalize" |
---|
145 | } |
---|