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

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

Set compression_level=2 from config.card as done in IPSLCM6.

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