source: LMDZ6/branches/Amaury_dev/libf/dyn3d/integrd.F90 @ 5186

Last change on this file since 5186 was 5159, checked in by abarral, 7 weeks ago

Put dimensions.h and paramet.h into modules

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