<div dir="ltr">Hi all<br><br>I have 3 hourly data from 1948 to 2100 and I want to calculate multi-monthly in 7 sub-regions. The script is attachment as follows. It cannot work at all. I hope anyone can help me to modify it. Thank you very much.<br>
<br>Best,<br><br>Xiaoli<br><br><br>function subset(args)
<br> <br>mods="MPI-ESM-LR "
<br>vars="prec tas"
<br>monstrs="JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC"
<br>mds="31 28 31 30 31 30 31 31 30 31 30 31"
<br> <br>lat1=17.5; lat2=54.5
<br>lon1=72.5; lon2=135.5
<br> <br>'open /home/xiaoliy/mask_0.5_8region.ctl'
<br>'define msk1=re(data, 63, linear, 72.5, 1, 38, linear, 17.5, 1, vt, 0.2, 0.6)'
<br> <br>'close 1'
<br>'set gxout grfill'
<br> <br> mod=1
<br> while (mod<=1)
<br>
<br> model=subwrd(mods, mod)
<br> say model
<br>
<br> v=1
<br> while (v<=1)
<br>
<br> var=subwrd(vars, v)
<br> say var
<br>
<br> '!mkdir -p /home/xiaoliy/'model'/'var
<br> <br> y1=1948
<br> y2=2100
<br>
<br> y=1948
<br> while (y<=y2)
<br> <br>
<br>
<br> 'open /home/xiaoliy/'model'/3hourly/'var'_'y'-'y'.ctl'
<br>
<br> dout="/home/xiaoliy/"model"/china/"var"/"var"_"model"_multi_monthly_"y"-"y".dat"
<br> '!/bin/rm -f 'dout
<br>
<br> 'set gxout fwrite'
<br>
<br> 'set lat 'lat1' 'lat2
<br> 'set lon 'lon1' 'lon2
<br>
<br> 'set t 00z1jan1948 21z1dec2100'
<br>
<br> m=1
<br> while (m<=12)
<br>
<br> mmm=subwrd(monstrs, m)
<br> md=subwrd(mds, m)
<br>
<br> if (m=2&math_mod(y, 4)=0)
<br>
<br> mmd=29
<br> endif
<br>
<br>
<br> <br> <br>
<br> val=y" "mm
<br>
<br> time1="01"%mmm%y
<br> time2="31"%mmm%y
<br>
<br> 'set time 00z1jan1948'
<br>
<br>
<br> d=1
<br> while (d<=d2)
<br>
<br>
<br> r=1
<br> while (r<=7)
<br>
<br> 'define a=ave(data, t=8*d-7, t=8*d)'
<br>
<br>
<br> 'd ave(aave(magcm/skout(a, (msk1-'r-0.5')*('r+0.5'-msk1)), g), time=jan'y', time=dec'y')'
<br>
<br> value=sublin(result,2)
<br> pfiles=subwrd(value, 4)
<br> val=val" "pfiles
<br> <br> r=r+1
<br> endwhile<br><br> <br>* say "Extracting from step "d" to "d2<br> <br> d=d+1
<br> endwhile
<br>
<br>
<br> say val
<br> ret=write(dout, val, append)
<br> ret=close(dout)
<br>
<br> m=m+1
<br> endwhile
<br> <br> y=y+1
<br> endwhile
<br>
<br> v=v+1
<br> endwhile
<br> 'close 1'
<br>
<br> mod=mod+1
<br> endwhile
<br> <br>
<br>
<br>
<br> <br> <br>'quit'
<br> <br>return<br> <br></div>