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