Index: palm/trunk/SOURCE/boundary_conds.f90
===================================================================
--- palm/trunk/SOURCE/boundary_conds.f90	(revision 766)
+++ palm/trunk/SOURCE/boundary_conds.f90	(revision 767)
@@ -4,5 +4,5 @@
 ! Current revisions:
 ! -----------------
-!
+! ug,vg replaced by u_init,v_init as the Dirichlet top boundary condition
 !  
 ! Former revisions:
@@ -90,6 +90,6 @@
 !--    Top boundary
        IF ( ibc_uv_t == 0 )  THEN
-           u_p(nzt+1,:,:) = ug(nzt+1)
-           v_p(nzt+1,:,:) = vg(nzt+1)
+           u_p(nzt+1,:,:) = u_init(nzt+1)
+           v_p(nzt+1,:,:) = v_init(nzt+1)
        ELSE
            u_p(nzt+1,:,:) = u_p(nzt,:,:)
@@ -312,6 +312,6 @@
 !--    Top boundary at the outflow
        IF ( ibc_uv_t == 0 )  THEN
-          u_p(nzt+1,-1,:) = ug(nzt+1)
-          v_p(nzt+1,0,:)  = vg(nzt+1)
+          u_p(nzt+1,-1,:) = u_init(nzt+1)
+          v_p(nzt+1,0,:)  = v_init(nzt+1)
        ELSE
           u_p(nzt+1,-1,:) = u(nzt,-1,:)
@@ -410,6 +410,6 @@
 !--    Top boundary at the outflow
        IF ( ibc_uv_t == 0 )  THEN
-          u_p(nzt+1,ny+1,:) = ug(nzt+1)
-          v_p(nzt+1,ny+1,:) = vg(nzt+1)
+          u_p(nzt+1,ny+1,:) = u_init(nzt+1)
+          v_p(nzt+1,ny+1,:) = v_init(nzt+1)
        ELSE
           u_p(nzt+1,ny+1,:) = u_p(nzt,nyn+1,:)
@@ -508,6 +508,6 @@
 !--    Top boundary at the outflow
        IF ( ibc_uv_t == 0 )  THEN
-          u_p(nzt+1,:,-1) = ug(nzt+1)
-          v_p(nzt+1,:,-1) = vg(nzt+1)
+          u_p(nzt+1,:,-1) = u_init(nzt+1)
+          v_p(nzt+1,:,-1) = v_init(nzt+1)
        ELSE
           u_p(nzt+1,:,-1) = u_p(nzt,:,-1)
@@ -606,6 +606,6 @@
 !--    Top boundary at the outflow
        IF ( ibc_uv_t == 0 )  THEN
-          u_p(nzt+1,:,nx+1) = ug(nzt+1)
-          v_p(nzt+1,:,nx+1) = vg(nzt+1)
+          u_p(nzt+1,:,nx+1) = u_init(nzt+1)
+          v_p(nzt+1,:,nx+1) = v_init(nzt+1)
        ELSE
           u_p(nzt+1,:,nx+1) = u_p(nzt,:,nx+1)
Index: palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- palm/trunk/SOURCE/check_parameters.f90	(revision 766)
+++ palm/trunk/SOURCE/check_parameters.f90	(revision 767)
@@ -4,5 +4,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! Calculating u,v-profiles from given profiles by linear interpolation.
+! bugfix: dirichlet_0 conditions for ug/vg moved from init_3d_model to here
 !
 ! Former revisions:
@@ -176,6 +177,6 @@
     CHARACTER (LEN=100) ::  action
 
-    INTEGER ::  i, ilen, intervals, iremote = 0, iter, j, k, nnxh, nnyh, &
-         position, prec
+    INTEGER ::  i, ilen, intervals, iremote = 0, iter, j, k, kk, nnxh, nnyh, &
+                position, prec
     LOGICAL ::  found, ldum
     REAL    ::  gradient, maxn, maxp, remote = 0.0, &
@@ -771,7 +772,5 @@
 
 !
-!--    Initial profiles for 1D and 3D model, respectively
-       u_init  = ug_surface
-       v_init  = vg_surface
+!--    Initial profiles for 1D and 3D model, respectively (u,v further below)
        pt_init = pt_surface
        IF ( humidity )        q_init  = q_surface
@@ -838,8 +837,6 @@
        ENDIF
 
-       u_init = ug
-
-!
-!--    In case of no given gradients for ug, choose a vanishing gradient
+!
+!--    In case of no given gradients for ug, choose a zero gradient
        IF ( ug_vertical_gradient_level(1) == -9999999.9 )  THEN
           ug_vertical_gradient_level(1) = 0.0
@@ -904,10 +901,59 @@
        ENDIF
 
-       v_init = vg
- 
-!
-!--    In case of no given gradients for vg, choose a vanishing gradient
+!
+!--    In case of no given gradients for vg, choose a zero gradient
        IF ( vg_vertical_gradient_level(1) == -9999999.9 )  THEN
           vg_vertical_gradient_level(1) = 0.0
+       ENDIF
+
+!
+!--    Let the initial wind profiles be the calculated ug/vg profiles or
+!--    interpolate them from wind profile data (if given)
+       IF ( u_profile(1) == 9999999.9  .AND.  v_profile(1) == 9999999.9 )  THEN
+
+          u_init = ug
+          v_init = vg
+
+       ELSEIF ( u_profile(1) == 0.0  .AND.  v_profile(1) == 0.0 )  THEN
+
+          IF ( uv_heights(1) /= 0.0 )  THEN
+             message_string = 'uv_heights(1) must be 0.0'
+             CALL message( 'check_parameters', 'PA0345', 1, 2, 0, 6, 0 )
+          ENDIF
+
+          use_prescribed_profile_data = .TRUE.
+
+          kk = 1
+          u_init(0) = 0.0
+          v_init(0) = 0.0
+
+          DO  k = 1, nz+1
+
+             IF ( kk < 100 )  THEN
+                DO WHILE ( uv_heights(kk+1) <= zu(k) )
+                   kk = kk + 1
+                   IF ( kk == 100 )  EXIT
+                ENDDO
+             ENDIF
+
+             IF ( kk < 100 )  THEN
+                u_init(k) = u_profile(kk) + ( zu(k) - uv_heights(kk) ) /       &
+                                       ( uv_heights(kk+1) - uv_heights(kk) ) * &
+                                       ( u_profile(kk+1) - u_profile(kk) )
+                v_init(k) = v_profile(kk) + ( zu(k) - uv_heights(kk) ) /       &
+                                       ( uv_heights(kk+1) - uv_heights(kk) ) * &
+                                       ( v_profile(kk+1) - v_profile(kk) )
+             ELSE
+                u_init(k) = u_profile(kk)
+                v_init(k) = v_profile(kk)
+             ENDIF
+
+          ENDDO
+
+       ELSE
+
+          message_string = 'u_profile(1) and v_profile(1) must be 0.0'
+          CALL message( 'check_parameters', 'PA0346', 1, 2, 0, 6, 0 )
+
        ENDIF
 
@@ -1539,4 +1585,11 @@
        IF ( bc_uv_t == 'dirichlet' .OR. bc_uv_t == 'dirichlet_0' )  THEN
           ibc_uv_t = 0
+          IF ( bc_uv_t == 'dirichlet_0' )  THEN
+!
+!--          Velocities for the initial u,v-profiles are set zero at the top
+!--          in case of dirichlet_0 conditions
+             u_init(nzt+1)    = 0.0
+             v_init(nzt+1)    = 0.0
+          ENDIF
        ELSEIF ( bc_uv_t == 'neumann' )  THEN
           ibc_uv_t = 1
Index: palm/trunk/SOURCE/header.f90
===================================================================
--- palm/trunk/SOURCE/header.f90	(revision 766)
+++ palm/trunk/SOURCE/header.f90	(revision 767)
@@ -4,5 +4,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Output of given initial u,v-profiles
 ! 
 ! Former revisions:
@@ -1317,4 +1317,8 @@
     WRITE ( io, 424 )  TRIM( coordinates ), TRIM( vgcomponent ), &
                        TRIM( gradients ), TRIM( slices )
+
+!
+!-- Initial wind profiles
+    IF ( u_profile(1) /= 9999999.9 )  WRITE ( io, 427 )
 
 !
@@ -1925,4 +1929,6 @@
             '       Gradient:    ',A,'  (m/s)/100m'/ &
             '       Gridpoint:   ',A)
+427 FORMAT (/'    Initial wind profiles (u,v) are interpolated from given'// &
+                  ' profiles')
 450 FORMAT (//' LES / Turbulence quantities:'/ &
               ' ---------------------------'/)
Index: palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- palm/trunk/SOURCE/init_3d_model.f90	(revision 766)
+++ palm/trunk/SOURCE/init_3d_model.f90	(revision 767)
@@ -7,5 +7,6 @@
 ! Current revisions:
 ! ------------------
-! 
+! adjustments for prescribed u,v-profiles
+! bugfix: dirichlet_0 conditions for ug/vg moved to check_parameters
 !
 ! Former revisions:
@@ -694,13 +695,6 @@
 !--    Apply channel flow boundary condition
        IF ( TRIM( bc_uv_t ) == 'dirichlet_0' )  THEN
-
           u(nzt+1,:,:) = 0.0
           v(nzt+1,:,:) = 0.0
-
-!--       For the Dirichlet condition to be correctly applied at the top, set
-!--       ug and vg to zero there
-          ug(nzt+1)    = 0.0
-          vg(nzt+1)    = 0.0
-
        ENDIF
 
@@ -937,6 +931,7 @@
     THEN
 !
-!--    When reading data for cyclic fill of 3D prerun data, first read
-!--    some of the global variables from restart file
+!--    When reading data for cyclic fill of 3D prerun data files, read
+!--    some of the global variables from the restart file which are required
+!--    for initializing the inflow
        IF ( TRIM( initializing_actions ) == 'cyclic_fill' )  THEN
 
@@ -951,79 +946,4 @@
           ENDDO
 
-!
-!--       Initialization of the turbulence recycling method
-          IF ( turbulent_inflow )  THEN
-!
-!--          Store temporally and horizontally averaged vertical profiles to be
-!--          used as mean inflow profiles
-             ALLOCATE( mean_inflow_profiles(nzb:nzt+1,5) )
-
-             mean_inflow_profiles(:,1) = hom_sum(:,1,0)    ! u
-             mean_inflow_profiles(:,2) = hom_sum(:,2,0)    ! v
-             mean_inflow_profiles(:,4) = hom_sum(:,4,0)    ! pt
-             mean_inflow_profiles(:,5) = hom_sum(:,8,0)    ! e
-
-!
-!--          Use these mean profiles for the inflow (provided that Dirichlet
-!--          conditions are used)
-             IF ( inflow_l )  THEN
-                DO  j = nysg, nyng
-                   DO  k = nzb, nzt+1
-                      u(k,j,nxlg:-1)  = mean_inflow_profiles(k,1)
-                      v(k,j,nxlg:-1)  = mean_inflow_profiles(k,2)
-                      w(k,j,nxlg:-1)  = 0.0
-                      pt(k,j,nxlg:-1) = mean_inflow_profiles(k,4)
-                      e(k,j,nxlg:-1)  = mean_inflow_profiles(k,5)
-                   ENDDO
-                ENDDO
-             ENDIF
-
-!
-!--          Calculate the damping factors to be used at the inflow. For a
-!--          turbulent inflow the turbulent fluctuations have to be limited
-!--          vertically because otherwise the turbulent inflow layer will grow
-!--          in time.
-             IF ( inflow_damping_height == 9999999.9 )  THEN
-!
-!--             Default: use the inversion height calculated by the prerun; if
-!--             this is zero, inflow_damping_height must be explicitly
-!--             specified.
-                IF ( hom_sum(nzb+6,pr_palm,0) /= 0.0 )  THEN
-                   inflow_damping_height = hom_sum(nzb+6,pr_palm,0)
-                ELSE
-                   WRITE( message_string, * ) 'inflow_damping_height must be ',&
-                        'explicitly specified because&the inversion height ', &
-                        'calculated by the prerun is zero.'
-                   CALL message( 'init_3d_model', 'PA0318', 1, 2, 0, 6, 0 )
-                ENDIF
-
-             ENDIF
-
-             IF ( inflow_damping_width == 9999999.9 )  THEN
-!
-!--             Default for the transition range: one tenth of the undamped
-!--             layer
-                inflow_damping_width = 0.1 * inflow_damping_height
-
-             ENDIF
-
-             ALLOCATE( inflow_damping_factor(nzb:nzt+1) )
-
-             DO  k = nzb, nzt+1
-
-                IF ( zu(k) <= inflow_damping_height )  THEN
-                   inflow_damping_factor(k) = 1.0
-                ELSEIF ( zu(k) <= inflow_damping_height +  &
-                                  inflow_damping_width )  THEN
-                   inflow_damping_factor(k) = 1.0 -                            &
-                                           ( zu(k) - inflow_damping_height ) / &
-                                           inflow_damping_width
-                ELSE
-                   inflow_damping_factor(k) = 0.0
-                ENDIF
-
-             ENDDO
-          ENDIF
-
        ENDIF
 
@@ -1038,4 +958,102 @@
 #endif
        ENDDO
+
+!
+!--    Initialization of the turbulence recycling method
+       IF ( TRIM( initializing_actions ) == 'cyclic_fill'  .AND.  &
+            turbulent_inflow )  THEN
+!
+!--       First store the profiles to be used at the inflow.
+!--       These profiles are the (temporally) and horizontally averaged vertical
+!--       profiles from the prerun. Alternatively, prescribed profiles
+!--       for u,v-components can be used.
+          ALLOCATE( mean_inflow_profiles(nzb:nzt+1,5) )
+
+          IF ( use_prescribed_profile_data )  THEN
+             mean_inflow_profiles(:,1) = u_init            ! u
+             mean_inflow_profiles(:,2) = v_init            ! v
+          ELSE
+             mean_inflow_profiles(:,1) = hom_sum(:,1,0)    ! u
+             mean_inflow_profiles(:,2) = hom_sum(:,2,0)    ! v
+          ENDIF
+          mean_inflow_profiles(:,4) = hom_sum(:,4,0)       ! pt
+          mean_inflow_profiles(:,5) = hom_sum(:,8,0)       ! e
+
+!
+!--       If necessary, adjust the horizontal flow field to the prescribed
+!--       profiles
+          IF ( use_prescribed_profile_data )  THEN
+             DO  i = nxlg, nxrg
+                DO  j = nysg, nyng
+                   DO  k = nzb, nzt+1
+                      u(k,j,i) = u(k,j,i) - hom_sum(k,1,0) + u_init(k)
+                      v(k,j,i) = v(k,j,i) - hom_sum(k,2,0) + v_init(k)
+                   ENDDO
+                ENDDO
+             ENDDO
+          ENDIF
+
+!
+!--       Use these mean profiles at the inflow (provided that Dirichlet
+!--       conditions are used)
+          IF ( inflow_l )  THEN
+             DO  j = nysg, nyng
+                DO  k = nzb, nzt+1
+                   u(k,j,nxlg:-1)  = mean_inflow_profiles(k,1)
+                   v(k,j,nxlg:-1)  = mean_inflow_profiles(k,2)
+                   w(k,j,nxlg:-1)  = 0.0
+                   pt(k,j,nxlg:-1) = mean_inflow_profiles(k,4)
+                   e(k,j,nxlg:-1)  = mean_inflow_profiles(k,5)
+                ENDDO
+             ENDDO
+          ENDIF
+
+!
+!--       Calculate the damping factors to be used at the inflow. For a
+!--       turbulent inflow the turbulent fluctuations have to be limited
+!--       vertically because otherwise the turbulent inflow layer will grow
+!--       in time.
+          IF ( inflow_damping_height == 9999999.9 )  THEN
+!
+!--          Default: use the inversion height calculated by the prerun; if
+!--          this is zero, inflow_damping_height must be explicitly
+!--          specified.
+             IF ( hom_sum(nzb+6,pr_palm,0) /= 0.0 )  THEN
+                inflow_damping_height = hom_sum(nzb+6,pr_palm,0)
+             ELSE
+                WRITE( message_string, * ) 'inflow_damping_height must be ',&
+                     'explicitly specified because&the inversion height ', &
+                     'calculated by the prerun is zero.'
+                CALL message( 'init_3d_model', 'PA0318', 1, 2, 0, 6, 0 )
+             ENDIF
+
+          ENDIF
+
+          IF ( inflow_damping_width == 9999999.9 )  THEN
+!
+!--          Default for the transition range: one tenth of the undamped
+!--          layer
+             inflow_damping_width = 0.1 * inflow_damping_height
+
+          ENDIF
+
+          ALLOCATE( inflow_damping_factor(nzb:nzt+1) )
+
+          DO  k = nzb, nzt+1
+
+             IF ( zu(k) <= inflow_damping_height )  THEN
+                inflow_damping_factor(k) = 1.0
+             ELSEIF ( zu(k) <= inflow_damping_height +  &
+                               inflow_damping_width )  THEN
+                inflow_damping_factor(k) = 1.0 -                            &
+                                        ( zu(k) - inflow_damping_height ) / &
+                                        inflow_damping_width
+             ELSE
+                inflow_damping_factor(k) = 0.0
+             ENDIF
+
+          ENDDO
+
+       ENDIF
 
 !
@@ -1146,5 +1164,41 @@
     IF ( conserve_volume_flow )  THEN
 
-       IF  ( TRIM( initializing_actions ) == 'cyclic_fill' )  THEN
+       IF ( use_prescribed_profile_data )  THEN
+
+          volume_flow_initial_l = 0.0
+          volume_flow_area_l    = 0.0
+
+          IF ( nxr == nx )  THEN
+             DO  j = nys, nyn
+                DO  k = nzb_2d(j,nx)+1, nzt
+                   volume_flow_initial_l(1) = volume_flow_initial_l(1) + &
+                                              u_init(k) * dzw(k)
+                   volume_flow_area_l(1)    = volume_flow_area_l(1) + dzw(k)
+                ENDDO
+             ENDDO
+          ENDIF
+          
+          IF ( nyn == ny )  THEN
+             DO  i = nxl, nxr
+                DO  k = nzb_2d(ny,i)+1, nzt  
+                   volume_flow_initial_l(2) = volume_flow_initial_l(2) + &
+                                              v_init(k) * dzw(k)
+                   volume_flow_area_l(2)    = volume_flow_area_l(2) + dzw(k)
+                ENDDO
+             ENDDO
+          ENDIF
+
+#if defined( __parallel )
+          CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),&
+                              2, MPI_REAL, MPI_SUM, comm2d, ierr )
+          CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1),      &
+                              2, MPI_REAL, MPI_SUM, comm2d, ierr )
+
+#else
+          volume_flow_initial = volume_flow_initial_l
+          volume_flow_area    = volume_flow_area_l
+#endif  
+
+       ELSEIF ( TRIM( initializing_actions ) == 'cyclic_fill' )  THEN
 
           volume_flow_initial_l = 0.0
Index: palm/trunk/SOURCE/modules.f90
===================================================================
--- palm/trunk/SOURCE/modules.f90	(revision 766)
+++ palm/trunk/SOURCE/modules.f90	(revision 767)
@@ -5,5 +5,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! +u_profile, v_profile, uv_heights, use_prescribed_profile_data
 !
 ! Former revisions:
@@ -536,8 +536,9 @@
                 stop_dt = .FALSE., synchronous_exchange = .FALSE., &
                 terminate_run = .FALSE., turbulent_inflow = .FALSE., &
+                use_prescribed_profile_data = .FALSE., &
                 use_prior_plot1d_parameters = .FALSE., use_reference = .FALSE.,&
                 use_surface_fluxes = .FALSE., use_top_fluxes = .FALSE., &
                 use_ug_for_galilei_tr = .TRUE., use_upstream_for_tke = .FALSE.,&
-                wall_adjustment = .TRUE., ws_scheme_sca = .FALSE.,             &
+                wall_adjustment = .TRUE., ws_scheme_sca = .FALSE., &
                 ws_scheme_mom = .FALSE.
 
@@ -636,4 +637,6 @@
              time_domask(max_masks) = 0.0, &
              tsc(10) = (/ 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 /), &
+             u_profile(100) = 9999999.9, uv_heights(100) = 9999999.9, &
+             v_profile(100) = 9999999.9, &
              ug_vertical_gradient(10) = 0.0, &
              ug_vertical_gradient_level(10) = -9999999.9, &
Index: palm/trunk/SOURCE/parin.f90
===================================================================
--- palm/trunk/SOURCE/parin.f90	(revision 766)
+++ palm/trunk/SOURCE/parin.f90	(revision 767)
@@ -4,5 +4,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! +u_profile, v_profile, uv_heights in inipar
 !
 ! Former revisions:
@@ -166,10 +166,10 @@
              top_momentumflux_u, top_momentumflux_v, top_salinityflux, &
              turbulent_inflow, ug_surface, ug_vertical_gradient, &
-             ug_vertical_gradient_level, u_bulk, ups_limit_e, ups_limit_pt, &
+             ug_vertical_gradient_level, ups_limit_e, ups_limit_pt, &
              ups_limit_u, ups_limit_v, ups_limit_w, use_surface_fluxes, &
              use_top_fluxes, use_ug_for_galilei_tr, use_upstream_for_tke, &
-             vg_surface, vg_vertical_gradient, vg_vertical_gradient_level, &
-             v_bulk, wall_adjustment, wall_heatflux, wall_humidityflux, &
-             wall_scalarflux
+             uv_heights, u_bulk, u_profile, vg_surface, vg_vertical_gradient, &
+             vg_vertical_gradient_level, v_bulk, v_profile, wall_adjustment, &
+             wall_heatflux, wall_humidityflux, wall_scalarflux
 
 
