source: trunk/LMDZ.MARS/libf/phymars/vlz_fi.F @ 4067

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

Mars PCM:
Some code tidying:

  • turn aeroptproperties, albedocaps, cvmgp and convadj into modules
  • remove useless check in callradite
  • clean module vlz_fi (remove obsolete #ifdef CRAY cpp alternatives)
  • remove function cvmgp since it was only called under #ifdef CRAY in vlz_fi

EM

File size: 5.8 KB
Line 
1      MODULE vlz_fi_mod
2     
3      IMPLICIT NONE
4     
5      CONTAINS
6     
7      SUBROUTINE vlz_fi(ngrid,nlay,q,pente_max,masse,w,wq)
8c
9c     Auteurs:   P.Le Van, F.Hourdin, F.Forget
10c
11c    ********************************************************************
12c    "pseudo upstream" Advection scheme along the vertical
13c    to be used in the physics (sedimentation)
14c    ********************************************************************
15
16      IMPLICIT NONE
17c
18
19c
20c
21c   Arguments:
22c   ----------
23      integer,intent(in) :: ngrid ! number of atmospheric columns
24      integer,intent(in) :: nlay ! number of atmospheric layers
25      real,intent(in) :: masse(ngrid,nlay) ! mass of atmospheric layer delta(P)/g
26      real,intent(in) :: pente_max ! maximum slope for the scheme (2 is recommended)
27      real,intent(inout) :: q(ngrid,nlay) ! tracer mixing ratio (kg/kg)
28      real,intent(inout) :: w(ngrid,nlay) ! mass of atmosphere "transfered" over the time step (kg.m-2)
29      real,intent(out) :: wq(ngrid,nlay+1) ! trancer increment due to advection (kg)
30c
31c      Local
32c   ---------
33c
34      INTEGER i,ij,l,j,ii
35c
36
37      real dzq(ngrid,nlay),dzqw(ngrid,nlay),adzqw(ngrid,nlay),dzqmax
38      real newmasse
39      real sigw, Mtot, MQtot
40      integer m
41
42
43c    Orientation follows pressure, i.e. follows W
44
45      do l=2,nlay
46         do ij=1,ngrid
47            dzqw(ij,l)=q(ij,l-1)-q(ij,l)
48            adzqw(ij,l)=abs(dzqw(ij,l))
49         enddo
50      enddo
51
52      do l=2,nlay-1
53         do ij=1,ngrid
54            if(dzqw(ij,l)*dzqw(ij,l+1).gt.0.) then
55                dzq(ij,l)=0.5*(dzqw(ij,l)+dzqw(ij,l+1))
56            else
57                dzq(ij,l)=0.
58            endif
59
60            dzqmax=pente_max*min(adzqw(ij,l),adzqw(ij,l+1))
61            dzq(ij,l)=sign(min(abs(dzq(ij,l)),dzqmax),dzq(ij,l))
62         enddo
63      enddo
64
65      do ij=1,ngrid
66         dzq(ij,1)=0.
67         dzq(ij,nlay)=0.
68      enddo
69c ---------------------------------------------------------------
70c   .... compute vertical advection terms   .......
71c ---------------------------------------------------------------
72
73c compute  - d( q   * w )/ d(sigma) , later added to dq to compute dq
74c
75c      No flux at the model top:
76       do ij=1,ngrid
77          wq(ij,nlay+1)=0.
78       enddo
79
80c      1) Compute wq where w > 0 (down) (ALWAYS FOR SEDIMENTATION)     
81c      ===============================
82
83       do l = 1,nlay          ! loop different than when w<0
84        do  ij = 1,ngrid
85         if(w(ij,l).gt.0.)then
86
87c         Regular scheme (transfered mass < 1 layer)
88c         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
89          if(w(ij,l).le.masse(ij,l))then
90            sigw=w(ij,l)/masse(ij,l)
91            wq(ij,l)=w(ij,l)*(q(ij,l)+0.5*(1.-sigw)*dzq(ij,l))
92           
93
94c         Extended scheme (transfered mass > 1 layer)
95c         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
96          else
97            m=l
98            Mtot = masse(ij,m)
99            MQtot = masse(ij,m)*q(ij,m)
100            if(m.ge.nlay)goto 88
101            do while(w(ij,l).gt.(Mtot+masse(ij,m+1)))
102                m=m+1
103                Mtot = Mtot + masse(ij,m)
104                MQtot = MQtot + masse(ij,m)*q(ij,m)
105                if(m.ge.nlay)goto 88
106            end do
107 88         continue
108            if (m.lt.nlay) then
109                sigw=(w(ij,l)-Mtot)/masse(ij,m+1)
110                wq(ij,l)=(MQtot + (w(ij,l)-Mtot)*
111     &          (q(ij,m+1)+0.5*(1.-sigw)*dzq(ij,m+1)) )
112            else
113                w(ij,l) = Mtot
114                wq(ij,l) = Mqtot
115            end if
116
117          end if
118         end if
119        enddo
120       enddo
121
122c      2) Compute wq where w < 0 (up) (NOT USEFUL FOR SEDIMENTATION)     
123c      ===============================
124       goto 99 ! SKIPPING THIS PART FOR SEDIMENTATION
125
126c      Surface flux up:
127       do  ij = 1,ngrid
128         if(w(ij,1).lt.0.) wq(ij,1)=0. ! warning : not always valid
129       end do
130
131       do l = 1,nlay-1  ! loop different than when w>0
132        do  ij = 1,ngrid
133         if(w(ij,l+1).le.0)then
134
135c         Regular scheme (transfered mass < 1 layer)
136c         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
137          if(-w(ij,l+1).le.masse(ij,l))then
138            sigw=w(ij,l+1)/masse(ij,l)
139            wq(ij,l+1)=w(ij,l+1)*(q(ij,l)-0.5*(1.+sigw)*dzq(ij,l))
140c         Extended scheme (transfered mass > 1 layer)
141c         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
142          else
143             m = l-1
144             Mtot = masse(ij,m+1)
145             MQtot = masse(ij,m+1)*q(ij,m+1)
146             if (m.le.0)goto 77
147             do while(-w(ij,l+1).gt.(Mtot+masse(ij,m)))
148                m=m-1
149                Mtot = Mtot + masse(ij,m+1)
150                MQtot = MQtot + masse(ij,m+1)*q(ij,m+1)
151                if (m.le.0)goto 77
152             end do
153 77          continue
154
155             if (m.gt.0) then
156                sigw=(w(ij,l+1)+Mtot)/masse(ij,m)
157                wq(ij,l+1)= - (MQtot + (-w(ij,l+1)-Mtot)*
158     &          (q(ij,m)-0.5*(1.+sigw)*dzq(ij,m))  )
159             else
160c               wq(ij,l+1)= (MQtot + (-w(ij,l+1)-Mtot)*qm(ij,1))
161                write(*,*) 'a rather weird situation in vlz_fi !'
162                call abort_physic("vlz_fi","weird situation",1)
163             end if
164
165          endif
166         endif
167        enddo
168       enddo
169 99    continue
170
171      do l=1,nlay
172         do ij=1,ngrid
173
174cccccccc lines below not used for sedimentation (No real flux)
175ccccc       newmasse=masse(ij,l)+w(ij,l+1)-w(ij,l)
176ccccc       q(ij,l)=(q(ij,l)*masse(ij,l)+wq(ij,l+1)-wq(ij,l))
177ccccc&         /newmasse
178ccccc       masse(ij,l)=newmasse
179
180c            it cannot entrain more than available mass !
181            if ((wq(ij,l+1)-wq(ij,l)) .lt. -(masse(ij,l)*q(ij,l))) then
182              wq(ij,l+1) = wq(ij,l)-masse(ij,l)*q(ij,l)
183            end if
184
185            q(ij,l)=q(ij,l) +  (wq(ij,l+1)-wq(ij,l))/masse(ij,l) 
186         enddo
187      enddo
188
189      END SUBROUTINE vlz_fi
190
191      END MODULE vlz_fi_mod
Note: See TracBrowser for help on using the repository browser.