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

Last change on this file since 1961 was 1961, checked in by suehring, 8 years ago

last commit documented

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