Ignore:
Timestamp:
Jun 25, 2020 9:53:58 AM (4 years ago)
Author:
raasch
Message:

further re-formatting to follow the PALM coding standard

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/data_output_module.f90

    r4500 r4577  
    33! This file is part of the PALM model system.
    44!
    5 ! PALM is free software: you can redistribute it and/or modify it under the
    6 ! terms of the GNU General Public License as published by the Free Software
    7 ! Foundation, either version 3 of the License, or (at your option) any later
    8 ! version.
    9 !
    10 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
    11 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
    12 ! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
    13 !
    14 ! You should have received a copy of the GNU General Public License along with
    15 ! PALM. If not, see <http://www.gnu.org/licenses/>.
     5! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General
     6! Public License as published by the Free Software Foundation, either version 3 of the License, or
     7! (at your option) any later version.
     8!
     9! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
     10! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
     11! Public License for more details.
     12!
     13! You should have received a copy of the GNU General Public License along with PALM. If not, see
     14! <http://www.gnu.org/licenses/>.
    1615!
    1716! Copyright 2019-2020 Leibniz Universitaet Hannover
     
    2524! -----------------
    2625! $Id$
     26! file re-formatted to follow the PALM coding standard
     27!
     28! 4500 2020-04-17 10:12:45Z suehring
    2729! Avoid uninitialized variables
    28 ! 
     30!
    2931! 4481 2020-03-31 18:55:54Z maronga
    3032! Enable character-array output
     
    7274    USE kinds
    7375
    74     USE data_output_netcdf4_module, &
    75        ONLY: netcdf4_init_dimension, &
    76              netcdf4_get_error_message, &
    77              netcdf4_stop_file_header_definition, &
    78              netcdf4_init_module, &
    79              netcdf4_init_variable, &
    80              netcdf4_finalize, &
    81              netcdf4_open_file, &
    82              netcdf4_write_attribute, &
     76    USE data_output_netcdf4_module,                                                                &
     77       ONLY: netcdf4_finalize,                                                                    &
     78             netcdf4_get_error_message,                                                            &
     79             netcdf4_init_dimension,                                                              &
     80             netcdf4_init_module,                                                                  &
     81             netcdf4_init_variable,                                                                &
     82             netcdf4_open_file,                                                                    &
     83             netcdf4_stop_file_header_definition,                                                  &
     84             netcdf4_write_attribute,                                                              &
    8385             netcdf4_write_variable
    8486
    85     USE data_output_binary_module, &
    86        ONLY: binary_finalize, &
    87              binary_get_error_message, &
    88              binary_init_dimension, &
    89              binary_stop_file_header_definition, &
    90              binary_init_module, &
    91              binary_init_variable, &
    92              binary_open_file, &
    93              binary_write_attribute, &
     87    USE data_output_binary_module,                                                                 &
     88       ONLY: binary_finalize,                                                                      &
     89             binary_get_error_message,                                                             &
     90             binary_init_dimension,                                                                &
     91             binary_init_module,                                                                  &
     92             binary_init_variable,                                                                &
     93             binary_open_file,                                                                    &
     94             binary_stop_file_header_definition,                                                  &
     95             binary_write_attribute,                                                               &
    9496             binary_write_variable
    9597
     
    113115       CHARACTER(LEN=charlen)                            ::  data_type = ''       !< data type
    114116       CHARACTER(LEN=charlen)                            ::  name                 !< variable name
     117       CHARACTER(LEN=charlen), DIMENSION(:), ALLOCATABLE ::  dimension_names      !< list of
     118                                                                                  !< dimension names used by variable
    115119       INTEGER                                           ::  id = no_id           !< id within file
    116        LOGICAL                                           ::  is_global = .FALSE.  !< true if global variable
    117        CHARACTER(LEN=charlen), DIMENSION(:), ALLOCATABLE ::  dimension_names      !< list of dimension names used by variable
    118        INTEGER,                DIMENSION(:), ALLOCATABLE ::  dimension_ids        !< list of dimension ids used by variable
    119        TYPE(attribute_type),   DIMENSION(:), ALLOCATABLE ::  attributes           !< list of attributes
     120       LOGICAL                                           ::  is_global = .FALSE.  !< true if global
     121                                                                                  !< variable
     122       INTEGER,                DIMENSION(:), ALLOCATABLE ::  dimension_ids        !< list of
     123                                                                                  !< dimension ids used by variable
     124       TYPE(attribute_type),   DIMENSION(:), ALLOCATABLE ::  attributes           !< list of
     125                                                                                  !< attributes
    120126    END TYPE variable_type
    121127
     
    123129       CHARACTER(LEN=charlen)                     ::  data_type = ''        !< data type
    124130       CHARACTER(LEN=charlen)                     ::  name                  !< dimension name
    125        INTEGER                                    ::  id = no_id            !< dimension id within file
     131       INTEGER                                    ::  id = no_id            !< dimension id within
     132                                                                            !< file
    126133       INTEGER                                    ::  length                !< length of dimension
    127        INTEGER                                    ::  length_mask           !< length of masked dimension
    128        INTEGER                                    ::  variable_id = no_id   !< associated variable id within file
     134       INTEGER                                    ::  length_mask           !< length of masked
     135                                                                            !< dimension
     136       INTEGER                                    ::  variable_id = no_id   !< associated variable
     137                                                                            !< id within file
    129138       LOGICAL                                    ::  is_masked = .FALSE.   !< true if masked
    130        INTEGER,         DIMENSION(2)              ::  bounds                !< lower and upper bound of dimension
    131        INTEGER,         DIMENSION(:), ALLOCATABLE ::  masked_indices        !< list of masked indices of dimension
    132        INTEGER(KIND=1), DIMENSION(:), ALLOCATABLE ::  masked_values_int8    !< masked dimension values if 16bit integer
    133        INTEGER(KIND=2), DIMENSION(:), ALLOCATABLE ::  masked_values_int16   !< masked dimension values if 16bit integer
    134        INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE ::  masked_values_int32   !< masked dimension values if 32bit integer
    135        INTEGER(iwp),    DIMENSION(:), ALLOCATABLE ::  masked_values_intwp   !< masked dimension values if working-precision int
    136        INTEGER(KIND=1), DIMENSION(:), ALLOCATABLE ::  values_int8           !< dimension values if 16bit integer
    137        INTEGER(KIND=2), DIMENSION(:), ALLOCATABLE ::  values_int16          !< dimension values if 16bit integer
    138        INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE ::  values_int32          !< dimension values if 32bit integer
    139        INTEGER(iwp),    DIMENSION(:), ALLOCATABLE ::  values_intwp          !< dimension values if working-precision integer
     139       INTEGER,         DIMENSION(2)              ::  bounds                !< lower and upper bound
     140                                                                            !< of dimension
     141       INTEGER,         DIMENSION(:), ALLOCATABLE ::  masked_indices        !< list of masked
     142                                                                            !< indices of dimension
     143       INTEGER(KIND=1), DIMENSION(:), ALLOCATABLE ::  masked_values_int8    !< masked dimension
     144                                                                            !< values if 16bit integer
     145       INTEGER(KIND=2), DIMENSION(:), ALLOCATABLE ::  masked_values_int16   !< masked dimension
     146                                                                            !< values if 16bit integer
     147       INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE ::  masked_values_int32   !< masked dimension
     148                                                                            !< values if 32bit integer
     149       INTEGER(iwp),    DIMENSION(:), ALLOCATABLE ::  masked_values_intwp   !< masked dimension
     150                                                                            !< values if working-precision int
     151       INTEGER(KIND=1), DIMENSION(:), ALLOCATABLE ::  values_int8           !< dimension values if
     152                                                                            !< 16bit integer
     153       INTEGER(KIND=2), DIMENSION(:), ALLOCATABLE ::  values_int16          !< dimension values if
     154                                                                            !< 16bit integer
     155       INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE ::  values_int32          !< dimension values if
     156                                                                            !< 32bit integer
     157       INTEGER(iwp),    DIMENSION(:), ALLOCATABLE ::  values_intwp          !< dimension values if
     158                                                                            !< working-precision integer
    140159       LOGICAL,         DIMENSION(:), ALLOCATABLE ::  mask                  !< mask
    141        REAL(KIND=4),    DIMENSION(:), ALLOCATABLE ::  masked_values_real32  !< masked dimension values if 32bit real
    142        REAL(KIND=8),    DIMENSION(:), ALLOCATABLE ::  masked_values_real64  !< masked dimension values if 64bit real
    143        REAL(wp),        DIMENSION(:), ALLOCATABLE ::  masked_values_realwp  !< masked dimension values if working-precision real
    144        REAL(KIND=4),    DIMENSION(:), ALLOCATABLE ::  values_real32         !< dimension values if 32bit real
    145        REAL(KIND=8),    DIMENSION(:), ALLOCATABLE ::  values_real64         !< dimension values if 64bit real
    146        REAL(wp),        DIMENSION(:), ALLOCATABLE ::  values_realwp         !< dimension values if working-precision real
     160       REAL(KIND=4),    DIMENSION(:), ALLOCATABLE ::  masked_values_real32  !< masked dimension
     161                                                                            !< values if 32bit real
     162       REAL(KIND=8),    DIMENSION(:), ALLOCATABLE ::  masked_values_real64  !< masked dimension
     163                                                                            !< values if 64bit real
     164       REAL(wp),        DIMENSION(:), ALLOCATABLE ::  masked_values_realwp  !< masked dimension
     165                                                                            !< values if working-precision real
     166       REAL(KIND=4),    DIMENSION(:), ALLOCATABLE ::  values_real32         !< dimension values if
     167                                                                            !< 32bit real
     168       REAL(KIND=8),    DIMENSION(:), ALLOCATABLE ::  values_real64         !< dimension values if
     169                                                                            !< 64bit real
     170       REAL(wp),        DIMENSION(:), ALLOCATABLE ::  values_realwp         !< dimension values if
     171                                                                            !< working-precision real
    147172       TYPE(attribute_type), DIMENSION(:), ALLOCATABLE ::  attributes       !< list of attributes
    148173    END TYPE dimension_type
     
    159184
    160185
     186    CHARACTER(LEN=800)     ::  internal_error_message = ''  !< string containing the last error message
    161187    CHARACTER(LEN=charlen) ::  output_file_suffix = ''      !< file suffix added to each file name
    162     CHARACTER(LEN=800)     ::  internal_error_message = ''  !< string containing the last error message
    163188    CHARACTER(LEN=800)     ::  temp_string                  !< dummy string
    164189
     
    296321 FUNCTION dom_def_file( file_name, file_format ) RESULT( return_value )
    297322
     323    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_def_file'  !< name of this routine
     324
    298325    CHARACTER(LEN=*), INTENT(IN) ::  file_name    !< name of file to be created
    299326    CHARACTER(LEN=*), INTENT(IN) ::  file_format  !< format of file to be created
    300 
    301     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_def_file'  !< name of this routine
    302327
    303328    INTEGER ::  f             !< loop index
     
    385410                       mask ) RESULT( return_value )
    386411
     412    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_def_dim'  !< name of this routine
     413
    387414    CHARACTER(LEN=*), INTENT(IN) ::  file_name       !< name of file
    388415    CHARACTER(LEN=*), INTENT(IN) ::  dimension_name  !< name of dimension
    389416    CHARACTER(LEN=*), INTENT(IN) ::  output_type     !< data type of dimension variable in output file
    390 
    391     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_def_dim'  !< name of this routine
    392417
    393418    INTEGER ::  d             !< loop index
     
    416441    return_value = 0
    417442
    418     CALL internal_message( 'debug', routine_name //                    &
    419                            ': define dimension ' //                    &
    420                            '(dimension "' // TRIM( dimension_name ) // &
     443    CALL internal_message( 'debug', routine_name //                                                &
     444                           ': define dimension ' //                                                &
     445                           '(dimension "' // TRIM( dimension_name ) //                             &
    421446                           '", file "' // TRIM( file_name ) // '")' )
    422447
     
    427452    IF ( SIZE( bounds ) == 1 )  THEN
    428453!
    429 !--    Dimension has only lower bound, which means it changes its size
    430 !--    during simulation.
     454!--    Dimension has only lower bound, which means it changes its size during simulation.
    431455!--    Set length to -1 as indicator.
    432456       dimension%bounds(:) = bounds(1)
     
    435459       IF ( PRESENT( mask ) )  THEN
    436460          return_value = 1
    437           CALL internal_message( 'error', routine_name //                      &
    438                                  ': unlimited dimensions cannot be masked ' // &
    439                                  '(dimension "' // TRIM( dimension_name ) //   &
     461          CALL internal_message( 'error', routine_name //                                          &
     462                                 ': unlimited dimensions cannot be masked ' //                     &
     463                                 '(dimension "' // TRIM( dimension_name ) //                       &
    440464                                 '", file "' // TRIM( file_name ) // '")!' )
    441465       ENDIF
     
    512536       ELSE
    513537          return_value = 1
    514           CALL internal_message( 'error', routine_name //                    &
    515                                  ': no values given ' //                     &
    516                                  '(dimension "' // TRIM( dimension_name ) // &
     538          CALL internal_message( 'error', routine_name //                                          &
     539                                 ': no values given ' //                                           &
     540                                 '(dimension "' // TRIM( dimension_name ) //                       &
    517541                                 '", file "' // TRIM( file_name ) // '")!' )
    518542       ENDIF
     
    520544       IF ( return_value == 2 )  THEN
    521545          return_value = 1
    522           CALL internal_message( 'error', routine_name //                               &
    523                                  ': number of values and given bounds do not match ' // &
    524                                  '(dimension "' // TRIM( dimension_name ) //            &
     546          CALL internal_message( 'error', routine_name //                                          &
     547                                 ': number of values and given bounds do not match ' //            &
     548                                 '(dimension "' // TRIM( dimension_name ) //                       &
    525549                                 '", file "' // TRIM( file_name ) // '")!' )
    526550       ENDIF
     
    533557             IF ( ALL( mask ) )  THEN
    534558
    535                 CALL internal_message( 'debug', routine_name //                              &
    536                                        ': mask contains only TRUE values. Ignoring mask ' // &
    537                                        '(dimension "' // TRIM( dimension_name ) //           &
     559                CALL internal_message( 'debug', routine_name //                                    &
     560                                       ': mask contains only TRUE values. Ignoring mask ' //       &
     561                                       '(dimension "' // TRIM( dimension_name ) //                 &
    538562                                       '", file "' // TRIM( file_name ) // '")!' )
    539563
     
    577601                   ALLOCATE( dimension%masked_values_int32(0:dimension%length_mask-1) )
    578602                   j = 0
    579                    DO  i =dimension%bounds(1), dimension%bounds(2)
     603                   DO  i = dimension%bounds(1), dimension%bounds(2)
    580604                      IF ( dimension%mask(i) )  THEN
    581605                         dimension%masked_values_int32(j) = dimension%values_int32(i)
     
    639663          ELSE
    640664             return_value = 1
    641              CALL internal_message( 'error', routine_name //                           &
    642                                     ': size of mask and given bounds do not match ' // &
    643                                     '(dimension "' // TRIM( dimension_name ) //        &
     665             CALL internal_message( 'error', routine_name //                                       &
     666                                    ': size of mask and given bounds do not match ' //             &
     667                                    '(dimension "' // TRIM( dimension_name ) //                    &
    644668                                    '", file "' // TRIM( file_name ) // '")!' )
    645669          ENDIF
     
    650674
    651675       return_value = 1
    652        CALL internal_message( 'error', routine_name //                                       &
    653                               ': at least one but no more than two bounds must be given ' // &
    654                               '(dimension "' // TRIM( dimension_name ) //                    &
     676       CALL internal_message( 'error', routine_name //                                             &
     677                              ': at least one but no more than two bounds must be given ' //       &
     678                              '(dimension "' // TRIM( dimension_name ) //                          &
    655679                              '", file "' // TRIM( file_name ) // '")!' )
    656680
     
    667691
    668692                return_value = 1
    669                 CALL internal_message( 'error', routine_name //                      &
    670                                        ': file already initialized. ' //             &
    671                                        'No further dimension definition allowed ' // &
    672                                        '(dimension "' // TRIM( dimension_name ) //   &
     693                CALL internal_message( 'error', routine_name //                                    &
     694                                       ': file already initialized. ' //                           &
     695                                       'No further dimension definition allowed ' //               &
     696                                       '(dimension "' // TRIM( dimension_name ) //                 &
    673697                                       '", file "' // TRIM( file_name ) // '")!' )
    674698                EXIT
     
    686710                      IF ( files(f)%variables(i)%name == dimension%name )  THEN
    687711                         return_value = 1
    688                          CALL internal_message( 'error', routine_name //                    &
    689                                  ': file already has a variable of this name defined. ' //  &
    690                                  'Defining a dimension of the same name is not allowed ' // &
    691                                  '(dimension "' // TRIM( dimension_name ) //                &
    692                                  '", file "' // TRIM( file_name ) // '")!' )
     712                         CALL internal_message( 'error', routine_name //                           &
     713                                        ': file already has a variable of this name defined. ' //  &
     714                                        'Defining a dimension of the same name is not allowed ' // &
     715                                        '(dimension "' // TRIM( dimension_name ) //                &
     716                                       '", file "' // TRIM( file_name ) // '")!' )
    693717                         EXIT
    694718                      ENDIF
     
    704728                      IF ( files(f)%dimensions(d)%name == dimension%name )  THEN
    705729                         return_value = 1
    706                          CALL internal_message( 'error', routine_name //     &
    707                                  ': dimension already exists in file ' //    &
    708                                  '(dimension "' // TRIM( dimension_name ) // &
    709                                  '", file "' // TRIM( file_name ) // '")!' )
     730                         CALL internal_message( 'error', routine_name //                           &
     731                                                ': dimension already exists in file ' //           &
     732                                                '(dimension "' // TRIM( dimension_name ) //        &
     733                                                '", file "' // TRIM( file_name ) // '")!' )
    710734                         EXIT
    711735                      ENDIF
     
    736760       IF ( f > nfiles )  THEN
    737761          return_value = 1
    738           CALL internal_message( 'error', routine_name //                                     &
    739                                  ': file not found (dimension "' // TRIM( dimension_name ) // &
     762          CALL internal_message( 'error', routine_name //                                          &
     763                                 ': file not found (dimension "' // TRIM( dimension_name ) //      &
    740764                                 '", file "' // TRIM( file_name ) // '")!' )
    741765       ENDIF
     
    750774!> Add variable to database.
    751775!> If a variable is identical for each MPI rank, the optional argument 'is_global' should be set to
    752 !> TRUE. This flags the variable to be a global variable and is later only written once by the
     776!> .TRUE. This flags the variable to be a global variable and is later only written once by the
    753777!> master output rank.
    754778!> Example call:
     
    770794!>          ALLOCATE( u(<z>,<y>,<x>) )
    771795!--------------------------------------------------------------------------------------------------!
    772  FUNCTION dom_def_var( file_name, variable_name, dimension_names, output_type, is_global ) &
     796 FUNCTION dom_def_var( file_name, variable_name, dimension_names, output_type, is_global )         &
    773797             RESULT( return_value )
    774798
     799    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_def_var'  !< name of this routine
     800
    775801    CHARACTER(LEN=*), INTENT(IN) ::  file_name      !< name of file
     802    CHARACTER(LEN=*), INTENT(IN) ::  output_type    !< data type of variable
    776803    CHARACTER(LEN=*), INTENT(IN) ::  variable_name  !< name of variable
    777     CHARACTER(LEN=*), INTENT(IN) ::  output_type    !< data type of variable
    778 
    779     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_def_var'  !< name of this routine
    780804
    781805    CHARACTER(LEN=*), DIMENSION(:), INTENT(IN) ::  dimension_names  !< list of dimension names
     
    797821    found = .FALSE.
    798822
    799     CALL internal_message( 'debug', routine_name //                                     &
    800                            ': define variable (variable "' // TRIM( variable_name ) //  &
     823    CALL internal_message( 'debug', routine_name //                                                &
     824                           ': define variable (variable "' // TRIM( variable_name ) //             &
    801825                           '", file "' // TRIM( file_name ) // '")' )
    802826
     
    824848
    825849             return_value = 1
    826              CALL internal_message( 'error', routine_name //                                  &
    827                      ': file already initialized. No further variable definition allowed ' // &
    828                      '(variable "' // TRIM( variable_name ) //                                &
    829                      '", file "' // TRIM( file_name ) // '")!' )
     850             CALL internal_message( 'error', routine_name //                                       &
     851                          ': file already initialized. No further variable definition allowed ' // &
     852                          '(variable "' // TRIM( variable_name ) //                                &
     853                          '", file "' // TRIM( file_name ) // '")!' )
    830854             EXIT
    831855
     
    836860                IF ( files(f)%dimensions(d)%name == variable%name )  THEN
    837861                   return_value = 1
    838                    CALL internal_message( 'error', routine_name //                    &
    839                            ': file already has a dimension of this name defined. ' // &
    840                            'Defining a variable of the same name is not allowed ' //  &
    841                            '(variable "' // TRIM( variable_name ) //                  &
    842                            '", file "' // TRIM( file_name ) // '")!' )
     862                   CALL internal_message( 'error', routine_name //                                 &
     863                                        ': file already has a dimension of this name defined. ' // &
     864                                        'Defining a variable of the same name is not allowed ' //  &
     865                                        '(variable "' // TRIM( variable_name ) //                  &
     866                                        '", file "' // TRIM( file_name ) // '")!' )
    843867                   EXIT
    844868                ENDIF
     
    857881                   IF ( .NOT. found )  THEN
    858882                      return_value = 1
    859                       CALL internal_message( 'error', routine_name //                            &
    860                               ': required dimension "'// TRIM( variable%dimension_names(i) ) // &
    861                               '" for variable is not defined ' //                                &
    862                               '(variable "' // TRIM( variable_name ) //                          &
    863                               '", file "' // TRIM( file_name ) // '")!' )
     883                      CALL internal_message( 'error', routine_name //                              &
     884                                 ': required dimension "'// TRIM( variable%dimension_names(i) ) // &
     885                                 '" for variable is not defined ' //                               &
     886                                 '(variable "' // TRIM( variable_name ) //                         &
     887                                 '", file "' // TRIM( file_name ) // '")!' )
    864888                      EXIT
    865889                   ENDIF
     
    870894
    871895             return_value = 1
    872              CALL internal_message( 'error', routine_name //                      &
    873                      ': no dimensions defined in file. Cannot define variable '// &
    874                      '(variable "' // TRIM( variable_name ) //                    &
    875                      '", file "' // TRIM( file_name ) // '")!' )
     896             CALL internal_message( 'error', routine_name //                                       &
     897                                    ': no dimensions defined in file. Cannot define variable '//  &
     898                                    '(variable "' // TRIM( variable_name ) //                      &
     899                                    '", file "' // TRIM( file_name ) // '")!' )
    876900
    877901          ENDIF
     
    891915                   IF ( files(f)%variables(i)%name == variable%name )  THEN
    892916                      return_value = 1
    893                       CALL internal_message( 'error', routine_name //   &
    894                               ': variable already exists '//            &
    895                               '(variable "' // TRIM( variable_name ) // &
    896                               '", file "' // TRIM( file_name ) // '")!' )
     917                      CALL internal_message( 'error', routine_name //                              &
     918                                             ': variable already exists '//                        &
     919                                             '(variable "' // TRIM( variable_name ) //            &
     920                                             '", file "' // TRIM( file_name ) // '")!' )
    897921                      EXIT
    898922                   ENDIF
     
    926950    IF ( f > nfiles )  THEN
    927951       return_value = 1
    928        CALL internal_message( 'error', routine_name //                                   &
    929                               ': file not found (variable "' // TRIM( variable_name ) // &
     952       CALL internal_message( 'error', routine_name //                                             &
     953                              ': file not found (variable "' // TRIM( variable_name ) //           &
    930954                              '", file "' // TRIM( file_name ) // '")!' )
    931955    ENDIF
     
    961985             RESULT( return_value )
    962986
     987    CHARACTER(LEN=*),      INTENT(IN)           ::  attribute_name          !< name of attribute
    963988    CHARACTER(LEN=*),      INTENT(IN)           ::  file_name               !< name of file
    964     CHARACTER(LEN=*),      INTENT(IN)           ::  attribute_name          !< name of attribute
    965989    CHARACTER(LEN=*),      INTENT(IN)           ::  value                   !< attribute value
    966990    CHARACTER(LEN=*),      INTENT(IN), OPTIONAL ::  variable_name           !< name of variable
     
    9951019    ENDIF
    9961020
    997     return_value = save_attribute_in_database( file_name=TRIM( file_name ), &
    998                       variable_name=TRIM( variable_name_internal ),         &
    999                       attribute=attribute, append=append_internal )
     1021    return_value = save_attribute_in_database( file_name=TRIM( file_name ),                        &
     1022                                               variable_name=TRIM( variable_name_internal ),       &
     1023                                               attribute=attribute, append=append_internal )
    10001024
    10011025 END FUNCTION dom_def_att_char
     
    10201044!>                   value=1_1 )
    10211045!--------------------------------------------------------------------------------------------------!
    1022  FUNCTION dom_def_att_int8( file_name, variable_name, attribute_name, value, append ) &
     1046 FUNCTION dom_def_att_int8( file_name, variable_name, attribute_name, value, append )              &
    10231047             RESULT( return_value )
    10241048
     1049    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_def_att_int8'  !< name of routine
     1050
     1051    CHARACTER(LEN=*),      INTENT(IN)           ::  attribute_name          !< name of attribute
    10251052    CHARACTER(LEN=*),      INTENT(IN)           ::  file_name               !< name of file
    1026     CHARACTER(LEN=*),      INTENT(IN)           ::  attribute_name          !< name of attribute
    10271053    CHARACTER(LEN=*),      INTENT(IN), OPTIONAL ::  variable_name           !< name of variable
    10281054    CHARACTER(LEN=charlen)                      ::  variable_name_internal  !< internal copy of variable_name
    1029 
    1030     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_def_att_int8'  !< name of routine
    10311055
    10321056    INTEGER(KIND=1), INTENT(IN) ::  value  !< attribute value
     
    10511075       IF ( append )  THEN
    10521076          return_value = 1
    1053           CALL internal_message( 'error', routine_name //                             &
    1054                                  ': numeric attribute cannot be appended ' //         &
    1055                                  '(attribute "' // TRIM( attribute_name ) //          &
    1056                                  '", variable "' // TRIM( variable_name_internal ) // &
     1077          CALL internal_message( 'error', routine_name //                                          &
     1078                                 ': numeric attribute cannot be appended ' //                      &
     1079                                 '(attribute "' // TRIM( attribute_name ) //                       &
     1080                                 '", variable "' // TRIM( variable_name_internal ) //              &
    10571081                                 '", file "' // TRIM( file_name ) // '")!' )
    10581082       ENDIF
     
    10661090       attribute%value_int8 = value
    10671091
    1068        return_value = save_attribute_in_database( file_name=TRIM( file_name ), &
    1069                          variable_name=TRIM( variable_name_internal ),         &
    1070                          attribute=attribute, append=append_internal )
     1092       return_value = save_attribute_in_database( file_name=TRIM( file_name ),                     &
     1093                                                  variable_name=TRIM( variable_name_internal ),    &
     1094                                                  attribute=attribute, append=append_internal )
    10711095    ENDIF
    10721096
     
    10921116!>                   value=1_2 )
    10931117!--------------------------------------------------------------------------------------------------!
    1094  FUNCTION dom_def_att_int16( file_name, variable_name, attribute_name, value, append ) &
     1118 FUNCTION dom_def_att_int16( file_name, variable_name, attribute_name, value, append )             &
    10951119             RESULT( return_value )
    10961120
     1121    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_def_att_int16'  !< name of routine
     1122
     1123    CHARACTER(LEN=*),      INTENT(IN)           ::  attribute_name          !< name of attribute
    10971124    CHARACTER(LEN=*),      INTENT(IN)           ::  file_name               !< name of file
    1098     CHARACTER(LEN=*),      INTENT(IN)           ::  attribute_name          !< name of attribute
    10991125    CHARACTER(LEN=*),      INTENT(IN), OPTIONAL ::  variable_name           !< name of variable
    11001126    CHARACTER(LEN=charlen)                      ::  variable_name_internal  !< internal copy of variable_name
    1101 
    1102     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_def_att_int16'  !< name of routine
    11031127
    11041128    INTEGER(KIND=2), INTENT(IN) ::  value  !< attribute value
     
    11231147       IF ( append )  THEN
    11241148          return_value = 1
    1125           CALL internal_message( 'error', routine_name //                             &
    1126                                  ': numeric attribute cannot be appended ' //         &
    1127                                  '(attribute "' // TRIM( attribute_name ) //          &
    1128                                  '", variable "' // TRIM( variable_name_internal ) // &
     1149          CALL internal_message( 'error', routine_name //                                          &
     1150                                 ': numeric attribute cannot be appended ' //                      &
     1151                                 '(attribute "' // TRIM( attribute_name ) //                       &
     1152                                 '", variable "' // TRIM( variable_name_internal ) //              &
    11291153                                 '", file "' // TRIM( file_name ) // '")!' )
    11301154       ENDIF
     
    11381162       attribute%value_int16 = value
    11391163
    1140        return_value = save_attribute_in_database( file_name=TRIM( file_name ), &
    1141                          variable_name=TRIM( variable_name_internal ),         &
    1142                          attribute=attribute, append=append_internal )
     1164       return_value = save_attribute_in_database( file_name=TRIM( file_name ),                     &
     1165                                                  variable_name=TRIM( variable_name_internal ),    &
     1166                                                  attribute=attribute, append=append_internal )
    11431167    ENDIF
    11441168
     
    11641188!>                   value=1_4 )
    11651189!--------------------------------------------------------------------------------------------------!
    1166  FUNCTION dom_def_att_int32( file_name, variable_name, attribute_name, value, append ) &
     1190 FUNCTION dom_def_att_int32( file_name, variable_name, attribute_name, value, append )             &
    11671191             RESULT( return_value )
    11681192
     1193    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_def_att_int32'  !< name of routine
     1194
     1195
     1196    CHARACTER(LEN=*),      INTENT(IN)           ::  attribute_name          !< name of attribute
    11691197    CHARACTER(LEN=*),      INTENT(IN)           ::  file_name               !< name of file
    1170     CHARACTER(LEN=*),      INTENT(IN)           ::  attribute_name          !< name of attribute
    11711198    CHARACTER(LEN=*),      INTENT(IN), OPTIONAL ::  variable_name           !< name of variable
    11721199    CHARACTER(LEN=charlen)                      ::  variable_name_internal  !< internal copy of variable_name
    1173 
    1174     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_def_att_int32'  !< name of routine
    11751200
    11761201    INTEGER(KIND=4), INTENT(IN) ::  value  !< attribute value
     
    11951220       IF ( append )  THEN
    11961221          return_value = 1
    1197           CALL internal_message( 'error', routine_name //                             &
    1198                                  ': numeric attribute cannot be appended ' //         &
    1199                                  '(attribute "' // TRIM( attribute_name ) //          &
    1200                                  '", variable "' // TRIM( variable_name_internal ) // &
     1222          CALL internal_message( 'error', routine_name //                                          &
     1223                                 ': numeric attribute cannot be appended ' //                      &
     1224                                 '(attribute "' // TRIM( attribute_name ) //                       &
     1225                                 '", variable "' // TRIM( variable_name_internal ) //              &
    12011226                                 '", file "' // TRIM( file_name ) // '")!' )
    12021227       ENDIF
     
    12101235       attribute%value_int32 = value
    12111236
    1212        return_value = save_attribute_in_database( file_name=TRIM( file_name ), &
    1213                          variable_name=TRIM( variable_name_internal ),         &
    1214                          attribute=attribute, append=append_internal )
     1237       return_value = save_attribute_in_database( file_name=TRIM( file_name ),                     &
     1238                                                  variable_name=TRIM( variable_name_internal ),    &
     1239                                                  attribute=attribute, append=append_internal )
    12151240    ENDIF
    12161241
     
    12361261!>                   value=1.0_4 )
    12371262!--------------------------------------------------------------------------------------------------!
    1238  FUNCTION dom_def_att_real32( file_name, variable_name, attribute_name, value, append ) &
     1263 FUNCTION dom_def_att_real32( file_name, variable_name, attribute_name, value, append )            &
    12391264             RESULT( return_value )
    12401265
     1266    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_def_att_real32'  !< name of routine
     1267
     1268    CHARACTER(LEN=*),      INTENT(IN)           ::  attribute_name          !< name of attribute
    12411269    CHARACTER(LEN=*),      INTENT(IN)           ::  file_name               !< name of file
    1242     CHARACTER(LEN=*),      INTENT(IN)           ::  attribute_name          !< name of attribute
    12431270    CHARACTER(LEN=*),      INTENT(IN), OPTIONAL ::  variable_name           !< name of variable
    12441271    CHARACTER(LEN=charlen)                      ::  variable_name_internal  !< internal copy of variable_name
    1245 
    1246     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_def_att_real32'  !< name of routine
    12471272
    12481273    INTEGER ::  return_value  !< return value
     
    12671292       IF ( append )  THEN
    12681293          return_value = 1
    1269           CALL internal_message( 'error', routine_name //                             &
    1270                                  ': numeric attribute cannot be appended ' //         &
    1271                                  '(attribute "' // TRIM( attribute_name ) //          &
    1272                                  '", variable "' // TRIM( variable_name_internal ) // &
     1294          CALL internal_message( 'error', routine_name //                                          &
     1295                                 ': numeric attribute cannot be appended ' //                      &
     1296                                 '(attribute "' // TRIM( attribute_name ) //                       &
     1297                                 '", variable "' // TRIM( variable_name_internal ) //              &
    12731298                                 '", file "' // TRIM( file_name ) // '")!' )
    12741299       ENDIF
     
    12821307       attribute%value_real32 = value
    12831308
    1284        return_value = save_attribute_in_database( file_name=TRIM( file_name ), &
    1285                          variable_name=TRIM( variable_name_internal ),         &
    1286                          attribute=attribute, append=append_internal )
     1309       return_value = save_attribute_in_database( file_name=TRIM( file_name ),                     &
     1310                                                  variable_name=TRIM( variable_name_internal ),    &
     1311                                                  attribute=attribute, append=append_internal )
    12871312    ENDIF
    12881313
     
    13081333!>                   value=1.0_8 )
    13091334!--------------------------------------------------------------------------------------------------!
    1310  FUNCTION dom_def_att_real64( file_name, variable_name, attribute_name, value, append ) &
     1335 FUNCTION dom_def_att_real64( file_name, variable_name, attribute_name, value, append )            &
    13111336             RESULT( return_value )
    13121337
     1338    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_def_att_real64'  !< name of routine
     1339
     1340    CHARACTER(LEN=*),      INTENT(IN)           ::  attribute_name          !< name of attribute
    13131341    CHARACTER(LEN=*),      INTENT(IN)           ::  file_name               !< name of file
    1314     CHARACTER(LEN=*),      INTENT(IN)           ::  attribute_name          !< name of attribute
    13151342    CHARACTER(LEN=*),      INTENT(IN), OPTIONAL ::  variable_name           !< name of variable
    13161343    CHARACTER(LEN=charlen)                      ::  variable_name_internal  !< internal copy of variable_name
    1317 
    1318     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_def_att_real64'  !< name of routine
    13191344
    13201345    INTEGER ::  return_value  !< return value
     
    13391364       IF ( append )  THEN
    13401365          return_value = 1
    1341           CALL internal_message( 'error', routine_name //                             &
    1342                                  ': numeric attribute cannot be appended ' //         &
    1343                                  '(attribute "' // TRIM( attribute_name ) //          &
    1344                                  '", variable "' // TRIM( variable_name_internal ) // &
     1366          CALL internal_message( 'error', routine_name //                                          &
     1367                                 ': numeric attribute cannot be appended ' //                      &
     1368                                 '(attribute "' // TRIM( attribute_name ) //                       &
     1369                                 '", variable "' // TRIM( variable_name_internal ) //              &
    13451370                                 '", file "' // TRIM( file_name ) // '")!' )
    13461371       ENDIF
     
    13541379       attribute%value_real64 = value
    13551380
    1356        return_value = save_attribute_in_database( file_name=TRIM( file_name ), &
    1357                          variable_name=TRIM( variable_name_internal ),         &
    1358                          attribute=attribute, append=append_internal )
     1381       return_value = save_attribute_in_database( file_name=TRIM( file_name ),                     &
     1382                                                  variable_name=TRIM( variable_name_internal ),    &
     1383                                                  attribute=attribute, append=append_internal )
    13591384    ENDIF
    13601385
     
    14081433          IF ( files(f)%is_init )  CYCLE
    14091434
    1410           CALL internal_message( 'debug', routine_name // ': initialize file "' // &
     1435          CALL internal_message( 'debug', routine_name // ': initialize file "' //                 &
    14111436                                 TRIM( files(f)%name ) // '"' )
    14121437!
    14131438!--       Open file
    1414           CALL open_output_file( files(f)%format, files(f)%name, files(f)%id, &
     1439          CALL open_output_file( files(f)%format, files(f)%name, files(f)%id,                      &
    14151440                                 return_value=return_value )
    14161441!
    14171442!--       Initialize file header:
    14181443!--       define dimensions and variables and write attributes
    1419           IF ( return_value == 0 )  &
    1420              CALL init_file_header( files(f), return_value=return_value )
     1444          IF ( return_value == 0 )  CALL init_file_header( files(f), return_value=return_value )
    14211445!
    14221446!--       End file definition
    1423           IF ( return_value == 0 )  &
    1424              CALL stop_file_header_definition( files(f)%format, files(f)%id, &
    1425                                                files(f)%name, return_value )
     1447          IF ( return_value == 0 )                                                                 &
     1448             CALL stop_file_header_definition( files(f)%format, files(f)%id, files(f)%name,        &
     1449                                               return_value )
    14261450
    14271451          IF ( return_value == 0 )  THEN
     
    14331457             DO  d = 1, SIZE( files(f)%dimensions )
    14341458                IF ( ALLOCATED( files(f)%dimensions(d)%values_int8 ) )  THEN
    1435                    ALLOCATE( values_int8(files(f)%dimensions(d)%bounds(1): &
     1459                   ALLOCATE( values_int8(files(f)%dimensions(d)%bounds(1):                         &
    14361460                                         files(f)%dimensions(d)%bounds(2)) )
    14371461                   values_int8 = files(f)%dimensions(d)%values_int8
    14381462                   values_int8_pointer => values_int8
    1439                    return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, &
    1440                                      bounds_start=(/ files(f)%dimensions(d)%bounds(1) /),    &
    1441                                      bounds_end  =(/ files(f)%dimensions(d)%bounds(2) /),    &
     1463                   return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name,       &
     1464                                     bounds_start=(/ files(f)%dimensions(d)%bounds(1) /),          &
     1465                                     bounds_end  =(/ files(f)%dimensions(d)%bounds(2) /),          &
    14421466                                     values_int8_1d=values_int8_pointer )
    14431467                   DEALLOCATE( values_int8 )
    14441468                ELSEIF ( ALLOCATED( files(f)%dimensions(d)%values_int16 ) )  THEN
    1445                    ALLOCATE( values_int16(files(f)%dimensions(d)%bounds(1): &
     1469                   ALLOCATE( values_int16(files(f)%dimensions(d)%bounds(1):                        &
    14461470                                          files(f)%dimensions(d)%bounds(2)) )
    14471471                   values_int16 = files(f)%dimensions(d)%values_int16
    14481472                   values_int16_pointer => values_int16
    1449                    return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, &
    1450                                      bounds_start=(/ files(f)%dimensions(d)%bounds(1) /),    &
    1451                                      bounds_end  =(/ files(f)%dimensions(d)%bounds(2) /),    &
     1473                   return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name,       &
     1474                                     bounds_start=(/ files(f)%dimensions(d)%bounds(1) /),          &
     1475                                     bounds_end  =(/ files(f)%dimensions(d)%bounds(2) /),          &
    14521476                                     values_int16_1d=values_int16_pointer )
    14531477                   DEALLOCATE( values_int16 )
    14541478                ELSEIF ( ALLOCATED( files(f)%dimensions(d)%values_int32 ) )  THEN
    1455                    ALLOCATE( values_int32(files(f)%dimensions(d)%bounds(1): &
     1479                   ALLOCATE( values_int32(files(f)%dimensions(d)%bounds(1):                        &
    14561480                                          files(f)%dimensions(d)%bounds(2)) )
    14571481                   values_int32 = files(f)%dimensions(d)%values_int32
    14581482                   values_int32_pointer => values_int32
    1459                    return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, &
    1460                                      bounds_start=(/ files(f)%dimensions(d)%bounds(1) /),    &
    1461                                      bounds_end  =(/ files(f)%dimensions(d)%bounds(2) /),    &
     1483                   return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name,       &
     1484                                     bounds_start=(/ files(f)%dimensions(d)%bounds(1) /),          &
     1485                                     bounds_end  =(/ files(f)%dimensions(d)%bounds(2) /),          &
    14621486                                     values_int32_1d=values_int32_pointer )
    14631487                   DEALLOCATE( values_int32 )
    14641488                ELSEIF ( ALLOCATED( files(f)%dimensions(d)%values_intwp ) )  THEN
    1465                    ALLOCATE( values_intwp(files(f)%dimensions(d)%bounds(1): &
     1489                   ALLOCATE( values_intwp(files(f)%dimensions(d)%bounds(1):                        &
    14661490                                          files(f)%dimensions(d)%bounds(2)) )
    14671491                   values_intwp = files(f)%dimensions(d)%values_intwp
    14681492                   values_intwp_pointer => values_intwp
    1469                    return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, &
    1470                                      bounds_start=(/ files(f)%dimensions(d)%bounds(1) /),    &
    1471                                      bounds_end  =(/ files(f)%dimensions(d)%bounds(2) /),    &
     1493                   return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name,       &
     1494                                     bounds_start=(/ files(f)%dimensions(d)%bounds(1) /),          &
     1495                                     bounds_end  =(/ files(f)%dimensions(d)%bounds(2) /),          &
    14721496                                     values_intwp_1d=values_intwp_pointer )
    14731497                   DEALLOCATE( values_intwp )
    14741498                ELSEIF ( ALLOCATED( files(f)%dimensions(d)%values_real32 ) )  THEN
    1475                    ALLOCATE( values_real32(files(f)%dimensions(d)%bounds(1): &
     1499                   ALLOCATE( values_real32(files(f)%dimensions(d)%bounds(1):                       &
    14761500                                           files(f)%dimensions(d)%bounds(2)) )
    14771501                   values_real32 = files(f)%dimensions(d)%values_real32
    14781502                   values_real32_pointer => values_real32
    1479                    return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, &
    1480                                      bounds_start=(/ files(f)%dimensions(d)%bounds(1) /),    &
    1481                                      bounds_end  =(/ files(f)%dimensions(d)%bounds(2) /),    &
     1503                   return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name,       &
     1504                                     bounds_start=(/ files(f)%dimensions(d)%bounds(1) /),          &
     1505                                     bounds_end  =(/ files(f)%dimensions(d)%bounds(2) /),          &
    14821506                                     values_real32_1d=values_real32_pointer )
    14831507                   DEALLOCATE( values_real32 )
    14841508                ELSEIF ( ALLOCATED( files(f)%dimensions(d)%values_real64 ) )  THEN
    1485                    ALLOCATE( values_real64(files(f)%dimensions(d)%bounds(1): &
     1509                   ALLOCATE( values_real64(files(f)%dimensions(d)%bounds(1):                       &
    14861510                                           files(f)%dimensions(d)%bounds(2)) )
    14871511                   values_real64 = files(f)%dimensions(d)%values_real64
    14881512                   values_real64_pointer => values_real64
    1489                    return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, &
    1490                                      bounds_start=(/ files(f)%dimensions(d)%bounds(1) /),    &
    1491                                      bounds_end  =(/ files(f)%dimensions(d)%bounds(2) /),    &
     1513                   return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name,       &
     1514                                     bounds_start=(/ files(f)%dimensions(d)%bounds(1) /),          &
     1515                                     bounds_end  =(/ files(f)%dimensions(d)%bounds(2) /),          &
    14921516                                     values_real64_1d=values_real64_pointer )
    14931517                   DEALLOCATE( values_real64 )
    14941518                ELSEIF ( ALLOCATED( files(f)%dimensions(d)%values_realwp ) )  THEN
    1495                    ALLOCATE( values_realwp(files(f)%dimensions(d)%bounds(1): &
     1519                   ALLOCATE( values_realwp(files(f)%dimensions(d)%bounds(1):                       &
    14961520                                           files(f)%dimensions(d)%bounds(2)) )
    14971521                   values_realwp = files(f)%dimensions(d)%values_realwp
    14981522                   values_realwp_pointer => values_realwp
    1499                    return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name, &
    1500                                      bounds_start=(/ files(f)%dimensions(d)%bounds(1) /),    &
    1501                                      bounds_end  =(/ files(f)%dimensions(d)%bounds(2) /),    &
     1523                   return_value = dom_write_var( files(f)%name, files(f)%dimensions(d)%name,       &
     1524                                     bounds_start=(/ files(f)%dimensions(d)%bounds(1) /),          &
     1525                                     bounds_end  =(/ files(f)%dimensions(d)%bounds(2) /),          &
    15021526                                     values_realwp_1d=values_realwp_pointer )
    15031527                   DEALLOCATE( values_realwp )
     
    15381562!>       chosen, the values are written to file as given in the 'dom_write_var' call.
    15391563!--------------------------------------------------------------------------------------------------!
    1540  FUNCTION dom_write_var( file_name, variable_name, bounds_start, bounds_end,         &
    1541              values_char_0d,   values_char_1d,   values_char_2d,   values_char_3d,   &
    1542              values_int8_0d,   values_int8_1d,   values_int8_2d,   values_int8_3d,   &
    1543              values_int16_0d,  values_int16_1d,  values_int16_2d,  values_int16_3d,  &
    1544              values_int32_0d,  values_int32_1d,  values_int32_2d,  values_int32_3d,  &
    1545              values_intwp_0d,  values_intwp_1d,  values_intwp_2d,  values_intwp_3d,  &
    1546              values_real32_0d, values_real32_1d, values_real32_2d, values_real32_3d, &
    1547              values_real64_0d, values_real64_1d, values_real64_2d, values_real64_3d, &
    1548              values_realwp_0d, values_realwp_1d, values_realwp_2d, values_realwp_3d  &
     1564 FUNCTION dom_write_var( file_name, variable_name, bounds_start, bounds_end,                       &
     1565             values_char_0d,   values_char_1d,   values_char_2d,   values_char_3d,                 &
     1566             values_int8_0d,   values_int8_1d,   values_int8_2d,   values_int8_3d,                 &
     1567             values_int16_0d,  values_int16_1d,  values_int16_2d,  values_int16_3d,                &
     1568             values_int32_0d,  values_int32_1d,  values_int32_2d,  values_int32_3d,                &
     1569             values_intwp_0d,  values_intwp_1d,  values_intwp_2d,  values_intwp_3d,                &
     1570             values_real32_0d, values_real32_1d, values_real32_2d, values_real32_3d,               &
     1571             values_real64_0d, values_real64_1d, values_real64_2d, values_real64_3d,               &
     1572             values_realwp_0d, values_realwp_1d, values_realwp_2d, values_realwp_3d                &
    15491573             ) RESULT( return_value )
     1574
     1575    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_write_var'  !< name of routine
    15501576
    15511577    CHARACTER(LEN=charlen)            ::  file_format    !< file format chosen for file
    15521578    CHARACTER(LEN=*),      INTENT(IN) ::  file_name      !< name of file
    15531579    CHARACTER(LEN=*),      INTENT(IN) ::  variable_name  !< name of variable
    1554 
    1555     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_write_var'  !< name of routine
    15561580
    15571581    CHARACTER(LEN=1), POINTER, INTENT(IN), OPTIONAL                   ::  values_char_0d           !< output variable
     
    15791603    INTEGER, DIMENSION(:),   INTENT(IN)  ::  bounds_end             !< end index per dimension of variable
    15801604    INTEGER, DIMENSION(:),   INTENT(IN)  ::  bounds_start           !< start index per dimension of variable
     1605
    15811606    INTEGER, DIMENSION(:),   ALLOCATABLE ::  bounds_origin          !< first index of each dimension
    15821607    INTEGER, DIMENSION(:),   ALLOCATABLE ::  bounds_start_internal  !< start index per dim. for output after masking
     
    16041629    INTEGER(iwp),    POINTER, INTENT(IN), OPTIONAL, DIMENSION(:,:,:) ::  values_intwp_3d            !< output variable
    16051630
    1606     INTEGER(KIND=1), TARGET, ALLOCATABLE, DIMENSION(:)               ::  values_int8_1d_resorted    !< resorted output variable
    1607     INTEGER(KIND=2), TARGET, ALLOCATABLE, DIMENSION(:)               ::  values_int16_1d_resorted   !< resorted output variable
    1608     INTEGER(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:)               ::  values_int32_1d_resorted   !< resorted output variable
    1609     INTEGER(iwp),    TARGET, ALLOCATABLE, DIMENSION(:)               ::  values_intwp_1d_resorted   !< resorted output variable
    1610     INTEGER(KIND=1), TARGET, ALLOCATABLE, DIMENSION(:,:)             ::  values_int8_2d_resorted    !< resorted output variable
    1611     INTEGER(KIND=2), TARGET, ALLOCATABLE, DIMENSION(:,:)             ::  values_int16_2d_resorted   !< resorted output variable
    1612     INTEGER(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:,:)             ::  values_int32_2d_resorted   !< resorted output variable
    1613     INTEGER(iwp),    TARGET, ALLOCATABLE, DIMENSION(:,:)             ::  values_intwp_2d_resorted   !< resorted output variable
    1614     INTEGER(KIND=1), TARGET, ALLOCATABLE, DIMENSION(:,:,:)           ::  values_int8_3d_resorted    !< resorted output variable
    1615     INTEGER(KIND=2), TARGET, ALLOCATABLE, DIMENSION(:,:,:)           ::  values_int16_3d_resorted   !< resorted output variable
    1616     INTEGER(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:,:,:)           ::  values_int32_3d_resorted   !< resorted output variable
    1617     INTEGER(iwp),    TARGET, ALLOCATABLE, DIMENSION(:,:,:)           ::  values_intwp_3d_resorted   !< resorted output variable
    1618 
    16191631    INTEGER(KIND=1), POINTER                                         ::  values_int8_0d_pointer     !< pointer to resortet array
    16201632    INTEGER(KIND=2), POINTER                                         ::  values_int16_0d_pointer    !< pointer to resortet array
     
    16341646    INTEGER(iwp),    POINTER, CONTIGUOUS, DIMENSION(:,:,:)           ::  values_intwp_3d_pointer    !< pointer to resortet array
    16351647
     1648    INTEGER(KIND=1), TARGET, ALLOCATABLE, DIMENSION(:)               ::  values_int8_1d_resorted    !< resorted output variable
     1649    INTEGER(KIND=2), TARGET, ALLOCATABLE, DIMENSION(:)               ::  values_int16_1d_resorted   !< resorted output variable
     1650    INTEGER(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:)               ::  values_int32_1d_resorted   !< resorted output variable
     1651    INTEGER(iwp),    TARGET, ALLOCATABLE, DIMENSION(:)               ::  values_intwp_1d_resorted   !< resorted output variable
     1652    INTEGER(KIND=1), TARGET, ALLOCATABLE, DIMENSION(:,:)             ::  values_int8_2d_resorted    !< resorted output variable
     1653    INTEGER(KIND=2), TARGET, ALLOCATABLE, DIMENSION(:,:)             ::  values_int16_2d_resorted   !< resorted output variable
     1654    INTEGER(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:,:)             ::  values_int32_2d_resorted   !< resorted output variable
     1655    INTEGER(iwp),    TARGET, ALLOCATABLE, DIMENSION(:,:)             ::  values_intwp_2d_resorted   !< resorted output variable
     1656    INTEGER(KIND=1), TARGET, ALLOCATABLE, DIMENSION(:,:,:)           ::  values_int8_3d_resorted    !< resorted output variable
     1657    INTEGER(KIND=2), TARGET, ALLOCATABLE, DIMENSION(:,:,:)           ::  values_int16_3d_resorted   !< resorted output variable
     1658    INTEGER(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:,:,:)           ::  values_int32_3d_resorted   !< resorted output variable
     1659    INTEGER(iwp),    TARGET, ALLOCATABLE, DIMENSION(:,:,:)           ::  values_intwp_3d_resorted   !< resorted output variable
     1660
    16361661    REAL(KIND=4), POINTER, INTENT(IN), OPTIONAL                      ::  values_real32_0d           !< output variable
    16371662    REAL(KIND=8), POINTER, INTENT(IN), OPTIONAL                      ::  values_real64_0d           !< output variable
     
    16471672    REAL(wp),     POINTER, INTENT(IN), OPTIONAL, DIMENSION(:,:,:)    ::  values_realwp_3d           !< output variable
    16481673
    1649     REAL(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:)                  ::  values_real32_1d_resorted  !< resorted output variable
    1650     REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:)                  ::  values_real64_1d_resorted  !< resorted output variable
    1651     REAL(wp),     TARGET, ALLOCATABLE, DIMENSION(:)                  ::  values_realwp_1d_resorted  !< resorted output variable
    1652     REAL(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:,:)                ::  values_real32_2d_resorted  !< resorted output variable
    1653     REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:)                ::  values_real64_2d_resorted  !< resorted output variable
    1654     REAL(wp),     TARGET, ALLOCATABLE, DIMENSION(:,:)                ::  values_realwp_2d_resorted  !< resorted output variable
    1655     REAL(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:,:,:)              ::  values_real32_3d_resorted  !< resorted output variable
    1656     REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:,:)              ::  values_real64_3d_resorted  !< resorted output variable
    1657     REAL(wp),     TARGET, ALLOCATABLE, DIMENSION(:,:,:)              ::  values_realwp_3d_resorted  !< resorted output variable
    1658 
    16591674    REAL(KIND=4), POINTER                                            ::  values_real32_0d_pointer   !< pointer to resortet array
    16601675    REAL(KIND=8), POINTER                                            ::  values_real64_0d_pointer   !< pointer to resortet array
     
    16701685    REAL(wp),     POINTER, CONTIGUOUS, DIMENSION(:,:,:)              ::  values_realwp_3d_pointer   !< pointer to resortet array
    16711686
     1687    REAL(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:)                  ::  values_real32_1d_resorted  !< resorted output variable
     1688    REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:)                  ::  values_real64_1d_resorted  !< resorted output variable
     1689    REAL(wp),     TARGET, ALLOCATABLE, DIMENSION(:)                  ::  values_realwp_1d_resorted  !< resorted output variable
     1690    REAL(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:,:)                ::  values_real32_2d_resorted  !< resorted output variable
     1691    REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:)                ::  values_real64_2d_resorted  !< resorted output variable
     1692    REAL(wp),     TARGET, ALLOCATABLE, DIMENSION(:,:)                ::  values_realwp_2d_resorted  !< resorted output variable
     1693    REAL(KIND=4), TARGET, ALLOCATABLE, DIMENSION(:,:,:)              ::  values_real32_3d_resorted  !< resorted output variable
     1694    REAL(KIND=8), TARGET, ALLOCATABLE, DIMENSION(:,:,:)              ::  values_real64_3d_resorted  !< resorted output variable
     1695    REAL(wp),     TARGET, ALLOCATABLE, DIMENSION(:,:,:)              ::  values_realwp_3d_resorted  !< resorted output variable
     1696
    16721697    TYPE(dimension_type), DIMENSION(:), ALLOCATABLE ::  dimension_list  !< list of used dimensions of variable
    16731698
     
    16761701    output_return_value = 0
    16771702
    1678     CALL internal_message( 'debug', routine_name // ': write ' // TRIM( variable_name ) // &
     1703    CALL internal_message( 'debug', routine_name // ': write ' // TRIM( variable_name ) //         &
    16791704                           ' into file ' // TRIM( file_name ) )
    16801705!
    16811706!-- Search for variable within file
    1682     CALL find_var_in_file( file_name, variable_name, file_format, file_id, variable_id, &
     1707    CALL find_var_in_file( file_name, variable_name, file_format, file_id, variable_id,            &
    16831708                           is_global, dimension_list, return_value=return_value  )
    16841709
     
    16861711!
    16871712!--    Check if the correct amount of variable bounds were given
    1688        IF ( SIZE( bounds_start ) /= SIZE( dimension_list )  .OR.  &
    1689             SIZE( bounds_end ) /= SIZE( dimension_list ) )  THEN
     1713       IF ( SIZE( bounds_start ) /= SIZE( dimension_list )  .OR.                                   &
     1714            SIZE( bounds_end )   /= SIZE( dimension_list ) )  THEN
    16901715          return_value = 1
    1691           CALL internal_message( 'error', routine_name //                  &
    1692                                  ': number bounds do not match with ' //   &
    1693                                  'number of dimensions of variable ' //    &
    1694                                  '(variable "' // TRIM( variable_name ) // &
     1716          CALL internal_message( 'error', routine_name //                                          &
     1717                                 ': number bounds do not match with ' //                           &
     1718                                 'number of dimensions of variable ' //                            &
     1719                                 '(variable "' // TRIM( variable_name ) //                         &
    16951720                                 '", file "' // TRIM( file_name ) // '")!' )
    16961721       ENDIF
     
    17061731
    17071732       WRITE( temp_string, * ) bounds_start
    1708        CALL internal_message( 'debug', routine_name //                    &
    1709                               ': file "' // TRIM( file_name ) //          &
    1710                               '", variable "' // TRIM( variable_name ) // &
     1733       CALL internal_message( 'debug', routine_name //                                             &
     1734                              ': file "' // TRIM( file_name ) //                                   &
     1735                              '", variable "' // TRIM( variable_name ) //                          &
    17111736                              '", bounds_start =' // TRIM( temp_string ) )
    17121737       WRITE( temp_string, * ) bounds_end
    1713        CALL internal_message( 'debug', routine_name //                    &
    1714                               ': file "' // TRIM( file_name ) //          &
    1715                               '", variable "' // TRIM( variable_name ) // &
     1738       CALL internal_message( 'debug', routine_name //                                             &
     1739                              ': file "' // TRIM( file_name ) //                                   &
     1740                              '", variable "' // TRIM( variable_name ) //                          &
    17161741                              '", bounds_end =' // TRIM( temp_string ) )
    17171742!
    17181743!--    Get bounds for masking
    1719        CALL get_masked_indices_and_masked_dimension_bounds( dimension_list,                  &
    1720                bounds_start, bounds_end, bounds_start_internal, value_counts, bounds_origin, &
    1721                masked_indices )
     1744       CALL get_masked_indices_and_masked_dimension_bounds( dimension_list, bounds_start,          &
     1745               bounds_end, bounds_start_internal, value_counts, bounds_origin, masked_indices )
    17221746
    17231747       do_output = .NOT. ANY( value_counts == 0 )
    17241748
    17251749       WRITE( temp_string, * ) bounds_start_internal
    1726        CALL internal_message( 'debug', routine_name //                    &
    1727                               ': file "' // TRIM( file_name ) //          &
    1728                               '", variable "' // TRIM( variable_name ) // &
     1750       CALL internal_message( 'debug', routine_name //                                             &
     1751                              ': file "' // TRIM( file_name ) //                                   &
     1752                              '", variable "' // TRIM( variable_name ) //                          &
    17291753                              '", bounds_start_internal =' // TRIM( temp_string ) )
    17301754       WRITE( temp_string, * ) value_counts
    1731        CALL internal_message( 'debug', routine_name //                    &
    1732                               ': file "' // TRIM( file_name ) //          &
    1733                               '", variable "' // TRIM( variable_name ) // &
     1755       CALL internal_message( 'debug', routine_name //                                             &
     1756                              ': file "' // TRIM( file_name ) //                                   &
     1757                              '", variable "' // TRIM( variable_name ) //                          &
    17341758                              '", value_counts =' // TRIM( temp_string ) )
    17351759!
     
    17541778       ELSEIF ( PRESENT( values_char_2d ) )  THEN
    17551779          IF ( do_output ) THEN
    1756              ALLOCATE( values_char_2d_resorted(0:value_counts(1)-1, &
    1757                                                0:value_counts(2)-1) )
     1780             ALLOCATE( values_char_2d_resorted(0:value_counts(1)-1,0:value_counts(2)-1) )
    17581781             !$OMP PARALLEL PRIVATE (i,j)
    17591782             !$OMP DO
    17601783             DO  i = 0, value_counts(1) - 1
    17611784                DO  j = 0, value_counts(2) - 1
    1762                    values_char_2d_resorted(i,j) = values_char_2d(masked_indices(2,j), &
    1763                                                                  masked_indices(1,i)  )
     1785                   values_char_2d_resorted(i,j) = values_char_2d(masked_indices(2,j),              &
     1786                                                                 masked_indices(1,i))
    17641787                ENDDO
    17651788             ENDDO
     
    17721795       ELSEIF ( PRESENT( values_char_3d ) )  THEN
    17731796          IF ( do_output ) THEN
    1774              ALLOCATE( values_char_3d_resorted(0:value_counts(1)-1, &
    1775                                                0:value_counts(2)-1, &
     1797             ALLOCATE( values_char_3d_resorted(0:value_counts(1)-1,                                &
     1798                                               0:value_counts(2)-1,                                &
    17761799                                               0:value_counts(3)-1) )
    17771800             !$OMP PARALLEL PRIVATE (i,j,k)
     
    17801803                DO  j = 0, value_counts(2) - 1
    17811804                   DO  k = 0, value_counts(3) - 1
    1782                       values_char_3d_resorted(i,j,k) = values_char_3d(masked_indices(3,k), &
    1783                                                                       masked_indices(2,j), &
    1784                                                                       masked_indices(1,i)  )
     1805                      values_char_3d_resorted(i,j,k) = values_char_3d(masked_indices(3,k),         &
     1806                                                                      masked_indices(2,j),         &
     1807                                                                      masked_indices(1,i))
    17851808                   ENDDO
    17861809                ENDDO
     
    18121835       ELSEIF ( PRESENT( values_int8_2d ) )  THEN
    18131836          IF ( do_output ) THEN
    1814              ALLOCATE( values_int8_2d_resorted(0:value_counts(1)-1, &
    1815                                                0:value_counts(2)-1) )
     1837             ALLOCATE( values_int8_2d_resorted(0:value_counts(1)-1,0:value_counts(2)-1) )
    18161838             !$OMP PARALLEL PRIVATE (i,j)
    18171839             !$OMP DO
    18181840             DO  i = 0, value_counts(1) - 1
    18191841                DO  j = 0, value_counts(2) - 1
    1820                    values_int8_2d_resorted(i,j) = values_int8_2d(masked_indices(2,j), &
    1821                                                                  masked_indices(1,i)  )
     1842                   values_int8_2d_resorted(i,j) = values_int8_2d(masked_indices(2,j),              &
     1843                                                                 masked_indices(1,i))
    18221844                ENDDO
    18231845             ENDDO
     
    18301852       ELSEIF ( PRESENT( values_int8_3d ) )  THEN
    18311853          IF ( do_output ) THEN
    1832              ALLOCATE( values_int8_3d_resorted(0:value_counts(1)-1, &
    1833                                                0:value_counts(2)-1, &
     1854             ALLOCATE( values_int8_3d_resorted(0:value_counts(1)-1,                                &
     1855                                               0:value_counts(2)-1,                                &
    18341856                                               0:value_counts(3)-1) )
    18351857             !$OMP PARALLEL PRIVATE (i,j,k)
     
    18381860                DO  j = 0, value_counts(2) - 1
    18391861                   DO  k = 0, value_counts(3) - 1
    1840                       values_int8_3d_resorted(i,j,k) = values_int8_3d(masked_indices(3,k), &
    1841                                                                       masked_indices(2,j), &
     1862                      values_int8_3d_resorted(i,j,k) = values_int8_3d(masked_indices(3,k),         &
     1863                                                                      masked_indices(2,j),         &
    18421864                                                                      masked_indices(1,i)  )
    18431865                   ENDDO
     
    18701892       ELSEIF ( PRESENT( values_int16_2d ) )  THEN
    18711893          IF ( do_output ) THEN
    1872              ALLOCATE( values_int16_2d_resorted(0:value_counts(1)-1, &
    1873                                                 0:value_counts(2)-1) )
     1894             ALLOCATE( values_int16_2d_resorted(0:value_counts(1)-1,0:value_counts(2)-1) )
    18741895             !$OMP PARALLEL PRIVATE (i,j)
    18751896             !$OMP DO
    18761897             DO  i = 0, value_counts(1) - 1
    18771898                DO  j = 0, value_counts(2) - 1
    1878                    values_int16_2d_resorted(i,j) = values_int16_2d(masked_indices(2,j), &
     1899                   values_int16_2d_resorted(i,j) = values_int16_2d(masked_indices(2,j),            &
    18791900                                                                   masked_indices(1,i))
    18801901                ENDDO
     
    18881909       ELSEIF ( PRESENT( values_int16_3d ) )  THEN
    18891910          IF ( do_output ) THEN
    1890              ALLOCATE( values_int16_3d_resorted(0:value_counts(1)-1, &
    1891                                                 0:value_counts(2)-1, &
     1911             ALLOCATE( values_int16_3d_resorted(0:value_counts(1)-1,                               &
     1912                                                0:value_counts(2)-1,                               &
    18921913                                                0:value_counts(3)-1) )
    18931914             !$OMP PARALLEL PRIVATE (i,j,k)
     
    18961917                DO  j = 0, value_counts(2) - 1
    18971918                   DO  k = 0, value_counts(3) - 1
    1898                       values_int16_3d_resorted(i,j,k) = values_int16_3d(masked_indices(3,k), &
    1899                                                                         masked_indices(2,j), &
    1900                                                                         masked_indices(1,i)  )
     1919                      values_int16_3d_resorted(i,j,k) = values_int16_3d(masked_indices(3,k),       &
     1920                                                                        masked_indices(2,j),       &
     1921                                                                        masked_indices(1,i))
    19011922                   ENDDO
    19021923                ENDDO
     
    19281949       ELSEIF ( PRESENT( values_int32_2d ) )  THEN
    19291950          IF ( do_output ) THEN
    1930              ALLOCATE( values_int32_2d_resorted(0:value_counts(1)-1, &
    1931                                                 0:value_counts(2)-1) )
     1951             ALLOCATE( values_int32_2d_resorted(0:value_counts(1)-1,0:value_counts(2)-1) )
    19321952             !$OMP PARALLEL PRIVATE (i,j)
    19331953             !$OMP DO
    19341954             DO  i = 0, value_counts(1) - 1
    19351955                DO  j = 0, value_counts(2) - 1
    1936                    values_int32_2d_resorted(i,j) = values_int32_2d(masked_indices(2,j), &
    1937                                                                    masked_indices(1,i)  )
     1956                   values_int32_2d_resorted(i,j) = values_int32_2d(masked_indices(2,j),            &
     1957                                                                   masked_indices(1,i))
    19381958                ENDDO
    19391959             ENDDO
     
    19461966       ELSEIF ( PRESENT( values_int32_3d ) )  THEN
    19471967          IF ( do_output ) THEN
    1948              ALLOCATE( values_int32_3d_resorted(0:value_counts(1)-1, &
    1949                                                 0:value_counts(2)-1, &
     1968             ALLOCATE( values_int32_3d_resorted(0:value_counts(1)-1,                               &
     1969                                                0:value_counts(2)-1,                               &
    19501970                                                0:value_counts(3)-1) )
    19511971             !$OMP PARALLEL PRIVATE (i,j,k)
     
    19541974                DO  j = 0, value_counts(2) - 1
    19551975                   DO  k = 0, value_counts(3) - 1
    1956                       values_int32_3d_resorted(i,j,k) = values_int32_3d(masked_indices(3,k), &
    1957                                                                         masked_indices(2,j), &
    1958                                                                         masked_indices(1,i)  )
     1976                      values_int32_3d_resorted(i,j,k) = values_int32_3d(masked_indices(3,k),       &
     1977                                                                        masked_indices(2,j),       &
     1978                                                                        masked_indices(1,i))
    19591979                   ENDDO
    19601980                ENDDO
     
    19671987          values_int32_3d_pointer => values_int32_3d_resorted
    19681988!
    1969 !--    working-precision integer output
     1989!--    Working-precision integer output
    19701990       ELSEIF ( PRESENT( values_intwp_0d ) )  THEN
    19711991          values_intwp_0d_pointer => values_intwp_0d
     
    19862006       ELSEIF ( PRESENT( values_intwp_2d ) )  THEN
    19872007          IF ( do_output ) THEN
    1988              ALLOCATE( values_intwp_2d_resorted(0:value_counts(1)-1, &
    1989                                                 0:value_counts(2)-1) )
     2008             ALLOCATE( values_intwp_2d_resorted(0:value_counts(1)-1,0:value_counts(2)-1) )
    19902009             !$OMP PARALLEL PRIVATE (i,j)
    19912010             !$OMP DO
    19922011             DO  i = 0, value_counts(1) - 1
    19932012                DO  j = 0, value_counts(2) - 1
    1994                    values_intwp_2d_resorted(i,j) = values_intwp_2d(masked_indices(2,j), &
    1995                                                                    masked_indices(1,i)  )
     2013                   values_intwp_2d_resorted(i,j) = values_intwp_2d(masked_indices(2,j),            &
     2014                                                                   masked_indices(1,i))
    19962015                ENDDO
    19972016             ENDDO
     
    20042023       ELSEIF ( PRESENT( values_intwp_3d ) )  THEN
    20052024          IF ( do_output ) THEN
    2006              ALLOCATE( values_intwp_3d_resorted(0:value_counts(1)-1, &
    2007                                                 0:value_counts(2)-1, &
     2025             ALLOCATE( values_intwp_3d_resorted(0:value_counts(1)-1,                               &
     2026                                                0:value_counts(2)-1,                               &
    20082027                                                0:value_counts(3)-1) )
    20092028             !$OMP PARALLEL PRIVATE (i,j,k)
     
    20122031                DO  j = 0, value_counts(2) - 1
    20132032                   DO  k = 0, value_counts(3) - 1
    2014                       values_intwp_3d_resorted(i,j,k) = values_intwp_3d(masked_indices(3,k), &
    2015                                                                         masked_indices(2,j), &
    2016                                                                         masked_indices(1,i)  )
     2033                      values_intwp_3d_resorted(i,j,k) = values_intwp_3d(masked_indices(3,k),       &
     2034                                                                        masked_indices(2,j),       &
     2035                                                                        masked_indices(1,i))
    20172036                   ENDDO
    20182037                ENDDO
     
    20442063       ELSEIF ( PRESENT( values_real32_2d ) )  THEN
    20452064          IF ( do_output ) THEN
    2046              ALLOCATE( values_real32_2d_resorted(0:value_counts(1)-1, &
    2047                                                  0:value_counts(2)-1) )
     2065             ALLOCATE( values_real32_2d_resorted(0:value_counts(1)-1,0:value_counts(2)-1) )
    20482066             !$OMP PARALLEL PRIVATE (i,j)
    20492067             !$OMP DO
    20502068             DO  i = 0, value_counts(1) - 1
    20512069                DO  j = 0, value_counts(2) - 1
    2052                    values_real32_2d_resorted(i,j) = values_real32_2d(masked_indices(2,j), &
    2053                                                                      masked_indices(1,i)  )
     2070                   values_real32_2d_resorted(i,j) = values_real32_2d(masked_indices(2,j),          &
     2071                                                                     masked_indices(1,i))
    20542072                ENDDO
    20552073             ENDDO
     
    20622080       ELSEIF ( PRESENT( values_real32_3d ) )  THEN
    20632081          IF ( do_output ) THEN
    2064              ALLOCATE( values_real32_3d_resorted(0:value_counts(1)-1, &
    2065                                                  0:value_counts(2)-1, &
     2082             ALLOCATE( values_real32_3d_resorted(0:value_counts(1)-1,                              &
     2083                                                 0:value_counts(2)-1,                              &
    20662084                                                 0:value_counts(3)-1) )
    20672085             !$OMP PARALLEL PRIVATE (i,j,k)
     
    20702088                DO  j = 0, value_counts(2) - 1
    20712089                   DO  k = 0, value_counts(3) - 1
    2072                       values_real32_3d_resorted(i,j,k) = values_real32_3d(masked_indices(3,k), &
    2073                                                                           masked_indices(2,j), &
    2074                                                                           masked_indices(1,i)  )
     2090                      values_real32_3d_resorted(i,j,k) = values_real32_3d(masked_indices(3,k),     &
     2091                                                                          masked_indices(2,j),     &
     2092                                                                          masked_indices(1,i))
    20752093                   ENDDO
    20762094                ENDDO
     
    21022120       ELSEIF ( PRESENT( values_real64_2d ) )  THEN
    21032121          IF ( do_output ) THEN
    2104              ALLOCATE( values_real64_2d_resorted(0:value_counts(1)-1, &
    2105                                                  0:value_counts(2)-1) )
     2122             ALLOCATE( values_real64_2d_resorted(0:value_counts(1)-1,0:value_counts(2)-1) )
    21062123             !$OMP PARALLEL PRIVATE (i,j)
    21072124             !$OMP DO
    21082125             DO  i = 0, value_counts(1) - 1
    21092126                DO  j = 0, value_counts(2) - 1
    2110                    values_real64_2d_resorted(i,j) = values_real64_2d(masked_indices(2,j), &
    2111                                                                      masked_indices(1,i)  )
     2127                   values_real64_2d_resorted(i,j) = values_real64_2d(masked_indices(2,j),          &
     2128                                                                     masked_indices(1,i))
    21122129                ENDDO
    21132130             ENDDO
     
    21202137       ELSEIF ( PRESENT( values_real64_3d ) )  THEN
    21212138          IF ( do_output ) THEN
    2122              ALLOCATE( values_real64_3d_resorted(0:value_counts(1)-1, &
    2123                                                  0:value_counts(2)-1, &
     2139             ALLOCATE( values_real64_3d_resorted(0:value_counts(1)-1,                              &
     2140                                                 0:value_counts(2)-1,                              &
    21242141                                                 0:value_counts(3)-1) )
    21252142             !$OMP PARALLEL PRIVATE (i,j,k)
     
    21282145                DO  j = 0, value_counts(2) - 1
    21292146                   DO  k = 0, value_counts(3) - 1
    2130                       values_real64_3d_resorted(i,j,k) = values_real64_3d(masked_indices(3,k), &
    2131                                                                           masked_indices(2,j), &
    2132                                                                           masked_indices(1,i)  )
     2147                      values_real64_3d_resorted(i,j,k) = values_real64_3d(masked_indices(3,k),     &
     2148                                                                          masked_indices(2,j),     &
     2149                                                                          masked_indices(1,i))
    21332150                   ENDDO
    21342151                ENDDO
     
    21412158          values_real64_3d_pointer => values_real64_3d_resorted
    21422159!
    2143 !--    working-precision real output
     2160!--    Working-precision real output
    21442161       ELSEIF ( PRESENT( values_realwp_0d ) )  THEN
    21452162          values_realwp_0d_pointer => values_realwp_0d
     
    21602177       ELSEIF ( PRESENT( values_realwp_2d ) )  THEN
    21612178          IF ( do_output ) THEN
    2162              ALLOCATE( values_realwp_2d_resorted(0:value_counts(1)-1, &
    2163                                                  0:value_counts(2)-1) )
     2179             ALLOCATE( values_realwp_2d_resorted(0:value_counts(1)-1,0:value_counts(2)-1) )
    21642180             !$OMP PARALLEL PRIVATE (i,j)
    21652181             !$OMP DO
    21662182             DO  i = 0, value_counts(1) - 1
    21672183                DO  j = 0, value_counts(2) - 1
    2168                    values_realwp_2d_resorted(i,j) = values_realwp_2d(masked_indices(2,j), &
    2169                                                                      masked_indices(1,i)  )
     2184                   values_realwp_2d_resorted(i,j) = values_realwp_2d(masked_indices(2,j),          &
     2185                                                                     masked_indices(1,i))
    21702186                ENDDO
    21712187             ENDDO
     
    21782194       ELSEIF ( PRESENT( values_realwp_3d ) )  THEN
    21792195          IF ( do_output ) THEN
    2180              ALLOCATE( values_realwp_3d_resorted(0:value_counts(1)-1, &
    2181                                                  0:value_counts(2)-1, &
     2196             ALLOCATE( values_realwp_3d_resorted(0:value_counts(1)-1,                              &
     2197                                                 0:value_counts(2)-1,                              &
    21822198                                                 0:value_counts(3)-1) )
    21832199             !$OMP PARALLEL PRIVATE (i,j,k)
     
    21862202                DO  j = 0, value_counts(2) - 1
    21872203                   DO  k = 0, value_counts(3) - 1
    2188                       values_realwp_3d_resorted(i,j,k) = values_realwp_3d(masked_indices(3,k), &
    2189                                                                           masked_indices(2,j), &
    2190                                                                           masked_indices(1,i)  )
     2204                      values_realwp_3d_resorted(i,j,k) = values_realwp_3d(masked_indices(3,k),     &
     2205                                                                          masked_indices(2,j),     &
     2206                                                                          masked_indices(1,i))
    21912207                   ENDDO
    21922208                ENDDO
     
    22012217       ELSE
    22022218          return_value = 1
    2203           CALL internal_message( 'error', routine_name //                  &
    2204                                  ': no output values given ' //            &
    2205                                  '(variable "' // TRIM( variable_name ) // &
     2219          CALL internal_message( 'error', routine_name //                                          &
     2220                                 ': no output values given ' //                                    &
     2221                                 '(variable "' // TRIM( variable_name ) //                         &
    22062222                                 '", file "' // TRIM( file_name ) // '")!'  )
    22072223       ENDIF
     
    22182234          CASE ( 'binary' )
    22192235!
    2220 !--          character output
     2236!--          Character output
    22212237             IF ( PRESENT( values_char_0d ) )  THEN
    2222                  CALL binary_write_variable( file_id, variable_id,                      &
    2223                          bounds_start_internal, value_counts, bounds_origin, is_global, &
     2238                 CALL binary_write_variable( file_id, variable_id,                                 &
     2239                         bounds_start_internal, value_counts, bounds_origin, is_global,            &
    22242240                        values_char_0d=values_char_0d_pointer, return_value=output_return_value )
    22252241             ELSEIF ( PRESENT( values_char_1d ) )  THEN
    2226                 CALL binary_write_variable( file_id, variable_id,                      &
    2227                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2242                CALL binary_write_variable( file_id, variable_id,                                  &
     2243                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    22282244                        values_char_1d=values_char_1d_pointer, return_value=output_return_value )
    22292245             ELSEIF ( PRESENT( values_char_2d ) )  THEN
    2230                 CALL binary_write_variable( file_id, variable_id,                      &
    2231                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2246                CALL binary_write_variable( file_id, variable_id,                                  &
     2247                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    22322248                        values_char_2d=values_char_2d_pointer, return_value=output_return_value )
    22332249             ELSEIF ( PRESENT( values_char_3d ) )  THEN
    2234                 CALL binary_write_variable( file_id, variable_id,                      &
    2235                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2250                CALL binary_write_variable( file_id, variable_id,                                  &
     2251                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    22362252                        values_char_3d=values_char_3d_pointer, return_value=output_return_value )
    22372253!
    22382254!--          8bit integer output
    22392255             ELSEIF ( PRESENT( values_int8_0d ) )  THEN
    2240                 CALL binary_write_variable( file_id, variable_id,                      &
    2241                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2256                CALL binary_write_variable( file_id, variable_id,                                  &
     2257                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    22422258                        values_int8_0d=values_int8_0d_pointer, return_value=output_return_value )
    22432259             ELSEIF ( PRESENT( values_int8_1d ) )  THEN
    2244                 CALL binary_write_variable( file_id, variable_id,                      &
    2245                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2260                CALL binary_write_variable( file_id, variable_id,                                  &
     2261                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    22462262                        values_int8_1d=values_int8_1d_pointer, return_value=output_return_value )
    22472263             ELSEIF ( PRESENT( values_int8_2d ) )  THEN
    2248                 CALL binary_write_variable( file_id, variable_id,                      &
    2249                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2264                CALL binary_write_variable( file_id, variable_id,                                  &
     2265                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    22502266                        values_int8_2d=values_int8_2d_pointer, return_value=output_return_value )
    22512267             ELSEIF ( PRESENT( values_int8_3d ) )  THEN
    2252                 CALL binary_write_variable( file_id, variable_id,                      &
    2253                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2268                CALL binary_write_variable( file_id, variable_id,                                  &
     2269                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    22542270                        values_int8_3d=values_int8_3d_pointer, return_value=output_return_value )
    22552271!
    22562272!--          16bit integer output
    22572273             ELSEIF ( PRESENT( values_int16_0d ) )  THEN
    2258                 CALL binary_write_variable( file_id, variable_id,                      &
    2259                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2274                CALL binary_write_variable( file_id, variable_id,                                  &
     2275                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    22602276                        values_int16_0d=values_int16_0d_pointer, return_value=output_return_value )
    22612277             ELSEIF ( PRESENT( values_int16_1d ) )  THEN
    2262                 CALL binary_write_variable( file_id, variable_id,                      &
    2263                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2278                CALL binary_write_variable( file_id, variable_id,                                  &
     2279                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    22642280                        values_int16_1d=values_int16_1d_pointer, return_value=output_return_value )
    22652281             ELSEIF ( PRESENT( values_int16_2d ) )  THEN
    2266                 CALL binary_write_variable( file_id, variable_id,                      &
    2267                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2282                CALL binary_write_variable( file_id, variable_id,                                  &
     2283                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    22682284                        values_int16_2d=values_int16_2d_pointer, return_value=output_return_value )
    22692285             ELSEIF ( PRESENT( values_int16_3d ) )  THEN
    2270                 CALL binary_write_variable( file_id, variable_id,                      &
    2271                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2286                CALL binary_write_variable( file_id, variable_id,                                  &
     2287                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    22722288                        values_int16_3d=values_int16_3d_pointer, return_value=output_return_value )
    22732289!
    22742290!--          32bit integer output
    22752291             ELSEIF ( PRESENT( values_int32_0d ) )  THEN
    2276                 CALL binary_write_variable( file_id, variable_id,                      &
    2277                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2292                CALL binary_write_variable( file_id, variable_id,                                  &
     2293                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    22782294                        values_int32_0d=values_int32_0d_pointer, return_value=output_return_value )
    22792295             ELSEIF ( PRESENT( values_int32_1d ) )  THEN
    2280                 CALL binary_write_variable( file_id, variable_id,                      &
    2281                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2296                CALL binary_write_variable( file_id, variable_id,                                  &
     2297                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    22822298                        values_int32_1d=values_int32_1d_pointer, return_value=output_return_value )
    22832299             ELSEIF ( PRESENT( values_int32_2d ) )  THEN
    2284                 CALL binary_write_variable( file_id, variable_id,                      &
    2285                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2300                CALL binary_write_variable( file_id, variable_id,                                  &
     2301                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    22862302                        values_int32_2d=values_int32_2d_pointer, return_value=output_return_value )
    22872303             ELSEIF ( PRESENT( values_int32_3d ) )  THEN
    2288                 CALL binary_write_variable( file_id, variable_id,                      &
    2289                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2304                CALL binary_write_variable( file_id, variable_id,                                  &
     2305                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    22902306                        values_int32_3d=values_int32_3d_pointer, return_value=output_return_value )
    22912307!
    2292 !--          working-precision integer output
     2308!--          Working-precision integer output
    22932309             ELSEIF ( PRESENT( values_intwp_0d ) )  THEN
    2294                 CALL binary_write_variable( file_id, variable_id,                      &
    2295                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2310                CALL binary_write_variable( file_id, variable_id,                                  &
     2311                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    22962312                        values_intwp_0d=values_intwp_0d_pointer, return_value=output_return_value )
    22972313             ELSEIF ( PRESENT( values_intwp_1d ) )  THEN
    2298                 CALL binary_write_variable( file_id, variable_id,                      &
    2299                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2314                CALL binary_write_variable( file_id, variable_id,                                  &
     2315                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23002316                        values_intwp_1d=values_intwp_1d_pointer, return_value=output_return_value )
    23012317             ELSEIF ( PRESENT( values_intwp_2d ) )  THEN
    2302                 CALL binary_write_variable( file_id, variable_id,                      &
    2303                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2318                CALL binary_write_variable( file_id, variable_id,                                  &
     2319                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23042320                        values_intwp_2d=values_intwp_2d_pointer, return_value=output_return_value )
    23052321             ELSEIF ( PRESENT( values_intwp_3d ) )  THEN
    2306                 CALL binary_write_variable( file_id, variable_id,                      &
    2307                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2322                CALL binary_write_variable( file_id, variable_id,                                  &
     2323                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23082324                        values_intwp_3d=values_intwp_3d_pointer, return_value=output_return_value )
    23092325!
    23102326!--          32bit real output
    23112327             ELSEIF ( PRESENT( values_real32_0d ) )  THEN
    2312                 CALL binary_write_variable( file_id, variable_id,                      &
    2313                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2328                CALL binary_write_variable( file_id, variable_id,                                  &
     2329                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23142330                        values_real32_0d=values_real32_0d_pointer, return_value=output_return_value )
    23152331             ELSEIF ( PRESENT( values_real32_1d ) )  THEN
    2316                 CALL binary_write_variable( file_id, variable_id,                      &
    2317                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2332                CALL binary_write_variable( file_id, variable_id,                                  &
     2333                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23182334                        values_real32_1d=values_real32_1d_pointer, return_value=output_return_value )
    23192335             ELSEIF ( PRESENT( values_real32_2d ) )  THEN
    2320                 CALL binary_write_variable( file_id, variable_id,                      &
    2321                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2336                CALL binary_write_variable( file_id, variable_id,                                  &
     2337                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23222338                        values_real32_2d=values_real32_2d_pointer, return_value=output_return_value )
    23232339             ELSEIF ( PRESENT( values_real32_3d ) )  THEN
    2324                 CALL binary_write_variable( file_id, variable_id,                      &
    2325                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2340                CALL binary_write_variable( file_id, variable_id,                                  &
     2341                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23262342                        values_real32_3d=values_real32_3d_pointer, return_value=output_return_value )
    23272343!
    23282344!--          64bit real output
    23292345             ELSEIF ( PRESENT( values_real64_0d ) )  THEN
    2330                 CALL binary_write_variable( file_id, variable_id,                      &
    2331                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2346                CALL binary_write_variable( file_id, variable_id,                                  &
     2347                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23322348                        values_real64_0d=values_real64_0d_pointer, return_value=output_return_value )
    23332349             ELSEIF ( PRESENT( values_real64_1d ) )  THEN
    2334                 CALL binary_write_variable( file_id, variable_id,                      &
    2335                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2350                CALL binary_write_variable( file_id, variable_id,                                  &
     2351                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23362352                        values_real64_1d=values_real64_1d_pointer, return_value=output_return_value )
    23372353             ELSEIF ( PRESENT( values_real64_2d ) )  THEN
    2338                 CALL binary_write_variable( file_id, variable_id,                      &
    2339                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2354                CALL binary_write_variable( file_id, variable_id,                                  &
     2355                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23402356                        values_real64_2d=values_real64_2d_pointer, return_value=output_return_value )
    23412357             ELSEIF ( PRESENT( values_real64_3d ) )  THEN
    2342                 CALL binary_write_variable( file_id, variable_id,                      &
    2343                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2358                CALL binary_write_variable( file_id, variable_id,                                  &
     2359                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23442360                        values_real64_3d=values_real64_3d_pointer, return_value=output_return_value )
    23452361!
    23462362!--          working-precision real output
    23472363             ELSEIF ( PRESENT( values_realwp_0d ) )  THEN
    2348                 CALL binary_write_variable( file_id, variable_id,                      &
    2349                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2364                CALL binary_write_variable( file_id, variable_id,                                  &
     2365                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23502366                        values_realwp_0d=values_realwp_0d_pointer, return_value=output_return_value )
    23512367             ELSEIF ( PRESENT( values_realwp_1d ) )  THEN
    2352                 CALL binary_write_variable( file_id, variable_id,                      &
    2353                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2368                CALL binary_write_variable( file_id, variable_id,                                  &
     2369                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23542370                        values_realwp_1d=values_realwp_1d_pointer, return_value=output_return_value )
    23552371             ELSEIF ( PRESENT( values_realwp_2d ) )  THEN
    2356                 CALL binary_write_variable( file_id, variable_id,                      &
    2357                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2372                CALL binary_write_variable( file_id, variable_id,                                  &
     2373                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23582374                        values_realwp_2d=values_realwp_2d_pointer, return_value=output_return_value )
    23592375             ELSEIF ( PRESENT( values_realwp_3d ) )  THEN
    2360                 CALL binary_write_variable( file_id, variable_id,                      &
    2361                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2376                CALL binary_write_variable( file_id, variable_id,                                  &
     2377                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23622378                        values_realwp_3d=values_realwp_3d_pointer, return_value=output_return_value )
    23632379             ELSE
    23642380                return_value = 1
    2365                 CALL internal_message( 'error', routine_name //                          &
    2366                                        ': output_type not supported by file format "' // &
    2367                                        TRIM( file_format ) // '" ' //                    &
    2368                                        '(variable "' // TRIM( variable_name ) //         &
     2381                CALL internal_message( 'error', routine_name //                                    &
     2382                                       ': output_type not supported by file format "' //           &
     2383                                       TRIM( file_format ) // '" ' //                              &
     2384                                       '(variable "' // TRIM( variable_name ) //                   &
    23692385                                       '", file "' // TRIM( file_name ) // '")!' )
    23702386             ENDIF
     
    23722388          CASE ( 'netcdf4-parallel', 'netcdf4-serial' )
    23732389!
    2374 !--          character output
     2390!--          Character output
    23752391             IF ( PRESENT( values_char_0d ) )  THEN
    2376                  CALL netcdf4_write_variable( file_id, variable_id,                     &
    2377                          bounds_start_internal, value_counts, bounds_origin, is_global, &
     2392                 CALL netcdf4_write_variable( file_id, variable_id,                                &
     2393                         bounds_start_internal, value_counts, bounds_origin, is_global,            &
    23782394                        values_char_0d=values_char_0d_pointer, return_value=output_return_value )
    23792395             ELSEIF ( PRESENT( values_char_1d ) )  THEN
    2380                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2381                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2396                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2397                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23822398                        values_char_1d=values_char_1d_pointer, return_value=output_return_value )
    23832399             ELSEIF ( PRESENT( values_char_2d ) )  THEN
    2384                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2385                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2400                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2401                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23862402                        values_char_2d=values_char_2d_pointer, return_value=output_return_value )
    23872403             ELSEIF ( PRESENT( values_char_3d ) )  THEN
    2388                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2389                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2404                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2405                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23902406                        values_char_3d=values_char_3d_pointer, return_value=output_return_value )
    23912407!
    23922408!--          8bit integer output
    23932409             ELSEIF ( PRESENT( values_int8_0d ) )  THEN
    2394                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2395                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2410                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2411                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    23962412                        values_int8_0d=values_int8_0d_pointer, return_value=output_return_value )
    23972413             ELSEIF ( PRESENT( values_int8_1d ) )  THEN
    2398                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2399                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2414                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2415                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24002416                        values_int8_1d=values_int8_1d_pointer, return_value=output_return_value )
    24012417             ELSEIF ( PRESENT( values_int8_2d ) )  THEN
    2402                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2403                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2418                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2419                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24042420                        values_int8_2d=values_int8_2d_pointer, return_value=output_return_value )
    24052421             ELSEIF ( PRESENT( values_int8_3d ) )  THEN
    2406                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2407                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2422                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2423                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24082424                        values_int8_3d=values_int8_3d_pointer, return_value=output_return_value )
    24092425!
    24102426!--          16bit integer output
    24112427             ELSEIF ( PRESENT( values_int16_0d ) )  THEN
    2412                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2413                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2428                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2429                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24142430                        values_int16_0d=values_int16_0d_pointer, return_value=output_return_value )
    24152431             ELSEIF ( PRESENT( values_int16_1d ) )  THEN
    2416                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2417                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2432                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2433                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24182434                        values_int16_1d=values_int16_1d_pointer, return_value=output_return_value )
    24192435             ELSEIF ( PRESENT( values_int16_2d ) )  THEN
    2420                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2421                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2436                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2437                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24222438                        values_int16_2d=values_int16_2d_pointer, return_value=output_return_value )
    24232439             ELSEIF ( PRESENT( values_int16_3d ) )  THEN
    2424                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2425                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2440                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2441                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24262442                        values_int16_3d=values_int16_3d_pointer, return_value=output_return_value )
    24272443!
    24282444!--          32bit integer output
    24292445             ELSEIF ( PRESENT( values_int32_0d ) )  THEN
    2430                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2431                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2446                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2447                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24322448                        values_int32_0d=values_int32_0d_pointer, return_value=output_return_value )
    24332449             ELSEIF ( PRESENT( values_int32_1d ) )  THEN
    2434                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2435                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2450                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2451                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24362452                        values_int32_1d=values_int32_1d_pointer, return_value=output_return_value )
    24372453             ELSEIF ( PRESENT( values_int32_2d ) )  THEN
    2438                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2439                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2454                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2455                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24402456                        values_int32_2d=values_int32_2d_pointer, return_value=output_return_value )
    24412457             ELSEIF ( PRESENT( values_int32_3d ) )  THEN
    2442                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2443                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2458                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2459                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24442460                        values_int32_3d=values_int32_3d_pointer, return_value=output_return_value )
    24452461!
    2446 !--          working-precision integer output
     2462!--          Working-precision integer output
    24472463             ELSEIF ( PRESENT( values_intwp_0d ) )  THEN
    2448                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2449                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2464                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2465                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24502466                        values_intwp_0d=values_intwp_0d_pointer, return_value=output_return_value )
    24512467             ELSEIF ( PRESENT( values_intwp_1d ) )  THEN
    2452                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2453                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2468                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2469                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24542470                        values_intwp_1d=values_intwp_1d_pointer, return_value=output_return_value )
    24552471             ELSEIF ( PRESENT( values_intwp_2d ) )  THEN
    2456                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2457                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2472                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2473                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24582474                        values_intwp_2d=values_intwp_2d_pointer, return_value=output_return_value )
    24592475             ELSEIF ( PRESENT( values_intwp_3d ) )  THEN
    2460                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2461                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2476                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2477                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24622478                        values_intwp_3d=values_intwp_3d_pointer, return_value=output_return_value )
    24632479!
    24642480!--          32bit real output
    24652481             ELSEIF ( PRESENT( values_real32_0d ) )  THEN
    2466                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2467                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2482                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2483                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24682484                        values_real32_0d=values_real32_0d_pointer, return_value=output_return_value )
    24692485             ELSEIF ( PRESENT( values_real32_1d ) )  THEN
    2470                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2471                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2486                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2487                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24722488                        values_real32_1d=values_real32_1d_pointer, return_value=output_return_value )
    24732489             ELSEIF ( PRESENT( values_real32_2d ) )  THEN
    2474                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2475                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2490                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2491                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24762492                        values_real32_2d=values_real32_2d_pointer, return_value=output_return_value )
    24772493             ELSEIF ( PRESENT( values_real32_3d ) )  THEN
    2478                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2479                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2494                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2495                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24802496                        values_real32_3d=values_real32_3d_pointer, return_value=output_return_value )
    24812497!
    24822498!--          64bit real output
    24832499             ELSEIF ( PRESENT( values_real64_0d ) )  THEN
    2484                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2485                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2500                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2501                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24862502                        values_real64_0d=values_real64_0d_pointer, return_value=output_return_value )
    24872503             ELSEIF ( PRESENT( values_real64_1d ) )  THEN
    2488                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2489                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2504                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2505                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24902506                        values_real64_1d=values_real64_1d_pointer, return_value=output_return_value )
    24912507             ELSEIF ( PRESENT( values_real64_2d ) )  THEN
    2492                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2493                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2508                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2509                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24942510                        values_real64_2d=values_real64_2d_pointer, return_value=output_return_value )
    24952511             ELSEIF ( PRESENT( values_real64_3d ) )  THEN
    2496                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2497                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2512                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2513                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    24982514                        values_real64_3d=values_real64_3d_pointer, return_value=output_return_value )
    24992515!
    25002516!--          working-precision real output
    25012517             ELSEIF ( PRESENT( values_realwp_0d ) )  THEN
    2502                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2503                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2518                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2519                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    25042520                        values_realwp_0d=values_realwp_0d_pointer, return_value=output_return_value )
    25052521             ELSEIF ( PRESENT( values_realwp_1d ) )  THEN
    2506                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2507                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2522                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2523                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    25082524                        values_realwp_1d=values_realwp_1d_pointer, return_value=output_return_value )
    25092525             ELSEIF ( PRESENT( values_realwp_2d ) )  THEN
    2510                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2511                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2526                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2527                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    25122528                        values_realwp_2d=values_realwp_2d_pointer, return_value=output_return_value )
    25132529             ELSEIF ( PRESENT( values_realwp_3d ) )  THEN
    2514                 CALL netcdf4_write_variable( file_id, variable_id,                     &
    2515                         bounds_start_internal, value_counts, bounds_origin, is_global, &
     2530                CALL netcdf4_write_variable( file_id, variable_id,                                 &
     2531                        bounds_start_internal, value_counts, bounds_origin, is_global,             &
    25162532                        values_realwp_3d=values_realwp_3d_pointer, return_value=output_return_value )
    25172533             ELSE
    25182534                return_value = 1
    2519                 CALL internal_message( 'error', routine_name //                          &
    2520                                        ': output_type not supported by file format "' // &
    2521                                        TRIM( file_format ) // '" ' //                    &
    2522                                        '(variable "' // TRIM( variable_name ) //         &
     2535                CALL internal_message( 'error', routine_name //                                    &
     2536                                       ': output_type not supported by file format "' //           &
     2537                                       TRIM( file_format ) // '" ' //                              &
     2538                                       '(variable "' // TRIM( variable_name ) //                   &
    25232539                                       '", file "' // TRIM( file_name ) // '")!' )
    25242540             ENDIF
     
    25262542          CASE DEFAULT
    25272543             return_value = 1
    2528              CALL internal_message( 'error', routine_name //                    &
    2529                                     ': file format "' // TRIM( file_format ) // &
    2530                                     '" not supported ' //                       &
    2531                                     '(variable "' // TRIM( variable_name ) //   &
     2544             CALL internal_message( 'error', routine_name //                                       &
     2545                                    ': file format "' // TRIM( file_format ) //                    &
     2546                                    '" not supported ' //                                          &
     2547                                    '(variable "' // TRIM( variable_name ) //                      &
    25322548                                    '", file "' // TRIM( file_name ) // '")!' )
    25332549
     
    25362552       IF ( return_value == 0  .AND.  output_return_value /= 0 )  THEN
    25372553          return_value = 1
    2538           CALL internal_message( 'error', routine_name //                  &
    2539                                  ': error while writing variable ' //      &
    2540                                  '(variable "' // TRIM( variable_name ) // &
     2554          CALL internal_message( 'error', routine_name //                                          &
     2555                                 ': error while writing variable ' //                              &
     2556                                 '(variable "' // TRIM( variable_name ) //                         &
    25412557                                 '", file "' // TRIM( file_name ) // '")!' )
    25422558       ENDIF
     
    25892605          IF ( output_return_value /= 0 )  THEN
    25902606             return_value = output_return_value
    2591              CALL internal_message( 'error', routine_name //             &
    2592                                     ': error while finalizing file "' // &
     2607             CALL internal_message( 'error', routine_name //                                       &
     2608                                    ': error while finalizing file "' //                           &
    25932609                                    TRIM( files(f)%name ) // '"' )
    25942610          ELSEIF ( return_value_internal /= 0 )  THEN
    25952611             return_value = return_value_internal
    2596              CALL internal_message( 'error', routine_name //                     &
    2597                                     ': unsupported file format "' //             &
    2598                                     TRIM( files(f)%format ) // '" for file "' // &
     2612             CALL internal_message( 'error', routine_name //                                       &
     2613                                    ': unsupported file format "' //                               &
     2614                                    TRIM( files(f)%format ) // '" for file "' //                   &
    25992615                                    TRIM( files(f)%name ) // '"' )
    26002616          ENDIF
     
    26362652             RESULT( return_value )
    26372653
     2654    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'save_attribute_in_database'  !< name of routine
     2655
    26382656    CHARACTER(LEN=*), INTENT(IN) ::  file_name      !< name of file
    26392657    CHARACTER(LEN=*), INTENT(IN) ::  variable_name  !< name of variable
    2640 
    2641     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'save_attribute_in_database'  !< name of routine
    26422658
    26432659    INTEGER ::  a             !< loop index
     
    26582674    found = .FALSE.
    26592675
    2660     CALL internal_message( 'debug', routine_name //                            &
    2661                            ': define attribute "' // TRIM( attribute%name ) // &
    2662                            '" of variable "' // TRIM( variable_name ) //       &
     2676    CALL internal_message( 'debug', routine_name //                                                &
     2677                           ': define attribute "' // TRIM( attribute%name ) //                     &
     2678                           '" of variable "' // TRIM( variable_name ) //                           &
    26632679                           '" in file "' // TRIM( file_name ) // '"' )
    26642680
     
    26692685          IF ( files(f)%is_init )  THEN
    26702686             return_value = 1
    2671              CALL internal_message( 'error', routine_name // ': file "' // TRIM( file_name ) // &
     2687             CALL internal_message( 'error', routine_name // ': file "' // TRIM( file_name ) //    &
    26722688                     '" is already initialized. No further attribute definition allowed!' )
    26732689             EXIT
     
    26902706!
    26912707!--                      Append existing string attribute
    2692                          files(f)%attributes(a)%value_char =             &
    2693                             TRIM( files(f)%attributes(a)%value_char ) // &
    2694                             TRIM( attribute%value_char )
     2708                         files(f)%attributes(a)%value_char =                                       &
     2709                                                      TRIM( files(f)%attributes(a)%value_char ) // &
     2710                                                      TRIM( attribute%value_char )
    26952711                      ELSE
    26962712                         files(f)%attributes(a) = attribute
     
    27452761!
    27462762!--                               Append existing character attribute
    2747                                   files(f)%dimensions(d)%attributes(a)%value_char =             &
    2748                                      TRIM( files(f)%dimensions(d)%attributes(a)%value_char ) // &
     2763                                  files(f)%dimensions(d)%attributes(a)%value_char =                &
     2764                                     TRIM( files(f)%dimensions(d)%attributes(a)%value_char ) //    &
    27492765                                     TRIM( attribute%value_char )
    27502766                               ELSE
     
    28012817!--                      Check if attribute already exists
    28022818                         DO  a = 1, natts
    2803                             IF ( files(f)%variables(d)%attributes(a)%name == attribute%name )  &
    2804                             THEN
     2819                            IF ( files(f)%variables(d)%attributes(a)%name == attribute%name )  THEN
    28052820                               IF ( append )  THEN
    28062821!
    28072822!--                               Append existing character attribute
    2808                                   files(f)%variables(d)%attributes(a)%value_char =             &
    2809                                      TRIM( files(f)%variables(d)%attributes(a)%value_char ) // &
     2823                                  files(f)%variables(d)%attributes(a)%value_char =                 &
     2824                                     TRIM( files(f)%variables(d)%attributes(a)%value_char ) //     &
    28102825                                     TRIM( attribute%value_char )
    28112826                               ELSE
     
    28482863             IF ( .NOT. found )  THEN
    28492864                return_value = 1
    2850                 CALL internal_message( 'error',                                        &
    2851                         routine_name //                                                &
    2852                         ': requested dimension/variable "' // TRIM( variable_name ) // &
    2853                         '" for attribute "' // TRIM( attribute%name ) //               &
    2854                         '" does not exist in file "' // TRIM( file_name ) // '"' )
     2865                CALL internal_message( 'error',                                                    &
     2866                                    routine_name //                                                &
     2867                                    ': requested dimension/variable "' // TRIM( variable_name ) // &
     2868                                    '" for attribute "' // TRIM( attribute%name ) //               &
     2869                                    '" does not exist in file "' // TRIM( file_name ) // '"' )
    28552870             ENDIF
    28562871
     
    28652880    IF ( .NOT. found  .AND.  return_value == 0 )  THEN
    28662881       return_value = 1
    2867        CALL internal_message( 'error',                                         &
    2868                               routine_name //                                  &
    2869                               ': requested file "' // TRIM( file_name ) //     &
    2870                               '" for attribute "' // TRIM( attribute%name ) // &
     2882       CALL internal_message( 'error',                                                             &
     2883                              routine_name //                                                      &
     2884                              ': requested file "' // TRIM( file_name ) //                         &
     2885                              '" for attribute "' // TRIM( attribute%name ) //                     &
    28712886                              '" does not exist' )
    28722887    ENDIF
     
    29432958       DO  d = 1, ndims
    29442959          DO  i = 1, nvars
    2945              dimension_is_used(d) = &
    2946                 ANY( files(f)%dimensions(d)%name == files(f)%variables(i)%dimension_names )
     2960             dimension_is_used(d) =                                                                &
     2961                         ANY( files(f)%dimensions(d)%name == files(f)%variables(i)%dimension_names )
    29472962             IF ( dimension_is_used(d) )  EXIT
    29482963          ENDDO
     
    29792994 SUBROUTINE open_output_file( file_format, file_name, file_id, return_value )
    29802995
     2996    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'open_output_file'  !< name of routine
     2997
    29812998    CHARACTER(LEN=*), INTENT(IN) ::  file_format  !< file format chosen for file
    29822999    CHARACTER(LEN=*), INTENT(IN) ::  file_name    !< name of file to be checked
    2983 
    2984     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'open_output_file'  !< name of routine
    29853000
    29863001    INTEGER, INTENT(OUT) ::  file_id              !< file ID
     
    30103025    IF ( output_return_value /= 0 )  THEN
    30113026       return_value = output_return_value
    3012        CALL internal_message( 'error', routine_name // &
     3027       CALL internal_message( 'error', routine_name //                                             &
    30133028                              ': error while opening file "' // TRIM( file_name ) // '"' )
    30143029    ELSEIF ( return_value /= 0 )  THEN
    3015        CALL internal_message( 'error', routine_name //                     &
    3016                               ': file "' // TRIM( file_name ) //           &
    3017                               '": file format "' // TRIM( file_format ) // &
     3030       CALL internal_message( 'error', routine_name //                                             &
     3031                              ': file "' // TRIM( file_name ) //                                   &
     3032                              '": file format "' // TRIM( file_format ) //                         &
    30183033                              '" not supported' )
    30193034    ENDIF
     
    30423057    IF ( ALLOCATED( file%attributes ) )  THEN
    30433058       DO  a = 1, SIZE( file%attributes )
    3044           return_value = write_attribute( file%format, file%id, file%name,     &
    3045                                           variable_id=no_id, variable_name='', &
     3059          return_value = write_attribute( file%format, file%id, file%name,                         &
     3060                                          variable_id=no_id, variable_name='',                     &
    30463061                                          attribute=file%attributes(a) )
    30473062          IF ( return_value /= 0 )  EXIT
     
    30573072!
    30583073!--          Initialize non-masked dimension
    3059              CALL init_file_dimension( file%format, file%id, file%name,       &
    3060                      file%dimensions(d)%id, file%dimensions(d)%name,          &
    3061                      file%dimensions(d)%data_type, file%dimensions(d)%length, &
    3062                      file%dimensions(d)%variable_id, return_value )
     3074             CALL init_file_dimension( file%format, file%id, file%name,                            &
     3075                                       file%dimensions(d)%id, file%dimensions(d)%name,             &
     3076                                       file%dimensions(d)%data_type, file%dimensions(d)%length,    &
     3077                                       file%dimensions(d)%variable_id, return_value )
    30633078
    30643079          ELSE
    30653080!
    30663081!--          Initialize masked dimension
    3067              CALL init_file_dimension( file%format, file%id, file%name,            &
    3068                      file%dimensions(d)%id, file%dimensions(d)%name,               &
    3069                      file%dimensions(d)%data_type, file%dimensions(d)%length_mask, &
    3070                      file%dimensions(d)%variable_id, return_value )
     3082             CALL init_file_dimension( file%format, file%id, file%name,                            &
     3083                                       file%dimensions(d)%id, file%dimensions(d)%name,             &
     3084                                       file%dimensions(d)%data_type, file%dimensions(d)%length_mask,&
     3085                                       file%dimensions(d)%variable_id, return_value )
    30713086
    30723087          ENDIF
     
    30763091!--          Write dimension attributes
    30773092             DO  a = 1, SIZE( file%dimensions(d)%attributes )
    3078                 return_value = write_attribute( file%format, file%id, file%name, &
    3079                                   variable_id=file%dimensions(d)%variable_id,    &
    3080                                   variable_name=file%dimensions(d)%name,         &
    3081                                   attribute=file%dimensions(d)%attributes(a) )
     3093                return_value = write_attribute( file%format, file%id, file%name,                   &
     3094                                                variable_id=file%dimensions(d)%variable_id,        &
     3095                                                variable_name=file%dimensions(d)%name,             &
     3096                                                attribute=file%dimensions(d)%attributes(a) )
    30823097                IF ( return_value /= 0 )  EXIT
    30833098             ENDDO
     
    30893104!
    30903105!--    Save dimension IDs for variables wihtin database
    3091        IF ( return_value == 0 )  &
     3106       IF ( return_value == 0 )                                                                    &
    30923107          CALL collect_dimesion_ids_for_variables( file%name, file%variables, file%dimensions, &
    30933108                                                   return_value )
     
    30973112          DO  d = 1, SIZE( file%variables )
    30983113
    3099              CALL init_file_variable( file%format, file%id, file%name,                          &
    3100                      file%variables(d)%id, file%variables(d)%name, file%variables(d)%data_type, &
    3101                      file%variables(d)%dimension_ids,                                           &
     3114             CALL init_file_variable( file%format, file%id, file%name,                             &
     3115                     file%variables(d)%id, file%variables(d)%name, file%variables(d)%data_type,    &
     3116                     file%variables(d)%dimension_ids,                                              &
    31023117                     file%variables(d)%is_global, return_value )
    31033118
     
    31063121!--             Write variable attributes
    31073122                DO  a = 1, SIZE( file%variables(d)%attributes )
    3108                    return_value = write_attribute( file%format, file%id, file%name, &
    3109                                      variable_id=file%variables(d)%id,              &
    3110                                      variable_name=file%variables(d)%name,          &
    3111                                      attribute=file%variables(d)%attributes(a) )
     3123                   return_value = write_attribute( file%format, file%id, file%name,                &
     3124                                                   variable_id=file%variables(d)%id,               &
     3125                                                   variable_name=file%variables(d)%name,           &
     3126                                                   attribute=file%variables(d)%attributes(a) )
    31123127                   IF ( return_value /= 0 )  EXIT
    31133128                ENDDO
     
    31283143!> Initialize dimension in file.
    31293144!--------------------------------------------------------------------------------------------------!
    3130  SUBROUTINE init_file_dimension( file_format, file_id, file_name,              &
    3131                dimension_id, dimension_name, dimension_type, dimension_length, &
    3132                variable_id, return_value )
     3145 SUBROUTINE init_file_dimension( file_format, file_id, file_name,                                  &
     3146                                 dimension_id, dimension_name, dimension_type, dimension_length,   &
     3147                                 variable_id, return_value )
     3148
     3149    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'init_file_dimension'  !< file format chosen for file
    31333150
    31343151    CHARACTER(LEN=*), INTENT(IN) ::  dimension_name  !< name of dimension
     
    31363153    CHARACTER(LEN=*), INTENT(IN) ::  file_format     !< file format chosen for file
    31373154    CHARACTER(LEN=*), INTENT(IN) ::  file_name       !< name of file
    3138 
    3139     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'init_file_dimension'  !< file format chosen for file
    31403155
    31413156    INTEGER, INTENT(OUT) ::  dimension_id         !< dimension ID
     
    31503165    output_return_value = 0
    31513166
    3152     temp_string = '(file "' // TRIM( file_name ) // &
     3167    temp_string = '(file "' // TRIM( file_name ) //                                                &
    31533168                  '", dimension "' // TRIM( dimension_name ) // '")'
    31543169
     
    31563171
    31573172       CASE ( 'binary' )
    3158           CALL binary_init_dimension( 'binary', file_id, dimension_id, variable_id, &
    3159                   dimension_name, dimension_type, dimension_length,                 &
    3160                   return_value=output_return_value )
     3173          CALL binary_init_dimension( 'binary', file_id, dimension_id, variable_id,                &
     3174                                       dimension_name, dimension_type, dimension_length,           &
     3175                                       return_value=output_return_value )
    31613176
    31623177       CASE ( 'netcdf4-serial' )
    3163           CALL netcdf4_init_dimension( 'serial', file_id, dimension_id, variable_id, &
    3164                   dimension_name, dimension_type, dimension_length,                  &
    3165                   return_value=output_return_value )
     3178          CALL netcdf4_init_dimension( 'serial', file_id, dimension_id, variable_id,               &
     3179                                       dimension_name, dimension_type, dimension_length,           &
     3180                                       return_value=output_return_value )
    31663181
    31673182       CASE ( 'netcdf4-parallel' )
    3168           CALL netcdf4_init_dimension( 'parallel', file_id, dimension_id, variable_id, &
    3169                   dimension_name, dimension_type, dimension_length,                    &
    3170                   return_value=output_return_value )
     3183          CALL netcdf4_init_dimension( 'parallel', file_id, dimension_id, variable_id,             &
     3184                                       dimension_name, dimension_type, dimension_length,           &
     3185                                       return_value=output_return_value )
    31713186
    31723187       CASE DEFAULT
    31733188          return_value = 1
    3174           CALL internal_message( 'error', routine_name //                    &
    3175                                  ': file format "' // TRIM( file_format ) // &
     3189          CALL internal_message( 'error', routine_name //                                          &
     3190                                 ': file format "' // TRIM( file_format ) //                       &
    31763191                                 '" not supported ' // TRIM( temp_string ) )
    31773192
     
    31803195    IF ( output_return_value /= 0 )  THEN
    31813196       return_value = output_return_value
    3182        CALL internal_message( 'error', routine_name // &
     3197       CALL internal_message( 'error', routine_name //                                             &
    31833198                              ': error while defining dimension ' // TRIM( temp_string ) )
    31843199    ENDIF
     
    31913206!> Initialize variable.
    31923207!--------------------------------------------------------------------------------------------------!
    3193  SUBROUTINE init_file_variable( file_format, file_id, file_name,        &
    3194                                 variable_id, variable_name, variable_type, dimension_ids, &
     3208 SUBROUTINE init_file_variable( file_format, file_id, file_name,                                   &
     3209                                variable_id, variable_name, variable_type, dimension_ids,          &
    31953210                                is_global, return_value )
     3211
     3212    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'init_file_variable'  !< file format chosen for file
    31963213
    31973214    CHARACTER(LEN=*), INTENT(IN) ::  file_format    !< file format chosen for file
     
    32003217    CHARACTER(LEN=*), INTENT(IN) ::  variable_type  !< data type of variable
    32013218
    3202     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'init_file_variable'  !< file format chosen for file
    3203 
    32043219    INTEGER, INTENT(IN)  ::  file_id              !< file ID
    32053220    INTEGER              ::  output_return_value  !< return value of a called output routine
     
    32213236
    32223237       CASE ( 'binary' )
    3223           CALL binary_init_variable( 'binary', file_id, variable_id, variable_name, &
     3238          CALL binary_init_variable( 'binary', file_id, variable_id, variable_name,                &
    32243239                  variable_type, dimension_ids, is_global, return_value=output_return_value )
    32253240
    32263241       CASE ( 'netcdf4-serial' )
    3227           CALL netcdf4_init_variable( 'serial', file_id, variable_id, variable_name, &
     3242          CALL netcdf4_init_variable( 'serial', file_id, variable_id, variable_name,               &
    32283243                  variable_type, dimension_ids, is_global, return_value=output_return_value )
    32293244
    32303245       CASE ( 'netcdf4-parallel' )
    3231           CALL netcdf4_init_variable( 'parallel', file_id, variable_id, variable_name, &
     3246          CALL netcdf4_init_variable( 'parallel', file_id, variable_id, variable_name,             &
    32323247                  variable_type, dimension_ids, is_global, return_value=output_return_value )
    32333248
    32343249       CASE DEFAULT
    32353250          return_value = 1
    3236           CALL internal_message( 'error', routine_name //                    &
    3237                                  ': file format "' // TRIM( file_format ) // &
     3251          CALL internal_message( 'error', routine_name //                                          &
     3252                                 ': file format "' // TRIM( file_format ) //                       &
    32383253                                 '" not supported ' // TRIM( temp_string ) )
    32393254
     
    32533268!> Write attribute to file.
    32543269!--------------------------------------------------------------------------------------------------!
    3255  FUNCTION write_attribute( file_format, file_id, file_name,        &
    3256                            variable_id, variable_name, attribute ) RESULT( return_value )
     3270 FUNCTION write_attribute( file_format, file_id, file_name, variable_id, variable_name, attribute )&
     3271    RESULT( return_value )
     3272
     3273    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'write_attribute'  !< file format chosen for file
    32573274
    32583275    CHARACTER(LEN=*), INTENT(IN) ::  file_format    !< file format chosen for file
     
    32603277    CHARACTER(LEN=*), INTENT(IN) ::  variable_name  !< variable name
    32613278
    3262     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'write_attribute'  !< file format chosen for file
    3263 
    32643279    INTEGER, INTENT(IN) ::  file_id              !< file ID
     3280    INTEGER             ::  output_return_value  !< return value of a called output routine
    32653281    INTEGER             ::  return_value         !< return value
    3266     INTEGER             ::  output_return_value  !< return value of a called output routine
    32673282    INTEGER, INTENT(IN) ::  variable_id          !< variable ID
    32683283
     
    32743289!
    32753290!-- Prepare for possible error message
    3276     temp_string = '(file "' // TRIM( file_name ) //           &
    3277                   '", variable "' // TRIM( variable_name ) // &
     3291    temp_string = '(file "' // TRIM( file_name ) //                                                &
     3292                  '", variable "' // TRIM( variable_name ) //                                      &
    32783293                  '", attribute "' // TRIM( attribute%name ) // '")'
    32793294!
     
    32863301
    32873302             CASE( 'char' )
    3288                 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id,  &
    3289                         attribute_name=attribute%name, value_char=attribute%value_char, &
     3303                CALL binary_write_attribute( file_id=file_id, variable_id=variable_id,             &
     3304                        attribute_name=attribute%name, value_char=attribute%value_char,            &
    32903305                        return_value=output_return_value )
    32913306
    32923307             CASE( 'int8' )
    3293                 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id,  &
    3294                         attribute_name=attribute%name, value_int8=attribute%value_int8, &
     3308                CALL binary_write_attribute( file_id=file_id, variable_id=variable_id,             &
     3309                        attribute_name=attribute%name, value_int8=attribute%value_int8,            &
    32953310                        return_value=output_return_value )
    32963311
    32973312             CASE( 'int16' )
    3298                 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id,    &
    3299                         attribute_name=attribute%name, value_int16=attribute%value_int16, &
     3313                CALL binary_write_attribute( file_id=file_id, variable_id=variable_id,             &
     3314                        attribute_name=attribute%name, value_int16=attribute%value_int16,          &
    33003315                        return_value=output_return_value )
    33013316
    33023317             CASE( 'int32' )
    3303                 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id,    &
    3304                         attribute_name=attribute%name, value_int32=attribute%value_int32, &
     3318                CALL binary_write_attribute( file_id=file_id, variable_id=variable_id,             &
     3319                        attribute_name=attribute%name, value_int32=attribute%value_int32,          &
    33053320                        return_value=output_return_value )
    33063321
    33073322             CASE( 'real32' )
    3308                 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id,      &
    3309                         attribute_name=attribute%name, value_real32=attribute%value_real32, &
     3323                CALL binary_write_attribute( file_id=file_id, variable_id=variable_id,             &
     3324                        attribute_name=attribute%name, value_real32=attribute%value_real32,        &
    33103325                        return_value=output_return_value )
    33113326
    33123327             CASE( 'real64' )
    3313                 CALL binary_write_attribute( file_id=file_id, variable_id=variable_id,      &
    3314                         attribute_name=attribute%name, value_real64=attribute%value_real64, &
     3328                CALL binary_write_attribute( file_id=file_id, variable_id=variable_id,             &
     3329                        attribute_name=attribute%name, value_real64=attribute%value_real64,        &
    33153330                        return_value=output_return_value )
    33163331
    33173332             CASE DEFAULT
    33183333                return_value = 1
    3319                 CALL internal_message( 'error', routine_name //                     &
    3320                                        ': file format "' // TRIM( file_format ) //  &
    3321                                        '" does not support attribute data type "'// &
    3322                                        TRIM( attribute%data_type ) //               &
     3334                CALL internal_message( 'error', routine_name //                                    &
     3335                                       ': file format "' // TRIM( file_format ) //                 &
     3336                                       '" does not support attribute data type "'//                &
     3337                                       TRIM( attribute%data_type ) //                              &
    33233338                                       '" ' // TRIM( temp_string ) )
    33243339
     
    33303345
    33313346             CASE( 'char' )
    3332                 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id, &
    3333                         attribute_name=attribute%name, value_char=attribute%value_char, &
     3347                CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id,            &
     3348                        attribute_name=attribute%name, value_char=attribute%value_char,            &
    33343349                        return_value=output_return_value )
    33353350
    33363351             CASE( 'int8' )
    3337                 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id, &
    3338                         attribute_name=attribute%name, value_int8=attribute%value_int8, &
     3352                CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id,            &
     3353                        attribute_name=attribute%name, value_int8=attribute%value_int8,            &
    33393354                        return_value=output_return_value )
    33403355
    33413356             CASE( 'int16' )
    3342                 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id,   &
    3343                         attribute_name=attribute%name, value_int16=attribute%value_int16, &
     3357                CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id,            &
     3358                        attribute_name=attribute%name, value_int16=attribute%value_int16,          &
    33443359                        return_value=output_return_value )
    33453360
    33463361             CASE( 'int32' )
    3347                 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id,   &
    3348                         attribute_name=attribute%name, value_int32=attribute%value_int32, &
     3362                CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id,            &
     3363                        attribute_name=attribute%name, value_int32=attribute%value_int32,          &
    33493364                        return_value=output_return_value )
    33503365
    33513366             CASE( 'real32' )
    3352                 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id,     &
    3353                         attribute_name=attribute%name, value_real32=attribute%value_real32, &
     3367                CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id,            &
     3368                        attribute_name=attribute%name, value_real32=attribute%value_real32,        &
    33543369                        return_value=output_return_value )
    33553370
    33563371             CASE( 'real64' )
    3357                 CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id,     &
    3358                         attribute_name=attribute%name, value_real64=attribute%value_real64, &
     3372                CALL netcdf4_write_attribute( file_id=file_id, variable_id=variable_id,            &
     3373                        attribute_name=attribute%name, value_real64=attribute%value_real64,        &
    33593374                        return_value=output_return_value )
    33603375
    33613376             CASE DEFAULT
    33623377                return_value = 1
    3363                 CALL internal_message( 'error', routine_name //                     &
    3364                                        ': file format "' // TRIM( file_format ) //  &
    3365                                        '" does not support attribute data type "'// &
    3366                                        TRIM( attribute%data_type ) //               &
     3378                CALL internal_message( 'error', routine_name //                                    &
     3379                                       ': file format "' // TRIM( file_format ) //                 &
     3380                                       '" does not support attribute data type "'//                &
     3381                                       TRIM( attribute%data_type ) //                              &
    33673382                                       '" ' // TRIM( temp_string ) )
    33683383
     
    33713386       CASE DEFAULT
    33723387          return_value = 1
    3373           CALL internal_message( 'error', routine_name //                                &
    3374                                  ': unsupported file format "' // TRIM( file_format ) // &
     3388          CALL internal_message( 'error', routine_name //                                          &
     3389                                 ': unsupported file format "' // TRIM( file_format ) //           &
    33753390                                 '" ' // TRIM( temp_string ) )
    33763391
     
    33793394    IF ( output_return_value /= 0 )  THEN
    33803395       return_value = output_return_value
    3381        CALL internal_message( 'error', routine_name // &
     3396       CALL internal_message( 'error', routine_name //                                             &
    33823397                              ': error while writing attribute ' // TRIM( temp_string ) )
    33833398    ENDIF
     
    33923407 SUBROUTINE collect_dimesion_ids_for_variables( file_name, variables, dimensions, return_value )
    33933408
     3409    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'collect_dimesion_ids_for_variables'  !< file format chosen for file
     3410
    33943411    CHARACTER(LEN=*), INTENT(IN) ::  file_name !< name of file
    3395 
    3396     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'collect_dimesion_ids_for_variables'  !< file format chosen for file
    33973412
    33983413    INTEGER              ::  d             !< loop index
     
    34033418    INTEGER, INTENT(OUT) ::  return_value  !< return value
    34043419
    3405     LOGICAL ::  found = .False. !< true if dimension required by variable was found in dimension list
     3420    LOGICAL ::  found = .FALSE. !< true if dimension required by variable was found in dimension list
    34063421
    34073422    TYPE(dimension_type), DIMENSION(:), INTENT(IN) ::  dimensions  !< list of dimensions in file
     
    34263441          IF ( .NOT. found )  THEN
    34273442             return_value = 1
    3428              CALL internal_message( 'error', routine_name //                                &
    3429                      ': required dimension "' // TRIM( variables(i)%dimension_names(j) ) // &
    3430                      '" is undefined (variable "' // TRIM( variables(i)%name ) //           &
     3443             CALL internal_message( 'error', routine_name //                                       &
     3444                     ': required dimension "' // TRIM( variables(i)%dimension_names(j) ) //        &
     3445                     '" is undefined (variable "' // TRIM( variables(i)%name ) //                  &
    34313446                     '", file "' // TRIM( file_name ) // '")!' )
    34323447             EXIT
     
    34473462 SUBROUTINE stop_file_header_definition( file_format, file_id, file_name, return_value )
    34483463
     3464    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'stop_file_header_definition'  !< name of routine
     3465
    34493466    CHARACTER(LEN=*), INTENT(IN) ::  file_format  !< file format
    34503467    CHARACTER(LEN=*), INTENT(IN) ::  file_name    !< file name
    3451 
    3452     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'stop_file_header_definition'  !< name of routine
    34533468
    34543469    INTEGER, INTENT(IN)  ::  file_id              !< file id
     
    34723487       CASE DEFAULT
    34733488          return_value = 1
    3474           CALL internal_message( 'error', routine_name //                    &
    3475                                  ': file format "' // TRIM( file_format ) // &
     3489          CALL internal_message( 'error', routine_name //                                          &
     3490                                 ': file format "' // TRIM( file_format ) //                       &
    34763491                                 '" not supported ' // TRIM( temp_string ) )
    34773492
     
    34803495    IF ( output_return_value /= 0 )  THEN
    34813496       return_value = output_return_value
    3482        CALL internal_message( 'error', routine_name //                          &
    3483                               ': error while leaving file-definition state ' // &
     3497       CALL internal_message( 'error', routine_name //                                             &
     3498                              ': error while leaving file-definition state ' //                    &
    34843499                              TRIM( temp_string ) )
    34853500    ENDIF
     
    34943509!> Find a requested variable 'variable_name' and its used dimensions in requested file 'file_name'.
    34953510!--------------------------------------------------------------------------------------------------!
    3496  SUBROUTINE find_var_in_file( file_name, variable_name, file_format, file_id, variable_id, &
     3511 SUBROUTINE find_var_in_file( file_name, variable_name, file_format, file_id, variable_id,         &
    34973512                              is_global, dimensions, return_value )
     3513
     3514    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'find_var_in_file'  !< name of routine
    34983515
    34993516    CHARACTER(LEN=charlen), INTENT(OUT) ::  file_format    !< file format chosen for file
    35003517    CHARACTER(LEN=*),       INTENT(IN)  ::  file_name      !< name of file
    35013518    CHARACTER(LEN=*),       INTENT(IN)  ::  variable_name  !< name of variable
    3502 
    3503     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'find_var_in_file'  !< name of routine
    35043519
    35053520    INTEGER              ::  d             !< loop index
     
    35263541          IF ( .NOT. files(f)%is_init )  THEN
    35273542             return_value = 1
    3528              CALL internal_message( 'error', routine_name //                     &
    3529                                     ': file not initialized. ' //                &
    3530                                     'Writing variable to file is impossible ' // &
    3531                                     '(variable "' // TRIM( variable_name ) //    &
     3543             CALL internal_message( 'error', routine_name //                                       &
     3544                                    ': file not initialized. ' //                                  &
     3545                                    'Writing variable to file is impossible ' //                   &
     3546                                    '(variable "' // TRIM( variable_name ) //                      &
    35323547                                    '", file "' // TRIM( file_name ) // '")!' )
    35333548             EXIT
     
    35913606          IF ( .NOT. found )  THEN
    35923607             return_value = 1
    3593              CALL internal_message( 'error', routine_name //                  &
    3594                                     ': variable not found in file ' //        &
    3595                                     '(variable "' // TRIM( variable_name ) // &
     3608             CALL internal_message( 'error', routine_name //                                       &
     3609                                    ': variable not found in file ' //                             &
     3610                                    '(variable "' // TRIM( variable_name ) //                      &
    35963611                                    '", file "' // TRIM( file_name ) // '")!' )
    35973612          ENDIF
     
    36043619    IF ( .NOT. found  .AND.  return_value == 0 )  THEN
    36053620       return_value = 1
    3606        CALL internal_message( 'error', routine_name //                  &
    3607                               ': file not found ' //                    &
    3608                               '(variable "' // TRIM( variable_name ) // &
     3621       CALL internal_message( 'error', routine_name //                                             &
     3622                              ': file not found ' //                                               &
     3623                              '(variable "' // TRIM( variable_name ) //                            &
    36093624                              '", file "' // TRIM( file_name ) // '")!' )
    36103625    ENDIF
     
    36223637!> starts and origins are set to zero for all dimensions.
    36233638!--------------------------------------------------------------------------------------------------!
    3624  SUBROUTINE get_masked_indices_and_masked_dimension_bounds(                             &
    3625                dimensions, bounds_start, bounds_end, bounds_masked_start, value_counts, &
     3639 SUBROUTINE get_masked_indices_and_masked_dimension_bounds(                                        &
     3640               dimensions, bounds_start, bounds_end, bounds_masked_start, value_counts,            &
    36263641               bounds_origin, masked_indices )
    36273642
     
    36563671!--       Find number of masked values within given variable bounds
    36573672          value_counts(d) = 0
    3658           DO  i = LBOUND( dimensions(d)%masked_indices, DIM=1 ), &
     3673          DO  i = LBOUND( dimensions(d)%masked_indices, DIM=1 ),                                   &
    36593674                  UBOUND( dimensions(d)%masked_indices, DIM=1 )
    36603675!
    36613676!--          Is masked index within given bounds?
    3662              IF ( dimensions(d)%masked_indices(i) >= bounds_start(d)  .AND.  &
     3677             IF ( dimensions(d)%masked_indices(i) >= bounds_start(d)  .AND.                        &
    36633678                  dimensions(d)%masked_indices(i) <= bounds_end(d)           )  THEN
    36643679!
     
    37023717! Description:
    37033718! ------------
    3704 !> Message routine writing debug information into the debug file
    3705 !> or creating the error message string.
     3719!> Message routine writing debug information into the debug file or creating the error message
     3720!> string.
    37063721!--------------------------------------------------------------------------------------------------!
    37073722 SUBROUTINE internal_message( level, string )
     
    37333748
    37343749    CHARACTER(LEN=*), PARAMETER ::  separation_string = '---'                   !< string separating blocks in output
     3750    CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_database_debug_output'  !< name of this routine
     3751
     3752    INTEGER, PARAMETER ::  indent_depth = 3        !< space per indentation
     3753    INTEGER, PARAMETER ::  max_keyname_length = 6  !< length of longest key name
     3754
    37353755    CHARACTER(LEN=50)           ::  write_format1                               !< format for write statements
    3736     CHARACTER(LEN=*), PARAMETER ::  routine_name = 'dom_database_debug_output'  !< name of this routine
    37373756
    37383757    INTEGER            ::  f                       !< loop index
    3739     INTEGER, PARAMETER ::  indent_depth = 3        !< space per indentation
    37403758    INTEGER            ::  indent_level            !< indentation level
    3741     INTEGER, PARAMETER ::  max_keyname_length = 6  !< length of longest key name
    37423759    INTEGER            ::  natts                   !< number of attributes
    37433760    INTEGER            ::  ndims                   !< number of dimensions
     
    37503767    WRITE( debug_output_unit, '(A)' ) REPEAT( separation_string // ' ', 4 )
    37513768
    3752     IF ( .NOT. ALLOCATED( files ) .OR. nfiles == 0 )  THEN
     3769    IF ( .NOT. ALLOCATED( files )  .OR. nfiles == 0 )  THEN
    37533770
    37543771       WRITE( debug_output_unit, '(A)' ) 'database is empty'
     
    37573774
    37583775       indent_level = 1
    3759        WRITE( write_format1, '(A,I3,A,I3,A)' ) '(T', indent_level * indent_depth + 1, ',A,T',  &
    3760                                          indent_level * indent_depth + 1 + max_keyname_length, &
    3761                                          ',(": ")'
     3776       WRITE( write_format1, '(A,I3,A,I3,A)' ) '(T', indent_level * indent_depth + 1, ',A,T',      &
     3777                                             indent_level * indent_depth + 1 + max_keyname_length, &
     3778                                             ',(": ")'
    37623779
    37633780       DO  f = 1, nfiles
     
    37913808    CONTAINS
    37923809
    3793 !--------------------------------------------------------------------------------------------!
    3794     ! Description:
    3795     ! ------------
    3796     !> Print list of attributes.
    3797 !--------------------------------------------------------------------------------------------!
     3810!--------------------------------------------------------------------------------------------------!
     3811! Description:
     3812! ------------
     3813!> Print list of attributes.
     3814!--------------------------------------------------------------------------------------------------!
    37983815    SUBROUTINE print_attributes( indent_level, attributes )
     3816
     3817       INTEGER, PARAMETER  ::  max_keyname_length = 6  !< length of longest key name
    37993818
    38003819       CHARACTER(LEN=50) ::  write_format1  !< format for write statements
     
    38033822       INTEGER             ::  i                       !< loop index
    38043823       INTEGER, INTENT(IN) ::  indent_level            !< indentation level
    3805        INTEGER, PARAMETER  ::  max_keyname_length = 6  !< length of longest key name
    38063824       INTEGER             ::  nelement                !< number of elements to print
    38073825
     
    38103828
    38113829       WRITE( write_format1, '(A,I3,A)' ) '(T', indent_level * indent_depth + 1, ',A'
    3812        WRITE( write_format2, '(A,I3,A,I3,A)' ) &
    3813           '(T', ( indent_level + 1 ) * indent_depth + 1, ',A,T', &
     3830       WRITE( write_format2, '(A,I3,A,I3,A)' )                                                     &
     3831          '(T', ( indent_level + 1 ) * indent_depth + 1, ',A,T',                                   &
    38143832          ( indent_level + 1 ) * indent_depth + 1 + max_keyname_length, ',(": ")'
    38153833
    3816        WRITE( debug_output_unit, TRIM( write_format1 ) // ',A)' ) &
     3834       WRITE( debug_output_unit, TRIM( write_format1 ) // ',A)' )                                  &
    38173835          REPEAT( separation_string // ' ', 4 )
    38183836       WRITE( debug_output_unit, TRIM( write_format1 ) // ')' ) 'attributes:'
     
    38203838       nelement = SIZE( attributes )
    38213839       DO  i = 1, nelement
    3822           WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) &
     3840          WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' )                               &
    38233841             'name', TRIM( attributes(i)%name )
    3824           WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) &
     3842          WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' )                               &
    38253843             'type', TRIM( attributes(i)%data_type )
    38263844
    38273845          IF ( TRIM( attributes(i)%data_type ) == 'char' )  THEN
    3828              WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) &
     3846             WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' )                            &
    38293847                'value', TRIM( attributes(i)%value_char )
    38303848          ELSEIF ( TRIM( attributes(i)%data_type ) == 'int8' )  THEN
    3831              WRITE( debug_output_unit, TRIM( write_format2 ) // ',I4)' ) &
     3849             WRITE( debug_output_unit, TRIM( write_format2 ) // ',I4)' )                           &
    38323850                'value', attributes(i)%value_int8
    38333851          ELSEIF ( TRIM( attributes(i)%data_type ) == 'int16' )  THEN
    3834              WRITE( debug_output_unit, TRIM( write_format2 ) // ',I6)' ) &
     3852             WRITE( debug_output_unit, TRIM( write_format2 ) // ',I6)' )                           &
    38353853                'value', attributes(i)%value_int16
    38363854          ELSEIF ( TRIM( attributes(i)%data_type ) == 'int32' )  THEN
    3837              WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)' ) &
     3855             WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)' )                          &
    38383856                'value', attributes(i)%value_int32
    38393857          ELSEIF ( TRIM( attributes(i)%data_type ) == 'real32' )  THEN
    3840              WRITE( debug_output_unit, TRIM( write_format2 ) // ',E14.7)' ) &
     3858             WRITE( debug_output_unit, TRIM( write_format2 ) // ',E14.7)' )                        &
    38413859                'value', attributes(i)%value_real32
    38423860          ELSEIF (  TRIM(attributes(i)%data_type) == 'real64' )  THEN
    3843              WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)' ) &
     3861             WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)' )                       &
    38443862                'value', attributes(i)%value_real64
    38453863          ENDIF
    3846           IF ( i < nelement )  &
     3864          IF ( i < nelement )                                                                      &
    38473865             WRITE( debug_output_unit, TRIM( write_format1 ) // ')' ) separation_string
    38483866       ENDDO
     
    38503868    END SUBROUTINE print_attributes
    38513869
    3852 !--------------------------------------------------------------------------------------------!
    3853     ! Description:
    3854     ! ------------
    3855     !> Print list of dimensions.
    3856 !--------------------------------------------------------------------------------------------!
     3870!--------------------------------------------------------------------------------------------------!
     3871! Description:
     3872! ------------
     3873!> Print list of dimensions.
     3874!--------------------------------------------------------------------------------------------------!
    38573875    SUBROUTINE print_dimensions( indent_level, dimensions )
     3876
     3877       INTEGER, PARAMETER  ::  max_keyname_length = 15  !< length of longest key name
    38583878
    38593879       CHARACTER(LEN=50) ::  write_format1  !< format for write statements
     
    38633883       INTEGER, INTENT(IN) ::  indent_level             !< indentation level
    38643884       INTEGER             ::  j                        !< loop index
    3865        INTEGER, PARAMETER  ::  max_keyname_length = 15  !< length of longest key name
    38663885       INTEGER             ::  nelement                 !< number of elements to print
    38673886
     
    38723891
    38733892       WRITE( write_format1, '(A,I3,A)' ) '(T', indent_level * indent_depth + 1, ',A'
    3874        WRITE( write_format2, '(A,I3,A,I3,A)' ) &
    3875           '(T', ( indent_level + 1 ) * indent_depth + 1, ',A,T', &
     3893       WRITE( write_format2, '(A,I3,A,I3,A)' )                                                     &
     3894          '(T', ( indent_level + 1 ) * indent_depth + 1, ',A,T',                                   &
    38763895          ( indent_level + 1 ) * indent_depth + 1 + max_keyname_length, ',(": ")'
    38773896
    3878        WRITE( debug_output_unit, TRIM( write_format1 ) // ',A)' ) &
     3897       WRITE( debug_output_unit, TRIM( write_format1 ) // ',A)' )                                  &
    38793898          REPEAT( separation_string // ' ', 4 )
    38803899       WRITE( debug_output_unit, TRIM( write_format1 ) // ')' ) 'dimensions:'
     
    38853904!
    38863905!--       Print general information
    3887           WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) &
     3906          WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' )                               &
    38883907             'name', TRIM( dimensions(i)%name )
    3889           WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) &
     3908          WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' )                               &
    38903909             'type', TRIM( dimensions(i)%data_type )
    3891           WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)' ) &
     3910          WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)' )                              &
    38923911             'id', dimensions(i)%id
    3893           WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)' ) &
     3912          WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)' )                              &
    38943913             'length', dimensions(i)%length
    3895           WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7,A,I7)' ) &
     3914          WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7,A,I7)' )                         &
    38963915             'bounds', dimensions(i)%bounds(1), ',', dimensions(i)%bounds(2)
    3897           WRITE( debug_output_unit, TRIM( write_format2 ) // ',L1)' ) &
     3916          WRITE( debug_output_unit, TRIM( write_format2 ) // ',L1)' )                              &
    38983917             'is masked', dimensions(i)%is_masked
    38993918!
    39003919!--       Print information about mask
    39013920          IF ( is_masked )  THEN
    3902              WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)' ) &
     3921             WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)' )                           &
    39033922                'masked length', dimensions(i)%length_mask
    39043923
    3905              WRITE( debug_output_unit, TRIM( write_format2 ) // ',L1)', ADVANCE='no' ) &
     3924             WRITE( debug_output_unit, TRIM( write_format2 ) // ',L1)', ADVANCE='no' )             &
    39063925                'mask', dimensions(i)%mask(dimensions(i)%bounds(1))
    39073926             DO  j = dimensions(i)%bounds(1)+1, dimensions(i)%bounds(2)
     
    39103929             WRITE( debug_output_unit, '(A)' )  ''  ! write line-end
    39113930
    3912              WRITE( debug_output_unit, TRIM( write_format2 ) // ',I6)', ADVANCE='no' ) &
     3931             WRITE( debug_output_unit, TRIM( write_format2 ) // ',I6)', ADVANCE='no' )             &
    39133932                'masked indices', dimensions(i)%masked_indices(0)
    39143933             DO  j = 1, dimensions(i)%length_mask-1
    3915                 WRITE( debug_output_unit, '(A,I6)', ADVANCE='no' ) &
     3934                WRITE( debug_output_unit, '(A,I6)', ADVANCE='no' )                                 &
    39163935                   ',', dimensions(i)%masked_indices(j)
    39173936             ENDDO
     
    39223941          IF ( ALLOCATED( dimensions(i)%values_int8 ) )  THEN
    39233942
    3924              WRITE( debug_output_unit, TRIM( write_format2 ) // ',I4)', ADVANCE='no' ) &
     3943             WRITE( debug_output_unit, TRIM( write_format2 ) // ',I4)', ADVANCE='no' )             &
    39253944                'values', dimensions(i)%values_int8(dimensions(i)%bounds(1))
    39263945             DO  j = dimensions(i)%bounds(1)+1, dimensions(i)%bounds(2)
    3927                 WRITE( debug_output_unit, '(A,I4)', ADVANCE='no' ) &
     3946                WRITE( debug_output_unit, '(A,I4)', ADVANCE='no' )                                 &
    39283947                   ',', dimensions(i)%values_int8(j)
    39293948             ENDDO
    39303949             WRITE( debug_output_unit, '(A)' )  ''  ! write line-end
    39313950             IF ( is_masked )  THEN
    3932                 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I4)', ADVANCE='no' ) &
     3951                WRITE( debug_output_unit, TRIM( write_format2 ) // ',I4)', ADVANCE='no' )          &
    39333952                   'masked values', dimensions(i)%masked_values_int8(0)
    39343953                DO  j = 1, dimensions(i)%length_mask-1
    3935                    WRITE( debug_output_unit, '(A,I4)', ADVANCE='no' ) &
     3954                   WRITE( debug_output_unit, '(A,I4)', ADVANCE='no' )                              &
    39363955                      ',', dimensions(i)%masked_values_int8(j)
    39373956                ENDDO
     
    39413960          ELSEIF ( ALLOCATED( dimensions(i)%values_int16 ) )  THEN
    39423961
    3943              WRITE( debug_output_unit, TRIM( write_format2 ) // ',I6)', ADVANCE='no' ) &
     3962             WRITE( debug_output_unit, TRIM( write_format2 ) // ',I6)', ADVANCE='no' )             &
    39443963                'values', dimensions(i)%values_int16(dimensions(i)%bounds(1))
    39453964             DO  j = dimensions(i)%bounds(1)+1, dimensions(i)%bounds(2)
    3946                 WRITE( debug_output_unit, '(A,I6)', ADVANCE='no' ) &
     3965                WRITE( debug_output_unit, '(A,I6)', ADVANCE='no' )                                 &
    39473966                   ',', dimensions(i)%values_int16(j)
    39483967             ENDDO
    39493968             WRITE( debug_output_unit, '(A)' )  ''  ! write line-end
    39503969             IF ( is_masked )  THEN
    3951                 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I6)', ADVANCE='no' ) &
     3970                WRITE( debug_output_unit, TRIM( write_format2 ) // ',I6)', ADVANCE='no' )          &
    39523971                   'masked values', dimensions(i)%masked_values_int16(0)
    39533972                DO  j = 1, dimensions(i)%length_mask-1
    3954                    WRITE( debug_output_unit, '(A,I6)', ADVANCE='no' ) &
     3973                   WRITE( debug_output_unit, '(A,I6)', ADVANCE='no' )                              &
    39553974                      ',', dimensions(i)%masked_values_int16(j)
    39563975                ENDDO
     
    39603979          ELSEIF ( ALLOCATED( dimensions(i)%values_int32 ) )  THEN
    39613980
    3962              WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)', ADVANCE='no' ) &
     3981             WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)', ADVANCE='no' )            &
    39633982                'values', dimensions(i)%values_int32(dimensions(i)%bounds(1))
    39643983             DO  j = dimensions(i)%bounds(1)+1, dimensions(i)%bounds(2)
    3965                 WRITE( debug_output_unit, '(A,I11)', ADVANCE='no' ) &
     3984                WRITE( debug_output_unit, '(A,I11)', ADVANCE='no' )                                &
    39663985                   ',', dimensions(i)%values_int32(j)
    39673986             ENDDO
    39683987             WRITE( debug_output_unit, '(A)' )  ''  ! write line-end
    39693988             IF ( is_masked )  THEN
    3970                 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)', ADVANCE='no' ) &
     3989                WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)', ADVANCE='no' )         &
    39713990                   'masked values', dimensions(i)%masked_values_int32(0)
    39723991                DO  j = 1, dimensions(i)%length_mask-1
    3973                    WRITE( debug_output_unit, '(A,I11)', ADVANCE='no' ) &
     3992                   WRITE( debug_output_unit, '(A,I11)', ADVANCE='no' )                             &
    39743993                      ',', dimensions(i)%masked_values_int32(j)
    39753994                ENDDO
     
    39793998          ELSEIF ( ALLOCATED( dimensions(i)%values_intwp ) )  THEN
    39803999
    3981              WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)', ADVANCE='no' ) &
     4000             WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)', ADVANCE='no' )            &
    39824001                'values', dimensions(i)%values_intwp(dimensions(i)%bounds(1))
    39834002             DO  j = dimensions(i)%bounds(1)+1, dimensions(i)%bounds(2)
    3984                 WRITE( debug_output_unit, '(A,I11)', ADVANCE='no' ) &
     4003                WRITE( debug_output_unit, '(A,I11)', ADVANCE='no' )                                &
    39854004                   ',', dimensions(i)%values_intwp(j)
    39864005             ENDDO
    39874006             WRITE( debug_output_unit, '(A)' )  ''  ! write line-end
    39884007             IF ( is_masked )  THEN
    3989                 WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)', ADVANCE='no' ) &
     4008                WRITE( debug_output_unit, TRIM( write_format2 ) // ',I11)', ADVANCE='no' )         &
    39904009                   'masked values', dimensions(i)%masked_values_intwp(0)
    39914010                DO  j = 1, dimensions(i)%length_mask-1
    3992                    WRITE( debug_output_unit, '(A,I11)', ADVANCE='no' ) &
     4011                   WRITE( debug_output_unit, '(A,I11)', ADVANCE='no' )                             &
    39934012                      ',', dimensions(i)%masked_values_intwp(j)
    39944013                ENDDO
     
    39984017          ELSEIF ( ALLOCATED( dimensions(i)%values_real32 ) )  THEN
    39994018
    4000              WRITE( debug_output_unit, TRIM( write_format2 ) // ',E14.7)', ADVANCE='no' ) &
     4019             WRITE( debug_output_unit, TRIM( write_format2 ) // ',E14.7)', ADVANCE='no' )          &
    40014020                'values', dimensions(i)%values_real32(dimensions(i)%bounds(1))
    40024021             DO  j = dimensions(i)%bounds(1)+1, dimensions(i)%bounds(2)
    4003                 WRITE( debug_output_unit, '(A,E14.7)', ADVANCE='no' ) &
     4022                WRITE( debug_output_unit, '(A,E14.7)', ADVANCE='no' )                              &
    40044023                   ',', dimensions(i)%values_real32(j)
    40054024             ENDDO
    40064025             WRITE( debug_output_unit, '(A)' )  ''  ! write line-end
    40074026             IF ( is_masked )  THEN
    4008                 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E14.7)', ADVANCE='no' ) &
     4027                WRITE( debug_output_unit, TRIM( write_format2 ) // ',E14.7)', ADVANCE='no' )       &
    40094028                   'masked values', dimensions(i)%masked_values_real32(0)
    40104029                DO  j = 1, dimensions(i)%length_mask-1
    4011                    WRITE( debug_output_unit, '(A,E14.7)', ADVANCE='no' ) &
     4030                   WRITE( debug_output_unit, '(A,E14.7)', ADVANCE='no' )                           &
    40124031                      ',', dimensions(i)%masked_values_real32(j)
    40134032                ENDDO
     
    40174036          ELSEIF ( ALLOCATED( dimensions(i)%values_real64 ) )  THEN
    40184037
    4019              WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)', ADVANCE='no' ) &
     4038             WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)', ADVANCE='no' )         &
    40204039                'values', dimensions(i)%values_real64(dimensions(i)%bounds(1))
    40214040             DO  j = dimensions(i)%bounds(1)+1, dimensions(i)%bounds(2)
    4022                 WRITE( debug_output_unit, '(A,E22.15)', ADVANCE='no' ) &
     4041                WRITE( debug_output_unit, '(A,E22.15)', ADVANCE='no' )                             &
    40234042                   ',', dimensions(i)%values_real64(j)
    40244043             ENDDO
    40254044             WRITE( debug_output_unit, '(A)' )  ''  ! write line-end
    40264045             IF ( is_masked )  THEN
    4027                 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)', ADVANCE='no' ) &
     4046                WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)', ADVANCE='no' )      &
    40284047                   'masked values', dimensions(i)%masked_values_real64(0)
    40294048                DO  j = 1, dimensions(i)%length_mask-1
    4030                    WRITE( debug_output_unit, '(A,E22.15)', ADVANCE='no' ) &
     4049                   WRITE( debug_output_unit, '(A,E22.15)', ADVANCE='no' )                          &
    40314050                      ',', dimensions(i)%masked_values_real64(j)
    40324051                ENDDO
     
    40364055          ELSEIF ( ALLOCATED( dimensions(i)%values_realwp ) )  THEN
    40374056
    4038              WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)', ADVANCE='no' ) &
     4057             WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)', ADVANCE='no' )         &
    40394058                'values', dimensions(i)%values_realwp(dimensions(i)%bounds(1))
    40404059             DO  j = dimensions(i)%bounds(1)+1, dimensions(i)%bounds(2)
    4041                 WRITE( debug_output_unit, '(A,E22.15)', ADVANCE='no' ) &
     4060                WRITE( debug_output_unit, '(A,E22.15)', ADVANCE='no' )                             &
    40424061                   ',', dimensions(i)%values_realwp(j)
    40434062             ENDDO
    40444063             WRITE( debug_output_unit, '(A)' )  ''  ! write line-end
    40454064             IF ( is_masked )  THEN
    4046                 WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)', ADVANCE='no' ) &
     4065                WRITE( debug_output_unit, TRIM( write_format2 ) // ',E22.15)', ADVANCE='no' )      &
    40474066                   'masked values', dimensions(i)%masked_values_realwp(0)
    40484067                DO  j = 1, dimensions(i)%length_mask-1
    4049                    WRITE( debug_output_unit, '(A,E22.15)', ADVANCE='no' ) &
     4068                   WRITE( debug_output_unit, '(A,E22.15)', ADVANCE='no' )                          &
    40504069                      ',', dimensions(i)%masked_values_realwp(j)
    40514070                ENDDO
     
    40554074          ENDIF
    40564075
    4057           IF ( ALLOCATED( dimensions(i)%attributes ) )  &
     4076          IF ( ALLOCATED( dimensions(i)%attributes ) )                                             &
    40584077             CALL print_attributes( indent_level+1, dimensions(i)%attributes )
    40594078
    4060           IF ( i < nelement )  &
     4079          IF ( i < nelement )                                                                      &
    40614080             WRITE( debug_output_unit, TRIM( write_format1 ) // ')' ) separation_string
    40624081       ENDDO
     
    40644083    END SUBROUTINE print_dimensions
    40654084
    4066 !--------------------------------------------------------------------------------------------!
    4067     ! Description:
    4068     ! ------------
    4069     !> Print list of variables.
    4070 !--------------------------------------------------------------------------------------------!
     4085!--------------------------------------------------------------------------------------------------!
     4086! Description:
     4087! ------------
     4088!> Print list of variables.
     4089!--------------------------------------------------------------------------------------------------!
    40714090    SUBROUTINE print_variables( indent_level, variables )
     4091
     4092       INTEGER, PARAMETER  ::  max_keyname_length = 16  !< length of longest key name
    40724093
    40734094       CHARACTER(LEN=50) ::  write_format1  !< format for write statements
     
    40774098       INTEGER, INTENT(IN) ::  indent_level             !< indentation level
    40784099       INTEGER             ::  j                        !< loop index
    4079        INTEGER, PARAMETER  ::  max_keyname_length = 16  !< length of longest key name
    40804100       INTEGER             ::  nelement                 !< number of elements to print
    40814101
     
    40844104
    40854105       WRITE( write_format1, '(A,I3,A)' ) '(T', indent_level * indent_depth + 1, ',A'
    4086        WRITE( write_format2, '(A,I3,A,I3,A)' ) &
    4087           '(T', ( indent_level + 1 ) * indent_depth + 1, ',A,T', &
     4106       WRITE( write_format2, '(A,I3,A,I3,A)' )                                                     &
     4107          '(T', ( indent_level + 1 ) * indent_depth + 1, ',A,T',                                   &
    40884108          ( indent_level + 1 ) * indent_depth + 1 + max_keyname_length, ',(": ")'
    40894109
    4090        WRITE( debug_output_unit, TRIM( write_format1 ) // ',A)' ) &
     4110       WRITE( debug_output_unit, TRIM( write_format1 ) // ',A)' )                                  &
    40914111          REPEAT( separation_string // ' ', 4 )
    40924112       WRITE( debug_output_unit, TRIM( write_format1 ) // ')' ) 'variables:'
     
    40944114       nelement = SIZE( variables )
    40954115       DO  i = 1, nelement
    4096           WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) &
     4116          WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' )                               &
    40974117             'name', TRIM( variables(i)%name )
    4098           WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' ) &
     4118          WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)' )                               &
    40994119             'type', TRIM( variables(i)%data_type )
    4100           WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)' ) &
     4120          WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)' )                              &
    41014121             'id', variables(i)%id
    4102           WRITE( debug_output_unit, TRIM( write_format2 ) // ',L1)' ) &
     4122          WRITE( debug_output_unit, TRIM( write_format2 ) // ',L1)' )                              &
    41034123             'is global', variables(i)%is_global
    41044124
    4105           WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)', ADVANCE='no' ) &
     4125          WRITE( debug_output_unit, TRIM( write_format2 ) // ',A)', ADVANCE='no' )                 &
    41064126             'dimension names', TRIM( variables(i)%dimension_names(1) )
    41074127          DO  j = 2, SIZE( variables(i)%dimension_names )
    4108              WRITE( debug_output_unit, '(A,A)', ADVANCE='no' ) &
     4128             WRITE( debug_output_unit, '(A,A)', ADVANCE='no' )                                     &
    41094129                ',', TRIM( variables(i)%dimension_names(j) )
    41104130          ENDDO
    41114131          WRITE( debug_output_unit, '(A)' )  ''  ! write line-end
    41124132
    4113           WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)', ADVANCE='no' ) &
     4133          WRITE( debug_output_unit, TRIM( write_format2 ) // ',I7)', ADVANCE='no' )                &
    41144134             'dimension ids', variables(i)%dimension_ids(1)
    41154135          DO  j = 2, SIZE( variables(i)%dimension_names )
    4116              WRITE( debug_output_unit, '(A,I7)', ADVANCE='no' ) &
     4136             WRITE( debug_output_unit, '(A,I7)', ADVANCE='no' )                                    &
    41174137                ',', variables(i)%dimension_ids(j)
    41184138          ENDDO
    41194139          WRITE( debug_output_unit, '(A)' )  ''  ! write line-end
    41204140
    4121           IF ( ALLOCATED( variables(i)%attributes ) )  &
     4141          IF ( ALLOCATED( variables(i)%attributes ) )                                              &
    41224142             CALL print_attributes( indent_level+1, variables(i)%attributes )
    4123           IF ( i < nelement )  &
     4143          IF ( i < nelement )                                                                      &
    41244144             WRITE( debug_output_unit, TRIM( write_format1 ) // ')' ) separation_string
    41254145       ENDDO
Note: See TracChangeset for help on using the changeset viewer.