Index: palm/trunk/SOURCE/advec_ws.f90
===================================================================
--- palm/trunk/SOURCE/advec_ws.f90	(revision 4339)
+++ palm/trunk/SOURCE/advec_ws.f90	(revision 4340)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Topography closed channel flow with symmetric boundaries implemented 
+! 
+! 4330 2019-12-10 16:16:33Z knoop
 ! Bugix: removed syntax error introduced by last commit
 ! 
@@ -166,4 +169,5 @@
                salsa,                                                          &
                scalar_advec,                                                   &
+               symmetry_flag,                                                  &
                intermediate_timestep_count,                                    &
                u_gtrans,                                                       &
@@ -502,5 +506,5 @@
                              BTEST(wall_flags_static_0(k+1,j,i),1)       .AND.     &
                              BTEST(wall_flags_static_0(k,j,i),1) )       .OR.      &
-                     k == nzt )                                                    &
+                     ( k == nzt .AND. symmetry_flag == 0 ) )                       &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 6 )       
@@ -512,6 +516,6 @@
                                  BTEST(wall_flags_static_0(k+1,j,i),1)     .AND.   &
                                  BTEST(wall_flags_static_0(k_pp,j,i),1)    .AND.   &
-                           .NOT. flag_set                           .OR.           & 
-                         k == nzt - 1 )                                            &
+                           .NOT. flag_set                                  .OR.    & 
+                         ( k == nzt - 1 .AND. symmetry_flag == 0 ) )               &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 7 )       
@@ -635,5 +639,5 @@
                              BTEST(wall_flags_static_0(k+1,j,i),2)          .AND.     &
                              BTEST(wall_flags_static_0(k,j,i),2) )          .OR.      &
-                     k == nzt )                                                       &
+                     ( k == nzt .AND. symmetry_flag == 0 ) )                          &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 15 )      
@@ -646,5 +650,5 @@
                                  BTEST(wall_flags_static_0(k_pp,j,i),2)    .AND.      &
                            .NOT. flag_set                                  .OR.       & 
-                         k == nzt - 1 )                                               &
+                         ( k == nzt - 1 .AND. symmetry_flag == 0 ) )                  &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 16 )      
@@ -1082,9 +1086,11 @@
                                                                                
                 flag_set = .FALSE.                                             
-                IF ( .NOT. BTEST(wall_flags_static_0(k-1,j,i),0)  .AND.               &
-                           BTEST(wall_flags_static_0(k,j,i),0)    .OR.                &
-                     .NOT. BTEST(wall_flags_static_0(k_pp,j,i),0) .AND.               &                              
-                           BTEST(wall_flags_static_0(k,j,i),0)    .OR.                &
-                     k == nzt )                                                &
+                IF ( ( .NOT. BTEST(wall_flags_static_0(k-1,j,i),0)          .AND.     &
+                             BTEST(wall_flags_static_0(k,j,i),0)            .AND.     &
+                             BTEST(wall_flags_static_0(k+1,j,i),0) )        .OR.      &
+                     ( .NOT. BTEST(wall_flags_static_0(k_pp,j,i),0)         .AND.     &                              
+                             BTEST(wall_flags_static_0(k+1,j,i),0)          .AND.     &
+                             BTEST(wall_flags_static_0(k,j,i),0) )          .OR.      &
+                     ( k == nzt .AND. symmetry_flag == 0 ) )                          &
                 THEN                                                           
                    advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 6 )             
@@ -1096,6 +1102,6 @@
                                  BTEST(wall_flags_static_0(k+1,j,i),0)     .AND.      &
                                  BTEST(wall_flags_static_0(k_pp,j,i),0)    .AND.      &
-                           .NOT. flag_set                           .OR.       & 
-                         k == nzt - 1 )                                        &
+                           .NOT. flag_set                                  .OR.       & 
+                         ( k == nzt - 1 .AND. symmetry_flag == 0 ) )                  &
                 THEN                                                           
                    advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 7 )             
@@ -1595,5 +1601,5 @@
        ENDDO       
        
-       DO  k = nzt-1, nzt
+       DO  k = nzt-1, nzt-symmetry_flag
           ibit8 = REAL( IBITS(advc_flag(k,j,i),8,1), KIND = wp )
           ibit7 = REAL( IBITS(advc_flag(k,j,i),7,1), KIND = wp )
@@ -1638,7 +1644,14 @@
        
 !
-!--    Set resolved/turbulent flux at model top to zero (w-level)
+!--    Set resolved/turbulent flux at model top to zero (w-level). In case that
+!--    a symmetric behavior between bottom and top shall be guaranteed (closed
+!--    channel flow), the flux at nzt is also set to zero. 
+       IF ( symmetry_flag == 1 ) THEN
+          flux_t(nzt) = 0.0_wp
+          diss_t(nzt) = 0.0_wp
+       ENDIF
        flux_t(nzt+1) = 0.0_wp
        diss_t(nzt+1) = 0.0_wp
+       
        
        IF ( limiter )  THEN
@@ -2323,5 +2336,5 @@
        ENDDO
        
-       DO  k = nzt-1, nzt
+       DO  k = nzt-1, nzt-symmetry_flag
 !
 !--       k index has to be modified near bottom and top, else array
@@ -2368,5 +2381,12 @@
        
 !
-!--    Set resolved/turbulent flux at model top to zero (w-level)
+!--    Set resolved/turbulent flux at model top to zero (w-level). In case that
+!--    a symmetric behavior between bottom and top shall be guaranteed (closed
+!--    channel flow), the flux at nzt is also set to zero. 
+       IF ( symmetry_flag == 1 ) THEN
+          flux_t(nzt) = 0.0_wp
+          diss_t(nzt) = 0.0_wp
+          w_comp(nzt) = 0.0_wp
+       ENDIF
        flux_t(nzt+1) = 0.0_wp
        diss_t(nzt+1) = 0.0_wp
@@ -2887,5 +2907,5 @@
        ENDDO
        
-       DO  k = nzt-1, nzt
+       DO  k = nzt-1, nzt-symmetry_flag
 !
 !--       k index has to be modified near bottom and top, else array
@@ -2932,5 +2952,12 @@
        
 !
-!--    Set resolved/turbulent flux at model top to zero (w-level)
+!--    Set resolved/turbulent flux at model top to zero (w-level). In case that
+!--    a symmetric behavior between bottom and top shall be guaranteed (closed
+!--    channel flow), the flux at nzt is also set to zero. 
+       IF ( symmetry_flag == 1 ) THEN
+          flux_t(nzt) = 0.0_wp
+          diss_t(nzt) = 0.0_wp
+          w_comp(nzt) = 0.0_wp
+       ENDIF
        flux_t(nzt+1) = 0.0_wp
        diss_t(nzt+1) = 0.0_wp
Index: palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- palm/trunk/SOURCE/check_parameters.f90	(revision 4339)
+++ palm/trunk/SOURCE/check_parameters.f90	(revision 4340)
@@ -25,4 +25,7 @@
 ! -----------------
 ! 4172 2019-08-20 11:55:33Z oliver.maas
+! Checks for closed channel flow implemented
+! 
+! 11:55:33Z oliver.maas
 ! Move 2-m potential temperature output to diagnostic_output_quantities
 ! 
@@ -498,13 +501,48 @@
           WRITE( action, '(A)' )  'cloud_droplets = .TRUE.'
        ENDIF
-       IF ( .NOT. constant_flux_layer )  THEN
+       IF ( .NOT. constant_flux_layer .AND. topography /= 'closed_channel' )   &
+       THEN
           WRITE( action, '(A)' )  'constant_flux_layer = .FALSE.'
        ENDIF
        IF ( action /= ' ' )  THEN
-          message_string = 'a non-flat topography does not allow ' //          &
+          message_string = 'The specified topography does not allow ' //       &
                            TRIM( action )
           CALL message( 'check_parameters', 'PA0014', 1, 2, 0, 6, 0 )
        ENDIF
-
+!
+!--    Check illegal/untested parameter combinations for closed channel
+       If ( topography == 'closed_channel' ) THEN 
+          symmetry_flag = 1
+          message_string = 'Bottom and top boundary are treated equal'
+          CALL message( 'check_parameters', 'PA0676', 0, 0, 0, 6, 0 )
+       
+          IF ( dz(1) /= dz(COUNT( dz /= -1.0_wp )) .OR.                        &
+               dz_stretch_level /= -9999999.9_wp) THEN
+             WRITE( message_string, * )  'dz should be equal close to the ' // &
+                                         'boundaries due to symmetrical problem'
+             CALL message( 'check_parameters', 'PA0313', 1, 2, 0, 6, 0 )
+          ENDIF
+       
+          IF ( constant_flux_layer ) THEN
+             WRITE( message_string, * )  'A constant flux layer is not '//     &
+                                         'allowed if a closed channel '//      &
+                                         'shall be used'
+             CALL message( 'check_parameters', 'PA0688', 1, 2, 0, 6, 0 )
+          ENDIF
+       
+          IF ( ocean_mode ) THEN
+             WRITE( message_string, * )  'The ocean mode is not allowed if '// &
+                                         'a closed channel shall be used'
+             CALL message( 'check_parameters', 'PA0689', 1, 2, 0, 6, 0 )
+          ENDIF
+       
+          IF ( momentum_advec /= 'ws-scheme' .OR.                              &
+               scalar_advec /= 'ws-scheme' ) THEN
+             WRITE( message_string, * )  'A closed channel require the '//     &
+                                         'upwind scheme of Wicker and ' //     &
+                                         'Skamarock as the advection scheme'
+             CALL message( 'check_parameters', 'PA0690', 1, 2, 0, 6, 0 )
+          ENDIF
+       ENDIF
     ENDIF
 
Index: palm/trunk/SOURCE/init_grid.f90
===================================================================
--- palm/trunk/SOURCE/init_grid.f90	(revision 4339)
+++ palm/trunk/SOURCE/init_grid.f90	(revision 4340)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Topography closed channel flow with symmetric boundaries implemented
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -132,5 +135,5 @@
                momentum_advec, number_stretch_level_end,                       &
                number_stretch_level_start, ocean_mode, psolver, scalar_advec,  &
-               topography, use_surface_fluxes
+               symmetry_flag, topography, use_surface_fluxes
          
     USE grid_variables,                                                        &
@@ -360,6 +363,8 @@
 !--    the first u/v- and w-level (k=0) are defined at same height (z=0). 
 !--    The second u-level (k=1) corresponds to the top of the 
-!--    Prandtl-layer.
-       IF ( ibc_uv_b == 0 .OR. ibc_uv_b == 2 ) THEN
+!--    Prandtl-layer. In case of symmetric boundaries (closed channel flow), 
+!--    the first grid point is always at z=0.
+       IF ( ibc_uv_b == 0 .OR. ibc_uv_b == 2 .OR.                              & 
+            topography == 'closed_channel' ) THEN
           zu(0) = 0.0_wp
        ELSE
@@ -379,5 +384,5 @@
 !--    The default value of dz_stretch_level_start is negative, thus the first
 !--    condition is always true. Hence, the second condition is necessary.
-       DO  k = 2, nzt+1
+       DO  k = 2, nzt+1-symmetry_flag
           IF ( dz_stretch_level_start(n) <= zu(k-1) .AND.                      &
                dz_stretch_level_start(n) /= -9999999.9_wp ) THEN
@@ -408,4 +413,14 @@
           ENDIF
        ENDDO
+       
+!
+!--    If a closed channel flow is simulated, make sure that grid structure is  
+!--    the same for both bottom and top boundary. (Hint: Using a different dz 
+!--    at the bottom and at the top makes no sense due to symmetric boundaries
+!--    where dz should be equal. Therefore, different dz at the bottom and top  
+!--    causes an abort (see check_parameters).)
+       IF ( topography == 'closed_channel' ) THEN
+          zu(nzt+1) = zu(nzt) + dz(1) * 0.5_wp
+       ENDIF
 
 !
@@ -413,10 +428,20 @@
 !--    corresponding u-levels. In case of dirichlet bc for u and v at the 
 !--    ground the first u- and w-level (k=0) are defined at same height (z=0). 
-!--    The top w-level is extrapolated linearly.
+!--    Per default, the top w-level is extrapolated linearly. In case of 
+!--    a closed channel flow, zu(nzt+1) and zw(nzt) must be set explicitely.
+!--    (Hint: Using a different dz at the bottom and at the top makes no sense
+!--    due to symmetric boundaries where dz should be equal. Therefore, 
+!--    different dz at the bottom and top causes an abort (see 
+!--    check_parameters).)
        zw(0) = 0.0_wp
-       DO  k = 1, nzt
+       DO  k = 1, nzt-symmetry_flag
           zw(k) = ( zu(k) + zu(k+1) ) * 0.5_wp
        ENDDO
-       zw(nzt+1) = zw(nzt) + 2.0_wp * ( zu(nzt+1) - zw(nzt) )
+       IF ( topography == 'closed_channel' ) THEN
+          zw(nzt)   = zw(nzt-1) + dz(1)
+          zw(nzt+1) = zw(nzt) + dz(1)
+       ELSE
+          zw(nzt+1) = zw(nzt) + 2.0_wp * ( zu(nzt+1) - zw(nzt) )
+       ENDIF
 
     ELSE
@@ -1817,5 +1842,10 @@
 !   
 !--       Initialilize 3D topography array, used later for initializing flags
-          topo(nzb+1:nzt+1,:,:) = IBSET( topo(nzb+1:nzt+1,:,:), 0 ) 
+          topo(nzb+1:nzt+1,:,:) = IBSET( topo(nzb+1:nzt+1,:,:), 0 )
+          
+       CASE ( 'closed_channel' )
+!   
+!--       Initialilize 3D topography array, used later for initializing flags
+          topo(nzb+1:nzt,:,:) = IBSET( topo(nzb+1:nzt,:,:), 0 ) 
 
        CASE ( 'single_building' )
@@ -2238,5 +2268,6 @@
 !--    is applicable. If this is not possible, abort.
        IF ( TRIM( topography_grid_convention ) == ' ' )  THEN
-          IF ( TRIM( topography ) /= 'single_building' .AND.                   &
+          IF ( TRIM( topography ) /= 'closed_channel' .AND.                    &
+               TRIM( topography ) /= 'single_building' .AND.                   &
                TRIM( topography ) /= 'single_street_canyon' .AND.              &
                TRIM( topography ) /= 'tunnel'  .AND.                           &
@@ -2250,5 +2281,6 @@
                'is not set. Its default value is & only valid for ',           &
                '"topography" = ''single_building'', ''tunnel'' ',              &
-               '''single_street_canyon'' & or ''read_from_file''.',            &
+               '''single_street_canyon'', ''closed_channel'' & or ',           &
+               '''read_from_file''.',                                          &
                '& Choose ''cell_edge'' or ''cell_center''.'
              CALL message( 'init_grid', 'PA0239', 1, 2, 0, 6, 0 )
@@ -2344,15 +2376,15 @@
 !
 !--          scalar grid
-             IF ( BTEST( topo(k,j,i), 0 ) )                                 &
+             IF ( BTEST( topo(k,j,i), 0 ) )                                    &
                 wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 0 )
 !
 !--          u grid
-             IF ( BTEST( topo(k,j,i),   0 )  .AND.                          &
-                  BTEST( topo(k,j,i-1), 0 ) )                               &
+             IF ( BTEST( topo(k,j,i),   0 )  .AND.                             &
+                  BTEST( topo(k,j,i-1), 0 ) )                                  &
                 wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 1 )
 !
 !--          v grid
-             IF ( BTEST( topo(k,j,i),   0 )  .AND.                          &
-                  BTEST( topo(k,j-1,i), 0 ) )                               &
+             IF ( BTEST( topo(k,j,i),   0 )  .AND.                             &
+                  BTEST( topo(k,j-1,i), 0 ) )                                  &
                  wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 2 )
 
@@ -2362,9 +2394,12 @@
 !
 !--          w grid
-             IF ( BTEST( topo(k,j,i),   0 )  .AND.                          &
-                  BTEST( topo(k+1,j,i), 0 ) )                               &
+             IF ( BTEST( topo(k,j,i),   0 )  .AND.                             &
+                  BTEST( topo(k+1,j,i), 0 ) )                                  &
                 wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 3 )
           ENDDO
-          wall_flags_static_0(nzt+1,j,i) = IBSET( wall_flags_static_0(nzt+1,j,i), 3 )
+          
+          IF ( topography /= 'closed_channel' ) THEN
+             wall_flags_static_0(nzt+1,j,i) = IBSET( wall_flags_static_0(nzt+1,j,i), 3 )
+          ENDIF
 
        ENDDO
@@ -2479,5 +2514,5 @@
 !
 !--       Flags indicating downward facing walls
-          DO k = nzb+1, nzt
+          DO k = nzb+1, nzt+1
 !
 !--          Scalar grid
Index: palm/trunk/SOURCE/modules.f90
===================================================================
--- palm/trunk/SOURCE/modules.f90	(revision 4339)
+++ palm/trunk/SOURCE/modules.f90	(revision 4340)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Flag for topography closed channel flow with symmetric boundaries introduced
+! 
+! 4331 2019-12-10 18:25:02Z suehring
 ! - do_output_at_2m, pt_2m_av
 ! 
@@ -621,4 +624,5 @@
     INTEGER(iwp) ::  runnr = 0                         !< number of run in job chain
     INTEGER(iwp) ::  subdomain_size                    !< number of grid points in (3d) subdomain including ghost points
+    INTEGER(iwp) ::  symmetry_flag = 0                 !< flag for sterring the symmetric behavior of the bottom and top boundary
     INTEGER(iwp) ::  terminate_coupled = 0             !< switch for steering termination in case of coupled runs
     INTEGER(iwp) ::  terminate_coupled_remote = 0      !< switch for steering termination in case of coupled runs (condition of the remote model)
Index: palm/trunk/SOURCE/radiation_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/radiation_model_mod.f90	(revision 4339)
+++ palm/trunk/SOURCE/radiation_model_mod.f90	(revision 4340)
@@ -27,10 +27,9 @@
 ! Former revisions:
 ! -----------------
-!
+! $Id$
 ! Albedo indices for building_surface_pars are now declared as parameters to 
 ! prevent an error if the gfortran compiler with -Werror=unused-value is used
-! 
-! 
-! $Id$
+!  
+! 4291 2019-11-11 12:36:54Z moh.hefny
 ! Enabled RTM in case of biometeorology even if there is no vertical 
 ! surfaces or 3D vegetation in the domain
