source: CONFIG_DEVT/ORCHIDEE_OL_TP/OOL_SEC_STO_FG2/COMP/stomate.driver @ 5577

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

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

File size: 8.4 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
80
81        if [ X${stomate_UserChoices_output_level_stomate_history_4dim} = X ] || [ X${stomate_UserChoices_output_level_stomate_history_4dim} = XNONE ] ; then
82            # output_level_stomate_history_4dim is not set in stomate.card or it is set to NONE.
83            # Deactivate the file.
84            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 enabled .FALSE.
85            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_level 0
86            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_freq 1mo
87        else
88            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 enabled      .TRUE.
89            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_level ${stomate_UserChoices_output_level_stomate_history_4dim}
90            IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_freq  ${stomate_UserChoices_output_freq_stomate_history_4dim}
91        fi
92
93        # Deactivate stomate IOIPSL output
94        (( STOMATE_WRITE_STEP = 0 ))
95    fi
96
97
98    if [ X${stomate_UserChoices_SPINUP_ANALYTIC} = Xy ] ; then
99       IGCM_comp_modifyDefFile nonblocker orchidee.def SPINUP_ANALYTIC y
100     
101       # Test if CyclicBegin and CyclicEnd is set in config.card
102       if ( [ X${config_UserChoices_CyclicBegin} = X ] || [ X${config_UserChoices_CyclicEnd} = X ] ) ; then
103           IGCM_debug_Exit "CyclicBegin and CyclicEnd must be set in config.card to run option spinup_analytic."
104       fi
105       # Calculate and set number of years of forcing data
106       CycleNb=$(( ${config_UserChoices_CyclicEnd} - ${config_UserChoices_CyclicBegin} + 1 ))
107       IGCM_comp_modifyDefFile nonblocker orchidee.def SPINUP_PERIOD ${CycleNb}
108    else
109        IGCM_comp_modifyDefFile nonblocker orchidee.def SPINUP_ANALYTIC n
110        IGCM_comp_modifyDefFile nonblocker orchidee.def SPINUP_PERIOD -1
111    fi
112
113    IGCM_comp_modifyDefFile nonblocker orchidee.def STOMATE_HIST_DT ${STOMATE_WRITE_STEP}
114    IGCM_comp_modifyDefFile nonblocker orchidee.def STOMATE_IPCC_HIST_DT ${STOMATE_WRITE_STEP}
115
116    if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SBG_Restart}" = "n" ] ) ; then
117        echo "STOMATE : without restart"
118        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_RESTART_FILEIN NONE
119    else
120        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_RESTART_FILEIN stomate_rest_in.nc
121    fi
122
123
124    # Special case using forcesoil executable
125    if [ -f forcesoil ] ; then
126        # Set STOMATE_CFORCING_NAME
127        IGCM_comp_modifyDefFile nonblocker orchidee.def STOMATE_CFORCING_NAME stomate_Cforcing.nc
128
129        # Check if restart file is missing
130        if ( [ ${CumulPeriod} -eq 1 ] && [ "${config_SBG_Restart}" = "n" ] ) ; then
131            IGCM_debug_Exit "YOU MUST USE OLD STOMATE RESTART FILE WITH THE JOB FORCESOIL."
132            IGCM_debug_Verif_Exit
133        fi
134    else
135        IGCM_comp_modifyDefFile nonblocker orchidee.def STOMATE_CFORCING_NAME NONE
136    fi
137
138
139
140    # Modify in orchidee.def NINPUT_UPDATE if it is set in stomate.card section UserChoices
141    # NINPUT_UPDATE inidcates if the nitrogen maps should be updated and at which frequency
142    if [ ! X${stomate_UserChoices_NINPUT_UPDATE} = X ] ; then
143        # Take the value from stomate.card
144        IGCM_comp_modifyDefFile nonblocker orchidee.def NINPUT_UPDATE   ${stomate_UserChoices_NINPUT_UPDATE}
145    else
146        # Set default value 0Y
147        IGCM_comp_modifyDefFile nonblocker orchidee.def NINPUT_UPDATE 0Y
148    fi
149
150    # Modify in orchidee.def STOMATE_IMPOSE_CN if it is set in stomate.card section UserChoices
151    # STOMATE_IMPOSE_CN inidcates if the nitrogen should be imposed or not.
152    if [ ! X${stomate_UserChoices_STOMATE_IMPOSE_CN} = X ] ; then
153        # Take the value from stomate.card
154        IGCM_comp_modifyDefFile nonblocker orchidee.def STOMATE_IMPOSE_CN   ${stomate_UserChoices_STOMATE_IMPOSE_CN}
155    else
156        # Set default value n (nitrogen is not imposed)
157        IGCM_comp_modifyDefFile nonblocker orchidee.def STOMATE_IMPOSE_CN n
158    fi
159
160    IGCM_debug_PopStack "SBG_Update"
161}
162
163#-----------------------------------------------------------------
164function SBG_Finalize
165{
166    IGCM_debug_PushStack "SBG_Finalize"
167
168#   Check if equilibrium is reached for spinup analytic
169#   and if true stop the simulation in the end of this period.
170    if [ X${stomate_UserChoices_SPINUP_ANALYTIC} = Xy ] ; then
171      CondSpinup=$(grep -a  "Equilibrium for carbon pools is reached"  out_*)
172      if [ X"${CondSpinup}" != X ] ; then
173          IGCM_debug_Print 1 "SPINUP ANALYTIC :  your spinup is successful :"
174          IGCM_debug_Print 1 ${CondSpinup}
175          IGCM_debug_Print 1  "You can now stop the simulation if you want."
176      fi
177    fi
178
179    IGCM_debug_PopStack "SBG_Finalize"
180}
Note: See TracBrowser for help on using the repository browser.