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