Index: palm/trunk/SOURCE/virtual_measurement_mod.f90
===================================================================
--- palm/trunk/SOURCE/virtual_measurement_mod.f90	(revision 4405)
+++ palm/trunk/SOURCE/virtual_measurement_mod.f90	(revision 4406)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Bugix: removed oro_rel wrong loop bounds and removed unnecessary restart method
+! 
+! 4400 2020-02-10 20:32:41Z suehring
 ! Revision of the module:
 ! - revised input from NetCDF setup file
@@ -142,5 +145,4 @@
     USE control_parameters,                                                    &
         ONLY:  air_chemistry,                                                  &
-               child_domain,                                                   &
                coupling_char,                                                  &
                dz,                                                             &
@@ -153,6 +155,5 @@
                surface_pressure,                                               &
                time_since_reference_point,                                     &
-               virtual_measurement,                                            &
-               write_binary
+               virtual_measurement
 
     USE cpulog,                                                                &
@@ -346,5 +347,4 @@
     INTEGER(iwp) ::  maximum_name_length = 32 !< maximum name length of station names
     INTEGER(iwp) ::  ntimesteps               !< number of timesteps defined in NetCDF output file
-    INTEGER(iwp) ::  ntimesteps_max = 80000   !< number of maximum timesteps defined in NetCDF output file
     INTEGER(iwp) ::  off_pr = 1               !< number neighboring grid points (in each direction) where virtual profile
                                               !< measurements shall be taken, in addition to the given coordinates in the driver
@@ -455,12 +455,7 @@
        CALL message( 'vm_check_parameters', 'PA0705', 1, 2, 0, 6, 0 )
     ENDIF
-!
-!-- Check if restart activation string is set. Virtual measurements may exceed
-!-- the maximum number of allowed timesteps in a NetCDF file. In order to handle
-!-- this, the module will trigger a programm abortion with writing the restart
-!-- data.
-    IF ( .NOT. write_binary )  THEN
-       message_string = 'virtual measurements require file activation ' //     &
-                        'string "restart"'
+
+    IF ( dt_virtual_measurement <= 0.0 )  THEN
+       message_string = 'dt_virtual_measurement must be > 0.0'
        CALL message( 'check_parameters', 'PA0706', 1, 2, 0, 6, 0 )
     ENDIF
@@ -1450,7 +1445,7 @@
 !-- Determine the number of output timesteps. Set a maximum value of 80000
 !-- timesteps.
-    ntimesteps = MIN( CEILING(                                                 &
+    ntimesteps = CEILING(                                                      &
                   ( end_time - MAX( vm_time_start, time_since_reference_point )&
-                  ) / MAX( 0.1_wp, dt_virtual_measurement ) ), ntimesteps_max )
+                  ) / dt_virtual_measurement )
 !
 !-- Create directory where output files will be stored.
@@ -2269,7 +2264,4 @@
     INTEGER(iwp)       ::  t_ind         !< time index
 
-    LOGICAL            ::  proceed_run   !< flag to indicate that the maximum number of
-                                         !< timesteps in the file will be exceeded
-
     REAL(wp), DIMENSION(:), ALLOCATABLE           ::  oro_rel                  !< relative altitude of model surface
     REAL(wp), DIMENSION(:), POINTER               ::  output_values_1d_pointer !< pointer for 1d output array
@@ -2391,5 +2383,5 @@
 !--          and add this to z.
              ALLOCATE( oro_rel(1:vmea(l)%ns_soil) )
-             DO  n = 1, vmea(l)%ns
+             DO  n = 1, vmea(l)%ns_soil
                 oro_rel(n) = zw(topo_top_ind(vmea(l)%j_soil(n),vmea(l)%i_soil(n),3))
              ENDDO
@@ -2497,32 +2489,5 @@
 
     ENDDO  ! loop over sites
-!
-!-- Check if the time index exceeds its maximum values. This case, terminate the
-!-- run and force a restart. This is simply done by creating the file
-!-- DO_RESTART_NOW.
-    proceed_run = .TRUE.
-    IF ( ANY( vmea(:)%file_time_index >= ntimesteps - 1) )  proceed_run = .FALSE.
-
-#if defined( __parallel )
-    CALL MPI_ALLREDUCE( MPI_IN_PLACE,                                          &
-                        proceed_run,                                           &
-                        1,                                                     &
-                        MPI_LOGICAL,                                           &
-                        MPI_LAND,                                              &
-                        MPI_COMM_WORLD,                                        &
-                        ierr )
-#endif
-!
-!-- Create file DO_RESTART_NOW to force a restart. This file is only created
-!-- by rank 0 of the root domain.
-    IF ( myid == 0  .AND.  .NOT. child_domain  .AND.  .NOT. proceed_run )  THEN
-       OPEN( 999, FILE='DO_RESTART_NOW' )
-       CLOSE( 999 )
-
-       message_string = 'Run will be terminated because virtual ' //           &
-                        'measurement times index exceeds its maximum value ' //&
-                        'in the output files. A restart run is forced.' 
-       CALL message( 'vm_data_output', 'PA0707', 0, 0, 0, 6, 0 )
-    ENDIF
+
 
   END SUBROUTINE vm_data_output
