Index: palm/trunk/SOURCE/Makefile
===================================================================
--- palm/trunk/SOURCE/Makefile	(revision 2815)
+++ palm/trunk/SOURCE/Makefile	(revision 2817)
@@ -25,4 +25,7 @@
 # -----------------
 # $Id$
+# Preliminary gust module interface implemented
+# 
+# 2802 2018-02-14 16:21:39Z thiele
 # Changed lpm from subroutine to module.
 # Introduce particle transfer in nested models.
@@ -420,5 +423,5 @@
 	disturb_heatflux.f90 eqn_state_seawater.f90 exchange_horiz.f90 \
 	exchange_horiz_2d.f90 fft_xy_mod.f90 flow_statistics.f90 \
-	global_min_max.f90 header.f90 \
+	global_min_max.f90 gust_mod.f90 header.f90 \
 	inflow_turbulence.f90 init_3d_model.f90 \
 	init_advec.f90 init_cloud_physics.f90 init_coupling.f90 init_dvrp.f90 \
@@ -571,4 +574,5 @@
                    large_scale_forcing_nudging_mod.o netcdf_interface_mod.o radiation_model_mod.o surface_mod.o
 global_min_max.o: modules.o mod_kinds.o
+gust_mod.o: modules.o mod_kinds.o
 header.o: modules.o cpulog_mod.o mod_kinds.o date_and_time_mod.o large_scale_forcing_nudging_mod.o netcdf_interface_mod.o \
    land_surface_model_mod.o microphysics_mod.o model_1d_mod.o plant_canopy_model_mod.o pmc_handle_communicator_mod.o \
Index: palm/trunk/SOURCE/average_3d_data.f90
===================================================================
--- palm/trunk/SOURCE/average_3d_data.f90	(revision 2815)
+++ palm/trunk/SOURCE/average_3d_data.f90	(revision 2817)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Preliminary gust module interface implemented
+! 
+! 2797 2018-02-08 13:24:35Z suehring
 ! Enable output of ground-heat flux also at urban surfaces.
 ! 
@@ -142,4 +145,7 @@
         ONLY:  cpu_log, log_point
 
+    USE gust_mod,                                                              &
+        ONLY:  gust_3d_data_averaging, gust_module_enabled
+
     USE indices,                                                               &
         ONLY:  nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt
@@ -526,4 +532,9 @@
              ENDIF
 !
+!--          Gust module quantities
+             IF ( gust_module_enabled )  THEN
+                CALL gust_3d_data_averaging( 'average', doav(ii) )
+             ENDIF
+!
 !--          Chemistry quantity
              IF ( air_chemistry )  THEN
Index: palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- palm/trunk/SOURCE/check_parameters.f90	(revision 2815)
+++ palm/trunk/SOURCE/check_parameters.f90	(revision 2817)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Preliminary gust module interface implemented
+! 
+! 2798 2018-02-09 17:16:39Z suehring
 ! Consider also default-type surfaces for surface temperature output. 
 ! 
@@ -602,4 +605,7 @@
     USE dvrp_variables
     USE grid_variables
+    USE gust_mod,                                                              &
+        ONLY: gust_check_data_output, gust_check_data_output_pr,               &
+              gust_check_parameters, gust_module_enabled
     USE indices
     USE land_surface_model_mod,                                                &
@@ -1413,4 +1419,7 @@
     IF ( radiation )  CALL radiation_check_parameters
 !
+!-- When gust module is used, perform additional checks
+    IF ( gust_module_enabled )  CALL gust_check_parameters
+!
 !-- When large-scale forcing or nudging is used, peform addtional checks
     IF ( large_scale_forcing  .OR.  nudging )  CALL lsf_nudging_check_parameters
@@ -3099,4 +3108,10 @@
                                                      unit, dopr_unit(i) )
              ENDIF
+!
+!--          Block of gust module profile outputs
+             IF ( unit == 'illegal'  .AND.  gust_module_enabled  )  THEN
+                   CALL gust_check_data_output_pr( data_output_pr(i), i, unit, &
+                                                   dopr_unit(i) )
+             ENDIF
 
              IF ( unit == 'illegal' )  THEN                                        
@@ -3418,4 +3433,10 @@
              IF ( unit == 'illegal' )  THEN
                 CALL radiation_check_data_output( var, unit, i, ilen, k )
+             ENDIF
+
+!
+!--          Block of gust module outputs
+             IF ( unit == 'illegal'  .AND.  gust_module_enabled  )  THEN
+                CALL gust_check_data_output ( var, unit )
              ENDIF
 
Index: palm/trunk/SOURCE/data_output_2d.f90
===================================================================
--- palm/trunk/SOURCE/data_output_2d.f90	(revision 2815)
+++ palm/trunk/SOURCE/data_output_2d.f90	(revision 2817)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Preliminary gust module interface implemented
+! 
+! 2805 2018-02-14 17:00:09Z suehring
 ! Consider also default-type surfaces for surface temperature output. 
 ! 
@@ -229,4 +232,7 @@
     USE grid_variables,                                                        &
         ONLY:  dx, dy
+
+    USE gust_mod,                                                              &
+        ONLY:  gust_data_output_2d, gust_module_enabled
         
     USE indices,                                                               &
@@ -1248,4 +1254,11 @@
                    CALL radiation_data_output_2d( av, do2d(av,if), found, grid,&
                                                   mode, local_pf, two_d  )
+                ENDIF
+
+!
+!--             Gust module quantities
+                IF ( .NOT. found  .AND.  gust_module_enabled )  THEN
+                   CALL gust_data_output_2d( av, do2d(av,if), found, grid,     &
+                                             local_pf, two_d, nzb_do, nzt_do )
                 ENDIF
 
Index: palm/trunk/SOURCE/data_output_3d.f90
===================================================================
--- palm/trunk/SOURCE/data_output_3d.f90	(revision 2815)
+++ palm/trunk/SOURCE/data_output_3d.f90	(revision 2817)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Preliminary gust module interface implemented
+! 
+! 2766 2018-01-22 17:17:47Z kanani
 ! Removed preprocessor directive __chem
 ! 
@@ -203,4 +206,7 @@
     USE cpulog,                                                                &
         ONLY:  log_point, cpu_log
+
+    USE gust_mod,                                                              &
+        ONLY: gust_data_output_3d, gust_module_enabled
         
     USE indices,                                                               &
@@ -680,4 +686,12 @@
 
 !
+!--          Gust module quantities
+             IF ( .NOT. found  .AND.  gust_module_enabled )  THEN
+                CALL gust_data_output_3d( av, do3d(av,if), found, local_pf,    &
+                                          nzb_do, nzt_do )
+                resorted = .TRUE.
+             ENDIF
+
+!
 !--          Chemistry model output
              IF ( .NOT. found  .AND.  air_chemistry )  THEN
Index: palm/trunk/SOURCE/flow_statistics.f90
===================================================================
--- palm/trunk/SOURCE/flow_statistics.f90	(revision 2815)
+++ palm/trunk/SOURCE/flow_statistics.f90	(revision 2817)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Preliminary gust module interface implemented
+! 
+! 2773 2018-01-30 14:12:54Z suehring
 ! Timeseries output of surface temperature.
 ! 
@@ -283,4 +286,7 @@
     USE grid_variables,                                                        &
         ONLY:   ddx, ddy
+
+    USE gust_mod,                                                              &
+        ONLY:  gust_module_enabled, gust_statistics
         
     USE indices,                                                               &
@@ -297,5 +303,5 @@
 
     USE netcdf_interface,                                                      &
-        ONLY:  dots_rad, dots_soil
+        ONLY:  dots_rad, dots_soil, dots_max
 
     USE pegrid
@@ -1742,4 +1748,9 @@
              ENDDO
           ENDDO
+       ENDIF
+!
+!--    Calculate the gust module profiles
+       IF ( gust_module_enabled )  THEN
+          CALL gust_statistics( 'profiles', sr, tn, dots_max )
        ENDIF
 !
@@ -2156,4 +2167,10 @@
 
 !
+!--    Calculate additional statistics provided by the gust module
+       IF ( gust_module_enabled )  THEN
+          CALL gust_statistics( 'time_series', sr, 0, dots_max )
+       ENDIF
+
+!
 !--    Calculate additional statistics provided by the user interface
        CALL user_statistics( 'time_series', sr, 0 )
Index: palm/trunk/SOURCE/gust_mod.f90
===================================================================
--- palm/trunk/SOURCE/gust_mod.f90	(revision 2817)
+++ palm/trunk/SOURCE/gust_mod.f90	(revision 2817)
@@ -0,0 +1,473 @@
+!> @file gust_mod.f90
+!------------------------------------------------------------------------------!
+! This file is part of PALM.
+!
+! PALM is free software: you can redistribute it and/or modify it under the
+! terms of the GNU General Public License as published by the Free Software
+! Foundation, either version 3 of the License, or (at your option) any later
+! version.
+!
+! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
+! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along with
+! PALM. If not, see <http://www.gnu.org/licenses/>.
+!
+! Copyright 1997-2018 Leibniz Universitaet Hannover
+!------------------------------------------------------------------------------!
+!
+! Current revisions:
+! -----------------
+! 
+! 
+! Former revisions:
+! -----------------
+!
+! Initial interface definition
+!
+! 
+!
+! Description:
+! ------------
+!> Gust model.
+!>
+!> @todo This is just a dummy module. The actual module ist not released yet.
+!------------------------------------------------------------------------------!
+ MODULE gust_mod
+
+    USE indices,                                                               &
+        ONLY:  nxl, nxlg, nxr, nxrg, nys, nysg, nyn, nyng, nzb, nzt
+
+    USE kinds
+
+    IMPLICIT NONE
+
+    LOGICAL  ::  gust_module_enabled = .FALSE.       !< switch, if the entire module is used at all
+
+    SAVE
+
+    PRIVATE
+
+!
+!-- Public functions
+    PUBLIC &
+       gust_parin, &
+       gust_check_parameters, &
+       gust_check_data_output_pr, &
+       gust_check_data_output, &
+       gust_init_arrays, &
+       gust_init, &
+       gust_define_netcdf_grid, &
+       gust_header, &
+       gust_actions, &
+       gust_swap_timelevel, &
+       gust_3d_data_averaging, &
+       gust_data_output_2d, &
+       gust_data_output_3d, &
+       gust_statistics, &
+       gust_read_restart_data, &
+       gust_write_restart_data
+!
+!-- Public parameters, constants and initial values
+    PUBLIC &
+       gust_module_enabled
+
+
+    INTERFACE gust_parin
+       MODULE PROCEDURE gust_parin
+    END INTERFACE gust_parin
+
+    INTERFACE gust_check_parameters
+       MODULE PROCEDURE gust_check_parameters
+    END INTERFACE gust_check_parameters
+
+    INTERFACE gust_check_data_output_pr
+       MODULE PROCEDURE gust_check_data_output_pr
+    END INTERFACE gust_check_data_output_pr
+
+    INTERFACE gust_check_data_output
+       MODULE PROCEDURE gust_check_data_output
+    END INTERFACE gust_check_data_output
+
+    INTERFACE gust_init_arrays
+       MODULE PROCEDURE gust_init_arrays
+    END INTERFACE gust_init_arrays
+
+    INTERFACE gust_init
+       MODULE PROCEDURE gust_init
+    END INTERFACE gust_init
+
+    INTERFACE gust_define_netcdf_grid
+       MODULE PROCEDURE gust_define_netcdf_grid
+    END INTERFACE gust_define_netcdf_grid
+
+    INTERFACE gust_header
+       MODULE PROCEDURE gust_header
+    END INTERFACE gust_header
+
+    INTERFACE gust_actions
+       MODULE PROCEDURE gust_actions
+       MODULE PROCEDURE gust_actions_ij
+    END INTERFACE gust_actions
+
+    INTERFACE gust_swap_timelevel
+       MODULE PROCEDURE gust_swap_timelevel
+    END INTERFACE gust_swap_timelevel
+
+    INTERFACE gust_3d_data_averaging
+       MODULE PROCEDURE gust_3d_data_averaging
+    END INTERFACE gust_3d_data_averaging
+
+    INTERFACE gust_data_output_2d
+       MODULE PROCEDURE gust_data_output_2d
+    END INTERFACE gust_data_output_2d
+
+    INTERFACE gust_data_output_3d
+       MODULE PROCEDURE gust_data_output_3d
+    END INTERFACE gust_data_output_3d
+
+    INTERFACE gust_statistics
+       MODULE PROCEDURE gust_statistics
+    END INTERFACE gust_statistics
+
+    INTERFACE gust_read_restart_data
+       MODULE PROCEDURE gust_read_restart_data
+    END INTERFACE gust_read_restart_data
+
+    INTERFACE gust_write_restart_data
+       MODULE PROCEDURE gust_write_restart_data
+    END INTERFACE gust_write_restart_data
+
+ CONTAINS
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Parin for &gust_par for gust module
+!------------------------------------------------------------------------------!
+    SUBROUTINE gust_parin
+
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=80)  ::  line  !< dummy string that contains the current line of the parameter file
+
+       NAMELIST /gust_par/  &
+          gust_module_enabled
+
+       line = ' '
+!
+!--    Try to find gust module package
+       REWIND ( 11 )
+       line = ' '
+       DO   WHILE ( INDEX( line, '&gust_par' ) == 0 )
+          READ ( 11, '(A)', END=10 )  line
+       ENDDO
+       BACKSPACE ( 11 )
+!
+!--    Read user-defined namelist
+       READ ( 11, gust_par )
+!
+!--    Set flag that indicates that the gust module is switched on
+       gust_module_enabled = .TRUE.
+
+10     CONTINUE
+
+
+    END SUBROUTINE gust_parin
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Check parameters routine for gust module
+!------------------------------------------------------------------------------!
+    SUBROUTINE gust_check_parameters
+
+
+       IMPLICIT NONE
+
+
+    END SUBROUTINE gust_check_parameters
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Check data output of profiles for gust module
+!------------------------------------------------------------------------------!
+    SUBROUTINE gust_check_data_output_pr( variable, var_count, unit, dopr_unit )
+
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=*) ::  unit      !<
+       CHARACTER (LEN=*) ::  variable  !<
+       CHARACTER (LEN=*) ::  dopr_unit !< local value of dopr_unit
+
+       INTEGER(iwp) ::  var_count      !<
+
+
+    END SUBROUTINE gust_check_data_output_pr
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Check data output for gust module
+!------------------------------------------------------------------------------!
+    SUBROUTINE gust_check_data_output( var, unit )
+
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=*) ::  unit  !<
+       CHARACTER (LEN=*) ::  var   !<
+
+
+    END SUBROUTINE gust_check_data_output
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Allocate gust module arrays and define pointers
+!------------------------------------------------------------------------------!
+    SUBROUTINE gust_init_arrays
+
+
+       IMPLICIT NONE
+
+
+    END SUBROUTINE gust_init_arrays
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Initialization of the gust module
+!------------------------------------------------------------------------------!
+    SUBROUTINE gust_init( dots_label, dots_unit, dots_num, dots_max )
+
+
+       IMPLICIT NONE
+
+       INTEGER(iwp) ::  dots_num
+       INTEGER(iwp) ::  dots_max
+       CHARACTER (LEN=13), DIMENSION(dots_max) :: dots_unit
+       CHARACTER (LEN=13), DIMENSION(dots_max) :: dots_label
+
+
+    END SUBROUTINE gust_init
+
+
+!------------------------------------------------------------------------------!
+!
+! Description:
+! ------------
+!> Subroutine defining appropriate grid for netcdf variables.
+!> It is called out from subroutine netcdf.
+!------------------------------------------------------------------------------!
+    SUBROUTINE gust_define_netcdf_grid( var, found, grid_x, grid_y, grid_z )
+
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=*), INTENT(IN)  ::  var         !<
+       LOGICAL, INTENT(OUT)           ::  found       !<
+       CHARACTER (LEN=*), INTENT(OUT) ::  grid_x      !<
+       CHARACTER (LEN=*), INTENT(OUT) ::  grid_y      !<
+       CHARACTER (LEN=*), INTENT(OUT) ::  grid_z      !<
+
+
+    END SUBROUTINE gust_define_netcdf_grid
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Header output for gust module
+!------------------------------------------------------------------------------!
+    SUBROUTINE gust_header ( io )
+
+
+       IMPLICIT NONE
+
+       INTEGER(iwp), INTENT(IN) ::  io  !< Unit of the output file
+
+
+    END SUBROUTINE gust_header
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Call for all grid points
+!------------------------------------------------------------------------------!
+    SUBROUTINE gust_actions( location )
+
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=*) ::  location !<
+
+
+    END SUBROUTINE gust_actions
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Call for grid point i,j
+!------------------------------------------------------------------------------!
+    SUBROUTINE gust_actions_ij( i, j, location )
+
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=*) ::  location
+
+       INTEGER(iwp) ::  i
+       INTEGER(iwp) ::  j
+
+
+    END SUBROUTINE gust_actions_ij
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Swapping of timelevels
+!------------------------------------------------------------------------------!
+    SUBROUTINE gust_swap_timelevel ( mod_count )
+
+
+       IMPLICIT NONE
+
+       INTEGER, INTENT(IN) :: mod_count
+
+
+    END SUBROUTINE gust_swap_timelevel
+
+
+!------------------------------------------------------------------------------!
+!
+! Description:
+! ------------
+!> Subroutine for averaging 3D data
+!------------------------------------------------------------------------------!
+    SUBROUTINE gust_3d_data_averaging( mode, variable )
+
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=*) ::  mode    !<
+       CHARACTER (LEN=*) :: variable !<
+
+
+    END SUBROUTINE gust_3d_data_averaging
+
+!------------------------------------------------------------------------------!
+!
+! Description:
+! ------------
+!> Subroutine defining 2D output variables
+!------------------------------------------------------------------------------!
+    SUBROUTINE gust_data_output_2d( av, variable, found, grid, local_pf,       &
+                                    two_d, nzb_do, nzt_do )
+
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=*) ::  grid     !<
+       CHARACTER (LEN=*) ::  variable !<
+
+       INTEGER(iwp) ::  av     !< flag to control data output of instantaneous or time-averaged data
+       INTEGER(iwp) ::  nzb_do !< lower limit of the data output (usually 0)
+       INTEGER(iwp) ::  nzt_do !< vertical upper limit of the data output (usually nz_do3d)
+
+       LOGICAL      ::  found !<
+       LOGICAL      ::  two_d !< flag parameter that indicates 2D variables (horizontal cross sections)
+
+       REAL(wp), DIMENSION(nxl:nxr,nys:nyn,nzb:nzt+1) ::  local_pf !<
+
+
+    END SUBROUTINE gust_data_output_2d
+
+
+!------------------------------------------------------------------------------!
+!
+! Description:
+! ------------
+!> Subroutine defining 3D output variables
+!------------------------------------------------------------------------------!
+    SUBROUTINE gust_data_output_3d( av, variable, found, local_pf, nzb_do, nzt_do )
+
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=*) ::  variable !<
+
+       INTEGER(iwp) ::  av    !<
+       INTEGER(iwp) ::  nzb_do !< lower limit of the data output (usually 0)
+       INTEGER(iwp) ::  nzt_do !< vertical upper limit of the data output (usually nz_do3d)
+
+       LOGICAL      ::  found !<
+
+       REAL(sp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do) ::  local_pf !<
+
+
+    END SUBROUTINE gust_data_output_3d
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> This routine computes profile and timeseries data for the gust module.
+!------------------------------------------------------------------------------!
+    SUBROUTINE gust_statistics( mode, sr, tn, dots_max )
+
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=*) ::  mode   !<
+
+       INTEGER(iwp) ::  sr   !<
+       INTEGER(iwp) ::  tn   !<
+       INTEGER(iwp) ::  dots_max   !<
+
+
+    END SUBROUTINE gust_statistics
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> This routine reads the respective restart data for the gust module.
+!------------------------------------------------------------------------------!
+    SUBROUTINE gust_read_restart_data
+
+
+       IMPLICIT NONE
+
+
+    END SUBROUTINE gust_read_restart_data
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> This routine writes the respective restart data for the gust module.
+!------------------------------------------------------------------------------!
+    SUBROUTINE gust_write_restart_data
+
+
+       IMPLICIT NONE
+
+
+    END SUBROUTINE gust_write_restart_data
+
+
+
+ END MODULE gust_mod
Index: palm/trunk/SOURCE/header.f90
===================================================================
--- palm/trunk/SOURCE/header.f90	(revision 2815)
+++ palm/trunk/SOURCE/header.f90	(revision 2817)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Preliminary gust module interface implemented
+! 
+! 2776 2018-01-31 10:44:42Z Giersch
 ! Variable synthetic_turbulence_generator has been abbreviated
 ! 
@@ -371,4 +374,7 @@
     USE grid_variables,                                                        &
         ONLY:  dx, dy
+
+    USE gust_mod,                                                              &
+        ONLY: gust_header, gust_module_enabled
         
     USE indices,                                                               &
@@ -1023,4 +1029,6 @@
 
     IF ( radiation )  CALL radiation_header ( io )
+
+    IF ( gust_module_enabled )  CALL gust_header ( io )
 
 !
Index: palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- palm/trunk/SOURCE/init_3d_model.f90	(revision 2815)
+++ palm/trunk/SOURCE/init_3d_model.f90	(revision 2817)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Preliminary gust module interface implemented
+! 
+! 2776 2018-01-31 10:44:42Z Giersch
 ! Variable use_synthetic_turbulence_generator has been abbreviated
 ! 
@@ -433,4 +436,7 @@
     USE grid_variables,                                                        &
         ONLY:  dx, dy, ddx2_mg, ddy2_mg
+
+    USE gust_mod,                                                              &
+        ONLY:  gust_init, gust_init_arrays, gust_module_enabled
     
     USE indices
@@ -455,5 +461,5 @@
 
     USE netcdf_interface,                                                      &
-        ONLY:  dots_max, dots_num
+        ONLY:  dots_max, dots_num, dots_unit, dots_label
 
     USE netcdf_data_input_mod,                                                  &
@@ -1029,5 +1035,10 @@
        CALL wtm_init_arrays
     ENDIF
-    
+!
+!-- Allocate gust module arrays
+    IF ( gust_module_enabled )  THEN
+       CALL gust_init_arrays
+    ENDIF
+
 !
 !-- Initialize virtual flight measurements
@@ -2377,4 +2388,9 @@
     ENDIF
 
+!
+!-- If required, initialize quantities needed for the gust module
+    IF ( gust_module_enabled )  THEN
+       CALL gust_init( dots_label, dots_unit, dots_num, dots_max )
+    ENDIF
 
 !
Index: palm/trunk/SOURCE/netcdf_interface_mod.f90
===================================================================
--- palm/trunk/SOURCE/netcdf_interface_mod.f90	(revision 2815)
+++ palm/trunk/SOURCE/netcdf_interface_mod.f90	(revision 2817)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Preliminary gust module interface implemented
+! 
+! 2769 2018-01-25 09:22:24Z raasch
 ! bugfix for calculating number of required output time levels in case of output
 ! at the beginning of a restart run
@@ -514,4 +517,7 @@
         ONLY:  dx, dy, zu_s_inner, zw_w_inner
 
+    USE gust_mod,                                                              &
+        ONLY: gust_define_netcdf_grid, gust_module_enabled
+
     USE indices,                                                               &
         ONLY:  nx, nxl, nxr, ny, nys, nyn, nz ,nzb, nzt
@@ -934,4 +940,11 @@
 
 !
+!--                Check for gust module quantities
+                   IF ( .NOT. found  .AND.  gust_module_enabled )  THEN
+                      CALL gust_define_netcdf_grid( domask(mid,av,i), found,   &
+                                                    grid_x, grid_y, grid_z )
+                   ENDIF
+
+!
 !--                Check for chemistry quantities                   
                    IF ( .NOT. found  .AND.  air_chemistry )  THEN
@@ -1473,4 +1486,10 @@
                                                          grid_x, grid_y,       &
                                                          grid_z )
+                   ENDIF
+
+!--                Check for gust module quantities
+                   IF ( .NOT. found  .AND.  gust_module_enabled )  THEN
+                      CALL gust_define_netcdf_grid( do3d(av,i), found, grid_x, &
+                                                    grid_y, grid_z )
                    ENDIF
 
@@ -2128,4 +2147,12 @@
                                                          found, grid_x, grid_y,&
                                                          grid_z )
+                         ENDIF
+
+!
+!--                      Check for gust module quantities
+                         IF ( .NOT. found  .AND.  gust_module_enabled )  THEN
+                            CALL gust_define_netcdf_grid( do2d(av,i), found,   &
+                                                          grid_x, grid_y,      &
+                                                          grid_z )
                          ENDIF
 
@@ -2851,4 +2878,11 @@
 
 !
+!--                   Check for gust module quantities
+                      IF ( .NOT. found  .AND.  gust_module_enabled )  THEN
+                         CALL gust_define_netcdf_grid( do2d(av,i), found,      &
+                                                       grid_x, grid_y, grid_z )
+                      ENDIF
+
+!
 !--                   Check for chemistry quantities
                       IF ( .NOT. found  .AND.  air_chemistry )  THEN
@@ -3520,4 +3554,11 @@
 
 !
+!--                   Check for gust module quantities
+                      IF ( .NOT. found  .AND.  gust_module_enabled )  THEN
+                         CALL gust_define_netcdf_grid( do2d(av,i), found,      &
+                                                       grid_x, grid_y, grid_z )
+                      ENDIF
+
+!
 !--                   Check for chemistry quantities
                       IF ( .NOT. found  .AND.  air_chemistry )  THEN
Index: palm/trunk/SOURCE/parin.f90
===================================================================
--- palm/trunk/SOURCE/parin.f90	(revision 2815)
+++ palm/trunk/SOURCE/parin.f90	(revision 2817)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Preliminary gust module interface implemented
+! 
+! 2773 2018-01-30 14:12:54Z suehring
 ! Nesting for chemical species implemented
 ! 
@@ -357,4 +360,7 @@
     USE grid_variables,                                                        &
         ONLY:  dx, dy
+
+    USE gust_mod,                                                              &
+        ONLY: gust_parin
 
     USE indices,                                                               &
@@ -724,4 +730,8 @@
 !--       Check if radiation model is used and read &radiation_par if required
           CALL radiation_parin
+
+!
+!--       Check if gust module is used and read &gust_par if required
+          CALL gust_parin
  
  
Index: palm/trunk/SOURCE/read_3d_binary.f90
===================================================================
--- palm/trunk/SOURCE/read_3d_binary.f90	(revision 2815)
+++ palm/trunk/SOURCE/read_3d_binary.f90	(revision 2817)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Preliminary gust module interface implemented
+! 
+! 2797 2018-02-08 13:24:35Z suehring
 ! Enable restarts for land- and urban-surface variables ghf_av, r_a_av and 
 ! tsurf_av.
@@ -171,4 +174,7 @@
     USE cpulog,                                                                &
         ONLY:  cpu_log, log_point_s
+
+    USE gust_mod,                                                              &
+        ONLY :  gust_module_enabled, gust_read_restart_data
 
     USE indices,                                                               &
@@ -1105,4 +1111,10 @@
 
        ENDDO  ! loop over variables
+
+!
+!--    Read gust model restart data
+       IF ( gust_module_enabled )  THEN
+          CALL gust_read_restart_data
+       ENDIF
 !
 !--    Read surface related variables
Index: palm/trunk/SOURCE/sum_up_3d_data.f90
===================================================================
--- palm/trunk/SOURCE/sum_up_3d_data.f90	(revision 2815)
+++ palm/trunk/SOURCE/sum_up_3d_data.f90	(revision 2817)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Preliminary gust module interface implemented
+! 
+! 2798 2018-02-09 17:16:39Z suehring
 ! Consider also default-type surfaces for surface temperature output. 
 ! 
@@ -199,4 +202,7 @@
         ONLY:  cpu_log, log_point
 
+    USE gust_mod,                                                              &
+        ONLY:  gust_3d_data_averaging, gust_module_enabled
+
     USE indices,                                                               &
         ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt 
@@ -512,4 +518,10 @@
                 IF ( radiation )  THEN
                    CALL radiation_3d_data_averaging( 'allocate', doav(ii) )
+                ENDIF
+
+!
+!--             Gust module quantities
+                IF ( gust_module_enabled )  THEN
+                   CALL gust_3d_data_averaging( 'allocate', doav(ii) )
                 ENDIF
 
@@ -1064,4 +1076,10 @@
 
 !
+!--          Gust module quantities
+             IF ( gust_module_enabled )  THEN
+                CALL gust_3d_data_averaging( 'sum', doav(ii) )
+             ENDIF
+
+!
 !--          Chemical quantity
              IF ( air_chemistry  .AND.  trimvar(1:3) == 'kc_')  THEN
Index: palm/trunk/SOURCE/swap_timelevel.f90
===================================================================
--- palm/trunk/SOURCE/swap_timelevel.f90	(revision 2815)
+++ palm/trunk/SOURCE/swap_timelevel.f90	(revision 2817)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Preliminary gust module interface implemented
+! 
+! 2766 2018-01-22 17:17:47Z kanani
 ! Removed preprocessor directive __chem
 ! 
@@ -148,4 +151,7 @@
                passive_scalar, timestep_count, urban_surface
 
+    USE gust_mod,                                                              &
+        ONLY: gust_module_enabled, gust_swap_timelevel
+
     USE indices,                                                               &
         ONLY:  nxlg, nxrg, nyng, nysg, nzb, nzt
@@ -214,4 +220,8 @@
     ENDIF
 
+    IF ( gust_module_enabled )  THEN
+       CALL gust_swap_timelevel ( 0 )
+    ENDIF
+
 
     CALL cpu_log( log_point(28), 'swap_timelevel (nop)', 'stop' )
@@ -293,4 +303,8 @@
     ENDIF
 
+    IF ( gust_module_enabled )  THEN
+       CALL gust_swap_timelevel ( MOD( timestep_count, 2) )
+    ENDIF
+
 !
 !-- Set the swap level for steering the pmc data transfer
Index: palm/trunk/SOURCE/time_integration.f90
===================================================================
--- palm/trunk/SOURCE/time_integration.f90	(revision 2815)
+++ palm/trunk/SOURCE/time_integration.f90	(revision 2817)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Preliminary gust module interface implemented
+! 
+! 2801 2018-02-14 16:01:55Z thiele
 ! Changed lpm from subroutine to module.
 ! Introduce particle transfer in nested models.
@@ -375,4 +378,6 @@
         ONLY:  flight_measurement
 
+    USE gust_mod,                                                              &
+        ONLY:  gust_actions, gust_module_enabled
 
     USE indices,                                                               &
@@ -559,4 +564,10 @@
           IF ( force%time(force%tind_p) <= simulated_time )                    &
              CALL netcdf_data_input_lsf
+       ENDIF
+
+!
+!--    Execute the gust module actions
+       IF ( gust_module_enabled )  THEN
+          CALL gust_actions( 'before_timestep' )
        ENDIF
 
@@ -1100,4 +1111,10 @@
 
 !
+!--    Execute the gust module actions
+       IF ( gust_module_enabled )  THEN
+          CALL gust_actions( 'after_integration' )
+       ENDIF
+
+!
 !--    Execute user-defined actions
        CALL user_actions( 'after_integration' )
@@ -1287,4 +1304,10 @@
 
 !
+!--    Execute the gust module actions
+       IF ( gust_module_enabled )  THEN
+          CALL gust_actions( 'after_timestep' )
+       ENDIF
+
+!
 !--    Execute user-defined actions
        CALL user_actions( 'after_timestep' )
Index: palm/trunk/SOURCE/write_3d_binary.f90
===================================================================
--- palm/trunk/SOURCE/write_3d_binary.f90	(revision 2815)
+++ palm/trunk/SOURCE/write_3d_binary.f90	(revision 2817)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Preliminary gust module interface implemented
+! 
+! 2798 2018-02-09 17:16:39Z suehring
 ! Consider also default-type surfaces for surface temperature output. 
 ! 
@@ -145,5 +148,8 @@
                land_surface, microphysics_morrison, microphysics_seifert,      &
                ocean, passive_scalar, topography, urban_surface
-                
+
+    USE gust_mod,                                                              &
+        ONLY :  gust_module_enabled, gust_write_restart_data
+
     USE indices,                                                               &
         ONLY:  nxl, nxr, nys, nyn, nzb, nzt
@@ -402,4 +408,8 @@
     WRITE ( 14 )  '*** end ***         '
 
+    IF ( gust_module_enabled )  THEN
+       CALL gust_write_restart_data
+    ENDIF
+
     CALL surface_write_restart_data
 
