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