source: TOOLS/CMIP6_FORCING/AER_TROP_EMISSIONS/REGRID/regrid.sh @ 3398

Last change on this file since 3398 was 3398, checked in by oboucher, 7 years ago

Hopefully last change regarding N>Ox units.
Now emissions are provided in kg NO for INCA.

  • Property svn:executable set to *
File size: 18.8 KB
Line 
1#--updated on 4/5/2017 with improved Sheng & Zwiers algorithm, ThL
2#--corrected some interpolation preprocessing (compared to v4)
3#--updated on 5/5/2017 with correction factor (30/46) on NOx vs. NO
4#--updated on 9/5/2017 with output separation BB/anthro for SO2, NOx and NH3
5#--corrected on 22/6/2017 for BB: undef values zeroed before remapping
6#--corrected on 26/09/2017 for NOx units: PNNL dataset is kg NO2, VUA is kg NO.
7#  INCA expects NO in its AER version.
8#
9#INCA  conc_dms flx_nox flx_bc flx_pom flx_bbbc flx_bbpom flx_so2 flx_so4 flx_h2s flx_nh3
10#CMIP6 species  NOx     BC     OC                         SO2                     NH3
11# + NMVOC CO
12
13#--INCA example file where dms_conc can be reused
14fileINCAex="/home/oboucher/CMIP6/AER_EMISSIONS/INCAfile/sflx_lmdz_phy_1997.nc"
15
16#--input directory for anthropogenic (non-BB) emissions
17dirinPNNL="/prodigfs/project/input4MIPs/PNNL-JGCRI/emissions/CMIP/CEDS-2017-05-18/mon/"
18##--Be careful if ever one needs the 3D (=AIR) data, the latest are in the different directory
19##dirinPNNL_AIR="/prodigfs/project/input4MIPs/PNNL-JGCRI/emissions/CMIP/mon/CEDS-2017-08-30/"
20#--input directory for anthropogenic (BB) emissions
21dirinVUA="/prodigfs/project/input4MIPs/VUA/emissions/CMIP/VUA-CMIP-BB4CMIP6-1-2/mon/"
22
23#--LMDz grid information
24grid="144x143"
25gridfile="../GRID/grid-lmdz-lonlat_"${grid}
26nbpoint=$((144*141+2))
27
28#--output directory
29dirout="/data/"${USER}"/CMIP6/AEROSOL/"
30if [ ! -d ${dirout} ] ; then mkdir -p ${dirout} ; fi
31
32#--year
33for year in {1850..2014}
34do
35
36#--species
37for species in "BC" "NOx" "OC" "SO2" "NH3"
38do
39
40if [ ${species} = "BC"  ] ; then speciesinca="bc"  ; fi
41if [ ${species} = "NOx" ] ; then speciesinca="nox" ; fi
42if [ ${species} = "OC"  ] ; then speciesinca="pom" ; fi
43if [ ${species} = "SO2" ] ; then speciesinca="so2" ; fi
44if [ ${species} = "NH3" ] ; then speciesinca="nh3" ; fi
45
46#--finding correct file for PNNL data
47if [ $year -ge 1750 -a $year -lt 1800 ]; then
48year1=1750
49year2=1799
50elif [ $year -ge 1800 -a $year -lt 1850 ]; then
51year1=1800
52year2=1849
53elif [ $year == 1850 ]; then
54year1=1850
55year2=1850
56elif [ $year -ge 1851 -a $year -lt 1900 ]; then
57year1=1851
58year2=1899
59elif [ $year -ge 1900 -a $year -lt 1950 ]; then
60year1=1900
61year2=1949
62elif [ $year -ge 1950 -a $year -lt 2000 ]; then
63year1=1950
64year2=1999
65elif [ $year -ge 2000 -a $year -lt 2015 ]; then
66year1=2000
67year2=2014
68else
69echo 'Houston we have a problem for the PNNL data'
70exit 1
71fi
72
73#--input file PNNL (fossil fuel emissions)
74filename=${dirinPNNL}${species}_em_anthro/gn/v20170519/${species}-em-anthro_input4MIPs_emissions_CMIP_CEDS-2017-05-18_gn_${year1}01-${year2}12.nc
75
76#--output files
77filenameout1=${dirout}flux_${speciesinca}_${year}.nc
78filenameout2=${dirout}flux_lmdz_${speciesinca}_${year}.nc
79filenameout3=${dirout}flux_vector_${speciesinca}_${year}.nc
80
81echo ${filename} ${filenameout1} ${filenameout2} ${filenameout3}
82rm -f ${filenameout1} ${filenameout2} ${filenameout3}
83
84#--unfortunately idl not happy with PNNL netcdf files so need to ferretize files
85#--I also sum over sectors and I extract the correct year as well
86rm -f rewrite.jnl
87cat << eod > rewrite.jnl
88use "${filename}"
89set region/t=16-jan-${year}:16-dec-${year}
90save/clobber/file="${filenameout1}" ${species}_EM_ANTHRO[k=@sum]
91eod
92
93#--run ferret script
94ferret << eod
95go rewrite.jnl
96exit
97eod
98
99#--remap to LMDz grid
100#--OC to POM conversion factor
101#--otherwise change to capital letters if not (eg NOx)
102if [ ${species} == "OC"  ] ; then
103echo cdo remapcon,${gridfile} -chname,`echo ${species}_EM_ANTHRO | awk '{print toupper($0)}'`,flux -mulc,1.4 ${filenameout1} ${filenameout2}
104cdo remapcon,${gridfile} -chname,`echo ${species}_EM_ANTHRO | awk '{print toupper($0)}'`,flux -mulc,1.4 ${filenameout1} ${filenameout2}
105else
106echo cdo remapcon,${gridfile} -chname,`echo ${species}_EM_ANTHRO | awk '{print toupper($0)}'`,flux  ${filenameout1} ${filenameout2}
107cdo remapcon,${gridfile} -chname,`echo ${species}_EM_ANTHRO | awk '{print toupper($0)}'`,flux ${filenameout1} ${filenameout2}
108fi
109
110#--Improved Sheng & Zwiers algorithm + transform into vector
111rm -f regrid.pro
112cat << eod >> regrid.pro
113pro regrid
114filename='${filenameout2}'
115print, filename
116NETCDFREAD,filename,'flux',flux,dimflux
117NETCDFREAD,filename,'lat',lat,dimlat0
118NETCDFREAD,filename,'lon',lon,dimlon0
119NETCDFREAD,filename,'TIME',time,dimtime0
120dimlat=dimlat0(0)
121dimlon=dimlon0(0)
122dimtime=dimtime0(0)
123print, 'dim flux=', dimflux
124A = float([     [3./4., 1./8., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1./8.],$
125                [1./8., 3./4., 1./8., 0., 0., 0., 0., 0., 0., 0., 0., 0.],$
126                [0., 1./8., 3./4., 1./8., 0., 0., 0., 0., 0., 0., 0., 0.],$
127                [0., 0., 1./8., 3./4., 1./8., 0., 0., 0., 0., 0., 0., 0.],$
128                [0., 0., 0., 1./8., 3./4., 1./8., 0., 0., 0., 0., 0., 0.],$
129                [0., 0., 0., 0., 1./8., 3./4., 1./8., 0., 0., 0., 0., 0.],$
130                [0., 0., 0., 0., 0., 1./8., 3./4., 1./8., 0., 0., 0., 0.],$
131                [0., 0., 0., 0., 0., 0., 1./8., 3./4., 1./8., 0., 0., 0.],$
132                [0., 0., 0., 0., 0., 0., 0., 1./8., 3./4., 1./8., 0., 0.],$
133                [0., 0., 0., 0., 0., 0., 0., 0., 1./8., 3./4., 1./8., 0.],$
134                [0., 0., 0., 0., 0., 0., 0., 0., 0., 1./8., 3./4., 1./8.],$
135                [1./8., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1./8., 3./4.]   ])
136fluxinit=flux
137flux_check=flux
138for lo=0,dimlon-1 do begin
139for la=0,dimlat-1 do begin
140flux_check(lo,la,*) = invert(A) ## transpose(fluxinit(lo,la,*))
141endfor
142endfor                 
143m_bloq = make_array(dimlon,dimlat,12,value=0)           ; Matrice booléenne "mois à bloquer ou non"
144if total(where(flux_check lt 0)) ne -1 then m_bloq(where(flux_check lt 0)) = 1
145; Correction/adaptation de la matrice S&Z en fonction du masque booléen m_bloq
146for lo=0,dimlon-1 do begin
147for la=0,dimlat-1 do begin
148whereneg = where(flux_check(lo,la,*) lt 0)              ; (12 pts max) Identification de potentiels points à problÚmes, corrigés négativement
149nbannul=n_elements(whereneg)*(total(whereneg) ne -1)
150flux_corr=flux_check(lo,la,*)                           ; Création d'un vecteur pour recevoir les valeurs corrigées, initialisé à flux_check au cas où on n'ait rien à faire d'autre qu'une seule itération
151A2 = A                                                  ; Je repars de la matrice A initiale, ce pour chaque point de grille
152;                                                       ; Potentiellement plusieurs passages pour éliminer toutes les valeurs négatives
153while nbannul ne 0 do begin                             ; Si l'on a effectivement des émissions corrigées négativement...
154m_bloq(lo,la,whereneg) = 1                              ; Update de la matrice m_bloq
155for m=0,11 do begin
156if m eq 11 then begin                                   ; Pour plus de facilité, mois précédents et suivants codés ici
157p=10
158s=0
159endif else if m eq 0 then begin
160p=11
161s=1
162endif else begin
163p = m-1
164s = m+1
165endelse
166if m_bloq(lo,la,m) then begin                           ; Je traite les mois bloqués en eux-mêmes
167A2(p,m) = 0.
168A2(m,m) = 1.
169A2(s,m) = 0.
170endif                                                   ; Fin du cas si l'on est sur un mois bloqué
171if ~m_bloq(lo,la,m) then begin                          ; Je traite les mois non bloqués, pour ceux adjacents à un mois bloqué
172if m_bloq(lo,la,p) and m_bloq(lo,la,s) then begin               ; Mois encadré de deux mois bloqués
173A2(p,m) = 1./4.
174A2(m,m) = 1./2.
175A2(s,m) = 1./4.
176endif else if m_bloq(lo,la,p) and ~m_bloq(lo,la,s) then begin   ; Mois précédent bloqué (uniquement)
177A2(p,m) = 2./8.
178A2(m,m) = 5./8.
179A2(s,m) = 1./8.
180endif else if ~m_bloq(lo,la,p) and m_bloq(lo,la,s) then begin   ; Mois suivant bloqué (uniquement)
181A2(p,m) = 1./8.
182A2(m,m) = 5./8.
183A2(s,m) = 2./8.
184endif
185endif                                                           ; Fin du cas mois non bloqué
186endfor                                                          ; Fin de la boucle sur les mois, balayage de la matrice
187flux_corr = invert(A2) ## transpose(fluxinit(lo,la,*))          ; Ré-itération de la multiplication matricielle avec la matrice A modifiée (A2)
188whereneg = where(flux_corr lt 0)                                ; (12 pts max) Ré-identification de potentiels nouveaux points à problÚmes, corrigés négativement
189nbannul=n_elements(whereneg)*(total(whereneg) ne -1)
190endwhile                                                        ; Fin du cas où l'on avait des problÚmes d'émissions corrigées négativement
191; *** IMPORTANT ! *** Pour signaler les mois bloqués, on prend la convention suivante :
192;       valeur négative ou nulle <=> mois bloqué
193;       valeur positive <=> mois à interpolation classique
194flux(lo,la,*) = flux_corr                                       ; En sortie de la boucle while, normalement flux_corr est complÚtement positif
195endfor                                                          ; Fin boucle lat
196endfor                                                          ; Fin boucle lon
197nbnegtotal = n_elements(where(m_bloq eq 1)) * (total(where(m_bloq eq 1)) ne -1)
198if nbnegtotal ne 0 then flux(where(m_bloq eq 1)) = -flux(where(m_bloq eq 1))            ; Je force à des valeurs négatives
199;
200month_in_year=12
201nbpoint=${nbpoint}
202flux2=fltarr(nbpoint,month_in_year)
203flux2(*,*)=0.0
204;
205for l=0,month_in_year-1 do begin
206flux2(0,l)=TOTAL(flux(*,0,l))/float(dimlon)
207flux2(nbpoint-1,l)=TOTAL(flux(*,dimlat-1,l))/float(dimlon)
208endfor
209;
210pt=1
211for j=1,dimlat-2  do begin
212for i=0,dimlon-1  do begin
213for l=0,month_in_year-1 do begin
214  flux2(pt,l)=flux(i,j,l)
215endfor
216pt=pt+1
217endfor
218endfor
219;
220;saving netcdf file
221;
222fluxstruct={vector:fltarr(nbpoint),time:fltarr(month_in_year), $
223            flx_${speciesinca}:fltarr(nbpoint,month_in_year) }
224;
225fluxstruct.vector=float(indgen(nbpoint)+1)
226;;fluxstruct.time=float(indgen(month_in_year)+1)
227fluxstruct.time=[15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345]
228fluxstruct.flx_${speciesinca}=flux2
229;
230attributes = {units:strarr(3),long_name:strarr(3)}
231attributes.units = ['vector','days since 1960-01-01','flux']
232attributes.long_name = ['vector', 'time', 'flux']
233;
234dimensions = {isdim:intarr(3), links:intarr(2,3)}
235       dimensions.isdim =  [1,1,0]  ; (1=dimension, 0=variable)
236       dimensions.links = [ [-1,-1],[-1,-1],[0,1]    ]
237;
238netcdfwrite,'${filenameout3}',fluxstruct,clobber=1, attributes=attributes, dimensions=dimensions
239;
240end
241eod
242
243#
244#--calling IDL
245#
246/opt/idl-6.4/idl/bin/idl << eod
247.r netcdf
248.r netcdfwrite
249.r struct_dims
250.r regrid
251regrid
252exit
253eod
254#
255
256#--finding correct file for VUA data
257if [ $year -ge 1750 -a $year -lt 1850 ]; then
258year1=1750
259year2=1849
260elif [ $year -ge 1850 -a $year -lt 2016 ]; then
261year1=1850
262year2=2015
263else
264echo 'Houston we have a problem for the VUA data'
265exit 1
266fi
267
268#--now dealing with BB sources
269filename=${dirinVUA}${species}"-em-biomassburning/gn/v20161213/"${species}"-em-biomassburning_input4MIPs_emissions_CMIP_VUA-CMIP-BB4CMIP6-1-2_gn_${year1}01-${year2}12.nc"
270
271#--output files
272filenameout1=${dirout}flux_${speciesinca}bb_${year}.nc
273filenameout1b=${dirout}flux_0_${speciesinca}bb_${year}.nc
274filenameout2=${dirout}flux_lmdz0_${speciesinca}bb_${year}.nc
275filenameout3=${dirout}flux_vector_${speciesinca}bb_${year}.nc
276
277echo ${filename} ${filenameout1} ${filenameout1b} ${filenameout2} ${filenameout3}
278rm -f ${filenameout1} ${filenameout1b} ${filenameout2} ${filenameout3}
279
280#--unfortunately idl not happy with VUA netcdf files so need to ferretize files
281#--I extract the correct year as well
282rm -f rewrite.jnl
283cat << eod > rewrite.jnl
284set memory/size=100
285use "${filename}"
286set region/t=16-jan-${year}:16-dec-${year}
287save/clobber/file="${filenameout1}" ${species}
288eod
289
290#--run ferret script
291ferret << eod
292go rewrite.jnl
293exit
294eod
295
296#--replace undef with 0               --------------------------- Moved here (before remap) by ThL 22/06/2017
297cdo setmisstoc,0.0 ${filenameout1} ${filenameout1b}
298
299#--remap to LMDz grid
300#--OC to POM conversion factor
301#--as ferret returns NOX, treat NOx NOX inconsistency in names by converting to upper case
302if [ ${species} != "OC"  ] ; then
303echo cdo remapcon,${gridfile} -chname,`echo ${species} | awk '{print toupper($0)}'`,flux ${filenameout1b} ${filenameout2}
304cdo remapcon,${gridfile} -chname,`echo ${species} | awk '{print toupper($0)}'`,flux ${filenameout1b} ${filenameout2}
305else
306echo cdo remapcon,${gridfile} -chname,${species},flux -mulc,1.4 ${filenameout1b} ${filenameout2}
307cdo remapcon,${gridfile} -chname,${species},flux -mulc,1.4 ${filenameout1b} ${filenameout2}
308fi
309
310#--Improved Sheng & Zwiers algorithm + transform into vector
311rm -f regrid.pro
312cat << eod >> regrid.pro
313pro regrid
314filename='${filenameout2}'
315print, filename
316NETCDFREAD,filename,'flux',flux,dimflux
317NETCDFREAD,filename,'lat',lat,dimlat0
318NETCDFREAD,filename,'lon',lon,dimlon0
319NETCDFREAD,filename,'TIME',time,dimtime0
320dimlat=dimlat0(0)
321dimlon=dimlon0(0)
322dimtime=dimtime0(0)
323print, 'dim flux=', dimflux
324A = float([     [3./4., 1./8., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1./8.],$
325                [1./8., 3./4., 1./8., 0., 0., 0., 0., 0., 0., 0., 0., 0.],$
326                [0., 1./8., 3./4., 1./8., 0., 0., 0., 0., 0., 0., 0., 0.],$
327                [0., 0., 1./8., 3./4., 1./8., 0., 0., 0., 0., 0., 0., 0.],$
328                [0., 0., 0., 1./8., 3./4., 1./8., 0., 0., 0., 0., 0., 0.],$
329                [0., 0., 0., 0., 1./8., 3./4., 1./8., 0., 0., 0., 0., 0.],$
330                [0., 0., 0., 0., 0., 1./8., 3./4., 1./8., 0., 0., 0., 0.],$
331                [0., 0., 0., 0., 0., 0., 1./8., 3./4., 1./8., 0., 0., 0.],$
332                [0., 0., 0., 0., 0., 0., 0., 1./8., 3./4., 1./8., 0., 0.],$
333                [0., 0., 0., 0., 0., 0., 0., 0., 1./8., 3./4., 1./8., 0.],$
334                [0., 0., 0., 0., 0., 0., 0., 0., 0., 1./8., 3./4., 1./8.],$
335                [1./8., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1./8., 3./4.]   ])
336fluxinit=flux
337flux_check=flux
338for lo=0,dimlon-1 do begin
339for la=0,dimlat-1 do begin
340flux_check(lo,la,*) = invert(A) ## transpose(fluxinit(lo,la,*))
341endfor
342endfor                 
343m_bloq = make_array(dimlon,dimlat,12,value=0)           ; Matrice booléenne "mois à bloquer ou non"
344if total(where(flux_check lt 0)) ne -1 then m_bloq(where(flux_check lt 0)) = 1
345; Correction/adaptation de la matrice S&Z en fonction du masque booléen m_bloq
346for lo=0,dimlon-1 do begin
347for la=0,dimlat-1 do begin
348whereneg = where(flux_check(lo,la,*) lt 0)              ; (12 pts max) Identification de potentiels points à problÚmes, corrigés négativement
349nbannul=n_elements(whereneg)*(total(whereneg) ne -1)
350flux_corr=flux_check(lo,la,*)                           ; Création d'un vecteur pour recevoir les valeurs corrigées, initialisé à flux_check au cas où on n'ait rien à faire (à part 1 seule correction matricielle)
351A2 = A                                                  ; Je repars de la matrice A initiale, ce pour chaque point de grille
352;                                                       ; Potentiellement plusieurs passages pour éliminer toutes les valeurs négatives
353while nbannul ne 0 do begin                             ; Si l'on a effectivement des émissions corrigées négativement...
354m_bloq(lo,la,whereneg) = 1                              ; Update de la matrice m_bloq
355for m=0,11 do begin
356if m eq 11 then begin                                   ; Pour plus de facilité, mois précédents et suivants codés ici
357p=10
358s=0
359endif else if m eq 0 then begin
360p=11
361s=1
362endif else begin
363p = m-1
364s = m+1
365endelse
366if m_bloq(lo,la,m) then begin                           ; Je traite les mois bloqués en eux-mêmes
367A2(p,m) = 0.
368A2(m,m) = 1.
369A2(s,m) = 0.
370endif                                                   ; Fin du cas si l'on est sur un mois bloqué
371if ~m_bloq(lo,la,m) then begin                          ; Je traite les mois non bloqués, pour ceux adjacents à un mois bloqué
372if m_bloq(lo,la,p) and m_bloq(lo,la,s) then begin               ; Mois encadré de deux mois bloqués
373A2(p,m) = 1./4.
374A2(m,m) = 1./2.
375A2(s,m) = 1./4.
376endif else if m_bloq(lo,la,p) and ~m_bloq(lo,la,s) then begin   ; Mois précédent bloqué (uniquement)
377A2(p,m) = 2./8.
378A2(m,m) = 5./8.
379A2(s,m) = 1./8.
380endif else if ~m_bloq(lo,la,p) and m_bloq(lo,la,s) then begin   ; Mois suivant bloqué (uniquement)
381A2(p,m) = 1./8.
382A2(m,m) = 5./8.
383A2(s,m) = 2./8.
384endif
385endif                                                           ; Fin du cas mois non bloqué
386endfor                                                          ; Fin de la boucle sur les mois, balayage de la matrice
387flux_corr = invert(A2) ## transpose(fluxinit(lo,la,*))          ; Ré-itération de la multiplication matricielle avec la matrice A modifiée (A2)
388whereneg = where(flux_corr lt 0)                                ; (12 pts max) Ré-identification de potentiels nouveaux points à problÚmes, corrigés négativement
389nbannul=n_elements(whereneg)*(total(whereneg) ne -1)
390endwhile                                                        ; Fin du cas où l'on avait des problÚmes d'émissions corrigées négativement
391; *** IMPORTANT ! *** Pour signaler les mois bloqués, on prend la convention suivante :
392;       valeur négative ou nulle <=> mois bloqué
393;       valeur positive <=> mois à interpolation classique
394flux(lo,la,*) = flux_corr                                       ; En sortie de la boucle while, normalement flux_corr est complÚtement positif
395endfor                                                          ; Fin boucle lat
396endfor                                                          ; Fin boucle lon
397nbnegtotal = n_elements(where(m_bloq eq 1)) * (total(where(m_bloq eq 1)) ne -1)
398if nbnegtotal ne 0 then flux(where(m_bloq eq 1)) = -flux(where(m_bloq eq 1))            ; Je force à des valeurs négatives
399;
400month_in_year=12
401nbpoint=${nbpoint}
402flux2=fltarr(nbpoint,month_in_year)
403flux2(*,*)=0.0
404;
405for l=0,month_in_year-1 do begin
406flux2(0,l)=TOTAL(flux(*,0,l))/float(dimlon)
407flux2(nbpoint-1,l)=TOTAL(flux(*,dimlat-1,l))/float(dimlon)
408endfor
409;
410pt=1
411for j=1,dimlat-2  do begin
412for i=0,dimlon-1  do begin
413for l=0,month_in_year-1 do begin
414  flux2(pt,l)=flux(i,j,l)
415endfor
416pt=pt+1
417endfor
418endfor
419;
420;saving netcdf file
421;
422fluxstruct={vector:fltarr(nbpoint),time:fltarr(month_in_year), $
423            flx_bb${speciesinca}:fltarr(nbpoint,month_in_year) }
424;
425fluxstruct.vector=float(indgen(nbpoint)+1)
426;;fluxstruct.time=float(indgen(month_in_year)+1)
427fluxstruct.time=[15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345]
428fluxstruct.flx_bb${speciesinca}=flux2
429;
430attributes = {units:strarr(3),long_name:strarr(3)}
431attributes.units = ['vector','days since 1960-01-01','flux']
432attributes.long_name = ['vector', 'time', 'flux']
433;
434dimensions = {isdim:intarr(3), links:intarr(2,3)}
435       dimensions.isdim =  [1,1,0]  ; (1=dimension, 0=variable)
436       dimensions.links = [ [-1,-1],[-1,-1],[0,1]    ]
437;
438netcdfwrite,'${filenameout3}',fluxstruct,clobber=1, attributes=attributes, dimensions=dimensions
439;
440end
441eod
442
443#
444#--calling IDL
445#
446/opt/idl-6.4/idl/bin/idl << eod
447.r netcdf
448.r netcdfwrite
449.r struct_dims
450.r regrid
451regrid
452exit
453eod
454#
455
456#--end loop on species
457done
458
459#--unfortunately idl use capital letters for variable names so need to change to small letters for now
460rm -f ${dirout}flux_vector_h2s_${year}.nc ${dirout}flux_vector_so4_${year}.nc
461cdo expr,'flx_h2s=0.*FLX_SO2' ${dirout}flux_vector_so2_${year}.nc ${dirout}flux_vector_h2s_${year}.nc
462cdo expr,'flx_so4=0.*FLX_SO2' ${dirout}flux_vector_so2_${year}.nc ${dirout}flux_vector_so4_${year}.nc
463
464rm -f ${dirout}flux_vector_${year}.nc
465
466#--combining everything into a single file with some final preprocessing
467rm -f ${dirout}flux_vector_noxtot_${year}.nc ${dirout}flux_vector_so2tot_${year}.nc ${dirout}flux_vector_nh3tot_${year}.nc
468
469#--deleting output file if already there
470rm -f ${dirout}sflx_lmdz_cmip6_${year}.nc
471#--merging all files into a single one
472#--PNNL NOx is NO2 so 30/46 scaling factor to change to NO
473#--VUA NOx is NO so no change in unit
474cdo merge -expr,'flx_bc=FLX_BC' ${dirout}flux_vector_bc_${year}.nc -expr,'flx_bbbc=FLX_BBBC' ${dirout}flux_vector_bcbb_${year}.nc -expr,'flx_pom=FLX_POM' ${dirout}flux_vector_pom_${year}.nc -expr,'flx_bbpom=FLX_BBPOM' ${dirout}flux_vector_pombb_${year}.nc -expr,'flx_nox=30.*FLX_NOX/46.' ${dirout}flux_vector_nox_${year}.nc -expr,'flx_bbnox=FLX_BBNOX;' ${dirout}flux_vector_noxbb_${year}.nc -expr,'flx_so2=FLX_SO2' ${dirout}flux_vector_so2_${year}.nc -expr,'flx_bbso2=FLX_BBSO2' ${dirout}flux_vector_so2bb_${year}.nc -expr,'flx_nh3=FLX_NH3' ${dirout}flux_vector_nh3_${year}.nc -expr,'flx_bbnh3=FLX_BBNH3' ${dirout}flux_vector_nh3bb_${year}.nc  ${dirout}flux_vector_h2s_${year}.nc ${dirout}flux_vector_so4_${year}.nc -selname,conc_dms ${fileINCAex} ${dirout}sflx_lmdz_cmip6_${year}.nc
475
476ncrename -d VECTOR,vector -v VECTOR,vector ${dirout}sflx_lmdz_cmip6_${year}.nc
477ncrename -d TIME,time     -v TIME,time     ${dirout}sflx_lmdz_cmip6_${year}.nc
478
479#--cleaning up
480rm -f ${dirout}flux*_${year}.nc
481
482#--end loop on years
483done
484
485#--cleaning the mess
486rm -f ferret*
487rm -f regrid.pro
Note: See TracBrowser for help on using the repository browser.