Index: palm/trunk/SOURCE/data_output_netcdf4_module.f90
===================================================================
--- palm/trunk/SOURCE/data_output_netcdf4_module.f90	(revision 4481)
+++ palm/trunk/SOURCE/data_output_netcdf4_module.f90	(revision 4577)
@@ -3,15 +3,14 @@
 ! This file is part of the PALM model system.
 !
-! PALM is free software: you can redistribute it and/or modify it under the
-! terms of the GNU General Public License as published by the Free Software
-! Foundation, either version 3 of the License, or (at your option) any later
-! version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with
-! PALM. If not, see <http://www.gnu.org/licenses/>.
+! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General
+! Public License as published by the Free Software Foundation, either version 3 of the License, or
+! (at your option) any later version.
+!
+! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
+! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+! Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along with PALM. If not, see
+! <http://www.gnu.org/licenses/>.
 !
 ! Copyright 2019-2020 Leibniz Universitaet Hannover
@@ -25,6 +24,9 @@
 ! -----------------
 ! $Id$
+! file re-formatted to follow the PALM coding standard
+!
+! 4481 2020-03-31 18:55:54Z maronga
 ! bugfix: cpp-directive moved to avoid compile error due to unused dummy argument
-! 
+!
 ! 4408 2020-02-14 10:04:39Z gronemeier
 ! Enable character-array output
@@ -67,10 +69,10 @@
 #endif
 
-    CHARACTER(LEN=800) ::  internal_error_message = ''  !< string containing the last error message
-    CHARACTER(LEN=100) ::  file_suffix = ''             !< file suffix added to each file name
-    CHARACTER(LEN=800) ::  temp_string                  !< dummy string
-
     CHARACTER(LEN=*), PARAMETER ::  mode_parallel = 'parallel'  !< string selecting netcdf4 parallel mode
     CHARACTER(LEN=*), PARAMETER ::  mode_serial   = 'serial'    !< string selecting netcdf4 serial mode
+
+    CHARACTER(LEN=100) ::  file_suffix = ''             !< file suffix added to each file name
+    CHARACTER(LEN=800) ::  internal_error_message = ''  !< string containing the last error message
+    CHARACTER(LEN=800) ::  temp_string                  !< dummy string
 
     INTEGER ::  debug_output_unit       !< Fortran Unit Number of the debug-output file
@@ -121,13 +123,13 @@
     END INTERFACE netcdf4_get_error_message
 
-    PUBLIC &
-       netcdf4_finalize, &
-       netcdf4_get_error_message, &
-       netcdf4_init_dimension, &
-       netcdf4_stop_file_header_definition, &
-       netcdf4_init_module, &
-       netcdf4_init_variable, &
-       netcdf4_open_file, &
-       netcdf4_write_attribute, &
+    PUBLIC                                                                                         &
+       netcdf4_finalize,                                                                           &
+       netcdf4_get_error_message,                                                                  &
+       netcdf4_init_dimension,                                                                     &
+       netcdf4_init_module,                                                                        &
+       netcdf4_init_variable,                                                                      &
+       netcdf4_open_file,                                                                          &
+       netcdf4_stop_file_header_definition,                                                        &
+       netcdf4_write_attribute,                                                                    &
        netcdf4_write_variable
 
@@ -141,6 +143,6 @@
 !> Initialize data-output module.
 !--------------------------------------------------------------------------------------------------!
- SUBROUTINE netcdf4_init_module( file_suffix_of_output_group, mpi_comm_of_output_group, &
-                                 master_output_rank,                                    &
+ SUBROUTINE netcdf4_init_module( file_suffix_of_output_group, mpi_comm_of_output_group,            &
+                                 master_output_rank,                                               &
                                  program_debug_output_unit, debug_output, dom_global_id )
 
@@ -174,8 +176,8 @@
  SUBROUTINE netcdf4_open_file( mode, file_name, file_id, return_value )
 
+    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'netcdf4_open_file'  !< name of this routine
+
     CHARACTER(LEN=*), INTENT(IN) ::  file_name  !< name of file
     CHARACTER(LEN=*), INTENT(IN) ::  mode       !< operation mode (either parallel or serial)
-
-    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'netcdf4_open_file'  !< name of this routine
 
     INTEGER, INTENT(OUT) ::  file_id       !< file ID
@@ -201,7 +203,7 @@
        IF ( my_rank /= master_rank )  THEN
           return_value = 1
-          CALL internal_message( 'error', routine_name // &
-                                 ': trying to define a NetCDF file in serial mode by an MPI ' // &
-                                 'rank other than the master output rank. Serial NetCDF ' // &
+          CALL internal_message( 'error', routine_name //                                          &
+                                 ': trying to define a NetCDF file in serial mode by an MPI ' //   &
+                                 'rank other than the master output rank. Serial NetCDF ' //       &
                                  'files can only be defined by the master output rank!' )
        ENDIF
@@ -212,12 +214,11 @@
 
        IF ( return_value == 0 )  &
-          nc_stat = NF90_CREATE( TRIM( file_name ) // TRIM( file_suffix ), &
-                                 IOR( NF90_NOCLOBBER, NF90_NETCDF4 ),      &
-                                 file_id )
+          nc_stat = NF90_CREATE( TRIM( file_name ) // TRIM( file_suffix ),                         &
+                                 IOR( NF90_NOCLOBBER, NF90_NETCDF4 ), file_id )
 #else
        nc_stat = 0
        return_value = 1
-       CALL internal_message( 'error', routine_name //                               &
-                              ': pre-processor directive "__netcdf4" not given. ' // &
+       CALL internal_message( 'error', routine_name //                                             &
+                              ': pre-processor directive "__netcdf4" not given. ' //               &
                               'Using NetCDF4 output not possible' )
 #endif
@@ -226,13 +227,13 @@
 
 #if defined( __parallel ) && defined( __netcdf4 ) && defined( __netcdf4_parallel )
-       nc_stat = NF90_CREATE( TRIM( file_name ) // TRIM( file_suffix ),               &
-                              IOR( NF90_NOCLOBBER, IOR( NF90_NETCDF4, NF90_MPIIO ) ), &
+       nc_stat = NF90_CREATE( TRIM( file_name ) // TRIM( file_suffix ),                            &
+                              IOR( NF90_NOCLOBBER, IOR( NF90_NETCDF4, NF90_MPIIO ) ),              &
                               file_id, COMM = output_group_comm, INFO = MPI_INFO_NULL )
 #else
        nc_stat = 0
        return_value = 1
-       CALL internal_message( 'error', routine_name //                                 &
-                              ': pre-processor directives "__parallel" and/or ' //     &
-                              '"__netcdf4" and/or "__netcdf4_parallel" not given. ' // &
+       CALL internal_message( 'error', routine_name //                                             &
+                              ': pre-processor directives "__parallel" and/or ' //                 &
+                              '"__netcdf4" and/or "__netcdf4_parallel" not given. ' //             &
                               'Using parallel NetCDF4 output not possible' )
 #endif
@@ -241,6 +242,6 @@
        nc_stat = 0
        return_value = 1
-       CALL internal_message( 'error', routine_name // ': selected mode "' //  &
-                                       TRIM( mode ) // '" must be either "' // &
+       CALL internal_message( 'error', routine_name // ': selected mode "' //                      &
+                                       TRIM( mode ) // '" must be either "' //                     &
                                        mode_serial // '" or "' // mode_parallel // '"' )
     ENDIF
@@ -249,6 +250,6 @@
     IF ( nc_stat /= NF90_NOERR  .AND.  return_value == 0 )  THEN
        return_value = 1
-       CALL internal_message( 'error', routine_name //                 &
-                              ': NetCDF error while opening file "' // &
+       CALL internal_message( 'error', routine_name //                                             &
+                              ': NetCDF error while opening file "' //                             &
                               TRIM( file_name ) // '": ' // NF90_STRERROR( nc_stat ) )
     ENDIF
@@ -262,12 +263,12 @@
 !> Write attribute to netcdf file.
 !--------------------------------------------------------------------------------------------------!
- SUBROUTINE netcdf4_write_attribute( file_id, variable_id, attribute_name, &
-                  value_char, value_int8, value_int16, value_int32,        &
-                  value_real32, value_real64, return_value )
+ SUBROUTINE netcdf4_write_attribute( file_id, variable_id, attribute_name,                         &
+                                     value_char, value_int8, value_int16, value_int32,             &
+                                     value_real32, value_real64, return_value )
+
+    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'netcdf4_write_attribute'  !< name of this routine
 
     CHARACTER(LEN=*), INTENT(IN)           ::  attribute_name  !< name of attribute
     CHARACTER(LEN=*), INTENT(IN), OPTIONAL ::  value_char      !< value of attribute
-
-    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'netcdf4_write_attribute'  !< name of this routine
 
     INTEGER ::  nc_stat    !< netcdf return value
@@ -295,5 +296,5 @@
     ENDIF
 
-    CALL internal_message( 'debug', routine_name // &
+    CALL internal_message( 'debug', routine_name //                                                &
                            ': write attribute "' // TRIM( attribute_name ) // '"' )
 
@@ -312,5 +313,5 @@
     ELSE
        return_value = 1
-       CALL internal_message( 'error', routine_name // &
+       CALL internal_message( 'error', routine_name //                                             &
                               ': no value given for attribute "' // TRIM( attribute_name ) // '"' )
     ENDIF
@@ -319,6 +320,6 @@
        IF ( nc_stat /= NF90_NOERR )  THEN
           return_value = 1
-          CALL internal_message( 'error', routine_name //                      &
-                                 ': NetCDF error while writing attribute "' // &
+          CALL internal_message( 'error', routine_name //                                          &
+                                 ': NetCDF error while writing attribute "' //                     &
                                  TRIM( attribute_name ) // '": ' // NF90_STRERROR( nc_stat ) )
        ENDIF
@@ -337,10 +338,10 @@
  SUBROUTINE netcdf4_init_dimension( mode, file_id, dimension_id, variable_id, &
                dimension_name, dimension_type, dimension_length, return_value )
+
+    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'netcdf4_init_dimension'  !< name of this routine
 
     CHARACTER(LEN=*), INTENT(IN) ::  dimension_name  !< name of dimension
     CHARACTER(LEN=*), INTENT(IN) ::  dimension_type  !< data type of dimension
     CHARACTER(LEN=*), INTENT(IN) ::  mode            !< operation mode (either parallel or serial)
-
-    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'netcdf4_init_dimension'  !< name of this routine
 
     INTEGER, INTENT(OUT) ::  dimension_id         !< dimension ID
@@ -357,5 +358,5 @@
     variable_id = -1
 
-    CALL internal_message( 'debug', routine_name // &
+    CALL internal_message( 'debug', routine_name //                                                &
                            ': init dimension "' // TRIM( dimension_name ) // '"' )
 !
@@ -378,6 +379,6 @@
     ELSE
        return_value = 1
-       CALL internal_message( 'error', routine_name //                           &
-                              ': NetCDF error while initializing dimension "' // &
+       CALL internal_message( 'error', routine_name //                                             &
+                              ': NetCDF error while initializing dimension "' //                   &
                               TRIM( dimension_name ) // '": ' // NF90_STRERROR( nc_stat ) )
     ENDIF
@@ -395,12 +396,12 @@
 !> Initialize variable.
 !--------------------------------------------------------------------------------------------------!
- SUBROUTINE netcdf4_init_variable( mode, file_id, variable_id, variable_name, variable_type, &
+ SUBROUTINE netcdf4_init_variable( mode, file_id, variable_id, variable_name, variable_type,       &
                                    dimension_ids, is_global, return_value )
+
+    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'netcdf4_init_variable'  !< name of this routine
 
     CHARACTER(LEN=*), INTENT(IN) ::  mode           !< operation mode (either parallel or serial)
     CHARACTER(LEN=*), INTENT(IN) ::  variable_name  !< name of variable
     CHARACTER(LEN=*), INTENT(IN) ::  variable_type  !< data type of variable
-
-    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'netcdf4_init_variable'  !< name of this routine
 
     INTEGER, INTENT(IN)  ::  file_id           !< file ID
@@ -419,6 +420,6 @@
 
     WRITE( temp_string, * ) is_global
-    CALL internal_message( 'debug', routine_name //                        &
-                           ': init variable "' // TRIM( variable_name ) // &
+    CALL internal_message( 'debug', routine_name //                                                &
+                           ': init variable "' // TRIM( variable_name ) //                         &
                            '" ( is_global = ' // TRIM( temp_string ) // ')' )
 
@@ -446,6 +447,6 @@
        IF ( nc_stat /= NF90_NOERR )  THEN
           return_value = 1
-          CALL internal_message( 'error', routine_name //                          &
-                                 ': NetCDF error while initializing variable "' // &
+          CALL internal_message( 'error', routine_name //                                          &
+                                 ': NetCDF error while initializing variable "' //                 &
                                  TRIM( variable_name ) // '": ' // NF90_STRERROR( nc_stat ) )
        ENDIF
@@ -507,15 +508,15 @@
 !> Write variable of different kind into netcdf file.
 !--------------------------------------------------------------------------------------------------!
- SUBROUTINE netcdf4_write_variable(                                                    &
-               file_id, variable_id, bounds_start, value_counts, bounds_origin,        &
-               is_global,                                                              &
-               values_char_0d,   values_char_1d,   values_char_2d,   values_char_3d,   &
-               values_int8_0d,   values_int8_1d,   values_int8_2d,   values_int8_3d,   &
-               values_int16_0d,  values_int16_1d,  values_int16_2d,  values_int16_3d,  &
-               values_int32_0d,  values_int32_1d,  values_int32_2d,  values_int32_3d,  &
-               values_intwp_0d,  values_intwp_1d,  values_intwp_2d,  values_intwp_3d,  &
-               values_real32_0d, values_real32_1d, values_real32_2d, values_real32_3d, &
-               values_real64_0d, values_real64_1d, values_real64_2d, values_real64_3d, &
-               values_realwp_0d, values_realwp_1d, values_realwp_2d, values_realwp_3d, &
+ SUBROUTINE netcdf4_write_variable(                                                                &
+               file_id, variable_id, bounds_start, value_counts, bounds_origin,                    &
+               is_global,                                                                          &
+               values_char_0d,   values_char_1d,   values_char_2d,   values_char_3d,               &
+               values_int8_0d,   values_int8_1d,   values_int8_2d,   values_int8_3d,               &
+               values_int16_0d,  values_int16_1d,  values_int16_2d,  values_int16_3d,              &
+               values_int32_0d,  values_int32_1d,  values_int32_2d,  values_int32_3d,              &
+               values_intwp_0d,  values_intwp_1d,  values_intwp_2d,  values_intwp_3d,              &
+               values_real32_0d, values_real32_1d, values_real32_2d, values_real32_3d,             &
+               values_real64_0d, values_real64_1d, values_real64_2d, values_real64_3d,             &
+               values_realwp_0d, values_realwp_1d, values_realwp_2d, values_realwp_3d,             &
                return_value )
 
@@ -586,5 +587,5 @@
 #endif
 
-    IF ( return_value == 0  .AND.  ( .NOT. is_global  .OR.  my_rank == master_rank ) )  THEN
+    IF ( return_value == 0  .AND.  ( .NOT. is_global .OR. my_rank == master_rank ) )  THEN
 
        WRITE( temp_string, * ) variable_id
@@ -596,144 +597,144 @@
 !--    character output
        IF ( PRESENT( values_char_0d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_char_0d /), &
-                                  start = bounds_start - bounds_origin + 1,   &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_char_0d /),                      &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_char_1d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_char_1d,     &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_char_1d,                            &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_char_2d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_char_2d,     &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_char_2d,                            &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_char_3d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_char_3d,     &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_char_3d,                            &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
 !
 !--    8bit integer output
        ELSEIF ( PRESENT( values_int8_0d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_int8_0d /), &
-                                  start = bounds_start - bounds_origin + 1,   &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_int8_0d /),                      &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_int8_1d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int8_1d,     &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int8_1d,                            &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_int8_2d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int8_2d,     &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int8_2d,                            &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_int8_3d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int8_3d,     &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int8_3d,                            &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
 !
 !--    16bit integer output
        ELSEIF ( PRESENT( values_int16_0d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_int16_0d /), &
-                                  start = bounds_start - bounds_origin + 1,    &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_int16_0d /),                     &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_int16_1d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int16_1d,    &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int16_1d,                           &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_int16_2d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int16_2d,    &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int16_2d,                           &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_int16_3d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int16_3d,    &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int16_3d,                           &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
 !
 !--    32bit integer output
        ELSEIF ( PRESENT( values_int32_0d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_int32_0d /),  &
-                                  start = bounds_start - bounds_origin + 1,     &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_int32_0d /),                     &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_int32_1d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int32_1d,    &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int32_1d,                           &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_int32_2d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int32_2d,    &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int32_2d,                           &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_int32_3d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int32_3d,    &
-                                  start = bounds_start - bounds_origin + 1, &
-                                  count = value_counts )
-!
-!--    working-precision integer output
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_int32_3d,                           &
+                                  start = bounds_start - bounds_origin + 1,                        &
+                                  count = value_counts )
+!
+!--    Working-precision integer output
        ELSEIF ( PRESENT( values_intwp_0d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_intwp_0d /),  &
-                                  start = bounds_start - bounds_origin + 1,     &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_intwp_0d /),                     &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_intwp_1d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_intwp_1d,    &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_intwp_1d,                           &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_intwp_2d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_intwp_2d,    &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_intwp_2d,                           &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_intwp_3d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_intwp_3d,    &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_intwp_3d,                           &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
 !
 !--    32bit real output
        ELSEIF ( PRESENT( values_real32_0d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_real32_0d /), &
-                                  start = bounds_start - bounds_origin + 1,     &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_real32_0d /),                    &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_real32_1d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real32_1d,   &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real32_1d,                          &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_real32_2d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real32_2d,   &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real32_2d,                          &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_real32_3d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real32_3d,   &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real32_3d,                          &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
 !
 !--    64bit real output
        ELSEIF ( PRESENT( values_real64_0d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_real64_0d /), &
-                                  start = bounds_start - bounds_origin + 1,     &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_real64_0d /),                    &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_real64_1d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real64_1d,   &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real64_1d,                          &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_real64_2d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real64_2d,   &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real64_2d,                          &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_real64_3d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real64_3d,   &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_real64_3d,                          &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
 !
 !--    working-precision real output
        ELSEIF ( PRESENT( values_realwp_0d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_realwp_0d /), &
-                                  start = bounds_start - bounds_origin + 1,     &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, (/ values_realwp_0d /),                    &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_realwp_1d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_realwp_1d,   &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_realwp_1d,                          &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_realwp_2d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_realwp_2d,   &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_realwp_2d,                          &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSEIF ( PRESENT( values_realwp_3d ) )  THEN
-          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_realwp_3d,   &
-                                  start = bounds_start - bounds_origin + 1, &
+          nc_stat = NF90_PUT_VAR( file_id, variable_id, values_realwp_3d,                          &
+                                  start = bounds_start - bounds_origin + 1,                        &
                                   count = value_counts )
        ELSE
@@ -741,5 +742,5 @@
           nc_stat = NF90_NOERR
           WRITE( temp_string, '(": variable_id=",I6,", file_id=",I6)' ) variable_id, file_id
-          CALL internal_message( 'error', routine_name // &
+          CALL internal_message( 'error', routine_name //                                          &
                                  ': no output values given ' // TRIM( temp_string ) )
        ENDIF
@@ -761,5 +762,5 @@
              d = 1
              DO WHILE ( d <= ndims .AND. nc_stat == NF90_NOERR )
-                nc_stat = NF90_INQUIRE_DIMENSION( file_id, dimension_ids(d), &
+                nc_stat = NF90_INQUIRE_DIMENSION( file_id, dimension_ids(d),                       &
                                                   LEN=dimension_lengths(d) )
                 d = d + 1
@@ -767,13 +768,13 @@
 
              IF ( nc_stat == NF90_NOERR )  THEN
-                WRITE( temp_string, * )  TRIM( temp_string ) // '; given variable bounds: ' //  &
+                WRITE( temp_string, * )  TRIM( temp_string ) // '; given variable bounds: ' //     &
                    'start=', bounds_start, ', count=', value_counts, ', origin=', bounds_origin
-                CALL internal_message( 'error', routine_name //     &
+                CALL internal_message( 'error', routine_name //                                    &
                                        ': error while writing: ' // TRIM( temp_string ) )
              ELSE
 !
 !--             Error occured during NF90_INQUIRE_VARIABLE or NF90_INQUIRE_DIMENSION
-                CALL internal_message( 'error', routine_name //            &
-                                       ': error while accessing file: ' // &
+                CALL internal_message( 'error', routine_name //                                    &
+                                       ': error while accessing file: ' //                         &
                                         NF90_STRERROR( nc_stat ) )
              ENDIF
@@ -782,5 +783,5 @@
 !
 !--          Other NetCDF error
-             CALL internal_message( 'error', routine_name //     &
+             CALL internal_message( 'error', routine_name //                                       &
                                     ': error while writing: ' // NF90_STRERROR( nc_stat ) )
           ENDIF
@@ -810,5 +811,5 @@
 #if defined( __netcdf4 )
     WRITE( temp_string, * ) file_id
-    CALL internal_message( 'debug', routine_name // &
+    CALL internal_message( 'debug', routine_name //                                                &
                            ': close file (file_id=' // TRIM( temp_string ) // ')' )
 
@@ -818,5 +819,5 @@
     ELSE
        return_value = 1
-       CALL internal_message( 'error', routine_name // &
+       CALL internal_message( 'error', routine_name //                                             &
                               ': NetCDF error: ' // NF90_STRERROR( nc_stat ) )
     ENDIF
@@ -834,7 +835,7 @@
  FUNCTION get_netcdf_data_type( data_type ) RESULT( return_value )
 
+    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'get_netcdf_data_type'  !< name of this routine
+
     CHARACTER(LEN=*), INTENT(IN) ::  data_type  !< requested data type
-
-    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'get_netcdf_data_type'  !< name of this routine
 
     INTEGER ::  return_value  !< netcdf data type
@@ -864,5 +865,5 @@
 
        CASE DEFAULT
-          CALL internal_message( 'error', routine_name // &
+          CALL internal_message( 'error', routine_name //                                          &
                                  ': data type unknown (' // TRIM( data_type ) // ')' )
           return_value = -1
@@ -875,6 +876,6 @@
 ! Description:
 ! ------------
-!> Message routine writing debug information into the debug file
-!> or creating the error message string.
+!> Message routine writing debug information into the debug file or creating the error message
+!> string.
 !--------------------------------------------------------------------------------------------------!
  SUBROUTINE internal_message( level, string )
