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

Last change on this file since 2172 was 2119, checked in by raasch, 7 years ago

last commit documented

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