c========================================================================= c c NAME: grid_moment_ch2 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 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 April 2002 c c============================================================================ subroutine grid_moment_ch2(nlon,nlat,sum,sumsq,count,iparm, . imn,isd,ict) implicit none include 'hirs_grid.inc' integer nlon,nlat,i,j,iparm integer*2 ict(nlon,nlat),imn(nlon,nlat) integer*2 isd(nlon,nlat),iscale integer count(nlon,nlat) real sum(nlon,nlat),sumsq(nlon,nlat),mn,sd,tmp1,tmp2 real offset_mn,sfactor_mn,offset_sd,sfactor_sd do j=1,nlat do i=1,nlon if(count(i,j) .gt. 0) then mn=sum(i,j)/count(i,j) tmp1=sumsq(i,j)/count(i,j) tmp2=(sum(i,j)/count(i,j))**2. if((tmp1 .ge. tmp2) .and. iparm .lt. 30) then sd=sqrt(tmp1-tmp2) else sd=0. endif else mn=imiss sd=imiss endif if(iparm .eq. 1) then offset_mn = 700. sfactor_mn = 10. offset_sd = 200. sfactor_sd = 100. elseif(iparm .eq. 2 .or. . iparm .ge. 4 .and. iparm .le. 20) then offset_mn = 100. sfactor_mn = 100. offset_sd = 0. sfactor_sd = 100. elseif(iparm .eq. 3) then offset_mn = 0. sfactor_mn = 100. offset_sd = 0. sfactor_sd = 100. else offset_mn = 0. sfactor_mn = 100. offset_sd = 0. sfactor_sd = 100. endif imn(i,j)=iscale(mn,offset_mn,sfactor_mn) isd(i,j)=iscale(sd,offset_sd,sfactor_sd) ict(i,j)=count(i,j) enddo enddo return end