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