source: LMDZ6/branches/IPSLCM6.0.14/libf/phylmd/rrtm/recmwf_aero.F90 @ 3205

Last change on this file since 3205 was 3106, checked in by oboucher, 7 years ago

Adding clear-sky clean (no aerosol) LW radiative fluxes at TOA and SFC as diagnostic

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
  • Property svn:keywords set to Author Date Id Revi
File size: 34.7 KB
Line 
1!
2! $Id: recmwf_aero.F90 3106 2017-12-03 21:03:26Z fairhead $
3!
4!OPTIONS XOPT(NOEVAL)
5SUBROUTINE RECMWF_AERO (KST, KEND, KPROMA, KTDIA , KLEV,&
6 & KMODE,&
7 & PALBD , PALBP , PAPRS , PAPRSF , PCCO2 , PCLFR,&
8 & PQO3  , PAER  , PDP   , PEMIS  , PMU0,&
9 & PQ    , PQS   , PQIWP , PQLWP , PSLM   , PT    , PTS,&
10 & PREF_LIQ, PREF_ICE,&
11!--OB
12 & PREF_LIQ_PI, PREF_ICE_PI,&
13!--fin
14 & PEMTD , PEMTU , PTRSO,&
15 & PTH   , PCTRSO, PCEMTR, PTRSOD,&
16 & PLWFC, PLWFT, PSWFC, PSWFT, PSFSWDIR, PSFSWDIF,&
17 & PFSDNN, PFSDNV,& 
18 & PPIZA_TOT,PCGA_TOT,PTAU_TOT, &
19!--OB
20 & PPIZA_NAT,PCGA_NAT,PTAU_NAT, &
21!--fin OB
22!--C.Kleinschmitt
23 & PTAU_LW_TOT, PTAU_LW_NAT, &
24!--end
25 & PFLUX,PFLUC,&
26 & PFSDN ,PFSUP , PFSCDN , PFSCUP, PFSCCDN, PFSCCUP, PFLCCDN, PFLCCUP,&
27!--OB diagnostics
28 & PTOPSWADAERO,PSOLSWADAERO,&
29 & PTOPSWAD0AERO,PSOLSWAD0AERO,&
30 & PTOPSWAIAERO,PSOLSWAIAERO,&
31 & PTOPSWCFAERO,PSOLSWCFAERO,&
32!--LW diagnostics CK
33 & PTOPLWADAERO,PSOLLWADAERO,&
34 & PTOPLWAD0AERO,PSOLLWAD0AERO,&
35 & PTOPLWAIAERO,PSOLLWAIAERO,&
36!..end
37 & ok_ade, ok_aie, flag_aerosol,flag_aerosol_strat)
38!--fin
39
40!**** *RECMWF* - METEO-FRANCE RADIATION INTERFACE TO ECMWF RADIATION SCHEME
41
42!     PURPOSE.
43!     --------
44!           SIMPLE INTERFACE TO RADLSW (NO INTERPOLATION)
45
46!**   INTERFACE.
47!     ----------
48
49!     EXPLICIT ARGUMENTS :
50!        --------------------
51! KST    : START INDEX OF DATA IN KPROMA-LONG VECTOR
52! KEND   : END   INDEX OF DATA IN KPROMA-LONG VECTOR
53! KPROMA : VECTOR LENGTH
54! KTDIA  : INDEX OF TOP LEVEL FROM WHICH COMPUTATIONS ARE ACTIVE
55! KLEV   : NUMBER OF LEVELS
56! PAER   : (KPROMA,KLEV ,6)     ; OPTICAL THICKNESS OF THE AEROSOLS
57! PALBD  : (KPROMA,NSW)         ; DIFFUSE ALBEDO IN THE 2 SW INTERVALS
58! PALBP  : (KPROMA,NSW)         ; PARALLEL ALBEDO IN THE 2 SW INTERVALS
59! PAPRS  : (KPROMA,KLEV+1)      ; HALF LEVEL PRESSURE
60! PAPRSF : (KPROMA,KLEV )       ; FULL LEVEL PRESSURE
61! PCCO2  :                      ; CONCENTRATION IN CO2 (PA/PA)
62! PCLFR  : (KPROMA,KLEV )       ; CLOUD FRACTIONAL COVER
63! PQO3   : (KPROMA,KLEV )       ; OZONE MIXING RATIO (MASS)
64! PDP    : (KPROMA,KLEV)        ; LAYER PRESSURE THICKNESS
65! PEMIS  : (KPROMA)             ; SURFACE EMISSIVITY
66! PMU0   : (KPROMA)             ; SOLAR ANGLE
67! PQ     : (KPROMA,KLEV )       ; SPECIFIC HUMIDITY PA/PA
68! PQS    : (KPROMA,KLEV )       ; SATURATION SPECIFIC HUMIDITY PA/PA
69! PQIWP  : (KPROMA,KLEV )       ; ICE    WATER KG/KG
70! PQLWP  : (KPROMA,KLEV )       ; LIQUID WATER KG/KG
71! PSLM   : (KPROMA)             ; LAND-SEA MASK
72! PT     : (KPROMA,KLEV)        ; FULL LEVEL TEMPERATURE
73! PTS    : (KPROMA)             ; SURFACE TEMPERATURE
74! PPIZA_TOT  : (KPROMA,KLEV,NSW); Single scattering albedo of total aerosol
75! PCGA_TOT   : (KPROMA,KLEV,NSW); Assymetry factor for total aerosol
76! PTAU_TOT: (KPROMA,KLEV,NSW)   ; Optical depth of total aerosol
77! PREF_LIQ (KPROMA,KLEV)        ; Liquid droplet radius (um) - present-day
78! PREF_ICE (KPROMA,KLEV)        ; Ice crystal radius (um) - present-day
79!--OB
80! PREF_LIQ_PI (KPROMA,KLEV)     ; Liquid droplet radius (um) - pre-industrial
81! PREF_ICE_PI (KPROMA,KLEV)     ; Ice crystal radius (um) - pre-industrial
82! ok_ade---input-L- apply the Aerosol Direct Effect or not?
83! ok_aie---input-L- apply the Aerosol Indirect Effect or not?
84! flag_aerosol-input-I- aerosol flag from 0 to 6
85! flag_aerosol_strat-input-I- use stratospheric aerosols flag (T/F)
86! PPIZA_NAT  : (KPROMA,KLEV,NSW); Single scattering albedo of natural aerosol
87! PCGA_NAT   : (KPROMA,KLEV,NSW); Assymetry factor for natural aerosol
88! PTAU_NAT: (KPROMA,KLEV,NSW)   ; Optical depth of natural aerosol
89! PTAU_LW_TOT  (KPROMA,KLEV,NLW); LW Optical depth of total aerosols 
90! PTAU_LW_NAT  (KPROMA,KLEV,NLW); LW Optical depth of natural aerosols
91!--fin OB
92
93!     ==== OUTPUTS ===
94! PEMTD (KPROMA,KLEV+1)         ; TOTAL DOWNWARD LONGWAVE EMISSIVITY
95! PEMTU (KPROMA,KLEV+1)         ; TOTAL UPWARD   LONGWAVE EMISSIVITY
96! PTRSO (KPROMA,KLEV+1)         ; TOTAL SHORTWAVE TRANSMISSIVITY
97! PTH   (KPROMA,KLEV+1)         ; HALF LEVEL TEMPERATURE
98! PCTRSO(KPROMA,2)              ; CLEAR-SKY SHORTWAVE TRANSMISSIVITY
99! PCEMTR(KPROMA,2)              ; CLEAR-SKY NET LONGWAVE EMISSIVITY
100! PTRSOD(KPROMA)                ; TOTAL-SKY SURFACE SW TRANSMISSITY
101! PLWFC (KPROMA,2)              ; CLEAR-SKY LONGWAVE FLUXES
102! PLWFT (KPROMA,KLEV+1)         ; TOTAL-SKY LONGWAVE FLUXES
103! PSWFC (KPROMA,2)              ; CLEAR-SKY SHORTWAVE FLUXES
104! PSWFT (KPROMA,KLEV+1)         ; TOTAL-SKY SHORTWAVE FLUXES
105! Ajout flux LW et SW montants et descendants, et ciel clair (MPL 19.12.08)
106! PFLUX (KPROMA,2,KLEV+1)       ; LW total sky flux (1=up, 2=down)
107! PFLUC (KPROMA,2,KLEV+1)       ; LW clear sky flux (1=up, 2=down)
108! PFSDN(KPROMA,KLEV+1)          ; SW total sky flux down
109! PFSUP(KPROMA,KLEV+1)          ; SW total sky flux up
110! PFSCDN(KPROMA,KLEV+1)         ; SW clear sky flux down
111! PFSCUP(KPROMA,KLEV+1)         ; SW clear sky flux up
112! PFSCCDN(KPROMA,KLEV+1)        ; SW clear sky clean (no aerosol) flux down
113! PFSCCUP(KPROMA,KLEV+1)        ; SW clear sky clean (no aerosol) flux up
114! PFLCCDN(KPROMA,KLEV+1)        ; LW clear sky clean (no aerosol) flux down
115! PFLCCUP(KPROMA,KLEV+1)        ; LW clear sky clean (no aerosol) flux up
116
117
118!        IMPLICIT ARGUMENTS :   NONE
119!        --------------------
120
121!     METHOD.
122!     -------
123!     SEE DOCUMENTATION
124
125!     EXTERNALS.
126!     ----------
127
128!     REFERENCE.
129!     ----------
130!     ECMWF RESEARCH DEPARTMENT DOCUMENTATION OF THE IFS
131
132!     AUTHORS.
133!     --------
134!     ORIGINAL BY  B. RITTER   *ECMWF*        83-10-13
135!     REWRITING FOR IFS BY J.-J. MORCRETTE    94-11-15
136!     96-11: Ph. Dandin. Meteo-France
137!     REWRITING FOR DM  BY J.PH. PIEDELIEVRE   1998-07
138!     Duplication of RFMR to use present (cy25) ECMWF radiation scheme : Y. Bouteloup 09-2003
139!     Use of 6 aerosols & introduce NSW : F. Bouyssel 09-2004
140!     04-11-18 : 4 New arguments for AROME : Y. Seity
141!     2005-10-10 Y. Seity : 3 optional arguments for dust optical properties
142!     JJMorcrette 20060721 PP of clear-sky PAR and TOA incident solar radiation (ECMWF)
143!     Olivier Boucher: added LMD radiation diagnostics 2014-03
144
145!-----------------------------------------------------------------------
146
147USE PARKIND1  ,ONLY : JPIM     ,JPRB
148USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
149USE YOEAERD  , ONLY : RCAEROS
150USE YOMCST   , ONLY :         RMD      ,RMO3
151USE YOMPHY3  , ONLY : RII0
152USE YOERAD   , ONLY : NLW, NAER, RCCNLND  ,RCCNSEA 
153USE YOERAD   , ONLY : NAER, RCCNLND  ,RCCNSEA 
154USE YOERDU   , ONLY : REPSCQ
155USE YOMGEM   , ONLY : NGPTOT
156USE YOERDI   , ONLY : RRAE   ,REPCLC    ,REPH2O
157USE YOMARPHY , ONLY : LRDUST
158USE phys_output_mod, ONLY : swaerofree_diag, swaero_diag
159
160!-----------------------------------------------------------------------
161
162!*       0.1   ARGUMENTS.
163!              ----------
164
165IMPLICIT NONE
166INCLUDE "clesphys.h"
167
168INTEGER(KIND=JPIM),INTENT(IN)    :: KPROMA
169INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV
170INTEGER(KIND=JPIM),INTENT(IN)    :: KST
171INTEGER(KIND=JPIM),INTENT(IN)    :: KEND
172INTEGER(KIND=JPIM)               :: KTDIA ! Argument NOT used
173INTEGER(KIND=JPIM),INTENT(IN)    :: KMODE
174REAL(KIND=JPRB)   ,INTENT(IN)    :: PALBD(KPROMA,NSW)
175REAL(KIND=JPRB)   ,INTENT(IN)    :: PALBP(KPROMA,NSW)
176REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPRS(KPROMA,KLEV+1)
177REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPRSF(KPROMA,KLEV)
178REAL(KIND=JPRB)   ,INTENT(IN)    :: PCCO2
179REAL(KIND=JPRB)   ,INTENT(IN)    :: PCLFR(KPROMA,KLEV)
180REAL(KIND=JPRB)   ,INTENT(IN)    :: PQO3(KPROMA,KLEV)
181REAL(KIND=JPRB)   ,INTENT(IN)    :: PAER(KPROMA,KLEV,6)
182REAL(KIND=JPRB)   ,INTENT(IN)    :: PDP(KPROMA,KLEV)
183REAL(KIND=JPRB)   ,INTENT(IN)    :: PEMIS(KPROMA)
184REAL(KIND=JPRB)   ,INTENT(IN)    :: PMU0(KPROMA)
185REAL(KIND=JPRB)   ,INTENT(IN)    :: PQ(KPROMA,KLEV)
186REAL(KIND=JPRB)   ,INTENT(IN)    :: PQS(KPROMA,KLEV)
187REAL(KIND=JPRB)   ,INTENT(IN)    :: PQIWP(KPROMA,KLEV)
188REAL(KIND=JPRB)   ,INTENT(IN)    :: PQLWP(KPROMA,KLEV)
189REAL(KIND=JPRB)   ,INTENT(IN)    :: PSLM(KPROMA)
190REAL(KIND=JPRB)   ,INTENT(IN)    :: PT(KPROMA,KLEV)
191REAL(KIND=JPRB)   ,INTENT(IN)    :: PTS(KPROMA)
192REAL(KIND=JPRB)   ,INTENT(IN)    :: PPIZA_TOT(KPROMA,KLEV,NSW)
193REAL(KIND=JPRB)   ,INTENT(IN)    :: PCGA_TOT(KPROMA,KLEV,NSW)
194REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAU_TOT(KPROMA,KLEV,NSW)
195!--OB
196REAL(KIND=JPRB)   ,INTENT(IN)    :: PPIZA_NAT(KPROMA,KLEV,NSW)
197REAL(KIND=JPRB)   ,INTENT(IN)    :: PCGA_NAT(KPROMA,KLEV,NSW)
198REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAU_NAT(KPROMA,KLEV,NSW)
199REAL(KIND=JPRB)                  :: PPIZA_ZERO(KPROMA,KLEV,NSW)
200REAL(KIND=JPRB)                  :: PCGA_ZERO(KPROMA,KLEV,NSW)
201REAL(KIND=JPRB)                  :: PTAU_ZERO(KPROMA,KLEV,NSW)
202!--fin
203!--C.Kleinschmitt
204REAL(KIND=JPRB)                  :: PTAU_LW_ZERO(KPROMA,KLEV,NLW)
205REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAU_LW_TOT(KPROMA,KLEV,NLW)
206REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAU_LW_NAT(KPROMA,KLEV,NLW)
207!--end
208REAL(KIND=JPRB)   ,INTENT(IN)    :: PREF_LIQ(KPROMA,KLEV)
209REAL(KIND=JPRB)   ,INTENT(IN)    :: PREF_ICE(KPROMA,KLEV)
210!--OB
211REAL(KIND=JPRB)   ,INTENT(IN)    :: PREF_LIQ_PI(KPROMA,KLEV)
212REAL(KIND=JPRB)   ,INTENT(IN)    :: PREF_ICE_PI(KPROMA,KLEV)
213LOGICAL, INTENT(in)  :: ok_ade, ok_aie         ! switches whether to use aerosol direct (indirect) effects or not
214INTEGER, INTENT(in)  :: flag_aerosol           ! takes value 0 (no aerosol) or 1 to 6 (aerosols)
215LOGICAL, INTENT(in)  :: flag_aerosol_strat     ! use stratospheric aerosols
216REAL(KIND=JPRB)   ,INTENT(out)   :: PTOPSWADAERO(KPROMA), PSOLSWADAERO(KPROMA)       ! Aerosol direct forcing at TOA and surface
217REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTOPSWAD0AERO(KPROMA), PSOLSWAD0AERO(KPROMA)     ! Aerosol direct forcing at TOA and surface
218REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTOPSWAIAERO(KPROMA), PSOLSWAIAERO(KPROMA)       ! ditto, indirect
219REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTOPSWCFAERO(KPROMA,3), PSOLSWCFAERO(KPROMA,3) !--do we keep this ?
220!--fin
221!--CK
222REAL(KIND=JPRB)   ,INTENT(out)   :: PTOPLWADAERO(KPROMA), PSOLLWADAERO(KPROMA)       ! LW Aerosol direct forcing at TOA + surface
223REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTOPLWAD0AERO(KPROMA), PSOLLWAD0AERO(KPROMA)     ! LW Aerosol direct forcing at TOA + surface
224REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTOPLWAIAERO(KPROMA), PSOLLWAIAERO(KPROMA)       ! LW Aer. indirect forcing at TOA + surface
225!--end
226REAL(KIND=JPRB)   ,INTENT(OUT)   :: PEMTD(KPROMA,KLEV+1)
227REAL(KIND=JPRB)   ,INTENT(OUT)   :: PEMTU(KPROMA,KLEV+1)
228REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTRSO(KPROMA,KLEV+1)
229REAL(KIND=JPRB)   ,INTENT(INOUT) :: PTH(KPROMA,KLEV+1)
230REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCTRSO(KPROMA,2)
231REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCEMTR(KPROMA,2)
232REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTRSOD(KPROMA)
233REAL(KIND=JPRB)   ,INTENT(OUT)   :: PLWFC(KPROMA,2)
234REAL(KIND=JPRB)   ,INTENT(OUT)   :: PLWFT(KPROMA,KLEV+1)
235REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSWFC(KPROMA,2)
236REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSWFT(KPROMA,KLEV+1)
237REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSFSWDIR(KPROMA,NSW)
238REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSFSWDIF(KPROMA,NSW)
239REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSDNN(KPROMA)
240REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSDNV(KPROMA)
241REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFLUX(KPROMA,2,KLEV+1) ! LW total sky flux (1=up, 2=down)
242REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFLUC(KPROMA,2,KLEV+1) ! LW clear sky flux (1=up, 2=down)
243REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSDN(KPROMA,KLEV+1)   ! SW total sky flux down
244REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSUP(KPROMA,KLEV+1)   ! SW total sky flux up
245REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSCDN(KPROMA,KLEV+1)  ! SW clear sky flux down
246REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSCUP(KPROMA,KLEV+1)  ! SW clear sky flux up
247REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSCCDN(KPROMA,KLEV+1) ! SW clear sky clean (no aerosol) flux down
248REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSCCUP(KPROMA,KLEV+1) ! SW clear sky clean (no aerosol) flux up
249REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFLCCDN(KPROMA,KLEV+1) ! LW clear sky clean (no aerosol) flux down
250REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFLCCUP(KPROMA,KLEV+1) ! LW clear sky clean (no aerosol) flux up
251
252!     ==== COMPUTED IN RADITE ===
253!     ------------------------------------------------------------------
254!*       0.2   LOCAL ARRAYS.
255!              -------------
256REAL(KIND=JPRB) :: ZRAER  (KPROMA,6,KLEV)
257REAL(KIND=JPRB) :: ZRCLC  (KPROMA,KLEV)
258REAL(KIND=JPRB) :: ZRMU0  (KPROMA)
259REAL(KIND=JPRB) :: ZRPR   (KPROMA,KLEV)
260REAL(KIND=JPRB) :: ZRTI   (KPROMA,KLEV)
261REAL(KIND=JPRB) :: ZQLWP (KPROMA,KLEV ) , ZQIWP (KPROMA,KLEV )
262
263REAL(KIND=JPRB) :: ZPQO3 (KPROMA,KLEV)
264REAL(KIND=JPRB) :: ZQOZ (NGPTOT,KLEV)
265REAL(KIND=JPRB) :: ZQS    (KPROMA,KLEV)
266REAL(KIND=JPRB) :: ZQ     (KPROMA,KLEV)
267REAL(KIND=JPRB) :: ZEMTD  (KPROMA,KLEV+1)
268REAL(KIND=JPRB) :: ZEMTU  (KPROMA,KLEV+1)
269REAL(KIND=JPRB) :: ZTRSOC (KPROMA,2)
270REAL(KIND=JPRB) :: ZEMTC  (KPROMA,2)
271
272REAL(KIND=JPRB) :: ZNBAS  (KPROMA)
273REAL(KIND=JPRB) :: ZNTOP  (KPROMA)
274REAL(KIND=JPRB) :: ZQRAIN (KPROMA,KLEV)
275REAL(KIND=JPRB) :: ZQRAINT(KPROMA,KLEV)
276REAL(KIND=JPRB) :: ZCCNL  (KPROMA)
277REAL(KIND=JPRB) :: ZCCNO  (KPROMA)
278
279!  output of radlsw
280
281REAL(KIND=JPRB) :: ZEMIT  (KPROMA)
282REAL(KIND=JPRB) :: ZFCT   (KPROMA,KLEV+1)
283REAL(KIND=JPRB) :: ZFLT   (KPROMA,KLEV+1)
284REAL(KIND=JPRB) :: ZFCS   (KPROMA,KLEV+1)
285REAL(KIND=JPRB) :: ZFLS   (KPROMA,KLEV+1)
286REAL(KIND=JPRB) :: ZFRSOD (KPROMA),ZSUDU(KPROMA)
287REAL(KIND=JPRB) :: ZPARF  (KPROMA),ZUVDF(KPROMA),ZPARCF(KPROMA),ZTINCF(KPROMA)
288
289INTEGER(KIND=JPIM) :: IBEG, IEND, JK, JL
290
291REAL(KIND=JPRB) :: ZCRAE, ZRII0, ZEMIW(KPROMA)
292REAL(KIND=JPRB) :: ZHOOK_HANDLE
293
294!---aerosol radiative diagnostics
295! Key to define the aerosol effect acting on climate
296! OB: AEROSOLFEEDBACK_ACTIVE is now a LOGICAL
297! TRUE: fluxes use natural and/or anthropogenic aerosols according to ok_ade and ok_aie, DEFAULT
298! FALSE: fluxes use no aerosols (case 1)
299! to be used only for maintaining bit reproducibility with aerosol diagnostics activated
300LOGICAL :: AEROSOLFEEDBACK_ACTIVE = .TRUE.
301
302!OB - Fluxes including aerosol effects
303!              |        direct effect
304!ind effect    | no aerosol  NATural  TOTal
305!standard      |   5
306!natural (PI)  |               1       3     
307!total   (PD)  |               2       4   
308! so we need which case when ?
309! if flag_aerosol is on
310! ok_ade and ok_aie         = 4-2, 4-3 and 4 to proceed
311! ok_ade and not ok_aie     = 3-1 and 3 to proceed
312! not ok_ade and ok_aie     = 2-1 and 2 to proceed
313! not ok_ade and not ok_aie = 1 to proceed
314! therefore the cases have the following corresponding switches
315! 1 = not ok_ade and not ok_aie OR not ok_ade and ok_aie and swaero_diag OR ok_ade and not ok_aie and swaero_diag
316! 2 = not ok_ade and ok_aie OR ok_aie and ok_ade and swaero_diag
317! 3 = ok_ade and not ok_aie OR ok_aie and ok_ade and swaero_diag
318! 4 = ok_ade and ok_aie
319! 5 = no aerosol feedback wanted or no aerosol at all
320! if they are called in this order then the correct call is used to proceed
321
322REAL(KIND=JPRB) ::  ZFSUP_AERO(KPROMA,KLEV+1,5)
323REAL(KIND=JPRB) ::  ZFSDN_AERO(KPROMA,KLEV+1,5)
324REAL(KIND=JPRB) ::  ZFSUP0_AERO(KPROMA,KLEV+1,5)
325REAL(KIND=JPRB) ::  ZFSDN0_AERO(KPROMA,KLEV+1,5)
326!--LW (CK):
327REAL(KIND=JPRB) ::  LWUP_AERO(KPROMA,KLEV+1,5)
328REAL(KIND=JPRB) ::  LWDN_AERO(KPROMA,KLEV+1,5)
329REAL(KIND=JPRB) ::  LWUP0_AERO(KPROMA,KLEV+1,5)
330REAL(KIND=JPRB) ::  LWDN0_AERO(KPROMA,KLEV+1,5)
331
332#include "radlsw.intfb.h"
333
334IF (LHOOK) CALL DR_HOOK('RECMWF_AERO',0,ZHOOK_HANDLE)
335IBEG=KST
336IEND=KEND
337
338!*       1.    PREPARATORY WORK
339!              ----------------
340!--OB
341!        1.0    INITIALIZATIONS
342!               --------------
343
344ZFSUP_AERO (:,:,:)=0.
345ZFSDN_AERO (:,:,:)=0.
346ZFSUP0_AERO(:,:,:)=0.
347ZFSDN0_AERO(:,:,:)=0.
348
349LWUP_AERO (:,:,:)=0.
350LWDN_AERO (:,:,:)=0.
351LWUP0_AERO(:,:,:)=0.
352LWDN0_AERO(:,:,:)=0.
353
354PTAU_ZERO(:,:,:) =1.e-15
355PPIZA_ZERO(:,:,:)=1.0
356PCGA_ZERO(:,:,:) =0.0
357
358PTAU_LW_ZERO(:,:,:) =1.e-15
359
360
361!*       1.1    LOCAL CONSTANTS
362!                ---------------
363
364ZRII0=RII0
365ZCRAE=RRAE*(RRAE+2.0_JPRB)
366
367!*       2.1    FULL-LEVEL QUANTITIES
368
369ZRPR =PAPRSF
370
371DO JK=1,KLEV
372  DO JL=IBEG,IEND
373!   ZPQO3(JL,JK)=PQO3(JL,JK)*PDP(JL,JK)*RMD/RMO3
374    ZPQO3(JL,JK)=PQO3(JL,JK)*PDP(JL,JK)
375    ZRCLC(JL,JK)=MAX( 0.0_JPRB ,MIN( 1.0_JPRB ,PCLFR(JL,JK)))
376    IF (ZRCLC(JL,JK) > REPCLC) THEN
377      ZQLWP(JL,JK)=PQLWP(JL,JK)
378      ZQIWP(JL,JK)=PQIWP(JL,JK)
379    ELSE
380      ZQLWP(JL,JK)=REPH2O*ZRCLC(JL,JK)
381      ZQIWP(JL,JK)=REPH2O*ZRCLC(JL,JK)
382    ENDIF
383    ZQRAIN(JL,JK)=0.
384    ZQRAINT(JL,JK)=0.
385    ZRTI(JL,JK) =PT(JL,JK)
386    ZQS (JL,JK)=MAX(2.0_JPRB*REPH2O,PQS(JL,JK))
387    ZQ  (JL,JK)=MAX(REPH2O,MIN(PQ(JL,JK),ZQS(JL,JK)*(1.0_JPRB-REPH2O)))
388    ZEMIW(JL)=PEMIS(JL)
389  ENDDO
390ENDDO
391
392IF (NAER == 0) THEN
393  ZRAER=RCAEROS
394ELSE
395  DO JK=1,KLEV
396    DO JL=IBEG,IEND
397      ZRAER(JL,1,JK)=PAER(JL,JK,1)
398      ZRAER(JL,2,JK)=PAER(JL,JK,2)
399      ZRAER(JL,3,JK)=PAER(JL,JK,3)
400      ZRAER(JL,4,JK)=PAER(JL,JK,4)
401      ZRAER(JL,5,JK)=RCAEROS
402      ZRAER(JL,6,JK)=PAER(JL,JK,6)
403    ENDDO
404  ENDDO
405ENDIF
406
407!*       2.2    HALF-LEVEL QUANTITIES
408
409DO JK=2,KLEV
410  DO JL=IBEG,IEND
411    PTH(JL,JK)=&
412     & (PT(JL,JK-1)*PAPRSF(JL,JK-1)*(PAPRSF(JL,JK)-PAPRS(JL,JK))&
413     & +PT(JL,JK)*PAPRSF(JL,JK)*(PAPRS(JL,JK)-PAPRSF(JL,JK-1)))&
414     & *(1.0_JPRB/(PAPRS(JL,JK)*(PAPRSF(JL,JK)-PAPRSF(JL,JK-1)))) 
415  ENDDO
416ENDDO
417
418!*       2.3     QUANTITIES AT BOUNDARIES
419
420DO JL=IBEG,IEND
421  PTH(JL,KLEV+1)=PTS(JL)
422  PTH(JL,1)=PT(JL,1)-PAPRSF(JL,1)*(PT(JL,1)-PTH(JL,2))&
423   & /(PAPRSF(JL,1)-PAPRS(JL,2)) 
424  ZNBAS(JL)=1.
425  ZNTOP(JL)=1.
426  ZCCNL(JL)=RCCNLND
427  ZCCNO(JL)=RCCNSEA
428ENDDO
429
430!*       3.1     SOLAR ZENITH ANGLE IS EARTH'S CURVATURE
431!                CORRECTED
432
433! CCMVAL: on impose ZRMU0=PMU0 MPL 25032010
434! 2eme essai en 3D MPL 20052010
435!DO JL=IBEG,IEND
436! ZRMU0(JL)=PMU0(JL)
437!ENDDO
438!!!!! A REVOIR MPL 20091201: enleve cette correction pour comparer a AR4
439 DO JL=IBEG,IEND
440   IF (PMU0(JL) > 1.E-10_JPRB) THEN
441     ZRMU0(JL)=RRAE/(SQRT(PMU0(JL)**2+ZCRAE)-PMU0(JL))
442   ELSE
443     ZRMU0(JL)= RRAE/SQRT(ZCRAE)
444   ENDIF   
445 ENDDO   
446
447!*         4.1     CALL TO ACTUAL RADIATION SCHEME
448!
449!----now we make multiple calls to the radiation according to which
450!----aerosol flags are on
451
452IF (flag_aerosol .GT. 0 .OR. flag_aerosol_strat) THEN
453
454!--Case 1
455IF ( ( .not. ok_ade .AND. .not. ok_aie ) .OR.             &
456   & ( .not. ok_ade .AND. ok_aie .AND. swaero_diag ) .OR. &
457   & ( ok_ade .AND. .not. ok_aie .AND. swaero_diag ) ) THEN
458
459! natural aerosols for direct and indirect effect
460! PI cloud optical properties
461! use PREF_LIQ_PI and PREF_ICE_PI
462! use NAT aerosol optical properties
463! store fluxes in index 1
464
465CALL RADLSW (&
466 & IBEG  , IEND   , KPROMA  , KLEV  , KMODE , NAER,&
467 & ZRII0 ,&
468 & ZRAER , PALBD  , PALBP   , PAPRS , ZRPR  ,&
469 & ZCCNL , ZCCNO  ,&
470 & PCCO2 , ZRCLC  , PDP     , PEMIS , ZEMIW ,PSLM    , ZRMU0 , ZPQO3,&
471 & ZQ    , ZQIWP  , ZQLWP   , ZQS   , ZQRAIN,ZQRAINT ,&
472 & PTH   , ZRTI   , PTS     , ZNBAS , ZNTOP ,&
473 & PREF_LIQ_PI, PREF_ICE_PI,&
474 & ZEMIT , ZFCT   , ZFLT    , ZFCS    , ZFLS  ,&
475 & ZFRSOD, ZSUDU  , ZUVDF   , ZPARF   , ZPARCF, ZTINCF, PSFSWDIR,&
476 & PSFSWDIF,PFSDNN, PFSDNV  ,& 
477 & LRDUST,PPIZA_NAT,PCGA_NAT,PTAU_NAT,PTAU_LW_NAT,PFLUX,PFLUC,&
478 & PFSDN , PFSUP  , PFSCDN  , PFSCUP )
479
480!* SAVE VARIABLES IN INTERIM VARIABLES A LA SW_AEROAR4
481ZFSUP0_AERO(:,:,1) = PFSCUP(:,:)
482ZFSDN0_AERO(:,:,1) = PFSCDN(:,:)
483
484ZFSUP_AERO(:,:,1) =  PFSUP(:,:)
485ZFSDN_AERO(:,:,1) =  PFSDN(:,:)
486
487LWUP0_AERO(:,:,1) = PFLUC(:,1,:)
488LWDN0_AERO(:,:,1) = PFLUC(:,2,:)
489
490LWUP_AERO(:,:,1) = PFLUX(:,1,:)
491LWDN_AERO(:,:,1) = PFLUX(:,2,:)
492
493ENDIF
494
495!--Case 2
496IF ( ( .not. ok_ade .AND. ok_aie ) .OR. &
497   & ( ok_ade .AND. ok_aie .AND. swaero_diag ) ) THEN
498
499! natural aerosols for direct indirect effect
500! use NAT aerosol optical properties
501! PD cloud optical properties
502! use PREF_LIQ and PREF_ICE
503! store fluxes in index 2
504
505CALL RADLSW (&
506 & IBEG  , IEND   , KPROMA  , KLEV  , KMODE , NAER,&
507 & ZRII0 ,&
508 & ZRAER , PALBD  , PALBP   , PAPRS , ZRPR  ,&
509 & ZCCNL , ZCCNO  ,&
510 & PCCO2 , ZRCLC  , PDP     , PEMIS , ZEMIW ,PSLM    , ZRMU0 , ZPQO3,&
511 & ZQ    , ZQIWP  , ZQLWP   , ZQS   , ZQRAIN,ZQRAINT ,&
512 & PTH   , ZRTI   , PTS     , ZNBAS , ZNTOP ,&
513 & PREF_LIQ, PREF_ICE,&
514 & ZEMIT , ZFCT   , ZFLT    , ZFCS    , ZFLS  ,&
515 & ZFRSOD, ZSUDU  , ZUVDF   , ZPARF   , ZPARCF, ZTINCF, PSFSWDIR,&
516 & PSFSWDIF,PFSDNN, PFSDNV  ,& 
517 & LRDUST,PPIZA_NAT,PCGA_NAT,PTAU_NAT,PTAU_LW_NAT,PFLUX,PFLUC,&
518 & PFSDN , PFSUP  , PFSCDN  , PFSCUP )
519
520!* SAVE VARIABLES IN INTERIM VARIABLES A LA SW_AEROAR4
521ZFSUP0_AERO(:,:,2) = PFSCUP(:,:)
522ZFSDN0_AERO(:,:,2) = PFSCDN(:,:)
523
524ZFSUP_AERO(:,:,2) =  PFSUP(:,:)
525ZFSDN_AERO(:,:,2) =  PFSDN(:,:)
526
527LWUP0_AERO(:,:,2) = PFLUC(:,1,:)
528LWDN0_AERO(:,:,2) = PFLUC(:,2,:)
529
530LWUP_AERO(:,:,2) = PFLUX(:,1,:)
531LWDN_AERO(:,:,2) = PFLUX(:,2,:)
532
533ENDIF ! ok_aie     
534
535!--Case 3
536IF ( ( ok_ade .AND. .not. ok_aie ) .OR. &
537   & ( ok_ade .AND. ok_aie .AND. swaero_diag ) ) THEN
538
539! direct effect of total aerosol activated
540! TOT aerosols for direct effect
541! PI cloud optical properties
542! use PREF_LIQ_PI and PREF_ICE_PI
543! STORE fluxes in index 3
544 
545CALL RADLSW (&
546 & IBEG  , IEND   , KPROMA  , KLEV  , KMODE , NAER,&
547 & ZRII0 ,&
548 & ZRAER , PALBD  , PALBP   , PAPRS , ZRPR  ,&
549 & ZCCNL , ZCCNO  ,&
550 & PCCO2 , ZRCLC  , PDP     , PEMIS , ZEMIW ,PSLM    , ZRMU0 , ZPQO3,&
551 & ZQ    , ZQIWP  , ZQLWP   , ZQS   , ZQRAIN,ZQRAINT ,&
552 & PTH   , ZRTI   , PTS     , ZNBAS , ZNTOP ,&
553 & PREF_LIQ_PI, PREF_ICE_PI,&
554 & ZEMIT , ZFCT   , ZFLT    , ZFCS    , ZFLS  ,&
555 & ZFRSOD, ZSUDU  , ZUVDF   , ZPARF   , ZPARCF, ZTINCF, PSFSWDIR,&
556 & PSFSWDIF,PFSDNN, PFSDNV  ,& 
557 & LRDUST,PPIZA_TOT,PCGA_TOT,PTAU_TOT,PTAU_LW_TOT,PFLUX,PFLUC,&
558 & PFSDN , PFSUP  , PFSCDN  , PFSCUP )
559
560!* SAVE VARIABLES IN INTERIM VARIABLES A LA SW_AEROAR4
561ZFSUP0_AERO(:,:,3) = PFSCUP(:,:)
562ZFSDN0_AERO(:,:,3) = PFSCDN(:,:)
563
564ZFSUP_AERO(:,:,3) =  PFSUP(:,:)
565ZFSDN_AERO(:,:,3) =  PFSDN(:,:)
566
567LWUP0_AERO(:,:,3) = PFLUC(:,1,:)
568LWDN0_AERO(:,:,3) = PFLUC(:,2,:)
569
570LWUP_AERO(:,:,3) = PFLUX(:,1,:)
571LWDN_AERO(:,:,3) = PFLUX(:,2,:)
572
573ENDIF !-end ok_ade
574
575!--Case 4
576IF (ok_ade .and. ok_aie) THEN
577
578! total aerosols for direct indirect effect
579! use TOT aerosol optical properties
580! PD cloud optical properties
581! use PREF_LIQ and PREF_ICE
582! store fluxes in index 4
583
584CALL RADLSW (&
585 & IBEG  , IEND   , KPROMA  , KLEV  , KMODE , NAER,&
586 & ZRII0 ,&
587 & ZRAER , PALBD  , PALBP   , PAPRS , ZRPR  ,&
588 & ZCCNL , ZCCNO  ,&
589 & PCCO2 , ZRCLC  , PDP     , PEMIS , ZEMIW ,PSLM    , ZRMU0 , ZPQO3,&
590 & ZQ    , ZQIWP  , ZQLWP   , ZQS   , ZQRAIN,ZQRAINT ,&
591 & PTH   , ZRTI   , PTS     , ZNBAS , ZNTOP ,&
592 & PREF_LIQ, PREF_ICE,&
593 & ZEMIT , ZFCT   , ZFLT    , ZFCS    , ZFLS  ,&
594 & ZFRSOD, ZSUDU  , ZUVDF   , ZPARF   , ZPARCF, ZTINCF, PSFSWDIR,&
595 & PSFSWDIF,PFSDNN, PFSDNV  ,& 
596 & LRDUST,PPIZA_TOT,PCGA_TOT,PTAU_TOT,PTAU_LW_TOT,PFLUX,PFLUC,&
597 & PFSDN , PFSUP  , PFSCDN  , PFSCUP )
598
599!* SAVE VARIABLES IN INTERIM VARIABLES A LA SW_AEROAR4
600ZFSUP0_AERO(:,:,4) = PFSCUP(:,:)
601ZFSDN0_AERO(:,:,4) = PFSCDN(:,:)
602
603ZFSUP_AERO(:,:,4) =  PFSUP(:,:)
604ZFSDN_AERO(:,:,4) =  PFSDN(:,:)
605
606LWUP0_AERO(:,:,4) = PFLUC(:,1,:)
607LWDN0_AERO(:,:,4) = PFLUC(:,2,:)
608
609LWUP_AERO(:,:,4) = PFLUX(:,1,:)
610LWDN_AERO(:,:,4) = PFLUX(:,2,:)
611
612ENDIF ! ok_ade .and. ok_aie
613
614ENDIF !--if flag_aerosol GT 0 OR flag_aerosol_strat
615
616! case with no aerosols at all is also computed IF ACTIVEFEEDBACK_ACTIVE is false
617IF (.not. AEROSOLFEEDBACK_ACTIVE .OR. flag_aerosol .EQ. 0 .OR. swaerofree_diag) THEN   
618
619! ZERO aerosol effect
620! ZERO aerosol optical depth
621! STANDARD cloud optical properties
622! STORE fluxes in index 5
623
624CALL RADLSW (&
625 & IBEG  , IEND   , KPROMA  , KLEV  , KMODE , NAER,&
626 & ZRII0 ,&
627 & ZRAER , PALBD  , PALBP   , PAPRS , ZRPR  ,&
628 & ZCCNL , ZCCNO  ,&
629 & PCCO2 , ZRCLC  , PDP     , PEMIS , ZEMIW ,PSLM    , ZRMU0 , ZPQO3,&
630 & ZQ    , ZQIWP  , ZQLWP   , ZQS   , ZQRAIN,ZQRAINT ,&
631 & PTH   , ZRTI   , PTS     , ZNBAS , ZNTOP ,&
632!--this needs to be changed to fixed cloud optical properties
633 & PREF_LIQ_PI, PREF_ICE_PI,&
634 & ZEMIT , ZFCT   , ZFLT    , ZFCS    , ZFLS  ,&
635 & ZFRSOD, ZSUDU  , ZUVDF   , ZPARF   , ZPARCF, ZTINCF, PSFSWDIR,&
636 & PSFSWDIF,PFSDNN, PFSDNV  ,& 
637 & LRDUST,PPIZA_ZERO,PCGA_ZERO,PTAU_ZERO, PTAU_LW_ZERO,PFLUX,PFLUC,&
638 & PFSDN , PFSUP  , PFSCDN  , PFSCUP )
639
640!* SAVE VARIABLES IN INTERIM VARIABLES A LA SW_AEROAR4
641ZFSUP0_AERO(:,:,5) = PFSCUP(:,:)
642ZFSDN0_AERO(:,:,5) = PFSCDN(:,:)
643
644ZFSUP_AERO(:,:,5) =  PFSUP(:,:)
645ZFSDN_AERO(:,:,5) =  PFSDN(:,:)
646
647LWUP0_AERO(:,:,5) = PFLUC(:,1,:)
648LWDN0_AERO(:,:,5) = PFLUC(:,2,:)
649
650LWUP_AERO(:,:,5) = PFLUX(:,1,:)
651LWDN_AERO(:,:,5) = PFLUX(:,2,:)
652
653ENDIF ! .not. AEROSOLFEEDBACK_ACTIVE
654
655!*         4.2     TRANSFORM FLUXES TO MODEL HISTORICAL VARIABLES
656
657DO JK=1,KLEV+1
658  DO JL=IBEG,IEND
659    PSWFT(JL,JK)=ZFLS(JL,JK)/(ZRII0*ZRMU0(JL))
660    PLWFT(JL,JK)=ZFLT(JL,JK)
661  ENDDO
662ENDDO
663
664ZEMTD=PLWFT
665ZEMTU=PLWFT
666
667DO JL=IBEG,IEND
668  ZTRSOC(JL, 1)=ZFCS(JL,     1)/(ZRII0*ZRMU0(JL))
669  ZTRSOC(JL, 2)=ZFCS(JL,KLEV+1)/(ZRII0*ZRMU0(JL))
670  ZEMTC (JL, 1)=ZFCT(JL,     1)
671  ZEMTC (JL, 2)=ZFCT(JL,KLEV+1)
672ENDDO
673
674!                 ------------ -- ------- -- ---- -----
675!*         5.1    STORAGE OF TRANSMISSIVITY AND EMISSIVITIES
676!*                IN KPROMA-LONG ARRAYS
677
678DO JK=1,KLEV+1
679  DO JL=IBEG,IEND
680    PEMTD(JL,JK)=ZEMTD(JL,JK)
681    PEMTU(JL,JK)=ZEMTU(JL,JK)
682    PTRSO(JL,JK)=MAX(0.0_JPRB,MIN(1.0_JPRB,PSWFT(JL,JK)))
683  ENDDO
684ENDDO
685DO JK=1,2
686  DO JL=IBEG,IEND
687    PCEMTR(JL,JK)=ZEMTC (JL,JK)
688    PCTRSO(JL,JK)=MAX( 0.0_JPRB,MIN(1.0_JPRB,ZTRSOC(JL,JK)))
689  ENDDO
690ENDDO
691DO JL=IBEG,IEND
692  PTRSOD(JL)=MAX(0.0_JPRB,MIN(1.0_JPRB,ZFRSOD(JL)/(ZRII0*ZRMU0(JL))))
693ENDDO
694
695!*         7.3   RECONSTRUCT FLUXES FOR DIAGNOSTICS
696
697DO JL=IBEG,IEND
698  IF (PMU0(JL) < 1.E-10_JPRB) ZRMU0(JL)=0.0_JPRB
699ENDDO
700DO JK=1,KLEV+1
701  DO JL=IBEG,IEND
702    PLWFT(JL,JK)=PEMTD(JL,JK)
703    PSWFT(JL,JK)=ZRMU0(JL)*ZRII0*PTRSO(JL,JK)
704  ENDDO
705ENDDO
706DO JK=1,2
707  DO JL=IBEG,IEND
708    PSWFC(JL,JK)=ZRMU0(JL)*ZRII0*PCTRSO(JL,JK)
709    PLWFC(JL,JK)=PCEMTR(JL,JK)
710  ENDDO
711ENDDO
712
713!*  8.0 DIAGNOSTICS
714!---Now we copy back the correct fields to proceed to the next timestep
715
716IF  ( AEROSOLFEEDBACK_ACTIVE .AND. (flag_aerosol .GT. 0 .OR. flag_aerosol_strat) ) THEN
717
718  IF ( ok_ade .and. ok_aie  ) THEN
719    PFSUP(:,:) =    ZFSUP_AERO(:,:,4)
720    PFSDN(:,:) =    ZFSDN_AERO(:,:,4)
721    PFSCUP(:,:) =   ZFSUP0_AERO(:,:,4)
722    PFSCDN(:,:) =   ZFSDN0_AERO(:,:,4)
723
724    PFLUX(:,1,:) =  LWUP_AERO(:,:,4)
725    PFLUX(:,2,:) =  LWDN_AERO(:,:,4)
726    PFLUC(:,1,:) =  LWUP0_AERO(:,:,4)
727    PFLUC(:,2,:) =  LWDN0_AERO(:,:,4)   
728  ENDIF
729
730  IF ( ok_ade .and. (.not. ok_aie) )  THEN
731    PFSUP(:,:) =    ZFSUP_AERO(:,:,3)
732    PFSDN(:,:) =    ZFSDN_AERO(:,:,3)
733    PFSCUP(:,:) =   ZFSUP0_AERO(:,:,3)
734    PFSCDN(:,:) =   ZFSDN0_AERO(:,:,3)
735
736    PFLUX(:,1,:) =  LWUP_AERO(:,:,3)
737    PFLUX(:,2,:) =  LWDN_AERO(:,:,3)
738    PFLUC(:,1,:) =  LWUP0_AERO(:,:,3)
739    PFLUC(:,2,:) =  LWDN0_AERO(:,:,3)
740  ENDIF
741
742  IF ( (.not. ok_ade) .and. ok_aie  )  THEN
743    PFSUP(:,:) =    ZFSUP_AERO(:,:,2)
744    PFSDN(:,:) =    ZFSDN_AERO(:,:,2)
745    PFSCUP(:,:) =   ZFSUP0_AERO(:,:,2)
746    PFSCDN(:,:) =   ZFSDN0_AERO(:,:,2)
747
748    PFLUX(:,1,:) =  LWUP_AERO(:,:,2)
749    PFLUX(:,2,:) =  LWDN_AERO(:,:,2)
750    PFLUC(:,1,:) =  LWUP0_AERO(:,:,2)
751    PFLUC(:,2,:) =  LWDN0_AERO(:,:,2)
752  ENDiF
753
754  IF ((.not. ok_ade) .and. (.not. ok_aie)) THEN
755    PFSUP(:,:) =    ZFSUP_AERO(:,:,1)
756    PFSDN(:,:) =    ZFSDN_AERO(:,:,1)
757    PFSCUP(:,:) =   ZFSUP0_AERO(:,:,1)
758    PFSCDN(:,:) =   ZFSDN0_AERO(:,:,1)
759
760    PFLUX(:,1,:) =  LWUP_AERO(:,:,1)
761    PFLUX(:,2,:) =  LWDN_AERO(:,:,1)
762    PFLUC(:,1,:) =  LWUP0_AERO(:,:,1)
763    PFLUC(:,2,:) =  LWDN0_AERO(:,:,1)
764  ENDIF
765
766! The following allows to compute the forcing diagostics without
767! letting the aerosol forcing act on the meteorology
768! SEE logic above
769
770ELSE  !--not AEROSOLFEEDBACK_ACTIVE
771
772    PFSUP(:,:) =    ZFSUP_AERO(:,:,5)
773    PFSDN(:,:) =    ZFSDN_AERO(:,:,5)
774    PFSCUP(:,:) =   ZFSUP0_AERO(:,:,5)
775    PFSCDN(:,:) =   ZFSDN0_AERO(:,:,5)
776
777    PFLUX(:,1,:) =  LWUP_AERO(:,:,5)
778    PFLUX(:,2,:) =  LWDN_AERO(:,:,5)
779    PFLUC(:,1,:) =  LWUP0_AERO(:,:,5)
780    PFLUC(:,2,:) =  LWDN0_AERO(:,:,5)
781
782ENDIF
783
784IF (swaerofree_diag) THEN
785! copy shortwave clear-sky clean (no aerosol) case
786  PFSCCUP(:,:) =   ZFSUP0_AERO(:,:,5)
787  PFSCCDN(:,:) =   ZFSDN0_AERO(:,:,5)
788! copy longwave clear-sky clean (no aerosol) case
789  PFLCCUP(:,:) =   LWUP0_AERO(:,:,5)
790  PFLCCDN(:,:) =   LWDN0_AERO(:,:,5)
791ENDIF
792
793!OB- HERE CHECK WITH MP IF BOTTOM AND TOP INDICES ARE OK !!!!!!!!!!!!!!!!!!
794! net anthropogenic forcing direct and 1st indirect effect diagnostics
795! requires a natural aerosol field read and used
796! Difference of net fluxes from double call to radiation
797! Will need to be extended to LW radiation -> done by CK (2014-05-23)
798
799IF (flag_aerosol .GT. 0 .OR. flag_aerosol_strat) THEN
800
801IF (ok_ade.AND.ok_aie) THEN
802
803! direct anthropogenic forcing
804     PSOLSWADAERO(:)  = (ZFSDN_AERO(:,1,4)      -ZFSUP_AERO(:,1,4))      -(ZFSDN_AERO(:,1,2)      -ZFSUP_AERO(:,1,2))
805     PTOPSWADAERO(:)  = (ZFSDN_AERO(:,KLEV+1,4) -ZFSUP_AERO(:,KLEV+1,4)) -(ZFSDN_AERO(:,KLEV+1,2) -ZFSUP_AERO(:,KLEV+1,2))
806     PSOLSWAD0AERO(:) = (ZFSDN0_AERO(:,1,4)     -ZFSUP0_AERO(:,1,4))     -(ZFSDN0_AERO(:,1,2)     -ZFSUP0_AERO(:,1,2))
807     PTOPSWAD0AERO(:) = (ZFSDN0_AERO(:,KLEV+1,4)-ZFSUP0_AERO(:,KLEV+1,4))-(ZFSDN0_AERO(:,KLEV+1,2)-ZFSUP0_AERO(:,KLEV+1,2))
808
809! indirect anthropogenic forcing
810     PSOLSWAIAERO(:) = (ZFSDN_AERO(:,1,4)     -ZFSUP_AERO(:,1,4))     -(ZFSDN_AERO(:,1,3)     -ZFSUP_AERO(:,1,3))
811     PTOPSWAIAERO(:) = (ZFSDN_AERO(:,KLEV+1,4)-ZFSUP_AERO(:,KLEV+1,4))-(ZFSDN_AERO(:,KLEV+1,3)-ZFSUP_AERO(:,KLEV+1,3))
812
813! Cloud radiative forcing with natural aerosol for direct effect
814     PSOLSWCFAERO(:,1) = (ZFSDN_AERO(:,1,2)     -ZFSUP_AERO(:,1,2))     -(ZFSDN0_AERO(:,1,2)     -ZFSUP0_AERO(:,1,2))
815     PTOPSWCFAERO(:,1) = (ZFSDN_AERO(:,KLEV+1,2)-ZFSUP_AERO(:,KLEV+1,2))-(ZFSDN0_AERO(:,KLEV+1,2)-ZFSUP0_AERO(:,KLEV+1,2))
816! Cloud radiative forcing with anthropogenic aerosol for direct effect
817     PSOLSWCFAERO(:,2) = (ZFSDN_AERO(:,1,4)     -ZFSUP_AERO(:,1,4))     -(ZFSDN0_AERO(:,1,4)     -ZFSUP0_AERO(:,1,4))
818     PTOPSWCFAERO(:,2) = (ZFSDN_AERO(:,KLEV+1,4)-ZFSUP_AERO(:,KLEV+1,4))-(ZFSDN0_AERO(:,KLEV+1,4)-ZFSUP0_AERO(:,KLEV+1,4))
819! Cloud radiative forcing with no direct effect at all
820     PSOLSWCFAERO(:,3) = 0.0
821     PTOPSWCFAERO(:,3) = 0.0
822
823! LW direct anthropogenic forcing
824     PSOLLWADAERO(:)  = (-LWDN_AERO(:,1,4)      -LWUP_AERO(:,1,4))      -(-LWDN_AERO(:,1,2)      -LWUP_AERO(:,1,2))
825     PTOPLWADAERO(:)  = (-LWDN_AERO(:,KLEV+1,4) -LWUP_AERO(:,KLEV+1,4)) -(-LWDN_AERO(:,KLEV+1,2) -LWUP_AERO(:,KLEV+1,2))
826     PSOLLWAD0AERO(:) = (-LWDN0_AERO(:,1,4)     -LWUP0_AERO(:,1,4))     -(-LWDN0_AERO(:,1,2)     -LWUP0_AERO(:,1,2))
827     PTOPLWAD0AERO(:) = (-LWDN0_AERO(:,KLEV+1,4)-LWUP0_AERO(:,KLEV+1,4))-(-LWDN0_AERO(:,KLEV+1,2)-LWUP0_AERO(:,KLEV+1,2))
828
829! LW indirect anthropogenic forcing
830     PSOLLWAIAERO(:) = (-LWDN_AERO(:,1,4)     -LWUP_AERO(:,1,4))     -(-LWDN_AERO(:,1,3)     -LWUP_AERO(:,1,3))
831     PTOPLWAIAERO(:) = (-LWDN_AERO(:,KLEV+1,4)-LWUP_AERO(:,KLEV+1,4))-(-LWDN_AERO(:,KLEV+1,3)-LWUP_AERO(:,KLEV+1,3))
832
833ENDIF
834
835IF (ok_ade.AND..NOT.ok_aie) THEN
836
837! direct anthropogenic forcing
838     PSOLSWADAERO(:)  = (ZFSDN_AERO(:,1,3)      -ZFSUP_AERO(:,1,3))      -(ZFSDN_AERO(:,1,1)      -ZFSUP_AERO(:,1,1))
839     PTOPSWADAERO(:)  = (ZFSDN_AERO(:,KLEV+1,3) -ZFSUP_AERO(:,KLEV+1,3)) -(ZFSDN_AERO(:,KLEV+1,1) -ZFSUP_AERO(:,KLEV+1,1))
840     PSOLSWAD0AERO(:) = (ZFSDN0_AERO(:,1,3)     -ZFSUP0_AERO(:,1,3))     -(ZFSDN0_AERO(:,1,1)     -ZFSUP0_AERO(:,1,1))
841     PTOPSWAD0AERO(:) = (ZFSDN0_AERO(:,KLEV+1,3)-ZFSUP0_AERO(:,KLEV+1,3))-(ZFSDN0_AERO(:,KLEV+1,1)-ZFSUP0_AERO(:,KLEV+1,1))
842
843! indirect anthropogenic forcing
844     PSOLSWAIAERO(:) = 0.0
845     PTOPSWAIAERO(:) = 0.0
846
847! Cloud radiative forcing with natural aerosol for direct effect
848     PSOLSWCFAERO(:,1) = (ZFSDN_AERO(:,1,1)     -ZFSUP_AERO(:,1,1))     -(ZFSDN0_AERO(:,1,1)     -ZFSUP0_AERO(:,1,1))
849     PTOPSWCFAERO(:,1) = (ZFSDN_AERO(:,KLEV+1,1)-ZFSUP_AERO(:,KLEV+1,1))-(ZFSDN0_AERO(:,KLEV+1,1)-ZFSUP0_AERO(:,KLEV+1,1))
850! Cloud radiative forcing with anthropogenic aerosol for direct effect
851     PSOLSWCFAERO(:,2) = (ZFSDN_AERO(:,1,3)     -ZFSUP_AERO(:,1,3))     -(ZFSDN0_AERO(:,1,3)     -ZFSUP0_AERO(:,1,3))
852     PTOPSWCFAERO(:,2) = (ZFSDN_AERO(:,KLEV+1,3)-ZFSUP_AERO(:,KLEV+1,3))-(ZFSDN0_AERO(:,KLEV+1,3)-ZFSUP0_AERO(:,KLEV+1,3))
853! Cloud radiative forcing with no direct effect at all
854     PSOLSWCFAERO(:,3) = 0.0
855     PTOPSWCFAERO(:,3) = 0.0
856
857! LW direct anthropogenic forcing
858     PSOLLWADAERO(:)  = (-LWDN_AERO(:,1,3)      -LWUP_AERO(:,1,3))      -(-LWDN_AERO(:,1,1)      -LWUP_AERO(:,1,1))
859     PTOPLWADAERO(:)  = (-LWDN_AERO(:,KLEV+1,3) -LWUP_AERO(:,KLEV+1,3)) -(-LWDN_AERO(:,KLEV+1,1) -LWUP_AERO(:,KLEV+1,1))
860     PSOLLWAD0AERO(:) = (-LWDN0_AERO(:,1,3)     -LWUP0_AERO(:,1,3))     -(-LWDN0_AERO(:,1,1)     -LWUP0_AERO(:,1,1))
861     PTOPLWAD0AERO(:) = (-LWDN0_AERO(:,KLEV+1,3)-LWUP0_AERO(:,KLEV+1,3))-(-LWDN0_AERO(:,KLEV+1,1)-LWUP0_AERO(:,KLEV+1,1))
862
863! LW indirect anthropogenic forcing
864     PSOLLWAIAERO(:) = 0.0
865     PTOPLWAIAERO(:) = 0.0
866
867ENDIF
868
869IF (.NOT.ok_ade.AND.ok_aie) THEN
870
871! direct anthropogenic forcing
872     PSOLSWADAERO(:)  = 0.0
873     PTOPSWADAERO(:)  = 0.0
874     PSOLSWAD0AERO(:) = 0.0
875     PTOPSWAD0AERO(:) = 0.0
876
877! indirect anthropogenic forcing
878     PSOLSWAIAERO(:) = (ZFSDN_AERO(:,1,2)     -ZFSUP_AERO(:,1,2))     -(ZFSDN_AERO(:,1,1)     -ZFSUP_AERO(:,1,1))
879     PTOPSWAIAERO(:) = (ZFSDN_AERO(:,KLEV+1,2)-ZFSUP_AERO(:,KLEV+1,2))-(ZFSDN_AERO(:,KLEV+1,1)-ZFSUP_AERO(:,KLEV+1,1))
880
881! Cloud radiative forcing with natural aerosol for direct effect
882     PSOLSWCFAERO(:,1) = (ZFSDN_AERO(:,1,2)     -ZFSUP_AERO(:,1,2))     -(ZFSDN0_AERO(:,1,2)     -ZFSUP0_AERO(:,1,2))
883     PTOPSWCFAERO(:,1) = (ZFSDN_AERO(:,KLEV+1,2)-ZFSUP_AERO(:,KLEV+1,2))-(ZFSDN0_AERO(:,KLEV+1,2)-ZFSUP0_AERO(:,KLEV+1,2))
884! Cloud radiative forcing with anthropogenic aerosol for direct effect
885     PSOLSWCFAERO(:,2) = 0.0
886     PTOPSWCFAERO(:,2) = 0.0
887! Cloud radiative forcing with no direct effect at all
888     PSOLSWCFAERO(:,3) = 0.0
889     PTOPSWCFAERO(:,3) = 0.0
890
891! LW direct anthropogenic forcing
892     PSOLLWADAERO(:)  = 0.0
893     PTOPLWADAERO(:)  = 0.0
894     PSOLLWAD0AERO(:) = 0.0
895     PTOPLWAD0AERO(:) = 0.0
896
897! LW indirect anthropogenic forcing
898     PSOLLWAIAERO(:) = (-LWDN_AERO(:,1,2)     -LWUP_AERO(:,1,2))     -(-LWDN_AERO(:,1,1)     -LWUP_AERO(:,1,1))
899     PTOPLWAIAERO(:) = (-LWDN_AERO(:,KLEV+1,2)-LWUP_AERO(:,KLEV+1,2))-(-LWDN_AERO(:,KLEV+1,1)-LWUP_AERO(:,KLEV+1,1))
900
901ENDIF
902
903IF (.NOT.ok_ade.AND..NOT.ok_aie) THEN
904
905! direct anthropogenic forcing
906     PSOLSWADAERO(:)  = 0.0
907     PTOPSWADAERO(:)  = 0.0
908     PSOLSWAD0AERO(:) = 0.0
909     PTOPSWAD0AERO(:) = 0.0
910
911! indirect anthropogenic forcing
912     PSOLSWAIAERO(:) = 0.0
913     PTOPSWAIAERO(:) = 0.0
914
915! Cloud radiative forcing with natural aerosol for direct effect
916     PSOLSWCFAERO(:,1) = (ZFSDN_AERO(:,1,1)     -ZFSUP_AERO(:,1,1))     -(ZFSDN0_AERO(:,1,1)     -ZFSUP0_AERO(:,1,1))
917     PTOPSWCFAERO(:,1) = (ZFSDN_AERO(:,KLEV+1,1)-ZFSUP_AERO(:,KLEV+1,1))-(ZFSDN0_AERO(:,KLEV+1,1)-ZFSUP0_AERO(:,KLEV+1,1))
918! Cloud radiative forcing with anthropogenic aerosol for direct effect
919     PSOLSWCFAERO(:,2) = 0.0
920     PTOPSWCFAERO(:,2) = 0.0
921! Cloud radiative forcing with no direct effect at all
922     PSOLSWCFAERO(:,3) = 0.0
923     PTOPSWCFAERO(:,3) = 0.0
924
925! LW direct anthropogenic forcing
926     PSOLLWADAERO(:)  = 0.0
927     PTOPLWADAERO(:)  = 0.0
928     PSOLLWAD0AERO(:) = 0.0
929     PTOPLWAD0AERO(:) = 0.0
930
931! LW indirect anthropogenic forcing
932     PSOLLWAIAERO(:) = 0.0
933     PTOPLWAIAERO(:) = 0.0
934
935ENDIF
936
937ENDIF
938
939!IF (swaero_diag .OR. .NOT. AEROSOLFEEDBACK_ACTIVE) THEN
940IF (.NOT. AEROSOLFEEDBACK_ACTIVE) THEN
941! Cloudforcing without aerosol at all
942     PSOLSWCFAERO(:,3) = (ZFSDN_AERO(:,1,5)     -ZFSUP_AERO(:,1,5))     -(ZFSDN0_AERO(:,1,5)     -ZFSUP0_AERO(:,1,5))
943     PTOPSWCFAERO(:,3) = (ZFSDN_AERO(:,KLEV+1,5)-ZFSUP_AERO(:,KLEV+1,5))-(ZFSDN0_AERO(:,KLEV+1,5)-ZFSUP0_AERO(:,KLEV+1,5))
944
945ENDIF
946
947IF (LHOOK) CALL DR_HOOK('RECMWF_AERO',1,ZHOOK_HANDLE)
948END SUBROUTINE RECMWF_AERO
Note: See TracBrowser for help on using the repository browser.