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

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