Index: palm/trunk/SOURCE/data_output_netcdf4_module.f90
===================================================================
--- palm/trunk/SOURCE/data_output_netcdf4_module.f90	(revision 4107)
+++ palm/trunk/SOURCE/data_output_netcdf4_module.f90	(revision 4123)
@@ -492,6 +492,6 @@
 !--------------------------------------------------------------------------------------------------!
 SUBROUTINE netcdf4_write_variable(                                        &
-              file_id, var_id, bounds_start, bounds_end, bounds_origin,   &
-              do_output, is_global,                                       &
+              file_id, var_id, bounds_start, value_counts, bounds_origin, &
+              is_global,                                                  &
               var_int8_0d,   var_int8_1d,   var_int8_2d,   var_int8_3d,   &
               var_int16_0d,  var_int16_1d,  var_int16_2d,  var_int16_3d,  &
@@ -514,9 +514,8 @@
 
    INTEGER(iwp), DIMENSION(:), INTENT(IN)  ::  bounds_origin  !< starting index of each dimension
-   INTEGER(iwp), DIMENSION(:), INTENT(IN)  ::  bounds_end     !< ending index of variable
    INTEGER(iwp), DIMENSION(:), INTENT(IN)  ::  bounds_start   !< starting index of variable
    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  dim_ids        !< IDs of dimensions of variable in file
    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  dim_lengths    !< length of dimensions of variable in file
-   INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  value_count    !< count of values along each dimension to be written
+   INTEGER(iwp), DIMENSION(:), INTENT(IN)  ::  value_counts   !< count of values along each dimension to be written
 
    INTEGER(KIND=1), POINTER, INTENT(IN), OPTIONAL                               ::  var_int8_0d  !< output variable
@@ -540,5 +539,4 @@
    INTEGER(iwp), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) ::  var_intwp_3d  !< output variable
 
-   LOGICAL, INTENT(IN) ::  do_output  !< if false, set count to 0 and do no output
    LOGICAL, INTENT(IN) ::  is_global  !< true if variable is global (same on all PE)
 
@@ -578,131 +576,123 @@
       ndim = SIZE( bounds_start )
 
-      ALLOCATE( value_count(ndim) )
-
-      IF ( do_output ) THEN
-         value_count = bounds_end - bounds_start + 1
-      ELSE
-         value_count = 0
-      END IF
-
       !-- 8bit integer output
       IF ( PRESENT( var_int8_0d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, (/ var_int8_0d /),       &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_int8_1d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_int8_1d,             &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_int8_2d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_int8_2d,             &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_int8_3d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_int8_3d,             &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       !-- 16bit integer output
       ELSEIF ( PRESENT( var_int16_0d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, (/ var_int16_0d /),      &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_int16_1d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_int16_1d,            &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_int16_2d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_int16_2d,            &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_int16_3d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_int16_3d,            &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       !-- 32bit integer output
       ELSEIF ( PRESENT( var_int32_0d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, (/ var_int32_0d /),      &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_int32_1d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_int32_1d,            &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_int32_2d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_int32_2d,            &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_int32_3d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_int32_3d,            &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       !-- working-precision integer output
       ELSEIF ( PRESENT( var_intwp_0d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, (/ var_intwp_0d /),      &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_intwp_1d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_intwp_1d,            &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_intwp_2d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_intwp_2d,            &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_intwp_3d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_intwp_3d,            &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       !-- 32bit real output
       ELSEIF ( PRESENT( var_real32_0d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, (/ var_real32_0d /),     &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_real32_1d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_real32_1d,           &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_real32_2d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_real32_2d,           &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_real32_3d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_real32_3d,           &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       !-- 64bit real output
       ELSEIF ( PRESENT( var_real64_0d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, (/ var_real64_0d /),     &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_real64_1d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_real64_1d,           &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_real64_2d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_real64_2d,           &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_real64_3d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_real64_3d,           &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       !-- working-precision real output
       ELSEIF ( PRESENT( var_realwp_0d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, (/ var_realwp_0d /),     &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_realwp_1d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_realwp_1d,           &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_realwp_2d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_realwp_2d,           &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSEIF ( PRESENT( var_realwp_3d ) )  THEN
          nc_stat = NF90_PUT_VAR( file_id, var_id, var_realwp_3d,           &
                                  start = bounds_start - bounds_origin + 1, &
-                                 count = value_count )
+                                 count = value_counts )
       ELSE
          return_value = 1
@@ -736,6 +726,5 @@
             IF ( nc_stat == NF90_NOERR )  THEN
                WRITE( temp_string, * )  TRIM( temp_string ) // '; given variable bounds: ' //  &
-                  'start=', bounds_start, ', end=', bounds_end, '; file dimension bounds: ' // &
-                  'start=', bounds_origin, ', end=', bounds_origin + dim_lengths - 1
+                  'start=', bounds_start, ', count=', value_counts, ', origin=', bounds_origin
                CALL internal_message( 'error', routine_name //     &
                                       ': error while writing: ' // &
