
**********************************************************************

	subroutine AVERAGE(n,rMiss,rData,rAve)

	real rData(1:n)

	rCount=0
	rSum = 0.0
	
	do i=1,n
	  if (rData(i).ne.rMiss) then
	    rCount=rCount+1.
	    rSum = rSum+rData(i)
	  endif
	enddo

	if (rCount.gt.0.) then
	  rAve=(rSum/rCount)
	else
	  rAve=rMiss
	endif

	return
	end

******************************************************************
	



	  
