Index: palm/trunk/SOURCE/data_output_binary_module.f90
===================================================================
--- palm/trunk/SOURCE/data_output_binary_module.f90	(revision 4123)
+++ palm/trunk/SOURCE/data_output_binary_module.f90	(revision 4141)
@@ -52,5 +52,5 @@
    IMPLICIT NONE
 
-   INTEGER(iwp), PARAMETER ::  charlen = 100_iwp  !< maximum length of character variables
+   INTEGER, PARAMETER ::  charlen = 100  !< maximum length of character variables
 
    CHARACTER(LEN=*), PARAMETER ::  config_file_name = 'BINARY_TO_NETCDF_CONFIG'  !< name of config file
@@ -62,13 +62,13 @@
    CHARACTER(LEN=800)          ::  temp_string                  !< dummy string
 
-   INTEGER(iwp) ::  binary_file_lowest_unit = 1000  !< lowest unit number of all binary files created by this module
-   INTEGER(iwp) ::  config_file_unit                !< unit number of config file
-   INTEGER(iwp) ::  debug_output_unit               !< Fortran Unit Number of the debug-output file
-   INTEGER(iwp) ::  global_id_in_file = -1          !< value of global ID within a file
-   INTEGER      ::  master_rank                     !< master rank for tasks to be executed by single PE only
-   INTEGER(iwp) ::  next_available_unit             !< next unit number available for new file
-   INTEGER      ::  output_group_comm               !< MPI communicator addressing all MPI ranks which participate in output
-
-   INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  files_highest_var_id  !< highest assigned ID of variable or dimension in a file
+   INTEGER ::  binary_file_lowest_unit = 1000  !< lowest unit number of all binary files created by this module
+   INTEGER ::  config_file_unit                !< unit number of config file
+   INTEGER ::  debug_output_unit               !< Fortran Unit Number of the debug-output file
+   INTEGER ::  global_id_in_file = -1          !< value of global ID within a file
+   INTEGER ::  master_rank                     !< master rank for tasks to be executed by single PE only
+   INTEGER ::  next_available_unit             !< next unit number available for new file
+   INTEGER ::  output_group_comm               !< MPI communicator addressing all MPI ranks which participate in output
+
+   INTEGER, DIMENSION(:), ALLOCATABLE ::  files_highest_variable_id  !< highest assigned ID of variable or dimension in a file
 
    LOGICAL ::  binary_open_file_first_call = .TRUE.  !< true if binary_open_file routine was not called yet
@@ -100,7 +100,7 @@
    END INTERFACE binary_write_attribute
 
-   INTERFACE binary_init_end
-      MODULE PROCEDURE binary_init_end
-   END INTERFACE binary_init_end
+   INTERFACE binary_stop_file_header_definition
+      MODULE PROCEDURE binary_stop_file_header_definition
+   END INTERFACE binary_stop_file_header_definition
 
    INTERFACE binary_write_variable
@@ -120,5 +120,5 @@
       binary_get_error_message, &
       binary_init_dimension, &
-      binary_init_end, &
+      binary_stop_file_header_definition, &
       binary_init_module, &
       binary_init_variable, &
@@ -143,8 +143,8 @@
                                                                  !> must be unique for each output group
 
-   INTEGER(iwp), INTENT(IN) ::  dom_global_id              !< global id within a file defined by DOM
-   INTEGER,      INTENT(IN) ::  master_output_rank         !< MPI rank executing tasks which must be executed by a single PE
-   INTEGER,      INTENT(IN) ::  mpi_comm_of_output_group   !< MPI communicator specifying the rank group participating in output
-   INTEGER(iwp), INTENT(IN) ::  program_debug_output_unit  !< file unit number for debug output
+   INTEGER, INTENT(IN) ::  dom_global_id              !< global id within a file defined by DOM
+   INTEGER, INTENT(IN) ::  master_output_rank         !< MPI rank executing tasks which must be executed by a single PE
+   INTEGER, INTENT(IN) ::  mpi_comm_of_output_group   !< MPI communicator specifying the rank group participating in output
+   INTEGER, INTENT(IN) ::  program_debug_output_unit  !< file unit number for debug output
 
    LOGICAL, INTENT(IN) ::  debug_output  !< if true, debug output is printed
@@ -167,8 +167,8 @@
 !> Open binary file.
 !--------------------------------------------------------------------------------------------------!
-SUBROUTINE binary_open_file( mode, filename, file_id, return_value )
+SUBROUTINE binary_open_file( mode, file_name, file_id, return_value )
 
    CHARACTER(LEN=charlen)             ::  bin_filename = ''  !< actual name of binary file
-   CHARACTER(LEN=charlen), INTENT(IN) ::  filename           !< name of file
+   CHARACTER(LEN=charlen), INTENT(IN) ::  file_name          !< name of file
    CHARACTER(LEN=7)                   ::  my_rank_char       !< string containing value of my_rank with leading zeros
    CHARACTER(LEN=*),       INTENT(IN) ::  mode               !< operation mode
@@ -176,10 +176,10 @@
    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'binary_open_file'  !< name of this routine
 
-   INTEGER(iwp), INTENT(OUT) ::  file_id       !< file ID
-   INTEGER                   ::  my_rank       !< MPI rank of local processor
-   INTEGER                   ::  nrank         !< number of MPI ranks participating in output
-   INTEGER(iwp), INTENT(OUT) ::  return_value  !< return value
-
-   INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  files_highest_var_id_tmp  !< temporary list of given variable IDs in file
+   INTEGER, INTENT(OUT) ::  file_id       !< file ID
+   INTEGER              ::  my_rank       !< MPI rank of local processor
+   INTEGER              ::  nranks        !< number of MPI ranks participating in output
+   INTEGER, INTENT(OUT) ::  return_value  !< return value
+
+   INTEGER, DIMENSION(:), ALLOCATABLE ::  files_highest_variable_id_tmp  !< temporary list of given variable IDs in file
 
    LOGICAL ::  file_exists  !< true if file to be opened already exists
@@ -189,5 +189,5 @@
 
 #if defined( __parallel )
-   CALL MPI_COMM_SIZE( output_group_comm, nrank, return_value )
+   CALL MPI_COMM_SIZE( output_group_comm, nranks, return_value )
    IF ( return_value == 0 )  CALL MPI_COMM_RANK( output_group_comm, my_rank, return_value )
    IF ( return_value == 0 )  THEN
@@ -197,5 +197,5 @@
    ENDIF
 #else
-   nrank = 1
+   nranks = 1
    my_rank = master_rank
    WRITE( my_rank_char, '("_",I6.6)' )  my_rank
@@ -237,5 +237,5 @@
 
             !-- Write some general information to config file
-            WRITE( config_file_unit )  nrank
+            WRITE( config_file_unit )  nranks
             WRITE( config_file_unit )  master_rank
             WRITE( config_file_unit )  LEN( file_prefix )
@@ -260,5 +260,5 @@
    IF ( return_value == 0 )  THEN
 
-      bin_filename = file_prefix // TRIM( filename ) // TRIM( file_suffix ) // my_rank_char
+      bin_filename = file_prefix // TRIM( file_name ) // TRIM( file_suffix ) // my_rank_char
 
       !-- Remove any pre-existing file
@@ -267,5 +267,5 @@
       IF ( file_exists )  THEN
          CALL internal_message( 'debug', routine_name // &
-                                         ': remove existing file ' // TRIM( bin_filename ) )
+                                ': remove existing file ' // TRIM( bin_filename ) )
          !> @note Fortran2008 feature 'EXECUTE_COMMAND_LINE' not yet supported by
          !>       PGI 18.10 compiler. Hence, non-standard 'SYSTEM' call must be used
@@ -282,7 +282,7 @@
       IF ( return_value == 0 )  THEN
 
-         !-- Add filename to config file
+         !-- Add file_name to config file
          IF ( my_rank == master_rank )  THEN
-            WRITE( config_file_unit )  filename
+            WRITE( config_file_unit )  file_name
          ENDIF
 
@@ -294,23 +294,23 @@
          WRITE ( file_id )  charlen
          WRITE ( file_id )  file_id
-         WRITE ( file_id )  filename
+         WRITE ( file_id )  file_name
 
          !-- Extend file-variable/dimension-ID list by 1 and set it to 0 for new file.
-         IF ( ALLOCATED( files_highest_var_id ) )  THEN
-            ALLOCATE( files_highest_var_id_tmp(SIZE( files_highest_var_id )) )
-            files_highest_var_id_tmp = files_highest_var_id
-            DEALLOCATE( files_highest_var_id )
-            ALLOCATE( files_highest_var_id(binary_file_lowest_unit+1:file_id) )
-            files_highest_var_id(:file_id-1) = files_highest_var_id_tmp
-            DEALLOCATE( files_highest_var_id_tmp )
+         IF ( ALLOCATED( files_highest_variable_id ) )  THEN
+            ALLOCATE( files_highest_variable_id_tmp(SIZE( files_highest_variable_id )) )
+            files_highest_variable_id_tmp = files_highest_variable_id
+            DEALLOCATE( files_highest_variable_id )
+            ALLOCATE( files_highest_variable_id(binary_file_lowest_unit+1:file_id) )
+            files_highest_variable_id(:file_id-1) = files_highest_variable_id_tmp
+            DEALLOCATE( files_highest_variable_id_tmp )
          ELSE
-            ALLOCATE( files_highest_var_id(binary_file_lowest_unit+1:file_id) )
+            ALLOCATE( files_highest_variable_id(binary_file_lowest_unit+1:file_id) )
          ENDIF
-         files_highest_var_id(file_id) = 0_iwp
+         files_highest_variable_id(file_id) = 0
 
       ELSE
          return_value = 1
          CALL internal_message( 'error', routine_name // &
-                                         ': could not open file "' // TRIM( filename ) // '"')
+                                ': could not open file "' // TRIM( file_name ) // '"')
       ENDIF
 
@@ -324,25 +324,25 @@
 !> Write attribute to file.
 !--------------------------------------------------------------------------------------------------!
-SUBROUTINE binary_write_attribute( file_id, var_id, att_name, att_value_char, &
-              att_value_int8, att_value_int16, att_value_int32,               &
-              att_value_real32, att_value_real64, return_value )
+SUBROUTINE binary_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 = 'binary_write_attribute'  !< name of this routine
 
-   CHARACTER(LEN=charlen), INTENT(IN)           ::  att_name        !< name of attribute
-   CHARACTER(LEN=charlen), INTENT(IN), OPTIONAL ::  att_value_char  !< value of attribute
-   CHARACTER(LEN=charlen)                       ::  att_type        !< data type of attribute
-   CHARACTER(LEN=charlen)                       ::  out_str         !< output string
-
-   INTEGER(KIND=1), INTENT(IN), OPTIONAL ::  att_value_int8   !< value of attribute
-   INTEGER(KIND=2), INTENT(IN), OPTIONAL ::  att_value_int16  !< value of attribute
-   INTEGER(KIND=4), INTENT(IN), OPTIONAL ::  att_value_int32  !< value of attribute
-
-   INTEGER(iwp), INTENT(IN)  ::  file_id       !< file ID
-   INTEGER(iwp), INTENT(IN)  ::  var_id        !< variable ID
-   INTEGER(iwp), INTENT(OUT) ::  return_value  !< return value
-
-   REAL(KIND=4), INTENT(IN), OPTIONAL ::  att_value_real32  !< value of attribute
-   REAL(KIND=8), INTENT(IN), OPTIONAL ::  att_value_real64  !< value of attribute
+   CHARACTER(LEN=charlen), INTENT(IN)           ::  attribute_name        !< name of attribute
+   CHARACTER(LEN=charlen), INTENT(IN), OPTIONAL ::  value_char  !< value of attribute
+   CHARACTER(LEN=charlen)                       ::  attribute_type        !< data type of attribute
+   CHARACTER(LEN=charlen)                       ::  output_string         !< output string
+
+   INTEGER(KIND=1), INTENT(IN), OPTIONAL ::  value_int8   !< value of attribute
+   INTEGER(KIND=2), INTENT(IN), OPTIONAL ::  value_int16  !< value of attribute
+   INTEGER(KIND=4), INTENT(IN), OPTIONAL ::  value_int32  !< value of attribute
+
+   INTEGER, INTENT(IN)  ::  file_id       !< file ID
+   INTEGER, INTENT(IN)  ::  variable_id   !< variable ID
+   INTEGER, INTENT(OUT) ::  return_value  !< return value
+
+   REAL(KIND=4), INTENT(IN), OPTIONAL ::  value_real32  !< value of attribute
+   REAL(KIND=8), INTENT(IN), OPTIONAL ::  value_real64  !< value of attribute
 
 
@@ -350,41 +350,41 @@
 
    CALL internal_message( 'debug', TRIM( routine_name ) // &
-                                   ': write attribute ' // TRIM( att_name ) )
+                          ': write attribute ' // TRIM( attribute_name ) )
 
    !-- Write attribute to file
-   out_str = 'attribute'
-   WRITE( file_id )  out_str
-
-   WRITE( file_id )  var_id
-   WRITE( file_id )  att_name
-
-   IF ( PRESENT( att_value_char ) )  THEN
-      att_type = 'char'
-      WRITE( file_id )  att_type
-      WRITE( file_id )  att_value_char
-   ELSEIF ( PRESENT( att_value_int8 ) )  THEN
-      att_type = 'int8'
-      WRITE( file_id )  att_type
-      WRITE( file_id )  att_value_int8
-   ELSEIF ( PRESENT( att_value_int16 ) )  THEN
-      att_type = 'int16'
-      WRITE( file_id )  att_type
-      WRITE( file_id )  att_value_int16
-   ELSEIF ( PRESENT( att_value_int32 ) )  THEN
-      att_type = 'int32'
-      WRITE( file_id )  att_type
-      WRITE( file_id )  att_value_int32
-   ELSEIF ( PRESENT( att_value_real32 ) )  THEN
-      att_type = 'real32'
-      WRITE( file_id )  att_type
-      WRITE( file_id )  att_value_real32
-   ELSEIF ( PRESENT( att_value_real64 ) )  THEN
-      att_type = 'real64'
-      WRITE( file_id )  att_type
-      WRITE( file_id )  att_value_real64
+   output_string = 'attribute'
+   WRITE( file_id )  output_string
+
+   WRITE( file_id )  variable_id
+   WRITE( file_id )  attribute_name
+
+   IF ( PRESENT( value_char ) )  THEN
+      attribute_type = 'char'
+      WRITE( file_id )  attribute_type
+      WRITE( file_id )  value_char
+   ELSEIF ( PRESENT( value_int8 ) )  THEN
+      attribute_type = 'int8'
+      WRITE( file_id )  attribute_type
+      WRITE( file_id )  value_int8
+   ELSEIF ( PRESENT( value_int16 ) )  THEN
+      attribute_type = 'int16'
+      WRITE( file_id )  attribute_type
+      WRITE( file_id )  value_int16
+   ELSEIF ( PRESENT( value_int32 ) )  THEN
+      attribute_type = 'int32'
+      WRITE( file_id )  attribute_type
+      WRITE( file_id )  value_int32
+   ELSEIF ( PRESENT( value_real32 ) )  THEN
+      attribute_type = 'real32'
+      WRITE( file_id )  attribute_type
+      WRITE( file_id )  value_real32
+   ELSEIF ( PRESENT( value_real64 ) )  THEN
+      attribute_type = 'real64'
+      WRITE( file_id )  attribute_type
+      WRITE( file_id )  value_real64
    ELSE
       return_value = 1
       CALL internal_message( 'error', TRIM( routine_name ) // &
-                             ': attribute "' // TRIM( att_name ) // '": no value given' )
+                             ': no value given for attribute "' // TRIM( attribute_name ) // '"' )
    ENDIF
 
@@ -394,27 +394,27 @@
 ! Description:
 ! ------------
-!> Initialize dimension. Write information in file header and save dimension
-!> values to be later written to file.
-!--------------------------------------------------------------------------------------------------!
-SUBROUTINE binary_init_dimension( mode, file_id, dim_id, var_id, &
-              dim_name, dim_type, dim_length, return_value )
-
-   CHARACTER(LEN=charlen), INTENT(IN) ::  dim_name  !< name of dimension
-   CHARACTER(LEN=charlen), INTENT(IN) ::  dim_type  !< data type of dimension
-   CHARACTER(LEN=charlen)             ::  out_str   !< output string
-   CHARACTER(LEN=*),       INTENT(IN) ::  mode      !< operation mode
+!> Initialize dimension. Write information in file header
+!> and save dimension values to be later written to file.
+!--------------------------------------------------------------------------------------------------!
+SUBROUTINE binary_init_dimension( mode, file_id, dimension_id, variable_id, &
+              dimension_name, dimension_type, dimension_length, return_value )
+
+   CHARACTER(LEN=charlen), INTENT(IN) ::  dimension_name  !< name of dimension
+   CHARACTER(LEN=charlen), INTENT(IN) ::  dimension_type  !< data type of dimension
+   CHARACTER(LEN=charlen)             ::  output_string   !< output string
+   CHARACTER(LEN=*),       INTENT(IN) ::  mode            !< operation mode
 
    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'binary_init_dimension'  !< name of this routine
 
-   INTEGER(iwp), INTENT(OUT) ::  dim_id        !< dimension ID
-   INTEGER(iwp), INTENT(IN)  ::  dim_length    !< length of dimension
-   INTEGER(iwp), INTENT(IN)  ::  file_id       !< file ID
-   INTEGER(iwp), INTENT(OUT) ::  return_value  !< return value
-   INTEGER(iwp), INTENT(OUT) ::  var_id        !< variable ID
+   INTEGER, INTENT(OUT) ::  dimension_id      !< dimension ID
+   INTEGER, INTENT(IN)  ::  dimension_length  !< length of dimension
+   INTEGER, INTENT(IN)  ::  file_id           !< file ID
+   INTEGER, INTENT(OUT) ::  return_value      !< return value
+   INTEGER, INTENT(OUT) ::  variable_id       !< variable ID
 
 
    return_value = 0
 
-   CALL internal_message( 'debug', routine_name // ': init dimension ' // TRIM( dim_name ) )
+   CALL internal_message( 'debug', routine_name // ': init dimension ' // TRIM( dimension_name ) )
 
    !-- Check mode (not required, added for compatibility reasons only)
@@ -422,21 +422,21 @@
 
    !-- Assign dimension ID
-   dim_id = files_highest_var_id( file_id ) + 1
-   files_highest_var_id( file_id ) = dim_id
+   dimension_id = files_highest_variable_id( file_id ) + 1
+   files_highest_variable_id( file_id ) = dimension_id
 
    !-- Define dimension in file
-   out_str = 'dimension'
-   WRITE( file_id )  out_str
-   WRITE( file_id )  dim_name
-   WRITE( file_id )  dim_id
-   WRITE( file_id )  dim_type
-   WRITE( file_id )  dim_length
+   output_string = 'dimension'
+   WRITE( file_id )  output_string
+   WRITE( file_id )  dimension_name
+   WRITE( file_id )  dimension_id
+   WRITE( file_id )  dimension_type
+   WRITE( file_id )  dimension_length
 
    !-- Define variable associated with dimension
-   CALL binary_init_variable( mode, file_id, var_id, dim_name, dim_type, (/dim_id/), &
-                              is_global=.TRUE., return_value=return_value )
+   CALL binary_init_variable( mode, file_id, variable_id, dimension_name, dimension_type, &
+                              (/ dimension_id /), is_global=.TRUE., return_value=return_value )
    IF ( return_value /= 0 )  THEN
       CALL internal_message( 'error', routine_name // &
-                                      ': init dimension "' // TRIM( dim_name ) // '"' )
+                             ': init dimension "' // TRIM( dimension_name ) // '"' )
    ENDIF
 
@@ -448,19 +448,19 @@
 !> Initialize variable. Write information of variable into file header.
 !--------------------------------------------------------------------------------------------------!
-SUBROUTINE binary_init_variable( mode, file_id, var_id, var_name, var_type, &
-                                 var_dim_ids, is_global, return_value )
-
-   CHARACTER(LEN=charlen)             ::  out_str   !< output string
-   CHARACTER(LEN=charlen), INTENT(IN) ::  var_name  !< name of variable
-   CHARACTER(LEN=charlen), INTENT(IN) ::  var_type  !< data type of variable
-   CHARACTER(LEN=*),       INTENT(IN) ::  mode      !< operation mode
+SUBROUTINE binary_init_variable( mode, file_id, variable_id, variable_name, variable_type, &
+                                 dimension_ids, is_global, return_value )
+
+   CHARACTER(LEN=charlen)             ::  output_string   !< output string
+   CHARACTER(LEN=charlen), INTENT(IN) ::  variable_name   !< name of variable
+   CHARACTER(LEN=charlen), INTENT(IN) ::  variable_type   !< data type of variable
+   CHARACTER(LEN=*),       INTENT(IN) ::  mode            !< operation mode
 
    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'binary_init_variable'  !< name of this routine
 
-   INTEGER(iwp), INTENT(IN)  ::  file_id       !< file ID
-   INTEGER(iwp), INTENT(OUT) ::  var_id        !< variable ID
-   INTEGER(iwp), INTENT(OUT) ::  return_value  !< return value
-
-   INTEGER(iwp), DIMENSION(:), INTENT(IN) ::  var_dim_ids  !< list of dimension IDs used by variable
+   INTEGER, INTENT(IN)  ::  file_id       !< file ID
+   INTEGER, INTENT(OUT) ::  variable_id   !< variable ID
+   INTEGER, INTENT(OUT) ::  return_value  !< return value
+
+   INTEGER, DIMENSION(:), INTENT(IN) ::  dimension_ids  !< list of dimension IDs used by variable
 
    LOGICAL, INTENT(IN)  ::  is_global  !< true if variable is global (same on all PE)
@@ -469,5 +469,5 @@
    return_value = 0
 
-   CALL internal_message( 'debug', routine_name // ': init variable ' // TRIM( var_name ) )
+   CALL internal_message( 'debug', routine_name // ': init variable ' // TRIM( variable_name ) )
 
    !-- Check mode (not required, added for compatibility reasons only)
@@ -478,15 +478,15 @@
 
    !-- Assign variable ID
-   var_id = files_highest_var_id( file_id ) + 1
-   files_highest_var_id( file_id ) = var_id
+   variable_id = files_highest_variable_id( file_id ) + 1
+   files_highest_variable_id( file_id ) = variable_id
 
    !-- Write variable information in file
-   out_str = 'variable'
-   WRITE( file_id )  out_str
-   WRITE( file_id )  var_name
-   WRITE( file_id )  var_id
-   WRITE( file_id )  var_type
-   WRITE( file_id )  SIZE( var_dim_ids )
-   WRITE( file_id )  var_dim_ids
+   output_string = 'variable'
+   WRITE( file_id )  output_string
+   WRITE( file_id )  variable_name
+   WRITE( file_id )  variable_id
+   WRITE( file_id )  variable_type
+   WRITE( file_id )  SIZE( dimension_ids )
+   WRITE( file_id )  dimension_ids
 
 END SUBROUTINE binary_init_variable
@@ -497,12 +497,12 @@
 !> Leave file definition state.
 !--------------------------------------------------------------------------------------------------!
-SUBROUTINE binary_init_end( file_id, return_value )
-
-   CHARACTER(LEN=charlen) ::  out_str  !< output string
-
-   CHARACTER(LEN=*), PARAMETER ::  routine_name = 'binary_init_end'  !< name of this routine
-
-   INTEGER(iwp), INTENT(IN)  ::  file_id       !< file ID
-   INTEGER(iwp), INTENT(OUT) ::  return_value  !< return value
+SUBROUTINE binary_stop_file_header_definition( file_id, return_value )
+
+   CHARACTER(LEN=charlen) ::  output_string  !< output string
+
+   CHARACTER(LEN=*), PARAMETER ::  routine_name = 'binary_stop_file_header_definition'  !< name of this routine
+
+   INTEGER, INTENT(IN)  ::  file_id       !< file ID
+   INTEGER, INTENT(OUT) ::  return_value  !< return value
 
 
@@ -510,12 +510,11 @@
 
    WRITE( temp_string, * ) file_id
-   CALL internal_message( 'debug', &
-                          routine_name // &
+   CALL internal_message( 'debug', routine_name // &
                           ': finalize file definition (file_id=' // TRIM( temp_string ) // ')' )
 
-   out_str = '*** end file header ***'
-   WRITE( file_id )  out_str
-
-END SUBROUTINE binary_init_end
+   output_string = '*** end file header ***'
+   WRITE( file_id )  output_string
+
+END SUBROUTINE binary_stop_file_header_definition
 
 !--------------------------------------------------------------------------------------------------!
@@ -524,69 +523,64 @@
 !> Write variable to file.
 !--------------------------------------------------------------------------------------------------!
-SUBROUTINE binary_write_variable(                                         &
-              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,  &
-              var_int32_0d,  var_int32_1d,  var_int32_2d,  var_int32_3d,  &
-              var_intwp_0d,  var_intwp_1d,  var_intwp_2d,  var_intwp_3d,  &
-              var_real32_0d, var_real32_1d, var_real32_2d, var_real32_3d, &
-              var_real64_0d, var_real64_1d, var_real64_2d, var_real64_3d, &
-              var_realwp_0d, var_realwp_1d, var_realwp_2d, var_realwp_3d, &
+SUBROUTINE binary_write_variable(                                                     &
+              file_id, variable_id, bounds_start, value_counts, bounds_origin,        &
+              is_global,                                                              &
+              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 )
 
-   CHARACTER(LEN=charlen) ::  out_str  !< output string
+   CHARACTER(LEN=charlen) ::  output_string  !< output string
 
    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'binary_write_variable'  !< name of this routine
 
-   INTEGER(iwp), INTENT(IN)  ::  file_id       !< file ID
-   INTEGER(iwp), INTENT(OUT) ::  return_value  !< return value
-   INTEGER(iwp), INTENT(IN)  ::  var_id        !< variable ID
-
-   INTEGER(iwp), DIMENSION(:), INTENT(IN) ::  bounds_origin  !< starting index of each dimension
-   INTEGER(iwp), DIMENSION(:), INTENT(IN) ::  bounds_start   !< starting index of variable
-   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
-   INTEGER(KIND=1), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:)     ::  var_int8_1d  !< output variable
-   INTEGER(KIND=1), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:)   ::  var_int8_2d  !< output variable
-   INTEGER(KIND=1), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) ::  var_int8_3d  !< output variable
-
-   INTEGER(KIND=2), POINTER, INTENT(IN), OPTIONAL                               ::  var_int16_0d  !< output variable
-   INTEGER(KIND=2), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:)     ::  var_int16_1d  !< output variable
-   INTEGER(KIND=2), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:)   ::  var_int16_2d  !< output variable
-   INTEGER(KIND=2), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) ::  var_int16_3d  !< output variable
-
-   INTEGER(KIND=4), POINTER, INTENT(IN), OPTIONAL                               ::  var_int32_0d  !< output variable
-   INTEGER(KIND=4), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:)     ::  var_int32_1d  !< output variable
-   INTEGER(KIND=4), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:)   ::  var_int32_2d  !< output variable
-   INTEGER(KIND=4), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) ::  var_int32_3d  !< output variable
-
-   INTEGER(iwp), POINTER, INTENT(IN), OPTIONAL                               ::  var_intwp_0d  !< output variable
-   INTEGER(iwp), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:)     ::  var_intwp_1d  !< output variable
-   INTEGER(iwp), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:)   ::  var_intwp_2d  !< output variable
-   INTEGER(iwp), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) ::  var_intwp_3d  !< output variable
+   INTEGER, INTENT(IN)  ::  file_id       !< file ID
+   INTEGER, INTENT(OUT) ::  return_value  !< return value
+   INTEGER, INTENT(IN)  ::  variable_id   !< variable ID
+
+   INTEGER, DIMENSION(:), INTENT(IN) ::  bounds_origin  !< starting index of each dimension
+   INTEGER, DIMENSION(:), INTENT(IN) ::  bounds_start   !< starting index of variable
+   INTEGER, DIMENSION(:), INTENT(IN) ::  value_counts   !< count of values along each dimension to be written
+
+   INTEGER(KIND=1), POINTER,             INTENT(IN), OPTIONAL                   ::  values_int8_0d   !< output variable
+   INTEGER(KIND=2), POINTER,             INTENT(IN), OPTIONAL                   ::  values_int16_0d  !< output variable
+   INTEGER(KIND=4), POINTER,             INTENT(IN), OPTIONAL                   ::  values_int32_0d  !< output variable
+   INTEGER(iwp),    POINTER,             INTENT(IN), OPTIONAL                   ::  values_intwp_0d  !< output variable
+   INTEGER(KIND=1), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:)     ::  values_int8_1d   !< output variable
+   INTEGER(KIND=2), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:)     ::  values_int16_1d  !< output variable
+   INTEGER(KIND=4), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:)     ::  values_int32_1d  !< output variable
+   INTEGER(iwp),    POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:)     ::  values_intwp_1d  !< output variable
+   INTEGER(KIND=1), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:)   ::  values_int8_2d   !< output variable
+   INTEGER(KIND=2), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:)   ::  values_int16_2d  !< output variable
+   INTEGER(KIND=4), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:)   ::  values_int32_2d  !< output variable
+   INTEGER(iwp),    POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:)   ::  values_intwp_2d  !< output variable
+   INTEGER(KIND=1), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) ::  values_int8_3d   !< output variable
+   INTEGER(KIND=2), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) ::  values_int16_3d  !< output variable
+   INTEGER(KIND=4), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) ::  values_int32_3d  !< output variable
+   INTEGER(iwp),    POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) ::  values_intwp_3d  !< output variable
 
    LOGICAL, INTENT(IN) ::  is_global  !< true if variable is global (same on all PE)
 
-   REAL(KIND=4), POINTER, INTENT(IN), OPTIONAL                               ::  var_real32_0d  !< output variable
-   REAL(KIND=4), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:)     ::  var_real32_1d  !< output variable
-   REAL(KIND=4), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:)   ::  var_real32_2d  !< output variable
-   REAL(KIND=4), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) ::  var_real32_3d  !< output variable
-
-   REAL(KIND=8), POINTER, INTENT(IN), OPTIONAL                               ::  var_real64_0d  !< output variable
-   REAL(KIND=8), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:)     ::  var_real64_1d  !< output variable
-   REAL(KIND=8), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:)   ::  var_real64_2d  !< output variable
-   REAL(KIND=8), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) ::  var_real64_3d  !< output variable
-
-   REAL(wp), POINTER, INTENT(IN), OPTIONAL                               ::  var_realwp_0d  !< output variable
-   REAL(wp), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:)     ::  var_realwp_1d  !< output variable
-   REAL(wp), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:)   ::  var_realwp_2d  !< output variable
-   REAL(wp), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) ::  var_realwp_3d  !< output variable
+   REAL(KIND=4), POINTER,             INTENT(IN), OPTIONAL                   ::  values_real32_0d  !< output variable
+   REAL(KIND=8), POINTER,             INTENT(IN), OPTIONAL                   ::  values_real64_0d  !< output variable
+   REAL(wp),     POINTER,             INTENT(IN), OPTIONAL                   ::  values_realwp_0d  !< output variable
+   REAL(KIND=4), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:)     ::  values_real32_1d  !< output variable
+   REAL(KIND=8), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:)     ::  values_real64_1d  !< output variable
+   REAL(wp),     POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:)     ::  values_realwp_1d  !< output variable
+   REAL(KIND=4), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:)   ::  values_real32_2d  !< output variable
+   REAL(KIND=8), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:)   ::  values_real64_2d  !< output variable
+   REAL(wp),     POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:)   ::  values_realwp_2d  !< output variable
+   REAL(KIND=4), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) ::  values_real32_3d  !< output variable
+   REAL(KIND=8), POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) ::  values_real64_3d  !< output variable
+   REAL(wp),     POINTER, CONTIGUOUS, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) ::  values_realwp_3d  !< output variable
 
 
    return_value = 0
 
-   WRITE( temp_string, '(": write variable ",I6," into file ",I6)' ) var_id, file_id
+   WRITE( temp_string, '(": write variable ",I6," into file ",I6)' ) variable_id, file_id
    CALL internal_message( 'debug', routine_name // TRIM( temp_string ) )
 
@@ -594,127 +588,127 @@
 
    IF ( .NOT. ANY( value_counts == 0 ) )  THEN
-      WRITE( file_id )  var_id
+      WRITE( file_id )  variable_id
       WRITE( file_id )  bounds_start
       WRITE( file_id )  value_counts
       WRITE( file_id )  bounds_origin
       !-- 8bit integer output
-      IF ( PRESENT( var_int8_0d ) )  THEN
-         out_str = 'int8'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_int8_0d
-      ELSEIF ( PRESENT( var_int8_1d ) )  THEN
-         out_str = 'int8'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_int8_1d
-      ELSEIF ( PRESENT( var_int8_2d ) )  THEN
-         out_str = 'int8'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_int8_2d
-      ELSEIF ( PRESENT( var_int8_3d ) )  THEN
-         out_str = 'int8'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_int8_3d
+      IF ( PRESENT( values_int8_0d ) )  THEN
+         output_string = 'int8'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_int8_0d
+      ELSEIF ( PRESENT( values_int8_1d ) )  THEN
+         output_string = 'int8'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_int8_1d
+      ELSEIF ( PRESENT( values_int8_2d ) )  THEN
+         output_string = 'int8'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_int8_2d
+      ELSEIF ( PRESENT( values_int8_3d ) )  THEN
+         output_string = 'int8'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_int8_3d
       !-- 16bit integer output
-      ELSEIF ( PRESENT( var_int16_0d ) )  THEN
-         out_str = 'int16'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_int16_0d
-      ELSEIF ( PRESENT( var_int16_1d ) )  THEN
-         out_str = 'int16'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_int16_1d
-      ELSEIF ( PRESENT( var_int16_2d ) )  THEN
-         out_str = 'int16'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_int16_2d
-      ELSEIF ( PRESENT( var_int16_3d ) )  THEN
-         out_str = 'int16'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_int16_3d
+      ELSEIF ( PRESENT( values_int16_0d ) )  THEN
+         output_string = 'int16'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_int16_0d
+      ELSEIF ( PRESENT( values_int16_1d ) )  THEN
+         output_string = 'int16'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_int16_1d
+      ELSEIF ( PRESENT( values_int16_2d ) )  THEN
+         output_string = 'int16'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_int16_2d
+      ELSEIF ( PRESENT( values_int16_3d ) )  THEN
+         output_string = 'int16'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_int16_3d
       !-- 32bit integer output
-      ELSEIF ( PRESENT( var_int32_0d ) )  THEN
-         out_str = 'int32'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_int32_0d
-      ELSEIF ( PRESENT( var_int32_1d ) )  THEN
-         out_str = 'int32'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_int32_1d
-      ELSEIF ( PRESENT( var_int32_2d ) )  THEN
-         out_str = 'int32'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_int32_2d
-      ELSEIF ( PRESENT( var_int32_3d ) )  THEN
-         out_str = 'int32'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_int32_3d
+      ELSEIF ( PRESENT( values_int32_0d ) )  THEN
+         output_string = 'int32'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_int32_0d
+      ELSEIF ( PRESENT( values_int32_1d ) )  THEN
+         output_string = 'int32'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_int32_1d
+      ELSEIF ( PRESENT( values_int32_2d ) )  THEN
+         output_string = 'int32'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_int32_2d
+      ELSEIF ( PRESENT( values_int32_3d ) )  THEN
+         output_string = 'int32'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_int32_3d
       !-- working-precision integer output
-      ELSEIF ( PRESENT( var_intwp_0d ) )  THEN
-         out_str = 'intwp'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_intwp_0d
-      ELSEIF ( PRESENT( var_intwp_1d ) )  THEN
-         out_str = 'intwp'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_intwp_1d
-      ELSEIF ( PRESENT( var_intwp_2d ) )  THEN
-         out_str = 'intwp'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_intwp_2d
-      ELSEIF ( PRESENT( var_intwp_3d ) )  THEN
-         out_str = 'intwp'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_intwp_3d
+      ELSEIF ( PRESENT( values_intwp_0d ) )  THEN
+         output_string = 'intwp'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_intwp_0d
+      ELSEIF ( PRESENT( values_intwp_1d ) )  THEN
+         output_string = 'intwp'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_intwp_1d
+      ELSEIF ( PRESENT( values_intwp_2d ) )  THEN
+         output_string = 'intwp'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_intwp_2d
+      ELSEIF ( PRESENT( values_intwp_3d ) )  THEN
+         output_string = 'intwp'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_intwp_3d
       !-- 32bit real output
-      ELSEIF ( PRESENT( var_real32_0d ) )  THEN
-         out_str = 'real32'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_real32_0d
-      ELSEIF ( PRESENT( var_real32_1d ) )  THEN
-         out_str = 'real32'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_real32_1d
-      ELSEIF ( PRESENT( var_real32_2d ) )  THEN
-         out_str = 'real32'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_real32_2d
-      ELSEIF ( PRESENT( var_real32_3d ) )  THEN
-         out_str = 'real32'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_real32_3d
+      ELSEIF ( PRESENT( values_real32_0d ) )  THEN
+         output_string = 'real32'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_real32_0d
+      ELSEIF ( PRESENT( values_real32_1d ) )  THEN
+         output_string = 'real32'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_real32_1d
+      ELSEIF ( PRESENT( values_real32_2d ) )  THEN
+         output_string = 'real32'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_real32_2d
+      ELSEIF ( PRESENT( values_real32_3d ) )  THEN
+         output_string = 'real32'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_real32_3d
       !-- 64bit real output
-      ELSEIF ( PRESENT( var_real64_0d ) )  THEN
-         out_str = 'real64'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_real64_0d
-      ELSEIF ( PRESENT( var_real64_1d ) )  THEN
-         out_str = 'real64'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_real64_1d
-      ELSEIF ( PRESENT( var_real64_2d ) )  THEN
-         out_str = 'real64'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_real64_2d
-      ELSEIF ( PRESENT( var_real64_3d ) )  THEN
-         out_str = 'real64'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_real64_3d
+      ELSEIF ( PRESENT( values_real64_0d ) )  THEN
+         output_string = 'real64'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_real64_0d
+      ELSEIF ( PRESENT( values_real64_1d ) )  THEN
+         output_string = 'real64'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_real64_1d
+      ELSEIF ( PRESENT( values_real64_2d ) )  THEN
+         output_string = 'real64'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_real64_2d
+      ELSEIF ( PRESENT( values_real64_3d ) )  THEN
+         output_string = 'real64'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_real64_3d
       !-- working-precision real output
-      ELSEIF ( PRESENT( var_realwp_0d ) )  THEN
-         out_str = 'realwp'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_realwp_0d
-      ELSEIF ( PRESENT( var_realwp_1d ) )  THEN
-         out_str = 'realwp'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_realwp_1d
-      ELSEIF ( PRESENT( var_realwp_2d ) )  THEN
-         out_str = 'realwp'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_realwp_2d
-      ELSEIF ( PRESENT( var_realwp_3d ) )  THEN
-         out_str = 'realwp'
-         WRITE( file_id )  out_str
-         WRITE( file_id )  var_realwp_3d
+      ELSEIF ( PRESENT( values_realwp_0d ) )  THEN
+         output_string = 'realwp'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_realwp_0d
+      ELSEIF ( PRESENT( values_realwp_1d ) )  THEN
+         output_string = 'realwp'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_realwp_1d
+      ELSEIF ( PRESENT( values_realwp_2d ) )  THEN
+         output_string = 'realwp'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_realwp_2d
+      ELSEIF ( PRESENT( values_realwp_3d ) )  THEN
+         output_string = 'realwp'
+         WRITE( file_id )  output_string
+         WRITE( file_id )  values_realwp_3d
       ELSE
          return_value = 1
@@ -733,16 +727,16 @@
 SUBROUTINE binary_finalize( file_id, return_value )
 
-   CHARACTER(LEN=charlen) ::  out_str  !< output string
+   CHARACTER(LEN=charlen) ::  output_string  !< output string
 
    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'binary_finalize'  !< name of this routine
 
-   INTEGER(iwp), INTENT(IN)  ::  file_id       !< file ID
-   INTEGER(iwp), INTENT(OUT) ::  return_value  !< return value
+   INTEGER, INTENT(IN)  ::  file_id       !< file ID
+   INTEGER, INTENT(OUT) ::  return_value  !< return value
 
 
    IF ( config_file_open )  THEN
 
-      out_str = '*** end config file ***'
-      WRITE( config_file_unit )  out_str
+      output_string = '*** end config file ***'
+      WRITE( config_file_unit )  output_string
 
       CLOSE( config_file_unit, IOSTAT=return_value )
@@ -762,13 +756,12 @@
    IF ( return_value == 0 )  THEN
 
-      WRITE(temp_string,*) file_id
+      WRITE( temp_string, * ) file_id
       CALL internal_message( 'debug', routine_name // &
-                                      ': close file (file_id=' // TRIM( temp_string ) // ')' )
+                             ': close file (file_id=' // TRIM( temp_string ) // ')' )
 
       CLOSE( file_id, IOSTAT=return_value )
       IF ( return_value /= 0 )  THEN
-         WRITE(temp_string,*) file_id
-         CALL internal_message( 'error',        &
-                                routine_name // &
+         WRITE( temp_string, * ) file_id
+         CALL internal_message( 'error', routine_name // &
                                 ': cannot close file (file_id=' // TRIM( temp_string ) // ')' )
       ENDIF
@@ -778,5 +771,4 @@
 END SUBROUTINE binary_finalize
 
-
 !--------------------------------------------------------------------------------------------------!
 ! Description:
@@ -809,13 +801,14 @@
 !> Return the last created error message.
 !--------------------------------------------------------------------------------------------------!
-SUBROUTINE binary_get_error_message( error_message )
-
-   CHARACTER(LEN=800), INTENT(OUT) ::  error_message  !< return error message to main program
-
-
-   error_message = internal_error_message
-
-END SUBROUTINE binary_get_error_message
-
+FUNCTION binary_get_error_message() RESULT( error_message )
+
+   CHARACTER(LEN=800) ::  error_message  !< return error message to main program
+
+
+   error_message = TRIM( internal_error_message )
+   
+   internal_error_message = ''
+
+END FUNCTION binary_get_error_message
 
 END MODULE data_output_binary_module
