Index: palm/trunk/SOURCE/advec_s_bc.f90
===================================================================
--- palm/trunk/SOURCE/advec_s_bc.f90	(revision 4426)
+++ palm/trunk/SOURCE/advec_s_bc.f90	(revision 4429)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! bugfix: cpp-directives added for serial mode
+! 
+! 4360 2020-01-07 11:25:50Z suehring
 ! Corrected "Former revisions" section
 ! 
@@ -104,7 +107,9 @@
        INTEGER(iwp) ::  j         !<
        INTEGER(iwp) ::  k         !<
+       INTEGER(iwp) ::  sr        !<
+#if defined( __parallel )
        INTEGER(iwp) ::  ngp       !<
-       INTEGER(iwp) ::  sr        !<
        INTEGER(iwp) ::  type_xz_2 !<
+#endif
 
        REAL(wp) ::  cim    !<
Index: palm/trunk/SOURCE/cpulog_mod.f90
===================================================================
--- palm/trunk/SOURCE/cpulog_mod.f90	(revision 4426)
+++ palm/trunk/SOURCE/cpulog_mod.f90	(revision 4429)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! bugfix: cpp-directives added for serial mode
+! 
+! 4378 2020-01-16 13:22:48Z Giersch
 ! Format of rms output changed to allow values >= 100
 ! 
@@ -263,6 +266,8 @@
        INTEGER(iwp)    ::  i               !< 
        INTEGER(iwp)    ::  ii(1)           !< 
+#if defined( __parallel )
        INTEGER(iwp)    ::  iii             !< 
-       INTEGER(iwp)    ::  sender          !< 
+       INTEGER(iwp)    ::  sender          !<
+#endif
        REAL(dp)       ::  average_cputime  !<
        REAL(dp), SAVE ::  norm = 1.0_dp    !<
Index: palm/trunk/SOURCE/data_output_netcdf4_module.f90
===================================================================
--- palm/trunk/SOURCE/data_output_netcdf4_module.f90	(revision 4426)
+++ palm/trunk/SOURCE/data_output_netcdf4_module.f90	(revision 4429)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! bugfix: cpp-directive moved to avoid compile error due to unused dummy argument
+! 
+! 4408 2020-02-14 10:04:39Z gronemeier
 ! Enable character-array output
 !
@@ -427,8 +430,8 @@
        nc_stat = NF90_DEF_VAR( file_id, variable_name, nc_variable_type, dimension_ids, variable_id )
 
-#if defined( __netcdf4_parallel )
 !
 !--    Define how variable can be accessed by PEs in parallel netcdf file
        IF ( nc_stat == NF90_NOERR  .AND.  TRIM( mode ) == mode_parallel )  THEN
+#if defined( __netcdf4_parallel )
           IF ( is_global )  THEN
              nc_stat = NF90_VAR_PAR_ACCESS( file_id, variable_id, NF90_INDEPENDENT )
@@ -436,6 +439,8 @@
              nc_stat = NF90_VAR_PAR_ACCESS( file_id, variable_id, NF90_COLLECTIVE )
           ENDIF
+#else
+          CONTINUE
+#endif
        ENDIF
-#endif
 
        IF ( nc_stat /= NF90_NOERR )  THEN
Index: palm/trunk/SOURCE/exchange_horiz.f90
===================================================================
--- palm/trunk/SOURCE/exchange_horiz.f90	(revision 4426)
+++ palm/trunk/SOURCE/exchange_horiz.f90	(revision 4429)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! bugfix: cpp-directives added for serial mode
+! 
+! 4360 2020-01-07 11:25:50Z suehring
 ! Corrected "Former revisions" section
 ! 
@@ -46,5 +49,10 @@
 
     USE control_parameters,                                                    &
-        ONLY:  bc_lr_cyc, bc_ns_cyc, grid_level, mg_switch_to_pe0, synchronous_exchange
+        ONLY:  bc_lr_cyc, bc_ns_cyc
+
+#if defined( __parallel )
+    USE control_parameters,                                                    &
+        ONLY:  grid_level, mg_switch_to_pe0, synchronous_exchange
+#endif
                 
     USE cpulog,                                                                &
@@ -272,8 +280,14 @@
 !> @todo Missing subroutine description.
 !------------------------------------------------------------------------------!
- SUBROUTINE exchange_horiz_int( ar, nys_l, nyn_l, nxl_l, nxr_l, nzt_l, nbgp_local)
+ SUBROUTINE exchange_horiz_int( ar, nys_l, nyn_l, nxl_l, nxr_l, nzt_l, nbgp_local )
+
 
     USE control_parameters,                                                    &
-        ONLY:  bc_lr_cyc, bc_ns_cyc, grid_level
+        ONLY:  bc_lr_cyc, bc_ns_cyc
+
+#if defined( __parallel )
+    USE control_parameters,                                                    &
+        ONLY:  grid_level
+#endif
                        
     USE indices,                                                               &
Index: palm/trunk/SOURCE/global_min_max.f90
===================================================================
--- palm/trunk/SOURCE/global_min_max.f90	(revision 4426)
+++ palm/trunk/SOURCE/global_min_max.f90	(revision 4429)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! bugfix: cpp-directives added for serial mode
+! 
+! 4360 2020-01-07 11:25:50Z suehring
 ! OpenACC support added
 ! 
@@ -59,6 +62,8 @@
     INTEGER(iwp) ::  i1             !<
     INTEGER(iwp) ::  i2             !<
+#if defined( __parallel )
     INTEGER(iwp) ::  id_fmax        !<
     INTEGER(iwp) ::  id_fmin        !<
+#endif
     INTEGER(iwp) ::  j              !<
     INTEGER(iwp) ::  j1             !<
Index: palm/trunk/SOURCE/inflow_turbulence.f90
===================================================================
--- palm/trunk/SOURCE/inflow_turbulence.f90	(revision 4426)
+++ palm/trunk/SOURCE/inflow_turbulence.f90	(revision 4429)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! bugfix: cpp-directives added for serial mode
+! 
+! 4360 2020-01-07 11:25:50Z suehring
 ! use y_shift instead of old parameter recycling_yshift
 ! 
@@ -57,7 +60,13 @@
         ONLY:  e, inflow_damping_factor, mean_inflow_profiles, pt, q, s, u, v, w
         
+#if defined( __parallel )
     USE control_parameters,                                                    &
-        ONLY:  humidity, passive_scalar, recycling_plane, y_shift,    &
+        ONLY:  humidity, passive_scalar, recycling_plane, y_shift,             &
                recycling_method_for_thermodynamic_quantities
+#else
+    USE control_parameters,                                                    &
+        ONLY:  humidity, passive_scalar, recycling_plane,                      &
+               recycling_method_for_thermodynamic_quantities
+#endif
         
     USE cpulog,                                                                &
@@ -78,8 +87,10 @@
     INTEGER(iwp) ::  k        !< loop index
     INTEGER(iwp) ::  l        !< loop index
-    INTEGER(iwp) ::  next     !< ID of receiving PE for y-shift
     INTEGER(iwp) ::  ngp_ifd  !< number of grid points stored in avpr
     INTEGER(iwp) ::  ngp_pr   !< number of grid points stored in inflow_dist
+#if defined( __parallel )
+    INTEGER(iwp) ::  next     !< ID of receiving PE for y-shift
     INTEGER(iwp) ::  prev     !< ID of sending PE for y-shift
+#endif
 
     REAL(wp), DIMENSION(nzb:nzt+1,7,nbgp)           ::                         &
@@ -89,6 +100,8 @@
     REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,7,nbgp) ::                         &
        inflow_dist        !< turbulence signal of vars, added at inflow boundary
+#if defined( __parallel )
     REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,7,nbgp) ::                         &
        local_inflow_dist  !< auxiliary variable for inflow_dist, used for y-shift
+#endif
     
     CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' )
Index: palm/trunk/SOURCE/land_surface_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 4426)
+++ palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 4429)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! bugfix: missing cpp-directives for serial mode added, misplaced cpp-directives moved
+! 
+! 4381 2020-01-20 13:51:46Z suehring
 ! - Bugfix in nested soil initialization in case no dynamic input file is 
 !   present
@@ -2332,6 +2335,8 @@
            ONLY:  nx, ny, topo_min_level
 
+#if defined( __parallel )
        USE pmc_handle_communicator,                                            &
         ONLY:  pmc_is_rootmodel
+#endif
            
        USE pmc_interface,                                                      &
@@ -4447,6 +4452,6 @@
                 DEALLOCATE( t_soil_root )
              ENDIF
-          ENDIF
 #endif
+          ENDIF
 !
 !--       Proceed with Level 2 initialization. 
Index: palm/trunk/SOURCE/poisfft_mod.f90
===================================================================
--- palm/trunk/SOURCE/poisfft_mod.f90	(revision 4426)
+++ palm/trunk/SOURCE/poisfft_mod.f90	(revision 4429)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Statements added to avoid compile errors due to unused dummy arguments in serial mode
+! 
+! 4366 2020-01-09 08:12:43Z raasch
 ! modification concerning NEC vectorizatio
 ! 
@@ -780,4 +783,8 @@
                           comm1dx, ierr )
        CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'stop' )
+#else
+!
+!--    Next line required to avoid compile error about unused dummy argument in serial mode
+       i = SIZE( f_out )
 #endif
 
@@ -830,4 +837,8 @@
                           comm1dx, ierr )
        CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'stop' )
+#else
+!
+!--    Next line required to avoid compile error about unused dummy argument in serial mode
+       i = SIZE( f_in )
 #endif
 
@@ -1172,4 +1183,8 @@
                           comm1dy, ierr )
        CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'stop' )
+#else
+!
+!--    Next line required to avoid compile error about unused dummy argument in serial mode
+       i = SIZE( f_out )
 #endif
 
@@ -1206,4 +1221,5 @@
        REAL(wp), DIMENSION(1:nz,nys:nyn,0:nx)             ::  f_out      !<
        REAL(wp), DIMENSION(nys:nyn,1:nz,0:nx)             ::  work       !<
+
 
 !
@@ -1216,4 +1232,8 @@
                           comm1dy, ierr )
        CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'stop' )
+#else
+!
+!--    Next line required to avoid compile error about unused dummy argument in serial mode
+       i = SIZE( f_in )
 #endif
 
Index: palm/trunk/SOURCE/poismg_mod.f90
===================================================================
--- palm/trunk/SOURCE/poismg_mod.f90	(revision 4426)
+++ palm/trunk/SOURCE/poismg_mod.f90	(revision 4429)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! statement added to avoid compile error due to unused dummy argument
+! bugfix: cpp-directives added for serial mode
+! 
+! 4360 2020-01-07 11:25:50Z suehring
 ! Corrected "Former revisions" section
 ! 
@@ -1210,4 +1214,5 @@
 !> Gather subdomain data from all PEs.
 !------------------------------------------------------------------------------!
+#if defined( __parallel )
     SUBROUTINE mg_gather( f2, f2_sub )
 
@@ -1244,5 +1249,4 @@
 
 
-#if defined( __parallel )
        CALL cpu_log( log_point_s(34), 'mg_gather', 'start' )
 
@@ -1279,8 +1283,7 @@
 
        CALL cpu_log( log_point_s(34), 'mg_gather', 'stop' )
-#endif
     
     END SUBROUTINE mg_gather
-
+#endif
 
 
@@ -1291,4 +1294,5 @@
 !>       non-blocking communication
 !------------------------------------------------------------------------------!
+#if defined( __parallel )
     SUBROUTINE mg_scatter( p2, p2_sub )
 
@@ -1303,6 +1307,4 @@
 
        IMPLICIT NONE
-
-       INTEGER(iwp) ::  nwords  !<
 
        REAL(wp), DIMENSION(nzb:nzt_mg(grid_level-1)+1,                         &
@@ -1314,9 +1316,5 @@
                            mg_loc_ind(1,myid)-1:mg_loc_ind(2,myid)+1) ::  p2_sub  !<
 
-!
-!--    Find out the number of array elements of the subdomain array
-       nwords = SIZE( p2_sub )
-
-#if defined( __parallel )
+
        CALL cpu_log( log_point_s(35), 'mg_scatter', 'start' )
 
@@ -1325,8 +1323,7 @@
 
        CALL cpu_log( log_point_s(35), 'mg_scatter', 'stop' )
-#endif
     
     END SUBROUTINE mg_scatter
-
+#endif
 
 !------------------------------------------------------------------------------!
@@ -1383,5 +1380,8 @@
 
        REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  f2_sub  !<
+
+#if defined( __parallel )
        REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  p2_sub  !<
+#endif
 
 !
@@ -1472,5 +1472,7 @@
 !
 !--          Gather all arrays from the subdomains on PE0
+#if defined( __parallel )
              CALL mg_gather( f2, f2_sub )
+#endif
 
 !
@@ -1760,9 +1762,18 @@
 
        USE control_parameters,                                                 &
-           ONLY:  grid_level, mg_switch_to_pe0_level, synchronous_exchange
+           ONLY:  grid_level
+
+#if defined( __parallel )
+       USE control_parameters,                                                 &
+           ONLY:  mg_switch_to_pe0_level, synchronous_exchange
+#endif
 
        USE indices,                                                            &
-           ONLY:  nxl, nxl_mg, nxr, nxr_mg, nys, nys_mg, nyn,      &
-                  nyn_mg, nzb, nzt, nzt_mg
+           ONLY:  nxl_mg, nxr_mg, nys_mg, nyn_mg, nzb, nzt_mg
+
+#if defined( __parallel )
+       USE indices,                                                            &
+           ONLY:  nxl, nxr, nys, nyn, nzt
+#endif
 
        IMPLICIT NONE
@@ -1773,5 +1784,7 @@
                                     p_mg   !< treated array
 
-       INTEGER(iwp), intent(IN) ::  color  !< flag for grid point type (red or black)
+       INTEGER(iwp), INTENT(IN) ::  color  !< flag for grid point type (red or black)
+
+#if defined ( __parallel )
 !
 !--    Local variables
@@ -1794,5 +1807,4 @@
        REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  temp  !< temporary array on next coarser grid level
 
-#if defined ( __parallel )
        synchronous_exchange_save   = synchronous_exchange
        synchronous_exchange        = .FALSE.
@@ -2261,5 +2273,6 @@
 
                 IF ( i == nxl_mg(l) )  THEN
-                   !DIR$ IVDEP
+                   !DIR$ IVDEP       INTEGER(iwp) ::  ngp       !<
+
                    DO  k = nzb+1, ind_even_odd
                       p_mg(k,j,nxr_mg(l)+1)  = temp(k,j1,ixr+1)
@@ -2299,4 +2312,7 @@
 
 !
+!--    Next line is to avoid compile error due to unused dummy argument
+       IF ( color == 1234567 )  RETURN
+!
 !--    Standard horizontal ghost boundary exchange for small coarse grid
 !--    levels, where the transfer time is latency bound
Index: palm/trunk/SOURCE/poismg_noopt_mod.f90
===================================================================
--- palm/trunk/SOURCE/poismg_noopt_mod.f90	(revision 4426)
+++ palm/trunk/SOURCE/poismg_noopt_mod.f90	(revision 4429)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! bugfix: cpp-directives added for serial mode
+! 
+! 4414 2020-02-19 20:16:04Z suehring
 ! Remove double-declared use only construct.
 ! 
@@ -1172,4 +1175,5 @@
 !> Gather subdomain data from all PEs.
 !------------------------------------------------------------------------------!
+#if defined( __parallel )
     SUBROUTINE mg_gather_noopt( f2, f2_sub )
 
@@ -1207,5 +1211,4 @@
 
 
-#if defined( __parallel )
        CALL cpu_log( log_point_s(34), 'mg_gather_noopt', 'start' )
 
@@ -1242,8 +1245,7 @@
 
        CALL cpu_log( log_point_s(34), 'mg_gather_noopt', 'stop' )
-#endif
        
     END SUBROUTINE mg_gather_noopt
-
+#endif
 
 
@@ -1254,4 +1256,5 @@
 !>       non-blocking communication
 !------------------------------------------------------------------------------!
+#if defined( __parallel )
     SUBROUTINE mg_scatter_noopt( p2, p2_sub )
 
@@ -1267,6 +1270,4 @@
 
        IMPLICIT NONE
-
-       INTEGER(iwp) ::  nwords  !<
 
        REAL(wp), DIMENSION(nzb:nzt_mg(grid_level-1)+1,                         &
@@ -1278,9 +1279,5 @@
                            mg_loc_ind(1,myid)-1:mg_loc_ind(2,myid)+1) ::  p2_sub  !<
 
-!
-!--    Find out the number of array elements of the subdomain array
-       nwords = SIZE( p2_sub )
-
-#if defined( __parallel )
+
        CALL cpu_log( log_point_s(35), 'mg_scatter_noopt', 'start' )
 
@@ -1289,7 +1286,7 @@
 
        CALL cpu_log( log_point_s(35), 'mg_scatter_noopt', 'stop' )
-#endif
        
     END SUBROUTINE mg_scatter_noopt
+#endif
 
 
@@ -1352,5 +1349,8 @@
 
        REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  f2_sub  !<
+
+#if defined( __parallel )
        REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  p2_sub  !<
+#endif
 
 !
@@ -1437,5 +1437,7 @@
 !
 !--          Gather all arrays from the subdomains on PE0
+#if defined( __parallel )
              CALL mg_gather_noopt( f2, f2_sub )
+#endif
 
 !
Index: palm/trunk/SOURCE/radiation_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/radiation_model_mod.f90	(revision 4426)
+++ palm/trunk/SOURCE/radiation_model_mod.f90	(revision 4429)
@@ -28,4 +28,7 @@
 ! -----------------
 ! $Id$
+! bugfixes: cpp-directives for serial mode moved, small changes to get serial mode compiled
+! 
+! 4400 2020-02-10 20:32:41Z suehring
 ! Initialize radiation arrays with zero
 ! 
@@ -795,5 +798,7 @@
     REAL(wp), DIMENSION(:,:), ALLOCATABLE          ::  csf              !< array of plant canopy sink fators + direct irradiation factors (transparency)
     REAL(wp), DIMENSION(:,:,:), POINTER            ::  sub_lad          !< subset of lad_s within urban surface, transformed to plain Z coordinate
+#if defined( __parallel )
     REAL(wp), DIMENSION(:), POINTER                ::  sub_lad_g        !< sub_lad globalized (used to avoid MPI RMA calls in raytracing)
+#endif
     REAL(wp)                                       ::  prototype_lad    !< prototype leaf area density for computing effective optical depth
     INTEGER(iwp), DIMENSION(:), ALLOCATABLE        ::  nzterr, plantt   !< temporary global arrays for raytracing
@@ -831,6 +836,6 @@
     INTEGER(iwp)                                   ::  win_lad          !< MPI RMA window for leaf area density
     INTEGER(iwp)                                   ::  win_gridsurf     !< MPI RMA window for reverse grid surface index
+    REAL(wp), DIMENSION(:), ALLOCATABLE            ::  lad_s_ray        !< array of received lad_s for appropriate gridboxes crossed by ray
 #endif
-    REAL(wp), DIMENSION(:), ALLOCATABLE            ::  lad_s_ray        !< array of received lad_s for appropriate gridboxes crossed by ray
     INTEGER(iwp), DIMENSION(:), ALLOCATABLE        ::  target_surfl
     INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE      ::  rt2_track
@@ -1495,4 +1500,5 @@
 !
 !--    Parallel rad_angular_discretization without raytrace_mpi_rma is not implemented
+!--    Serial mode does not allow mpi_rma
 #if defined( __parallel )      
        IF ( rad_angular_discretization  .AND.  .NOT. raytrace_mpi_rma )  THEN
@@ -1500,5 +1506,10 @@
                            'together with raytrace_mpi_rma or when ' //  &
                            'no parallelization is applied.'
-          CALL message( 'check_parameters', 'PA0486', 1, 2, 0, 6, 0 )
+          CALL message( 'readiation_check_parameters', 'PA0486', 1, 2, 0, 6, 0 )
+       ENDIF
+#else
+       IF ( raytrace_mpi_rma )  THEN
+          message_string = 'raytrace_mpi_rma = .T. not allowed in serial mode'
+          CALL message( 'readiation_check_parameters', 'PA0710', 1, 2, 0, 6, 0 )
        ENDIF
 #endif
@@ -7370,6 +7381,4 @@
 
         INTEGER(iwp)                                  :: udim
-        INTEGER(iwp), DIMENSION(:), ALLOCATABLE,TARGET:: nzterrl_l
-        INTEGER(iwp), DIMENSION(:,:), POINTER         :: nzterrl
         REAL(wp),     DIMENSION(:), ALLOCATABLE,TARGET:: csflt_l, pcsflt_l
         REAL(wp),     DIMENSION(:,:), POINTER         :: csflt, pcsflt
@@ -7385,8 +7394,10 @@
         INTEGER(idp)                                  :: ray_skip_maxdist, ray_skip_minval !< skipped raytracing counts
         INTEGER(iwp)                                  :: max_track_len !< maximum 2d track length
+#if defined( __parallel )
+        INTEGER(iwp), DIMENSION(:), ALLOCATABLE,TARGET:: nzterrl_l
+        INTEGER(iwp), DIMENSION(:,:), POINTER         :: nzterrl
         INTEGER(iwp)                                  :: minfo
         REAL(wp), DIMENSION(:), POINTER, SAVE         :: lad_s_rma       !< fortran 1D pointer
         TYPE(c_ptr)                                   :: lad_s_rma_p     !< allocated c pointer
-#if defined( __parallel )
         INTEGER(kind=MPI_ADDRESS_KIND)                :: size_lad_rma
 #endif
@@ -8624,5 +8635,4 @@
       INTEGER(iwp)                           ::  ip           !< number of processor where gridbox reside
       INTEGER(iwp)                           ::  ig           !< 1D index of gridbox in global 2D array
-      INTEGER(iwp)                           ::  wcount       !< RMA window item count
       INTEGER(iwp)                           ::  maxboxes     !< max no of CSF created
       INTEGER(iwp)                           ::  nly          !< maximum  plant canopy height 
@@ -8634,9 +8644,10 @@
       INTEGER(iwp)                           ::  iz
       INTEGER(iwp)                           ::  zsgn
-      INTEGER(iwp)                           ::  lowest_lad   !< lowest column cell for which we need LAD
       INTEGER(iwp)                           ::  lastdir      !< wall direction before hitting this column
       INTEGER(iwp), DIMENSION(2)             ::  lastcolumn
 
 #if defined( __parallel )
+      INTEGER(iwp)                           ::  lowest_lad   !< lowest column cell for which we need LAD
+      INTEGER(iwp)                           ::  wcount       !< RMA window item count
       INTEGER(MPI_ADDRESS_KIND)              ::  wdisp        !< RMA window displacement
 #endif
@@ -9055,9 +9066,8 @@
          INTEGER(iwp), INTENT(out)           ::  iproc
 #if defined( __parallel )
-#else
-         INTEGER(iwp)                        ::  target_displ  !< index of the grid in the local gridsurf array
-#endif
          INTEGER(iwp)                        ::  px, py        !< number of processors in x and y direction
                                                                !< before the processor in the question
+#endif
+
 #if defined( __parallel )
          INTEGER(KIND=MPI_ADDRESS_KIND)      ::  target_displ  !< index of the grid in the local gridsurf array
@@ -9082,4 +9092,5 @@
 !--      set index target_surfl(i)
          isurfl = gridsurf(d,z,y,x)
+         iproc  = 0  ! required to avoid compile error about unused variable in serial mode
 #endif
 
Index: palm/trunk/SOURCE/spectra_mod.f90
===================================================================
--- palm/trunk/SOURCE/spectra_mod.f90	(revision 4426)
+++ palm/trunk/SOURCE/spectra_mod.f90	(revision 4429)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! bugfix: preprocessor directives rearranged for serial mode
+! 
+! 4360 2020-01-07 11:25:50Z suehring
 ! Corrected "Former revisions" section
 ! 
@@ -81,4 +84,5 @@
     END INTERFACE preprocess_spectra
 
+#if defined( __parallel )
     INTERFACE calc_spectra_x
        MODULE PROCEDURE calc_spectra_x
@@ -88,4 +92,5 @@
        MODULE PROCEDURE calc_spectra_y
     END INTERFACE calc_spectra_y
+#endif
 
     INTERFACE spectra_check_parameters
@@ -345,5 +350,9 @@
 
        USE arrays_3d,                                                          &
-           ONLY:  d, tend
+           ONLY:  d
+#if defined( __parallel )
+       USE arrays_3d,                                                          &
+           ONLY:  tend
+#endif
 
        USE control_parameters,                                                 &
@@ -362,5 +371,9 @@
 
        USE pegrid,                                                             &
-           ONLY:  myid, pdims
+           ONLY:  myid
+#if defined( __parallel )
+       USE pegrid,                                                             &
+           ONLY:  pdims
+#endif
 
        IMPLICIT NONE
@@ -489,8 +502,8 @@
        USE MPI
 #endif
-#endif
 
        USE pegrid,                                                             &
            ONLY:  collective_wait, comm2d, ierr
+#endif
 
        USE statistics,                                                         &
@@ -583,4 +596,5 @@
 !> @todo Missing subroutine description.
 !------------------------------------------------------------------------------!
+#if defined( __parallel )
     SUBROUTINE calc_spectra_x( ddd, m )
 
@@ -596,9 +610,7 @@
        USE kinds
 
-#if defined( __parallel )
 #if !defined( __mpifh )
        USE MPI
 #endif
-#endif
 
        USE pegrid,                                                             &
@@ -611,8 +623,6 @@
        IMPLICIT NONE
 
-#if defined( __parallel )
 #if defined( __mpifh )
        INCLUDE "mpif.h"
-#endif
 #endif
 
@@ -718,4 +728,5 @@
 
     END SUBROUTINE calc_spectra_x
+#endif
 
 
@@ -725,4 +736,5 @@
 !> @todo Missing subroutine description.
 !------------------------------------------------------------------------------!
+#if defined( __parallel )
     SUBROUTINE calc_spectra_y( ddd, m )
 
@@ -738,9 +750,7 @@
        USE kinds
 
-#if defined( __parallel )
 #if !defined( __mpifh )
        USE MPI
 #endif
-#endif
 
        USE pegrid,                                                             &
@@ -753,8 +763,6 @@
        IMPLICIT NONE
 
-#if defined( __parallel )
 #if defined( __mpifh )
        INCLUDE "mpif.h"
-#endif
 #endif
 
@@ -862,4 +870,5 @@
 
     END SUBROUTINE calc_spectra_y
+#endif
 
  END MODULE spectra_mod
Index: palm/trunk/SOURCE/surface_coupler.f90
===================================================================
--- palm/trunk/SOURCE/surface_coupler.f90	(revision 4426)
+++ palm/trunk/SOURCE/surface_coupler.f90	(revision 4429)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! bugfix: preprocessor directives rearranged for serial mode
+! 
+! 4360 2020-01-07 11:25:50Z suehring
 ! Corrected "Former revisions" section
 ! 
@@ -38,4 +41,5 @@
 !------------------------------------------------------------------------------!
  SUBROUTINE surface_coupler
+#if defined( __parallel )
  
 
@@ -78,6 +82,4 @@
     REAL(wp), DIMENSION(nysg:nyng,nxlg:nxrg) ::  surface_flux !< dummy array for surface fluxes on 2D grid
 
-
-#if defined( __parallel )
 
     CALL cpu_log( log_point(39), 'surface_coupler', 'start' )
@@ -454,5 +456,4 @@
     CALL cpu_log( log_point(39), 'surface_coupler', 'stop' )
 
-#endif
 
      CONTAINS 
@@ -613,4 +614,5 @@
         END SUBROUTINE transfer_2D_to_1D_unequal
 
+#endif
   END SUBROUTINE surface_coupler
 
@@ -622,7 +624,7 @@
 !> @todo Missing subroutine description.
 !------------------------------------------------------------------------------!
+#if defined( __parallel )
+
   SUBROUTINE interpolate_to_atmos( tag )
-
-#if defined( __parallel )
 
     USE arrays_3d,                                                             &
@@ -701,7 +703,7 @@
     CALL MPI_BARRIER( comm2d, ierr )
 
+  END SUBROUTINE interpolate_to_atmos
+
 #endif
-
-  END SUBROUTINE interpolate_to_atmos
 
 
@@ -711,7 +713,7 @@
 !> @todo Missing subroutine description.
 !------------------------------------------------------------------------------!
+#if defined( __parallel )
+
   SUBROUTINE interpolate_to_ocean( tag )
-
-#if defined( __parallel )
 
     USE arrays_3d,                                                             &
@@ -786,5 +788,5 @@
     CALL MPI_BARRIER( comm2d, ierr )  
 
+  END SUBROUTINE interpolate_to_ocean
+
 #endif
-
-  END SUBROUTINE interpolate_to_ocean
Index: palm/trunk/SOURCE/transpose.f90
===================================================================
--- palm/trunk/SOURCE/transpose.f90	(revision 4426)
+++ palm/trunk/SOURCE/transpose.f90	(revision 4429)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! bugfix: cpp-directives added for serial mode
+! 
+! 4415 2020-02-20 10:30:33Z raasch
 ! bugfix for misplaced preprocessor directive
 ! 
@@ -111,6 +114,8 @@
 
 
+#if defined( __parallel )
     USE cpulog,                                                                &
         ONLY:  cpu_log, cpu_log_nowait, log_point_s
+#endif
 
     USE indices,                                                               &
@@ -129,13 +134,18 @@
     INTEGER(iwp) ::  j  !<
     INTEGER(iwp) ::  k  !<
+
+#if defined( __parallel )
     INTEGER(iwp) ::  l  !<
     INTEGER(iwp) ::  ys !<
+#endif
 
     REAL(wp) ::  f_inv(nys_x:nyn_x,nzb_x:nzt_x,0:nx) !<
     REAL(wp) ::  f_out(0:ny,nxl_y:nxr_y,nzb_y:nzt_y) !<
 
+#if defined( __parallel )
     REAL(wp), DIMENSION(nyn_x-nys_x+1,nzb_y:nzt_y,nxl_y:nxr_y,0:pdims(2)-1) ::  work !<
 #if __acc_fft_device
     !$ACC DECLARE CREATE(work)
+#endif
 #endif
 
@@ -271,5 +281,5 @@
  SUBROUTINE transpose_xz( f_in, f_inv )
 
-
+#if defined( __parallel )
     USE cpulog,                                                                &
         ONLY:  cpu_log, cpu_log_nowait, log_point_s
@@ -277,7 +287,12 @@
     USE fft_xy,                                                                &
         ONLY:  f_vec_x, temperton_fft_vec
+#endif
 
     USE indices,                                                               &
-        ONLY:  nnx, nx, nxl, nxr, nyn, nys, nz
+        ONLY:  nx, nxl, nxr, nyn, nys, nz
+#if defined( __parallel )
+    USE indices,                                                               &
+        ONLY:  nnx
+#endif
 
     USE kinds
@@ -293,14 +308,18 @@
     INTEGER(iwp) ::  j  !<
     INTEGER(iwp) ::  k  !<
+#if defined( __parallel )
     INTEGER(iwp) ::  l  !<
     INTEGER(iwp) ::  mm !<
     INTEGER(iwp) ::  xs !<
+#endif
 
     REAL(wp) ::  f_in(0:nx,nys_x:nyn_x,nzb_x:nzt_x) !<
     REAL(wp) ::  f_inv(nys:nyn,nxl:nxr,1:nz) !<
 
+#if defined( __parallel )
     REAL(wp), DIMENSION(nys_x:nyn_x,nnx,nzb_x:nzt_x,0:pdims(1)-1) ::  work !<
 #if __acc_fft_device
     !$ACC DECLARE CREATE(work)
+#endif
 #endif
 
@@ -460,6 +479,8 @@
 
 
+#if defined( __parallel )
     USE cpulog,                                                                &
         ONLY:  cpu_log, cpu_log_nowait, log_point_s
+#endif
 
     USE indices,                                                               &
@@ -478,13 +499,17 @@
     INTEGER(iwp) ::  j  !<
     INTEGER(iwp) ::  k  !<
+#if defined( __parallel )
     INTEGER(iwp) ::  l  !<
     INTEGER(iwp) ::  ys !<
+#endif
 
     REAL(wp) ::  f_in(0:ny,nxl_y:nxr_y,nzb_y:nzt_y)  !<
     REAL(wp) ::  f_inv(nys_x:nyn_x,nzb_x:nzt_x,0:nx) !<
 
+#if defined( __parallel )
     REAL(wp), DIMENSION(nyn_x-nys_x+1,nzb_y:nzt_y,nxl_y:nxr_y,0:pdims(2)-1) ::  work !<
 #if __acc_fft_device
     !$ACC DECLARE CREATE(work)
+#endif
 #endif
 
@@ -575,4 +600,5 @@
 !> (k,j,i) (cf. transpose_yx).
 !------------------------------------------------------------------------------!
+#if defined( __parallel )
  SUBROUTINE transpose_yxd( f_in, f_out )
 
@@ -604,5 +630,4 @@
     REAL(wp) ::  f_out(0:nx,nys_x:nyn_x,nzb_x:nzt_x) !<
     REAL(wp) ::  work(nnx*nny*nnz)                   !<
-#if defined( __parallel )
 
 !
@@ -641,7 +666,6 @@
     ENDDO
 
-#endif
-
  END SUBROUTINE transpose_yxd
+#endif
 
 
@@ -703,6 +727,8 @@
 
 
+#if defined( __parallel )
     USE cpulog,                                                                &
         ONLY:  cpu_log, cpu_log_nowait, log_point_s
+#endif
 
     USE indices,                                                               &
@@ -721,13 +747,17 @@
     INTEGER(iwp) ::  j  !<
     INTEGER(iwp) ::  k  !<
+#if defined( __parallel )
     INTEGER(iwp) ::  l  !<
     INTEGER(iwp) ::  zs !<
+#endif
 
     REAL(wp) ::  f_inv(nxl_y:nxr_y,nzb_y:nzt_y,0:ny) !<
     REAL(wp) ::  f_out(nxl_z:nxr_z,nys_z:nyn_z,1:nz) !<
 
+#if defined( __parallel )
     REAL(wp), DIMENSION(nxl_z:nxr_z,nzt_y-nzb_y+1,nys_z:nyn_z,0:pdims(1)-1) ::  work !<
 #if __acc_fft_device
     !$ACC DECLARE CREATE(work)
+#endif
 #endif
 
@@ -864,4 +894,5 @@
 
 
+#if defined( __parallel )
     USE cpulog,                                                                &
         ONLY:  cpu_log, cpu_log_nowait, log_point_s
@@ -869,7 +900,12 @@
     USE fft_xy,                                                                &
         ONLY:  f_vec_x, temperton_fft_vec
+#endif
 
     USE indices,                                                               &
-        ONLY:  nnx, nx, nxl, nxr, nyn, nys, nz
+        ONLY:  nx, nxl, nxr, nyn, nys, nz
+#if defined( __parallel )
+    USE indices,                                                               &
+        ONLY:  nnx
+#endif
 
     USE kinds
@@ -885,14 +921,18 @@
     INTEGER(iwp) ::  j  !<
     INTEGER(iwp) ::  k  !<
+#if defined( __parallel )
     INTEGER(iwp) ::  l  !<
     INTEGER(iwp) ::  mm !<
     INTEGER(iwp) ::  xs !<
+#endif
 
     REAL(wp) ::  f_inv(nys:nyn,nxl:nxr,1:nz)         !<
     REAL(wp) ::  f_out(0:nx,nys_x:nyn_x,nzb_x:nzt_x) !<
 
+#if defined( __parallel )
     REAL(wp), DIMENSION(nys_x:nyn_x,nnx,nzb_x:nzt_x,0:pdims(1)-1) ::  work !<
 #if __acc_fft_device
     !$ACC DECLARE CREATE(work)
+#endif
 #endif
 
@@ -1054,6 +1094,8 @@
 
 
+#if defined( __parallel )
     USE cpulog,                                                                &
         ONLY:  cpu_log, cpu_log_nowait, log_point_s
+#endif
 
     USE indices,                                                               &
@@ -1072,13 +1114,17 @@
     INTEGER(iwp) ::  j  !<
     INTEGER(iwp) ::  k  !<
+#if defined( __parallel )
     INTEGER(iwp) ::  l  !<
     INTEGER(iwp) ::  zs !<
+#endif
 
     REAL(wp) ::  f_in(nxl_z:nxr_z,nys_z:nyn_z,1:nz)  !<
     REAL(wp) ::  f_inv(nxl_y:nxr_y,nzb_y:nzt_y,0:ny) !<
 
+#if defined( __parallel )
     REAL(wp), DIMENSION(nxl_z:nxr_z,nzt_y-nzb_y+1,nys_z:nyn_z,0:pdims(1)-1) ::  work !<
 #if __acc_fft_device
     !$ACC DECLARE CREATE(work)
+#endif
 #endif
 
@@ -1170,4 +1216,5 @@
 !> (k,j,i) (cf. transpose_zy).
 !------------------------------------------------------------------------------!
+#if defined( __parallel )
  SUBROUTINE transpose_zyd( f_in, f_out )
 
@@ -1199,6 +1246,4 @@
     REAL(wp) ::  f_out(0:ny,nxl_yd:nxr_yd,nzb_yd:nzt_yd) !<
     REAL(wp) ::  work(nnx*nny*nnz)                       !<
-
-#if defined( __parallel )
 
 !
@@ -1253,5 +1298,4 @@
     ENDDO
 
-#endif
-
  END SUBROUTINE transpose_zyd
+#endif
