source: LMDZ6/trunk/libf/phylmd/phys_state_var_mod.F90 @ 5134

Last change on this file since 5134 was 5084, checked in by Laurent Fairhead, 5 months ago

Reverting to r4065. Updating fortran standard broke too much stuff. Will do it by smaller chunks
AB, LF

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