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