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

Last change on this file since 2001 was 2001, checked in by knoop, 8 years ago

last commit documented

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