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