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