<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>&nbsp;</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 &#8220;bin_sum&#8221; 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>&nbsp;</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"'>&#8220;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gbin [*][*] : numeric ,&nbsp; <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gknt [*][*] : integer ,&nbsp; <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>glon&nbsp;&nbsp;&nbsp; [*] : numeric ,&nbsp; <o:p></o:p></b></span></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; glat&nbsp;&nbsp; &nbsp;&nbsp;[*] : numeric ,&nbsp; <o:p></o:p></span></b></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zlon&nbsp;&nbsp; &nbsp;&nbsp;[*] : numeric ,&nbsp; <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zlat&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[*] : numeric ,&nbsp; <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; z&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[*] : numeric&nbsp;&nbsp;&nbsp; &#8221;<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>The targeted output &#8220;glon&#8221; and &#8220;glat&#8221; 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 &#8220;bin_sum&#8221; 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>&nbsp;</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"'> &nbsp;gbin&nbsp; = 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"'>&nbsp; gknt&nbsp; = 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>&nbsp;</o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'>&nbsp; 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"'>&nbsp; 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>&nbsp;</o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'>&nbsp; gbin_temp&nbsp; = 0.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; initialization<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'>&nbsp; gknt_temp&nbsp; = 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>&nbsp;</o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'>&nbsp; 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"'>&nbsp; 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"'>&nbsp; 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>&nbsp;</o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'>&nbsp; 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"'>&nbsp; end do<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:12.0pt;font-family:"Arial","sans-serif"'>&nbsp; print(&quot;zyq finish &quot;+ 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>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p>&nbsp;</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>&nbsp;</o:p></p></div></body></html>