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

Last change on this file since 2008 was 2008, checked in by kanani, 8 years ago

last commit documented

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