source: LMDZ6/branches/Amaury_dev/libf/phylmd/cv3_inicp.F90 @ 5225

Last change on this file since 5225 was 5158, checked in by abarral, 3 months ago

Add missing klon on strataer_emiss_mod.F90
Correct various missing explicit declarations
Replace tabs by spaces (tabs are not part of the fortran charset)
Continue cleaning modules
Removed unused arguments and variables

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1SUBROUTINE cv3_inicp()
2
3  ! **************************************************************
4  ! *
5  ! CV3_INIP Lecture des choix de lois de probabilité de mélange*
6  ! et calcul de leurs coefficients normalisés.        *
7  ! *
8  ! written by   : Jean-Yves Grandpeix, 06/06/2006, 19.39.27    *
9  ! modified by :                                               *
10  ! **************************************************************
11  USE lmdz_abort_physic, ONLY: abort_physic
12  USE lmdz_yomcst2
13
14  IMPLICIT NONE
15
16  INTEGER iflag_clos
17  CHARACTER (LEN = 20) :: modname = 'cv3_inicp'
18  CHARACTER (LEN = 80) :: abort_message
19
20  ! --   Mixing probability distribution functions
21
22  REAL qcoef1, qcoef2, qff, qfff, qmix, rmix, qmix1, rmix1, qmix2, rmix2, f
23  REAL :: sumcoef, sigma, aire, pdf, mu, df, ff
24
25  qcoef1(f) = tanh(f / gammas)
26  qcoef2(f) = (tanh(f / gammas) + gammas * log(cosh((1. - f) / gammas) / cosh(f / gammas)))
27  qff(f) = max(min(f, 1.), 0.)
28  qfff(f) = min(qff(f), scut)
29  qmix1(f) = (tanh((qff(f) - fmax) / gammas) + qcoef1max) / qcoef2max
30  rmix1(f) = (gammas * log(cosh((qff(f) - fmax) / gammas)) + qff(f) * qcoef1max) / &
31          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
37  ! cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
38
39
40  ! ===========================================================================
41  ! READ IN PARAMETERS FOR THE MIXING DISTRIBUTION
42  ! AND PASS THESE THROUGH A COMMON BLOCK TO SUBROUTINE CONVECT etc.
43  ! (Written by V.T.J. Phillips, 20-30/Jan/99)
44  ! ===========================================================================
45
46  ! line 1:  a flag (0 or 1) to decide whether P(F) = 1 or the general P(F)
47  ! is to be
48  ! used, followed by SCUT, which is the cut-off value of F in CONVECT
49  ! line 2:  blank
50  ! line 3:  the coefficients for the linear combination of P(F)s to
51  ! make the general P(F)
52  ! line 4:  blank
53  ! line 5:  gammas, Fmax for the cosh^2 component of P(F)
54  ! line 6:  blank
55  ! line 7:  alphas for the 1st irrational P(F)
56  ! line 8:  blank
57  ! line 9:  betas  for the 2nd irrational P(F)
58
59
60  ! open(57,file='parameter_mix.data')
61
62  ! read(57,*) iflag_clos
63  ! read(57,*) iflag_mix, scut
64  ! read(57,*)
65  ! IF(iflag_mix .gt. 0) THEN
66  ! read(57,*) qqa1, qqa2
67  ! read(57,*)
68  ! read(57,*) gammas, Fmax
69  ! read(57,*)
70  ! read(57,*) alphas
71  ! END IF
72  ! close(57)
73
74  IF (iflag_mix>0) THEN
75
76    ! --      Normalize Pdf weights
77
78    sumcoef = qqa1 + qqa2
79    qqa1 = qqa1 / sumcoef
80    qqa2 = qqa2 / sumcoef
81
82    qcoef1max = qcoef1(fmax)
83    qcoef2max = qcoef2(fmax)
84
85    sigma = 0.
86    aire = 0.0
87    pdf = 0.0
88    mu = 0.0
89    df = 0.0001
90
91    ! do ff = 0.0 + df, 1.0 - 2.*df, df
92    ff = df
93    DO WHILE (ff<=1.0 - 2. * df)
94      pdf = (qmix(ff + df) - qmix(ff)) * (1. - ff) / df
95      aire = aire + (qmix(ff + df) - qmix(ff)) * (1. - ff)
96      mu = mu + pdf * ff * df
97      ! c              WRITE(*,*) pdf,  Qmix(ff), aire, ff
98      ff = ff + df
99    END DO
100
101    ! do ff=0.0+df,1.0 - 2.*df,df
102    ff = df
103    DO WHILE (ff<=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    END DO
108    sigma = sqrt(sigma)
109
110    IF (abs(aire - 1.0)>0.02) THEN
111      PRINT *, 'WARNING:: AREA OF MIXING PDF IS::', aire
112      abort_message = ''
113      CALL abort_physic(modname, abort_message, 1)
114    ELSE
115      PRINT *, 'Area, mean & std deviation are ::', aire, mu, sigma
116    END IF
117  END IF !  (iflag_mix .gt. 0)
118
119END SUBROUTINE cv3_inicp
Note: See TracBrowser for help on using the repository browser.