source: trunk/LMDZ.MARS/libf/aeronomars/molvis.F @ 3026

Last change on this file since 3026 was 2615, checked in by romain.vande, 3 years ago

LMDZ_MARS RV : Open_MP;
Put all the "save" variables as "!$OMP THREADPRIVATE" in aeronomars

File size: 5.6 KB
RevLine 
[1047]1       SUBROUTINE molvis(ngrid,nlayer,ptimestep,
2     &            pplay,pplev,pt,pdteuv,pdtconduc
[690]3     $           ,pvel,tsurf,zzlev,zzlay,zdvelmolvis)
[1047]4     
5      use conc_mod, only: cpnew, Akknew, rnew
[38]6      IMPLICIT NONE
7
8c=======================================================================
9c
10c   Molecular Viscosity Diffusion
11
12c   Based on conduction.F  by N. Descamp, F. Forget 05/1999
13c
14c   modified by M. Angelats i Coll
15c
16c=======================================================================
17
18c-----------------------------------------------------------------------
19c   declarations:
20c-----------------------------------------------------------------------
21
22c   arguments:
23c   ----------
24
[1047]25      integer,intent(in) :: ngrid ! number of atmospheric columns
26      integer,intent(in) :: nlayer ! number of atmospheric layers
[38]27      REAL ptimestep
[1047]28      REAL pplay(ngrid,nlayer)
29      REAL pplev(ngrid,nlayer+1)
30      REAL zzlay(ngrid,nlayer)
31      REAL zzlev(ngrid,nlayer+1)
32      real pt(ngrid,nlayer)
33      real tsurf(ngrid)
34      REAL pvel(ngrid,nlayer)
35      REAL pdvel(ngrid,nlayer)
36      real pdteuv(ngrid,nlayer)
37      real pdtconduc(ngrid,nlayer)
[38]38
[1047]39      real zdvelmolvis(ngrid,nlayer)
[38]40
41c   local:
42c   ------
43
[1047]44      INTEGER l,ig, nz
45      real Akk,phitop,fac, m, tmean
46      REAL zvel(nlayer)
47      real zt(nlayer)
48      REAL alpha(nlayer)
49      REAL lambda(nlayer)
50      real muvol(nlayer)
51      REAL C(nlayer)
52      real D(nlayer)
53      real den(nlayer)
54      REAL pdvelm(nlayer)
55      REAL zlay(nlayer)
56      real zlev(nlayer+1)
[38]57
58c   constants used locally
59c    ---------------------
60c     The atmospheric conductivity is a function of temperature T :
61c      conductivity = Akk* T**skk
62c     Molecular viscosity is related to thermal conductivity by:
63c       conduc = 0.25*(9*gamma - 5)* Cv * molvis
64c     where gamma = Cp/Cv.  For dry air.
65
66
[1047]67      REAL,PARAMETER :: skk=0.69
[38]68
[1047]69      REAL,PARAMETER :: velsurf =0.0
[38]70     
[1047]71      logical,save :: firstcall=.true.
72
[2615]73!$OMP THREADPRIVATE(firstcall)
74
[38]75c-----------------------------------------------------------------------
76c   calcul des coefficients alpha et lambda
77c-----------------------------------------------------------------------
78
79      IF (firstcall) THEN
80!        write(*,*)'molvis: coeff of molecular viscosity Akk,skk,factor'
81!        write(*,*) Akk,skk,fac
82! NB: Akk and fac are undefined at firstcall
83        write(*,*)'molvis: coeff of molecular viscosity skk ', skk
84       
85        firstcall = .false.
86      END IF
87
88! Initialize phitop
89      phitop=0.0
90
[1047]91      nz=nlayer
[38]92
93      do ig=1,ngrid
94
95        zt(1)=pt(ig,1)+(pdteuv(ig,1)+pdtconduc(ig,1))*ptimestep
96        zvel(1)=pvel(ig,1)
97c        zlay(1)=-log(pplay(ig,1)/pplev(ig,1))*Rnew(ig,1)*zt(1)/g
98c        zlev(1)=0.0
99
100        zlay(1)=zzlay(ig,1)
101        zlev(1)=zzlev(ig,1)
102
103        do l=2,nz
104          zt(l)=pt(ig,l)+(pdteuv(ig,l)+pdtconduc(ig,l))*ptimestep
105          zvel(l)=pvel(ig,l)
106c          tmean=zt(l)
107c          if(zt(l).ne.zt(l-1)) tmean=(zt(l)-zt(l-1))/log(zt(l)/zt(l-1))
108c          zlay(l)= zlay(l-1)
109c     &          -log(pplay(ig,l)/pplay(ig,l-1))*Rnew(ig,l-1)*tmean/g
110c          zlev(l)= zlev(l-1)
111c     &         -log(pplev(ig,l)/pplev(ig,l-1))*Rnew(ig,l-1)*tmean/g
112        zlay(l)=zzlay(ig,l)
113        zlev(l)=zzlev(ig,l)
114        enddo
115
116c          zlev(nz+1)= zlev(nz)
117c     &         -log(max(pplev(ig,nz+1),1.e-30)/pplev(ig,nz))
118c     &          *Rnew(ig,nz)*tmean/g
119c          if(pplev(ig,nz+1).eq.0.)
120c     &       zlev(nz+1)=zlev(nz)+(zlay(nz)-zlay(nz-1))
121
122          zlev(nz+1)= zlev(nz)+10000.
123
124        fac=0.25*(9.*cpnew(ig,1)-5.*(cpnew(ig,1)-rnew(ig,1)))
125        Akk=Akknew(ig,1)
126        lambda(1)=Akk*tsurf(ig)**skk/zlay(1)/fac   
127c        write(*,*) 'rnew(ig,nz)  ',ig , rnew(ig,nz)
128
129        DO l=2,nz
130          fac=(9.*cpnew(ig,l)-5.*(cpnew(ig,l)-rnew(ig,l)))/4.
131          Akk=Akknew(ig,l)
132          lambda(l)=Akk/fac*zt(l)**skk/(zlay(l)-zlay(l-1))
133        ENDDO
134   
135        DO l=1,nz-1
136          muvol(l)=pplay(ig,l)/(rnew(ig,l)*zt(l))
137          alpha(l)=(muvol(l)/ptimestep)*(zlev(l+1)-zlev(l))
138        ENDDO
139        muvol(nz)=pplay(ig,nz)/(rnew(ig,nz)*zt(nz))
140        alpha(nz)=(muvol(nz)/ptimestep)*(zlev(nz+1)-zlev(nz))
141
142c--------------------------------------------------------------------
143c
144c     calcul des coefficients C et D
145c
146c-------------------------------------------------------------------
147
148      den(1)=alpha(1)+lambda(2)+lambda(1)
149      C(1)=lambda(1)*(velsurf-zvel(1))+lambda(2)*(zvel(2)-zvel(1))
150      C(1)=C(1)/den(1)       
151      D(1)=lambda(2)/den(1)           
152   
153      DO l = 2,nz-1
154         den(l)=alpha(l)+lambda(l+1)
155         den(l)=den(l)+lambda(l)*(1-D(l-1))
156         
157         C(l) =lambda(l+1)*(zvel(l+1)-zvel(l))
158     $        +lambda(l)*(zvel(l-1)-zvel(l)+C(l-1))   
159         C(l) =C(l)/den(l)           
160
161         D(l) =lambda(l+1) / den(l)
162      ENDDO
163
164      den(nz)=alpha(nz) + lambda(nz) * (1-D(nz-1))
165      C(nz)=C(nz-1)+zvel(nz-1)-zvel(nz)
166      C(nz)=(C(nz)*lambda(nz)+phitop) / den(nz)
167               
168c----------------------------------------------------------------------
169c
170c      calcul de la nouvelle pdvelm
171c
172c----------------------------------------------------------------------
173
174      DO l=1,nz
175         pdvelm(l)=0.
176      ENDDO
177         pdvelm(nz)=C(nz)
178      DO l=nz-1,1,-1
179         pdvelm(l)=C(l)+D(l)*pdvelm(l+1)
180      ENDDO
181c-----------------------------------------------------------------------
182c
183c     calcul de la tendance zdvelmolvis
184c
185c-----------------------------------------------------------------------
186   
187      DO l=1,nz
188        zdvelmolvis(ig,l)=pdvelm(l)/ptimestep
189      ENDDO
190
191      ENDDO             ! boucle sur ngrid
192
193      RETURN
194      END
Note: See TracBrowser for help on using the repository browser.