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}/../../../modeles/DYNAMICO/xml/file_def_dynamico.xml ]; then |
---|
27 | module load python3 |
---|
28 | python3 ${SUBMIT_DIR}/../../../modeles/DYNAMICO/xml/file_def_dynamico.xml.py > ${SUBMIT_DIR}/../../../modeles/DYNAMICO/xml/file_def_dynamico.xml |
---|
29 | fi |
---|
30 | |
---|
31 | |
---|
32 | IGCM_debug_PopStack "ICO_Initialize" |
---|
33 | } |
---|
34 | |
---|
35 | #----------------------------------------------------------------- |
---|
36 | function ICO_Update |
---|
37 | { |
---|
38 | IGCM_debug_PushStack "ICO_Update" |
---|
39 | |
---|
40 | # Reset date from start.nc file on the first iteration in the simulation |
---|
41 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
42 | IGCM_comp_modifyDefFile blocker run_dynamico.def etat0_start_iteration_reset y |
---|
43 | else |
---|
44 | IGCM_comp_modifyDefFile blocker run_dynamico.def etat0_start_iteration_reset n |
---|
45 | fi |
---|
46 | |
---|
47 | # Set lenght for execution |
---|
48 | IGCM_comp_modifyDefFile blocker run_dynamico.def run_length $(( ${PeriodLengthInDays} * 86400 )) |
---|
49 | |
---|
50 | # Change run_dynamico.def according to UserChoices options set in dynmaico.card |
---|
51 | |
---|
52 | # Set create_etat0_limit=y or n and |
---|
53 | if [ X${dynamico_UserChoices_create_etat0_limit} = Xy ] ; then |
---|
54 | # create_etat0_limit is set in dynamcio.card to y |
---|
55 | # Activate create_etat0_limit=y in run_dynamico.def |
---|
56 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def create_etat0_limit y |
---|
57 | |
---|
58 | # Use iflag_phys=101 or higher to activate aquaplanet mode |
---|
59 | if [ X${dynamico_UserChoices_iflag_phys} = X ] || [ X${dynamico_UserChoices_iflag_phys} = X1 ]; then |
---|
60 | # iflag_phys is not set or iflag_phys=1 => run is not an aquaplanet |
---|
61 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def etat0 database |
---|
62 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def iflag_phys 1 |
---|
63 | else |
---|
64 | # This is an aquaplanet |
---|
65 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def etat0 held_suarez |
---|
66 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def iflag_phys ${dynamico_UserChoices_iflag_phys} |
---|
67 | fi |
---|
68 | |
---|
69 | # Optimize the grid: set read_metric=n and optim_it=100000 |
---|
70 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def read_metric n |
---|
71 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def optim_it 100000 |
---|
72 | else |
---|
73 | # Deactivate create_etat0_limit to run a the GCM (aquaplanet or not) |
---|
74 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def create_etat0_limit n |
---|
75 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def etat0 start_file |
---|
76 | |
---|
77 | # Set iflag_phys even though it only will be read but not used for the case create_etat0_limit=n |
---|
78 | if [ X${dynamico_UserChoices_iflag_phys} = X ] || [ X${dynamico_UserChoices_iflag_phys} = X1 ]; then |
---|
79 | # iflag_phys is not set or iflag_phys=1 => run is not an aquaplanet |
---|
80 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def iflag_phys 1 |
---|
81 | else |
---|
82 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def iflag_phys ${dynamico_UserChoices_iflag_phys} |
---|
83 | fi |
---|
84 | |
---|
85 | # Read grid from start.nc file: set read_metric=y and optim_it=0 |
---|
86 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def read_metric y |
---|
87 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def optim_it 0 |
---|
88 | fi |
---|
89 | |
---|
90 | |
---|
91 | # Add include of context xml files for DYNAMICO in iodef.xml |
---|
92 | # In iodef.xml add on the next line after "COMPONENT CONTEXT" |
---|
93 | echo '<context id="icosagcm" src="./context_dynamico.xml"/>' >> add.tmp |
---|
94 | |
---|
95 | # Add inclusion of file context_input_dynamico.xml if this file exists |
---|
96 | if [ -f context_input_dynamico.xml ] ; then |
---|
97 | echo '<context id="icosagcm_input" src="./context_input_dynamico.xml"/>' >> add.tmp |
---|
98 | fi |
---|
99 | |
---|
100 | # Include xml files for output configuration if running with workflow CMIP6 |
---|
101 | if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then |
---|
102 | if [ -f ping_dynamico.xml ] ; then |
---|
103 | echo '<context id="icosagcm" src="./ping_dynamico.xml"/>' >> add.tmp |
---|
104 | echo '<context id="icosagcm" src="./dr2xml_dynamico.xml"/>' >> add.tmp |
---|
105 | fi |
---|
106 | fi |
---|
107 | cp iodef.xml iodef.xml.tmp |
---|
108 | sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml |
---|
109 | rm iodef.xml.tmp add.tmp |
---|
110 | |
---|
111 | # Add a Long Name as global attribute in output files if LongName is set in config.card |
---|
112 | if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then |
---|
113 | listfile=$(ls file_def*dynamico.xml) |
---|
114 | echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp |
---|
115 | for file in ${listfile} ; do |
---|
116 | cp ${file} ${file}.tmp |
---|
117 | sed -e "/<file id/r add.tmp" \ |
---|
118 | ${file}.tmp > ${file} |
---|
119 | rm ${file}.tmp |
---|
120 | done |
---|
121 | rm add.tmp |
---|
122 | fi |
---|
123 | |
---|
124 | if [ X${config_ListOfComponents_CPL} = Xoasis ] ; then |
---|
125 | echo "Coupling mode using oasis, set using_oasis=y in run_dynamico.def" |
---|
126 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def using_oasis y |
---|
127 | else |
---|
128 | echo "DYNAMICO is running in forced mode without ocean model, set using_oasis=y in run_dynamico.def" |
---|
129 | IGCM_comp_modifyDefFile nonblocker run_dynamico.def using_oasis n |
---|
130 | fi |
---|
131 | |
---|
132 | |
---|
133 | # Compression level (if CompressionLevel is not empty) |
---|
134 | if [ ! "X${config_UserChoices_CompressionLevel}" = "X" ] ; then |
---|
135 | echo "NetCDF output files compression level is " ${config_UserChoices_CompressionLevel} |
---|
136 | listfile=$(ls file_def*dynamico.xml) |
---|
137 | for file in ${listfile} ; do |
---|
138 | sed -i -e "s/\(compression_level=\"\)[^\"]*\(\"\)/\1${config_UserChoices_CompressionLevel}\2/" ${file} |
---|
139 | done |
---|
140 | fi |
---|
141 | |
---|
142 | IGCM_debug_PopStack "ICO_Update" |
---|
143 | } |
---|
144 | |
---|
145 | #----------------------------------- |
---|
146 | function ICO_Finalize |
---|
147 | { |
---|
148 | IGCM_debug_PushStack "ICO_Finalize" |
---|
149 | |
---|
150 | IGCM_debug_PopStack "ICO_Finalize" |
---|
151 | } |
---|
152 | |
---|