My Project
 All Classes Files Functions Variables Macros
cv3_inip.F
Go to the documentation of this file.
1  SUBROUTINE cv3_inip()
2 ***************************************************************
3 * *
4 * cv3_inip lecture des choix de lois de probabilité de mélange*
5 * et calcul de leurs coefficients normalisés. *
6 * *
7 * written by : jean-yves grandpeix, 06/06/2006, 19.39.27 *
8 * modified by : *
9 ***************************************************************
10 *
11 #include "YOMCST2.h"
12 c
13 c INTEGER iflag_mix
14  include 'iniprint.h'
15 
16  CHARACTER (LEN=20) :: modname='cv3_inip'
17  CHARACTER (LEN=80) :: abort_message
18 
19 c
20 c -- mixing probability distribution functions
21 c
22  real qcoef1,qcoef2,qff,qfff,qmix,rmix,qmix1,rmix1,qmix2,rmix2,f
23  qcoef1(f) = tanh(f/gammas)
24  qcoef2(f) = ( tanh(f/gammas) + gammas *
25  $ log(cosh((1.- f)/gammas)/cosh(f/gammas)))
26  qff(f) = max(min(f,1.),0.)
27  qfff(f) = min(qff(f),scut)
28  qmix1(f) = ( tanh((qff(f) - fmax)/gammas)+qcoef1max )/
29  $ qcoef2max
30  rmix1(f) = ( gammas*log(cosh((qff(f)-fmax)/gammas))
31  1 +qff(f)*qcoef1max ) / qcoef2max
32  qmix2(f) = -log(1.-qfff(f))/scut
33  rmix2(f) = (qfff(f)+(1.-qff(f))*log(1.-qfff(f)))/scut
34  qmix(f) = qqa1*qmix1(f) + qqa2*qmix2(f)
35  rmix(f) = qqa1*rmix1(f) + qqa2*rmix2(f)
36 c
37 ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
38 c
39 c
40 c===========================================================================
41 c READ in parameters for the mixing distribution
42 c and pass these through a COMMON block to SUBROUTINE convect etc.
43 c(written by v.t.j. phillips, 20-30/jan/99)
44 c===========================================================================
45 c
46 c line 1: a flag(0 or 1) to decide whether p(f) = 1 or the general p(f) is to be
47 c used, followed by scut, which is the cut-off value of f in convect
48 c line 2: blank
49 c line 3: the coefficients for the linear combination of p(f)s to
50 c make the general p(f)
51 c line 4: blank
52 c line 5: gammas, fmax for the cosh^2 component of p(f)
53 c line 6: blank
54 c line 7: alphas for the 1st irrational p(f)
55 c line 8: blank
56 c line 9: betas for the 2nd irrational p(f)
57 c
58 
59 cc$$$ open(57,file='parameter_mix.data')
60 cc$$$
61 cc$$$ read(57,*) iflag_mix, scut
62 cc$$$ read(57,*)
63 cc$$$ if(iflag_mix .gt. 0) then
64 cc$$$ read(57,*) qqa1, qqa2
65 cc$$$ read(57,*)
66 cc$$$ read(57,*) gammas, fmax
67 cc$$$ read(57,*)
68 cc$$$ read(57,*) alphas
69 cc$$$ endif
70 cc$$$ close(57)
71 
72 c
73  if(iflag_mix .gt. 0) then
74 c
75 c-- normalize pdf weights
76 c
77  sumcoef=qqa1+qqa2
78  qqa1=qqa1/sumcoef
79  qqa2=qqa2/sumcoef
80 c
81  qcoef1max = qcoef1(fmax)
82  qcoef2max = qcoef2(fmax)
83 c
84  sigma = 0.
85  aire=0.0
86  pdf=0.0
87  mu=0.0
88  df = 0.0001
89 c
90 c do ff = 0.0 + df, 1.0 - 2.*df, df
91  ff=df
92  dowhile( ff .le. 1.0 - 2.*df )
93  pdf = (qmix(ff+df) - qmix(ff)) * (1.-ff) / df
94  aire=aire+(qmix(ff+df) - qmix(ff)) * (1.-ff)
95  mu = mu + pdf * ff * df
96  IF(prt_level>9)WRITE(lunout,*) &
97  & pdf, qmix(ff), aire, ff
98  ff=ff+df
99  enddo
100 c
101 c do ff=0.0+df,1.0 - 2.*df,df
102  ff=df
103  dowhile( ff .le. 1.0 - 2.*df )
104  pdf = (qmix(ff+df)- qmix(ff)) * (1.-ff) / df
105  sigma = sigma+pdf*(ff - mu)*(ff - mu)*df
106  ff=ff+df
107  enddo
108  sigma = sqrt(sigma)
109 c
110  if (abs(aire-1.0) .gt. 0.02) then
111  write(lunout,*)'WARNING:: AREA OF MIXING PDF IS::', aire
112  abort_message = ''
113  CALL abort_gcm(modname,abort_message,1)
114  else
115  print *,'Area, mean & std deviation are ::', aire,mu,sigma
116  endif
117  endif ! (iflag_mix .gt. 0)
118 
119  RETURN
120  END