source: CONFIG/UNIFORM/v7/ICOLMDZOR_v7/GENERAL/DRIVER/dynamico.driver @ 4599

Last change on this file since 4599 was 4599, checked in by jgipsl, 5 years ago

Parameters optim_it and read_metric(new) are now changed by the driver depending on if the run is create_etat0_limit true or false.

File size: 5.4 KB
RevLine 
[4180]1#!/bin/ksh
2#-----------------------------------------------------------------
[4281]3function ICO_Initialize
[4180]4{
[4281]5    IGCM_debug_PushStack "ICO_Initialize"
[4180]6
[4281]7    ##- Horizontal resolution read from dynamic.card
8    if [ ! X${dynamico_UserChoices_RESOL_NBP} = X ] ; then
9        RESOL_NBP=${dynamico_UserChoices_RESOL_NBP}
[4180]10    else
[4323]11        # Exit
12        IGCM_debug_Exit "RESOL_NBP must be set in dynamico.card UserSection"
13    IGCM_debug_Verif_Exit
[4180]14    fi
15
[4281]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}
[4180]19    else
[4281]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
[4180]23    fi
24
[4281]25    IGCM_debug_PopStack "ICO_Initialize"
[4180]26}
27
28#-----------------------------------------------------------------
[4281]29function ICO_Update
[4180]30{
[4281]31    IGCM_debug_PushStack "ICO_Update"
[4180]32
[4372]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
[4318]41    IGCM_comp_modifyDefFile blocker run_dynamico.def run_length $(( ${PeriodLengthInDays} * 86400 ))
[4180]42
[4288]43    # Change run_dynamico.def according to UserChoices options set in dynmaico.card
44   
[4290]45    # Set create_etat0_limit=y or n and
[4288]46    if [ X${dynamico_UserChoices_create_etat0_limit} = Xy ] ; then 
47        # create_etat0_limit is set in dynamcio.card to y
[4290]48        # Activate create_etat0_limit=y in run_dynamico.def
[4288]49        IGCM_comp_modifyDefFile nonblocker run_dynamico.def create_etat0_limit y
50
51        # Use iflag_phys=101 or higher to activate aquaplanet mode
[4341]52        if [ X${dynamico_UserChoices_iflag_phys} = X ] || [ X${dynamico_UserChoices_iflag_phys} = X1 ]; then 
[4288]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
[4599]61
62        # Optimize the grid: set read_metric=n and optim_it=100000     
63        IGCM_comp_modifyDefFile nonblocker   run_dynamico.def   read_metric  n
64        IGCM_comp_modifyDefFile nonblocker   run_dynamico.def   optim_it     100000
[4288]65    else
[4290]66        # Deactivate create_etat0_limit to run a the GCM (aquaplanet or not)
[4288]67        IGCM_comp_modifyDefFile nonblocker run_dynamico.def create_etat0_limit   n
68        IGCM_comp_modifyDefFile nonblocker run_dynamico.def etat0                start_file
[4290]69
70        # Set iflag_phys even though it only will be read but not used for the case create_etat0_limit=n
71        if [ X${dynamico_UserChoices_iflag_phys} = X ] ||  X${dynamico_UserChoices_iflag_phys} = X1 ]; then 
72            # iflag_phys is not set or iflag_phys=1 => run is not an aquaplanet
73            IGCM_comp_modifyDefFile nonblocker run_dynamico.def iflag_phys           1
74        else
75            IGCM_comp_modifyDefFile nonblocker run_dynamico.def iflag_phys         ${dynamico_UserChoices_iflag_phys}
[4599]76        fi     
77
78        # Read grid from start.nc file: set read_metric=y and optim_it=0       
79        IGCM_comp_modifyDefFile nonblocker   run_dynamico.def   read_metric  y
80        IGCM_comp_modifyDefFile nonblocker   run_dynamico.def   optim_it     0
[4288]81    fi 
82
83
[4281]84    # Add include of context xml files for DYNAMICO in iodef.xml
[4190]85    # In iodef.xml add on the next line after "COMPONENT CONTEXT"
86    echo '<context id="icosagcm" src="./context_dynamico.xml"/>' >> add.tmp
87
88    # Add inclusion of file context_input_dynamico.xml if this file exists
89    if [ -f context_input_dynamico.xml ] ; then
90        echo '<context id="icosagcm" src="./context_input_dynamico.xml"/>' >> add.tmp
91    fi
92
93    # Include xml files for output configuration if running with workflow CMIP6
94    if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then
[4281]95      if [ -f ping_dynamico.xml ] ; then
96        echo '<context id="icosagcm" src="./ping_dynamico.xml"/>' >> add.tmp
97        echo '<context id="icosagcm" src="./dr2xml_dynamico.xml"/>' >> add.tmp
98      fi
[4190]99    fi
100    cp iodef.xml iodef.xml.tmp
101    sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml
102    rm iodef.xml.tmp add.tmp
103
104    # Add a Long Name as global attribute in output files if LongName is set in config.card
105    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
[4281]106      listfile=$(ls file_def*dynamico.xml)
[4190]107      echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
108      for file in ${listfile} ; do
109          cp ${file} ${file}.tmp
110          sed -e "/<file id/r add.tmp" \
111          ${file}.tmp > ${file}
112          rm ${file}.tmp
113      done
114      rm add.tmp
115    fi
116
[4357]117
118    # Compression level (if CompressionLevel is not empty)
119    if [ ! "X${config_UserChoices_CompressionLevel}" = "X" ] ; then
120        echo "NetCDF output files compression level is " ${config_UserChoices_CompressionLevel}
121        listfile=$(ls file_def*dynamico.xml)
122        for file in ${listfile} ; do
123            sed -i -e "s/\(compression_level=\"\)[^\"]*\(\"\)/\1${config_UserChoices_CompressionLevel}\2/" ${file}
124        done
125    fi
126
[4281]127    IGCM_debug_PopStack "ICO_Update"
[4180]128}
129
130#-----------------------------------
[4281]131function ICO_Finalize
[4180]132{
[4281]133    IGCM_debug_PushStack "ICO_Finalize"
[4180]134
[4281]135    IGCM_debug_PopStack "ICO_Finalize"
[4180]136}
137
Note: See TracBrowser for help on using the repository browser.