source: trunk/LMDZ.MARS/libf/phymars/nltecool.F @ 1036

Last change on this file since 1036 was 1036, checked in by emillour, 11 years ago

Mars GCM: (a first step towards using parallel dynamics)

  • IMPORTANT CHANGE: Implemented dynamic tracers. It is no longer necessary to compile the model with the '-t #' option, number of tracers is simply read from tracer.def file (as before). Adapted makegcm_* scripts (and co.) accordingly. Technical aspects of the switch to dynamic tracers are:
    • advtrac.h (in dyn3d) removed and replaced by module infotrac.F
    • tracer.h (in phymars) removed and replaced by module tracer_mod.F90 (which contains nqmx, the number of tracers, etc. and can be used anywhere in the physics).
  • Included some side cleanups: removed unused files (in dyn3d) anldoppler2.F, anl_mcdstats.F and anl_stats-diag.F, and all the unecessary dimensions.* files in grid/dimension.
  • Checked that changes are clean and that GCM yields identical results (in debug mode) to previous svn version.

EM

File size: 11.8 KB
Line 
1c**************************************************************************
2c
3      subroutine nltecool(ngrid,nlayer,nq,pplay,pt,pq,dtnlte)
4c
5c This code was designed as a delivery for the "Martian Environment Models"
6c project ( ESA contract 11369/95/nl/jg CCN2 )
7c Computes non-LTE heating rates from CO2 emission at 15 um
8c in the Martian upper atmosphere.
9c Uses a simplified model consisting of two excited levels with two
10c emission bands, one of them stronger than the other, which correspond
11c to the behaviours of the 626 fundamental band and the isotopic fund.bands.
12c It uses a cool-to-space approximation with tabulated escape functions.
13c These escape functions have been precomputed for the strong and weak bands,
14c and are given as a function of pressure in separate files.
15c The output values are the heating rates (actually, cooling, since they
16c are always negative) for the two bands, i.e., the total cooling is the
17c sum of them.
18c Miguel A. Lopez Valverde
19c Instituto de Astrofisica de Andalucia (CSIC), Granada, Spain
20c
21c Version 1b.  See description above.  22-March-2000.
22c Adapted as a subroutine for use in GCM -- PLR/SRL 6/2000
23c Version 1c.  Inclusion of VMR in the tabulation of escape functions.
24c              Table contains now only 1 input file -- Miguel 11/Jul/2000
25c Version 1d  data contained in original input file "nlte_escape.dat"
26c now stored in include file "nltedata.h" Y.Wanherdrick 09/2000
27
28c       jul 2011 fgg   Modified to allow variable O
29c     
30c***************************************************************************
31
32      use tracer_mod, only: igcm_co2, igcm_co, igcm_o, igcm_n2, mmol
33      implicit none
34
35#include "nltedata.h" ! (Equivalent to the reading of the "nlte_escape.dat" file)
36#include "dimensions.h"
37#include "dimphys.h"
38#include "chimiedata.h"
39#include "conc.h" !Added to have "dynamic composition" in the scheme
40!#include "tracer.h" !"
41#include "callkeys.h"
42
43c Input and output variables
44c
45      integer     ngrid                           ! no. of horiz. gridpoints
46      integer     nlayer                          ! no. of atmospheric layers
47      integer     nq                              ! no. of tracers
48      real        pplay(ngrid,nlayer)             ! input pressure grid
49      real        pt(ngrid,nlayer)                ! input temperatures
50      real        pq(ngrid,nlayer,nq)                ! input mmrs
51      real        dtnlte(ngrid,nlayer)            ! output temp. tendencies
52
53c
54c Standard atmosphere variables
55c
56      real        nt                              ! number density [cm-3]
57      real        co2(nlayer)                     !  "   of CO2
58      real        o3p(nlayer)                     !  "   of atomic oxygen
59      real        n2co(nlayer)                    !  "  of N2 + CO
60      real        pyy(nlayer)                     ! auxiliary pressure grid
61
62c
63c Vectors and indexes for the tabulation of escape functions and VMR
64c
65c                 np                              ! # data points in tabulation
66c                 pnb(np)                         ! Pressure in tabulation
67c                 ef1(np)                         ! Esc.funct.#1, tabulated
68c                 ef2(np)                         ! Esc.funct.#2, tabulated
69c                 co2vmr(np)                      ! CO2 VMR tabulated
70c                 o3pvmr(np)                      ! CO2 VMR tabulated
71c                 n2covmr(np)                     ! N2+CO VMR tabulated
72      real        escf1(nlayer)                   ! Esc.funct.#1, interpolated
73      real        escf2(nlayer)                   ! Esc.funct.#2, interpolated
74
75
76c
77c Local Constants
78c
79      real       nu1, nu2                         ! freq. of energy levels
80      real       imr1, imr2                       ! isotopic abundances
81      real       hplanck, gamma, vlight           ! physical constants
82      real       ee
83      real       rfvt                             ! collisional rate
84      real       rfvto3p                          !     "
85      real       rfvv                             !     "
86
87c
88c Local variables for the main loop
89c
90      real       n1, n2, co2t                     ! ground populations
91      real       l1, p1, p12                      ! prod & losses
92      real       l2, p2, p21
93      real       tt                               ! dummy variable
94      real       c1, c2                           ! molecular constants
95      real       ae1, ae2                         ! einstein spontaneous emission
96      real       a1, a2, a12, a21
97      real       pl1, pl2
98      real       el1, el2
99      real       hr1, hr2                         ! heating rate due to each band
100      real       hr(nlayer)                       ! total heating rate
101
102c
103c Indexes
104c
105      integer    i
106      integer    j,ii
107
108c
109c Rate coefficients
110c
111      real       k19xca, k19xcb
112      real       k19cap1, k19cap2
113      real       k19cbp1, k19cbp2
114      real       d19c, d19cp1, d19cp2
115      real       k20xc, k20cp1, k20cp2
116      real       k21xc, k21cp2
117
118      logical    firstcall
119      data       firstcall/.true./
120      save       firstcall,ef1,ef2,co2vmr,n2covmr,o3pvmr,pnb
121
122c
123c Data
124c
125      data       nu1, nu2, hplanck, gamma, vlight, ee/
126     1     667.38, 662.3734, 6.6261e-27, 1.191e-5, 3.e10, 1.438769/
127
128c*************************************************************************
129c       PROGRAM  STARTS
130c*************************************************************************
131
132      imr1 = 0.987
133      imr2 = 0.00408 + 0.0112
134      rfvt = 0.1
135      rfvto3p = 1.0
136      rfvv = 0.1
137
138      if(firstcall) then
139
140         do i=1,np
141            pnb(i)=1.0e-4*exp(pnb(i)) ! p into Pa
142         end do
143
144         firstcall = .false.
145
146      endif
147
148c
149c MAIN LOOP, for each gridpoint and altitude:
150c
151      do j=1,ngrid  ! loop over grid points
152c
153c set up local pressure grid
154c
155         do ii=1,nlayer
156            pyy(ii)=pplay(j,ii)
157         enddo
158!
159! Interpolate escape functions and VMR to the desired grid
160!
161         call interp1(escf2,pyy,nlayer,ef2,pnb,np)
162         call interp1(escf1,pyy,nlayer,ef1,pnb,np)
163         if(nltemodel.eq.0) then
164            call interp3(co2,o3p,n2co,pyy,nlayer,
165     &           co2vmr,o3pvmr,n2covmr,pnb,np)
166         endif
167       
168         do i=1,nlayer  ! loop over layers
169C
170C test if p lies outside range (p > 3.5 Pa)
171C changed to 1 Pa since transition will always be higher than this
172C
173            if(pyy(i) .gt. 1.0 .or. pyy(i) .lt. 4.0e-6) then
174               hr(i)=0.0
175               dtnlte(j,i)=0.0
176            else
177c
178c           if(pt(j,i).lt.1.0)print*,pt(j,i)
179               nt = pyy(i)/(1.381e-17*pt(j,i)) ! nt in cm-3
180               !Dynamic composition
181               if(nltemodel.eq.1) then
182                  co2(i)=pq(j,i,igcm_co2)*mmean(j,i)/mmol(igcm_co2)
183                  o3p(i)=pq(j,i,igcm_o)*mmean(j,i)/mmol(igcm_o)
184                  n2co(i)=pq(j,i,igcm_co)*mmean(j,i)/mmol(igcm_co) +
185     $                 pq(j,i,igcm_n2)*mmean(j,i)/mmol(igcm_n2)
186               endif
187
188               !Mixing ratio to density
189               co2(i)=co2(i)*nt                ! CO2 density in cm-3
190               o3p(i)=o3p(i)*nt                ! O3p density in cm-3
191               n2co(i)=n2co(i)*nt              ! N2+CO in cm-3
192c molecular populations
193               n1 = co2(i) * imr1
194               n2 = co2(i) * imr2
195               co2t = n1 + n2
196
197c intermediate collisional rates
198               tt = pt(j,i)*pt(j,i)
199
200               if (pt(j,i).le.175.0) then
201                  k19xca = 3.3e-15
202                  k19xcb = 7.6e-16
203               else
204                  k19xca = 4.2e-12 * exp( -2988.0/pt(j,i) + 303930.0/tt)
205                  k19xcb = 2.1e-12 * exp( -2659.0/pt(j,i) + 223052.0/tt)
206               endif
207               k19xca = k19xca * rfvt
208               k19xcb = k19xcb * rfvt
209               k19cap1 = k19xca * 2.0 * exp( -ee*nu1/pt(j,i) )
210               k19cap2 = k19xca * 2.0 * exp( -ee*nu2/pt(j,i) )
211               k19cbp1 = k19xcb * 2.0 * exp( -ee*nu1/pt(j,i) )
212               k19cbp2 = k19xcb * 2.0 * exp( -ee*nu2/pt(j,i) )
213               d19c = k19xca*co2t + k19xcb*n2co(i)
214               d19cp1 = k19cap1*co2t + k19cbp1*n2co(i)
215               d19cp2 = k19cap2*co2t + k19cbp2*n2co(i)
216                                !
217               k20xc = 3.e-12 * rfvto3p
218               k20cp1 = k20xc * 2.0 * exp( -ee/pt(j,i) * nu1 )
219               k20cp2 = k20xc * 2.0 * exp( -ee/pt(j,i) * nu2 )
220                                !
221               k21xc = 2.49e-11 * 0.5 * rfvv
222               k21cp2 = k21xc * exp( - ee/pt(j,i) * (nu2-nu1) )
223                                !
224               l1 = d19c + k20xc*o3p(i) + k21cp2*n2
225               p1 = ( d19cp1 + k20cp1*o3p(i) ) * n1
226               p12 = k21xc*n1
227                                !
228               l2 = d19c + k20xc*o3p(i) + k21xc*n1
229               p2 = ( d19cp2 + k20cp2*o3p(i) ) * n2
230               p21 = k21cp2*n2
231
232c radiative rates
233               ae1 = 1.3546 * 1.66 / 4.0 * escf1(i)
234               ae2 = ( 1.3452 + 1.1878 ) * 1.66 / 4.0 * escf2(i)
235               l1 = l1 + ae1
236               l2 = l2 + ae2
237
238c solving the system
239               c1 = gamma*nu1**3. * 0.5
240               c2 = gamma*nu2**3. * 0.5
241               a1 = c1 * p1 / (n1*l1)
242               a2 = c2 * p2 / (n2*l2)
243               a12 = (nu1/nu2)**3. * n2/n1 * p12/l1
244               a21 = (nu2/nu1)**3. * n1/n2 * p21/l2
245               el2 = (a2 + a21 * a1 ) / ( 1.0 - a21 * a12 )
246               el1 = a1 + a12 * el2
247               pl1 = el1 * n1 / c1
248               pl2 = el2 * n2 / c2
249
250c  heating rate
251               hr1 = - hplanck*vlight * nu1 * ae1 * pl1
252               hr2 = - hplanck*vlight * nu2 * ae2 * pl2
253               hr(i) = hr1 + hr2
254               dtnlte(j,i)=0.1*hr(i)*pt(j,i)/(4.4*pyy(i)) ! dtnlte in K s-1
255c              write(7,25)pxx(i),hr1,hr2,hr(i),qt
256c  25         format(' ',1p5e12.4)
257
258            endif
259
260         enddo  ! end loop over layers
261      enddo     ! end loop over grid points
262c     close(7)
263c
264        return
265        end
266
267c***********************************************************************
268
269      subroutine interp1(escout,p,nlayer,escin,pin,nl)
270C
271C subroutine to perform linear interpolation in pressure from 1D profile
272C escin(nl) sampled on pressure grid pin(nl) to profile
273C escout(nlayer) on pressure grid p(nlayer).
274C
275      real escout(nlayer),p(nlayer)
276      real escin(nl),pin(nl),wm,wp
277      integer nl,nlayer,n1,n,nm,np
278      do n1=1,nlayer
279         if(p(n1) .gt. 3.5 .or. p(n1) .lt. 4.0e-6) then
280            escout(n1) = 0.0
281         else
282            do n = 1,nl-1
283               if (p(n1).le.pin(n).and.p(n1).ge.pin(n+1)) then
284                  nm=n
285                  np=n+1
286                  wm=abs(pin(np)-p(n1))/(pin(nm)-pin(np))
287                  wp=1.0 - wm
288               endif
289            enddo
290            escout(n1) = escin(nm)*wm + escin(np)*wp
291         endif
292      enddo
293      return
294      end
295
296c***********************************************************************
297
298      subroutine interp3(esco1,esco2,esco3,p,nlayer,
299     1     esci1,esci2,esci3,pin,nl)
300C
301C subroutine to perform 3 simultaneous linear interpolations in pressure from
302C 1D profiles esci1-3(nl) sampled on pressure grid pin(nl) to 1D profiles
303C esco1-3(nlayer) on pressure grid p(ngrid,nlayer).
304C
305      real esco1(nlayer),esco2(nlayer),esco3(nlayer),p(nlayer)
306      real esci1(nl),    esci2(nl),    esci3(nl),    pin(nl),wm,wp
307      integer nl,nlayer,n1,n,nm,np
308      do n1=1,nlayer
309         if (p(n1).gt. 3.5 .or. p(n1) .lt. 4.0e-6) then
310            esco1(n1)=0.0
311            esco2(n1)=0.0
312            esco3(n1)=0.0
313         else
314            do n = 1,nl-1
315               if (p(n1).le.pin(n).and.p(n1).ge.pin(n+1)) then
316                  nm=n
317                  np=n+1
318                  wm=abs(pin(np)-p(n1))/(pin(nm)-pin(np))
319                  wp=1.0 - wm
320               endif
321            enddo
322            esco1(n1) = esci1(nm)*wm + esci1(np)*wp
323            esco2(n1) = esci2(nm)*wm + esci2(np)*wp
324            esco3(n1) = esci3(nm)*wm + esci3(np)*wp
325         endif
326      enddo
327      return
328      end
Note: See TracBrowser for help on using the repository browser.