source: LMDZ6/branches/Amaury_dev/libf/dyn3dmem/addfi_loc.f90 @ 5411

Last change on this file since 5411 was 5182, checked in by abarral, 3 months ago

(WIP) Replace REPROBUS CPP KEY by logical
properly name 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
File size: 5.9 KB
RevLine 
[1673]1! $Id$
[5099]2
[5105]3SUBROUTINE addfi_loc(pdt, leapf, forward, &
[5123]4        pucov, pvcov, pteta, pq, pps, &
5        pdufi, pdvfi, pdhfi, pdqfi, pdpfi)
[5105]6  USE parallel_lmdz
[5182]7  USE lmdz_infotrac, ONLY: nqtot
[5105]8  USE control_mod, ONLY: planet_type
[5123]9  USE lmdz_ssum_scopy, ONLY: ssum
[5136]10  USE lmdz_comgeom
[5123]11
[5159]12  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
13  USE lmdz_paramet
[5105]14  IMPLICIT NONE
[5159]15
[5105]16  !=======================================================================
[5159]17
[5105]18  !    Addition of the physical tendencies
[5159]19
[5105]20  !    Interface :
21  !    -----------
[5159]22
[5105]23  !  Input :
24  !  -------
25  !  pdt                    time step of integration
26  !  leapf                  logical
27  !  forward                logical
28  !  pucov(ip1jmp1,llm)     first component of the covariant velocity
29  !  pvcov(ip1ip1jm,llm)    second component of the covariant velocity
30  !  pteta(ip1jmp1,llm)     potential temperature
31  !  pts(ip1jmp1,llm)       surface temperature
32  !  pdufi(ip1jmp1,llm)     |
33  !  pdvfi(ip1jm,llm)       |   respective
34  !  pdhfi(ip1jmp1)         |      tendencies
35  !  pdtsfi(ip1jmp1)        |
[5159]36
[5105]37  !  Output :
38  !  --------
39  !  pucov
40  !  pvcov
41  !  ph
42  !  pts
[5159]43
44
[5105]45  !=======================================================================
[5159]46
[5105]47  !-----------------------------------------------------------------------
[5159]48
[5105]49  !    0.  Declarations :
50  !    ------------------
51  !
[5159]52
53
54
[5105]55  !    Arguments :
56  !    -----------
[5159]57
[5123]58  REAL, INTENT(IN) :: pdt ! time step for the integration (s)
[5159]59
[5123]60  REAL, INTENT(INOUT) :: pvcov(ijb_v:ije_v, llm) ! covariant meridional wind
61  REAL, INTENT(INOUT) :: pucov(ijb_u:ije_u, llm) ! covariant zonal wind
62  REAL, INTENT(INOUT) :: pteta(ijb_u:ije_u, llm) ! potential temperature
63  REAL, INTENT(INOUT) :: pq(ijb_u:ije_u, llm, nqtot) ! tracers
64  REAL, INTENT(INOUT) :: pps(ijb_u:ije_u) ! surface pressure (Pa)
[5105]65  ! respective tendencies (.../s) to add
[5123]66  REAL, INTENT(IN) :: pdvfi(ijb_v:ije_v, llm)
67  REAL, INTENT(IN) :: pdufi(ijb_u:ije_u, llm)
68  REAL, INTENT(IN) :: pdqfi(ijb_u:ije_u, llm, nqtot)
69  REAL, INTENT(IN) :: pdhfi(ijb_u:ije_u, llm)
70  REAL, INTENT(IN) :: pdpfi(ijb_u:ije_u)
[5159]71
[5123]72  LOGICAL, INTENT(IN) :: leapf, forward ! not used
[5159]73
74
[5105]75  !    Local variables :
76  !    -----------------
[5159]77
[5123]78  REAL :: xpn(iim), xps(iim), tpn, tps
79  INTEGER :: j, k, iq, ij
80  REAL, PARAMETER :: qtestw = 1.0e-15
81  REAL, PARAMETER :: qtestt = 1.0e-40
[1632]82
[5123]83  INTEGER :: ijb, ije
[5159]84
[5105]85  !-----------------------------------------------------------------------
[1632]86
[5123]87  ijb = ij_begin
88  ije = ij_end
[1632]89
[5123]90  !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
91  DO k = 1, llm
92    DO j = ijb, ije
93      pteta(j, k) = pteta(j, k) + pdhfi(j, k) * pdt
94    ENDDO
[5105]95  ENDDO
[5123]96  !$OMP END DO NOWAIT
[1632]97
[5117]98  IF (pole_nord) THEN
[5123]99    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
100    DO  k = 1, llm
101      DO  ij = 1, iim
102        xpn(ij) = aire(ij) * pteta(ij, k)
103      ENDDO
104      tpn = SSUM(iim, xpn, 1) / apoln
[1632]105
[5123]106      DO ij = 1, iip1
107        pteta(ij, k) = tpn
108      ENDDO
109    ENDDO
110    !$OMP END DO NOWAIT
[5117]111  ENDIF
[1632]112
[5117]113  IF (pole_sud) THEN
[5123]114    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
115    DO  k = 1, llm
116      DO  ij = 1, iim
117        xps(ij) = aire(ij + ip1jm) * pteta(ij + ip1jm, k)
118      ENDDO
119      tps = SSUM(iim, xps, 1) / apols
[1632]120
[5123]121      DO ij = 1, iip1
122        pteta(ij + ip1jm, k) = tps
123      ENDDO
124    ENDDO
125    !$OMP END DO NOWAIT
[5117]126  ENDIF
[5105]127  !
[1632]128
[5123]129  ijb = ij_begin
130  ije = ij_end
131  IF (pole_nord) ijb = ij_begin + iip1
132  IF (pole_sud)  ije = ij_end - iip1
[1632]133
[5123]134  !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
135  DO k = 1, llm
136    DO j = ijb, ije
137      pucov(j, k) = pucov(j, k) + pdufi(j, k) * pdt
138    ENDDO
[5105]139  ENDDO
[5123]140  !$OMP END DO NOWAIT
[1632]141
[5123]142  IF (pole_nord) ijb = ij_begin
[1632]143
[5123]144  !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
145  DO k = 1, llm
146    DO j = ijb, ije
147      pvcov(j, k) = pvcov(j, k) + pdvfi(j, k) * pdt
148    ENDDO
[5105]149  ENDDO
[5123]150  !$OMP END DO NOWAIT
[5105]151
[5159]152
[5123]153  IF (pole_sud)  ije = ij_end
154  !$OMP MASTER
155  DO j = ijb, ije
156    pps(j) = pps(j) + pdpfi(j) * pdt
[5105]157  ENDDO
[5123]158  !$OMP END MASTER
[5105]159
[5117]160  IF (planet_type=="earth") THEN
[5123]161    ! earth case, special treatment for first 2 tracers (water)
162    DO iq = 1, 2
163      !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
164      DO k = 1, llm
165        DO j = ijb, ije
166          pq(j, k, iq) = pq(j, k, iq) + pdqfi(j, k, iq) * pdt
167          pq(j, k, iq) = AMAX1(pq(j, k, iq), qtestw)
[5105]168        ENDDO
[5123]169      ENDDO
170      !$OMP END DO NOWAIT
171    ENDDO
[5105]172
[5123]173    DO iq = 3, nqtot
174      !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
175      DO k = 1, llm
176        DO j = ijb, ije
177          pq(j, k, iq) = pq(j, k, iq) + pdqfi(j, k, iq) * pdt
178          pq(j, k, iq) = AMAX1(pq(j, k, iq), qtestt)
[5105]179        ENDDO
[5123]180      ENDDO
181      !$OMP END DO NOWAIT
182    ENDDO
[5105]183  else
[5123]184    ! general case, treat all tracers equally)
185    DO iq = 1, nqtot
186      !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
187      DO k = 1, llm
188        DO j = ijb, ije
189          pq(j, k, iq) = pq(j, k, iq) + pdqfi(j, k, iq) * pdt
190          pq(j, k, iq) = AMAX1(pq(j, k, iq), qtestt)
[5105]191        ENDDO
[5123]192      ENDDO
193      !$OMP END DO NOWAIT
194    ENDDO
[5117]195  ENDIF ! of if (planet_type=="earth")
[5105]196
[5123]197  !$OMP MASTER
[5117]198  IF (pole_nord) THEN
[5123]199    DO  ij = 1, iim
200      xpn(ij) = aire(ij) * pps(ij)
[5105]201    ENDDO
202
[5123]203    tpn = SSUM(iim, xpn, 1) / apoln
[5105]204
[5123]205    DO ij = 1, iip1
206      pps (ij) = tpn
[5105]207    ENDDO
208
[5117]209  ENDIF
[5105]210
[5117]211  IF (pole_sud) THEN
[5123]212    DO  ij = 1, iim
213      xps(ij) = aire(ij + ip1jm) * pps(ij + ip1jm)
[5105]214    ENDDO
215
[5123]216    tps = SSUM(iim, xps, 1) / apols
[5105]217
[5123]218    DO ij = 1, iip1
219      pps (ij + ip1jm) = tps
[5105]220    ENDDO
221
[5117]222  ENDIF
[5123]223  !$OMP END MASTER
[5105]224
[5117]225  IF (pole_nord) THEN
[5105]226    DO iq = 1, nqtot
[5123]227      !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
228      DO  k = 1, llm
229        DO  ij = 1, iim
230          xpn(ij) = aire(ij) * pq(ij, k, iq)
[1632]231        ENDDO
[5123]232        tpn = SSUM(iim, xpn, 1) / apoln
[1632]233
[5123]234        DO ij = 1, iip1
235          pq (ij, k, iq) = tpn
[1632]236        ENDDO
[5105]237      ENDDO
[5123]238      !$OMP END DO NOWAIT
[5105]239    ENDDO
[5117]240  ENDIF
[1632]241
[5117]242  IF (pole_sud) THEN
[5105]243    DO iq = 1, nqtot
[5123]244      !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
245      DO  k = 1, llm
246        DO  ij = 1, iim
247          xps(ij) = aire(ij + ip1jm) * pq(ij + ip1jm, k, iq)
[1632]248        ENDDO
[5123]249        tps = SSUM(iim, xps, 1) / apols
[1632]250
[5123]251        DO ij = 1, iip1
252          pq (ij + ip1jm, k, iq) = tps
[1632]253        ENDDO
[5105]254      ENDDO
[5123]255      !$OMP END DO NOWAIT
[5105]256    ENDDO
[5117]257  ENDIF
[1632]258
[5105]259END SUBROUTINE addfi_loc
Note: See TracBrowser for help on using the repository browser.