mean_mask Function

public function mean_mask(array, mask, n1, n2, n3)

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: array(n1,n2,n3)
logical, intent(in) :: mask(n1,n2)
integer, intent(in) :: n1
integer, intent(in) :: n2
integer, intent(in) :: n3

Return Value real


Called by

proc~~mean_mask~~CalledByGraph proc~mean_mask mean_mask proc~uemep_combine_local_source uEMEP_combine_local_source proc~uemep_combine_local_source->proc~mean_mask proc~uemep_save_netcdf_control uEMEP_save_netcdf_control proc~uemep_save_netcdf_control->proc~mean_mask program~uemep uEMEP program~uemep->proc~uemep_combine_local_source program~uemep->proc~uemep_save_netcdf_control

Source Code

    function mean_mask(array,mask,n1,n2,n3)

        !use uEMEP_definitions
        implicit none
        real, intent (in) :: array(n1,n2,n3)
        logical, intent (in) :: mask(n1,n2)
        integer, intent (in) :: n1,n2,n3
        real :: mean_mask
        integer i,j,t
        real :: count=0
        real :: sum_array=0

        sum_array=0
        count=0

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

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


    end function mean_mask