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