Changeset 772 in lmdz_wrf for trunk/tools/module_ForDiagnostics.F90
- Timestamp:
- May 24, 2016, 11:05:01 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/module_ForDiagnostics.F90
r770 r772 1 1 !! Fortran version of different diagnostics 2 2 ! L. Fita. LMD May 2016 3 ! gfortran module_generic.o -c module_ForDiagnostics.F90 3 ! gfortran module_generic.o module_ForDiagnosticsVars.o -c module_ForDiagnostics.F90 4 ! 5 ! f2py -m module_ForDiagnostics --f90exec=/usr/bin/gfortran-4.7 -c module_generic.F90 module_ForDiagnosticsVars.F90 module_ForDiagnostics.F90 6 4 7 MODULE module_ForDiagnostics 5 8 6 9 USE module_generic 7 8 IMPLICIT NONE 9 10 INTEGER, PARAMETER :: r_k = KIND(1.d0) 11 REAL(r_k), PARAMETER :: ZEPSEC=1.0D-12 12 ! Low limit pressure for medium clouds [Pa] 13 REAL(r_k), PARAMETER :: prmhc = 44000.d0 14 ! Low limit pressure for High clouds [Pa] 15 REAL(r_k), PARAMETER :: prmlc = 68000.d0 16 17 REAL(r_k), PARAMETER :: zero=0.d0 18 REAL(r_k), PARAMETER :: one=1.d0 19 REAL(r_k), PARAMETER :: two=2.d0 10 USE module_ForDiagnosticsVars 20 11 21 12 CONTAINS 22 13 23 !!!!!!! Variables24 ! var_clt: total cloudiness [1,0]25 26 27 14 !!!!!!! Calculations 15 ! compute_cllmh4D3: Computation of low, medium and high cloudiness from a 4D CLDFRA and pressure being 3rd dimension the z-dim 16 ! compute_cllmh3D3: Computation of low, medium and high cloudiness from a 3D CLDFRA and pressure being 3rd dimension the z-dim 17 ! compute_cllmh: Computation of low, medium and high cloudiness 18 ! compute_clt4D3: Computation of total cloudiness from a 4D CLDFRA being 3rd dimension the z-dim 19 ! compute_clt3D3: Computation of total cloudiness from a 3D CLDFRA being 3rd dimension the z-dim 28 20 ! compute_clt: Computation of total cloudiness 29 30 !!!31 ! Variables32 !!!33 34 35 REAL(r_k), FUNCTION var_cllmh(clfra, p, dz):36 ! Function to compute cllmh on a 1D column37 38 IMPLICIT NONE39 40 INTEGER, INTENT(in) :: dz41 REAL(r_k), DIMENSION(dz), INTENT(in) :: clfra, p42 43 ! Local44 INTEGER :: iz45 CHARACTER(LEN=50) :: fname46 REAL(r_k) :: zclearl, zcloudl, zclearm, zcloudm, &47 zclearh, zcloudh48 49 !!!!!!! Variables50 ! clfra: cloudfraction as 1D verical-column [1]51 ! p: pressure values of the column52 fname = 'var_cllmh'53 54 zclearl = one55 zcloudl = zero56 zclearm = one57 zcloudm = zero58 zclearh = one59 zcloudh = zero60 61 DO iz=1, dz62 IF (p(iz) < prmhc) THEN63 cllmh(2) = cllmh(2)*(one-MAX(clfra(iz), zcloudh))/(one-MIN(zcloudh,one-ZEPSEC))64 zcloudh = clfra(iz)65 ELSE IF ( (p(iz) >= prmhc).AND.(p(iz) < prmlc)) ) THEN66 cllmh[1] = cllmh[1]*(1.-np.max([cfra[iz], zcloudm]))/(1.- \67 np.min([zcloudm,1.-ZEPSEC]))68 zcloudm = cfra[iz]69 elif p[iz] >= prmlc:70 cllmh[0] = cllmh[0]*(1.-np.max([cfra[iz], zcloudl]))/(1.- \71 np.min([zcloudl,1.-ZEPSEC]))72 zcloudl = cfra[iz]73 74 cllmh = 1.- cllmh75 76 RETURN77 78 END FUNCTION var_clmh79 80 REAL(r_k) FUNCTION var_clt(clfra, dz)81 ! Function to compute the total cloud fraction following 'newmicro.F90' from LMDZ using 1D vertical82 ! column values83 84 IMPLICIT NONE85 86 REAL(r_k), DIMENSION(dz), INTENT(in) :: clfra87 INTEGER, INTENT(in) :: dz88 ! Local89 INTEGER :: iz90 REAL(r_k) :: zclear, zcloud91 CHARACTER(LEN=50) :: fname92 !!!!!!! Variables93 ! cfra: 1-column cloud fraction values94 95 fname = 'var_clt'96 97 zclear = one98 zcloud = zero99 100 DO iz=1,dz101 zclear = zclear*(one-MAX(clfra(iz),zcloud))/(one-MIN(zcloud,1.-ZEPSEC))102 var_clt = one - zclear103 zcloud = clfra(iz)104 END DO105 106 RETURN107 108 END FUNCTION var_clt109 21 110 22 !!! … … 112 24 !!! 113 25 114 SUBROUTINE compute_clt(cldfra1D, cldfra2D, cldfra3D, cldfra4D, Ndim, d1, d2, d3, d4, zdim, clt1D, & 115 clt2D1, clt2D2, clt3D1, clt3D2, clt3D3, clt4D1, clt4D2, clt4D3, clt4D4) 116 ! Subroutine to compute the total cloud fraction following 'newmicro.F90' from LMDZ 117 118 IMPLICIT NONE 119 26 SUBROUTINE compute_cllmh4D2(cldfra4D, pres4D, cllmh4D2, d1, d2, d3, d4) 27 ! Subroutine to compute the low, medium and high cloudiness following 'newmicro.F90' from LMDZ from a 4D CLDFRA and pressure 28 ! where zdim is the 2nd dimension (thus, cldfra4D(d1,d2,d3,d4) --> cllmh(3,d1,d3,d4) 1: low, 2: medium, 3: high 29 ! It should be properly done via an 'INTERFACE', but... 30 31 IMPLICIT NONE 32 33 INTEGER, PARAMETER :: r_k = KIND(1.d0) 34 REAL(r_k), DIMENSION(d1,d2,d3,d4), INTENT(in) :: cldfra4D, pres4D 35 INTEGER, INTENT(in) :: d1, d2, d3, d4 36 REAL(r_k), DIMENSION(3,d1,d3,d4), INTENT(out) :: cllmh4D2 37 38 ! Local 39 INTEGER :: i,j,k, zdim, Ndim 40 CHARACTER(LEN=50) :: fname 41 42 !!!!!!! Variables 43 ! cldfra4D: 4D cloud fraction values [1] 44 ! pres4D: 4D pressure values [Pa] 45 ! Ndim: number of dimensions of the input data 46 ! d[1-4]: dimensions of 'cldfra4D' 47 ! zdim: number of the vertical-dimension within the matrix 48 ! cltlmh4D2: low, medium, high cloudiness for the 4D cldfra and d2 being 'zdim' 49 50 fname = 'compute_cllmh4D2' 51 zdim = 2 52 Ndim = 4 53 54 DO i=1, d1 55 DO j=1, d3 56 DO k=1, d4 57 cllmh4D2(:,i,j,k) = var_cllmh(cldfra4D(i,:,j,k), pres4D(i,:,j,k), d2) 58 END DO 59 END DO 60 END DO 61 62 RETURN 63 64 END SUBROUTINE compute_cllmh4D2 65 66 SUBROUTINE compute_cllmh3D1(cldfra3D, pres3D, cllmh3D1, d1, d2, d3) 67 ! Subroutine to compute the low, medium and high cloudiness following 'newmicro.F90' from LMDZ from a 3D CLDFRA and pressure 68 ! where zdim is the 1st dimension (thus, cldfra3D(d1,d2,d3) --> cllmh(3,d2,d3) 1: low, 2: medium, 3: high 69 ! It should be properly done via an 'INTERFACE', but... 70 71 IMPLICIT NONE 72 73 INTEGER, PARAMETER :: r_k = KIND(1.d0) 74 REAL(r_k), DIMENSION(d1,d2,d3), INTENT(in) :: cldfra3D, pres3D 75 INTEGER, INTENT(in) :: d1, d2, d3 76 REAL(r_k), DIMENSION(3,d2,d3), INTENT(out) :: cllmh3D1 77 78 ! Local 79 INTEGER :: i,j,k, zdim, Ndim 80 CHARACTER(LEN=50) :: fname 81 82 !!!!!!! Variables 83 ! cldfra3D: 3D cloud fraction values [1] 84 ! pres3D: 3D pressure values [Pa] 85 ! Ndim: number of dimensions of the input data 86 ! d[1-3]: dimensions of 'cldfra3D' 87 ! zdim: number of the vertical-dimension within the matrix 88 ! cltlmh3D1: low, medium, high cloudiness for the 3D cldfra and d1 being 'zdim' 89 90 fname = 'compute_cllmh3D1' 91 zdim = 1 92 Ndim = 3 93 94 DO i=1, d1 95 DO j=1, d2 96 cllmh3D1(:,i,j) = var_cllmh(cldfra3D(:,i,j), pres3D(:,i,j), d1) 97 END DO 98 END DO 99 100 RETURN 101 102 END SUBROUTINE compute_cllmh3D1 103 104 SUBROUTINE compute_cllmh(cldfra1D, cldfra2D, cldfra3D, cldfra4D, pres1D, pres2D, pres3D, pres4D, & 105 Ndim, zdim, cllmh1D, cllmh2D1, cllmh2D2, cllmh3D1, cllmh3D2, cllmh3D3, cllmh4D1, cllmh4D2, & 106 cllmh4D3, cllmh4D4, d1, d2, d3, d4) 107 ! Subroutine to compute the low, medium and high cloudiness following 'newmicro.F90' from LMDZ 108 109 IMPLICIT NONE 110 111 INTEGER, PARAMETER :: r_k = KIND(1.d0) 112 REAL(r_k), DIMENSION(d1), OPTIONAL, INTENT(in) :: cldfra1D, pres1D 113 REAL(r_k), DIMENSION(d1,d2), OPTIONAL, INTENT(in) :: cldfra2D, pres2D 114 REAL(r_k), DIMENSION(d1,d2,d3), OPTIONAL, INTENT(in) :: cldfra3D, pres3D 115 REAL(r_k), DIMENSION(d1,d2,d3,d4), OPTIONAL, & 116 INTENT(in) :: cldfra4D, pres4D 117 INTEGER, INTENT(in) :: Ndim, d1, d2, d3, d4, zdim 118 REAL(r_k), DIMENSION(3), OPTIONAL, INTENT(out) :: cllmh1D 119 REAL(r_k), DIMENSION(d1,3), OPTIONAL, INTENT(out) :: cllmh2D1 120 REAL(r_k), DIMENSION(d2,3), OPTIONAL, INTENT(out) :: cllmh2D2 121 REAL(r_k), DIMENSION(d2,d3,3), OPTIONAL, INTENT(out) :: cllmh3D1 122 REAL(r_k), DIMENSION(d1,d3,3), OPTIONAL, INTENT(out) :: cllmh3D2 123 REAL(r_k), DIMENSION(d1,d2,3), OPTIONAL, INTENT(out) :: cllmh3D3 124 REAL(r_k), DIMENSION(d2,d3,d4,3), OPTIONAL, & 125 INTENT(out) :: cllmh4D1 126 REAL(r_k), DIMENSION(d1,d3,d4,3), OPTIONAL, & 127 INTENT(out) :: cllmh4D2 128 REAL(r_k), DIMENSION(d1,d2,d4,3), OPTIONAL, & 129 INTENT(out) :: cllmh4D3 130 REAL(r_k), DIMENSION(d1,d2,d3,3), OPTIONAL, & 131 INTENT(out) :: cllmh4D4 132 133 ! Local 134 INTEGER :: i,j,k 135 CHARACTER(LEN=50) :: fname 136 137 !!!!!!! Variables 138 ! cldfra[1-4]D: cloud fraction values [1] 139 ! pres[1-4]D: pressure values [Pa] 140 ! Ndim: number of dimensions of the input data 141 ! d[1-4]: dimensions of 'cldfra' 142 ! zdim: number of the vertical-dimension within the matrix 143 ! cllmh1D: low, medium and high cloudiness for the 1D cldfra 144 ! cllmh2D1: low, medium and high cloudiness for the 2D cldfra and d1 being 'zdim' 145 ! cllmh2D2: low, medium and high cloudiness for the 2D cldfra and d2 being 'zdim' 146 ! cllmh3D1: low, medium and high cloudiness for the 3D cldfra and d1 being 'zdim' 147 ! cllmh3D2: low, medium and high cloudiness for the 3D cldfra and d2 being 'zdim' 148 ! cllmh3D3: low, medium and high cloudiness for the 3D cldfra and d3 being 'zdim' 149 ! cllmh4D1: low, medium and high cloudiness for the 4D cldfra and d1 being 'zdim' 150 ! cllmh4D2: low, medium and high cloudiness for the 4D cldfra and d2 being 'zdim' 151 ! cllmh4D3: low, medium and high cloudiness for the 4D cldfra and d3 being 'zdim' 152 ! cllmh4D4: low, medium and high cloudiness for the 4D cldfra and d4 being 'zdim' 153 154 fname = 'compute_cllmh' 155 156 SELECT CASE (Ndim) 157 CASE (1) 158 cllmh1D = var_cllmh(cldfra1D, pres1D, d1) 159 CASE (2) 160 IF (zdim == 1) THEN 161 DO i=1, d2 162 cllmh2D1(i,:) = var_cllmh(cldfra2D(:,i), pres2D(:,i), d1) 163 END DO 164 ELSE IF (zdim == 2) THEN 165 DO i=1, d1 166 cllmh2D2(i,:) = var_cllmh(cldfra2D(:,i), pres2D(i,:), d2) 167 END DO 168 ELSE 169 PRINT *,TRIM(ErrWarnMsg('err')) 170 PRINT *,' ' // TRIM(fname) // ': wrong zdim:', zdim,' for Ndim=', Ndim, ' !!' 171 PRINT *,' accepted values: 1,2' 172 STOP 173 END IF 174 CASE (3) 175 IF (zdim == 1) THEN 176 DO i=1, d2 177 DO j=1, d3 178 cllmh3D1(i,j,:) = var_cllmh(cldfra3D(:,i,j), pres3D(:,i,j), d1) 179 END DO 180 END DO 181 ELSE IF (zdim == 2) THEN 182 DO i=1, d1 183 DO j=1, d3 184 cllmh3D2(i,j,:) = var_cllmh(cldfra3D(i,:,j), pres3D(i,:,j), d2) 185 END DO 186 END DO 187 ELSE IF (zdim == 3) THEN 188 DO i=1, d1 189 DO j=1, d2 190 cllmh3D3(i,j,:) = var_cllmh(cldfra3D(i,j,:), pres3D(i,j,:), d3) 191 END DO 192 END DO 193 ELSE 194 PRINT *,TRIM(ErrWarnMsg('err')) 195 PRINT *,' ' // TRIM(fname) // ': wrong zdim:', zdim,' for Ndim=', Ndim, ' !!' 196 PRINT *,' accepted values: 1,2,3' 197 STOP 198 END IF 199 CASE (4) 200 IF (zdim == 1) THEN 201 DO i=1, d2 202 DO j=1, d3 203 DO k=1, d4 204 cllmh4D1(i,j,k,:) = var_cllmh(cldfra4D(:,i,j,k), pres4D(:,i,j,k), d1) 205 END DO 206 END DO 207 END DO 208 ELSE IF (zdim == 2) THEN 209 DO i=1, d1 210 DO j=1, d3 211 DO k=1, d4 212 cllmh4D2(i,j,k,:) = var_cllmh(cldfra4D(i,:,j,k), pres4D(i,:,j,k), d2) 213 END DO 214 END DO 215 END DO 216 ELSE IF (zdim == 3) THEN 217 DO i=1, d2 218 DO j=1, d3 219 DO k=1, d4 220 cllmh4D3(i,j,k,:) = var_cllmh(cldfra4D(i,j,:,k), pres4D(i,j,:,k), d3) 221 END DO 222 END DO 223 END DO 224 ELSE IF (zdim == 4) THEN 225 DO i=1, d1 226 DO j=1, d2 227 DO k=1, d3 228 cllmh4D4(i,j,k,:) = var_cllmh(cldfra4D(i,j,k,:), pres4D(i,j,k,:), d4) 229 END DO 230 END DO 231 END DO 232 ELSE 233 PRINT *,TRIM(ErrWarnMsg('err')) 234 PRINT *,' ' // TRIM(fname) // ': wrong zdim:', zdim,' for Ndim=', Ndim, ' !!' 235 PRINT *,' accepted values: 1,2,3,4' 236 STOP 237 END IF 238 CASE DEFAULT 239 PRINT *,TRIM(ErrWarnMsg('err')) 240 PRINT *,' ' // TRIM(fname) // ': Ndim:', Ndim,' not ready !!' 241 STOP 242 END SELECT 243 244 RETURN 245 246 END SUBROUTINE compute_cllmh 247 248 SUBROUTINE compute_clt4D2(cldfra4D, clt4D2, d1, d2, d3, d4) 249 ! Subroutine to compute the total cloudiness following 'newmicro.F90' from LMDZ from a 4D CLDFRA 250 ! where zdim is the 2nd dimension (thus, cldfra4D(d1,d2,d3,d4) --> clt(d1,d3,d4) 251 ! It should be properly done via an 'INTERFACE', but... 252 253 IMPLICIT NONE 254 255 INTEGER, PARAMETER :: r_k = KIND(1.d0) 256 REAL(r_k), DIMENSION(d1,d2,d3,d4), INTENT(in) :: cldfra4D 257 INTEGER, INTENT(in) :: d1, d2, d3, d4 258 REAL(r_k), DIMENSION(d1,d3,d4), INTENT(out) :: clt4D2 259 260 ! Local 261 INTEGER :: i,j,k, zdim, Ndim 262 CHARACTER(LEN=50) :: fname 263 264 !!!!!!! Variables 265 ! cldfra4D: 4D cloud fraction values [1] 266 ! Ndim: number of dimensions of the input data 267 ! d[1-4]: dimensions of 'cldfra4D' 268 ! zdim: number of the vertical-dimension within the matrix 269 ! clt4D2: total cloudiness for the 4D cldfra and d2 being 'zdim' 270 271 fname = 'compute_clt4D2' 272 zdim = 2 273 Ndim = 4 274 275 DO i=1, d1 276 DO j=1, d3 277 DO k=1, d4 278 clt4D2(i,j,k) = var_clt(cldfra4D(i,:,j,k), d2) 279 END DO 280 END DO 281 END DO 282 283 RETURN 284 285 END SUBROUTINE compute_clt4D2 286 287 SUBROUTINE compute_clt3D1(cldfra3D, clt3D1, d1, d2, d3) 288 ! Subroutine to compute the total cloudiness following 'newmicro.F90' from LMDZ from a 3D CLDFRA 289 ! where zdim is the 1st dimension (thus, cldfra4D(d1,d2,d3) --> clt(d2,d3) 290 ! It should be properly done via an 'INTERFACE', but... 291 292 IMPLICIT NONE 293 294 INTEGER, PARAMETER :: r_k = KIND(1.d0) 295 REAL(r_k), DIMENSION(d1,d2,d3), INTENT(in) :: cldfra3D 296 INTEGER, INTENT(in) :: d1, d2, d3 297 REAL(r_k), DIMENSION(d2,d3), INTENT(out) :: clt3D1 298 299 ! Local 300 INTEGER :: i,j,k, zdim, Ndim 301 CHARACTER(LEN=50) :: fname 302 303 !!!!!!! Variables 304 ! cldfra3D: 3D cloud fraction values [1] 305 ! Ndim: number of dimensions of the input data 306 ! d[1-3]: dimensions of 'cldfra3D' 307 ! zdim: number of the vertical-dimension within the matrix 308 ! clt3D1: total cloudiness for the 3D cldfra and d1 being 'zdim' 309 310 fname = 'compute_clt3D1' 311 zdim = 1 312 Ndim = 3 313 314 DO i=1, d2 315 DO j=1, d3 316 clt3D1(i,j) = var_clt(cldfra3D(:,i,j), d1) 317 END DO 318 END DO 319 320 RETURN 321 322 END SUBROUTINE compute_clt3D1 323 324 SUBROUTINE compute_clt(cldfra1D, cldfra2D, cldfra3D, cldfra4D, Ndim, zdim, clt1D, clt2D1, clt2D2, & 325 clt3D1, clt3D2, clt3D3, clt4D1, clt4D2, clt4D3, clt4D4, d1, d2, d3, d4) 326 ! Subroutine to compute the total cloudiness following 'newmicro.F90' from LMDZ 327 328 IMPLICIT NONE 329 330 INTEGER, PARAMETER :: r_k = KIND(1.d0) 120 331 REAL(r_k), DIMENSION(d1), OPTIONAL, INTENT(in) :: cldfra1D 121 332 REAL(r_k), DIMENSION(d1,d2), OPTIONAL, INTENT(in) :: cldfra2D … … 137 348 ! Local 138 349 INTEGER :: i,j,k 139 REAL(r_k) :: var_clt140 350 CHARACTER(LEN=50) :: fname 141 351
Note: See TracChangeset
for help on using the changeset viewer.