Index: palm/trunk/SOURCE/user_module.f90
===================================================================
--- palm/trunk/SOURCE/user_module.f90	(revision 4503)
+++ palm/trunk/SOURCE/user_module.f90	(revision 4504)
@@ -21,10 +21,12 @@
 ! -----------------
 ! 
-! 
+!
 ! Former revisions:
 ! -----------------
 ! $Id$
+! hint for setting rmask arrays added
+! 
+! 4497 2020-04-15 10:20:51Z raasch
 ! file re-formatted to follow the PALM coding standard
-!
 !
 ! 4495 2020-04-13 20:11:20Z raasch
@@ -464,4 +466,8 @@
 !
 !-- Example for defining a statistic region:
+!-- ATTENTION: rmask = 0 is required at the ghost boundaries to guarantee correct statistic
+!--            evaluations (otherwise ghost points would be counted twice). This setting has
+!--            already been cared for in routine init_3d_model. Please don't set the ghost points
+!--            /= 0. i.e. run the following loop only over nxl,nxr and nys,nyn.
 !     IF ( statistic_regions >= 1 )  THEN
 !        region = 1
Index: palm/trunk/SOURCE/virtual_measurement_mod.f90
===================================================================
--- palm/trunk/SOURCE/virtual_measurement_mod.f90	(revision 4503)
+++ palm/trunk/SOURCE/virtual_measurement_mod.f90	(revision 4504)
@@ -21,10 +21,9 @@
 ! -----------------
 ! 
-! 
+!
 ! Former revisions:
 ! -----------------
 ! $Id$
 ! file re-formatted to follow the PALM coding standard
-!
 !
 ! 4481 2020-03-31 18:55:54Z maronga
@@ -456,6 +455,5 @@
                         'If virtual measurements are taken, the number ' //                        &
                         'of surrounding grid points must not be larger ' //                        &
-                        'than the number of ghost points - 1, which is: ',                         &
-                        nbgp - 1
+                        'than the number of ghost points - 1, which is: ', nbgp - 1
        CALL message( 'vm_check_parameters', 'PA0705', 1, 2, 0, 6, 0 )
     ENDIF
@@ -1360,7 +1358,6 @@
 !
 !-- Determine the number of output timesteps.
-    ntimesteps = CEILING(                                                                          &
-                  ( end_time - MAX( vm_time_start, time_since_reference_point )                    &
-                  ) / dt_virtual_measurement )
+    ntimesteps = CEILING( ( end_time - MAX( vm_time_start, time_since_reference_point )            &
+                          ) / dt_virtual_measurement )
 !
 !-- Create directory where output files will be stored.
@@ -1384,90 +1381,59 @@
                                        dum_lon, dum_lat )
 
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'site',                                        &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'site',                   &
                                    value = TRIM( vmea(l)%site ) )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'title',                                       &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'title',                  &
                                    value = 'Virtual measurement output')
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'source',                                      &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'source',                 &
                                    value = 'PALM-4U')
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'institution',                                 &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'institution',            &
                                    value = input_file_atts%institution )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'acronym',                                     &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'acronym',                &
                                    value = input_file_atts%acronym )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'author',                                      &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'author',                 &
                                    value = input_file_atts%author )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'contact_person',                              &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'contact_person',         &
                                    value = input_file_atts%contact_person )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'iop',                                         &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'iop',                    &
                                    value = input_file_atts%campaign )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'campaign',                                    &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'campaign',               &
                                    value = 'PALM-4U' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'origin_time ',                                &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'origin_time ',           &
                                    value = origin_date_time)
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'location',                                    &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'location',               &
                                    value = input_file_atts%location )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'origin_x',                                    &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'origin_x',               &
                                    value = vmea(l)%origin_x_obs )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'origin_y',                                    &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'origin_y',               &
                                    value = vmea(l)%origin_y_obs )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'origin_lon',                                  &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'origin_lon',             &
                                    value = dum_lon )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'origin_lat',                                  &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'origin_lat',             &
                                    value = dum_lat )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'origin_z',                                    &
-                                   value = 0.0 )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'rotation_angle',                              &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'origin_z', value = 0.0 )
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'rotation_angle',         &
                                    value = input_file_atts%rotation_angle )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'featureType',                                 &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'featureType',            &
                                    value = TRIM( vmea(l)%feature_type_out ) )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'data_content',                                &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'data_content',           &
                                    value = TRIM( vmea(l)%data_content ) )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'creation_time',                               &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'creation_time',          &
                                    value = input_file_atts%creation_time )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'version',                                     &
-                                   value = 1 ) !input_file_atts%version )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'creation_time',                               &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'version', value = 1 ) !input_file_atts%version
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'creation_time',          &
                                    value = TRIM( vmea(l)%site ) )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'Conventions',                                 &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'Conventions',            &
                                    value = input_file_atts%conventions )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'dependencies',                                &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'dependencies',           &
                                    value = input_file_atts%dependencies )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'history',                                     &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'history',                &
                                    value = input_file_atts%history )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'references',                                  &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'references',             &
                                    value = input_file_atts%references )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'comment',                                     &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'comment',                &
                                    value = input_file_atts%comment )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'keywords',                                    &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'keywords',               &
                                    value = input_file_atts%keywords )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   attribute_name = 'licence',                                     &
+       return_value = dom_def_att( vmea(l)%nc_filename, attribute_name = 'licence',                &
                                    value = '[UC]2 Open Licence; see [UC]2 ' //                     &
                                            'data policy available at ' //                          &
@@ -1584,217 +1550,134 @@
 !--    of attributes.
 !--    Units
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'time',                                         &
-                                   attribute_name = char_unit,                                     &
-                                   value = 'seconds since ' // origin_date_time )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'z',                                            &
-                                   attribute_name = char_unit,                                     &
-                                   value = 'm' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'station_h',                                    &
-                                   attribute_name = char_unit,                                     &
-                                   value = 'm' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'x',                                            &
-                                   attribute_name = char_unit,                                     &
-                                   value = 'm' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'y',                                            &
-                                   attribute_name = char_unit,                                     &
-                                   value = 'm' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'E_UTM',                                        &
-                                   attribute_name = char_unit,                                     &
-                                   value = 'm' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'N_UTM',                                        &
-                                   attribute_name = char_unit,                                     &
-                                   value = 'm' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'lat',                                          &
-                                   attribute_name = char_unit,                                     &
-                                   value = 'degrees_north' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'lon',                                          &
-                                   attribute_name = char_unit,                                     &
-                                   value = 'degrees_east' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'time',                    &
+                                   attribute_name = char_unit, value = 'seconds since ' //         &
+                                   origin_date_time )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'z',                       &
+                                   attribute_name = char_unit, value = 'm' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'station_h',               &
+                                   attribute_name = char_unit, value = 'm' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'x',                       &
+                                   attribute_name = char_unit, value = 'm' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'y',                       &
+                                   attribute_name = char_unit, value = 'm' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'E_UTM',                   &
+                                   attribute_name = char_unit, value = 'm' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'N_UTM',                   &
+                                   attribute_name = char_unit, value = 'm' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'lat',                     &
+                                   attribute_name = char_unit, value = 'degrees_north' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'lon',                     &
+                                   attribute_name = char_unit, value = 'degrees_east' )
 !
 !--    Long name
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'station_name',                                 &
-                                   attribute_name = char_long,                                     &
-                                   value = 'station name')
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'time',                                         &
-                                   attribute_name = char_long,                                     &
-                                   value = 'time')
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'z',                                            &
-                                   attribute_name = char_long,                                     &
-                                   value = 'height above origin' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'station_h',                                    &
-                                   attribute_name = char_long,                                     &
-                                   value = 'surface altitude' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'x',                                            &
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'station_name',            &
+                                   attribute_name = char_long, value = 'station name')
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'time',                    &
+                                   attribute_name = char_long, value = 'time')
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'z',                       &
+                                   attribute_name = char_long, value = 'height above origin' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'station_h',               &
+                                   attribute_name = char_long, value = 'surface altitude' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'x',                       &
                                    attribute_name = char_long,                                     &
                                    value = 'distance to origin in x-direction')
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'y',                                            &
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'y',                       &
                                    attribute_name = char_long,                                     &
                                    value = 'distance to origin in y-direction')
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'E_UTM',                                        &
-                                   attribute_name = char_long,                                     &
-                                   value = 'easting' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'N_UTM',                                        &
-                                   attribute_name = char_long,                                     &
-                                   value = 'northing' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'lat',                                          &
-                                   attribute_name = char_long,                                     &
-                                   value = 'latitude' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'lon',                                          &
-                                   attribute_name = char_long,                                     &
-                                   value = 'longitude' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'E_UTM',                   &
+                                   attribute_name = char_long, value = 'easting' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'N_UTM',                   &
+                                   attribute_name = char_long, value = 'northing' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'lat',                     &
+                                   attribute_name = char_long, value = 'latitude' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'lon',                     &
+                                   attribute_name = char_long, value = 'longitude' )
 !
 !--    Standard name
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'station_name',                                 &
-                                   attribute_name = char_standard,                                 &
-                                   value = 'platform_name')
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'time',                                         &
-                                   attribute_name = char_standard,                                 &
-                                   value = 'time')
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'z',                                            &
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'station_name',            &
+                                   attribute_name = char_standard, value = 'platform_name')
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'time',                    &
+                                   attribute_name = char_standard, value = 'time')
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'z',                       &
                                    attribute_name = char_standard,                                 &
                                    value = 'height_above_mean_sea_level' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'station_h',                                    &
-                                   attribute_name = char_standard,                                 &
-                                   value = 'surface_altitude' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'E_UTM',                                        &
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'station_h',               &
+                                   attribute_name = char_standard, value = 'surface_altitude' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'E_UTM',                   &
                                    attribute_name = char_standard,                                 &
                                    value = 'projection_x_coordinate' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'N_UTM',                                        &
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'N_UTM',                   &
                                    attribute_name = char_standard,                                 &
                                    value = 'projection_y_coordinate' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'lat',                                          &
-                                   attribute_name = char_standard,                                 &
-                                   value = 'latitude' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'lon',                                          &
-                                   attribute_name = char_standard,                                 &
-                                   value = 'longitude' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'lat',                     &
+                                   attribute_name = char_standard, value = 'latitude' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'lon',                     &
+                                   attribute_name = char_standard, value = 'longitude' )
 !
 !--    Axis
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'time',                                         &
-                                   attribute_name = 'axis',                                        &
-                                   value = 'T')
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'z',                                            &
-                                   attribute_name = 'axis',                                        &
-                                   value = 'Z' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'x',                                            &
-                                   attribute_name = 'axis',                                        &
-                                   value = 'X' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'y',                                            &
-                                   attribute_name = 'axis',                                        &
-                                   value = 'Y' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'time',                    &
+                                   attribute_name = 'axis', value = 'T')
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'z',                       &
+                                   attribute_name = 'axis', value = 'Z' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'x',                       &
+                                   attribute_name = 'axis', value = 'X' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'y',                       &
+                                   attribute_name = 'axis', value = 'Y' )
 !
 !--    Set further individual attributes for the coordinate variables.
 !--    For station name
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'station_name',                                 &
-                                   attribute_name = 'cf_role',                                     &
-                                   value = 'timeseries_id' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'station_name',            &
+                                   attribute_name = 'cf_role', value = 'timeseries_id' )
 !
 !--    For time
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'time',                                         &
-                                   attribute_name = 'calendar',                                    &
-                                   value = 'proleptic_gregorian' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'time',                                         &
-                                   attribute_name = 'bounds',                                      &
-                                   value = 'time_bounds' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'time',                    &
+                                   attribute_name = 'calendar', value = 'proleptic_gregorian' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'time',                    &
+                                   attribute_name = 'bounds', value = 'time_bounds' )
 !
 !--    For vertical reference system
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'vrs',                                          &
-                                   attribute_name = char_long,                                     &
-                                   value = 'vertical reference system' )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'vrs',                                          &
-                                   attribute_name = 'system_name',                                 &
-                                   value = 'DHHN2016' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'vrs',                     &
+                                   attribute_name = char_long, value = 'vertical reference system' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'vrs',                     &
+                                   attribute_name = 'system_name', value = 'DHHN2016' )
 !
 !--    For z
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'z',                                            &
-                                   attribute_name = 'positive',                                    &
-                                   value = 'up' )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'z',                       &
+                                   attribute_name = 'positive', value = 'up' )
 !
 !--    For coordinate reference system
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'crs',                                          &
-                                   attribute_name = 'epsg_code',                                   &
-                                   value = coord_ref_sys%epsg_code )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'crs',                                          &
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'crs',                     &
+                                   attribute_name = 'epsg_code', value = coord_ref_sys%epsg_code )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'crs',                     &
                                    attribute_name = 'false_easting',                               &
                                    value = coord_ref_sys%false_easting )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'crs',                                          &
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'crs',                     &
                                    attribute_name = 'false_northing',                              &
                                    value = coord_ref_sys%false_northing )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'crs',                                          &
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'crs',                     &
                                    attribute_name = 'grid_mapping_name',                           &
                                    value = coord_ref_sys%grid_mapping_name )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'crs',                                          &
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'crs',                     &
                                    attribute_name = 'inverse_flattening',                          &
                                    value = coord_ref_sys%inverse_flattening )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'crs',                                          &
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'crs',                     &
                                    attribute_name = 'latitude_of_projection_origin',&
                                    value = coord_ref_sys%latitude_of_projection_origin )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'crs',                                          &
-                                   attribute_name = char_long,                                     &
-                                   value = coord_ref_sys%long_name )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'crs',                                          &
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'crs',                     &
+                                   attribute_name = char_long, value = coord_ref_sys%long_name )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'crs',                     &
                                    attribute_name = 'longitude_of_central_meridian',               &
                                    value = coord_ref_sys%longitude_of_central_meridian )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'crs',                                          &
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'crs',                     &
                                    attribute_name = 'longitude_of_prime_meridian',                 &
                                    value = coord_ref_sys%longitude_of_prime_meridian )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'crs',                                          &
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'crs',                     &
                                    attribute_name = 'scale_factor_at_central_meridian',            &
                                    value = coord_ref_sys%scale_factor_at_central_meridian )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'crs',                                          &
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'crs',                     &
                                    attribute_name = 'semi_major_axis',                             &
                                    value = coord_ref_sys%semi_major_axis )
-       return_value = dom_def_att( vmea(l)%nc_filename,                                            &
-                                   variable_name = 'crs',                                          &
-                                   attribute_name = char_unit,                                     &
-                                   value = coord_ref_sys%units )
+       return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'crs',                     &
+                                   attribute_name = char_unit, value = coord_ref_sys%units )
 !
 !--    In case of sampled soil quantities, define further dimensions and coordinates.
@@ -1807,9 +1690,7 @@
           ENDDO
 
-          return_value = dom_def_dim( vmea(l)%nc_filename,                                         &
-                                      dimension_name = 'station_soil',                             &
+          return_value = dom_def_dim( vmea(l)%nc_filename, dimension_name = 'station_soil',        &
                                       output_type = 'int32',                                       &
-                                      bounds = (/1_iwp,vmea(l)%ns_soil_tot/),                      &
-                                      values_int32 = ndim )
+                                      bounds = (/1_iwp,vmea(l)%ns_soil_tot/), values_int32 = ndim )
           DEALLOCATE( ndim )
 !
@@ -1820,8 +1701,6 @@
           ENDDO
 
-          return_value = dom_def_dim( vmea(l)%nc_filename,                                         &
-                                      dimension_name = 'ntime_soil',                               &
-                                      output_type = 'int32',                                       &
-                                      bounds = (/1_iwp,ntimesteps/),                               &
+          return_value = dom_def_dim( vmea(l)%nc_filename, dimension_name = 'ntime_soil',          &
+                                      output_type = 'int32', bounds = (/1_iwp,ntimesteps/),        &
                                       values_int32 = ndim )
           DEALLOCATE( ndim )
@@ -1829,230 +1708,146 @@
 !--       time for soil
           variable_name = 'time_soil'
-          return_value = dom_def_var( vmea(l)%nc_filename,                                         &
-                                      variable_name = variable_name,                               &
-                                      dimension_names = (/'station_soil',                          &
-                                                          'ntime_soil  '/),                        &
+          return_value = dom_def_var( vmea(l)%nc_filename, variable_name = variable_name,          &
+                                      dimension_names = (/'station_soil', 'ntime_soil  '/),        &
                                       output_type = 'real32' )
 !
 !--       station_name for soil
           variable_name = 'station_name_soil'
-          return_value = dom_def_var( vmea(l)%nc_filename,                                         &
-                                      variable_name = variable_name,                               &
-                                      dimension_names = (/ 'max_name_len',                         &
-                                                           'station_soil' /),                      &
+          return_value = dom_def_var( vmea(l)%nc_filename, variable_name = variable_name,          &
+                                      dimension_names = (/ 'max_name_len', 'station_soil' /),      &
                                       output_type = 'char' )
 !
 !--       z
           variable_name = 'z_soil'
-          return_value = dom_def_var( vmea(l)%nc_filename,                                         &
-                                      variable_name = variable_name,                               &
-                                      dimension_names = (/'station_soil'/),                        &
-                                      output_type = 'real32' )
+          return_value = dom_def_var( vmea(l)%nc_filename, variable_name = variable_name,          &
+                                      dimension_names = (/'station_soil'/), output_type = 'real32' )
 !
 !--       station_h for soil
           variable_name = 'station_h_soil'
-          return_value = dom_def_var( vmea(l)%nc_filename,                                         &
-                                      variable_name = variable_name,                               &
-                                      dimension_names = (/'station_soil'/),                        &
-                                      output_type = 'real32' )
+          return_value = dom_def_var( vmea(l)%nc_filename, variable_name = variable_name,          &
+                                      dimension_names = (/'station_soil'/), output_type = 'real32' )
 !
 !--       x soil
           variable_name = 'x_soil'
-          return_value = dom_def_var( vmea(l)%nc_filename,                                         &
-                                      variable_name = variable_name,                               &
-                                      dimension_names = (/'station_soil'/),                        &
-                                      output_type = 'real32' )
+          return_value = dom_def_var( vmea(l)%nc_filename, variable_name = variable_name,          &
+                                      dimension_names = (/'station_soil'/), output_type = 'real32' )
 !
 !-        y soil
           variable_name = 'y_soil'
-          return_value = dom_def_var( vmea(l)%nc_filename,                                         &
-                                      variable_name = variable_name,                               &
-                                      dimension_names = (/'station_soil'/),                        &
-                                      output_type = 'real32' )
+          return_value = dom_def_var( vmea(l)%nc_filename, variable_name = variable_name,          &
+                                      dimension_names = (/'station_soil'/), output_type = 'real32' )
 !
 !--       E-UTM soil
           variable_name = 'E_UTM_soil'
-          return_value = dom_def_var( vmea(l)%nc_filename,                                         &
-                                      variable_name = variable_name,                               &
-                                      dimension_names = (/'station_soil'/),                        &
-                                      output_type = 'real32' )
+          return_value = dom_def_var( vmea(l)%nc_filename, variable_name = variable_name,          &
+                                      dimension_names = (/'station_soil'/), output_type = 'real32' )
 !
 !--       N-UTM soil
           variable_name = 'N_UTM_soil'
-          return_value = dom_def_var( vmea(l)%nc_filename,                                         &
-                                      variable_name = variable_name,                               &
-                                      dimension_names = (/'station_soil'/),                        &
-                                      output_type = 'real32' )
+          return_value = dom_def_var( vmea(l)%nc_filename, variable_name = variable_name,          &
+                                      dimension_names = (/'station_soil'/), output_type = 'real32' )
 !
 !--       latitude soil
           variable_name = 'lat_soil'
-          return_value = dom_def_var( vmea(l)%nc_filename,                                         &
-                                      variable_name = variable_name,                               &
-                                      dimension_names = (/'station_soil'/),                        &
-                                      output_type = 'real32' )
+          return_value = dom_def_var( vmea(l)%nc_filename, variable_name = variable_name,          &
+                                      dimension_names = (/'station_soil'/), output_type = 'real32' )
 !
 !--       longitude soil
           variable_name = 'lon_soil'
-          return_value = dom_def_var( vmea(l)%nc_filename,                                         &
-                                      variable_name = variable_name,                               &
-                                      dimension_names = (/'station_soil'/),                        &
-                                      output_type = 'real32' )
+          return_value = dom_def_var( vmea(l)%nc_filename, variable_name = variable_name,          &
+                                      dimension_names = (/'station_soil'/), output_type = 'real32' )
 !
 !--       Set attributes for the coordinate variables. Note, not all coordinates have the same
 !--       number of attributes.
 !--       Units
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'time_soil',                                 &
-                                      attribute_name = char_unit,                                  &
-                                      value = 'seconds since ' // origin_date_time )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'z_soil',                                    &
-                                      attribute_name = char_unit,                                  &
-                                      value = 'm' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'station_h_soil',                            &
-                                      attribute_name = char_unit,                                  &
-                                      value = 'm' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'x_soil',                                    &
-                                      attribute_name = char_unit,                                  &
-                                      value = 'm' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'y_soil',                                    &
-                                      attribute_name = char_unit,                                  &
-                                      value = 'm' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'E_UTM_soil',                                &
-                                      attribute_name = char_unit,                                  &
-                                      value = 'm' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'N_UTM_soil',                                &
-                                      attribute_name = char_unit,                                  &
-                                      value = 'm' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'lat_soil',                                  &
-                                      attribute_name = char_unit,                                  &
-                                      value = 'degrees_north' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'lon_soil',                                  &
-                                      attribute_name = char_unit,                                  &
-                                      value = 'degrees_east' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'time_soil',            &
+                                      attribute_name = char_unit, value = 'seconds since ' //      &
+                                      origin_date_time )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'z_soil',               &
+                                      attribute_name = char_unit, value = 'm' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'station_h_soil',       &
+                                      attribute_name = char_unit, value = 'm' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'x_soil',               &
+                                      attribute_name = char_unit, value = 'm' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'y_soil',               &
+                                      attribute_name = char_unit, value = 'm' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'E_UTM_soil',           &
+                                      attribute_name = char_unit, value = 'm' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'N_UTM_soil',           &
+                                      attribute_name = char_unit, value = 'm' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'lat_soil',             &
+                                      attribute_name = char_unit, value = 'degrees_north' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'lon_soil',             &
+                                      attribute_name = char_unit, value = 'degrees_east' )
 !
 !--       Long name
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'station_name_soil',                         &
-                                      attribute_name = char_long,                                  &
-                                      value = 'station name')
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'time_soil',                                 &
-                                      attribute_name = char_long,                                  &
-                                      value = 'time')
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'z_soil',                                    &
-                                      attribute_name = char_long,                                  &
-                                      value = 'height above origin' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'station_h_soil',                            &
-                                      attribute_name = char_long,                                  &
-                                      value = 'surface altitude' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'x_soil',                                    &
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'station_name_soil',    &
+                                      attribute_name = char_long, value = 'station name')
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'time_soil',            &
+                                      attribute_name = char_long, value = 'time')
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'z_soil',               &
+                                      attribute_name = char_long, value = 'height above origin' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'station_h_soil',       &
+                                      attribute_name = char_long, value = 'surface altitude' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'x_soil',               &
                                       attribute_name = char_long,                                  &
                                       value = 'distance to origin in x-direction' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'y_soil',                                    &
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'y_soil',               &
                                       attribute_name = char_long,                                  &
                                       value = 'distance to origin in y-direction' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'E_UTM_soil',                                &
-                                      attribute_name = char_long,                                  &
-                                      value = 'easting' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'N_UTM_soil',                                &
-                                      attribute_name = char_long,                                  &
-                                      value = 'northing' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'lat_soil',                                  &
-                                      attribute_name = char_long,                                  &
-                                      value = 'latitude' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'lon_soil',                                  &
-                                      attribute_name = char_long,                                  &
-                                      value = 'longitude' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'E_UTM_soil',           &
+                                      attribute_name = char_long, value = 'easting' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'N_UTM_soil',           &
+                                      attribute_name = char_long, value = 'northing' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'lat_soil',             &
+                                      attribute_name = char_long, value = 'latitude' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'lon_soil',             &
+                                      attribute_name = char_long, value = 'longitude' )
 !
 !--       Standard name
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'station_name_soil',                         &
-                                      attribute_name = char_standard,                              &
-                                      value = 'platform_name')
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'time_soil',                                 &
-                                      attribute_name = char_standard,                              &
-                                      value = 'time')
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'z_soil',                                    &
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'station_name_soil',    &
+                                      attribute_name = char_standard, value = 'platform_name')
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'time_soil',            &
+                                      attribute_name = char_standard, value = 'time')
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'z_soil',               &
                                       attribute_name = char_standard,                              &
                                       value = 'height_above_mean_sea_level' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'station_h_soil',                            &
-                                      attribute_name = char_standard,                              &
-                                      value = 'surface_altitude' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'E_UTM_soil',                                &
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'station_h_soil',       &
+                                      attribute_name = char_standard, value = 'surface_altitude' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'E_UTM_soil',           &
                                       attribute_name = char_standard,                              &
                                       value = 'projection_x_coordinate' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'N_UTM_soil',                                &
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'N_UTM_soil',           &
                                       attribute_name = char_standard,                              &
                                       value = 'projection_y_coordinate' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'lat_soil',                                  &
-                                      attribute_name = char_standard,                              &
-                                      value = 'latitude' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'lon_soil',                                  &
-                                      attribute_name = char_standard,                              &
-                                      value = 'longitude' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'lat_soil',             &
+                                      attribute_name = char_standard, value = 'latitude' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'lon_soil',             &
+                                      attribute_name = char_standard, value = 'longitude' )
 !
 !--       Axis
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'time_soil',                                 &
-                                      attribute_name = 'axis',                                     &
-                                      value = 'T')
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'z_soil',                                    &
-                                      attribute_name = 'axis',                                     &
-                                      value = 'Z' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'x_soil',                                    &
-                                      attribute_name = 'axis',                                     &
-                                      value = 'X' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'y_soil',                                    &
-                                      attribute_name = 'axis',                                     &
-                                      value = 'Y' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'time_soil',            &
+                                      attribute_name = 'axis', value = 'T')
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'z_soil',               &
+                                      attribute_name = 'axis', value = 'Z' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'x_soil',               &
+                                      attribute_name = 'axis', value = 'X' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'y_soil',               &
+                                      attribute_name = 'axis', value = 'Y' )
 !
 !--       Set further individual attributes for the coordinate variables.
 !--       For station name soil
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'station_name_soil',                         &
-                                      attribute_name = 'cf_role',                                  &
-                                      value = 'timeseries_id' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'station_name_soil',    &
+                                      attribute_name = 'cf_role', value = 'timeseries_id' )
 !
 !--       For time soil
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'time_soil',                                 &
-                                      attribute_name = 'calendar',                                 &
-                                      value = 'proleptic_gregorian' )
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'time_soil',                                 &
-                                      attribute_name = 'bounds',                                   &
-                                      value = 'time_bounds' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'time_soil',            &
+                                      attribute_name = 'calendar', value = 'proleptic_gregorian' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'time_soil',            &
+                                      attribute_name = 'bounds', value = 'time_bounds' )
 !
 !--       For z soil
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = 'z_soil',                                    &
-                                      attribute_name = 'positive',                                 &
-                                      value = 'up' )
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = 'z_soil',               &
+                                      attribute_name = 'positive', value = 'up' )
        ENDIF
 !
@@ -2066,15 +1861,11 @@
                ANY( TRIM( vmea(l)%var_atts(n)%name) == soil_vars ) )  THEN
 
-             return_value = dom_def_var( vmea(l)%nc_filename,                                      &
-                                         variable_name = variable_name,                            &
-                                         dimension_names = (/'station_soil',                       &
-                                                             'ntime_soil  '/),                     &
+             return_value = dom_def_var( vmea(l)%nc_filename, variable_name = variable_name,       &
+                                         dimension_names = (/'station_soil', 'ntime_soil  '/),     &
                                          output_type = 'real32' )
           ELSE
 
-             return_value = dom_def_var( vmea(l)%nc_filename,                                      &
-                                         variable_name = variable_name,                            &
-                                         dimension_names = (/'station',                            &
-                                                             'ntime  '/),                          &
+             return_value = dom_def_var( vmea(l)%nc_filename, variable_name = variable_name,       &
+                                         dimension_names = (/'station', 'ntime  '/),               &
                                          output_type = 'real32' )
           ENDIF
@@ -2085,34 +1876,28 @@
 
           IF ( vmea(l)%var_atts(n)%long_name /= 'none' )  THEN
-             return_value = dom_def_att( vmea(l)%nc_filename,                                      &
-                                         variable_name = variable_name,                            &
+             return_value = dom_def_att( vmea(l)%nc_filename,  variable_name = variable_name,      &
                                          attribute_name = char_long,                               &
                                          value = TRIM( vmea(l)%var_atts(n)%long_name ) )
           ENDIF
           IF ( vmea(l)%var_atts(n)%standard_name /= 'none' )  THEN
-             return_value = dom_def_att( vmea(l)%nc_filename,                                      &
-                                         variable_name = variable_name,                            &
+             return_value = dom_def_att( vmea(l)%nc_filename, variable_name = variable_name,       &
                                          attribute_name = char_standard,                           &
                                          value = TRIM( vmea(l)%var_atts(n)%standard_name ) )
           ENDIF
           IF ( vmea(l)%var_atts(n)%units /= 'none' )  THEN
-             return_value = dom_def_att( vmea(l)%nc_filename,                                      &
-                                         variable_name = variable_name,                            &
+             return_value = dom_def_att( vmea(l)%nc_filename, variable_name = variable_name,       &
                                          attribute_name = char_unit,                               &
                                          value = TRIM( vmea(l)%var_atts(n)%units ) )
           ENDIF
 
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = variable_name,                               &
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = variable_name,          &
                                       attribute_name = 'grid_mapping',                             &
                                       value = TRIM( vmea(l)%var_atts(n)%grid_mapping ) )
 
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = variable_name,                               &
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = variable_name,          &
                                       attribute_name = 'coordinates',                              &
                                       value = TRIM( vmea(l)%var_atts(n)%coordinates ) )
 
-          return_value = dom_def_att( vmea(l)%nc_filename,                                         &
-                                      variable_name = variable_name,                               &
+          return_value = dom_def_att( vmea(l)%nc_filename, variable_name = variable_name,          &
                                       attribute_name = char_fill,                                  &
                                       value = REAL( vmea(l)%var_atts(n)%fill_value, KIND=4 ) )
@@ -2172,10 +1957,8 @@
           output_values_1d_pointer => output_values_1d_target
 
-          return_value =                                                                           &
-                  dom_write_var( vmea(l)%nc_filename,                                              &
-                                 'E_UTM',                                                          &
-                                 values_realwp_1d = output_values_1d_pointer,                      &
-                                 bounds_start = (/vmea(l)%start_coord_a/),                         &
-                                 bounds_end   = (/vmea(l)%end_coord_a  /) )
+          return_value = dom_write_var( vmea(l)%nc_filename, 'E_UTM',                              &
+                                        values_realwp_1d = output_values_1d_pointer,               &
+                                        bounds_start = (/vmea(l)%start_coord_a/),                  &
+                                        bounds_end   = (/vmea(l)%end_coord_a  /) )
 !
 !--       Output of Northing coordinate. Before output, recalculate NUTM.
@@ -2187,10 +1970,8 @@
 
           output_values_1d_pointer => output_values_1d_target
-          return_value =                                                                           &
-                  dom_write_var( vmea(l)%nc_filename,                                              &
-                                 'N_UTM',                                                          &
-                                 values_realwp_1d = output_values_1d_pointer,                      &
-                                 bounds_start = (/vmea(l)%start_coord_a/),                         &
-                                 bounds_end   = (/vmea(l)%end_coord_a  /) )
+          return_value = dom_write_var( vmea(l)%nc_filename, 'N_UTM',                              &
+                                        values_realwp_1d = output_values_1d_pointer,               &
+                                        bounds_start = (/vmea(l)%start_coord_a/),                  &
+                                        bounds_end   = (/vmea(l)%end_coord_a  /) )
 !
 !--       Output of relative height coordinate.
@@ -2203,10 +1984,8 @@
           output_values_1d_target = vmea(l)%zar(1:vmea(l)%ns) + oro_rel(:)
           output_values_1d_pointer => output_values_1d_target
-          return_value =                                                                           &
-                  dom_write_var( vmea(l)%nc_filename,                                              &
-                                 'z',                                                              &
-                                 values_realwp_1d = output_values_1d_pointer,                      &
-                                 bounds_start = (/vmea(l)%start_coord_a/),                         &
-                                 bounds_end   = (/vmea(l)%end_coord_a  /) )
+          return_value = dom_write_var( vmea(l)%nc_filename, 'z',                                  &
+                                        values_realwp_1d = output_values_1d_pointer,               &
+                                        bounds_start = (/vmea(l)%start_coord_a/),                  &
+                                        bounds_end   = (/vmea(l)%end_coord_a  /) )
 !
 !--       Write surface altitude for the station. Note, since z is already a relative observation
@@ -2214,10 +1993,8 @@
           output_values_1d_target = oro_rel(:)
           output_values_1d_pointer => output_values_1d_target
-          return_value =                                                                           &
-                  dom_write_var( vmea(l)%nc_filename,                                              &
-                                 'station_h',                                                      &
-                                 values_realwp_1d = output_values_1d_pointer,                      &
-                                 bounds_start = (/vmea(l)%start_coord_a/),                         &
-                                 bounds_end   = (/vmea(l)%end_coord_a  /) )
+          return_value = dom_write_var( vmea(l)%nc_filename, 'station_h',                          &
+                                        values_realwp_1d = output_values_1d_pointer,               &
+                                        bounds_start = (/vmea(l)%start_coord_a/),                  &
+                                        bounds_end   = (/vmea(l)%end_coord_a  /) )
 
           DEALLOCATE( oro_rel )
@@ -2239,10 +2016,9 @@
           output_values_2d_char_pointer => output_values_2d_char_target
 
-          return_value =                                                                           &
-                  dom_write_var( vmea(l)%nc_filename,                                              &
-                                 'station_name',                                                   &
-                                 values_char_2d = output_values_2d_char_pointer,                   &
-                                 bounds_start = (/ 1,                   vmea(l)%start_coord_a /),  &
-                                 bounds_end   = (/ maximum_name_length, vmea(l)%end_coord_a /) )
+          return_value = dom_write_var( vmea(l)%nc_filename, 'station_name',                       &
+                                        values_char_2d = output_values_2d_char_pointer,            &
+                                        bounds_start = (/ 1, vmea(l)%start_coord_a /),             &
+                                        bounds_end   = (/ maximum_name_length,                     &
+                                        vmea(l)%end_coord_a /) )
 
           DEALLOCATE( station_name )
@@ -2260,10 +2036,8 @@
                * SIN( init_model%rotation_angle * pi / 180.0_wp )
              output_values_1d_pointer => output_values_1d_target
-             return_value =                                                                        &
-                  dom_write_var( vmea(l)%nc_filename,                                              &
-                                 'E_UTM_soil',                                                     &
-                                 values_realwp_1d = output_values_1d_pointer,                      &
-                                 bounds_start = (/vmea(l)%start_coord_s/),                         &
-                                 bounds_end   = (/vmea(l)%end_coord_s  /) )
+             return_value = dom_write_var( vmea(l)%nc_filename, 'E_UTM_soil',                      &
+                                           values_realwp_1d = output_values_1d_pointer,            &
+                                           bounds_start = (/vmea(l)%start_coord_s/),               &
+                                           bounds_end   = (/vmea(l)%end_coord_s  /) )
 !
 !--          Output of Northing coordinate. Before output, recalculate NUTM.
@@ -2275,10 +2049,8 @@
 
              output_values_1d_pointer => output_values_1d_target
-             return_value =                                                                        &
-                  dom_write_var( vmea(l)%nc_filename,                                              &
-                                 'N_UTM_soil',                                                     &
-                                 values_realwp_1d = output_values_1d_pointer,                      &
-                                 bounds_start = (/vmea(l)%start_coord_s/),                         &
-                                 bounds_end   = (/vmea(l)%end_coord_s  /) )
+             return_value = dom_write_var( vmea(l)%nc_filename, 'N_UTM_soil',                      &
+                                           values_realwp_1d = output_values_1d_pointer,            &
+                                           bounds_start = (/vmea(l)%start_coord_s/),               &
+                                           bounds_end   = (/vmea(l)%end_coord_s  /) )
 !
 !--          Output of relative height coordinate.
@@ -2291,10 +2063,8 @@
              output_values_1d_target = vmea(l)%depth(1:vmea(l)%ns_soil) + oro_rel(:)
              output_values_1d_pointer => output_values_1d_target
-             return_value =                                                                        &
-                  dom_write_var( vmea(l)%nc_filename,                                              &
-                                 'z_soil',                                                         &
-                                 values_realwp_1d = output_values_1d_pointer,                      &
-                                 bounds_start = (/vmea(l)%start_coord_s/),                         &
-                                 bounds_end   = (/vmea(l)%end_coord_s  /) )
+             return_value = dom_write_var( vmea(l)%nc_filename, 'z_soil',                          &
+                                           values_realwp_1d = output_values_1d_pointer,            &
+                                           bounds_start = (/vmea(l)%start_coord_s/),               &
+                                           bounds_end   = (/vmea(l)%end_coord_s  /) )
 !
 !--          Write surface altitude for the station. Note, since z is already a relative observation
@@ -2302,10 +2072,8 @@
              output_values_1d_target = oro_rel(:)
              output_values_1d_pointer => output_values_1d_target
-             return_value =                                                                        &
-                  dom_write_var( vmea(l)%nc_filename,                                              &
-                                 'station_h_soil',                                                 &
-                                 values_realwp_1d = output_values_1d_pointer,                      &
-                                 bounds_start = (/vmea(l)%start_coord_s/),                         &
-                                 bounds_end   = (/vmea(l)%end_coord_s  /) )
+             return_value = dom_write_var( vmea(l)%nc_filename, 'station_h_soil',                  &
+                                           values_realwp_1d = output_values_1d_pointer,            &
+                                           bounds_start = (/vmea(l)%start_coord_s/),               &
+                                           bounds_end   = (/vmea(l)%end_coord_s  /) )
 
              DEALLOCATE( oro_rel )
@@ -2326,10 +2094,9 @@
              output_values_2d_char_pointer => output_values_2d_char_target
 
-             return_value =                                                                        &
-                  dom_write_var( vmea(l)%nc_filename,                                              &
-                                 'station_name_soil',                                              &
-                                 values_char_2d = output_values_2d_char_pointer,                   &
-                                 bounds_start = (/ 1,                   vmea(l)%start_coord_s /),  &
-                                 bounds_end   = (/ maximum_name_length, vmea(l)%end_coord_s   /) )
+             return_value = dom_write_var( vmea(l)%nc_filename, 'station_name_soil',               &
+                                           values_char_2d = output_values_2d_char_pointer,         &
+                                           bounds_start = (/ 1, vmea(l)%start_coord_s /),          &
+                                           bounds_end   = (/ maximum_name_length,                  &
+                                           vmea(l)%end_coord_s   /) )
 
              DEALLOCATE( station_name )
@@ -2363,7 +2130,6 @@
              output_values_2d_pointer => output_values_2d_target
 
-             return_value = dom_write_var( vmea(l)%nc_filename,                                    &
-                                           variable_name,                                          &
-                                           values_realwp_2d = output_values_2d_pointer, &
+             return_value = dom_write_var( vmea(l)%nc_filename, variable_name,                     &
+                                           values_realwp_2d = output_values_2d_pointer,            &
                                            bounds_start = (/vmea(l)%start_coord_s, t_ind/),        &
                                            bounds_end   = (/vmea(l)%end_coord_s, t_ind /) )
@@ -2372,10 +2138,8 @@
              output_values_2d_target(t_ind,:) = vmea(l)%measured_vars_soil(:,n)
              output_values_2d_pointer => output_values_2d_target
-             return_value =                                                                        &
-                      dom_write_var( vmea(l)%nc_filename,                                          &
-                                     variable_name,                                                &
-                                     values_realwp_2d = output_values_2d_pointer,                  &
-                                     bounds_start = (/vmea(l)%start_coord_s, t_ind/),              &
-                                     bounds_end   = (/vmea(l)%end_coord_s, t_ind  /) )
+             return_value = dom_write_var( vmea(l)%nc_filename, variable_name,                     &
+                                           values_realwp_2d = output_values_2d_pointer,            &
+                                           bounds_start = (/vmea(l)%start_coord_s, t_ind/),        &
+                                           bounds_end   = (/vmea(l)%end_coord_s, t_ind  /) )
              DEALLOCATE( output_values_2d_target )
           ELSE
@@ -2387,6 +2151,5 @@
              output_values_2d_pointer => output_values_2d_target
 
-             return_value = dom_write_var( vmea(l)%nc_filename,                                    &
-                                           variable_name,                                          &
+             return_value = dom_write_var( vmea(l)%nc_filename, variable_name,                     &
                                            values_realwp_2d = output_values_2d_pointer,            &
                                            bounds_start = (/vmea(l)%start_coord_a, t_ind/),        &
@@ -2397,10 +2160,8 @@
              output_values_2d_target(t_ind,:) = vmea(l)%measured_vars(:,n)
              output_values_2d_pointer => output_values_2d_target
-             return_value =                                                                        &
-                      dom_write_var( vmea(l)%nc_filename,                                          &
-                                     variable_name,                                                &
-                                     values_realwp_2d = output_values_2d_pointer,                  &
-                                     bounds_start = (/ vmea(l)%start_coord_a, t_ind /),            &
-                                     bounds_end   = (/ vmea(l)%end_coord_a, t_ind /) )
+             return_value = dom_write_var( vmea(l)%nc_filename, variable_name,                     &
+                                           values_realwp_2d = output_values_2d_pointer,            &
+                                           bounds_start = (/ vmea(l)%start_coord_a, t_ind /),      &
+                                           bounds_end   = (/ vmea(l)%end_coord_a, t_ind /) )
 
              DEALLOCATE( output_values_2d_target )
@@ -2563,7 +2324,6 @@
                     j = vmea(l)%j(m)
                     i = vmea(l)%i(m)
-                    vmea(l)%measured_vars(m,n) = SQRT(                                             &
-                                                 ( 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) )**2 +       &
-                                                 ( 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) )**2         &
+                    vmea(l)%measured_vars(m,n) = SQRT(   ( 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) )**2 &
+                                                       + ( 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) )**2 &
                                                      )
                  ENDDO
@@ -2576,7 +2336,7 @@
 
                     vmea(l)%measured_vars(m,n) = 180.0_wp + 180.0_wp / pi * ATAN2(                 &
-                                                 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ),               &
-                                                 0.5_wp * ( u(k,j,i) + u(k,j,i+1) )                &
-                                                                                  )
+                                                               0.5_wp * ( v(k,j,i) + v(k,j+1,i) ), &
+                                                               0.5_wp * ( u(k,j,i) + u(k,j,i+1) )  &
+                                                                                 )
                  ENDDO
 
