c========================================================================= c c NAME: grid_moment_cm c c PURPOSE: Computes mean and standard deviation from summed arrays. c c INPUTS: name data type dimension description c --------------------------------------------------------- c nlon integer scalar number of longitude points c nlat integer scalar number of latitude points c nparm integer scalar number of parameters c sum real 3D summed value at given gridpoint c sumsq real 3D sum**2 value at given gridpoint.(float) c count real 3D total number of points.(Int*4) c c OUTPUTS: c imn integer*2 3D mean value c isd integer*2 3D standard deviation c ict integer*2 3D total number of points c c 3D = nlon x nlat x nparm c c EXTERNALS: c hirs_grid.inc c iscale.f c c AUTHOR: c Darren Jackson CIRES/ETL June 2002 c c============================================================================ subroutine grid_moment_cm(nlon,nlat,nparm,sum,sumsq,count, . imn,isd,ict) implicit none include 'hirs_grid.inc' integer nlon,nlat,nparm,i,j,k integer*2 ict(nlon,nlat,nparm),imn(nlon,nlat,nparm) integer*2 isd(nlon,nlat,nparm),iscale integer count(nlon,nlat,nparm) real sum(nlon,nlat,nparm),sumsq(nlon,nlat,nparm),mn,sd,tmp1,tmp2 real offset_mn,sfactor_mn,offset_sd,sfactor_sd do k=1,nparm do j=1,nlat do i=1,nlon if(count(i,j,k) .gt. 0) then mn=sum(i,j,k)/count(i,j,k) tmp1=sumsq(i,j,k)/count(i,j,k) tmp2=(sum(i,j,k)/count(i,j,k))**2. if(tmp1 .ge. tmp2) then sd=sqrt(tmp1-tmp2) else sd=0. endif else mn=imiss sd=imiss endif offset_mn = 100. sfactor_mn = 100. offset_sd = 0. sfactor_sd = 100. imn(i,j,k)=iscale(mn,offset_mn,sfactor_mn) isd(i,j,k)=iscale(sd,offset_sd,sfactor_sd) ict(i,j,k)=count(i,j,k) enddo enddo enddo return end