1 | !> @file swap_timelevel.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of PALM. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
6 | ! terms of the GNU General Public License as published by the Free Software |
---|
7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
8 | ! version. |
---|
9 | ! |
---|
10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
13 | ! |
---|
14 | ! You should have received a copy of the GNU General Public License along with |
---|
15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | ! |
---|
17 | ! Copyright 1997-2016 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: swap_timelevel.f90 2012 2016-09-19 17:31:38Z suehring $ |
---|
27 | ! |
---|
28 | ! 2011 2016-09-19 17:29:57Z kanani |
---|
29 | ! Flag urban_surface is now defined in module control_parameters. |
---|
30 | ! |
---|
31 | ! 2007 2016-08-24 15:47:17Z kanani |
---|
32 | ! Added swapping of urban surface model quantities, |
---|
33 | ! removed redundance for land surface model |
---|
34 | ! |
---|
35 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
36 | ! Forced header and separation lines into 80 columns |
---|
37 | ! |
---|
38 | ! 1960 2016-07-12 16:34:24Z suehring |
---|
39 | ! Separate humidity and passive scalar |
---|
40 | ! |
---|
41 | ! 1822 2016-04-07 07:49:42Z hoffmann |
---|
42 | ! icloud_scheme replaced by microphysics_* |
---|
43 | ! |
---|
44 | ! swap_timelevel.f90 1766 2016-02-29 08:37:15Z raasch |
---|
45 | ! setting the swap level for pmc data transfer |
---|
46 | ! |
---|
47 | ! 1747 2016-02-08 12:25:53Z raasch |
---|
48 | ! explicit loops in nopointer case to omit craypointer option of pgi compiler |
---|
49 | ! |
---|
50 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
51 | ! Code annotations made doxygen readable |
---|
52 | ! |
---|
53 | ! 1496 2014-12-02 17:25:50Z maronga |
---|
54 | ! Added swapping of land surface model quantities |
---|
55 | ! |
---|
56 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
57 | ! bugfix: use-statement for nopointer-case added |
---|
58 | ! |
---|
59 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
60 | ! ONLY-attribute added to USE-statements, |
---|
61 | ! revision history before 2012 removed, |
---|
62 | ! 1318 2014-03-17 13:35:16Z raasch |
---|
63 | ! module interfaces removed |
---|
64 | ! |
---|
65 | ! 1115 2013-03-26 18:16:16Z hoffmann |
---|
66 | ! calculation of qr and nr is restricted to precipitation |
---|
67 | ! |
---|
68 | ! 1111 2013-03-08 23:54:10Z raasch |
---|
69 | ! openACC directives added |
---|
70 | ! |
---|
71 | ! 1053 2012-11-13 17:11:03Z hoffmann |
---|
72 | ! swap of timelevels for nr, qr added |
---|
73 | ! |
---|
74 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
75 | ! code put under GPL (PALM 3.9) |
---|
76 | ! |
---|
77 | ! 1032 2012-10-21 13:03:21Z letzel |
---|
78 | ! save memory by not allocating pt_2 in case of neutral = .T. |
---|
79 | ! |
---|
80 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
81 | ! cpp switch __nopointer added for pointer free version |
---|
82 | ! |
---|
83 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
84 | ! all actions concerning leapfrog scheme removed |
---|
85 | ! |
---|
86 | ! Revision 1.1 2000/01/10 10:08:58 10:08:58 raasch (Siegfried Raasch) |
---|
87 | ! Initial revision |
---|
88 | ! |
---|
89 | ! |
---|
90 | ! Description: |
---|
91 | ! ------------ |
---|
92 | !> Swap of timelevels of variables after each timestep |
---|
93 | !------------------------------------------------------------------------------! |
---|
94 | SUBROUTINE swap_timelevel |
---|
95 | |
---|
96 | |
---|
97 | #if defined( __nopointer ) |
---|
98 | USE arrays_3d, & |
---|
99 | ONLY: e, e_p, nr, nr_p, pt, pt_p, q, q_p, qr, qr_p, s, s_p, sa, sa_p, & |
---|
100 | u, u_p, v, v_p, w, w_p |
---|
101 | #else |
---|
102 | USE arrays_3d, & |
---|
103 | ONLY: e, e_1, e_2, e_p, nr, nr_1, nr_2, nr_p, pt, pt_1, pt_2, pt_p, q,& |
---|
104 | q_1, q_2, q_p, qr, qr_1, qr_2, qr_p, s, s_1, s_2, s_p, sa, sa_1,& |
---|
105 | sa_2, sa_p, u, u_1, u_2, u_p, v, v_1, v_2, v_p, w, w_1, w_2, w_p |
---|
106 | |
---|
107 | #endif |
---|
108 | |
---|
109 | USE land_surface_model_mod, & |
---|
110 | ONLY: land_surface, lsm_swap_timelevel |
---|
111 | |
---|
112 | USE cpulog, & |
---|
113 | ONLY: cpu_log, log_point |
---|
114 | |
---|
115 | USE control_parameters, & |
---|
116 | ONLY: cloud_physics, constant_diffusion, humidity, & |
---|
117 | microphysics_seifert, neutral, ocean, passive_scalar, & |
---|
118 | timestep_count, urban_surface |
---|
119 | |
---|
120 | USE indices, & |
---|
121 | ONLY: nxlg, nxrg, nyng, nysg, nzb, nzt |
---|
122 | |
---|
123 | USE pmc_interface, & |
---|
124 | ONLY: nested_run, pmci_set_swaplevel |
---|
125 | |
---|
126 | USE urban_surface_mod, & |
---|
127 | ONLY: usm_swap_timelevel |
---|
128 | |
---|
129 | |
---|
130 | IMPLICIT NONE |
---|
131 | |
---|
132 | INTEGER :: i, j, k !> loop indices |
---|
133 | INTEGER :: swap_level !> swap_level for steering the pmc data transfer |
---|
134 | |
---|
135 | ! |
---|
136 | !-- Incrementing timestep counter |
---|
137 | timestep_count = timestep_count + 1 |
---|
138 | |
---|
139 | ! |
---|
140 | !-- Swap of variables |
---|
141 | #if defined( __nopointer ) |
---|
142 | CALL cpu_log( log_point(28), 'swap_timelevel (nop)', 'start' ) |
---|
143 | |
---|
144 | !$acc kernels present( pt, pt_p, u, u_p, v, v_p, w, w_p ) |
---|
145 | !$acc loop independent |
---|
146 | DO i = nxlg, nxrg |
---|
147 | !$acc loop independent |
---|
148 | DO j = nysg, nyng |
---|
149 | !$acc loop independent |
---|
150 | DO k = nzb, nzt+1 |
---|
151 | u(k,j,i) = u_p(k,j,i) |
---|
152 | v(k,j,i) = v_p(k,j,i) |
---|
153 | w(k,j,i) = w_p(k,j,i) |
---|
154 | pt(k,j,i) = pt_p(k,j,i) |
---|
155 | ENDDO |
---|
156 | ENDDO |
---|
157 | ENDDO |
---|
158 | ! u = u_p |
---|
159 | ! v = v_p |
---|
160 | ! w = w_p |
---|
161 | ! pt = pt_p |
---|
162 | !$acc end kernels |
---|
163 | IF ( .NOT. constant_diffusion ) THEN |
---|
164 | !$acc kernels present( e, e_p ) |
---|
165 | !$acc loop independent |
---|
166 | DO i = nxlg, nxrg |
---|
167 | !$acc loop independent |
---|
168 | DO j = nysg, nyng |
---|
169 | !$acc loop independent |
---|
170 | DO k = nzb, nzt+1 |
---|
171 | e(k,j,i) = e_p(k,j,i) |
---|
172 | ENDDO |
---|
173 | ENDDO |
---|
174 | ENDDO |
---|
175 | ! e = e_p |
---|
176 | !$acc end kernels |
---|
177 | ENDIF |
---|
178 | IF ( ocean ) THEN |
---|
179 | sa = sa_p |
---|
180 | ENDIF |
---|
181 | IF ( humidity ) THEN |
---|
182 | q = q_p |
---|
183 | IF ( cloud_physics .AND. microphysics_seifert ) THEN |
---|
184 | qr = qr_p |
---|
185 | nr = nr_p |
---|
186 | ENDIF |
---|
187 | ENDIF |
---|
188 | IF ( passive_scalar ) s = s_p |
---|
189 | |
---|
190 | IF ( land_surface ) THEN |
---|
191 | CALL lsm_swap_timelevel ( 0 ) |
---|
192 | ENDIF |
---|
193 | |
---|
194 | IF ( urban_surface ) THEN |
---|
195 | CALL usm_swap_timelevel ( 0 ) |
---|
196 | ENDIF |
---|
197 | |
---|
198 | |
---|
199 | CALL cpu_log( log_point(28), 'swap_timelevel (nop)', 'stop' ) |
---|
200 | #else |
---|
201 | CALL cpu_log( log_point(28), 'swap_timelevel', 'start' ) |
---|
202 | |
---|
203 | SELECT CASE ( MOD( timestep_count, 2 ) ) |
---|
204 | |
---|
205 | CASE ( 0 ) |
---|
206 | |
---|
207 | u => u_1; u_p => u_2 |
---|
208 | v => v_1; v_p => v_2 |
---|
209 | w => w_1; w_p => w_2 |
---|
210 | IF ( .NOT. neutral ) THEN |
---|
211 | pt => pt_1; pt_p => pt_2 |
---|
212 | ENDIF |
---|
213 | IF ( .NOT. constant_diffusion ) THEN |
---|
214 | e => e_1; e_p => e_2 |
---|
215 | ENDIF |
---|
216 | IF ( ocean ) THEN |
---|
217 | sa => sa_1; sa_p => sa_2 |
---|
218 | ENDIF |
---|
219 | IF ( humidity ) THEN |
---|
220 | q => q_1; q_p => q_2 |
---|
221 | IF ( cloud_physics .AND. microphysics_seifert ) THEN |
---|
222 | qr => qr_1; qr_p => qr_2 |
---|
223 | nr => nr_1; nr_p => nr_2 |
---|
224 | ENDIF |
---|
225 | ENDIF |
---|
226 | IF ( passive_scalar ) THEN |
---|
227 | s => s_1; s_p => s_2 |
---|
228 | ENDIF |
---|
229 | |
---|
230 | swap_level = 1 |
---|
231 | |
---|
232 | CASE ( 1 ) |
---|
233 | |
---|
234 | u => u_2; u_p => u_1 |
---|
235 | v => v_2; v_p => v_1 |
---|
236 | w => w_2; w_p => w_1 |
---|
237 | IF ( .NOT. neutral ) THEN |
---|
238 | pt => pt_2; pt_p => pt_1 |
---|
239 | ENDIF |
---|
240 | IF ( .NOT. constant_diffusion ) THEN |
---|
241 | e => e_2; e_p => e_1 |
---|
242 | ENDIF |
---|
243 | IF ( ocean ) THEN |
---|
244 | sa => sa_2; sa_p => sa_1 |
---|
245 | ENDIF |
---|
246 | IF ( humidity ) THEN |
---|
247 | q => q_2; q_p => q_1 |
---|
248 | IF ( cloud_physics .AND. microphysics_seifert ) THEN |
---|
249 | qr => qr_2; qr_p => qr_1 |
---|
250 | nr => nr_2; nr_p => nr_1 |
---|
251 | ENDIF |
---|
252 | ENDIF |
---|
253 | IF ( passive_scalar ) THEN |
---|
254 | s => s_2; s_p => s_1 |
---|
255 | ENDIF |
---|
256 | |
---|
257 | swap_level = 2 |
---|
258 | |
---|
259 | END SELECT |
---|
260 | |
---|
261 | IF ( land_surface ) THEN |
---|
262 | CALL lsm_swap_timelevel ( MOD( timestep_count, 2) ) |
---|
263 | ENDIF |
---|
264 | |
---|
265 | IF ( urban_surface ) THEN |
---|
266 | CALL usm_swap_timelevel ( MOD( timestep_count, 2) ) |
---|
267 | ENDIF |
---|
268 | |
---|
269 | ! |
---|
270 | !-- Set the swap level for steering the pmc data transfer |
---|
271 | IF ( nested_run ) CALL pmci_set_swaplevel( swap_level ) |
---|
272 | |
---|
273 | CALL cpu_log( log_point(28), 'swap_timelevel', 'stop' ) |
---|
274 | #endif |
---|
275 | |
---|
276 | END SUBROUTINE swap_timelevel |
---|
277 | |
---|
278 | |
---|