PHYEX 0.9.5
PHYsique EXternalisée
Loading...
Searching...
No Matches
mode_tiwmx_tab.F90
Go to the documentation of this file.
2IMPLICIT NONE
3CONTAINS
4FUNCTION tiwmx_tab(CST, TIWMX, P,T,QR,FICE,QRSN,RS,EPS)
5
6! Purpose: (*)
7! The fuction tiwmx_tab returns the wet bulb temperature, but also the
8! corresponding saturation specific humidity as an output parameter.
9! -------------------------------------------------------------------
10! Computation of wet bulb temperature.
11! TIW is found iteratively. Note that Q is used instead of WV.
12! Converges VERY quickly. EPS is the threshold value for
13! TIW(n)-TIW(n-1) at wich the iteration is interupted. (n is
14! iteration number).
15! Modified in July 1988 by Stefan Gollvik
16! Converted to new fortran standard in Dec. 2006 by Karl-Ivar Ivarsson.
17
18! INTERFACE : the function is intended to be used everywhere.
19! INPUT arguments (arguments d'entree)
20! -----------------------------------------------------
21! P : pressure (Pa)
22! T : temperature (K)
23! QR : mixing ratio humidity (kg/Kg)
24! FICE : fraction of ice (0 to 1)
25! EPS : The value determines the accuracy of the output value. 0.1
26! : is suffient in most cases. Low value means high accuracy but
27! : also high computational cost.
28
29! OUTPUT arguments (arguments d'sortie)
30! -----------------------------------------------------
31! RS : saturation mixing ratio (fice determines if it is over ice or water)
32!
33! QRSN : saturation mixing ratio for the wet bulb temperature.
34! (Kg/Kg)
35! ( the function itself is the wet bulb temperature (K) )
36
37! Work variables :
38! -----------------------------------------------------
39! f : temporary variable , temperature (K)
40! dfdt : temporary variable (K/K)
41! t2 : temperature used in iteration (K)
42! dt : temperature residual (K)
43! dqsdt : d(qsat)/d(T) in iteration (1/K)
44! b : (latent heat)/(heat capacity for dry air) (K)
45! iter : iteration number
46
47! 1. Declarations.
48! ==================================================================
49! 1.1 MODULES USED
50 USE modd_cst ,ONLY : cst_t
51 USE modd_tiwmx, ONLY: tiwmx_t
52 USE yomhook , ONLY : lhook, dr_hook, jphook
53
54 IMPLICIT NONE
55
56! Function name :
57 REAL :: tiwmx_tab
58
59! Input Arguments
60 TYPE(cst_t), INTENT(IN) :: cst
61 TYPE(tiwmx_t), INTENT(IN) :: tiwmx
62 REAL, INTENT(IN) :: p,t,qr,fice,eps
63
64! Output Arguments
65 REAL, INTENT(OUT) :: qrsn,rs
66
67! Work variables :
68 REAL :: f,dfdt,t2,dt,qsn,dqsdt,b
69 REAL :: zes,zdesdt
70 INTEGER :: iter
71 REAL(kind=jphook) :: zhook_handle
72
73 IF (lhook) CALL dr_hook('TIWMX_TAB',0,zhook_handle)
74
75 t2 = t
76
77 b = ( cst%XLVTT*(1.-fice) + fice*cst%XLSTT )/cst%XCPD
78
79 tiwmx_tab = t2
80 DO iter=1,10
81 zes = esati(tiwmx, t2)*fice + esatw(tiwmx, t2)*(1.-fice)
82 zdesdt= desdti(tiwmx, t2)*fice + desdtw(tiwmx, t2)*(1.-fice)
83 IF(zes >= p*0.61)THEN ! Do not to compute when condensation
84 qrsn = 1. ! not possible and avoid mixing ratio > 1
85 tiwmx_tab = t2
86 IF (lhook) CALL dr_hook('TIWMX_TAB',1,zhook_handle)
87 RETURN
88 ELSE
89 qsn = cst%XEPSILO*zes/(p-zes)
90 dqsdt = qsn*zdesdt*( 1.0/zes + 1.0/(p-zes) )
91 ENDIF
92 IF ( iter == 1 ) rs = qsn
93 f = t2 - t + b*(qsn - qr)
94 dfdt = 1. + b*dqsdt
95 dt = -f / dfdt
96 t2 = t2 + dt
97 IF(abs(dt) <= eps)THEN
98 tiwmx_tab = t2
99 qsn = min(1.,qsn+dt*dqsdt)
100 qrsn = qsn ! approximation
101 IF (lhook) CALL dr_hook('TIWMX_TAB',1,zhook_handle)
102 RETURN
103 ENDIF
104 ENDDO
105
106 IF (lhook) CALL dr_hook('TIWMX_TAB',1,zhook_handle)
107
108CONTAINS
109include "tiwmx.func.h"
110END FUNCTION tiwmx_tab
111END MODULE mode_tiwmx_tab
elemental real function esatw(tt)
type(cst_t), target, save cst
Definition modd_cst.F90:137
type(tiwmx_t), target, save tiwmx
real function tiwmx_tab(cst, tiwmx, p, t, qr, fice, qrsn, rs, eps)