source: CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/DRIVER/orchidee.driver @ 3545

Last change on this file since 3545 was 3537, checked in by jgipsl, 6 years ago

Added option VEGET_UPDATE_at_start in orchidee.card and driver. This option is set to yes in all control simulations to be sure to take the vegetation file and woodharvest file set in orchidee.card instead of those stored in the restart file. The input files must be in BoundaryFiles because InitialStatFiles? will not be copied for the case if starting with restart file.

By default, VEGET_UPDATE_at_start=n and nothing will be done.

File size: 6.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_freq 1mo
37        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE.
38        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq 1mo
39    fi
40
41    # Define in orchidee.def if restart file should be used
42    if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then
43        IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in sechiba_rest_in.nc
44    else
45        IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in NONE
46    fi
47
48    # 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)
49    if [ X${orchidee_UserChoices_VEGET_UPDATE_at_start} = Xy ] && [ ${CumulPeriod} -eq 1 ] ; then
50        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE   1Y
51    fi
52
53    # Modify in orchidee.def VEGET_UPDATE if it is set in orchidee.card section UserChoices
54    # Note: if the variable has been set by VEGET_UPDATE_at_start, this section will not overwrite it.
55    if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then
56        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE   ${orchidee_UserChoices_VEGET_UPDATE}
57    else
58        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 0Y
59    fi
60
61    # Activate creation of river description file only for the first period
62    if [ ${CumulPeriod} -eq 1 ] ; then
63        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC y
64    else
65        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC n
66    fi
67
68
69    ## 2. Mangement of output and modifications of related xml files
70
71    # Set default values for sechiba1_enabled and sechiba1_freq.
72    # These variables are used only to modify file_def_orchidee.xml
73    sechiba1_enabled=.FALSE.
74    sechiba2_enabled=.FALSE.
75    sechiba1_freq=0s
76    sechiba2_freq=0s
77
78
79    # Get WriteFrenquecy for SRF (SECHIBA) from config.card
80    # 1 or 2 frequencies can be set in WriteFrenquecy for SRF
81    # The first frequency will always be used for the sechiba_history file and the
82    # second frequency will be used for the sechiba_out_2.nc file.
83    # The files are activated only if its corresponding frequency is set in WriteFrequency
84    ifreq=0
85    for frequency in ${config_SRF_WriteFrequency} ; do
86        case ${frequency} in
87            *Y|*y) 
88                NbYears=$( echo ${frequency} | awk -F '[yY]' '{print $1}' )
89                NbDaysYear=$( IGCM_date_DaysInYear ${year} )
90                file_enabled=.TRUE.
91                file_freq=${NbYears}y ;;
92            *M|*m)
93                NbMonths=$( echo ${frequency} | awk -F '[mM]' '{print $1}' )
94                file_enabled=.TRUE.
95                file_freq=${NbMonths}mo ;;
96            *D|*d)
97                NbDays=$( echo ${frequency} | awk -F '[dD]' '{print $1}' )
98                file_enabled=.TRUE.
99                file_freq=${NbDays}d ;;
100            *s)
101                WriteInSeconds=$( echo ${frequency} | awk -F '[s]' '{print $1}' )
102                file_enabled=.TRUE.
103                file_freq=${WriteInSeconds}s ;;
104            HF|hf) 
105                file_enabled=.TRUE.
106                file_freq=10800s ;;
107            *) 
108                IGCM_debug_Exit "SRF_Update " ${frequency} " invalid WriteFrequency : choose in xY, xM, xD, xs and HF" 
109                IGCM_debug_Verif_Exit ;;
110        esac
111
112        (( ifreq = ifreq + 1 ))
113        case ${ifreq} in
114            1)
115                sechiba1_enabled=${file_enabled}
116                sechiba1_freq=${file_freq} ;;
117            2)
118                sechiba2_enabled=${file_enabled}
119                sechiba2_freq=${file_freq} ;;
120        *)
121                IGCM_debug_Exit "SRF_Update: It is not possible to set more than 2 output files for sechiba from config.card"
122                IGCM_debug_Exit "You must correct WriteFrequancy in SRF secion in config.card."
123                IGCM_debug_Exit "Adapt file_def_orchidee.xml directly if you want more output files"
124                IGCM_debug_Verif_Exit ;;
125        esac
126    done
127
128
129    # Modify file_def_orchidee.xml file
130    IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled ${sechiba1_enabled}
131    IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq ${sechiba1_freq}
132    IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled ${sechiba2_enabled}
133    IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq ${sechiba2_freq}
134    # Use same values for sechiba1 and for sechiba3 files
135    IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled ${sechiba1_enabled}
136    IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq ${sechiba1_freq}
137   
138
139    # Add include of orchidee context in iodef.xml
140    # In iodef.xml add on next line after "COMPONENT CONTEXT"
141    #  <context id="orchidee" src="./context_orchidee.xml"/>
142    echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
143    if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then
144        echo '<context id="orchidee" src="./ping_orchidee.xml"/>' >> add.tmp
145        echo '<context id="orchidee" src="./dr2xml_orchidee.xml"/>' >> add.tmp
146    fi
147    cp iodef.xml iodef.xml.tmp
148    sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml
149    rm iodef.xml.tmp add.tmp
150
151    # Add LongName as global attribute in XIOS output files (if LongName is not empty)
152    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
153        listfile=$(ls file_def*orchidee.xml)
154        echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
155        for file in ${listfile}
156        do
157            cp ${file} ${file}.tmp
158            sed -e "/<file id/r add.tmp" \
159                ${file}.tmp > ${file}
160            rm ${file}.tmp
161        done
162        rm add.tmp
163    fi
164
165
166    IGCM_debug_PopStack "SRF_Update"
167}
168
169#-----------------------------------------------------------------
170function SRF_Finalize
171{
172    IGCM_debug_PushStack "SRF_Finalize"
173
174    IGCM_debug_PopStack "SRF_Finalize"
175}
Note: See TracBrowser for help on using the repository browser.