<span style="color: rgb(0, 0, 0); font-family: Tahoma,sans-serif; font-size:
13px;"><br>Diane:<br>
<br>
I corrected my Fortran code according to your 2nd suggestion, and the
values from fortran and grads matched (with small errors, but not
significant).<br>
<br>
Thanks,<br>
Sandra<br>
<div id="__assinatura__"> </div><blockquote id="prevContent"
style="border-left: 2px solid rgb(0, 0, 0); color: rgb(0, 0, 0); font-family:
arial,verdana,sans-serif; font-size: 10pt; padding-right: 0px; padding-left:
5px; margin-left: 5px; margin-right: 0px;"><div style="color: rgb(0, 0, 0);
font-family: arial; font-style: normal; font-variant: normal; font-weight:
normal; font-size: 10pt; line-height: normal; font-size-adjust: none;
font-stretch: normal;">----- Original Message ----- </div><div style="color:
rgb(0, 0, 0); background-color: rgb(228, 228, 228);"><b>De:</b> Diane Stokes
<<span class="spanLink" style="cursor: pointer;"
onclick="a6H({c2o:a3w.g52(), b7y:event, e0e: 'Diane.Stokes@NOAA.GOV',
label:'Diane Stokes', g6C:1}); c44(event);">Diane.Stokes@NOAA.GOV</span>>
</div><div style="color: rgb(0, 0, 0); font-family: arial; font-style: normal;
font-variant: normal; font-weight: normal; font-size: 10pt; line-height:
normal; font-size-adjust: none; font-stretch: normal;"><b>Para:</b> <<span
class="spanLink" style="cursor: pointer;" onclick="a6H({c2o:a3w.g52(),
b7y:event, e0e: 'GRADSUSR@LIST.CINECA.IT', label:'', g6C:1});
c44(event);">GRADSUSR@LIST.CINECA.IT</span>></div><div style="color: rgb(0,
0, 0); font-family: arial; font-style: normal; font-variant: normal;
font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust:
none; font-stretch: normal;"><b>Data:</b> 23/02/2007 15:23</div><div
style="color: rgb(0, 0, 0); font-family: arial; font-style: normal;
font-variant: normal; font-weight: normal; font-size: 10pt; line-height:
normal; font-size-adjust: none; font-stretch: normal;"><b>Assunto:</b> Re:
problems with aave</div>I see two (maybe three) contributing factors to the
difference:<br>
<br>
First, the result from aave is latitude weighted. From the documentation:<br>
<br>
"The aave function assumes that the world coordinates are longitude in<br>
the X dimension and latitude in the Y dimension, and does weighting in<br>
the latitude dimension by the difference between the sines of the<br>
latitude at the northern and southern edges of the grid box. For areal<br>
averaging without latitude weighting, use the amean function."<br>
<br>
The impact of using aave vs amean depends on the latitude range of your<br>
region.<br>
<br>
<br>
Second, in your fortran code, the denominator is too small when you<br>
divide mh(i) by the number of gridsquares. You have:<br>
mh(i)=mh(i)/((35-26)*(50-43))<br>
Try:<br>
mh(i)=mh(i)/((35-26+1)*(50-43+1))<br>
<br>
<br>
A third (possible) factor is that you have missing value(s) that would<br>
get excluded from the aave (or amean) calculation but are not excluded<br>
in the code. The impact from that would depend on the value you use for<br>
"missing".<br>
<br>
<br>
Diane<br>
<br>
<br>
sansaad wrote:<br>
> Hi everybody<br>
><br>
> I'd done some calculations using both GRADS and Fortran, and I realised
<br>
> that the spatial average using GRADS (aave) differs by a ratio of<br>
> approximately 0.787 from the spatial average using Fortran. By this I<br>
> mean that if I multiply the Fortran's values by 0.787, they ALWAYS match
<br>
> with the GRADS' values (with small errors).<br>
><br>
> Can anyone explain the reason for this "magic number" (0.787)?<br>
><br>
> A part of the program using GRADS and Fortran respectively are given<br>
> bellow.<br>
><br>
> I would appreciate any kind of commentaries.<br>
><br>
> Sandra Saad<br>
><br>
><br>
> ### Spatial Average using GRADS ########<br>
><br>
> set t 1 last<br>
> d aave(h,x=26,x=35,y=43,y=50)<br>
><br>
><br>
> ### Spatial Average using Fortran (90) ########<br>
><br>
> do i=1,it<br>
> do ny=43,50<br>
> do nx=26,35<br>
> mh(i)=mh(i)+h(i,nx,ny)<br>
> enddo<br>
> enddo<br>
> mh(i)=mh(i)/((35-26)*(50-43))<br>
> enddo<br>
><br>
> do i=1,it<br>
> write(3,*)i,mh(i)<br>
> enddo<br>
><br>
</blockquote>
</span>