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

Last change on this file since 2261 was 2233, checked in by suehring, 7 years ago

last commit documented

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