<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Times New Roman","serif";
        color:windowtext;
        font-weight:normal;
        font-style:normal;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>Hi All,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>I need to regrid the population data from fine rectilinear grid to coarse curvilinear grid. <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>Procedure “bin_sum” will not work very efficiently for me, as <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>Bin_Sum<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>“ gbin [*][*] : numeric , <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> gknt [*][*] : integer , <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> <b>glon [*] : numeric , <o:p></o:p></b></span></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> glat [*] : numeric , <o:p></o:p></span></b></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> zlon [*] : numeric , <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> zlat [*] : numeric , <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> z [*] : numeric ”<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>The targeted output “glon” and “glat” are one-dimension and need to be equals to the rightmost and leftmost dimension of the gbin. However, I need all of them at the same dimension (lat2d, lon2d). What I am doing right now is loop over each grid cell, and then apply the “bin_sum” procedure. It works fine, but just run very slowly. I copied part of my scripts down here:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p> </o:p></span></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'>;*****************************************************************<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'>; Variables to hold binned quantities<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'>;*****************************************************************<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'> gbin = new ( (/nlat,mlon/), float )<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'> gknt = new ( (/nlat,mlon/), integer)<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'><o:p> </o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'> gbin_temp = new ((/1, 1/), float )<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'> gknt_temp = new ((/1, 1/), integer)<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'><o:p> </o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'> gbin_temp = 0.0 ; initialization<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'> gknt_temp = 0<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'><o:p> </o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'> printVarSummary(gbin_temp)<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'>;*****************************************************************<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'>;loop over the all the latitude and longitude in target grid<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'> do I = 0, mlon-1<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'> do J = 0, nlat-1<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'> bin_sum(gbin_temp,gknt_temp, glon(J,I), glat(J,I), ndtooned(zlon2d), ndtooned(zlat2d), ndtooned(z) )<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'><o:p> </o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'> gbin(J, I) = gbin_temp(0,0)<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'> end do<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'> print("zyq finish "+ I)<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'> end do<o:p></o:p></span></b></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>Any one has the idea to improve this? <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>Thanks for all your time! <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>Regards,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>Yuqiang <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>Regards,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>Yuqiang<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>