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