Index: palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- palm/trunk/SOURCE/check_parameters.f90	(revision 1428)
+++ palm/trunk/SOURCE/check_parameters.f90	(revision 1429)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! run_description_header exended to provide ensemble_member_nr if specified
 ! 
 ! Former revisions:
@@ -510,10 +510,18 @@
     ENDIF       
 
-    WRITE ( run_description_header,                                        &
-                             '(A,2X,A,2X,A,A,A,I2.2,A,2X,A,A,2X,A,1X,A)' ) &
-              TRIM( version ), TRIM( revision ), 'run: ',                  &
-              TRIM( run_identifier ), '.', runnr, TRIM( coupling_string ), &
+    IF ( ensemble_member_nr /= 0 )  THEN
+       WRITE ( run_description_header,                                         &
+                  '(A,2X,A,2X,A,A,A,I2.2,A,2X,A,I2.2,2X,A,A,2X,A,1X,A)' )      &
+              TRIM( version ), TRIM( revision ), 'run: ',                      &
+              TRIM( run_identifier ), '.', runnr, TRIM( coupling_string ),     &
+              'en-no: ', ensemble_member_nr,'host: ', TRIM( host ),            &
+              run_date, run_time
+    ELSE
+       WRITE ( run_description_header,                                         &
+                  '(A,2X,A,2X,A,A,A,I2.2,A,2X,A,A,2X,A,1X,A)' )                &
+              TRIM( version ), TRIM( revision ), 'run: ',                      &
+              TRIM( run_identifier ), '.', runnr, TRIM( coupling_string ),     &
               'host: ', TRIM( host ), run_date, run_time
-
+    ENDIF
 !
 !-- Check the general loop optimization method
Index: palm/trunk/SOURCE/header.f90
===================================================================
--- palm/trunk/SOURCE/header.f90	(revision 1428)
+++ palm/trunk/SOURCE/header.f90	(revision 1429)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! header exended to provide ensemble_member_nr if specified
 ! 
 ! Former revisions:
@@ -327,6 +327,11 @@
     ENDIF
 #endif
-    WRITE ( io, 102 )  run_date, run_identifier, run_time, runnr, &
+    IF ( ensemble_member_nr /= 0 )  THEN
+       WRITE ( io, 512 )  run_date, run_identifier, run_time, runnr,           &
+                       ADJUSTR( host_chr ), ensemble_member_nr
+    ELSE
+       WRITE ( io, 102 )  run_date, run_identifier, run_time, runnr,           &
                        ADJUSTR( host_chr )
+    ENDIF
 #if defined( __parallel )
     IF ( npex == -1  .AND.  pdims(2) /= 1 )  THEN
@@ -2138,4 +2143,7 @@
 511 FORMAT ('        Sedimentation Courant number:                  '/&
             '                               C_s   = ',F3.1,'        ')
+512 FORMAT (/' Date:                 ',A8,6X,'Run:       ',A20/      &
+            ' Time:                 ',A8,6X,'Run-No.:   ',I2.2/     &
+            ' Run on host:        ',A10,6X,'En-No.:    ',I2.2)
 
  END SUBROUTINE header
Index: palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- palm/trunk/SOURCE/init_3d_model.f90	(revision 1428)
+++ palm/trunk/SOURCE/init_3d_model.f90	(revision 1429)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! ------------------
-! 
+! Ensemble run capability added to parallel random number generator
 ! 
 ! Former revisions:
@@ -194,5 +194,5 @@
     USE indices
 
-    USE lpm_init_mod,                                                              &
+    USE lpm_init_mod,                                                          &
         ONLY:  lpm_init
     
@@ -948,13 +948,18 @@
 !--    Initialize the random number generators (from numerical recipes)
        CALL random_function_ini
+       
        IF ( random_generator == 'random-parallel' )  THEN
-          CALL random_function_ini
-          !- asigning an ID to every vertical gridpoint column
+!--       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) = 1000000*i + j
+                id_random_array(j,i) = random_dummy + 1E6 * ( ensemble_member_nr - 1000 )
+                random_dummy = random_dummy + 1
              END DO
           ENDDO
-          !- executing the initial ran_parallel
+!--       Initializing with random_seed_parallel for every vertical 
+!--       gridpoint column.
+          random_dummy=0
           DO j = nysg, nyng
              DO i = nxlg, nxrg
Index: palm/trunk/SOURCE/modules.f90
===================================================================
--- palm/trunk/SOURCE/modules.f90	(revision 1428)
+++ palm/trunk/SOURCE/modules.f90	(revision 1429)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! ------------------
-! 
+! +ensemble_member_nr to prepare the random_generator for ensemble runs
 ! 
 ! Former revisions:
@@ -560,5 +560,5 @@
                      do2d_xy_n = 0, do2d_xz_n = 0, do2d_yz_n = 0, do3d_avs_n = 0, &
                      dp_level_ind_b = 0, dvrp_filecount = 0, &
-                     dz_stretch_level_index, gamma_mg, gathered_size, &
+                     dz_stretch_level_index, ensemble_member_nr = 0, gamma_mg, gathered_size, &
                      grid_level, ibc_e_b, ibc_p_b, ibc_p_t, &
                      ibc_pt_b, ibc_pt_t, ibc_q_b, ibc_q_t, &
Index: palm/trunk/SOURCE/parin.f90
===================================================================
--- palm/trunk/SOURCE/parin.f90	(revision 1428)
+++ palm/trunk/SOURCE/parin.f90	(revision 1429)
@@ -19,6 +19,6 @@
 !
 ! Current revisions:
-! -----------------
-! 
+! ------------------
+! +ensemble_member_nr to prepare the random_generator for ensemble runs
 ! 
 ! Former revisions:
@@ -174,10 +174,11 @@
                do2d_at_begin, do3d_at_begin,                                   &
                dp_external, dp_level_b, dp_smooth, dpdxy, drag_coefficient,    &
-               drizzle, dt, dz, dt_averaging_input, dt_averaging_input_pr,     &
+               drizzle, dt, dt_averaging_input, dt_averaging_input_pr,         &
                dt_coupling, dt_data_output, dt_data_output_av, dt_disturb,     &
                dt_domask, dt_dopr, dt_dopr_listing, dt_dots, dt_do2d_xy,       &
                dt_do2d_xz, dt_do2d_yz, dt_do3d, dt_max, dt_restart,            &
-               dt_run_control, dz_max, dz_stretch_factor, dz_stretch_level,    &
-               end_time, e_init, e_min, fft_method, force_print_header,        &
+               dt_run_control, dz, dz_max, dz_stretch_factor, dz_stretch_level,&
+               end_time, ensemble_member_nr, e_init, e_min, fft_method,        &
+               force_print_header,                                             &
                galilei_transformation, host, humidity, inflow_damping_height,  &
                inflow_damping_width, inflow_disturbance_begin,                 &
@@ -261,85 +262,86 @@
 
     NAMELIST /inipar/  alpha_surface, background_communication, bc_e_b, bc_lr, &
-                       bc_ns, bc_p_b, bc_p_t, bc_pt_b, bc_pt_t, bc_q_b, &
-             bc_q_t,bc_s_b, bc_s_t, bc_sa_t, bc_uv_b, bc_uv_t, &
-             bottom_salinityflux, building_height, building_length_x, &
-             building_length_y, building_wall_left, building_wall_south, &
-             call_psolver_at_all_substeps, call_microphysics_at_all_substeps, &
-             canopy_mode, canyon_height, &
-             canyon_width_x, canyon_width_y, canyon_wall_left, &
-             canyon_wall_south, c_sedimentation, cfl_factor, cloud_droplets, &
-             cloud_physics, cloud_scheme, collective_wait, &
-             conserve_volume_flow, &
-             conserve_volume_flow_mode, coupling_start_time, cthf, &
-             curvature_solution_effects, cycle_mg, damp_level_1d, &
-             dissipation_1d, & !dissipation_control, &
-             dp_external, dp_level_b, dp_smooth, dpdxy, drag_coefficient, &
-             drizzle, dt, dt_pr_1d, dt_run_control_1d, dx, dy, dz, dz_max, & 
-             dz_stretch_factor, dz_stretch_level, e_init, e_min, end_time_1d, &
-             fft_method, galilei_transformation, humidity, &
-             inflow_damping_height, inflow_damping_width, &
-             inflow_disturbance_begin, inflow_disturbance_end, &
-             initializing_actions, km_constant, lad_surface, &
-             lad_vertical_gradient, lad_vertical_gradient_level, &
-             large_scale_forcing, large_scale_subsidence, &
-             leaf_surface_concentration, limiter_sedimentation, &
-             loop_optimization, masking_method, mg_cycles, &
-             mg_switch_to_pe0_level, mixing_length_1d, momentum_advec, &
-             nc_const, netcdf_precision, neutral, ngsrb, &
-             nsor, nsor_ini, nudging, nx, ny, nz, ocean, omega, omega_sor, &
-             passive_scalar, pch_index, phi, plant_canopy, prandtl_layer, &
-             prandtl_number, precipitation, psolver, pt_damping_factor, &
-             pt_damping_width, pt_reference, pt_surface, &
-             pt_surface_initial_change, pt_vertical_gradient, &
-             pt_vertical_gradient_level, q_surface, q_surface_initial_change, &
-             q_vertical_gradient, q_vertical_gradient_level, &
-             radiation, random_generator, random_heatflux, &
+                       bc_ns, bc_p_b, bc_p_t, bc_pt_b, bc_pt_t, bc_q_b,        &
+             bc_q_t,bc_s_b, bc_s_t, bc_sa_t, bc_uv_b, bc_uv_t,                 &
+             bottom_salinityflux, building_height, building_length_x,          &
+             building_length_y, building_wall_left, building_wall_south,       &
+             call_psolver_at_all_substeps, call_microphysics_at_all_substeps,  &
+             canopy_mode, canyon_height,                                       &
+             canyon_width_x, canyon_width_y, canyon_wall_left,                 &
+             canyon_wall_south, c_sedimentation, cfl_factor, cloud_droplets,   &
+             cloud_physics, cloud_scheme, collective_wait,                     &
+             conserve_volume_flow,                                             &
+             conserve_volume_flow_mode, coupling_start_time, cthf,             &
+             curvature_solution_effects, cycle_mg, damp_level_1d,              &
+             dissipation_1d,                                                   &
+             dp_external, dp_level_b, dp_smooth, dpdxy, drag_coefficient,      &
+             drizzle, dt, dt_pr_1d, dt_run_control_1d, dx, dy, dz, dz_max,     & 
+             dz_stretch_factor, dz_stretch_level, end_time_1d,                 &
+             ensemble_member_nr,                                               &
+             e_init, e_min, fft_method, galilei_transformation, humidity,      &
+             inflow_damping_height, inflow_damping_width,                      &
+             inflow_disturbance_begin, inflow_disturbance_end,                 &
+             initializing_actions, km_constant, lad_surface,                   &
+             lad_vertical_gradient, lad_vertical_gradient_level,               &
+             large_scale_forcing, large_scale_subsidence,                      &
+             leaf_surface_concentration, limiter_sedimentation,                &
+             loop_optimization, masking_method, mg_cycles,                     &
+             mg_switch_to_pe0_level, mixing_length_1d, momentum_advec,         &
+             nc_const, netcdf_precision, neutral, ngsrb,                       &
+             nsor, nsor_ini, nudging, nx, ny, nz, ocean, omega, omega_sor,     &
+             passive_scalar, pch_index, phi, plant_canopy, prandtl_layer,      &
+             prandtl_number, precipitation, psolver, pt_damping_factor,        &
+             pt_damping_width, pt_reference, pt_surface,                       &
+             pt_surface_initial_change, pt_vertical_gradient,                  &
+             pt_vertical_gradient_level, q_surface, q_surface_initial_change,  &
+             q_vertical_gradient, q_vertical_gradient_level,                   &
+             radiation, random_generator, random_heatflux,                     &
              rayleigh_damping_factor, rayleigh_damping_height, recycling_width,&
-             reference_state, residual_limit, &
-             rif_max, rif_min, roughness_length, sa_surface, &
-             sa_vertical_gradient, sa_vertical_gradient_level, scalar_advec, &
-             scalar_exchange_coefficient, scalar_rayleigh_damping, &
-             statistic_regions, subs_vertical_gradient, &
+             reference_state, residual_limit,                                  &
+             rif_max, rif_min, roughness_length, sa_surface,                   &
+             sa_vertical_gradient, sa_vertical_gradient_level, scalar_advec,   &
+             scalar_exchange_coefficient, scalar_rayleigh_damping,             &
+             statistic_regions, subs_vertical_gradient,                        &
              subs_vertical_gradient_level, surface_heatflux, surface_pressure, &
-             surface_scalarflux, surface_waterflux, &
-             s_surface, s_surface_initial_change, s_vertical_gradient, &
-             s_vertical_gradient_level, timestep_scheme, &
-             topography, topography_grid_convention, top_heatflux, &
-             top_momentumflux_u, top_momentumflux_v, top_salinityflux, &
-             transpose_compute_overlap, turbulence, turbulent_inflow, &
-             use_subsidence_tendencies, ug_surface, ug_vertical_gradient, &
-             ug_vertical_gradient_level, use_surface_fluxes, use_cmax, &
-             use_top_fluxes, use_ug_for_galilei_tr, use_upstream_for_tke, &
-             uv_heights, u_bulk, u_profile, vg_surface, vg_vertical_gradient, &
-             vg_vertical_gradient_level, v_bulk, v_profile, ventilation_effect, &
-             wall_adjustment, wall_heatflux, wall_humidityflux, wall_scalarflux, &
-             z0h_factor
+             surface_scalarflux, surface_waterflux,                            &
+             s_surface, s_surface_initial_change, s_vertical_gradient,         &
+             s_vertical_gradient_level, timestep_scheme,                       &
+             topography, topography_grid_convention, top_heatflux,             &
+             top_momentumflux_u, top_momentumflux_v, top_salinityflux,         &
+             transpose_compute_overlap, turbulence, turbulent_inflow,          &
+             use_subsidence_tendencies, ug_surface, ug_vertical_gradient,      &
+             ug_vertical_gradient_level, use_surface_fluxes, use_cmax,         &
+             use_top_fluxes, use_ug_for_galilei_tr, use_upstream_for_tke,      &
+             uv_heights, u_bulk, u_profile, vg_surface, vg_vertical_gradient,  &
+             vg_vertical_gradient_level, v_bulk, v_profile, ventilation_effect,&
+             wall_adjustment, wall_heatflux, wall_humidityflux,                &
+             wall_scalarflux, z0h_factor
       
-    NAMELIST /d3par/  averaging_interval, averaging_interval_pr, &
-             cpu_log_barrierwait, create_disturbances, &
-             cross_profiles, cross_ts_uymax, cross_ts_uymin, &
+    NAMELIST /d3par/  averaging_interval, averaging_interval_pr,               &
+             cpu_log_barrierwait, create_disturbances,                         &
+             cross_profiles, cross_ts_uymax, cross_ts_uymin,                   &
              data_output, data_output_masks,                                   &
              data_output_pr, data_output_2d_on_each_pe, disturbance_amplitude, &
-             disturbance_energy_limit, disturbance_level_b, &
+             disturbance_energy_limit, disturbance_level_b,                    &
              disturbance_level_t, do2d_at_begin, do3d_at_begin,                &
-             dt, dt_averaging_input, dt_averaging_input_pr, &
-             dt_coupling, dt_data_output, dt_data_output_av, dt_disturb, &
-             dt_domask, dt_dopr, dt_dopr_listing, dt_dots, dt_do2d_xy, &
-             dt_do2d_xz, dt_do2d_yz, dt_do3d, dt_max, dt_restart, &
-             dt_run_control,end_time, force_print_header, mask_scale_x, &
-             mask_scale_y, mask_scale_z, mask_x, mask_y, mask_z, mask_x_loop, &
+             dt, dt_averaging_input, dt_averaging_input_pr,                    &
+             dt_coupling, dt_data_output, dt_data_output_av, dt_disturb,       &
+             dt_domask, dt_dopr, dt_dopr_listing, dt_dots, dt_do2d_xy,         &
+             dt_do2d_xz, dt_do2d_yz, dt_do3d, dt_max, dt_restart,              &
+             dt_run_control,end_time, force_print_header, mask_scale_x,        &
+             mask_scale_y, mask_scale_z, mask_x, mask_y, mask_z, mask_x_loop,  &
              mask_y_loop, mask_z_loop, netcdf_data_format, normalizing_region, &
-             npex, npey, nz_do3d, precipitation_amount_interval, &
-             profile_columns, profile_rows, restart_time, section_xy, &
-             section_xz, section_yz, skip_time_data_output, &
-             skip_time_data_output_av, skip_time_dopr, skip_time_do2d_xy, &
-             skip_time_do2d_xz, skip_time_do2d_yz, skip_time_do3d, &
-             skip_time_domask, synchronous_exchange, termination_time_needed, &
+             npex, npey, nz_do3d, precipitation_amount_interval,               &
+             profile_columns, profile_rows, restart_time, section_xy,          &
+             section_xz, section_yz, skip_time_data_output,                    &
+             skip_time_data_output_av, skip_time_dopr, skip_time_do2d_xy,      &
+             skip_time_do2d_xz, skip_time_do2d_yz, skip_time_do3d,             &
+             skip_time_domask, synchronous_exchange, termination_time_needed,  &
              z_max_do2d
 
 
-    NAMELIST /envpar/  batch_job, host, local_dvrserver_running, &
-                       maximum_cpu_time_allowed, maximum_parallel_io_streams, &
-                       revision, return_addres, return_username, &
+    NAMELIST /envpar/  batch_job, host, local_dvrserver_running,               &
+                       maximum_cpu_time_allowed, maximum_parallel_io_streams,  &
+                       revision, return_addres, return_username,               &
                        run_identifier, tasks_per_node, write_binary
 
@@ -361,5 +363,5 @@
 !-- system.
 !-- First, set the default:
-    IF ( maximum_parallel_io_streams == -1  .OR. &
+    IF ( maximum_parallel_io_streams == -1  .OR.                               &
          maximum_parallel_io_streams > numprocs )  THEN
        maximum_parallel_io_streams = numprocs
@@ -403,5 +405,5 @@
           GOTO 12
 
- 10       message_string = 'errors in \$inipar &or no \$inipar-namelist ' // &
+ 10       message_string = 'errors in \$inipar &or no \$inipar-namelist ' //   &
                            'found (CRAY-machines only)'
           CALL message( 'parin', 'PA0271', 1, 2, 0, 6, 0 )
@@ -456,15 +458,15 @@
 
              IF ( nx <= 0 )  THEN
-                WRITE( message_string, * ) 'no value or wrong value given', &
+                WRITE( message_string, * ) 'no value or wrong value given',    &
                                            ' for nx: nx=', nx
                 CALL message( 'parin', 'PA0273', 1, 2, 0, 6, 0 )
              ENDIF
              IF ( ny <= 0 )  THEN
-                WRITE( message_string, * ) 'no value or wrong value given', &
+                WRITE( message_string, * ) 'no value or wrong value given',    &
                                            ' for ny: ny=', ny
                 CALL message( 'parin', 'PA0274', 1, 2, 0, 6, 0 )
              ENDIF
              IF ( nz <= 0 )  THEN
-                WRITE( message_string, * ) 'no value or wrong value given', &
+                WRITE( message_string, * ) 'no value or wrong value given',    &
                                            ' for nz: nz=', nz
                 CALL message( 'parin', 'PA0275', 1, 2, 0, 6, 0 )
@@ -473,8 +475,8 @@
 !--          ATTENTION: in case of changes to the following statement please
 !--                  also check the allocate statement in routine read_var_list
-             ALLOCATE( lad(0:nz+1), pt_init(0:nz+1), q_init(0:nz+1),          &
-                       ref_state(0:nz+1), sa_init(0:nz+1), ug(0:nz+1),        &
-                       u_init(0:nz+1), v_init(0:nz+1), vg(0:nz+1),            &
-                       hom(0:nz+1,2,pr_palm+max_pr_user,0:statistic_regions), &
+             ALLOCATE( lad(0:nz+1), pt_init(0:nz+1), q_init(0:nz+1),           &
+                       ref_state(0:nz+1), sa_init(0:nz+1), ug(0:nz+1),         &
+                       u_init(0:nz+1), v_init(0:nz+1), vg(0:nz+1),             &
+                       hom(0:nz+1,2,pr_palm+max_pr_user,0:statistic_regions),  &
                        hom_sum(0:nz+1,pr_palm+max_pr_user,0:statistic_regions) )
 
@@ -497,15 +499,15 @@
     RETURN
 
- 30 message_string = 'local file ENVPAR not found' // &
+ 30 message_string = 'local file ENVPAR not found' //                          &
                      '&some variables for steering may not be properly set'
     CALL message( 'parin', 'PA0276', 0, 1, 0, 6, 0 )
     RETURN
 
- 31 message_string = 'errors in local file ENVPAR' // &
+ 31 message_string = 'errors in local file ENVPAR' //                          &
                      '&some variables for steering may not be properly set'
     CALL message( 'parin', 'PA0277', 0, 1, 0, 6, 0 )
     RETURN
 
- 32 message_string = 'no envpar-NAMELIST found in local file ENVPAR'  // &
+ 32 message_string = 'no envpar-NAMELIST found in local file ENVPAR'  //       &
                      '&some variables for steering may not be properly set'
     CALL message( 'parin', 'PA0278', 0, 1, 0, 6, 0 )
