mean_nodata Function

private function mean_nodata(array, n1, n2, n3, nodata_num)

Arguments

Type IntentOptional Attributes Name
real :: array(n1,n2,n3)
integer :: n1
integer :: n2
integer :: n3
real :: nodata_num

Return Value real


Source Code

    function mean_nodata(array,n1,n2,n3,nodata_num)

        !use uEMEP_definitions
        implicit none
        real :: array(n1,n2,n3)
        real :: nodata_num
        integer :: n1,n2,n3
        real :: mean_nodata
        integer i,j,t
        real :: count=0
        real :: sum_array=0

        do t=1,n3
            do j=1,n2
                do i=1,n1
                    if (array(i,j,t).ne.nodata_num) then
                        sum_array=sum_array+array(i,j,t)
                        count=count+1.
                    endif
                enddo
            enddo
        enddo

        if (count.gt.0) then
            mean_nodata=sum_array/count
        else
            mean_nodata=0
        endif


    end function mean_nodata