source: palm/trunk/SOURCE/swap_timelevel.f90 @ 3428

Last change on this file since 3428 was 3303, checked in by raasch, 6 years ago

salinity allowed to be switched off, bugfix for swapping in case of ocean mode

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