Index: /palm/trunk/SOURCE/disturb_field.f90
===================================================================
--- /palm/trunk/SOURCE/disturb_field.f90	(revision 2171)
+++ /palm/trunk/SOURCE/disturb_field.f90	(revision 2172)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! ------------------
-! 
+! Bugfix removed id_random_array from USE list
 ! 
 ! Former revisions:
@@ -89,5 +89,5 @@
     USE random_generator_parallel,                                             &
         ONLY:  random_number_parallel, random_seed_parallel, random_dummy,     &
-               id_random_array, seq_random_array
+               seq_random_array
 
     IMPLICIT NONE
Index: /palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- /palm/trunk/SOURCE/init_3d_model.f90	(revision 2171)
+++ /palm/trunk/SOURCE/init_3d_model.f90	(revision 2172)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! ------------------
-! 
+! Bugfix: moved parallel random generator initialization into its module
 ! 
 ! Former revisions:
@@ -370,6 +370,5 @@
     
     USE random_generator_parallel,                                             &
-        ONLY:  random_number_parallel, random_seed_parallel, random_dummy,     &
-               id_random_array, seq_random_array
+        ONLY:  init_parallel_random_generator
     
     USE statistics,                                                            &
@@ -816,13 +815,4 @@
 
 !
-!-- ID-array and state-space-array for the parallel random number generator
-    IF ( random_generator == 'random-parallel' )  THEN
-       ALLOCATE ( seq_random_array(5,nysg:nyng,nxlg:nxrg) )
-       ALLOCATE ( id_random_array(0:ny,0:nx) )
-       seq_random_array = 0
-       id_random_array  = 0
-    ENDIF
-    
-!
 !-- 4D-array for storing the Rif-values at vertical walls
     IF ( topography /= 'flat' )  THEN
@@ -1287,24 +1277,5 @@
        
        IF ( random_generator == 'random-parallel' )  THEN
-!--       Asigning an ID to every vertical gridpoint column 
-!--       dependig on the ensemble run number.
-          random_dummy=1
-          DO j=0,ny
-             DO i=0,nx
-                id_random_array(j,i) = random_dummy + 1E6                      &
-                                       * ( ensemble_member_nr - 1000 )
-                random_dummy = random_dummy + 1
-             END DO
-          ENDDO
-!--       Initializing with random_seed_parallel for every vertical 
-!--       gridpoint column.
-          random_dummy=0
-          DO j = nysg, nyng
-             DO i = nxlg, nxrg
-                CALL random_seed_parallel (random_sequence=id_random_array(j, i))
-                CALL random_number_parallel (random_dummy)
-                CALL random_seed_parallel (get=seq_random_array(:, j, i))
-             END DO
-          ENDDO
+          CALL init_parallel_random_generator(nx, ny, nys, nyn, nxl, nxr)
        ENDIF
 
Index: /palm/trunk/SOURCE/random_generator_parallel_mod.f90
===================================================================
--- /palm/trunk/SOURCE/random_generator_parallel_mod.f90	(revision 2171)
+++ /palm/trunk/SOURCE/random_generator_parallel_mod.f90	(revision 2172)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Bugfix: added global initialization routine and removed global array
 ! 
 ! Former revisions:
@@ -67,5 +67,5 @@
    PRIVATE
    PUBLIC random_number_parallel, random_seed_parallel, random_dummy,          &
-          id_random_array, seq_random_array
+          id_random_array, seq_random_array, init_parallel_random_generator
    
    INTEGER(isp), SAVE :: lenran=0             !< 
@@ -96,4 +96,8 @@
    REAL(wp) :: random_dummy=0.0   !< 
    
+   INTERFACE init_parallel_random_generator
+      MODULE PROCEDURE init_parallel_random_generator
+   END INTERFACE
+   
    INTERFACE random_number_parallel
       MODULE PROCEDURE ran0_s
@@ -117,4 +121,55 @@
 
  CONTAINS
+ 
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Initialize the parallel random number generator for a specific subdomain
+!------------------------------------------------------------------------------!
+   SUBROUTINE init_parallel_random_generator(nx, ny, nys, nyn, nxl, nxr)
+
+      USE kinds
+
+      USE control_parameters,                                                  &
+          ONLY: ensemble_member_nr
+
+      IMPLICIT NONE
+
+      INTEGER(isp), INTENT(IN) ::  nx    !< 
+      INTEGER(isp), INTENT(IN) ::  ny    !< 
+      INTEGER(isp), INTENT(IN) ::  nys   !< 
+      INTEGER(isp), INTENT(IN) ::  nyn   !< 
+      INTEGER(isp), INTENT(IN) ::  nxl   !< 
+      INTEGER(isp), INTENT(IN) ::  nxr   !< 
+
+      INTEGER(iwp) ::  i   !<
+      INTEGER(iwp) ::  j   !<
+
+!--   Allocate ID-array and state-space-array
+      ALLOCATE ( seq_random_array(5,nys:nyn,nxl:nxr) )
+      ALLOCATE ( id_random_array(nys:nyn,nxl:nxr) )
+      seq_random_array = 0
+      id_random_array  = 0
+
+!--       Asigning an ID to every vertical gridpoint column 
+!--       dependig on the ensemble run number.
+          DO i=nxl, nxr
+             DO j=nys, nyn
+                id_random_array(j,i) = j*(nx+1.0_wp) + i + 1.0_wp + 1E6 * &
+                                       ( ensemble_member_nr - 1000 )
+             ENDDO
+          ENDDO
+!--       Initializing with random_seed_parallel for every vertical 
+!--       gridpoint column.
+          random_dummy=0
+          DO i = nxl, nxr
+             DO j = nys, nyn
+                CALL random_seed_parallel (random_sequence=id_random_array(j, i))
+                CALL random_number_parallel (random_dummy)
+                CALL random_seed_parallel (get=seq_random_array(:, j, i))
+             ENDDO
+          ENDDO
+
+   END SUBROUTINE init_parallel_random_generator
  
 !------------------------------------------------------------------------------!
