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

Last change on this file since 1766 was 1766, checked in by raasch, 8 years ago

pmc now runs with pointer version too

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