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

Last change on this file since 3299 was 3294, checked in by raasch, 6 years ago

modularization of the ocean code

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