source: trunk/LMDZ.VENUS/libf/phyvenus/concentrations2.F @ 1517

Last change on this file since 1517 was 1452, checked in by slebonnois, 11 years ago

SL: converging photochemistry/high atm, with bug corrections and rho output

File size: 6.8 KB
Line 
1      SUBROUTINE concentrations2(pplay,t_seri,pdt,tr_seri, nqmx)
2
3      use dimphy
4      use conc,  only: mmean, rho, Akknew, rnew, cpnew
5      use cpdet_mod, only: cpdet                       
6      USE chemparam_mod
7      use infotrac
8
9      implicit none
10
11!=======================================================================
12! CALCULATION OF MEAN MOLECULAR MASS, Cp, Akk and R
13!
14! mmean(klon,klev)      amu
15! cpnew(klon,klev)      J/kg/K
16! rnew(klon,klev)       J/kg/K
17! akknew(klon,klev)     coefficient of thermal conduction
18!
19! version: April 2012 - Franck Lefevre
20!=======================================================================
21
22!     declarations
23 
24#include "dimensions.h"
25#include "YOMCST.h"
26#include "clesphys.h"
27c#include "comdiurn.h"
28c#include "chimiedata.h"
29c#include "tracer.h"
30c#include "mmol.h"
31
32!     input/output
33
34      real pplay(klon,klev)
35c      real pt(klon,klev)
36      integer,intent(in) :: nqmx    ! number of tracers
37      real t_seri(klon, klev)
38      real pdt(klon,klev)
39      real n2vmr_gcm(klon,klev),nvmr_gcm(klon,klev)
40      real tr_seri(klon,klev,nqmx)
41c      real pdq(klon,klev,nqmx)
42      real ptimestep
43
44!     local variables
45
46      integer       :: i, l, ig, iq
47      integer, save :: nbq
48      integer,allocatable,save :: niq(:)
49      real          :: ni(nqmx), ntot
50      real          :: zt(klon, klev)
51      real          :: zq(klon, klev, nqmx)
52      real,allocatable,save    :: aki(:)
53      real,allocatable,save    :: cpi(:)
54      real, save    :: akin,akin2
55
56      logical, save :: firstcall = .true.
57
58      if (firstcall) then
59
60!        initialize thermal conductivity and specific heat coefficients
61!        values are taken from the literature [J/kg K]
62
63         ! allocate local saved arrays:
64         allocate(aki(nqmx))
65         allocate(cpi(nqmx))
66         allocate(niq(nqmx))
67
68!        find index of chemical tracers to use
69!        initialize thermal conductivity and specific heat coefficients
70!        !? values are estimated
71
72         nbq = 0 ! to count number of tracers used in this subroutine
73
74         if (i_co2 /= 0) then
75            nbq = nbq + 1
76            niq(nbq) = i_co2
77            aki(nbq) = 3.072e-4
78            cpi(nbq) = 0.834e3
79         end if
80         if (i_co /= 0) then
81            nbq = nbq + 1
82            niq(nbq) = i_co
83            aki(nbq) = 4.87e-4
84            cpi(nbq) = 1.034e3
85         end if
86         if (i_o /= 0) then
87            nbq = nbq + 1
88            niq(nbq) = i_o
89            aki(nbq) = 7.59e-4
90            cpi(nbq) = 1.3e3
91         end if
92         if (i_o1d /= 0) then
93            nbq = nbq + 1
94            niq(nbq) = i_o1d
95            aki(nbq) = 7.59e-4  !?
96            cpi(nbq) = 1.3e3    !?
97         end if
98         if (i_o2 /= 0) then
99            nbq = nbq + 1
100            niq(nbq) = i_o2
101            aki(nbq) = 5.68e-4
102            cpi(nbq) = 0.9194e3
103         end if
104         if (i_o3 /= 0) then
105            nbq = nbq + 1
106            niq(nbq) = i_o3
107            aki(nbq) = 3.00e-4  !?
108            cpi(nbq) = 0.800e3  !?
109         end if
110         if (i_h /= 0) then
111            nbq = nbq + 1
112            niq(nbq) = i_h
113            aki(nbq) = 0.0
114            cpi(nbq) = 20.780e3
115         end if
116         if (i_h2 /= 0) then
117            nbq = nbq + 1
118            niq(nbq) = i_h2
119            aki(nbq) = 36.314e-4
120            cpi(nbq) = 14.266e3
121         end if
122         if (i_oh /= 0) then
123            nbq = nbq + 1
124            niq(nbq) = i_oh
125            aki(nbq)  = 7.00e-4 !?
126            cpi(nbq)  = 1.045e3
127         end if
128         if (i_ho2 /= 0) then
129            nbq = nbq + 1
130            niq(nbq) = i_ho2
131            aki(nbq) = 0.0
132            cpi(nbq) = 1.065e3  !?
133         end if
134         if (i_n2 /= 0) then
135            nbq = nbq + 1
136            niq(nbq) = i_n2
137            aki(nbq) = 5.6e-4
138            cpi(nbq) = 1.034e3
139         end if
140c         if (i_ar /= 0) then
141c            nbq = nbq + 1
142c            niq(nbq) = i_ar
143c            aki(nbq) = 0.0      !?
144c            cpi(nbq) = 1.000e3  !?
145c         end if
146         if (i_h2o /= 0) then
147            nbq = nbq + 1
148            niq(nbq) = i_h2o
149            aki(nbq) = 0.0
150            cpi(nbq) = 1.870e3
151         end if
152c         if (i_n /= 0) then
153c            nbq = nbq + 1
154c            niq(nbq) = i_n
155c            aki(nbq) = 0.0
156c            cpi(nbq) = 0.0
157c         endif
158c         if(i_no /= 0) then
159c            nbq = nbq + 1
160c            niq(nbq) = i_no
161c            aki(nbq) = 0.0
162c            cpi(nbq) = 0.0
163c         endif
164c         if(i_no2 /= 0) then
165c            nbq = nbq + 1
166c            niq(nbq) = i_no2
167c            aki(nbq) = 0.0
168c            cpi(nbq) = 0.0
169c         endif
170c         if(i_n2d /= 0) then
171c            nbq = nbq + 1
172c            niq(nbq) = i_n2d
173c            aki(nbq) = 0.0
174c            cpi(nbq) = 0.0
175c         endif
176
177  !     n2
178c            akin2 = 5.6e-4
179c            cpin2 = 1.034e3
180
181
182         
183         ! tell the world about it:
184         write(*,*) "concentrations: firstcall, nbq=",nbq
185!         write(*,*) "  niq(1:nbq)=",niq(1:nbq)
186!         write(*,*) "  aki(1:nbq)=",aki(1:nbq)
187!         write(*,*) "  cpi(1:nbq)=",cpi(1:nbq)
188
189
190         firstcall = .false.
191      end if ! if (firstcall)
192
193!     update temperature
194
195      do l = 1,klev
196         do ig = 1,klon
197            zt(ig,l) = t_seri(ig,l)
198         end do
199      end do
200
201
202!     update mass mixing ratio tracers
203
204      do l = 1,klev
205         do ig = 1,klon
206            do i = 1,nqmx
207!               iq = niq(i)
208               zq(ig,l,i) = max(1.e-30, tr_seri(ig,l,i))
209            end do
210         end do
211      end do
212
213!     mmean : mean molecular mass
214!     rho   : mass density [kg/m3]
215!     rnew  : specific gas constant
216   
217      mmean(:,:)  = 0.
218      rho(:,:) = 0.     
219
220      do l = 1,klev
221         do ig = 1,klon
222            do i = 1,nqmx
223c               iq = niq(i)
224               mmean(ig,l) = mmean(ig,l) + zq(ig,l,i)/M_tr(i)
225            end do
226            mmean(ig,l) = 1./mmean(ig,l)
227            rnew(ig,l) = 8.314/mmean(ig,l)*1.e3     ! J/kg K           
228 
229c            write(*,*),'Mmean: ',ig, l, mmean(ig,l)
230         end do
231      end do
232
233!     cpnew  : specific heat
234!     akknew : thermal conductivity cofficient
235     
236      cpnew(:,:)  = 0.
237      akknew(:,:) = 0.
238
239      do l = 1,klev
240          do ig = 1,klon
241
242            ntot = pplay(ig,l)/(RKBOL*zt(ig,l))*1.e-6  ! in #/cm3
243            rho(ig,l) = (ntot * mmean(ig,l))/RNAVO*1.e3     ! in kg/m3
244
245c            write(*,*),'Air density: ',ig, l, rho(0,l)           
246
247!!! --- INSERT N2 values ----
248!!  WARNING -> Cp here below doesn't depend on T (cpdet)
249
250            do i = 1,nbq
251c               iq = niq(i)
252               ni(i) = ntot*zq(ig,l,i)*mmean(ig,l)/M_tr(i)
253               cpnew(ig,l) = cpnew(ig,l) + ni(i)*cpi(i)
254               akknew(ig,l) = akknew(ig,l) + ni(i)*aki(i)
255            end do
256 
257
258            cpnew(ig,l) = cpnew(ig,l)/ntot
259            akknew(ig,l)= akknew(ig,l)/ntot
260
261
262          end do
263       end do
264
265      return
266      end
Note: See TracBrowser for help on using the repository browser.