SUBROUTINE advec_v_ups !------------------------------------------------------------------------------! ! Current revisions: ! ----------------- ! ! ! Former revisions: ! ----------------- ! $Id: advec_v_ups.f90 484 2010-02-05 07:36:54Z raasch $ ! ! 164 2008-05-15 08:46:15Z raasch ! Arguments removed from transpose routines ! ! February 2007 ! RCS Log replace by Id keyword, revision history cleaned up ! ! Revision 1.7 2004/04/30 08:03:52 raasch ! Enlarged transposition arrays introduced ! ! Revision 1.1 1999/02/05 08:50:32 raasch ! Initial revision ! ! ! Description: ! ------------ ! Upstream-Spline advection of the v velocity-component. The advection process ! is divided into three subsequent steps, one for each of the dimensions. The ! result is stored as a tendency in array tend. The computation of the cubic ! splines and the possible execution of the Long-filter require that all grid ! points of the relevant dimension are available. For model runs on more than ! one PE therefore both the advected and the advecting quantities are ! transposed accordingly. ! ! Internally used arrays: ! v_ad = scalar quantity to be advected, initialised = v at the beginning, ! also being used as temporary storage after each time step ! d = advecting component (u, v, or w) !------------------------------------------------------------------------------! USE advection USE arrays_3d USE cpulog USE grid_variables USE indices USE interfaces USE control_parameters IMPLICIT NONE INTEGER :: i, j, k REAL, DIMENSION(:,:,:), ALLOCATABLE :: v_ad CALL cpu_log( log_point_s(18), 'advec_v_ups', 'start' ) #if defined( __parallel ) ! !-- Advection of v in x-direction: !-- Store v in temporary array v_ad (component to be advected, boundaries !-- are not used because they disturb the transposition) ALLOCATE( v_ad(nzb+1:nzta,nys:nyna,nxl:nxra) ) v_ad = 0.0 v_ad(nzb+1:nzt,nys:nyn,nxl:nxr) = v(nzb+1:nzt,nys:nyn,nxl:nxr) ! !-- Enlarge the size of tend, used as a working array for the transpositions IF ( nxra > nxr .OR. nyna > nyn .OR. nza > nz ) THEN DEALLOCATE( tend ) ALLOCATE( tend(1:nza,nys:nyna,nxl:nxra) ) ENDIF ! !-- Transpose the component to be advected: z --> x CALL transpose_zx( v_ad, tend, v_ad ) #else ! !-- Advection of v in x-direction: !-- Store v in temporary array v_ad (component to be advected) ALLOCATE( v_ad(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) v_ad(:,:,:) = v(:,:,:) #endif ! !-- Advecting component (u) must be averaged out on the v grid d = 0.0 DO i = nxl, nxr DO j = nys, nyn DO k = nzb+1, nzt d(k,j,i) = 0.25 * ( u(k,j-1,i) + u(k,j-1,i+1) + & u(k,j,i+1) + u(k,j,i) ) - u_gtrans ENDDO ENDDO ENDDO #if defined( __parallel ) ! !-- Transpose the advecting component: z --> x CALL transpose_zx( d, tend, d ) #endif ! !-- Upstream-Spline advection of v in x-direction. Array tend comes out !-- as v_ad before the advection step including cyclic boundaries. !-- It is needed for the long filter. CALL spline_x( v_ad, d, 'v' ) ! !-- Advection of v in y-direction: !-- advecting component (d) = component to be advected (v) d(nzb+1:nzt,nys:nyn,nxl:nxr) = v(nzb+1:nzt,nys:nyn,nxl:nxr) - v_gtrans #if defined( __parallel ) ! !-- Transpose the advecting component: z --> y CALL transpose_zx( d, tend, d ) CALL transpose_xy( d, tend, d ) ! !-- Transpose the component to be advected: x --> y CALL transpose_xy( v_ad, tend, v_ad ) #endif ! !-- Upstream-Spline advection of v in y-direction CALL spline_y( v_ad, d, 'v' ) ! !-- Advection of v in z-direction: !-- the advecting component (w) must be averaged out on the v grid !-- (weighted for non-equidistant grid) DO i = nxl, nxr DO j = nys, nyn DO k = nzb+1, nzt d(k,j,i) = ( 0.5 * ( w(k-1,j-1,i) + w(k-1,j,i) ) * & ( zw(k) - zu(k) ) + & 0.5 * ( w(k,j,i) + w(k,j-1,i) ) * & ( zu(k) - zw(k-1) ) & ) * ddzw(k) ENDDO ENDDO ENDDO #if defined( __parallel ) ! !-- Transpose the component to be advected: y --> z (= y --> x + x --> z) CALL transpose_yx( v_ad, tend, v_ad ) CALL transpose_xz( v_ad, tend, v_ad ) ! !-- Resize tend to its normal size IF ( nxra > nxr .OR. nyna > nyn .OR. nza > nz ) THEN DEALLOCATE( tend ) ALLOCATE( tend(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF #endif ! !-- Upstream-Spline advection of v in z-direction CALL spline_z( v_ad, d, dzu, spl_tri_zu, 'v' ) ! !-- Compute the tendency term DO i = nxl, nxr DO j = nys, nyn DO k = nzb+1, nzt tend(k,j,i) = ( v_ad(k,j,i) - v(k,j,i) ) / dt_3d ENDDO ENDDO ENDDO DEALLOCATE( v_ad ) CALL cpu_log( log_point_s(18), 'advec_v_ups', 'stop' ) END SUBROUTINE advec_v_ups