source: branches/ORCHIDEE_2_2/ORCHIDEE_OL/OOL_SEC_STO_FG2/COMP/orchidee_ol.driver @ 7421

Last change on this file since 7421 was 5567, checked in by josefine.ghattas, 6 years ago

Update of configuration files needed according to changeset [5565] done on the trunk.

  • Added copy of input file context_input_orchidee.xml
  • Removed copy of input file file_def_input_orchidee.xml
  • Updated drivers to include the file context_input_orchidee.xml in iodef.xml
File size: 5.4 KB
Line 
1#!/bin/ksh
2
3#-----------------------------------------------------------------
4function OOL_Initialize
5{
6    IGCM_debug_PushStack "OOL_Initialize"
7
8    IGCM_debug_PopStack "OOL_Initialize"
9}
10
11#-----------------------------------------------------------------
12function OOL_Update
13{
14    IGCM_debug_PushStack "OOL_Update"
15
16    # Set TIME_LENGTH in run.def depending on PeriodLenght in config.card
17    case ${config_UserChoices_PeriodLength} in
18        *M|*m|*D|*d)
19            IGCM_comp_modifyDefFile nonblocker run.def TIME_LENGTH ${PeriodLengthInDays}D
20            ;;
21        *s|*Y)
22            IGCM_comp_modifyDefFile nonblocker run.def TIME_LENGTH ${config_UserChoices_PeriodLength}
23            ;;
24        *)
25            IGCM_debug_Exit "OOL_Update " ${config_UserChoices_PeriodLength} " invalid PeriodLength in config.card : choose between 1Y, 1M, 5D, 1D."
26            IGCM_debug_Verif_Exit
27    esac
28   
29
30    # Set TIME_SKIP only if starting without restart file
31    if ( ${FirstInitialize} && [ "${config_OOL_Restart}" = "n" ] ) ; then
32        # Calculate the TIME_SKIP as difference between the start date and 1th of January the same year
33        IGCM_comp_modifyDefFile nonblocker run.def TIME_SKIP $( IGCM_date_DaysBetweenGregorianDate ${DateBegin} ${year}0101 )D
34    else
35        # Here using restart file, set TIME_SKIP=0
36        IGCM_comp_modifyDefFile nonblocker run.def TIME_SKIP 0D
37    fi
38
39    # Set RESTART_FILEIN in run.def
40    if ( ${FirstInitialize} && [ "${config_OOL_Restart}" = "n" ] ) ; then
41        # Set RESTART_FILEIN=NONE in run.def
42        IGCM_comp_modifyDefFile blocker run.def RESTART_FILEIN NONE
43    else
44        # Default option using restart file, set RESTART_FILEIN=driver_rest_in.nc in orchidee.def
45        IGCM_comp_modifyDefFile blocker run.def RESTART_FILEIN driver_rest_in.nc
46    fi
47
48    # Reset the simulation date as ORCHIDEE understands it for some special cases
49    # DRIVER_reset_time=y : take the date from the first time step of the forcing file
50    # DRIVER_reset_time=n : default, take the date from the restart file if existing, else take it from the forcing file
51    if ( ${FirstInitialize} &&  [ ${month} = 01 ] && [ ${day} = 01 ] ) ; then
52        # Starting a new simulation: take the date from the forcing file instead of from restart file
53        IGCM_comp_modifyDefFile nonblocker run.def DRIVER_reset_time y
54    elif ( [ X${CyclicYear} = X${config_UserChoices_CyclicBegin} ] && [ ${month} = 01 ] && [ ${day} = 01 ] ) ; then
55        # Start a new cycle, take the date from the forcing file instead of from restart file
56        IGCM_comp_modifyDefFile nonblocker run.def DRIVER_reset_time y
57    else
58        # Default option, take the date from the restart file
59        IGCM_comp_modifyDefFile nonblocker run.def DRIVER_reset_time n
60    fi
61
62
63    if [ -f CO2.txt ] ; then
64        # If this file exist, then read CO2 value and set ATM_CO2 in run.def
65        IPCC_CO2=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'`
66        if [ X"${IPCC_CO2}" = X ] ; then
67            # The grep returned empty variable: stop execution
68            IGCM_debug_Exit "The file CO2.txt do not contain the current year."
69            IGCM_debug_Verif_Exit
70        fi
71        IGCM_comp_modifyDefFile nonblocker run.def ATM_CO2 ${IPCC_CO2}
72    else
73        # The file is not available: take the default value from run.def.
74        # The syntax in run.def must be respected, for example:
75        # ATM_CO2 = _AUTO_: DEFAULT = 350.
76        IGCM_comp_modifyDefFile nonblocker run.def ATM_CO2 DEFAULT
77    fi
78
79
80    # Activation of XIOS
81    if [ X${orchidee_ol_UserChoices_XIOS} = Xy ] ; then
82      # Add include of orchidee context in iodef.xml
83      # In iodef.xml add on next line after "COMPONENT CONTEXT"
84      #  <context id="orchidee" src="./context_orchidee.xml"/>
85      echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
86
87      # Add inclusion of file context_input_orchidee.xml if this file exists
88      if [ -f context_input_orchidee.xml ] ; then
89          echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp
90      fi
91 
92      cp iodef.xml iodef.xml.tmp
93      sed -e "/COMPONENT CONTEXT/r add.tmp" \
94        iodef.xml.tmp > iodef.xml
95      rm iodef.xml.tmp add.tmp
96
97
98      # Special case if SBG component is not activated: deactivate stomate output files from file_def_orchidee.xml
99      # If SBG is activated, then the stomate.driver will take care of these variables
100      if [ X${config_ListOfComponents_SBG} = X ] ; then
101          # Stomate is not activated
102          IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled .FALSE.
103          IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq 1mo
104          IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE.
105          IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq 1mo     
106      fi
107    fi
108
109
110    # Add LongName as global attribute in all files produced by XIOS (if LongName is not empty)
111    # Remove file_def_input_orchidee.xml from the list.
112    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
113        listfile=$(ls file_def*orchidee.xml | grep -v input)
114        echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
115        for file in ${listfile} ; do
116            cp ${file} ${file}.tmp
117            sed -e "/<file id/r add.tmp" \
118                ${file}.tmp > ${file}
119            rm ${file}.tmp
120        done
121        rm add.tmp
122    fi
123         
124    IGCM_debug_PopStack "OOL_Update"
125}
126
127#-----------------------------------------------------------------
128function OOL_Finalize
129{
130    IGCM_debug_PushStack "OOL_Finalize"
131   
132    IGCM_debug_PopStack "OOL_Finalize"
133}
Note: See TracBrowser for help on using the repository browser.