Index: palm/trunk/UTIL/Makefile
===================================================================
--- palm/trunk/UTIL/Makefile	(revision 4901)
+++ 	(revision )
@@ -1,80 +1,0 @@
-#--------------------------------------------------------------------------------#
-# This file is part of PALM.
-#
-# PALM is free software: you can redistribute it and/or modify it under the terms
-# of the GNU General Public License as published by the Free Software Foundation,
-# either version 3 of the License, or (at your option) any later version.
-#
-# PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# PALM. If not, see <http://www.gnu.org/licenses/>.
-#
-# Copyright 1997-2021  Leibniz Universitaet Hannover
-#--------------------------------------------------------------------------------#
-#
-# Current revisions:
-# -----------------
-#
-# Former revisions:
-# -----------------
-# $Id$
-#
-# 1046 2012-11-09 14:38:45Z maronga
-# code put under GPL (PALM 3.9)
-#
-# utility programs are created separately for each block in the configuration
-# file,
-# compare_palm_logs added
-# added PROG3 in 'all:' statement (line 39, bugfix)
-#
-# Initial revision somewhere in 2003/04
-#
-# Description:
-# ------------
-# Makefile for generating the utility programs needed by mrun and palm
-#--------------------------------------------------------------------------------#
-
-PROG1 =  ../SCRIPTS/combine_plot_fields$(BLOCK).x
-PROG2 =  ../SCRIPTS/compare_palm_logs$(BLOCK).x
-PROG3 =  ../SCRIPTS/interpret_config$(BLOCK).x
-
-OBJS1 =  combine_plot_fields.o
-OBJS2 =  compare_palm_logs.o
-OBJS3 =  interpret_config.o
-
-CC = cc
-CFLAGS = -O
-
-F90 = mpif90
-F90_SER = gfortran
-COPT = -cpp -DMPI_REAL=MPI_DOUBLE_PRECISION -DMPI_2REAL=MPI_2DOUBLE_PRECISION -D__netcdf
-F90FLAGS = -fcheck=all -fdefault-real-8 -fconvert=little-endian
-LDFLAGS  = -fcheck=all -fdefault-real-8 -fconvert=little-endian
-
-PKG_CONFIG      := PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config
-NETCDF_F90FLAGS != $(PKG_CONFIG) --cflags netcdf-fortran
-NETCDF_LDFLAGS  != $(PKG_CONFIG) --libs netcdf-fortran
-F90FLAGS        += $(NETCDF_F90FLAGS)
-LDFLAGS         += $(NETCDF_LDFLAGS)
-
-.SUFFIXES: $(SUFFIXES) .f90
-
-
-all: $(PROG1) $(PROG2) $(PROG3)
-
-$(PROG1): $(OBJS1)
-	$(F90_SER) -o $(PROG1) $(OBJS1) $(LDFLAGS)
-
-$(PROG2): $(OBJS2)
-	$(F90_SER) -o $(PROG2) $(OBJS2) $(LDFLAGS)
-
-$(PROG3): $(OBJS3)
-	$(F90_SER) -o $(PROG3) $(OBJS3) $(LDFLAGS)
-
-.f90.o:
-	$(F90_SER) $(F90FLAGS) $(COPT) -c $<
-
-
Index: palm/trunk/UTIL/Makefile_utilities
===================================================================
--- palm/trunk/UTIL/Makefile_utilities	(revision 4901)
+++ 	(revision )
@@ -1,168 +1,0 @@
-#------------------------------------------------------------------------------#
-# This file is part of the PALM model system.
-#
-# PALM is free software: you can redistribute it and/or modify it under the terms
-# of the GNU General Public License as published by the Free Software Foundation,
-# either version 3 of the License, or (at your option) any later version.
-#
-# PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# PALM. If not, see <http://www.gnu.org/licenses/>.
-#
-# Copyright 1997-2021  Leibniz Universitaet Hannover
-#------------------------------------------------------------------------------#
-#
-# Current revisions:
-# -----------------
-# 
-# 
-# Former revisions:
-# -----------------
-# $Id$
-# Use PALM's kinds module in inifor
-# 
-# 
-# 3795 2019-03-15 09:40:05Z eckhard
-# Upated inifor build dependencies
-# 
-# 3793 2019-03-15 08:31:37Z raasch
-# bugfix for suffix setting
-# 
-# 3757 2019-02-20 11:40:34Z suehring
-# Disable build of surface-output processing tool
-# 
-# 3534 2018-11-19 15:35:16Z raasch
-# inifor build added
-# 
-# 3523 2018-11-13 16:09:31Z suehring
-# Enable compilation of post-processing tool for surface output - interface
-# for posix conform sytemcalls is implemented.
-# 
-# 3499 2018-11-07 10:55:15Z suehring
-# Temporarily avoid compilation of post-processing tool for surface output
-# until a workaround for compiler-specific intrinsic functions is found.
-# 
-# 3494 2018-11-06 14:51:27Z suehring
-# Added make directive for surface-output post-processing
-# 
-# 3208 2018-08-27 13:10:50Z sward
-# Added make directive for agent_preprocessing tool
-# 
-# 2718 2018-01-02 08:49:38Z maronga
-# Corrected "Former revisions" section
-# 
-# 2696 2017-12-14 17:12:51Z kanani
-# Change in file header (GPL part)
-#
-# 2380 2017-09-01 08:33:46Z raasch
-# file renamed to Makefile_utilities
-# executables are created in current working directory
-# interpret_config removed
-#
-# 1046 2012-11-09 14:38:45Z maronga
-# code put under GPL (PALM 3.9)
-#
-# utility programs are created separately for each block in the configuration
-# file,
-# compare_palm_logs added
-# added PROG3 in 'all:' statement (line 39, bugfix)
-#
-# Initial revision somewhere in 2003/04
-#
-# Description:
-# ------------
-# Makefile for generating the utility programs required by mrun and palm
-#------------------------------------------------------------------------------#
-
-PROG1 =  combine_plot_fields.x
-PROG2 =  compare_palm_logs.x
-PROG3 =  agent_preprocessing
-#PROG4 =  surface_output_to_vtk
-PROG5 =  inifor
-
-SOURCES5 = \
-	 inifor.f90 \
-	 inifor_control.f90 \
-	 inifor_defs.f90 \
-	 inifor_grid.f90 \
-	 inifor_io.f90 \
-	 inifor_transform.f90 \
-	 inifor_types.f90 \
-	 inifor_util.f90
-
-
-OBJS1 =  combine_plot_fields.o
-OBJS2 =  compare_palm_logs.o
-OBJS3 =  agent_preprocessing.o
-#OBJS4 =  surface_output_to_vtk.o
-OBJS5=$(SOURCES5:.f90=.o)
-
-CC = cc
-CFLAGS = -O
-
-F90 =
-F90_SER =
-COPT =
-F90FLAGS =
-LDFLAGS =
-
-.SUFFIXES:
-.SUFFIXES: .o .f90
-
-
-all: $(PROG1) $(PROG2) $(PROG3) $(PROG4) $(PROG5)
-
-$(PROG1): $(OBJS1)
-	$(F90_SER) -o $(PROG1) $(OBJS1) $(LDFLAGS)
-
-$(PROG2): $(OBJS2)
-	$(F90_SER) -o $(PROG2) $(OBJS2) $(LDFLAGS)
-
-$(PROG3): $(OBJS3)
-	$(F90_SER) -o $(PROG3) $(OBJS3) $(LDFLAGS)
-
-$(PROG4): $(OBJS4)
-	$(F90_SER) -o $(PROG4) $(OBJS4) $(LDFLAGS)
-
-$(PROG5): $(OBJS5)
-	$(F90_SER) -o $(PROG5) $(OBJS5) $(LDFLAGS)
-
-.f90.o:
-	$(F90_SER) $(F90FLAGS) $(COPT) -c $<
-
-
-inifor.o: \
-	inifor_control.o \
-	inifor_defs.o \
-	inifor_grid.o \
-	inifor_io.o \
-	inifor_transform.o \
-	inifor_types.o
-inifor_control.o: \
-	inifor_defs.o \
-	inifor_util.o
-inifor_grid.o: \
-	inifor_control.o \
-	inifor_defs.o \
-	inifor_io.o \
-	inifor_transform.o \
-	inifor_types.o \
-	inifor_util.o
-inifor_io.o: \
-	inifor_control.o \
-	inifor_defs.o \
-	inifor_types.o \
-	inifor_util.o
-inifor_transform.o: \
-	inifor_control.o \
-	inifor_defs.o \
-	inifor_types.o \
-	inifor_util.o
-inifor_types.o: \
-	inifor_defs.o
-inifor_util.o: \
-	inifor_defs.o \
-	inifor_types.o
Index: palm/trunk/UTIL/analyze_particle_data.f90
===================================================================
--- palm/trunk/UTIL/analyze_particle_data.f90	(revision 4901)
+++ palm/trunk/UTIL/analyze_particle_data.f90	(revision 1)
@@ -1,38 +1,12 @@
  PROGRAM analyze_particle_data
-!------------------------------------------------------------------------------!
-! This file is part of the PALM model system.
-!
-! PALM is free software: you can redistribute it and/or modify it under the
-! terms of the GNU General Public License as published by the Free Software
-! Foundation, either version 3 of the License, or (at your option) any later
-! version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with
-! PALM. If not, see <http://www.gnu.org/licenses/>.
-!
-! Copyright 1997-2021  Leibniz Universitaet Hannover
-!------------------------------------------------------------------------------!
-!
-! Current revisions:
+
+!-------------------------------------------------------------------------------!
+! Actual revisions:
 ! -----------------
 ! 
-! 
+!
 ! Former revisions:
 ! -----------------
-! $Id$
-! Corrected "Former revisions" section
-!
-! 2696 2017-12-14 17:12:51Z kanani
-! Change in file header (GPL part)
-!
-! 1310 2014-03-14 08:01:56Z raasch
-! update of GPL copyright
-!
-! 1046 2012-11-09 14:38:45Z maronga
-! code put under GPL (PALM 3.9)
+! 
 !
 ! Description:
@@ -40,5 +14,5 @@
 ! This routine reads the particle data files generated by PALM
 ! and does some statistical analysis on these data.
-!------------------------------------------------------------------------------!
+!-------------------------------------------------------------------------------!
 
     IMPLICIT NONE
Index: palm/trunk/UTIL/analyze_particle_netcdf_data.f90
===================================================================
--- palm/trunk/UTIL/analyze_particle_netcdf_data.f90	(revision 4901)
+++ palm/trunk/UTIL/analyze_particle_netcdf_data.f90	(revision 1)
@@ -2,39 +2,10 @@
 
 !------------------------------------------------------------------------------!
-! This file is part of the PALM model system.
-!
-! PALM is free software: you can redistribute it and/or modify it under the
-! terms of the GNU General Public License as published by the Free Software
-! Foundation, either version 3 of the License, or (at your option) any later
-! version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with
-! PALM. If not, see <http://www.gnu.org/licenses/>.
-!
-! Copyright 1997-2021  Leibniz Universitaet Hannover
-!------------------------------------------------------------------------------!
-!
-! Current revisions:
+! Actual revisions:
 ! -----------------
 ! 
-! 
+!
 ! Former revisions:
 ! -----------------
-! $Id$
-! Corrected "Former revisions" section
-!
-! 2696 2017-12-14 17:12:51Z kanani
-! Change in file header (GPL part)
-!
-! 1310 2014-03-14 08:01:56Z raasch
-! update of GPL copyright
-!
-! 1046 2012-11-09 14:38:45Z maronga
-! code put under GPL (PALM 3.9)
-!
 ! Initial revision 12/07/05
 !
Index: palm/trunk/UTIL/binary_to_netcdf.f90
===================================================================
--- palm/trunk/UTIL/binary_to_netcdf.f90	(revision 4901)
+++ 	(revision )
@@ -1,1038 +1,0 @@
-!> @file binary_to_netcdf.f90
-!--------------------------------------------------------------------------------------------------!
-! This file is part of the PALM model system.
-!
-! PALM is free software: you can redistribute it and/or modify it under the
-! terms of the GNU General Public License as published by the Free Software
-! Foundation, either version 3 of the License, or (at your option) any later
-! version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with
-! PALM. If not, see <http://www.gnu.org/licenses/>.
-!
-! Copyright 2019-2021 Leibniz Universitaet Hannover
-!--------------------------------------------------------------------------------------------------!
-!
-! Current revisions:
-! ------------------
-!
-!
-! Former revisions:
-! -----------------
-! $Id$
-! Initial revision
-!
-!
-! Authors:
-! --------
-!> @author Viola Weniger
-!> @author Tobias Gronemeier
-!> @author Helge Knoop
-!
-!--------------------------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> This program reads binary output files written by DOM (the data-output module of PALM) and
-!> converts the data into NetCDF files.
-!>
-!> @todo Change style of printed messages to terminal in accordance to PALM termial output.
-!--------------------------------------------------------------------------------------------------!
-PROGRAM binary_to_netcdf
-
-   USE NETCDF
-
-   IMPLICIT NONE
-
-   !-- Set kinds to be used as defaults
-   INTEGER, PARAMETER ::  iwp = 4  !< default integer kind for output-variable values
-   INTEGER, PARAMETER ::  wp  = 8  !< default real kind for output-variable values
-
-   INTEGER, PARAMETER ::  charlen_internal = 1000  !< length of strings within this program
-
-
-   TYPE attribute_type
-      CHARACTER(LEN=charlen_internal) ::  data_type     !< data type of attribute value
-      CHARACTER(LEN=charlen_internal) ::  name          !< name of attribute
-      CHARACTER(LEN=charlen_internal) ::  value_char    !< character value
-      INTEGER                         ::  variable_id   !< id of variable to which the attribute belongs to
-      INTEGER(KIND=1)                 ::  value_int8    !< 8bit integer value
-      INTEGER(KIND=2)                 ::  value_int16   !< 16bit integer value
-      INTEGER(KIND=4)                 ::  value_int32   !< 32bit integer value
-      REAL(KIND=4)                    ::  value_real32  !< 32bit real value
-      REAL(KIND=8)                    ::  value_real64  !< 64bit real value
-   END TYPE attribute_type
-
-   TYPE dimension_type
-      CHARACTER(LEN=charlen_internal) ::  data_type  !< data type of dimension
-      CHARACTER(LEN=charlen_internal) ::  name       !< dimension name
-      INTEGER                         ::  id         !< dimension id within file
-      INTEGER                         ::  length     !< length of dimension
-   END TYPE dimension_type
-
-   TYPE variable_type
-      CHARACTER(LEN=charlen_internal)    ::  data_type      !< data type of variable
-      CHARACTER(LEN=charlen_internal)    ::  name           !< variable name
-      INTEGER                            ::  id             !< variable id within file
-      INTEGER, DIMENSION(:), ALLOCATABLE ::  dimension_ids  !< list of dimension ids used by variable
-   END TYPE variable_type
-
-
-   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 ::  charlen            !< length of characters (strings) in binary file
-   INTEGER ::  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_nranks         !< number of MPI ranks used by DOM
-   INTEGER ::  file_index         !< loop index to loop over files
-   INTEGER ::  group              !< loop index to loop over groups
-   INTEGER ::  nc_file_id         !< ID of netcdf output file
-   INTEGER ::  nfiles             !< number of output files defined in config file
-   INTEGER ::  ngroups            !< number of output-file groups
-   INTEGER ::  return_value       !< return value
-   INTEGER ::  your_return_value  !< returned value of called routine
-
-   INTEGER(KIND=1) ::  dummy_int8   !< dummy variable used for reading
-   INTEGER(KIND=2) ::  dummy_int16  !< dummy variable used for reading
-   INTEGER(KIND=4) ::  dummy_int32  !< dummy variable used for reading
-   INTEGER         ::  dummy_int    !< dummy variable used for reading
-
-   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 ::  dimension_id_netcdf  !< mapped dimension id within NetCDF file:
-                                                         !> dimension_list(i)%id and dimension_id_netcdf(dimension_list(i)%id)
-                                                         !> reference the same dimension
-   INTEGER, DIMENSION(:), ALLOCATABLE ::  variable_id_netcdf  !< mapped variable id within NetCDF file:
-                                                         !> variable_list(i)%id and variable_id_netcdf(variable_list(i)%id)
-                                                         !> reference the same variable
-
-   LOGICAL ::  print_debug_output = .FALSE.  !< if true, print debug output to STDOUT
-
-   REAL(KIND=4) ::  dummy_real32  !< dummy variable used for reading
-   REAL(KIND=8) ::  dummy_real64  !< dummy variable used for reading
-
-   TYPE(attribute_type), DIMENSION(:), ALLOCATABLE ::  attribute_list  !< list containing all attributes of a file
-   TYPE(dimension_type), DIMENSION(:), ALLOCATABLE ::  dimension_list  !< list containing all dimensions of a file
-   TYPE(variable_type),  DIMENSION(:), ALLOCATABLE ::  variable_list   !< list containing all variables of a file
-
-
-   return_value = 0
-
-   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, ngroups
-
-         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
-            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 ( ALLOCATED( filename_list   ) )  DEALLOCATE( filename_list   )
-         IF ( ALLOCATED( filename_prefix ) )  DEALLOCATE( filename_prefix )
-
-      ENDDO
-
-   ENDIF
-
-   IF ( return_value == 0 )  THEN
-      CALL internal_message( 'info', 'Execution finished' )
-   ELSE
-      CALL internal_message( 'error', routine_name // ': Error during execution! Check results!' )
-      STOP 1
-   ENDIF
-
-CONTAINS
-
-
-!--------------------------------------------------------------------------------------------------!
-! 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
-      ngroups = 0
-      DO WHILE ( io_stat == 0 )
-         READ( config_file_list_unit, '(A)', IOSTAT=io_stat )  file_name
-         IF ( io_stat == 0 )  ngroups = ngroups + 1
-      ENDDO
-      REWIND( config_file_list_unit )
-
-      IF ( ngroups /= 0 )  THEN
-
-         ALLOCATE( group_names(ngroups) )
-
-         !-- Extract the group names
-         DO  i = 1, ngroups
-            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( 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
-
-   INTEGER              ::  filename_prefix_length  !< length of string containing the filname prefix
-   INTEGER              ::  io_stat                 !< status of Fortran I/O operations
-   INTEGER, INTENT(OUT) ::  return_value            !< return value of routine
-
-
-   return_value = 0
-
-   config_file_name = config_file_name_base // group_name
-
-   OPEN( config_file_unit, FILE=config_file_name, FORM='unformatted', &
-         STATUS='OLD', IOSTAT=io_stat )
-
-   IF ( io_stat /= 0 )  THEN
-      return_value = 1
-      CALL internal_message( 'error', routine_name // &
-                             ': error while opening configuration file "' // &
-                             TRIM( config_file_name ) // '"' )
-   ENDIF
-
-   IF ( return_value == 0 )  THEN
-
-      READ( config_file_unit ) dom_nranks
-
-      IF ( dom_nranks > 1000000 )  THEN
-         dom_nranks = 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
-
-      ALLOCATE( CHARACTER(filename_prefix_length)::filename_prefix )
-
-      READ( config_file_unit ) filename_prefix
-      READ( config_file_unit ) charlen
-      READ( config_file_unit ) dom_global_id
-
-      !-- Read the list of output file names
-      ALLOCATE( CHARACTER(LEN=charlen) ::  read_string )
-      nfiles = 0
-      DO WHILE ( io_stat == 0 )
-
-         READ( config_file_unit, IOSTAT=io_stat )  read_string
-
-         IF ( io_stat == 0 )  THEN
-
-            IF ( TRIM( read_string ) == '*** end config file ***' )  THEN
-               EXIT
-            ELSE
-
-               !-- Extend the list of file names if necessary
-               IF ( .NOT. ALLOCATED( filename_list ) )  THEN
-                  nfiles = 1
-                  ALLOCATE( filename_list(nfiles) )
-               ELSE
-                  ALLOCATE( filename_list_tmp(nfiles) )
-                  filename_list_tmp = filename_list
-                  DEALLOCATE( filename_list )
-                  nfiles = nfiles + 1
-                  ALLOCATE( filename_list(nfiles) )
-                  filename_list(:nfiles-1) = filename_list_tmp
-                  DEALLOCATE( filename_list_tmp )
-               ENDIF
-
-               filename_list(nfiles) = TRIM( read_string ) // group_name
-
-            ENDIF
-
-         ELSEIF ( io_stat > 0 )  THEN
-            return_value = 1
-            CALL internal_message( 'error', routine_name // &
-                                   ': error while reading file names from config' )
-            EXIT
-         ENDIF
-
-      ENDDO
-
-      CLOSE( config_file_unit )
-
-   ENDIF
-
-END SUBROUTINE read_config
-
-!--------------------------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Read header information from binary files.
-!--------------------------------------------------------------------------------------------------!
-SUBROUTINE read_binary_header( bin_filename_body, return_value )
-
-   CHARACTER(LEN=2*charlen)             ::  bin_filename       !< name of binary file which to read
-   CHARACTER(LEN=*),         INTENT(IN) ::  bin_filename_body  !< body of binary filename which to read
-   CHARACTER(LEN=charlen  )             ::  read_string        !< string read from file
-
-   CHARACTER(LEN=*), PARAMETER ::  routine_name = 'read_binary_header'  !< name of routine
-
-   INTEGER              ::  i                  !< loop index
-   INTEGER              ::  io_stat            !< status of Fortran I/O operations
-   INTEGER              ::  n_attributes       !< number of attributes in file
-   INTEGER              ::  n_dimensions       !< number of dimensions in file
-   INTEGER              ::  n_variables        !< number of variables in file
-   INTEGER              ::  variable_ndims     !< number of dimensions of a variable
-   INTEGER, INTENT(OUT) ::  return_value       !< return value
-
-   TYPE(attribute_type), DIMENSION(:), ALLOCATABLE ::  attribute_list_tmp  !< temporary attribute list
-   TYPE(dimension_type), DIMENSION(:), ALLOCATABLE ::  dimension_list_tmp  !< temporary dimension list
-   TYPE(variable_type),  DIMENSION(:), ALLOCATABLE ::  variable_list_tmp   !< temporary variable list
-
-
-   return_value = 0
-
-   !-- 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 ) )
-
-   OPEN( bin_file_unit, FILE=bin_filename, FORM='UNFORMATTED', STATUS='OLD', IOSTAT=io_stat )
-
-   !-- Skip redundant information
-   IF ( io_stat == 0 )  THEN
-
-      READ( bin_file_unit ) dummy_int    ! charlen
-      READ( bin_file_unit ) dummy_int    ! file_id
-      READ( bin_file_unit ) read_string  ! filename
-
-   ELSE
-
-      return_value = 1
-      CALL internal_message( 'error', routine_name // &
-                             ': could not open file ' // TRIM( bin_filename ) )
-
-   ENDIF
-
-   !-- Read dimension, variable and attribute information
-   DO WHILE ( io_stat == 0 )  ! iterate over file header
-
-      READ( bin_file_unit ) read_string
-
-      CALL internal_message( 'debug', routine_name // ': read_string=' // TRIM( read_string ) )
-
-      SELECT CASE ( TRIM( read_string ) )
-
-         CASE ( 'dimension' )
-
-            !-- Increase dimension list by 1 element
-            IF ( .NOT. ALLOCATED( dimension_list ) )  THEN
-               ALLOCATE( dimension_list(1) )
-               n_dimensions = 1
-            ELSE
-               ALLOCATE( dimension_list_tmp(n_dimensions) )
-               dimension_list_tmp = dimension_list
-               DEALLOCATE( dimension_list )
-               n_dimensions = n_dimensions + 1
-               ALLOCATE( dimension_list(n_dimensions) )
-               dimension_list(1:n_dimensions-1) = dimension_list_tmp
-               DEALLOCATE( dimension_list_tmp )
-            ENDIF
-
-            !-- Read dimension
-            READ( bin_file_unit ) read_string
-            dimension_list(n_dimensions)%name = read_string
-            READ( bin_file_unit ) dimension_list(n_dimensions)%id
-            READ( bin_file_unit ) read_string
-            dimension_list(n_dimensions)%data_type = read_string
-            READ( bin_file_unit ) dimension_list(n_dimensions)%length
-
-         CASE ( 'variable' )
-
-            !-- Increase variable list by 1 element
-            IF ( .NOT. ALLOCATED( variable_list ) )  THEN
-               ALLOCATE( variable_list(1) )
-               n_variables = 1
-            ELSE
-               ALLOCATE( variable_list_tmp(n_variables) )
-               variable_list_tmp = variable_list
-               DEALLOCATE( variable_list )
-               n_variables = n_variables + 1
-               ALLOCATE( variable_list(n_variables) )
-               variable_list(1:n_variables-1) = variable_list_tmp
-               DEALLOCATE( variable_list_tmp )
-            ENDIF
-
-            !-- Read variable
-            READ( bin_file_unit ) read_string
-            variable_list(n_variables)%name = read_string
-            READ( bin_file_unit ) variable_list(n_variables)%id
-            READ( bin_file_unit ) read_string
-            variable_list(n_variables)%data_type = read_string
-            READ( bin_file_unit ) variable_ndims
-            ALLOCATE( variable_list(n_variables)%dimension_ids(1:variable_ndims) )
-            READ( bin_file_unit ) &
-               ( variable_list(n_variables)%dimension_ids(i), i = 1, variable_ndims )
-
-         CASE ( 'attribute' )
-
-            !-- Increase attribute list by 1 element
-            IF ( .NOT. ALLOCATED( attribute_list ) )  THEN
-               ALLOCATE( attribute_list(1) )
-               n_attributes = 1
-            ELSE
-               ALLOCATE( attribute_list_tmp(n_attributes) )
-               attribute_list_tmp = attribute_list
-               DEALLOCATE( attribute_list )
-               n_attributes = n_attributes + 1
-               ALLOCATE( attribute_list(n_attributes) )
-               attribute_list(1:n_attributes-1) = attribute_list_tmp
-               DEALLOCATE( attribute_list_tmp )
-            ENDIF
-
-            !-- Read attribute
-            READ( bin_file_unit ) attribute_list(n_attributes)%variable_id
-            READ( bin_file_unit ) read_string
-            attribute_list(n_attributes)%name = read_string
-            READ( bin_file_unit ) read_string
-            attribute_list(n_attributes)%data_type = read_string
-
-            SELECT CASE( attribute_list(n_attributes)%data_type )
-
-               CASE ( 'char' )
-                  READ( bin_file_unit ) read_string
-                  attribute_list(n_attributes)%value_char = read_string
-
-               CASE ( 'int16' )
-                  READ( bin_file_unit ) attribute_list(n_attributes)%value_int16
-
-               CASE ( 'int32' )
-                  READ( bin_file_unit ) attribute_list(n_attributes)%value_int32
-
-               CASE ( 'real32' )
-                  READ( bin_file_unit ) attribute_list(n_attributes)%value_real32
-
-               CASE ( 'real64' )
-                  READ( bin_file_unit ) attribute_list(n_attributes)%value_real64
-
-               CASE DEFAULT
-                  return_value = 1
-                  CALL internal_message( 'error', routine_name // ': data type "' //       &
-                                         TRIM( attribute_list(n_attributes)%data_type ) // &
-                                         '" of attribute "' //                             &
-                                         TRIM( attribute_list(n_attributes)%name ) //      &
-                                         '" is not supported' )
-
-            END SELECT
-
-         CASE ( '*** end file header ***' )
-            EXIT
-
-         CASE DEFAULT
-            return_value = 1
-            CALL internal_message( 'error', routine_name // &
-                                   ': unknown header information: ' // TRIM( read_string ) )
-
-      END SELECT
-
-      IF ( return_value /= 0 )  EXIT
-
-   ENDDO  ! iterate over file header
-
-   CLOSE( bin_file_unit )
-
-END SUBROUTINE read_binary_header
-
-!--------------------------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Define all netcdf files.
-!--------------------------------------------------------------------------------------------------!
-SUBROUTINE define_netcdf_files( nc_filename, return_value )
-
-   CHARACTER(LEN=*), INTENT(IN) ::  nc_filename  !< name of netcdf file
-
-   CHARACTER(LEN=*), PARAMETER  ::  routine_name = 'define_netcdf_files'  !< routine name
-
-   INTEGER              ::  i                    !< loop index
-   INTEGER              ::  j                    !< loop index
-   INTEGER              ::  nc_data_type         !< netcdf data type of output variable
-   INTEGER              ::  nc_dimension_length  !< length of dimension in netcdf file
-   INTEGER              ::  nc_stat              !< return value of Netcdf calls
-   INTEGER, INTENT(OUT) ::  return_value         !< return value
-
-   INTEGER, DIMENSION(:), ALLOCATABLE ::  dimension_ids  !< list of dimension ids of a variable
-
-
-   return_value = 0
-
-   !-- Create Netcdf-file
-   nc_stat = NF90_CREATE( TRIM( nc_filename ), IOR( NF90_CLOBBER, NF90_NETCDF4 ), nc_file_id )
-
-   IF ( nc_stat /= NF90_NOERR )  THEN
-      return_value = 1
-      CALL internal_message( 'error', routine_name // &
-                             ': NF90_CREATE error: ' // TRIM( NF90_STRERROR( nc_stat ) ) )
-   ELSE
-
-      !-- Define dimensions in NetCDF file
-      ALLOCATE( dimension_id_netcdf(1:MAXVAL(dimension_list(:)%id)) )
-
-      DO  i = 1, SIZE( dimension_list )
-
-         IF ( dimension_list(i)%length < 0 )  THEN
-            nc_dimension_length = NF90_UNLIMITED
-         ELSE
-            nc_dimension_length = dimension_list(i)%length
-         ENDIF
-
-         nc_stat =  NF90_DEF_DIM( nc_file_id, dimension_list(i)%name, nc_dimension_length, &
-                                  dimension_id_netcdf(dimension_list(i)%id) )
-
-         IF ( nc_stat /= NF90_NOERR )  THEN
-            return_value = 1
-            CALL internal_message( 'error', routine_name //                             &
-                                   ': dimension "' // TRIM( dimension_list(i)%name ) // &
-                                   '": NF90_DEF_DIM error: ' // TRIM( NF90_STRERROR( nc_stat ) ) )
-            EXIT
-         ENDIF
-
-      ENDDO
-
-   ENDIF
-
-   IF ( return_value == 0 )  THEN
-
-      !-- Create vector to map variable IDs from binary file to those within netcdf file
-      ALLOCATE( variable_id_netcdf(MIN( MINVAL( attribute_list(:)%variable_id ), &
-                                        MINVAL( variable_list(:)%id ) )          &
-                                   :                                             &
-                                   MAX( MAXVAL( attribute_list(:)%variable_id ), &
-                                        MAXVAL( variable_list(:)%id ) )     ) )
-
-      !-- Map global id from binary file to that of the netcdf file
-      variable_id_netcdf(dom_global_id) = NF90_GLOBAL
-
-      !-- Define variables in NetCDF file
-      DO  i = 1, SIZE( variable_list )
-
-        SELECT CASE ( TRIM( variable_list(i)%data_type ) )
-
-            CASE ( 'char' )
-               nc_data_type = NF90_CHAR
-
-            CASE ( 'int8' )
-               nc_data_type = NF90_BYTE
-
-            CASE ( 'int16' )
-               nc_data_type = NF90_SHORT
-
-            CASE ( 'int32' )
-               nc_data_type = NF90_INT
-
-            CASE ( 'real32' )
-               nc_data_type = NF90_FLOAT
-
-            CASE ( 'real64' )
-               nc_data_type = NF90_DOUBLE
-
-            CASE DEFAULT
-               return_value = 1
-               CALL internal_message( 'error', routine_name //                                 &
-                                      ': data type "' // TRIM( variable_list(i)%data_type ) // &
-                                      '" of variable "' // TRIM( variable_list(i)%name ) //    &
-                                      '" is not supported' )
-
-         END SELECT
-
-         IF ( return_value == 0 )  THEN
-
-            ALLOCATE( dimension_ids(1:SIZE( variable_list(i)%dimension_ids )) )
-
-            DO  j = 1, SIZE( variable_list(i)%dimension_ids )
-
-               dimension_ids(j) = dimension_id_netcdf(variable_list(i)%dimension_ids(j))
-
-            ENDDO
-
-            nc_stat =  NF90_DEF_VAR( nc_file_id, variable_list(i)%name, nc_data_type, &
-                                     dimension_ids, variable_id_netcdf(variable_list(i)%id) )
-            IF ( nc_stat /= NF90_NOERR )  THEN
-               return_value = 1
-               CALL internal_message( 'error', routine_name //            &
-                       ': variable "' // TRIM( variable_list(i)%name ) // &
-                       '": NF90_DEF_VAR error: ' // TRIM( NF90_STRERROR( nc_stat ) ) )
-            ENDIF
-
-            DEALLOCATE( dimension_ids )
-
-         ENDIF
-
-         IF ( return_value /= 0 )  EXIT
-
-      ENDDO
-
-   ENDIF
-
-   IF ( return_value == 0 )  THEN
-
-      !-- Define attributes in netcdf
-      DO i = 1, SIZE( attribute_list )
-
-         SELECT CASE ( TRIM( attribute_list(i)%data_type ) )
-
-            CASE ( 'char' )
-               nc_stat = NF90_PUT_ATT( nc_file_id,                                        &
-                                       variable_id_netcdf(attribute_list(i)%variable_id), &
-                                       TRIM(attribute_list(i)%name),                      &
-                                       TRIM(attribute_list(i)%value_char) )
-
-            CASE ( 'int8' )
-               nc_stat = NF90_PUT_ATT( nc_file_id,                                        &
-                                       variable_id_netcdf(attribute_list(i)%variable_id), &
-                                       TRIM(attribute_list(i)%name),                      &
-                                       attribute_list(i)%value_int8 )
-
-            CASE ( 'int16' )
-               nc_stat = NF90_PUT_ATT( nc_file_id,                                        &
-                                       variable_id_netcdf(attribute_list(i)%variable_id), &
-                                       TRIM(attribute_list(i)%name),                      &
-                                       attribute_list(i)%value_int16 )
-
-            CASE ( 'int32' )
-               nc_stat = NF90_PUT_ATT( nc_file_id,                                        &
-                                       variable_id_netcdf(attribute_list(i)%variable_id), &
-                                       TRIM(attribute_list(i)%name),                      &
-                                       attribute_list(i)%value_int32 )
-
-            CASE ( 'real32' )
-               nc_stat = NF90_PUT_ATT( nc_file_id,                                        &
-                                       variable_id_netcdf(attribute_list(i)%variable_id), &
-                                       TRIM(attribute_list(i)%name),                      &
-                                       attribute_list(i)%value_real32 )
-
-            CASE ( 'real64' )
-               nc_stat = NF90_PUT_ATT( nc_file_id,                                        &
-                                       variable_id_netcdf(attribute_list(i)%variable_id), &
-                                       TRIM(attribute_list(i)%name),                      &
-                                       attribute_list(i)%value_real64 )
-
-            CASE DEFAULT
-               return_value = 1
-               CALL internal_message( 'error', routine_name //                   &
-                       ': data type "' // TRIM( attribute_list(i)%data_type ) // &
-                       '" of attribute "' // TRIM( attribute_list(i)%name ) //   &
-                       '" is not supported' )
-               EXIT
-
-         END SELECT
-
-         IF ( nc_stat /= NF90_NOERR )  THEN
-            return_value = 1
-            CALL internal_message( 'error', routine_name //              &
-                    ': attribute "' // TRIM( attribute_list(i)%name ) // &
-                    '": NF90_PUT_ATT error: ' // TRIM( NF90_STRERROR( nc_stat ) ) )
-            EXIT
-         ENDIF
-
-      ENDDO  ! loop over attributes
-
-   ENDIF
-
-   IF ( ALLOCATED( attribute_list ) )  DEALLOCATE( attribute_list )
-   IF ( ALLOCATED( dimension_list ) )  DEALLOCATE( dimension_list )
-
-   nc_stat = NF90_ENDDEF( nc_file_id )
-   IF ( nc_stat /= NF90_NOERR )  THEN
-      return_value = 1
-      CALL internal_message( 'error', routine_name // &
-                             ': NF90_ENDDEF error: ' // TRIM( NF90_STRERROR( nc_stat ) ) )
-   ENDIF
-
-END SUBROUTINE define_netcdf_files
-
-!--------------------------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Read variable data from binary and write them into netcdf files.
-!--------------------------------------------------------------------------------------------------!
-SUBROUTINE convert_data_to_netcdf( bin_filename_body, return_value )
-
-   CHARACTER(LEN=2*charlen)             ::  bin_filename       !< name of binary file which to read
-   CHARACTER(LEN=*        ), INTENT(IN) ::  bin_filename_body  !< body of binary filename which to read
-   CHARACTER(LEN=charlen  )             ::  read_string        !< string read from file
-   CHARACTER(LEN=charlen  )             ::  variable_name      !< name of variable to be read
-
-   CHARACTER(LEN=*), PARAMETER  ::  routine_name = 'convert_data_to_netcdf'  !< routine name
-
-   INTEGER              ::  data_count    !< count of data values of a variable over all dimensions
-   INTEGER              ::  i             !< loop file_index
-   INTEGER              ::  io_stat       !< status of Fortran I/O operations
-   INTEGER              ::  rank          !< loop index for loop over rank files
-   INTEGER              ::  n_dimensions  !< number of dimensions of a variable
-   INTEGER              ::  nc_stat       !< return value of Netcdf calls
-   INTEGER, INTENT(OUT) ::  return_value  !< return value
-   INTEGER              ::  variable_id   !< variable id read from binary file
-
-   INTEGER, DIMENSION(:), ALLOCATABLE ::  start_positions           !< start position of data per dimension
-   INTEGER, DIMENSION(:), ALLOCATABLE ::  data_count_per_dimension  !< data count of variable per dimension
-   INTEGER, DIMENSION(:), ALLOCATABLE ::  bounds_start              !< lower bounds of variable
-   INTEGER, DIMENSION(:), ALLOCATABLE ::  bounds_origin             !< lower bounds of dimensions in output file
-
-   INTEGER(KIND=1), DIMENSION(:), ALLOCATABLE ::  values_int8   !< variable values
-   INTEGER(KIND=2), DIMENSION(:), ALLOCATABLE ::  values_int16  !< variable values
-   INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE ::  values_int32  !< variable values
-   INTEGER(iwp),    DIMENSION(:), ALLOCATABLE ::  values_intwp  !< variable values
-
-   LOGICAL ::  file_exists  !< true if file exists
-
-   REAL(KIND=4), DIMENSION(:), ALLOCATABLE ::  values_real32  !< variable values
-   REAL(KIND=8), DIMENSION(:), ALLOCATABLE ::  values_real64  !< variable values
-   REAL(wp),     DIMENSION(:), ALLOCATABLE ::  values_realwp  !< variable values
-
-
-   return_value = 0
-
-   !-- Open binary files of every possible MPI rank
-   DO  rank = 0, dom_nranks - 1
-
-      WRITE( bin_filename, '(A, I6.6)' ) &
-         TRIM( filename_prefix ) // TRIM( bin_filename_body ) // '_', rank
-
-      INQUIRE( FILE=bin_filename, EXIST=file_exists )
-
-      !-- Read file if it exists
-      IF ( file_exists )  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
-
-         !-- Read variable data
-         io_stat = 0
-         DO WHILE ( io_stat == 0  .AND.  return_value == 0 )
-
-            READ( bin_file_unit, IOSTAT=io_stat ) variable_id
-            IF ( io_stat < 0 )  EXIT  ! End-of-file
-
-            DO  i = LBOUND( variable_list, DIM=1 ), UBOUND( variable_list, DIM=1 )
-               IF ( variable_id == variable_list(i)%id )  THEN
-                  n_dimensions = SIZE( variable_list(i)%dimension_ids )
-                  variable_name = variable_list(i)%name
-
-                  CALL internal_message( 'debug', routine_name // ': read variable "' // &
-                                         TRIM( variable_name ) // '"' )
-                  WRITE( temp_string, * ) n_dimensions
-                  CALL internal_message( 'debug', routine_name // &
-                                         ':  n_dimensions = ' // TRIM( temp_string ) )
-
-                  EXIT
-               ENDIF
-            ENDDO
-
-            ALLOCATE( bounds_start(1:n_dimensions) )
-            ALLOCATE( bounds_origin(1:n_dimensions) )
-            ALLOCATE( start_positions(1:n_dimensions) )
-            ALLOCATE( data_count_per_dimension(1:n_dimensions) )
-
-            READ( bin_file_unit ) ( bounds_start(i), i = 1, n_dimensions )
-            READ( bin_file_unit ) ( data_count_per_dimension(i), i = 1, n_dimensions )
-            READ( bin_file_unit ) ( bounds_origin(i), i = 1, n_dimensions )
-
-            WRITE( temp_string, * ) bounds_start
-            CALL internal_message( 'debug', routine_name // &
-                                   ': bounds_start = ' // TRIM( temp_string ) )
-            WRITE( temp_string, * ) data_count_per_dimension
-            CALL internal_message( 'debug', routine_name // &
-                                   ': data_count_per_dimension = ' // TRIM( temp_string ) )
-            WRITE( temp_string, * ) bounds_origin
-            CALL internal_message( 'debug', routine_name // &
-                                   ': bounds_origin = ' // TRIM( temp_string ) )
-
-            data_count = 1
-
-            DO  i = 1, n_dimensions
-               data_count = data_count * data_count_per_dimension(i)
-               start_positions(i) = bounds_start(i) - bounds_origin(i) + 1
-            ENDDO
-
-            read_string = ''
-            READ( bin_file_unit ) read_string  ! read data type of following values
-
-            SELECT CASE ( TRIM( read_string ) )
-
-               CASE ( 'int8' )
-                  ALLOCATE( values_int8(1:data_count) )
-
-                  READ( bin_file_unit ) ( values_int8(i), i = 1, data_count )
-
-                  nc_stat = NF90_PUT_VAR( nc_file_id, variable_id_netcdf(variable_id), &
-                               values_int8,                                            &
-                               start = start_positions, count = data_count_per_dimension )
-
-                  DEALLOCATE( values_int8 )
-
-               CASE ( 'int16' )
-                  ALLOCATE( values_int16(1:data_count) )
-
-                  READ( bin_file_unit ) ( values_int16(i), i = 1, data_count )
-
-                  nc_stat = NF90_PUT_VAR( nc_file_id, variable_id_netcdf(variable_id), &
-                               values_int16,                                           &
-                               start = start_positions, count = data_count_per_dimension )
-
-                  DEALLOCATE( values_int16 )
-
-               CASE ( 'int32' )
-                  ALLOCATE( values_int32(1:data_count) )
-
-                  READ( bin_file_unit ) ( values_int32(i), i = 1, data_count )
-
-                  nc_stat = NF90_PUT_VAR( nc_file_id, variable_id_netcdf(variable_id), &
-                               values_int32,                                           &
-                               start = start_positions, count = data_count_per_dimension )
-
-                  DEALLOCATE( values_int32 )
-
-               CASE ( 'intwp' )
-                  ALLOCATE( values_intwp(1:data_count) )
-
-                  READ( bin_file_unit ) ( values_intwp(i), i = 1, data_count )
-
-                  nc_stat = NF90_PUT_VAR( nc_file_id, variable_id_netcdf(variable_id), &
-                               values_intwp,                                          &
-                               start = start_positions, count = data_count_per_dimension )
-
-                  DEALLOCATE( values_intwp )
-
-               CASE ( 'real32' )
-                  ALLOCATE( values_real32(1:data_count) )
-
-                  READ( bin_file_unit ) ( values_real32(i), i = 1, data_count )
-
-                  nc_stat = NF90_PUT_VAR( nc_file_id, variable_id_netcdf(variable_id), &
-                               values_real32,                                          &
-                               start = start_positions, count = data_count_per_dimension )
-
-                  DEALLOCATE( values_real32 )
-
-               CASE ( 'real64' )
-                  ALLOCATE( values_real64(1:data_count) )
-
-                  READ( bin_file_unit ) ( values_real64(i), i = 1, data_count )
-
-                  nc_stat = NF90_PUT_VAR( nc_file_id, variable_id_netcdf(variable_id), &
-                               values_real64,                                          &
-                               start = start_positions, count = data_count_per_dimension )
-
-                  DEALLOCATE( values_real64 )
-
-               CASE ( 'realwp' )
-                  ALLOCATE( values_realwp(1:data_count) )
-
-                  READ( bin_file_unit ) ( values_realwp(i), i = 1, data_count )
-
-                  nc_stat = NF90_PUT_VAR( nc_file_id, variable_id_netcdf(variable_id), &
-                               values_realwp,                                          &
-                               start = start_positions, count = data_count_per_dimension )
-
-                  DEALLOCATE( values_realwp )
-
-            END SELECT
-
-            IF ( nc_stat /= NF90_NOERR )  THEN
-               return_value = 1
-               CALL internal_message( 'error', routine_name //    &
-                       ': variable "' // TRIM( variable_name ) // &
-                       '": NF90_PUT_VAR error: ' // TRIM( NF90_STRERROR( nc_stat ) ) )
-            ENDIF
-
-            !-- Deallocate fields for next variable
-            DEALLOCATE( start_positions )
-            DEALLOCATE( data_count_per_dimension )
-            DEALLOCATE( bounds_start )
-            DEALLOCATE( bounds_origin )
-
-         ENDDO  ! end loop over variables in a file
-
-         CLOSE( bin_file_unit )
-
-      ENDIF  ! if file exists
-
-   ENDDO  ! end loop over all PE
-
-   nc_stat = NF90_CLOSE( nc_file_id )
-
-   IF ( nc_stat /= NF90_NOERR )  THEN
-      return_value = 1
-      CALL internal_message( 'error', routine_name // &
-                             ': NF90_CLOSE error: ' // TRIM( NF90_STRERROR( nc_stat ) ) )
-   ENDIF
-
-   !-- Deallocate fields for next file
-   IF ( ALLOCATED( variable_list       ) )  DEALLOCATE( variable_list )
-   IF ( ALLOCATED( dimension_id_netcdf ) )  DEALLOCATE( dimension_id_netcdf )
-   IF ( ALLOCATED( variable_id_netcdf  ) )  DEALLOCATE( variable_id_netcdf )
-
-END SUBROUTINE convert_data_to_netcdf
-
-!--------------------------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Message routine for internal use.
-!--------------------------------------------------------------------------------------------------!
-SUBROUTINE internal_message( level, string )
-
-   CHARACTER(LEN=*), INTENT(IN) :: level   !< message importance level
-   CHARACTER(LEN=*), INTENT(IN) :: string  !< message string
-
-   IF ( TRIM( level ) == 'error' )  THEN
-      WRITE( *, '(A,A)' ) ' ## ERROR ', string
-      FLUSH(6)
-   ELSEIF ( TRIM( level ) == 'debug'  .AND.  print_debug_output )  THEN
-      WRITE( *, '(A,A)' ) ' ++ DEBUG ', string
-      FLUSH(6)
-   ELSEIF ( TRIM( level ) == 'info' )  THEN
-      WRITE( *, '(A,A)' ) ' -- INFO  ', string
-      FLUSH(6)
-   ENDIF
-
-END SUBROUTINE internal_message
-
-END PROGRAM binary_to_netcdf
Index: palm/trunk/UTIL/check_pegrid.f90
===================================================================
--- palm/trunk/UTIL/check_pegrid.f90	(revision 1)
+++ palm/trunk/UTIL/check_pegrid.f90	(revision 1)
@@ -0,0 +1,145 @@
+ PROGRAM check_pegrid
+
+!-------------------------------------------------------------------------------!
+! Beschreibung:
+! -------------
+! Ueberpruefung der Konsistenz von Prozessortopologie und gewaehlten Feldgrenzen
+!-------------------------------------------------------------------------------!
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=1) ::  char = ''
+    INTEGER ::  i, j, k, maximum_grid_level, mg_levels_x, mg_levels_y,        &
+                mg_levels_z, numprocs, numproc_sqr, nx, nxanz, ny, nyanz, nz, &
+                pdims(2)
+
+!
+!-- Prozessoranzahl abfragen
+    PRINT*, '*** Anzahl der verfuegbaren PE''s:'
+    READ (*,*)  numprocs
+
+!
+!-- Prozessortopologie bestimmen
+    numproc_sqr = SQRT( REAL( numprocs ) )
+    pdims(1)    = MAX( numproc_sqr , 1 )
+    DO  WHILE ( MOD( numprocs , pdims(1) ) /= 0 )
+       pdims(1) = pdims(1) - 1
+    ENDDO
+    pdims(2) = numprocs / pdims(1)
+
+!
+!-- Prozessortopologie ausgeben
+    PRINT*, ' '
+    PRINT*, '*** berechnetes Prozessorgitter: (',pdims(1),',',pdims(2),')'
+
+!
+!-- Evtl. Uebersteuerung der Prozessortopologie durch den Benutzer
+    PRINT*, ' '
+    PRINT*, '*** soll dieses Prozessorgitter benutzt werden? (y/n/<return>=y)'
+    READ (*,'(A1)')  char
+    IF ( char /= 'y'  .AND.  char /= 'Y'  .AND.  char /= '' )  THEN
+       DO
+          PRINT*, ' '
+          PRINT*, '*** Bitte Prozessoranzahl in x- und y-Richtung angeben:'
+          READ (*,*)  pdims(1), pdims(2)
+          IF ( pdims(1)*pdims(2) == numprocs )  EXIT
+          PRINT*, '+++ berechnete Prozessoranzahl (', pdims(1)*pdims(2), &
+                  ') stimmt nicht mit vorgegebener Anzahl'
+          PRINT*, '    (', numprocs, ') ueberein!'
+       ENDDO
+    ENDIF
+
+!
+!-- Gitterpunktanzahl abfragen
+    PRINT*, ' '
+    PRINT*, ' '
+    PRINT*, '*** bitte nx, ny und nz angeben:'
+    READ (*,*)  nx, ny, nz
+
+!
+!-- Pruefung, ob sich Gitterpunkte in x-Richtung glatt aufteilen lassen
+    IF ( MOD( nx+1 , pdims(1) ) /= 0 )  THEN
+       PRINT*,'+++ x-Richtung:  Gitterpunktanzahl (',nx+1,') ist kein ganz-'
+       PRINT*,'                 zahliges Vielfaches der Prozessoranzahl (',&
+                                &pdims(1),')'
+       STOP
+    ELSE
+       nxanz  = ( nx + 1 ) / pdims(1)
+    ENDIF
+
+!
+!-- Pruefung, ob sich Gitterpunkte in y-Richtung glatt aufteilen lassen
+    IF ( MOD( ny+1 , pdims(2) ) /= 0 )  THEN
+       PRINT*,'+++ y-Richtung:  Gitterpunktanzahl (',ny+1,') ist kein ganz-'
+       PRINT*,'                 zahliges Vielfaches der Prozessoranzahl (',&
+                                &pdims(2),')'
+       STOP
+    ELSE
+       nyanz  = ( ny + 1 ) / pdims(2)
+    ENDIF
+
+    PRINT*, ''
+    PRINT*, '*** Anzahl der Gitterpunkte in x- und y-Richtung je PE: (', &
+            nxanz,',',nyanz,')'
+
+!
+!-- Pruefen der Gitterpunktanzahl bzgl. Transposition
+    IF ( MOD( nz , pdims(1) ) /= 0 )  THEN
+       PRINT*,'+++ Transposition z --> x:'
+       PRINT*,'    nz=',nz,' ist kein ganzzahliges Vielfaches von pdims(1)=', &
+              &pdims(1)
+       PRINT*, ''
+       STOP
+    ENDIF
+    IF ( MOD( nx+1 , pdims(2) ) /= 0 )  THEN
+       PRINT*,'+++ Transposition x --> y:'
+       PRINT*,'    nx+1=',nx+1,' ist kein ganzzahliges Vielfaches von ',&
+              &'pdims(2)=',pdims(2)
+       PRINT*, ''
+       STOP
+    ENDIF
+    IF ( MOD( ny+1 , pdims(1) ) /= 0 )  THEN
+       PRINT*,'+++ Transposition y --> z:'
+       PRINT*,'    ny+1=',ny+1,' ist kein ganzzahliges Vielfaches von ',&
+              &'pdims(1)=',pdims(1)
+       PRINT*, ''
+       STOP
+    ENDIF
+
+!
+!-- Moegliche Anzahl von Gitterniveaus im Falle der Benutzung des
+!-- Mehrgitterverfahrens berechnen und die Gitterpunktanzahl des groebsten
+!-- Gitters ausgeben
+    mg_levels_x = 1
+    mg_levels_y = 1
+    mg_levels_z = 1
+
+    i = nxanz
+    DO WHILE ( MOD( i, 2 ) == 0  .AND.  i /= 2 )
+       i = i / 2
+       mg_levels_x = mg_levels_x + 1
+    ENDDO
+
+    j = nyanz
+    DO WHILE ( MOD( j, 2 ) == 0  .AND.  j /= 2 )
+       j = j / 2
+       mg_levels_y = mg_levels_y + 1
+    ENDDO
+
+    k = nz
+    DO WHILE ( MOD( k, 2 ) == 0  .AND.  k /= 2 )
+       k = k / 2
+       mg_levels_z = mg_levels_z + 1
+    ENDDO
+
+    maximum_grid_level = MIN( mg_levels_x, mg_levels_y, mg_levels_z )
+    i = nxanz / 2**(maximum_grid_level-1) 
+    j = nyanz / 2**(maximum_grid_level-1)
+    k = nz    / 2**(maximum_grid_level-1)
+
+    PRINT*, '    Anzahl der moeglichen Gitterniveaus: ', maximum_grid_level
+    PRINT*, '    Anz. Gitterpunkte auf groebstem Gitter (x,y,z): (', i, ',', &
+                 j,',',k,')'
+    PRINT*, ''
+
+ END PROGRAM check_pegrid
Index: palm/trunk/UTIL/combine_plot_fields.f90
===================================================================
--- palm/trunk/UTIL/combine_plot_fields.f90	(revision 4901)
+++ palm/trunk/UTIL/combine_plot_fields.f90	(revision 1)
@@ -2,92 +2,10 @@
 
 !------------------------------------------------------------------------------!
-! This file is part of the PALM model system.
-!
-! PALM is free software: you can redistribute it and/or modify it under the
-! terms of the GNU General Public License as published by the Free Software
-! Foundation, either version 3 of the License, or (at your option) any later
-! version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with
-! PALM. If not, see <http://www.gnu.org/licenses/>.
-!
-! Copyright 1997-2021  Leibniz Universitaet Hannover
-!------------------------------------------------------------------------------!
-!
-! Current revisions:
+! Actual revisions:
 ! -----------------
 ! 
-! 
+!
 ! Former revisions:
 ! -----------------
-! $Id$
-! bugfix for processing data from atmosphere-ocean coupled runs (only atmosphere data were
-! processed, but twice)
-! 
-! 3241 2018-09-12 15:02:00Z raasch
-! unused variables removed
-! 
-! 2718 2018-01-02 08:49:38Z maronga
-! Corrected "Former revisions" section
-! 
-! 2696 2017-12-14 17:12:51Z kanani
-! Change in file header (GPL part)
-!
-! 2669 2017-12-06 16:03:27Z raasch
-! data of 3d-nest runs are completely processed now
-! 
-! 2523 2017-10-05 14:42:47Z kanani
-! Increased LEN for CHARACTER variable var_name, equal to the value in PALM
-! 
-! 2512 2017-10-04 08:26:59Z raasch
-! PALM output does not contain ghost layer data any more
-! avs- and iso2d-related parts removed, handling of compressed data removed
-! 
-! 2365 2017-08-21 14:59:59Z kanani
-! Vertical grid nesting implemented (SadiqHuq)
-!
-! 1809 2016-04-05 20:13:28Z raasch
-!
-! 1808 2016-04-05 19:44:00Z raasch
-! cpu measurements are done with standard FORTRAN routine on every machine
-!
-! 1551 2015-03-03 14:18:16Z maronga
-! Adjustments for data output of soil model quantities
-! 
-! 1468 2014-09-24 14:06:57Z maronga
-! Adapted for use on up to 6-digit processor cores (not tested)
-!
-! 1394 2014-05-06 10:17:31Z keck
-! KIND-attribute added to all INTEGER and REAL declaration statements
-!
-! 1046 2012-11-09 14:38:45Z maronga
-! code put under GPL (PALM 3.9)
-!
-! 691 2011-03-04 08:45:30Z maronga
-! Bugfix: check for precursor ocean runs, removed typo
-!
-! 493 2010-03-01 08:30:24Z raasch
-! Exit in case of already complete NetCDF data (due to parallel output in PALM)
-! cpu measurements included
-!
-! 210 2008-11-06 08:54:02Z raasch
-! Size of pf3d adjusted to the required output size (1 gridpoint less, along
-! all three dimensions), because output of a subset of the data
-! (pf3d(nxa:nxe...) in the NF90_PUT_VAR statement caused segmentation fault
-! with the INTEL compiler.
-! Subdomain data are read into temporary arrays pf_tmp/pf3d_tmp in order to
-! avoid INTEL compiler warnings about (automatic) creation of temporary arrays
-! Bugfix: three misplaced #endif directives
-!
-! 114 2007-10-10 00:03:15Z raasch
-! Bugfix: model_string needed a default value
-!
-! Aug 07    Loop for processing of output by coupled runs, id_string does not
-!           contain modus any longer
-!
 ! 18/01/06  Output of time-averaged data
 !
@@ -112,4 +30,33 @@
 ! Output format is NetCDF. Additionally, a data are output in a binary format
 ! readable by ISO2D-software (cross-sections) and by AVS (3D-data).
+!
+! This routine must be compiled with:
+! decalpha:
+!    f95 -cpp -D__netcdf -fast -r8 -I/usr/local/netcdf-3.5.1/include
+!    -L/usr/local/netcdf-3.5.1/lib -lnetcdf
+! IBM-Regatta:
+!    xlf95 -qsuffix=cpp=f90 -WF,-D__netcdf -qrealsize=8 -q64 -qmaxmem=-1 -Q
+!    -I /aws/dataformats/netcdf-3.6.0-p1/64-32/include-64
+!    -L/aws/dataformats/netcdf-3.6.0-p1/64-32/lib -lnetcdf -O3
+! IBM-Regatta KISTI:
+!    xlf95 -qsuffix=cpp=f90 -WF,-D__netcdf -qrealsize=8 -q64 -qmaxmem=-1 -Q
+!    -I /applic/netcdf64/src/f90
+!    -L/applic/lib/NETCDF64 -lnetcdf -O3
+! IBM-Regatta Yonsei (gfdl5):
+!    xlf95 -qsuffix=cpp=f90 -WF,-D__netcdf -qrealsize=8 -q64 -qmaxmem=-1 -Q
+!    -I /usr1/users/raasch/pub/netcdf-3.6.0-p1/include
+!    -L/usr1/users/raasch/pub/netcdf-3.6.0-p1/lib -lnetcdf -O3
+! IMUK:
+!    ifort combine...f90 -o combine...x
+!    -cpp -D__netcdf -I /muksoft/packages/netcdf/linux/include -axW -r8 -nbs
+!    -Vaxlib -L /muksoft/packages/netcdf/linux/lib -lnetcdf
+! NEC-SX6:
+!    sxf90 combine...f90 -o combine...x 
+!    -I /pool/SX-6/netcdf/netcdf-3.6.0-p1/include  -C hopt -Wf '-A idbl4'
+!    -D__netcdf -L/pool/SX-6/netcdf/netcdf-3.6.0-p1/lib -lnetcdf
+! Sun Fire X4600
+!    pgf95 combine...f90 -o combine...x
+!    -Mpreprocess -D__netcdf -I /home/usr5/mkanda/netcdf-3.6.1/src/f90 -r8
+!    -fast -L/home/usr5/mkanda/netcdf-3.6.1/src/libsrc -lnetcdf
 !------------------------------------------------------------------------------!
 
@@ -123,503 +70,72 @@
 !-- Local variables
     CHARACTER (LEN=2)    ::  modus
-    CHARACTER (LEN=4)    ::  model_string
-    CHARACTER (LEN=6)    ::  id_string
-    CHARACTER (LEN=30)   ::  dimname, var_name
+    CHARACTER (LEN=7)    ::  id_char
+    CHARACTER (LEN=10)   ::  dimname, var_name
     CHARACTER (LEN=40)   ::  filename
 
     CHARACTER (LEN=2000), DIMENSION(0:1) ::  var_list
 
-    INTEGER, PARAMETER ::  iwp = 4, spk = SELECTED_REAL_KIND( 6 ), wp = 8
-
-    INTEGER(iwp) ::  av, danz, i, id, j, k, model, models, nc_stat,            &
-                     nxa, nxe, nya, nye,               &
-                     nza, nze, pos, time_step, xa, xe, xxa, xxe, ya, ya_do,    &
-                     ya_tot, ye, ye_do, ye_tot, yya, yye, za, ze
-
-    INTEGER(8)                        ::  count, count_rate
-
-    INTEGER(iwp), DIMENSION(0:1)      ::  current_level, current_var,          &
-                                          fanz, id_set, id_var_time, num_var
-    INTEGER(iwp), DIMENSION(4)        ::  id_dims_loc
-    INTEGER(iwp), DIMENSION(0:1,4)    ::  id_dims
-    INTEGER(iwp), DIMENSION(0:1,1000) ::  id_var, levels
-
-    LOGICAL  ::  found, found_ao, nest3d, netcdf_output, netcdf_parallel, netcdf_0,      &
-                 netcdf_1, vnest
-
-    REAL(wp) ::  cpu_start_time, cpu_end_time, simulated_time
-    REAL(wp),  DIMENSION(:,:), ALLOCATABLE   ::  pf, pf_tmp
-    REAL(spk), DIMENSION(:,:,:), ALLOCATABLE ::  pf3d, pf3d_tmp
-
-
-
+    INTEGER, PARAMETER ::  spk = SELECTED_REAL_KIND( 6 )
+
+    INTEGER ::  av, danz, i, id,             &
+                j, nc_stat, nxa, nxag, nxe, nxeg, nya,   &
+                nyag, nye, nyeg, nza, nzag, nze, nzeg, pos, time_step, xa, xe, &
+                ya, ye, za, ze
+
+    INTEGER, DIMENSION(0:1) ::  current_level, current_var, fanz, id_set, id_var_time, num_var
+
+    INTEGER, DIMENSION(4) ::  id_dims_loc
+
+    INTEGER, DIMENSION(0:1,4) ::  id_dims
+
+    INTEGER, DIMENSION(0:1,1000) ::  id_var, levels
+
+    LOGICAL ::  avs_output, compressed, found, iso2d_output, netcdf_output, &
+                netcdf_0, netcdf_1
+
+    REAL ::  dx, simulated_time
+    REAL, DIMENSION(:),   ALLOCATABLE   ::  eta, ho, hu
+    REAL, DIMENSION(:,:), ALLOCATABLE   ::  pf
+    REAL(spk), DIMENSION(:,:,:), ALLOCATABLE ::  pf3d
+
+
+!
+!-- 2D-arrays for ISO2D
+!-- Main loop for the three different cross-sections, starting with xy-section
+    modus = 'XY'
     PRINT*, ''
-    PRINT*, ''
-    PRINT*, '*** combine_plot_fields ***'
-
-!
-!-- Find out if a coupled or nested run has been carried out
-    INQUIRE( FILE='COUPLING_PORT_OPENED', EXIST=found_ao )
-    INQUIRE( FILE='VNESTING_PORT_OPENED', EXIST=vnest )
-    INQUIRE( FILE='3DNESTING', EXIST=nest3d )
-    IF ( found_ao )  THEN
-       models = 2
-       PRINT*, '    coupled run'
-    ELSEIF ( vnest )  THEN
-       models = 2
-       PRINT*, '    Vertically nested grid coupling'
-    ELSEIF ( nest3d )  THEN
-       OPEN( 90, FILE='3DNESTING', FORM='FORMATTED' )
-       READ ( 90, '(I2)' )  models
-       CLOSE ( 90 )
-       PRINT*, '    3d-nest run'
-       PRINT*, '    number of nest domains = ', models
-    ELSE
-       models = 1
-       PRINT*, '    uncoupled run'
-    ENDIF
-
-!
-!-- Find out if a precursor ocean run has been carried out
-    INQUIRE( FILE='PRECURSOR_OCEAN', EXIST=found )
-    IF ( found )  THEN
-       model_string = '_O'
-       PRINT*, '    precursor ocean run'
-    ELSE
-       model_string = ''
-    ENDIF
-
-!
-!-- Do everything for each model
-    DO model = 1, models
-!
-!--    Set the model string used to identify the filenames
-       IF ( found_ao  .OR.  vnest )  THEN
-          PRINT*, ''
-          IF ( model == 2 )  THEN
-             IF ( vnest )  THEN
-                model_string = '_N'
-                PRINT*, '    now combining FINE data'
-                PRINT*, '    ========================'
-             ELSE
-                model_string = '_O'
-                PRINT*, '    now combining ocean data'
-                PRINT*, '    ========================'
-             ENDIF
-          ELSE
-             IF ( vnest )  THEN
-                PRINT*, '    now combining COARSE data'
-                PRINT*, '    ============================='
-             ELSE
-                PRINT*, '    now combining atmosphere data'
-                PRINT*, '    ============================='
-             ENDIF
-          ENDIF
-       ELSEIF ( nest3d )  THEN
-          PRINT*, ''
-          PRINT*, '--> processing nest id = ', model
-          IF ( model == 1 )  THEN
-             model_string = ''
-          ELSE
-             WRITE( model_string, '(A2,I2.2)' )  '_N', model
-          ENDIF
-       ENDIF
-!
-!--    2D-arrays for ISO2D
-!--    Main loop for the three different cross-sections, starting with 
-!--    xy-section
-       modus = 'XY'
-       PRINT*, ''
-       DO  WHILE ( modus == 'XY'  .OR.  modus == 'XZ'  .OR.  modus == 'YZ' )
-!
-!--       Take current time
-          CALL SYSTEM_CLOCK( count, count_rate )
-          cpu_start_time = REAL( count ) / REAL( count_rate )
-
-          netcdf_parallel = .FALSE.
-!
-!--       Check, if file from PE0 exists. If it does not exist, PALM did not
-!--       create any output for this cross-section.
-          danz = 0
-          WRITE (id_string,'(I6.6)')  danz
-          INQUIRE ( &
-               FILE='PLOT2D_'//modus//TRIM( model_string )//'_'//id_string, &
-               EXIST=found )
-!
-!--       Find out the number of files (equal to the number of PEs which
-!--       have been used in PALM) and open them
-          DO  WHILE ( found )
-
-             OPEN ( danz+110, &
-                  FILE='PLOT2D_'//modus//TRIM( model_string )//'_'//id_string, &
-                  FORM='UNFORMATTED' )
-             danz = danz + 1
-             WRITE (id_string,'(I6.6)')  danz
-             INQUIRE ( &
-                  FILE='PLOT2D_'//modus//TRIM( model_string )//'_'//id_string, &
-                  EXIST=found )
-
-          ENDDO
-
-!
-!--       Inquire whether a NetCDF file exists
-          INQUIRE( FILE='DATA_2D_'//modus//'_NETCDF'//TRIM( model_string ), &
-               EXIST=netcdf_0 )
-
-!
-!--       Inquire whether a NetCDF file for time-averaged data exists
-          INQUIRE( FILE='DATA_2D_'//modus//'_AV_NETCDF'//TRIM( model_string ),&
-               EXIST=netcdf_1 )
-
-          IF ( netcdf_0  .OR.  netcdf_1 )  THEN
-             netcdf_output = .TRUE.
-!
-!--          Inquire whether the NetCDF file is already complete (parallel
-!--          output)
-             INQUIRE( FILE='NO_COMBINE_PLOT_FIELDS_'//modus, &
-                      EXIST=netcdf_parallel )
-             IF ( netcdf_parallel )  THEN
-                netcdf_parallel = .TRUE.
-             ELSE
-                netcdf_parallel = .FALSE.
-             ENDIF
-          ELSE
-             netcdf_output = .FALSE.
-          ENDIF
-
-!
-!--       Info-output
-          PRINT*, ''
-#if defined( __netcdf )
-          IF ( netcdf_output )  THEN
-             IF ( netcdf_parallel )  THEN
-             PRINT*, '    NetCDF ' // modus // '-data are in one file ', &
-                          '(NetCDF4-format) - merging not neccessary'
-             ELSE
-                PRINT*, '    NetCDF output enabled'
-             ENDIF 
-          ENDIF
-#else
-          IF ( netcdf_output )  THEN
-             PRINT*, '--- Sorry, no NetCDF support on this host'
-             netcdf_output = .FALSE.
-          ENDIF
-#endif
-          IF ( .NOT. netcdf_parallel )  THEN
-             IF ( danz /= 0 )  THEN
-                PRINT*, '    ',modus,'-section:  ', danz, ' file(s) found'
-             ELSE
-                PRINT*, '    no ', modus, '-section data available'
-             ENDIF
-          ENDIF
-
-          IF ( netcdf_output  .AND. .NOT. netcdf_parallel  .AND.  danz /= 0 ) &
-          THEN
-#if defined( __netcdf )
-             DO  av = 0, 1
-
-                IF ( av == 0  .AND.  .NOT.  netcdf_0 )  CYCLE
-                IF ( av == 1  .AND.  .NOT.  netcdf_1 )  CYCLE
-
-!
-!--             Open NetCDF dataset
-                IF ( av == 0 )  THEN
-                   filename = 'DATA_2D_'//modus//'_NETCDF' &
-                        //TRIM( model_string )
-                ELSE
-                   filename = 'DATA_2D_'//modus//'_AV_NETCDF' &
-                        //TRIM( model_string )
-                ENDIF
-                nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set(av) )
-                IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 1 )
-
-!
-!--             Get the list of variables (order of variables corresponds with
-!--             the order of data on the binary file)
-                var_list(av) = ' '    ! GET_ATT does not assign trailing blanks
-                nc_stat = NF90_GET_ATT( id_set(av), NF90_GLOBAL, 'VAR_LIST', &
-                     var_list(av) )
-                IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 2 )
-
-!
-!--             Inquire id of the time coordinate variable
-                nc_stat = NF90_INQ_VARID( id_set(av), 'time', id_var_time(av) )
-                IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 3 )
-
-!
-!--             Count number of variables; there is one more semicolon in the
-!--             string than variable names
-                num_var(av) = -1
-                DO  i = 1, LEN( var_list(av) )
-                   IF ( var_list(av)(i:i) == ';' )  num_var(av) = num_var(av) +1
-                ENDDO
-
-!
-!--             Extract the variable names from the list and inquire their
-!--             NetCDF IDs
-                pos = INDEX( var_list(av), ';' )
-!
-!--             Loop over all variables
-                DO  i = 1, num_var(av)
-
-!
-!--                Extract variable name from list
-                   var_list(av) = var_list(av)(pos+1:)
-                   pos = INDEX( var_list(av), ';' )
-                   var_name = var_list(av)(1:pos-1)
-
-!
-!--                Get variable ID from name
-                   nc_stat = NF90_INQ_VARID( id_set(av), TRIM( var_name ), &
-                        id_var(av,i) )
-                   IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 4 )
-
-!
-!--                Get number of x/y/z levels for that variable
-                   nc_stat = NF90_INQUIRE_VARIABLE( id_set(av), id_var(av,i), &
-                        dimids = id_dims_loc )
-                   IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 5 )
-                   id_dims(av,:) = id_dims_loc
-
-!
-!--                Inquire dimension ID
-                   DO  j = 1, 4
-                      nc_stat = NF90_INQUIRE_DIMENSION( id_set(av), &
-                           id_dims(av,j), dimname, levels(av,i) )
-                      IF ( nc_stat /= NF90_NOERR ) CALL handle_netcdf_error( 6 )
-
-                      IF ( modus == 'XY' .AND. INDEX(dimname, 'z') /= 0 )  EXIT
-                      IF ( modus == 'XZ' .AND. INDEX(dimname, 'y') /= 0 )  EXIT
-                      IF ( modus == 'YZ' .AND. INDEX(dimname, 'x') /= 0 )  EXIT
-                   ENDDO
-
-                ENDDO
-
-             ENDDO   ! av = 0, 1
-
-#endif
-          ENDIF
-
-!
-!--       Read the arrays, as long as the end of the file is reached
-          IF ( .NOT. netcdf_parallel )  THEN
-
-             fanz          =         0
-             current_level =         1
-             current_var   = 999999999
-
-             DO  WHILE ( danz /= 0 )
-
-!
-!--             Loop over all files (reading data of the subdomains)
-                DO  id = 0, danz-1
-!
-!--                File from PE0 contains special information at the beginning,
-!--                concerning the lower and upper indices of the total-domain
-!--                used in PALM (nxa, nxe, nya, nye).
-!--                Allocate necessary arrays, open the output file and write
-!--                the coordinate informations needed by ISO2D.
-                   IF ( id == 0  .AND.  fanz(0) == 0  .AND.  fanz(1) == 0 ) THEN
-
-                      READ ( id+110 )  nxa, nxe, nya, nye
-                      ALLOCATE ( pf(nxa:nxe,nya:nye) )
-!
-!--                   Set actual domain bounds to total domain
-                      ya_do = nya
-                      ye_do = nye
-
-                   ENDIF
-!
-!--                Read output time
-                   IF ( netcdf_output  .AND.  id == 0 )  THEN
-                      READ ( id+110, END=998 )  simulated_time, time_step, av
-                   ENDIF
-!
-!--                Read subdomain indices
-                   READ ( id+110, END=998 )  xa, xe, ya, ye, ya_tot, ye_tot
-
-!
-!--                IF the PE made no output (in case that no part of the
-!--                cross-section is situated on this PE), indices have the
-!--                value -1
-                   IF ( .NOT. ( xa == -1  .AND.  xe == -1  .AND. &
-                                ya == -1  .AND.  ye == -1 ) )  THEN
-
-
-!
-!--                   Read the subdomain grid-point values
-                      ALLOCATE( pf_tmp(xa:xe,ya:ye) )
-                      READ ( id+110 )  pf_tmp
-!
-!--                   Calculate indices on atmospheric grid (e.g. for soil model
-!--                   quantities)
-                      IF ( ya /= ya_tot .OR. ye /= ye_tot )  THEN
-                         ye_do = ye - ya
-                         ya_do = ya
-                         pf(xa:xe,ya_do:ye_do) = pf_tmp
-                      ELSE
-                         ye_do = nye
-                         ya_do = nya
-                         pf(xa:xe,ya:ye) = pf_tmp
-                      ENDIF
-
-                      DEALLOCATE( pf_tmp )
-                   ENDIF
-                   IF ( id == 0 )  fanz(av) = fanz(av) + 1
-
-                ENDDO
-!
-!--             Write data in NetCDF format
-                IF ( netcdf_output )  THEN
-#if defined( __netcdf )
-!
-!--                Check if a new time step has begun; if yes write data to
-!--                time axis
-                   IF ( current_var(av) > num_var(av) )  THEN
-                      current_var(av) = 1
-                      nc_stat = NF90_PUT_VAR( id_set(av), id_var_time(av), &
-                                              (/ simulated_time /),        &
-                                              start = (/ time_step /),     &
-                                              count = (/ 1 /) )
-                      IF ( nc_stat /= NF90_NOERR ) CALL handle_netcdf_error( 7 )
-                   ENDIF
-
-!
-!--                Now write the data; this is mode dependent
-                   SELECT CASE ( modus )
-
-                      CASE ( 'XY' )
-                         nc_stat = NF90_PUT_VAR( id_set(av),                   &
-                                           id_var(av,current_var(av)),         &
-                                           pf(nxa:nxe,nya:nye),                &
-                             start = (/ 1, 1, current_level(av), time_step /), &
-                                      count = (/ nxe-nxa+1, nye-nya+1, 1, 1 /) )
-                         IF ( nc_stat /= NF90_NOERR )  THEN
-                            CALL handle_netcdf_error( 8 )
-                         ENDIF
-                  
-                      CASE ( 'XZ' )
-                         nc_stat = NF90_PUT_VAR( id_set(av),                   &
-                                           id_var(av,current_var(av)),         &
-                                           pf(nxa:nxe,ya_do:ye_do),            &
-                             start = (/ 1, current_level(av), 1, time_step /), &
-                                      count = (/ nxe-nxa+1, 1, ye_do-ya_do+1, 1 /) )
-                         IF ( nc_stat /= NF90_NOERR )  THEN
-                            CALL handle_netcdf_error( 9 )
-                         ENDIF
-
-                      CASE ( 'YZ' )
-                         nc_stat = NF90_PUT_VAR( id_set(av),                   &
-                                           id_var(av,current_var(av)),         &
-                                           pf(nxa:nxe,ya_do:ye_do),            &
-                             start = (/ current_level(av), 1, 1, time_step /), &
-                                      count = (/ 1, nxe-nxa+1, ye_do-ya_do+1, 1 /) )
-                         IF ( nc_stat /= NF90_NOERR )  THEN
-                            CALL handle_netcdf_error( 10 )
-                         ENDIF
-
-                   END SELECT
-
-!
-!--                Data is written, check if max level is reached
-                   current_level(av) = current_level(av) + 1
-                   IF ( current_level(av) > levels(av,current_var(av)) )  THEN
-                      current_level(av) = 1
-                      current_var(av)   = current_var(av) + 1
-                   ENDIF
-
-#endif
-                ENDIF
-
-             ENDDO
-
-          ENDIF
-
-998       IF ( danz /= 0  .AND.  .NOT. netcdf_parallel )  THEN
-!
-!--          Print the number of the arrays processed
-             WRITE (*,'(16X,I4,A)')  fanz(0)+fanz(1), ' array(s) processed'
-             IF ( fanz(1) /= 0 )  THEN
-                WRITE (*,'(16X,I4,A)')  fanz(1), ' array(s) are time-averaged'
-             ENDIF
-
-!
-!--          Close all files and deallocate arrays
-             DO  id = 0, danz-1
-                CLOSE ( id+110 )
-             ENDDO
-             CLOSE ( 2 )
-             DEALLOCATE ( pf )
-
-!
-!--          Close the NetCDF file
-             IF ( netcdf_output )  THEN
-#if defined( __netcdf )
-                IF ( netcdf_0 )  THEN
-                   nc_stat = NF90_CLOSE( id_set(0) )
-                   IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 11 )
-                ENDIF
-                IF ( netcdf_1 )  THEN
-                   nc_stat = NF90_CLOSE( id_set(1) )
-                   IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 12 )
-                ENDIF
-#endif
-             ENDIF
-          ENDIF
-
-!
-!--       Output required cpu time
-          IF ( danz /= 0  .AND.  .NOT. netcdf_parallel )  THEN
-             CALL SYSTEM_CLOCK( count, count_rate )
-             cpu_end_time = REAL( count ) / REAL( count_rate )
-             WRITE (*,'(5X,A,F9.3,A)')  'Required cpu-time: ', &
-                                        cpu_end_time-cpu_start_time, ' sec'
-          ENDIF
-
-!
-!--       Choose the next cross-section
-          SELECT CASE ( modus )
-             CASE ( 'XY' )
-                modus = 'XZ'
-             CASE ( 'XZ' )
-                modus = 'YZ'
-             CASE ( 'YZ' )
-                modus = 'no'
-          END SELECT
+    DO  WHILE ( modus == 'XY'  .OR.  modus == 'XZ'  .OR.  modus == 'YZ' )
+!
+!--    Check, if file from PE0 exists. If it does not exist, PALM did not
+!--    create any output for this cross-section.
+       danz = 0
+       WRITE (id_char,'(A2,''_'',I4.4)')  modus, danz
+       INQUIRE ( FILE='PLOT2D_'//id_char, EXIST=found )
+!
+!--    Find out the number of files (equal to the number of PEs which
+!--    have been used in PALM) and open them
+       DO  WHILE ( found )
+
+          OPEN ( danz+110, FILE='PLOT2D_'//id_char, FORM='UNFORMATTED' )
+          danz = danz + 1
+          WRITE (id_char,'(A2,''_'',I4.4)')  modus, danz
+          INQUIRE ( FILE='PLOT2D_'//id_char, EXIST=found )
 
        ENDDO
 
-
-!
-!--    Combine the 3D-arrays
-       netcdf_parallel = .FALSE.
-
-!
-!--    Info-output
-       PRINT*, ' '
-
-!
-!--    Take current time
-       CALL SYSTEM_CLOCK( count, count_rate )
-       cpu_start_time = REAL( count ) / REAL( count_rate )
+!
+!--    Inquire whether an iso2d parameter file exists
+       INQUIRE( FILE='PLOT2D_' // modus // '_GLOBAL', EXIST=iso2d_output )
 
 !
 !--    Inquire whether a NetCDF file exists
-       INQUIRE( FILE='DATA_3D_NETCDF'//TRIM( model_string ), EXIST=netcdf_0 )
+       INQUIRE( FILE='DATA_2D_' // modus // '_NETCDF', EXIST=netcdf_0 )
 
 !
 !--    Inquire whether a NetCDF file for time-averaged data exists
-       INQUIRE( FILE='DATA_3D_AV_NETCDF'//TRIM( model_string ), EXIST=netcdf_1 )
+       INQUIRE( FILE='DATA_2D_' // modus // '_AV_NETCDF', EXIST=netcdf_1 )
 
        IF ( netcdf_0  .OR.  netcdf_1 )  THEN
           netcdf_output = .TRUE.
-!
-!--       Inquire whether the NetCDF file is already complete (parallel output)
-          INQUIRE( FILE='NO_COMBINE_PLOT_FIELDS_3D', EXIST=netcdf_parallel )
-          IF ( netcdf_parallel )  THEN
-             netcdf_parallel = .TRUE.
-          ELSE
-             netcdf_parallel = .FALSE.
-          ENDIF
        ELSE
           netcdf_output = .FALSE.
@@ -627,40 +143,9 @@
 
 !
-!--    Check, if file from PE0 exists; not neccessary in case of parallel
-!--    PALM output
-       IF ( .NOT. netcdf_parallel )  THEN
-          danz = 0
-          WRITE (id_string,'(I6.6)')  danz
-          INQUIRE ( &
-               FILE='PLOT3D_DATA'//TRIM( model_string )//'_'//TRIM( id_string ),  &
-               EXIST=found )
-       ELSE
-          found = .FALSE.
-       ENDIF
-
-!
-!--    Find out the number of files and open them
-       DO  WHILE ( found )
-
-          OPEN ( danz+110, &
-               FILE='PLOT3D_DATA'//TRIM( model_string )//'_'//TRIM(id_string), &
-               FORM='UNFORMATTED')
-          danz = danz + 1
-          WRITE (id_string,'(I6.6)')  danz
-          INQUIRE ( &
-               FILE='PLOT3D_DATA'//TRIM( model_string )//'_'//TRIM(id_string), &
-               EXIST=found )
-
-       ENDDO
-
-#if defined( __netcdf )
-       IF ( netcdf_output )  THEN
-          IF ( netcdf_parallel )  THEN
-             PRINT*, '    NetCDF data are in one file (NetCDF4-format)', &
-                          ' - merging not neccessary'
-          ELSE
-             PRINT*, '    NetCDF output enabled'
-          ENDIF
-       ENDIF
+!--    Info-output
+       PRINT*, ''
+       PRINT*, '*** combine_plot_fields ***'
+#if defined( __netcdf )
+       IF ( netcdf_output )  PRINT*, '    NetCDF output enabled'
 #else
        IF ( netcdf_output )  THEN
@@ -669,13 +154,11 @@
        ENDIF
 #endif
-       IF ( .NOT. netcdf_parallel )  THEN
-          IF ( danz /= 0 )  THEN
-             PRINT*, '    3D-data:     ', danz, ' file(s) found'
-          ELSE
-             PRINT*, '    no 3D-data file available'
-          ENDIF
-       ENDIF
-
-       IF ( netcdf_output  .AND. .NOT. netcdf_parallel  .AND.  danz /= 0 )  THEN
+       IF ( danz /= 0 )  THEN
+          PRINT*, '    ',modus,'-section:  ', danz, ' file(s) found'
+       ELSE
+          PRINT*, '    no ', modus, '-section data available'
+       ENDIF
+
+       IF ( netcdf_output  .AND.  danz /= 0 )  THEN
 #if defined( __netcdf )
           DO  av = 0, 1
@@ -687,11 +170,10 @@
 !--          Open NetCDF dataset
              IF ( av == 0 )  THEN
-                filename = 'DATA_3D_NETCDF'//TRIM( model_string )
+                filename = 'DATA_2D_' // modus // '_NETCDF'
              ELSE
-                filename = 'DATA_3D_AV_NETCDF'//TRIM( model_string )
+                filename = 'DATA_2D_' // modus // '_AV_NETCDF'
              ENDIF
              nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set(av) )
-             IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 13 )
-
+             IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 1 )
 
 !
@@ -700,11 +182,11 @@
              var_list(av) = ' '    ! GET_ATT does not assign trailing blanks
              nc_stat = NF90_GET_ATT( id_set(av), NF90_GLOBAL, 'VAR_LIST', &
-                  var_list(av) )
-             IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 14 )
+                                     var_list(av) )
+             IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 2 )
 
 !
 !--          Inquire id of the time coordinate variable
              nc_stat = NF90_INQ_VARID( id_set(av), 'time', id_var_time(av) )
-             IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 15 )
+             IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 3 )
 
 !
@@ -717,6 +199,6 @@
 
 !
-!--          Extract the variable names from the list and inquire their NetCDF
-!--          IDs
+!--          Extract the variable names from the list and inquire their
+!--          NetCDF IDs
              pos = INDEX( var_list(av), ';' )
 !
@@ -733,140 +215,443 @@
 !--             Get variable ID from name
                 nc_stat = NF90_INQ_VARID( id_set(av), TRIM( var_name ), &
-                     id_var(av,i) )
-                IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 16 )
+                                          id_var(av,i) )
+                IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 4 )
+
+!
+!--             Get number of x/y/z levels for that variable
+                nc_stat = NF90_INQUIRE_VARIABLE( id_set(av), id_var(av,i), &
+                                                 dimids = id_dims_loc )
+                IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 5 )
+                id_dims(av,:) = id_dims_loc
+
+!
+!--             Inquire dimension ID
+                DO  j = 1, 4
+                   nc_stat = NF90_INQUIRE_DIMENSION( id_set(av), id_dims(av,j),&
+                                                     dimname, levels(av,i) )
+                   IF ( nc_stat /= NF90_NOERR ) CALL handle_netcdf_error( 6 )
+
+                   IF ( modus == 'XY' .AND. INDEX(dimname, 'z') /= 0 )  EXIT
+                   IF ( modus == 'XZ' .AND. INDEX(dimname, 'y') /= 0 )  EXIT
+                   IF ( modus == 'YZ' .AND. INDEX(dimname, 'x') /= 0 )  EXIT
+                ENDDO
 
              ENDDO
 
-          ENDDO    ! av=0,1
-
-#endif
-       ENDIF
-
-!
-!--    Read arrays, until the end of the file is reached
-       IF ( .NOT. netcdf_parallel )  THEN
-
-          current_var = 999999999
-          fanz = 0
-          DO  WHILE ( danz /= 0 )
-
-!
-!--          Loop over all files
-             DO  id = 0, danz-1
-!
-!--             File from PE0 contains at the beginning the index bounds 
-!--             of PALM's total domain.
-!--             Allocate the array for storing the total domain data
-                IF ( id == 0  .AND.  fanz(0) == 0  .AND.  fanz(1) == 0 )  THEN
-                   READ ( id+110 )  nxa, nxe, nya, nye, nza, nze
-                   ALLOCATE ( pf3d(nxa:nxe,nya:nye,nza:nze) )
+          ENDDO   ! av = 0, 1
+
+       ENDIF
+#endif
+
+!
+!--    Read the arrays, as long as the end of the file is reached
+       fanz          =         0
+       current_level =         1
+       current_var   = 999999999
+
+       DO  WHILE ( danz /= 0 )
+
+!
+!--       Loop over all files (reading data of the subdomains)
+          DO  id = 0, danz-1
+!
+!--          File from PE0 contains special information at the beginning,
+!--          concerning the lower and upper indices of the total-domain used
+!--          in PALM (nxag, nxeg, nyag, nyeg) and the lower and upper
+!--          indices of the array to be writte by this routine (nxa, nxe, nya,
+!--          nye). Usually in the horizontal directions nxag=-1 and nxa=0
+!--          while all other variables have the same value (i.e. nxeg=nxe).
+!--          Allocate necessary arrays, open the output file and write
+!--          the coordinate informations needed by ISO2D.
+             IF ( id == 0  .AND.  fanz(0) == 0  .AND.  fanz(1) == 0 )  THEN
+                READ ( id+110 )  nxag, nxeg, nyag, nyeg
+                READ ( id+110 )  nxa, nxe, nya, nye
+                ALLOCATE ( eta(nya:nye), ho(nxa:nxe), hu(nxa:nxe), &
+                           pf(nxag:nxeg,nyag:nyeg) )
+                READ ( id+110 )  dx, eta, hu, ho
+
+                IF ( iso2d_output )  THEN
+                   OPEN ( 2, FILE='PLOT2D_'//modus, FORM='UNFORMATTED' )
+                   WRITE ( 2 )  dx, eta, hu, ho
                 ENDIF
-
-!
-!--             Read output time
-                IF ( netcdf_output  .AND.  id == 0 )  THEN
-                   IF ( netcdf_1 )  THEN
-                      READ ( id+110, END=999 )  simulated_time, time_step, av
-                   ELSE
-!
-!--                   For compatibility with earlier PALM versions
-                      READ ( id+110, END=999 )  simulated_time, time_step
-                      av = 0
-                   ENDIF
+             ENDIF
+!
+!--          Read output time
+             IF ( netcdf_output  .AND.  id == 0 )  THEN
+                IF ( netcdf_1 )  THEN
+                   READ ( id+110, END=998 )  simulated_time, time_step, av
+                ELSE
+!
+!--                For compatibility with earlier PALM versions
+                   READ ( id+110, END=998 )  simulated_time, time_step
+                   av = 0
                 ENDIF
-
-!
-!--             Read subdomain indices and grid point values
-                READ ( id+110, END=999 )  xa, xe, ya, ye, za, ze
-                ALLOCATE( pf3d_tmp(xa:xe,ya:ye,za:ze) )
-                READ ( id+110 )  pf3d_tmp
-
-                xxa = MAX( nxa, xa )
-                xxe = MIN( nxe, xe )
-                yya = MAX( nya, ya )
-                yye = MIN( nye, ye )
-                DO  k = za, ze
-                   DO  j = yya, yye
-                      DO  i = xxa, xxe
-                         pf3d(i,j,k) = pf3d_tmp(i,j,k)
-                      ENDDO
-                   ENDDO
-                ENDDO
-
-                DEALLOCATE( pf3d_tmp )
-                IF ( id == 0 )  fanz(av) = fanz(av) + 1
-
-             ENDDO
-
-!
-!--          Write data of the total domain in NetCDF format
-             IF ( netcdf_output )  THEN
-#if defined( __netcdf )
-!
-!--             Check if a new time step has begun; if yes write data to time
-!--             axis
-                IF ( current_var(av) > num_var(av) )  THEN
-                   current_var(av) = 1
-                   nc_stat = NF90_PUT_VAR( id_set(av), id_var_time(av), &
-                                      (/ simulated_time /),&
-                                      start = (/ time_step /), count = (/ 1 /) )
-                   IF ( nc_stat /= NF90_NOERR ) CALL handle_netcdf_error( 17 )
-                ENDIF
-
-!
-!--             Now write the data
-                nc_stat = NF90_PUT_VAR( id_set(av), id_var(av,current_var(av)),&
-                                        pf3d(nxa:nxe,nya:nye,za:ze), start = (/ 1, 1, 1, time_step /),&
-                              count = (/ nxe-nxa+1, nye-nya+1, ze-za+1, 1 /) )
-                IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 18 )
-
-                current_var(av) = current_var(av) + 1
-
-#endif
-             ENDIF
+             ENDIF
+!
+!--          Read subdomain indices
+             READ ( id+110, END=998 )  xa, xe, ya, ye
+!
+!--          IF the PE made no output (in case that no part of the
+!--          cross-section is situated on this PE), indices have the
+!--          value -1
+             IF ( .NOT. ( xa == -1  .AND.  xe == -1  .AND. &
+                          ya == -1  .AND.  ye == -1 ) )  THEN
+!
+!--              Read the subdomain grid-point values
+                 READ ( id+110 )  pf(xa:xe,ya:ye)
+             ENDIF
+             IF ( id == 0 )  fanz(av) = fanz(av) + 1
 
           ENDDO
-
-       ENDIF
-
-999    IF ( danz /= 0  .AND.  .NOT. netcdf_parallel )  THEN
-!
-!--       Print the number of arrays processed
+!
+!--       Write the data of the total domain cross-section
+          IF ( iso2d_output )  WRITE ( 2 )  pf(nxa:nxe,nya:nye)
+       
+!
+!--       Write same data in NetCDF format
+          IF ( netcdf_output )  THEN
+#if defined( __netcdf )
+!
+!--          Check if a new time step has begun; if yes write data to time axis
+             IF ( current_var(av) > num_var(av) )  THEN
+                current_var(av) = 1
+                nc_stat = NF90_PUT_VAR( id_set(av), id_var_time(av), &
+                                        (/ simulated_time /),        &
+                                        start = (/ time_step /),     &
+                                        count = (/ 1 /) )
+                IF ( nc_stat /= NF90_NOERR ) CALL handle_netcdf_error( 7 )
+             ENDIF
+
+!
+!--          Now write the data; this is mode dependent
+             SELECT CASE ( modus )
+
+                CASE ( 'XY' )
+                   nc_stat = NF90_PUT_VAR( id_set(av),                         &
+                                           id_var(av,current_var(av)),         &
+                                           pf(nxa:nxe,nya:nye),                &
+                             start = (/ 1, 1, current_level(av), time_step /), &
+                                      count = (/ nxe-nxa+1, nye-nya+1, 1, 1 /) )
+                   IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 8 )
+                  
+                CASE ( 'XZ' )
+                   nc_stat = NF90_PUT_VAR( id_set(av),                         &
+                                           id_var(av,current_var(av)),         &
+                                           pf(nxa:nxe,nya:nye),                &
+                             start = (/ 1, current_level(av), 1, time_step /), &
+                                      count = (/ nxe-nxa+1, 1, nye-nya+1, 1 /) )
+                   IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 9 )
+
+                CASE ( 'YZ' )
+                   nc_stat = NF90_PUT_VAR( id_set(av),                         &
+                                           id_var(av,current_var(av)),         &
+                                           pf(nxa:nxe,nya:nye),                &
+                             start = (/ current_level(av), 1, 1, time_step /), &
+                                      count = (/ 1, nxe-nxa+1, nye-nya+1, 1 /) )
+                   IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 10 )
+
+             END SELECT
+
+!
+!--          Data is written, check if max level is reached
+             current_level(av) = current_level(av) + 1
+             IF ( current_level(av) > levels(av,current_var(av)) )  THEN
+                current_level(av) = 1
+                current_var(av)   = current_var(av) + 1
+             ENDIF
+
+          ENDIF
+#endif
+
+       ENDDO
+
+998    IF ( danz /= 0 )  THEN
+!
+!--       Print the number of the arrays processed
           WRITE (*,'(16X,I4,A)')  fanz(0)+fanz(1), ' array(s) processed'
           IF ( fanz(1) /= 0 )  THEN
              WRITE (*,'(16X,I4,A)')  fanz(1), ' array(s) are time-averaged'
           ENDIF
-!
-!--       Close all files and deallocate array
+
+!
+!--       Close all files and deallocate arrays
           DO  id = 0, danz-1
              CLOSE ( id+110 )
           ENDDO
           CLOSE ( 2 )
-          DEALLOCATE ( pf3d )
-!
-!--       Close the NetCDF file
-          IF ( netcdf_output )  THEN
-#if defined( __netcdf )
-             IF ( netcdf_0 )  THEN
-                nc_stat = NF90_CLOSE( id_set(0) )
-                IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 19 )
-             ENDIF
+          DEALLOCATE ( eta, ho, hu, pf )
+       ENDIF
+
+!
+!--    Close the NetCDF file
+       IF ( netcdf_output  .AND.  danz /= 0 )  THEN
+#if defined( __netcdf )
+          IF ( netcdf_0 )  THEN
+             nc_stat = NF90_CLOSE( id_set(0) )
+             IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 11 )
+          ENDIF
+          IF ( netcdf_1 )  THEN
+             nc_stat = NF90_CLOSE( id_set(1) )
+             IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 12 )
+          ENDIF
+#endif
+       ENDIF
+
+!
+!--    Choose the next cross-section
+       SELECT CASE ( modus )
+          CASE ( 'XY' )
+             modus = 'XZ'
+          CASE ( 'XZ' )
+             modus = 'YZ'
+          CASE ( 'YZ' )
+             modus = 'no'
+       END SELECT
+
+    ENDDO
+
+
+!
+!-- Combine the 3D-arrays
+
+!
+!-- Inquire whether an avs fld file exists
+    INQUIRE( FILE='PLOT3D_FLD', EXIST=avs_output )
+
+!
+!-- Inquire whether a NetCDF file exists
+    INQUIRE( FILE='DATA_3D_NETCDF', EXIST=netcdf_0 )
+
+!
+!-- Inquire whether a NetCDF file for time-averaged data exists
+    INQUIRE( FILE='DATA_3D_AV_NETCDF', EXIST=netcdf_1 )
+
+    IF ( netcdf_0  .OR.  netcdf_1 )  THEN
+       netcdf_output = .TRUE.
+    ELSE
+       netcdf_output = .FALSE.
+    ENDIF
+
+!
+!-- Check, if file from PE0 exists
+    danz = 0
+    WRITE (id_char,'(I4.4)')  danz
+    INQUIRE ( FILE='PLOT3D_DATA_'//TRIM( id_char ), EXIST=found )
+
+!
+!-- Combination only works, if data are not compressed. In that case, 
+!-- PALM created a flag file (PLOT3D_COMPRESSED)
+    INQUIRE ( FILE='PLOT3D_COMPRESSED', EXIST=compressed )
+
+!
+!-- Find out the number of files and open them
+    DO  WHILE ( found  .AND.  .NOT. compressed )
+
+       OPEN ( danz+110, FILE='PLOT3D_DATA_'//TRIM( id_char ), &
+              FORM='UNFORMATTED')
+       danz = danz + 1
+       WRITE (id_char,'(I4.4)')  danz
+       INQUIRE ( FILE='PLOT3D_DATA_'//TRIM( id_char ), EXIST=found )
+
+    ENDDO
+
+!
+!-- Info-output
+    PRINT*, ' '
+    PRINT*, '*** combine_plot_fields ***'
+#if defined( __netcdf )
+       IF ( netcdf_output )  PRINT*, '    NetCDF output enabled'
+#else
+       IF ( netcdf_output )  THEN
+          PRINT*, '--- Sorry, no NetCDF support on this host'
+          netcdf_output = .FALSE.
+       ENDIF
+#endif
+    IF ( danz /= 0 )  THEN
+       PRINT*, '    3D-data:     ', danz, ' file(s) found'
+    ELSE
+       IF ( found .AND. compressed )  THEN
+          PRINT*, '+++ no 3D-data processing, since data are compressed'
+       ELSE
+          PRINT*, '    no 3D-data file available'
+       ENDIF
+    ENDIF
+
+    IF ( netcdf_output  .AND.  danz /= 0 )  THEN
+#if defined( __netcdf )
+       DO  av = 0, 1
+
+          IF ( av == 0  .AND.  .NOT.  netcdf_0 )  CYCLE
+          IF ( av == 1  .AND.  .NOT.  netcdf_1 )  CYCLE
+
+!
+!--       Open NetCDF dataset
+          IF ( av == 0 )  THEN
+             filename = 'DATA_3D_NETCDF'
+          ELSE
+             filename = 'DATA_3D_AV_NETCDF'
+          ENDIF
+          nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set(av) )
+          IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 13 )
+
+
+!
+!--       Get the list of variables (order of variables corresponds with the
+!--       order of data on the binary file)
+          var_list(av) = ' '    ! GET_ATT does not assign trailing blanks
+          nc_stat = NF90_GET_ATT( id_set(av), NF90_GLOBAL, 'VAR_LIST', &
+                                  var_list(av) )
+          IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 14 )
+
+!
+!--       Inquire id of the time coordinate variable
+          nc_stat = NF90_INQ_VARID( id_set(av), 'time', id_var_time(av) )
+          IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 15 )
+
+!
+!--       Count number of variables; there is one more semicolon in the string
+!--       than variable names
+          num_var(av) = -1
+          DO  i = 1, LEN( var_list(av) )
+             IF ( var_list(av)(i:i) == ';' )  num_var(av) = num_var(av) + 1
+          ENDDO
+
+!
+!--       Extract the variable names from the list and inquire their NetCDF IDs
+          pos = INDEX( var_list(av), ';' )
+!
+!--       Loop over all variables
+          DO  i = 1, num_var(av)
+
+!
+!--          Extract variable name from list
+             var_list(av) = var_list(av)(pos+1:)
+             pos = INDEX( var_list(av), ';' )
+             var_name = var_list(av)(1:pos-1)
+
+!
+!--          Get variable ID from name
+!             print*, '*** find id for "',TRIM( var_name ),'" begin'
+             nc_stat = NF90_INQ_VARID( id_set(av), TRIM( var_name ), &
+                                       id_var(av,i) )
+             IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 16 )
+!             print*, '*** find id for "',TRIM( var_name ),'" end'
+
+          ENDDO
+
+       ENDDO    ! av=0,1
+
+    ENDIF
+#endif
+
+!
+!-- Read arrays, until the end of the file is reached
+    current_var = 999999999
+    fanz = 0
+    DO  WHILE ( danz /= 0 )
+
+!
+!--    Loop over all files
+       DO  id = 0, danz-1
+!
+!--       File from PE0 contains special information at the beginning,
+!--       concerning the lower and upper indices of the total-domain used
+!--       in PALM (nxag, nxeg, nyag, nyeg, nzag, nzeg) and the lower and upper
+!--       indices of the array to be written by this routine (nxa, nxe, nya,
+!--       nye, nza, nze). Usually nxag=-1 and nxa=0, nyag=-1 and nya=0,
+!--       nzeg=nz and nze=nz_plot3d.
+!--       Allocate necessary array and open the output file.
+          IF ( id == 0  .AND.  fanz(0) == 0  .AND.  fanz(1) == 0 )  THEN
+             READ ( id+110 )  nxag, nxeg, nyag, nyeg, nzag, nzeg
+             READ ( id+110 )  nxa, nxe, nya, nye, nza, nze
+             ALLOCATE ( pf3d(nxag:nxeg,nyag:nyeg,nzag:nzeg) )
+             IF ( avs_output )  THEN
+                OPEN ( 2, FILE='PLOT3D_DATA', FORM='UNFORMATTED' )
+             ENDIF
+          ENDIF
+
+!
+!--       Read output time
+          IF ( netcdf_output  .AND.  id == 0 )  THEN
              IF ( netcdf_1 )  THEN
-                nc_stat = NF90_CLOSE( id_set(1) )
-                IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 20 )
-             ENDIF
-#endif
-          ENDIF
-
-!
-!--       Output required cpu time
-          CALL SYSTEM_CLOCK( count, count_rate )
-          cpu_end_time = REAL( count ) / REAL( count_rate )
-          WRITE (*,'(5X,A,F9.3,A)')  'Required cpu-time: ', &
-                                     cpu_end_time-cpu_start_time, ' sec'
-
-       ENDIF
-
-    ENDDO  ! models
+                READ ( id+110, END=999 )  simulated_time, time_step, av
+             ELSE
+!
+!--             For compatibility with earlier PALM versions
+                READ ( id+110, END=999 )  simulated_time, time_step
+                av = 0
+             ENDIF
+          ENDIF
+
+!
+!--       Read subdomain indices and grid point values
+          READ ( id+110, END=999 )  xa, xe, ya, ye, za, ze
+          READ ( id+110 )  pf3d(xa:xe,ya:ye,za:ze)
+          IF ( id == 0 )  fanz(av) = fanz(av) + 1
+
+       ENDDO
+
+!
+!--    Write data of the total domain
+       IF ( avs_output )  WRITE ( 2 )  pf3d(nxa:nxe,nya:nye,nza:nze)
+       
+!
+!--    Write same data in NetCDF format
+       IF ( netcdf_output )  THEN
+#if defined( __netcdf )
+!
+!--       Check if a new time step has begun; if yes write data to time axis
+          IF ( current_var(av) > num_var(av) )  THEN
+             current_var(av) = 1
+             nc_stat = NF90_PUT_VAR( id_set(av), id_var_time(av), &
+                                     (/ simulated_time /),&
+                                     start = (/ time_step /), count = (/ 1 /) )
+             IF ( nc_stat /= NF90_NOERR ) CALL handle_netcdf_error( 17 )
+          ENDIF
+
+!
+!--       Now write the data
+          nc_stat = NF90_PUT_VAR( id_set(av), id_var(av,current_var(av)), &
+                                  pf3d(nxa:nxe,nya:nye,nza:nze),      &
+                                  start = (/ 1, 1, 1, time_step /),   &
+                              count = (/ nxe-nxa+1, nye-nya+1, nze-nza+1, 1 /) )
+          IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 18 )
+
+          current_var(av) = current_var(av) + 1
+
+#endif
+       ENDIF
+
+    ENDDO
+
+999 IF ( danz /= 0 )  THEN
+!
+!--    Print the number of arrays processed
+       WRITE (*,'(16X,I4,A)')  fanz(0)+fanz(1), ' array(s) processed'
+       IF ( fanz(1) /= 0 )  THEN
+          WRITE (*,'(16X,I4,A)')  fanz(1), ' array(s) are time-averaged'
+       ENDIF
+!
+!--    Close all files and deallocate array
+       DO  id = 0, danz-1
+          CLOSE ( id+110 )
+       ENDDO
+       CLOSE ( 2 )
+       DEALLOCATE ( pf3d )
+!
+!--    Close the NetCDF file
+       IF ( netcdf_output )  THEN
+#if defined( __netcdf )
+          IF ( netcdf_0 )  THEN
+             nc_stat = NF90_CLOSE( id_set(0) )
+             IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 19 )
+          ENDIF
+          IF ( netcdf_1 )  THEN
+             nc_stat = NF90_CLOSE( id_set(1) )
+             IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 20 )
+          ENDIF
+#endif
+       ENDIF
+    ENDIF
 
 
@@ -882,10 +667,8 @@
        INTEGER, INTENT(IN) ::  errno
 
-#if defined( __netcdf )
        IF ( nc_stat /= NF90_NOERR )  THEN
           PRINT*, '+++ combine_plot_fields  netcdf: ', av, errno, &
                   TRIM( nf90_strerror( nc_stat ) )
        ENDIF
-#endif
 
     END SUBROUTINE handle_netcdf_error
Index: palm/trunk/UTIL/combine_plot_fields_single_open.f90
===================================================================
--- palm/trunk/UTIL/combine_plot_fields_single_open.f90	(revision 4901)
+++ palm/trunk/UTIL/combine_plot_fields_single_open.f90	(revision 1)
@@ -1,49 +1,20 @@
  PROGRAM combine_plot_fields
 
-!------------------------------------------------------------------------------!
-! This file is part of the PALM model system.
-!
-! PALM is free software: you can redistribute it and/or modify it under the
-! terms of the GNU General Public License as published by the Free Software
-! Foundation, either version 3 of the License, or (at your option) any later
-! version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with
-! PALM. If not, see <http://www.gnu.org/licenses/>.
-!
-! Copyright 1997-2021  Leibniz Universitaet Hannover
-!------------------------------------------------------------------------------!
-!
-! Current revisions:
-! -----------------
-! 
-! 
-! Former revisions:
+!-------------------------------------------------------------------------------!
+! Aktuelle Aenderungen:
 ! ---------------------
-! $Id$
-! Corrected "Former revisions" section
-! 
-! 2696 2017-12-14 17:12:51Z kanani
-! Change in file header (GPL part)
-!
-! 1468 2014-09-24 14:06:57Z maronga
-! Adapted for use on up to 6-digit processor cores (not tested)
-!
-! code put under GPL (PALM 3.9)
 ! Prozessordateien werden einzeln geoeffnet und geschlossen
 !
+! Fruehere Aenderungen:
+! ---------------------
 ! 23/02/99  Keine Bearbeitung komprimierter 3D-Daten
 ! Ursprungsversion vom 28/07/97
 !
 !
-! Description:
+! Beschreibung:
 ! -------------
 ! Vereinigung der von PARLES im Parallelbetrieb erzeugten Teilfelder zu
 ! gemeinsamen, das jeweilige Gesamtgebiet umfassenden Plotfeldern
-!------------------------------------------------------------------------------!
+!-------------------------------------------------------------------------------!
 
     IMPLICIT NONE
@@ -52,5 +23,5 @@
 !-- Lokale Variablen
     CHARACTER (LEN=2) ::  modus
-    CHARACTER (LEN=9) ::  id_char
+    CHARACTER (LEN=7) ::  id_char
 
     INTEGER, PARAMETER ::  spk = SELECTED_REAL_KIND( 6 )
@@ -76,5 +47,5 @@
 !--    Pruefen, ob Basisdatei von PE0 vorhanden
        danz = 0
-       WRITE (id_char,'(A2,''_'',I6.6)')  modus, danz
+       WRITE (id_char,'(A2,''_'',I4.4)')  modus, danz
        INQUIRE ( FILE='PLOT2D_'//id_char, EXIST=found )
 !
@@ -83,5 +54,5 @@
 
           danz = danz + 1
-          WRITE (id_char,'(A2,''_'',I6.6)')  modus, danz
+          WRITE (id_char,'(A2,''_'',I4.4)')  modus, danz
           INQUIRE ( FILE='PLOT2D_'//id_char, EXIST=found )
 
@@ -107,5 +78,5 @@
 !
 !--          Prozessordatei oeffnen
-             WRITE (id_char,'(A2,''_'',I6.6)')  modus, id
+             WRITE (id_char,'(A2,''_'',I4.4)')  modus, id
              OPEN ( 1, FILE='PLOT2D_'//id_char, FORM='UNFORMATTED', &
                        POSITION='ASIS' )
@@ -177,5 +148,5 @@
 !-- Pruefen, ob Basisdatei von PE0 vorhanden
     danz = 0
-    WRITE (id_char,'(I6.6)')  danz
+    WRITE (id_char,'(I4.4)')  danz
     INQUIRE ( FILE='PLOT3D_DATA_'//TRIM( id_char ), EXIST=found )
 
@@ -189,5 +160,5 @@
 
        danz = danz + 1
-       WRITE (id_char,'(I6.6)')  danz
+       WRITE (id_char,'(I4.4)')  danz
        INQUIRE ( FILE='PLOT3D_DATA_'//TRIM( id_char ), EXIST=found )
 
@@ -218,5 +189,5 @@
 !
 !--       Prozessordatei oeffnen
-          WRITE (id_char,'(I6.6)')  id
+          WRITE (id_char,'(I4.4)')  id
           OPEN ( 1, FILE='PLOT3D_DATA_'//TRIM( id_char ), FORM='UNFORMATTED', &
                     POSITION='ASIS' )
Index: palm/trunk/UTIL/compare_palm_logs.f90
===================================================================
--- palm/trunk/UTIL/compare_palm_logs.f90	(revision 4901)
+++ palm/trunk/UTIL/compare_palm_logs.f90	(revision 1)
@@ -2,39 +2,10 @@
 
 !------------------------------------------------------------------------------!
-! This file is part of the PALM model system.
-!
-! PALM is free software: you can redistribute it and/or modify it under the
-! terms of the GNU General Public License as published by the Free Software
-! Foundation, either version 3 of the License, or (at your option) any later
-! version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with
-! PALM. If not, see <http://www.gnu.org/licenses/>.
-!
-! Copyright 1997-2021  Leibniz Universitaet Hannover
-!------------------------------------------------------------------------------!
-!
-! Current revisions:
+! Actual revisions:
 ! -----------------
 ! 
-! 
+!
 ! Former revisions:
 ! -----------------
-! $Id$
-! Corrected "Former revisions" section
-!
-! 2696 2017-12-14 17:12:51Z kanani
-! Change in file header (GPL part)
-!
-! 1310 2014-03-14 08:01:56Z raasch
-! update of GPL copyright
-!
-! 1046 2012-11-09 14:38:45Z maronga
-! code put under GPL (PALM 3.9)
-! name of data-directories are read from input
 !
 ! Description:
@@ -75,14 +46,6 @@
     REAL, DIMENSION(:,:,:), ALLOCATABLE ::  array_1, array_2
 
-
-!
-!-- Read the two data-directories to be compared
-    PRINT*, '*** please enter name of first data-directory:'
-    READ ( *, * )  directory(1)
-    directory(1) = TRIM( directory(1) ) // '/'
-
-    PRINT*, '*** please enter name of second data-directory:'
-    READ ( *, * )  directory(2)
-    directory(2) = TRIM( directory(2) ) // '/'
+    directory(1) = 'const_log/'
+    directory(2) = 'const_log.1/'
 
 !
Index: palm/trunk/UTIL/find_palm_config.f90
===================================================================
--- palm/trunk/UTIL/find_palm_config.f90	(revision 1)
+++ palm/trunk/UTIL/find_palm_config.f90	(revision 1)
@@ -0,0 +1,336 @@
+ PROGRAM find_palm_config
+
+!------------------------------------------------------------------------------!
+! Description:
+! -------------
+! Find possible configurations for given processor and grid point numbers
+!------------------------------------------------------------------------------!
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=1) ::  char = ''
+    INTEGER ::  count = 0, i, ii(1), j, k, maximum_grid_level, mg_levels_x, &
+                mg_levels_y, mg_levels_z, n, numprocs, numprocs_max,        &
+                numprocs_min, nx, nxanz, nx_max, nx_min, ny, nyanz, ny_max, &
+                ny_min, nz, nz_max, nz_min, pdims(2)
+    INTEGER ::  numnx(10000), numpr(10000)
+    LOGICAL ::  cubic_domain = .FALSE., found, found_once = .FALSE., &
+                one_d_decomp = .FALSE., quadratic_domain_xy = .FALSE.
+    REAL    ::  grid_ratio, grid_ratio_new, maximum_grid_ratio, tolerance, &
+                tolerance_nx, tolerance_ny, tolerance_nz
+    REAL    ::  gridratio(10000)
+
+    TYPE configuration
+       REAL               ::  grid_ratio
+       INTEGER            ::  numprocs, pdims_1, pdims_2, nx, ny, nz, nxanz, &
+                              nyanz, grid_levels, nx_mg, ny_mg, nz_mg
+    END TYPE configuration
+
+    TYPE(configuration), DIMENSION(10000) ::  config
+
+!
+!-- Ask number of processors available
+    PRINT*, '*** number of PEs available + allowed tolerance:'
+    READ (*,*)  numprocs, tolerance
+    IF ( tolerance < 0.0 )  THEN
+       numprocs_max = numprocs
+       numprocs_min = numprocs * ( 1.0 + tolerance )
+    ELSE
+       numprocs_max = numprocs * ( 1.0 + tolerance )
+       numprocs_min = numprocs * ( 1.0 - tolerance )
+    ENDIF
+
+!
+!-- Ask for 1D-decomposition
+    PRINT*, ' '
+    PRINT*, ' '
+    PRINT*, '*** shall a 1d-decomposition along x be used (y/n)?'
+    READ (*,*)  char
+    IF ( char == 'y' )  one_d_decomp = .TRUE.
+
+!
+!-- Ask for quadratic domain
+    PRINT*, ' '
+    PRINT*, ' '
+    PRINT*, '*** shall a quadratic domain along x and y be used (y/n)?'
+    READ (*,*)  char
+    IF ( char == 'y' )  THEN
+       quadratic_domain_xy = .TRUE.
+       PRINT*, ' '
+       PRINT*, ' '
+       PRINT*, '*** shall also grid points along z be equal to x and y (y/n)?'
+       READ (*,*)  char
+       IF ( char == 'y' )  cubic_domain = .TRUE.
+    ENDIF
+
+!
+!-- Read number of gridpoints in each direction
+    PRINT*, ' '
+    PRINT*, ' '
+    PRINT*, '*** please type nx + allowed tolerance:'
+    READ (*,*)  nx, tolerance_nx
+    IF ( tolerance_nx < 0.0 )  THEN
+       nx_max = nx
+       nx_min = nx * ( 1.0 + tolerance_nx )
+    ELSE
+       nx_max = nx * ( 1.0 + tolerance_nx )
+       nx_min = nx * ( 1.0 - tolerance_nx )
+    ENDIF
+    IF ( quadratic_domain_xy )  THEN
+       ny           = nx
+       tolerance_ny = tolerance_nx
+    ELSE
+       PRINT*, '*** please type ny + allowed tolerance:'
+       READ (*,*)  ny, tolerance_ny
+    ENDIF
+    IF ( tolerance_ny < 0.0 )  THEN
+       ny_max = ny
+       ny_min = ny * ( 1.0 + tolerance_ny )
+    ELSE
+       ny_max = ny * ( 1.0 + tolerance_ny )
+       ny_min = ny * ( 1.0 - tolerance_ny )
+    ENDIF
+    IF ( cubic_domain )  THEN
+       nz           = nx
+       tolerance_nz = tolerance_nx
+    ELSE
+       PRINT*, '*** please type nz + allowed tolerance:'
+       READ (*,*)  nz, tolerance_nz
+    ENDIF
+    IF ( tolerance_nz < 0.0 )  THEN
+       nz_max = nz
+       nz_min = nz * ( 1.0 + tolerance_nz )
+    ELSE
+       nz_max = nz * ( 1.0 + tolerance_nz )
+       nz_min = nz * ( 1.0 - tolerance_nz )
+    ENDIF
+
+!
+!-- Read maximum gridpoint-ratio for which results shall be printed
+    PRINT*, ' '
+    PRINT*, '*** please type maximum subdomain gridpoint-ratio'
+    PRINT*, '    ( ABS( nx_sub / ny_sub - 1.0 ) ) for which results shall be'
+    PRINT*, '    printed'
+    READ (*,*)  maximum_grid_ratio
+
+!
+!-- Loop over allowed numbers of processors
+g:  DO  n = numprocs_max, numprocs_min, -1
+
+!
+!--    Set initial configuration
+       numprocs   = n
+       pdims(1)   = numprocs + 1
+       pdims(2)   = 1
+
+!
+!--    Looking for practicable virtual processor grids
+p:     DO  WHILE ( pdims(1) > 1 )
+
+          pdims(1) = pdims(1) - 1
+
+!
+!--       Create the virtual PE-grid topology
+          IF ( MOD( numprocs , pdims(1) ) /= 0 )  THEN
+             CYCLE p
+          ELSE
+             IF ( one_d_decomp  .AND.  pdims(1) < numprocs )  CYCLE g
+          ENDIF
+          pdims(2) = numprocs / pdims(1)
+
+      xn: DO  nx = nx_min, nx_max
+!
+!--          Proof, if grid points in x-direction can be distributed without
+!--          rest to the processors in x- and y-direction
+             IF ( MOD(nx+1, pdims(1)) /= 0 .OR. &
+                  MOD(nx+1, pdims(2)) /= 0 )  CYCLE xn
+             nxanz  = ( nx + 1 ) / pdims(1)
+
+         yn: DO  ny = ny_min, ny_max
+!
+!--             Eventually exit in case of non quadratic domains
+                IF ( quadratic_domain_xy  .AND.  ny /= nx )  CYCLE yn
+!
+!--             Proof, if grid points in y-direction can be distributed without
+!--             rest to the processors in x- and y-direction
+                IF ( MOD( ny+1 , pdims(2) ) /= 0 .OR. &
+                     MOD( ny+1, pdims(1) ) /= 0 )  CYCLE yn
+                nyanz  = ( ny + 1 ) / pdims(2)
+
+                grid_ratio = ABS( REAL( nxanz ) / REAL( nyanz ) - 1.0 )
+
+            zn: DO  nz = nz_min, nz_max
+!
+!--                Eventually exit in case of non cubic domains
+                   IF ( cubic_domain  .AND.  nz /= nx )  CYCLE zn
+!
+!--                Proof, if grid points in z-direction can be distributed
+!--                without rest to the processors in x-direction
+                   IF ( MOD( nz, pdims(1) ) /= 0  .AND.  .NOT. one_d_decomp ) &
+                   THEN
+                      CYCLE zn
+                   ENDIF
+
+!
+!--                Store configuration found
+                   IF ( grid_ratio < maximum_grid_ratio )  THEN
+                      found = .TRUE.
+                      count = count + 1
+                      config(count)%grid_ratio = grid_ratio
+                      config(count)%numprocs   = numprocs
+                      config(count)%pdims_1    = pdims(1)
+                      config(count)%pdims_2    = pdims(2)
+                      config(count)%nx         = nx
+                      config(count)%ny         = ny
+                      config(count)%nz         = nz
+                      config(count)%nxanz      = nxanz
+                      config(count)%nyanz      = nyanz
+                      IF ( count == 10000 )  THEN
+                         PRINT*, '+++ more than 10000 configurations'
+                         EXIT g
+                      ENDIF
+                   ENDIF
+
+                   IF ( one_d_decomp )  CYCLE yn
+
+                ENDDO zn
+
+             ENDDO yn
+
+          ENDDO xn
+
+       ENDDO p
+
+    ENDDO g
+
+    IF ( .NOT. found )  THEN
+       PRINT*, ' '
+       PRINT*, '+++ No valid processor grid found for the given number of'
+       PRINT*, '    processors and gridpoints'
+       STOP
+    ENDIF
+
+!
+!-- Calculate number of possible grid levels and gridpoints of the coarsest grid
+!-- used by the multigrid method
+    DO  n = 1, count
+       mg_levels_x = 1
+       mg_levels_y = 1
+       mg_levels_z = 1
+
+       i =  config(n)%nxanz
+       DO WHILE ( MOD( i, 2 ) == 0  .AND.  i /= 2 )
+          i = i / 2
+          mg_levels_x = mg_levels_x + 1
+       ENDDO
+
+       j =  config(n)%nyanz
+       DO WHILE ( MOD( j, 2 ) == 0  .AND.  j /= 2 )
+          j = j / 2
+          mg_levels_y = mg_levels_y + 1
+       ENDDO
+
+       k =  config(n)%nz
+       DO WHILE ( MOD( k, 2 ) == 0  .AND.  k /= 2 )
+          k = k / 2
+          mg_levels_z = mg_levels_z + 1
+       ENDDO
+
+       maximum_grid_level = MIN( mg_levels_x, mg_levels_y, mg_levels_z )
+       config(n)%grid_levels = maximum_grid_level
+       config(n)%nx_mg = config(n)%nxanz / 2**(maximum_grid_level-1) 
+       config(n)%ny_mg = config(n)%nyanz / 2**(maximum_grid_level-1)
+       config(n)%nz_mg = config(n)%nz    / 2**(maximum_grid_level-1)
+    ENDDO
+
+!
+!-- Print the configurations computed above
+    PRINT*, ' '
+    PRINT*, ' '
+    PRINT*, '*** print out results in ascending grid-ratio order (y/n)?'
+    READ (*,*)  char
+    IF ( char == 'y' )  THEN
+       gridratio = 10000.0
+       gridratio(1:count) = config(1:count)%grid_ratio
+       WRITE ( *, * )  ' '
+       WRITE ( *, * )  'Possible configurations found:'
+       WRITE ( *, * )  'sorted in ascending grid-ratio order'
+       WRITE ( *, 100 )
+       DO
+          ii = MINLOC( gridratio )
+          i = ii(1)
+          IF ( gridratio(i) /= 10000.0 )  THEN
+             WRITE ( *, 101 ) &
+                config(i)%grid_ratio, config(i)%numprocs, config(i)%pdims_1, &
+                config(i)%pdims_2, config(i)%nx, config(i)%ny, config(i)%nz, &
+                config(i)%nxanz, config(i)%nyanz, config(i)%grid_levels,     &
+                config(i)%nx_mg, config(i)%ny_mg, config(i)%nz_mg
+             gridratio(i) = 10000.0
+          ELSE
+             EXIT 
+          ENDIF
+       ENDDO
+    ENDIF
+
+    PRINT*, ' '
+    PRINT*, ' '
+    PRINT*, '*** print out results in descending PE order (y/n)?'
+    READ (*,*)  char
+    IF ( char == 'y' )  THEN
+       numpr = 0
+       numpr(1:count) = config(1:count)%numprocs
+       WRITE ( *, * )  ' '
+       WRITE ( *, * )  'Possible configurations found:'
+       WRITE ( *, * )  'sorted after number of PEs'
+       WRITE ( *, 100 )
+       DO
+          ii = MAXLOC( numpr )
+          i = ii(1)
+          IF ( numpr(i) /= 0 )  THEN
+             WRITE ( *, 101 ) &
+                config(i)%grid_ratio, config(i)%numprocs, config(i)%pdims_1, &
+                config(i)%pdims_2, config(i)%nx, config(i)%ny, config(i)%nz, &
+                config(i)%nxanz, config(i)%nyanz, config(i)%grid_levels,     &
+                config(i)%nx_mg, config(i)%ny_mg, config(i)%nz_mg
+             numpr(i) = 0
+          ELSE
+             EXIT 
+          ENDIF
+       ENDDO
+    ENDIF
+
+    PRINT*, ' '
+    PRINT*, ' '
+    PRINT*, '*** print out results in descending grid size order (y/n)?'
+    READ (*,*)  char
+    IF ( char == 'y' )  THEN
+       numnx = 0
+       DO  i = 1, count
+          numnx(i) = config(i)%nx * config(i)%ny * config(i)%nz
+       ENDDO
+       WRITE ( *, * )  ' '
+       WRITE ( *, * )  'Possible configurations found:'
+       WRITE ( *, * )  'sorted after grid size'
+       WRITE ( *, 100 )
+       DO
+          ii = MAXLOC( numnx )
+          i = ii(1)
+          IF ( numnx(i) /= 0 )  THEN
+             WRITE ( *, 101 ) &
+                config(i)%grid_ratio, config(i)%numprocs, config(i)%pdims_1, &
+                config(i)%pdims_2, config(i)%nx, config(i)%ny, config(i)%nz, &
+                config(i)%nxanz, config(i)%nyanz, config(i)%grid_levels,     &
+                config(i)%nx_mg, config(i)%ny_mg, config(i)%nz_mg
+             numnx(i) = 0
+          ELSE
+             EXIT 
+          ENDIF
+       ENDDO
+    ENDIF
+
+100 FORMAT('ratio  PEs   PE-grid      nx   ny   nz   subdomain  grid_levels  ', &
+           'coarsest subd.')
+101 FORMAT(F4.2,2X,I4,' (',I4,',',I4,')',2X,I4,1X,I4,1X,I4,'  (',I4,',',I4,')', &
+           5X,I2,7X,'(',I3,',',I3,',',I3,')')
+
+ END PROGRAM find_palm_config
Index: palm/trunk/UTIL/interpret_config.f90
===================================================================
--- palm/trunk/UTIL/interpret_config.f90	(revision 1)
+++ palm/trunk/UTIL/interpret_config.f90	(revision 1)
@@ -0,0 +1,544 @@
+ PROGRAM interpret_config
+
+!-------------------------------------------------------------------------------!
+! 21/07/97 - Siggi - Erste Fassung
+! 18/11/97 - Siggi - Komma in 2010-FORMAT hinzugefuegt
+! 29/04/05 - Siggi - extin wird auch fuer Input-Dateien ausgegeben
+! 29/06/05 - Siggi - Fehlermeldung ins englische uebertragen und ergaenzt
+! 01/11/05 - Siggi - s2b-Feld erlaubt den Wert locopt
+!
+! Letzte Aenderungen:
+! -------------------
+!
+! Beschreibung:
+! -------------
+! Interpretation der MRUN-Konfigurationsdatei. Ausgegeben werden ksh-Kommandos,
+! die anschliessend von MRUN ausgefuehrt werden muessen.
+!-------------------------------------------------------------------------------!
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=1)   ::  bs = ACHAR( 92 )   ! backslash (auf vpp sonst n. druckbar)
+    CHARACTER (LEN=20)  ::  do_remote, do_trace, host, localhost
+    CHARACTER (LEN=100) ::  config_file, icf
+    CHARACTER (LEN=300) ::  cond1, cond2, empty = REPEAT( ' ', 240 ), &
+                            for_cond1, for_cond2, for_host, input_list, &
+                            iolist, output_list, s1, s2, s2a, s2b, s2c, s3, &
+                            s3cond, s4, s5, s6, value, value_mrun,&
+                            var, zeile
+
+    INTEGER ::  dummy, i, icomment = 0, icond1, icond2, idatver = 0, iec = 0, &
+                ienvvar = 0, ifor_cond1, ifor_cond2, ifor_host, ihost, &
+                iic = 0, iicf, iin = 0, iinput_list, il, ilocalhost,  ioc = 0, &
+                ios, iout = 0, ioutput_list, is1, is2, is2a, is2b, is2c, &
+                is3, is3cond, is4, is5, is6, ivalue, ivalue_mrun, ivar, izeile
+
+    LOGICAL ::  found
+
+    CALL local_getenv( 'cond1', 5, cond1, icond1 )
+    CALL local_getenv( 'cond2', 5, cond2, icond2 )
+    CALL local_getenv( 'config_file', 11, config_file, il )
+    CALL local_getenv( 'do_remote', 9, do_remote, dummy )
+    CALL local_getenv( 'do_trace', 8, do_trace, dummy )
+    CALL local_getenv( 'host', 4, host, ihost )
+    CALL local_getenv( 'input_list', 10, input_list, iinput_list )
+    CALL local_getenv( 'interpreted_config_file', 23, icf, iicf )
+    CALL local_getenv( 'localhost', 9, localhost, ilocalhost )
+    CALL local_getenv( 'output_list', 11, output_list, ioutput_list )
+    iolist = input_list(1:iinput_list) // output_list(1:ioutput_list)
+
+    IF ( do_trace(1:4) == 'true' )  THEN
+       PRINT*,'*** cond1="',cond1(1:icond1),'"'
+       PRINT*,'*** cond2="',cond2(1:icond2),'"'
+       PRINT*,'*** config_file="',config_file(1:il),'"'
+       PRINT*,'*** do_remote="',do_remote,'"'
+       PRINT*,'*** do_trace="',do_trace,'"'
+       PRINT*,'*** host="',host(1:ihost),'"'
+       PRINT*,'*** input_list="',input_list(1:iinput_list),'"'
+       PRINT*,'*** interpreted_config_file="',icf(1:iicf),'"'
+       PRINT*,'*** localhost="',localhost(1:ilocalhost),'"'
+       PRINT*,'*** output_list="',output_list(1:ioutput_list),'"'
+    ENDIF
+
+    OPEN ( 1, FILE=config_file(1:il), FORM='formatted' )
+    OPEN ( 2, FILE=icf(1:iicf), FORM='formatted' )
+
+    READ ( 1, '(A)', IOSTAT=ios )  zeile
+
+
+    DO WHILE ( ios == 0 )
+
+       izeile = LEN_TRIM( zeile )
+
+       IF ( zeile(1:1) == '#' )  THEN
+          icomment = icomment + 1
+       ELSEIF ( zeile(1:1) == '%' )  THEN
+          ienvvar = ienvvar + 1
+          i = INDEX( zeile, ' ' )
+          var = zeile(2:i-1)
+          ivar = i - 2
+
+!
+!--       Achtung: Auf hpmuk und vpp sind nur die Variablen bekannt, die
+!--       von MRUN exportiert wurden!
+          CALL local_getenv( var, ivar, value_mrun, ivalue_mrun )
+
+!
+!--       Variable bekommt nur dann neuen Wert, wenn ihr per Shellscript-
+!--       Option noch keiner zugewiesen wurde
+          IF ( value_mrun(1:ivalue_mrun) == ''  .OR. &
+               value_mrun(1:ivalue_mrun) == '0' )  THEN
+
+             zeile(1:i) = empty(1:i)
+             zeile = ADJUSTL( zeile )
+             i = INDEX( zeile, ' ' )
+             value = zeile(1:i-1)
+             ivalue = i - 1
+
+             zeile(1:i) = empty(1:i)
+             zeile = ADJUSTL( zeile )
+             i = INDEX( zeile, ' ' )
+
+             IF ( i /= 1 )  THEN
+                for_host = zeile(1:i-1)
+                ifor_host = i - 1
+
+                zeile(1:i) = empty(1:i)
+                zeile = ADJUSTL( zeile )
+                i = INDEX( zeile, ' ' )
+
+                IF ( i /= 1 )  THEN
+                   for_cond1 = zeile(1:i-1)
+                   ifor_cond1 = i - 1
+
+                   zeile(1:i) = empty(1:i)
+                   zeile = ADJUSTL( zeile )
+                   i = INDEX( zeile, ' ' )
+
+                   IF ( i /= 1 )  THEN
+                      for_cond2 = zeile(1:i-1)
+                      ifor_cond2 = i - 1
+                   ELSE
+                      for_cond2 = ''
+                      ifor_cond2 = 0
+                   ENDIF
+                ELSE
+                   for_cond1 = ''
+                   ifor_cond1 = 0
+                   for_cond2 = ''
+                   ifor_cond2 = 0
+                ENDIF
+             ELSE
+                for_host = ' '
+                ifor_host = 1
+                for_cond1 = ''
+                ifor_cond1 = 0
+                for_cond2 = ''
+                ifor_cond2 = 0
+             ENDIF
+             IF ( do_trace(1:4) == 'true' )  THEN
+                PRINT*,'var="',var(1:ivar),'"'
+                PRINT*,'value="',value(1:ivalue),'"'
+                PRINT*,'for_host="',for_host(1:ifor_host),'"'
+                PRINT*,'for_cond1="',for_cond1(1:ifor_cond1),'"'
+                PRINT*,'for_cond2="',for_cond2(1:ifor_cond2),'"'
+             ENDIF
+!
+!--          Geltungsbereich pruefen und evtl. Variable ausgeben
+             IF ( for_host == ' '  .OR.  ( &
+                  for_host(1:ifor_host) == host(1:ihost)  .AND. &
+                  for_cond1(1:ifor_cond1) == cond1(1:icond1)  .AND. &
+                  for_cond2(1:ifor_cond2) == cond2(1:icond2) &
+                                         )  .OR. ( &
+                  INDEX( iolist, for_host(1:ifor_host) ) /= 0 &
+                                                 ) )  THEN
+
+!
+!--             Zuerst Doppelpunkte durch Blanks ersetzen (aber doppelt
+!--             auftretende Doppelpunkte durch einen Doppelpunkt)
+                i = 0
+                DO
+                   i = i + 1
+                   IF ( i > ivalue )  EXIT
+                   IF ( value(i:i) == ':' )  THEN
+                      IF ( value(i+1:i+1) == ':' )  THEN
+                         value = value(1:i) // value(i+2:ivalue)
+                         ivalue = ivalue - 1
+                      ELSE
+                         value(i:i) = ' '
+                      ENDIF
+                   ENDIF
+                ENDDO
+
+!
+!--             Variable ausgeben
+                WRITE (2,2200)  var(1:ivar), bs, value(1:ivalue), bs, &
+                                var(1:ivar)
+ 2200           FORMAT ('eval ',A,'=',A,'"',A,A,'"'/'export ',A)
+
+                IF ( do_trace(1:4) == 'true' )  THEN
+                   WRITE (2,2201)  bs, var(1:ivar), value(1:ivalue)
+ 2201              FORMAT ('printf "',A,'n*** ENVIRONMENT-VARIABLE ',A,' = ',A)
+                ENDIF
+
+             ENDIF
+
+!
+!--          Variable "host" muss gleich ausgewertet werden, da mit ihr ein
+!--          neuer Geltungsbereich festgelegt wird
+             IF ( var(1:ivar) == 'host' )  THEN
+
+                host  = value(1:ivalue)
+                ihost = ivalue
+
+!                IF ( host(1:ihost) /= localhost(1:ilocalhost) )  THEN
+!
+!                   SELECT CASE ( value(1:ivalue) )
+!
+!                      CASE ( 'cray','hpcs','t3d','t3eb','t3eh','unics','vpp' )
+!
+!                         dummy = 1
+!
+!                      CASE DEFAULT
+!
+!                         WRITE (2,2202)  bs, bs, value(1:ivalue), bs, bs
+! 2202                    FORMAT ('printf "',A,'n +++ Auf Zielrechner ',A,'"',A,A,'" ist kein NQS-System vorhanden"'/ &
+!                                 'printf "',A,'n     Programmlauf kann deshalb nicht gestartet werden"'/ &
+!                                 'locat=nqs; exit')
+!                         STOP
+!
+!                   END SELECT
+!
+!                ENDIF
+
+             ENDIF
+
+          ENDIF
+
+       ELSEIF ( zeile(1:3) == 'EC:' )  THEN
+!
+!--       Error-Kommandos
+          iec = iec + 1
+          IF ( iec < 10 )  THEN
+             WRITE (2,'(''err_command['',I1,'']="'',A,''"'')')  iec, &
+                                                                zeile(4:izeile)
+          ELSEIF ( iec < 100 )  THEN
+             WRITE (2,'(''err_command['',I2,'']="'',A,''"'')')  iec, &
+                                                                zeile(4:izeile)
+          ELSE
+             WRITE (2,'(''err_command['',I3,'']="'',A,''"'')')  iec, &
+                                                                zeile(4:izeile)
+          ENDIF
+
+       ELSEIF ( zeile(1:3) == 'IC:' )  THEN
+!
+!--       Input-Kommandos
+          iic = iic + 1
+          IF ( iic < 10 )  THEN
+             WRITE (2,'(''in_command['',I1,'']="'',A,''"'')')  iic, &
+                                                               zeile(4:izeile)
+          ELSEIF ( iic < 100 )  THEN
+             WRITE (2,'(''in_command['',I2,'']="'',A,''"'')')  iic, &
+                                                               zeile(4:izeile)
+          ELSE
+             WRITE (2,'(''in_command['',I3,'']="'',A,''"'')')  iic, &
+                                                               zeile(4:izeile)
+          ENDIF
+
+       ELSEIF ( zeile(1:3) == 'OC:' )  THEN
+!
+!--       Output-Kommandos
+          ioc = ioc + 1
+          IF ( ioc < 10 )  THEN
+             WRITE (2,'(''out_command['',I1,'']="'',A,''"'')')  ioc, &
+                                                                zeile(4:izeile)
+          ELSEIF ( ioc < 100 )  THEN
+             WRITE (2,'(''out_command['',I2,'']="'',A,''"'')')  ioc, &
+                                                                zeile(4:izeile)
+          ELSE
+             WRITE (2,'(''out_command['',I3,'']="'',A,''"'')')  ioc, &
+                                                                zeile(4:izeile)
+          ENDIF
+
+       ELSE
+!
+!--       Dateiverbindungen
+          idatver = idatver + 1
+!
+!--       Lokaler Name
+          i   = INDEX( zeile , ' ' )
+          s1  = zeile(1:i-1)
+          is1 = i-1
+!
+!--       Dateieigenschaften
+          zeile = ADJUSTL( zeile(i:izeile) )
+          i   = INDEX( zeile , ' ' )
+          s2  = zeile(1:i-1)
+          is2 = i-1
+!
+!--       Geltungsbereich
+          zeile = ADJUSTL( zeile(i:izeile) )
+          i   = INDEX( zeile , ' ' )
+          s3  = zeile(1:i-1)
+          is3 = i-1
+!
+!--       Pfadname
+          zeile = ADJUSTL( zeile(i:izeile) )
+          i   = INDEX( zeile , ' ' )
+          s4  = zeile(1:i-1)
+          is4 = i-1
+!
+!--       evtl. Extension
+          zeile = ADJUSTL( zeile(i:izeile) )
+          i = INDEX( zeile , ' ' )
+          IF ( i == 1 )  THEN
+             s5  = ' '
+             is5 = 1
+             s6  = ' '
+             is6 = 1
+          ELSE
+             s5  = zeile(1:i-1)
+             is5 = i-1
+!
+!--          evtl. 2. Extension
+             zeile = ADJUSTL( zeile(i:izeile) )
+             i = INDEX( zeile , ' ' )
+             IF ( i == 1 )  THEN
+                s6  = ' '
+                is6 = 1
+             ELSE
+                s6  = zeile(1:i-1)
+                is6 = i-1
+             ENDIF
+          ENDIF
+
+!
+!--       Dateieigenschaften aufspalten
+          i = INDEX( s2 , ':' )
+          IF ( i == 0 )  THEN
+             s2a  = s2
+             is2a = is2
+             s2b  = ''
+             is2b = 0
+             s2c  = ''
+             is2c = 0
+          ELSE
+             s2a  = s2(1:i-1)
+             is2a = i-1
+             s2   = s2(i+1:is2)
+
+             i = INDEX( s2 , ':' )
+             IF ( i == 0 )  THEN
+                s2b  = s2
+                is2b = LEN_TRIM( s2 )
+                s2c  = ''
+                is2c = 0
+             ELSE
+                s2b  = s2(1:i-1)
+                is2b = i-1
+                s2c  = s2(i+1:)
+                is2c = LEN_TRIM( s2c )
+             ENDIF
+          ENDIF
+!
+!--       Pruefung, ob Eingabedateiverbindung abgespeichert werden soll
+          IF ( s2a(1:is2a) == 'in'  .AND.  .NOT. (                     &
+               do_remote(1:4) == 'true'  .AND.                         &
+               ( s2b(1:is2b) == 'loc'  .OR.  s2b(1:is2b) == 'locopt' ) &
+                                                 ) )  THEN
+             found = .FALSE.
+             i = INDEX( s3 , ':' )
+             IF ( i == 0 )  THEN
+                s3cond  = s3
+                is3cond = LEN_TRIM( s3cond )
+             ELSE
+                s3cond  = s3(1:i-1)
+                is3cond = i-1
+                s3      = s3(i+1:)
+             ENDIF
+
+             DO WHILE ( s3cond(1:1) /= ' ' )
+
+                IF ( INDEX( input_list(1:iinput_list) , s3cond(1:is3cond) ) /= 0 &
+                     .OR.  s3cond(1:is3cond) == '-' )  THEN
+                   found = .TRUE.
+                ENDIF
+
+                IF ( s3(1:1) == ' ' )  THEN
+                   s3cond = ' '
+                ELSE
+                   i = INDEX( s3 , ':' )
+                   IF ( i == 0 )  THEN
+                      s3cond  = s3
+                      is3cond = LEN_TRIM( s3cond )
+                      s3      = ' '
+                   ELSE
+                      s3cond  = s3(1:i-1)
+                      is3cond = i-1
+                      s3      = s3(i+1:)
+                   ENDIF
+                ENDIF
+
+             ENDDO
+
+!
+!--          Wenn Geltungsbereich erfuellt, dann Dateiverbindung abspeichern
+             IF ( found )  THEN
+
+                iin = iin + 1
+                IF ( iin < 10 )  THEN
+                   WRITE (2,2000)  iin, s1(1:is1), iin, s2b(1:is2b), &
+                                   iin, s2c(1:is2c), &
+                                   iin, s3(1:is3), iin, s4(1:is4), &
+                                   iin, s5(1:is5), iin, s6(1:is6)
+2000               FORMAT ('localin[',I1,']="',A,'"; transin[',I1,']="',A, &
+                           '"; actionin[',I1,']="',A, &
+                           '"; typein[',I1,']="',A,'"'/'pathin[',I1,']="',A, &
+                           '"; endin[',I1,']="',A,'"; extin[',I1,']="',A,'"')
+                ELSEIF ( iin < 100 )  THEN
+                   WRITE (2,2001)  iin, s1(1:is1), iin, s2b(1:is2b), &
+                                   iin, s2c(1:is2c), &
+                                   iin, s3(1:is3), iin, s4(1:is4), &
+                                   iin, s5(1:is5), iin, s6(1:is6)
+2001               FORMAT ('localin[',I2,']="',A,'"; transin[',I2,']="',A, &
+                           '"; actionin[',I2,']="',A, &
+                           '"; typein[',I2,']="',A,'"'/'pathin[',I2,']="',A, &
+                           '"; endin[',I2,']="',A,'"; extin[',I2,']="',A,'"')
+                ELSE
+                   WRITE (2,2002)  iin, s1(1:is1), iin, s2b(1:is2b), &
+                                   iin, s2c(1:is2c), &
+                                   iin, s3(1:is3), iin, s4(1:is4), &
+                                   iin, s5(1:is5), iin, s6(1:is6)
+2002               FORMAT ('localin[',I3,']="',A,'"; transin[',I3,']="',A, &
+                           '"; actionin[',I3,']="',A, &
+                           '"; typein[',I3,']="',A,'"'/'pathin[',I3,']="',A, &
+                           '"; endin[',I3,']="',A,'"; extin[',I3,']="',A,'"')
+                ENDIF
+             ENDIF
+
+          ELSEIF ( s2a(1:is2a) == 'out'  .AND.  .NOT. ( &
+                   do_remote(1:4) == 'true'  .AND.  s2b(1:is2b) == 'loc' &
+                                                      ) )  THEN
+!
+!--          Pruefung, ob Ausgabedateiverbindung abgespeichert werden soll
+             found = .FALSE.
+             i = INDEX( s3 , ':' )
+             IF ( i == 0 )  THEN
+                s3cond  = s3
+                is3cond = LEN_TRIM( s3cond )
+             ELSE
+                s3cond  = s3(1:i-1)
+                is3cond = i-1
+                s3      = s3(i+1:)
+             ENDIF
+
+             DO WHILE ( s3cond(1:1) /= ' ' )
+
+                IF ( INDEX( output_list(1:ioutput_list) , s3cond(1:is3cond) ) /= 0 &
+                     .OR.  s3cond(1:is3cond) == '-' )  THEN
+                   found = .TRUE.
+                ENDIF
+
+                IF ( s3(1:1) == ' ' )  THEN
+                   s3cond = ' '
+                ELSE
+                   i = INDEX( s3 , ':' )
+                   IF ( i == 0 )  THEN
+                      s3cond  = s3
+                      is3cond = LEN_TRIM( s3cond )
+                      s3      = ' '
+                   ELSE
+                      s3cond  = s3(1:i-1)
+                      is3cond = i-1
+                      s3      = s3(i+1:)
+                   ENDIF
+                ENDIF
+
+             ENDDO
+!
+!--          Wenn Geltungsbereich erfuellt, dann Dateiverbindung abspeichern
+             IF ( found )  THEN
+
+                iout = iout + 1
+                IF ( iout < 10 )  THEN
+                   WRITE (2,2003)  iout, s1(1:is1), iout, s2c(1:is2c), &
+                                   iout, s3(1:is3), iout, s4(1:is4), &
+                                   iout, s5(1:is5), iout, s6(1:is6)
+ 2003              FORMAT ('localout[',I1,']="',A,'"; actionout[',I1,']="',A, &
+                           '"; typeout[',I1,']="',A,'"'/'pathout[',I1,']="',A, &
+                           '"; endout[',I1,']="',A,'"; extout[',I1,']="',A,'"')
+                ELSEIF ( iin < 100 )  THEN
+                      WRITE (2,2004)  iout, s1(1:is1), iout, s2c(1:is2c), &
+                                      iout, s3(1:is3), iout, s4(1:is4), &
+                                      iout, s5(1:is5), iout, s6(1:is6)
+ 2004              FORMAT ('localout[',I2,']="',A,'"; actionout[',I2,']="',A, &
+                           '"; typeout[',I2,']="',A,'"'/'pathout[',I2,']="',A, &
+                           '"; endout[',I2,']="',A,'"; extout[',I2,']="',A,'"')
+                ELSE
+                      WRITE (2,2005)  iout, s1(1:is1), iout, s2c(1:is2c), &
+                                      iout, s3(1:is3), iout, s4(1:is4), &
+                                      iout, s5(1:is5), iout, s6(1:is6)
+ 2005              FORMAT ('localout[',I3,']="',A,'"; actionout[',I3,']="',A, &
+                           '"; typeout[',I3,']="',A,'"'/'pathout[',I3,']="',A, &
+                           '"; endout[',I3,']="',A,'"; extout[',I3,']="',A,'"')
+                ENDIF
+             ENDIF
+
+          ELSEIF ( s2a(1:is2a) /= 'in'  .AND.  s2a(1:is2a) /= 'out' )  THEN
+!
+!--          Kein gueltiger Wert fuer I/O-Feld
+             WRITE (2,2010)  bs, bs, config_file(1:il), bs, bs, s2a(1:is2a), &
+                             bs, bs, bs, bs, bs, bs, bs
+ 2010        FORMAT ('printf "',A,'n',A,'n +++ I/O-field in configuration ', &
+                     'file ',A, ' has the illegal"'/ &
+                     'printf "',A,'n     value ',A,'"',A,A,'". Only ', &
+                     A,'"in',A,'" or ',A,'"out',A,'" are allowed!"'/ &
+                     'printf "',A,'n     The error may be caused by an', &
+                     ' empty line at the end of the "'/ &
+                     'printf "',A,'n     configuration file."' &
+                    )
+             WRITE (2,'(''locat=connect; exit'')')
+             STOP
+          ENDIF
+          
+       ENDIF
+
+       READ( 1, '(A)', IOSTAT=ios )  zeile
+
+    ENDDO
+
+!
+!-- Ausgabe der Anzahl von gefundenen Zeilen
+    IF ( iec > 0 )  WRITE (2,'(''(( iec = '',I3,'' ))'')')  iec
+    IF ( iic > 0 )  WRITE (2,'(''(( iic = '',I3,'' ))'')')  iic
+    IF ( ioc > 0 )  WRITE (2,'(''(( ioc = '',I3,'' ))'')')  ioc
+    IF ( iin > 0 )  WRITE (2,'(''(( iin = '',I3,'' ))'')')  iin
+    IF ( iout > 0 )  WRITE (2,'(''(( iout = '',I3,'' ))'')')  iout
+
+    IF ( do_trace(1:4) == 'true' )  THEN
+       PRINT*,' '
+       PRINT*,'*** Inhalt von: ',config_file(1:il)
+       PRINT*,icomment,' Kommentarzeilen'
+       PRINT*,ienvvar,' Environment-Variablen-Vereinbarungen'
+       PRINT*,iec,' Error-Kommandos'
+       PRINT*,iic,' Input-Kommandos'
+       PRINT*,ioc,' Output-Kommandos'
+       PRINT*,idatver,' Dateiverbindungs-Anweisungen'
+       PRINT*,'Davon interpretiert:'
+       PRINT*,iin,' Eingabedateien'
+       PRINT*,iout,' Ausgabedateien'
+    ENDIF
+
+ END PROGRAM interpret_config
+
+
+
+ SUBROUTINE local_getenv( var, ivar, value, ivalue )
+
+    CHARACTER (LEN=*) ::  var, value
+    INTEGER           ::  ivalue, ivar
+
+    CALL GETENV( var(1:ivar), value )
+    ivalue = LEN_TRIM( value )
+
+ END SUBROUTINE local_getenv    
Index: palm/trunk/UTIL/read_palm_2d_netcdf_data.f90
===================================================================
--- palm/trunk/UTIL/read_palm_2d_netcdf_data.f90	(revision 1)
+++ palm/trunk/UTIL/read_palm_2d_netcdf_data.f90	(revision 1)
@@ -0,0 +1,169 @@
+ PROGRAM read_palm_2d_netcdf_data
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! 
+!
+! Former revisions:
+! -----------------
+!
+! This routine must be compiled with:
+! decalpha:
+!    f95 -cpp -D__netcdf -fast -r8 -I/usr/local/netcdf-3.5.1/include
+!    -L/usr/local/netcdf-3.5.1/lib -lnetcdf
+! IBM-Regatta:
+!    xlf95 -qsuffix=cpp=f90 -WF,-D__netcdf -qrealsize=8 -q64 -qmaxmem=-1 -Q
+!    -I /aws/dataformats/netcdf-3.6.0-p1/64-32/include
+!    -L/aws/dataformats/netcdf-3.6.0-p1/64-32/lib -lnetcdf -O3
+! IBM-Regatta KISTI:
+!    xlf95 -qsuffix=cpp=f90 -WF,-D__netcdf -qrealsize=8 -q64 -qmaxmem=-1 -Q
+!    -I /applic/netcdf64/src/f90
+!    -L/applic/lib/NETCDF64 -lnetcdf -O3
+! IBM-Regatta Yonsei (gfdl5):
+!    xlf95 -qsuffix=cpp=f90 -WF,-D__netcdf -qrealsize=8 -q64 -qmaxmem=-1 -Q
+!    -I /usr1/users/raasch/pub/netcdf-3.6.0-p1/include
+!    -L/usr1/users/raasch/pub/netcdf-3.6.0-p1/lib -lnetcdf -O3
+! IMUK:
+!    ifort combine...f90 -o combine...x
+!    -cpp -D__netcdf -I /muksoft/packages/netcdf/linux/include -axW -r8 -nbs
+!    -Vaxlib -L /muksoft/packages/netcdf/linux/lib -lnetcdf
+! NEC-SX6:
+!    sxf90 combine...f90 -o combine...x 
+!    -I /pool/SX-6/netcdf/netcdf-3.6.0-p1/include  -C hopt -Wf '-A idbl4'
+!    -D__netcdf -L/pool/SX-6/netcdf/netcdf-3.6.0-p1/lib -lnetcdf
+!------------------------------------------------------------------------------!
+
+    USE netcdf
+
+    IMPLICIT NONE
+
+!
+!-- Local variables
+    CHARACTER (LEN=10)   ::  dimname, var_name
+    CHARACTER (LEN=40)   ::  filename
+
+    CHARACTER (LEN=2000) ::  var_list
+
+    INTEGER ::  i, j, k, nc_stat, pos, time_step
+
+    INTEGER ::  current_level, current_var, id_set, id_var_time, num_var
+
+    INTEGER, DIMENSION(4) ::  id_dims_loc
+
+    INTEGER, DIMENSION(4) ::  id_dims
+
+    INTEGER, DIMENSION(1000) ::  id_var, levels
+
+!    REAL, DIMENSION(0:576,0:128,3,6) ::  pf
+    REAL, DIMENSION(0:576,2,0:64,6) ::  pf
+
+
+
+    filename = 'ibmh_rinne_xz_av.nc'
+    nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set )
+    IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 1 )
+
+!
+!-- Get the list of variables (order of variables corresponds with the
+!-- order of data on the binary file)
+    var_list = ' '    ! GET_ATT does not assign trailing blanks
+    nc_stat = NF90_GET_ATT( id_set, NF90_GLOBAL, 'VAR_LIST', var_list )
+    IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 2 )
+
+!
+!-- Inquire id of the time coordinate variable
+    nc_stat = NF90_INQ_VARID( id_set, 'time', id_var_time )
+    IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 3 )
+
+!
+!-- Count number of variables; there is one more semicolon in the
+!-- string than variable names
+    num_var = -1
+    DO  i = 1, LEN( var_list )
+       IF ( var_list(i:i) == ';' )  num_var = num_var + 1
+    ENDDO
+
+!
+!-- Extract the variable names from the list and inquire their NetCDF IDs
+    pos = INDEX( var_list, ';' )
+!
+!-- Loop over all variables
+    DO  i = 1, num_var
+
+!
+!--    Extract variable name from list
+       var_list = var_list(pos+1:)
+       pos = INDEX( var_list, ';' )
+       var_name = var_list(1:pos-1)
+
+!
+!--    Get variable ID from name
+       nc_stat = NF90_INQ_VARID( id_set, TRIM( var_name ), id_var(i) )
+       IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 4 )
+
+!
+!--    Get number of x/y/z levels for that variable
+       nc_stat = NF90_INQUIRE_VARIABLE( id_set, id_var(i), &
+                                        dimids = id_dims_loc )
+       IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 5 )
+       id_dims = id_dims_loc
+
+!
+!--    Inquire dimension ID
+       DO  j = 1, 4
+          nc_stat = NF90_INQUIRE_DIMENSION( id_set, id_dims(j),&
+                                            dimname, levels(i) )
+          IF ( nc_stat /= NF90_NOERR ) CALL handle_netcdf_error( 6 )
+       ENDDO
+
+       PRINT*, '*** reading array ', i
+!       nc_stat = NF90_GET_VAR( id_set, id_var(i), pf(0:576,0:128,1:3,i), &
+!                                start = (/ 1, 1, 1, 1 /), &
+!                                count = (/ 577, 129, 3, 1 /) )
+       nc_stat = NF90_GET_VAR( id_set, id_var(i), pf(0:576,1:2,0:64,i), &
+                                start = (/ 1, 1, 1, 1 /), &
+                                count = (/ 577, 2, 65, 1 /) )
+       IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 7+i )
+                  
+    ENDDO
+
+    PRINT*, ' '
+    i = 190
+    j =  60
+
+!    DO  k = 3, 1, -1
+!       WRITE ( *, '(F5.2,1X,F5.2,1X,F6.3,1X,F6.2,1X,F6.4,1X,F6.4)' )  &
+!          pf(i,j,k,1), pf(i,j,k,2), pf(i,j,k,3), pf(i,j,k,4), pf(i,j,k,5), &
+!          pf(i,j,k,6)
+!    ENDDO
+    DO  k = 2, 0, -1
+       WRITE ( *, '(F5.2,1X,F5.2,1X,F6.3,1X,F6.2,1X,F6.4,1X,F6.4)' )  &
+          pf(i,1,k,1), pf(i,1,k,2), pf(i,1,k,3), pf(i,1,k,4), pf(i,1,k,5), &
+          pf(i,1,k,6)
+    ENDDO
+
+
+ CONTAINS
+
+
+    SUBROUTINE handle_netcdf_error( errno )
+!
+!--    Prints out a text message corresponding to the current NetCDF status
+
+       IMPLICIT NONE
+
+       INTEGER, INTENT(IN) ::  errno
+
+       IF ( nc_stat /= NF90_NOERR )  THEN
+          PRINT*, '+++ read_palm_2d_netcdf_data  netcdf: ', errno, &
+                  TRIM( nf90_strerror( nc_stat ) )
+       ENDIF
+
+    END SUBROUTINE handle_netcdf_error
+
+
+ END PROGRAM read_palm_2d_netcdf_data
+
+
+
Index: palm/trunk/UTIL/read_palm_netcdf_data.f90
===================================================================
--- palm/trunk/UTIL/read_palm_netcdf_data.f90	(revision 4901)
+++ 	(revision )
@@ -1,235 +1,0 @@
- PROGRAM read_palm_netcdf_data
-
-!------------------------------------------------------------------------------!
-! This file is part of the PALM model system.
-!
-! PALM is free software: you can redistribute it and/or modify it under the
-! terms of the GNU General Public License as published by the Free Software
-! Foundation, either version 3 of the License, or (at your option) any later
-! version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with
-! PALM. If not, see <http://www.gnu.org/licenses/>.
-!
-! Copyright 1997-2021  Leibniz Universitaet Hannover
-!------------------------------------------------------------------------------!
-!
-! Current revisions:
-! -----------------
-! 
-! 
-! Former revisions:
-! -----------------
-! $Id$
-! Corrected "Former revisions" section
-!
-! 2696 2017-12-14 17:12:51Z kanani
-! Change in file header (GPL part)
-!
-! 1310 2014-03-14 08:01:56Z raasch
-! update of GPL copyright
-!
-! 1046 2012-11-09 14:38:45Z maronga
-! code put under GPL (PALM 3.9)
-!
-! Description:
-! ------------                     
-! This is an example program for reading PALM 2d/3d NetCDF datasets
-!
-! The user has to add his own code for further storing and analyzing of
-! these data!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!
-! The NetCDF include file and library has to be given with the respective
-! compiler options. Please find out the respective paths on your system and
-! set them appropriately.
-!
-! Here are some examples how this routine should be compiled:
-!
-! decalpha:
-!    f95 -fast -r8 -I/usr/local/netcdf-3.5.1/include
-!    -L/usr/local/netcdf-3.5.1/lib -lnetcdf
-! IBM-Regatta:
-!    xlf95 -qrealsize=8 -q64 -qmaxmem=-1 -Q
-!    -I /aws/dataformats/netcdf-3.6.0-p1/64-32/include
-!    -L/aws/dataformats/netcdf-3.6.0-p1/64-32/lib -lnetcdf -O3
-! IBM-Regatta KISTI:
-!    xlf95 -qrealsize=8 -q64 -qmaxmem=-1 -Q
-!    -I /applic/netcdf64/src/f90
-!    -L/applic/lib/NETCDF64 -lnetcdf -O3
-! IBM-Regatta Yonsei (gfdl5):
-!    xlf95 -qrealsize=8 -q64 -qmaxmem=-1 -Q
-!    -I /usr1/users/raasch/pub/netcdf-3.6.0-p1/include
-!    -L/usr1/users/raasch/pub/netcdf-3.6.0-p1/lib -lnetcdf -O3
-! IMUK:
-!    ifort read_palm...f90 -o read_palm...x
-!    -I /muksoft/packages/netcdf/linux/include -axW -r8 -nbs
-!    -Vaxlib -L /muksoft/packages/netcdf/linux/lib -lnetcdf
-! NEC-SX6:
-!    sxf90 read_palm...f90 -o read_palm...x 
-!    -I /pool/SX-6/netcdf/netcdf-3.6.0-p1/include  -C hopt -Wf '-A idbl4'
-!    -L/pool/SX-6/netcdf/netcdf-3.6.0-p1/lib -lnetcdf
-!------------------------------------------------------------------------------!
-
-    USE netcdf
-
-    IMPLICIT NONE
-
-!
-!-- Local variables
-    CHARACTER (LEN=10)   ::  dimname(4), var_name
-    CHARACTER (LEN=40)   ::  filename
-
-    CHARACTER (LEN=2000) ::  title, var_list
-
-    INTEGER ::  i, j, k, nc_stat, pos, time_step
-
-    INTEGER ::  current_level, current_var, id_set, id_var_time, num_var
-
-    INTEGER, DIMENSION(4) ::  id_dims, id_dims_loc, levels
-
-    INTEGER, DIMENSION(1000) ::  id_var
-
-    REAL ::  time(1)
-
-    REAL, DIMENSION(:,:,:), ALLOCATABLE ::  data_array
-
-
-    PRINT*, '*** Please type NetCDF filename to be read:'
-    READ*, filename
-
-    nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set )
-    IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 1 )
-
-!
-!-- Get the run description header and output
-    title = ' '
-    nc_stat = NF90_GET_ATT( id_set, NF90_GLOBAL, 'title', title )
-    IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 2 )
-    WRITE (*,'(/A/A)')  '*** file created by:', TRIM( title )
-
-!
-!-- Get the list of variables (order of variables corresponds with the
-!-- order of data on the binary file)
-    var_list = ' '    ! GET_ATT does not assign trailing blanks
-    nc_stat = NF90_GET_ATT( id_set, NF90_GLOBAL, 'VAR_LIST', var_list )
-    IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 3 )
-
-!
-!-- Inquire id of the time coordinate variable
-    nc_stat = NF90_INQ_VARID( id_set, 'time', id_var_time )
-    IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 4 )
-
-!
-!-- Count number of variables; there is one more semicolon in the
-!-- string than variable names
-    num_var = -1
-    DO  i = 1, LEN( var_list )
-       IF ( var_list(i:i) == ';' )  num_var = num_var + 1
-    ENDDO
-    WRITE (*,'(/A,I3,A/)')  '*** file contains ', num_var, ' variable(s)'
-
-
-    pos = INDEX( var_list, ';' )
-!
-!-- Loop over all variables
-    DO  i = 1, num_var
-
-!
-!--    Extract variable name from list
-       var_list = var_list(pos+1:)
-       pos = INDEX( var_list, ';' )
-       var_name = var_list(1:pos-1)
-
-!
-!--    Get variable ID from name
-       nc_stat = NF90_INQ_VARID( id_set, TRIM( var_name ), id_var(i) )
-       IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 5 )
-
-!
-!--    Inquire the dimension IDs
-       nc_stat = NF90_INQUIRE_VARIABLE( id_set, id_var(i), &
-                                        dimids = id_dims_loc )
-       IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 6 )
-       id_dims = id_dims_loc
-
-!
-!--    Get number of x/y/z/time levels(gridpoints) for that variable
-       DO  j = 1, 4
-          nc_stat = NF90_INQUIRE_DIMENSION( id_set, id_dims(j),&
-                                            dimname(j), levels(j) )
-          IF ( nc_stat /= NF90_NOERR ) CALL handle_netcdf_error( 7 )
-       ENDDO
-
-       WRITE (*,100)  '*** reading variable "', TRIM(var_name),         &
-                      '", dimensioned as', TRIM(var_name), levels(1)-1, &
-                      levels(2)-1, levels(3)-1
-100    FORMAT (A,A,A/4X,A,'(0:',I4,',0:',I4,',0:',I4,')   (x/y/z)'/)
-
-!
-!--    Allocate the data array to be read
-       ALLOCATE( data_array(0:levels(1)-1,0:levels(2)-1,0:levels(3)-1) )
-
-!
-!--    Read the data from file for each timestep
-       DO  j = 1, levels(4)
-
-!
-!--        Get the time of the current timelevel and output
-           nc_stat = NF90_GET_VAR( id_set, id_var_time, time, start = (/ j /), &
-                                   count = (/ 1 /) )
-
-           IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 7+i )
-
-           WRITE (*,'(A,I3,A,F8.1,A)')  '    reading timelevel ', i, &
-                                        '    time = ', time(1), ' s'     
-
-           nc_stat = NF90_GET_VAR( id_set, id_var(i),                    &
-                                   data_array, start = (/ 1, 1, 1, j /), &
-                             count = (/ levels(1), levels(2), levels(3), 1 /) )
-
-           IF ( nc_stat /= NF90_NOERR )  &
-                                       CALL handle_netcdf_error( 7+levels(4)+i )
-!
-!--        ADD YOUR OWN CODE FOR FURTHER STORING OF THESE DATA HERE
-!--        --------------------------------------------------------
-
-
-       ENDDO
-
-       WRITE (*,'(/)')
-
-       DEALLOCATE( data_array )
-
-    ENDDO
-
-
-
- CONTAINS
-
-
-    SUBROUTINE handle_netcdf_error( errno )
-!
-!--    Prints out a text message corresponding to the current NetCDF status
-
-       IMPLICIT NONE
-
-       INTEGER, INTENT(IN) ::  errno
-
-       IF ( nc_stat /= NF90_NOERR )  THEN
-          WRITE (*,'(A,1X,I3/4X,A)')                                           &
-                                   '+++ read_palm_netcdf_data  error handle:', &
-                                   errno, TRIM( nf90_strerror( nc_stat ) )
-          STOP
-       ENDIF
-
-    END SUBROUTINE handle_netcdf_error
-
-
- END PROGRAM read_palm_netcdf_data
-
-
-
Index: palm/trunk/UTIL/read_prt_data.f90
===================================================================
--- palm/trunk/UTIL/read_prt_data.f90	(revision 4901)
+++ 	(revision )
@@ -1,244 +1,0 @@
- PROGRAM read_prt_data
-!------------------------------------------------------------------------------!
-! This file is part of the PALM model system.
-!
-! PALM is free software: you can redistribute it and/or modify it under the
-! terms of the GNU General Public License as published by the Free Software
-! Foundation, either version 3 of the License, or (at your option) any later
-! version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with
-! PALM. If not, see <http://www.gnu.org/licenses/>.
-!
-! Copyright 1997-2021  Leibniz Universitaet Hannover
-!------------------------------------------------------------------------------!
-!
-! Current revisions:
-! -----------------
-! 
-! 
-! Former revisions:
-! -----------------
-! $Id: read_prt_data.f90 2696 2017-12-14 17:12:51Z kanani $
-! Added BIND attribute and C datatypes
-! 
-! 2696 2017-12-14 17:12:51Z kanani
-! Adapted for changed particle attributes
-! 
-! 2696 2017-12-14 17:12:51Z kanani
-! Corrected "Former revisions" section
-!
-! 2696 2017-12-14 17:12:51Z kanani
-! Change in file header (GPL part)
-!
-! 2123 2017-01-18 12:49:59Z hoffmann
-! Particle variables renamed: tailpoints, tail_id, and dvrp_psize to id1, id2, 
-! and user
-!
-! 1771 2016-02-29 10:57:56Z hoffmann
-! Initial revision.
-!
-! Description:
-! ------------
-! This routine reads the particle data generated by PALM, and enables user
-! analysis. Compile and execute this program in the folder where your particle 
-! data (_000000, _000001, ...) is stored.
-!------------------------------------------------------------------------------!
-
-    USE, INTRINSIC ::  ISO_C_BINDING
-
-    IMPLICIT NONE
-
-    CHARACTER(LEN=7)    ::  i_proc_char
-    CHARACTER (LEN=80)  ::  rtext
-    CHARACTER (LEN=110) ::  run_description_header
-
-    REAL(KIND=8) ::  simulated_time
-    INTEGER      ::  ip, i_proc=0, i_proc_end, jp, kp,                         &
-                     max_number_of_particle_groups, number_of_particles,       &
-                     number_of_particle_groups, n, nxl,                        &
-                     nxr, nys, nyn, nzb, nzt, nbgp, status
-
-    INTEGER, DIMENSION(:,:,:), ALLOCATABLE ::  prt_count
-
-!
-!-- WARNING: For compatibility of derived types, the BIND attribute is required, and interoperable C
-!-- datatypes must be used. These type are hard wired here! So changes in working precision (wp, iwp)
-!-- will not affect the particle_type!
-!-- The main reason for introducing the interoperable datatypes was to avoid compiler warnings of
-!-- the gfortran compiler.
-!-- The BIND attribite is required because of C_F_POINTER usage in the pmc particle interface.
-    TYPE, BIND(C) ::  particle_type
-        REAL(C_DOUBLE) ::  aux1          !< auxiliary multi-purpose feature
-        REAL(C_DOUBLE) ::  aux2          !< auxiliary multi-purpose feature
-        REAL(C_DOUBLE) ::  radius        !< radius of particle
-        REAL(C_DOUBLE) ::  age           !< age of particle
-        REAL(C_DOUBLE) ::  age_m         !<
-        REAL(C_DOUBLE) ::  dt_sum        !<
-        REAL(C_DOUBLE) ::  e_m           !< interpolated sgs tke
-        REAL(C_DOUBLE) ::  origin_x      !< origin x-position of particle (changed cyclic bc)
-        REAL(C_DOUBLE) ::  origin_y      !< origin y-position of particle (changed cyclic bc)
-        REAL(C_DOUBLE) ::  origin_z      !< origin z-position of particle (changed cyclic bc)
-        REAL(C_DOUBLE) ::  rvar1         !<
-        REAL(C_DOUBLE) ::  rvar2         !<
-        REAL(C_DOUBLE) ::  rvar3         !<
-        REAL(C_DOUBLE) ::  speed_x       !< speed of particle in x
-        REAL(C_DOUBLE) ::  speed_y       !< speed of particle in y
-        REAL(C_DOUBLE) ::  speed_z       !< speed of particle in z
-        REAL(C_DOUBLE) ::  weight_factor !< weighting factor
-        REAL(C_DOUBLE) ::  x             !< x-position
-        REAL(C_DOUBLE) ::  y             !< y-position
-        REAL(C_DOUBLE) ::  z             !< z-position
-        INTEGER(C_INT) ::  class         !< radius class needed for collision
-        INTEGER(C_INT) ::  group         !< number of particle group
-        INTEGER(C_LONG_LONG) ::  id            !< particle ID (64 bit integer)
-        LOGICAL(C_BOOL) ::  particle_mask !< if this parameter is set to false the particle will be deleted
-        INTEGER(C_INT) ::  block_nr      !< number for sorting (removable?)
-    END TYPE particle_type
-
-
-
-    TYPE(particle_type), DIMENSION(:), ALLOCATABLE ::  particles_temp
-    TYPE(particle_type), DIMENSION(:), POINTER     ::  particles
-
-    TYPE  grid_particle_def
-       TYPE(particle_type), DIMENSION(:), ALLOCATABLE ::  particles
-    END TYPE grid_particle_def
-
-    TYPE(grid_particle_def), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  grid_particles
-
-    TYPE particle_groups_type
-        SEQUENCE
-        REAL(KIND=8) ::  density_ratio, radius, exp_arg, exp_term
-    END TYPE particle_groups_type
-
-    TYPE(particle_groups_type), DIMENSION(:), ALLOCATABLE ::  particle_groups
-
-    LOGICAL ::  found
-!
-!-- Check if file from PE0 exists and terminate program if it doesn't.
-    WRITE (i_proc_char,'(''_'',I6.6)')  i_proc
-    INQUIRE ( FILE=i_proc_char, EXIST=found )
-!
-!-- Estimate the number of files (equal to the number of PEs which
-!-- have been used in PALM)
-    DO  WHILE ( found )
-       OPEN ( 85, FILE=i_proc_char, FORM='UNFORMATTED' )
-       i_proc = i_proc + 1
-       WRITE (i_proc_char,'(''_'',I6.6)')  i_proc
-       INQUIRE ( FILE=i_proc_char, EXIST=found )
-       CLOSE( 85 )
-    ENDDO
-!
-!-- Info-output
-    PRINT*, ''
-    PRINT*, '*** read_prt ***'
-    IF ( i_proc /= 0 )  THEN
-       PRINT*, '***', i_proc, ' file(s) found'
-    ELSE
-       PRINT*, '+++ file _000000 not found'
-       PRINT*, '    program terminated'
-       STOP
-    ENDIF
-!
-!-- Set number of files and opens them sequentially
-    i_proc_end = i_proc-1
-
-    DO  i_proc = 0, i_proc_end
-!
-!--    Open particle data file for each process
-       WRITE (i_proc_char,'(''_'',I6.6)')  i_proc
-       OPEN ( 85, FILE=i_proc_char, FORM='UNFORMATTED' ) 
-!
-!--    Read general description of file and inform user
-       READ ( 85 )  run_description_header
-       READ ( 85 )  rtext
-       IF ( i_proc == 0 )  THEN
-          PRINT*, ' '
-          PRINT*, '*** data description header:'
-          PRINT*, '*** ', run_description_header
-          PRINT*, '*** ', rtext
-          PRINT*, ' '
-       ENDIF
-       PRINT*, '*** data of file', i_proc, 'is analysed'
-       READ ( 85 )  number_of_particle_groups, max_number_of_particle_groups
-
-       IF ( .NOT. ALLOCATED(particle_groups) )  THEN
-          ALLOCATE( particle_groups(max_number_of_particle_groups) )
-       ENDIF
-    
-       READ ( 85 )  particle_groups
-       READ ( 85 )  nxl, nxr, nys, nyn, nzb, nzt, nbgp
-
-       IF ( ALLOCATED(prt_count)  .OR.  ALLOCATED(grid_particles) )  THEN
-          DEALLOCATE( prt_count, grid_particles )
-       ENDIF
-
-       ALLOCATE( prt_count(nzb:nzt+1,nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp),     &
-                 grid_particles(nzb+1:nzt,nys:nyn,nxl:nxr) )
-
-!
-!--    Start individual time loop
-       DO
-          READ( 85, IOSTAT=status)  simulated_time
-          IF ( status < 0 )  THEN
-             PRINT*, '*** end of file reached'
-             EXIT
-          ENDIF
-          PRINT*, '*** time of analyzed data set:', simulated_time
-
-          READ ( 85 )  prt_count
-
-          DO  ip = nxl, nxr
-             DO  jp = nys, nyn
-                DO  kp = nzb+1, nzt
-                   number_of_particles = prt_count(kp,jp,ip)
-                   IF ( number_of_particles <= 0 )  CYCLE
-                   ALLOCATE( grid_particles(kp,jp,ip)%particles(1:number_of_particles) )
-                   ALLOCATE( particles_temp(1:number_of_particles) )
-                   READ ( 85 )  particles_temp
-                   grid_particles(kp,jp,ip)%particles = particles_temp
-                   DEALLOCATE( particles_temp )
-                ENDDO
-             ENDDO
-          ENDDO
-!
-!--       This part can be used for user analysis
-          DO  ip = nxl, nxr
-             DO  jp = nys, nyn
-                DO  kp = nzb+1, nzt
-                   number_of_particles = prt_count(kp,jp,ip)
-                   IF ( number_of_particles <= 0 )  CYCLE
-                   particles => grid_particles(kp,jp,ip)%particles
-!
-!--                Add your analysis here
-!                   DO  n = 1, number_of_particles
-!
-!                   ENDDO
-
-                ENDDO
-             ENDDO
-          ENDDO
-!
-!--       Deallocate grid_particles%particles in case of more than one timestep
-          DO  ip = nxl, nxr
-             DO  jp = nys, nyn
-                DO  kp = nzb+1, nzt
-                   number_of_particles = prt_count(kp,jp,ip)
-                   IF ( number_of_particles <= 0 )  CYCLE
-                   DEALLOCATE( grid_particles(kp,jp,ip)%particles )
-                ENDDO
-             ENDDO
-          ENDDO     
-
-       ENDDO ! end of time loop
-
-       CLOSE( 85 )
-
-    ENDDO ! end of file loop
-
- END PROGRAM read_prt_data
