Index: /palm/trunk/SOURCE/data_output_binary_module.f90
===================================================================
--- /palm/trunk/SOURCE/data_output_binary_module.f90	(revision 4106)
+++ /palm/trunk/SOURCE/data_output_binary_module.f90	(revision 4107)
@@ -56,6 +56,7 @@
    CHARACTER(LEN=*), PARAMETER ::  config_file_name = 'BINARY_TO_NETCDF_CONFIG'  !< name of config file
    CHARACTER(LEN=*), PARAMETER ::  mode_binary = 'binary'                        !< string to select operation mode of module
-   CHARACTER(LEN=*), PARAMETER ::  prefix = 'BIN_'                               !< file prefix for binary files
-
+   CHARACTER(LEN=*), PARAMETER ::  file_prefix = 'BIN_'                          !< file prefix for binary files
+
+   CHARACTER(LEN=charlen)      ::  file_suffix = ''             !< file suffix added to each file name
    CHARACTER(LEN=800)          ::  internal_error_message = ''  !< string containing the last error message
    CHARACTER(LEN=800)          ::  temp_string                  !< dummy string
@@ -65,5 +66,7 @@
    INTEGER(iwp) ::  debug_output_unit               !< Fortran Unit Number of the debug-output file
    INTEGER(iwp) ::  global_id_in_file = -1          !< value of global ID within a file
+   INTEGER      ::  master_rank                     !< master rank for tasks to be executed by single PE only
    INTEGER(iwp) ::  next_available_unit             !< next unit number available for new file
+   INTEGER      ::  output_group_comm               !< MPI communicator addressing all MPI ranks which participate in output
 
    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  files_highest_var_id  !< highest assigned ID of variable or dimension in a file
@@ -133,7 +136,14 @@
 !> Initialize data-output module.
 !--------------------------------------------------------------------------------------------------!
-SUBROUTINE binary_init_module( program_debug_output_unit, debug_output, dom_global_id )
+SUBROUTINE binary_init_module( file_suffix_of_output_group, mpi_comm_of_output_group, &
+                               master_output_rank,                                    &
+                               program_debug_output_unit, debug_output, dom_global_id )
+
+   CHARACTER(LEN=*), INTENT(IN) ::  file_suffix_of_output_group  !> file-name suffix added to each file;
+                                                                 !> must be unique for each output group
 
    INTEGER(iwp), INTENT(IN) ::  dom_global_id              !< global id within a file defined by DOM
+   INTEGER,      INTENT(IN) ::  master_output_rank         !< MPI rank executing tasks which must be executed by a single PE
+   INTEGER,      INTENT(IN) ::  mpi_comm_of_output_group   !< MPI communicator specifying the rank group participating in output
    INTEGER(iwp), INTENT(IN) ::  program_debug_output_unit  !< file unit number for debug output
 
@@ -141,10 +151,12 @@
 
 
+   file_suffix = file_suffix_of_output_group
+   output_group_comm = mpi_comm_of_output_group
+   master_rank = master_output_rank
+
    debug_output_unit = program_debug_output_unit
-
    print_debug_output = debug_output
 
    global_id_in_file = dom_global_id
-
 
 END SUBROUTINE binary_init_module
@@ -159,5 +171,5 @@
    CHARACTER(LEN=charlen)             ::  bin_filename = ''  !< actual name of binary file
    CHARACTER(LEN=charlen), INTENT(IN) ::  filename           !< name of file
-   CHARACTER(LEN=7)                   ::  myid_char          !< string containing value of myid with leading zeros
+   CHARACTER(LEN=7)                   ::  my_rank_char       !< string containing value of my_rank with leading zeros
    CHARACTER(LEN=*),       INTENT(IN) ::  mode               !< operation mode
 
@@ -165,5 +177,6 @@
 
    INTEGER(iwp), INTENT(OUT) ::  file_id       !< file ID
-   INTEGER(iwp)              ::  myid          !< id of local processor id (MPI rank)
+   INTEGER                   ::  my_rank       !< MPI rank of local processor
+   INTEGER                   ::  nrank         !< number of MPI ranks participating in output
    INTEGER(iwp), INTENT(OUT) ::  return_value  !< return value
 
@@ -176,13 +189,15 @@
 
 #if defined( __parallel )
-   CALL MPI_COMM_RANK( MPI_COMM_WORLD, myid, return_value )
+   CALL MPI_COMM_SIZE( output_group_comm, nrank, return_value )
+   IF ( return_value == 0 )  CALL MPI_COMM_RANK( output_group_comm, my_rank, return_value )
    IF ( return_value == 0 )  THEN
-      WRITE( myid_char, '("_",I6.6)' )  myid
+      WRITE( my_rank_char, '("_",I6.6)' )  my_rank
    ELSE
-      CALL internal_message( 'debug', routine_name // ': MPI_COMM_RANK error' )
+      CALL internal_message( 'error', routine_name // ': MPI error' )
    ENDIF
 #else
-   myid = 0
-   myid_char = '_' // REPEAT('0', 6)
+   nrank = 1
+   my_rank = master_rank
+   WRITE( my_rank_char, '("_",I6.6)' )  my_rank
 #endif
 
@@ -196,17 +211,20 @@
       config_file_unit = binary_file_lowest_unit
 
-      IF ( myid == 0 )  THEN
+      IF ( my_rank == master_rank )  THEN
 
          !-- Remove any pre-existing file
-         INQUIRE( FILE=TRIM( config_file_name ), EXIST=file_exists )
+         INQUIRE( FILE=TRIM( config_file_name ) // TRIM( file_suffix ), &
+                  EXIST=file_exists )
 
          IF ( file_exists )  THEN
-            CALL internal_message( 'debug', routine_name //              &
-                                            ': Remove existing file ' // &
-                                            TRIM( config_file_name ) )
-            CALL SYSTEM( 'rm ' // TRIM( config_file_name ) )
+            CALL internal_message( 'debug', routine_name //     &
+                                   ': Remove existing file ' // &
+                                   TRIM( config_file_name ) // TRIM( file_suffix ) )
+            CALL EXECUTE_COMMAND_LINE(                                                &
+                    COMMAND='rm ' // TRIM( config_file_name ) // TRIM( file_suffix ), &
+                    WAIT=.TRUE., EXITSTAT=return_value )
          ENDIF
 
-         OPEN( config_file_unit, FILE=TRIM( config_file_name ), &
+         OPEN( config_file_unit, FILE=TRIM( config_file_name ) // TRIM( file_suffix ), &
                FORM='UNFORMATTED', STATUS='NEW', IOSTAT=return_value )
 
@@ -216,6 +234,8 @@
 
             !-- Write some general information to config file
-            WRITE( config_file_unit )  LEN( prefix )
-            WRITE( config_file_unit )  prefix
+            WRITE( config_file_unit )  nrank
+            WRITE( config_file_unit )  master_rank
+            WRITE( config_file_unit )  LEN( file_prefix )
+            WRITE( config_file_unit )  file_prefix
             WRITE( config_file_unit )  charlen
             WRITE( config_file_unit )  global_id_in_file
@@ -237,5 +257,5 @@
    IF ( return_value == 0 )  THEN
 
-      bin_filename = prefix // TRIM( filename ) // myid_char
+      bin_filename = file_prefix // TRIM( filename ) // TRIM( file_suffix ) // my_rank_char
 
       !-- Remove any pre-existing file
@@ -245,5 +265,6 @@
          CALL internal_message( 'debug', routine_name // &
                                          ': remove existing file ' // TRIM( bin_filename ) )
-         CALL SYSTEM( 'rm ' // TRIM( bin_filename ) )
+         CALL EXECUTE_COMMAND_LINE( COMMAND='rm ' // TRIM( bin_filename ), &
+                                    WAIT=.TRUE., EXITSTAT=return_value )
       ENDIF
 
@@ -256,5 +277,5 @@
 
          !-- Add filename to config file
-         IF ( myid == 0 )  THEN
+         IF ( my_rank == master_rank )  THEN
             WRITE( config_file_unit )  filename
          ENDIF
Index: /palm/trunk/SOURCE/data_output_module.f90
===================================================================
--- /palm/trunk/SOURCE/data_output_module.f90	(revision 4106)
+++ /palm/trunk/SOURCE/data_output_module.f90	(revision 4107)
@@ -136,4 +136,5 @@
 
    CHARACTER(LEN=charlen) ::  output_file_format = 'binary'  !< file format (namelist parameter)
+   CHARACTER(LEN=charlen) ::  output_file_suffix = ''        !< file suffix added to each file name
 
    CHARACTER(LEN=800) ::  internal_error_message = '' !< string containing the last error message
@@ -142,4 +143,6 @@
    INTEGER(iwp) ::  debug_output_unit  !< Fortran Unit Number of the debug-output file
    INTEGER(iwp) ::  nf                 !< number of files
+   INTEGER      ::  master_rank = 0    !< master rank for tasks to be executed by single PE only
+   INTEGER      ::  output_group_comm  !< MPI communicator addressing all MPI ranks which participate in output
 
    INTEGER(iwp), PARAMETER ::  no_var_id = -1  !< value of var_id if no variable is selected
@@ -223,18 +226,32 @@
 !> Initialize data-output module
 !--------------------------------------------------------------------------------------------------!
-SUBROUTINE dom_init( program_debug_output_unit, debug_output )
-
-   INTEGER(iwp), INTENT(IN) ::  program_debug_output_unit  !< file unit number for debug output
+SUBROUTINE dom_init( file_suffix_of_output_group, mpi_comm_of_output_group, master_output_rank, &
+                     program_debug_output_unit, debug_output )
+
+   CHARACTER(LEN=*), INTENT(IN), OPTIONAL ::  file_suffix_of_output_group  !< file-name suffix added to each file;
+                                                                           !> must be unique for each output group
+
+   INTEGER, INTENT(IN), OPTIONAL ::  master_output_rank         !< MPI rank executing tasks which must
+                                                                !> be executed by a single PE only
+   INTEGER, INTENT(IN)           ::  mpi_comm_of_output_group   !< MPI communicator specifying the MPI group
+                                                                !> which participate in the output
+   INTEGER, INTENT(IN)           ::  program_debug_output_unit  !< file unit number for debug output
 
    LOGICAL, INTENT(IN) ::  debug_output  !< if true, debug output is printed
 
 
+   IF ( PRESENT( file_suffix_of_output_group ) )  output_file_suffix = file_suffix_of_output_group
+   IF ( PRESENT( master_output_rank ) )  master_rank = master_output_rank
+
+   output_group_comm = mpi_comm_of_output_group
+
    debug_output_unit = program_debug_output_unit
-
    print_debug_output = debug_output
 
-   CALL binary_init_module( debug_output_unit, debug_output, no_var_id )
-
-   CALL netcdf4_init_module( debug_output_unit, debug_output, no_var_id )
+   CALL binary_init_module( output_file_suffix, output_group_comm, master_rank, &
+                            debug_output_unit, debug_output, no_var_id )
+
+   CALL netcdf4_init_module( output_file_suffix, output_group_comm, master_rank, &
+                            debug_output_unit, debug_output, no_var_id )
 
 END SUBROUTINE dom_init
Index: /palm/trunk/SOURCE/data_output_netcdf4_module.f90
===================================================================
--- /palm/trunk/SOURCE/data_output_netcdf4_module.f90	(revision 4106)
+++ /palm/trunk/SOURCE/data_output_netcdf4_module.f90	(revision 4107)
@@ -56,4 +56,5 @@
 
    CHARACTER(LEN=800) ::  internal_error_message = ''  !< string containing the last error message
+   CHARACTER(LEN=100) ::  file_suffix = ''             !< file suffix added to each file name
    CHARACTER(LEN=800) ::  temp_string                  !< dummy string
 
@@ -63,4 +64,6 @@
    INTEGER(iwp) ::  debug_output_unit       !< Fortran Unit Number of the debug-output file
    INTEGER(iwp) ::  global_id_in_file = -1  !< value of global ID within a file
+   INTEGER      ::  master_rank             !< master rank for tasks to be executed by single PE only
+   INTEGER      ::  output_group_comm       !< MPI communicator addressing all MPI ranks which participate in output
 
    LOGICAL ::  print_debug_output = .FALSE.  !< if true, debug output is printed
@@ -126,7 +129,14 @@
 !> Initialize data-output module.
 !--------------------------------------------------------------------------------------------------!
-SUBROUTINE netcdf4_init_module( program_debug_output_unit, debug_output, dom_global_id )
+SUBROUTINE netcdf4_init_module( file_suffix_of_output_group, mpi_comm_of_output_group, &
+                                master_output_rank,                                    &
+                                program_debug_output_unit, debug_output, dom_global_id )
+
+   CHARACTER(LEN=*), INTENT(IN) ::  file_suffix_of_output_group  !> file-name suffix added to each file;
+                                                                 !> must be unique for each output group
 
    INTEGER(iwp), INTENT(IN) ::  dom_global_id              !< global id within a file defined by DOM
+   INTEGER,      INTENT(IN) ::  master_output_rank         !< MPI rank executing tasks which must be executed by a single PE
+   INTEGER,      INTENT(IN) ::  mpi_comm_of_output_group   !< MPI communicator specifying the rank group participating in output
    INTEGER(iwp), INTENT(IN) ::  program_debug_output_unit  !< file unit number for debug output
 
@@ -134,6 +144,9 @@
 
 
+   file_suffix = file_suffix_of_output_group
+   output_group_comm = mpi_comm_of_output_group
+   master_rank = master_output_rank
+
    debug_output_unit = program_debug_output_unit
-
    print_debug_output = debug_output
 
@@ -155,4 +168,5 @@
 
    INTEGER(iwp), INTENT(OUT) ::  file_id       !< file ID
+   INTEGER                   ::  my_rank       !< MPI rank of processor
    INTEGER(iwp)              ::  nc_stat       !< netcdf return value
    INTEGER(iwp), INTENT(OUT) ::  return_value  !< return value
@@ -160,4 +174,5 @@
 
    return_value = 0
+   file_id = -1
 
    !-- Open new file
@@ -167,9 +182,26 @@
 
 #if defined( __netcdf4 )
-      nc_stat = NF90_CREATE( TRIM( filename ),                    &
-                             IOR( NF90_NOCLOBBER, NF90_NETCDF4 ), &
-                             file_id )
-#else
-      file_id = -1
+#if defined( __parallel )
+      CALL MPI_COMM_RANK( output_group_comm, my_rank, return_value )
+      IF ( return_value /= 0 )  THEN
+         CALL internal_message( 'error', routine_name // ': MPI_COMM_RANK error' )
+      ENDIF
+      IF ( my_rank /= master_rank )  THEN
+         return_value = 1
+         CALL internal_message( 'error', routine_name // &
+                                ': trying to define a NetCDF file in serial mode by an MPI ' // &
+                                'rank other than the master output rank. Serial NetCDF ' // &
+                                'files can only be defined by the master output rank!' )
+      ENDIF
+#else
+      my_rank = master_rank
+      return_value = 0
+#endif
+
+      IF ( return_value == 0 )  &
+         nc_stat = NF90_CREATE( TRIM( filename ) // TRIM( file_suffix ), &
+                                IOR( NF90_NOCLOBBER, NF90_NETCDF4 ), &
+                                file_id )
+#else
       nc_stat = 0
       return_value = 1
@@ -182,9 +214,8 @@
 
 #if defined( __parallel ) && defined( __netcdf4 ) && defined( __netcdf4_parallel )
-      nc_stat = NF90_CREATE( TRIM( filename ),                                       &
+      nc_stat = NF90_CREATE( TRIM( filename ) // TRIM( file_suffix ),                &
                              IOR( NF90_NOCLOBBER, IOR( NF90_NETCDF4, NF90_MPIIO ) ), &
-                             file_id, COMM = MPI_COMM_WORLD, INFO = MPI_INFO_NULL )
-#else
-      file_id = -1
+                             file_id, COMM = output_group_comm, INFO = MPI_INFO_NULL )
+#else
       nc_stat = 0
       return_value = 1
@@ -196,5 +227,4 @@
 
    ELSE
-      file_id = -1
       nc_stat = 0
       return_value = 1
@@ -205,5 +235,5 @@
 
 #if defined( __netcdf4 )
-   IF ( nc_stat /= NF90_NOERR )  THEN
+   IF ( nc_stat /= NF90_NOERR  .AND.  return_value == 0 )  THEN
       return_value = 1
       CALL internal_message( 'error', routine_name // ': NetCDF error while opening file "' // &
@@ -477,5 +507,5 @@
    INTEGER(iwp)              ::  d             !< loop index
    INTEGER(iwp), INTENT(IN)  ::  file_id       !< file ID
-   INTEGER(iwp)              ::  myid          !< id number of processor element
+   INTEGER                   ::  my_rank       !< MPI rank of processor
    INTEGER(iwp)              ::  nc_stat       !< netcdf return value
    INTEGER(iwp)              ::  ndim          !< number of dimensions of variable in file
@@ -532,14 +562,14 @@
 
 #if defined( __parallel )
-   CALL MPI_COMM_RANK( MPI_COMM_WORLD, myid, return_value )
+   CALL MPI_COMM_RANK( output_group_comm, my_rank, return_value )
    IF ( return_value /= 0 )  THEN
       CALL internal_message( 'error', routine_name // ': MPI_COMM_RANK error' )
    ENDIF
 #else
-   myid = 0
+   my_rank = master_rank
    return_value = 0
 #endif
 
-   IF ( return_value == 0  .AND.  ( .NOT. is_global  .OR.  myid == 0 ) )  THEN
+   IF ( return_value == 0  .AND.  ( .NOT. is_global  .OR.  my_rank == master_rank ) )  THEN
 
       WRITE( temp_string, * ) var_id
Index: /palm/trunk/UTIL/binary_to_netcdf.f90
===================================================================
--- /palm/trunk/UTIL/binary_to_netcdf.f90	(revision 4106)
+++ /palm/trunk/UTIL/binary_to_netcdf.f90	(revision 4107)
@@ -82,18 +82,23 @@
 
 
-   CHARACTER(LEN=200)            ::  temp_string      !< dummy string
-
-   CHARACTER(LEN=:), ALLOCATABLE ::  filename_prefix  !< prefix of names of files to be read
-
-   CHARACTER(LEN=*), PARAMETER   ::  routine_name = 'binary_to_netcdf'             !< name of routine
-   CHARACTER(LEN=*), PARAMETER   ::  config_file_name = 'BINARY_TO_NETCDF_CONFIG'  !< name of configuration file
-
-   CHARACTER(LEN=charlen_internal), DIMENSION(:), ALLOCATABLE ::  filename_list  !< list of netcdf file names
+   CHARACTER(LEN=charlen_internal)                            ::  temp_string      !< dummy string
+   CHARACTER(LEN=:),                              ALLOCATABLE ::  filename_prefix  !< prefix of names of files to be read
+   CHARACTER(LEN=charlen_internal), DIMENSION(:), ALLOCATABLE ::  group_names      !< names of output groups
+   CHARACTER(LEN=charlen_internal), DIMENSION(:), ALLOCATABLE ::  filename_list    !< list of netcdf file names
+
+   CHARACTER(LEN=*), PARAMETER   ::  routine_name = 'binary_to_netcdf'                  !< name of routine
+   CHARACTER(LEN=*), PARAMETER   ::  config_file_name_base = 'BINARY_TO_NETCDF_CONFIG'  !< name of config file
+   CHARACTER(LEN=*), PARAMETER   ::  &
+      config_file_list_name = 'BINARY_CONFIG_LIST'  !< file containing list of binary config files of each output group
 
    INTEGER(iwp) ::  charlen            !< length of characters (strings) in binary file
    INTEGER(iwp) ::  dom_global_id      !< global ID within a single file defined by DOM
+   INTEGER      ::  dom_master_rank    !< master MPI rank in DOM (rank which wrote additional information in DOM)
+   INTEGER      ::  dom_nrank          !< number of MPI ranks used by DOM
    INTEGER(iwp) ::  file_index         !< loop index to loop over files
+   INTEGER      ::  group              !< loop index to loop over groups
    INTEGER(iwp) ::  nc_file_id         !< ID of netcdf output file
    INTEGER(iwp) ::  nfiles             !< number of output files defined in config file
+   INTEGER      ::  ngroup             !< number of output-file groups
    INTEGER      ::  return_value       !< return value
    INTEGER      ::  your_return_value  !< returned value of called routine
@@ -104,6 +109,7 @@
    INTEGER(iwp)    ::  dummy_intwp  !< dummy variable used for reading
 
-   INTEGER, PARAMETER ::  bin_file_unit = 2     !< Fortran unit of binary file
-   INTEGER, PARAMETER ::  config_file_unit = 1  !< Fortran unit of configuration file
+   INTEGER, PARAMETER ::  bin_file_unit = 12          !< Fortran unit of binary file
+   INTEGER, PARAMETER ::  config_file_unit = 11       !< Fortran unit of configuration file
+   INTEGER, PARAMETER ::  config_file_list_unit = 10  !< Fortran unit of file containing config-file list
 
    INTEGER, DIMENSION(:), ALLOCATABLE ::  dim_id_netcdf  !< mapped dimension id within NetCDF file:
@@ -126,35 +132,51 @@
    return_value = 0
 
-   CALL internal_message( 'info', routine_name // ': Start converting binary files...' )
-
-   CALL read_config( your_return_value )
-
-   IF ( your_return_value == 0 )  THEN
-      DO  file_index = 1, nfiles
-
-         CALL internal_message( 'info', routine_name // &
-                                ': create file ' // TRIM( filename_list(file_index) ) )
-
-         CALL read_binary_header( TRIM( filename_list(file_index) ), your_return_value )
+   CALL internal_message( 'info', 'Start ' // routine_name // ' ...' )
+
+   CALL get_group_names( return_value )
+
+   IF ( return_value == 0 )  THEN
+
+      !-- Go through each group of output files (all marked by same file suffix)
+      DO  group = 1, ngroup
+
+         CALL internal_message( 'info', 'Start converting ' // TRIM( group_names(group) ) // &
+                                ' binary files:' )
+
+         CALL read_config( TRIM( group_names(group) ), your_return_value )
 
          IF ( your_return_value == 0 )  THEN
-            CALL define_netcdf_files( TRIM( filename_list(file_index) ), your_return_value )
+            DO  file_index = 1, nfiles
+
+               CALL internal_message( 'info', 'Create file ' // TRIM( filename_list(file_index) ) )
+
+               CALL read_binary_header( TRIM( filename_list(file_index) ), your_return_value )
+
+               IF ( your_return_value == 0 )  THEN
+                  CALL define_netcdf_files( TRIM( filename_list(file_index) ), your_return_value )
+               ELSE
+                  return_value = your_return_value
+               ENDIF
+
+               IF ( your_return_value == 0 )  THEN
+                  CALL convert_data_to_netcdf( TRIM( filename_list(file_index) ), your_return_value )
+               ELSE
+                  return_value = your_return_value
+               ENDIF
+
+            ENDDO
          ELSE
             return_value = your_return_value
          ENDIF
 
-         IF ( your_return_value == 0 )  THEN
-            CALL convert_data_to_netcdf( TRIM( filename_list(file_index) ), your_return_value )
-         ELSE
-            return_value = your_return_value
-         ENDIF
+         IF ( ALLOCATED( filename_list   ) )  DEALLOCATE( filename_list   )
+         IF ( ALLOCATED( filename_prefix ) )  DEALLOCATE( filename_prefix )
 
       ENDDO
-   ELSE
-      return_value = your_return_value
+
    ENDIF
 
    IF ( return_value == 0 )  THEN
-      CALL internal_message( 'info', routine_name // ': Execution finished' )
+      CALL internal_message( 'info', 'Execution finished' )
    ELSE
       CALL internal_message( 'error', routine_name // ': Error during execution! Check results!' )
@@ -168,10 +190,95 @@
 ! Description:
 ! ------------
+!> Check if any configuration file is present in the current directory and get the list of all
+!> these files and extract the output-group names.
+!--------------------------------------------------------------------------------------------------!
+SUBROUTINE get_group_names( return_value )
+
+   CHARACTER(LEN=charlen_internal) ::  file_name  !< file name read from list
+
+   CHARACTER(LEN=*), PARAMETER ::  routine_name = 'get_group_names'  !< name of routine
+
+   INTEGER              ::  i             !< loop index
+   INTEGER              ::  io_stat       !< status of Fortran I/O operations
+   INTEGER, INTENT(OUT) ::  return_value  !< return value
+
+
+   CALL internal_message( 'info', 'Check if anything to convert...' )
+
+   !-- Search for configuration files and save the list of file names in a separate file
+   CALL EXECUTE_COMMAND_LINE( &
+           COMMAND='find . -type f -name "' // config_file_name_base // '*" | ' // &
+                   'sed -r "s/^\.\/(' // config_file_name_base // ')?(.+)$/\1\2/" > ' // &
+                   config_file_list_name, &
+           WAIT=.TRUE., &
+           EXITSTAT=return_value )
+
+   !-- Read the config-file-name list and extract the group names from the file names
+   IF ( return_value /= 0 )  THEN
+
+      CALL internal_message( 'error', routine_name // &
+                             ': error while searching for configuration files: ' // &
+                             'System returned non-zero exit status. ' // &
+                             'Please report this error to the developers!' )
+
+   ELSE
+
+      OPEN( config_file_list_unit, FILE=config_file_list_name, FORM='formatted', &
+            STATUS='OLD', IOSTAT=io_stat )
+
+      !-- Count the configuration files
+      ngroup = 0
+      DO WHILE ( io_stat == 0 )
+         READ( config_file_list_unit, '(A)', IOSTAT=io_stat )  file_name
+         IF ( io_stat == 0 )  ngroup = ngroup + 1
+      ENDDO
+      REWIND( config_file_list_unit )
+
+      IF ( ngroup /= 0 )  THEN
+
+         ALLOCATE( group_names(ngroup) )
+
+         !-- Extract the group names
+         DO  i = 1, ngroup
+            READ( config_file_list_unit, '(A)', IOSTAT=io_stat )  file_name
+            IF ( INDEX( TRIM( file_name ), config_file_name_base ) == 1 )  THEN
+               IF ( TRIM( file_name ) ==  TRIM( config_file_name_base ) )  THEN
+                  group_names(i) = ''
+               ELSE
+                  group_names(i) = file_name(LEN_TRIM( config_file_name_base )+1:)
+               ENDIF
+            ELSE
+               return_value = 1
+               CALL internal_message( 'error', routine_name // &
+                                      ': error while getting list of binary config files: ' // &
+                                      'Unexpected text found in file list. ' // &
+                                      'Please report this error to the developers!' )
+               EXIT
+            ENDIF
+         ENDDO
+
+      ELSE
+         CALL internal_message( 'info', 'No configuration files found. ' // &
+                                'No binary files to convert to NetCDF.' )
+      ENDIF
+
+      CLOSE( config_file_list_unit )
+
+   ENDIF
+
+END SUBROUTINE get_group_names
+
+!--------------------------------------------------------------------------------------------------!
+! Description:
+! ------------
 !> Read configuration file.
 !--------------------------------------------------------------------------------------------------!
-SUBROUTINE read_config( return_value )
+SUBROUTINE read_config( group_name, return_value )
 
    CHARACTER(LEN=:), ALLOCATABLE ::  read_string                   !< string read from file
+   CHARACTER(LEN=*), INTENT(IN)  ::  group_name                    !< group name
    CHARACTER(LEN=*), PARAMETER   ::  routine_name = 'read_config'  !< name of routine
+
+   CHARACTER(LEN=charlen_internal) ::  config_file_name  !< config file name with additional suffix
 
    CHARACTER(LEN=charlen_internal), DIMENSION(:), ALLOCATABLE ::  filename_list_tmp  !< temporary list of file names
@@ -183,4 +290,6 @@
 
    return_value = 0
+
+   config_file_name = config_file_name_base // group_name
 
    OPEN( config_file_unit, FILE=config_file_name, FORM='unformatted', &
@@ -196,4 +305,14 @@
    IF ( return_value == 0 )  THEN
 
+      READ( config_file_unit ) dom_nrank
+
+      IF ( dom_nrank > 1000000 )  THEN
+         dom_nrank = 1000000
+         CALL internal_message( 'info', routine_name // &
+                 ': number of MPI ranks used in PALM is greater than the maximum ' // &
+                 'amount I can handle. I will only consider the first 1000000 output files.' )
+      ENDIF
+
+      READ( config_file_unit ) dom_master_rank
       READ( config_file_unit ) filename_prefix_length
 
@@ -201,7 +320,5 @@
 
       READ( config_file_unit ) filename_prefix
-
       READ( config_file_unit ) charlen
-
       READ( config_file_unit ) dom_global_id
 
@@ -233,5 +350,5 @@
                ENDIF
 
-               filename_list(nfiles) = TRIM( read_string )
+               filename_list(nfiles) = TRIM( read_string ) // group_name
 
             ENDIF
@@ -280,6 +397,7 @@
    return_value = 0
 
-   !-- Open binary file of PE0
-   bin_filename = TRIM( filename_prefix ) // TRIM( bin_filename_body ) // '_000000'
+   !-- Open binary file written by dom_master_rank
+   WRITE( bin_filename , '(A,I6.6)' ) &
+      TRIM( filename_prefix ) // TRIM( bin_filename_body ) // '_', dom_master_rank
 
    CALL internal_message( 'debug', routine_name // ': read file ' // TRIM( bin_filename ) )
@@ -426,4 +544,6 @@
    ENDDO  ! iterate over file header
 
+   CLOSE( bin_file_unit )
+
 END SUBROUTINE read_binary_header
 
@@ -679,5 +799,5 @@
 
    !-- Open binary files of every possible PE
-   DO  pe_id = 0, 999999
+   DO  pe_id = 0, dom_nrank - 1
 
       WRITE( bin_filename, '(A, I6.6)' ) &
@@ -689,42 +809,37 @@
       IF ( file_exists )  THEN
 
-         !-- Open file and skip header (file of PE0 is already opened)
-         IF ( pe_id /= 0 )  THEN
-
-            OPEN( bin_file_unit, FILE=bin_filename, FORM='UNFORMATTED', STATUS='OLD' )
-
-            CALL internal_message( 'debug', routine_name // &
-                                   ': read binary file ' // TRIM( bin_filename ) )
-
-            read_string = ''
-            DO WHILE ( TRIM( read_string ) /= '*** end file header ***' )
-
-               READ( bin_file_unit ) read_string
-
-               SELECT CASE ( TRIM( read_string ) )
-
-                  CASE ( 'char' )
-                     READ( bin_file_unit ) read_string
-
-                  CASE ( 'int8' )
-                     READ( bin_file_unit ) dummy_int8
-
-                  CASE ( 'int16' )
-                     READ( bin_file_unit ) dummy_int16
-
-                  CASE ( 'int32' )
-                     READ( bin_file_unit ) dummy_int32
-
-                  CASE ( 'real32' )
-                     READ( bin_file_unit ) dummy_real32
-
-                  CASE ( 'real64' )
-                     READ( bin_file_unit ) dummy_real64
-
-               END SELECT
-
-            ENDDO
-
-         ENDIF
+         OPEN( bin_file_unit, FILE=bin_filename, FORM='UNFORMATTED', STATUS='OLD' )
+
+         CALL internal_message( 'debug', routine_name // &
+                                ': read binary file ' // TRIM( bin_filename ) )
+
+         read_string = ''
+         DO WHILE ( TRIM( read_string ) /= '*** end file header ***' )
+
+            READ( bin_file_unit ) read_string
+
+            SELECT CASE ( TRIM( read_string ) )
+
+               CASE ( 'char' )
+                  READ( bin_file_unit ) read_string
+
+               CASE ( 'int8' )
+                  READ( bin_file_unit ) dummy_int8
+
+               CASE ( 'int16' )
+                  READ( bin_file_unit ) dummy_int16
+
+               CASE ( 'int32' )
+                  READ( bin_file_unit ) dummy_int32
+
+               CASE ( 'real32' )
+                  READ( bin_file_unit ) dummy_real32
+
+               CASE ( 'real64' )
+                  READ( bin_file_unit ) dummy_real64
+
+            END SELECT
+
+         ENDDO
 
          !-- Read variable data
@@ -873,8 +988,4 @@
          CLOSE( bin_file_unit )
 
-      ELSE
-
-         EXIT
-
       ENDIF  ! if file exists
 
