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