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

Last change on this file since 1969 was 1961, checked in by suehring, 8 years ago

last commit documented

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