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