source: CONFIG_DEVT/ORCHIDEE_OL_TP/SPINUP_ANALYTIC_FG1/COMP/stomate.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.

File size: 9.3 KB
Line 
1#!/bin/ksh
2## Driver for the component SBG corresponding to the stomate part of ORCHIDEE
3
4#-----------------------------------------------------------------
5function SBG_Initialize
6{
7    IGCM_debug_PushStack "SBG_Initialize"
8
9    IGCM_debug_PopStack "SBG_Initialize"
10}
11
12#-----------------------------------------------------------------
13function SBG_Update
14{
15    IGCM_debug_PushStack "SBG_Update"
16
17    # For IOIPSL: get frequency from config.card
18    # Set default values for stomate output files.
19    # These variables are used only to modify file_def_orchidee.xml if XIOS=y
20    stomate_enabled=.FALSE.
21    stomate_freq=0s
22
23    # Read WriteFrequency set in config.card section SBG.
24    # Only one choice can be set as WriteFrequency. The same choice will be used for
25    # both stomate_history and stomate_ipcc_history files.
26    case ${config_SBG_WriteFrequency} in
27        *Y|*y) 
28            NbYears=$( echo ${config_SBG_WriteFrequency} | awk -F '[yY]' '{print $1}' )
29            NbDaysYear=$( IGCM_date_DaysInYear ${year} )
30            stomate_enabled=.TRUE.
31            stomate_freq=${NbYears}y
32            (( STOMATE_WRITE_STEP = NbYears * NbDaysYear )) 
33        ;;
34        *M|*m) 
35            NbMonths=$( echo ${config_SBG_WriteFrequency} | awk -F '[mM]' '{print $1}' )
36            stomate_enabled=.TRUE.
37            stomate_freq=${NbMonths}mo
38            # Note only 1M possible with IOIPSL!
39            STOMATE_WRITE_STEP=-1. ;;
40        *D|*d)
41            NbDays=$( echo ${config_SBG_WriteFrequency} | awk -F '[dD]' '{print $1}' )
42            stomate_enabled=.TRUE.
43            stomate_freq=${NbDays}d
44            STOMATE_WRITE_STEP=${NbDays} ;;
45    esac
46
47    # Modify file_def_orchidee.xml if XIOS is activated using information in stomate.card
48    # Settings in config.card WriteFrequency are not used any more.
49    if [ X${orchidee_ol_UserChoices_XIOS} = Xy ] ; then
50
51        # Modify file_def_orchidee.xml file using settings from stomate.card
52        # We here suppose that for each file, in stomate.card UserChoices section, if the parameter
53        # output_level_filename is set, then also output_freq_filename must be set. The existance of output_freq_filename will not be checked.
54        # If output_level_filename=NONE or if it is not set, the corresponding file will be deactivated.
55
56        if [ X${stomate_UserChoices_output_level_stomate_history} = X ] || [ X${stomate_UserChoices_output_level_stomate_history} = XNONE ] ; then
57            # output_level_stomate_history is not set in stomate.card or it is set to NONE.
58            # Deactivate the file.
59            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled .FALSE.
60            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_level 0
61            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq 1mo
62        else
63            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled      .TRUE.
64            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_level ${stomate_UserChoices_output_level_stomate_history}
65            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq  ${stomate_UserChoices_output_freq_stomate_history}
66        fi
67
68        if [ X${stomate_UserChoices_output_level_stomate_ipcc_history} = X ] || [ X${stomate_UserChoices_output_level_stomate_ipcc_history} = XNONE ] ; then
69            # output_level_stomate_ipcc_history is not set in stomate.card or it is set to NONE.
70            # Deactivate the file.
71            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE.
72            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_level 0
73            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq 1mo
74        else
75            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled      .TRUE.
76            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_level ${stomate_UserChoices_output_level_stomate_ipcc_history}
77            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq  ${stomate_UserChoices_output_freq_stomate_ipcc_history}
78        fi
79    if [ X${stomate_UserChoices_output_level_stomate_history_4dim} = X ] || [ X${stomate_UserChoices_output_level_stomate_history_4dim} = XNONE ] ; then
80        # output_level_stomate_history is not set in stomate.card or it is set to NONE.
81        # Deactivate the file.
82        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 enabled .FALSE.
83        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_level 0
84        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_freq 1mo
85    else
86        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 enabled      .TRUE.
87        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_level ${stomate_UserChoices_output_level_stomate_history_4dim}
88        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_freq  ${stomate_UserChoices_output_freq_stomate_history_4dim}
89    fi
90
91        if [ X${stomate_UserChoices_output_level_stomate_history_4dim} = X ] || [ X${stomate_UserChoices_output_level_stomate_history_4dim} = XNONE ] ; then
92            # output_level_stomate_history_4dim is not set in stomate.card or it is set to NONE.
93            # Deactivate the file.
94            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 enabled .FALSE.
95            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_level 0
96            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_freq 1mo
97        else
98            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 enabled      .TRUE.
99            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_level ${stomate_UserChoices_output_level_stomate_history_4dim}
100            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_freq  ${stomate_UserChoices_output_freq_stomate_history_4dim}
101        fi
102
103
104
105        # Deactivate stomate IOIPSL output
106        (( STOMATE_WRITE_STEP = 0 ))
107    fi
108
109
110    if [ X${stomate_UserChoices_SPINUP_ANALYTIC} = Xy ] ; then
111       IGCM_comp_modifyDefFile nonblocker orchidee.def SPINUP_ANALYTIC y
112     
113       # Test if CyclicBegin and CyclicEnd is set in config.card
114       if ( [ X${config_UserChoices_CyclicBegin} = X ] || [ X${config_UserChoices_CyclicEnd} = X ] ) ; then
115           IGCM_debug_Exit "CyclicBegin and CyclicEnd must be set in config.card to run option spinup_analytic."
116       fi
117       # Calculate and set number of years of forcing data
118       CycleNb=$(( ${config_UserChoices_CyclicEnd} - ${config_UserChoices_CyclicBegin} + 1 ))
119       IGCM_comp_modifyDefFile nonblocker orchidee.def SPINUP_PERIOD ${CycleNb}
120    else
121        IGCM_comp_modifyDefFile nonblocker orchidee.def SPINUP_ANALYTIC n
122        IGCM_comp_modifyDefFile nonblocker orchidee.def SPINUP_PERIOD -1
123    fi
124
125    IGCM_comp_modifyDefFile nonblocker orchidee.def STOMATE_HIST_DT ${STOMATE_WRITE_STEP}
126    IGCM_comp_modifyDefFile nonblocker orchidee.def STOMATE_IPCC_HIST_DT ${STOMATE_WRITE_STEP}
127
128    if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SBG_Restart}" = "n" ] ) ; then
129        echo "STOMATE : without restart"
130        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_RESTART_FILEIN NONE
131    else
132        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_RESTART_FILEIN stomate_rest_in.nc
133    fi
134
135
136    # Special case using forcesoil executable
137    if [ -f forcesoil ] ; then
138        # Set STOMATE_CFORCING_NAME
139        IGCM_comp_modifyDefFile nonblocker orchidee.def STOMATE_CFORCING_NAME stomate_Cforcing.nc
140
141        # Check if restart file is missing
142        if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SBG_Restart}" = "n" ] ) ; then
143            IGCM_debug_Exit "YOU MUST USE OLD STOMATE RESTART FILE WITH THE JOB FORCESOIL."
144            IGCM_debug_Verif_Exit
145        fi
146    else
147        IGCM_comp_modifyDefFile nonblocker orchidee.def STOMATE_CFORCING_NAME NONE
148    fi
149
150
151
152    # Modify in orchidee.def NINPUT_UPDATE if it is set in stomate.card section UserChoices
153    # NINPUT_UPDATE inidcates if the nitrogen maps should be updated and at which frequency
154    if [ ! X${stomate_UserChoices_NINPUT_UPDATE} = X ] ; then
155        # Take the value from stomate.card
156        IGCM_comp_modifyDefFile nonblocker orchidee.def NINPUT_UPDATE   ${stomate_UserChoices_NINPUT_UPDATE}
157    else
158        # Set default value 0Y
159        IGCM_comp_modifyDefFile nonblocker orchidee.def NINPUT_UPDATE 0Y
160    fi
161
162    # Modify in orchidee.def STOMATE_IMPOSE_CN if it is set in stomate.card section UserChoices
163    # STOMATE_IMPOSE_CN inidcates if the nitrogen should be imposed or not.
164    if [ ! X${stomate_UserChoices_STOMATE_IMPOSE_CN} = X ] ; then
165        # Take the value from stomate.card
166        IGCM_comp_modifyDefFile nonblocker orchidee.def STOMATE_IMPOSE_CN   ${stomate_UserChoices_STOMATE_IMPOSE_CN}
167    else
168        # Set default value n (nitrogen is not imposed)
169        IGCM_comp_modifyDefFile nonblocker orchidee.def STOMATE_IMPOSE_CN n
170    fi
171
172    IGCM_debug_PopStack "SBG_Update"
173}
174
175#-----------------------------------------------------------------
176function SBG_Finalize
177{
178    IGCM_debug_PushStack "SBG_Finalize"
179
180#   Check if equilibrium is reached for spinup analytic
181#   and if true stop the simulation in the end of this period.
182    if [ X${stomate_UserChoices_SPINUP_ANALYTIC} = Xy ] ; then
183      CondSpinup=$(grep -a  "Equilibrium for carbon pools is reached"  out_*)
184      if [ X"${CondSpinup}" != X ] ; then
185          IGCM_debug_Print 1 "SPINUP ANALYTIC :  your spinup is successful :"
186          IGCM_debug_Print 1 ${CondSpinup}
187          IGCM_debug_Print 1  "You can now stop the simulation if you want."
188      fi
189    fi
190
191    IGCM_debug_PopStack "SBG_Finalize"
192}
Note: See TracBrowser for help on using the repository browser.