source: LMDZ6/trunk/libf/phylmd/ecrad/ifs/satur.F90 @ 4945

Last change on this file since 4945 was 4876, checked in by idelkadi, 9 months ago

Addition of missing files following the last update (for offline mode)

File size: 4.1 KB
Line 
1! (C) Copyright 1996- ECMWF.
2!
3! This software is licensed under the terms of the Apache Licence Version 2.0
4! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5!
6! In applying this licence, ECMWF does not waive the privileges and immunities
7! granted to it by virtue of its status as an intergovernmental organisation
8! nor does it submit to any jurisdiction.
9
10SUBROUTINE SATUR ( KIDIA , KFDIA , KLON  , KTDIA , KLEV, LDPHYLIN, &
11 & PAPRSF, PT    , PQSAT , KFLAG)
12
13!***
14
15! **   *SATUR* -  COMPUTES SPECIFIC HUMIDITY AT SATURATION
16
17!       J.F. MAHFOUF       E.C.M.W.F.     15/05/96
18
19!       Modified J. HAGUE          13/01/03 MASS Vector Functions
20
21!       PURPOSE.
22!       --------
23
24!       SPECIFIC HUMIDITY AT SATURATION IS USED BY THE
25!       DIAGNOSTIC CLOUD SCHEME TO COMPUTE RELATIVE HUMIDITY
26!       AND LIQUID WATER CONTENT
27
28!       INTERFACE
29!       ---------
30
31!       THIS ROUTINE IS CALLED FROM *CALLPAR*.
32
33!       PARAMETER     DESCRIPTION                                 UNITS
34!       ---------     -----------                                 -----
35!       INPUT PARAMETERS (INTEGER):
36
37!      *KIDIA*        START POINT
38!      *KFDIA*        END POINT
39!      *KLON*         NUMBER OF GRID POINTS PER PACKET
40!      *KTDIA*        START OF THE VERTICAL LOOP
41!      *KLEV*         NUMBER OF LEVELS
42
43!       INPUT PARAMETERS (REAL):
44
45!      *PAPRSF*        PRESSURE ON FULL LEVELS                      PA
46!      *PT*            TEMPERATURE AT T-DT                          K
47
48!       INPUT PARAMETERS (INTEGER):
49
50!      *KFLAG*         FLAG TO DETECT CALL FROM
51
52!                      CONVECTION  KFLAG=1
53!                      OTHER       KFLAG=2
54
55!       OUTPUT PARAMETER (REAL):
56
57!      *PQSAT*         SATURATION SPECIFIC HUMIDITY                 KG/KG
58
59!-------------------------------------------------------------------------
60
61USE PARKIND1  ,ONLY : JPIM     ,JPRB
62USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK, JPHOOK
63
64USE YOMCST   , ONLY : RETV     ,RLVTT    ,RLSTT    ,RTT
65USE YOETHF   , ONLY : R2ES     ,R3LES    ,R3IES    ,R4LES    ,&
66 &                    R4IES    ,R5LES    ,R5IES    ,R5ALVCP  ,R5ALSCP  ,&
67 &                    RALVDCP  ,RALSDCP  ,RTWAT    ,RTICE    ,RTICECU  ,&
68 &                    RTWAT_RTICE_R      ,RTWAT_RTICECU_R
69
70IMPLICIT NONE
71
72INTEGER(KIND=JPIM),INTENT(IN)    :: KLON
73INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV
74INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA
75INTEGER(KIND=JPIM),INTENT(IN)    :: KFDIA
76INTEGER(KIND=JPIM),INTENT(IN)    :: KTDIA
77LOGICAL           ,INTENT(IN)    :: LDPHYLIN
78REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPRSF(KLON,KLEV)
79REAL(KIND=JPRB)   ,INTENT(IN)    :: PT(KLON,KLEV)
80REAL(KIND=JPRB)   ,INTENT(OUT)   :: PQSAT(KLON,KLEV)
81INTEGER(KIND=JPIM),INTENT(IN)    :: KFLAG
82INTEGER(KIND=JPIM) :: JK, JL
83
84REAL(KIND=JPRB) :: ZCOR, ZEW, ZFOEEW, ZQMAX, ZQS, ZTARG
85REAL(KIND=JPRB) :: ZALFA, ZFOEEWL, ZFOEEWI
86REAL(KIND=JPHOOK) :: ZHOOK_HANDLE
87
88!DIR$ VFUNCTION EXPHF
89
90#include "fcttre.func.h"
91
92!----------------------------------------------------------------------
93
94!*    1.           DEFINE CONSTANTS
95!                  ----------------
96
97IF (LHOOK) CALL DR_HOOK('SATUR',0,ZHOOK_HANDLE)
98ZQMAX=0.5_JPRB
99
100!     *
101!----------------------------------------------------------------------
102
103!     *    2.           CALCULATE SATURATION SPECIFIC HUMIDITY
104!                       --------------------------------------
105
106IF (LDPHYLIN) THEN
107  DO JK=KTDIA,KLEV
108    DO JL=KIDIA, KFDIA
109      ZTARG = PT(JL,JK)
110      ZALFA = FOEALFA(ZTARG)
111
112      ZFOEEWL = R2ES*EXP(R3LES*(ZTARG-RTT)/(ZTARG-R4LES))
113      ZFOEEWI = R2ES*EXP(R3IES*(ZTARG-RTT)/(ZTARG-R4IES))
114      ZFOEEW = ZALFA*ZFOEEWL+(1.0_JPRB-ZALFA)*ZFOEEWI
115
116      ZQS    = ZFOEEW/PAPRSF(JL,JK)
117      IF (ZQS > ZQMAX) THEN
118        ZQS=ZQMAX
119      ENDIF
120      ZCOR = 1.0_JPRB/(1.0_JPRB-RETV*ZQS)
121      PQSAT(JL,JK)=ZQS*ZCOR
122    ENDDO
123  ENDDO
124ELSE
125
126  DO JK=KTDIA,KLEV
127    DO JL=KIDIA, KFDIA
128      IF(KFLAG == 1) THEN
129        ZEW  = FOEEWMCU(PT(JL,JK))
130      ELSE
131        ZEW  = FOEEWM(PT(JL,JK))
132      ENDIF
133      ZQS  = ZEW/PAPRSF(JL,JK)
134      ZQS  = MIN(ZQMAX,ZQS)
135      ZCOR = 1.0_JPRB/(1.0_JPRB-RETV*ZQS)
136      PQSAT(JL,JK)=ZQS*ZCOR
137    ENDDO
138  ENDDO
139
140ENDIF
141
142IF (LHOOK) CALL DR_HOOK('SATUR',1,ZHOOK_HANDLE)
143END SUBROUTINE SATUR
Note: See TracBrowser for help on using the repository browser.