source: TOOLS/CMIP6_FORCING/AER_STRAT/volc.sh @ 3403

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

Script to prepare volcanic (=stratospheric) aerosols for CMIP6

  • Property svn:executable set to *
File size: 14.8 KB
Line 
1dirpwd=`pwd`
2
3vv='v3'
4
5#--choose the resolution
6#--only LR works for now !
7#lmdz='VVLR'
8#lmdz='VLR_L79'
9#lmdz='VLR'
10lmdz='LR'
11#lmdz='MR'
12
13dirout='/data/'${USER}'/CMIP6/VOLC/'${lmdz}'_'${vv}'/'
14echo $dirout
15if [ ! -d ${dirout} ] ; then mkdir -p ${dirout} ; fi
16
17cat > process_volc.pro << EOF
18pro regrid
19;--version sans longitude
20;--latitude - level - wavelength - time
21;--sep 2017: add lat and month z variations of model layers
22;--Olivier Boucher
23;
24if (lmdz eq 'VVLR') then begin
25dimlonlmdz=48
26dimlatlmdz=37
27dimz=19
28output='/data/${USER}/CMIP6/VOLC/VVLR_${vv}/'
29endif
30
31if (lmdz eq 'VLR') then begin
32dimlonlmdz=96
33dimlatlmdz=96
34dimz=39
35output='/data/${USER}/CMIP6/VOLC/VLR_${vv}/'
36endif
37
38if (lmdz eq 'VLR_L79') then begin
39dimlonlmdz=96
40dimlatlmdz=96
41dimz=79
42output='/data/${USER}/CMIP6/VOLC/VLR_L79_${vv}/'
43endif
44
45if (lmdz eq 'LR') then begin
46dimlonlmdz=144
47dimlatlmdz=143
48dimz=79
49output='/data/${USER}/CMIP6/VOLC/LR_${vv}/'
50endif
51
52if (lmdz eq 'MR') then begin
53dimlonlmdz=256
54dimlatlmdz=257
55dimz=79
56output='/data/${USER}/CMIP6/VOLC/MR_${vv}/'
57endif
58
59latfirst=90.
60latinc=-180./float(dimlatlmdz-1)
61lonfirst=-180.
62loninc=360./float(dimlonlmdz-1)
63latitudelmdz=latfirst+latinc*indgen(dimlatlmdz)
64longitudelmdz=lonfirst+loninc*indgen(dimlonlmdz)
65NSW=6
66NLW=16
67;
68;--script only works on ciclad
69dir='/prodigfs/project/input4MIPs/VOLC/${vv}/'
70filename=dir+'CMIP_1850_2014_extinction_550nm_${vv}.nc'
71NETCDFREAD,filename,'altitude',altitude,dimaltitude
72NETCDFREAD,filename,'ext550',ext550,dimext
73;
74filename=dir+'CMIP_IPSL-CM6_radiation_${vv}.nc'
75;
76NETCDFREAD,filename,'altitude',altitude,dimaltitude
77NETCDFREAD,filename,'latitude',latitude,dimlatitude
78NETCDFREAD,filename,'wl1_sun',wl1_sun,solar_bands
79NETCDFREAD,filename,'wl2_sun',wl2_sun,solar_bands
80NETCDFREAD,filename,'wl1_earth',wl1_earth,terrestrial_bands
81NETCDFREAD,filename,'wl2_earth',wl2_earth,terrestrial_bands
82NETCDFREAD,filename,'month',month,dimmonth
83NETCDFREAD,filename,'ext_sun',ext_sun,dimext
84NETCDFREAD,filename,'omega_sun',omega_sun,dimext
85NETCDFREAD,filename,'g_sun',g_sun,dimext
86NETCDFREAD,filename,'ext_earth',ext_earth,dimext
87NETCDFREAD,filename,'omega_earth',omega_earth,dimext
88NETCDFREAD,filename,'g_earth',g_earth,dimext
89;
90print ,'wl1_sun=', wl1_sun
91print ,'wl2_sun=', wl2_sun
92print ,'wl1_ear=', wl1_earth
93print ,'wl2_ear=', wl2_earth
94;
95print ,'min max ext_sun=', min(ext_sun),   max(ext_sun)
96print ,'min max ome_sun=', min(omega_sun), max(omega_sun)
97;for nl=0, NSW-1 do begin
98;print ,'min max ome_sun nl=', nl, min(omega_sun(*,*,*,nl)), max(omega_sun(*,*,*,nl))
99;endfor
100print ,'min max ggg_sun=', min(g_sun),     max(g_sun)
101print ,'min max ext_ear=', min(ext_earth), max(ext_earth)
102;
103dimlat=dimlatitude(0)
104dimalt=dimaltitude(0)
105dimtime=dimmonth(0)
106;
107;--vertical resolution in Beiping's code
108dz=0.5
109;
110month_in_year=12
111;;month_in_year=1
112;
113;--compute optical depth of input data
114;--dimension ext_sun(l,k,j,nl)
115;ext_sun0=ext_sun(0,*,*,*)
116;print , 'size ext_sun0=', size(ext_sun0)
117;tau_sun=TOTAL(ext_sun0,2)*dz
118;print ,'min max tau_sun l=0 =', min(tau_sun),   max(tau_sun)
119;
120zz=fltarr(dimz)
121;
122;---approximate altitudes of LMDZ - L19 and L39
123;---NOT RECOMMENDED
124;
125if (dimz eq 19) then begin
126zz=[ 0.07125416, 0.2402302, 0.4865242, 0.8627044, 1.426484, 2.244528,    $
127    3.394085, 4.952366, 6.950302, 9.26943, 11.59338, 13.71214, 15.83651, $
128    18.27338, 21.16397, 24.63156, 28.9039, 34.57184, 44.51565] ;
129endif
130;
131if (dimz eq 39) then begin
132zz=[0.0338988, 0.1106602, 0.2139233, 0.3609663, 0.5685416, 0.8534464,     $
133    1.233232, 1.726868, 2.355076, 3.139813, 4.101937, 5.25541, 6.596076,  $
134    8.085103, 9.636482, 11.13441, 12.50023, 13.75765, 15.00424, 16.32207, $
135    17.74403, 19.27899, 20.93219, 22.70941, 24.61736, 26.66389, 28.85831, $
136    31.21178, 33.73778, 36.45278, 39.37709, 42.53607, 45.96209, 49.69786, $
137    53.80379, 58.37727, 63.61497, 70.07092, 80.52708]
138endif
139;
140;---exact altitudes of LMDZ -- L79
141;--only exists for LR at the moment
142if (dimz eq 79) then begin
143  filename='./zalt_zonmean_LR_l79_rev.nc'
144  NETCDFREAD,filename,'GEOP',zz,dimzz
145  NETCDFREAD,filename,'LAT',zzlat,dimzzlat
146  NETCDFREAD,filename,'TIME_COUNTER',zztime,dimzztime
147  dimzzilat=dimzzlat[0]
148  dimzzitime=dimzztime[0]
149  ;--becareful zz comes with four dimensions
150  ;--lon lat k time
151  print, 'GEOP size=', size(zz)
152  ;--becareful zzlat comes with South Pole first
153  print, 'LAT from zalt field=', zzlat
154  if (dimzzilat ne dimlatlmdz) then begin
155    print , 'PB dimension latitude'
156  endif
157endif
158;
159;
160;--reconstructing the vertical coordinate at interfaces (in unit km)
161;--and reverse lat axis for zzi  i==>ii
162;--and reverse zz axis for zzi   dimz-1-k==>k
163;--and forget about lon axis : index 0 in zz
164zzi=fltarr(dimzzilat,dimzzitime,dimz+1)
165for i=0, dimzzilat-1 do begin
166 ii=dimzzilat-1-i
167 for t=0, dimzzitime-1 do begin
168  zzi(ii,t,0)=0.0
169  for k=1, dimz-1 do begin
170   zzi(ii,t,k)=(zz(0,i,dimz-1-(k-1),t)+zz(0,i,dimz-1-k,t))/2.0
171  endfor
172  zzi(ii,t,dimz)=100.00
173 endfor
174endfor
175print, 'zzi=',zzi
176;
177lev=indgen(dimz)+1
178;
179dimzori=dimalt
180zziori=fltarr(dimzori+1)
181zziori(0)=altitude(0)-0.25
182for k=1, dimzori do begin
183 zziori(k)=altitude(k-1)+0.25
184endfor
185;
186;--550 nm properties
187tau_550_lmdz=fltarr(dimlatlmdz,dimz,month_in_year)
188;
189;--SW properties
190tau_sun_lmdz=fltarr(dimlatlmdz,dimz,NSW,month_in_year)
191ome_sun_lmdz=fltarr(dimlatlmdz,dimz,NSW,month_in_year)
192ggg_sun_lmdz=fltarr(dimlatlmdz,dimz,NSW,month_in_year)
193;
194tau_sun_lmdz_ave=fltarr(dimlatlmdz,dimz,NSW,month_in_year)
195ome_sun_lmdz_ave=fltarr(dimlatlmdz,dimz,NSW,month_in_year)
196ggg_sun_lmdz_ave=fltarr(dimlatlmdz,dimz,NSW,month_in_year)
197;
198;--LW properties tau_abs
199tau_ear_lmdz=fltarr(dimlatlmdz,dimz,NLW,month_in_year)
200;
201tau_ear_lmdz_ave=fltarr(dimlatlmdz,dimz,NLW,month_in_year)
202;
203tau_sun_lmdz_ave(*,*,*,0)=1.e-15
204ome_sun_lmdz_ave(*,*,*,0)=1.e-15
205ggg_sun_lmdz_ave(*,*,*,0)=0.0
206tau_ear_lmdz_ave(*,*,*,0)=1.e-15
207;
208for year=0, dimtime/month_in_year-1 do begin
209;for year=141, 142 do begin ;--Pinatubo
210;
211tau_550_lmdz(*,*,*)=1.e-15
212tau_sun_lmdz(*,*,*,*)=1.e-15
213ome_sun_lmdz(*,*,*,*)=1.e-15
214ggg_sun_lmdz(*,*,*,*)=0.0
215tau_ear_lmdz(*,*,*,*)=1.e-15
216;
217chyr=strcompress(1850+year,/rem)
218;
219for mth=0,month_in_year-1 do begin
220;
221;--timestep
222l=mth+month_in_year*year
223print,'year mth l=',chyr, mth, l
224;
225;regridding
226for j=0, dimlatlmdz-1  do begin
227;
228;--finding latitude in beiping luo data
229jj=0
230for jluo=0,dimlat-2 do begin
231  if (latitudelmdz(j) gt (latitude(jluo)+latitude(jluo+1))/2. ) then begin
232    jj=jluo+1
233  endif
234endfor
235;
236for k=0, dimz-1 do begin
237for kori=0, dimzori-1 do begin
238;
239;fraction de la maille kori qui se trouve dans la maille k
240frac= max([0.0,min([zzi(j,mth,k+1),zziori(kori+1)])-max([zzi(j,mth,k),zziori(kori)])])/(zziori(kori+1)-zziori(kori))
241;
242tau_550_lmdz(j,k,mth)=tau_550_lmdz(j,k,mth)+ext550(l,kori,jj)*dz*frac
243;
244for nl=0, NSW-1 do begin
245  tau_sun_lmdz(j,k,nl,mth)=tau_sun_lmdz(j,k,nl,mth)+ext_sun(l,kori,jj,nl)*dz*frac
246  ome_sun_lmdz(j,k,nl,mth)=ome_sun_lmdz(j,k,nl,mth)+omega_sun(l,kori,jj,nl)*ext_sun(l,kori,jj,nl)*dz*frac
247  ggg_sun_lmdz(j,k,nl,mth)=ggg_sun_lmdz(j,k,nl,mth)+g_sun(l,kori,jj,nl)*omega_sun(l,kori,jj,nl)*ext_sun(l,kori,jj,nl)*dz*frac
248;
249  tau_sun_lmdz_ave(j,k,nl,0)=tau_sun_lmdz_ave(j,k,nl,0)+ext_sun(l,kori,jj,nl)*dz*frac
250  ome_sun_lmdz_ave(j,k,nl,0)=ome_sun_lmdz_ave(j,k,nl,0)+omega_sun(l,kori,jj,nl)*ext_sun(l,kori,jj,nl)*dz*frac
251  ggg_sun_lmdz_ave(j,k,nl,0)=ggg_sun_lmdz_ave(j,k,nl,0)+g_sun(l,kori,jj,nl)*omega_sun(l,kori,jj,nl)*ext_sun(l,kori,jj,nl)*dz*frac
252endfor
253;
254for nl=0, NLW-1 do begin
255  tau_ear_lmdz(j,k,nl,mth)=tau_ear_lmdz(j,k,nl,mth)+ext_earth(l,kori,jj,nl)*(1.-omega_earth(l,kori,jj,nl))*dz*frac
256  tau_ear_lmdz_ave(j,k,nl,0)=tau_ear_lmdz_ave(j,k,nl,0)+ext_earth(l,kori,jj,nl)*(1.-omega_earth(l,kori,jj,nl))*dz*frac
257endfor
258;
259endfor
260;--end lat loop
261;
262endfor
263endfor
264;--end k loops
265;
266endfor
267;--end month loop
268;
269;renormalizing intensive SW properties
270ggg_sun_lmdz(*,*,*,*)=ggg_sun_lmdz(*,*,*,*)/ome_sun_lmdz(*,*,*,*)
271ome_sun_lmdz(*,*,*,*)=ome_sun_lmdz(*,*,*,*)/tau_sun_lmdz(*,*,*,*)
272;
273;saving netcdf file
274;
275print ,'min max ext_sun lmdz=', min(tau_sun_lmdz), max(tau_sun_lmdz)
276print ,'min max ome_sun lmdz=', min(ome_sun_lmdz), max(ome_sun_lmdz)
277;for nl=0, NSW-1 do begin
278;print ,'min max ome_sun lmdz nl =', nl, min(ome_sun_lmdz(*,*,nl,*)), max(ome_sun_lmdz(*,*,nl,*))
279;endfor
280print ,'min max ggg_sun lmdz=', min(ggg_sun_lmdz), max(ggg_sun_lmdz)
281print ,'min max ext_ear lmdz=', min(tau_ear_lmdz), max(tau_ear_lmdz)
282;
283print ,'min max ext_sun lmdz l=1=', min(tau_sun_lmdz(*,*,*,0)), max(tau_sun_lmdz(*,*,*,0))
284print ,'min max ome_sun lmdz l=1=', min(ome_sun_lmdz(*,*,*,0)), max(ome_sun_lmdz(*,*,*,0))
285print ,'min max ggg_sun lmdz l=1=', min(ggg_sun_lmdz(*,*,*,0)), max(ggg_sun_lmdz(*,*,*,0))
286print ,'min max ext_ear lmdz l=1=', min(tau_ear_lmdz(*,*,*,0)), max(tau_ear_lmdz(*,*,*,0))
287;
288;--compute optical depth of output data
289;tau_sun=TOTAL(tau_sun_lmdz,2)
290;print ,'min max tau_sun_lmdz vert=', min(tau_sun),   max(tau_sun)
291;
292opticstruct={lat:fltarr(dimlatlmdz),lev:fltarr(dimz),             $
293             wav:fltarr(NSW),time:fltarr(month_in_year),          $
294             tau_sun:fltarr(dimlatlmdz,dimz,NSW,month_in_year),   $
295             ome_sun:fltarr(dimlatlmdz,dimz,NSW,month_in_year),   $
296             ggg_sun:fltarr(dimlatlmdz,dimz,NSW,month_in_year) }
297;
298opticstruct.lat=latitudelmdz
299opticstruct.lev=lev
300opticstruct.wav=(wl1_sun(0:NSW-1)+wl2_sun(0:NSW-1))/2.
301opticstruct.time=float(indgen(month_in_year)+1)
302opticstruct.tau_sun=tau_sun_lmdz
303opticstruct.ome_sun=ome_sun_lmdz
304opticstruct.ggg_sun=ggg_sun_lmdz
305;
306attributes = {units:strarr(7),long_name:strarr(7)}
307attributes.units =     ['degrees_north','level','meters','month','-','-','-']
308attributes.long_name = ['latitude','level','wavelength','time','tau_sun','ome_sun','g_sun']
309;
310dimensions = {isdim:intarr(7), links:intarr(4,7)}
311       dimensions.isdim =  [1,1,1,1,0,0,0]  ; (1=dimension, 0=variable)
312       dimensions.links = [ [-1,-1,-1,-1],[-1,-1,-1,-1],   $
313                            [-1,-1,-1,-1],[-1,-1,-1,-1],   $
314                            [0,1,2,3],[0,1,2,3],[0,1,2,3]  ]
315;
316netcdfwrite,output+'tauswstrat.2D.'+chyr+'.nc',opticstruct,clobber=1, $
317            attributes=attributes, dimensions=dimensions
318;
319opticstruct={lat:fltarr(dimlatlmdz),lev:fltarr(dimz),             $
320             wav:fltarr(NLW),time:fltarr(month_in_year),          $
321             tau_ear:fltarr(dimlatlmdz,dimz,NLW,month_in_year) }
322;
323opticstruct.lat=latitudelmdz
324opticstruct.lev=lev
325opticstruct.wav=(wl1_earth+wl2_earth)/2.
326opticstruct.time=float(indgen(month_in_year)+1)
327opticstruct.tau_ear=tau_ear_lmdz
328;
329attributes = {units:strarr(5),long_name:strarr(5)}
330attributes.units = ['degrees_north','level','cm-1','month','-']
331attributes.long_name = ['latitude','level','wavenumber','time','tau_ear']
332;
333dimensions = {isdim:intarr(5), links:intarr(4,5)}
334       dimensions.isdim =  [1,1,1,1,0]  ; (1=dimension, 0=variable)
335       dimensions.links = [ [-1,-1,-1,-1],[-1,-1,-1,-1],   $
336                            [-1,-1,-1,-1],[-1,-1,-1,-1],   $
337                            [0,1,2,3]  ]
338;
339netcdfwrite,output+'taulwstrat.2D.'+chyr+'.nc',opticstruct,clobber=1, $
340            attributes=attributes, dimensions=dimensions
341;
342opticstruct={lat:fltarr(dimlatlmdz),lev:fltarr(dimz),             $
343             time:fltarr(month_in_year),                          $
344             tau550:fltarr(dimlatlmdz,dimz,month_in_year) }
345;
346opticstruct.lat=latitudelmdz
347opticstruct.lev=lev
348opticstruct.time=float(indgen(month_in_year)+1)
349opticstruct.tau550=tau_550_lmdz
350;
351attributes = {units:strarr(4),long_name:strarr(4)}
352attributes.units = ['degrees_north','level','month','-']
353attributes.long_name = ['latitude','level','time','tau550']
354;
355dimensions = {isdim:intarr(4), links:intarr(3,4)}
356       dimensions.isdim =  [1,1,1,0]  ; (1=dimension, 0=variable)
357       dimensions.links = [ [-1,-1,-1],[-1,-1,-1],   $
358                            [-1,-1,-1],[0,1,2]  ]
359;
360netcdfwrite,output+'tau550strat.2D.'+chyr+'.nc',opticstruct,clobber=1, $
361            attributes=attributes, dimensions=dimensions
362;
363endfor
364;--end loop on years
365;
366;now deal with average conditions
367ggg_sun_lmdz_ave(*,*,*,0)=ggg_sun_lmdz_ave(*,*,*,0)/ome_sun_lmdz_ave(*,*,*,0)
368ome_sun_lmdz_ave(*,*,*,0)=ome_sun_lmdz_ave(*,*,*,0)/tau_sun_lmdz_ave(*,*,*,0)
369tau_sun_lmdz_ave(*,*,*,0)=tau_sun_lmdz_ave(*,*,*,0)/float(dimtime)
370tau_ear_lmdz_ave(*,*,*,0)=tau_ear_lmdz_ave(*,*,*,0)/float(dimtime)
371;
372for mth=1, month_in_year-1 do begin
373ggg_sun_lmdz_ave(*,*,*,mth)=ggg_sun_lmdz_ave(*,*,*,0)
374ome_sun_lmdz_ave(*,*,*,mth)=ome_sun_lmdz_ave(*,*,*,0)
375tau_sun_lmdz_ave(*,*,*,mth)=tau_sun_lmdz_ave(*,*,*,0)
376tau_ear_lmdz_ave(*,*,*,mth)=tau_ear_lmdz_ave(*,*,*,0)
377endfor
378;
379opticstruct={lat:fltarr(dimlatlmdz),lev:fltarr(dimz),             $
380             wav:fltarr(NSW),time:fltarr(month_in_year),          $
381             tau_sun:fltarr(dimlatlmdz,dimz,NSW,month_in_year),   $
382             ome_sun:fltarr(dimlatlmdz,dimz,NSW,month_in_year),   $
383             ggg_sun:fltarr(dimlatlmdz,dimz,NSW,month_in_year) }
384;
385opticstruct.lat=latitudelmdz
386opticstruct.lev=lev
387opticstruct.wav=(wl1_sun(0:NSW-1)+wl2_sun(0:NSW-1))/2.
388opticstruct.time=float(indgen(month_in_year))
389opticstruct.tau_sun=tau_sun_lmdz_ave
390opticstruct.ome_sun=ome_sun_lmdz_ave
391opticstruct.ggg_sun=ggg_sun_lmdz_ave
392;
393attributes = {units:strarr(7),long_name:strarr(7)}
394attributes.units =     ['degrees_north','level','meters','month','-','-','-']
395attributes.long_name = ['latitude','level','wavelength','time','tau_sun','ome_sun','g_sun']
396;
397dimensions = {isdim:intarr(7), links:intarr(4,7)}
398       dimensions.isdim =  [1,1,1,1,0,0,0]  ; (1=dimension, 0=variable)
399       dimensions.links = [ [-1,-1,-1,-1],[-1,-1,-1,-1],   $
400                            [-1,-1,-1,-1],[-1,-1,-1,-1],   $
401                            [0,1,2,3],[0,1,2,3],[0,1,2,3]  ]
402;
403netcdfwrite,output+'tauswstrat.2D.ave.nc',opticstruct,clobber=1, $
404            attributes=attributes, dimensions=dimensions
405;
406opticstruct={lat:fltarr(dimlatlmdz),lev:fltarr(dimz),             $
407             wav:fltarr(NLW),time:fltarr(month_in_year),          $
408             tau_ear:fltarr(dimlatlmdz,dimz,NLW,month_in_year) }
409;
410opticstruct.lat=latitudelmdz
411opticstruct.lev=lev
412opticstruct.wav=(wl1_earth+wl2_earth)/2.
413opticstruct.time=float(indgen(month_in_year))
414opticstruct.tau_ear=tau_ear_lmdz_ave
415;
416attributes = {units:strarr(5),long_name:strarr(5)}
417attributes.units = ['degrees_north','level','cm-1','month','-']
418attributes.long_name = ['latitude','level','wavenumber','time','tau_ear']
419;
420dimensions = {isdim:intarr(5), links:intarr(4,5)}
421       dimensions.isdim =  [1,1,1,1,0]  ; (1=dimension, 0=variable)
422       dimensions.links = [ [-1,-1,-1,-1],[-1,-1,-1,-1],   $
423                            [-1,-1,-1,-1],[-1,-1,-1,-1],   $
424                            [0,1,2,3]  ]
425;
426netcdfwrite,output+'taulwstrat.2D.ave.nc',opticstruct,clobber=1, $
427            attributes=attributes, dimensions=dimensions
428;
429end
430EOF
431
432cat > volc.job << EOF2
433#PBS -N process_volc
434#PBS -S /bin/bash
435#PBS -q week # there exist: short, day, days3, week...
436#PBS -k eo  # to write the output of stdin
437### Max memory
438#PBS -l vmem=10gb   # virtual memory
439#PBS -l  mem=10gb
440
441cd $dirpwd
442
443idl << eof
444.r netcdf
445.r process_volc
446regrid
447eof
448EOF2
449
450#qsub volc.job
Note: See TracBrowser for help on using the repository browser.