source: CONFIG/UNIFORM/v6/IPSLESM6/GENERAL/DRIVER/orchidee.driver

Last change on this file was 4294, checked in by acosce, 5 years ago

Add possibility to manage in orchidee.card the interaction between surf and chm (chemistry_bvoc). Desactivate by default except in IPSLCM5A2CHT

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