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