source: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/libf/dyn3d/integrd.F

Last change on this file was 222, checked in by ymipsl, 10 years ago

Creating temporary dynamico/lmdz/saturn branche

YM

File size: 7.1 KB
Line 
1!
2! $Id: integrd.F 1616 2012-02-17 11:59:00Z emillour $
3!
4      SUBROUTINE integrd
5     $  (  nq,vcovm1,ucovm1,tetam1,psm1,massem1,
6     $     dv,du,dteta,dq,dp,vcov,ucov,teta,q,ps,masse,phis !,finvmaold
7     &  )
8
9      use control_mod, only : planet_type
10
11      IMPLICIT NONE
12
13
14c=======================================================================
15c
16c   Auteur:  P. Le Van
17c   -------
18c
19c   objet:
20c   ------
21c
22c   Incrementation des tendances dynamiques
23c
24c=======================================================================
25c-----------------------------------------------------------------------
26c   Declarations:
27c   -------------
28
29#include "dimensions.h"
30#include "paramet.h"
31#include "comconst.h"
32#include "comgeom.h"
33#include "comvert.h"
34#include "logic.h"
35#include "temps.h"
36#include "serre.h"
37#include "iniprint.h"
38
39c   Arguments:
40c   ----------
41
42      integer,intent(in) :: nq ! number of tracers to handle in this routine
43      real,intent(inout) :: vcov(ip1jm,llm) ! covariant meridional wind
44      real,intent(inout) :: ucov(ip1jmp1,llm) ! covariant zonal wind
45      real,intent(inout) :: teta(ip1jmp1,llm) ! potential temperature
46      real,intent(inout) :: q(ip1jmp1,llm,nq) ! advected tracers
47      real,intent(inout) :: ps(ip1jmp1) ! surface pressure
48      real,intent(inout) :: masse(ip1jmp1,llm) ! atmospheric mass
49      real,intent(in) :: phis(ip1jmp1) ! ground geopotential !!! unused
50      ! values at previous time step
51      real,intent(inout) :: vcovm1(ip1jm,llm)
52      real,intent(inout) :: ucovm1(ip1jmp1,llm)
53      real,intent(inout) :: tetam1(ip1jmp1,llm)
54      real,intent(inout) :: psm1(ip1jmp1)
55      real,intent(inout) :: massem1(ip1jmp1,llm)
56      ! the tendencies to add
57      real,intent(in) :: dv(ip1jm,llm)
58      real,intent(in) :: du(ip1jmp1,llm)
59      real,intent(in) :: dteta(ip1jmp1,llm)
60      real,intent(in) :: dp(ip1jmp1)
61      real,intent(in) :: dq(ip1jmp1,llm,nq) !!! unused
62!      real,intent(out) :: finvmaold(ip1jmp1,llm) !!! unused
63
64c   Local:
65c   ------
66
67      REAL vscr( ip1jm ),uscr( ip1jmp1 ),hscr( ip1jmp1 ),pscr(ip1jmp1)
68      REAL massescr( ip1jmp1,llm )
69!      REAL finvmasse(ip1jmp1,llm)
70      REAL p(ip1jmp1,llmp1)
71      REAL tpn,tps,tppn(iim),tpps(iim)
72      REAL qpn,qps,qppn(iim),qpps(iim)
73      REAL deltap( ip1jmp1,llm )
74
75      INTEGER  l,ij,iq,i,j
76
77      REAL SSUM
78
79c-----------------------------------------------------------------------
80
81      DO  l = 1,llm
82        DO  ij = 1,iip1
83         ucov(    ij    , l) = 0.
84         ucov( ij +ip1jm, l) = 0.
85         uscr(     ij      ) = 0.
86         uscr( ij +ip1jm   ) = 0.
87        ENDDO
88      ENDDO
89
90
91c    ............    integration  de       ps         ..............
92
93      CALL SCOPY(ip1jmp1*llm, masse, 1, massescr, 1)
94
95      DO ij = 1,ip1jmp1
96       pscr (ij)    = ps(ij)
97       ps (ij)      = psm1(ij) + dt * dp(ij)
98      ENDDO
99c
100      DO ij = 1,ip1jmp1
101        IF( ps(ij).LT.0. ) THEN
102         write(lunout,*) "integrd: negative surface pressure ",ps(ij)
103         write(lunout,*) " at node ij =", ij
104         ! since ij=j+(i-1)*jjp1 , we have
105         j=modulo(ij,jjp1)
106         i=1+(ij-j)/jjp1
107         write(lunout,*) " lon = ",rlonv(i)*180./pi, " deg",
108     &                   " lat = ",rlatu(j)*180./pi, " deg"
109         write(lunout,*) " psm1(ij)=",psm1(ij)," dt=",dt,
110     &                   " dp(ij)=",dp(ij)
111         stop
112        ENDIF
113      ENDDO
114c
115      DO  ij    = 1, iim
116       tppn(ij) = aire(   ij   ) * ps(  ij    )
117       tpps(ij) = aire(ij+ip1jm) * ps(ij+ip1jm)
118      ENDDO
119       tpn      = SSUM(iim,tppn,1)/apoln
120       tps      = SSUM(iim,tpps,1)/apols
121      DO ij   = 1, iip1
122       ps(   ij   )  = tpn
123       ps(ij+ip1jm)  = tps
124      ENDDO
125c
126c  ... Calcul  de la nouvelle masse d'air au dernier temps integre t+1 ...
127c
128      CALL pression ( ip1jmp1, ap, bp, ps, p )
129      CALL massdair (     p  , masse         )
130
131! Ehouarn : we don't use/need finvmaold and finvmasse,
132!           so might as well not compute them
133!      CALL   SCOPY( ijp1llm  , masse, 1, finvmasse,  1      )
134!      CALL filtreg( finvmasse, jjp1, llm, -2, 2, .TRUE., 1  )
135c
136
137c    ............   integration  de  ucov, vcov,  h     ..............
138
139      DO l = 1,llm
140
141       DO ij = iip2,ip1jm
142        uscr( ij )   =  ucov( ij,l )
143        ucov( ij,l ) = ucovm1( ij,l ) + dt * du( ij,l )
144       ENDDO
145
146       DO ij = 1,ip1jm
147        vscr( ij )   =  vcov( ij,l )
148        vcov( ij,l ) = vcovm1( ij,l ) + dt * dv( ij,l )
149       ENDDO
150
151       DO ij = 1,ip1jmp1
152        hscr( ij )    =  teta(ij,l)
153        teta ( ij,l ) = tetam1(ij,l) *  massem1(ij,l) / masse(ij,l) 
154     &                + dt * dteta(ij,l) / masse(ij,l)
155       ENDDO
156
157c   ....  Calcul de la valeur moyenne, unique  aux poles pour  teta    ......
158c
159c
160       DO  ij   = 1, iim
161        tppn(ij) = aire(   ij   ) * teta(  ij    ,l)
162        tpps(ij) = aire(ij+ip1jm) * teta(ij+ip1jm,l)
163       ENDDO
164        tpn      = SSUM(iim,tppn,1)/apoln
165        tps      = SSUM(iim,tpps,1)/apols
166
167       DO ij   = 1, iip1
168        teta(   ij   ,l)  = tpn
169        teta(ij+ip1jm,l)  = tps
170       ENDDO
171c
172
173       IF(leapf)  THEN
174         CALL SCOPY ( ip1jmp1, uscr(1), 1, ucovm1(1, l), 1 )
175         CALL SCOPY (   ip1jm, vscr(1), 1, vcovm1(1, l), 1 )
176         CALL SCOPY ( ip1jmp1, hscr(1), 1, tetam1(1, l), 1 )
177       END IF
178
179      ENDDO ! of DO l = 1,llm
180
181
182c
183c   .......  integration de   q   ......
184c
185c$$$      IF( iadv(1).NE.3.AND.iadv(2).NE.3 )    THEN
186c$$$c
187c$$$       IF( forward. OR . leapf )  THEN
188c$$$        DO iq = 1,2
189c$$$        DO  l = 1,llm
190c$$$        DO ij = 1,ip1jmp1
191c$$$        q(ij,l,iq) = ( q(ij,l,iq)*finvmaold(ij,l) + dtvr *dq(ij,l,iq) )/
192c$$$     $                            finvmasse(ij,l)
193c$$$        ENDDO
194c$$$        ENDDO
195c$$$        ENDDO
196c$$$       ELSE
197c$$$         DO iq = 1,2
198c$$$         DO  l = 1,llm
199c$$$         DO ij = 1,ip1jmp1
200c$$$         q( ij,l,iq ) = q( ij,l,iq ) * finvmaold(ij,l) / finvmasse(ij,l)
201c$$$         ENDDO
202c$$$         ENDDO
203c$$$         ENDDO
204c$$$
205c$$$       END IF
206c$$$c
207c$$$      ENDIF
208
209      if (planet_type.eq."earth") then
210! Earth-specific treatment of first 2 tracers (water)
211        DO l = 1, llm
212          DO ij = 1, ip1jmp1
213            deltap(ij,l) =  p(ij,l) - p(ij,l+1) 
214          ENDDO
215        ENDDO
216
217        CALL qminimum( q, nq, deltap )
218
219c
220c    .....  Calcul de la valeur moyenne, unique  aux poles pour  q .....
221c
222
223       DO iq = 1, nq
224        DO l = 1, llm
225
226           DO ij = 1, iim
227             qppn(ij) = aire(   ij   ) * q(   ij   ,l,iq)
228             qpps(ij) = aire(ij+ip1jm) * q(ij+ip1jm,l,iq)
229           ENDDO
230             qpn  =  SSUM(iim,qppn,1)/apoln
231             qps  =  SSUM(iim,qpps,1)/apols
232
233           DO ij = 1, iip1
234             q(   ij   ,l,iq)  = qpn
235             q(ij+ip1jm,l,iq)  = qps
236           ENDDO
237
238        ENDDO
239       ENDDO
240
241! Ehouarn: forget about finvmaold
242!      CALL  SCOPY( ijp1llm , finvmasse, 1, finvmaold, 1 )
243
244      endif ! of if (planet_type.eq."earth")
245c
246c
247c     .....   FIN  de l'integration  de   q    .......
248
249c    .................................................................
250
251
252      IF( leapf )  THEN
253         CALL SCOPY (    ip1jmp1 ,  pscr   , 1,   psm1  , 1 )
254         CALL SCOPY ( ip1jmp1*llm, massescr, 1,  massem1, 1 )
255      END IF
256
257      RETURN
258      END
Note: See TracBrowser for help on using the repository browser.