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

Last change on this file since 3558 was 3467, checked in by suehring, 6 years ago

Branch salsa @3446 re-integrated into trunk

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