source: CONFIG/UNIFORM/v6/LMDZORINCA_v6/GENERAL/DRIVER/inca.driver @ 3395

Last change on this file since 3395 was 3319, checked in by acosce, 5 years ago

Inca configuration :
allowed inca.card to manage the parameter value for threshold or weibull10m method

File size: 15.2 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    enable1=.FALSE.
42    enable2=.FALSE.
43
44    for frequency in ${config_CHM_WriteFrequency} ; do
45        case ${frequency} in
46            1D|1d) enable1=.TRUE. ;;
47        esac
48        case ${frequency} in
49            1M|1m) enable2=.TRUE. ;;
50        esac
51    done
52
53
54
55    IGCM_debug_PopStack "CHM_Initialize"
56}
57
58#-----------------------------------------------------------------
59function CHM_Update
60{
61    IGCM_debug_PushStack "CHM_Update"
62
63
64
65    case ${CHEM} in
66        AER)
67            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   forcage1     enabled ${enable1}
68            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml forcage2     enabled ${enable2}
69            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   aero1        enabled ${enable1}
70            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml aero2        enabled ${enable2}
71            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   chemistry1   enabled ${enable1}
72            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml chemistry2   enabled ${enable2}
73            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   emissions1   enabled ${enable1}
74            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml emissions2   enabled ${enable2}
75            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   species1     enabled ${enable1}
76            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml species2     enabled ${enable2}
77            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   dvel1        enabled ${enable1}
78            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml dvel2        enabled ${enable2}
79            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   washout1     enabled ${enable1}
80            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml washout2     enabled ${enable2}
81            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   reacflux1    enabled ${enable1}
82            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml reacflux2    enabled ${enable2}
83            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml   invariants1  enabled ${enable1}
84            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml invariants2  enabled ${enable2}
85
86            if [ X${LMDZ_Physics} = X"AP" ] ; then
87                IGCM_comp_modifyDefFile nonblocker run.def config_inca aero
88            else
89                IGCM_comp_modifyDefFile nonblocker run.def config_inca aeNP
90            fi
91        ;;
92        DUSS)
93            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml forcage1     enabled ${enable1}
94            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml aero1        enabled ${enable1}
95            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml emissions1   enabled ${enable1}
96            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml species1     enabled ${enable1}
97            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml vegetation1  enabled ${enable1}
98
99            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml forcage2     enabled ${enable2}
100            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml aero2        enabled ${enable2}
101            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml emissions2   enabled ${enable2}
102            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml species2     enabled ${enable2}
103            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml vegetation2  enabled ${enable2}
104
105            if [ X${LMDZ_Physics} = X"AP" ] ; then
106                IGCM_comp_modifyDefFile nonblocker run.def config_inca aero
107            else
108                IGCM_comp_modifyDefFile nonblocker run.def config_inca aeNP
109            fi
110        ;;
111        NMHC) 
112            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml reacflux1    enabled ${enable1}
113            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml emissions1   enabled ${enable1}
114            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml species1     enabled ${enable1}
115            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml chemistry1   enabled ${enable1}
116            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml dvel1        enabled ${enable1}
117            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml washout1     enabled ${enable1}
118
119            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml reacflux2  enabled ${enable2} 
120            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml emissions2 enabled ${enable2} 
121            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml species2   enabled ${enable2} 
122            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml chemistry2 enabled ${enable2} 
123            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml dvel2      enabled ${enable2} 
124            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml washout2   enabled ${enable2} 
125
126            IGCM_comp_modifyDefFile nonblocker run.def config_inca chem
127            ;;
128        NMHC_AER)
129            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml forcage1     enabled ${enable1}
130            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml aero1        enabled ${enable1}
131            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml species1     enabled ${enable1}
132            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml chemistry1   enabled ${enable1}
133            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml emissions1   enabled ${enable1}
134            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml dvel1        enabled ${enable1}
135            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml phtrate1     enabled ${enable1}
136            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml washout1     enabled ${enable1}
137            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml reacflux1    enabled ${enable1}
138            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml vegetation1  enabled ${enable1}
139
140            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml forcage2    enabled ${enable2} 
141            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml aero2       enabled ${enable2} 
142            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml species2    enabled ${enable2} 
143            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml chemistry2  enabled ${enable2} 
144            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml emissions2  enabled ${enable2} 
145            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml dvel2       enabled ${enable2} 
146            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml phtrate2    enabled ${enable2} 
147            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml washout2    enabled ${enable2} 
148            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml reacflux2   enabled ${enable2} 
149            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml vegetation2 enabled ${enable2} 
150
151            if [ X${LMDZ_Physics} = X"AP" ] ; then
152                IGCM_comp_modifyDefFile nonblocker run.def config_inca aero
153            else
154                IGCM_comp_modifyDefFile nonblocker run.def config_inca aeNP
155            fi
156        ;;
157
158        NMHC_AER_S)
159            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml forcage1     enabled ${enable1}
160            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml aero1        enabled ${enable1}
161            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml species1     enabled ${enable1}
162            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml chemistry1   enabled ${enable1}
163            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml emissions1   enabled ${enable1}
164            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml dvel1        enabled ${enable1}
165            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml phtrate1     enabled ${enable1}
166            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml washout1     enabled ${enable1}
167            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml reacflux1    enabled ${enable1}
168            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml vegetation1  enabled ${enable1}
169
170            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml forcage2    enabled ${enable2} 
171            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml aero2       enabled ${enable2} 
172            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml species2    enabled ${enable2} 
173            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml chemistry2  enabled ${enable2} 
174            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml emissions2  enabled ${enable2} 
175            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml phtrate2    enabled ${enable2} 
176            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml dvel2       enabled ${enable2} 
177            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml washout2    enabled ${enable2} 
178            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml reacflux2   enabled ${enable2} 
179            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml vegetation2 enabled ${enable2} 
180
181            if [ X${LMDZ_Physics} = X"AP" ] ; then
182                IGCM_comp_modifyDefFile nonblocker run.def config_inca aero
183            else
184                IGCM_comp_modifyDefFile nonblocker run.def config_inca aeNP
185            fi
186        ;;
187        GES)
188            IGCM_comp_modifyXmlFile nonblocker file_def_inca_daily.xml emissions1    enabled ${enable1}
189
190            IGCM_comp_modifyXmlFile nonblocker file_def_inca_monthly.xml emissions2    enabled ${enable2}
191
192            IGCM_comp_modifyDefFile nonblocker run.def config_inca chem
193        esac
194
195
196    # inca.def : Activate reading of 10m wind in files if LMDZ_10m_winds=n in inca.card
197    if [ ! X${inca_UserChoices_LMDZ_10m_winds} = X ] ; then
198        IGCM_comp_modifyDefFile nonblocker inca.def LMDZ_10m_winds  ${inca_UserChoices_LMDZ_10m_winds}
199    else
200        IGCM_comp_modifyDefFile nonblocker inca.def LMDZ_10m_winds  n
201    fi
202
203    if [  X${inca_UserChoices_10m_winds_method} = X ] ; then
204    IGCM_comp_modifyDefFile nonblocker inca.def  10m_winds_method  threshold
205    else
206    IGCM_comp_modifyDefFile nonblocker inca.def  10m_winds_method ${inca_UserChoices_10m_winds_method}
207    fi
208
209
210    if [ ! X${inca_UserChoices_wind_parameter} = X ] ; then
211        if [  X${inca_UserChoices_10m_winds_method} = Xthreshold ] ; then
212            IGCM_comp_modifyDefFile nonblocker inca.def  tref ${inca_UserChoices_wind_parameter}
213            IGCM_comp_modifyDefFile nonblocker inca.def  kref DEFAULT
214        else
215            IGCM_comp_modifyDefFile nonblocker inca.def  kref ${inca_UserChoices_wind_parameter}
216            IGCM_comp_modifyDefFile nonblocker inca.def  tref DEFAULT
217        fi
218    else
219            IGCM_comp_modifyDefFile nonblocker inca.def  kref DEFAULT
220            IGCM_comp_modifyDefFile nonblocker inca.def  tref DEFAULT
221    fi
222
223
224    # inca.def : choose write frequency for inca_avgr in inca.card
225    if [ ! X${inca_UserChoices_freq_write_chem} = X ] ; then
226        IGCM_comp_modifyDefFile nonblocker inca.def freq_write_chem  ${inca_UserChoices_freq_write_chem}
227    else
228        IGCM_comp_modifyDefFile nonblocker inca.def  freq_write_chem  86400
229    fi
230
231    #inca.def : choose aerosol effect with feedback variable
232    if [ ! X${inca_UserChoices_feedb} = X ] ; then
233        IGCM_comp_modifyDefFile nonblocker inca.def  feedb  ${inca_UserChoices_feedb}
234    else
235        IGCM_comp_modifyDefFile nonblocker inca.def feedb  0
236    fi
237   
238    #inca.def : choose coupled model with orchidee 
239    if [ ! X${inca_UserChoices_CoupOrchInca} = X ]; then
240        IGCM_comp_modifyDefFile nonblocker inca.def CoupOrchInca ${inca_UserChoices_CoupOrchInca}
241    else
242        IGCM_comp_modifyDefFile nonblocker inca.def CoupOrchInca n
243    fi
244
245    #inca.def : choose sedimentation schema
246    if [ ! X${inca_UserChoices_multilayer_sedim} = X ]; then
247        IGCM_comp_modifyDefFile nonblocker inca.def multilayer_sediment ${inca_UserChoices_multilayer_sedim}
248    else
249        IGCM_comp_modifyDefFile nonblocker inca.def multilayer_sediment y
250    fi
251
252    #inca.def : choose calcul interactif des diagnostiques flux chimique ou non 
253    if [ ! X${inca_UserChoices_calcul_flux} = X ]; then
254        IGCM_comp_modifyDefFile nonblocker inca.def calcul_flux ${inca_UserChoices_calcul_flux}
255    else
256        IGCM_comp_modifyDefFile nonblocker inca.def calcul_flux n
257    fi
258
259    #inca.def : choose aircraft emission
260    if [ ! X${inca_UserChoices_flag_plane} = X ]; then
261        IGCM_comp_modifyDefFile nonblocker inca.def flag_plane ${inca_UserChoices_flag_plane}
262    else
263        IGCM_comp_modifyDefFile nonblocker inca.def flag_plane 0
264    fi
265   
266    #inca.def : choose time interpolation for sflx.nc
267    if [ ! X${inca_UserChoices_emi_interp_time} = X ]; then
268        IGCM_comp_modifyDefFile nonblocker inca.def emi_interp_time ${inca_UserChoices_emi_interp_time}
269    else
270        IGCM_comp_modifyDefFile nonblocker inca.def emi_interp_time 1
271    fi
272
273    #inca.def : choose output library
274    if [  X${inca_UserChoices_XIOS} = Xy ] ; then
275        IGCM_comp_modifyDefFile nonblocker inca.def  XIOS_INCA_OK  y
276    else
277        IGCM_comp_modifyDefFile nonblocker inca.def  XIOS_INCA_OK n
278    fi
279
280    if [  X${inca_UserChoices_IOIPSL} = Xy ] ; then
281        IGCM_comp_modifyDefFile nonblocker inca.def  IOIPSL_INCA_OK  y
282    else
283        IGCM_comp_modifyDefFile nonblocker inca.def  IOIPSL_INCA_OK n
284    fi
285
286
287
288
289    if [ X${inca_UserChoices_XIOS}  = Xy ] ; then
290    # Add include of INCA context in iodef.xml
291    # In iodef.xml add on next line after "COMPONENT CONTEXT"
292    #  <context id="inca" src="./context_inca.xml"/>
293        echo '<context id="inca" src="./context_inca.xml"/>' > add.tmp
294        cp iodef.xml iodef.xml.tmp
295        sed -e "/COMPONENT CONTEXT/r add.tmp" \
296            iodef.xml.tmp > iodef.xml
297        rm iodef.xml.tmp add.tmp
298    fi
299
300    # Add LongName as global attribute in XIOS output files (if LongName is not empty)
301    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
302        listfile=$(ls file_def*inca.xml)
303        echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
304        for file in ${listfile}
305        do
306            cp ${file} ${file}.tmp
307            sed -e "/<file id/r add.tmp" \
308                ${file}.tmp > ${file}
309            rm ${file}.tmp
310        done
311        rm add.tmp
312    fi
313
314    IGCM_debug_PopStack "CHM_Update"
315}
316
317#-----------------------------------------------------------------
318function CHM_Finalize
319{
320    IGCM_debug_PushStack "CHM_Finalize"
321
322    echo FINALIZE CHM !!!
323#
324#    IGCM_sys_Mkdir ${R_OUT_EXE}
325#    cd ${MODIPSL}
326#    tar cf src_${config_UserChoices_JobName}.tar  modeles
327#    IGCM_sys_Mv src_${config_UserChoices_JobName}.tar ${R_OUT_EXE}/.
328#    cd -
329#
330
331    IGCM_debug_PopStack "CHM_Finalize"
332}
Note: See TracBrowser for help on using the repository browser.