MODULE advec_s_up_mod !------------------------------------------------------------------------------! ! Current revisions: ! ----------------- ! ! Former revisions: ! ----------------- ! $Id: advec_s_up.f90 982 2012-08-09 15:01:57Z raasch $ ! ! 981 2012-08-09 14:57:44Z maronga ! Typo removed ! ! RCS Log replace by Id keyword, revision history cleaned up ! ! Revision 1.11 2006/02/23 09:43:44 raasch ! nzb_2d replaced by nzb_s_inner ! ! Revision 1.1 1997/08/29 08:54:33 raasch ! Initial revision ! ! ! Description: ! ------------ ! Advection term for scalar quantities using the Upstream scheme. ! NOTE: vertical advection at k=1 still has wrong grid spacing for w>0! ! The same problem occurs for all topography boundaries! !------------------------------------------------------------------------------! PRIVATE PUBLIC advec_s_up INTERFACE advec_s_up MODULE PROCEDURE advec_s_up MODULE PROCEDURE advec_s_up_ij END INTERFACE advec_s_up CONTAINS !------------------------------------------------------------------------------! ! Call for all grid points !------------------------------------------------------------------------------! SUBROUTINE advec_s_up( sk ) USE arrays_3d USE control_parameters USE grid_variables USE indices IMPLICIT NONE INTEGER :: i, j, k REAL :: ukomp, vkomp, wkomp REAL, DIMENSION(:,:,:), POINTER :: sk DO i = nxl, nxr DO j = nys, nyn DO k = nzb_s_inner(j,i)+1, nzt ! !-- x-direction ukomp = 0.5 * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans IF ( ukomp > 0.0 ) THEN tend(k,j,i) = tend(k,j,i) - ukomp * & ( sk(k,j,i) - sk(k,j,i-1) ) * ddx ELSE tend(k,j,i) = tend(k,j,i) - ukomp * & ( sk(k,j,i+1) - sk(k,j,i) ) * ddx ENDIF ! !-- y-direction vkomp = 0.5 * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans IF ( vkomp > 0.0 ) THEN tend(k,j,i) = tend(k,j,i) - vkomp * & ( sk(k,j,i) - sk(k,j-1,i) ) * ddy ELSE tend(k,j,i) = tend(k,j,i) - vkomp * & ( sk(k,j+1,i) - sk(k,j,i) ) * ddy ENDIF ! !-- z-direction wkomp = 0.5 * ( w(k,j,i) + w(k-1,j,i) ) IF ( wkomp > 0.0 ) THEN tend(k,j,i) = tend(k,j,i) - wkomp * & ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) ELSE tend(k,j,i) = tend(k,j,i) - wkomp * & ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) ENDIF ENDDO ENDDO ENDDO END SUBROUTINE advec_s_up !------------------------------------------------------------------------------! ! Call for grid point i,j !------------------------------------------------------------------------------! SUBROUTINE advec_s_up_ij( i, j, sk ) USE arrays_3d USE control_parameters USE grid_variables USE indices IMPLICIT NONE INTEGER :: i, j, k REAL :: ukomp, vkomp, wkomp REAL, DIMENSION(:,:,:), POINTER :: sk DO k = nzb_s_inner(j,i)+1, nzt ! !-- x-direction ukomp = 0.5 * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans IF ( ukomp > 0.0 ) THEN tend(k,j,i) = tend(k,j,i) - ukomp * & ( sk(k,j,i) - sk(k,j,i-1) ) * ddx ELSE tend(k,j,i) = tend(k,j,i) - ukomp * & ( sk(k,j,i+1) - sk(k,j,i) ) * ddx ENDIF ! !-- y-direction vkomp = 0.5 * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans IF ( vkomp > 0.0 ) THEN tend(k,j,i) = tend(k,j,i) - vkomp * & ( sk(k,j,i) - sk(k,j-1,i) ) * ddy ELSE tend(k,j,i) = tend(k,j,i) - vkomp * & ( sk(k,j+1,i) - sk(k,j,i) ) * ddy ENDIF ! !-- z-direction wkomp = 0.5 * ( w(k,j,i) + w(k-1,j,i) ) IF ( wkomp > 0.0 ) THEN tend(k,j,i) = tend(k,j,i) - wkomp * & ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) ELSE tend(k,j,i) = tend(k,j,i) - wkomp * & ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) ENDIF ENDDO END SUBROUTINE advec_s_up_ij END MODULE advec_s_up_mod