Index: /palm/trunk/SOURCE/virtual_measurement_mod.f90
===================================================================
--- /palm/trunk/SOURCE/virtual_measurement_mod.f90	(revision 3912)
+++ /palm/trunk/SOURCE/virtual_measurement_mod.f90	(revision 3913)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Bugfix: rotate positions of measurements before writing them into file
+! 
+! 3910 2019-04-17 11:46:56Z suehring
 ! Bugfix in rotation of UTM coordinates
 ! 
@@ -962,7 +965,7 @@
      IMPLICIT NONE
          
-     INTEGER(iwp) ::  i         !< running index over IO blocks    
-     INTEGER(iwp) ::  l         !< running index over all stations
-     INTEGER(iwp) ::  n         !< running index over all measured variables at a station
+     INTEGER(iwp) ::  i  !< running index over IO blocks    
+     INTEGER(iwp) ::  l  !< running index over all stations
+     INTEGER(iwp) ::  n  !< running index over all measured variables at a station
 !
 !--  Header output on each PE
@@ -994,9 +997,15 @@
                  WRITE ( 27 )  vmea(l)%ns
                  WRITE ( 27 )  'E_UTM                             '
-                 WRITE ( 27 )  init_model%origin_x +                           &
-                        REAL( vmea(l)%i(1:vmea(l)%ns) + 0.5_wp, KIND = wp ) * dx
+                 WRITE ( 27 )  init_model%origin_x                             &
+                    + REAL( vmea(l)%i(1:vmea(l)%ns) + 0.5_wp, KIND = wp ) * dx &
+                    * COS( init_model%rotation_angle * pi / 180.0_wp )         &
+                    + REAL( vmea(l)%j(1:vmea(l)%ns) + 0.5_wp, KIND = wp ) * dy &
+                    * SIN( init_model%rotation_angle * pi / 180.0_wp )
                  WRITE ( 27 )  'N_UTM                             '
-                 WRITE ( 27 )  init_model%origin_y +                           &
-                        REAL( vmea(l)%j(1:vmea(l)%ns) + 0.5_wp, KIND = wp ) * dy
+                 WRITE ( 27 )  init_model%origin_y                             &
+                    - REAL( vmea(l)%i(1:vmea(l)%ns) + 0.5_wp, KIND = wp ) * dx &
+                    * SIN( init_model%rotation_angle * pi / 180.0_wp )         &
+                    + REAL( vmea(l)%j(1:vmea(l)%ns) + 0.5_wp, KIND = wp ) * dy &
+                    * COS( init_model%rotation_angle * pi / 180.0_wp )
                  WRITE ( 27 )  'Z_AG                              '
                  WRITE ( 27 )  vmea(l)%z_ag(1:vmea(l)%ns)
@@ -1012,11 +1021,19 @@
                     WRITE ( 27 )  vmea(l)%ns_soil
                     WRITE ( 27 )  'E_UTM soil                        '
-                    WRITE ( 27 )  init_model%origin_x +                        &
-                           REAL( vmea(l)%i_soil(1:vmea(l)%ns_soil) + 0.5_wp,   &
-                                 KIND = wp ) * dx
+                    WRITE ( 27 )  init_model%origin_x                          &
+                       + REAL( vmea(l)%i_soil(1:vmea(l)%ns_soil) + 0.5_wp,     &
+                               KIND = wp ) * dx                                &
+                       * COS( init_model%rotation_angle * pi / 180.0_wp )      &
+                       + REAL( vmea(l)%j_soil(1:vmea(l)%ns_soil) + 0.5_wp,     &
+                               KIND = wp ) * dy                                &
+                       * SIN( init_model%rotation_angle * pi / 180.0_wp )
                     WRITE ( 27 )  'N_UTM soil                        '
-                    WRITE ( 27 )  init_model%origin_y +                        &
-                           REAL( vmea(l)%j_soil(1:vmea(l)%ns_soil) + 0.5_wp,   &
-                                 KIND = wp ) * dy
+                    WRITE ( 27 )  init_model%origin_y                          &
+                       - REAL( vmea(l)%i_soil(1:vmea(l)%ns_soil) + 0.5_wp,     &
+                               KIND = wp ) * dx                                &
+                       * SIN( init_model%rotation_angle * pi / 180.0_wp )      &
+                       + REAL( vmea(l)%j_soil(1:vmea(l)%ns_soil) + 0.5_wp,     &
+                               KIND = wp ) * dy                                &
+                       * COS( init_model%rotation_angle * pi / 180.0_wp )
                     WRITE ( 27 )  'DEPTH                             '
                     WRITE ( 27 )  vmea(l)%depth(1:vmea(l)%ns_soil)
