Index: palm/trunk/SCRIPTS/palm_cvd
===================================================================
--- palm/trunk/SCRIPTS/palm_cvd	(revision 4762)
+++ palm/trunk/SCRIPTS/palm_cvd	(revision 4763)
@@ -26,4 +26,10 @@
 # -----------------
 # $Id$
+# - Check automatically for data organization (stored in subdirectories or not)
+# - Convert trajectory and timeseriesProfile coordinates into 1-D coordinates
+#   equivalent to timeseries coordiates. This simplifies processing in PALM and
+#   makes the virtual-measurement module also applicable to other campaigns.
+#
+# 4758 2020-10-26 13:03:52Z suehring
 # In order to do not omit observations that are on the same site but have different
 # coordinates or feature-types, process all files rather than only one and omit 
@@ -54,4 +60,5 @@
 import os
 import numpy as np
+import time
 
 
@@ -187,4 +194,5 @@
 name_featuretype   = "featureType"
 name_ts            = "timeSeries"
+name_tspr          = "timeSeriesProfile"
 name_traj          = "trajectory"
 name_ntime         = "ntime"
@@ -196,5 +204,5 @@
 name_eutm          = "E_UTM"
 name_nutm          = "N_UTM"
-name_hao           = "height_above_origin"
+name_hao           = "height"
 name_station_h     = "station_h"
 name_z             = "z"
@@ -271,154 +279,370 @@
 if ( input_from_observations ):
 
-   # Run loop over all subdirectories, detect the files and extract a list of sites.
+   # Run loop over all listed input data. Depending on the data set, this could be
+   # a list of files or a list of subdirectories.
    # This is done to reduce the number of virtual measurements in the model. Each
    # virtual measurement has an overhead and consumes memory.
    sites = []
    input_files = []
+   input_files_orig = []
    for dirname in list_input_data:
        data_file = data_path + dirname
 
-       # Directory may contain various file versions.
-       # Take the one with highest cycle number.
-       highest_cycle_nr = 0
-       for filename in os.listdir(data_file):
-          start_seq = len( filename ) - 6
-          end_seq   = len( filename ) - 3
-          if int( filename[start_seq:end_seq] ) > highest_cycle_nr:
-             highest_cycle_nr = int(filename[start_seq:end_seq])
-             latest_file      = filename
+       if ( os.path.isdir(data_file) == True ):
+          # Directory may contain various file versions.
+          # Take the one with highest cycle number.
+          highest_cycle_nr = 0
+          for filename in os.listdir(data_file):
+             start_seq = len( filename ) - 6
+             end_seq   = len( filename ) - 3
+             if int( filename[start_seq:end_seq] ) > highest_cycle_nr:
+                highest_cycle_nr = int(filename[start_seq:end_seq])
+                latest_file      = filename
+          input_file = data_file + "/" + latest_file
+          input_file_orig = latest_file
+       else:
+          input_file = data_file
+          input_file_orig = dirname
 
        # Open the NetCDF file
-       input_file = data_file + "/" + latest_file
        ncfile_in = Dataset( input_file, "r", format="NETCDF4", encoding='ascii')
        input_files.append(input_file)
-
-   # Define a nested list of default variables that shall be measured. Based on this list,
-   # the final number of measured variables is determined.
-   measured_variables_all_sites = [ ['u', 'v', 'w', 'theta', 'hus'] for var in range(0, len(input_files))]
-
-   # Run loop over all subdirectories that contain observational data
-   for counter, file in enumerate(input_files):
-
-      # Open the NetCDF input file
-      input_file = input_files[counter]
+       input_files_orig.append(input_file_orig)
+
+#  Gather all files according to their feature type and all sites for the respective feature type
+   files_traj  = []
+   files_ts    = []
+   files_tspr  = []
+   sites_traj  = []
+   sites_ts    = []
+   sites_tspr  = []
+   for input_file in input_files:
       ncfile_in = Dataset( input_file, "r", format="NETCDF4", encoding='ascii' )
 
-      # Determine index for the treated site
-      num_vmeas = input_files.index( input_file ) + 1
-      print( counter, num_vmeas )
-
-      # Read global attributes and write them immediately into the output file
       for att in ncfile_in.ncattrs():
          if ( att == name_featuretype ):
             feature = ncfile_in.getncattr(att)
-         if ( att == name_datacontent ):
-            content = ncfile_in.getncattr(att)
          if ( att == name_site ):
             site = ncfile_in.getncattr(att)
 
-         if ( att in atts_float ):
-            ncfile_out.setncattr( att + str(num_vmeas), np.double(ncfile_in.getncattr(att)) )
-         else:
-            ncfile_out.setncattr( att + str(num_vmeas), ncfile_in.getncattr(att) )
-
-      #timeSeries
-      if ( feature == name_ts ):
-         ntime = len( ncfile_in.dimensions[name_ntime]   )
-         nstat = len( ncfile_in.dimensions[name_station] )
-         ncfile_out.createDimension( name_ntime   + str(num_vmeas), ntime )
-         ncfile_out.createDimension( name_station + str(num_vmeas), nstat )
-
-      #trajectory
-      elif ( feature == name_traj ):
-         ntime = len( ncfile_in.dimensions[name_ntime]   )
-         ntraj = len( ncfile_in.dimensions[name_traj_dim] )
-         ncfile_out.createDimension( name_ntime    + str(num_vmeas), ntime )
-         ncfile_out.createDimension( name_traj_dim + str(num_vmeas), ntraj )
-
-      #timeseriesProfile
+      if ( feature == name_traj ):
+         files_traj.append(input_file)
+      elif ( feature == name_ts ):
+         files_ts.append(input_file)
       else:
-         ntime = len( ncfile_in.dimensions[name_ntime]   )
-         nstat = len( ncfile_in.dimensions[name_station] )
-         nz    = len( ncfile_in.dimensions[name_nz]      )
-         ncfile_out.createDimension( name_ntime   + str(num_vmeas), ntime )
-         ncfile_out.createDimension( name_station + str(num_vmeas), nstat )
-         ncfile_out.createDimension( name_nz      + str(num_vmeas), nz    )
-
-      for var in ncfile_in.variables.keys():
-         if ( var in dims_out ):
-            # Create a variable and write it to file after it is read. In order to
-            # avoid fill values in the dimensions, these are converted to zero
-            # before written to file. Depending on the featureType of the measurement,
-            # the array shape is different. For more informations, please see
-            # [UC]2 data standard.
-            # Timeseries
-            if ( feature == name_ts  ):
-               temp_ts = ncfile_out.createVariable( var + str(num_vmeas), float, \
-                                                    name_station + str(num_vmeas))
-               temp_ts[:] = np.nan_to_num( ncfile_in.variables[var][:] )
-
-            # Trajectories
-            elif ( feature == name_traj ):
-               # @note: If there are files where station_h is present although featureType is
-               #        trajectory, station_h must not be read.
-               if var != name_station_h:
-                  temp_traj = ncfile_out.createVariable( var + str(num_vmeas), float, \
-                                                         ( name_traj_dim + str(num_vmeas), \
-                                                           name_ntime + str(num_vmeas) ) )
-                  temp_traj[:,:] = np.nan_to_num( ncfile_in.variables[var][:,:] )
-
-            # TimeseriesProfiles
-            else:
-               if ( var == 'z' ):
-                  temp_pr = ncfile_out.createVariable( var + str(num_vmeas), float, \
-                                                      ( name_station + str(num_vmeas), \
-                                                        name_nz + str(num_vmeas) ) )
-                  temp_pr[:] = np.nan_to_num( ncfile_in.variables[var][:,0,:] )
-               else:
-                  temp_pr = ncfile_out.createVariable( var + str(num_vmeas), float, \
-                                                       name_station + str(num_vmeas))
-                  temp_pr[:] = np.nan_to_num( ncfile_in.variables[var][:] )
-
-      # Search for variables to be measured. In case the variable isn't already defined,
-      # append the variable to the list.
-      for var in ncfile_in.variables.keys():
-         if ( var not in non_measurable_vars  and  \
-              var not in vars_default         and  \
-              var not in measured_variables_all_sites[input_files.index( input_file )] ):
-
-            measured_variables_all_sites[input_files.index( input_file )].append(var)
-
-      # Close the NetCDF input file
+         files_tspr.append(input_file)
+
+      if ( feature == name_traj  and  site not in sites_traj ):
+         sites_traj.append(site)
+      if ( feature == name_ts  and  site not in sites_ts ):
+         sites_ts.append(site)
+      if ( feature == name_tspr  and  site not in sites_tspr ):
+         sites_tspr.append(site)
+
       ncfile_in.close()
 
-   # After variables are gathered and dimensions / attributes are already written to file,
-   # the list of measured variables is written to file.
-   for site in input_files:
-
-      num_vmeas = input_files.index( site ) + 1
-
-      ncfile_out.createDimension( "nvar"+ str(num_vmeas), \
-                                  len( measured_variables_all_sites[input_files.index( site )] ) )
-
-      measured = ncfile_out.createVariable( 'measured_variables' + str(num_vmeas), 'S1', \
-                                            ("nvar" + str(num_vmeas), "string_len")) # must be NC_CHAR
-
-      for counter, meas in enumerate( measured_variables_all_sites[input_files.index( site )] ):
-         measured[counter] = stringtochar( np.array( meas,"S%s"%(max_string_len) ) )
-
-      # Check if any of the measured variables is a soil variable. Set flag accordingly.
+   for input_file in files_traj:
+      print( "traj", input_file )
+   for site in sites_traj:
+      print( "traj", site )
+
+   for site in sites_ts:
+      print( "ts", site )
+   for site in sites_tspr:
+      print( "tspr", site )
+      
+   for file in files_tspr:
+      print( "tspr", file )
+   counter_id = 1
+   for site_traj in sites_traj:
+      # For the given site already define the featureTpye and site
+      ncfile_out.setncattr( name_featuretype + str(counter_id), name_traj )
+      ncfile_out.setncattr( name_site + str(counter_id), site_traj )
+
+      # Define the number of coordinates for the site
+      num_coords = 0
+
+      e_utm_traj = np.array([])
+      n_utm_traj = np.array([])
+      h_traj     = np.array([])
+      measured_variables = ['u', 'v', 'w', 'theta', 'hus']
+      for input_file in files_traj:
+         ncfile_in = Dataset( input_file, "r", format="NETCDF4", encoding='ascii' )
+         for att in ncfile_in.ncattrs():
+            if ( att == name_site ):
+               site = ncfile_in.getncattr(att)
+
+         if ( site == site_traj ):
+
+            for att in ncfile_in.ncattrs():
+               if ( att == name_orig_x ):
+                  orig_x = ncfile_in.getncattr(att)
+               if ( att == name_orig_y ):
+                  orig_y = ncfile_in.getncattr(att)
+               if ( att == name_orig_z ):
+                  orig_z = ncfile_in.getncattr(att)
+
+            ntime = len( ncfile_in.dimensions[name_ntime]    )
+            ntraj = len( ncfile_in.dimensions[name_traj_dim] )
+
+            num_coords += ntime * ntraj
+#           Gather UTM and height coordinates and merge them into one array. Further, gather
+#           the variables that shall be sampled. Coordinates are checked to for NaN values and
+#           are tranformed to arithmetric numbers. Further, 2D input array is transformed into
+#           a 1D array.
+            for var in ncfile_in.variables.keys():
+               if ( var in dims_out  and  var == name_eutm ):
+                  e_utm_traj = np.append(e_utm_traj, np.nan_to_num( ncfile_in.variables[var][:,:] ).flatten())
+                  #e_utm_traj.append( np.nan_to_num( ncfile_in.variables[var][:,:] ).flatten() )
+               if ( var in dims_out  and  var == name_nutm ):
+                  n_utm_traj = np.append(n_utm_traj, np.nan_to_num( ncfile_in.variables[var][:,:] ).flatten())
+               if ( var in dims_out  and  var == name_hao ):
+                  h_traj = np.append(h_traj, np.nan_to_num( ncfile_in.variables[var][:,:] ).flatten())
+
+               if ( var not in non_measurable_vars  and  \
+                    var not in vars_default         and  \
+                    var not in measured_variables ):
+                  measured_variables.append(var)
+
+         ncfile_in.close()
+
+#     After all files for the current site are processed, write the origin-coordinates for x,y,z
+      ncfile_out.setncattr( name_orig_x + str(counter_id), orig_x )
+      ncfile_out.setncattr( name_orig_y + str(counter_id), orig_y )
+      ncfile_out.setncattr( name_orig_z + str(counter_id), orig_z )
+#     Create the dimensions
+      ncfile_out.createDimension( name_station + str(counter_id), num_coords )
+
+      temp_traj = ncfile_out.createVariable( name_eutm + str(counter_id), float, name_station + str(counter_id) )
+      temp_traj[:] = e_utm_traj
+
+      temp_traj = ncfile_out.createVariable( name_nutm + str(counter_id), float, name_station + str(counter_id) )
+      temp_traj[:] = n_utm_traj
+
+      temp_traj = ncfile_out.createVariable( name_hao  + str(counter_id), float, name_station + str(counter_id) )
+      temp_traj[:] = h_traj
+
+#     Check if any of the measured variables is a soil variable. Set flag accordingly.
       soil = False
-      for var in measured_variables_all_sites[input_files.index( site )]:
+      for var in measured_variables:
          if ( var in soil_vars ):
             soil = True
-
-      # Write soil flag
-      ncfile_out.setncattr( name_soil_sampling + str( num_vmeas), np.int8(soil) )
-
-
-
-    # Store the number of observational sites
-   num_sites += len( input_files )
+#     Write soil flag
+      ncfile_out.setncattr( name_soil_sampling + str( counter_id), np.int8(soil) )
+
+#     Create dimension for sample-variable string
+      ncfile_out.createDimension( "nvar"+ str(counter_id), len( measured_variables ) )
+
+      measured_var = ncfile_out.createVariable( 'measured_variables' + str(counter_id), 'S1', \
+                                                ("nvar" + str(counter_id), "string_len") ) # must be NC_CHAR
+
+      # Write the variables to the file
+      for counter, meas in enumerate( measured_variables ):
+         measured_var[counter] = stringtochar( np.array( meas,"S%s"%(max_string_len) ) )
+
+#     Increment the counter
+      counter_id += 1
+   
+   
+   for site_tspr in sites_tspr:
+      # For the given site already define the featureTpye and site
+      ncfile_out.setncattr( name_featuretype + str(counter_id), name_tspr )
+      ncfile_out.setncattr( name_site + str(counter_id), site_tspr )
+
+      # Define the number of coordinates for the site
+      num_coords = 0
+      e_utm_tspr     = np.array([])
+      n_utm_tspr     = np.array([])
+      station_h_tspr = np.array([])
+      z_tspr         = np.array([])
+
+      measured_variables = ['u', 'v', 'w', 'theta', 'hus']
+      for input_file in files_tspr:
+         ncfile_in = Dataset( input_file, "r", format="NETCDF4", encoding='ascii' )
+         for att in ncfile_in.ncattrs():
+            if ( att == name_site ):
+               site = ncfile_in.getncattr(att)
+
+         if ( site == site_tspr ):
+            for att in ncfile_in.ncattrs():
+               if ( att == name_orig_x ):
+                  orig_x = ncfile_in.getncattr(att)
+               if ( att == name_orig_y ):
+                  orig_y = ncfile_in.getncattr(att)
+               if ( att == name_orig_z ):
+                  orig_z = ncfile_in.getncattr(att)
+
+            nstation = len( ncfile_in.dimensions[name_station] )
+            ntime    = len( ncfile_in.dimensions[name_ntime]   )
+            nz       = len( ncfile_in.dimensions[name_nz]   )
+
+            num_coords += nstation * ntime * nz
+#           Gather UTM and height coordinates and merge them into one array. Further, gather
+#           the variables that shall be sampled. Coordinates are checked to for NaN values and
+#           are tranformed to arithmetric numbers. Further, 2D input array is transformed into
+#           a 1D array.
+            for var in ncfile_in.variables.keys():
+               tspr_tmp1 = np.zeros((nstation))
+               tspr_tmp2 = np.zeros((ntime*nz))
+               if ( var in dims_out  and  var == name_eutm ):
+                  tspr_tmp1 = np.nan_to_num( ncfile_in.variables[var][:] )
+                  for ns in range(0,int(nstation)):
+                     tspr_tmp2[:] = tspr_tmp1[ns]
+                     e_utm_tspr = np.append(e_utm_tspr, tspr_tmp2)
+               if ( var in dims_out  and  var == name_nutm ):
+                  tspr_tmp1 = np.nan_to_num( ncfile_in.variables[var][:] )
+                  for ns in range(0,int(nstation)):
+                     tspr_tmp2[:] = tspr_tmp1[ns]
+                     n_utm_tspr = np.append(n_utm_tspr, tspr_tmp2)
+               if ( var in dims_out  and  var == name_z ):
+                  z_tspr_tmp = np.nan_to_num( ncfile_in.variables[var][:,:,:] )
+                  z_tspr = np.append(z_tspr, np.concatenate( z_tspr_tmp ))
+               if ( var in dims_out  and  var == name_station_h ):
+                  tspr_tmp1 = np.nan_to_num( ncfile_in.variables[var][:] )
+                  for ns in range(0,int(nstation)):
+                     tspr_tmp2[:] = tspr_tmp1[ns]
+                     station_h_tspr = np.append(station_h_tspr, tspr_tmp2)
+
+               if ( var not in non_measurable_vars  and  \
+                    var not in vars_default         and  \
+                    var not in measured_variables ):
+                  measured_variables.append(var)
+
+         ncfile_in.close()
+
+#     After all files for the current site are processed, write the origin-coordinates for x,y,z
+      ncfile_out.setncattr( name_orig_x + str(counter_id), orig_x )
+      ncfile_out.setncattr( name_orig_y + str(counter_id), orig_y )
+      ncfile_out.setncattr( name_orig_z + str(counter_id), orig_z )
+#     Create the dimensions
+      ncfile_out.createDimension( name_station + str(counter_id), num_coords )
+
+      temp_tspr = ncfile_out.createVariable( name_eutm      + str(counter_id), float, name_station + str(counter_id) )
+      temp_tspr[:] = e_utm_tspr
+
+      temp_tspr = ncfile_out.createVariable( name_nutm      + str(counter_id), float, name_station + str(counter_id) )
+      temp_tspr[:] = n_utm_tspr
+
+      temp_tspr = ncfile_out.createVariable( name_z         + str(counter_id), float, name_station + str(counter_id) )
+      temp_tspr[:] = z_tspr
+
+      temp_tspr = ncfile_out.createVariable( name_station_h + str(counter_id), float, name_station + str(counter_id) )
+      temp_tspr[:] = station_h_tspr
+
+#     Check if any of the measured variables is a soil variable. Set flag accordingly.
+      soil = False
+      for var in measured_variables:
+         if ( var in soil_vars ):
+            soil = True
+#     Write soil flag
+      ncfile_out.setncattr( name_soil_sampling + str( counter_id), np.int8(soil) )
+
+#     Create dimension for sample-variable string
+      ncfile_out.createDimension( "nvar"+ str(counter_id), len( measured_variables ) )
+
+      measured_var = ncfile_out.createVariable( 'measured_variables' + str(counter_id), 'S1', \
+                                                ("nvar" + str(counter_id), "string_len") ) # must be NC_CHAR
+
+      # Write the variables to the file
+      for counter, meas in enumerate( measured_variables ):
+         measured_var[counter] = stringtochar( np.array( meas,"S%s"%(max_string_len) ) )
+
+#     Increment the counter
+      counter_id += 1
+   
+   
+   for site_ts in sites_ts:
+      # For the given site already define the featureTpye and site
+      ncfile_out.setncattr( name_featuretype + str(counter_id), name_ts )
+      ncfile_out.setncattr( name_site + str(counter_id), site_ts )
+
+      # Define the number of coordinates for the site
+      num_coords = 0
+      e_utm_ts     = np.array([])
+      n_utm_ts     = np.array([])
+      station_h_ts = np.array([])
+      z_ts         = np.array([])
+      
+      measured_variables = ['u', 'v', 'w', 'theta', 'hus']
+      for input_file in files_ts:
+         ncfile_in = Dataset( input_file, "r", format="NETCDF4", encoding='ascii' )
+         for att in ncfile_in.ncattrs():
+            if ( att == name_site ):
+               site = ncfile_in.getncattr(att)
+
+         if ( site == site_ts ):
+
+            for att in ncfile_in.ncattrs():
+               if ( att == name_orig_x ):
+                  orig_x = ncfile_in.getncattr(att)
+               if ( att == name_orig_y ):
+                  orig_y = ncfile_in.getncattr(att)
+               if ( att == name_orig_z ):
+                  orig_z = ncfile_in.getncattr(att)
+
+            nstation = len( ncfile_in.dimensions[name_station]    )
+            num_coords += nstation
+#           Gather UTM and height coordinates and merge them into one array. Further, gather
+#           the variables that shall be sampled. Coordinates are checked to for NaN values and
+#           are tranformed to arithmetric numbers.
+            for var in ncfile_in.variables.keys():
+               if ( var in dims_out  and  var == name_eutm ):
+                  e_utm_ts = np.append(e_utm_ts, np.nan_to_num( ncfile_in.variables[var][:] ))
+               if ( var in dims_out  and  var == name_nutm ):
+                  n_utm_ts = np.append(n_utm_ts, np.nan_to_num( ncfile_in.variables[var][:] ))
+               if ( var in dims_out  and  var == name_z ):
+                  z_ts = np.append(z_ts, np.nan_to_num( ncfile_in.variables[var][:] ))
+               if ( var in dims_out  and  var == name_station_h ):
+                  station_h_ts = np.append(station_h_ts, np.nan_to_num( ncfile_in.variables[var][:] ))
+
+               if ( var not in non_measurable_vars  and  \
+                    var not in vars_default         and  \
+                    var not in measured_variables ):
+                  measured_variables.append(var)
+
+         ncfile_in.close()
+
+#     After all files for the current site are processed, write the origin-coordinates for x,y,z
+      ncfile_out.setncattr( name_orig_x + str(counter_id), orig_x )
+      ncfile_out.setncattr( name_orig_y + str(counter_id), orig_y )
+      ncfile_out.setncattr( name_orig_z + str(counter_id), orig_z )
+#     Create the dimensions
+      ncfile_out.createDimension( name_station + str(counter_id), num_coords )
+
+      temp_ts = ncfile_out.createVariable( name_eutm      + str(counter_id), float, name_station + str(counter_id) )
+      temp_ts[:] = e_utm_ts
+
+      temp_ts = ncfile_out.createVariable( name_nutm      + str(counter_id), float, name_station + str(counter_id) )
+      temp_ts[:] = n_utm_ts
+
+      temp_ts = ncfile_out.createVariable( name_z         + str(counter_id), float, name_station + str(counter_id) )
+      temp_ts[:] = z_ts
+
+      temp_ts = ncfile_out.createVariable( name_station_h + str(counter_id), float, name_station + str(counter_id) )
+      temp_ts[:] = station_h_ts
+
+#     Check if any of the measured variables is a soil variable. Set flag accordingly.
+      soil = False
+      for var in measured_variables:
+         if ( var in soil_vars ):
+            soil = True
+#     Write soil flag
+      ncfile_out.setncattr( name_soil_sampling + str( counter_id), np.int8(soil) )
+
+#     Create dimension for sample-variable string
+      ncfile_out.createDimension( "nvar"+ str(counter_id), len( measured_variables ) )
+
+      measured_var = ncfile_out.createVariable( 'measured_variables' + str(counter_id), 'S1', \
+                                                ("nvar" + str(counter_id), "string_len") ) # must be NC_CHAR
+
+      # Write the variables to the file
+      for counter, meas in enumerate( measured_variables ):
+         measured_var[counter] = stringtochar( np.array( meas,"S%s"%(max_string_len) ) )
+
+#     Increment the counter
+      counter_id += 1
+
+# Store the number of observational sites
+   num_sites = len( sites_traj ) + len( sites_ts ) + len( sites_tspr )
 
 
@@ -426,17 +650,16 @@
 # are possible.
 if ( custom_coordinates ):
-
-   count_site = num_sites + 1
+   num_sites = counter_id - 1
    for coord in coordinates:
       # Define mandatory attributes
-      ncfile_out.setncattr( name_featuretype + str(count_site),  \
+      ncfile_out.setncattr( name_featuretype + str(counter_id),  \
                             name_ts )
-      ncfile_out.setncattr( name_site        + str(count_site),  \
-                            "custom"         + str(count_site - num_sites) )
-      ncfile_out.setncattr( name_orig_x      + str(count_site),  \
+      ncfile_out.setncattr( name_site        + str(counter_id),  \
+                            "custom"         + str(counter_id - num_sites) )
+      ncfile_out.setncattr( name_orig_x      + str(counter_id),  \
                             coord[0] )
-      ncfile_out.setncattr( name_orig_y      + str(count_site),  \
+      ncfile_out.setncattr( name_orig_y      + str(counter_id),  \
                             coord[1] )
-      ncfile_out.setncattr( name_orig_z      + str(count_site),  \
+      ncfile_out.setncattr( name_orig_z      + str(counter_id),  \
                             0.0 )
 
@@ -444,33 +667,33 @@
       ntime = 1
       nstat = 1
-      ncfile_out.createDimension( name_ntime   + str(count_site), ntime )
-      ncfile_out.createDimension( name_station + str(count_site), nstat )
+      ncfile_out.createDimension( name_ntime   + str(counter_id), ntime )
+      ncfile_out.createDimension( name_station + str(counter_id), nstat )
 
       # Define coordinate variables
-      temp_ts = ncfile_out.createVariable( name_eutm      + str(count_site), \
+      temp_ts = ncfile_out.createVariable( name_eutm      + str(counter_id), \
                                            float,                            \
-                                           name_station   + str(count_site) )
+                                           name_station   + str(counter_id) )
       temp_ts[:] = np.array( coord[0] )
 
-      temp_ts = ncfile_out.createVariable( name_nutm      + str(count_site), \
+      temp_ts = ncfile_out.createVariable( name_nutm      + str(counter_id), \
                                            float,                            \
-                                           name_station   + str(count_site) )
+                                           name_station   + str(counter_id) )
       temp_ts[:] = np.array( coord[1] )
 
-      temp_ts = ncfile_out.createVariable( name_z         + str(count_site), \
+      temp_ts = ncfile_out.createVariable( name_z         + str(counter_id), \
                                            float,                            \
-                                           name_station   + str(count_site) )
+                                           name_station   + str(counter_id) )
       temp_ts[:] = np.array( coord[2] )
 
-      temp_ts = ncfile_out.createVariable( name_station_h + str(count_site), \
+      temp_ts = ncfile_out.createVariable( name_station_h + str(counter_id), \
                                            float,                            \
-                                           name_station   + str(count_site) )
+                                           name_station   + str(counter_id) )
       temp_ts[:] = np.array( 0.0 )
 
 
-      count_site += 1
+      counter_id += 1
 
    # Reset counter variable
-   count_site = num_sites + 1
+   counter_id = num_sites + 1
 
    # check if variables are prescribed. If so, prepare final output string
@@ -491,9 +714,9 @@
                 measured_variables.append(var)
 
-         ncfile_out.createDimension( "nvar"+ str(count_site), \
+         ncfile_out.createDimension( "nvar"+ str(counter_id), \
                                      len( measured_variables ) )
 
-         measured_var = ncfile_out.createVariable( 'measured_variables' + str(count_site), 'S1', \
-                                                  ("nvar" + str(count_site), "string_len") ) # must be NC_CHAR
+         measured_var = ncfile_out.createVariable( 'measured_variables' + str(counter_id), 'S1', \
+                                                  ("nvar" + str(counter_id), "string_len") ) # must be NC_CHAR
 
          # Write the variables to the file
@@ -507,13 +730,13 @@
 
          # Write soil flag
-         ncfile_out.setncattr( name_soil_sampling + str( count_site), np.int8(soil) )
+         ncfile_out.setncattr( name_soil_sampling + str( counter_id), np.int8(soil) )
 
          # Increment counter variable
-         count_site += 1
+         counter_id += 1
 
          del ( measured_variables[:] )
 
    # Add the number of customized sites.
-   num_sites += int( number_positions )
+   num_sites = counter_id - 1
 
 
Index: palm/trunk/SOURCE/virtual_measurement_mod.f90
===================================================================
--- palm/trunk/SOURCE/virtual_measurement_mod.f90	(revision 4762)
+++ palm/trunk/SOURCE/virtual_measurement_mod.f90	(revision 4763)
@@ -25,4 +25,12 @@
 ! -----------------
 ! $Id$
+! - Simplified input of coordinates. All coordinate and height arrays are now 1D, independent on
+!   featuretype. This allows easier usage also for other campaign data sets independent of UC2.
+! - Avoid type conversion from 64 to 32 bit when output the data
+! - Increase dimension size of sample-variable string (sometimes more than 100 variables are listed
+!   for heavy measured locations)
+! - Remove quantities that cannot be sampled
+!
+! 4752 2020-10-21 13:54:51Z suehring
 ! Remove unnecessary output and merge output for quantities that are represented by the same
 ! variable in PALM, e.g. surface temperature and brightness temperature
@@ -191,4 +199,5 @@
         ONLY:  air_chemistry,                                                                      &
                coupling_char,                                                                      &
+               debug_output,                                                                       &
                dz,                                                                                 &
                end_time,                                                                           &
@@ -305,5 +314,5 @@
        INTEGER(iwp) ::  ns              = 0  !< number of observation coordinates on subdomain, for atmospheric measurements
        INTEGER(iwp) ::  ns_tot          = 0  !< total number of observation coordinates, for atmospheric measurements
-       INTEGER(iwp) ::  n_tr_st              !< number of trajectories / station of a measurement
+       INTEGER(iwp) ::  nst                  !< number of coordinate points given for a measurement
        INTEGER(iwp) ::  nmeas                !< number of measured variables (atmosphere + soil)
        INTEGER(iwp) ::  ns_soil         = 0  !< number of observation coordinates on subdomain, for soil measurements
@@ -677,9 +686,4 @@
           output_variable%units         = 'm2 s-2'
 
-       CASE ( 'plev' )
-          output_variable%long_name     = 'air pressure'
-          output_variable%standard_name = 'air_pressure'
-          output_variable%units         = 'Pa'
-
        CASE ( 'm_soil' )
           output_variable%long_name     = 'soil moisture volumetric'
@@ -731,14 +735,4 @@
           output_variable%units         = 'hPa'
 
-       CASE ( 'pswrtg' )
-          output_variable%long_name     = 'platform speed wrt ground'
-          output_variable%standard_name = 'platform_speed_wrt_ground'
-          output_variable%units         = 'm s-1'
-
-       CASE ( 'pswrta' )
-          output_variable%long_name     = 'platform speed wrt air'
-          output_variable%standard_name = 'platform_speed_wrt_air'
-          output_variable%units         = 'm s-1'
-
        CASE ( 'pwv' )
           output_variable%long_name     = 'water vapor partial pressure in air'
@@ -746,9 +740,4 @@
           output_variable%units         = 'hPa'
 
-       CASE ( 'ssdu' )
-          output_variable%long_name     = 'duration of sunshine'
-          output_variable%standard_name = 'duration_of_sunshine'
-          output_variable%units         = 's'
-
        CASE ( 't_lw' )
           output_variable%long_name     = 'land water temperature'
@@ -771,14 +760,4 @@
           output_variable%long_name     = 'upward kinematic latent heat flux in air'
           output_variable%units         = 'g kg-1 m s-1'
-
-       CASE ( 'zcb' )
-          output_variable%long_name     = 'cloud base altitude'
-          output_variable%standard_name = 'cloud_base_altitude'
-          output_variable%units         = 'm'
-
-       CASE ( 'zmla' )
-          output_variable%long_name     = 'atmosphere boundary layer thickness'
-          output_variable%standard_name = 'atmosphere_boundary_layer_thickness'
-          output_variable%units         = 'm'
 
        CASE ( 'mcpm1' )
@@ -880,8 +859,7 @@
 
     CHARACTER(LEN=5)                  ::  dum                           !< dummy string indicating station id
-    CHARACTER(LEN=100), DIMENSION(50) ::  measured_variables_file = ''  !< array with all measured variables read from NetCDF
-    CHARACTER(LEN=100), DIMENSION(50) ::  measured_variables      = ''  !< dummy array with all measured variables that are allowed
-
-    INTEGER(iwp) ::  dim_ntime  !< dimension size of time coordinate
+    CHARACTER(LEN=100), DIMENSION(200) ::  measured_variables_file = ''  !< array with all measured variables read from NetCDF
+    CHARACTER(LEN=100), DIMENSION(200) ::  measured_variables      = ''  !< dummy array with all measured variables that are allowed
+
     INTEGER(iwp) ::  i          !< grid index of virtual observation point in x-direction
     INTEGER(iwp) ::  is         !< grid index of real observation point of the respective station in x-direction
@@ -897,5 +875,4 @@
     INTEGER(iwp) ::  ll         !< running index over all measured variables in file
     INTEGER(iwp) ::  m          !< running index for surface elements
-    INTEGER(iwp) ::  n          !< running index over trajectory coordinates
     INTEGER(iwp) ::  nofill     !< dummy for nofill return value (not used)
     INTEGER(iwp) ::  ns         !< counter variable for number of observation points on subdomain
@@ -922,11 +899,13 @@
     REAL(wp) ::  fill_zar    !< _FillValue for zar coordinate
 
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  e_utm      !< easting UTM coordinate, temporary variable
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  e_utm_tmp  !< EUTM coordinate before rotation
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  height     !< observation height above ground (for trajectories)
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  n_utm      !< northing UTM coordinate, temporary variable
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  n_utm_tmp  !< NUTM coordinate before rotation
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  station_h  !< station height above reference
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  zar        !< observation height above reference
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  e_utm      !< easting UTM coordinate, temporary variable
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  e_utm_tmp  !< EUTM coordinate before rotation
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  height     !< observation height above ground (for trajectories)
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  n_utm      !< northing UTM coordinate, temporary variable
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  n_utm_tmp  !< NUTM coordinate before rotation
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  station_h  !< station height above reference
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  zar        !< observation height above reference
+
+    IF ( debug_output )  CALL debug_message( 'vm_init', 'start' )
 #if defined( __netcdf )
 !
@@ -1042,32 +1021,15 @@
        IF ( vmea(l)%nmeas > 0 )  THEN
 !
-!--       For stationary measurements UTM coordinates are just one value and its dimension is
-!--       "station", while for mobile measurements UTM coordinates are arrays depending on the
-!--       number of trajectories and time, according to (UC)2 standard. First, inquire dimension
-!--       length of the UTM coordinates.
-          IF ( vmea(l)%trajectory )  THEN
-!
-!--          For non-stationary measurements read the number of trajectories and the number of time
-!--          coordinates.
-             CALL get_dimension_length( pids_id, vmea(l)%n_tr_st, "traj" // TRIM( dum ) )
-             CALL get_dimension_length( pids_id, dim_ntime, "ntime" // TRIM( dum ) )
-!
-!--       For stationary measurements the dimension for UTM is station and for the time-coordinate
-!--       it is one.
-          ELSE
-             CALL get_dimension_length( pids_id, vmea(l)%n_tr_st, "station" // TRIM( dum ) )
-             dim_ntime = 1
-          ENDIF
-!
-!-        Allocate array which defines individual time/space frame for each trajectory or station.
-          ALLOCATE( vmea(l)%dim_t(1:vmea(l)%n_tr_st) )
+!--       For stationary and mobile measurements UTM coordinates are just one value and its dimension
+!--       is "station".
+          CALL get_dimension_length( pids_id, vmea(l)%nst, "station" // TRIM( dum ) )
 !
 !--       Allocate temporary arrays for UTM and height coordinates. Note, on file UTM coordinates
 !--       might be 1D or 2D variables
-          ALLOCATE( e_utm(1:vmea(l)%n_tr_st,1:dim_ntime)       )
-          ALLOCATE( n_utm(1:vmea(l)%n_tr_st,1:dim_ntime)       )
-          ALLOCATE( station_h(1:vmea(l)%n_tr_st,1:dim_ntime)   )
-          ALLOCATE( zar(1:vmea(l)%n_tr_st,1:dim_ntime)         )
-          IF ( vmea(l)%trajectory )  ALLOCATE( height(1:vmea(l)%n_tr_st,1:dim_ntime) )
+          ALLOCATE( e_utm(1:vmea(l)%nst)       )
+          ALLOCATE( n_utm(1:vmea(l)%nst)       )
+          ALLOCATE( station_h(1:vmea(l)%nst)   )
+          ALLOCATE( zar(1:vmea(l)%nst)         )
+          IF ( vmea(l)%trajectory )  ALLOCATE( height(1:vmea(l)%nst) )
           e_utm     = 0.0_wp
           n_utm     = 0.0_wp
@@ -1076,6 +1038,6 @@
           IF ( vmea(l)%trajectory )  height = 0.0_wp
 
-          ALLOCATE( e_utm_tmp(1:vmea(l)%n_tr_st,1:dim_ntime) )
-          ALLOCATE( n_utm_tmp(1:vmea(l)%n_tr_st,1:dim_ntime) )
+          ALLOCATE( e_utm_tmp(1:vmea(l)%nst) )
+          ALLOCATE( n_utm_tmp(1:vmea(l)%nst) )
 !
 !--       Read UTM and height coordinates for all trajectories and times. Note, in case
@@ -1094,17 +1056,12 @@
 !--       UC2-standard.
           IF ( vmea(l)%trajectory )  THEN
-             CALL get_variable( pids_id, char_eutm   // TRIM( dum ), e_utm,  0, dim_ntime-1, 0,    &
-                                vmea(l)%n_tr_st-1 )
-             CALL get_variable( pids_id, char_nutm   // TRIM( dum ), n_utm,  0, dim_ntime-1, 0,    &
-                                vmea(l)%n_tr_st-1 )
-             CALL get_variable( pids_id, char_zar    // TRIM( dum ), zar,    0, dim_ntime-1, 0,    &
-                                vmea(l)%n_tr_st-1 )
-             CALL get_variable( pids_id, char_height // TRIM( dum ), height, 0, dim_ntime-1, 0,    &
-                                vmea(l)%n_tr_st-1 )
+             CALL get_variable( pids_id, char_eutm      // TRIM( dum ), e_utm(:)     )
+             CALL get_variable( pids_id, char_nutm      // TRIM( dum ), n_utm(:)     )
+             CALL get_variable( pids_id, char_height    // TRIM( dum ), height(:)    )
           ELSE
-             CALL get_variable( pids_id, char_eutm      // TRIM( dum ), e_utm(:,1)     )
-             CALL get_variable( pids_id, char_nutm      // TRIM( dum ), n_utm(:,1)     )
-             CALL get_variable( pids_id, char_station_h // TRIM( dum ), station_h(:,1) )
-             CALL get_variable( pids_id, char_zar       // TRIM( dum ), zar(:,1)       )
+             CALL get_variable( pids_id, char_eutm      // TRIM( dum ), e_utm(:)     )
+             CALL get_variable( pids_id, char_nutm      // TRIM( dum ), n_utm(:)     )
+             CALL get_variable( pids_id, char_station_h // TRIM( dum ), station_h(:) )
+             CALL get_variable( pids_id, char_zar       // TRIM( dum ), zar(:)       )
           ENDIF
 
@@ -1116,5 +1073,5 @@
 !
 !--       Compute observation height above ground. Note, for trajectory measurements the height
-!--       above the surface is actually stored in 'height'
+!--       above the surface is actually stored in 'height'.
           IF ( vmea(l)%trajectory )  THEN
              zar      = height
@@ -1127,5 +1084,5 @@
 !--       on subdomain. This case, setup grid index space sample these quantities.
           meas_flag = 0
-          DO  t = 1, vmea(l)%n_tr_st
+          DO  t = 1, vmea(l)%nst
 !
 !--          First, compute relative x- and y-coordinates with respect to the lower-left origin of
@@ -1133,25 +1090,14 @@
 !--          is not correct, the virtual sites will be misplaced. Further, in case of an rotated
 !--          model domain, the UTM coordinates must also be rotated.
-             e_utm_tmp(t,1:dim_ntime) = e_utm(t,1:dim_ntime) - init_model%origin_x
-             n_utm_tmp(t,1:dim_ntime) = n_utm(t,1:dim_ntime) - init_model%origin_y
-             e_utm(t,1:dim_ntime) = COS( init_model%rotation_angle * pi / 180.0_wp )               &
-                                    * e_utm_tmp(t,1:dim_ntime)                                     &
+             e_utm_tmp(t) = e_utm(t) - init_model%origin_x
+             n_utm_tmp(t) = n_utm(t) - init_model%origin_y
+             e_utm(t) = COS( init_model%rotation_angle * pi / 180.0_wp )                           &
+                                    * e_utm_tmp(t)                                                 &
                                   - SIN( init_model%rotation_angle * pi / 180.0_wp )               &
-                                    * n_utm_tmp(t,1:dim_ntime)
-             n_utm(t,1:dim_ntime) = SIN( init_model%rotation_angle * pi / 180.0_wp )               &
-                                    * e_utm_tmp(t,1:dim_ntime)                                     &
+                                    * n_utm_tmp(t)
+             n_utm(t) = SIN( init_model%rotation_angle * pi / 180.0_wp )                           &
+                                    * e_utm_tmp(t)                                                 &
                                   + COS( init_model%rotation_angle * pi / 180.0_wp )               &
-                                    * n_utm_tmp(t,1:dim_ntime)
-!
-!--          Determine the individual time coordinate length for each station and trajectory. This
-!--          is required as several stations and trajectories are merged into one file but they do
-!--          not have the same number of points in time, hence, missing values may occur and cannot
-!--          be processed further. This is actually a work-around for the specific (UC)2 dataset,
-!--          but it won't harm anyway.
-             vmea(l)%dim_t(t) = 0
-             DO  n = 1, dim_ntime
-                IF ( e_utm(t,n) /= fill_eutm  .AND.  n_utm(t,n) /= fill_nutm  .AND.                &
-                     zar(t,n)   /= fill_zar )  vmea(l)%dim_t(t) = n
-             ENDDO
+                                    * n_utm_tmp(t)
 !
 !--          Compute grid indices relative to origin and check if these are on the subdomain. Note,
@@ -1170,34 +1116,32 @@
              ENDIF
 
-             DO  n = 1, vmea(l)%dim_t(t)
-                 is = INT( ( e_utm(t,n) + 0.5_wp * dx ) * ddx, KIND = iwp )
-                 js = INT( ( n_utm(t,n) + 0.5_wp * dy ) * ddy, KIND = iwp )
-!
-!--             Is the observation point on subdomain?
-                on_pe = ( is >= nxl  .AND.  is <= nxr  .AND.  js >= nys  .AND.  js <= nyn )
-!
-!--             Check if observation coordinate is on subdomain.
-                IF ( on_pe )  THEN
-!
-!--                Determine vertical index which corresponds to the observation height.
-                   ksurf = topo_top_ind(js,is,0)
-                   ks = MINLOC( ABS( zu - zw(ksurf) - zar(t,n) ), DIM = 1 ) - 1
-!
-!--                Set mask array at the observation coordinates. Also, flag the surrounding
-!--                coordinate points, but first check whether the surrounding coordinate points are
-!--                on the subdomain.
-                   kl = MERGE( ks-off_z, ksurf, ks-off_z >= nzb  .AND. ks-off_z >= ksurf )
-                   ku = MERGE( ks+off_z, nzt,   ks+off_z < nzt+1 )
-
-                   DO  i = is-off, is+off
-                      DO  j = js-off, js+off
-                         DO  k = kl, ku
-                            meas_flag(k,j,i) = MERGE( IBSET( meas_flag(k,j,i), 0 ), 0,             &
-                                                      BTEST( wall_flags_total_0(k,j,i), 0 ) )
-                         ENDDO
+             is = INT( ( e_utm(t) + 0.5_wp * dx ) * ddx, KIND = iwp )
+             js = INT( ( n_utm(t) + 0.5_wp * dy ) * ddy, KIND = iwp )
+!
+!--          Is the observation point on subdomain?
+             on_pe = ( is >= nxl  .AND.  is <= nxr  .AND.  js >= nys  .AND.  js <= nyn )
+!
+!--          Check if observation coordinate is on subdomain.
+             IF ( on_pe )  THEN
+!
+!--             Determine vertical index which corresponds to the observation height.
+                ksurf = topo_top_ind(js,is,0)
+                ks = MINLOC( ABS( zu - zw(ksurf) - zar(t) ), DIM = 1 ) - 1
+!
+!--             Set mask array at the observation coordinates. Also, flag the surrounding
+!--             coordinate points, but first check whether the surrounding coordinate points are
+!--             on the subdomain.
+                kl = MERGE( ks-off_z, ksurf, ks-off_z >= nzb  .AND. ks-off_z >= ksurf )
+                ku = MERGE( ks+off_z, nzt,   ks+off_z < nzt+1 )
+
+                DO  i = is-off, is+off
+                   DO  j = js-off, js+off
+                      DO  k = kl, ku
+                         meas_flag(k,j,i) = MERGE( IBSET( meas_flag(k,j,i), 0 ), 0,                &
+                                                          BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
-                ENDIF
-             ENDDO
+                ENDDO
+             ENDIF
 
           ENDDO
@@ -1317,5 +1261,4 @@
           IF ( ALLOCATED( n_utm_tmp ) )  DEALLOCATE( n_utm_tmp )
           IF ( ALLOCATED( n_utm )     )  DEALLOCATE( n_utm )
-          IF ( ALLOCATED( zar  )      )  DEALLOCATE( vmea(l)%dim_t )
           IF ( ALLOCATED( zar  )      )  DEALLOCATE( zar  )
           IF ( ALLOCATED( height )    )  DEALLOCATE( height )
@@ -1336,6 +1279,5 @@
     ns_all = 0
 #if defined( __parallel )
-    CALL MPI_ALLREDUCE( vmea(:)%ns, ns_all(:), vmea_general%nvm,                                   &
-                        MPI_INTEGER, MPI_SUM, comm2d, ierr )
+    CALL MPI_ALLREDUCE( vmea(:)%ns, ns_all(:), vmea_general%nvm, MPI_INTEGER, MPI_SUM, comm2d, ierr )
 #else
     ns_all(:) = vmea(:)%ns
@@ -1346,6 +1288,5 @@
     ns_all = 0
 #if defined( __parallel )
-    CALL MPI_ALLREDUCE( vmea(:)%ns_soil, ns_all(:), vmea_general%nvm,                              &
-                        MPI_INTEGER, MPI_SUM, comm2d, ierr )
+    CALL MPI_ALLREDUCE( vmea(:)%ns_soil, ns_all(:), vmea_general%nvm, MPI_INTEGER, MPI_SUM, comm2d, ierr )
 #else
     ns_all(:) = vmea(:)%ns_soil
@@ -1403,5 +1344,5 @@
 
 #endif
-
+    IF ( debug_output )  CALL debug_message( 'vm_init', 'end' )
  END SUBROUTINE vm_init
 
@@ -1999,8 +1940,8 @@
     REAL(wp), DIMENSION(:), ALLOCATABLE           ::  dum_lon                   !< transformed geographical coordinate (longitude)
     REAL(wp), DIMENSION(:), ALLOCATABLE           ::  oro_rel                   !< relative altitude of model surface
-    REAL(wp), DIMENSION(:), POINTER               ::  output_values_1d_pointer  !< pointer for 1d output array
-    REAL(wp), DIMENSION(:), ALLOCATABLE, TARGET   ::  output_values_1d_target   !< target for 1d output array
-    REAL(wp), DIMENSION(:,:), POINTER             ::  output_values_2d_pointer  !< pointer for 2d output array
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE, TARGET ::  output_values_2d_target   !< target for 2d output array
+    REAL(sp), DIMENSION(:), POINTER               ::  output_values_1d_pointer  !< pointer for 1d output array
+    REAL(sp), DIMENSION(:), ALLOCATABLE, TARGET   ::  output_values_1d_target   !< target for 1d output array
+    REAL(sp), DIMENSION(:,:), POINTER             ::  output_values_2d_pointer  !< pointer for 2d output array
+    REAL(sp), DIMENSION(:,:), ALLOCATABLE, TARGET ::  output_values_2d_target   !< target for 2d output array
 
     CALL cpu_log( log_point_s(26), 'VM output', 'start' )
@@ -2027,5 +1968,5 @@
 
           return_value = dom_write_var( vmea(l)%nc_filename, 'E_UTM',                              &
-                                        values_realwp_1d = output_values_1d_pointer,               &
+                                        values_real32_1d = output_values_1d_pointer,               &
                                         bounds_start = (/vmea(l)%start_coord_a/),                  &
                                         bounds_end   = (/vmea(l)%end_coord_a  /) )
@@ -2040,5 +1981,5 @@
           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,               &
+                                        values_real32_1d = output_values_1d_pointer,               &
                                         bounds_start = (/vmea(l)%start_coord_a/),                  &
                                         bounds_end   = (/vmea(l)%end_coord_a  /) )
@@ -2066,5 +2007,5 @@
           output_values_1d_pointer => output_values_1d_target
           return_value = dom_write_var( vmea(l)%nc_filename, 'lat',                                &
-                                        values_realwp_1d = output_values_1d_pointer,               &
+                                        values_real32_1d = output_values_1d_pointer,               &
                                         bounds_start = (/vmea(l)%start_coord_a/),                  &
                                         bounds_end   = (/vmea(l)%end_coord_a  /) )
@@ -2073,5 +2014,5 @@
           output_values_1d_pointer => output_values_1d_target
           return_value = dom_write_var( vmea(l)%nc_filename, 'lon',                                &
-                                        values_realwp_1d = output_values_1d_pointer,               &
+                                        values_real32_1d = output_values_1d_pointer,               &
                                         bounds_start = (/vmea(l)%start_coord_a/),                  &
                                         bounds_end   = (/vmea(l)%end_coord_a  /) )
@@ -2089,5 +2030,5 @@
           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,               &
+                                        values_real32_1d = output_values_1d_pointer,               &
                                         bounds_start = (/vmea(l)%start_coord_a/),                  &
                                         bounds_end   = (/vmea(l)%end_coord_a  /) )
@@ -2098,5 +2039,5 @@
           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,               &
+                                        values_real32_1d = output_values_1d_pointer,               &
                                         bounds_start = (/vmea(l)%start_coord_a/),                  &
                                         bounds_end   = (/vmea(l)%end_coord_a  /) )
@@ -2141,5 +2082,5 @@
              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,            &
+                                           values_real32_1d = output_values_1d_pointer,            &
                                            bounds_start = (/vmea(l)%start_coord_s/),               &
                                            bounds_end   = (/vmea(l)%end_coord_s  /) )
@@ -2154,5 +2095,5 @@
              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,            &
+                                           values_real32_1d = output_values_1d_pointer,            &
                                            bounds_start = (/vmea(l)%start_coord_s/),               &
                                            bounds_end   = (/vmea(l)%end_coord_s  /) )
@@ -2180,5 +2121,5 @@
              output_values_1d_pointer => output_values_1d_target
              return_value = dom_write_var( vmea(l)%nc_filename, 'lat_soil',                        &
-                                           values_realwp_1d = output_values_1d_pointer,            &
+                                           values_real32_1d = output_values_1d_pointer,            &
                                            bounds_start = (/vmea(l)%start_coord_s/),               &
                                            bounds_end   = (/vmea(l)%end_coord_s  /) )
@@ -2187,5 +2128,5 @@
              output_values_1d_pointer => output_values_1d_target
              return_value = dom_write_var( vmea(l)%nc_filename, 'lon_soil',                        &
-                                           values_realwp_1d = output_values_1d_pointer,            &
+                                           values_real32_1d = output_values_1d_pointer,            &
                                            bounds_start = (/vmea(l)%start_coord_s/),               &
                                            bounds_end   = (/vmea(l)%end_coord_s  /) )
@@ -2203,5 +2144,5 @@
              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,            &
+                                           values_real32_1d = output_values_1d_pointer,            &
                                            bounds_start = (/vmea(l)%start_coord_s/),               &
                                            bounds_end   = (/vmea(l)%end_coord_s  /) )
@@ -2212,5 +2153,5 @@
              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,            &
+                                           values_real32_1d = output_values_1d_pointer,            &
                                            bounds_start = (/vmea(l)%start_coord_s/),               &
                                            bounds_end   = (/vmea(l)%end_coord_s  /) )
@@ -2270,5 +2211,5 @@
 
              return_value = dom_write_var( vmea(l)%nc_filename, variable_name,                     &
-                                           values_realwp_2d = output_values_2d_pointer,            &
+                                           values_real32_2d = output_values_2d_pointer,            &
                                            bounds_start = (/vmea(l)%start_coord_s, t_ind/),        &
                                            bounds_end   = (/vmea(l)%end_coord_s, t_ind /) )
@@ -2278,5 +2219,5 @@
              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,            &
+                                           values_real32_2d = output_values_2d_pointer,            &
                                            bounds_start = (/vmea(l)%start_coord_s, t_ind/),        &
                                            bounds_end   = (/vmea(l)%end_coord_s, t_ind  /) )
@@ -2291,5 +2232,5 @@
 
              return_value = dom_write_var( vmea(l)%nc_filename, variable_name,                     &
-                                           values_realwp_2d = output_values_2d_pointer,            &
+                                           values_real32_2d = output_values_2d_pointer,            &
                                            bounds_start = (/vmea(l)%start_coord_a, t_ind/),        &
                                            bounds_end   = (/vmea(l)%end_coord_a, t_ind/) )
@@ -2300,5 +2241,5 @@
              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,            &
+                                           values_real32_2d = output_values_2d_pointer,            &
                                            bounds_start = (/ vmea(l)%start_coord_a, t_ind /),      &
                                            bounds_end   = (/ vmea(l)%end_coord_a, t_ind /) )
