1 | !> @file swap_timelevel.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of the PALM model system. |
---|
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-2018 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: swap_timelevel.f90 3589 2018-11-30 15:09:51Z kanani $ |
---|
27 | ! Move the control parameter "salsa" from salsa_mod to control_parameters |
---|
28 | ! (M. Kurppa) |
---|
29 | ! |
---|
30 | ! 3582 2018-11-29 19:16:36Z suehring |
---|
31 | ! Implementation of a new aerosol module salsa. |
---|
32 | ! |
---|
33 | ! 3303 2018-10-03 12:04:15Z raasch |
---|
34 | ! bugfix for swapping in case of ocean mode |
---|
35 | ! |
---|
36 | ! 3294 2018-10-01 02:37:10Z raasch |
---|
37 | ! changes concerning modularization of ocean option |
---|
38 | ! |
---|
39 | ! 3274 2018-09-24 15:42:55Z knoop |
---|
40 | ! Modularization of all bulk cloud physics code components |
---|
41 | ! |
---|
42 | ! 3241 2018-09-12 15:02:00Z raasch |
---|
43 | ! unused variables removed |
---|
44 | ! |
---|
45 | ! 2817 2018-02-19 16:32:21Z knoop |
---|
46 | ! Preliminary gust module interface implemented |
---|
47 | ! |
---|
48 | ! 2766 2018-01-22 17:17:47Z kanani |
---|
49 | ! Removed preprocessor directive __chem |
---|
50 | ! |
---|
51 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
52 | ! Corrected "Former revisions" section |
---|
53 | ! |
---|
54 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
55 | ! Change in file header (GPL part) |
---|
56 | ! Moved TKE to turbulence_closure_mod (TG) |
---|
57 | ! Implementation of chemistry module (FK) |
---|
58 | ! |
---|
59 | ! 2350 2017-08-15 11:48:26Z kanani |
---|
60 | ! Bugfix in nopointer version |
---|
61 | ! |
---|
62 | ! 2292 2017-06-20 09:51:42Z schwenkel |
---|
63 | ! Implementation of new microphysic scheme: cloud_scheme = 'morrison' |
---|
64 | ! includes two more prognostic equations for cloud drop concentration (nc) |
---|
65 | ! and cloud water content (qc). |
---|
66 | ! |
---|
67 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
68 | ! |
---|
69 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
70 | ! Adjustments to new surface concept |
---|
71 | ! |
---|
72 | ! 2118 2017-01-17 16:38:49Z raasch |
---|
73 | ! OpenACC directives removed |
---|
74 | ! |
---|
75 | ! 2011 2016-09-19 17:29:57Z kanani |
---|
76 | ! Flag urban_surface is now defined in module control_parameters. |
---|
77 | ! |
---|
78 | ! 2007 2016-08-24 15:47:17Z kanani |
---|
79 | ! Added swapping of urban surface model quantities, |
---|
80 | ! removed redundance for land surface model |
---|
81 | ! |
---|
82 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
83 | ! Forced header and separation lines into 80 columns |
---|
84 | ! |
---|
85 | ! 1960 2016-07-12 16:34:24Z suehring |
---|
86 | ! Separate humidity and passive scalar |
---|
87 | ! |
---|
88 | ! 1822 2016-04-07 07:49:42Z hoffmann |
---|
89 | ! icloud_scheme replaced by microphysics_* |
---|
90 | ! |
---|
91 | ! swap_timelevel.f90 1766 2016-02-29 08:37:15Z raasch |
---|
92 | ! setting the swap level for pmc data transfer |
---|
93 | ! |
---|
94 | ! 1747 2016-02-08 12:25:53Z raasch |
---|
95 | ! explicit loops in nopointer case to omit craypointer option of pgi compiler |
---|
96 | ! |
---|
97 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
98 | ! Code annotations made doxygen readable |
---|
99 | ! |
---|
100 | ! 1496 2014-12-02 17:25:50Z maronga |
---|
101 | ! Added swapping of land surface model quantities |
---|
102 | ! |
---|
103 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
104 | ! bugfix: use-statement for nopointer-case added |
---|
105 | ! |
---|
106 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
107 | ! ONLY-attribute added to USE-statements, |
---|
108 | ! revision history before 2012 removed, |
---|
109 | ! 1318 2014-03-17 13:35:16Z raasch |
---|
110 | ! module interfaces removed |
---|
111 | ! |
---|
112 | ! 1115 2013-03-26 18:16:16Z hoffmann |
---|
113 | ! calculation of qr and nr is restricted to precipitation |
---|
114 | ! |
---|
115 | ! 1111 2013-03-08 23:54:10Z raasch |
---|
116 | ! openACC directives added |
---|
117 | ! |
---|
118 | ! 1053 2012-11-13 17:11:03Z hoffmann |
---|
119 | ! swap of timelevels for nr, qr added |
---|
120 | ! |
---|
121 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
122 | ! code put under GPL (PALM 3.9) |
---|
123 | ! |
---|
124 | ! 1032 2012-10-21 13:03:21Z letzel |
---|
125 | ! save memory by not allocating pt_2 in case of neutral = .T. |
---|
126 | ! |
---|
127 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
128 | ! cpp switch __nopointer added for pointer free version |
---|
129 | ! |
---|
130 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
131 | ! all actions concerning leapfrog scheme removed |
---|
132 | ! |
---|
133 | ! Revision 1.1 2000/01/10 10:08:58 10:08:58 raasch (Siegfried Raasch) |
---|
134 | ! Initial revision |
---|
135 | ! |
---|
136 | ! |
---|
137 | ! Description: |
---|
138 | ! ------------ |
---|
139 | !> Swap of timelevels of variables after each timestep |
---|
140 | !------------------------------------------------------------------------------! |
---|
141 | SUBROUTINE swap_timelevel |
---|
142 | |
---|
143 | |
---|
144 | #if defined( __nopointer ) |
---|
145 | USE arrays_3d, & |
---|
146 | ONLY: nc, nc_p, nr, nr_p, pt, pt_p, q, q_p, qc, qc_p, qr, qr_p, s, & |
---|
147 | s_p, sa, sa_p, u, u_p, v, v_p, w, w_p |
---|
148 | #else |
---|
149 | USE arrays_3d, & |
---|
150 | ONLY: nc, nc_1, nc_2, nc_p, nr, nr_1, nr_2, nr_p, pt, pt_1, pt_2, & |
---|
151 | pt_p, q, q_1, q_2, q_p, qc, qc_1, qc_2, qc_p, qr, qr_1, qr_2, & |
---|
152 | qr_p, s, s_1, s_2, s_p, sa, sa_1, sa_2, sa_p, u, u_1, u_2, u_p, & |
---|
153 | v, v_1, v_2, v_p, w, w_1, w_2, w_p |
---|
154 | #endif |
---|
155 | |
---|
156 | USE bulk_cloud_model_mod, & |
---|
157 | ONLY: bulk_cloud_model, bcm_swap_timelevel |
---|
158 | |
---|
159 | USE chemistry_model_mod, & |
---|
160 | ONLY: chem_swap_timelevel |
---|
161 | |
---|
162 | USE cpulog, & |
---|
163 | ONLY: cpu_log, log_point |
---|
164 | |
---|
165 | USE control_parameters, & |
---|
166 | ONLY: air_chemistry, humidity, land_surface, neutral, ocean_mode, & |
---|
167 | passive_scalar, simulated_time, timestep_count, urban_surface, & |
---|
168 | time_since_reference_point, salsa |
---|
169 | |
---|
170 | USE gust_mod, & |
---|
171 | ONLY: gust_module_enabled, gust_swap_timelevel |
---|
172 | |
---|
173 | #if defined( __nopointer ) |
---|
174 | USE indices, & |
---|
175 | ONLY: nxlg, nxrg, nyng, nysg, nzb, nzt |
---|
176 | #endif |
---|
177 | |
---|
178 | USE land_surface_model_mod, & |
---|
179 | ONLY: lsm_swap_timelevel |
---|
180 | |
---|
181 | USE ocean_mod, & |
---|
182 | ONLY: ocean_swap_timelevel |
---|
183 | |
---|
184 | USE pmc_interface, & |
---|
185 | ONLY: nested_run, pmci_set_swaplevel |
---|
186 | |
---|
187 | USE salsa_mod, & |
---|
188 | ONLY: salsa_swap_timelevel, skip_time_do_salsa |
---|
189 | |
---|
190 | USE turbulence_closure_mod, & |
---|
191 | ONLY: tcm_swap_timelevel |
---|
192 | |
---|
193 | USE urban_surface_mod, & |
---|
194 | ONLY: usm_swap_timelevel |
---|
195 | |
---|
196 | |
---|
197 | IMPLICIT NONE |
---|
198 | |
---|
199 | #if defined( __nopointer ) |
---|
200 | INTEGER :: i, j, k !> loop indices |
---|
201 | #endif |
---|
202 | INTEGER :: swap_level !> swap_level for steering the pmc data transfer |
---|
203 | |
---|
204 | ! |
---|
205 | !-- Incrementing timestep counter |
---|
206 | timestep_count = timestep_count + 1 |
---|
207 | |
---|
208 | ! |
---|
209 | !-- Swap of variables |
---|
210 | #if defined( __nopointer ) |
---|
211 | CALL cpu_log( log_point(28), 'swap_timelevel (nop)', 'start' ) |
---|
212 | |
---|
213 | DO i = nxlg, nxrg |
---|
214 | DO j = nysg, nyng |
---|
215 | DO k = nzb, nzt+1 |
---|
216 | u(k,j,i) = u_p(k,j,i) |
---|
217 | v(k,j,i) = v_p(k,j,i) |
---|
218 | w(k,j,i) = w_p(k,j,i) |
---|
219 | pt(k,j,i) = pt_p(k,j,i) |
---|
220 | ENDDO |
---|
221 | ENDDO |
---|
222 | ENDDO |
---|
223 | |
---|
224 | IF ( humidity ) THEN |
---|
225 | q = q_p |
---|
226 | ENDIF |
---|
227 | |
---|
228 | IF ( passive_scalar ) s = s_p |
---|
229 | |
---|
230 | ! |
---|
231 | !-- Swapping the timelevel of other modules |
---|
232 | IF ( humidity .AND. bulk_cloud_model ) CALL bcm_swap_timelevel( 0 ) |
---|
233 | IF ( gust_module_enabled ) CALL gust_swap_timelevel( 0 ) |
---|
234 | IF ( land_surface ) CALL lsm_swap_timelevel( 0 ) |
---|
235 | IF ( ocean_mode ) CALL ocean_swap_timelevel( 0 ) |
---|
236 | CALL tcm_swap_timelevel( 0 ) |
---|
237 | IF ( urban_surface ) CALL usm_swap_timelevel( 0 ) |
---|
238 | |
---|
239 | CALL cpu_log( log_point(28), 'swap_timelevel (nop)', 'stop' ) |
---|
240 | #else |
---|
241 | CALL cpu_log( log_point(28), 'swap_timelevel', 'start' ) |
---|
242 | |
---|
243 | SELECT CASE ( MOD( timestep_count, 2 ) ) |
---|
244 | |
---|
245 | CASE ( 0 ) |
---|
246 | |
---|
247 | u => u_1; u_p => u_2 |
---|
248 | v => v_1; v_p => v_2 |
---|
249 | w => w_1; w_p => w_2 |
---|
250 | IF ( .NOT. neutral ) THEN |
---|
251 | pt => pt_1; pt_p => pt_2 |
---|
252 | ENDIF |
---|
253 | IF ( humidity ) THEN |
---|
254 | q => q_1; q_p => q_2 |
---|
255 | ENDIF |
---|
256 | IF ( passive_scalar ) THEN |
---|
257 | s => s_1; s_p => s_2 |
---|
258 | ENDIF |
---|
259 | |
---|
260 | swap_level = 1 |
---|
261 | |
---|
262 | CASE ( 1 ) |
---|
263 | |
---|
264 | u => u_2; u_p => u_1 |
---|
265 | v => v_2; v_p => v_1 |
---|
266 | w => w_2; w_p => w_1 |
---|
267 | IF ( .NOT. neutral ) THEN |
---|
268 | pt => pt_2; pt_p => pt_1 |
---|
269 | ENDIF |
---|
270 | IF ( humidity ) THEN |
---|
271 | q => q_2; q_p => q_1 |
---|
272 | ENDIF |
---|
273 | IF ( passive_scalar ) THEN |
---|
274 | s => s_2; s_p => s_1 |
---|
275 | ENDIF |
---|
276 | |
---|
277 | swap_level = 2 |
---|
278 | |
---|
279 | END SELECT |
---|
280 | |
---|
281 | IF ( humidity .AND. bulk_cloud_model ) THEN |
---|
282 | CALL bcm_swap_timelevel( MOD( timestep_count, 2) ) |
---|
283 | ENDIF |
---|
284 | |
---|
285 | IF ( air_chemistry ) CALL chem_swap_timelevel( MOD( timestep_count, 2) ) |
---|
286 | |
---|
287 | IF ( gust_module_enabled ) THEN |
---|
288 | CALL gust_swap_timelevel( MOD( timestep_count, 2) ) |
---|
289 | ENDIF |
---|
290 | |
---|
291 | IF ( land_surface ) THEN |
---|
292 | CALL lsm_swap_timelevel( MOD( timestep_count, 2) ) |
---|
293 | ENDIF |
---|
294 | |
---|
295 | IF ( ocean_mode ) THEN |
---|
296 | CALL ocean_swap_timelevel( MOD( timestep_count, 2 ) ) |
---|
297 | ENDIF |
---|
298 | |
---|
299 | IF ( salsa .AND. simulated_time >= time_since_reference_point ) THEN |
---|
300 | CALL salsa_swap_timelevel( MOD( timestep_count, 2 ) ) |
---|
301 | ENDIF |
---|
302 | |
---|
303 | CALL tcm_swap_timelevel( MOD( timestep_count, 2) ) |
---|
304 | |
---|
305 | IF ( urban_surface ) THEN |
---|
306 | CALL usm_swap_timelevel( MOD( timestep_count, 2) ) |
---|
307 | ENDIF |
---|
308 | |
---|
309 | ! |
---|
310 | !-- Set the swap level for steering the pmc data transfer |
---|
311 | IF ( nested_run ) CALL pmci_set_swaplevel( swap_level ) |
---|
312 | |
---|
313 | CALL cpu_log( log_point(28), 'swap_timelevel', 'stop' ) |
---|
314 | #endif |
---|
315 | |
---|
316 | END SUBROUTINE swap_timelevel |
---|
317 | |
---|
318 | |
---|