source: branches/ORCHIDEE_2_2/ORCHIDEE_OL/OOL_SEC_STO_FG2nd/COMP/sechiba.driver

Last change on this file was 8572, checked in by josefine.ghattas, 5 weeks ago

Integrated from the trunk [8571]:

xml and driver : add new output file with mixed sechiba and stomate variables done to optimize output for the tuning of IPSLCM model (less variables and files). The variables in the new file were previously set up in experiment IPSLCM7/IPSLCM-reg/pdpiControl_TUNING.

intersurf : remove write at each time step

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