source: trunk/LMDZ.MARS/libf/phymars/vdifc_mod.F @ 2350

Last change on this file since 2350 was 2316, checked in by lrossi, 5 years ago

Mars GCM:
Fixing some errors in vdifc_mod related to variable watercap. This variable was also integrated to the hdo cycle.
Also added watercap output for the 1D model.
LR

File size: 33.9 KB
RevLine 
[1969]1      MODULE vdifc_mod
2     
3      IMPLICIT NONE
4     
5      CONTAINS
6     
[38]7      SUBROUTINE vdifc(ngrid,nlay,nq,co2ice,ppopsk,
8     $                ptimestep,pcapcal,lecrit,
9     $                pplay,pplev,pzlay,pzlev,pz0,
10     $                pu,pv,ph,pq,ptsrf,pemis,pqsurf,
11     $                pdufi,pdvfi,pdhfi,pdqfi,pfluxsrf,
12     $                pdudif,pdvdif,pdhdif,pdtsrf,pq2,
[660]13     $                pdqdif,pdqsdif,wstar,zcdv_true,zcdh_true,
[1996]14     $                hfmax,pcondicea_co2microp,sensibFlux,
[2260]15     $                dustliftday,local_time,watercap, dwatercap_dif)
[1236]16
[1036]17      use tracer_mod, only: noms, igcm_dust_mass, igcm_dust_number,
18     &                      igcm_dust_submicron, igcm_h2o_vap,
[1974]19     &                      igcm_h2o_ice, alpha_lift,
[2312]20     &                      igcm_hdo_vap, igcm_hdo_ice,
[1974]21     &                      igcm_stormdust_mass, igcm_stormdust_number
[1224]22      use surfdat_h, only: watercaptag, frost_albedo_threshold, dryness
[1969]23      USE comcstfi_h, ONLY: cpp, r, rcp, g
[1996]24      use watersat_mod, only: watersat
[1242]25      use turb_mod, only: turb_resolved, ustar, tstar
[2160]26      use compute_dtau_mod, only: ti_injection_sol,tf_injection_sol
[2312]27      use hdo_surfex_mod, only: hdo_surfex
28
[38]29      IMPLICIT NONE
30
31c=======================================================================
32c
33c   subject:
34c   --------
35c   Turbulent diffusion (mixing) for potential T, U, V and tracer
36c
37c   Shema implicite
38c   On commence par rajouter au variables x la tendance physique
39c   et on resoult en fait:
40c      x(t+1) =  x(t) + dt * (dx/dt)phys(t)  +  dt * (dx/dt)difv(t+1)
41c
42c   author:
43c   ------
44c      Hourdin/Forget/Fournier
45c=======================================================================
46
47c-----------------------------------------------------------------------
48c   declarations:
49c   -------------
50
[1944]51      include "callkeys.h"
52      include "microphys.h"
[38]53
54c
55c   arguments:
56c   ----------
57
[1036]58      INTEGER,INTENT(IN) :: ngrid,nlay
59      REAL,INTENT(IN) :: ptimestep
60      REAL,INTENT(IN) :: pplay(ngrid,nlay),pplev(ngrid,nlay+1)
61      REAL,INTENT(IN) :: pzlay(ngrid,nlay),pzlev(ngrid,nlay+1)
62      REAL,INTENT(IN) :: pu(ngrid,nlay),pv(ngrid,nlay)
63      REAL,INTENT(IN) :: ph(ngrid,nlay)
64      REAL,INTENT(IN) :: ptsrf(ngrid),pemis(ngrid)
65      REAL,INTENT(IN) :: pdufi(ngrid,nlay),pdvfi(ngrid,nlay)
66      REAL,INTENT(IN) :: pdhfi(ngrid,nlay)
67      REAL,INTENT(IN) :: pfluxsrf(ngrid)
68      REAL,INTENT(OUT) :: pdudif(ngrid,nlay),pdvdif(ngrid,nlay)
69      REAL,INTENT(OUT) :: pdtsrf(ngrid),pdhdif(ngrid,nlay)
[1130]70      REAL,INTENT(IN) :: pcapcal(ngrid)
71      REAL,INTENT(INOUT) :: pq2(ngrid,nlay+1)
[38]72
73c    Argument added for condensation:
[1036]74      REAL,INTENT(IN) :: co2ice (ngrid), ppopsk(ngrid,nlay)
75      logical,INTENT(IN) :: lecrit
[1996]76      REAL,INTENT(IN) :: pcondicea_co2microp(ngrid,nlay)! tendency due to CO2 condensation (kg/kg.s-1)
77     
[1036]78      REAL,INTENT(IN) :: pz0(ngrid) ! surface roughness length (m)
[224]79
[256]80c    Argument added to account for subgrid gustiness :
81
[1944]82      REAL,INTENT(IN) :: wstar(ngrid), hfmax(ngrid)!, zi(ngrid)
[256]83
[38]84c    Traceurs :
[1036]85      integer,intent(in) :: nq
86      REAL,INTENT(IN) :: pqsurf(ngrid,nq)
87      real,intent(in) :: pq(ngrid,nlay,nq), pdqfi(ngrid,nlay,nq)
88      real,intent(out) :: pdqdif(ngrid,nlay,nq)
[1974]89      real,intent(out) :: pdqsdif(ngrid,nq)
90      REAL,INTENT(in) :: dustliftday(ngrid)
91      REAL,INTENT(in) :: local_time(ngrid)
[38]92     
93c   local:
94c   ------
95
[1130]96      REAL :: pt(ngrid,nlay)
[473]97 
[38]98      INTEGER ilev,ig,ilay,nlev
99
[1047]100      REAL z4st,zdplanck(ngrid)
101      REAL zkv(ngrid,nlay+1),zkh(ngrid,nlay+1)
102      REAL zkq(ngrid,nlay+1)
103      REAL zcdv(ngrid),zcdh(ngrid)
104      REAL zcdv_true(ngrid),zcdh_true(ngrid)    ! drag coeff are used by the LES to recompute u* and hfx
105      REAL zu(ngrid,nlay),zv(ngrid,nlay)
106      REAL zh(ngrid,nlay)
107      REAL ztsrf2(ngrid)
108      REAL z1(ngrid),z2(ngrid)
109      REAL za(ngrid,nlay),zb(ngrid,nlay)
110      REAL zb0(ngrid,nlay)
111      REAL zc(ngrid,nlay),zd(ngrid,nlay)
[38]112      REAL zcst1
[1047]113      REAL zu2(ngrid)
[38]114
115      EXTERNAL SSUM,SCOPY
116      REAL SSUM
[1036]117      LOGICAL,SAVE :: firstcall=.true.
[38]118
[626]119
[38]120c     variable added for CO2 condensation:
121c     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[1047]122      REAL hh , zhcond(ngrid,nlay)
123      REAL,PARAMETER :: latcond=5.9e5
124      REAL,PARAMETER :: tcond1mb=136.27
125      REAL,SAVE :: acond,bcond
[669]126     
[2179]127c     For latent heat release from ground water ice sublimation   
128      REAL tsrf_lh(ngrid) ! temporary surface temperature
129      REAL lh ! latent heat, formulation given in the Technical Document:
130              ! "Modeling water ice sublimation under Phoenix-like conditions", Montmessin et al. 2004 
[1047]131!      REAL tsrf_lw(ngrid)
[1036]132!      REAL alpha
[2179]133!      REAL T1,T2
134!      SAVE T1,T2
135!      DATA T1,T2/-604.3,1080.7/ ! zeros of latent heat equation for ice
[38]136
137c    Tracers :
138c    ~~~~~~~
139      INTEGER iq
[1047]140      REAL zq(ngrid,nlay,nq)
141      REAL zq1temp(ngrid)
142      REAL rho(ngrid) ! near surface air density
143      REAL qsat(ngrid)
[38]144
[2312]145      REAL hdoflux(ngrid)       ! value of vapour flux of HDO
146      REAL h2oflux(ngrid)       ! value of vapour flux of H2O
147      REAL old_h2o_vap(ngrid)   ! traceur d'eau avant traitement
148
[38]149      REAL kmixmin
150
[2260]151c    Argument added for surface water ice budget:
152      REAL,INTENT(IN) :: watercap(ngrid)
153      REAL,INTENT(OUT) :: dwatercap_dif(ngrid)
154
[473]155c    Mass-variation scheme :
156c    ~~~~~~~
157
158      INTEGER j,l
[1047]159      REAL zcondicea(ngrid,nlay)
160      REAL zt(ngrid,nlay),ztcond(ngrid,nlay+1)
161      REAL betam(ngrid,nlay),dmice(ngrid,nlay)
162      REAL pdtc(ngrid,nlay)
163      REAL zhs(ngrid,nlay)
164      REAL,SAVE :: ccond
[473]165
166c     Theta_m formulation for mass-variation scheme :
167c     ~~~~~~~
168
[1047]169      INTEGER,SAVE :: ico2
170      INTEGER llnt(ngrid)
171      REAL,SAVE :: m_co2, m_noco2, A , B
172      REAL vmr_co2(ngrid,nlay)
[473]173      REAL qco2,mmean
174
[1047]175      REAL,INTENT(OUT) :: sensibFlux(ngrid)
[660]176
[2312]177!!MARGAUX
178      REAL DoH_vap(ngrid,nlay)
179
[38]180c    ** un petit test de coherence
181c       --------------------------
182
[1779]183      ! AS: OK firstcall absolute
[38]184      IF (firstcall) THEN
185c        To compute: Tcond= 1./(bcond-acond*log(.0095*p)) (p in pascal)
186         bcond=1./tcond1mb
187         acond=r/latcond
[473]188         ccond=cpp/(g*latcond)
[38]189         PRINT*,'In vdifc: Tcond(P=1mb)=',tcond1mb,' Lcond=',latcond
[473]190         PRINT*,'          acond,bcond,ccond',acond,bcond,ccond
[38]191
[473]192
193         ico2=0
194
195         if (tracer) then
196c          Prepare Special treatment if one of the tracer is CO2 gas
[1036]197           do iq=1,nq
[473]198             if (noms(iq).eq."co2") then
199                ico2=iq
200                m_co2 = 44.01E-3  ! CO2 molecular mass (kg/mol)
201                m_noco2 = 33.37E-3  ! Non condensible mol mass (kg/mol)
202c               Compute A and B coefficient use to compute
203c               mean molecular mass Mair defined by
204c               1/Mair = q(ico2)/m_co2 + (1-q(ico2))/m_noco2
205c               1/Mair = A*q(ico2) + B
206                A =(1/m_co2 - 1/m_noco2)
207                B=1/m_noco2
208             endif
209           enddo
210         end if
211
[38]212        firstcall=.false.
213      ENDIF
214
215
216c-----------------------------------------------------------------------
217c    1. initialisation
218c    -----------------
219
220      nlev=nlay+1
221
[1035]222      ! initialize output tendencies to zero:
223      pdudif(1:ngrid,1:nlay)=0
224      pdvdif(1:ngrid,1:nlay)=0
225      pdhdif(1:ngrid,1:nlay)=0
226      pdtsrf(1:ngrid)=0
227      pdqdif(1:ngrid,1:nlay,1:nq)=0
228      pdqsdif(1:ngrid,1:nq)=0
[2260]229      dwatercap_dif(1:ngrid)=0
[1035]230
[38]231c    ** calcul de rho*dz et dt*rho/dz=dt*rho**2 g/dp
232c       avec rho=p/RT=p/ (R Theta) (p/ps)**kappa
233c       ----------------------------------------
234
235      DO ilay=1,nlay
236         DO ig=1,ngrid
237            za(ig,ilay)=(pplev(ig,ilay)-pplev(ig,ilay+1))/g
[473]238! Mass variation scheme:
239            betam(ig,ilay)=-za(ig,ilay)*latcond/(cpp*ppopsk(ig,ilay))
[38]240         ENDDO
241      ENDDO
242
243      zcst1=4.*g*ptimestep/(r*r)
244      DO ilev=2,nlev-1
245         DO ig=1,ngrid
246            zb0(ig,ilev)=pplev(ig,ilev)*
247     s      (pplev(ig,1)/pplev(ig,ilev))**rcp /
248     s      (ph(ig,ilev-1)+ph(ig,ilev))
249            zb0(ig,ilev)=zcst1*zb0(ig,ilev)*zb0(ig,ilev)/
250     s      (pplay(ig,ilev-1)-pplay(ig,ilev))
251         ENDDO
252      ENDDO
253      DO ig=1,ngrid
[473]254         zb0(ig,1)=ptimestep*pplev(ig,1)/(r*ptsrf(ig))
[38]255      ENDDO
256
257c    ** diagnostique pour l'initialisation
258c       ----------------------------------
259
260      IF(lecrit) THEN
261         ig=ngrid/2+1
262         PRINT*,'Pression (mbar) ,altitude (km),u,v,theta, rho dz'
263         DO ilay=1,nlay
264            WRITE(*,'(6f11.5)')
265     s      .01*pplay(ig,ilay),.001*pzlay(ig,ilay),
266     s      pu(ig,ilay),pv(ig,ilay),ph(ig,ilay),za(ig,ilay)
267         ENDDO
268         PRINT*,'Pression (mbar) ,altitude (km),zb'
269         DO ilev=1,nlay
270            WRITE(*,'(3f15.7)')
271     s      .01*pplev(ig,ilev),.001*pzlev(ig,ilev),
272     s      zb0(ig,ilev)
273         ENDDO
274      ENDIF
275
[473]276c     -----------------------------------
[38]277c     Potential Condensation temperature:
278c     -----------------------------------
279
[473]280c     Compute CO2 Volume mixing ratio
281c     -------------------------------
282      if (callcond.and.(ico2.ne.0)) then
283         DO ilev=1,nlay
284            DO ig=1,ngrid
[529]285              qco2=MAX(1.E-30
286     &             ,pq(ig,ilev,ico2)+pdqfi(ig,ilev,ico2)*ptimestep)
[473]287c             Mean air molecular mass = 1/(q(ico2)/m_co2 + (1-q(ico2))/m_noco2)
288              mmean=1/(A*qco2 +B)
289              vmr_co2(ig,ilev) = qco2*mmean/m_co2
290            ENDDO
291         ENDDO
292      else
293         DO ilev=1,nlay
294            DO ig=1,ngrid
295              vmr_co2(ig,ilev)=0.95
296            ENDDO
297         ENDDO
298      end if
[38]299
[473]300c     forecast of atmospheric temperature zt and frost temperature ztcond
301c     --------------------------------------------------------------------
[38]302
[473]303      if (callcond) then
304        DO ilev=1,nlay
305          DO ig=1,ngrid
[884]306              ztcond(ig,ilev)=
307     &      1./(bcond-acond*log(.01*vmr_co2(ig,ilev)*pplay(ig,ilev)))
308            if (pplay(ig,ilev).lt.1e-4) ztcond(ig,ilev)=0.0 !mars Monica
[473]309!            zhcond(ig,ilev) =
310!     &  (1./(bcond-acond*log(.0095*pplay(ig,ilev))))/ppopsk(ig,ilev)
311              zhcond(ig,ilev) = ztcond(ig,ilev)/ppopsk(ig,ilev)
312          END DO
313        END DO
[884]314        ztcond(:,nlay+1)=ztcond(:,nlay)
[473]315      else
[884]316         zhcond(:,:) = 0
317         ztcond(:,:) = 0
[473]318      end if
319
320
[38]321c-----------------------------------------------------------------------
322c   2. ajout des tendances physiques
323c      -----------------------------
324
325      DO ilev=1,nlay
326         DO ig=1,ngrid
327            zu(ig,ilev)=pu(ig,ilev)+pdufi(ig,ilev)*ptimestep
328            zv(ig,ilev)=pv(ig,ilev)+pdvfi(ig,ilev)*ptimestep
329            zh(ig,ilev)=ph(ig,ilev)+pdhfi(ig,ilev)*ptimestep
[473]330!            zh(ig,ilev)=max(zh(ig,ilev),zhcond(ig,ilev))
[38]331         ENDDO
332      ENDDO
333      if(tracer) then
334        DO iq =1, nq
335         DO ilev=1,nlay
336           DO ig=1,ngrid
337              zq(ig,ilev,iq)=pq(ig,ilev,iq)+pdqfi(ig,ilev,iq)*ptimestep
338           ENDDO
339         ENDDO
340        ENDDO
341      end if
342
343c-----------------------------------------------------------------------
344c   3. schema de turbulence
345c      --------------------
346
347c    ** source d'energie cinetique turbulente a la surface
348c       (condition aux limites du schema de diffusion turbulente
349c       dans la couche limite
350c       ---------------------
351
[499]352      CALL vdif_cd(ngrid,nlay,pz0,g,pzlay,pu,pv,wstar,ptsrf,ph
[1236]353     &             ,zcdv_true,zcdh_true)
[256]354
[290]355        zu2(:)=pu(:,1)*pu(:,1)+pv(:,1)*pv(:,1)
[256]356
[291]357        IF (callrichsl) THEN
[545]358          zcdv(:)=zcdv_true(:)*sqrt(zu2(:)+
359     &     (log(1.+0.7*wstar(:) + 2.3*wstar(:)**2))**2)
360          zcdh(:)=zcdh_true(:)*sqrt(zu2(:)+
361     &     (log(1.+0.7*wstar(:) + 2.3*wstar(:)**2))**2)
[496]362
[1242]363           ustar(:)=sqrt(zcdv_true(:))*sqrt(zu2(:)+
[545]364     &     (log(1.+0.7*wstar(:) + 2.3*wstar(:)**2))**2)
365
[1242]366           tstar(:)=0.
[545]367           DO ig=1,ngrid
368              IF (zcdh_true(ig) .ne. 0.) THEN      ! When Cd=Ch=0, u*=t*=0
[1242]369                 tstar(ig)=(ph(ig,1)-ptsrf(ig))*zcdh(ig)/ustar(ig)
[545]370              ENDIF
371           ENDDO
372
[284]373        ELSE
[545]374           zcdv(:)=zcdv_true(:)*sqrt(zu2(:))     ! 1 / bulk aerodynamic momentum conductance
375           zcdh(:)=zcdh_true(:)*sqrt(zu2(:))     ! 1 / bulk aerodynamic heat conductance
[1242]376           ustar(:)=sqrt(zcdv_true(:))*sqrt(zu2(:))
377           tstar(:)=(ph(:,1)-ptsrf(:))*zcdh_true(:)/sqrt(zcdv_true(:))
[290]378        ENDIF
[38]379
[529]380! Some usefull diagnostics for the new surface layer parametrization :
[290]381
[1130]382!        call WRITEDIAGFI(ngrid,'vdifc_zcdv_true',
[256]383!     &              'momentum drag','no units',
384!     &                         2,zcdv_true)
[1130]385!        call WRITEDIAGFI(ngrid,'vdifc_zcdh_true',
[256]386!     &              'heat drag','no units',
387!     &                         2,zcdh_true)
[1130]388!        call WRITEDIAGFI(ngrid,'vdifc_ust',
[473]389!     &              'friction velocity','m/s',2,ust)
[1130]390!       call WRITEDIAGFI(ngrid,'vdifc_tst',
[473]391!     &              'friction temperature','K',2,tst)
[1130]392!        call WRITEDIAGFI(ngrid,'vdifc_zcdv',
[268]393!     &              'aerodyn momentum conductance','m/s',
[256]394!     &                         2,zcdv)
[1130]395!        call WRITEDIAGFI(ngrid,'vdifc_zcdh',
[268]396!     &              'aerodyn heat conductance','m/s',
[256]397!     &                         2,zcdh)
398
[38]399c    ** schema de diffusion turbulente dans la couche limite
400c       ----------------------------------------------------
[1240]401       IF (.not. callyamada4) THEN
[529]402
[1130]403       CALL vdif_kc(ngrid,nlay,nq,ptimestep,g,pzlev,pzlay
[38]404     &              ,pu,pv,ph,zcdv_true
[325]405     &              ,pq2,zkv,zkh,zq)
[529]406
[544]407      ELSE
[38]408
[555]409      pt(:,:)=ph(:,:)*ppopsk(:,:)
[1036]410      CALL yamada4(ngrid,nlay,nq,ptimestep,g,r,pplev,pt
[1242]411     s   ,pzlev,pzlay,pu,pv,ph,pq,zcdv_true,pq2,zkv,zkh,zkq,ustar
[652]412     s   ,9)
[544]413      ENDIF
414
[38]415      if ((doubleq).and.(ngrid.eq.1)) then
416        kmixmin = 80. !80.! minimum eddy mix coeff in 1D
417        do ilev=1,nlay
418          do ig=1,ngrid
419           zkh(ig,ilev) = max(kmixmin,zkh(ig,ilev))
420           zkv(ig,ilev) = max(kmixmin,zkv(ig,ilev))
421          end do
422        end do
423      end if
424
425c    ** diagnostique pour le schema de turbulence
426c       -----------------------------------------
427
428      IF(lecrit) THEN
429         PRINT*
430         PRINT*,'Diagnostic for the vertical turbulent mixing'
431         PRINT*,'Cd for momentum and potential temperature'
432
433         PRINT*,zcdv(ngrid/2+1),zcdh(ngrid/2+1)
434         PRINT*,'Mixing coefficient for momentum and pot.temp.'
435         DO ilev=1,nlay
436            PRINT*,zkv(ngrid/2+1,ilev),zkh(ngrid/2+1,ilev)
437         ENDDO
438      ENDIF
439
440
441
442
443c-----------------------------------------------------------------------
444c   4. inversion pour l'implicite sur u
445c      --------------------------------
446
447c    ** l'equation est
448c       u(t+1) =  u(t) + dt * {(du/dt)phys}(t)  +  dt * {(du/dt)difv}(t+1)
449c       avec
450c       /zu/ = u(t) + dt * {(du/dt)phys}(t)   (voir paragraphe 2.)
451c       et
452c       dt * {(du/dt)difv}(t+1) = dt * {(d/dz)[ Ku (du/dz) ]}(t+1)
453c       donc les entrees sont /zcdv/ pour la condition a la limite sol
454c       et /zkv/ = Ku
[2312]455
[2274]456      zb(1:ngrid,2:nlay)=zkv(1:ngrid,2:nlay)*zb0(1:ngrid,2:nlay)
457      zb(1:ngrid,1)=zcdv(1:ngrid)*zb0(1:ngrid,1)
[38]458
459      DO ig=1,ngrid
460         z1(ig)=1./(za(ig,nlay)+zb(ig,nlay))
461         zc(ig,nlay)=za(ig,nlay)*zu(ig,nlay)*z1(ig)
462         zd(ig,nlay)=zb(ig,nlay)*z1(ig)
463      ENDDO
464
465      DO ilay=nlay-1,1,-1
466         DO ig=1,ngrid
467            z1(ig)=1./(za(ig,ilay)+zb(ig,ilay)+
468     $         zb(ig,ilay+1)*(1.-zd(ig,ilay+1)))
469            zc(ig,ilay)=(za(ig,ilay)*zu(ig,ilay)+
470     $         zb(ig,ilay+1)*zc(ig,ilay+1))*z1(ig)
471            zd(ig,ilay)=zb(ig,ilay)*z1(ig)
472         ENDDO
473      ENDDO
474
475      DO ig=1,ngrid
476         zu(ig,1)=zc(ig,1)
477      ENDDO
478      DO ilay=2,nlay
479         DO ig=1,ngrid
480            zu(ig,ilay)=zc(ig,ilay)+zd(ig,ilay)*zu(ig,ilay-1)
481         ENDDO
482      ENDDO
483
484
485
486
487
488c-----------------------------------------------------------------------
489c   5. inversion pour l'implicite sur v
490c      --------------------------------
491
492c    ** l'equation est
493c       v(t+1) =  v(t) + dt * {(dv/dt)phys}(t)  +  dt * {(dv/dt)difv}(t+1)
494c       avec
495c       /zv/ = v(t) + dt * {(dv/dt)phys}(t)   (voir paragraphe 2.)
496c       et
497c       dt * {(dv/dt)difv}(t+1) = dt * {(d/dz)[ Kv (dv/dz) ]}(t+1)
498c       donc les entrees sont /zcdv/ pour la condition a la limite sol
499c       et /zkv/ = Kv
500
501      DO ig=1,ngrid
502         z1(ig)=1./(za(ig,nlay)+zb(ig,nlay))
503         zc(ig,nlay)=za(ig,nlay)*zv(ig,nlay)*z1(ig)
504         zd(ig,nlay)=zb(ig,nlay)*z1(ig)
505      ENDDO
506
507      DO ilay=nlay-1,1,-1
508         DO ig=1,ngrid
509            z1(ig)=1./(za(ig,ilay)+zb(ig,ilay)+
510     $         zb(ig,ilay+1)*(1.-zd(ig,ilay+1)))
511            zc(ig,ilay)=(za(ig,ilay)*zv(ig,ilay)+
512     $         zb(ig,ilay+1)*zc(ig,ilay+1))*z1(ig)
513            zd(ig,ilay)=zb(ig,ilay)*z1(ig)
514         ENDDO
515      ENDDO
516
517      DO ig=1,ngrid
518         zv(ig,1)=zc(ig,1)
519      ENDDO
520      DO ilay=2,nlay
521         DO ig=1,ngrid
522            zv(ig,ilay)=zc(ig,ilay)+zd(ig,ilay)*zv(ig,ilay-1)
523         ENDDO
524      ENDDO
525
526
527
528
529
530c-----------------------------------------------------------------------
531c   6. inversion pour l'implicite sur h sans oublier le couplage
532c      avec le sol (conduction)
533c      ------------------------
534
535c    ** l'equation est
536c       h(t+1) =  h(t) + dt * {(dh/dt)phys}(t)  +  dt * {(dh/dt)difv}(t+1)
537c       avec
538c       /zh/ = h(t) + dt * {(dh/dt)phys}(t)   (voir paragraphe 2.)
539c       et
540c       dt * {(dh/dt)difv}(t+1) = dt * {(d/dz)[ Kh (dh/dz) ]}(t+1)
541c       donc les entrees sont /zcdh/ pour la condition de raccord au sol
542c       et /zkh/ = Kh
543c       -------------
544
[473]545c Mass variation scheme:
[2274]546      zb(1:ngrid,2:nlay)=zkh(1:ngrid,2:nlay)*zb0(1:ngrid,2:nlay)
547      zb(1:ngrid,1)=zcdh(1:ngrid)*zb0(1:ngrid,1)
[38]548
[473]549c on initialise dm c
550     
551      pdtc(:,:)=0.
552      zt(:,:)=0.
553      dmice(:,:)=0.
[38]554
555c    ** calcul de (d Planck / dT) a la temperature d'interface
556c       ------------------------------------------------------
557
558      z4st=4.*5.67e-8*ptimestep
[544]559      IF (tke_heat_flux .eq. 0.) THEN
[38]560      DO ig=1,ngrid
561         zdplanck(ig)=z4st*pemis(ig)*ptsrf(ig)*ptsrf(ig)*ptsrf(ig)
562      ENDDO
[544]563      ELSE
564         zdplanck(:)=0.
565      ENDIF
[38]566
[473]567! calcul de zc et zd pour la couche top en prenant en compte le terme
[2080]568! de variation de masse (on fait une boucle pour que \E7a converge)
[473]569
570! Identification des points de grilles qui ont besoin de la correction
571
572      llnt(:)=1
[1236]573      IF (.not.turb_resolved) THEN
[884]574      IF (callcond) THEN
575       DO ig=1,ngrid
[473]576         DO l=1,nlay
577            if(zh(ig,l) .lt. zhcond(ig,l)) then
578               llnt(ig)=300 
579! 200 and 100 do not go beyond month 9 with normal dissipation
580               goto 5
581            endif
582         ENDDO
[884]5835      continue
584       ENDDO
585      ENDIF
[473]586
[529]587      ENDIF
588
[473]589      DO ig=1,ngrid
590
591! Initialization of z1 and zd, which do not depend on dmice
592
593      z1(ig)=1./(za(ig,nlay)+zb(ig,nlay))
594      zd(ig,nlay)=zb(ig,nlay)*z1(ig)
595
596      DO ilay=nlay-1,1,-1
597          z1(ig)=1./(za(ig,ilay)+zb(ig,ilay)+
598     $        zb(ig,ilay+1)*(1.-zd(ig,ilay+1)))
599          zd(ig,ilay)=zb(ig,ilay)*z1(ig)
600      ENDDO
601
602! Convergence loop
603
604      DO j=1,llnt(ig)
605
606            z1(ig)=1./(za(ig,nlay)+zb(ig,nlay))
607            zc(ig,nlay)=za(ig,nlay)*zh(ig,nlay)
608     &      -betam(ig,nlay)*dmice(ig,nlay)
609            zc(ig,nlay)=zc(ig,nlay)*z1(ig)
610!            zd(ig,nlay)=zb(ig,nlay)*z1(ig)
611
612! calcul de zc et zd pour les couches du haut vers le bas
613
614             DO ilay=nlay-1,1,-1
615               z1(ig)=1./(za(ig,ilay)+zb(ig,ilay)+
616     $            zb(ig,ilay+1)*(1.-zd(ig,ilay+1)))
617               zc(ig,ilay)=(za(ig,ilay)*zh(ig,ilay)+
618     $            zb(ig,ilay+1)*zc(ig,ilay+1)-
619     $            betam(ig,ilay)*dmice(ig,ilay))*z1(ig)
620!               zd(ig,ilay)=zb(ig,ilay)*z1(ig)
621            ENDDO
622
[38]623c    ** calcul de la temperature_d'interface et de sa tendance.
624c       on ecrit que la somme des flux est nulle a l'interface
625c       a t + \delta t,
626c       c'est a dire le flux radiatif a {t + \delta t}
627c       + le flux turbulent a {t + \delta t}
628c            qui s'ecrit K (T1-Tsurf) avec T1 = d1 Tsurf + c1
629c            (notation K dt = /cpp*b/)       
630c       + le flux dans le sol a t
631c       + l'evolution du flux dans le sol lorsque la temperature d'interface
632c       passe de sa valeur a t a sa valeur a {t + \delta t}.
633c       ----------------------------------------------------
634
635         z1(ig)=pcapcal(ig)*ptsrf(ig)+cpp*zb(ig,1)*zc(ig,1)
636     s     +zdplanck(ig)*ptsrf(ig)+ pfluxsrf(ig)*ptimestep
637         z2(ig)= pcapcal(ig)+cpp*zb(ig,1)*(1.-zd(ig,1))+zdplanck(ig)
638         ztsrf2(ig)=z1(ig)/z2(ig)
[473]639!         pdtsrf(ig)=(ztsrf2(ig)-ptsrf(ig))/ptimestep  !incremented outside loop
640            zhs(ig,1)=zc(ig,1)+zd(ig,1)*ztsrf2(ig)
[38]641
642c    ** et a partir de la temperature au sol on remonte
643c       -----------------------------------------------
644
[473]645            DO ilay=2,nlay
646               zhs(ig,ilay)=zc(ig,ilay)+zd(ig,ilay)*zhs(ig,ilay-1)
647            ENDDO
648            DO ilay=1,nlay
649               zt(ig,ilay)=zhs(ig,ilay)*ppopsk(ig,ilay)
650            ENDDO
651
652c      Condensation/sublimation in the atmosphere
653c      ------------------------------------------
654c      (computation of zcondicea and dmice)
655
[1996]656      IF (.NOT. co2clouds) then
657       DO l=nlay , 1, -1
[473]658           IF(zt(ig,l).LT.ztcond(ig,l)) THEN
659               pdtc(ig,l)=(ztcond(ig,l) - zt(ig,l))/ptimestep
660               zcondicea(ig,l)=(pplev(ig,l)-pplev(ig,l+1))
661     &                        *ccond*pdtc(ig,l)
662              dmice(ig,l)= dmice(ig,l) + zcondicea(ig,l)*ptimestep
663            END IF
[1996]664       ENDDO
665      ELSE
666       DO l=nlay , 1, -1
667         zcondicea(ig,l)= 0.!pcondicea_co2microp(ig,l)*
668c     &                        (pplev(ig,l) - pplev(ig,l+1))/g
669         dmice(ig,l)= 0.!dmice(ig,l) + zcondicea(ig,l)*ptimestep
670         pdtc(ig,l)=0.
671       ENDDO   
672      ENDIF
673     
674       ENDDO!of Do j=1,XXX
[38]675
[1996]676      ENDDO   !of Do ig=1,ngrid
[38]677
[473]678      pdtsrf(:)=(ztsrf2(:)-ptsrf(:))/ptimestep
[669]679     
[660]680      DO ig=1,ngrid  ! computing sensible heat flux (atm => surface)
681         sensibFlux(ig)=cpp*zb(ig,1)/ptimestep*(zhs(ig,1)-ztsrf2(ig))
682      ENDDO
[473]683
[38]684c-----------------------------------------------------------------------
685c   TRACERS
686c   -------
687
688      if(tracer) then
689
690c     Using the wind modified by friction for lifting and  sublimation
691c     ----------------------------------------------------------------
692
[529]693!     This is computed above and takes into account surface-atmosphere flux
694!     enhancement by subgrid gustiness and atmospheric-stability related
695!     variations of transfer coefficients.
696
697!        DO ig=1,ngrid
698!          zu2(ig)=zu(ig,1)*zu(ig,1)+zv(ig,1)*zv(ig,1)
699!          zcdv(ig)=zcdv_true(ig)*sqrt(zu2(ig))
700!          zcdh(ig)=zcdh_true(ig)*sqrt(zu2(ig))
701!        ENDDO
702
[38]703c       Calcul du flux vertical au bas de la premiere couche (dust) :
704c       -----------------------------------------------------------
[1047]705        do ig=1,ngrid 
[38]706          rho(ig) = zb0(ig,1) /ptimestep
707c          zb(ig,1) = 0.
708        end do
709c       Dust lifting:
710        if (lifting) then
[310]711#ifndef MESOSCALE
[38]712           if (doubleq.AND.submicron) then
713             do ig=1,ngrid
714c              if(co2ice(ig).lt.1) then
715                 pdqsdif(ig,igcm_dust_mass) =
716     &             -alpha_lift(igcm_dust_mass) 
717                 pdqsdif(ig,igcm_dust_number) =
718     &             -alpha_lift(igcm_dust_number) 
719                 pdqsdif(ig,igcm_dust_submicron) =
720     &             -alpha_lift(igcm_dust_submicron)
721c              end if
722             end do
723           else if (doubleq) then
[1974]724             if (dustinjection.eq.0) then !injection scheme 0 (old)
725                                          !or 2 (injection in CL)
726              do ig=1,ngrid
[1455]727               if(co2ice(ig).lt.1) then ! pas de soulevement si glace CO2
[38]728                 pdqsdif(ig,igcm_dust_mass) =
729     &             -alpha_lift(igcm_dust_mass) 
730                 pdqsdif(ig,igcm_dust_number) =
[520]731     &             -alpha_lift(igcm_dust_number)
732               end if
[1974]733              end do
734             elseif(dustinjection.eq.1)then ! dust injection scheme = 1 injection from surface
735              do ig=1,ngrid
736               if(co2ice(ig).lt.1) then ! pas de soulevement si glace CO2
[2160]737                IF((ti_injection_sol.LE.local_time(ig)).and.
738     &                  (local_time(ig).LE.tf_injection_sol)) THEN
[1974]739                  if (rdstorm) then !Rocket dust storm scheme
740                        pdqsdif(ig,igcm_stormdust_mass) =
741     &                          -alpha_lift(igcm_stormdust_mass)
742     &                          *dustliftday(ig)
743                        pdqsdif(ig,igcm_stormdust_number) =
744     &                          -alpha_lift(igcm_stormdust_number)
745     &                          *dustliftday(ig)
746                        pdqsdif(ig,igcm_dust_mass)= 0.
747                        pdqsdif(ig,igcm_dust_number)= 0.
748                  else
749                        pdqsdif(ig,igcm_dust_mass)=
750     &                          -dustliftday(ig)*
751     &                          alpha_lift(igcm_dust_mass)               
752                        pdqsdif(ig,igcm_dust_number)=
753     &                          -dustliftday(ig)*
754     &                          alpha_lift(igcm_dust_number)
755                  endif
756                  if (submicron) then
757                        pdqsdif(ig,igcm_dust_submicron) = 0.
758                  endif ! if (submicron)
759                ELSE ! outside dust injection time frame
[2080]760                  pdqsdif(ig,igcm_dust_mass)= 0.
761                  pdqsdif(ig,igcm_dust_number)= 0.
762                  if (rdstorm) then     
[1974]763                        pdqsdif(ig,igcm_stormdust_mass)= 0.
764                        pdqsdif(ig,igcm_stormdust_number)= 0.
[2080]765                  end if
[1974]766                ENDIF
767               
768                end if ! of if(co2ice(ig).lt.1)
769              end do
770             endif ! end if dustinjection
[38]771           else if (submicron) then
772             do ig=1,ngrid
773                 pdqsdif(ig,igcm_dust_submicron) =
774     &             -alpha_lift(igcm_dust_submicron)
775             end do
776           else
[1236]777#endif
[38]778            call dustlift(ngrid,nlay,nq,rho,zcdh_true,zcdh,co2ice,
779     &                    pdqsdif)
[1236]780#ifndef MESOSCALE
[38]781           endif !doubleq.AND.submicron
[310]782#endif
[38]783        else
784           pdqsdif(1:ngrid,1:nq) = 0.
785        end if
786
787c       OU calcul de la valeur de q a la surface (water)  :
788c       ----------------------------------------
789        if (water) then
[1047]790            call watersat(ngrid,ptsrf,pplev(1,1),qsat)
[38]791        end if
792
793c      Inversion pour l'implicite sur q
794c       --------------------------------
[1974]795        do iq=1,nq  !for all tracers including stormdust
[2274]796          zb(1:ngrid,2:nlay)=zkh(1:ngrid,2:nlay)*zb0(1:ngrid,2:nlay)
[38]797
[2312]798          if ((water).and.(iq.eq.igcm_h2o_vap)) then
[38]799c            This line is required to account for turbulent transport
800c            from surface (e.g. ice) to mid-layer of atmosphere:
[2274]801             zb(1:ngrid,1)=zcdv(1:ngrid)*zb0(1:ngrid,1)
802             zb(1:ngrid,1)=dryness(1:ngrid)*zb(1:ngrid,1)
[38]803          else ! (re)-initialize zb(:,1)
804             zb(1:ngrid,1)=0
805          end if
806
807          DO ig=1,ngrid
808               z1(ig)=1./(za(ig,nlay)+zb(ig,nlay))
809               zc(ig,nlay)=za(ig,nlay)*zq(ig,nlay,iq)*z1(ig)
810               zd(ig,nlay)=zb(ig,nlay)*z1(ig)
811          ENDDO
812 
813          DO ilay=nlay-1,2,-1
814               DO ig=1,ngrid
815                z1(ig)=1./(za(ig,ilay)+zb(ig,ilay)+
816     $           zb(ig,ilay+1)*(1.-zd(ig,ilay+1)))
817                zc(ig,ilay)=(za(ig,ilay)*zq(ig,ilay,iq)+
818     $           zb(ig,ilay+1)*zc(ig,ilay+1))*z1(ig)
819                zd(ig,ilay)=zb(ig,ilay)*z1(ig)
820               ENDDO
821          ENDDO
822
[2312]823          if ( (water.and.(iq.eq.igcm_h2o_ice))
824     $      .or. (hdo.and.(iq.eq.igcm_hdo_ice)) ) then
[38]825            ! special case for water ice tracer: do not include
826            ! h2o ice tracer from surface (which is set when handling
[473]827           ! h2o vapour case (see further down).
[38]828            DO ig=1,ngrid
829                z1(ig)=1./(za(ig,1)+zb(ig,1)+
830     $           zb(ig,2)*(1.-zd(ig,2)))
831                zc(ig,1)=(za(ig,1)*zq(ig,1,iq)+
832     $         zb(ig,2)*zc(ig,2)) *z1(ig)
833            ENDDO
[2312]834         else if (hdo.and.(iq.eq.igcm_hdo_vap)) then
835            CALL hdo_surfex(ngrid,nlay,nq,ptimestep,
836     &                      zt,zq,pqsurf,
[2316]837     &                      old_h2o_vap,pdqsdif,dwatercap_dif,
[2312]838     &                      hdoflux)
839            DO ig=1,ngrid
840                z1(ig)=1./(za(ig,1)+zb(ig,1)+
841     $           zb(ig,2)*(1.-zd(ig,2)))
842                zc(ig,1)=(za(ig,1)*zq(ig,1,iq)+
843     $         zb(ig,2)*zc(ig,2) +
844     $        (-hdoflux(ig)) *ptimestep) *z1(ig)  !tracer flux from surface
845            ENDDO
846
[38]847          else ! general case
848            DO ig=1,ngrid
849                z1(ig)=1./(za(ig,1)+zb(ig,1)+
850     $           zb(ig,2)*(1.-zd(ig,2)))
851                zc(ig,1)=(za(ig,1)*zq(ig,1,iq)+
852     $         zb(ig,2)*zc(ig,2) +
853     $        (-pdqsdif(ig,iq)) *ptimestep) *z1(ig)  !tracer flux from surface
854            ENDDO
[2312]855
[38]856          endif ! of if (water.and.(iq.eq.igcm_h2o_ice))
857 
858          IF ((water).and.(iq.eq.igcm_h2o_vap)) then
859c           Calculation for turbulent exchange with the surface (for ice)
860            DO ig=1,ngrid
[2312]861              old_h2o_vap(ig)=zq(ig,1,igcm_h2o_vap)
[38]862              zd(ig,1)=zb(ig,1)*z1(ig)
863              zq1temp(ig)=zc(ig,1)+ zd(ig,1)*qsat(ig)
864
865              pdqsdif(ig,igcm_h2o_ice)=rho(ig)*dryness(ig)*zcdv(ig)
866     &                       *(zq1temp(ig)-qsat(ig))
867c             write(*,*)'flux vers le sol=',pdqsdif(ig,nq)
868            END DO
869
870            DO ig=1,ngrid
[2312]871            IF (hdo) then !if hdo, need to treat polar caps differently
872              h2oflux(ig) = pdqsdif(ig,igcm_h2o_ice) ! h2oflux is
873                                                     ! uncorrected waterflux
874            ENDIF !hdo
875
[2260]876              if ((-pdqsdif(ig,igcm_h2o_ice)*ptimestep)
877     &             .gt.(pqsurf(ig,igcm_h2o_ice))) then
878c              write(*,*)'subliming more than available frost:  qsurf!'
879                if(watercaptag(ig)) then
880c              dwatercap_dif same sign as pdqsdif (pos. toward ground)
[2316]881                   dwatercap_dif(ig) = pdqsdif(ig,igcm_h2o_ice)
882     &                         + pqsurf(ig,igcm_h2o_ice)/ptimestep
[2260]883                   pdqsdif(ig,igcm_h2o_ice)=
[38]884     &                         -pqsurf(ig,igcm_h2o_ice)/ptimestep
[2260]885c                  write(*,*) "subliming more than available frost:  qsurf!"
886                else  !  (case not.watercaptag(ig))
887                   pdqsdif(ig,igcm_h2o_ice)=
888     &                         -pqsurf(ig,igcm_h2o_ice)/ptimestep
889                   dwatercap_dif(ig) = 0.0
[2312]890                   if (hdo) then
891                     h2oflux(ig) = pdqsdif(ig,igcm_h2o_ice)
892                   endif
[2260]893
[38]894c                 write(*,*)'flux vers le sol=',pdqsdif(ig,nq)
895                  z1(ig)=1./(za(ig,1)+ zb(ig,2)*(1.-zd(ig,2)))
896                  zc(ig,1)=(za(ig,1)*zq(ig,1,igcm_h2o_vap)+
[2316]897     $            zb(ig,2)*zc(ig,2) +
898     $              (-pdqsdif(ig,igcm_h2o_ice)) *ptimestep) *z1(ig)
[38]899                  zq1temp(ig)=zc(ig,1)
[2316]900                endif  !if .not.watercaptag(ig)
901              endif ! if sublim more than surface
902
[38]903c             Starting upward calculations for water :
[669]904              zq(ig,1,igcm_h2o_vap)=zq1temp(ig)
905             
[742]906!c             Take into account H2O latent heat in surface energy budget
907!c             We solve dT/dt = (2834.3-0.28*(T-To)-0.004*(T-To)^2)*1e3*iceflux/cpp
908!              tsrf_lw(ig) = ptsrf(ig) + pdtsrf(ig) *ptimestep
909!             
910!              alpha = exp(-4*abs(T1-T2)*pdqsdif(ig,igcm_h2o_ice)
911!     &            *ptimestep/pcapcal(ig))
912!
913!              tsrf_lw(ig) = (tsrf_lw(ig)*(T2-alpha*T1)+T1*T2*(alpha-1))
914!     &                      /(tsrf_lw(ig)*(1-alpha)+alpha*T2-T1)  ! surface temperature at t+1
915!
916!              pdtsrf(ig) = (tsrf_lw(ig)-ptsrf(ig))/ptimestep
[2179]917c             Take into account the H2O latent heat impact on the surface temperature
[2218]918              if (latentheat_surfwater) then
[2179]919                tsrf_lh(ig) = ptsrf(ig) + pdtsrf(ig) *ptimestep
920                lh=(2834.3-0.28*(tsrf_lh(ig)-To)-
921     &              0.004*(tsrf_lh(ig)-To)*(tsrf_lh(ig)-To))*1.e+3
[2260]922                pdtsrf(ig)= pdtsrf(ig) + (dwatercap_dif(ig)+
923     &               pdqsdif(ig,igcm_h2o_ice))*lh /pcapcal(ig)
[2179]924              endif
[669]925
926               if(pqsurf(ig,igcm_h2o_ice)
[2316]927     &           +pdqsdif(ig,igcm_h2o_ice)*ptimestep
[669]928     &           .gt.frost_albedo_threshold) ! if there is still ice, T cannot exceed To
929     &           pdtsrf(ig) = min(pdtsrf(ig),(To-ptsrf(ig))/ptimestep) ! ice melt case
930     
[38]931            ENDDO ! of DO ig=1,ngrid
932          ELSE
933c           Starting upward calculations for simple mixing of tracer (dust)
934            DO ig=1,ngrid
935               zq(ig,1,iq)=zc(ig,1)
936            ENDDO
937          END IF ! of IF ((water).and.(iq.eq.igcm_h2o_vap))
938
939          DO ilay=2,nlay
940             DO ig=1,ngrid
[626]941               zq(ig,ilay,iq)=zc(ig,ilay)+zd(ig,ilay)*zq(ig,ilay-1,iq)
[38]942             ENDDO
943          ENDDO
944        enddo ! of do iq=1,nq
945      end if ! of if(tracer)
946
[2312]947C       Diagnostic output for HDO
948        if (hdo) then
949            CALL WRITEDIAGFI(ngrid,'hdoflux',
950     &                       'hdoflux',
951     &                       ' ',2,hdoflux) 
952            CALL WRITEDIAGFI(ngrid,'h2oflux',
953     &                       'h2oflux',
954     &                       ' ',2,h2oflux)
955        endif
956
[38]957c-----------------------------------------------------------------------
958c   8. calcul final des tendances de la diffusion verticale
959c      ----------------------------------------------------
960
961      DO ilev = 1, nlay
962         DO ig=1,ngrid
963            pdudif(ig,ilev)=(    zu(ig,ilev)-
964     $      (pu(ig,ilev)+pdufi(ig,ilev)*ptimestep)    )/ptimestep
965            pdvdif(ig,ilev)=(    zv(ig,ilev)-
966     $      (pv(ig,ilev)+pdvfi(ig,ilev)*ptimestep)    )/ptimestep
[473]967            hh = ph(ig,ilev)+pdhfi(ig,ilev)*ptimestep
968     $  + (latcond*dmice(ig,ilev)/cpp)/ppopsk(ig,ilev)
969            pdhdif(ig,ilev)=( zhs(ig,ilev)- hh )/ptimestep
[38]970         ENDDO
971      ENDDO
972
973      if (tracer) then
974        DO iq = 1, nq
975          DO ilev = 1, nlay
976            DO ig=1,ngrid
977              pdqdif(ig,ilev,iq)=(zq(ig,ilev,iq)-
978     $      (pq(ig,ilev,iq) + pdqfi(ig,ilev,iq)*ptimestep))/ptimestep
979            ENDDO
980          ENDDO
981        ENDDO
982      end if
983
984c    ** diagnostique final
985c       ------------------
986
987      IF(lecrit) THEN
988         PRINT*,'In vdif'
989         PRINT*,'Ts (t) and Ts (t+st)'
990         WRITE(*,'(a10,3a15)')
991     s   'theta(t)','theta(t+dt)','u(t)','u(t+dt)'
992         PRINT*,ptsrf(ngrid/2+1),ztsrf2(ngrid/2+1)
993         DO ilev=1,nlay
994            WRITE(*,'(4f15.7)')
[473]995     s      ph(ngrid/2+1,ilev),zhs(ngrid/2+1,ilev),
[38]996     s      pu(ngrid/2+1,ilev),zu(ngrid/2+1,ilev)
997
998         ENDDO
999      ENDIF
1000
[1036]1001      END SUBROUTINE vdifc
[1969]1002
[2312]1003c====================================
1004
1005
[1969]1006      END MODULE vdifc_mod
Note: See TracBrowser for help on using the repository browser.