Index: /palm/trunk/SOURCE/lpm_write_exchange_statistics.f90
===================================================================
--- /palm/trunk/SOURCE/lpm_write_exchange_statistics.f90	(revision 2840)
+++ /palm/trunk/SOURCE/lpm_write_exchange_statistics.f90	(revision 2841)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Bugfix: wrong placement of include 'mpif.h' corrected,
+! kinds module added and pegrid module scope restricted
+! 
+! 2801 2018-02-14 16:01:55Z thiele
 ! Introduce particle transfer in nested models.
 ! 
@@ -71,6 +75,8 @@
 !------------------------------------------------------------------------------!
  SUBROUTINE lpm_write_exchange_statistics
- 
+
+#if !defined( __mpifh )
     USE MPI
+#endif
 
     USE control_parameters,                                                    &
@@ -79,4 +85,6 @@
     USE indices,                                                               &
         ONLY:  nxl, nxr, nys, nyn, nzb, nzt
+
+    USE kinds
 
     USE particle_attributes,                                                   &
@@ -89,7 +97,12 @@
         ONLY:  pmcp_g_print_number_of_particles
 
-    USE pegrid
+    USE pegrid,                                                                &
+        ONLY:  comm2d, ierr, pleft, pright, psouth, pnorth
 
     IMPLICIT NONE
+
+#if defined( __mpifh )
+    INCLUDE "mpif.h"
+#endif
 
     INTEGER(iwp) :: ip         !<
Index: /palm/trunk/SOURCE/pmc_child_mod.f90
===================================================================
--- /palm/trunk/SOURCE/pmc_child_mod.f90	(revision 2840)
+++ /palm/trunk/SOURCE/pmc_child_mod.f90	(revision 2841)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! Bugfix: wrong placement of include 'mpif.h' corrected
+! 
+! 2809 2018-02-15 09:55:58Z schwenkel
 ! Bugfix for gfortran: Replace the function C_SIZEOF with STORAGE_SIZE
 ! 
@@ -96,11 +99,10 @@
     USE, INTRINSIC ::  iso_c_binding
 
-#if defined( __mpifh )
-    INCLUDE "mpif.h"
-#else
+#if !defined( __mpifh )
     USE MPI
 #endif
 
     USE kinds
+
     USE pmc_general,                                                           &
         ONLY:  arraydef, childdef, da_desclen, da_namedef, da_namelen, pedef,  &
@@ -114,4 +116,8 @@
 
     IMPLICIT NONE
+
+#if defined( __mpifh )
+    INCLUDE "mpif.h"
+#endif
 
     PRIVATE
Index: /palm/trunk/SOURCE/pmc_general_mod.f90
===================================================================
--- /palm/trunk/SOURCE/pmc_general_mod.f90	(revision 2840)
+++ /palm/trunk/SOURCE/pmc_general_mod.f90	(revision 2841)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! Bugfix: wrong placement of include 'mpif.h' corrected
+! 
+! 2801 2018-02-14 16:01:55Z thiele
 ! Introduce particle transfer in nested models.
 ! 
@@ -80,11 +83,13 @@
     USE kinds
 
+#if !defined( __mpifh )
+    USE MPI
+#endif
+
+    IMPLICIT NONE
+
 #if defined( __mpifh )
     INCLUDE "mpif.h"
-#else
-    USE MPI
 #endif
-
-    IMPLICIT NONE
 
     PRIVATE
Index: /palm/trunk/SOURCE/pmc_handle_communicator_mod.f90
===================================================================
--- /palm/trunk/SOURCE/pmc_handle_communicator_mod.f90	(revision 2840)
+++ /palm/trunk/SOURCE/pmc_handle_communicator_mod.f90	(revision 2841)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Bugfix: wrong placement of include 'mpif.h' corrected
+! 
+! 2801 2018-02-14 16:01:55Z thiele
 ! Introduce particle transfer in nested models.
 ! 
@@ -112,7 +115,5 @@
     USE kinds
 
-#if defined( __mpifh )
-    INCLUDE "mpif.h"
-#else
+#if !defined( __mpifh )
     USE MPI
 #endif
@@ -124,4 +125,8 @@
 
     IMPLICIT NONE
+
+#if defined( __mpifh )
+    INCLUDE "mpif.h"
+#endif
 
     TYPE pmc_layout
Index: /palm/trunk/SOURCE/pmc_interface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 2840)
+++ /palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 2841)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Bugfix: wrong placement of include 'mpif.h' corrected
+! 
+! 2812 2018-02-16 13:40:25Z hellstea
 ! Bugfixes in computation of the interpolation loglaw-correction parameters
 ! 
@@ -275,7 +278,5 @@
 
 #if defined( __parallel )
-#if defined( __mpifh )
-    INCLUDE "mpif.h"
-#else
+#if !defined( __mpifh )
     USE MPI
 #endif
@@ -314,4 +315,10 @@
 
     IMPLICIT NONE
+
+#if defined( __parallel )
+#if defined( __mpifh )
+    INCLUDE "mpif.h"
+#endif
+#endif
 
     PRIVATE
Index: /palm/trunk/SOURCE/pmc_mpi_wrapper_mod.f90
===================================================================
--- /palm/trunk/SOURCE/pmc_mpi_wrapper_mod.f90	(revision 2840)
+++ /palm/trunk/SOURCE/pmc_mpi_wrapper_mod.f90	(revision 2841)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! Bugfix: wrong placement of include 'mpif.h' corrected
+! 
+! 2809 2018-02-15 09:55:58Z schwenkel
 ! Bugfix for gfortran: Replace the function C_SIZEOF with STORAGE_SIZE
 ! 
@@ -74,7 +77,5 @@
     USE, INTRINSIC ::  ISO_C_BINDING
 
-#if defined( __mpifh )
-    INCLUDE "mpif.h"
-#else
+#if !defined( __mpifh )
     USE MPI
 #endif
@@ -85,4 +86,8 @@
 
     IMPLICIT NONE
+
+#if defined( __mpifh )
+    INCLUDE "mpif.h"
+#endif
 
     PRIVATE
Index: /palm/trunk/SOURCE/pmc_parent_mod.f90
===================================================================
--- /palm/trunk/SOURCE/pmc_parent_mod.f90	(revision 2840)
+++ /palm/trunk/SOURCE/pmc_parent_mod.f90	(revision 2841)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! Bugfix: wrong placement of include 'mpif.h' corrected
+! 
+! 2809 2018-02-15 09:55:58Z schwenkel
 ! Bugfix for gfortran: Replace the function C_SIZEOF with STORAGE_SIZE
 ! 
@@ -99,7 +102,5 @@
     USE, INTRINSIC ::  ISO_C_BINDING
 
-#if defined( __mpifh )
-    INCLUDE "mpif.h"
-#else
+#if !defined( __mpifh )
     USE MPI
 #endif
@@ -117,4 +118,8 @@
 
    IMPLICIT NONE
+
+#if defined( __mpifh )
+   INCLUDE "mpif.h"
+#endif
 
    PRIVATE
Index: /palm/trunk/SOURCE/pmc_particle_interface.f90
===================================================================
--- /palm/trunk/SOURCE/pmc_particle_interface.f90	(revision 2840)
+++ /palm/trunk/SOURCE/pmc_particle_interface.f90	(revision 2841)
@@ -26,4 +26,7 @@
 ! -----------------! 
 ! $Id$
+! Bugfix: wrong placement of include 'mpif.h' corrected
+! 
+! 2809 2018-02-15 09:55:58Z schwenkel
 ! Bugfix for gfortran: Replace the function C_SIZEOF with STORAGE_SIZE.
 !  
@@ -40,5 +43,8 @@
 
    USE, INTRINSIC ::  ISO_C_BINDING
+
+#if !defined( __mpifh )
    USE MPI
+#endif
 
    USE kinds
@@ -92,4 +98,9 @@
 
    IMPLICIT NONE
+
+#if defined( __mpifh )
+   INCLUDE "mpif.h"
+#endif
+
    PRIVATE
    SAVE
Index: /palm/trunk/SOURCE/spectra_mod.f90
===================================================================
--- /palm/trunk/SOURCE/spectra_mod.f90	(revision 2840)
+++ /palm/trunk/SOURCE/spectra_mod.f90	(revision 2841)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Bugfix: wrong placement of include 'mpif.h' corrected
+! 
+! 2718 2018-01-02 08:49:38Z maronga
 ! Corrected "Former revisions" section
 ! 
@@ -507,18 +510,23 @@
 
 #if defined( __parallel )
+#if !defined( __mpifh )
+       USE MPI
+#endif
+#endif
+
+       USE pegrid,                                                             &
+           ONLY:  collective_wait, comm2d, ierr
+
+       USE statistics,                                                         &
+           ONLY:  hom
+
+
+       IMPLICIT NONE
+
+#if defined( __parallel )
 #if defined( __mpifh )
        INCLUDE "mpif.h"
-#else
-       USE MPI
-#endif
-#endif
-       USE pegrid,                                                             &
-           ONLY:  collective_wait, comm2d, ierr
-
-       USE statistics,                                                         &
-           ONLY:  hom
-
-
-       IMPLICIT NONE
+#endif
+#endif
 
        INTEGER(iwp) :: i  !<
@@ -616,18 +624,23 @@
 
 #if defined( __parallel )
+#if !defined( __mpifh )
+       USE MPI
+#endif
+#endif
+
+       USE pegrid,                                                             &
+           ONLY:  comm2d, ierr, myid
+
+       USE transpose_indices,                                                  &
+           ONLY:  nyn_x, nys_x, nzb_x, nzt_x
+
+
+       IMPLICIT NONE
+
+#if defined( __parallel )
 #if defined( __mpifh )
        INCLUDE "mpif.h"
-#else
-       USE MPI
-#endif
-#endif
-       USE pegrid,                                                             &
-           ONLY:  comm2d, ierr, myid
-
-       USE transpose_indices,                                                  &
-           ONLY:  nyn_x, nys_x, nzb_x, nzt_x
-
-
-       IMPLICIT NONE
+#endif
+#endif
 
        INTEGER(iwp) ::  i         !<
@@ -758,18 +771,23 @@
 
 #if defined( __parallel )
+#if !defined( __mpifh )
+       USE MPI
+#endif
+#endif
+
+       USE pegrid,                                                             &
+           ONLY:  comm2d, ierr, myid
+
+       USE transpose_indices,                                                  &
+           ONLY:  nxl_yd, nxr_yd, nzb_yd, nzt_yd
+
+
+       IMPLICIT NONE
+
+#if defined( __parallel )
 #if defined( __mpifh )
        INCLUDE "mpif.h"
-#else
-       USE MPI
-#endif
-#endif
-       USE pegrid,                                                             &
-           ONLY:  comm2d, ierr, myid
-
-       USE transpose_indices,                                                  &
-           ONLY:  nxl_yd, nxr_yd, nzb_yd, nzt_yd
-
-
-       IMPLICIT NONE
+#endif
+#endif
 
        INTEGER(iwp) ::  i         !<
Index: /palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90
===================================================================
--- /palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90	(revision 2840)
+++ /palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90	(revision 2841)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Bugfix: wrong placement of include 'mpif.h' corrected
+! 
+! 2836 2018-02-26 13:40:05Z Giersch
 ! The variables synthetic_turbulence_generator and 
 ! use_synthetic_turbulence_generator have been abbreviated + syn_turb_gen_prerun
@@ -99,5 +102,7 @@
     USE kinds
 
+#if !defined( __mpifh )
     USE MPI
+#endif
 
     USE pegrid,                                                                &
@@ -109,4 +114,8 @@
 
     IMPLICIT NONE
+
+#if defined( __mpifh )
+    INCLUDE "mpif.h"
+#endif
 
     LOGICAL :: velocity_seed_initialized = .FALSE.  !< true after first call of stg_main
