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

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

changes in the course of urban surface model implementation

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