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