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

Last change on this file since 1666 was 1551, checked in by maronga, 9 years ago

land surface model released

  • Property svn:keywords set to Id
File size: 5.9 KB
Line 
1 SUBROUTINE swap_timelevel
2
3!--------------------------------------------------------------------------------!
4! This file is part of PALM.
5!
6! PALM is free software: you can redistribute it and/or modify it under the terms
7! of the GNU General Public License as published by the Free Software Foundation,
8! either version 3 of the License, or (at your option) any later 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-2014 Leibniz Universitaet Hannover
18!--------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: swap_timelevel.f90 1551 2015-03-03 14:18:16Z raasch $
27!
28! 1496 2014-12-02 17:25:50Z maronga
29! Added swapping of land surface model quantities
30!
31! 1374 2014-04-25 12:55:07Z raasch
32! bugfix: use-statement for nopointer-case added
33!
34! 1320 2014-03-20 08:40:49Z raasch
35! ONLY-attribute added to USE-statements,
36! revision history before 2012 removed,
37! 1318 2014-03-17 13:35:16Z raasch
38! module interfaces removed
39!
40! 1115 2013-03-26 18:16:16Z hoffmann
41! calculation of qr and nr is restricted to precipitation
42!
43! 1111 2013-03-08 23:54:10Z raasch
44! openACC directives added
45!
46! 1053 2012-11-13 17:11:03Z hoffmann
47! swap of timelevels for nr, qr added
48!
49! 1036 2012-10-22 13:43:42Z raasch
50! code put under GPL (PALM 3.9)
51!
52! 1032 2012-10-21 13:03:21Z letzel
53! save memory by not allocating pt_2 in case of neutral = .T.
54!
55! 1010 2012-09-20 07:59:54Z raasch
56! cpp switch __nopointer added for pointer free version
57!
58! 1001 2012-09-13 14:08:46Z raasch
59! all actions concerning leapfrog scheme removed
60!
61! Revision 1.1  2000/01/10  10:08:58  10:08:58  raasch (Siegfried Raasch)
62! Initial revision
63!
64!
65! Description:
66! ------------
67! Swap of timelevels of variables after each timestep
68!------------------------------------------------------------------------------!
69
70#if defined( __nopointer )
71    USE arrays_3d,                                                             &
72        ONLY:  e, e_p, nr, nr_p, pt, pt_p, q, q_p, qr, qr_p, sa, sa_p, u, u_p, &
73               v, v_p, w, w_p
74#else
75    USE arrays_3d,                                                             &
76        ONLY:  e, e_1, e_2, e_p, nr, nr_1, nr_2, nr_p, pt, pt_1, pt_2, pt_p, q,&
77               q_1, q_2, q_p, qr, qr_1, qr_2, qr_p, sa, sa_1, sa_2, sa_p, u,   &
78               u_1, u_2, u_p, v, v_1, v_2, v_p, w, w_1, w_2, w_p
79
80#endif
81
82    USE land_surface_model_mod,                                                &
83        ONLY: land_surface, lsm_swap_timelevel
84
85    USE cpulog,                                                                &
86        ONLY: cpu_log, log_point
87
88    USE control_parameters,                                                    &
89        ONLY:  cloud_physics, constant_diffusion, humidity, icloud_scheme,     &
90               neutral, ocean, passive_scalar, precipitation, timestep_count
91
92    IMPLICIT NONE
93
94!
95!-- Incrementing timestep counter
96    timestep_count = timestep_count + 1
97
98!
99!-- Swap of variables
100#if defined( __nopointer )
101    CALL cpu_log( log_point(28), 'swap_timelevel (nop)', 'start' )
102
103    !$acc kernels present( pt, pt_p, u, u_p, v, v_p, w, w_p )
104    u  = u_p
105    v  = v_p
106    w  = w_p
107    pt = pt_p
108    !$acc end kernels
109    IF ( .NOT. constant_diffusion )  THEN
110       !$acc kernels present( e, e_p )
111       e = e_p
112       !$acc end kernels
113    ENDIF
114    IF ( ocean )  THEN
115       sa = sa_p
116    ENDIF
117    IF ( humidity  .OR.  passive_scalar )  THEN
118       q = q_p             
119       IF ( cloud_physics  .AND.  icloud_scheme == 0 )  THEN
120          qr = qr_p
121          nr = nr_p
122       ENDIF
123    ENDIF
124
125    IF ( land_surface )  THEN
126       CALL lsm_swap_timelevel ( 0 )
127    ENDIF
128
129
130    CALL cpu_log( log_point(28), 'swap_timelevel (nop)', 'stop' )
131#else
132    CALL cpu_log( log_point(28), 'swap_timelevel', 'start' )
133
134    SELECT CASE ( MOD( timestep_count, 2 ) )
135
136       CASE ( 0 )
137
138          u  => u_1;   u_p  => u_2
139          v  => v_1;   v_p  => v_2
140          w  => w_1;   w_p  => w_2
141          IF ( .NOT. neutral )  THEN
142             pt => pt_1;  pt_p => pt_2
143          ENDIF
144          IF ( .NOT. constant_diffusion )  THEN
145             e => e_1;    e_p => e_2
146          ENDIF
147          IF ( ocean )  THEN
148             sa => sa_1;  sa_p => sa_2
149          ENDIF
150          IF ( humidity  .OR.  passive_scalar )  THEN
151             q => q_1;    q_p => q_2
152             IF ( cloud_physics  .AND.  icloud_scheme == 0  .AND.  &
153                  precipitation )  THEN
154                qr => qr_1;    qr_p => qr_2
155                nr => nr_1;    nr_p => nr_2
156             ENDIF
157          ENDIF
158
159          IF ( land_surface )  THEN
160             CALL lsm_swap_timelevel ( MOD( timestep_count, 2) )
161          ENDIF
162
163
164       CASE ( 1 )
165
166          u  => u_2;   u_p  => u_1
167          v  => v_2;   v_p  => v_1
168          w  => w_2;   w_p  => w_1
169          IF ( .NOT. neutral )  THEN
170             pt => pt_2;  pt_p => pt_1
171          ENDIF
172          IF ( .NOT. constant_diffusion )  THEN
173             e => e_2;    e_p => e_1
174          ENDIF
175          IF ( ocean )  THEN
176             sa => sa_2;  sa_p => sa_1
177          ENDIF
178          IF ( humidity  .OR.  passive_scalar )  THEN
179             q => q_2;    q_p => q_1
180             IF ( cloud_physics  .AND.  icloud_scheme == 0  .AND.  &
181                  precipitation)  THEN
182                qr => qr_2;    qr_p => qr_1
183                nr => nr_2;    nr_p => nr_1
184             ENDIF
185          ENDIF
186
187          IF ( land_surface )  THEN
188             CALL lsm_swap_timelevel ( MOD( timestep_count, 2) )
189          ENDIF
190
191
192    END SELECT
193
194    CALL cpu_log( log_point(28), 'swap_timelevel', 'stop' )
195#endif
196
197 END SUBROUTINE swap_timelevel
198
199
Note: See TracBrowser for help on using the repository browser.