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