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

Last change on this file since 2261 was 2233, checked in by suehring, 7 years ago

last commit documented

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