source: CONFIG_DEVT/ORCHIDEE_OL_TP/SPINUP_ANALYTIC_FG1/COMP/sechiba.driver @ 6327

Last change on this file since 6327 was 5570, checked in by aclsce, 3 years ago

Created ORCHIDEE_OL_TP configuration : temporary configuration to be used during prectical session.

  • Property svn:executable set to *
File size: 9.7 KB
Line 
1#!/bin/ksh
2## Driver for the component SRF corresponding to the sechiba part of ORCHIDEE
3
4#-----------------------------------------------------------------
5function SRF_Initialize
6{
7    IGCM_debug_PushStack "SRF_Initialize"
8
9    IGCM_debug_PopStack "SRF_Initialize"
10}
11
12#-----------------------------------------------------------------
13function SRF_Update
14{
15    IGCM_debug_PushStack "SRF_Update"
16
17    ## 1. Modifications in orchidee.def parameter file
18
19    # Activate STOMATE if the compontent SBG=stomate is set in config.card
20    if [ X${config_ListOfComponents_SBG} = Xstomate ] ; then
21        # Activate stomate in orchidee.def
22        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE y
23    else
24        # Deactivate stomate in orchidee.def
25        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE n
26        # Deactivate output files for stomate
27        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled .FALSE.
28        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_level 0
29        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq 1mo
30
31        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE.
32        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_level 0
33        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq 1mo
34
35        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 enabled .FALSE.
36        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_level 0
37        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_freq 1mo
38    fi
39
40    # Define in orchidee.def if restart file should be used
41    if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SRF_Restart}" = "n" ] ) ; then
42        IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in NONE
43
44        # Check if running executable teststomate. In that case sechiba restart file is mandatory.
45        if [ -f teststomate ] ; then
46            IGCM_debug_Print 1 "Error in launching teststomate !"
47            IGCM_debug_Exit    "YOU MUST USE EXISTING RESTART FILE FOR SECHIBA WITH JOB TESTSTOMATE!" 
48            IGCM_debug_Verif_Exit           
49        fi
50    else
51        IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in sechiba_rest_in.nc
52    fi
53
54
55    # Modify in orchidee.def VEGET_UPDATE if it is set in sechiba.card section UserChoices
56    # VEGET_UPDATE inidcates if the vegetation map should be updated and at which frequency
57    if [ ! X${sechiba_UserChoices_VEGET_UPDATE} = X ] ; then
58        # Take the value from sechiba.card
59        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE   ${sechiba_UserChoices_VEGET_UPDATE}
60    else
61        # Set default value 0Y
62        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 0Y
63    fi
64
65
66    # Activate the creation of river_desc.nc file only during the first execution in the simulation.
67    if [ ${CumulPeriod} -eq 1 ] ; then
68        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC y
69    else
70        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC n
71    fi
72
73
74
75    ## 2. Mangement of output and modifications of related xml files
76
77    # Set default values for sechiba1_enabled and sechiba1_freq.
78    # These variables are used only to modify file_def_orchidee.xml if XIOS=y
79    sechiba1_enabled=.FALSE.
80    sechiba2_enabled=.FALSE.
81    sechiba1_freq=0s
82    sechiba2_freq=0s
83    # These variables are used if XIOS=n
84    SECHIBA_WRITE_STEP=0
85    SECHIBA_WRITE_STEP2=0
86
87    if [ X${orchidee_ol_UserChoices_XIOS} = Xy ] ; then
88      # Activate XIOS output
89      IGCM_comp_modifyDefFile blocker orchidee.def XIOS_ORCHIDEE_OK y
90      # Deactivate IOIPSL output
91      IGCM_comp_modifyDefFile nonblocker orchidee.def WRITE_STEP 0
92    else
93      # Deactivate XIOS output
94      IGCM_comp_modifyDefFile blocker orchidee.def XIOS_ORCHIDEE_OK n
95    fi
96
97    # Get WriteFrenquecy for SRF (SECHIBA) from config.card
98    # 1 or 2 frequencies can be set in WriteFrenquecy for SRF
99    # The first frequency will always be used for the sechiba_history file and the
100    # second frequency will be used for the sechiba_out_2.nc file.
101    # The files are activated only if its corresponding frequency is set in WriteFrequency
102    ifreq=0
103    for frequency in ${config_SRF_WriteFrequency} ; do
104        case ${frequency} in
105            *Y|*y) 
106                NbYears=$( echo ${frequency} | awk -F '[yY]' '{print $1}' )
107                NbDaysYear=$( IGCM_date_DaysInYear ${year} )
108                file_enabled=.TRUE.
109                file_freq=${NbYears}y
110                (( file_WRITE_STEP = NbYears * NbDaysYear * 86400 )) ;;
111            *M|*m)
112                NbMonths=$( echo ${frequency} | awk -F '[mM]' '{print $1}' )
113                file_enabled=.TRUE.
114                file_freq=${NbMonths}mo
115                # Note only 1M possible with IOIPSL!
116                file_WRITE_STEP=-1. ;;
117            *D|*d)
118                NbDays=$( echo ${frequency} | awk -F '[dD]' '{print $1}' )
119                file_enabled=.TRUE.
120                file_freq=${NbDays}d
121                (( file_WRITE_STEP = NbDays * 86400 )) ;;
122            *s)
123                WriteInSeconds=$( echo ${frequency} | awk -F '[s]' '{print $1}' )
124                file_enabled=.TRUE.
125                file_freq=${WriteInSeconds}s
126                (( file_WRITE_STEP = WriteInSeconds )) ;;
127            HF|hf) 
128                file_enabled=.TRUE.
129                file_freq=10800s
130                (( file_WRITE_STEP = 10800 )) ;;
131            *) 
132                IGCM_debug_Exit "SRF_Update " ${frequency} " invalid WriteFrequency : choose in xY, xM, xD, xs and HF" 
133                IGCM_debug_Verif_Exit ;;
134        esac
135
136        (( ifreq = ifreq + 1 ))
137        case ${ifreq} in
138            1)
139                sechiba1_enabled=${file_enabled}
140                SECHIBA_WRITE_STEP=${file_WRITE_STEP} ;;
141            2)
142                sechiba2_enabled=${file_enabled}
143                SECHIBA_WRITE_STEP2=${file_WRITE_STEP} ;;
144            *)
145                IGCM_debug_Exit "SRF_Update: It is not possible to set more than 2 output files for sechiba from config.card"
146                IGCM_debug_Exit "You must correct WriteFrequancy in SRF secion in config.card."
147                IGCM_debug_Exit "Adapt file_def_orchidee.xml directly if you want more output files"
148                IGCM_debug_Verif_Exit ;;
149        esac
150    done
151
152    # Modify file_def_orchidee.xml if XIOS is activated
153    # Settings in config.card WriteFrequency are not used any more. The section above is only used for IOIPSL.
154    if [ X${orchidee_ol_UserChoices_XIOS} = Xy ] ; then
155        # Modify file_def_orchidee.xml file using settings from sechiba.card/orchidee.card
156        # We here suppose that for each file, in sechiba.card/orchidee.card UserChoices section, if the parameter
157        # output_level_filename is set, then also output_freq_filename must be set. The existance of output_freq_filename will not be checked.
158        # If output_level_filename=NONE or if it is not set, the corresponding file will be deactivated.
159
160        if [ X${sechiba_UserChoices_output_level_sechiba_history} = X ] || [ X${sechiba_UserChoices_output_level_sechiba_history} = XNONE ] ; then
161            # output_level_sechiba_history is not set in sechiba.card or it is set to NONE.
162            # Deactivate the file.
163            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled .FALSE.
164            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level 0
165            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq 1mo
166        else
167            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled      .TRUE.
168            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level ${sechiba_UserChoices_output_level_sechiba_history}
169            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq  ${sechiba_UserChoices_output_freq_sechiba_history}
170        fi
171
172        if [ X${sechiba_UserChoices_output_level_sechiba_out_2} = X ] || [ X${sechiba_UserChoices_output_level_sechiba_out_2} = XNONE ] ; then
173            # output_level_sechiba_out_2 is not set in sechiba.card or it is set to NONE.
174            # Deactivate the file.
175            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled .FALSE.
176            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level 0
177            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq 1mo
178        else
179            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled      .TRUE.
180            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level ${sechiba_UserChoices_output_level_sechiba_out_2}
181            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq  ${sechiba_UserChoices_output_freq_sechiba_out_2}
182        fi
183
184        if [ X${sechiba_UserChoices_output_level_sechiba_history_4dim} = X ] || [ X${sechiba_UserChoices_output_level_sechiba_history_4dim} = XNONE ] ; then
185            # output_level_sechiba_history_4dim is not set in sechiba.card or it is set to NONE.
186            # Deactivate the file.
187            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled .FALSE.
188            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level 0
189            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq 1mo
190        else
191            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled      .TRUE.
192            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level ${sechiba_UserChoices_output_level_sechiba_history_4dim}
193            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq  ${sechiba_UserChoices_output_freq_sechiba_history_4dim}
194        fi
195    fi
196
197
198    # Set IOIPSL output in orchidee.def. This is done for all cases only to avoid AUTO variables during run time.
199    IGCM_comp_modifyDefFile nonblocker orchidee.def WRITE_STEP ${SECHIBA_WRITE_STEP}
200    IGCM_comp_modifyDefFile nonblocker orchidee.def WRITE_STEP2 ${SECHIBA_WRITE_STEP2}
201
202    # Outputs HF in HISTFILE2 if required
203    if [ ${sechiba2_enabled} = .TRUE. ] ; then
204        IGCM_comp_modifyDefFile nonblocker orchidee.def SECHIBA_HISTFILE2 y
205    else
206        IGCM_comp_modifyDefFile nonblocker orchidee.def SECHIBA_HISTFILE2 n
207    fi
208
209
210    IGCM_debug_PopStack "SRF_Update"
211}
212
213#-----------------------------------------------------------------
214function SRF_Finalize
215{
216    IGCM_debug_PushStack "SRF_Finalize"
217
218    IGCM_debug_PopStack "SRF_Finalize"
219}
Note: See TracBrowser for help on using the repository browser.