
subroutine Mean1DimFast ( A, B, offset, offset2, ndims, linf, lsup, alen, blen)
	integer offset,offset2,ndims,linf,lsup,i,j,z,tmp,alen,blen,nas
	double precision A(0:alen-1),B(0:blen-1)

	tmp = offset * ndims

	do i=0,offset2-1
		do j=0,offset-1
			nas = 0
			do z=linf,lsup-1
				if(A(tmp*i+(offset*z)+j) .NE. A(tmp*i+(offset*z)+j)) then 
					A(tmp*i+(offset*z)+j) = 0
					nas = nas + 1
				end if
          		B((offset*i)+j) = B((offset*i)+j) + A((tmp*i)+(offset*z)+j)
          	end do
          	B((offset*i)+j) =  B((offset*i)+j) / (ndims-nas);
        end do
    end do

end subroutine Mean1DimFast