1 | #!/bin/ksh |
---|
2 | |
---|
3 | #----------------------------------------------------------------- |
---|
4 | function OOL_Initialize |
---|
5 | { |
---|
6 | IGCM_debug_PushStack "OOL_Initialize" |
---|
7 | |
---|
8 | IGCM_debug_PopStack "OOL_Initialize" |
---|
9 | } |
---|
10 | |
---|
11 | #----------------------------------------------------------------- |
---|
12 | function OOL_Update |
---|
13 | { |
---|
14 | IGCM_debug_PushStack "OOL_Update" |
---|
15 | |
---|
16 | # Set start and end date based on information from config.card |
---|
17 | HumanDateBegin=$( IGCM_date_ConvertFormatToHuman ${PeriodDateBegin} ) |
---|
18 | IGCM_comp_modifyDefFile nonblocker run.def START_DATE ${HumanDateBegin}" 00:00:00" |
---|
19 | HumanDateEnd=$( IGCM_date_ConvertFormatToHuman ${PeriodDateEnd} ) |
---|
20 | IGCM_comp_modifyDefFile nonblocker run.def END_DATE ${HumanDateEnd}" 24:00:00" |
---|
21 | |
---|
22 | IGCM_comp_modifyDefFile nonblocker run.def CYCLIC_STARTDATE ${CyclicYear}"-01-01 00:00:00" |
---|
23 | CyclicYear_end=$(( CyclicYear + PeriodLengthInYears -1 )) |
---|
24 | IGCM_comp_modifyDefFile nonblocker run.def CYCLIC_ENDDATE ${CyclicYear_end}"-12-31 24:00:00" |
---|
25 | |
---|
26 | # Set RESTART_FILEIN in run.def |
---|
27 | if ( ${FirstInitialize} && [ "${config_OOL_Restart}" = "n" ] ) ; then |
---|
28 | # Set RESTART_FILEIN=NONE in run.def |
---|
29 | IGCM_comp_modifyDefFile blocker run.def RESTART_FILEIN NONE |
---|
30 | fi |
---|
31 | |
---|
32 | if [ -f CO2.txt ] ; then |
---|
33 | # If this file exist, then read CO2 value and set ATM_CO2 in run.def |
---|
34 | IPCC_CO2=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'` |
---|
35 | if [ X"${IPCC_CO2}" = X ] ; then |
---|
36 | # The grep returned empty variable: stop execution |
---|
37 | IGCM_debug_Exit "The file CO2.txt do not contain the current year." |
---|
38 | IGCM_debug_Verif_Exit |
---|
39 | fi |
---|
40 | IGCM_comp_modifyDefFile nonblocker run.def ATM_CO2 ${IPCC_CO2} |
---|
41 | else |
---|
42 | # The file is not available: take the default value from run.def. |
---|
43 | # The syntax in run.def must be respected, for example: |
---|
44 | # ATM_CO2 = _AUTO_: DEFAULT = 350. |
---|
45 | IGCM_comp_modifyDefFile nonblocker run.def ATM_CO2 DEFAULT |
---|
46 | fi |
---|
47 | |
---|
48 | |
---|
49 | # Activation of XIOS |
---|
50 | if [ X${orchideedriver_UserChoices_XIOS} = Xy ] ; then |
---|
51 | # Add include of orchidee context in iodef.xml |
---|
52 | # In iodef.xml add on next line after "COMPONENT CONTEXT" |
---|
53 | # <context id="orchidee" src="./context_orchidee.xml"/> |
---|
54 | echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp |
---|
55 | |
---|
56 | # Add inclusion of file context_input_orchidee.xml if this file exists |
---|
57 | if [ -f context_input_orchidee.xml ] ; then |
---|
58 | echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp |
---|
59 | fi |
---|
60 | |
---|
61 | cp iodef.xml iodef.xml.tmp |
---|
62 | sed -e "/COMPONENT CONTEXT/r add.tmp" \ |
---|
63 | iodef.xml.tmp > iodef.xml |
---|
64 | rm iodef.xml.tmp add.tmp |
---|
65 | |
---|
66 | |
---|
67 | # Special case if SBG component is not activated: deactivate stomate output files from file_def_orchidee.xml |
---|
68 | # If SBG is activated, then the stomate.driver will take care of these variables |
---|
69 | if [ X${config_ListOfComponents_SBG} = X ] ; then |
---|
70 | # Stomate is not activated |
---|
71 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled .FALSE. |
---|
72 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq 1mo |
---|
73 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE. |
---|
74 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq 1mo |
---|
75 | fi |
---|
76 | fi |
---|
77 | |
---|
78 | |
---|
79 | # Add LongName as global attribute in all files produced by XIOS (if LongName is not empty) |
---|
80 | # Remove file_def_input_orchidee.xml from the list. |
---|
81 | if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then |
---|
82 | listfile=$(ls file_def*orchidee.xml | grep -v input) |
---|
83 | echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp |
---|
84 | for file in ${listfile} ; do |
---|
85 | cp ${file} ${file}.tmp |
---|
86 | sed -e "/<file id/r add.tmp" \ |
---|
87 | ${file}.tmp > ${file} |
---|
88 | rm ${file}.tmp |
---|
89 | done |
---|
90 | rm add.tmp |
---|
91 | fi |
---|
92 | |
---|
93 | IGCM_debug_PopStack "OOL_Update" |
---|
94 | } |
---|
95 | |
---|
96 | #----------------------------------------------------------------- |
---|
97 | function OOL_Finalize |
---|
98 | { |
---|
99 | IGCM_debug_PushStack "OOL_Finalize" |
---|
100 | |
---|
101 | IGCM_debug_PopStack "OOL_Finalize" |
---|
102 | } |
---|