source: CONFIG/UNIFORM/v6/IPSLCM5A2CHT.2/GENERAL/DRIVER/orchidee.driver @ 6238

Last change on this file since 6238 was 6046, checked in by acosce, 2 years ago

modifications to run paleo simulation (mosaic) with IPSLCM5A2CHT configuration and v6.2 compilation

File size: 6.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    ##- Define variable DefSuffix set in orchidee.card
9    ##  This variable is used in orchidee.card to choose
10    ##  parameter file(orchidee.def_DefSuffix).
11    if [ ! X${orchidee_UserChoices_DefSuffix} = X ] ; then
12        DefSuffix=${orchidee_UserChoices_DefSuffix}
13    else
14        DefSuffix=Choi
15    fi
16
17    IGCM_debug_PopStack "SRF_Initialize"
18}
19
20#-----------------------------------------------------------------
21function SRF_Update
22{
23    IGCM_debug_PushStack "SRF_Update"
24
25    ## 1. Modifications in orchidee.def parameter file
26
27    # Activate STOMATE if the compontent SBG=stomate is set in config.card
28    if [ X${config_ListOfComponents_SBG} = Xstomate ] ; then
29        # Activate stomate in orchidee.def
30        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE y
31    else
32        # Deactivate stomate in orchidee.def
33        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE n
34        # Deactivate output files for stomate
35        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled .FALSE.
36        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq 1mo
37        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE.
38        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq 1mo
39    fi
40
41    # Define in orchidee.def if restart file should be used
42    if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then
43        IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in sechiba_rest_in.nc
44    else
45        IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in NONE
46    fi
47
48    # Modify in orchidee.def VEGET_UPDATE if it is set in orchidee.card section UserChoices
49    if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then
50        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE   ${orchidee_UserChoices_VEGET_UPDATE}
51    else
52        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 0Y
53    fi
54
55    # Activate creation of river description file only for the first period
56    if [ ${CumulPeriod} -eq 1 ] ; then
57        if [ x$ConfExp != X ]; then
58            ISPALEO=${ConfExp}
59        elif  [ -f ${SUBMIT_DIR}/../.resol ] ; then
60            ISPALEO=${config_UserChoices_ExpType##*/}
61        fi
62
63        if [ "${ISPALEO}" = "paleo" ] ; then # change to y if needed for paleo
64            IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC n
65        else
66            IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC y
67        fi
68    else
69        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC n
70    fi
71
72    # Activate calcul of chemistry BVOC
73    if [ ! X${orchidee_UserChoices_CHEMISTRY_BVOC} = X ] ; then
74        IGCM_comp_modifyDefFile nonblocker orchidee.def CHEMISTRY_BVOC ${orchidee_UserChoices_CHEMISTRY_BVOC}
75    else
76        IGCM_comp_modifyDefFile nonblocker orchidee.def CHEMISTRY_BVOC n
77    fi
78
79    ## 2. Mangement of output and modifications of related xml files
80
81    # Set default values for sechiba1_enabled, sechiba1_freq and sechiba2_enabled.
82    sechiba1_enabled=.FALSE.
83    sechiba2_enabled=.FALSE.
84    sechiba1_freq=0s
85
86    # Get WriteFrenquecies from config.card for SECHIBA
87    # Note that it is only possible to have one HF and one other option.
88    # If more options are set in config.card only the latest will be used.
89    for frequency in ${config_SRF_WriteFrequency} ; do
90        case ${frequency} in
91            *Y|*y) 
92                NbYears=$( echo ${frequency} | awk -F '[yY]' '{print $1}' )
93                NbDaysYear=$( IGCM_date_DaysInYear ${year} )
94                sechiba1_enabled=.TRUE.
95                sechiba1_freq=${NbYears}y ;;
96            *M|*m)
97                NbMonths=$( echo ${frequency} | awk -F '[mM]' '{print $1}' )
98                sechiba1_enabled=.TRUE.
99                sechiba1_freq=${NbMonths}mo ;;
100            *D|*d)
101                NbDays=$( echo ${frequency} | awk -F '[dD]' '{print $1}' )
102                sechiba1_enabled=.TRUE.
103                sechiba1_freq=${NbDays}d ;;
104            *s)
105                WriteInSeconds=$( echo ${frequency} | awk -F '[s]' '{print $1}' )
106                sechiba1_enabled=.TRUE.
107                sechiba1_freq=${WriteInSeconds}s ;;
108            HF|hf) 
109                sechiba2_enabled=.TRUE. ;;
110            *) 
111                IGCM_debug_Exit "SRF WriteFrequency=${frequency} is invalid. Choose between xY, xM, xD, xs and HF for Sechiba." ;;
112        esac
113    done
114
115    # Do the modifications in file_def_orchidee.xml
116    IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled ${sechiba1_enabled}
117    IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq ${sechiba1_freq}
118    IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled ${sechiba2_enabled}
119
120    # Add include of orchidee context in iodef.xml
121    # In iodef.xml add on the next line after "COMPONENT CONTEXT"
122    echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
123    # Add inclusion of file context_input_orchidee.xml if this file exists
124    if [ -f context_input_orchidee.xml ] ; then
125        echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp
126    fi
127    # Include xml files for output configuration if running with workflow CMIP6
128    if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then
129        echo '<context id="orchidee" src="./ping_orchidee.xml"/>' >> add.tmp
130        echo '<context id="orchidee" src="./dr2xml_orchidee.xml"/>' >> add.tmp
131    fi
132    cp iodef.xml iodef.xml.tmp
133    sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml
134    rm iodef.xml.tmp add.tmp
135
136    #Long Name as global attribute (if LongName is not empty)
137        if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
138            listfile=$(ls file_def*orchidee.xml)
139            echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
140            for file in ${listfile}
141            do
142                cp ${file} ${file}.tmp
143                sed -e "/<file id/r add.tmp" \
144                    ${file}.tmp > ${file}
145                rm ${file}.tmp
146            done
147            rm add.tmp
148        fi
149
150    IGCM_debug_PopStack "SRF_Update"
151}
152
153#-----------------------------------------------------------------
154function SRF_Finalize
155{
156    IGCM_debug_PushStack "SRF_Finalize"
157
158    IGCM_debug_PopStack "SRF_Finalize"
159}
Note: See TracBrowser for help on using the repository browser.