Index: palm/trunk/SOURCE/check_open.f90
===================================================================
--- palm/trunk/SOURCE/check_open.f90	(revision 1030)
+++ palm/trunk/SOURCE/check_open.f90	(revision 1031)
@@ -4,5 +4,7 @@
 ! Current revisions:
 ! -----------------
-!
+! netCDF4 without parallel file support implemented,
+! opening of netCDF files are done by new routines create_netcdf_file and
+! open_write_netcdf_file
 !
 ! Former revisions:
@@ -37,8 +39,8 @@
 !
 ! 519 2010-03-19 05:30:02Z raasch
-! NetCDF4 support for particle data
+! netCDF4 support for particle data
 !
 ! 493 2010-03-01 08:30:24Z raasch
-! NetCDF4 support (parallel output)
+! netCDF4 support (parallel output)
 !
 ! 410 2009-12-04 17:05:40Z letzel
@@ -46,5 +48,5 @@
 !
 ! 277 2009-03-31 09:13:47Z heinze
-! Output of NetCDF messages with aid of message handling routine.
+! Output of netCDF messages with aid of message handling routine.
 ! Output of messages replaced by message handling routine
 !
@@ -55,5 +57,5 @@
 !
 ! 120 2007-10-17 11:54:43Z raasch
-! Status of 3D-volume NetCDF data file only depends on switch netcdf_64bit_3d
+! Status of 3D-volume netCDF data file only depends on switch netcdf_64bit_3d
 !
 ! 105 2007-08-08 07:12:55Z raasch
@@ -169,5 +171,5 @@
        CASE ( 101:103, 106, 111:113, 116, 201:200+2*max_masks )
 
-          IF ( netcdf_data_format < 3 )  THEN
+          IF ( netcdf_data_format < 5 )  THEN
           
              IF ( myid /= 0 )  THEN
@@ -738,5 +740,5 @@
           ENDIF
 !
-!--       Inquire, if there is a NetCDF file from a previuos run. This should
+!--       Inquire, if there is a netCDF file from a previuos run. This should
 !--       be opened for extension, if its dimensions and variables match the
 !--       actual run.
@@ -745,15 +747,6 @@
           IF ( netcdf_extend )  THEN
 !
-!--          Open an existing NetCDF file for output
-             IF ( netcdf_data_format < 3 )  THEN
-                nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_xy(av) )
-             ELSE
-#if defined( __netcdf4 )
-                nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_xy(av), &
-                                     COMM = comm2d, INFO = MPI_INFO_NULL )
-#endif
-             ENDIF
-
-             CALL handle_netcdf_error( 'check_open', 20 )
+!--          Open an existing netCDF file for output
+             CALL open_write_netcdf_file( filename, id_set_xy(av), .TRUE., 20 )
 !
 !--          Read header information and set all ids. If there is a mismatch
@@ -774,38 +767,6 @@
           IF ( .NOT. netcdf_extend )  THEN
 !
-!--          Create a new NetCDF output file with requested NetCDF format
-             IF ( netcdf_data_format == 1 )  THEN
-!
-!--             Classic NetCDF format
-                nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_xy(av) )
-
-             ELSEIF ( netcdf_data_format == 2 )  THEN
-!
-!--             64bit-offset format
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
-                                       id_set_xy(av) )
-
-#if defined( __netcdf4 )
-             ELSEIF ( netcdf_data_format == 3 )  THEN
-!
-!--             NetCDF4/HDF5 format
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER, NF90_NETCDF4 ),     &
-                                       id_set_xy(av), COMM = comm2d,           &
-                                       INFO = MPI_INFO_NULL )
-
-             ELSEIF ( netcdf_data_format == 4 )  THEN
-!
-!--             NetCDF4/HDF5 format with classic model flag
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER,                     &
-                                        OR( NF90_CLASSIC_MODEL, NF90_HDF5 ) ), &
-                                       id_set_xy(av), COMM = comm2d,           &
-                                       INFO = MPI_INFO_NULL )
-#endif
-             ENDIF
-
-             CALL handle_netcdf_error( 'check_open', 22 )
+!--          Create a new netCDF output file with requested netCDF format
+             CALL create_netcdf_file( filename, id_set_xy(av), .TRUE., 22 )
 
 !
@@ -814,7 +775,7 @@
 
 !
-!--          In case of parallel NetCDF output, create flag file which tells
+!--          In case of parallel netCDF output, create flag file which tells
 !--          combine_plot_fields that nothing is to do.
-             IF ( myid == 0  .AND.  netcdf_data_format > 2 )  THEN
+             IF ( myid == 0  .AND.  netcdf_data_format > 4 )  THEN
                 OPEN( 99, FILE='NO_COMBINE_PLOT_FIELDS_XY' )
                 WRITE ( 99, '(A)' )  'no combine_plot_fields.x neccessary'
@@ -835,5 +796,5 @@
           ENDIF
 !
-!--       Inquire, if there is a NetCDF file from a previuos run. This should
+!--       Inquire, if there is a netCDF file from a previuos run. This should
 !--       be opened for extension, if its dimensions and variables match the
 !--       actual run.
@@ -842,15 +803,6 @@
           IF ( netcdf_extend )  THEN
 !
-!--          Open an existing NetCDF file for output
-             IF ( netcdf_data_format < 3 )  THEN
-                nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_xz(av) )
-             ELSE
-#if defined( __netcdf4 )
-                nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_xz(av), &
-                                     COMM = comm2d, INFO = MPI_INFO_NULL )
-#endif
-             ENDIF
-
-             CALL handle_netcdf_error( 'check_open', 23 )
+!--          Open an existing netCDF file for output
+             CALL open_write_netcdf_file( filename, id_set_xz(av), .TRUE., 23 )
 !
 !--          Read header information and set all ids. If there is a mismatch
@@ -871,38 +823,6 @@
           IF ( .NOT. netcdf_extend )  THEN
 !
-!--          Create a new NetCDF output file with requested NetCDF format
-             IF ( netcdf_data_format == 1 )  THEN
-!
-!--             Classic NetCDF format
-                nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_xz(av) )
-
-             ELSEIF ( netcdf_data_format == 2 )  THEN
-!
-!--             64bit-offset format
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
-                                       id_set_xz(av) )
-
-#if defined( __netcdf4 )
-             ELSEIF ( netcdf_data_format == 3 )  THEN
-!
-!--             NetCDF4/HDF5 format
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER, NF90_NETCDF4 ),     &
-                                       id_set_xz(av), COMM = comm2d,           &
-                                       INFO = MPI_INFO_NULL )
-
-             ELSEIF ( netcdf_data_format == 4 )  THEN
-!
-!--             NetCDF4/HDF5 format with classic model flag
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER,                     &
-                                        OR( NF90_CLASSIC_MODEL, NF90_HDF5 ) ), &
-                                       id_set_xz(av), COMM = comm2d,           &
-                                       INFO = MPI_INFO_NULL )
-#endif
-             ENDIF
-
-             CALL handle_netcdf_error( 'check_open', 25 )
+!--          Create a new netCDF output file with requested netCDF format
+             CALL create_netcdf_file( filename, id_set_xz(av), .TRUE., 25 )
 
 !
@@ -911,7 +831,7 @@
 
 !
-!--          In case of parallel NetCDF output, create flag file which tells
+!--          In case of parallel netCDF output, create flag file which tells
 !--          combine_plot_fields that nothing is to do.
-             IF ( myid == 0  .AND.  netcdf_data_format > 2 )  THEN
+             IF ( myid == 0  .AND.  netcdf_data_format > 4 )  THEN
                 OPEN( 99, FILE='NO_COMBINE_PLOT_FIELDS_XZ' )
                 WRITE ( 99, '(A)' )  'no combine_plot_fields.x neccessary'
@@ -932,5 +852,5 @@
           ENDIF
 !
-!--       Inquire, if there is a NetCDF file from a previuos run. This should
+!--       Inquire, if there is a netCDF file from a previuos run. This should
 !--       be opened for extension, if its dimensions and variables match the
 !--       actual run.
@@ -939,15 +859,6 @@
           IF ( netcdf_extend )  THEN
 !
-!--          Open an existing NetCDF file for output
-             IF ( netcdf_data_format < 3 )  THEN 
-                nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_yz(av) )
-             ELSE
-#if defined( __netcdf4 )
-                nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_yz(av), &
-                                     COMM = comm2d, INFO = MPI_INFO_NULL )
-#endif
-             ENDIF
-             
-             CALL handle_netcdf_error( 'check_open', 26 )
+!--          Open an existing netCDF file for output
+             CALL open_write_netcdf_file( filename, id_set_yz(av), .TRUE., 26 )
 !
 !--          Read header information and set all ids. If there is a mismatch
@@ -968,38 +879,6 @@
           IF ( .NOT. netcdf_extend )  THEN
 !
-!--          Create a new NetCDF output file with requested NetCDF format
-             IF ( netcdf_data_format == 1 )  THEN
-!
-!--             Classic NetCDF format
-                nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_yz(av) )
-
-             ELSEIF ( netcdf_data_format == 2 )  THEN
-!
-!--             64bit-offset format
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
-                                       id_set_yz(av) )
-
-#if defined( __netcdf4 )
-             ELSEIF ( netcdf_data_format == 3 )  THEN
-!
-!--             NetCDF4/HDF5 format
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER, NF90_NETCDF4 ),     &
-                                       id_set_yz(av), COMM = comm2d,           &
-                                       INFO = MPI_INFO_NULL )
-
-             ELSEIF ( netcdf_data_format == 4 )  THEN
-!
-!--             NetCDF4/HDF5 format with classic model flag
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER,                     &
-                                        OR( NF90_CLASSIC_MODEL, NF90_HDF5 ) ), &
-                                       id_set_yz(av), COMM = comm2d,           &
-                                       INFO = MPI_INFO_NULL )
-#endif
-             ENDIF
-
-             CALL handle_netcdf_error( 'check_open', 28 )
+!--          Create a new netCDF output file with requested netCDF format
+             CALL create_netcdf_file( filename, id_set_yz(av), .TRUE., 28 )
 
 !
@@ -1008,7 +887,7 @@
 
 !
-!--          In case of parallel NetCDF output, create flag file which tells
+!--          In case of parallel netCDF output, create flag file which tells
 !--          combine_plot_fields that nothing is to do.
-             IF ( myid == 0  .AND.  netcdf_data_format > 2 )  THEN
+             IF ( myid == 0  .AND.  netcdf_data_format > 4 )  THEN
                 OPEN( 99, FILE='NO_COMBINE_PLOT_FIELDS_YZ' )
                 WRITE ( 99, '(A)' )  'no combine_plot_fields.x neccessary'
@@ -1024,5 +903,5 @@
 
 !
-!--       Inquire, if there is a NetCDF file from a previuos run. This should
+!--       Inquire, if there is a netCDF file from a previuos run. This should
 !--       be opened for extension, if its variables match the actual run.
           INQUIRE( FILE=filename, EXIST=netcdf_extend )
@@ -1030,7 +909,6 @@
           IF ( netcdf_extend )  THEN
 !
-!--          Open an existing NetCDF file for output 
-             nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_pr )
-             CALL handle_netcdf_error( 'check_open', 29 )
+!--          Open an existing netCDF file for output
+             CALL open_write_netcdf_file( filename, id_set_pr, .FALSE., 29 )
 !
 !--          Read header information and set all ids. If there is a mismatch
@@ -1051,13 +929,6 @@
           IF ( .NOT. netcdf_extend )  THEN
 !
-!--          Create a new NetCDF output file
-             IF ( netcdf_data_format > 1 )  THEN
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
-                                       id_set_pr )
-             ELSE
-                nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_pr )
-             ENDIF
-             CALL handle_netcdf_error( 'check_open', 31 )
+!--          Create a new netCDF output file with requested netCDF format
+             CALL create_netcdf_file( filename, id_set_pr, .FALSE., 31 )
 !
 !--          Define the header
@@ -1072,5 +943,5 @@
 
 !
-!--       Inquire, if there is a NetCDF file from a previuos run. This should
+!--       Inquire, if there is a netCDF file from a previuos run. This should
 !--       be opened for extension, if its variables match the actual run.
           INQUIRE( FILE=filename, EXIST=netcdf_extend )
@@ -1078,7 +949,6 @@
           IF ( netcdf_extend )  THEN
 !
-!--          Open an existing NetCDF file for output 
-             nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_ts )
-             CALL handle_netcdf_error( 'check_open', 32 )
+!--          Open an existing netCDF file for output
+             CALL open_write_netcdf_file( filename, id_set_ts, .FALSE., 32 )
 !
 !--          Read header information and set all ids. If there is a mismatch
@@ -1099,13 +969,6 @@
           IF ( .NOT. netcdf_extend )  THEN
 !
-!--          Create a new NetCDF output file
-             IF ( netcdf_data_format > 1 )  THEN
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
-                                       id_set_ts )
-             ELSE
-                nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_ts )
-             ENDIF
-             CALL handle_netcdf_error( 'check_open', 34 )
+!--          Create a new netCDF output file with requested netCDF format
+             CALL create_netcdf_file( filename, id_set_ts, .FALSE., 34 )
 !
 !--          Define the header
@@ -1126,5 +989,5 @@
           ENDIF
 !
-!--       Inquire, if there is a NetCDF file from a previous run. This should
+!--       Inquire, if there is a netCDF file from a previous run. This should
 !--       be opened for extension, if its dimensions and variables match the
 !--       actual run.
@@ -1133,14 +996,6 @@
           IF ( netcdf_extend )  THEN
 !
-!--          Open an existing NetCDF file for output
-             IF ( netcdf_data_format < 3 )  THEN 
-                nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_3d(av) )
-             ELSE
-#if defined( __netcdf4 )
-                nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_3d(av), &
-                                     COMM = comm2d, INFO = MPI_INFO_NULL )
-#endif
-             ENDIF
-             CALL handle_netcdf_error( 'check_open', 35 )
+!--          Open an existing netCDF file for output
+             CALL open_write_netcdf_file( filename, id_set_3d(av), .TRUE., 35 )
 !
 !--          Read header information and set all ids. If there is a mismatch
@@ -1161,38 +1016,6 @@
           IF ( .NOT. netcdf_extend )  THEN
 !
-!--          Create a new NetCDF output file with requested NetCDF format
-             IF ( netcdf_data_format == 1 )  THEN
-!
-!--             Classic NetCDF format
-                nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_3d(av) )
-
-             ELSEIF ( netcdf_data_format == 2 )  THEN
-!
-!--             64bit-offset format
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
-                                       id_set_3d(av) )
-
-#if defined( __netcdf4 )
-             ELSEIF ( netcdf_data_format == 3 )  THEN
-!
-!--             NetCDF4/HDF5 format
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER, NF90_NETCDF4 ),     &
-                                       id_set_3d(av), COMM = comm2d,           &
-                                       INFO = MPI_INFO_NULL )
-
-             ELSEIF ( netcdf_data_format == 4 )  THEN
-!
-!--             NetCDF4/HDF5 format with classic model flag
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER,                     &
-                                        OR( NF90_CLASSIC_MODEL, NF90_HDF5 ) ), &
-                                       id_set_3d(av), COMM = comm2d,           &
-                                       INFO = MPI_INFO_NULL )
-#endif
-             ENDIF
-
-             CALL handle_netcdf_error( 'check_open', 37 )
+!--          Create a new netCDF output file with requested netCDF format
+             CALL create_netcdf_file( filename, id_set_3d(av), .TRUE., 37 )
 
 !
@@ -1201,7 +1024,7 @@
 
 !
-!--          In case of parallel NetCDF output, create flag file which tells
+!--          In case of parallel netCDF output, create flag file which tells
 !--          combine_plot_fields that nothing is to do.
-             IF ( myid == 0  .AND.  netcdf_data_format > 2 )  THEN
+             IF ( myid == 0  .AND.  netcdf_data_format > 4 )  THEN
                 OPEN( 99, FILE='NO_COMBINE_PLOT_FIELDS_3D' )
                 WRITE ( 99, '(A)' )  'no combine_plot_fields.x neccessary'
@@ -1218,5 +1041,5 @@
 
 !
-!--       Inquire, if there is a NetCDF file from a previuos run. This should
+!--       Inquire, if there is a netCDF file from a previuos run. This should
 !--       be opened for extension, if its variables match the actual run.
           INQUIRE( FILE=filename, EXIST=netcdf_extend )
@@ -1224,7 +1047,6 @@
           IF ( netcdf_extend )  THEN
 !
-!--          Open an existing NetCDF file for output 
-             nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_sp )
-             CALL handle_netcdf_error( 'check_open', 38 )
+!--          Open an existing netCDF file for output
+             CALL open_write_netcdf_file( filename, id_set_sp, .FALSE., 38 )
 
 !
@@ -1246,13 +1068,6 @@
           IF ( .NOT. netcdf_extend )  THEN
 !
-!--          Create a new NetCDF output file
-             IF ( netcdf_data_format > 1 )  THEN
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
-                                       id_set_sp )
-             ELSE
-                nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_sp )
-             ENDIF
-             CALL handle_netcdf_error( 'check_open', 40 )
+!--          Create a new netCDF output file with requested netCDF format
+             CALL create_netcdf_file( filename, id_set_sp, .FALSE., 40 )
 !
 !--          Define the header
@@ -1271,5 +1086,5 @@
           ENDIF
 !
-!--       Inquire, if there is a NetCDF file from a previuos run. This should
+!--       Inquire, if there is a netCDF file from a previuos run. This should
 !--       be opened for extension, if its variables match the actual run.
           INQUIRE( FILE=filename, EXIST=netcdf_extend )
@@ -1277,7 +1092,6 @@
           IF ( netcdf_extend )  THEN
 !
-!--          Open an existing NetCDF file for output 
-             nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_prt )
-             CALL handle_netcdf_error( 'check_open', 41 )
+!--          Open an existing netCDF file for output
+             CALL open_write_netcdf_file( filename, id_set_prt, .FALSE., 41 )
 !
 !--          Read header information and set all ids. If there is a mismatch
@@ -1315,37 +1129,6 @@
 
 !
-!--          Create a new NetCDF output file with requested NetCDF format
-             IF ( netcdf_data_format == 1 )  THEN
-!
-!--             Classic NetCDF format
-                nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_prt )
-
-             ELSEIF ( netcdf_data_format == 2 )  THEN
-!
-!--             64bit-offset format
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
-                                       id_set_prt )
-
-#if defined( __netcdf4 )
-             ELSEIF ( netcdf_data_format == 3 )  THEN
-!
-!--             NetCDF4/HDF5 format, but no parallel output into a single file!
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER, NF90_NETCDF4 ),     &
-                                       id_set_prt )
-
-             ELSEIF ( netcdf_data_format == 4 )  THEN
-!
-!--             NetCDF4/HDF5 format with classic model flag, but no parallel
-!--             output into a single file!
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER,                     &
-                                        OR( NF90_CLASSIC_MODEL, NF90_HDF5 ) ), &
-                                       id_set_prt )
-#endif
-             ENDIF
-             
-             CALL handle_netcdf_error( 'check_open', 43 )  
+!--          Create a new netCDF output file with requested netCDF format
+             CALL create_netcdf_file( filename, id_set_prt, .FALSE., 43 )
 
 !
@@ -1361,5 +1144,5 @@
 
 !
-!--       Inquire, if there is a NetCDF file from a previuos run. This should
+!--       Inquire, if there is a netCDF file from a previuos run. This should
 !--       be opened for extension, if its variables match the actual run.
           INQUIRE( FILE=filename, EXIST=netcdf_extend )
@@ -1367,7 +1150,6 @@
           IF ( netcdf_extend )  THEN
 !
-!--          Open an existing NetCDF file for output 
-             nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_pts )
-             CALL handle_netcdf_error( 'check_open', 393 )
+!--          Open an existing netCDF file for output
+             CALL open_write_netcdf_file( filename, id_set_pts, .FALSE., 393 )
 !
 !--          Read header information and set all ids. If there is a mismatch
@@ -1388,13 +1170,6 @@
           IF ( .NOT. netcdf_extend )  THEN
 !
-!--          Create a new NetCDF output file
-             IF ( netcdf_data_format > 1 )  THEN
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
-                                       id_set_pts )
-             ELSE
-                nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_pts )
-             ENDIF
-             CALL handle_netcdf_error( 'check_open', 395 )
+!--          Create a new netCDF output file with requested netCDF format
+             CALL create_netcdf_file( filename, id_set_pts, .FALSE., 395 )
 !
 !--          Define the header
@@ -1419,5 +1194,5 @@
           ENDIF
 !
-!--       Inquire, if there is a NetCDF file from a previuos run. This should
+!--       Inquire, if there is a netCDF file from a previuos run. This should
 !--       be opened for extension, if its dimensions and variables match the
 !--       actual run.
@@ -1426,12 +1201,7 @@
           IF ( netcdf_extend )  THEN
 !
-!--          Open an existing NetCDF file for output 
-#if defined( __netcdf4 )
-             nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_mask(mid,av), &
-                                  COMM = comm2d, INFO = MPI_INFO_NULL )
-#else
-             nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_mask(mid,av) )
-#endif
-             CALL handle_netcdf_error( 'check_open', 456 )
+!--          Open an existing netCDF file for output
+             CALL open_write_netcdf_file( filename, id_set_mask(mid,av), &
+                                          .TRUE., 456 )
 !
 !--          Read header information and set all ids. If there is a mismatch
@@ -1452,40 +1222,6 @@
           IF ( .NOT. netcdf_extend )  THEN
 !
-!--          Create a new NetCDF output file with requested NetCDF format
-             IF ( netcdf_data_format == 1 )  THEN
-!
-!--             Classic NetCDF format
-                nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, &
-                                       id_set_mask(mid,av) )
-
-             ELSEIF ( netcdf_data_format == 2 )  THEN
-!
-!--             64bit-offset format
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
-                                       id_set_mask(mid,av) )
-
-
-#if defined( __netcdf4 )
-             ELSEIF ( netcdf_data_format == 3 )  THEN
-!
-!--             NetCDF4/HDF5 format
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER, NF90_NETCDF4 ),     &
-                                       id_set_mask(mid,av), COMM = comm2d,     &
-                                       INFO = MPI_INFO_NULL )
-
-             ELSEIF ( netcdf_data_format == 4 )  THEN
-!
-!--             NetCDF4/HDF5 format with classic model flag
-                nc_stat = NF90_CREATE( filename,                               &
-                                       OR( NF90_NOCLOBBER,                     &
-                                        OR( NF90_CLASSIC_MODEL, NF90_HDF5 ) ), &
-                                       id_set_mask(mid,av), COMM = comm2d,     &
-                                       INFO = MPI_INFO_NULL )
-#endif
-             ENDIF
-
-             CALL handle_netcdf_error( 'check_open', 458 )
+!--          Create a new netCDF output file with requested netCDF format
+             CALL create_netcdf_file( filename, id_set_mask(mid,av), .TRUE., 458 )
 !
 !--          Define the header
Index: palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- palm/trunk/SOURCE/check_parameters.f90	(revision 1030)
+++ palm/trunk/SOURCE/check_parameters.f90	(revision 1031)
@@ -4,5 +4,5 @@
 ! Current revisions:
 ! -----------------
-!
+! check of netcdf4 parallel file support
 !
 ! Former revisions:
@@ -2847,4 +2847,25 @@
 
        ENDDO
+    ENDIF
+
+!
+!-- Set output format string (used in header)
+    IF ( netcdf_output )  THEN
+
+       SELECT CASE ( netcdf_data_format )
+          CASE ( 1 )
+             output_format_netcdf = 'netCDF classic'
+          CASE ( 2 )
+             output_format_netcdf = 'netCDF 64bit offset'
+          CASE ( 3 )
+             output_format_netcdf = 'netCDF4/HDF5'
+          CASE ( 4 )
+             output_format_netcdf = 'netCDF4/HDF5 classic'
+          CASE ( 5 )
+             output_format_netcdf = 'parallel netCDF4/HDF5'
+          CASE ( 6 )
+             output_format_netcdf = 'parallel netCDF4/HDF5 classic'
+
+       END SELECT
 
     ENDIF
@@ -2882,9 +2903,9 @@
 !-- Check the NetCDF data format
 #if ! defined ( __check )
-    IF ( netcdf_data_format > 2 )  THEN
+    IF ( netcdf_data_format > 2  .AND.  netcdf_data_format < 5 )  THEN
 #if defined( __netcdf4 )
        CONTINUE
 #else
-       message_string = 'NetCDF: NetCDF4 format requested but no ' // &
+       message_string = 'netCDF: netCDF4 format requested but no ' // &
                         'cpp-directive __netcdf4 given & switch '  // &
                         'back to 64-bit offset format'
@@ -2893,8 +2914,19 @@
 #endif
     ENDIF
+    IF ( netcdf_data_format > 4 )  THEN
+#if defined( __netcdf4 ) && defined( __netcdf4_parallel )
+       CONTINUE
+#else
+       message_string = 'netCDF: netCDF4 parallel output requested but no ' // &
+                        'cpp-directive __netcdf4_parallel given & switch '  // &
+                        'back to netCDF4 non-parallel output'
+       CALL message( 'check_parameters', 'PA0099', 0, 1, 0, 6, 0 )
+       netcdf_data_format = netcdf_data_format - 2
 #endif
-!
+    ENDIF
+#endif
 
 #if ! defined( __check )
+!
 !-- Check netcdf precison
     ldum = .FALSE.
Index: palm/trunk/SOURCE/close_file.f90
===================================================================
--- palm/trunk/SOURCE/close_file.f90	(revision 1030)
+++ palm/trunk/SOURCE/close_file.f90	(revision 1031)
@@ -4,5 +4,5 @@
 ! Current revisions:
 ! -----------------
-!
+! netCDF4 without parallel file support implemented
 !
 ! Former revisions:
@@ -189,5 +189,5 @@
 
                 IF ( netcdf_output  .AND.  &
-                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
+                     ( myid == 0  .OR.  netcdf_data_format > 4 ) )  THEN
                    nc_stat = NF90_CLOSE( id_set_xy(0) )
                    CALL handle_netcdf_error( 'close_file', 44 )
@@ -197,5 +197,5 @@
 
                 IF ( netcdf_output  .AND.  &
-                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
+                     ( myid == 0  .OR.  netcdf_data_format > 4 ) )  THEN
                    nc_stat = NF90_CLOSE( id_set_xz(0) )
                    CALL handle_netcdf_error( 'close_file', 45 )
@@ -205,5 +205,5 @@
 
                 IF ( netcdf_output  .AND.  &
-                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
+                     ( myid == 0  .OR.  netcdf_data_format > 4 ) )  THEN
                    nc_stat = NF90_CLOSE( id_set_yz(0) )
                    CALL handle_netcdf_error( 'close_file', 46 )
@@ -227,5 +227,5 @@
 
                 IF ( netcdf_output  .AND.  &
-                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
+                     ( myid == 0  .OR.  netcdf_data_format > 4 ) )  THEN
                    nc_stat = NF90_CLOSE( id_set_3d(0) )
                    CALL handle_netcdf_error( 'close_file', 49 )
@@ -256,5 +256,5 @@
 
                 IF ( netcdf_output  .AND.  &
-                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
+                     ( myid == 0  .OR.  netcdf_data_format > 4 ) )  THEN
                    nc_stat = NF90_CLOSE( id_set_xy(1) )
                    CALL handle_netcdf_error( 'close_file', 52 )
@@ -264,5 +264,5 @@
 
                 IF ( netcdf_output  .AND.  &
-                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
+                     ( myid == 0  .OR.  netcdf_data_format > 4 ) )  THEN
                    nc_stat = NF90_CLOSE( id_set_xz(1) )
                    CALL handle_netcdf_error( 'close_file', 352 )
@@ -272,5 +272,5 @@
 
                 IF ( netcdf_output  .AND.  &
-                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
+                     ( myid == 0  .OR.  netcdf_data_format > 4 ) )  THEN
                    nc_stat = NF90_CLOSE( id_set_yz(1) )
                    CALL handle_netcdf_error( 'close_file', 353 )
@@ -280,5 +280,5 @@
 
                 IF ( netcdf_output  .AND.  &
-                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
+                     ( myid == 0  .OR.  netcdf_data_format > 4 ) )  THEN
                    nc_stat = NF90_CLOSE( id_set_3d(1) )
                    CALL handle_netcdf_error( 'close_file', 353 )
@@ -288,5 +288,5 @@
 	     
                 IF ( netcdf_output  .AND.  &
-                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
+                     ( myid == 0  .OR.  netcdf_data_format > 4 ) )  THEN
 !
 !--                decompose fid into mid and av
Index: palm/trunk/SOURCE/data_output_2d.f90
===================================================================
--- palm/trunk/SOURCE/data_output_2d.f90	(revision 1030)
+++ palm/trunk/SOURCE/data_output_2d.f90	(revision 1031)
@@ -4,5 +4,5 @@
 ! Current revisions:
 ! -----------------
-!
+! netCDF4 without parallel file support implemented
 !
 ! Former revisions:
@@ -44,9 +44,9 @@
 !
 ! 493 2010-03-01 08:30:24Z raasch
-! NetCDF4 support (parallel output)
+! netCDF4 support (parallel output)
 !
 ! 367 2009-08-25 08:35:52Z maronga
-! simulated_time in NetCDF output replaced by time_since_reference_point.
-! Output of NetCDF messages with aid of message handling routine.
+! simulated_time in netCDF output replaced by time_since_reference_point.
+! Output of netCDF messages with aid of message handling routine.
 ! Bugfix: averaging along z is not allowed for 2d quantities (e.g. u* and z0)
 ! Output of messages replaced by message handling routine.
@@ -85,5 +85,5 @@
 ! Description:
 ! ------------
-! Data output of horizontal cross-sections in NetCDF format or binary format
+! Data output of horizontal cross-sections in netCDF format or binary format
 ! compatible to old graphic software iso2d.
 ! Attention: The position of the sectional planes is still not always computed 
@@ -146,7 +146,6 @@
 
 !
-!--       Classic and 64bit offset NetCDF output is done only on PE0.
-!--       netCDF4/HDF5 output is done in parallel on all PEs.
-          IF ( netcdf_output .AND. ( myid == 0 .OR. netcdf_data_format > 2 ) ) &
+!--       Parallel netCDF4/HDF5 output is done on all PEs, all other on PE0 only
+          IF ( netcdf_output .AND. ( myid == 0 .OR. netcdf_data_format > 4 ) ) &
           THEN
              CALL check_open( 101+av*10 )
@@ -169,7 +168,6 @@
 
 !
-!--       Classic and 64bit offset NetCDF output is done only on PE0.
-!--       netCDF4/HDF5 output may be done in parallel on all PEs.
-          IF ( netcdf_output .AND. ( myid == 0 .OR. netcdf_data_format > 2 ) ) &
+!--       Parallel netCDF4/HDF5 output is done on all PEs, all other on PE0 only
+          IF ( netcdf_output .AND. ( myid == 0 .OR. netcdf_data_format > 4 ) ) &
           THEN
              CALL check_open( 102+av*10 )
@@ -193,7 +191,6 @@
 
 !
-!--       Classic and 64bit offset NetCDF output is done only on PE0.
-!--       netCDF4/HDF5 output may be done in parallel on all PEs.
-          IF ( netcdf_output .AND. ( myid == 0 .OR. netcdf_data_format > 2 ) ) &
+!--       Parallel netCDF4/HDF5 output is done on all PEs, all other on PE0 only
+          IF ( netcdf_output .AND. ( myid == 0 .OR. netcdf_data_format > 4 ) ) &
           THEN
              CALL check_open( 103+av*10 )
@@ -703,11 +700,11 @@
 
 !
-!--                Update the NetCDF xy cross section time axis
-                   IF ( myid == 0  .OR.  netcdf_data_format > 2 )  THEN
+!--                Update the netCDF xy cross section time axis
+                   IF ( myid == 0  .OR.  netcdf_data_format > 4 )  THEN
                       IF ( simulated_time /= do2d_xy_last_time(av) )  THEN
                          do2d_xy_time_count(av) = do2d_xy_time_count(av) + 1
                          do2d_xy_last_time(av)  = simulated_time
                          IF ( ( .NOT. data_output_2d_on_each_pe  .AND. &
-                              netcdf_output )  .OR.  netcdf_data_format > 2 ) &
+                              netcdf_output )  .OR.  netcdf_data_format > 4 ) &
                          THEN
 #if defined( __netcdf )
@@ -747,7 +744,7 @@
 
 #if defined( __parallel )
-                   IF ( netcdf_output  .AND.  netcdf_data_format > 2 )  THEN
-!
-!--                   Output in NetCDF4/HDF5 format.
+                   IF ( netcdf_output  .AND.  netcdf_data_format > 4 )  THEN
+!
+!--                   Parallel output in netCDF4/HDF5 format.
 !--                   Do not output redundant ghost point data except for the
 !--                   boundaries of the total domain.
@@ -951,6 +948,6 @@
                 CASE ( 'xz' )
 !
-!--                Update the NetCDF xz cross section time axis
-                   IF ( myid == 0  .OR.  netcdf_data_format > 2 )  THEN
+!--                Update the netCDF xz cross section time axis
+                   IF ( myid == 0  .OR.  netcdf_data_format > 4 )  THEN
 
                       IF ( simulated_time /= do2d_xz_last_time(av) )  THEN
@@ -958,5 +955,5 @@
                          do2d_xz_last_time(av)  = simulated_time
                          IF ( ( .NOT. data_output_2d_on_each_pe  .AND.        &
-                              netcdf_output )  .OR.  netcdf_data_format > 2 ) &
+                              netcdf_output )  .OR.  netcdf_data_format > 4 ) &
                          THEN
 #if defined( __netcdf )
@@ -1016,9 +1013,9 @@
 
 #if defined( __parallel )
-                   IF ( netcdf_output  .AND.  netcdf_data_format > 2 )  THEN
+                   IF ( netcdf_output  .AND.  netcdf_data_format > 4 )  THEN
 !
 !--                   ATTENTION: The following lines are a workaround, because
 !--                              independet output does not work with the
-!--                              current NetCDF4 installation. Therefore, data
+!--                              current netCDF4 installation. Therefore, data
 !--                              are transferred from PEs having the cross
 !--                              sections to other PEs along y having no cross
@@ -1049,5 +1046,5 @@
 
 !
-!--                   Output in NetCDF4/HDF5 format.
+!--                   Output in netCDF4/HDF5 format.
 !--                   Output only on those PEs where the respective cross
 !--                   sections reside. Cross sections averaged along y are
@@ -1261,6 +1258,6 @@
                 CASE ( 'yz' )
 !
-!--                Update the NetCDF yz cross section time axis
-                   IF ( myid == 0  .OR.  netcdf_data_format > 2 )  THEN
+!--                Update the netCDF yz cross section time axis
+                   IF ( myid == 0  .OR.  netcdf_data_format > 4 )  THEN
 
                       IF ( simulated_time /= do2d_yz_last_time(av) )  THEN
@@ -1268,5 +1265,5 @@
                          do2d_yz_last_time(av)  = simulated_time
                          IF ( ( .NOT. data_output_2d_on_each_pe  .AND.        &
-                              netcdf_output )  .OR.  netcdf_data_format > 2 ) &
+                              netcdf_output )  .OR.  netcdf_data_format > 4 ) &
                          THEN
 #if defined( __netcdf )
@@ -1325,9 +1322,9 @@
 
 #if defined( __parallel )
-                   IF ( netcdf_output  .AND.  netcdf_data_format > 2 )  THEN
+                   IF ( netcdf_output  .AND.  netcdf_data_format > 4 )  THEN
 !
 !--                   ATTENTION: The following lines are a workaround, because
 !--                              independet output does not work with the
-!--                              current NetCDF4 installation. Therefore, data
+!--                              current netCDF4 installation. Therefore, data
 !--                              are transferred from PEs having the cross
 !--                              sections to other PEs along y having no cross
@@ -1358,5 +1355,5 @@
 
 !
-!--                   Output in NetCDF4/HDF5 format.
+!--                   Output in netCDF4/HDF5 format.
 !--                   Output only on those PEs where the respective cross
 !--                   sections reside. Cross sections averaged along x are
Index: palm/trunk/SOURCE/data_output_3d.f90
===================================================================
--- palm/trunk/SOURCE/data_output_3d.f90	(revision 1030)
+++ palm/trunk/SOURCE/data_output_3d.f90	(revision 1031)
@@ -4,5 +4,5 @@
 ! Current revisions:
 ! -----------------
-!
+! netCDF4 without parallel file support implemented
 !
 ! Former revisions:
@@ -45,9 +45,9 @@
 !
 ! 493 2010-03-01 08:30:24Z raasch
-! NetCDF4 support (parallel output)
+! netCDF4 support (parallel output)
 !
 ! 355 2009-07-17 01:03:01Z letzel
-! simulated_time in NetCDF output replaced by time_since_reference_point.
-! Output of NetCDF messages with aid of message handling routine.
+! simulated_time in netCDF output replaced by time_since_reference_point.
+! Output of netCDF messages with aid of message handling routine.
 ! Output of messages replaced by message handling routine.
 ! Bugfix: to_be_resorted => s_av for time-averaged scalars
@@ -75,5 +75,5 @@
 ! Description:
 ! ------------
-! Output of the 3D-arrays in NetCDF and/or AVS format.
+! Output of the 3D-arrays in netCDF and/or AVS format.
 !------------------------------------------------------------------------------!
 
@@ -113,5 +113,5 @@
 !-- Open output file.
 !-- Also creates coordinate and fld-file for AVS.
-!-- For classic or 64bit NetCDF output or output of other (old) data formats,
+!-- For classic or 64bit netCDF output or output of other (old) data formats,
 !-- for a run on more than one PE, each PE opens its own file and
 !-- writes the data of its subdomain in binary format (regardless of the format
@@ -119,7 +119,7 @@
 !-- file by combine_plot_fields in the format requested by the user (netcdf
 !-- and/or avs).
-!-- For NetCDF4/HDF5 output, data is written in parallel into one file.
+!-- For netCDF4/HDF5 output, data is written in parallel into one file.
     IF ( netcdf_output )  THEN
-       IF ( netcdf_data_format < 3 )  THEN
+       IF ( netcdf_data_format < 5 )  THEN
           CALL check_open( 30 )
           IF ( myid == 0 )  CALL check_open( 106+av*10 )
@@ -136,7 +136,7 @@
 
 !
-!-- Update the NetCDF time axis
+!-- Update the netCDF time axis
 #if defined( __netcdf )
-    IF ( myid == 0  .OR.  netcdf_data_format > 2 )  THEN
+    IF ( myid == 0  .OR.  netcdf_data_format > 4 )  THEN
        do3d_time_count(av) = do3d_time_count(av) + 1
        IF ( netcdf_output )  THEN
@@ -456,8 +456,8 @@
 #if defined( __parallel )
           IF ( netcdf_output )  THEN
-             IF ( netcdf_data_format < 3 )  THEN
-!
-!--             Classic or 64bit format. Data is output in parallel in FORTRAN
-!--             binary format here, and later collected into one file by
+             IF ( netcdf_data_format < 5 )  THEN
+!
+!--             Non-parallel netCDF output. Data is output in parallel in
+!--             FORTRAN binary format here, and later collected into one file by
 !--             combine_plot_fields
                 IF ( myid == 0 )  THEN
@@ -478,5 +478,5 @@
 #if defined( __netcdf )
 !
-!--             Output in NetCDF4/HDF5 format.
+!--             Parallel output in netCDF4/HDF5 format.
 !--             Do not output redundant ghost point data except for the
 !--             boundaries of the total domain.
Index: palm/trunk/SOURCE/data_output_mask.f90
===================================================================
--- palm/trunk/SOURCE/data_output_mask.f90	(revision 1030)
+++ palm/trunk/SOURCE/data_output_mask.f90	(revision 1031)
@@ -4,5 +4,5 @@
 ! Current revisions:
 ! -----------------
-!
+! netCDF4 without parallel file support implemented
 !
 ! Former revisions:
@@ -35,5 +35,5 @@
 ! Description:
 ! ------------
-! Masked data output in NetCDF format for current mask (current value of mid).
+! Masked data output in netCDF format for current mask (current value of mid).
 !------------------------------------------------------------------------------!
 
@@ -72,5 +72,5 @@
 !
 !-- Open output file.
-    IF ( netcdf_output  .AND.  ( myid == 0  .OR.  netcdf_data_format > 2 ) ) &
+    IF ( netcdf_output  .AND.  ( myid == 0  .OR.  netcdf_data_format > 4 ) ) &
     THEN
        CALL check_open( 200+mid+av*max_masks )
@@ -88,7 +88,7 @@
 
 !
-!-- Update the NetCDF time axis.
+!-- Update the netCDF time axis.
     domask_time_count(mid,av) = domask_time_count(mid,av) + 1
-    IF ( netcdf_output  .AND.  ( myid == 0  .OR.  netcdf_data_format > 2 ) ) &
+    IF ( netcdf_output  .AND.  ( myid == 0  .OR.  netcdf_data_format > 4 ) ) &
     THEN
        nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_time_mask(mid,av), &
@@ -106,5 +106,5 @@
 !
 !--    Reallocate local_pf on PE 0 since its shape changes during MPI exchange
-       IF ( netcdf_data_format < 3   .AND.  myid == 0  .AND.  if > 1 )  THEN
+       IF ( netcdf_data_format < 5   .AND.  myid == 0  .AND.  if > 1 )  THEN
           DEALLOCATE( local_pf )
           ALLOCATE( local_pf(mask_size_l(mid,1),mask_size_l(mid,2), &
@@ -366,15 +366,15 @@
 !--    I/O block. I/O methods are implemented
 !--    (1) for parallel execution
-!--     a. with NetCDF 4 parallel I/O-enabled library
-!--     b. with NetCDF 3 library
+!--     a. with netCDF 4 parallel I/O-enabled library
+!--     b. with netCDF 3 library
 !--    (2) for serial execution.
 !--    The choice of method depends on the correct setting of preprocessor
-!--    directives __parallel and __netcdf4 as well as on the parameter 
+!--    directives __parallel and __netcdf4_parallel as well as on the parameter
 !--    netcdf_data_format.
 #if defined( __parallel )
-#if defined( __netcdf4 )
-       IF ( netcdf_data_format > 2 )  THEN
-!
-!--       (1) a. Parallel I/O using NetCDF 4 (not yet tested)
+#if defined( __netcdf4_parallel )
+       IF ( netcdf_data_format > 4 )  THEN
+!
+!--       (1) a. Parallel I/O using netCDF 4 (not yet tested)
           nc_stat = NF90_PUT_VAR( id_set_mask(mid,av),  &
                id_var_domask(mid,av,if),  &
@@ -463,5 +463,5 @@
 !--       fast so that PE0 may receive wrong data on tag 0.
           CALL MPI_BARRIER( comm2d, ierr )
-#if defined( __netcdf4 )
+#if defined( __netcdf4_parallel )
        ENDIF
 #endif
Index: palm/trunk/SOURCE/header.f90
===================================================================
--- palm/trunk/SOURCE/header.f90	(revision 1030)
+++ palm/trunk/SOURCE/header.f90	(revision 1031)
@@ -4,5 +4,5 @@
 ! Current revisions:
 ! -----------------
-!
+! output of netCDF data format modified
 !
 ! Former revisions:
@@ -730,9 +730,5 @@
        output_format = ''
        IF ( netcdf_output )  THEN
-          IF ( netcdf_data_format == 1 )  THEN
-             output_format = 'NetCDF classic'
-          ELSE
-             output_format = 'NetCDF 64bit offset'
-          ENDIF
+          output_format = output_format_netcdf
        ENDIF
        WRITE ( io, 344 )  output_format
@@ -801,17 +797,9 @@
           output_format = ''
           IF ( netcdf_output )  THEN
-             IF ( netcdf_data_format == 1 )  THEN
-                output_format = 'NetCDF classic'
-             ELSEIF ( netcdf_data_format == 2 )  THEN
-                output_format = 'NetCDF 64bit offset'
-             ELSEIF ( netcdf_data_format == 3 )  THEN
-                output_format = 'NetCDF4/HDF5'
-             ELSEIF ( netcdf_data_format == 4 )  THEN
-                output_format = 'NetCDF4/HDF5 clasic'
-             ENDIF
+             output_format = output_format_netcdf
           ENDIF
           IF ( iso2d_output )  THEN
              IF ( netcdf_output )  THEN
-                output_format = TRIM( output_format ) // ' and iso2d'
+                output_format = TRIM( output_format_netcdf ) // ' and iso2d'
              ELSE
                 output_format = 'iso2d'
@@ -962,17 +950,9 @@
           output_format = ''
           IF ( netcdf_output )  THEN
-             IF ( netcdf_data_format == 1 )  THEN
-                output_format = 'NetCDF classic'
-             ELSEIF ( netcdf_data_format == 2 )  THEN
-                output_format = 'NetCDF 64bit offset'
-             ELSEIF ( netcdf_data_format == 3 )  THEN
-                output_format = 'NetCDF4/HDF5'
-             ELSEIF ( netcdf_data_format == 4 )  THEN
-                output_format = 'NetCDF4/HDF5 clasic'
-             ENDIF
+             output_format = output_format_netcdf
           ENDIF
           IF ( avs_output )  THEN
              IF ( netcdf_output )  THEN
-                output_format = TRIM( output_format ) // ' and avs'
+                output_format = TRIM( output_format_netcdf ) // ' and avs'
              ELSE
                 output_format = 'avs'
@@ -1058,15 +1038,7 @@
              ENDIF
 
-             output_format = ''
+             output_format = ' '
              IF ( netcdf_output )  THEN
-                IF ( netcdf_data_format == 1 )  THEN
-                   output_format = 'NetCDF classic'
-                ELSEIF ( netcdf_data_format == 2 )  THEN
-                   output_format = 'NetCDF 64bit offset'
-                ELSEIF ( netcdf_data_format == 3 )  THEN
-                   output_format = 'NetCDF4/HDF5'
-                ELSEIF ( netcdf_data_format == 4 )  THEN
-                   output_format = 'NetCDF4/HDF5 clasic'
-                ENDIF
+                output_format = output_format_netcdf
              ENDIF
              WRITE ( io, 344 )  output_format
@@ -1122,9 +1094,5 @@
        output_format = ''
        IF ( netcdf_output )  THEN
-          IF ( netcdf_data_format == 1 )  THEN
-             output_format = 'NetCDF classic'
-          ELSE
-             output_format = 'NetCDF 64bit offset'
-          ENDIF
+          output_format = output_format_netcdf
        ENDIF
        WRITE ( io, 344 )  output_format
@@ -1190,11 +1158,7 @@
        WRITE ( io, 370 )
 
-       output_format = ''
+       output_format = ' '
        IF ( netcdf_output )  THEN
-          IF ( netcdf_data_format == 1 )  THEN
-             output_format = 'NetCDF classic'
-          ELSE
-             output_format = 'NetCDF 64bit offset'
-          ENDIF
+          output_format = output_format_netcdf
        ENDIF
        WRITE ( io, 344 )  output_format
@@ -1532,5 +1496,5 @@
        IF ( dt_write_particle_data /= 9999999.9 )  THEN
           WRITE ( io, 485 )  dt_write_particle_data
-          output_format = ''
+          output_format = ' '
           IF ( netcdf_output )  THEN
              IF ( netcdf_data_format > 1 )  THEN
Index: palm/trunk/SOURCE/init_masks.f90
===================================================================
--- palm/trunk/SOURCE/init_masks.f90	(revision 1030)
+++ palm/trunk/SOURCE/init_masks.f90	(revision 1031)
@@ -4,5 +4,5 @@
 ! Current revisions:
 ! -----------------
-!
+! netCDF4 without parallel file support implemented
 !
 ! Former revisions:
@@ -82,5 +82,5 @@
 !
 !-- Parallel mask output not yet tested
-    IF ( netcdf_data_format > 2 )  THEN
+    IF ( netcdf_data_format > 4 )  THEN
        message_string = 'netCDF file formats '//                         &
                         '3 (netCDF 4) and 4 (netCDF 4 Classic model)'//  &
@@ -127,5 +127,5 @@
 !
 !-- Global arrays are required by define_netcdf_header.
-    IF ( myid == 0  .OR.  netcdf_data_format > 2 )  THEN
+    IF ( myid == 0  .OR.  netcdf_data_format > 4 )  THEN
        ALLOCATE( mask_i_global(max_masks,nx+1), &
                  mask_j_global(max_masks,ny+1), &
@@ -412,5 +412,5 @@
        CALL MPI_BARRIER( comm2d, ierr )
        
-       IF ( netcdf_data_format > 2 )  THEN  
+       IF ( netcdf_data_format > 4 )  THEN
          
           CALL MPI_BCAST( mask_i_global(mid,:), nx+1, MPI_INTEGER, 0, comm2d, &
Index: palm/trunk/SOURCE/modules.f90
===================================================================
--- palm/trunk/SOURCE/modules.f90	(revision 1030)
+++ palm/trunk/SOURCE/modules.f90	(revision 1031)
@@ -4,5 +4,5 @@
 ! Current revisions:
 ! -----------------
-!
+! +output_format_netcdf
 !
 ! Former revisions:
@@ -523,5 +523,6 @@
                              return_addres, return_username, &
                              timestep_scheme = 'runge-kutta-3'
-    CHARACTER (LEN=40)   ::  avs_data_file, topography = 'flat'
+    CHARACTER (LEN=40)   ::  avs_data_file, output_format_netcdf, &
+                             topography = 'flat'
     CHARACTER (LEN=64)   ::  host = ' '
     CHARACTER (LEN=80)   ::  log_message, run_identifier
Index: palm/trunk/SOURCE/netcdf.f90
===================================================================
--- palm/trunk/SOURCE/netcdf.f90	(revision 1030)
+++ palm/trunk/SOURCE/netcdf.f90	(revision 1031)
@@ -7,5 +7,6 @@
 ! Current revisions:
 ! ------------------
-!
+! netCDF4 without parallel file support implemented, new routines
+! create_netcdf_file and open_write_netcdf_file at end
 !
 ! Former revisions:
@@ -27,5 +28,5 @@
 !
 ! 951 2012-07-19 14:22:52Z hoffmann
-! cross_profiles, profile_rows, profile_columns are written to NetCDF header
+! cross_profiles, profile_rows, profile_columns are written to netCDF header
 !
 ! 771 2011-10-27 10:56:21Z heinze
@@ -41,11 +42,11 @@
 !
 ! 519 2010-03-19 05:30:02Z raasch
-! particle number defined as unlimited dimension in case of NetCDF4 output,
-! special characters like * and " are now allowed for NetCDF variable names,
+! particle number defined as unlimited dimension in case of netCDF4 output,
+! special characters like * and " are now allowed for netCDF variable names,
 ! replacement of these characters removed, routine clean_netcdf_varname
 ! removed
 !
 ! 493 2010-03-01 08:30:24Z raasch
-! Extensions for NetCDF4 output
+! Extensions for netCDF4 output
 !
 ! 410 2009-12-04 17:05:40Z letzel
@@ -53,14 +54,14 @@
 !
 ! 359 2009-08-19 16:56:44Z letzel
-! for extended NetCDF files, the updated title attribute includes an update of
+! for extended netCDF files, the updated title attribute includes an update of
 ! time_average_text where appropriate.
-! Bugfix for extended NetCDF files: In order to avoid 'data mode' errors if 
+! Bugfix for extended netCDF files: In order to avoid 'data mode' errors if
 ! updated attributes are larger than their original size, NF90_PUT_ATT is called
 ! in 'define mode' enclosed by NF90_REDEF and NF90_ENDDEF calls. This implies a
 ! possible performance loss; an alternative strategy would be to ensure equal
 ! attribute size in a job chain.
-! NetCDF unit attribute in timeseries output in case of statistic
+! netCDF unit attribute in timeseries output in case of statistic
 ! regions added.
-! Output of NetCDF messages with aid of message handling routine.
+! Output of netCDF messages with aid of message handling routine.
 ! Output of messages replaced by message handling routine.
 ! Typographical errors fixed.
@@ -95,6 +96,6 @@
 ! In case of extend = .FALSE.:
 ! Define all necessary dimensions, axes and variables for the different
-! NetCDF datasets. This subroutine is called from check_open after a new
-! dataset is created. It leaves the open NetCDF files ready to write.
+! netCDF datasets. This subroutine is called from check_open after a new
+! dataset is created. It leaves the open netCDF files ready to write.
 !
 ! In case of extend = .TRUE.:
@@ -163,5 +164,5 @@
     IF ( .NOT. init_netcdf )  THEN
 !
-!--    Check and set accuracy for NetCDF output. First set default value
+!--    Check and set accuracy for netCDF output. First set default value
        nc_precision = NF90_REAL4
 
@@ -547,5 +548,5 @@
 
 !
-!--       Leave NetCDF define mode
+!--       Leave netCDF define mode
           nc_stat = NF90_ENDDEF( id_set_mask(mid,av) )
           CALL handle_netcdf_error( 'netcdf', 498 )
@@ -683,5 +684,5 @@
 
           IF ( TRIM( var_list ) /= TRIM( var_list_old ) )  THEN
-             WRITE ( message_string, * ) 'NetCDF file for ', TRIM( var ), &
+             WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), &
                   ' data for mask', mid, ' from previous run found,', &
                   '&but this file cannot be extended due to variable ', &
@@ -710,5 +711,5 @@
 
           IF ( mask_size(mid,3) /= nz_old )  THEN
-             WRITE ( message_string, * ) 'NetCDF file for ', TRIM( var ), &
+             WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), &
                   ' data for mask', mid, ' from previous run found,', &
                   '&but this file cannot be extended due to mismatch in ', &
@@ -748,5 +749,5 @@
 
           IF ( last_time_coordinate(1) >= simulated_time )  THEN
-             WRITE ( message_string, * ) 'NetCDF file for ', TRIM( var ), &
+             WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), &
                   ' data for mask', mid, ' from previous run found,', &
                   '&but this file cannot be extended because the current ', &
@@ -792,5 +793,5 @@
           nc_stat = NF90_ENDDEF( id_set_mask(mid,av) )
           CALL handle_netcdf_error( 'netcdf', 518 )
-          WRITE ( message_string, * ) 'NetCDF file for ', TRIM( var ), &
+          WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), &
                ' data for mask', mid, ' from previous run found.', &
                '&This file will be extended.'
@@ -1055,8 +1056,8 @@
                                      'units', TRIM( do3d_unit(av,i) ) )
              CALL handle_netcdf_error( 'netcdf', 357 )
-#if defined( __netcdf4 )
+#if defined( __netcdf4_parallel )
 !
 !--          Set collective io operations for parallel io
-             IF ( netcdf_data_format > 2 )  THEN
+             IF ( netcdf_data_format > 4 )  THEN
                 nc_stat = NF90_VAR_PAR_ACCESS( id_set_3d(av),     &
                                                id_var_do3d(av,i), &
@@ -1081,5 +1082,5 @@
 
 !
-!--       Leave NetCDF define mode
+!--       Leave netCDF define mode
           nc_stat = NF90_ENDDEF( id_set_3d(av) )
           CALL handle_netcdf_error( 'netcdf', 82 )
@@ -1188,5 +1189,5 @@
 
           IF ( TRIM( var_list ) /= TRIM( var_list_old ) )  THEN
-             message_string = 'NetCDF file for volume data ' //             &  
+             message_string = 'netCDF file for volume data ' //             &
                               TRIM( var ) // ' from previous run found,' // &
                               '&but this file cannot be extended due to' // &
@@ -1213,5 +1214,5 @@
 
           IF ( nz_do3d-nzb+1 /= nz_old )  THEN
-              message_string = 'NetCDF file for volume data ' //             &
+              message_string = 'netCDF file for volume data ' //             &
                                TRIM( var ) // ' from previous run found,' // &
                                '&but this file cannot be extended due to' // &
@@ -1249,5 +1250,5 @@
 
           IF ( last_time_coordinate(1) >= simulated_time )  THEN
-             message_string = 'NetCDF file for volume data ' // &
+             message_string = 'netCDF file for volume data ' // &
                               TRIM( var ) // ' from previous run found,' // &
                               '&but this file cannot be extended becaus' // &
@@ -1270,8 +1271,8 @@
                                        id_var_do3d(av,i) )
              CALL handle_netcdf_error( 'netcdf', 95 )
-#if defined( __netcdf4 )
+#if defined( __netcdf4_parallel )
 !
 !--          Set collective io operations for parallel io
-             IF ( netcdf_data_format > 2 )  THEN
+             IF ( netcdf_data_format > 4 )  THEN
                 nc_stat = NF90_VAR_PAR_ACCESS( id_set_3d(av),     &
                                                id_var_do3d(av,i), &
@@ -1304,5 +1305,5 @@
           nc_stat = NF90_ENDDEF( id_set_3d(av) )
           CALL handle_netcdf_error( 'netcdf', 430 )
-          message_string = 'NetCDF file for volume data ' //             &
+          message_string = 'netCDF file for volume data ' //             &
                            TRIM( var ) // ' from previous run found.' // &
                            '&This file will be extended.'
@@ -1621,8 +1622,8 @@
                                         'units', TRIM( do2d_unit(av,i) ) )
                 CALL handle_netcdf_error( 'netcdf', 354 ) 
-#if defined( __netcdf4 )
+#if defined( __netcdf4_parallel )
 !
 !--             Set collective io operations for parallel io
-                IF ( netcdf_data_format > 2 )  THEN
+                IF ( netcdf_data_format > 4 )  THEN
                    nc_stat = NF90_VAR_PAR_ACCESS( id_set_xy(av),     &
                                                   id_var_do2d(av,i), &
@@ -1649,5 +1650,5 @@
 
 !
-!--       Leave NetCDF define mode
+!--       Leave netCDF define mode
           nc_stat = NF90_ENDDEF( id_set_xy(av) )
           CALL handle_netcdf_error( 'netcdf', 122 ) 
@@ -1794,5 +1795,5 @@
 
           IF ( TRIM( var_list ) /= TRIM( var_list_old ) )  THEN
-             message_string = 'NetCDF file for cross-sections ' //           &
+             message_string = 'netCDF file for cross-sections ' //           &
                               TRIM( var ) // ' from previous run found,' //  &
                               '& but this file cannot be extended due to' // &
@@ -1827,5 +1828,5 @@
 
           IF ( ns /= ns_old )  THEN
-             message_string = 'NetCDF file for cross-sections ' //          &
+             message_string = 'netCDF file for cross-sections ' //          &
                               TRIM( var ) // ' from previous run found,' // &
                               '&but this file cannot be extended due to' // &
@@ -1848,5 +1849,5 @@
              IF ( section(i,1) /= -1 )  THEN
                 IF ( zu(section(i,1)) /= netcdf_data(i) )  THEN
-                   message_string = 'NetCDF file for cross-sections ' //     &
+                   message_string = 'netCDF file for cross-sections ' //     &
                                TRIM( var ) // ' from previous run found,' // &
                                '&but this file cannot be extended' //        &
@@ -1861,5 +1862,5 @@
              ELSE
                 IF ( -1.0 /= netcdf_data(i) )  THEN
-                   message_string = 'NetCDF file for cross-sections ' //     &
+                   message_string = 'netCDF file for cross-sections ' //     &
                                TRIM( var ) // ' from previous run found,' // &
                                '&but this file cannot be extended' //        &
@@ -1901,5 +1902,5 @@
 
           IF ( last_time_coordinate(1) >= simulated_time )  THEN
-             message_string = 'NetCDF file for cross sections ' //          &
+             message_string = 'netCDF file for cross sections ' //          &
                               TRIM( var ) // ' from previous run found,' // &
                               '&but this file cannot be extended becaus' // &
@@ -1923,8 +1924,8 @@
                                           id_var_do2d(av,i) )
                 CALL handle_netcdf_error( 'netcdf', 138 )
-#if defined( __netcdf4 )
+#if defined( __netcdf4_parallel )
 !
 !--             Set collective io operations for parallel io
-                IF ( netcdf_data_format > 2 )  THEN
+                IF ( netcdf_data_format > 4 )  THEN
                    nc_stat = NF90_VAR_PAR_ACCESS( id_set_xy(av),     &
                                                   id_var_do2d(av,i), &
@@ -1958,5 +1959,5 @@
           nc_stat = NF90_ENDDEF( id_set_xy(av) )
           CALL handle_netcdf_error( 'netcdf', 432 )
-          message_string = 'NetCDF file for cross-sections ' //           & 
+          message_string = 'netCDF file for cross-sections ' //           &
                             TRIM( var ) // ' from previous run found.' // &
                            '&This file will be extended.'
@@ -2205,10 +2206,10 @@
                                         'units', TRIM( do2d_unit(av,i) ) )
                 CALL handle_netcdf_error( 'netcdf', 355 )
-#if defined( __netcdf4 )
+#if defined( __netcdf4_parallel )
 !
 !--             Set independent io operations for parallel io. Collective io
 !--             is only allowed in case of a 1d-decomposition along x, because
 !--             otherwise, not all PEs have output data.
-                IF ( netcdf_data_format > 2 )  THEN
+                IF ( netcdf_data_format > 4 )  THEN
                    IF ( npey == 1 )  THEN
                       nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av),     &
@@ -2217,5 +2218,5 @@
                    ELSE
 !
-!--                   ATTENTION: Due to a probable bug in the NetCDF4
+!--                   ATTENTION: Due to a probable bug in the netCDF4
 !--                              installation, independet output does not work
 !--                              A workaround is used in data_output_2d on those
@@ -2249,5 +2250,5 @@
 
 !
-!--       Leave NetCDF define mode
+!--       Leave netCDF define mode
           nc_stat = NF90_ENDDEF( id_set_xz(av) )
           CALL handle_netcdf_error( 'netcdf', 162 )
@@ -2364,5 +2365,5 @@
 
           IF ( TRIM( var_list ) /= TRIM( var_list_old ) )  THEN
-             message_string = 'NetCDF file for cross-sections ' //           &
+             message_string = 'netCDF file for cross-sections ' //           &
                               TRIM( var ) // ' from previous run found,' //  &
                               '& but this file cannot be extended due to' // &
@@ -2397,5 +2398,5 @@
 
           IF ( ns /= ns_old )  THEN
-             message_string = 'NetCDF file for cross-sections ' //          &
+             message_string = 'netCDF file for cross-sections ' //          &
                               TRIM( var ) // ' from previous run found,' // &
                               '&but this file cannot be extended due to' // &
@@ -2418,5 +2419,5 @@
              IF ( section(i,2) /= -1 )  THEN
                 IF ( ( ( section(i,2) + 0.5 ) * dy ) /= netcdf_data(i) )  THEN
-                   message_string = 'NetCDF file for cross-sections ' //     &
+                   message_string = 'netCDF file for cross-sections ' //     &
                                TRIM( var ) // ' from previous run found,' // &
                                '&but this file cannot be extended' //        &
@@ -2431,5 +2432,5 @@
              ELSE
                 IF ( -1.0 /= netcdf_data(i) )  THEN
-                   message_string = 'NetCDF file for cross-sections ' //     &
+                   message_string = 'netCDF file for cross-sections ' //     &
                                TRIM( var ) // ' from previous run found,' // &
                                '&but this file cannot be extended' //        &
@@ -2471,5 +2472,5 @@
 
           IF ( last_time_coordinate(1) >= simulated_time )  THEN
-             message_string = 'NetCDF file for cross sections ' //          &
+             message_string = 'netCDF file for cross sections ' //          &
                               TRIM( var ) // ' from previous run found,' // &
                               '&but this file cannot be extended becaus' // &
@@ -2493,10 +2494,10 @@
                                           id_var_do2d(av,i) )
                 CALL handle_netcdf_error( 'netcdf', 177 )
-#if defined( __netcdf4 )
+#if defined( __netcdf4_parallel )
 !
 !--             Set independent io operations for parallel io. Collective io
 !--             is only allowed in case of a 1d-decomposition along x, because
 !--             otherwise, not all PEs have output data.
-                IF ( netcdf_data_format > 2 )  THEN
+                IF ( netcdf_data_format > 4 )  THEN
                    IF ( npey == 1 )  THEN
                       nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av),     &
@@ -2505,5 +2506,5 @@
                    ELSE
 !
-!--                   ATTENTION: Due to a probable bug in the NetCDF4
+!--                   ATTENTION: Due to a probable bug in the netCDF4
 !--                              installation, independet output does not work
 !--                              A workaround is used in data_output_2d on those
@@ -2544,5 +2545,5 @@
           nc_stat = NF90_ENDDEF( id_set_xz(av) )
           CALL handle_netcdf_error( 'netcdf', 434 )
-          message_string = 'NetCDF file for cross-sections ' //           & 
+          message_string = 'netCDF file for cross-sections ' //           &
                             TRIM( var ) // ' from previous run found.' // &
                            '&This file will be extended.'
@@ -2791,10 +2792,10 @@
                                         'units', TRIM( do2d_unit(av,i) ) )
                 CALL handle_netcdf_error( 'netcdf', 356 )
-#if defined( __netcdf4 )
+#if defined( __netcdf4_parallel )
 !
 !--             Set independent io operations for parallel io. Collective io
 !--             is only allowed in case of a 1d-decomposition along y, because
 !--             otherwise, not all PEs have output data.
-                IF ( netcdf_data_format > 2 )  THEN
+                IF ( netcdf_data_format > 4 )  THEN
                    IF ( npex == 1 )  THEN
                       nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av),     &
@@ -2803,5 +2804,5 @@
                    ELSE
 !
-!--                   ATTENTION: Due to a probable bug in the NetCDF4
+!--                   ATTENTION: Due to a probable bug in the netCDF4
 !--                              installation, independet output does not work
 !--                              A workaround is used in data_output_2d on those
@@ -2835,5 +2836,5 @@
 
 !
-!--       Leave NetCDF define mode
+!--       Leave netCDF define mode
           nc_stat = NF90_ENDDEF( id_set_yz(av) )
           CALL handle_netcdf_error( 'netcdf', 201 )
@@ -2948,5 +2949,5 @@
 
           IF ( TRIM( var_list ) /= TRIM( var_list_old ) )  THEN
-             message_string = 'NetCDF file for cross-sections ' //           &
+             message_string = 'netCDF file for cross-sections ' //           &
                               TRIM( var ) // ' from previous run found,' //  &
                               '& but this file cannot be extended due to' // &
@@ -2981,5 +2982,5 @@
 
           IF ( ns /= ns_old )  THEN
-             message_string = 'NetCDF file for cross-sections ' //          &
+             message_string = 'netCDF file for cross-sections ' //          &
                               TRIM( var ) // ' from previous run found,' // &
                               '&but this file cannot be extended due to' // &
@@ -3002,5 +3003,5 @@
              IF ( section(i,3) /= -1 )  THEN
                 IF ( ( ( section(i,3) + 0.5 ) * dx ) /= netcdf_data(i) )  THEN
-                   message_string = 'NetCDF file for cross-sections ' //    &
+                   message_string = 'netCDF file for cross-sections ' //    &
                               TRIM( var ) // ' from previous run found,' // &
                               '&but this file cannot be extended' //        &
@@ -3015,5 +3016,5 @@
              ELSE
                 IF ( -1.0 /= netcdf_data(i) )  THEN
-                   message_string = 'NetCDF file for cross-sections ' //    &
+                   message_string = 'netCDF file for cross-sections ' //    &
                               TRIM( var ) // ' from previous run found,' // &
                               '&but this file cannot be extended' //        &
@@ -3055,5 +3056,5 @@
 
           IF ( last_time_coordinate(1) >= simulated_time )  THEN
-             message_string = 'NetCDF file for cross sections ' //          &
+             message_string = 'netCDF file for cross sections ' //          &
                               TRIM( var ) // ' from previous run found,' // &
                               '&but this file cannot be extended becaus' // &
@@ -3077,10 +3078,10 @@
                                           id_var_do2d(av,i) )
                 CALL handle_netcdf_error( 'netcdf', 216 )
-#if defined( __netcdf4 )
+#if defined( __netcdf4_parallel )
 !
 !--             Set independent io operations for parallel io. Collective io
 !--             is only allowed in case of a 1d-decomposition along y, because
 !--             otherwise, not all PEs have output data.
-                IF ( netcdf_data_format > 2 )  THEN
+                IF ( netcdf_data_format > 4 )  THEN
                    IF ( npex == 1 )  THEN
                       nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av),     &
@@ -3089,5 +3090,5 @@
                    ELSE
 !
-!--                   ATTENTION: Due to a probable bug in the NetCDF4
+!--                   ATTENTION: Due to a probable bug in the netCDF4
 !--                              installation, independet output does not work
 !--                              A workaround is used in data_output_2d on those
@@ -3128,5 +3129,5 @@
           nc_stat = NF90_ENDDEF( id_set_yz(av) )
           CALL handle_netcdf_error( 'netcdf', 436 )
-          message_string = 'NetCDF file for cross-sections ' //           & 
+          message_string = 'netCDF file for cross-sections ' //           &
                             TRIM( var ) // ' from previous run found.' // &
                            '&This file will be extended.'
@@ -3432,5 +3433,5 @@
 
 !
-!--       Leave NetCDF define mode
+!--       Leave netCDF define mode
           nc_stat = NF90_ENDDEF( id_set_pr )
           CALL handle_netcdf_error( 'netcdf', 238 )
@@ -3478,5 +3479,5 @@
 
           IF ( TRIM( var_list ) /= TRIM( var_list_old ) )  THEN
-             message_string = 'NetCDF file for vertical profiles ' //        &
+             message_string = 'netCDF file for vertical profiles ' //        &
                               'from previous run found,' //                  &
                               '& but this file cannot be extended due to' // &
@@ -3512,5 +3513,5 @@
 
           IF ( last_time_coordinate(1) >= simulated_time )  THEN
-             message_string = 'NetCDF file for vertical profiles ' //       &
+             message_string = 'netCDF file for vertical profiles ' //       &
                               'from previous run found,' //                 &
                               '&but this file cannot be extended becaus' // &
@@ -3578,5 +3579,5 @@
           nc_stat = NF90_ENDDEF( id_set_pr )
           CALL handle_netcdf_error( 'netcdf', 438 )
-          message_string = 'NetCDF file for vertical profiles ' // & 
+          message_string = 'netCDF file for vertical profiles ' // &
                            'from previous run found.' //           &
                            '&This file will be extended.'
@@ -3667,5 +3668,5 @@
 
 !
-!--       Leave NetCDF define mode
+!--       Leave netCDF define mode
           nc_stat = NF90_ENDDEF( id_set_ts )
           CALL handle_netcdf_error( 'netcdf', 259 )
@@ -3700,5 +3701,5 @@
 
           IF ( TRIM( var_list ) /= TRIM( var_list_old ) )  THEN
-             message_string = 'NetCDF file for time series ' //              &
+             message_string = 'netCDF file for time series ' //              &
                               'from previous run found,' //                  &
                               '& but this file cannot be extended due to' // &
@@ -3734,5 +3735,5 @@
 
           IF ( last_time_coordinate(1) >= simulated_time )  THEN
-             message_string = 'NetCDF file for time series ' //             &
+             message_string = 'netCDF file for time series ' //             &
                               'from previous run found,' //                 &
                               '&but this file cannot be extended becaus' // &
@@ -3783,5 +3784,5 @@
           nc_stat = NF90_ENDDEF( id_set_ts )
           CALL handle_netcdf_error( 'netcdf', 440 )
-          message_string = 'NetCDF file for time series ' // & 
+          message_string = 'netCDF file for time series ' // &
                            'from previous run found.' //     &
                            '&This file will be extended.'
@@ -3982,5 +3983,5 @@
 
 !
-!--       Leave NetCDF define mode
+!--       Leave netCDF define mode
           nc_stat = NF90_ENDDEF( id_set_sp )
           CALL handle_netcdf_error( 'netcdf', 292 )
@@ -4060,5 +4061,5 @@
 
           IF ( TRIM( var_list ) /= TRIM( var_list_old ) )  THEN
-             message_string = 'NetCDF file for spectra  ' //                 &
+             message_string = 'netCDF file for spectra  ' //                 &
                               'from previous run found,' //                  &
                               '& but this file cannot be extended due to' // &
@@ -4094,5 +4095,5 @@
 
           IF ( ns /= ns_old )  THEN
-             message_string = 'NetCDF file for spectra ' //                 &
+             message_string = 'netCDF file for spectra ' //                 &
                               ' from previous run found,' //                &
                               '&but this file cannot be extended due to' // &
@@ -4114,5 +4115,5 @@
           DO  i = 1, ns
              IF ( zu(comp_spectra_level(i)) /= netcdf_data(i) )  THEN
-                message_string = 'NetCDF file for spectra ' //                 &
+                message_string = 'netCDF file for spectra ' //                 &
                                  ' from previous run found,' //                &
                                  '&but this file cannot be extended due to' // &
@@ -4152,5 +4153,5 @@
 
           IF ( last_time_coordinate(1) >= simulated_time )  THEN
-             message_string = 'NetCDF file for spectra ' //                 &
+             message_string = 'netCDF file for spectra ' //                 &
                               'from previous run found,' //                 &
                               '&but this file cannot be extended becaus' // &
@@ -4216,5 +4217,5 @@
           nc_stat = NF90_ENDDEF( id_set_sp )
           CALL handle_netcdf_error( 'netcdf', 442 )
-          message_string = 'NetCDF file for spectra ' //     & 
+          message_string = 'netCDF file for spectra ' //     &
                            'from previous run found.' //     &
                            '&This file will be extended.'
@@ -4251,5 +4252,5 @@
           ELSE
 !
-!--          NetCDF4 allows more than one unlimited dimension
+!--          netCDF4 allows more than one unlimited dimension
              nc_stat = NF90_DEF_DIM( id_set_prt, 'particle_number', &
                                      NF90_UNLIMITED, id_dim_prtnum)
@@ -4296,5 +4297,5 @@
 
 !
-!--       Leave NetCDF define mode
+!--       Leave netCDF define mode
           nc_stat = NF90_ENDDEF( id_set_prt )
           CALL handle_netcdf_error( 'netcdf', 322 )
@@ -4327,5 +4328,5 @@
 
           IF ( last_time_coordinate(1) >= simulated_time )  THEN
-             message_string = 'NetCDF file for particles ' //               &
+             message_string = 'netCDF file for particles ' //               &
                               'from previous run found,' //                 &
                               '&but this file cannot be extended becaus' // &
@@ -4355,5 +4356,5 @@
           ENDDO
 
-          message_string = 'NetCDF file for particles ' // & 
+          message_string = 'netCDF file for particles ' // &
                            'from previous run found.' //   &
                            '&This file will be extended.'
@@ -4439,5 +4440,5 @@
 
 !
-!--       Leave NetCDF define mode
+!--       Leave netCDF define mode
           nc_stat = NF90_ENDDEF( id_set_pts )
           CALL handle_netcdf_error( 'netcdf', 404 )
@@ -4477,5 +4478,5 @@
 
           IF ( TRIM( var_list ) /= TRIM( var_list_old ) )  THEN
-             message_string = 'NetCDF file for particle time series ' //     &
+             message_string = 'netCDF file for particle time series ' //     &
                               'from previous run found,' //                  &
                               '& but this file cannot be extended due to' // &
@@ -4511,5 +4512,5 @@
 
           IF ( last_time_coordinate(1) >= simulated_time )  THEN
-             message_string = 'NetCDF file for particle time series ' //    &
+             message_string = 'netCDF file for particle time series ' //    &
                               'from previous run found,' //                 &
                               '&but this file cannot be extended becaus' // &
@@ -4564,5 +4565,5 @@
           nc_stat = NF90_ENDDEF( id_set_pts )
           CALL handle_netcdf_error( 'netcdf', 444 )
-          message_string = 'NetCDF file for particle time series ' // & 
+          message_string = 'netCDF file for particle time series ' // &
                            'from previous run found.' //              &
                            '&This file will be extended.'
@@ -4581,9 +4582,122 @@
 
 
-SUBROUTINE handle_netcdf_error( routine_name, errno )
+ SUBROUTINE create_netcdf_file( filename , id, parallel, errno )
 #if defined( __netcdf )
 
 !------------------------------------------------------------------------------!
-!
+! Description:
+! ------------
+! Creates a netCDF file and give back the id. The parallel flag has to be TRUE
+! for parallel netCDF output support.
+!------------------------------------------------------------------------------!
+
+    USE control_parameters
+    USE netcdf
+    USE netcdf_control
+    USE pegrid
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=*), INTENT(IN) :: filename
+    INTEGER, INTENT(IN)           :: errno
+    INTEGER, INTENT(OUT)          :: id
+    LOGICAL, INTENT(IN)           :: parallel
+
+
+!
+!-- Create a new netCDF output file with requested netCDF format
+    IF ( netcdf_data_format == 1 )  THEN
+!
+!-- Classic netCDF format
+    nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id )
+
+    ELSEIF ( netcdf_data_format == 2 )  THEN
+!
+!--    64bit-offset format
+       nc_stat = NF90_CREATE( filename,                                        &
+                              OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ), id )
+
+#if defined( __netcdf4 )
+    ELSEIF ( netcdf_data_format == 3  .OR.                                     &
+             ( .NOT. parallel  .AND.  netcdf_data_format == 5 ) )  THEN
+!
+!--    netCDF4/HDF5 format
+       nc_stat = NF90_CREATE( filename, OR( NF90_NOCLOBBER, NF90_NETCDF4 ), id )
+
+    ELSEIF ( netcdf_data_format == 4  .OR.                                     &
+             ( .NOT. parallel  .AND.  netcdf_data_format == 6 ) )  THEN
+!
+!--    netCDF4/HDF5 format with classic model flag
+       nc_stat = NF90_CREATE( filename,                                        &
+                              OR( NF90_NOCLOBBER,                              &
+                              OR( NF90_CLASSIC_MODEL, NF90_HDF5 ) ), id )
+
+#if defined( __netcdf4_parallel )
+    ELSEIF ( netcdf_data_format == 5  .AND.  parallel )  THEN
+!
+!--    netCDF4/HDF5 format, parallel
+       nc_stat = NF90_CREATE( filename, OR( NF90_NOCLOBBER, NF90_NETCDF4 ),    &
+                              id, COMM = comm2d, INFO = MPI_INFO_NULL )
+
+    ELSEIF ( netcdf_data_format == 6  .AND.  parallel )  THEN
+!
+!--    netCDF4/HDF5 format with classic model flag, parallel
+       nc_stat = NF90_CREATE( filename,                                        &
+                              OR( NF90_NOCLOBBER,                              &
+                              OR( NF90_CLASSIC_MODEL, NF90_HDF5 ) ),           &
+                              id, COMM = comm2d, INFO = MPI_INFO_NULL )
+
+#endif
+#endif
+    ENDIF
+
+    CALL handle_netcdf_error( 'create_netcdf_file', errno )
+#endif
+ END SUBROUTINE create_netcdf_file
+
+
+ SUBROUTINE open_write_netcdf_file( filename, id, parallel, errno )
+#if defined( __netcdf )
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+! Opens an existing netCDF file for writing and gives back the id.
+! The parallel flag has to be TRUE for parallel netCDF output support.
+!------------------------------------------------------------------------------!
+
+    USE control_parameters
+    USE netcdf
+    USE netcdf_control
+    USE pegrid
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=*), INTENT(IN) :: filename
+    INTEGER, INTENT(IN)           :: errno
+    INTEGER, INTENT(OUT)          :: id
+    LOGICAL, INTENT(IN)           :: parallel
+
+
+    IF ( netcdf_data_format < 5  .OR.  .NOT. parallel )  THEN
+       nc_stat = NF90_OPEN( filename, NF90_WRITE, id )
+#if defined( __netcdf4 )
+#if defined( __netcdf4par )
+    ELSEIF ( netcdf_data_format > 4  .AND.  parallel )  THEN
+       nc_stat = NF90_OPEN( filename, NF90_WRITE, id, COMM = comm2d, &
+                            INFO = MPI_INFO_NULL )
+#endif
+#endif
+    ENDIF
+
+    CALL handle_netcdf_error( 'open_write_netcdf_file', errno )
+#endif
+ END SUBROUTINE open_write_netcdf_file
+
+
+ SUBROUTINE handle_netcdf_error( routine_name, errno )
+#if defined( __netcdf )
+
+!------------------------------------------------------------------------------!
 ! Description:
 ! ------------
