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

Last change on this file since 3765 was 3765, checked in by oboucher, 6 years ago

correction

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