source: lmdz_wrf/trunk/tools/module_ForDiagnosticsVars.f90 @ 1664

Last change on this file since 1664 was 1608, checked in by lfita, 7 years ago

Adding new Fortran capabilities after Rominas' DistriCorrection?

File size: 3.4 KB
Line 
1!! Fortran version of different diagnostics
2! L. Fita. LMD May 2016
3! gfortran module_generic.o -c module_ForDiagnostics.F90
4!
5! f2py -m module_ForDiagnostics --f90exec=/usr/bin/gfortran-4.7 -c module_generic.F90 module_ForDiagnostics.F90
6
7MODULE module_ForDiagnosticsVars
8
9  USE module_definitions
10  USE module_generic
11
12  IMPLICIT NONE
13
14  REAL(r_k), PARAMETER                                   :: ZEPSEC=1.0D-12
15! Low limit pressure for medium clouds [Pa]
16  REAL(r_k), PARAMETER                                   :: prmhc = 44000.d0
17! Low limit pressure for High clouds [Pa]
18  REAL(r_k), PARAMETER                                   :: prmlc = 68000.d0
19
20  CONTAINS
21
22!!!!!!! Variables
23! var_cllmh: low, medium, high-cloud [0,1]
24! var_clt: total cloudiness [0,1]
25
26!!!!!!! Calculations
27! compute_clt: Computation of total cloudiness
28
29!!!
30! Variables
31!!!
32
33  FUNCTION var_cllmh(clfra, p, dz)
34! Function to compute cllmh on a 1D column 1: low-cloud; 2: medium-cloud; 3: high-cloud [1]
35
36    IMPLICIT NONE
37
38    INTEGER, INTENT(in)                                  :: dz
39    REAL(r_k), DIMENSION(dz), INTENT(in)                 :: clfra, p
40    REAL(r_k), DIMENSION(3)                              :: var_cllmh
41
42! Local
43    INTEGER                                              :: iz
44    REAL(r_k)                                            :: zclearl, zcloudl, zclearm, zcloudm,       &
45      zclearh, zcloudh
46
47!!!!!!! Variables
48! clfra: cloudfraction as 1D verical-column [1]
49! p: pressure values of the column
50    fname = 'var_cllmh'
51
52    zclearl = oneRK
53    zcloudl = zeroRK
54    zclearm = oneRK
55    zcloudm = zeroRK
56    zclearh = oneRK
57    zcloudh = zeroRK
58
59    var_cllmh = oneRK
60
61    DO iz=1, dz
62      IF (p(iz) < prmhc) THEN
63        var_cllmh(3) = var_cllmh(3)*(oneRK-MAX(clfra(iz),zcloudh))/(oneRK-MIN(zcloudh,oneRK-ZEPSEC))
64        zcloudh = clfra(iz)
65      ELSE IF ( (p(iz) >= prmhc) .AND. (p(iz) < prmlc) ) THEN
66        var_cllmh(2) = var_cllmh(2)*(oneRK-MAX(clfra(iz),zcloudm))/(oneRK-MIN(zcloudm,oneRK-ZEPSEC))
67        zcloudm = clfra(iz)
68      ELSE IF (p(iz) >= prmlc) THEN
69        var_cllmh(1) = var_cllmh(1)*(oneRK-MAX(clfra(iz),zcloudl))/(oneRK-MIN(zcloudl,oneRK-ZEPSEC))
70        zcloudl = clfra(iz)
71      ELSE
72        PRINT *,'  ' // TRIM(fname) // ': This is weird, pressure:', p(iz), ' Pa fails out!!'
73        PRINT *,'    from high, low cloud pressures:', prmhc, ' ,', prmlc,' Pa at z-level:', iz
74        PRINT *,'    p_high > p:', prmhc,'> ',p(iz),' Pa'
75        PRINT *,'    p_low > p >= p_high:', prmlc,'> ',p(iz),' >=', prmhc,' Pa'
76        PRINT *,'    p_low >= p:', prmlc,'>= ',p(iz),' Pa'
77        STOP
78      END IF
79    END DO
80
81    var_cllmh = oneRK - var_cllmh
82
83    RETURN
84
85  END FUNCTION var_cllmh
86
87  REAL(r_k) FUNCTION var_clt(clfra, dz)
88! Function to compute the total cloud following 'newmicro.F90' from LMDZ using 1D vertical
89!   column values
90
91    IMPLICIT NONE
92
93    INTEGER, INTENT(in)                                  :: dz
94    REAL(r_k), DIMENSION(dz), INTENT(in)                 :: clfra
95! Local
96    INTEGER                                              :: iz
97    REAL(r_k)                                            :: zclear, zcloud
98
99!!!!!!! Variables
100! cfra: 1-column cloud fraction values
101
102    fname = 'var_clt'
103
104    zclear = oneRK
105    zcloud = zeroRK
106
107    DO iz=1,dz
108      zclear = zclear*(oneRK-MAX(clfra(iz),zcloud))/(oneRK-MIN(zcloud,1.-ZEPSEC))
109      var_clt = oneRK - zclear
110      zcloud = clfra(iz)
111    END DO
112
113    RETURN
114
115  END FUNCTION var_clt
116
117END MODULE module_ForDiagnosticsVars
Note: See TracBrowser for help on using the repository browser.