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

Last change on this file since 2768 was 2766, checked in by kanani, 6 years ago

Removal of chem directive, plus minor changes

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