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

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

added beta version of a land surface model and a simple radiation model for clear sky conditions

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