source: LMDZ6/branches/Amaury_dev/libf/dyn3d/addfi.F90 @ 5112

Last change on this file since 5112 was 5105, checked in by abarral, 4 months ago

Replace 1DUTILS.h by module lmdz_1dutils.f90
Replace 1DConv.h by module lmdz_old_1dconv.f90 (it's only used by old_* files)
Convert *.F to *.f90
Fix gradsdef.h formatting
Remove unnecessary "RETURN" at the end of functions/subroutines

  • 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: 4.4 KB
Line 
1! $Id: addfi.F90 5105 2024-07-23 17:14:34Z abarral $
2
3SUBROUTINE addfi(pdt, leapf, forward, &
4        pucov, pvcov, pteta, pq, pps, &
5        pdufi, pdvfi, pdhfi, pdqfi, pdpfi)
6
7  USE infotrac, ONLY: nqtot
8  USE control_mod, ONLY: planet_type
9  IMPLICIT NONE
10  !
11  !=======================================================================
12  !
13  !    Addition of the physical tendencies
14  !
15  !    Interface :
16  !    -----------
17  !
18  !  Input :
19  !  -------
20  !  pdt                    time step of integration
21  !  leapf                  logical
22  !  forward                logical
23  !  pucov(ip1jmp1,llm)     first component of the covariant velocity
24  !  pvcov(ip1ip1jm,llm)    second component of the covariant velocity
25  !  pteta(ip1jmp1,llm)     potential temperature
26  !  pts(ip1jmp1,llm)       surface temperature
27  !  pdufi(ip1jmp1,llm)     |
28  !  pdvfi(ip1jm,llm)       |   respective
29  !  pdhfi(ip1jmp1)         |      tendencies
30  !  pdtsfi(ip1jmp1)        |
31  !
32  !  Output :
33  !  --------
34  !  pucov
35  !  pvcov
36  !  ph
37  !  pts
38  !
39  !
40  !=======================================================================
41  !
42  !-----------------------------------------------------------------------
43  !
44  !    0.  Declarations :
45  !    ------------------
46  !
47  include "dimensions.h"
48  include "paramet.h"
49  include "comgeom.h"
50  !
51  !    Arguments :
52  !    -----------
53  !
54  REAL, INTENT(IN) :: pdt ! time step for the integration (s)
55  !
56  REAL, INTENT(INOUT) :: pvcov(ip1jm, llm) ! covariant meridional wind
57  REAL, INTENT(INOUT) :: pucov(ip1jmp1, llm) ! covariant zonal wind
58  REAL, INTENT(INOUT) :: pteta(ip1jmp1, llm) ! potential temperature
59  REAL, INTENT(INOUT) :: pq(ip1jmp1, llm, nqtot) ! tracers
60  REAL, INTENT(INOUT) :: pps(ip1jmp1) ! surface pressure (Pa)
61  ! respective tendencies (.../s) to add
62  REAL, INTENT(IN) :: pdvfi(ip1jm, llm)
63  REAL, INTENT(IN) :: pdufi(ip1jmp1, llm)
64  REAL, INTENT(IN) :: pdqfi(ip1jmp1, llm, nqtot)
65  REAL, INTENT(IN) :: pdhfi(ip1jmp1, llm)
66  REAL, INTENT(IN) :: pdpfi(ip1jmp1)
67  !
68  LOGICAL, INTENT(IN) :: leapf, forward ! not used
69  !
70  !
71  !    Local variables :
72  !    -----------------
73  !
74  REAL :: xpn(iim), xps(iim), tpn, tps
75  INTEGER :: j, k, iq, ij
76  REAL, PARAMETER :: qtestw = 1.0e-15
77  REAL, PARAMETER :: qtestt = 1.0e-40
78
79  REAL :: SSUM
80  !
81  !-----------------------------------------------------------------------
82
83  DO k = 1, llm
84    DO j = 1, ip1jmp1
85      pteta(j, k) = pteta(j, k) + pdhfi(j, k) * pdt
86    ENDDO
87  ENDDO
88
89  DO  k = 1, llm
90    DO  ij = 1, iim
91      xpn(ij) = aire(ij) * pteta(ij, k)
92      xps(ij) = aire(ij + ip1jm) * pteta(ij + ip1jm, k)
93    ENDDO
94    tpn = SSUM(iim, xpn, 1) / apoln
95    tps = SSUM(iim, xps, 1) / apols
96
97    DO ij = 1, iip1
98      pteta(ij, k) = tpn
99      pteta(ij + ip1jm, k) = tps
100    ENDDO
101  ENDDO
102  !
103
104  DO k = 1, llm
105    DO j = iip2, ip1jm
106      pucov(j, k) = pucov(j, k) + pdufi(j, k) * pdt
107    ENDDO
108  ENDDO
109
110  DO k = 1, llm
111    DO j = 1, ip1jm
112      pvcov(j, k) = pvcov(j, k) + pdvfi(j, k) * pdt
113    ENDDO
114  ENDDO
115
116  !
117  DO j = 1, ip1jmp1
118    pps(j) = pps(j) + pdpfi(j) * pdt
119  ENDDO
120
121  if (planet_type=="earth") then
122    ! ! earth case, special treatment for first 2 tracers (water)
123    DO iq = 1, 2
124      DO k = 1, llm
125        DO j = 1, ip1jmp1
126          pq(j, k, iq) = pq(j, k, iq) + pdqfi(j, k, iq) * pdt
127          pq(j, k, iq) = AMAX1(pq(j, k, iq), qtestw)
128        ENDDO
129      ENDDO
130    ENDDO
131
132    DO iq = 3, nqtot
133      DO k = 1, llm
134        DO j = 1, ip1jmp1
135          pq(j, k, iq) = pq(j, k, iq) + pdqfi(j, k, iq) * pdt
136          pq(j, k, iq) = AMAX1(pq(j, k, iq), qtestt)
137        ENDDO
138      ENDDO
139    ENDDO
140  else
141    ! ! general case, treat all tracers equally)
142    DO iq = 1, nqtot
143      DO k = 1, llm
144        DO j = 1, ip1jmp1
145          pq(j, k, iq) = pq(j, k, iq) + pdqfi(j, k, iq) * pdt
146          pq(j, k, iq) = AMAX1(pq(j, k, iq), qtestt)
147        ENDDO
148      ENDDO
149    ENDDO
150  endif ! of if (planet_type=="earth")
151
152  DO  ij = 1, iim
153    xpn(ij) = aire(ij) * pps(ij)
154    xps(ij) = aire(ij + ip1jm) * pps(ij + ip1jm)
155  ENDDO
156  tpn = SSUM(iim, xpn, 1) / apoln
157  tps = SSUM(iim, xps, 1) / apols
158
159  DO ij = 1, iip1
160    pps (ij) = tpn
161    pps (ij + ip1jm) = tps
162  ENDDO
163
164  DO iq = 1, nqtot
165    DO  k = 1, llm
166      DO  ij = 1, iim
167        xpn(ij) = aire(ij) * pq(ij, k, iq)
168        xps(ij) = aire(ij + ip1jm) * pq(ij + ip1jm, k, iq)
169      ENDDO
170      tpn = SSUM(iim, xpn, 1) / apoln
171      tps = SSUM(iim, xps, 1) / apols
172
173      DO ij = 1, iip1
174        pq (ij, k, iq) = tpn
175        pq (ij + ip1jm, k, iq) = tps
176      ENDDO
177    ENDDO
178  ENDDO
179
180
181END SUBROUTINE addfi
Note: See TracBrowser for help on using the repository browser.