source: trunk/LMDZ.MARS/libf/aeronomars/conduction.F @ 2883

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