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