CTBTO FLEXPART WO4 (2015-10-15)
 All Classes Files Functions Variables
mean.f90
Go to the documentation of this file.
1 !**********************************************************************
2 ! Copyright 1998,1999,2000,2001,2002,2005,2007,2008,2009,2010 *
3 ! Andreas Stohl, Petra Seibert, A. Frank, Gerhard Wotawa, *
4 ! Caroline Forster, Sabine Eckhardt, John Burkhart, Harald Sodemann *
5 ! *
6 ! This file is part of FLEXPART. *
7 ! *
8 ! FLEXPART is free software: you can redistribute it and/or modify *
9 ! it under the terms of the GNU General Public License as published by*
10 ! the Free Software Foundation, either version 3 of the License, or *
11 ! (at your option) any later version. *
12 ! *
13 ! FLEXPART is distributed in the hope that it will be useful, *
14 ! but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 ! GNU General Public License for more details. *
17 ! *
18 ! You should have received a copy of the GNU General Public License *
19 ! along with FLEXPART. If not, see <http://www.gnu.org/licenses/>. *
20 !**********************************************************************
21 
22 subroutine mean(x,xm,xs,number)
23 
24  !*****************************************************************************
25  ! *
26  ! This subroutine calculates mean and standard deviation of a given element.*
27  ! *
28  ! AUTHOR: Andreas Stohl, 25 January 1994 *
29  ! *
30  !*****************************************************************************
31  ! *
32  ! Variables: *
33  ! x(number) field of input data *
34  ! xm mean *
35  ! xs standard deviation *
36  ! number number of elements of field x *
37  ! *
38  ! Constants: *
39  ! eps tiny number *
40  ! *
41  !*****************************************************************************
42 
43  implicit none
44 
45  integer :: number,i
46  real :: x(number),xm,xs,xl,xq,xaux
47  real,parameter :: eps=1.0e-30
48 
49  xl=0.
50  xq=0.
51  do i=1,number
52  xl=xl+x(i)
53  xq=xq+x(i)*x(i)
54  end do
55 
56  xm=xl/real(number)
57 
58  xaux=xq-xl*xl/real(number)
59 
60  if (xaux.lt.eps) then
61  xs=0.
62  else
63  xs=sqrt(xaux/real(number-1))
64  endif
65 
66 end subroutine mean
subroutine mean(x, xm, xs, number)
Definition: mean.f90:22