1 | #!/bin/ksh |
---|
2 | #----------------------------------------------------------------- |
---|
3 | function ICO_Initialize |
---|
4 | { |
---|
5 | IGCM_debug_PushStack "ICO_Initialize" |
---|
6 | |
---|
7 | ##- Horizontal resolution read from dynamic.card |
---|
8 | if [ ! X${dynamico_UserChoices_RESOL_NBP} = X ] ; then |
---|
9 | RESOL_NBP=${dynamico_UserChoices_RESOL_NBP} |
---|
10 | else |
---|
11 | # Exit |
---|
12 | IGCM_debug_Exit "RESOL_NBP must be set in dynamico.card UserSection" |
---|
13 | IGCM_debug_Verif_Exit |
---|
14 | fi |
---|
15 | |
---|
16 | ##- Horizontal resolution read from dynamico.card |
---|
17 | if [ ! X${dynamico_UserChoices_RESOL_ATM_Z} = X ] ; then |
---|
18 | RESOL_ATM_Z=${dynamico_UserChoices_RESOL_ATM_Z} |
---|
19 | else |
---|
20 | # RESOL_ATM_Z is not set in dynamico.card but this is needed |
---|
21 | IGCM_debug_Exit "RESOL_ATM_Z must be set in dynamico.card UserSection" |
---|
22 | IGCM_debug_Verif_Exit |
---|
23 | fi |
---|
24 | |
---|
25 | |
---|
26 | if [ -f ${SUBMIT_DIR}/../../../bin/inca_${OptMode}_${ConfChem}.dat ]; then |
---|
27 | eval $(grep nbtrac ${SUBMIT_DIR}/../../../bin/inca_${OptMode}_${ConfChem}.dat) || nbtrac=1 |
---|
28 | else |
---|
29 | nbtrac=1 |
---|
30 | fi |
---|
31 | ((nbtrac=nbtrac+3)) |
---|
32 | |
---|
33 | |
---|
34 | if [ ! -f ${SUBMIT_DIR}/../../../modeles/DYNAMICO/xml/file_def_dynamico.xml ]; then |
---|
35 | module load python3 |
---|
36 | python3 ${SUBMIT_DIR}/../../../modeles/DYNAMICO/xml/file_def_dynamico.xml.py > ${SUBMIT_DIR}/../../../modeles/DYNAMICO/xml/file_def_dynamico.xml |
---|
37 | fi |
---|
38 | |
---|
39 | IGCM_debug_PopStack "ICO_Initialize" |
---|
40 | } |
---|
41 | |
---|
42 | #----------------------------------------------------------------- |
---|
43 | function ICO_Update |
---|
44 | { |
---|
45 | IGCM_debug_PushStack "ICO_Update" |
---|
46 | |
---|
47 | # Reset date from start.nc file on the first iteration in the simulation |
---|
48 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
49 | IGCM_comp_modifyDefFile blocker run_dynamico.def etat0_start_iteration_reset y |
---|
50 | else |
---|
51 | IGCM_comp_modifyDefFile blocker run_dynamico.def etat0_start_iteration_reset n |
---|
52 | fi |
---|
53 | |
---|
54 | # set number of tracer in run_dynamico.def |
---|
55 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def nqtot ${nbtrac} |
---|
56 | |
---|
57 | # Set lenght for execution |
---|
58 | IGCM_comp_modifyDefFile blocker run_dynamico.def run_length $(( ${PeriodLengthInDays} * 86400 )) |
---|
59 | |
---|
60 | # Activate nudging if ok_guide=y set in dynamico.card |
---|
61 | if [ X${dynamico_UserChoices_ok_guide} = Xy ] ; then |
---|
62 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def guided_type nudging |
---|
63 | else |
---|
64 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def guided_type none |
---|
65 | fi |
---|
66 | |
---|
67 | # Change run_dynamico.def according to UserChoices options set in dynmaico.card |
---|
68 | |
---|
69 | # Set create_etat0_limit=y or n and |
---|
70 | if [ X${dynamico_UserChoices_create_etat0_limit} = Xy ] ; then |
---|
71 | # create_etat0_limit is set in dynamcio.card to y |
---|
72 | # Activate create_etat0_limit=y in run_dynamico.def |
---|
73 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def create_etat0_limit y |
---|
74 | |
---|
75 | # Use iflag_phys=101 or higher to activate aquaplanet mode |
---|
76 | if [ X${dynamico_UserChoices_iflag_phys} = X ] || [ X${dynamico_UserChoices_iflag_phys} = X1 ]; then |
---|
77 | # iflag_phys is not set or iflag_phys=1 => run is not an aquaplanet |
---|
78 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def etat0 database |
---|
79 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def iflag_phys 1 |
---|
80 | else |
---|
81 | # This is an aquaplanet |
---|
82 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def etat0 held_suarez |
---|
83 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def iflag_phys ${dynamico_UserChoices_iflag_phys} |
---|
84 | fi |
---|
85 | |
---|
86 | # Optimize the grid: set read_metric=n and optim_it=100000 |
---|
87 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def read_metric n |
---|
88 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def optim_it 100000 |
---|
89 | else |
---|
90 | # Deactivate create_etat0_limit to run a the GCM (aquaplanet or not) |
---|
91 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def create_etat0_limit n |
---|
92 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def etat0 start_file |
---|
93 | |
---|
94 | # Set iflag_phys even though it only will be read but not used for the case create_etat0_limit=n |
---|
95 | if [ X${dynamico_UserChoices_iflag_phys} = X ] || [ X${dynamico_UserChoices_iflag_phys} = X1 ]; then |
---|
96 | # iflag_phys is not set or iflag_phys=1 => run is not an aquaplanet |
---|
97 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def iflag_phys 1 |
---|
98 | else |
---|
99 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def iflag_phys ${dynamico_UserChoices_iflag_phys} |
---|
100 | fi |
---|
101 | |
---|
102 | # Read grid from start.nc file: set read_metric=y and optim_it=0 |
---|
103 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def read_metric y |
---|
104 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def optim_it 0 |
---|
105 | fi |
---|
106 | |
---|
107 | |
---|
108 | # Add include of context xml files for DYNAMICO in iodef.xml |
---|
109 | # In iodef.xml add on the next line after "COMPONENT CONTEXT" |
---|
110 | echo '<context id="icosagcm" src="./context_dynamico.xml"/>' >> add.tmp |
---|
111 | |
---|
112 | # Add inclusion of file context_input_dynamico.xml if this file exists |
---|
113 | if [ -f context_input_dynamico.xml ] ; then |
---|
114 | echo '<context id="icosagcm_input" src="./context_input_dynamico.xml"/>' >> add.tmp |
---|
115 | fi |
---|
116 | |
---|
117 | if [ -f tracers_dynamico.xml ] ; then |
---|
118 | echo '<context id="icosagcm" src="./tracers_dynamico.xml" />' >> add.tmp |
---|
119 | fi |
---|
120 | |
---|
121 | if [ X${dynamico_UserChoices_ok_guide} = Xy ] ; then |
---|
122 | if [ -f nudging_dynamico.xml ] ; then |
---|
123 | echo '<context id="icosagcm" src="./nudging_dynamico.xml" />' >> add.tmp |
---|
124 | else |
---|
125 | IGCM_debug_Exit "you choose ok_guide=y and forget to add the copy of nudging_dynamico.xml file in dynamico.card" |
---|
126 | IGCM_debug_Verif_Exit |
---|
127 | fi |
---|
128 | fi |
---|
129 | |
---|
130 | if [ -f file_def_dynamico.xml ] ; then |
---|
131 | echo '<context id="icosagcm" src="./file_def_dynamico.xml" />' >> add.tmp |
---|
132 | fi |
---|
133 | |
---|
134 | |
---|
135 | # Include xml files for output configuration if running with workflow CMIP6 |
---|
136 | if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then |
---|
137 | if [ -f ping_dynamico.xml ] ; then |
---|
138 | echo '<context id="icosagcm" src="./ping_dynamico.xml"/>' >> add.tmp |
---|
139 | echo '<context id="icosagcm" src="./dr2xml_dynamico.xml"/>' >> add.tmp |
---|
140 | fi |
---|
141 | fi |
---|
142 | cp iodef.xml iodef.xml.tmp |
---|
143 | sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml |
---|
144 | rm iodef.xml.tmp add.tmp |
---|
145 | |
---|
146 | # Add a Long Name as global attribute in output files if LongName is set in config.card |
---|
147 | if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then |
---|
148 | listfile=$(ls file_def*dynamico.xml) |
---|
149 | echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp |
---|
150 | for file in ${listfile} ; do |
---|
151 | cp ${file} ${file}.tmp |
---|
152 | sed -e "/<file id/r add.tmp" \ |
---|
153 | ${file}.tmp > ${file} |
---|
154 | rm ${file}.tmp |
---|
155 | done |
---|
156 | rm add.tmp |
---|
157 | fi |
---|
158 | |
---|
159 | #remove unlimited time axis on winds files |
---|
160 | if [ -f u.nc ] ; then |
---|
161 | nccopy -u u.nc tmp.nc |
---|
162 | mv tmp.nc u.nc |
---|
163 | fi |
---|
164 | if [ -f v.nc ] ; then |
---|
165 | nccopy -u v.nc tmp.nc |
---|
166 | mv tmp.nc v.nc |
---|
167 | fi |
---|
168 | |
---|
169 | |
---|
170 | if [ X${config_ListOfComponents_CPL} = Xoasis ] ; then |
---|
171 | echo "Coupling mode using oasis, set using_oasis=y in run_dynamico.def" |
---|
172 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def using_oasis y |
---|
173 | else |
---|
174 | echo "DYNAMICO is running in forced mode without ocean model, set using_oasis=y in run_dynamico.def" |
---|
175 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def using_oasis n |
---|
176 | fi |
---|
177 | |
---|
178 | |
---|
179 | # Compression level (if CompressionLevel is not empty) |
---|
180 | if [ ! "X${config_UserChoices_CompressionLevel}" = "X" ] ; then |
---|
181 | echo "NetCDF output files compression level is " ${config_UserChoices_CompressionLevel} |
---|
182 | listfile=$(ls file_def*dynamico.xml) |
---|
183 | for file in ${listfile} ; do |
---|
184 | sed -i -e "s/\(compression_level=\"\)[^\"]*\(\"\)/\1${config_UserChoices_CompressionLevel}\2/" ${file} |
---|
185 | done |
---|
186 | fi |
---|
187 | |
---|
188 | IGCM_debug_PopStack "ICO_Update" |
---|
189 | } |
---|
190 | |
---|
191 | #----------------------------------- |
---|
192 | function ICO_Finalize |
---|
193 | { |
---|
194 | IGCM_debug_PushStack "ICO_Finalize" |
---|
195 | |
---|
196 | IGCM_debug_PopStack "ICO_Finalize" |
---|
197 | } |
---|
198 | |
---|