source: CONFIG/UNIFORM/v7/ICOLMDZORINCA_v7/GENERAL/DRIVER/dynamico.driver @ 5711

Last change on this file since 5711 was 5711, checked in by acosce, 3 years ago

for ICOLMDZORINCA_v7 config add the possibility to read nqtot from pre-process inca file and write it automatically in run_dynamico.def

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