[1873] | 1 | !> @file advec_s_up.f90 |
---|
[4488] | 2 | !--------------------------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1036] | 4 | ! |
---|
[4488] | 5 | ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General |
---|
| 6 | ! Public License as published by the Free Software Foundation, either version 3 of the License, or |
---|
| 7 | ! (at your option) any later version. |
---|
[1036] | 8 | ! |
---|
[4488] | 9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
---|
| 10 | ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
---|
| 11 | ! Public License for more details. |
---|
[1036] | 12 | ! |
---|
[4488] | 13 | ! You should have received a copy of the GNU General Public License along with PALM. If not, see |
---|
| 14 | ! <http://www.gnu.org/licenses/>. |
---|
[1036] | 15 | ! |
---|
[4828] | 16 | ! Copyright 1997-2021 Leibniz Universitaet Hannover |
---|
[4488] | 17 | !--------------------------------------------------------------------------------------------------! |
---|
[1036] | 18 | ! |
---|
[484] | 19 | ! Current revisions: |
---|
[1] | 20 | ! ----------------- |
---|
[1354] | 21 | ! |
---|
[2233] | 22 | ! |
---|
[1321] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
| 25 | ! $Id: advec_s_up.f90 4828 2021-01-05 11:21:41Z forkel $ |
---|
[4488] | 26 | ! file re-formatted to follow the PALM coding standard |
---|
| 27 | ! |
---|
| 28 | ! 4360 2020-01-07 11:25:50Z suehring |
---|
[4182] | 29 | ! Corrected "Former revisions" section |
---|
[4488] | 30 | ! |
---|
[4182] | 31 | ! 3927 2019-04-23 13:24:29Z raasch |
---|
[3927] | 32 | ! pointer attribute removed from scalar 3d-array for performance reasons |
---|
[4488] | 33 | ! |
---|
[3927] | 34 | ! 3665 2019-01-10 08:28:24Z raasch |
---|
[3665] | 35 | ! unused variables removed |
---|
[4488] | 36 | ! |
---|
[3665] | 37 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
[3636] | 38 | ! nopointer option removed |
---|
[1321] | 39 | ! |
---|
[4182] | 40 | ! Revision 1.1 1997/08/29 08:54:33 raasch |
---|
| 41 | ! Initial revision |
---|
| 42 | ! |
---|
| 43 | ! |
---|
[1] | 44 | ! Description: |
---|
| 45 | ! ------------ |
---|
[1682] | 46 | !> Advection term for scalar quantities using the Upstream scheme. |
---|
| 47 | !> NOTE: vertical advection at k=1 still has wrong grid spacing for w>0! |
---|
| 48 | !> The same problem occurs for all topography boundaries! |
---|
[4488] | 49 | !--------------------------------------------------------------------------------------------------! |
---|
[1682] | 50 | MODULE advec_s_up_mod |
---|
[1] | 51 | |
---|
[4488] | 52 | |
---|
[1] | 53 | PRIVATE |
---|
| 54 | PUBLIC advec_s_up |
---|
| 55 | |
---|
| 56 | INTERFACE advec_s_up |
---|
| 57 | MODULE PROCEDURE advec_s_up |
---|
| 58 | MODULE PROCEDURE advec_s_up_ij |
---|
| 59 | END INTERFACE advec_s_up |
---|
| 60 | |
---|
| 61 | CONTAINS |
---|
| 62 | |
---|
| 63 | |
---|
[4488] | 64 | !--------------------------------------------------------------------------------------------------! |
---|
[1682] | 65 | ! Description: |
---|
| 66 | ! ------------ |
---|
| 67 | !> Call for all grid points |
---|
[4488] | 68 | !--------------------------------------------------------------------------------------------------! |
---|
| 69 | SUBROUTINE advec_s_up( sk ) |
---|
[1] | 70 | |
---|
[4488] | 71 | USE arrays_3d, & |
---|
| 72 | ONLY: ddzu, tend, u, v, w |
---|
[1] | 73 | |
---|
[4488] | 74 | USE control_parameters, & |
---|
| 75 | ONLY: u_gtrans, v_gtrans |
---|
[1320] | 76 | |
---|
[4488] | 77 | USE grid_variables, & |
---|
| 78 | ONLY: ddx, ddy |
---|
[1320] | 79 | |
---|
[4488] | 80 | USE indices, & |
---|
| 81 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt |
---|
[1320] | 82 | |
---|
[4488] | 83 | USE kinds |
---|
[1320] | 84 | |
---|
| 85 | |
---|
[4488] | 86 | IMPLICIT NONE |
---|
[1] | 87 | |
---|
[4488] | 88 | INTEGER(iwp) :: i !< grid index along x-direction |
---|
| 89 | INTEGER(iwp) :: j !< grid index along y-direction |
---|
| 90 | INTEGER(iwp) :: k !< grid index along z-direction |
---|
[1] | 91 | |
---|
[4488] | 92 | REAL(wp) :: ukomp !< advection velocity along x-direction |
---|
| 93 | REAL(wp) :: vkomp !< advection velocity along y-direction |
---|
| 94 | REAL(wp) :: wkomp !< advection velocity along z-direction |
---|
[3636] | 95 | |
---|
[4488] | 96 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !< treated scalar |
---|
[1] | 97 | |
---|
| 98 | |
---|
[4488] | 99 | DO i = nxl, nxr |
---|
| 100 | DO j = nys, nyn |
---|
| 101 | DO k = nzb+1, nzt |
---|
[1] | 102 | ! |
---|
[4488] | 103 | !-- x-direction |
---|
| 104 | ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
| 105 | IF ( ukomp > 0.0_wp ) THEN |
---|
| 106 | tend(k,j,i) = tend(k,j,i) - ukomp * ( sk(k,j,i) - sk(k,j,i-1) ) * ddx |
---|
| 107 | ELSE |
---|
| 108 | tend(k,j,i) = tend(k,j,i) - ukomp * ( sk(k,j,i+1) - sk(k,j,i) ) * ddx |
---|
| 109 | ENDIF |
---|
[1] | 110 | ! |
---|
[4488] | 111 | !-- y-direction |
---|
| 112 | vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
| 113 | IF ( vkomp > 0.0_wp ) THEN |
---|
| 114 | tend(k,j,i) = tend(k,j,i) - vkomp * ( sk(k,j,i) - sk(k,j-1,i) ) * ddy |
---|
| 115 | ELSE |
---|
| 116 | tend(k,j,i) = tend(k,j,i) - vkomp * ( sk(k,j+1,i) - sk(k,j,i) ) * ddy |
---|
| 117 | ENDIF |
---|
[1] | 118 | ! |
---|
[4488] | 119 | !-- z-direction |
---|
| 120 | wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
| 121 | IF ( wkomp > 0.0_wp ) THEN |
---|
| 122 | tend(k,j,i) = tend(k,j,i) - wkomp * ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) |
---|
| 123 | ELSE |
---|
| 124 | tend(k,j,i) = tend(k,j,i) - wkomp * ( sk(k+1,j,i) - sk(k,j,i) ) * ddzu(k+1) |
---|
| 125 | ENDIF |
---|
[1] | 126 | |
---|
| 127 | ENDDO |
---|
| 128 | ENDDO |
---|
[4488] | 129 | ENDDO |
---|
[1] | 130 | |
---|
[4488] | 131 | END SUBROUTINE advec_s_up |
---|
[1] | 132 | |
---|
| 133 | |
---|
[4488] | 134 | !--------------------------------------------------------------------------------------------------! |
---|
[1682] | 135 | ! Description: |
---|
| 136 | ! ------------ |
---|
| 137 | !> Call for grid point i,j |
---|
[4488] | 138 | !--------------------------------------------------------------------------------------------------! |
---|
| 139 | SUBROUTINE advec_s_up_ij( i, j, sk ) |
---|
[1] | 140 | |
---|
[4488] | 141 | USE arrays_3d, & |
---|
| 142 | ONLY: ddzu, tend, u, v, w |
---|
[1] | 143 | |
---|
[4488] | 144 | USE control_parameters, & |
---|
| 145 | ONLY: u_gtrans, v_gtrans |
---|
[1320] | 146 | |
---|
[4488] | 147 | USE grid_variables, & |
---|
| 148 | ONLY: ddx, ddy |
---|
[1320] | 149 | |
---|
[4488] | 150 | USE indices, & |
---|
| 151 | ONLY: nxlg, nxrg, nyng, nysg, nzb, nzt |
---|
[1320] | 152 | |
---|
[4488] | 153 | USE kinds |
---|
[1320] | 154 | |
---|
| 155 | |
---|
[4488] | 156 | IMPLICIT NONE |
---|
[1] | 157 | |
---|
[4488] | 158 | INTEGER(iwp) :: i !< grid index along x-direction |
---|
| 159 | INTEGER(iwp) :: j !< grid index along y-direction |
---|
| 160 | INTEGER(iwp) :: k !< grid index along z-direction |
---|
[1] | 161 | |
---|
[4488] | 162 | REAL(wp) :: ukomp !< advection velocity along x-direction |
---|
| 163 | REAL(wp) :: vkomp !< advection velocity along y-direction |
---|
| 164 | REAL(wp) :: wkomp !< advection velocity along z-direction |
---|
[1] | 165 | |
---|
[4488] | 166 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !< treated scalar |
---|
[1] | 167 | |
---|
[4488] | 168 | |
---|
| 169 | DO k = nzb+1, nzt |
---|
[1] | 170 | ! |
---|
[4488] | 171 | !-- x-direction |
---|
| 172 | ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
| 173 | IF ( ukomp > 0.0_wp ) THEN |
---|
| 174 | tend(k,j,i) = tend(k,j,i) - ukomp * ( sk(k,j,i) - sk(k,j,i-1) ) * ddx |
---|
| 175 | ELSE |
---|
| 176 | tend(k,j,i) = tend(k,j,i) - ukomp * ( sk(k,j,i+1) - sk(k,j,i) ) * ddx |
---|
| 177 | ENDIF |
---|
[1] | 178 | ! |
---|
[4488] | 179 | !-- y-direction |
---|
| 180 | vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
| 181 | IF ( vkomp > 0.0_wp ) THEN |
---|
| 182 | tend(k,j,i) = tend(k,j,i) - vkomp * ( sk(k,j,i) - sk(k,j-1,i) ) * ddy |
---|
| 183 | ELSE |
---|
| 184 | tend(k,j,i) = tend(k,j,i) - vkomp * ( sk(k,j+1,i) - sk(k,j,i) ) * ddy |
---|
| 185 | ENDIF |
---|
[1] | 186 | ! |
---|
[4488] | 187 | !-- z-direction |
---|
| 188 | wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
| 189 | IF ( wkomp > 0.0_wp ) THEN |
---|
| 190 | tend(k,j,i) = tend(k,j,i) - wkomp * ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) |
---|
| 191 | ELSE |
---|
| 192 | tend(k,j,i) = tend(k,j,i) - wkomp * ( sk(k+1,j,i) - sk(k,j,i) ) * ddzu(k+1) |
---|
| 193 | ENDIF |
---|
[1] | 194 | |
---|
[4488] | 195 | ENDDO |
---|
[1] | 196 | |
---|
[4488] | 197 | END SUBROUTINE advec_s_up_ij |
---|
[1] | 198 | |
---|
| 199 | END MODULE advec_s_up_mod |
---|