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

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

last commit documented

  • Property svn:keywords set to Id
File size: 6.9 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!
22!
23! Former revisions:
24! -----------------
25! $Id: swap_timelevel.f90 1748 2016-02-08 12:38:17Z hellstea $
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    IMPLICIT NONE
102
103    INTEGER ::  i, j, k   !: loop indices
104
105!
106!-- Incrementing timestep counter
107    timestep_count = timestep_count + 1
108
109!
110!-- Swap of variables
111#if defined( __nopointer )
112    CALL cpu_log( log_point(28), 'swap_timelevel (nop)', 'start' )
113
114    !$acc kernels present( pt, pt_p, u, u_p, v, v_p, w, w_p )
115    !$acc loop independent
116    DO  i = nxlg, nxrg
117       !$acc loop independent
118       DO  j = nysg, nyng
119          !$acc loop independent
120          DO  k = nzb, nzt+1
121             u(k,j,i)  = u_p(k,j,i)
122             v(k,j,i)  = v_p(k,j,i)
123             w(k,j,i)  = w_p(k,j,i)
124             pt(k,j,i) = pt_p(k,j,i)
125          ENDDO
126       ENDDO
127    ENDDO
128!    u  = u_p
129!    v  = v_p
130!    w  = w_p
131!    pt = pt_p
132    !$acc end kernels
133    IF ( .NOT. constant_diffusion )  THEN
134       !$acc kernels present( e, e_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                e(k,j,i) = e_p(k,j,i)
142             ENDDO
143          ENDDO
144       ENDDO
145!       e = e_p
146       !$acc end kernels
147    ENDIF
148    IF ( ocean )  THEN
149       sa = sa_p
150    ENDIF
151    IF ( humidity  .OR.  passive_scalar )  THEN
152       q = q_p             
153       IF ( cloud_physics  .AND.  icloud_scheme == 0 )  THEN
154          qr = qr_p
155          nr = nr_p
156       ENDIF
157    ENDIF
158
159    IF ( land_surface )  THEN
160       CALL lsm_swap_timelevel ( 0 )
161    ENDIF
162
163
164    CALL cpu_log( log_point(28), 'swap_timelevel (nop)', 'stop' )
165#else
166    CALL cpu_log( log_point(28), 'swap_timelevel', 'start' )
167
168    SELECT CASE ( MOD( timestep_count, 2 ) )
169
170       CASE ( 0 )
171
172          u  => u_1;   u_p  => u_2
173          v  => v_1;   v_p  => v_2
174          w  => w_1;   w_p  => w_2
175          IF ( .NOT. neutral )  THEN
176             pt => pt_1;  pt_p => pt_2
177          ENDIF
178          IF ( .NOT. constant_diffusion )  THEN
179             e => e_1;    e_p => e_2
180          ENDIF
181          IF ( ocean )  THEN
182             sa => sa_1;  sa_p => sa_2
183          ENDIF
184          IF ( humidity  .OR.  passive_scalar )  THEN
185             q => q_1;    q_p => q_2
186             IF ( cloud_physics  .AND.  icloud_scheme == 0  .AND.  &
187                  precipitation )  THEN
188                qr => qr_1;    qr_p => qr_2
189                nr => nr_1;    nr_p => nr_2
190             ENDIF
191          ENDIF
192
193          IF ( land_surface )  THEN
194             CALL lsm_swap_timelevel ( MOD( timestep_count, 2) )
195          ENDIF
196
197
198       CASE ( 1 )
199
200          u  => u_2;   u_p  => u_1
201          v  => v_2;   v_p  => v_1
202          w  => w_2;   w_p  => w_1
203          IF ( .NOT. neutral )  THEN
204             pt => pt_2;  pt_p => pt_1
205          ENDIF
206          IF ( .NOT. constant_diffusion )  THEN
207             e => e_2;    e_p => e_1
208          ENDIF
209          IF ( ocean )  THEN
210             sa => sa_2;  sa_p => sa_1
211          ENDIF
212          IF ( humidity  .OR.  passive_scalar )  THEN
213             q => q_2;    q_p => q_1
214             IF ( cloud_physics  .AND.  icloud_scheme == 0  .AND.  &
215                  precipitation)  THEN
216                qr => qr_2;    qr_p => qr_1
217                nr => nr_2;    nr_p => nr_1
218             ENDIF
219          ENDIF
220
221          IF ( land_surface )  THEN
222             CALL lsm_swap_timelevel ( MOD( timestep_count, 2) )
223          ENDIF
224
225
226    END SELECT
227
228    CALL cpu_log( log_point(28), 'swap_timelevel', 'stop' )
229#endif
230
231 END SUBROUTINE swap_timelevel
232
233
Note: See TracBrowser for help on using the repository browser.