source: CMIP6/DECK/CM61-LR-pi-03/DRIVER/orchidee.driver @ 3900

Last change on this file since 3900 was 3900, checked in by mafoipsl, 6 years ago

Second try to record CMIP6 piControl experiment : CM61-LR-pi-03

File size: 7.8 KB
Line 
1#!/bin/ksh
2## Driver for the component SRF corresponding to the sechiba part of ORCHIDEE
3#-----------------------------------------------------------------
4function SRF_Initialize
5{
6    IGCM_debug_PushStack "SRF_Initialize"
7
8    ##- Define variable DefSuffix set in orchidee.card
9    ##  This variable is used in orchidee.card to choose
10    ##  parameter file(orchidee.def_DefSuffix).
11    if [ ! X${orchidee_UserChoices_DefSuffix} = X ] ; then
12        DefSuffix=${orchidee_UserChoices_DefSuffix}
13    else
14        DefSuffix=Choi
15    fi
16
17    IGCM_debug_PopStack "SRF_Initialize"
18}
19
20#-----------------------------------------------------------------
21function SRF_Update
22{
23    IGCM_debug_PushStack "SRF_Update"
24
25    ## 1. Modifications in orchidee.def parameter file
26
27    # Activate STOMATE if the compontent SBG=stomate is set in config.card
28    if [ X${config_ListOfComponents_SBG} = Xstomate ] ; then
29        # Activate stomate in orchidee.def
30        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE y
31    else
32        # Deactivate stomate in orchidee.def
33        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE n
34        # Deactivate output files for stomate
35        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled .FALSE.
36        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_level 0
37        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq 1mo
38        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE.
39        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_level 0
40        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq 1mo
41    fi
42
43    # Define in orchidee.def if restart file should be used
44    if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then
45        IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in sechiba_rest_in.nc
46    else
47        IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in NONE
48    fi
49
50    # Set VEGET_UPDATE=1Y in orchidee.def if VEGET_UPDATE_at_start=y in orchidee.card and if it is the first cumul periond (start of new simulation)
51    if [ X${orchidee_UserChoices_VEGET_UPDATE_at_start} = Xy ] && [ ${CumulPeriod} -eq 1 ] ; then
52        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE   1Y
53    fi
54
55    # Modify in orchidee.def VEGET_UPDATE if it is set in orchidee.card section UserChoices
56    # Note: if the variable has been set by VEGET_UPDATE_at_start, this section will not overwrite it.
57    if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then
58        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE   ${orchidee_UserChoices_VEGET_UPDATE}
59    else
60        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 0Y
61    fi
62
63    # Set LAI_MAP in orchidee.def acording to value set in orchidee.card section UserChoices
64    # If LAI_MAP is not definded in orchidee.card, set default value n
65    # Note: this option is only read by ORCHIDEE if starting without restart files
66    if [ ! X${orchidee_UserChoices_LAI_MAP} = X ] ; then
67        IGCM_comp_modifyDefFile nonblocker orchidee.def LAI_MAP   ${orchidee_UserChoices_LAI_MAP}
68    else
69        IGCM_comp_modifyDefFile nonblocker orchidee.def LAI_MAP   DEFAULT
70    fi
71
72    # Activate creation of river description file only for the first period
73    if [ ${CumulPeriod} -eq 1 ] ; then
74        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC y
75    else
76        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC n
77    fi
78
79
80    ## 2. Mangement of output and modifications of related xml files
81    # Modify file_def_orchidee.xml file using settings from orchidee.card
82    # We here suppose that for each file, in orchidee.card UserChoices section, if the parameter
83    # output_level_filename is set, then also output_freq_filename must be set. The existance of output_freq_filename will not be checked.
84    # If output_level_filename=NONE or if it is not set, the corresponding file will be deactivated.
85    # Settings in config.card WriteFrequency are not used any more.
86   
87    if [ X${orchidee_UserChoices_output_level_sechiba_history} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history} = XNONE ] ; then
88        # output_level_sechiba_history is not set in orchidee.card or it is set to NONE.
89        # Deactivate the file.
90        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled .FALSE.
91        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level 0
92        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq 1mo
93    else
94        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled      .TRUE.
95        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level ${orchidee_UserChoices_output_level_sechiba_history}
96        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq  ${orchidee_UserChoices_output_freq_sechiba_history}
97    fi
98   
99    if [ X${orchidee_UserChoices_output_level_sechiba_out_2} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_out_2} = XNONE ] ; then
100        # output_level_sechiba_out_2 is not set in orchidee.card or it is set to NONE.
101        # Deactivate the file.
102        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled .FALSE.
103        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level 0
104        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq 1mo
105    else
106        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled      .TRUE.
107        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level ${orchidee_UserChoices_output_level_sechiba_out_2}
108        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq  ${orchidee_UserChoices_output_freq_sechiba_out_2}
109    fi
110   
111    if [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = XNONE ] ; then
112        # output_level_sechiba_history_4dim is not set in orchidee.card or it is set to NONE.
113        # Deactivate the file.
114        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled .FALSE.
115        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level 0
116        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq 1mo
117    else
118        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled      .TRUE.
119        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level ${orchidee_UserChoices_output_level_sechiba_history_4dim}
120        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq  ${orchidee_UserChoices_output_freq_sechiba_history_4dim}
121    fi
122       
123
124    # Add include of orchidee context in iodef.xml
125    # In iodef.xml add on next line after "COMPONENT CONTEXT"
126    #  <context id="orchidee" src="./context_orchidee.xml"/>
127    echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
128    if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then
129        echo '<context id="orchidee" src="./ping_orchidee.xml"/>' >> add.tmp
130        echo '<context id="orchidee" src="./dr2xml_orchidee.xml"/>' >> add.tmp
131    fi
132    cp iodef.xml iodef.xml.tmp
133    sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml
134    rm iodef.xml.tmp add.tmp
135
136    # Add LongName as global attribute in XIOS output files (if LongName is not empty)
137    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
138        listfile=$(ls file_def*orchidee.xml)
139        echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
140        for file in ${listfile}
141        do
142            cp ${file} ${file}.tmp
143            sed -e "/<file id/r add.tmp" \
144                ${file}.tmp > ${file}
145            rm ${file}.tmp
146        done
147        rm add.tmp
148    fi
149
150
151    IGCM_debug_PopStack "SRF_Update"
152}
153
154#-----------------------------------------------------------------
155function SRF_Finalize
156{
157    IGCM_debug_PushStack "SRF_Finalize"
158
159    IGCM_debug_PopStack "SRF_Finalize"
160}
Note: See TracBrowser for help on using the repository browser.