1 | #!/bin/ksh |
---|
2 | #D- Driver du script pour ORCHIDEE |
---|
3 | #----------------------------------------------------------------- |
---|
4 | function SRF_Initialize |
---|
5 | { |
---|
6 | IGCM_debug_PushStack "SRF_Initialize" |
---|
7 | |
---|
8 | ##- Define variable DefSuffix set in orchidee.card |
---|
9 | ## This variable is used in orchidee.card to choose |
---|
10 | ## parameter file(orchidee.def_DefSuffix). |
---|
11 | if [ ! X${orchidee_UserChoices_DefSuffix} = X ] ; then |
---|
12 | DefSuffix=${orchidee_UserChoices_DefSuffix} |
---|
13 | else |
---|
14 | DefSuffix=Choi |
---|
15 | fi |
---|
16 | |
---|
17 | IGCM_debug_PopStack "SRF_Initialize" |
---|
18 | } |
---|
19 | |
---|
20 | #----------------------------------------------------------------- |
---|
21 | function SRF_Update |
---|
22 | { |
---|
23 | IGCM_debug_PushStack "SRF_Update" |
---|
24 | |
---|
25 | ## 1. Modifications in orchidee.def parameter file |
---|
26 | |
---|
27 | # Activate STOMATE if the compontent SBG=stomate is set in config.card |
---|
28 | if [ X${config_ListOfComponents_SBG} = Xstomate ] ; then |
---|
29 | # Activate stomate in orchidee.def |
---|
30 | IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE y |
---|
31 | else |
---|
32 | # Deactivate stomate in orchidee.def |
---|
33 | IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE n |
---|
34 | # Deactivate output files for stomate |
---|
35 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled .FALSE. |
---|
36 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq 1mo |
---|
37 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE. |
---|
38 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq 1mo |
---|
39 | fi |
---|
40 | |
---|
41 | # Define in orchidee.def if restart file should be used |
---|
42 | if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then |
---|
43 | IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in sechiba_rest_in.nc |
---|
44 | else |
---|
45 | IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in NONE |
---|
46 | fi |
---|
47 | |
---|
48 | # Modify in orchidee.def VEGET_UPDATE if it is set in orchidee.card section UserChoices |
---|
49 | if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then |
---|
50 | IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE ${orchidee_UserChoices_VEGET_UPDATE} |
---|
51 | else |
---|
52 | IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 0Y |
---|
53 | fi |
---|
54 | |
---|
55 | # Activate creation of river description file only for the first period |
---|
56 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
57 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC y |
---|
58 | else |
---|
59 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC n |
---|
60 | fi |
---|
61 | |
---|
62 | |
---|
63 | ## 2. Mangement of output and modifications of related xml files |
---|
64 | |
---|
65 | # Set default values for sechiba1_enabled, sechiba1_freq and sechiba2_enabled. |
---|
66 | sechiba1_enabled=.FALSE. |
---|
67 | sechiba2_enabled=.FALSE. |
---|
68 | sechiba1_freq=0s |
---|
69 | |
---|
70 | # Get WriteFrenquecies from config.card for SECHIBA |
---|
71 | # Note that it is only possible to have one HF and one other option. |
---|
72 | # If more options are set in config.card only the latest will be used. |
---|
73 | for frequency in ${config_SRF_WriteFrequency} ; do |
---|
74 | case ${frequency} in |
---|
75 | *Y|*y) |
---|
76 | NbYears=$( echo ${frequency} | awk -F '[yY]' '{print $1}' ) |
---|
77 | NbDaysYear=$( IGCM_date_DaysInYear ${year} ) |
---|
78 | sechiba1_enabled=.TRUE. |
---|
79 | sechiba1_freq=${NbYears}y ;; |
---|
80 | *M|*m) |
---|
81 | NbMonths=$( echo ${frequency} | awk -F '[mM]' '{print $1}' ) |
---|
82 | sechiba1_enabled=.TRUE. |
---|
83 | sechiba1_freq=${NbMonths}mo ;; |
---|
84 | *D|*d) |
---|
85 | NbDays=$( echo ${frequency} | awk -F '[dD]' '{print $1}' ) |
---|
86 | sechiba1_enabled=.TRUE. |
---|
87 | sechiba1_freq=${NbDays}d ;; |
---|
88 | *s) |
---|
89 | WriteInSeconds=$( echo ${frequency} | awk -F '[s]' '{print $1}' ) |
---|
90 | sechiba1_enabled=.TRUE. |
---|
91 | sechiba1_freq=${WriteInSeconds}s ;; |
---|
92 | HF|hf) |
---|
93 | sechiba2_enabled=.TRUE. ;; |
---|
94 | *) |
---|
95 | IGCM_debug_Exit "SRF WriteFrequency=${frequency} is invalid. Choose between xY, xM, xD, xs and HF for Sechiba." ;; |
---|
96 | esac |
---|
97 | done |
---|
98 | |
---|
99 | # Do the modifications in file_def_orchidee.xml |
---|
100 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled ${sechiba1_enabled} |
---|
101 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq ${sechiba1_freq} |
---|
102 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled ${sechiba2_enabled} |
---|
103 | |
---|
104 | # Add include of orchidee context in iodef.xml |
---|
105 | # In iodef.xml add on next line after "COMPONENT CONTEXT" |
---|
106 | # <context id="orchidee" src="./context_orchidee.xml"/> |
---|
107 | echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp |
---|
108 | cp iodef.xml iodef.xml.tmp |
---|
109 | sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml |
---|
110 | rm iodef.xml.tmp add.tmp |
---|
111 | |
---|
112 | #Long Name as global attribute (if LongName is not empty) |
---|
113 | if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then |
---|
114 | listfile=$(ls file_def*orchidee.xml) |
---|
115 | echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp |
---|
116 | for file in ${listfile} |
---|
117 | do |
---|
118 | cp ${file} ${file}.tmp |
---|
119 | sed -e "/<file id/r add.tmp" \ |
---|
120 | ${file}.tmp > ${file} |
---|
121 | rm ${file}.tmp |
---|
122 | done |
---|
123 | rm add.tmp |
---|
124 | fi |
---|
125 | |
---|
126 | IGCM_debug_PopStack "SRF_Update" |
---|
127 | } |
---|
128 | |
---|
129 | #----------------------------------------------------------------- |
---|
130 | function SRF_Finalize |
---|
131 | { |
---|
132 | IGCM_debug_PushStack "SRF_Finalize" |
---|
133 | |
---|
134 | IGCM_debug_PopStack "SRF_Finalize" |
---|
135 | } |
---|