source: CONFIG/UNIFORM/v6/LMDZORINCA_v6/GENERAL/DRIVER/orchidee.driver @ 2410

Last change on this file since 2410 was 2410, checked in by jgipsl, 10 years ago
  • clean in orchidee.def : only keep paramers not having default values
  • change to AUTOBLOCKER in run.def and orchidee.def to make it visible that these parameters can not be changed by the user
  • change some blocker variables to nonblocker in orchidee.driver
File size: 8.1 KB
Line 
1#!/bin/ksh
2#D- Driver du script pour ORCHIDEE
3#-----------------------------------------------------------------
4function SRF_Initialize
5{
6    IGCM_debug_PushStack "SRF_Initialize"
7
8    RESOL_SRF=ALL
9
10    for frequency in ${config_SRF_WriteFrequency} ; do
11        case ${frequency} in
12            HF|hf) SRF_ok_hf=y ;;
13        esac
14    done
15
16    ##- Define variable DefSuffix set in orchidee.card
17    ##  This variable is used in orchidee.card to choose
18    ##  parameter file(orchidee.def_DefSuffix).
19    if [ ! X${orchidee_UserChoices_DefSuffix} = X ] ; then
20        DefSuffix=${orchidee_UserChoices_DefSuffix}
21    else
22        DefSuffix=Choi
23    fi
24
25    IGCM_debug_PopStack "SRF_Initialize"
26}
27
28#-----------------------------------------------------------------
29function SRF_Update
30{
31    IGCM_debug_PushStack "SRF_Update"
32
33    # Activate STOMATE if the compontent SBG=stomate is set in config.card
34    if [ X${config_ListOfComponents_SBG} = Xstomate ] ; then
35        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE y
36    else
37        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE n
38    fi
39
40    typeset SECHIBA_WRITE_STEP
41
42    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
43        IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 enabled .FALSE.
44        IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba2 enabled .FALSE.
45        IGCM_comp_modifyDefFile nonblocker orchidee.def XIOS_ORCHIDEE_OK y
46    else
47        IGCM_comp_modifyDefFile nonblocker orchidee.def XIOS_ORCHIDEE_OK n
48    fi   
49
50    SRF_WriteFrequency=$( echo ${config_SRF_WriteFrequency} | sed -e 's/\([0-9]*[yYmMdDs]\).*/\1/' ) 
51    case ${SRF_WriteFrequency} in
52        *Y|*y) 
53            WriteInYears=$( echo ${SRF_WriteFrequency} | awk -F '[yY]' '{print $1}' )
54            PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
55            (( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInYears / PeriodLengthInYears * 86400 )) 
56            if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
57                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 enabled .TRUE.
58                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 output_freq ${WriteInYears}y
59                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 name sechiba_history
60            fi
61            ;;
62        1M)
63            if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
64                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 enabled .TRUE.
65                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 output_freq 1mo
66                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 name sechiba_history
67            fi
68            case ${config_UserChoices_PeriodLength} in
69            *Y|*y)
70                SECHIBA_WRITE_STEP=-1.
71                ;;
72            *M|*m)
73                SECHIBA_WRITE_STEP=-1.
74                ;;
75            *)
76                (( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 ))
77                ;;
78            esac
79            ;;
80        *M|*m) 
81            WriteInMonths=$( echo ${SRF_WriteFrequency} | awk -F '[mM]' '{print $1}' )
82            if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
83                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 enabled .TRUE.
84                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 output_freq ${WriteInMonths}mo
85                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 name sechiba_history
86            fi
87            case ${config_UserChoices_PeriodLength} in
88            *Y|*y)
89                PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
90                (( SECHIBA_WRITE_STEP = PeriodLengthInDays * 86400 / PeriodLengthInYears / 12  ))
91                ;;
92            *M|*m)
93                PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' )
94                (( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInMonths  * 86400 / PeriodLengthInMonths  ))
95                ;;
96            *)
97                (( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 ))
98                if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
99                    IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 enabled .TRUE.
100                    IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 output_freq ${SECHIBA_WRITE_STEP}s
101                    IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 name sechiba_history
102                fi
103                ;;
104            esac
105            ;;
106        5D|5d) 
107            if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
108                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 enabled .TRUE.
109                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 output_freq 5d
110                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 name sechiba_history
111            fi
112            (( SECHIBA_WRITE_STEP = 5 * 86400 )) 
113            ;;
114        1D|1d) 
115            if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
116                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 enabled .TRUE.
117                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 output_freq 1d
118                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 name sechiba_history
119            fi
120            (( SECHIBA_WRITE_STEP = 86400 )) 
121            ;;
122        *s)
123            WriteInSeconds=$( echo ${SRF_WriteFrequency} | awk -F '[s]' '{print $1}' )
124            if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
125                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 enabled .TRUE.
126                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 output_freq ${WriteInSeconds}s
127                IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba1 name sechiba_history
128            fi
129            (( SECHIBA_WRITE_STEP = WriteInSeconds )) ;;
130        *) 
131            IGCM_debug_Exit "SRF_Update " ${SRF_WriteFrequency} " invalid WriteFrequency : choose in 1Y, 1M, 5D, 1D." 
132            IGCM_debug_Verif_Exit ;;
133    esac
134
135#Use of XIOS ouputs only
136
137    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
138        (( SECHIBA_WRITE_STEP = 0 ))
139    fi
140    IGCM_comp_modifyDefFile nonblocker orchidee.def WRITE_STEP ${SECHIBA_WRITE_STEP}
141    IGCM_comp_modifyDefFile nonblocker orchidee.def SECHIBA_HISTLEVEL ${orchidee_UserChoices_sechiba_LEVEL}
142
143    # Outputs HF in HISTFILE2 if required
144    if [ X${SRF_ok_hf} = Xy ] ; then
145        IGCM_comp_modifyDefFile nonblocker orchidee.def SECHIBA_HISTFILE2 y
146        if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
147            IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba2 enabled .TRUE.
148            IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba2 output_freq 10800s
149            IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba2 name sechiba_out_2
150        fi
151    else
152        IGCM_comp_modifyDefFile nonblocker orchidee.def SECHIBA_HISTFILE2 n
153    fi
154    IGCM_comp_modifyDefFile nonblocker orchidee.def SECHIBA_HISTLEVEL2 1
155    IGCM_comp_modifyDefFile nonblocker orchidee.def WRITE_STEP2 10800.0
156
157    if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then
158        IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in sechiba_rest_in.nc
159    else
160        IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in NONE
161    fi
162
163# Modify in orchidee.def VEGET_UPDATE and LAND_COVER_CHANGE if they are set in orchidee.card section UserChoices
164    if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then
165        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE   ${orchidee_UserChoices_VEGET_UPDATE}
166    else
167        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 0Y
168    fi
169    if [ ! X${orchidee_UserChoices_LAND_COVER_CHANGE} = X ] ; then
170        IGCM_comp_modifyDefFile nonblocker orchidee.def LAND_COVER_CHANGE ${orchidee_UserChoices_LAND_COVER_CHANGE}
171    else
172        IGCM_comp_modifyDefFile nonblocker orchidee.def LAND_COVER_CHANGE n
173    fi
174
175    #IGCM_sys_Cp ${RUN_DIR}/orchidee.def ${RUN_DIR}/run.def
176    #IGCM_sys_Put_Out ${RUN_DIR}/run.def ${R_SAVE}/${PREFIX}_run.def
177
178#Temporary way to fix bug on cimean variable
179    IGCM_comp_modifyXmlFile force field_def_orchidee.xml cimean enabled .FALSE.
180
181    if [ X${orchidee_UserChoices_XIOS} = Xy ] ; then
182    # Add include of orchidee context in iodef.xml
183    # In iodef.xml add on next line after "COMPONENT CONTEXT"
184    #  <context id="orchidee" src="./context_orchidee.xml"/>
185        echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
186        cp iodef.xml iodef.xml.tmp
187        sed -e "/COMPONENT CONTEXT/r add.tmp" \
188            iodef.xml.tmp > iodef.xml
189        rm iodef.xml.tmp add.tmp
190    fi
191
192    IGCM_debug_PopStack "SRF_Update"
193}
194
195#-----------------------------------------------------------------
196function SRF_Finalize
197{
198    IGCM_debug_PushStack "SRF_Finalize"
199
200    #IGCM_sys_Put_Out ${RUN_DIR}/used_run.def ${R_SAVE}/${PREFIX}_used_run.def
201
202    echo FINALIZE SRF !!!
203
204    IGCM_debug_PopStack "SRF_Finalize"
205}
Note: See TracBrowser for help on using the repository browser.