source: trunk/LMDZ.MARS/libf/phymars/newsedim_mod.F @ 3727

Last change on this file since 3727 was 3727, checked in by emillour, 9 months ago

Mars PCM:
Code tidying: put routines in modules, remove useless "return" statements and
remove obsolete and unused scopyi.F
EM

File size: 7.4 KB
Line 
1      MODULE newsedim_mod
2     
3      IMPLICIT NONE
4     
5      CONTAINS
6
7      SUBROUTINE newsedim(ngrid,nlay,naersize,nrhosize,ptimestep,
8     &  pplev,masse,epaisseur,pt,rd,rho,pqi,wq,beta)
9      USE vlz_fi_mod, ONLY: vlz_fi
10      USE comcstfi_h, ONLY: r,g
11      IMPLICIT NONE
12
13c=======================================================================
14c
15c      Compute sedimentation of 1 tracer
16c      of radius rd (m) and density rho (kg.m-3)
17c
18c=======================================================================
19
20c-----------------------------------------------------------------------
21c   declarations:
22c   -------------
23
24c
25c   arguments:
26c   ----------
27
28      INTEGER,INTENT(IN) :: ngrid,nlay,naersize,nrhosize
29      REAL,INTENT(IN) :: ptimestep            ! pas de temps physique (s)
30      REAL,INTENT(IN) :: pplev(ngrid,nlay+1) ! pression aux inter-couches (Pa)
31      REAL,INTENT(IN) :: pt(ngrid,nlay) ! temperature au centre des couches (K)
32      real,intent(in) :: masse (ngrid,nlay) ! masse d'une couche (kg)
33      real,intent(in) :: epaisseur (ngrid,nlay)  ! epaisseur d'une couche (m)
34      real,intent(in) :: rd(naersize)             ! particle radius (m)
35      real,intent(in) :: rho(nrhosize)             ! particle density (kg.m-3)
36
37
38c    Traceurs :
39      real,intent(inout) :: pqi(ngrid,nlay)  ! traceur   (e.g. ?/kg)
40      real,intent(out) :: wq(ngrid,nlay+1)  ! flux de traceur durant timestep (?/m-2)
41      real,intent(in) :: beta ! correction for the shape of the particles
42                !   (see Murphy et al. JGR 1990 vol.95)
43                !   beta=1 for spheres
44                !   beta=0.85 for irregular particles
45                !   beta=0.5 for disk shaped particles
46     
47c   local:
48c   ------
49
50      INTEGER l,ig, k, i
51      REAL rfall,rhofall
52
53      LOGICAL,SAVE :: firstcall=.true.
54
55!$OMP THREADPRIVATE(firstcall)
56
57c    Traceurs :
58c    ~~~~~~~~
59      real traversee (ngrid,nlay)
60      real vstokes(ngrid,nlay)
61      real w(ngrid,nlay)
62      real ptop, dztop, Ep, Stra
63
64
65c    Physical constant
66c    ~~~~~~~~~~~~~~~~~
67c     Gas molecular viscosity (N.s.m-2)
68      real,parameter :: visc=1.e-5       ! CO2
69c     Effective gas molecular radius (m)
70      real,parameter :: molrad=2.2e-10   ! CO2
71
72c     local and saved variable
73      real,save :: a,b
74
75!$OMP THREADPRIVATE(a,b)
76
77
78c    ** un petit test de coherence
79c       --------------------------
80
81      ! AS: OK firstcall absolute
82      IF (firstcall) THEN
83
84         firstcall=.false.
85
86
87c       Preliminary calculations for sedimenation velocity :
88c       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
89
90c       - Constant to compute stokes speed simple formulae
91c        (Vstokes =  b * rho* r**2   avec   b= (2/9) * rho * g / visc
92         b = 2./9. * g / visc
93      ENDIF ! of IF(firstcall)
94     
95c       - Constant  to compute gas mean free path
96c        l= (T/P)*a, avec a = (  0.707*8.31/(4*pi*molrad**2 * avogadro))
97         a = 0.707*8.31/(4*3.1416* molrad*molrad * 6.023e23)
98
99c       - Correction to account for non-spherical shape (Murphy et al.  1990)
100         a = a * beta
101
102
103
104c-----------------------------------------------------------------------
105c    1. initialisation
106c    -----------------
107
108c     Sedimentation velocity (m/s)
109c     ~~~~~~~~~~~~~~~~~~~~~~
110c     (stokes law corrected for low pressure by the Cunningham
111c     slip-flow correction  according to Rossow (Icarus 36, 1-50, 1978)
112
113        do  l=1,nlay
114          do ig=1, ngrid
115c           radius
116            if (naersize.eq.1) then
117              rfall=rd(1)
118            else
119              i=ngrid*(l-1)+ig
120              rfall=rd(i)
121            endif 
122c           density
123            if (nrhosize.eq.1) then
124              rhofall=rho(1)
125            else
126              i=ngrid*(l-1)+ig
127              rhofall=rho(i)
128            endif 
129c           vstokes
130            vstokes(ig,l) = b * rhofall * rfall*rfall *
131     &      (1 + 1.333* ( a*pt(ig,l)/pplev(ig,l) )/rfall)
132
133c           Layer crossing time (s) :
134            traversee(ig,l)= epaisseur(ig,l)/vstokes(ig,l)
135          end do
136        end do
137
138
139c     Calcul de la masse d'atmosphere correspondant a q transferee
140c     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
141c     (e.g. on recherche le niveau  en dessous de laquelle le traceur
142c      va traverser le niveau intercouche l : "dztop" est sa hauteur
143c      au dessus de l (m), "ptop" est sa pression (Pa))
144
145      do  l=1,nlay
146        do ig=1, ngrid
147             
148             dztop = vstokes(ig,l)*  ptimestep
149             Ep=0
150             k=0
151
152            w(ig,l) = 0. !! JF+AS ajout initialisation
153c **************************************************************
154c            Simple Method
155
156cc             w(ig,l) =
157cc     &       (1.- exp(-dztop*g/(r*pt(ig,l))))*pplev(ig,l) / g
158cccc           write(*,*) 'OK simple method l,w =', l, w(ig,l)
159cccc           write(*,*) 'OK simple method dztop =', dztop
160
161             w(ig,l) = 1. - exp(-dztop*g/(r*pt(ig,l)))
162             !!! Diagnostic: JF. Fix: AS. Date: 05/11
163             !!! Probleme arrondi avec la quantite ci-dessus
164             !!! ---> vaut 0 pour -dztop*g/(r*pt(ig,l)) trop petit
165             !!! ---> dans ce cas on utilise le developpement limite !
166             !!! ---> exp(-x) = 1 - x lorsque x --> 0 avec une erreur de x^2 / 2           
167             IF ( w(ig,l) .eq. 0. ) THEN
168                w(ig,l) = ( dztop*g/(r*pt(ig,l)) ) * pplev(ig,l) / g
169             ELSE
170                w(ig,l) = w(ig,l) * pplev(ig,l) / g 
171             ENDIF
172
173
174c **************************************************************
175cccc         Complex method :
176            if (dztop.gt.epaisseur(ig,l)) then                !!!if on traverse plus d'une couche
177cccc            Cas ou on "epuise" la couche l : On calcule le flux
178cccc            Venant de dessus en tenant compte de la variation de Vstokes
179c **************************************************************
180               Ep= epaisseur(ig,l)
181               Stra= traversee(ig,l)
182               do while(dztop.gt.Ep.and.l+k+1.le.nlay)
183                 k=k+1
184                 dztop= Ep + vstokes(ig,l+k)*(ptimestep -Stra)
185                 Ep = Ep + epaisseur(ig,l+k)
186                 Stra = Stra + traversee(ig,l+k)
187               enddo
188               Ep = Ep - epaisseur(ig,l+k)
189             !ptop=pplev(ig,l+k)*exp(-(dztop-Ep)*g/(r*pt(ig,l+k)))
190
191             !!! JF+AS 05/11 Probleme arrondi potentiel, meme solution que ci-dessus
192             ptop=exp(-(dztop-Ep)*g/(r*pt(ig,l+k)))
193             IF ( ptop .eq. 1. ) THEN
194                !PRINT*, 'newsedim: exposant trop petit ', ig, l
195                ptop=pplev(ig,l+k) * ( 1. - (dztop-Ep)*g/(r*pt(ig,l+k)))
196             ELSE
197                ptop=pplev(ig,l+k) * ptop
198             ENDIF
199             w(ig,l) = (pplev(ig,l) - Ptop)/g
200
201            endif                !!!!!if complex method
202
203
204cc           write(*,*) 'OK new    method l,w =', l, w(ig,l)
205cc           write(*,*) 'OK new    method dztop =', dztop
206cc       if(l.eq.7)write(*,*)'l=7,k,pplev,Ptop',pplev(ig,l),Ptop
207cc       if(l.eq.7)write(*,*)'l=7,dztop,Ep',dztop,Ep
208cc            if(l.eq.6)write(*,*)'l=6,k, w',k, w(1,l)
209cc            if(l.eq.7)write(*,*)'l=7,k, w',k, w(1,l)
210cc            if(l.eq.8)write(*,*)'l=8,k, w',k, w(1,l)
211c **************************************************************
212
213
214        end do
215      end do
216      call vlz_fi(ngrid,nlay,pqi,2.,masse,w,wq)
217c         write(*,*) ' newsed: wq(6), wq(7), q(6)',
218c    &                wq(1,6),wq(1,7),pqi(1,6)
219
220
221      END SUBROUTINE newsedim
222     
223      END MODULE newsedim_mod
224
Note: See TracBrowser for help on using the repository browser.