source: LMDZ4/trunk/libf/phylmd/thermcell_dq.F90 @ 977

Last change on this file since 977 was 972, checked in by lmdzadmin, 17 years ago

Version thermique FH/CRio
Ajout tests cas physiques non pris en comptes et ajout/enleve prints
Nouvelle routine thermcell_flux2.F90
IM

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
RevLine 
[878]1      subroutine thermcell_dq(ngrid,nlay,ptimestep,fm,entr,  &
2     &           masse,q,dq,qa,lev_out)
3      implicit none
4
[938]5#include "iniprint.h"
[878]6!=======================================================================
7!
8!   Calcul du transport verticale dans la couche limite en presence
9!   de "thermiques" explicitement representes
10!   calcul du dq/dt une fois qu'on connait les ascendances
11!
12!=======================================================================
13
14      integer ngrid,nlay
15
16      real ptimestep
17      real masse(ngrid,nlay),fm(ngrid,nlay+1)
18      real entr(ngrid,nlay)
19      real q(ngrid,nlay)
20      real dq(ngrid,nlay)
21      integer lev_out                           ! niveau pour les print
22
23      real qa(ngrid,nlay),detr(ngrid,nlay),wqd(ngrid,nlay+1)
24
[972]25      real zzm
26
[878]27      integer ig,k
[972]28      real cfl
[878]29
[972]30      real qold(ngrid,nlay)
31      real ztimestep
32      integer niter,iter
[878]33
[972]34
35
36! Calcul du critere CFL pour l'advection dans la subsidence
37      do k=1,nlay
38         do ig=1,ngrid
39            zzm=masse(ig,k)/ptimestep
40            cfl=max(cfl,fm(ig,k)/zzm)
41            if (entr(ig,k).gt.zzm) then
42               print*,'entr dt > m ',entr(ig,k)*ptimestep,masse(ig,k)
43               stop
44            endif
45         enddo
46      enddo
47
48!IM 090508     print*,'CFL CFL CFL CFL ',cfl
49
50#undef CFL
51#ifdef CFL
52! On subdivise le calcul en niter pas de temps.
53      niter=int(cfl)+1
54#else
55      niter=1
56#endif
57
58      ztimestep=ptimestep/niter
59      qold=q
60
61
62do iter=1,niter
[938]63      if (prt_level.ge.1) print*,'Q2 THERMCEL_DQ 0'
[878]64
[972]65!   calcul du detrainement
[878]66      do k=1,nlay
67         do ig=1,ngrid
68            detr(ig,k)=fm(ig,k)-fm(ig,k+1)+entr(ig,k)
69!           print*,'Q2 DQ ',detr(ig,k),fm(ig,k),entr(ig,k)
70!test
71            if (detr(ig,k).lt.0.) then
72               entr(ig,k)=entr(ig,k)-detr(ig,k)
73               detr(ig,k)=0.
74!               print*,'detr2<0!!!','ig=',ig,'k=',k,'f=',fm(ig,k),
75!     s         'f+1=',fm(ig,k+1),'e=',entr(ig,k),'d=',detr(ig,k)
76            endif
77            if (fm(ig,k+1).lt.0.) then
78!               print*,'fm2<0!!!'
79            endif
80            if (entr(ig,k).lt.0.) then
81!               print*,'entr2<0!!!'
82            endif
83         enddo
84      enddo
85
86!   calcul de la valeur dans les ascendances
87      do ig=1,ngrid
88         qa(ig,1)=q(ig,1)
89      enddo
90
91      do k=2,nlay
92         do ig=1,ngrid
[972]93            if ((fm(ig,k+1)+detr(ig,k))*ztimestep.gt.  &
[878]94     &         1.e-5*masse(ig,k)) then
95         qa(ig,k)=(fm(ig,k)*qa(ig,k-1)+entr(ig,k)*q(ig,k))  &
96     &         /(fm(ig,k+1)+detr(ig,k))
97            else
98               qa(ig,k)=q(ig,k)
99            endif
100            if (qa(ig,k).lt.0.) then
101!               print*,'qa<0!!!'
102            endif
103            if (q(ig,k).lt.0.) then
104!               print*,'q<0!!!'
105            endif
106         enddo
107      enddo
108
[972]109! Calcul du flux subsident
110
[878]111      do k=2,nlay
112         do ig=1,ngrid
[972]113#undef centre
114#ifdef centre
115             wqd(ig,k)=fm(ig,k)*0.5*(q(ig,k-1)+q(ig,k))
116#else
117
118#define plusqueun
119#ifdef plusqueun
120! Schema avec advection sur plus qu'une maille.
121            zzm=masse(ig,k)/ztimestep
122            if (fm(ig,k)>zzm) then
123               wqd(ig,k)=zzm*q(ig,k)+(fm(ig,k)-zzm)*q(ig,k+1)
124            else
125               wqd(ig,k)=fm(ig,k)*q(ig,k)
126            endif
127#else
[878]128            wqd(ig,k)=fm(ig,k)*q(ig,k)
[972]129#endif
130#endif
131
[878]132            if (wqd(ig,k).lt.0.) then
133!               print*,'wqd<0!!!'
134            endif
135         enddo
136      enddo
137      do ig=1,ngrid
138         wqd(ig,1)=0.
139         wqd(ig,nlay+1)=0.
140      enddo
141     
[972]142
143! Calcul des tendances
[878]144      do k=1,nlay
145         do ig=1,ngrid
[972]146            q(ig,k)=q(ig,k)+(detr(ig,k)*qa(ig,k)-entr(ig,k)*q(ig,k)  &
[878]147     &               -wqd(ig,k)+wqd(ig,k+1))  &
[972]148     &               *ztimestep/masse(ig,k)
[878]149!            if (dq(ig,k).lt.0.) then
150!               print*,'dq<0!!!'
151!            endif
152         enddo
153      enddo
154
[972]155
156enddo
157
158
159! Calcul des tendances
160      do k=1,nlay
161         do ig=1,ngrid
162            dq(ig,k)=(q(ig,k)-qold(ig,k))/ptimestep
163            q(ig,k)=qold(ig,k)
164         enddo
165      enddo
166
[878]167      return
168      end
Note: See TracBrowser for help on using the repository browser.