source: CONFIG/UNIFORM/v6/IPSLCM5A2CHT/GENERAL/DRIVER/inca.driver @ 3283

Last change on this file since 3283 was 3283, checked in by acosce, 4 years ago

New configuration : modele IPSLCM5A2 coupled with INCA modele

File size: 10.5 KB
Line 
1#!/bin/ksh
2
3#D- Driver du script pour INCA
4#-----------------------------------------------------------------
5function INCA_sed_replace
6{
7    IGCM_debug_PushStack "INCA_sed_replace"
8
9    sed -e "s/${2}/${3}/" ${1} > ${1}.tmp
10    RET=$?
11    echo "INCA_sed : ${1} ${2} ${3}"
12    \mv ${1}.tmp ${1}
13
14    IGCM_debug_PopStack "INCA_sed_replace"
15    return $RET
16}
17#-----------------------------------------------------------------
18function CHM_Initialize
19{
20    IGCM_debug_PushStack "CHM_Initialize"
21
22    RESOL_CHM=$( echo $RESOL | awk "-Fx" '{print $2}' | awk "-FD" '{print $2}')
23
24    [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x19
25    RESOL_CHM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' | awk "-F-" '{print $1}')
26    echo 'resol chimie', $RESOL_CHM
27
28    [ -f ${SUBMIT_DIR}/../.chimie ] && eval $(grep CHEM ${SUBMIT_DIR}/../.chimie) 
29    INCA_sed_replace ${SUBMIT_DIR}/config.card \${CHEM} ${CHEM}
30    echo "INCA Tag : LMDZ-INCA" ${config_UserChoices_TagName}
31
32    ##- LMDZ physics version
33    ##  Read LMDZ_Physics option in lmdz.card, if not present take default value AP (old physics)
34    if [ ! X${lmdz_UserChoices_LMDZ_Physics} = X ] ; then
35        LMDZ_Physics=${lmdz_UserChoices_LMDZ_Physics}
36    else
37        LMDZ_Physics=AP
38    fi
39    echo LMDZ physics version : ${LMDZ_Physics}
40
41    for frequency in ${config_CHM_WriteFrequency} ; do
42    case ${frequency} in
43        1M|1m) freq_output=1mo ;;
44        1D|1d) freq_output=1d ;;
45            *) IGCM_debug_Exit "CHM_Update " ${frequency} " invalid WriteFrequency : choose between 1M and 1D"
46        IGCM_debug_Verif_Exit ;;
47
48    esac
49    done
50
51
52
53    IGCM_debug_PopStack "CHM_Initialize"
54}
55
56#-----------------------------------------------------------------
57function CHM_Update
58{
59    IGCM_debug_PushStack "CHM_Update"
60
61    case ${CHEM} in
62        AER)
63            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml forcage     output_freq ${freq_output}
64            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml aero        output_freq ${freq_output}
65            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml chemistry   output_freq ${freq_output}
66            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml emissions   output_freq ${freq_output}
67            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml species     output_freq ${freq_output}
68            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml dvel        output_freq ${freq_output}
69            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml washout     output_freq ${freq_output}
70            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml reacflux    output_freq ${freq_output}
71            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml invariants  output_freq ${freq_output}
72
73            if [ X${LMDZ_Physics} = X"AP" ] ; then
74                IGCM_comp_modifyDefFile nonblocker run.def config_inca aero
75            else
76                IGCM_comp_modifyDefFile nonblocker run.def config_inca aeNP
77            fi
78        ;;
79        DUSS)
80            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml forcage     output_freq ${freq_output}
81            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml aero        output_freq ${freq_output}
82            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml emissions   output_freq ${freq_output}
83            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml species     output_freq ${freq_output}
84            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml vegetation  output_freq ${freq_output}
85            if [ X${LMDZ_Physics} = X"AP" ] ; then
86                IGCM_comp_modifyDefFile nonblocker run.def config_inca aero
87            else
88                IGCM_comp_modifyDefFile nonblocker run.def config_inca aeNP
89            fi
90        ;;
91        NMHC) 
92            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml reacflux    output_freq ${freq_output}
93            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml emissions   output_freq ${freq_output}
94            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml species     output_freq ${freq_output}
95            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml chemistry   output_freq ${freq_output}
96            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml dvel        output_freq ${freq_output}
97            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml washout     output_freq ${freq_output}
98            IGCM_comp_modifyDefFile nonblocker run.def config_inca chem
99            ;;
100        NMHC_AER)
101            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml forcage     output_freq ${freq_output}
102            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml aero        output_freq ${freq_output}
103            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml species     output_freq ${freq_output}
104            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml chemistry   output_freq ${freq_output}
105            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml emissions   output_freq ${freq_output}
106            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml dvel        output_freq ${freq_output}
107            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml phtrate     output_freq ${freq_output}
108            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml washout     output_freq ${freq_output}
109            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml reacflux    output_freq ${freq_output}
110            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml vegetation  output_freq ${freq_output}
111            if [ X${LMDZ_Physics} = X"AP" ] ; then
112                IGCM_comp_modifyDefFile nonblocker run.def config_inca aero
113            else
114                IGCM_comp_modifyDefFile nonblocker run.def config_inca aeNP
115            fi
116        ;;
117
118        NMHC_AER_S)
119            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml forcage     output_freq ${freq_output}
120            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml aero        output_freq ${freq_output}
121            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml species     output_freq ${freq_output}
122            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml chemistry   output_freq ${freq_output}
123            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml phtrate     output_freq ${freq_output}
124            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml emissions   output_freq ${freq_output}
125            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml dvel        output_freq ${freq_output}
126            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml washout     output_freq ${freq_output}
127            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml reacflux    output_freq ${freq_output}
128            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml vegetation  output_freq ${freq_output}
129
130            if [ X${LMDZ_Physics} = X"AP" ] ; then
131                IGCM_comp_modifyDefFile nonblocker run.def config_inca aero
132            else
133                IGCM_comp_modifyDefFile nonblocker run.def config_inca aeNP
134            fi
135        ;;
136        GES)
137            IGCM_comp_modifyXmlFile nonblocker file_def_inca.xml divers   output_freq ${freq_output}
138            IGCM_comp_modifyDefFile nonblocker run.def config_inca chem
139        esac
140
141
142
143
144    # inca.def : Activate reading of 10m wind in files if LMDZ_10m_winds=n in inca.card
145    if [ ! X${inca_UserChoices_LMDZ_10m_winds} = X ] ; then
146        IGCM_comp_modifyDefFile nonblocker inca.def LMDZ_10m_winds  ${inca_UserChoices_LMDZ_10m_winds}
147    else
148        IGCM_comp_modifyDefFile nonblocker inca.def LMDZ_10m_winds  n
149    fi
150
151    # inca.def : choose write frequency for inca_avgr in inca.card
152    if [ ! X${inca_UserChoices_freq_write_chem} = X ] ; then
153        IGCM_comp_modifyDefFile nonblocker inca.def freq_write_chem  ${inca_UserChoices_freq_write_chem}
154    else
155        IGCM_comp_modifyDefFile nonblocker inca.def  freq_write_chem  86400
156    fi
157
158    #inca.def : choose aerosol effect with feedback variable
159    if [ ! X${inca_UserChoices_feedb} = X ] ; then
160        IGCM_comp_modifyDefFile nonblocker inca.def  feedb  ${inca_UserChoices_feedb}
161    else
162        IGCM_comp_modifyDefFile nonblocker inca.def feedb  0
163    fi
164   
165    #inca.def : choose coupled model with orchidee 
166    if [ ! X${inca_UserChoices_CoupOrchInca} = X ]; then
167        IGCM_comp_modifyDefFile nonblocker inca.def CoupOrchInca ${inca_UserChoices_CoupOrchInca}
168    else
169        IGCM_comp_modifyDefFile nonblocker inca.def CoupOrchInca n
170    fi
171
172    #inca.def : choose sedimentation schema
173    if [ ! X${inca_UserChoices_multilayer_sedim} = X ]; then
174        IGCM_comp_modifyDefFile nonblocker inca.def multilayer_sediment ${inca_UserChoices_multilayer_sedim}
175    else
176        IGCM_comp_modifyDefFile nonblocker inca.def multilayer_sediment y
177    fi
178
179    #inca.def : choose calcul interactif des diagnostiques flux chimique ou non 
180    if [ ! X${inca_UserChoices_calcul_flux} = X ]; then
181        IGCM_comp_modifyDefFile nonblocker inca.def calcul_flux ${inca_UserChoices_calcul_flux}
182    else
183        IGCM_comp_modifyDefFile nonblocker inca.def calcul_flux n
184    fi
185
186    #inca.def : choose aircraft emission
187    if [ ! X${inca_UserChoices_flag_plane} = X ]; then
188        IGCM_comp_modifyDefFile nonblocker inca.def flag_plane ${inca_UserChoices_flag_plane}
189    else
190        IGCM_comp_modifyDefFile nonblocker inca.def flag_plane 0
191    fi
192   
193
194    #inca.def : choose output library
195    if [  X${inca_UserChoices_XIOS} = Xy ] ; then
196        IGCM_comp_modifyDefFile nonblocker inca.def  XIOS_INCA_OK  y
197    else
198        IGCM_comp_modifyDefFile nonblocker inca.def  XIOS_INCA_OK n
199    fi
200
201    if [  X${inca_UserChoices_IOIPSL} = Xy ] ; then
202        IGCM_comp_modifyDefFile nonblocker inca.def  IOIPSL_INCA_OK  y
203    else
204        IGCM_comp_modifyDefFile nonblocker inca.def  IOIPSL_INCA_OK n
205    fi
206
207
208    if [  X${inca_UserChoices_10m_winds_method} = X ] ; then
209    IGCM_comp_modifyDefFile nonblocker inca.def  10m_winds_method  threshold
210    else
211    IGCM_comp_modifyDefFile nonblocker inca.def  10m_winds_method ${inca_UserChoices_10m_winds_method}
212    fi
213
214
215
216    if [ X${inca_UserChoices_XIOS}  = Xy ] ; then
217    # Add include of INCA context in iodef.xml
218    # In iodef.xml add on next line after "COMPONENT CONTEXT"
219    #  <context id="inca" src="./context_inca.xml"/>
220        echo '<context id="inca" src="./context_inca.xml"/>' > add.tmp
221        cp iodef.xml iodef.xml.tmp
222        sed -e "/COMPONENT CONTEXT/r add.tmp" \
223            iodef.xml.tmp > iodef.xml
224        rm iodef.xml.tmp add.tmp
225    fi
226
227    # Add LongName as global attribute in XIOS output files (if LongName is not empty)
228    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
229        listfile=$(ls file_def*inca.xml)
230        echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
231        for file in ${listfile}
232        do
233            cp ${file} ${file}.tmp
234            sed -e "/<file id/r add.tmp" \
235                ${file}.tmp > ${file}
236            rm ${file}.tmp
237        done
238        rm add.tmp
239    fi
240
241    IGCM_debug_PopStack "CHM_Update"
242}
243
244#-----------------------------------------------------------------
245function CHM_Finalize
246{
247    IGCM_debug_PushStack "CHM_Finalize"
248
249    echo FINALIZE CHM !!!
250#
251#    IGCM_sys_Mkdir ${R_OUT_EXE}
252#    cd ${MODIPSL}
253#    tar cf src_${config_UserChoices_JobName}.tar  modeles
254#    IGCM_sys_Mv src_${config_UserChoices_JobName}.tar ${R_OUT_EXE}/.
255#    cd -
256#
257
258    IGCM_debug_PopStack "CHM_Finalize"
259}
Note: See TracBrowser for help on using the repository browser.