[1682] | 1 | !> @file swap_timelevel.f90 |
---|
[1036] | 2 | !--------------------------------------------------------------------------------! |
---|
| 3 | ! This file is part of PALM. |
---|
| 4 | ! |
---|
| 5 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 6 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 7 | ! either version 3 of the License, or (at your option) any later version. |
---|
| 8 | ! |
---|
| 9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 10 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 11 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 12 | ! |
---|
| 13 | ! You should have received a copy of the GNU General Public License along with |
---|
| 14 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 15 | ! |
---|
[1818] | 16 | ! Copyright 1997-2016 Leibniz Universitaet Hannover |
---|
[1036] | 17 | !--------------------------------------------------------------------------------! |
---|
| 18 | ! |
---|
[484] | 19 | ! Current revisions: |
---|
[1] | 20 | ! ----------------- |
---|
[1748] | 21 | ! |
---|
[1823] | 22 | ! |
---|
[1] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
[3] | 25 | ! $Id: swap_timelevel.f90 1823 2016-04-07 08:57:52Z hoffmann $ |
---|
[39] | 26 | ! |
---|
[1823] | 27 | ! 1822 2016-04-07 07:49:42Z hoffmann |
---|
| 28 | ! icloud_scheme replaced by microphysics_* |
---|
| 29 | ! |
---|
[1767] | 30 | ! swap_timelevel.f90 1766 2016-02-29 08:37:15Z raasch |
---|
| 31 | ! setting the swap level for pmc data transfer |
---|
| 32 | ! |
---|
[1748] | 33 | ! 1747 2016-02-08 12:25:53Z raasch |
---|
| 34 | ! explicit loops in nopointer case to omit craypointer option of pgi compiler |
---|
| 35 | ! |
---|
[1683] | 36 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 37 | ! Code annotations made doxygen readable |
---|
| 38 | ! |
---|
[1497] | 39 | ! 1496 2014-12-02 17:25:50Z maronga |
---|
| 40 | ! Added swapping of land surface model quantities |
---|
| 41 | ! |
---|
[1375] | 42 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
| 43 | ! bugfix: use-statement for nopointer-case added |
---|
| 44 | ! |
---|
[1321] | 45 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
| 46 | ! ONLY-attribute added to USE-statements, |
---|
| 47 | ! revision history before 2012 removed, |
---|
[1319] | 48 | ! 1318 2014-03-17 13:35:16Z raasch |
---|
| 49 | ! module interfaces removed |
---|
| 50 | ! |
---|
[1116] | 51 | ! 1115 2013-03-26 18:16:16Z hoffmann |
---|
| 52 | ! calculation of qr and nr is restricted to precipitation |
---|
| 53 | ! |
---|
[1112] | 54 | ! 1111 2013-03-08 23:54:10Z raasch |
---|
| 55 | ! openACC directives added |
---|
| 56 | ! |
---|
[1054] | 57 | ! 1053 2012-11-13 17:11:03Z hoffmann |
---|
| 58 | ! swap of timelevels for nr, qr added |
---|
| 59 | ! |
---|
[1037] | 60 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 61 | ! code put under GPL (PALM 3.9) |
---|
| 62 | ! |
---|
[1033] | 63 | ! 1032 2012-10-21 13:03:21Z letzel |
---|
| 64 | ! save memory by not allocating pt_2 in case of neutral = .T. |
---|
| 65 | ! |
---|
[1011] | 66 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
| 67 | ! cpp switch __nopointer added for pointer free version |
---|
| 68 | ! |
---|
[1002] | 69 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
| 70 | ! all actions concerning leapfrog scheme removed |
---|
| 71 | ! |
---|
[1] | 72 | ! Revision 1.1 2000/01/10 10:08:58 10:08:58 raasch (Siegfried Raasch) |
---|
| 73 | ! Initial revision |
---|
| 74 | ! |
---|
| 75 | ! |
---|
| 76 | ! Description: |
---|
| 77 | ! ------------ |
---|
[1682] | 78 | !> Swap of timelevels of variables after each timestep |
---|
[3] | 79 | !------------------------------------------------------------------------------! |
---|
[1682] | 80 | SUBROUTINE swap_timelevel |
---|
| 81 | |
---|
[1] | 82 | |
---|
[1374] | 83 | #if defined( __nopointer ) |
---|
[1320] | 84 | USE arrays_3d, & |
---|
[1374] | 85 | ONLY: e, e_p, nr, nr_p, pt, pt_p, q, q_p, qr, qr_p, sa, sa_p, u, u_p, & |
---|
| 86 | v, v_p, w, w_p |
---|
| 87 | #else |
---|
| 88 | USE arrays_3d, & |
---|
[1320] | 89 | ONLY: e, e_1, e_2, e_p, nr, nr_1, nr_2, nr_p, pt, pt_1, pt_2, pt_p, q,& |
---|
| 90 | q_1, q_2, q_p, qr, qr_1, qr_2, qr_p, sa, sa_1, sa_2, sa_p, u, & |
---|
| 91 | u_1, u_2, u_p, v, v_1, v_2, v_p, w, w_1, w_2, w_p |
---|
[1496] | 92 | |
---|
[1374] | 93 | #endif |
---|
[1] | 94 | |
---|
[1551] | 95 | USE land_surface_model_mod, & |
---|
| 96 | ONLY: land_surface, lsm_swap_timelevel |
---|
| 97 | |
---|
[1320] | 98 | USE cpulog, & |
---|
| 99 | ONLY: cpu_log, log_point |
---|
| 100 | |
---|
| 101 | USE control_parameters, & |
---|
[1822] | 102 | ONLY: cloud_physics, constant_diffusion, humidity, & |
---|
| 103 | microphysics_seifert, neutral, ocean, passive_scalar, & |
---|
| 104 | timestep_count |
---|
[1320] | 105 | |
---|
[1747] | 106 | USE indices, & |
---|
| 107 | ONLY: nxlg, nxrg, nyng, nysg, nzb, nzt |
---|
[1766] | 108 | |
---|
| 109 | USE pmc_interface, & |
---|
| 110 | ONLY: nested_run, pmci_set_swaplevel |
---|
| 111 | |
---|
| 112 | |
---|
[1] | 113 | IMPLICIT NONE |
---|
| 114 | |
---|
[1766] | 115 | INTEGER :: i, j, k !> loop indices |
---|
| 116 | INTEGER :: swap_level !> swap_level for steering the pmc data transfer |
---|
[1747] | 117 | |
---|
[1] | 118 | ! |
---|
| 119 | !-- Incrementing timestep counter |
---|
| 120 | timestep_count = timestep_count + 1 |
---|
| 121 | |
---|
| 122 | ! |
---|
[1001] | 123 | !-- Swap of variables |
---|
[1010] | 124 | #if defined( __nopointer ) |
---|
| 125 | CALL cpu_log( log_point(28), 'swap_timelevel (nop)', 'start' ) |
---|
| 126 | |
---|
[1111] | 127 | !$acc kernels present( pt, pt_p, u, u_p, v, v_p, w, w_p ) |
---|
[1747] | 128 | !$acc loop independent |
---|
| 129 | DO i = nxlg, nxrg |
---|
| 130 | !$acc loop independent |
---|
| 131 | DO j = nysg, nyng |
---|
| 132 | !$acc loop independent |
---|
| 133 | DO k = nzb, nzt+1 |
---|
| 134 | u(k,j,i) = u_p(k,j,i) |
---|
| 135 | v(k,j,i) = v_p(k,j,i) |
---|
| 136 | w(k,j,i) = w_p(k,j,i) |
---|
| 137 | pt(k,j,i) = pt_p(k,j,i) |
---|
| 138 | ENDDO |
---|
| 139 | ENDDO |
---|
| 140 | ENDDO |
---|
| 141 | ! u = u_p |
---|
| 142 | ! v = v_p |
---|
| 143 | ! w = w_p |
---|
| 144 | ! pt = pt_p |
---|
[1111] | 145 | !$acc end kernels |
---|
[1010] | 146 | IF ( .NOT. constant_diffusion ) THEN |
---|
[1111] | 147 | !$acc kernels present( e, e_p ) |
---|
[1747] | 148 | !$acc loop independent |
---|
| 149 | DO i = nxlg, nxrg |
---|
| 150 | !$acc loop independent |
---|
| 151 | DO j = nysg, nyng |
---|
| 152 | !$acc loop independent |
---|
| 153 | DO k = nzb, nzt+1 |
---|
| 154 | e(k,j,i) = e_p(k,j,i) |
---|
| 155 | ENDDO |
---|
| 156 | ENDDO |
---|
| 157 | ENDDO |
---|
| 158 | ! e = e_p |
---|
[1111] | 159 | !$acc end kernels |
---|
[1010] | 160 | ENDIF |
---|
| 161 | IF ( ocean ) THEN |
---|
| 162 | sa = sa_p |
---|
| 163 | ENDIF |
---|
| 164 | IF ( humidity .OR. passive_scalar ) THEN |
---|
[1053] | 165 | q = q_p |
---|
[1822] | 166 | IF ( cloud_physics .AND. microphysics_seifert ) THEN |
---|
[1053] | 167 | qr = qr_p |
---|
| 168 | nr = nr_p |
---|
| 169 | ENDIF |
---|
[1010] | 170 | ENDIF |
---|
| 171 | |
---|
[1496] | 172 | IF ( land_surface ) THEN |
---|
[1551] | 173 | CALL lsm_swap_timelevel ( 0 ) |
---|
[1496] | 174 | ENDIF |
---|
| 175 | |
---|
| 176 | |
---|
[1010] | 177 | CALL cpu_log( log_point(28), 'swap_timelevel (nop)', 'stop' ) |
---|
| 178 | #else |
---|
| 179 | CALL cpu_log( log_point(28), 'swap_timelevel', 'start' ) |
---|
| 180 | |
---|
[1] | 181 | SELECT CASE ( MOD( timestep_count, 2 ) ) |
---|
| 182 | |
---|
| 183 | CASE ( 0 ) |
---|
| 184 | |
---|
[1001] | 185 | u => u_1; u_p => u_2 |
---|
| 186 | v => v_1; v_p => v_2 |
---|
| 187 | w => w_1; w_p => w_2 |
---|
[1032] | 188 | IF ( .NOT. neutral ) THEN |
---|
| 189 | pt => pt_1; pt_p => pt_2 |
---|
| 190 | ENDIF |
---|
[1001] | 191 | IF ( .NOT. constant_diffusion ) THEN |
---|
| 192 | e => e_1; e_p => e_2 |
---|
| 193 | ENDIF |
---|
| 194 | IF ( ocean ) THEN |
---|
| 195 | sa => sa_1; sa_p => sa_2 |
---|
| 196 | ENDIF |
---|
| 197 | IF ( humidity .OR. passive_scalar ) THEN |
---|
| 198 | q => q_1; q_p => q_2 |
---|
[1822] | 199 | IF ( cloud_physics .AND. microphysics_seifert ) THEN |
---|
[1053] | 200 | qr => qr_1; qr_p => qr_2 |
---|
| 201 | nr => nr_1; nr_p => nr_2 |
---|
| 202 | ENDIF |
---|
[1001] | 203 | ENDIF |
---|
[1] | 204 | |
---|
[1496] | 205 | IF ( land_surface ) THEN |
---|
[1551] | 206 | CALL lsm_swap_timelevel ( MOD( timestep_count, 2) ) |
---|
[1496] | 207 | ENDIF |
---|
[1] | 208 | |
---|
[1766] | 209 | swap_level = 1 |
---|
[1496] | 210 | |
---|
[1001] | 211 | CASE ( 1 ) |
---|
[1] | 212 | |
---|
[1001] | 213 | u => u_2; u_p => u_1 |
---|
| 214 | v => v_2; v_p => v_1 |
---|
| 215 | w => w_2; w_p => w_1 |
---|
[1032] | 216 | IF ( .NOT. neutral ) THEN |
---|
| 217 | pt => pt_2; pt_p => pt_1 |
---|
| 218 | ENDIF |
---|
[1001] | 219 | IF ( .NOT. constant_diffusion ) THEN |
---|
| 220 | e => e_2; e_p => e_1 |
---|
[1] | 221 | ENDIF |
---|
[1001] | 222 | IF ( ocean ) THEN |
---|
| 223 | sa => sa_2; sa_p => sa_1 |
---|
| 224 | ENDIF |
---|
| 225 | IF ( humidity .OR. passive_scalar ) THEN |
---|
| 226 | q => q_2; q_p => q_1 |
---|
[1822] | 227 | IF ( cloud_physics .AND. microphysics_seifert ) THEN |
---|
[1053] | 228 | qr => qr_2; qr_p => qr_1 |
---|
| 229 | nr => nr_2; nr_p => nr_1 |
---|
| 230 | ENDIF |
---|
[1001] | 231 | ENDIF |
---|
[1] | 232 | |
---|
[1496] | 233 | IF ( land_surface ) THEN |
---|
[1551] | 234 | CALL lsm_swap_timelevel ( MOD( timestep_count, 2) ) |
---|
[1496] | 235 | ENDIF |
---|
[1] | 236 | |
---|
[1766] | 237 | swap_level = 2 |
---|
[1496] | 238 | |
---|
[1] | 239 | END SELECT |
---|
| 240 | |
---|
[1766] | 241 | ! |
---|
| 242 | !-- Set the swap level for steering the pmc data transfer |
---|
| 243 | IF ( nested_run ) CALL pmci_set_swaplevel( swap_level ) |
---|
| 244 | |
---|
[1] | 245 | CALL cpu_log( log_point(28), 'swap_timelevel', 'stop' ) |
---|
[1010] | 246 | #endif |
---|
[1] | 247 | |
---|
| 248 | END SUBROUTINE swap_timelevel |
---|
| 249 | |
---|
| 250 | |
---|