source: LMDZ6/branches/contrails/libf/phylmd/phys_state_var_mod.F90 @ 5456

Last change on this file since 5456 was 5452, checked in by aborella, 28 hours ago

First implementation of the contrails parameterisation
Lacks the emission of H2O + the impact on radiative transfer

  • 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:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 37.4 KB
Line 
1!
2! $Id: phys_state_var_mod.F90 5452 2024-12-23 17:12:29Z aborella $
3!
4      MODULE phys_state_var_mod
5! Variables sauvegardees pour le startphy.nc
6!======================================================================
7!
8!
9!======================================================================
10! Declaration des variables
11      USE dimphy
12      USE netcdf, only: nf90_fill_real
13      INTEGER, PARAMETER :: nlevSTD=17
14      INTEGER, PARAMETER :: nlevSTD8=8
15      INTEGER, PARAMETER :: nlevSTD3=3
16      INTEGER, PARAMETER :: nout=3
17      INTEGER, PARAMETER :: napisccp=1
18      INTEGER, SAVE :: radpas  ! radiation is called every "radpas" step
19      INTEGER, SAVE :: cvpas   ! convection is called every "cvpas" step
20      INTEGER, SAVE :: cvpas_0 = 1 ! reference value for cvpas
21      INTEGER, SAVE :: wkpas   ! wake scheme is called every "wkpas" step
22      REAL, PARAMETER :: missing_val_nf90=nf90_fill_real
23!$OMP THREADPRIVATE(radpas)
24!$OMP THREADPRIVATE(cvpas)
25!$OMP THREADPRIVATE(cvpas_0)
26!$OMP THREADPRIVATE(wkpas)
27      REAL, SAVE :: phys_tstep=0, solaire_etat0
28!$OMP THREADPRIVATE(phys_tstep, solaire_etat0)
29
30      REAL, ALLOCATABLE, SAVE :: pctsrf(:,:)
31!$OMP THREADPRIVATE(pctsrf)
32      REAL, ALLOCATABLE, SAVE :: ftsol(:,:)
33!$OMP THREADPRIVATE(ftsol)
34      REAL, ALLOCATABLE, SAVE :: beta_aridity(:,:)
35!$OMP THREADPRIVATE(beta_aridity)
36      REAL,ALLOCATABLE,SAVE :: qsol(:),fevap(:,:),z0m(:,:),z0h(:,:),agesno(:,:)
37!$OMP THREADPRIVATE(qsol,fevap,z0m,z0h,agesno)
38!FC drag des arbres
39      REAL, ALLOCATABLE, SAVE :: treedrg(:,:,:)
40!$OMP THREADPRIVATE(treedrg)
41
42!      character(len=6), SAVE :: ocean
43!!!!!!$OMP THREADPRIVATE(ocean)
44!      logical, SAVE :: ok_veget
45!!!!!!$OMP THREADPRIVATE(ok_veget)
46      REAL, ALLOCATABLE, SAVE :: falb1(:,:), falb2(:,:)
47!$OMP THREADPRIVATE(falb1, falb2)
48
49!albedo SB >>>
50      REAL, ALLOCATABLE, SAVE :: falb_dif(:,:,:), falb_dir(:,:,:)
51      REAL, ALLOCATABLE, SAVE :: chl_con(:)
52!$OMP THREADPRIVATE(falb_dir,falb_dif,chl_con)
53!albedo SB <<<
54
55
56      REAL, ALLOCATABLE, SAVE :: rain_fall(:), snow_fall(:), bs_fall(:)
57!$OMP THREADPRIVATE( rain_fall, snow_fall, bs_fall)
58      REAL, ALLOCATABLE, SAVE :: solsw(:), solswfdiff(:), sollw(:)
59!$OMP THREADPRIVATE(solsw, solswfdiff, sollw)
60      REAL, ALLOCATABLE, SAVE :: radsol(:)
61!$OMP THREADPRIVATE(radsol)
62      REAL, ALLOCATABLE, SAVE :: swradcorr(:)
63!$OMP THREADPRIVATE(swradcorr)
64#ifdef ISO
65      REAL,ALLOCATABLE,SAVE :: xtsol(:,:),fxtevap(:,:,:)
66!$OMP THREADPRIVATE(xtsol,fxtevap)
67      REAL, ALLOCATABLE, SAVE :: xtrain_fall(:,:), xtsnow_fall(:,:)
68!$OMP THREADPRIVATE(xtrain_fall,xtsnow_fall)
69#endif
70
71!clesphy0 param physiq
72!
73! Parametres de l'Orographie a l'Echelle Sous-Maille (OESM):
74!
75      REAL, ALLOCATABLE, SAVE :: zmea(:), zstd(:), zsig(:), zgam(:)
76!$OMP THREADPRIVATE(zmea, zstd, zsig, zgam)
77      REAL, ALLOCATABLE, SAVE :: zthe(:), zpic(:), zval(:)
78!$OMP THREADPRIVATE(zthe, zpic, zval)
79!     REAL tabcntr0(100)
80      REAL, ALLOCATABLE, SAVE :: rugoro(:)
81!$OMP THREADPRIVATE(rugoro)
82      REAL, ALLOCATABLE, SAVE :: t_ancien(:,:), q_ancien(:,:)
83!$OMP THREADPRIVATE(t_ancien, q_ancien)
84      REAL, ALLOCATABLE, SAVE :: ql_ancien(:,:), qs_ancien(:,:), qbs_ancien(:,:)
85!$OMP THREADPRIVATE(ql_ancien, qs_ancien, qbs_ancien)
86      REAL, ALLOCATABLE, SAVE :: prw_ancien(:), prlw_ancien(:), prsw_ancien(:), prbsw_ancien(:)
87!$OMP THREADPRIVATE(prw_ancien, prlw_ancien, prsw_ancien, prbsw_ancien)
88#ifdef ISO
89      REAL, ALLOCATABLE, SAVE :: xt_ancien(:,:,:),xtl_ancien(:,:,:),xts_ancien(:,:,:), xtbs_ancien(:,:,:)
90!$OMP THREADPRIVATE(xt_ancien,xtl_ancien,xts_ancien,xtbs_ancien)
91#endif
92      REAL, ALLOCATABLE, SAVE :: u_ancien(:,:), v_ancien(:,:)
93!$OMP THREADPRIVATE(u_ancien, v_ancien)
94      REAL, ALLOCATABLE, SAVE :: cf_ancien(:,:), rvc_ancien(:,:), rcont_ancien(:,:)
95!$OMP THREADPRIVATE(cf_ancien, rvc_ancien, rcont_ancien)
96!!! RomP >>>
97      REAL, ALLOCATABLE, SAVE :: tr_ancien(:,:,:)
98!$OMP THREADPRIVATE(tr_ancien)
99!!! RomP <<<
100      LOGICAL, SAVE :: ancien_ok
101!$OMP THREADPRIVATE(ancien_ok)
102      REAL, ALLOCATABLE, SAVE :: clwcon(:,:),rnebcon(:,:)
103!$OMP THREADPRIVATE(clwcon,rnebcon)
104      REAL, ALLOCATABLE, SAVE :: qtc_cv(:,:),sigt_cv(:,:),detrain_cv(:,:),fm_cv(:,:)
105!$OMP THREADPRIVATE(qtc_cv,sigt_cv,detrain_cv,fm_cv)
106      REAL, ALLOCATABLE, SAVE :: ratqs(:,:)
107!$OMP THREADPRIVATE(ratqs)
108      REAL, ALLOCATABLE, SAVE :: pbl_tke(:,:,:) ! turb kinetic energy
109      REAL, ALLOCATABLE, SAVE :: coefh(:,:,:) ! Kz enthalpie
110      REAL, ALLOCATABLE, SAVE :: coefm(:,:,:) ! Kz momentum
111!$OMP THREADPRIVATE(pbl_tke, coefh,coefm)
112      REAL, ALLOCATABLE, SAVE :: zmax0(:), f0(:) !
113!$OMP THREADPRIVATE(zmax0,f0)
114      REAL, ALLOCATABLE, SAVE :: sig1(:,:), w01(:,:)
115!$OMP THREADPRIVATE(sig1,w01)
116      REAL, ALLOCATABLE, SAVE :: entr_therm(:,:), fm_therm(:,:)
117!$OMP THREADPRIVATE(entr_therm,fm_therm)
118      REAL, ALLOCATABLE, SAVE :: detr_therm(:,:)
119!$OMP THREADPRIVATE(detr_therm)
120!IM 150408
121!     pour phsystoke avec thermiques
122      REAL,ALLOCATABLE,SAVE :: clwcon0th(:,:),rnebcon0th(:,:)
123!$OMP THREADPRIVATE(clwcon0th,rnebcon0th)
124! radiation outputs
125      REAL,ALLOCATABLE,SAVE :: swdnc0(:,:), swdn0(:,:), swdn(:,:)
126!$OMP THREADPRIVATE(swdnc0,swdn0,swdn)
127      REAL,ALLOCATABLE,SAVE :: swupc0(:,:), swup0(:,:), swup(:,:)
128!$OMP THREADPRIVATE(swupc0, swup0,swup)
129      REAL,ALLOCATABLE,SAVE :: SWdn200clr(:), SWdn200(:)
130!$OMP THREADPRIVATE(SWdn200clr,SWdn200)
131      REAL,ALLOCATABLE,SAVE :: SWup200clr(:), SWup200(:)
132!$OMP THREADPRIVATE(SWup200clr,SWup200)
133      REAL,ALLOCATABLE,SAVE :: lwdnc0(:,:), lwdn0(:,:), lwdn(:,:)
134!$OMP THREADPRIVATE(lwdnc0,lwdn0,lwdn)
135      REAL,ALLOCATABLE,SAVE :: lwupc0(:,:), lwup0(:,:), lwup(:,:)
136!$OMP THREADPRIVATE(lwupc0,lwup0,lwup)
137      REAL,ALLOCATABLE,SAVE :: LWdn200clr(:), LWdn200(:)
138!$OMP THREADPRIVATE(LWdn200clr,LWdn200)
139      REAL,ALLOCATABLE,SAVE :: LWup200clr(:), LWup200(:)
140!$OMP THREADPRIVATE(LWup200clr,LWup200)
141      REAL,ALLOCATABLE,SAVE :: LWdnTOA(:), LWdnTOAclr(:)
142!$OMP THREADPRIVATE(LWdnTOA,LWdnTOAclr)
143! pressure level
144      REAL,ALLOCATABLE,SAVE :: tsumSTD(:,:,:)
145!$OMP THREADPRIVATE(tsumSTD)
146      REAL,ALLOCATABLE,SAVE :: usumSTD(:,:,:), vsumSTD(:,:,:)
147!$OMP THREADPRIVATE(usumSTD,vsumSTD)
148      REAL,ALLOCATABLE,SAVE :: wsumSTD(:,:,:), phisumSTD(:,:,:)
149!$OMP THREADPRIVATE(wsumSTD,phisumSTD)
150      REAL,ALLOCATABLE,SAVE :: qsumSTD(:,:,:), rhsumSTD(:,:,:)
151!$OMP THREADPRIVATE(qsumSTD,rhsumSTD)
152      REAL,ALLOCATABLE,SAVE :: tnondef(:,:,:)
153!$OMP THREADPRIVATE(tnondef)
154      REAL,ALLOCATABLE,SAVE :: uvsumSTD(:,:,:)
155!$OMP THREADPRIVATE(uvsumSTD)
156      REAL,ALLOCATABLE,SAVE :: vqsumSTD(:,:,:)
157!$OMP THREADPRIVATE(vqsumSTD)
158      REAL,ALLOCATABLE,SAVE :: vTsumSTD(:,:,:)
159!$OMP THREADPRIVATE(vTsumSTD)
160      REAL,ALLOCATABLE,SAVE :: wqsumSTD(:,:,:)
161!$OMP THREADPRIVATE(wqsumSTD)
162      REAL,ALLOCATABLE,SAVE :: vphisumSTD(:,:,:)
163!$OMP THREADPRIVATE(vphisumSTD)
164      REAL,ALLOCATABLE,SAVE :: wTsumSTD(:,:,:)
165!$OMP THREADPRIVATE(wTsumSTD)
166      REAL,ALLOCATABLE,SAVE :: u2sumSTD(:,:,:)
167!$OMP THREADPRIVATE(u2sumSTD)
168      REAL,ALLOCATABLE,SAVE :: v2sumSTD(:,:,:)
169!$OMP THREADPRIVATE(v2sumSTD)
170      REAL,ALLOCATABLE,SAVE :: T2sumSTD(:,:,:)
171!$OMP THREADPRIVATE(T2sumSTD)
172      REAL,ALLOCATABLE,SAVE :: O3sumSTD(:,:,:), O3daysumSTD(:,:,:)
173!$OMP THREADPRIVATE(O3sumSTD,O3daysumSTD)
174!IM begin
175      REAL,ALLOCATABLE,SAVE :: wlevSTD(:,:), ulevSTD(:,:), vlevSTD(:,:)
176!$OMP THREADPRIVATE(wlevSTD,ulevSTD,vlevSTD)
177      REAL,ALLOCATABLE,SAVE :: tlevSTD(:,:), qlevSTD(:,:), rhlevSTD(:,:)
178!$OMP THREADPRIVATE(tlevSTD,qlevSTD,rhlevSTD)
179      REAL,ALLOCATABLE,SAVE :: philevSTD(:,:)
180!$OMP THREADPRIVATE(philevSTD)
181      REAL,ALLOCATABLE,SAVE :: uvSTD(:,:)
182!$OMP THREADPRIVATE(uvSTD)
183      REAL,ALLOCATABLE,SAVE :: vqSTD(:,:)
184!$OMP THREADPRIVATE(vqSTD)
185      REAL,ALLOCATABLE,SAVE :: vTSTD(:,:)
186!$OMP THREADPRIVATE(vTSTD)
187      REAL,ALLOCATABLE,SAVE :: wqSTD(:,:)
188!$OMP THREADPRIVATE(wqSTD)
189      REAL,ALLOCATABLE,SAVE :: vphiSTD(:,:)
190!$OMP THREADPRIVATE(vphiSTD)
191      REAL,ALLOCATABLE,SAVE :: wTSTD(:,:)
192!$OMP THREADPRIVATE(wTSTD)
193      REAL,ALLOCATABLE,SAVE :: u2STD(:,:)
194!$OMP THREADPRIVATE(u2STD)
195      REAL,ALLOCATABLE,SAVE :: v2STD(:,:)
196!$OMP THREADPRIVATE(v2STD)
197      REAL,ALLOCATABLE,SAVE :: T2STD(:,:)
198!$OMP THREADPRIVATE(T2STD)
199      REAL,ALLOCATABLE,SAVE :: O3STD(:,:), O3daySTD(:,:)
200!$OMP THREADPRIVATE(O3STD,O3daySTD)
201!IM end
202      INTEGER,ALLOCATABLE,SAVE :: seed_old(:,:)
203!$OMP THREADPRIVATE(seed_old)
204      REAL,ALLOCATABLE,SAVE :: zuthe(:),zvthe(:)
205!$OMP THREADPRIVATE(zuthe,zvthe)
206      REAL,ALLOCATABLE,SAVE :: alb_neig(:)
207!$OMP THREADPRIVATE(alb_neig)
208!cloud base mass flux
209      REAL,ALLOCATABLE,SAVE :: ema_cbmf(:)
210!$OMP THREADPRIVATE(ema_cbmf)
211!cloud base pressure & cloud top pressure
212      REAL,ALLOCATABLE,SAVE :: ema_pcb(:), ema_pct(:)
213!$OMP THREADPRIVATE(ema_pcb,ema_pct)
214      REAL,ALLOCATABLE,SAVE :: Mipsh(:,:)     ! mass flux shed from  adiab. ascents
215!$OMP THREADPRIVATE(Mipsh)
216      REAL,ALLOCATABLE,SAVE :: Ma(:,:)       ! undilute upward mass flux
217!$OMP THREADPRIVATE(Ma)
218      REAL,ALLOCATABLE,SAVE :: qcondc(:,:)    ! in-cld water content from convect
219!$OMP THREADPRIVATE(qcondc)
220      REAL,ALLOCATABLE,SAVE :: wd(:) ! sb
221!$OMP THREADPRIVATE(wd)
222      REAL,ALLOCATABLE,SAVE :: sigd(:)
223!$OMP THREADPRIVATE(sigd)
224!
225      REAL,ALLOCATABLE,SAVE :: cin(:)
226!$OMP THREADPRIVATE(cin)
227! ftd : convective heating due to unsaturated downdraughts
228      REAL,ALLOCATABLE,SAVE :: ftd(:,:)
229!$OMP THREADPRIVATE(ftd)
230! fqd : convective moistening due to unsaturated downdraughts
231      REAL,ALLOCATABLE,SAVE :: fqd(:,:),fqcomp(:,:)     
232!$OMP THREADPRIVATE(fqd,fqcomp)
233#ifdef ISO
234      REAL, ALLOCATABLE, SAVE :: fxtd(:,:,:)
235!$OMP THREADPRIVATE(fxtd)
236#endif
237!34EK
238! -- Variables de controle de ALE et ALP
239!ALE : Energie disponible pour soulevement : utilisee par la
240!      convection d'Emanuel pour le declenchement et la regulation
241      REAL,ALLOCATABLE,SAVE :: ALE(:)
242!$OMP THREADPRIVATE(ALE)
243!ALP : Puissance  disponible pour soulevement
244      REAL,ALLOCATABLE,SAVE :: ALP(:)
245!$OMP THREADPRIVATE(ALP)
246!
247! nouvelles variables pour le couplage convection-couche limite
248      REAL,ALLOCATABLE,SAVE :: Ale_bl(:)
249!$OMP THREADPRIVATE(Ale_bl)
250      REAL,ALLOCATABLE,SAVE :: Alp_bl(:)
251!$OMP THREADPRIVATE(Alp_bl)
252      INTEGER,ALLOCATABLE,SAVE :: lalim_conv(:)
253!$OMP THREADPRIVATE(lalim_conv)
254      REAL,ALLOCATABLE,SAVE :: wght_th(:,:)
255!$OMP THREADPRIVATE(wght_th)
256      REAL,ALLOCATABLE,SAVE    :: ale_wake(:)
257!$OMP THREADPRIVATE(ale_wake)
258      REAL,ALLOCATABLE,SAVE    :: ale_bl_stat(:)
259!$OMP THREADPRIVATE(ale_bl_stat)
260!
261! variables de la wake
262! wake_deltat : ecart de temperature avec la zone non perturbee
263! wake_deltaq : ecart d'humidite avec la zone non perturbee
264! wake_s      : fraction surfacique occupee par la poche froide
265! awake_s     : surface fraction covered by active wakes
266! wake_dens   : number of wakes per unit area
267! awake_dens  : number of active wakes per unit area
268! cv_gen      : birth rate of cumulonimbus per unit area.
269! wake_occ    : occurence of wakes (= 1 if wakes occur, =0 otherwise)
270! wake_Cstar  : vitesse d'etalement de la poche
271! wake_pe     : wake potential energy - WAPE
272! wake_fip    : Gust Front Impinging power - ALP
273      REAL,ALLOCATABLE,SAVE :: wake_deltat(:,:)
274!$OMP THREADPRIVATE(wake_deltat)
275      REAL,ALLOCATABLE,SAVE :: wake_deltaq(:,:)
276!$OMP THREADPRIVATE(wake_deltaq)
277#ifdef ISO
278      REAL, ALLOCATABLE, SAVE :: wake_deltaxt(:,:,:)
279!$OMP THREADPRIVATE(wake_deltaxt)
280#endif
281      REAL,ALLOCATABLE,SAVE :: wake_s(:), awake_s(:)
282!$OMP THREADPRIVATE(wake_s, awake_s)
283      REAL,ALLOCATABLE,SAVE :: wake_dens(:), awake_dens(:)
284!$OMP THREADPRIVATE(wake_dens, awake_dens)
285      REAL,ALLOCATABLE,SAVE :: cv_gen(:)
286!$OMP THREADPRIVATE(cv_gen)
287      REAL,ALLOCATABLE,SAVE :: wake_Cstar(:)
288!$OMP THREADPRIVATE(wake_Cstar)
289      REAL,ALLOCATABLE,SAVE :: wake_pe(:)
290!$OMP THREADPRIVATE(wake_pe)
291      REAL,ALLOCATABLE,SAVE :: wake_fip(:)
292!$OMP THREADPRIVATE(wake_fip)
293!
294!jyg<
295! variables related to the spitting of the PBL between wake and
296! off-wake regions.
297! wake_delta_pbl_TKE : difference TKE_w - TKE_x
298      REAL,ALLOCATABLE,SAVE :: wake_delta_pbl_TKE(:,:,:)
299!$OMP THREADPRIVATE(wake_delta_pbl_TKE)
300!nrlmd<
301      REAL, ALLOCATABLE, SAVE :: delta_tsurf(:,:) ! Surface temperature difference inside-outside cold pool
302!$OMP THREADPRIVATE(delta_tsurf)
303!>nrlmd
304!>jyg
305!
306! pfrac_impa : Produits des coefs lessivage impaction
307! pfrac_nucl : Produits des coefs lessivage nucleation
308! pfrac_1nucl: Produits des coefs lessi nucl (alpha = 1)
309      REAL,ALLOCATABLE,SAVE :: pfrac_impa(:,:), pfrac_nucl(:,:)
310!$OMP THREADPRIVATE(pfrac_impa,pfrac_nucl)
311      REAL,ALLOCATABLE,SAVE :: pfrac_1nucl(:,:)
312!$OMP THREADPRIVATE(pfrac_1nucl)
313!
314      REAL,ALLOCATABLE,SAVE :: total_rain(:), nday_rain(:) 
315!$OMP THREADPRIVATE(total_rain,nday_rain)
316      REAL,ALLOCATABLE,SAVE :: ndayrain_mth(:)
317!$OMP THREADPRIVATE(ndayrain_mth)
318      REAL,ALLOCATABLE,SAVE :: paire_ter(:)
319!$OMP THREADPRIVATE(paire_ter)
320! albsol1: albedo du sol total pour SW visible
321! albsol2: albedo du sol total pour SW proche IR
322      REAL,ALLOCATABLE,SAVE :: albsol1(:), albsol2(:)
323!$OMP THREADPRIVATE(albsol1,albsol2)
324
325!albedo SB >>>
326      REAL,ALLOCATABLE,SAVE :: albsol_dif(:,:),albsol_dir(:,:)
327!$OMP THREADPRIVATE(albsol_dif,albsol_dir)
328!albedo SB <<<
329
330
331      REAL, ALLOCATABLE, SAVE:: wo(:, :, :)
332      ! column-density of ozone in a layer, in kilo-Dobsons
333      ! Third dimension has size 1 or 2.
334      ! "wo(:, :, 1)" is for the average day-night field,
335      ! "wo(:, :, 2)" is for daylight time.
336      !$OMP THREADPRIVATE(wo)
337
338! heat : chauffage solaire
339! heat0: chauffage solaire ciel clair
340! cool : refroidissement infrarouge
341! cool0 : refroidissement infrarouge ciel clair
342! sollwdown : downward LW flux at surface
343! sollwdownclr : downward CS LW flux at surface
344! toplwdown : downward CS LW flux at TOA
345! toplwdownclr : downward CS LW flux at TOA
346! heat_volc : chauffage solaire du au volcanisme
347! cool_volc : refroidissement infrarouge du au volcanisme
348      REAL,ALLOCATABLE,SAVE :: clwcon0(:,:),rnebcon0(:,:)
349!$OMP THREADPRIVATE(clwcon0,rnebcon0)
350      REAL,ALLOCATABLE,SAVE :: heat(:,:)   
351!$OMP THREADPRIVATE(heat)
352      REAL,ALLOCATABLE,SAVE :: heat0(:,:)
353!$OMP THREADPRIVATE(heat0)
354      REAL,ALLOCATABLE,SAVE :: cool(:,:)
355!$OMP THREADPRIVATE(cool)
356      REAL,ALLOCATABLE,SAVE :: cool0(:,:)
357!$OMP THREADPRIVATE(cool0)
358      REAL,ALLOCATABLE,SAVE :: heat_volc(:,:)   
359!$OMP THREADPRIVATE(heat_volc)
360      REAL,ALLOCATABLE,SAVE :: cool_volc(:,:)
361!$OMP THREADPRIVATE(cool_volc)
362      REAL,ALLOCATABLE,SAVE :: topsw(:), toplw(:)
363!$OMP THREADPRIVATE(topsw,toplw)
364      REAL,ALLOCATABLE,SAVE :: sollwdown(:)
365!$OMP THREADPRIVATE(sollwdown)
366      REAL,ALLOCATABLE,SAVE :: gustiness(:)
367!$OMP THREADPRIVATE(gustiness)
368      REAL,ALLOCATABLE,SAVE :: sollwdownclr(:)
369!$OMP THREADPRIVATE(sollwdownclr)
370      REAL,ALLOCATABLE,SAVE :: toplwdown(:)
371!$OMP THREADPRIVATE(toplwdown)
372      REAL,ALLOCATABLE,SAVE :: toplwdownclr(:)
373!$OMP THREADPRIVATE(toplwdownclr)
374      REAL,ALLOCATABLE,SAVE :: topsw0(:),toplw0(:),solsw0(:),sollw0(:)
375!$OMP THREADPRIVATE(topsw0,toplw0,solsw0,sollw0)
376      REAL,ALLOCATABLE,SAVE :: albpla(:)
377!$OMP THREADPRIVATE(albpla)
378
379!IM ajout variables CFMIP2/CMIP5
380      REAL,ALLOCATABLE,SAVE :: heatp(:,:), coolp(:,:)
381!$OMP THREADPRIVATE(heatp, coolp)
382      REAL,ALLOCATABLE,SAVE :: heat0p(:,:), cool0p(:,:)
383!$OMP THREADPRIVATE(heat0p, cool0p)
384      REAL,ALLOCATABLE,SAVE :: radsolp(:), topswp(:), toplwp(:)
385!$OMP THREADPRIVATE(radsolp, topswp, toplwp)
386      REAL,ALLOCATABLE,SAVE :: albplap(:)
387!$OMP THREADPRIVATE(albplap)
388      REAL,ALLOCATABLE,SAVE :: solswp(:), solswfdiffp(:), sollwp(:)
389!$OMP THREADPRIVATE(solswp, solswfdiffp, sollwp)
390      REAL,ALLOCATABLE,SAVE :: sollwdownp(:)
391!$OMP THREADPRIVATE(sollwdownp)
392      REAL,ALLOCATABLE,SAVE :: topsw0p(:),toplw0p(:)
393      REAL,ALLOCATABLE,SAVE :: solsw0p(:),sollw0p(:)
394!$OMP THREADPRIVATE(topsw0p,toplw0p,solsw0p,sollw0p)
395      REAL,ALLOCATABLE,SAVE :: lwdnc0p(:,:), lwdn0p(:,:), lwdnp(:,:)
396      REAL,ALLOCATABLE,SAVE :: lwupc0p(:,:), lwup0p(:,:), lwupp(:,:)
397!$OMP THREADPRIVATE(lwdnc0p, lwdn0p, lwdnp, lwupc0p, lwup0p, lwupp)
398      REAL,ALLOCATABLE,SAVE :: swdnc0p(:,:), swdn0p(:,:), swdnp(:,:)
399      REAL,ALLOCATABLE,SAVE :: swupc0p(:,:), swup0p(:,:), swupp(:,:)
400!$OMP THREADPRIVATE(swdnc0p, swdn0p, swdnp, swupc0p, swup0p, swupp)
401
402!AI ajout variables double appel Ecrad (3Deffect)
403      REAL,ALLOCATABLE,SAVE :: heat_s2(:,:), cool_s2(:,:)
404!$OMP THREADPRIVATE(heat_s2, cool_s2)
405      REAL,ALLOCATABLE,SAVE :: heat0_s2(:,:), cool0_s2(:,:)
406!$OMP THREADPRIVATE(heat0_s2, cool0_s2)
407      REAL,ALLOCATABLE,SAVE :: radsol_s2(:), topsw_s2(:), toplw_s2(:)
408!$OMP THREADPRIVATE(radsol_s2, topsw_s2, toplw_s2)
409      REAL,ALLOCATABLE,SAVE :: albpla_s2(:)
410!$OMP THREADPRIVATE(albpla_s2)
411      REAL,ALLOCATABLE,SAVE :: solsw_s2(:), solswfdiff_s2(:), sollw_s2(:)
412!$OMP THREADPRIVATE(solsw_s2, solswfdiff_s2, sollw_s2)
413      REAL,ALLOCATABLE,SAVE :: sollwdown_s2(:), sollwdownclr_s2(:)
414!$OMP THREADPRIVATE(sollwdown_s2, sollwdownclr_s2)
415      REAL,ALLOCATABLE,SAVE :: topsw0_s2(:),toplw0_s2(:)
416      REAL,ALLOCATABLE,SAVE :: solsw0_s2(:),sollw0_s2(:)
417!$OMP THREADPRIVATE(topsw0_s2,toplw0_s2,solsw0_s2,sollw0_s2)
418      REAL,ALLOCATABLE,SAVE :: lwdnc0_s2(:,:), lwdn0_s2(:,:), lwdn_s2(:,:)
419      REAL,ALLOCATABLE,SAVE :: lwupc0_s2(:,:), lwup0_s2(:,:), lwup_s2(:,:)
420!$OMP THREADPRIVATE(lwdnc0_s2,lwdn0_s2,lwdn_s2,lwupc0_s2,lwup0_s2,lwup_s2)       
421      REAL,ALLOCATABLE,SAVE :: swdnc0_s2(:,:), swdn0_s2(:,:), swdn_s2(:,:)
422      REAL,ALLOCATABLE,SAVE :: swupc0_s2(:,:), swup0_s2(:,:), swup_s2(:,:)
423!$OMP THREADPRIVATE(swdnc0_s2, swdn0_s2, swdn_s2, swupc0_s2, swup0_s2, swup_s2)
424
425! pbase : cloud base pressure
426! bbase : cloud base buoyancy
427      REAL,ALLOCATABLE,SAVE :: cape(:)
428!$OMP THREADPRIVATE(cape)
429      REAL,ALLOCATABLE,SAVE :: pbase(:)
430!$OMP THREADPRIVATE(pbase)
431      REAL,ALLOCATABLE,SAVE :: bbase(:)
432!$OMP THREADPRIVATE(bbase)
433!
434      REAL,SAVE,ALLOCATABLE :: zqasc(:,:)
435!$OMP THREADPRIVATE( zqasc)
436      INTEGER,ALLOCATABLE,SAVE :: ibas_con(:), itop_con(:)
437!$OMP THREADPRIVATE(ibas_con,itop_con)
438      REAL,SAVE,ALLOCATABLE :: rain_con(:)
439!$OMP THREADPRIVATE(rain_con)
440      REAL,SAVE,ALLOCATABLE :: snow_con(:)
441!$OMP THREADPRIVATE(snow_con)
442!
443#ifdef ISO
444      REAL,SAVE,ALLOCATABLE :: xtrain_con(:,:)
445!$OMP THREADPRIVATE(xtrain_con)
446      REAL,SAVE,ALLOCATABLE :: xtsnow_con(:,:)
447!$OMP THREADPRIVATE(xtsnow_con)
448#endif
449      REAL,SAVE,ALLOCATABLE :: rlonPOS(:)
450!$OMP THREADPRIVATE(rlonPOS)
451      REAL,SAVE,ALLOCATABLE :: newsst(:)
452!$OMP THREADPRIVATE(newsst)
453      REAL,SAVE,ALLOCATABLE :: ustar(:,:),u10m(:,:), v10m(:,:),wstar(:,:)
454!$OMP THREADPRIVATE(ustar,u10m,v10m,wstar)
455!
456! ok_ade=T -ADE=topswad-topsw
457! ok_aie=T ->
458!       ok_ade=T -AIE=topswai-topswad
459!       ok_ade=F -AIE=topswai-topsw
460!
461!topswad, solswad : Aerosol direct effect
462      REAL,SAVE,ALLOCATABLE :: topswad(:), solswad(:)
463!$OMP THREADPRIVATE(topswad,solswad)
464!topswai, solswai : Aerosol indirect effect
465      REAL,SAVE,ALLOCATABLE :: topswai(:), solswai(:)
466!$OMP THREADPRIVATE(topswai,solswai)
467
468      REAL,SAVE,ALLOCATABLE :: tau_aero(:,:,:,:), piz_aero(:,:,:,:), cg_aero(:,:,:,:)
469!$OMP THREADPRIVATE(tau_aero, piz_aero, cg_aero)
470      REAL,SAVE,ALLOCATABLE :: tau_aero_sw_rrtm(:,:,:,:), piz_aero_sw_rrtm(:,:,:,:), cg_aero_sw_rrtm(:,:,:,:)
471!$OMP THREADPRIVATE(tau_aero_sw_rrtm, piz_aero_sw_rrtm, cg_aero_sw_rrtm)
472      REAL,SAVE,ALLOCATABLE :: tau_aero_lw_rrtm(:,:,:,:), piz_aero_lw_rrtm(:,:,:,:), cg_aero_lw_rrtm(:,:,:,:)
473!$OMP THREADPRIVATE(tau_aero_lw_rrtm, piz_aero_lw_rrtm, cg_aero_lw_rrtm)
474      REAL,SAVE,ALLOCATABLE :: ccm(:,:,:)
475!$OMP THREADPRIVATE(ccm)
476
477      REAL,SAVE,ALLOCATABLE :: ale_bl_trig(:)
478!$OMP THREADPRIVATE(ale_bl_trig)
479
480      REAL,SAVE,ALLOCATABLE :: ratqs_inter_(:,:),sigma_qtherm(:,:)
481!$OMP THREADPRIVATE(ratqs_inter_,sigma_qtherm)
482
483#ifdef ISO
484#ifdef ISOTRAC
485      INTEGER,SAVE,ALLOCATABLE :: bassin_map(:)
486!$OMP THREADPRIVATE(bassin_map)
487      INTEGER,SAVE,ALLOCATABLE :: boite_map(:,:)
488!$OMP THREADPRIVATE(boite_map)
489#endif   
490#endif
491      REAL, ALLOCATABLE, SAVE:: du_gwd_rando(:, :), du_gwd_front(:, :)
492      !$OMP THREADPRIVATE(du_gwd_rando, du_gwd_front)
493      ! tendencies on wind due to gravity waves
494
495      LOGICAL,SAVE :: is_initialized=.FALSE.
496!$OMP THREADPRIVATE(is_initialized)   
497
498      ! Ocean-atmosphere interface:
499
500      REAL, ALLOCATABLE, SAVE:: ds_ns(:) ! (klon)
501      ! "delta salinity near surface". Salinity variation in the
502      ! near-surface turbulent layer. That is subskin salinity minus
503      ! foundation salinity. In ppt.
504
505      REAL, ALLOCATABLE, SAVE:: dt_ns(:) ! (klon)
506      ! "delta temperature near surface". Temperature variation in the
507      ! near-surface turbulent layer. That is subskin temperature
508      ! minus foundation temperature. (Can be negative.) In K.
509     
510      REAL, ALLOCATABLE, SAVE:: delta_sst(:) ! (klon)
511      ! Ocean-air interface temperature minus bulk SST, in
512      ! K. Allocated and defined only if activate_ocean_skin >= 1.
513
514      REAL, ALLOCATABLE, SAVE:: delta_sal(:) ! (klon)
515      ! Ocean-air interface salinity minus bulk salinity, in ppt
516     
517      REAL, ALLOCATABLE, SAVE:: dter(:) ! (klon)
518      ! Temperature variation in the diffusive microlayer, that is
519      ! ocean-air interface temperature minus subskin temperature. In K.
520
521      REAL, SAVE, ALLOCATABLE:: dser(:) ! (klon)
522      ! Salinity variation in the diffusive microlayer, that is
523      ! ocean-air interface salinity minus subskin salinity. In ppt.
524
525      real, SAVE, ALLOCATABLE:: dt_ds(:) ! (klon)
526      ! (tks / tkt) * dTer, in K
527
528      !$OMP THREADPRIVATE(delta_sal, ds_ns, dt_ns, delta_sst, dter, dser, dt_ds)
529
530    CONTAINS
531
532!======================================================================
533SUBROUTINE phys_state_var_init(read_climoz)
534USE dimphy
535USE aero_mod
536USE infotrac_phy, ONLY : nbtr
537#ifdef ISO
538USE infotrac_phy, ONLY : ntraciso=>ntiso,niso
539#endif
540USE clesphys_mod_h
541USE indice_sol_mod
542use config_ocean_skin_m, only: activate_ocean_skin
543use surface_data, only: type_ocean
544IMPLICIT NONE
545
546integer, intent(in)::  read_climoz
547! read ozone climatology
548! Allowed values are 0, 1 and 2
549! 0: do not read an ozone climatology
550! 1: read a single ozone climatology that will be used day and night
551! 2: read two ozone climatologies, the average day and night
552! climatology and the daylight climatology
553
554
555      print*, 'is_initialized', is_initialized
556      IF (is_initialized) RETURN
557      is_initialized=.TRUE.
558      ALLOCATE(pctsrf(klon,nbsrf))
559      ALLOCATE(ftsol(klon,nbsrf))
560      ALLOCATE(beta_aridity(klon,nbsrf))
561      ALLOCATE(qsol(klon),fevap(klon,nbsrf))
562      ALLOCATE(z0m(klon,nbsrf+1),z0h(klon,nbsrf+1),agesno(klon,nbsrf))
563!FC
564      ALLOCATE(treedrg(klon,klev,nbsrf))
565      ALLOCATE(falb1(klon,nbsrf))
566      ALLOCATE(falb2(klon,nbsrf))
567!albedo SB >>>
568      print*, 'allocate falb'
569      ALLOCATE(falb_dir(klon,nsw,nbsrf),falb_dif(klon,nsw,nbsrf))
570!!      print*, 'allocate falb good', falb_dir(1,1,1)
571      ALLOCATE(chl_con(klon))
572!albedo SB <<<
573      ALLOCATE(rain_fall(klon))
574      ALLOCATE(snow_fall(klon))
575      ALLOCATE(bs_fall(klon))
576      ALLOCATE(solsw(klon), solswfdiff(klon), sollw(klon))
577      sollw=0.0
578      ALLOCATE(radsol(klon))
579      ALLOCATE(swradcorr(klon))
580      ALLOCATE(zmea(klon), zstd(klon), zsig(klon), zgam(klon))
581      ALLOCATE(zthe(klon), zpic(klon), zval(klon))
582
583      ALLOCATE(rugoro(klon))
584      ALLOCATE(t_ancien(klon,klev), q_ancien(klon,klev))
585      ALLOCATE(ql_ancien(klon,klev), qs_ancien(klon,klev), qbs_ancien(klon,klev))
586      ALLOCATE(prw_ancien(klon), prlw_ancien(klon), prsw_ancien(klon), prbsw_ancien(klon))
587      ALLOCATE(u_ancien(klon,klev), v_ancien(klon,klev))
588      ALLOCATE(cf_ancien(klon,klev), rvc_ancien(klon,klev), rcont_ancien(klon,klev))
589!!! Rom P >>>
590      ALLOCATE(tr_ancien(klon,klev,nbtr))
591!!! Rom P <<<
592      ALLOCATE(clwcon(klon,klev),rnebcon(klon,klev))
593      ALLOCATE(qtc_cv(klon,klev),sigt_cv(klon,klev),detrain_cv(klon,klev),fm_cv(klon,klev))
594      ALLOCATE(ratqs(klon,klev))
595      ALLOCATE(pbl_tke(klon,klev+1,nbsrf+1))
596!nrlmd<
597      ALLOCATE(delta_tsurf(klon,nbsrf))
598!>nrlmd
599      ALLOCATE(coefh(klon,klev+1,nbsrf+1))
600      ALLOCATE(coefm(klon,klev+1,nbsrf+1))
601      ! initialize cleanly coefh,coefm
602      ! (most of the time in the code these are assumed to be on klev levels)
603      coefh(:,:,:)=0
604      coefm(:,:,:)=0
605      ALLOCATE(zmax0(klon), f0(klon))
606      ALLOCATE(sig1(klon,klev), w01(klon,klev))
607      ALLOCATE(entr_therm(klon,klev), fm_therm(klon,klev+1))
608      ALLOCATE(detr_therm(klon,klev))
609!     pour phsystoke avec thermiques
610      ALLOCATE(clwcon0th(klon,klev),rnebcon0th(klon,klev))
611! radiation outputs
612      ALLOCATE(swdnc0(klon,klevp1), swdn0(klon,klevp1), swdn(klon,klevp1))
613      ALLOCATE(swupc0(klon,klevp1), swup0(klon,klevp1), swup(klon,klevp1))
614      ALLOCATE(lwdnc0(klon,klevp1), lwdn0(klon,klevp1), lwdn(klon,klevp1))
615      ALLOCATE(lwupc0(klon,klevp1), lwup0(klon,klevp1), lwup(klon,klevp1))
616      ALLOCATE(SWdn200clr(klon), SWdn200(klon))
617      ALLOCATE(SWup200clr(klon), SWup200(klon))
618      ALLOCATE(LWdn200clr(klon), LWdn200(klon))
619      ALLOCATE(LWup200clr(klon), LWup200(klon))
620      ALLOCATE(LWdnTOA(klon), LWdnTOAclr(klon))
621! pressure level
622      ALLOCATE(tsumSTD(klon,nlevSTD,nout))
623      ALLOCATE(usumSTD(klon,nlevSTD,nout), vsumSTD(klon,nlevSTD,nout))
624      ALLOCATE(wsumSTD(klon,nlevSTD,nout), phisumSTD(klon,nlevSTD,nout))
625      ALLOCATE(qsumSTD(klon,nlevSTD,nout), rhsumSTD(klon,nlevSTD,nout))
626      ALLOCATE(tnondef(klon,nlevSTD,nout))
627      ALLOCATE(uvsumSTD(klon,nlevSTD,nout))
628      ALLOCATE(vqsumSTD(klon,nlevSTD,nout))
629      ALLOCATE(vTsumSTD(klon,nlevSTD,nout))
630      ALLOCATE(wqsumSTD(klon,nlevSTD,nout))
631      ALLOCATE(vphisumSTD(klon,nlevSTD,nout))
632      ALLOCATE(wTsumSTD(klon,nlevSTD,nout))
633      ALLOCATE(u2sumSTD(klon,nlevSTD,nout))
634      ALLOCATE(v2sumSTD(klon,nlevSTD,nout))
635      ALLOCATE(T2sumSTD(klon,nlevSTD,nout))
636      ALLOCATE(O3sumSTD(klon,nlevSTD,nout))
637      ALLOCATE(O3daysumSTD(klon,nlevSTD,nout))
638!IM beg
639      ALLOCATE(wlevSTD(klon,nlevSTD), ulevSTD(klon,nlevSTD), vlevSTD(klon,nlevSTD))
640      ALLOCATE(tlevSTD(klon,nlevSTD), qlevSTD(klon,nlevSTD), rhlevSTD(klon,nlevSTD))
641      ALLOCATE(philevSTD(klon,nlevSTD))
642      ALLOCATE(uvSTD(klon,nlevSTD),vqSTD(klon,nlevSTD))
643      ALLOCATE(vTSTD(klon,nlevSTD),wqSTD(klon,nlevSTD))
644      ALLOCATE(vphiSTD(klon,nlevSTD),wTSTD(klon,nlevSTD))
645      ALLOCATE(u2STD(klon,nlevSTD),v2STD(klon,nlevSTD))
646      ALLOCATE(T2STD(klon,nlevSTD))
647      ALLOCATE(O3STD(klon,nlevSTD))
648      ALLOCATE(O3daySTD(klon,nlevSTD))
649!IM end
650      ALLOCATE(seed_old(klon,napisccp))
651      ALLOCATE(zuthe(klon),zvthe(klon))
652      ALLOCATE(alb_neig(klon))
653!cloud base mass flux
654      ALLOCATE(ema_cbmf(klon))
655!cloud base pressure & cloud top pressure
656      ALLOCATE(ema_pcb(klon), ema_pct(klon))
657!
658      ALLOCATE(Mipsh(klon,klev))
659      ALLOCATE(Ma(klon,klev))
660      ALLOCATE(qcondc(klon,klev))
661      ALLOCATE(wd(klon))
662      ALLOCATE(sigd(klon))
663      ALLOCATE(cin(klon), ALE(klon), ALP(klon))
664      ALLOCATE(ftd(klon,klev), fqd(klon,klev),fqcomp(klon,klev))
665      ALLOCATE(Ale_bl(klon))
666      ALLOCATE(ale_wake(klon))
667      ALLOCATE(ale_bl_stat(klon))
668      ale_bl_stat(:)=0
669      ALLOCATE(Alp_bl(klon))
670      ALLOCATE(lalim_conv(klon))
671      ALLOCATE(wght_th(klon,klev))
672      ALLOCATE(wake_deltat(klon,klev), wake_deltaq(klon,klev))
673      ALLOCATE(wake_s(klon), awake_s(klon), wake_dens(klon), awake_dens(klon))
674!!      awake_dens = 0.  ! initialized in phyetat0
675      ALLOCATE(cv_gen(klon))
676      ALLOCATE(wake_Cstar(klon))
677      ALLOCATE(wake_pe(klon), wake_fip(klon))
678!jyg<
679      ALLOCATE(wake_delta_pbl_TKE(klon,klev+1,nbsrf+1))
680!>jyg
681      ALLOCATE(pfrac_impa(klon,klev), pfrac_nucl(klon,klev))
682      ALLOCATE(pfrac_1nucl(klon,klev))
683      ALLOCATE(total_rain(klon), nday_rain(klon))
684      ALLOCATE(ndayrain_mth(klon))
685      ALLOCATE(paire_ter(klon))
686      ALLOCATE(albsol1(klon), albsol2(klon))
687!albedo SB >>>
688      ALLOCATE(albsol_dir(klon,nsw),albsol_dif(klon,nsw))
689!albedo SB <<<
690
691      if (read_climoz <= 1) then
692         ALLOCATE(wo(klon,klev, 1))
693      else
694         ! read_climoz == 2
695         ALLOCATE(wo(klon,klev, 2))
696      end if
697     
698      ALLOCATE(clwcon0(klon,klev),rnebcon0(klon,klev))
699      ALLOCATE(heat(klon,klev), heat0(klon,klev))
700      ALLOCATE(cool(klon,klev), cool0(klon,klev))
701      ALLOCATE(heat_volc(klon,klev), cool_volc(klon,klev))
702      ALLOCATE(topsw(klon), toplw(klon))
703      ALLOCATE(sollwdown(klon), sollwdownclr(klon))
704      sollwdown = 0.
705      ALLOCATE(toplwdown(klon), toplwdownclr(klon))
706      ALLOCATE(topsw0(klon),toplw0(klon),solsw0(klon),sollw0(klon))
707      sollw0 = 0.
708      ALLOCATE(albpla(klon))
709!IM ajout variables CFMIP2/CMIP5
710      ALLOCATE(heatp(klon,klev), coolp(klon,klev))
711      ALLOCATE(heat0p(klon,klev), cool0p(klon,klev))
712      ALLOCATE(radsolp(klon), topswp(klon), toplwp(klon))
713      ALLOCATE(albplap(klon))
714      ALLOCATE(solswp(klon), solswfdiffp(klon), sollwp(klon))
715      ALLOCATE(gustiness(klon))
716      ALLOCATE(sollwdownp(klon))
717      ALLOCATE(topsw0p(klon),toplw0p(klon))
718      ALLOCATE(solsw0p(klon),sollw0p(klon))
719      ALLOCATE(lwdnc0p(klon,klevp1), lwdn0p(klon,klevp1), lwdnp(klon,klevp1))
720      ALLOCATE(lwupc0p(klon,klevp1), lwup0p(klon,klevp1), lwupp(klon,klevp1))
721      ALLOCATE(swdnc0p(klon,klevp1), swdn0p(klon,klevp1), swdnp(klon,klevp1))
722      ALLOCATE(swupc0p(klon,klevp1), swup0p(klon,klevp1), swupp(klon,klevp1))
723
724!AI Ajout pour Ecrad (3Deffect)       
725      ALLOCATE(heat_s2(klon,klev), cool_s2(klon,klev))
726      ALLOCATE(heat0_s2(klon,klev), cool0_s2(klon,klev))
727      ALLOCATE(radsol_s2(klon), topsw_s2(klon), toplw_s2(klon))
728      ALLOCATE(albpla_s2(klon))
729      ALLOCATE(solsw_s2(klon), solswfdiff_s2(klon), sollw_s2(klon))
730      ALLOCATE(sollwdown_s2(klon),sollwdownclr_s2(klon))
731      ALLOCATE(topsw0_s2(klon),toplw0_s2(klon))
732      ALLOCATE(solsw0_s2(klon),sollw0_s2(klon))
733      ALLOCATE(lwdnc0_s2(klon,klevp1), lwdn0_s2(klon,klevp1), lwdn_s2(klon,klevp1))
734      ALLOCATE(lwupc0_s2(klon,klevp1), lwup0_s2(klon,klevp1), lwup_s2(klon,klevp1))
735      ALLOCATE(swdnc0_s2(klon,klevp1), swdn0_s2(klon,klevp1), swdn_s2(klon,klevp1))
736      ALLOCATE(swupc0_s2(klon,klevp1), swup0_s2(klon,klevp1), swup_s2(klon,klevp1))
737
738      ALLOCATE(cape(klon))
739      ALLOCATE(pbase(klon),bbase(klon))
740      ALLOCATE(zqasc(klon,klev))
741      ALLOCATE(ibas_con(klon), itop_con(klon))
742      ALLOCATE(rain_con(klon), snow_con(klon))
743      ALLOCATE(rlonPOS(klon))
744      ALLOCATE(newsst(klon))
745      ALLOCATE(ustar(klon,nbsrf),u10m(klon,nbsrf), v10m(klon,nbsrf),wstar(klon,nbsrf+1))
746      ALLOCATE(topswad(klon), solswad(klon))
747      ALLOCATE(topswai(klon), solswai(klon))
748      ALLOCATE(tau_aero(klon,klev,naero_grp,nbands),piz_aero(klon,klev,naero_grp,nbands),cg_aero(klon,klev,naero_grp,nbands))
749      ALLOCATE(tau_aero_sw_rrtm(klon,klev,2,nbands_sw_rrtm),piz_aero_sw_rrtm(klon,klev,2,nbands_sw_rrtm))
750      ALLOCATE(cg_aero_sw_rrtm(klon,klev,2,nbands_sw_rrtm))
751      ALLOCATE(tau_aero_lw_rrtm(klon,klev,2,nbands_lw_rrtm),piz_aero_lw_rrtm(klon,klev,2,nbands_lw_rrtm))
752      ALLOCATE(cg_aero_lw_rrtm(klon,klev,2,nbands_lw_rrtm))
753      ALLOCATE(ccm(klon,klev,nbands))
754
755#ifdef ISO
756      ALLOCATE(xtsol(niso,klon),fxtevap(ntraciso,klon,nbsrf))
757      ALLOCATE(fxtd(ntraciso,klon,klev))
758      ALLOCATE(wake_deltaxt(ntraciso,klon,klev))
759      ALLOCATE(xt_ancien(ntraciso,klon,klev))
760      ALLOCATE(xtl_ancien(ntraciso,klon,klev))
761      ALLOCATE(xts_ancien(ntraciso,klon,klev))
762      ALLOCATE(xtbs_ancien(ntraciso,klon,klev))
763      ALLOCATE(xtrain_fall(ntraciso,klon))
764      ALLOCATE(xtsnow_fall(ntraciso,klon))
765      ALLOCATE(xtrain_con(ntraciso,klon))
766      ALLOCATE(xtsnow_con(ntraciso,klon))
767#ifdef ISOTRAC
768      ALLOCATE(bassin_map(klon))
769      ALLOCATE(boite_map(klon,klev)) 
770#endif     
771#endif
772
773      ALLOCATE(ale_bl_trig(klon))
774      ALLOCATE(ratqs_inter_(klon,klev),sigma_qtherm(klon,klev))
775      IF (ok_gwd_rando) THEN
776        ALLOCATE(du_gwd_rando(klon, klev))
777        du_gwd_rando(:,:)=0.
778      ENDIF
779      IF (.not. ok_hines .and. ok_gwd_rando) THEN
780        ALLOCATE(du_gwd_front(klon, klev))
781        du_gwd_front(:,:) = 0 !ym missing init   
782      ENDIF
783
784      if (activate_ocean_skin >= 1) then
785         ALLOCATE(delta_sal(klon), ds_ns(klon), dt_ns(klon), delta_sst(klon), &
786              dter(klon), dser(klon))
787         if (activate_ocean_skin == 2 .and. type_ocean == "couple") &
788              allocate(dt_ds(klon))
789      end if
790
791    END SUBROUTINE phys_state_var_init
792
793!======================================================================
794    SUBROUTINE phys_state_var_end
795      ! Useful only for lmdz1d.
796      USE clesphys_mod_h
797USE indice_sol_mod
798use config_ocean_skin_m, only: activate_ocean_skin
799use surface_data, only: type_ocean
800IMPLICIT NONE
801
802      DEALLOCATE(pctsrf, ftsol, falb1, falb2)
803      DEALLOCATE(beta_aridity)
804      DEALLOCATE(qsol,fevap,z0m,z0h,agesno)
805!FC
806      DEALLOCATE(treedrg)
807      DEALLOCATE(rain_fall, snow_fall, bs_fall,solsw, solswfdiff, sollw, radsol, swradcorr)
808      DEALLOCATE(zmea, zstd, zsig, zgam)
809      DEALLOCATE(zthe, zpic, zval)
810      DEALLOCATE(rugoro, t_ancien, q_ancien, clwcon, rnebcon)
811      DEALLOCATE(qs_ancien, ql_ancien, qbs_ancien)
812      DEALLOCATE(prw_ancien, prlw_ancien, prsw_ancien, prbsw_ancien)
813      DEALLOCATE(qtc_cv,sigt_cv,detrain_cv,fm_cv)
814      DEALLOCATE(u_ancien, v_ancien)
815      DEALLOCATE(cf_ancien, rvc_ancien, rcont_ancien)
816      DEALLOCATE(tr_ancien)                           !RomP
817      DEALLOCATE(ratqs, pbl_tke,coefh,coefm)
818      DEALLOCATE(zmax0, f0)
819      DEALLOCATE(sig1, w01)
820      DEALLOCATE(entr_therm, fm_therm)
821      DEALLOCATE(detr_therm)
822      DEALLOCATE(clwcon0th, rnebcon0th)
823! radiation outputs
824      DEALLOCATE(swdnc0, swdn0, swdn)
825      DEALLOCATE(swupc0, swup0, swup)
826      DEALLOCATE(lwdnc0, lwdn0, lwdn)
827      DEALLOCATE(lwupc0, lwup0, lwup)
828      DEALLOCATE(SWdn200clr, SWdn200)
829      DEALLOCATE(SWup200clr, SWup200)
830      DEALLOCATE(LWdn200clr, LWdn200)
831      DEALLOCATE(LWup200clr, LWup200)
832      DEALLOCATE(LWdnTOA, LWdnTOAclr)
833! pressure level
834      DEALLOCATE(tsumSTD)
835      DEALLOCATE(usumSTD, vsumSTD)
836      DEALLOCATE(wsumSTD, phisumSTD)
837      DEALLOCATE(tnondef)
838      DEALLOCATE(qsumSTD, rhsumSTD)
839      DEALLOCATE(uvsumSTD)
840      DEALLOCATE(vqsumSTD)
841      DEALLOCATE(vTsumSTD)
842      DEALLOCATE(wqsumSTD)
843      DEALLOCATE(vphisumSTD)
844      DEALLOCATE(wTsumSTD)
845      DEALLOCATE(u2sumSTD)
846      DEALLOCATE(v2sumSTD)
847      DEALLOCATE(T2sumSTD)
848      DEALLOCATE(O3sumSTD)
849      DEALLOCATE(O3daysumSTD)
850!IM beg
851      DEALLOCATE(wlevSTD,ulevSTD,vlevSTD,tlevSTD,qlevSTD,rhlevSTD,philevSTD)
852      DEALLOCATE(uvSTD,vqSTD,vTSTD,wqSTD,vphiSTD,wTSTD,u2STD,v2STD,T2STD,O3STD,O3daySTD)
853!IM end
854      DEALLOCATE(seed_old)
855      DEALLOCATE(zuthe, zvthe)
856      DEALLOCATE(alb_neig)
857      DEALLOCATE(ema_cbmf)
858      DEALLOCATE(ema_pcb, ema_pct)
859      DEALLOCATE(Mipsh, Ma, qcondc)
860      DEALLOCATE(wd, sigd)
861      DEALLOCATE(cin, ALE, ALP)
862      DEALLOCATE(ftd, fqd, fqcomp)
863      DEALLOCATE(Ale_bl, Alp_bl)
864      DEALLOCATE(ale_wake)
865      DEALLOCATE(ale_bl_stat)
866      DEALLOCATE(lalim_conv, wght_th)
867      DEALLOCATE(wake_deltat, wake_deltaq)
868      DEALLOCATE(wake_s, awake_s, wake_dens, awake_dens)
869      DEALLOCATE(cv_gen)
870      DEALLOCATE(wake_Cstar, wake_pe, wake_fip)
871!jyg<
872      DEALLOCATE(wake_delta_pbl_TKE)
873!nrlmd<
874      DEALLOCATE(delta_tsurf)
875!>nrlmd
876!>jyg
877      DEALLOCATE(pfrac_impa, pfrac_nucl)
878      DEALLOCATE(pfrac_1nucl)
879      DEALLOCATE(total_rain, nday_rain)
880      DEALLOCATE(ndayrain_mth)
881      DEALLOCATE(paire_ter)
882      DEALLOCATE(albsol1, albsol2)
883!albedo SB >>>
884      DEALLOCATE(albsol_dir,albsol_dif,falb_dir,falb_dif,chl_con)
885!albedo SB <<<
886      DEALLOCATE(wo)
887      DEALLOCATE(clwcon0,rnebcon0)
888      DEALLOCATE(heat, heat0)
889      DEALLOCATE(cool, cool0)
890      DEALLOCATE(heat_volc, cool_volc)
891      DEALLOCATE(topsw, toplw)
892      DEALLOCATE(sollwdown, sollwdownclr)
893      DEALLOCATE(gustiness)
894      DEALLOCATE(toplwdown, toplwdownclr)
895      DEALLOCATE(topsw0,toplw0,solsw0,sollw0)
896      DEALLOCATE(albpla)
897
898!AI Ajout pour Ecrad (3Deffect)
899      DEALLOCATE(heat_s2, cool_s2)
900      DEALLOCATE(heat0_s2, cool0_s2)
901      DEALLOCATE(radsol_s2, topsw_s2, toplw_s2)
902      DEALLOCATE(albpla_s2)
903      DEALLOCATE(solsw_s2, solswfdiff_s2, sollw_s2)
904      DEALLOCATE(sollwdown_s2, sollwdownclr_s2)
905      DEALLOCATE(topsw0_s2,toplw0_s2)
906      DEALLOCATE(solsw0_s2,sollw0_s2)
907      DEALLOCATE(lwdnc0_s2, lwdn0_s2, lwdn_s2)
908      DEALLOCATE(lwupc0_s2, lwup0_s2, lwup_s2)
909      DEALLOCATE(swdnc0_s2, swdn0_s2, swdn_s2)
910      DEALLOCATE(swupc0_s2, swup0_s2, swup_s2)
911
912!IM ajout variables CFMIP2/CMIP5
913      DEALLOCATE(heatp, coolp)
914      DEALLOCATE(heat0p, cool0p)
915      DEALLOCATE(radsolp, topswp, toplwp)
916      DEALLOCATE(albplap)
917      DEALLOCATE(solswp, solswfdiffp, sollwp)
918      DEALLOCATE(sollwdownp)
919      DEALLOCATE(topsw0p,toplw0p)
920      DEALLOCATE(solsw0p,sollw0p)
921      DEALLOCATE(lwdnc0p, lwdn0p, lwdnp)
922      DEALLOCATE(lwupc0p, lwup0p, lwupp)
923      DEALLOCATE(swdnc0p, swdn0p, swdnp)
924      DEALLOCATE(swupc0p, swup0p, swupp)
925      DEALLOCATE(cape)
926      DEALLOCATE(pbase,bbase)
927      DEALLOCATE(zqasc)
928      DEALLOCATE(ibas_con, itop_con)
929      DEALLOCATE(rain_con, snow_con)
930      DEALLOCATE(rlonPOS)
931      DEALLOCATE(newsst)
932      DEALLOCATE(ustar,u10m, v10m,wstar)
933      DEALLOCATE(topswad, solswad)
934      DEALLOCATE(topswai, solswai)
935      DEALLOCATE(tau_aero,piz_aero,cg_aero)
936      DEALLOCATE(tau_aero_sw_rrtm,piz_aero_sw_rrtm,cg_aero_sw_rrtm)
937      DEALLOCATE(tau_aero_lw_rrtm,piz_aero_lw_rrtm,cg_aero_lw_rrtm)
938      DEALLOCATE(ccm)
939      if (ok_gwd_rando) DEALLOCATE(du_gwd_rando)
940      if (.not. ok_hines .and. ok_gwd_rando) DEALLOCATE(du_gwd_front)
941      DEALLOCATE(ale_bl_trig)
942      DEALLOCATE(ratqs_inter_,sigma_qtherm)
943
944      if (activate_ocean_skin >= 1) then
945         deALLOCATE(delta_sal, ds_ns, dt_ns, delta_sst, dter, dser)
946         if (activate_ocean_skin == 2 .and. type_ocean == "couple") &
947              deALLOCATE(dt_ds)
948      end if
949
950#ifdef ISO   
951      DEALLOCATE(xtsol,fxtevap) 
952      DEALLOCATE(xt_ancien,xtl_ancien,xts_ancien,xtbs_ancien, fxtd, wake_deltaxt)
953      DEALLOCATE(xtrain_fall, xtsnow_fall, xtrain_con, xtsnow_con)
954#ifdef ISOTRAC
955      DEALLOCATE(bassin_map,boite_map)
956#endif       
957#endif
958      is_initialized=.FALSE.
959     
960END SUBROUTINE phys_state_var_end
961
962      END MODULE phys_state_var_mod
Note: See TracBrowser for help on using the repository browser.