
!--------------------------------------------------------------------------------
Real Function Area_Mean (X, ireg, it)   ! Tinh trung binh vung chi so X nao do
Integer :: it, ilon, ilat, ireg, icount
Real, Dimension(Nlon,Nlat,Ntime) :: X
Real :: tmp
tmp = 0; icount=0
Do ilon=1, Nlon
   Do ilat=1, Nlat
      if (INT(Reg(ilon,ilat))==ireg) then
         if (X(ilon,ilat,it)/=Miss) then
            tmp=tmp+X(ilon,ilat,it); icount=icount+1
         endif
      endif
   Enddo
Enddo
if (icount>0) tmp=tmp/real(icount); Area_Mean = tmp
End Function Area_Mean
!--------------------------------------------------------------------------------

