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 | # Set TIME_LENGTH in run.def depending on PeriodLenght in config.card |
---|
23 | case ${config_UserChoices_PeriodLength} in |
---|
24 | *M|*m|*D|*d) |
---|
25 | IGCM_comp_modifyDefFile nonblocker run.def TIME_LENGTH ${PeriodLengthInDays}D |
---|
26 | ;; |
---|
27 | *s|*Y) |
---|
28 | IGCM_comp_modifyDefFile nonblocker run.def TIME_LENGTH ${config_UserChoices_PeriodLength} |
---|
29 | ;; |
---|
30 | *) |
---|
31 | IGCM_debug_Exit "OOL_Update " ${config_UserChoices_PeriodLength} " invalid PeriodLength in config.card : choose between 1Y, 1M, 5D, 1D." |
---|
32 | IGCM_debug_Verif_Exit |
---|
33 | esac |
---|
34 | |
---|
35 | |
---|
36 | # Set TIME_SKIP only if starting without restart file |
---|
37 | if ( ${FirstInitialize} && [ "${config_OOL_Restart}" = "n" ] ) ; then |
---|
38 | # Calculate the TIME_SKIP as difference between the start date and 1th of January the same year |
---|
39 | IGCM_comp_modifyDefFile nonblocker run.def TIME_SKIP $( IGCM_date_DaysBetweenGregorianDate ${DateBegin} ${year}0101 )D |
---|
40 | else |
---|
41 | # Here using restart file, set TIME_SKIP=0 |
---|
42 | IGCM_comp_modifyDefFile nonblocker run.def TIME_SKIP 0D |
---|
43 | fi |
---|
44 | |
---|
45 | |
---|
46 | |
---|
47 | # Set RESTART_FILEIN in run.def |
---|
48 | if ( ${FirstInitialize} && [ "${config_OOL_Restart}" = "n" ] ) ; then |
---|
49 | # Set RESTART_FILEIN=NONE in run.def |
---|
50 | IGCM_comp_modifyDefFile blocker run.def RESTART_FILEIN NONE |
---|
51 | else |
---|
52 | # Default option using restart file, set RESTART_FILEIN=driver_rest_in.nc in orchidee.def |
---|
53 | IGCM_comp_modifyDefFile blocker run.def RESTART_FILEIN driver_rest_in.nc |
---|
54 | fi |
---|
55 | |
---|
56 | if [ -f CO2.txt ] ; then |
---|
57 | # If this file exist, then read CO2 value and set ATM_CO2 in run.def |
---|
58 | IPCC_CO2=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'` |
---|
59 | if [ X"${IPCC_CO2}" = X ] ; then |
---|
60 | # The grep returned empty variable: stop execution |
---|
61 | IGCM_debug_Exit "The file CO2.txt do not contain the current year." |
---|
62 | IGCM_debug_Verif_Exit |
---|
63 | fi |
---|
64 | IGCM_comp_modifyDefFile nonblocker run.def ATM_CO2 ${IPCC_CO2} |
---|
65 | else |
---|
66 | # The file is not available: take the default value from run.def. |
---|
67 | # The syntax in run.def must be respected, for example: |
---|
68 | # ATM_CO2 = _AUTO_: DEFAULT = 350. |
---|
69 | IGCM_comp_modifyDefFile nonblocker run.def ATM_CO2 DEFAULT |
---|
70 | fi |
---|
71 | |
---|
72 | |
---|
73 | # Activation of XIOS |
---|
74 | if [ X${orchideedriver_UserChoices_XIOS} = Xy ] ; then |
---|
75 | # Add include of orchidee context in iodef.xml |
---|
76 | # In iodef.xml add on next line after "COMPONENT CONTEXT" |
---|
77 | # <context id="orchidee" src="./context_orchidee.xml"/> |
---|
78 | echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp |
---|
79 | # Add inclusion of file context_input_orchidee.xml if this file exists |
---|
80 | if [ -f context_input_orchidee.xml ] ; then |
---|
81 | echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp |
---|
82 | fi |
---|
83 | cp iodef.xml iodef.xml.tmp |
---|
84 | sed -e "/COMPONENT CONTEXT/r add.tmp" \ |
---|
85 | iodef.xml.tmp > iodef.xml |
---|
86 | rm iodef.xml.tmp add.tmp |
---|
87 | |
---|
88 | |
---|
89 | # Special case if SBG component is not activated: deactivate stomate output files from file_def_orchidee.xml |
---|
90 | # If SBG is activated, then the stomate.driver will take care of these variables |
---|
91 | if [ X${config_ListOfComponents_SBG} = X ] ; then |
---|
92 | # Stomate is not activated |
---|
93 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled .FALSE. |
---|
94 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq 1mo |
---|
95 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE. |
---|
96 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq 1mo |
---|
97 | fi |
---|
98 | fi |
---|
99 | |
---|
100 | |
---|
101 | # Add LongName as global attribute in all files produced by XIOS (if LongName is not empty) |
---|
102 | # Remove file_def_input_orchidee.xml from the list. |
---|
103 | if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then |
---|
104 | listfile=$(ls file_def*orchidee.xml | grep -v input) |
---|
105 | echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp |
---|
106 | for file in ${listfile} ; do |
---|
107 | cp ${file} ${file}.tmp |
---|
108 | sed -e "/<file id/r add.tmp" \ |
---|
109 | ${file}.tmp > ${file} |
---|
110 | rm ${file}.tmp |
---|
111 | done |
---|
112 | rm add.tmp |
---|
113 | fi |
---|
114 | |
---|
115 | IGCM_debug_PopStack "OOL_Update" |
---|
116 | } |
---|
117 | |
---|
118 | #----------------------------------------------------------------- |
---|
119 | function OOL_Finalize |
---|
120 | { |
---|
121 | IGCM_debug_PushStack "OOL_Finalize" |
---|
122 | |
---|
123 | IGCM_debug_PopStack "OOL_Finalize" |
---|
124 | } |
---|