source: trunk/LMDZ.MARS/libf/phymars/vdifc.F @ 498

Last change on this file since 498 was 496, checked in by acolaitis, 14 years ago

M 489 libf/phymars/thermcell_main_mars.F90
--------------------> New parameters for thermals, following latest version of the relevant article

M 489 libf/phymars/physiq.F
--------------------> Minor modifications

D 489 libf/phymars/surflayer_interpol.F
A 0 libf/phymars/pbl_parameters.F
--------------------> Replaced surflayer_interpol.F by a cleaner and richer version called pbl_parameters.F

This routine is the base of what will later be implemented in the MCD and as a tool to
compute surface properties from output fields (so that it will ultimately disappear from libf
and might become an utility)

M 489 libf/phymars/vdif_cd.F
--------------------> Minor modification to the Richardson computation

M 489 libf/phymars/vdifc.F
--------------------> Minor modification to the aerodynamic conductances computation, replacing wmax by hfmax, which

is a better proxy for convective activity. Might be replaced by w_star later.

File size: 26.4 KB
RevLine 
[38]1      SUBROUTINE vdifc(ngrid,nlay,nq,co2ice,ppopsk,
2     $                ptimestep,pcapcal,lecrit,
3     $                pplay,pplev,pzlay,pzlev,pz0,
4     $                pu,pv,ph,pq,ptsrf,pemis,pqsurf,
5     $                pdufi,pdvfi,pdhfi,pdqfi,pfluxsrf,
6     $                pdudif,pdvdif,pdhdif,pdtsrf,pq2,
[496]7     $                pdqdif,pdqsdif,wmax,zcdv_true,zcdh_true,hfmax)
[38]8      IMPLICIT NONE
9
10c=======================================================================
11c
12c   subject:
13c   --------
14c   Turbulent diffusion (mixing) for potential T, U, V and tracer
15c
16c   Shema implicite
17c   On commence par rajouter au variables x la tendance physique
18c   et on resoult en fait:
19c      x(t+1) =  x(t) + dt * (dx/dt)phys(t)  +  dt * (dx/dt)difv(t+1)
20c
21c   author:
22c   ------
23c      Hourdin/Forget/Fournier
24c=======================================================================
25
26c-----------------------------------------------------------------------
27c   declarations:
28c   -------------
29
30#include "dimensions.h"
31#include "dimphys.h"
32#include "comcstfi.h"
33#include "callkeys.h"
34#include "surfdat.h"
35#include "comgeomfi.h"
36#include "tracer.h"
37
38c
39c   arguments:
40c   ----------
41
42      INTEGER ngrid,nlay
43      REAL ptimestep
44      REAL pplay(ngrid,nlay),pplev(ngrid,nlay+1)
45      REAL pzlay(ngrid,nlay),pzlev(ngrid,nlay+1)
[496]46      REAL pu(ngrid,nlay),pv(ngrid,nlay),ph(ngrid,nlay),pt(ngrid,nlay)
[38]47      REAL ptsrf(ngrid),pemis(ngrid)
48      REAL pdufi(ngrid,nlay),pdvfi(ngrid,nlay),pdhfi(ngrid,nlay)
49      REAL pfluxsrf(ngrid)
50      REAL pdudif(ngrid,nlay),pdvdif(ngrid,nlay),pdhdif(ngrid,nlay)
51      REAL pdtsrf(ngrid),pcapcal(ngrid)
52      REAL pq2(ngrid,nlay+1)
53
54c    Argument added for condensation:
55      REAL co2ice (ngrid), ppopsk(ngrid,nlay)
56      logical lecrit
57
[224]58      REAL pz0(ngridmx) ! surface roughness length (m)
59
[256]60c    Argument added to account for subgrid gustiness :
61
[496]62      REAL wmax(ngridmx), hfmax(ngridmx)
[256]63
[38]64c    Traceurs :
65      integer nq
66      REAL pqsurf(ngrid,nq)
67      real pq(ngrid,nlay,nq), pdqfi(ngrid,nlay,nq)
68      real pdqdif(ngrid,nlay,nq)
69      real pdqsdif(ngrid,nq)
70     
71c   local:
72c   ------
73
[473]74      REAL ust(ngridmx),tst(ngridmx)
75 
[38]76      INTEGER ilev,ig,ilay,nlev
77
78      REAL z4st,zdplanck(ngridmx)
79      REAL zkv(ngridmx,nlayermx+1),zkh(ngridmx,nlayermx+1)
[496]80      REAL zkq(ngridmx,nlayermx+1)
[38]81      REAL zcdv(ngridmx),zcdh(ngridmx)
[268]82      REAL zcdv_true(ngridmx),zcdh_true(ngridmx)    ! drag coeff are used by the LES to recompute u* and hfx
[38]83      REAL zu(ngridmx,nlayermx),zv(ngridmx,nlayermx)
84      REAL zh(ngridmx,nlayermx)
85      REAL ztsrf2(ngridmx)
86      REAL z1(ngridmx),z2(ngridmx)
87      REAL za(ngridmx,nlayermx),zb(ngridmx,nlayermx)
88      REAL zb0(ngridmx,nlayermx)
89      REAL zc(ngridmx,nlayermx),zd(ngridmx,nlayermx)
90      REAL zcst1
[284]91      REAL zu2(ngridmx)
[38]92
93      EXTERNAL SSUM,SCOPY
94      REAL SSUM
95      LOGICAL firstcall
96      SAVE firstcall
97
98c     variable added for CO2 condensation:
99c     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100      REAL hh , zhcond(ngridmx,nlayermx)
101      REAL latcond,tcond1mb
102      REAL acond,bcond
103      SAVE acond,bcond
104      DATA latcond,tcond1mb/5.9e5,136.27/
105
106c    Tracers :
107c    ~~~~~~~
108      INTEGER iq
109      REAL zq(ngridmx,nlayermx,nqmx)
110      REAL zq1temp(ngridmx)
111      REAL rho(ngridmx) ! near surface air density
112      REAL qsat(ngridmx)
113      DATA firstcall/.true./
114
115      REAL kmixmin
116
[473]117c    Mass-variation scheme :
118c    ~~~~~~~
119
120      INTEGER j,l
121      REAL zcondicea(ngrid,nlayermx)
122      REAL zt(ngridmx,nlayermx),ztcond(ngridmx,nlayermx+1)
123      REAL betam(ngridmx,nlayermx),dmice(ngridmx,nlayermx)
124      REAL pdtc(ngrid,nlayermx)
125      REAL zhs(ngridmx,nlayermx)
[496]126      REAL ccond
127      SAVE ccond
[473]128
129c     Theta_m formulation for mass-variation scheme :
130c     ~~~~~~~
131
132      INTEGER ico2,llnt(ngridmx)
133      SAVE ico2
134      REAL m_co2, m_noco2, A , B
135      SAVE A, B, m_co2, m_noco2
136      REAL vmr_co2(ngridmx,nlayermx)
137      REAL qco2,mmean
138
[38]139c    ** un petit test de coherence
140c       --------------------------
141
142      IF (firstcall) THEN
143         IF(ngrid.NE.ngridmx) THEN
144            PRINT*,'STOP dans vdifc'
145            PRINT*,'probleme de dimensions :'
146            PRINT*,'ngrid  =',ngrid
147            PRINT*,'ngridmx  =',ngridmx
148            STOP
149         ENDIF
150c        To compute: Tcond= 1./(bcond-acond*log(.0095*p)) (p in pascal)
151         bcond=1./tcond1mb
152         acond=r/latcond
[473]153         ccond=cpp/(g*latcond)
[38]154         PRINT*,'In vdifc: Tcond(P=1mb)=',tcond1mb,' Lcond=',latcond
[473]155         PRINT*,'          acond,bcond,ccond',acond,bcond,ccond
[38]156
[473]157
158         ico2=0
159
160         if (tracer) then
161c          Prepare Special treatment if one of the tracer is CO2 gas
162           do iq=1,nqmx
163             if (noms(iq).eq."co2") then
164                ico2=iq
165                m_co2 = 44.01E-3  ! CO2 molecular mass (kg/mol)
166                m_noco2 = 33.37E-3  ! Non condensible mol mass (kg/mol)
167c               Compute A and B coefficient use to compute
168c               mean molecular mass Mair defined by
169c               1/Mair = q(ico2)/m_co2 + (1-q(ico2))/m_noco2
170c               1/Mair = A*q(ico2) + B
171                A =(1/m_co2 - 1/m_noco2)
172                B=1/m_noco2
173             endif
174           enddo
175         end if
176
[38]177        firstcall=.false.
178      ENDIF
179
180
181
182
183
184c-----------------------------------------------------------------------
185c    1. initialisation
186c    -----------------
187
188      nlev=nlay+1
189
190c    ** calcul de rho*dz et dt*rho/dz=dt*rho**2 g/dp
191c       avec rho=p/RT=p/ (R Theta) (p/ps)**kappa
192c       ----------------------------------------
193
194      DO ilay=1,nlay
195         DO ig=1,ngrid
196            za(ig,ilay)=(pplev(ig,ilay)-pplev(ig,ilay+1))/g
[473]197! Mass variation scheme:
198            betam(ig,ilay)=-za(ig,ilay)*latcond/(cpp*ppopsk(ig,ilay))
[38]199         ENDDO
200      ENDDO
201
202      zcst1=4.*g*ptimestep/(r*r)
203      DO ilev=2,nlev-1
204         DO ig=1,ngrid
205            zb0(ig,ilev)=pplev(ig,ilev)*
206     s      (pplev(ig,1)/pplev(ig,ilev))**rcp /
207     s      (ph(ig,ilev-1)+ph(ig,ilev))
208            zb0(ig,ilev)=zcst1*zb0(ig,ilev)*zb0(ig,ilev)/
209     s      (pplay(ig,ilev-1)-pplay(ig,ilev))
210         ENDDO
211      ENDDO
212      DO ig=1,ngrid
[473]213         zb0(ig,1)=ptimestep*pplev(ig,1)/(r*ptsrf(ig))
[38]214      ENDDO
215
216c    ** diagnostique pour l'initialisation
217c       ----------------------------------
218
219      IF(lecrit) THEN
220         ig=ngrid/2+1
221         PRINT*,'Pression (mbar) ,altitude (km),u,v,theta, rho dz'
222         DO ilay=1,nlay
223            WRITE(*,'(6f11.5)')
224     s      .01*pplay(ig,ilay),.001*pzlay(ig,ilay),
225     s      pu(ig,ilay),pv(ig,ilay),ph(ig,ilay),za(ig,ilay)
226         ENDDO
227         PRINT*,'Pression (mbar) ,altitude (km),zb'
228         DO ilev=1,nlay
229            WRITE(*,'(3f15.7)')
230     s      .01*pplev(ig,ilev),.001*pzlev(ig,ilev),
231     s      zb0(ig,ilev)
232         ENDDO
233      ENDIF
234
[473]235c     -----------------------------------
[38]236c     Potential Condensation temperature:
237c     -----------------------------------
238
[473]239c     Compute CO2 Volume mixing ratio
240c     -------------------------------
241      if (callcond.and.(ico2.ne.0)) then
242         DO ilev=1,nlay
243            DO ig=1,ngrid
244              qco2=pq(ig,ilev,ico2)+pdqfi(ig,ilev,ico2)*ptimestep
245c             Mean air molecular mass = 1/(q(ico2)/m_co2 + (1-q(ico2))/m_noco2)
246              mmean=1/(A*qco2 +B)
247              vmr_co2(ig,ilev) = qco2*mmean/m_co2
248            ENDDO
249         ENDDO
250      else
251         DO ilev=1,nlay
252            DO ig=1,ngrid
253              vmr_co2(ig,ilev)=0.95
254            ENDDO
255         ENDDO
256      end if
[38]257
[473]258c     forecast of atmospheric temperature zt and frost temperature ztcond
259c     --------------------------------------------------------------------
[38]260
[473]261      DO ilev=1,nlay
262         DO ig=1,ngrid
263            ztcond(ig,ilev)=
264     &         1./(bcond-acond*log(.01*vmr_co2(ig,ilev)*pplay(ig,ilev)))
265            if (pplay(ig,ilev).lt.1e-4) ztcond(ig,ilev)=0.0 !mars Monica
266         ENDDO
267      ENDDO
268
269      ztcond(:,nlay+1)=ztcond(:,nlay)
270
271      if (callcond) then
272        DO ilev=1,nlay
273          DO ig=1,ngrid
274!            zhcond(ig,ilev) =
275!     &  (1./(bcond-acond*log(.0095*pplay(ig,ilev))))/ppopsk(ig,ilev)
276              zhcond(ig,ilev) = ztcond(ig,ilev)/ppopsk(ig,ilev)
277          END DO
278        END DO
279      else
280         call zerophys(ngrid*nlay,zhcond)
281      end if
282
283
[38]284c-----------------------------------------------------------------------
285c   2. ajout des tendances physiques
286c      -----------------------------
287
288      DO ilev=1,nlay
289         DO ig=1,ngrid
290            zu(ig,ilev)=pu(ig,ilev)+pdufi(ig,ilev)*ptimestep
291            zv(ig,ilev)=pv(ig,ilev)+pdvfi(ig,ilev)*ptimestep
292            zh(ig,ilev)=ph(ig,ilev)+pdhfi(ig,ilev)*ptimestep
[473]293!            zh(ig,ilev)=max(zh(ig,ilev),zhcond(ig,ilev))
[38]294         ENDDO
295      ENDDO
296      if(tracer) then
297        DO iq =1, nq
298         DO ilev=1,nlay
299           DO ig=1,ngrid
300              zq(ig,ilev,iq)=pq(ig,ilev,iq)+pdqfi(ig,ilev,iq)*ptimestep
301           ENDDO
302         ENDDO
303        ENDDO
304      end if
305
306c-----------------------------------------------------------------------
307c   3. schema de turbulence
308c      --------------------
309
310c    ** source d'energie cinetique turbulente a la surface
311c       (condition aux limites du schema de diffusion turbulente
312c       dans la couche limite
313c       ---------------------
314
[268]315      CALL vdif_cd(ngrid,nlay,pz0,g,pzlay,pu,pv,wmax,ptsrf,ph
[38]316     &             ,zcdv_true,zcdh_true)
[256]317
[290]318        zu2(:)=pu(:,1)*pu(:,1)+pv(:,1)*pv(:,1)
[256]319
[291]320        IF (callrichsl) THEN
[496]321       zcdv(:)=zcdv_true(:)*sqrt(zu2(:)+(6.*hfmax(:))**2)     ! subgrid gustiness added by quadratic interpolation with a coeff beta
322       zcdh(:)=zcdh_true(:)*sqrt(zu2(:)+(10.*hfmax(:))**2)     ! LES comparisons. This parameter is linked to the thermals settings)
323
324!       zcdv(:)=zcdv_true(:)*sqrt(zu2(:)+(0.7*wmax(:))**2)     ! subgrid gustiness added by quadratic interpolation with a coeff beta
325!       zcdh(:)=zcdh_true(:)*sqrt(zu2(:)+(1.2*wmax(:))**2)     ! LES comparisons. This parameter is linked to the thermals settings)
326
327        ust(:)=sqrt(zcdv_true(:))*sqrt(zu2(:)+(6.*hfmax(:))**2)
328        tst(:)=(ph(:,1)-ptsrf(:))*zcdh(:)/ust(:)
[473]329!        ust(:)=sqrt(zcdv_true(:))*sqrt(zu2(:)+(0.7*wmax(:))**2)
330!        tst(:)=(ph(:,1)-ptsrf(:))*zcdh(:)/ust(:)
331!        ust(:)=sqrt(zcdv_true(:))*sqrt(zu2(:))
332!        tst(:)=(ph(:,1)-ptsrf(:))*zcdh_true(:)/sqrt(zcdv_true(:))
[284]333        ELSE
334        zcdv(:)=zcdv_true(:)*sqrt(zu2(:))     ! 1 / bulk aerodynamic momentum conductance
335        zcdh(:)=zcdh_true(:)*sqrt(zu2(:))     ! 1 / bulk aerodynamic heat conductance
[473]336!        ust(:)=sqrt(zcdv_true(:))*sqrt(zu2(:))
337!        tst(:)=(ph(:,1)-ptsrf(:))*zcdh(:)/ust(:)
[290]338        ENDIF
[38]339
[290]340
[256]341! Some usefull diagnostics for the new surface layer parametrization :
342
[268]343!         call WRITEDIAGFI(ngridmx,'pcdv',
[256]344!     &              'momentum drag','no units',
345!     &                         2,zcdv_true)
[268]346!        call WRITEDIAGFI(ngridmx,'pcdh',
[256]347!     &              'heat drag','no units',
348!     &                         2,zcdh_true)
[496]349!        call WRITEDIAGFI(ngridmx,'ust',
[473]350!     &              'friction velocity','m/s',2,ust)
[496]351!       call WRITEDIAGFI(ngridmx,'tst',
[473]352!     &              'friction temperature','K',2,tst)
[268]353!        call WRITEDIAGFI(ngridmx,'rm-1',
354!     &              'aerodyn momentum conductance','m/s',
[256]355!     &                         2,zcdv)
[268]356!        call WRITEDIAGFI(ngridmx,'rh-1',
357!     &              'aerodyn heat conductance','m/s',
[256]358!     &                         2,zcdh)
359
[38]360c    ** schema de diffusion turbulente dans la couche limite
361c       ----------------------------------------------------
[496]362!
363       CALL vdif_kc(ptimestep,g,pzlev,pzlay
[38]364     &              ,pu,pv,ph,zcdv_true
[325]365     &              ,pq2,zkv,zkh,zq)
[496]366!
367!      pt(:,:)=ph(:,:)*ppopsk(:,:)
368!      CALL yamada4(ngrid,nlay,ptimestep,g,r,pplev,pt
369!     s   ,pzlev,pzlay,pu,pv,ph,zcdv_true,pq2,zkv,zkh,zkq,ust
370!     s   ,8)
[38]371
372      if ((doubleq).and.(ngrid.eq.1)) then
373        kmixmin = 80. !80.! minimum eddy mix coeff in 1D
374        do ilev=1,nlay
375          do ig=1,ngrid
376           zkh(ig,ilev) = max(kmixmin,zkh(ig,ilev))
377           zkv(ig,ilev) = max(kmixmin,zkv(ig,ilev))
378          end do
379        end do
380      end if
381
382c    ** diagnostique pour le schema de turbulence
383c       -----------------------------------------
384
385      IF(lecrit) THEN
386         PRINT*
387         PRINT*,'Diagnostic for the vertical turbulent mixing'
388         PRINT*,'Cd for momentum and potential temperature'
389
390         PRINT*,zcdv(ngrid/2+1),zcdh(ngrid/2+1)
391         PRINT*,'Mixing coefficient for momentum and pot.temp.'
392         DO ilev=1,nlay
393            PRINT*,zkv(ngrid/2+1,ilev),zkh(ngrid/2+1,ilev)
394         ENDDO
395      ENDIF
396
397
398
399
400c-----------------------------------------------------------------------
401c   4. inversion pour l'implicite sur u
402c      --------------------------------
403
404c    ** l'equation est
405c       u(t+1) =  u(t) + dt * {(du/dt)phys}(t)  +  dt * {(du/dt)difv}(t+1)
406c       avec
407c       /zu/ = u(t) + dt * {(du/dt)phys}(t)   (voir paragraphe 2.)
408c       et
409c       dt * {(du/dt)difv}(t+1) = dt * {(d/dz)[ Ku (du/dz) ]}(t+1)
410c       donc les entrees sont /zcdv/ pour la condition a la limite sol
411c       et /zkv/ = Ku
412 
413      CALL multipl((nlay-1)*ngrid,zkv(1,2),zb0(1,2),zb(1,2))
414      CALL multipl(ngrid,zcdv,zb0,zb)
415
416      DO ig=1,ngrid
417         z1(ig)=1./(za(ig,nlay)+zb(ig,nlay))
418         zc(ig,nlay)=za(ig,nlay)*zu(ig,nlay)*z1(ig)
419         zd(ig,nlay)=zb(ig,nlay)*z1(ig)
420      ENDDO
421
422      DO ilay=nlay-1,1,-1
423         DO ig=1,ngrid
424            z1(ig)=1./(za(ig,ilay)+zb(ig,ilay)+
425     $         zb(ig,ilay+1)*(1.-zd(ig,ilay+1)))
426            zc(ig,ilay)=(za(ig,ilay)*zu(ig,ilay)+
427     $         zb(ig,ilay+1)*zc(ig,ilay+1))*z1(ig)
428            zd(ig,ilay)=zb(ig,ilay)*z1(ig)
429         ENDDO
430      ENDDO
431
432      DO ig=1,ngrid
433         zu(ig,1)=zc(ig,1)
434      ENDDO
435      DO ilay=2,nlay
436         DO ig=1,ngrid
437            zu(ig,ilay)=zc(ig,ilay)+zd(ig,ilay)*zu(ig,ilay-1)
438         ENDDO
439      ENDDO
440
441
442
443
444
445c-----------------------------------------------------------------------
446c   5. inversion pour l'implicite sur v
447c      --------------------------------
448
449c    ** l'equation est
450c       v(t+1) =  v(t) + dt * {(dv/dt)phys}(t)  +  dt * {(dv/dt)difv}(t+1)
451c       avec
452c       /zv/ = v(t) + dt * {(dv/dt)phys}(t)   (voir paragraphe 2.)
453c       et
454c       dt * {(dv/dt)difv}(t+1) = dt * {(d/dz)[ Kv (dv/dz) ]}(t+1)
455c       donc les entrees sont /zcdv/ pour la condition a la limite sol
456c       et /zkv/ = Kv
457
458      DO ig=1,ngrid
459         z1(ig)=1./(za(ig,nlay)+zb(ig,nlay))
460         zc(ig,nlay)=za(ig,nlay)*zv(ig,nlay)*z1(ig)
461         zd(ig,nlay)=zb(ig,nlay)*z1(ig)
462      ENDDO
463
464      DO ilay=nlay-1,1,-1
465         DO ig=1,ngrid
466            z1(ig)=1./(za(ig,ilay)+zb(ig,ilay)+
467     $         zb(ig,ilay+1)*(1.-zd(ig,ilay+1)))
468            zc(ig,ilay)=(za(ig,ilay)*zv(ig,ilay)+
469     $         zb(ig,ilay+1)*zc(ig,ilay+1))*z1(ig)
470            zd(ig,ilay)=zb(ig,ilay)*z1(ig)
471         ENDDO
472      ENDDO
473
474      DO ig=1,ngrid
475         zv(ig,1)=zc(ig,1)
476      ENDDO
477      DO ilay=2,nlay
478         DO ig=1,ngrid
479            zv(ig,ilay)=zc(ig,ilay)+zd(ig,ilay)*zv(ig,ilay-1)
480         ENDDO
481      ENDDO
482
483
484
485
486
487c-----------------------------------------------------------------------
488c   6. inversion pour l'implicite sur h sans oublier le couplage
489c      avec le sol (conduction)
490c      ------------------------
491
492c    ** l'equation est
493c       h(t+1) =  h(t) + dt * {(dh/dt)phys}(t)  +  dt * {(dh/dt)difv}(t+1)
494c       avec
495c       /zh/ = h(t) + dt * {(dh/dt)phys}(t)   (voir paragraphe 2.)
496c       et
497c       dt * {(dh/dt)difv}(t+1) = dt * {(d/dz)[ Kh (dh/dz) ]}(t+1)
498c       donc les entrees sont /zcdh/ pour la condition de raccord au sol
499c       et /zkh/ = Kh
500c       -------------
501
[473]502c Mass variation scheme:
[38]503      CALL multipl((nlay-1)*ngrid,zkh(1,2),zb0(1,2),zb(1,2))
504      CALL multipl(ngrid,zcdh,zb0,zb)
505
[473]506c on initialise dm c
507     
508      pdtc(:,:)=0.
509      zt(:,:)=0.
510      dmice(:,:)=0.
[38]511
512c    ** calcul de (d Planck / dT) a la temperature d'interface
513c       ------------------------------------------------------
514
515      z4st=4.*5.67e-8*ptimestep
516      DO ig=1,ngrid
517         zdplanck(ig)=z4st*pemis(ig)*ptsrf(ig)*ptsrf(ig)*ptsrf(ig)
518      ENDDO
519
[473]520
521! calcul de zc et zd pour la couche top en prenant en compte le terme
522! de variation de masse (on fait une boucle pour que ça converge)
523
524! Identification des points de grilles qui ont besoin de la correction
525
526      llnt(:)=1
527
528      DO ig=1,ngrid
529         DO l=1,nlay
530            if(zh(ig,l) .lt. zhcond(ig,l)) then
531               llnt(ig)=300 
532! 200 and 100 do not go beyond month 9 with normal dissipation
533               goto 5
534            endif
535         ENDDO
5365     continue
537      ENDDO
538
539      DO ig=1,ngrid
540
541! Initialization of z1 and zd, which do not depend on dmice
542
543      z1(ig)=1./(za(ig,nlay)+zb(ig,nlay))
544      zd(ig,nlay)=zb(ig,nlay)*z1(ig)
545
546      DO ilay=nlay-1,1,-1
547          z1(ig)=1./(za(ig,ilay)+zb(ig,ilay)+
548     $        zb(ig,ilay+1)*(1.-zd(ig,ilay+1)))
549          zd(ig,ilay)=zb(ig,ilay)*z1(ig)
550      ENDDO
551
552! Convergence loop
553
554      DO j=1,llnt(ig)
555
556            z1(ig)=1./(za(ig,nlay)+zb(ig,nlay))
557            zc(ig,nlay)=za(ig,nlay)*zh(ig,nlay)
558     &      -betam(ig,nlay)*dmice(ig,nlay)
559            zc(ig,nlay)=zc(ig,nlay)*z1(ig)
560!            zd(ig,nlay)=zb(ig,nlay)*z1(ig)
561
562! calcul de zc et zd pour les couches du haut vers le bas
563
564             DO ilay=nlay-1,1,-1
565               z1(ig)=1./(za(ig,ilay)+zb(ig,ilay)+
566     $            zb(ig,ilay+1)*(1.-zd(ig,ilay+1)))
567               zc(ig,ilay)=(za(ig,ilay)*zh(ig,ilay)+
568     $            zb(ig,ilay+1)*zc(ig,ilay+1)-
569     $            betam(ig,ilay)*dmice(ig,ilay))*z1(ig)
570!               zd(ig,ilay)=zb(ig,ilay)*z1(ig)
571            ENDDO
572
[38]573c    ** calcul de la temperature_d'interface et de sa tendance.
574c       on ecrit que la somme des flux est nulle a l'interface
575c       a t + \delta t,
576c       c'est a dire le flux radiatif a {t + \delta t}
577c       + le flux turbulent a {t + \delta t}
578c            qui s'ecrit K (T1-Tsurf) avec T1 = d1 Tsurf + c1
579c            (notation K dt = /cpp*b/)       
580c       + le flux dans le sol a t
581c       + l'evolution du flux dans le sol lorsque la temperature d'interface
582c       passe de sa valeur a t a sa valeur a {t + \delta t}.
583c       ----------------------------------------------------
584
585         z1(ig)=pcapcal(ig)*ptsrf(ig)+cpp*zb(ig,1)*zc(ig,1)
586     s     +zdplanck(ig)*ptsrf(ig)+ pfluxsrf(ig)*ptimestep
587         z2(ig)= pcapcal(ig)+cpp*zb(ig,1)*(1.-zd(ig,1))+zdplanck(ig)
588         ztsrf2(ig)=z1(ig)/z2(ig)
[473]589!         pdtsrf(ig)=(ztsrf2(ig)-ptsrf(ig))/ptimestep  !incremented outside loop
[38]590
[473]591            zhs(ig,1)=zc(ig,1)+zd(ig,1)*ztsrf2(ig)
[38]592
593c    ** et a partir de la temperature au sol on remonte
594c       -----------------------------------------------
595
[473]596            DO ilay=2,nlay
597               zhs(ig,ilay)=zc(ig,ilay)+zd(ig,ilay)*zhs(ig,ilay-1)
598            ENDDO
599            DO ilay=1,nlay
600               zt(ig,ilay)=zhs(ig,ilay)*ppopsk(ig,ilay)
601            ENDDO
602
603c      Condensation/sublimation in the atmosphere
604c      ------------------------------------------
605c      (computation of zcondicea and dmice)
606
607      zcondicea(ig,:)=0.
608      pdtc(ig,:)=0.
609
610      DO l=nlay , 1, -1
611           IF(zt(ig,l).LT.ztcond(ig,l)) THEN
612               pdtc(ig,l)=(ztcond(ig,l) - zt(ig,l))/ptimestep
613               zcondicea(ig,l)=(pplev(ig,l)-pplev(ig,l+1))
614     &                        *ccond*pdtc(ig,l)
615              dmice(ig,l)= dmice(ig,l) + zcondicea(ig,l)*ptimestep
616            END IF
[38]617      ENDDO
618
[473]619         ENDDO    !of Do j=1,XXX
[38]620
[473]621      ENDDO   !of Do ig=1,nlay
622
623      pdtsrf(:)=(ztsrf2(:)-ptsrf(:))/ptimestep
624
625
[38]626c-----------------------------------------------------------------------
627c   TRACERS
628c   -------
629
630      if(tracer) then
631
632c     Using the wind modified by friction for lifting and  sublimation
633c     ----------------------------------------------------------------
634        DO ig=1,ngrid
[284]635          zu2(ig)=zu(ig,1)*zu(ig,1)+zv(ig,1)*zv(ig,1)
636          zcdv(ig)=zcdv_true(ig)*sqrt(zu2(ig))
637          zcdh(ig)=zcdh_true(ig)*sqrt(zu2(ig))
[38]638        ENDDO
639
640c       Calcul du flux vertical au bas de la premiere couche (dust) :
641c       -----------------------------------------------------------
642        do ig=1,ngridmx 
643          rho(ig) = zb0(ig,1) /ptimestep
644c          zb(ig,1) = 0.
645        end do
646c       Dust lifting:
647        if (lifting) then
[310]648#ifndef MESOSCALE
[38]649           if (doubleq.AND.submicron) then
650             do ig=1,ngrid
651c              if(co2ice(ig).lt.1) then
652                 pdqsdif(ig,igcm_dust_mass) =
653     &             -alpha_lift(igcm_dust_mass) 
654                 pdqsdif(ig,igcm_dust_number) =
655     &             -alpha_lift(igcm_dust_number) 
656                 pdqsdif(ig,igcm_dust_submicron) =
657     &             -alpha_lift(igcm_dust_submicron)
658c              end if
659             end do
660           else if (doubleq) then
661             do ig=1,ngrid
[77]662           !!! soulevement constant
[38]663                 pdqsdif(ig,igcm_dust_mass) =
664     &             -alpha_lift(igcm_dust_mass) 
665                 pdqsdif(ig,igcm_dust_number) =
666     &             -alpha_lift(igcm_dust_number) 
667             end do
668           else if (submicron) then
669             do ig=1,ngrid
670                 pdqsdif(ig,igcm_dust_submicron) =
671     &             -alpha_lift(igcm_dust_submicron)
672             end do
673           else
674            call dustlift(ngrid,nlay,nq,rho,zcdh_true,zcdh,co2ice,
675     &                    pdqsdif)
676           endif !doubleq.AND.submicron
[310]677#else
678            call dustlift(ngrid,nlay,nq,rho,zcdh_true,zcdh,co2ice,
679     &                    pdqsdif)
680#endif
[38]681        else
682           pdqsdif(1:ngrid,1:nq) = 0.
683        end if
684
685c       OU calcul de la valeur de q a la surface (water)  :
686c       ----------------------------------------
687        if (water) then
688            call watersat(ngridmx,ptsrf,pplev(1,1),qsat)
689        end if
690
691c      Inversion pour l'implicite sur q
692c       --------------------------------
693        do iq=1,nq
694          CALL multipl((nlay-1)*ngrid,zkh(1,2),zb0(1,2),zb(1,2))
695
696          if ((water).and.(iq.eq.igcm_h2o_vap)) then
697c            This line is required to account for turbulent transport
698c            from surface (e.g. ice) to mid-layer of atmosphere:
699             CALL multipl(ngrid,zcdv,zb0,zb(1,1))
700             CALL multipl(ngrid,dryness,zb(1,1),zb(1,1))
701          else ! (re)-initialize zb(:,1)
702             zb(1:ngrid,1)=0
703          end if
704
705          DO ig=1,ngrid
706               z1(ig)=1./(za(ig,nlay)+zb(ig,nlay))
707               zc(ig,nlay)=za(ig,nlay)*zq(ig,nlay,iq)*z1(ig)
708               zd(ig,nlay)=zb(ig,nlay)*z1(ig)
709          ENDDO
710 
711          DO ilay=nlay-1,2,-1
712               DO ig=1,ngrid
713                z1(ig)=1./(za(ig,ilay)+zb(ig,ilay)+
714     $           zb(ig,ilay+1)*(1.-zd(ig,ilay+1)))
715                zc(ig,ilay)=(za(ig,ilay)*zq(ig,ilay,iq)+
716     $           zb(ig,ilay+1)*zc(ig,ilay+1))*z1(ig)
717                zd(ig,ilay)=zb(ig,ilay)*z1(ig)
718               ENDDO
719          ENDDO
720
721          if (water.and.(iq.eq.igcm_h2o_ice)) then
722            ! special case for water ice tracer: do not include
723            ! h2o ice tracer from surface (which is set when handling
[473]724           ! h2o vapour case (see further down).
[38]725            DO ig=1,ngrid
726                z1(ig)=1./(za(ig,1)+zb(ig,1)+
727     $           zb(ig,2)*(1.-zd(ig,2)))
728                zc(ig,1)=(za(ig,1)*zq(ig,1,iq)+
729     $         zb(ig,2)*zc(ig,2)) *z1(ig)
730            ENDDO
731          else ! general case
732            DO ig=1,ngrid
733                z1(ig)=1./(za(ig,1)+zb(ig,1)+
734     $           zb(ig,2)*(1.-zd(ig,2)))
735                zc(ig,1)=(za(ig,1)*zq(ig,1,iq)+
736     $         zb(ig,2)*zc(ig,2) +
737     $        (-pdqsdif(ig,iq)) *ptimestep) *z1(ig)  !tracer flux from surface
738            ENDDO
739          endif ! of if (water.and.(iq.eq.igcm_h2o_ice))
740 
741          IF ((water).and.(iq.eq.igcm_h2o_vap)) then
742c           Calculation for turbulent exchange with the surface (for ice)
743            DO ig=1,ngrid
744              zd(ig,1)=zb(ig,1)*z1(ig)
745              zq1temp(ig)=zc(ig,1)+ zd(ig,1)*qsat(ig)
746
747              pdqsdif(ig,igcm_h2o_ice)=rho(ig)*dryness(ig)*zcdv(ig)
748     &                       *(zq1temp(ig)-qsat(ig))
749c             write(*,*)'flux vers le sol=',pdqsdif(ig,nq)
750            END DO
751
752            DO ig=1,ngrid
753              if(.not.watercaptag(ig)) then
754                if ((-pdqsdif(ig,igcm_h2o_ice)*ptimestep)
755     &             .gt.pqsurf(ig,igcm_h2o_ice)) then
756c                 write(*,*)'on sublime plus que qsurf!'
757                  pdqsdif(ig,igcm_h2o_ice)=
758     &                         -pqsurf(ig,igcm_h2o_ice)/ptimestep
759c                 write(*,*)'flux vers le sol=',pdqsdif(ig,nq)
760                  z1(ig)=1./(za(ig,1)+ zb(ig,2)*(1.-zd(ig,2)))
761                  zc(ig,1)=(za(ig,1)*zq(ig,1,igcm_h2o_vap)+
762     $            zb(ig,2)*zc(ig,2) +
763     $            (-pdqsdif(ig,igcm_h2o_ice)) *ptimestep) *z1(ig)
764                  zq1temp(ig)=zc(ig,1)
765                endif   
766              endif ! if (.not.watercaptag(ig))
767c             Starting upward calculations for water :
768               zq(ig,1,igcm_h2o_vap)=zq1temp(ig)
769            ENDDO ! of DO ig=1,ngrid
770          ELSE
771c           Starting upward calculations for simple mixing of tracer (dust)
772            DO ig=1,ngrid
773               zq(ig,1,iq)=zc(ig,1)
774            ENDDO
775          END IF ! of IF ((water).and.(iq.eq.igcm_h2o_vap))
776
777          DO ilay=2,nlay
778             DO ig=1,ngrid
779                zq(ig,ilay,iq)=zc(ig,ilay)+zd(ig,ilay)*zq(ig,ilay-1,iq)
780             ENDDO
781          ENDDO
782        enddo ! of do iq=1,nq
783      end if ! of if(tracer)
784
785c-----------------------------------------------------------------------
786c   8. calcul final des tendances de la diffusion verticale
787c      ----------------------------------------------------
788
789      DO ilev = 1, nlay
790         DO ig=1,ngrid
791            pdudif(ig,ilev)=(    zu(ig,ilev)-
792     $      (pu(ig,ilev)+pdufi(ig,ilev)*ptimestep)    )/ptimestep
793            pdvdif(ig,ilev)=(    zv(ig,ilev)-
794     $      (pv(ig,ilev)+pdvfi(ig,ilev)*ptimestep)    )/ptimestep
[473]795            hh = ph(ig,ilev)+pdhfi(ig,ilev)*ptimestep
796     $  + (latcond*dmice(ig,ilev)/cpp)/ppopsk(ig,ilev)
797            pdhdif(ig,ilev)=( zhs(ig,ilev)- hh )/ptimestep
[38]798         ENDDO
799      ENDDO
800
801      if (tracer) then
802        DO iq = 1, nq
803          DO ilev = 1, nlay
804            DO ig=1,ngrid
805              pdqdif(ig,ilev,iq)=(zq(ig,ilev,iq)-
806     $      (pq(ig,ilev,iq) + pdqfi(ig,ilev,iq)*ptimestep))/ptimestep
807            ENDDO
808          ENDDO
809        ENDDO
810      end if
811
812c    ** diagnostique final
813c       ------------------
814
815      IF(lecrit) THEN
816         PRINT*,'In vdif'
817         PRINT*,'Ts (t) and Ts (t+st)'
818         WRITE(*,'(a10,3a15)')
819     s   'theta(t)','theta(t+dt)','u(t)','u(t+dt)'
820         PRINT*,ptsrf(ngrid/2+1),ztsrf2(ngrid/2+1)
821         DO ilev=1,nlay
822            WRITE(*,'(4f15.7)')
[473]823     s      ph(ngrid/2+1,ilev),zhs(ngrid/2+1,ilev),
[38]824     s      pu(ngrid/2+1,ilev),zu(ngrid/2+1,ilev)
825
826         ENDDO
827      ENDIF
828
829      RETURN
830      END
Note: See TracBrowser for help on using the repository browser.