Index: palm/trunk/UTIL/binary_to_netcdf.f90
===================================================================
--- palm/trunk/UTIL/binary_to_netcdf.f90	(revision 4123)
+++ palm/trunk/UTIL/binary_to_netcdf.f90	(revision 4141)
@@ -49,6 +49,6 @@
 
    !-- Set kinds to be used as defaults
-   INTEGER, PARAMETER ::   wp = 8  !< default real kind
-   INTEGER, PARAMETER ::  iwp = 4  !< default integer kind
+   INTEGER, PARAMETER ::  iwp = 4  !< default integer kind for output-variable values
+   INTEGER, PARAMETER ::  wp  = 8  !< default real kind for output-variable values
 
    INTEGER, PARAMETER ::  charlen_internal = 1000  !< length of strings within this program
@@ -59,5 +59,5 @@
       CHARACTER(LEN=charlen_internal) ::  name          !< name of attribute
       CHARACTER(LEN=charlen_internal) ::  value_char    !< character value
-      INTEGER(iwp)                    ::  var_id        !< id of variable to which the attribute belongs to
+      INTEGER                         ::  variable_id   !< id of variable to which the attribute belongs to
       INTEGER(KIND=1)                 ::  value_int8    !< 8bit integer value
       INTEGER(KIND=2)                 ::  value_int16   !< 16bit integer value
@@ -70,13 +70,13 @@
       CHARACTER(LEN=charlen_internal) ::  data_type  !< data type of dimension
       CHARACTER(LEN=charlen_internal) ::  name       !< dimension name
-      INTEGER(iwp)                    ::  id         !< dimension id within file
-      INTEGER(iwp)                    ::  length     !< length of dimension
+      INTEGER                         ::  id         !< dimension id within file
+      INTEGER                         ::  length     !< length of dimension
    END TYPE dimension_type
 
    TYPE variable_type
-      CHARACTER(LEN=charlen_internal) ::  data_type  !< data type of variable
-      CHARACTER(LEN=charlen_internal) ::  name       !< variable name
-      INTEGER(iwp)                    ::  id         !< variable id within file
-      INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  dimension_ids  !< list of dimension ids used by variable
+      CHARACTER(LEN=charlen_internal)    ::  data_type      !< data type of variable
+      CHARACTER(LEN=charlen_internal)    ::  name           !< variable name
+      INTEGER                            ::  id             !< variable id within file
+      INTEGER, DIMENSION(:), ALLOCATABLE ::  dimension_ids  !< list of dimension ids used by variable
    END TYPE variable_type
 
@@ -92,20 +92,20 @@
       config_file_list_name = 'BINARY_CONFIG_LIST'  !< file containing list of binary config files of each output group
 
-   INTEGER(iwp) ::  charlen            !< length of characters (strings) in binary file
-   INTEGER(iwp) ::  dom_global_id      !< global ID within a single file defined by DOM
-   INTEGER      ::  dom_master_rank    !< master MPI rank in DOM (rank which wrote additional information in DOM)
-   INTEGER      ::  dom_nrank          !< number of MPI ranks used by DOM
-   INTEGER(iwp) ::  file_index         !< loop index to loop over files
-   INTEGER      ::  group              !< loop index to loop over groups
-   INTEGER(iwp) ::  nc_file_id         !< ID of netcdf output file
-   INTEGER(iwp) ::  nfiles             !< number of output files defined in config file
-   INTEGER      ::  ngroup             !< number of output-file groups
-   INTEGER      ::  return_value       !< return value
-   INTEGER      ::  your_return_value  !< returned value of called routine
+   INTEGER ::  charlen            !< length of characters (strings) in binary file
+   INTEGER ::  dom_global_id      !< global ID within a single file defined by DOM
+   INTEGER ::  dom_master_rank    !< master MPI rank in DOM (rank which wrote additional information in DOM)
+   INTEGER ::  dom_nranks         !< number of MPI ranks used by DOM
+   INTEGER ::  file_index         !< loop index to loop over files
+   INTEGER ::  group              !< loop index to loop over groups
+   INTEGER ::  nc_file_id         !< ID of netcdf output file
+   INTEGER ::  nfiles             !< number of output files defined in config file
+   INTEGER ::  ngroups            !< number of output-file groups
+   INTEGER ::  return_value       !< return value
+   INTEGER ::  your_return_value  !< returned value of called routine
 
    INTEGER(KIND=1) ::  dummy_int8   !< dummy variable used for reading
    INTEGER(KIND=2) ::  dummy_int16  !< dummy variable used for reading
    INTEGER(KIND=4) ::  dummy_int32  !< dummy variable used for reading
-   INTEGER(iwp)    ::  dummy_intwp  !< dummy variable used for reading
+   INTEGER         ::  dummy_int    !< dummy variable used for reading
 
    INTEGER, PARAMETER ::  bin_file_unit = 12          !< Fortran unit of binary file
@@ -113,9 +113,9 @@
    INTEGER, PARAMETER ::  config_file_list_unit = 10  !< Fortran unit of file containing config-file list
 
-   INTEGER, DIMENSION(:), ALLOCATABLE ::  dim_id_netcdf  !< mapped dimension id within NetCDF file:
-                                                         !> dimension_list(i)%id and dim_id_netcdf(dimension_list(i)%id)
+   INTEGER, DIMENSION(:), ALLOCATABLE ::  dimension_id_netcdf  !< mapped dimension id within NetCDF file:
+                                                         !> dimension_list(i)%id and dimension_id_netcdf(dimension_list(i)%id)
                                                          !> reference the same dimension
-   INTEGER, DIMENSION(:), ALLOCATABLE ::  var_id_netcdf  !< mapped variable id within NetCDF file:
-                                                         !> variable_list(i)%id and var_id_netcdf(variable_list(i)%id)
+   INTEGER, DIMENSION(:), ALLOCATABLE ::  variable_id_netcdf  !< mapped variable id within NetCDF file:
+                                                         !> variable_list(i)%id and variable_id_netcdf(variable_list(i)%id)
                                                          !> reference the same variable
 
@@ -139,5 +139,5 @@
 
       !-- Go through each group of output files (all marked by same file suffix)
-      DO  group = 1, ngroup
+      DO  group = 1, ngroups
 
          CALL internal_message( 'info', 'Start converting ' // TRIM( group_names(group) ) // &
@@ -160,5 +160,6 @@
 
                IF ( your_return_value == 0 )  THEN
-                  CALL convert_data_to_netcdf( TRIM( filename_list(file_index) ), your_return_value )
+                  CALL convert_data_to_netcdf( TRIM( filename_list(file_index) ), &
+                                               your_return_value )
                ELSE
                   return_value = your_return_value
@@ -228,17 +229,17 @@
 
       !-- Count the configuration files
-      ngroup = 0
+      ngroups = 0
       DO WHILE ( io_stat == 0 )
          READ( config_file_list_unit, '(A)', IOSTAT=io_stat )  file_name
-         IF ( io_stat == 0 )  ngroup = ngroup + 1
+         IF ( io_stat == 0 )  ngroups = ngroups + 1
       ENDDO
       REWIND( config_file_list_unit )
 
-      IF ( ngroup /= 0 )  THEN
-
-         ALLOCATE( group_names(ngroup) )
+      IF ( ngroups /= 0 )  THEN
+
+         ALLOCATE( group_names(ngroups) )
 
          !-- Extract the group names
-         DO  i = 1, ngroup
+         DO  i = 1, ngroups
             READ( config_file_list_unit, '(A)', IOSTAT=io_stat )  file_name
             IF ( INDEX( TRIM( file_name ), config_file_name_base ) == 1 )  THEN
@@ -284,5 +285,5 @@
    CHARACTER(LEN=charlen_internal), DIMENSION(:), ALLOCATABLE ::  filename_list_tmp  !< temporary list of file names
 
-   INTEGER(iwp)         ::  filename_prefix_length  !< length of string containing the filname prefix
+   INTEGER              ::  filename_prefix_length  !< length of string containing the filname prefix
    INTEGER              ::  io_stat                 !< status of Fortran I/O operations
    INTEGER, INTENT(OUT) ::  return_value            !< return value of routine
@@ -298,15 +299,15 @@
    IF ( io_stat /= 0 )  THEN
       return_value = 1
-      CALL internal_message( 'error', &
-              routine_name // ': error while opening configuration file "' // &
-              TRIM( config_file_name ) // '"' )
+      CALL internal_message( 'error', routine_name // &
+                             ': error while opening configuration file "' // &
+                             TRIM( config_file_name ) // '"' )
    ENDIF
 
    IF ( return_value == 0 )  THEN
 
-      READ( config_file_unit ) dom_nrank
-
-      IF ( dom_nrank > 1000000 )  THEN
-         dom_nrank = 1000000
+      READ( config_file_unit ) dom_nranks
+
+      IF ( dom_nranks > 1000000 )  THEN
+         dom_nranks = 1000000
          CALL internal_message( 'info', routine_name // &
                  ': number of MPI ranks used in PALM is greater than the maximum ' // &
@@ -357,5 +358,5 @@
             return_value = 1
             CALL internal_message( 'error', routine_name // &
-                                            ': error while reading file names from config' )
+                                   ': error while reading file names from config' )
             EXIT
          ENDIF
@@ -377,5 +378,5 @@
 
    CHARACTER(LEN=2*charlen)             ::  bin_filename       !< name of binary file which to read
-   CHARACTER(LEN=*        ), INTENT(IN) ::  bin_filename_body  !< body of binary filename which to read
+   CHARACTER(LEN=*),         INTENT(IN) ::  bin_filename_body  !< body of binary filename which to read
    CHARACTER(LEN=charlen  )             ::  read_string        !< string read from file
 
@@ -387,5 +388,5 @@
    INTEGER              ::  n_dimensions       !< number of dimensions in file
    INTEGER              ::  n_variables        !< number of variables in file
-   INTEGER(iwp)         ::  var_ndim           !< number of dimensions of a variable
+   INTEGER              ::  variable_ndims     !< number of dimensions of a variable
    INTEGER, INTENT(OUT) ::  return_value       !< return value
 
@@ -408,7 +409,7 @@
    IF ( io_stat == 0 )  THEN
 
-      READ( bin_file_unit ) dummy_intwp
-      READ( bin_file_unit ) dummy_intwp
-      READ( bin_file_unit ) read_string
+      READ( bin_file_unit ) dummy_int    ! charlen
+      READ( bin_file_unit ) dummy_int    ! file_id
+      READ( bin_file_unit ) read_string  ! filename
 
    ELSE
@@ -475,7 +476,8 @@
             READ( bin_file_unit ) read_string
             variable_list(n_variables)%data_type = read_string
-            READ( bin_file_unit ) var_ndim
-            ALLOCATE( variable_list(n_variables)%dimension_ids(1:var_ndim) )
-            READ( bin_file_unit )  ( variable_list(n_variables)%dimension_ids(i), i = 1, var_ndim )
+            READ( bin_file_unit ) variable_ndims
+            ALLOCATE( variable_list(n_variables)%dimension_ids(1:variable_ndims) )
+            READ( bin_file_unit ) &
+               ( variable_list(n_variables)%dimension_ids(i), i = 1, variable_ndims )
 
          CASE ( 'attribute' )
@@ -496,5 +498,5 @@
 
             !-- Read attribute
-            READ( bin_file_unit ) attribute_list(n_attributes)%var_id
+            READ( bin_file_unit ) attribute_list(n_attributes)%variable_id
             READ( bin_file_unit ) read_string
             attribute_list(n_attributes)%name = read_string
@@ -559,12 +561,12 @@
    CHARACTER(LEN=*), PARAMETER  ::  routine_name = 'define_netcdf_files'  !< routine name
 
-   INTEGER              ::  i              !< loop index
-   INTEGER              ::  j              !< loop index
-   INTEGER              ::  nc_data_type   !< netcdf data type of output variable
-   INTEGER              ::  nc_dim_length  !< length of dimension in netcdf file
-   INTEGER              ::  nc_stat        !< return value of Netcdf calls
-   INTEGER, INTENT(OUT) ::  return_value   !< return value
-
-   INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  var_dim_id  !< list of dimension ids of a variable
+   INTEGER              ::  i                    !< loop index
+   INTEGER              ::  j                    !< loop index
+   INTEGER              ::  nc_data_type         !< netcdf data type of output variable
+   INTEGER              ::  nc_dimension_length  !< length of dimension in netcdf file
+   INTEGER              ::  nc_stat              !< return value of Netcdf calls
+   INTEGER, INTENT(OUT) ::  return_value         !< return value
+
+   INTEGER, DIMENSION(:), ALLOCATABLE ::  dimension_ids  !< list of dimension ids of a variable
 
 
@@ -581,16 +583,16 @@
 
       !-- Define dimensions in NetCDF file
-      ALLOCATE( dim_id_netcdf(1:MAXVAL(dimension_list(:)%id)) )
+      ALLOCATE( dimension_id_netcdf(1:MAXVAL(dimension_list(:)%id)) )
 
       DO  i = 1, SIZE( dimension_list )
 
          IF ( dimension_list(i)%length < 0 )  THEN
-            nc_dim_length = NF90_UNLIMITED
+            nc_dimension_length = NF90_UNLIMITED
          ELSE
-            nc_dim_length = dimension_list(i)%length
+            nc_dimension_length = dimension_list(i)%length
          ENDIF
 
-         nc_stat =  NF90_DEF_DIM( nc_file_id, dimension_list(i)%name, nc_dim_length, &
-                                  dim_id_netcdf(dimension_list(i)%id) )
+         nc_stat =  NF90_DEF_DIM( nc_file_id, dimension_list(i)%name, nc_dimension_length, &
+                                  dimension_id_netcdf(dimension_list(i)%id) )
 
          IF ( nc_stat /= NF90_NOERR )  THEN
@@ -609,11 +611,12 @@
 
       !-- Create vector to map variable IDs from binary file to those within netcdf file
-      ALLOCATE( var_id_netcdf(MIN( MINVAL(attribute_list(:)%var_id),   &
-                                   MINVAL(variable_list(:)%id) )     : &
-                              MAX( MAXVAL(attribute_list(:)%var_id),   &
-                                   MAXVAL(variable_list(:)%id) )     ) )
+      ALLOCATE( variable_id_netcdf(MIN( MINVAL( attribute_list(:)%variable_id ), &
+                                        MINVAL( variable_list(:)%id ) )          &
+                                   :                                             &
+                                   MAX( MAXVAL( attribute_list(:)%variable_id ), &
+                                        MAXVAL( variable_list(:)%id ) )     ) )
 
       !-- Map global id from binary file to that of the netcdf file
-      var_id_netcdf(dom_global_id) = NF90_GLOBAL
+      variable_id_netcdf(dom_global_id) = NF90_GLOBAL
 
       !-- Define variables in NetCDF file
@@ -651,14 +654,14 @@
          IF ( return_value == 0 )  THEN
 
-            ALLOCATE( var_dim_id(1:SIZE( variable_list(i)%dimension_ids )) )
+            ALLOCATE( dimension_ids(1:SIZE( variable_list(i)%dimension_ids )) )
 
             DO  j = 1, SIZE( variable_list(i)%dimension_ids )
 
-               var_dim_id(j) = dim_id_netcdf(variable_list(i)%dimension_ids(j))
+               dimension_ids(j) = dimension_id_netcdf(variable_list(i)%dimension_ids(j))
 
             ENDDO
 
             nc_stat =  NF90_DEF_VAR( nc_file_id, variable_list(i)%name, nc_data_type, &
-                                     var_dim_id, var_id_netcdf(variable_list(i)%id) )
+                                     dimension_ids, variable_id_netcdf(variable_list(i)%id) )
             IF ( nc_stat /= NF90_NOERR )  THEN
                return_value = 1
@@ -668,5 +671,5 @@
             ENDIF
 
-            DEALLOCATE( var_dim_id )
+            DEALLOCATE( dimension_ids )
 
          ENDIF
@@ -686,42 +689,42 @@
 
             CASE ( 'char' )
-               nc_stat = NF90_PUT_ATT( nc_file_id,                              &
-                                       var_id_netcdf(attribute_list(i)%var_id), &
-                                       TRIM(attribute_list(i)%name),            &
+               nc_stat = NF90_PUT_ATT( nc_file_id,                                        &
+                                       variable_id_netcdf(attribute_list(i)%variable_id), &
+                                       TRIM(attribute_list(i)%name),                      &
                                        TRIM(attribute_list(i)%value_char) )
 
             CASE ( 'int8' )
-               nc_stat = NF90_PUT_ATT( nc_file_id,                              &
-                                       var_id_netcdf(attribute_list(i)%var_id), &
-                                       TRIM(attribute_list(i)%name),            &
+               nc_stat = NF90_PUT_ATT( nc_file_id,                                        &
+                                       variable_id_netcdf(attribute_list(i)%variable_id), &
+                                       TRIM(attribute_list(i)%name),                      &
                                        attribute_list(i)%value_int8 )
 
             CASE ( 'int16' )
-               nc_stat = NF90_PUT_ATT( nc_file_id,                              &
-                                       var_id_netcdf(attribute_list(i)%var_id), &
-                                       TRIM(attribute_list(i)%name),            &
+               nc_stat = NF90_PUT_ATT( nc_file_id,                                        &
+                                       variable_id_netcdf(attribute_list(i)%variable_id), &
+                                       TRIM(attribute_list(i)%name),                      &
                                        attribute_list(i)%value_int16 )
 
             CASE ( 'int32' )
-               nc_stat = NF90_PUT_ATT( nc_file_id,                              &
-                                       var_id_netcdf(attribute_list(i)%var_id), &
-                                       TRIM(attribute_list(i)%name),            &
+               nc_stat = NF90_PUT_ATT( nc_file_id,                                        &
+                                       variable_id_netcdf(attribute_list(i)%variable_id), &
+                                       TRIM(attribute_list(i)%name),                      &
                                        attribute_list(i)%value_int32 )
 
             CASE ( 'real32' )
-               nc_stat = NF90_PUT_ATT( nc_file_id,                              &
-                                       var_id_netcdf(attribute_list(i)%var_id), &
-                                       TRIM(attribute_list(i)%name),            &
+               nc_stat = NF90_PUT_ATT( nc_file_id,                                        &
+                                       variable_id_netcdf(attribute_list(i)%variable_id), &
+                                       TRIM(attribute_list(i)%name),                      &
                                        attribute_list(i)%value_real32 )
 
             CASE ( 'real64' )
-               nc_stat = NF90_PUT_ATT( nc_file_id,                              &
-                                       var_id_netcdf(attribute_list(i)%var_id), &
-                                       TRIM(attribute_list(i)%name),            &
+               nc_stat = NF90_PUT_ATT( nc_file_id,                                        &
+                                       variable_id_netcdf(attribute_list(i)%variable_id), &
+                                       TRIM(attribute_list(i)%name),                      &
                                        attribute_list(i)%value_real64 )
 
             CASE DEFAULT
                return_value = 1
-               CALL internal_message( 'error', routine_name // &
+               CALL internal_message( 'error', routine_name //                   &
                        ': data type "' // TRIM( attribute_list(i)%data_type ) // &
                        '" of attribute "' // TRIM( attribute_list(i)%name ) //   &
@@ -733,6 +736,6 @@
          IF ( nc_stat /= NF90_NOERR )  THEN
             return_value = 1
-            CALL internal_message( 'error', routine_name // &
-                    ': attribute "' // TRIM( attribute_list(i)%name ) //   &
+            CALL internal_message( 'error', routine_name //              &
+                    ': attribute "' // TRIM( attribute_list(i)%name ) // &
                     '": NF90_PUT_ATT error: ' // TRIM( NF90_STRERROR( nc_stat ) ) )
             EXIT
@@ -750,5 +753,5 @@
       return_value = 1
       CALL internal_message( 'error', routine_name // &
-              ': NF90_ENDDEF error: ' // TRIM( NF90_STRERROR( nc_stat ) ) )
+                             ': NF90_ENDDEF error: ' // TRIM( NF90_STRERROR( nc_stat ) ) )
    ENDIF
 
@@ -772,14 +775,14 @@
    INTEGER              ::  i             !< loop file_index
    INTEGER              ::  io_stat       !< status of Fortran I/O operations
-   INTEGER              ::  pe_id         !< loop index for loop over PE files
-   INTEGER              ::  n_dim         !< number of dimensions of a variable
+   INTEGER              ::  rank          !< loop index for loop over rank files
+   INTEGER              ::  n_dimensions  !< number of dimensions of a variable
    INTEGER              ::  nc_stat       !< return value of Netcdf calls
    INTEGER, INTENT(OUT) ::  return_value  !< return value
-   INTEGER(iwp)         ::  var_id        !< variable id read from binary file
-
-   INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  start_positions           !< start position of data per dimension
-   INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  data_count_per_dimension  !< data count of variable per dimension
-   INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  bounds_start              !< lower bounds of variable
-   INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  bounds_origin             !< lower bounds of dimensions in output file
+   INTEGER              ::  variable_id   !< variable id read from binary file
+
+   INTEGER, DIMENSION(:), ALLOCATABLE ::  start_positions           !< start position of data per dimension
+   INTEGER, DIMENSION(:), ALLOCATABLE ::  data_count_per_dimension  !< data count of variable per dimension
+   INTEGER, DIMENSION(:), ALLOCATABLE ::  bounds_start              !< lower bounds of variable
+   INTEGER, DIMENSION(:), ALLOCATABLE ::  bounds_origin             !< lower bounds of dimensions in output file
 
    INTEGER(KIND=1), DIMENSION(:), ALLOCATABLE ::  values_int8   !< variable values
@@ -797,9 +800,9 @@
    return_value = 0
 
-   !-- Open binary files of every possible PE
-   DO  pe_id = 0, dom_nrank - 1
+   !-- Open binary files of every possible MPI rank
+   DO  rank = 0, dom_nranks - 1
 
       WRITE( bin_filename, '(A, I6.6)' ) &
-         TRIM( filename_prefix ) // TRIM( bin_filename_body ) // '_', pe_id
+         TRIM( filename_prefix ) // TRIM( bin_filename_body ) // '_', rank
 
       INQUIRE( FILE=bin_filename, EXIST=file_exists )
@@ -846,17 +849,17 @@
          DO WHILE ( io_stat == 0  .AND.  return_value == 0 )
 
-            READ( bin_file_unit, IOSTAT=io_stat ) var_id
+            READ( bin_file_unit, IOSTAT=io_stat ) variable_id
             IF ( io_stat < 0 )  EXIT  ! End-of-file
 
             DO  i = LBOUND( variable_list, DIM=1 ), UBOUND( variable_list, DIM=1 )
-               IF ( var_id == variable_list(i)%id )  THEN
-                  n_dim = SIZE( variable_list(i)%dimension_ids )
+               IF ( variable_id == variable_list(i)%id )  THEN
+                  n_dimensions = SIZE( variable_list(i)%dimension_ids )
                   variable_name = variable_list(i)%name
 
                   CALL internal_message( 'debug', routine_name // ': read variable "' // &
                                          TRIM( variable_name ) // '"' )
-                  WRITE( temp_string, * ) n_dim
+                  WRITE( temp_string, * ) n_dimensions
                   CALL internal_message( 'debug', routine_name // &
-                                         ':  n_dim = ' // TRIM( temp_string ) )
+                                         ':  n_dimensions = ' // TRIM( temp_string ) )
 
                   EXIT
@@ -864,12 +867,12 @@
             ENDDO
 
-            ALLOCATE( bounds_start(1:n_dim) )
-            ALLOCATE( bounds_origin(1:n_dim) )
-            ALLOCATE( start_positions(1:n_dim) )
-            ALLOCATE( data_count_per_dimension(1:n_dim) )
-
-            READ( bin_file_unit ) ( bounds_start(i), i = 1, n_dim )
-            READ( bin_file_unit ) ( data_count_per_dimension(i), i = 1, n_dim )
-            READ( bin_file_unit ) ( bounds_origin(i), i = 1, n_dim )
+            ALLOCATE( bounds_start(1:n_dimensions) )
+            ALLOCATE( bounds_origin(1:n_dimensions) )
+            ALLOCATE( start_positions(1:n_dimensions) )
+            ALLOCATE( data_count_per_dimension(1:n_dimensions) )
+
+            READ( bin_file_unit ) ( bounds_start(i), i = 1, n_dimensions )
+            READ( bin_file_unit ) ( data_count_per_dimension(i), i = 1, n_dimensions )
+            READ( bin_file_unit ) ( bounds_origin(i), i = 1, n_dimensions )
 
             WRITE( temp_string, * ) bounds_start
@@ -885,5 +888,5 @@
             data_count = 1
 
-            DO  i = 1, n_dim
+            DO  i = 1, n_dimensions
                data_count = data_count * data_count_per_dimension(i)
                start_positions(i) = bounds_start(i) - bounds_origin(i) + 1
@@ -900,5 +903,6 @@
                   READ( bin_file_unit ) ( values_int8(i), i = 1, data_count )
 
-                  nc_stat = NF90_PUT_VAR( nc_file_id, var_id_netcdf(var_id), values_int8, &
+                  nc_stat = NF90_PUT_VAR( nc_file_id, variable_id_netcdf(variable_id), &
+                               values_int8,                                            &
                                start = start_positions, count = data_count_per_dimension )
 
@@ -910,5 +914,6 @@
                   READ( bin_file_unit ) ( values_int16(i), i = 1, data_count )
 
-                  nc_stat = NF90_PUT_VAR( nc_file_id, var_id_netcdf(var_id), values_int16, &
+                  nc_stat = NF90_PUT_VAR( nc_file_id, variable_id_netcdf(variable_id), &
+                               values_int16,                                           &
                                start = start_positions, count = data_count_per_dimension )
 
@@ -920,5 +925,6 @@
                   READ( bin_file_unit ) ( values_int32(i), i = 1, data_count )
 
-                  nc_stat = NF90_PUT_VAR( nc_file_id, var_id_netcdf(var_id), values_int32, &
+                  nc_stat = NF90_PUT_VAR( nc_file_id, variable_id_netcdf(variable_id), &
+                               values_int32,                                           &
                                start = start_positions, count = data_count_per_dimension )
 
@@ -930,5 +936,6 @@
                   READ( bin_file_unit ) ( values_intwp(i), i = 1, data_count )
 
-                  nc_stat = NF90_PUT_VAR( nc_file_id, var_id_netcdf(var_id), values_intwp, &
+                  nc_stat = NF90_PUT_VAR( nc_file_id, variable_id_netcdf(variable_id), &
+                               values_intwp,                                          &
                                start = start_positions, count = data_count_per_dimension )
 
@@ -940,5 +947,6 @@
                   READ( bin_file_unit ) ( values_real32(i), i = 1, data_count )
 
-                  nc_stat = NF90_PUT_VAR( nc_file_id, var_id_netcdf(var_id), values_real32, &
+                  nc_stat = NF90_PUT_VAR( nc_file_id, variable_id_netcdf(variable_id), &
+                               values_real32,                                          &
                                start = start_positions, count = data_count_per_dimension )
 
@@ -950,5 +958,6 @@
                   READ( bin_file_unit ) ( values_real64(i), i = 1, data_count )
 
-                  nc_stat = NF90_PUT_VAR( nc_file_id, var_id_netcdf(var_id), values_real64, &
+                  nc_stat = NF90_PUT_VAR( nc_file_id, variable_id_netcdf(variable_id), &
+                               values_real64,                                          &
                                start = start_positions, count = data_count_per_dimension )
 
@@ -960,5 +969,6 @@
                   READ( bin_file_unit ) ( values_realwp(i), i = 1, data_count )
 
-                  nc_stat = NF90_PUT_VAR( nc_file_id, var_id_netcdf(var_id), values_realwp, &
+                  nc_stat = NF90_PUT_VAR( nc_file_id, variable_id_netcdf(variable_id), &
+                               values_realwp,                                          &
                                start = start_positions, count = data_count_per_dimension )
 
@@ -997,7 +1007,7 @@
 
    !-- Deallocate fields for next file
-   IF ( ALLOCATED( variable_list ) )  DEALLOCATE( variable_list )
-   IF ( ALLOCATED( dim_id_netcdf ) )  DEALLOCATE( dim_id_netcdf )
-   IF ( ALLOCATED( var_id_netcdf ) )  DEALLOCATE( var_id_netcdf )
+   IF ( ALLOCATED( variable_list       ) )  DEALLOCATE( variable_list )
+   IF ( ALLOCATED( dimension_id_netcdf ) )  DEALLOCATE( dimension_id_netcdf )
+   IF ( ALLOCATED( variable_id_netcdf  ) )  DEALLOCATE( variable_id_netcdf )
 
 END SUBROUTINE convert_data_to_netcdf
@@ -1010,6 +1020,6 @@
 SUBROUTINE internal_message( level, string )
 
-   CHARACTER(LEN=*), INTENT(IN) :: level  !< message importance level
-   CHARACTER(LEN=*), INTENT(IN) :: string !< message string
+   CHARACTER(LEN=*), INTENT(IN) :: level   !< message importance level
+   CHARACTER(LEN=*), INTENT(IN) :: string  !< message string
 
    IF ( TRIM( level ) == 'error' )  THEN
