NADCON5-ng  0.0.2
NADCON5 Next Generation Documentation
gridstats.f
Go to the documentation of this file.
1 c> \ingroup core
2 c> \if MANPAGE
3 c> \page gridstats
4 c> \endif
5 c>
6 c> Subroutine to print grid statistics to stdout
7 c>
8 c> \param[in] fname name of grid stat file
9 c> \param[out] ave average
10 c> \param[out] std standard deviatio
11 c> \param[out] median
12 c>
13  subroutine gridstats(fname,ave,std,med)
14  implicit real*8(a-h,o-z)
15  parameter(nmax = 1561*3541)
16  real*8 med
17  real*4 data(5000),s1,select2,arr(nmax)
18  integer*4 nla,nlo,ikind
19  character*200 fname
20  open(11,file=fname,status='old',form='unformatted')
21 
22  ave = 0.d0
23  rms = 0.d0
24 
25  read(11)glamn,glomn,dla,dlo,nla,nlo,ikind
26  if(ikind.eq.0)stop 20304
27 
28  ikt = 0
29  do 1 i=1,nla
30  if(ikind.eq.1)read(11)(data(j),j=1,nlo)
31  do 3 j=1,nlo
32  ikt = ikt + 1
33  arr(ikt) = data(j)
34  3 continue
35  do 2 j=1,nlo
36  ave = ave + dble(data(j))
37  rms = rms + dble(data(j))**2
38  2 continue
39  1 continue
40  fact = dble(nla*nlo) / dble(nla*nlo - 1)
41 
42  ave = ave / dble(nla*nlo)
43  rms = sqrt(rms / dble(nla*nlo))
44  std = dsqrt(fact*(rms**2 - ave**2))
45 
46  npts = ikt
47  nmed = 1+ ikt/2
48 
49  write(6,*) ' IN gridstats, npts = ',npts
50  write(6,*) ' IN gridstats, nmed = ',nmed
51 
52 c nmed = ikt/3
53  s1 = select2(nmed,npts,arr,nmax)
54 
55  write(6,*) ' IN gridstats, s1 = ',s1
56  med = s1
57  write(6,*) ' IN gridstats, med = ',med
58 
59  write(6,100)trim(fname),ave,std,med
60  100 format('gridstats for ',a,' = ',3f20.10)
61 
62  close(11)
63 
64  return
65  end
subroutine gridstats(fname, ave, std, med)
Subroutine to print grid statistics to stdout.
Definition: gridstats.f:14