source: CONFIG_DEVT/ORCHIDEE_OL_TP/OOL_SEC_STO_FG1transnd/COMP/orchideedriver.driver @ 6898

Last change on this file since 6898 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: 3.6 KB
Line 
1#!/bin/ksh
2
3#-----------------------------------------------------------------
4function OOL_Initialize
5{
6    IGCM_debug_PushStack "OOL_Initialize"
7
8     ##- Define variable DefSuffix set in orchidee_ol.card
9     ##  This variable is used in orchidee_ol.card to choose
10     ##  parameter file (orchidee_pft.def_DefSuffix).
11     if [ ! X${orchidee_ol_UserChoices_DefSuffix} = X ] ; then
12         DefSuffix=${orchidee_ol_UserChoices_DefSuffix}
13     else
14         # Default value used if DefSuffix is not set in orchidee_ol.card
15         DefSuffix=15pft.1ac
16     fi
17
18     IGCM_debug_PopStack "OOL_Initialize"
19}
20
21#-----------------------------------------------------------------
22function OOL_Update
23{
24    IGCM_debug_PushStack "OOL_Update"
25
26    # Set start and end date based on information from config.card
27    HumanDateBegin=$(   IGCM_date_ConvertFormatToHuman ${PeriodDateBegin} )
28    IGCM_comp_modifyDefFile nonblocker run.def START_DATE ${HumanDateBegin}" 00:00:00"
29    HumanDateEnd=$(     IGCM_date_ConvertFormatToHuman ${PeriodDateEnd} )
30    IGCM_comp_modifyDefFile nonblocker run.def END_DATE ${HumanDateEnd}" 24:00:00"
31   
32    # Set RESTART_FILEIN in run.def
33    if ( ${FirstInitialize} && [ "${config_OOL_Restart}" = "n" ] ) ; then
34        # Set RESTART_FILEIN=NONE in run.def
35        IGCM_comp_modifyDefFile blocker run.def RESTART_FILEIN NONE
36    else
37        # Default option using restart file, set RESTART_FILEIN=driver_rest_in.nc in run.def
38        IGCM_comp_modifyDefFile blocker run.def RESTART_FILEIN driver_rest_in.nc
39    fi
40
41    if [ -f CO2.txt ] ; then
42        # If this file exist, then read CO2 value and set ATM_CO2 in run.def
43        IPCC_CO2=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'`
44        if [ X"${IPCC_CO2}" = X ] ; then
45            # The grep returned empty variable: stop execution
46            IGCM_debug_Exit "The file CO2.txt do not contain the current year."
47            IGCM_debug_Verif_Exit
48        fi
49        IGCM_comp_modifyDefFile nonblocker run.def ATM_CO2 ${IPCC_CO2}
50    else
51        # The file is not available: take the default value from run.def.
52        # The syntax in run.def must be respected, for example:
53        # ATM_CO2 = _AUTO_: DEFAULT = 350.
54        IGCM_comp_modifyDefFile nonblocker run.def ATM_CO2 DEFAULT
55    fi
56
57
58    # Activation of XIOS
59    if [ X${orchideedriver_UserChoices_XIOS} = Xy ] ; then
60      # Add include of orchidee context in iodef.xml
61      # In iodef.xml add on next line after "COMPONENT CONTEXT"
62      #  <context id="orchidee" src="./context_orchidee.xml"/>
63      echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
64      # Add inclusion of file context_input_orchidee.xml if this file exists
65      if [ -f context_input_orchidee.xml ] ; then
66          echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp
67      fi
68      cp iodef.xml iodef.xml.tmp
69      sed -e "/COMPONENT CONTEXT/r add.tmp" \
70        iodef.xml.tmp > iodef.xml
71      rm iodef.xml.tmp add.tmp
72
73    fi
74
75
76    # Add LongName as global attribute in all files produced by XIOS (if LongName is not empty)
77    # Remove file_def_input_orchidee.xml from the list.
78    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
79        listfile=$(ls file_def*orchidee.xml | grep -v input)
80        echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
81        for file in ${listfile} ; do
82            cp ${file} ${file}.tmp
83            sed -e "/<file id/r add.tmp" \
84                ${file}.tmp > ${file}
85            rm ${file}.tmp
86        done
87        rm add.tmp
88    fi
89         
90    IGCM_debug_PopStack "OOL_Update"
91}
92
93#-----------------------------------------------------------------
94function OOL_Finalize
95{
96    IGCM_debug_PushStack "OOL_Finalize"
97   
98    IGCM_debug_PopStack "OOL_Finalize"
99}
Note: See TracBrowser for help on using the repository browser.