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

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

all OpenACC directives and related parts removed from the code

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