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