module moyenne
   implicit none
   private ! by default everything is private. Don't pollute name space!
   public :: mean  ! list of exported routines
   interface mean
      module procedure rmean
      module procedure r2dmean
      module procedure dmean
      module procedure d2dmean
      module procedure cmean
      module procedure c2dmean
      module procedure zmean
      module procedure z2dmean
   end interface
 contains
      function rmean(a) result(value)
         real a(:),value
         value=sum(a)/size(a)
      end function
      function r2dmean(a) result(value)
         real a(:,:),value
         value=sum(a)/size(a)
      end function
      function dmean(a) result(value)
        real(kind(0d0)) a(:), value
        value=sum(a)/size(a)
      end function
      function d2dmean(a) result(value)
        real(kind(0d0)) a(:,:), value
        value=sum(a)/size(a)
      end function
      function cmean(a) result(value)
        complex a(:), value
        value=sum(a)/size(a)
      end function
      function c2dmean(a) result(value)
        complex a(:,:), value
        value=sum(a)/size(a)
      end function
      function zmean(a) result(value)
        complex(kind(0d0)) a(:), value
        value=sum(a)/size(a)
      end function
      function z2dmean(a) result(value)
        complex(kind(0d0)) a(:,:), value
        value=sum(a)/size(a)
      end function
end module moyenne

module standard_dev
   implicit none
   private 
   public :: stdev
   interface stdev
      module procedure rdev
      module procedure r2ddev
      module procedure r3ddev
      module procedure ddev
      module procedure d2ddev
   end interface
 contains
	real function rdev(a)
	 real am,a(:)
	 am=sum(a)/size(a)
	 rdev=sqrt(sum((a-am)**2)/size(a))
	end function
	real function r2ddev(a)
	 real am,a(:,:)
	 am=sum(a)/size(a)
	 r2ddev=sqrt(sum((a-am)**2)/size(a))
	end function
	real function r3ddev(a)
	 real am,a(:,:,:)
	 am=sum(a)/size(a)
	 r3ddev=sqrt(sum((a-am)**2)/size(a))
	end function
	real(kind(0d0)) function ddev(a)
	 real(kind(0d0)) am,a(:)
	 am=sum(a)/size(a)
	 ddev=sqrt(sum((a-am)**2)/size(a))
	end function
	real(kind(0d0)) function d2ddev(a)
	 real(kind(0d0)) am,a(:,:)
	 am=sum(a)/size(a)
	 d2ddev=sqrt(sum((a-am)**2)/size(a))
	end function
end module standard_dev

	module statistics

	use moyenne
	use standard_dev

	end module statistics
