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 | |
---|
7 | MODULE module_ForDiagnosticsVars |
---|
8 | |
---|
9 | USE module_generic |
---|
10 | |
---|
11 | IMPLICIT NONE |
---|
12 | |
---|
13 | ! INTEGER, PARAMETER :: r_k = KIND(1.d0) |
---|
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 | REAL(r_k), PARAMETER :: zero=0.d0 |
---|
21 | REAL(r_k), PARAMETER :: one=1.d0 |
---|
22 | REAL(r_k), PARAMETER :: two=2.d0 |
---|
23 | |
---|
24 | CONTAINS |
---|
25 | |
---|
26 | !!!!!!! Variables |
---|
27 | ! var_cllmh: low, medium, high-cloud [0,1] |
---|
28 | ! var_clt: total cloudiness [0,1] |
---|
29 | |
---|
30 | !!!!!!! Calculations |
---|
31 | ! compute_clt: Computation of total cloudiness |
---|
32 | |
---|
33 | !!! |
---|
34 | ! Variables |
---|
35 | !!! |
---|
36 | |
---|
37 | FUNCTION var_cllmh(clfra, p, dz) |
---|
38 | ! Function to compute cllmh on a 1D column 1: low-cloud; 2: medium-cloud; 3: high-cloud [1] |
---|
39 | |
---|
40 | IMPLICIT NONE |
---|
41 | |
---|
42 | ! INTEGER, PARAMETER :: r_k = KIND(1.d0) |
---|
43 | INTEGER, INTENT(in) :: dz |
---|
44 | REAL(r_k), DIMENSION(dz), INTENT(in) :: clfra, p |
---|
45 | REAL(r_k), DIMENSION(3) :: var_cllmh |
---|
46 | |
---|
47 | ! Local |
---|
48 | INTEGER :: iz |
---|
49 | CHARACTER(LEN=50) :: fname |
---|
50 | REAL(r_k) :: zclearl, zcloudl, zclearm, zcloudm, & |
---|
51 | zclearh, zcloudh |
---|
52 | |
---|
53 | !!!!!!! Variables |
---|
54 | ! clfra: cloudfraction as 1D verical-column [1] |
---|
55 | ! p: pressure values of the column |
---|
56 | fname = 'var_cllmh' |
---|
57 | |
---|
58 | zclearl = one |
---|
59 | zcloudl = zero |
---|
60 | zclearm = one |
---|
61 | zcloudm = zero |
---|
62 | zclearh = one |
---|
63 | zcloudh = zero |
---|
64 | |
---|
65 | var_cllmh = one |
---|
66 | |
---|
67 | DO iz=1, dz |
---|
68 | IF (p(iz) < prmhc) THEN |
---|
69 | var_cllmh(3) = var_cllmh(3)*(one-MAX(clfra(iz),zcloudh))/(one-MIN(zcloudh,one-ZEPSEC)) |
---|
70 | zcloudh = clfra(iz) |
---|
71 | ELSE IF ( (p(iz) >= prmhc) .AND. (p(iz) < prmlc) ) THEN |
---|
72 | var_cllmh(2) = var_cllmh(2)*(one-MAX(clfra(iz),zcloudm))/(one-MIN(zcloudm,one-ZEPSEC)) |
---|
73 | zcloudm = clfra(iz) |
---|
74 | ELSE IF (p(iz) >= prmlc) THEN |
---|
75 | var_cllmh(1) = var_cllmh(1)*(one-MAX(clfra(iz),zcloudl))/(one-MIN(zcloudl,one-ZEPSEC)) |
---|
76 | zcloudl = clfra(iz) |
---|
77 | ELSE |
---|
78 | PRINT *,' ' // TRIM(fname) // ': This is weird, pressure:', p(iz), ' Pa fails out!!' |
---|
79 | PRINT *,' from high, low cloud pressures:', prmhc, ' ,', prmlc,' Pa at z-level:', iz |
---|
80 | PRINT *,' p_high > p:', prmhc,'> ',p(iz),' Pa' |
---|
81 | PRINT *,' p_low > p >= p_high:', prmlc,'> ',p(iz),' >=', prmhc,' Pa' |
---|
82 | PRINT *,' p_low >= p:', prmlc,'>= ',p(iz),' Pa' |
---|
83 | STOP |
---|
84 | END IF |
---|
85 | END DO |
---|
86 | |
---|
87 | var_cllmh = one - var_cllmh |
---|
88 | |
---|
89 | RETURN |
---|
90 | |
---|
91 | END FUNCTION var_cllmh |
---|
92 | |
---|
93 | REAL(r_k) FUNCTION var_clt(clfra, dz) |
---|
94 | ! Function to compute the total cloud following 'newmicro.F90' from LMDZ using 1D vertical |
---|
95 | ! column values |
---|
96 | |
---|
97 | IMPLICIT NONE |
---|
98 | |
---|
99 | ! INTEGER, PARAMETER :: r_k = KIND(1.d0) |
---|
100 | INTEGER, INTENT(in) :: dz |
---|
101 | REAL(r_k), DIMENSION(dz), INTENT(in) :: clfra |
---|
102 | ! Local |
---|
103 | INTEGER :: iz |
---|
104 | REAL(r_k) :: zclear, zcloud |
---|
105 | CHARACTER(LEN=50) :: fname |
---|
106 | !!!!!!! Variables |
---|
107 | ! cfra: 1-column cloud fraction values |
---|
108 | |
---|
109 | fname = 'var_clt' |
---|
110 | |
---|
111 | zclear = one |
---|
112 | zcloud = zero |
---|
113 | |
---|
114 | DO iz=1,dz |
---|
115 | zclear = zclear*(one-MAX(clfra(iz),zcloud))/(one-MIN(zcloud,1.-ZEPSEC)) |
---|
116 | var_clt = one - zclear |
---|
117 | zcloud = clfra(iz) |
---|
118 | END DO |
---|
119 | |
---|
120 | RETURN |
---|
121 | |
---|
122 | END FUNCTION var_clt |
---|
123 | |
---|
124 | END MODULE module_ForDiagnosticsVars |
---|