Index: /palm/trunk/EXAMPLES/wind_turbine/example_wtm.txt
===================================================================
--- /palm/trunk/EXAMPLES/wind_turbine/example_wtm.txt	(revision 1914)
+++ /palm/trunk/EXAMPLES/wind_turbine/example_wtm.txt	(revision 1914)
@@ -0,0 +1,52 @@
+example_wtm
+
+1. Purpose
+   This example shows the application of enhanced actuator disc wind turbine models in PALM 
+   The model is based on blade elements and conversion of airfoil lift 
+   and drag coefficients from the NREL 5MW reference turbine (see Jonkman et al. 2009:
+   Technical Report NREL/TP-500-38060, doi:10.2172/947422) to local forces on the flow.
+   The example simulates 4 different turbines in laminar flow that correct their orientation
+   after 30s of simulated time by use of a yaw controller.
+   
+2. PALM-Version / SVN Revision
+   PALM 4.0 / SVN Revision 1912
+
+3. Required user code
+   No user code is required
+   
+4. Input: 
+   example_wtm_p3d: Cyclic lateral boundary conditions are used. The 3d-model is initialized with
+                    constant temperature and constant laminar flow.
+   example_wtm_wtm: The property file of the NREL 5MW model turbine has also to be copied to the
+                    local INPUT folder, it will be automatically read by PALM
+
+5. Preprocessing
+   No preprocessing is required.
+   
+6. Program start 
+   Modifications to .mrun.config: 
+   If you don't use the default .mrun.config-files in trunk/SCRIPTS/ you will have to add the
+   following lines in your .mrun.config file:
+   In "List of input-files":
+   WTM_DATA               in:locopt     d3#:d3f  $base_data/$fname/INPUT     _wtm
+   In "List of output-files":
+   TURBINE_PARAMETERS01   out:loc:tr    d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+   TURBINE_PARAMETERS02   out:loc:tr    d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+   TURBINE_PARAMETERS03   out:loc:tr    d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+   TURBINE_PARAMETERS04   out:loc:tr    d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
+   
+   mrun call (example for lccrayh):
+   mrun -d example_wtm -h lccrayh -K parallel -X 64 -T 24 -t 2000 -q mpp1testq -r "d3# ts# ma#"
+
+7. Monitoring: 
+   example_wtm_rc and TURBINE_PARAMETERS01 should be equal to the attached files when run at
+   Cray System of HLRN Berlin. For other systems the deviations should be small.
+
+8. Postprocessing
+   No postprocessing of the data is required.
+
+9. List of attachments
+   example_wtm_p3d
+   example_wtm_wtm
+   lccrayb_example_wtm_rc
+   lccrayb_example_wtm_turbine_parameters01
Index: /palm/trunk/EXAMPLES/wind_turbine/example_wtm_p3d
===================================================================
--- /palm/trunk/EXAMPLES/wind_turbine/example_wtm_p3d	(revision 1914)
+++ /palm/trunk/EXAMPLES/wind_turbine/example_wtm_p3d	(revision 1914)
@@ -0,0 +1,64 @@
+ &inipar nx = 191, ny = 191, nz = 192,
+    
+         dx = 5.0, dy = 5.0, dz = 5.0,
+
+         bc_lr = 'cyclic',
+         bc_ns = 'cyclic',
+
+         initializing_actions = 'set_constant_profiles',
+         ug_surface = 8.0, vg_surface = 0.0,
+
+         bc_uv_b = 'neumann',
+         fft_method = 'temperton-algorithm',
+         
+         constant_flux_layer = .F., /
+
+ &d3par  end_time = 60.0,
+
+         npex = 8, npey = 8,
+
+         termination_time_needed = 600.0,
+         
+         create_disturbances = .F.,
+         
+         dt_run_control = 1.,
+           
+         mask_x_loop(1,:) = 200.0, 800.0, 5.0,
+         mask_y_loop(1,:) = 200.0, 800.0, 5.0,
+         mask_z_loop(1,:) = 400.0, 560.0, 15.0,
+         
+         data_output_masks(1,:) = 'u', 'v','w',
+
+         dt_domask = 2.,/
+
+ &wind_turbine_par
+         time_turbine_on  = 1.0,
+
+         nturbines = 4,
+         rcx =   300.0, 600.0, 300.0, 600.0,
+         rcy =   300.0, 300.0, 600.0, 600.0,
+         rcz =   480.0, 480.0, 480.0, 480.0,
+         rr  =    63.0, 63.0, 63.0, 63.0,
+         rnac =    1.5, 1.5, 1.5, 1.5,
+         dtow =    4.0, 4.0, 4.0, 4.0,
+
+         omega_rot = 0.9, 0.9, 0.9, 0.9,
+         phi_yaw = -20.0, 10.0, 0.0, 30.0,
+         tilt = 0.0,
+         rated_power = 5296610.0,
+         speed_control = .T.,
+         pitch_control = .T.,
+         pitch_add = 0.0,
+         yaw_control = .T.,
+         yaw_speed = 0.01,
+        
+         turb_cd_nacelle = 0.85, 0.85, 0.85, 0.85,
+         turb_cd_tower   = 1.2, 1.2, 1.2, 1.2,
+        
+         segment_length = 1.0,
+         segment_width  = 0.5,
+        
+         nairfoils = 8, /
+            
+! mrun -d example_wtm -v -h lccrayb -q mpp1testq -K parallel -X 64 -T 24 -t 1200 -r "d3# ts# ma#"
+! mrun -d example_wtm -v -c .mrun.config.forwind_flow -h lcflow  -K parallel -X 64 -t 2000 -r "d3# ts# ma#"
Index: /palm/trunk/EXAMPLES/wind_turbine/example_wtm_rc
===================================================================
--- /palm/trunk/EXAMPLES/wind_turbine/example_wtm_rc	(revision 1914)
+++ /palm/trunk/EXAMPLES/wind_turbine/example_wtm_rc	(revision 1914)
@@ -0,0 +1,239 @@
+
+ ******************************    --------------------------------------------
+ * PALM 4.0  Rev: 1865:18     *    atmosphere - run without 1D - prerun
+ ******************************    --------------------------------------------
+
+ Date:                 26-05-16    Run:       example_wtm         
+ Time:                 14:48:47    Run-No.:   00
+ Run on host:            lcflow
+ Number of PEs:              64    Processor grid (x,y): (   8,   8) predefined
+ ------------------------------------------------------------------------------
+
+ Numerical Schemes:
+ -----------------
+
+ --> Solve perturbation pressure via FFT using temperton-algorithm routines
+     perturbation pressure is calculated at every Runge-Kutta step
+ --> Momentum advection via Wicker-Skamarock-Scheme 5th order
+ --> Scalar advection via Wicker-Skamarock-Scheme 5th order
+ --> Loop optimization method: cache
+ --> Time differencing scheme: runge-kutta-3       
+ ------------------------------------------------------------------------------
+
+
+ Run time and time step information:
+ ----------------------------------
+
+ Timestep:             variable     maximum value: 20.000 s    CFL-factor: 0.90
+ Start time:              0.000 s
+ End time:               60.000 s
+
+
+ Computational grid and domain size:
+ ----------------------------------
+
+ Grid length:      dx =      5.000 m    dy =      5.000 m    dz =      5.000 m
+ Domain size:       x =    960.000 m     y =    960.000 m  z(u) =    962.500 m
+
+ Number of gridpoints (x,y,z):  (0: 191, 0: 191, 0: 193)
+ Subdomain size (x,y,z):        (    24,     24,    194)
+
+
+
+ Large scale forcing and nudging:
+ -------------------------------
+
+ --> No large scale forcing from external is used (default) 
+ --> No nudging is used (default) 
+
+    Characteristic levels of the geo. wind component ug:
+
+       Height:         0.0     0.0  m
+       ug:            8.00    8.00  m/s
+       Gradient:    ------    0.00  1/100s
+       Gridpoint:        0       0
+
+    Characteristic levels of the geo. wind component vg:
+
+       Height:         0.0     0.0  m
+       vg:            0.00    0.00  m/s
+       Gradient:    ------    0.00  1/100s
+       Gridpoint:        0       0
+
+
+ Topography information:
+ ----------------------
+
+ Topography: flat                                    
+
+
+ Boundary conditions:
+ -------------------
+
+                     p                    uv                                  pt
+
+ B. bound.: p(0)     = p(1)   | uv(0)     = uv(1)                 | pt(0)     = pt_surface       
+ T. bound.: p(nzt+1) = 0      | uv(nzt+1) = ug(nzt+1), vg(nzt+1)  | pt(nzt+1) = pt(nzt) + dpt/dz_
+
+                     e
+
+ B. bound.: e(0)     = e(1)                                                                      
+ T. bound.: e(nzt+1) = e(nzt) = e(nzt-1)                                                         
+
+
+ Lateral boundaries:
+       left/right:  cyclic              
+       north/south: cyclic              
+
+
+ Initial profiles:
+ ----------------
+
+    Characteristic levels of the initial temperature profile:
+
+       Height:           0.0     0.0  m
+       Temperature:   300.00  300.00  K
+       Gradient:      ------    0.00  K/100m
+       Gridpoint:          0       0
+
+
+ List output:
+ -----------
+
+    1D-Profiles:
+       Output every             ******** s
+
+
+ Data output:
+ -----------
+
+
+    Scaling lengths for output locations of all subsequent mask IDs:
+       mask_scale_x (in x-direction):     1.000 m
+       mask_scale_y (in y-direction):     1.000 m
+       mask_scale_z (in z-direction):     1.000 m
+
+    Masked data output for mask ID  1:
+       Output format: netCDF 64bit offset                     
+
+       Variables:  u, v, w,                                                             
+       Output every                 2.00 s
+
+       Output locations in x-direction in multiples of mask_scale_x constructed from array mask_01_x_loop:
+          loop begin:  200.00, end:  800.00, stride:    5.00
+
+       Output locations in y-direction in multiples of mask_scale_y constructed from array mask_01_y_loop:
+          loop begin:  200.00, end:  800.00, stride:    5.00
+
+       Output locations in z-direction in multiples of mask_scale_z constructed from array mask_01_z_loop:
+          loop begin:  400.00, end:  560.00, stride:   15.00
+
+    Time series:
+       Output format: netCDF 64bit offset                     
+
+       Output every                 1.00 s
+
+ ------------------------------------------------------------------------------
+
+
+ Physical quantities:
+ -------------------
+
+    Geograph. latitude  :   phi    = 55.0 degr
+    Angular velocity    :   omega  = 0.729E-04 rad/s
+    Coriolis parameter  :   f      =  0.000119 1/s
+                            f*     =  0.000084 1/s
+
+    Gravity             :   g      =  9.8 m/s**2
+
+    Reference state used in buoyancy terms: initial_profile
+
+
+ Cloud physics quantities / methods:
+ ----------------------------------
+
+
+
+ LES / Turbulence quantities:
+ ---------------------------
+
+    Mixing length is limited to 1.80 * z
+
+
+ Actions during the simulation:
+ -----------------------------
+
+
+
+ *** no user-defined variables found
+
+ ------------------------------------------------------------------------------
+
+
+
+Run-control output:
+------------------
+
+RUN  ITER. HH:MM:SS.SS    DT(E)     UMAX     VMAX     WMAX     U*    W*      THETA*     Z_I     ENERG.   DISTENERG    DIVOLD     DIVNEW     UMAX(KJI)    VMAX(KJI)    WMAX(KJI)   ADVECX   ADVECY   MGCYC
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+  0      0 00:00:00.00   0.5620A   8.0000   0.0000   0.0000  0.000  0.00   0.000E+00      0.  0.320E+02  0.000E+00  0.000E+00  0.000E+00    0 189 189    0 189 189    0 189 189    0.000    0.000       0
+  0      2 00:00:01.12   0.5620A   8.0000   0.0000  -0.0000  0.000  0.00   0.000E+00      0.  0.320E+02  0.598E-36  0.194E-06  0.166E-18    0 189 189  190 190 189    6 189 189    0.000    0.000       0
+  0      4 00:00:02.22   0.5350A   8.4064  -0.7424   0.3528  0.000  0.00   0.000E+00      0.  0.320E+02 -0.583E-02  0.424E-04  0.125E-13   82 120  60   92  59 119   96  59  59    0.000    0.000       0
+  0      6 00:00:03.25   0.5140A   8.7587  -1.3055  -0.8617  0.000  0.00   0.000E+00      0.  0.320E+02 -0.408E-02  0.409E-04  0.117E-13   96 120  61   92  60  62   96 124  61    0.000    0.000       0
+  0      8 00:00:04.26   0.5020A   8.9570  -1.5839  -1.1958  0.000  0.00   0.000E+00      0.  0.320E+02 -0.246E-02  0.414E-04  0.117E-13   96 120  62   92  60  63   96  64 122    0.000    0.000       0
+  0     10 00:00:05.27   0.5000A   9.0084  -1.7344  -1.3332  0.000  0.00   0.000E+00      0.  0.319E+02 -0.734E-03  0.428E-04  0.119E-13   96  60 123   92  60  63   96  64 123    0.000    0.000       0
+  0     12 00:00:06.27   0.5020A   8.9599  -1.8419  -1.3748  0.000  0.00   0.000E+00      0.  0.319E+02  0.121E-02  0.442E-04  0.122E-13   96  60 123   92  60  64   96  64 123    0.000    0.000       0
+  0     14 00:00:07.27   0.5010A   8.9826  -1.9345  -1.3851  0.000  0.00   0.000E+00      0.  0.319E+02  0.343E-02  0.451E-04  0.123E-13   82  58  66   92  60  65   96  64 124    0.000    0.000       0
+  0     16 00:00:08.27   0.5000A   8.9995  -2.0131  -1.3855  0.000  0.00   0.000E+00      0.  0.319E+02  0.589E-02  0.458E-04  0.124E-13   82  58  67   92  60  66   96  64 126    0.000    0.000       0
+  0     18 00:00:09.27   0.4990A   9.0164  -2.0693   1.4189  0.000  0.00   0.000E+00      0.  0.319E+02  0.850E-02  0.463E-04  0.124E-13   81  58  68   92  60  67  108  58 119    0.000    0.000       0
+  0     20 00:00:10.27   0.4980A   9.0421  -2.0980   1.4853  0.000  0.00   0.000E+00      0.  0.319E+02  0.112E-01  0.466E-04  0.125E-13   81  58  69   92  60  68  108  58 119    0.000    0.000       0
+  0     22 00:00:11.26   0.4960A   9.0685  -2.1240   1.5405  0.000  0.00   0.000E+00      0.  0.319E+02  0.141E-01  0.468E-04  0.125E-13   81  58  69   92  59  70  108 118  59    0.000    0.000       0
+  0     24 00:00:12.25   0.4950A   9.0930  -2.1701   1.5864  0.000  0.00   0.000E+00      0.  0.319E+02  0.170E-01  0.470E-04  0.125E-13   81  58  69   92  59  71  108 118  59    0.000    0.000       0
+  0     26 00:00:13.24   0.4930A   9.1195  -2.2074   1.6236  0.000  0.00   0.000E+00      0.  0.318E+02  0.199E-01  0.470E-04  0.125E-13   81  58  70   92  59  71  108 118  59    0.000    0.000       0
+  0     28 00:00:14.22   0.4920A   9.1419  -2.2207   1.6568  0.000  0.00   0.000E+00      0.  0.318E+02  0.229E-01  0.470E-04  0.124E-13   81  58  71   92  59  72  109 119  59    0.000    0.000       0
+  0     30 00:00:15.21   0.4910A   9.1603  -2.2371   1.6912  0.000  0.00   0.000E+00      0.  0.318E+02  0.260E-01  0.470E-04  0.124E-13   81  58  72   92  58  74  109 119  60    0.000    0.000       0
+  0     32 00:00:16.19   0.4900A   9.1763  -2.2662   1.7220  0.000  0.00   0.000E+00      0.  0.318E+02  0.290E-01  0.470E-04  0.124E-13   81  58  72   92  58  75  109 119  60    0.000    0.000       0
+  0     34 00:00:17.17   0.4900A   9.1885   2.2892   1.7479  0.000  0.00   0.000E+00      0.  0.318E+02  0.321E-01  0.470E-04  0.124E-13   81  58  73  101 122 137  109 119  60    0.000    0.000       0
+  0     36 00:00:18.15   0.4890A   9.1966   2.3217   1.7696  0.000  0.00   0.000E+00      0.  0.318E+02  0.351E-01  0.469E-04  0.123E-13   81  58  74  101 122 138  109 119  60    0.000    0.000       0
+  0     38 00:00:19.12   0.4890A   9.2005   2.3512   1.7877  0.000  0.00   0.000E+00      0.  0.318E+02  0.382E-01  0.469E-04  0.123E-13   81  58  75  101 122 139  109 119  60    0.000    0.000       0
+  0     40 00:00:20.10   0.4890A   9.2005   2.3778   1.8029  0.000  0.00   0.000E+00      0.  0.318E+02  0.412E-01  0.469E-04  0.123E-13   81  58  76  101 122 140  109 119  60    0.000    0.000       0
+  0     42 00:00:21.08   0.4890A   9.1967   2.4010   1.8159  0.000  0.00   0.000E+00      0.  0.318E+02  0.443E-01  0.468E-04  0.123E-13   81  58  77  101 122 141  109 119  60    0.000    0.000       0
+  0     44 00:00:22.06   0.4900A   9.1890   2.4387   1.8270  0.000  0.00   0.000E+00      0.  0.318E+02  0.473E-01  0.469E-04  0.123E-13   81  58  78  101 123 143  109 119  60    0.000    0.000       0
+  0     46 00:00:23.04   0.4900A   9.1778   2.4741   1.8363  0.000  0.00   0.000E+00      0.  0.317E+02  0.504E-01  0.468E-04  0.123E-13   81  58  79  101 123 144  109 119  60    0.000    0.000       0
+  0     48 00:00:24.02   0.4900A   9.1745   2.5033   1.8441  0.000  0.00   0.000E+00      0.  0.317E+02  0.534E-01  0.468E-04  0.123E-13   80  58  77  101 123 145  109 119  60    0.000    0.000       0
+  0     50 00:00:25.00   0.4900A   9.1774   2.5238   1.8506  0.000  0.00   0.000E+00      0.  0.317E+02  0.565E-01  0.467E-04  0.122E-13   80  58  78  101 123 146  109 119  60    0.000    0.000       0
+  0     53 00:00:26.47   0.4900A   9.1753   2.5697   1.8586  0.000  0.00   0.000E+00      0.  0.317E+02  0.577E-01  0.467E-04  0.122E-13   80  58  79  101 124 148  109 119  60    0.000    0.000       0
+  0     55 00:00:27.45   0.4910A   9.1703   2.5941   1.8629  0.000  0.00   0.000E+00      0.  0.317E+02  0.640E-01  0.467E-04  0.122E-13   80  58  79  101 124 149  109 119  60    0.000    0.000       0
+  0     57 00:00:28.43   0.4910A   9.1631   2.6040   1.8667  0.000  0.00   0.000E+00      0.  0.317E+02  0.670E-01  0.468E-04  0.122E-13   80  58  80  101 124 150  109 119  60    0.000    0.000       0
+  0     59 00:00:29.42   0.4920A   9.1537   2.6340   1.8698  0.000  0.00   0.000E+00      0.  0.317E+02  0.700E-01  0.469E-04  0.122E-13   80  58  80  101 125 151  109 119  60    0.000    0.000       0
+  0     61 00:00:30.40   0.4920A   9.1421   2.6567   1.8724  0.000  0.00   0.000E+00      0.  0.317E+02  0.730E-01  0.469E-04  0.122E-13   80  58  80  101 125 152  109 119  60    0.000    0.000       0
+  0     63 00:00:31.39   0.4930A   9.1293   2.6608   1.8747  0.000  0.00   0.000E+00      0.  0.317E+02  0.760E-01  0.471E-04  0.122E-13   80  58  80  101 125 153  109 119  60    0.000    0.000       0
+  0     65 00:00:32.37   0.4940A   9.1156   2.6612   1.8767  0.000  0.00   0.000E+00      0.  0.316E+02  0.790E-01  0.472E-04  0.123E-13   80  58  80  101 126 154  109 119  60    0.000    0.000       0
+  0     67 00:00:33.36   0.4940A   9.1014   2.6809   1.8783  0.000  0.00   0.000E+00      0.  0.316E+02  0.820E-01  0.473E-04  0.122E-13   80  58  80  101 126 155  109 119  60    0.000    0.000       0
+  0     69 00:00:34.35   0.4950A   9.0870   2.6790   1.8796  0.000  0.00   0.000E+00      0.  0.316E+02  0.851E-01  0.475E-04  0.123E-13   80  58  80  101 126 156  109 119  60    0.000    0.000       0
+  0     71 00:00:35.34   0.4960A   9.0726   2.6568   1.8806  0.000  0.00   0.000E+00      0.  0.316E+02  0.881E-01  0.476E-04  0.123E-13   80  58  80  101 127 158  109 119  60    0.000    0.000       0
+  0     73 00:00:36.34   0.4970A   9.0584   2.6658   1.8813  0.000  0.00   0.000E+00      0.  0.316E+02  0.912E-01  0.478E-04  0.123E-13   80  58  80  101 127 158  109 119  60    0.000    0.000       0
+  0     75 00:00:37.33   0.4980A   9.0444   2.6608   1.8819  0.000  0.00   0.000E+00      0.  0.316E+02  0.943E-01  0.479E-04  0.123E-13   80  58  79  101 127 159  109 119  60    0.000    0.000       0
+  0     77 00:00:38.33   0.4980A   9.0303   2.6318   1.8823  0.000  0.00   0.000E+00      0.  0.316E+02  0.974E-01  0.479E-04  0.123E-13   80  58  80  101 127 160  109 119  60    0.000    0.000       0
+  0     79 00:00:39.33   0.4990A   9.0155   2.6279   1.8829  0.000  0.00   0.000E+00      0.  0.316E+02  0.100E+00  0.479E-04  0.123E-13   80  58  80  100 120 160  109 119  60    0.000    0.000       0
+  0     81 00:00:40.33   0.5000A   8.9997   2.6619   1.8835  0.000  0.00   0.000E+00      0.  0.316E+02  0.104E+00  0.479E-04  0.123E-13   80  58  80  100 120 161  109 119  60    0.000    0.000       0
+  0     83 00:00:41.33   0.5010A   8.9837   2.6894   1.8839  0.000  0.00   0.000E+00      0.  0.316E+02  0.107E+00  0.480E-04  0.123E-13   80  60 154  100 120 162  109 119  60    0.000    0.000       0
+  0     85 00:00:42.33   0.5010A   8.9820   2.7129   1.8842  0.000  0.00   0.000E+00      0.  0.315E+02  0.110E+00  0.478E-04  0.122E-13   80  60 155  100 120 163  109 119  60    0.000    0.000       0
+  0     87 00:00:43.33   0.5010A   8.9799   2.7485   1.8844  0.000  0.00   0.000E+00      0.  0.315E+02  0.113E+00  0.477E-04  0.121E-13   80  60 155  100 121 164  109 119  60    0.000    0.000       0
+  0     89 00:00:44.33   0.5010A   8.9774   2.7794  -1.9322  0.000  0.00   0.000E+00      0.  0.315E+02  0.116E+00  0.475E-04  0.121E-13   80  60 156  100 121 165   91  57  98    0.000    0.000       0
+  0     91 00:00:45.33   0.5010A   8.9746   2.8067  -1.9961  0.000  0.00   0.000E+00      0.  0.315E+02  0.120E+00  0.473E-04  0.120E-13   80  60 157  100 121 166   91  57  99    0.000    0.000       0
+  0     93 00:00:46.34   0.5020A   8.9716   2.8317  -2.0212  0.000  0.00   0.000E+00      0.  0.315E+02  0.123E+00  0.472E-04  0.119E-13   80  60 158  100 121 167   90  56 100    0.000    0.000       0
+  0     95 00:00:47.34   0.5020A   8.9682   2.8550  -2.1016  0.000  0.00   0.000E+00      0.  0.315E+02  0.126E+00  0.470E-04  0.118E-13   80  60 159  100 121 168   90  56 101    0.000    0.000       0
+  0     97 00:00:48.35   0.5020A   8.9647   2.8818  -2.1485  0.000  0.00   0.000E+00      0.  0.315E+02  0.129E+00  0.468E-04  0.118E-13   80  60 160  100 122 169   90  57 101    0.000    0.000       0
+  0     99 00:00:49.35   0.5020A   8.9610   2.9113  -2.2384  0.000  0.00   0.000E+00      0.  0.315E+02  0.132E+00  0.467E-04  0.117E-13   80  60 161  100 122 170   90  56 102    0.000    0.000       0
+  0    101 00:00:50.35   0.5020A   8.9570   2.9381  -2.3073  0.000  0.00   0.000E+00      0.  0.315E+02  0.136E+00  0.466E-04  0.117E-13   80  60 162  100 122 171   90  56 103    0.000    0.000       0
+  0    103 00:00:51.36   0.5030A   8.9529   2.9615  -2.3729  0.000  0.00   0.000E+00      0.  0.315E+02  0.139E+00  0.467E-04  0.116E-13   80  60 163  100 122 172   90  57 103    0.000    0.000       0
+  0    105 00:00:52.37   0.5030A   8.9484  -3.1200  -2.3997  0.000  0.00   0.000E+00      0.  0.315E+02  0.142E+00  0.466E-04  0.116E-13   80  60 164   92  48 118   90  57 104    0.000    0.000       0
+  0    107 00:00:53.36   0.4980A   9.0450  -3.2174  -2.4912  0.000  0.00   0.000E+00      0.  0.315E+02  0.145E+00  0.462E-04  0.115E-13   90  42 121   92  48 119   89  56 105    0.000    0.000       0
+  0    109 00:00:54.35   0.4930A   9.1324  -3.2931  -2.5369  0.000  0.00   0.000E+00      0.  0.314E+02  0.148E+00  0.458E-04  0.113E-13   89  42 122   91  48 119   89  56 106    0.000    0.000       0
+  0    111 00:00:55.33   0.4890A   9.2067  -3.2999  -2.5922  0.000  0.00   0.000E+00      0.  0.314E+02  0.151E+00  0.455E-04  0.112E-13   89  42 123   91  48 119   89  56 106    0.000    0.000       0
+  0    113 00:00:56.30   0.4850A   9.2748  -3.2739  -2.6654  0.000  0.00   0.000E+00      0.  0.314E+02  0.154E+00  0.451E-04  0.111E-13   90  41 124   93  58 119   89  56 107    0.000    0.000       0
+  0    115 00:00:57.27   0.4830A   9.3215  -3.3870  -2.6825  0.000  0.00   0.000E+00      0.  0.314E+02  0.157E+00  0.450E-04  0.110E-13   88  42 125   93  58 119   89  57 107    0.000    0.000       0
+  0    117 00:00:58.23   0.4800A   9.3729  -3.4816  -2.7431  0.000  0.00   0.000E+00      0.  0.314E+02  0.160E+00  0.448E-04  0.110E-13   89  41 126   93  58 119   89  57 108    0.000    0.000       0
+  0    119 00:00:59.19   0.4800A   9.3830  -3.5641  -2.8063  0.000  0.00   0.000E+00      0.  0.314E+02  0.163E+00  0.449E-04  0.110E-13   87  42 127   94  58 119   88  56 109    0.000    0.000       0
+  0    121 00:01:00.15   0.4780A   9.4228  -3.6298  -2.8581  0.000  0.00   0.000E+00      0.  0.314E+02  0.166E+00  0.448E-04  0.109E-13   88  41 128   94  58 119   88  56 110    0.000    0.000       0
Index: /palm/trunk/EXAMPLES/wind_turbine/example_wtm_turbine_parameters01
===================================================================
--- /palm/trunk/EXAMPLES/wind_turbine/example_wtm_turbine_parameters01	(revision 1914)
+++ /palm/trunk/EXAMPLES/wind_turbine/example_wtm_turbine_parameters01	(revision 1914)
@@ -0,0 +1,122 @@
+Turbine control data for turbine  1 :
+----------------------------------------
+   Time   RSpeed  GSpeed  GenTorque  AeroTorque  Pitch  Power(Gen)  Power(Rot)  RotThrust  WDirection  YawOrient
+    1.124    0.886    85.91    38972.9   2925675.1   0.00   3160712.9   3174246.6  382728.5     0.00  -20.00
+    1.686    0.881    85.41    30947.9   2774185.1   0.00   2495335.5   2992439.8  369976.6     0.53  -20.00
+    2.221    0.884    85.74    23072.9   2656071.9   0.00   1867386.9   2875836.0  362290.1    -0.03  -20.00
+    2.746    0.895    86.86    15362.9   2557605.6   0.00   1259640.4   2805427.3  357999.7    -0.82  -20.00
+    3.260    0.915    88.78    14902.4   2488126.9   0.00   1249006.4   2789803.8  358780.9    -1.29  -20.00
+    3.768    0.935    90.67    17085.1   2438792.9   0.00   1462368.7   2792579.0  364284.3    -1.40  -20.00
+    4.270    0.951    92.22    18853.1   2387498.3   0.00   1641224.7   2780493.3  368566.4    -1.29  -20.00
+    4.771    0.964    93.49    19817.5   2346629.3   0.00   1749018.1   2770657.8  372374.4    -1.12  -20.00
+    5.271    0.975    94.60    20388.4   2313862.4   0.00   1820794.3   2764444.3  375954.8    -0.96  -20.00
+    5.771    0.986    95.60    20891.7   2280338.7   0.00   1885421.0   2753126.9  378505.7    -0.83  -20.00
+    6.273    0.995    96.49    21338.2   2247130.6   0.00   1943606.4   2738243.0  380406.1    -0.70  -20.00
+    6.775    1.003    97.28    21734.8   2215222.3   0.00   1995857.9   2721349.0  381803.7    -0.59  -20.00
+    7.276    1.010    97.97    22087.7   2184868.5   0.00   2042732.1   2703198.4  382799.6    -0.48  -20.00
+    7.777    1.016    98.58    22400.1   2156373.9   0.00   2084478.0   2684500.9  383490.0    -0.40  -20.00
+    8.277    1.022    99.11    22675.8   2129124.1   0.00   2121487.4   2664839.1  383817.7    -0.33  -20.00
+    8.777    1.026    99.57    22917.1   2103787.3   0.00   2153994.7   2645324.4  383940.0    -0.27  -20.00
+    9.276    1.031    99.96    23127.0   2080151.8   0.00   2182333.4   2625972.1  383891.9    -0.23  -20.00
+    9.774    1.034   100.30    23308.4   2057832.3   0.00   2206864.3   2606547.8  383619.0    -0.19  -20.00
+   10.272    1.037   100.58    23463.1   2036124.4   0.00   2227770.8   2586317.7  383075.2    -0.16  -20.00
+   10.769    1.039   100.82    23594.1   2017662.3   0.00   2245474.6   2568893.8  382754.3    -0.14  -20.00
+   11.265    1.041   101.01    23703.5   1999069.4   0.00   2260227.0   2550110.1  382039.3    -0.12  -20.00
+   11.761    1.043   101.17    23793.6   1982761.7   0.00   2272325.9   2533222.6  381466.5    -0.11  -20.00
+   12.256    1.044   101.29    23866.2   1967152.1   0.00   2282017.7   2516322.9  380703.0    -0.10  -20.00
+   12.750    1.045   101.38    23923.2   1952760.9   0.00   2289558.5   2500198.5  379944.5    -0.09  -20.00
+   13.243    1.046   101.45    23966.4   1939416.4   0.00   2295194.7   2484738.2  379153.3    -0.08  -20.00
+   13.736    1.046   101.49    23997.1   1926738.3   0.00   2299104.1   2469531.3  378284.5    -0.08  -20.00
+   14.228    1.047   101.51    24017.0   1915306.9   0.00   2301511.2   2455416.8  377468.4    -0.08  -20.00
+   14.720    1.047   101.52    24027.2   1904466.4   0.00   2302576.7   2441615.0  376617.2    -0.07  -20.00
+   15.211    1.046   101.50    24028.7   1893987.5   0.00   2302436.8   2427880.0  375654.4    -0.07  -20.00
+   15.702    1.046   101.48    24022.4   1883910.6   0.00   2301212.9   2414309.4  374677.4    -0.07  -20.00
+   16.192    1.046   101.44    24009.3   1874788.2   0.00   2299051.4   2401670.1  373737.8    -0.07  -20.00
+   16.682    1.045   101.39    23990.4   1866477.3   0.00   2296089.8   2389828.3  372848.5    -0.07  -20.00
+   17.172    1.045   101.33    23966.3   1858436.5   0.00   2292422.5   2378118.4  371908.8    -0.07  -20.00
+   17.662    1.044   101.26    23937.8   1850844.7   0.00   2288152.4   2366803.6  370996.6    -0.07  -20.00
+   18.151    1.043   101.18    23905.6   1843954.8   0.00   2283372.6   2356241.6  370120.0    -0.07  -20.00
+   18.640    1.042   101.10    23870.1   1837197.2   0.00   2278145.3   2345719.1  369214.1    -0.07  -20.00
+   19.129    1.041   101.01    23831.7   1830924.5   0.00   2272544.2   2335712.3  368324.6    -0.07  -20.00
+   19.618    1.040   100.92    23791.1   1825142.1   0.00   2266641.6   2326251.8  367476.2    -0.07  -20.00
+   20.107    1.039   100.83    23748.5   1819315.4   0.00   2260470.1   2316660.5  366575.0    -0.07  -20.00
+   20.596    1.038   100.73    23704.2   1813841.8   0.00   2254078.0   2307462.1  365691.8    -0.07  -20.00
+   21.085    1.037   100.63    23658.6   1808588.5   0.00   2247504.4   2298498.8  364810.4    -0.07  -20.00
+   21.574    1.036   100.53    23611.7   1803627.1   0.00   2240774.2   2289870.1  363956.0    -0.06  -20.00
+   22.064    1.035   100.43    23563.9   1798856.7   0.00   2233936.1   2281461.1  363107.8    -0.06  -20.00
+   22.554    1.034   100.32    23515.5   1794467.7   0.00   2227031.0   2273528.0  362298.4    -0.06  -20.00
+   23.044    1.033   100.22    23466.6   1790206.6   0.00   2220066.8   2265749.1  361497.9    -0.06  -20.00
+   23.535    1.032   100.11    23417.6   1786226.9   0.00   2213107.1   2258338.7  360722.9    -0.05  -20.00
+   24.025    1.031   100.01    23368.6   1782557.5   0.00   2206164.4   2251337.6  359995.1    -0.05  -20.00
+   24.515    1.030    99.90    23319.7   1778806.3   0.00   2199242.7   2244247.2  359234.3    -0.05  -20.00
+   25.005    1.029    99.80    23271.1   1775408.1   0.00   2192368.1   2237627.2  358525.1    -0.05  -20.00
+   25.495    1.028    99.70    23222.7   1771983.9   0.00   2185544.5   2230997.4  357805.3    -0.05  -20.00
+   25.985    1.027    99.59    23174.7   1768808.6   0.00   2178789.0   2224710.9  357118.3    -0.04  -20.00
+   26.475    1.026    99.49    23127.1   1765662.5   0.00   2172090.3   2218486.0  356425.1    -0.04  -20.00
+   26.966    1.025    99.39    23080.0   1762646.8   0.00   2165473.9   2212457.6  355750.9    -0.04  -19.72
+   27.457    1.024    99.30    23036.0   1766839.8   0.00   2159415.1   2215735.0  355726.2    -0.04  -19.44
+   27.948    1.023    99.22    22996.3   1770773.7   0.00   2153991.4   2218921.4  355716.1    -0.03  -19.16
+   28.439    1.022    99.16    22961.3   1775553.4   0.00   2149278.4   2223419.6  355921.7    -0.01  -18.87
+   28.930    1.022    99.10    22931.1   1779570.7   0.00   2145217.3   2227176.5  356037.0     0.01  -18.59
+   29.422    1.021    99.05    22905.4   1783762.1   0.00   2141799.5   2231363.4  356236.3     0.02  -18.31
+   29.914    1.021    99.02    22884.0   1787687.3   0.00   2138975.6   2235410.0  356423.1     0.04  -18.03
+   30.406    1.020    98.99    22866.7   1791692.6   0.00   2136709.3   2239740.8  356674.9     0.05  -17.75
+   30.899    1.020    98.96    22853.1   1795461.8   0.00   2134959.6   2243945.2  356926.4     0.06  -17.46
+   31.392    1.020    98.95    22843.0   1798977.3   0.00   2133675.6   2247983.8  357187.4     0.07  -17.18
+   31.885    1.020    98.94    22835.9   1802130.8   0.00   2132798.1   2251700.9  357393.5     0.08  -16.90
+   32.379    1.020    98.93    22831.7   1805913.9   0.00   2132338.7   2256349.8  357774.2     0.08  -16.62
+   32.873    1.020    98.94    22830.2   1808968.0   0.00   2132231.5   2260201.7  358046.9     0.08  -16.33
+   33.367    1.020    98.94    22831.1   1812100.6   0.00   2132452.6   2264261.7  358370.3     0.08  -16.05
+   33.862    1.020    98.95    22834.1   1814866.6   0.00   2132955.7   2267955.3  358648.6     0.08  -15.77
+   34.357    1.020    98.97    22839.1   1817894.4   0.00   2133736.0   2272072.3  359010.5     0.07  -15.48
+   34.853    1.020    98.99    22846.1   1821028.0   0.00   2134784.3   2276415.8  359410.4     0.07  -15.20
+   35.349    1.021    99.01    22854.6   1823537.4   0.00   2136046.1   2280047.2  359729.2     0.06  -14.91
+   35.845    1.021    99.03    22864.6   1826077.8   0.00   2137504.9   2283783.5  360087.7     0.05  -14.63
+   36.342    1.021    99.06    22875.9   1828611.3   0.00   2139142.0   2287572.3  360454.4     0.05  -14.34
+   36.839    1.022    99.09    22888.3   1830723.1   0.00   2140921.1   2290878.2  360777.5     0.04  -14.06
+   37.337    1.022    99.12    22901.6   1832848.8   0.00   2142822.7   2294242.4  361121.4     0.03  -13.77
+   37.835    1.022    99.15    22915.6   1834575.3   0.00   2144809.3   2297131.6  361410.8     0.03  -13.49
+   38.333    1.022    99.18    22930.2   1836494.5   0.00   2146885.1   2300293.2  361744.6     0.02  -13.20
+   38.832    1.023    99.21    22945.4   1838380.2   0.00   2149037.0   2303439.5  362093.1     0.02  -12.92
+   39.331    1.023    99.25    22961.1   1840242.5   0.00   2151263.5   2306582.7  362441.8     0.01  -12.63
+   39.831    1.024    99.29    22977.1   1841837.0   0.00   2153536.3   2309403.7  362750.9     0.01  -12.34
+   40.331    1.024    99.32    22993.5   1843538.3   0.00   2155854.9   2312375.2  363098.2     0.01  -12.06
+   40.831    1.024    99.36    23010.0   1844612.0   0.00   2158179.1   2314554.5  363347.9     0.00  -11.77
+   41.332    1.025    99.39    23026.5   1845621.5   0.00   2160487.2   2316643.9  363600.4     0.00  -11.48
+   41.833    1.025    99.43    23042.8   1846799.9   0.00   2162784.8   2318941.9  363887.9    -0.00  -11.19
+   42.334    1.025    99.46    23059.1   1847870.9   0.00   2165065.1   2321098.2  364153.6    -0.00  -10.91
+   42.835    1.026    99.50    23075.1   1848719.0   0.00   2167312.1   2322960.1  364383.7    -0.00  -10.62
+   43.336    1.026    99.53    23091.1   1850207.5   0.00   2169566.1   2325635.5  364744.7    -0.00  -10.33
+   43.837    1.026    99.56    23106.8   1850895.7   0.00   2171781.5   2327285.7  364970.6    -0.00  -10.05
+   44.338    1.027    99.60    23122.3   1851552.5   0.00   2173948.2   2328876.1  365197.2    -0.00   -9.76
+   44.839    1.027    99.63    23137.4   1852278.3   0.00   2176068.3   2330536.5  365442.2    -0.00   -9.47
+   45.340    1.027    99.66    23152.2   1853006.7   0.00   2178143.3   2332184.4  365701.1     0.00   -9.19
+   45.841    1.028    99.69    23166.6   1853366.6   0.00   2180154.4   2333341.9  365889.2     0.00   -8.90
+   46.343    1.028    99.72    23180.4   1853559.3   0.00   2182081.9   2334255.8  366046.6     0.01   -8.61
+   46.845    1.028    99.75    23193.7   1853888.6   0.00   2183933.6   2335315.2  366249.9     0.01   -8.32
+   47.347    1.029    99.77    23206.4   1854009.5   0.00   2185698.9   2336079.6  366416.5     0.01   -8.03
+   47.849    1.029    99.80    23218.3   1853792.0   0.00   2187355.6   2336374.8  366516.5     0.02   -7.75
+   48.351    1.029    99.82    23229.5   1853633.9   0.00   2188905.6   2336706.0  366616.2     0.02   -7.46
+   48.853    1.029    99.84    23240.0   1853667.6   0.00   2190365.5   2337249.3  366758.6     0.03   -7.17
+   49.355    1.029    99.86    23249.8   1853592.2   0.00   2191734.9   2337622.9  366878.7     0.03   -6.88
+   49.857    1.030    99.88    23258.9   1853080.8   0.00   2192988.2   2337401.2  366927.6     0.04   -6.60
+   50.359    1.030    99.90    23267.3   1852709.0   0.00   2194135.7   2337318.1  367003.6     0.04   -6.31
+   50.862    1.030    99.91    23274.7   1851945.9   0.00   2195152.0   2336691.1  367003.7     0.05   -6.02
+   51.365    1.030    99.92    23281.3   1851358.0   0.00   2196048.9   2336243.4  367040.8     0.06   -5.73
+   51.868    1.030    99.93    23287.0   1850689.0   0.00   2196827.2   2335651.7  367052.2     0.06   -5.44
+   52.371    1.030    99.94    23291.9   1849941.3   0.00   2197482.2   2334917.0  367047.1     0.07   -5.16
+   52.871    1.030    99.95    23295.8   1848933.7   0.00   2198004.2   2333804.8  366989.2     0.08   -4.87
+   53.369    1.030    99.95    23298.8   1847946.5   0.00   2198396.7   2332672.5  366951.9     0.09   -4.59
+   53.864    1.030    99.96    23301.1   1847206.0   0.00   2198683.5   2331817.4  366956.9     0.09   -4.31
+   54.357    1.031    99.96    23302.5   1846117.9   0.00   2198851.3   2330479.8  366899.4     0.10   -4.02
+   54.848    1.031    99.96    23303.2   1845408.2   0.00   2198928.5   2329591.7  366903.2     0.11   -3.74
+   55.337    1.030    99.96    23303.1   1843847.9   0.00   2198869.0   2327575.1  366760.0     0.12   -3.47
+   55.824    1.030    99.95    23302.0   1842411.7   0.00   2198677.0   2325667.4  366621.8     0.13   -3.19
+   56.309    1.030    99.95    23300.1   1841246.5   0.00   2198374.0   2324065.9  366539.3     0.14   -2.91
+   56.793    1.030    99.94    23297.3   1839547.6   0.00   2197934.5   2321739.4  366371.1     0.15   -2.63
+   57.276    1.030    99.93    23293.7   1838369.9   0.00   2197392.7   2320039.5  366283.4     0.16   -2.36
+   57.758    1.030    99.92    23289.2   1836734.1   0.00   2196731.7   2317717.7  366108.0     0.17   -2.08
+   58.238    1.030    99.91    23284.1   1835525.0   0.00   2195977.8   2315906.4  366016.2     0.18   -1.81
+   58.718    1.030    99.89    23278.1   1833456.9   0.00   2195085.2   2312956.5  365764.5     0.19   -1.53
+   59.198    1.030    99.88    23271.3   1831897.8   0.00   2194086.9   2310615.2  365591.9     0.20   -1.26
+   59.676    1.029    99.86    23263.7   1830265.2   0.00   2192982.4   2308145.8  365414.1     0.21   -0.98
Index: /palm/trunk/EXAMPLES/wind_turbine/example_wtm_wtm
===================================================================
--- /palm/trunk/EXAMPLES/wind_turbine/example_wtm_wtm	(revision 1914)
+++ /palm/trunk/EXAMPLES/wind_turbine/example_wtm_wtm	(revision 1914)
@@ -0,0 +1,217 @@
+ # Tablefiles for nrel5MW                                                                                   
+ # Table 1: Distribution table                                                                                                  
+ # Assigns the airfoils 1-8 to positions along the blade          
+ # Pos1[m] Pos2[m] no.atPos1 no.atPos2                                                       
+  0.0   1.5  0  0
+  1.5   5.6  1  1
+  5.6   8.3  1  2
+  8.3  11.8  2  3
+ 11.8  15.9  3  4
+ 15.9  20.0  4  4
+ 20.0  24.0  4  5
+ 24.0  28.2  5  6
+ 28.2  32.3  6  6
+ 32.3  36.4  6  7
+ 36.4  40.5  7  7
+ 40.5  44.5  7  8
+ 44.5  63.0  8  8
+ #                                                                                                   
+ # Table 2: Layout file                                                                                                  
+ # Physical layout of the blade                                                                                                  
+ # Pos[m] twist[deg] chord[m]                                                                                              
+  0.0 13.308  3.542
+  2.9 13.308  3.542
+  5.6 13.308  3.854
+  8.3 13.308  4.167
+ 11.8 13.308  4.557
+ 15.9 11.480  4.652
+ 20.0 10.162  4.458
+ 24.1  9.011  4.249
+ 28.2  7.795  4.007
+ 32.3  6.544  3.748
+ 36.4  5.361  3.502
+ 40.5  4.188  3.256
+ 44.6  3.125  3.010
+ 48.7  2.319  2.764
+ 52.8  1.526  2.518
+ 56.2  0.863  2.313
+ 58.9  0.370  2.086
+ 61.6  0.106  1.419
+ 63.0  0.106  1.419
+ # 
+ # Table 3: Lift and drag coefficients for airfoils 1-8  
+ # alpha   C_l_1   C_d_1   C_l_2   C_d_2   C_l_3   C_d_3   C_l_4   C_d_4   C_l_5   C_d_5   C_l_6   C_d_6   C_l_7   C_d_7   C_l_8   C_d_8
+ #
+-180.00   0.000  0.5000   0.000  0.3500   0.000  0.0602   0.000  0.0407   0.000  0.0267   0.000  0.0202   0.000  0.0185   0.000  0.0198
+-175.00   0.000  0.5000   0.000  0.3500   0.218  0.0699   0.223  0.0507   0.274  0.0370   0.368  0.0324   0.394  0.0332   0.374  0.0341
+-170.00   0.000  0.5000   0.000  0.3500   0.397  0.1107   0.405  0.1055   0.547  0.0968   0.735  0.0943   0.788  0.0945   0.749  0.0955
+-160.00   0.000  0.5000   0.000  0.3500   0.642  0.3045   0.658  0.2982   0.685  0.2876   0.695  0.2848   0.670  0.2909   0.659  0.2807
+-155.00   0.000  0.5000   0.000  0.3500   0.715  0.4179   0.733  0.4121   0.766  0.4025   0.777  0.4001   0.749  0.3932   0.736  0.3919
+-150.00   0.000  0.5000   0.000  0.3500   0.757  0.5355   0.778  0.5308   0.816  0.5232   0.828  0.5215   0.797  0.5112   0.783  0.5086
+-145.00   0.000  0.5000   0.000  0.3500   0.772  0.6535   0.795  0.6503   0.836  0.6454   0.850  0.6447   0.818  0.6309   0.803  0.6267
+-140.00   0.000  0.5000   0.000  0.3500   0.762  0.7685   0.787  0.7672   0.832  0.7656   0.846  0.7660   0.813  0.7485   0.798  0.7427
+-135.00   0.000  0.5000   0.000  0.3500   0.731  0.8777   0.757  0.8785   0.804  0.8807   0.818  0.8823   0.786  0.8612   0.771  0.8537
+-130.00   0.000  0.5000   0.000  0.3500   0.680  0.9788   0.708  0.9819   0.756  0.9882   0.771  0.9911   0.739  0.9665   0.724  0.9574
+-125.00   0.000  0.5000   0.000  0.3500   0.613  1.0700   0.641  1.0756   0.690  1.0861   0.705  1.0905   0.675  1.0625   0.660  1.0519
+-120.00   0.000  0.5000   0.000  0.3500   0.532  1.1499   0.560  1.1580   0.609  1.1730   0.624  1.1787   0.596  1.1476   0.581  1.1355
+-115.00   0.000  0.5000   0.000  0.3500   0.439  1.2174   0.467  1.2280   0.515  1.2474   0.530  1.2545   0.505  1.2206   0.491  1.2070
+-110.00   0.000  0.5000   0.000  0.3500   0.337  1.2716   0.365  1.2847   0.411  1.3084   0.426  1.3168   0.403  1.2805   0.390  1.3656
+-105.00   0.000  0.5000   0.000  0.3500   0.228  1.3118   0.255  1.3274   0.300  1.3552   0.314  1.3650   0.294  1.3265   0.282  1.3104
+-100.00   0.000  0.5000   0.000  0.3500   0.114  1.3378   0.139  1.3557   0.182  1.3875   0.195  1.3984   0.179  1.3582   0.169  1.3410
+ -95.00   0.000  0.5000   0.000  0.3500  -0.002  1.3492   0.021  1.3692   0.061  1.4048   0.073  1.4169   0.060  1.3752   0.052  1.3572
+ -90.00   0.000  0.5000   0.000  0.3500  -0.120  1.3460  -0.098  1.3680  -0.061  1.4070  -0.050  1.4201  -0.060  1.3774  -0.067  1.3587
+ -85.00   0.000  0.5000   0.000  0.3500  -0.236  1.3283  -0.216  1.3521  -0.183  1.3941  -0.173  1.4081  -0.179  1.3648  -0.184  1.3456
+ -80.00   0.000  0.5000   0.000  0.3500  -0.349  1.2964  -0.331  1.3218  -0.302  1.3664  -0.294  1.3811  -0.295  1.3376  -0.299  1.3181
+ -75.00   0.000  0.5000   0.000  0.3500  -0.456  1.2507  -0.441  1.2773  -0.416  1.3240  -0.409  1.3394  -0.407  1.2962  -0.409  1.2765
+ -70.00   0.000  0.5000   0.000  0.3500  -0.557  1.1918  -0.544  1.2193  -0.523  1.2676  -0.518  1.2833  -0.512  1.2409  -0.512  1.2212
+ -65.00   0.000  0.5000   0.000  0.3500  -0.647  1.1204  -0.638  1.1486  -0.622  1.1978  -0.617  1.2138  -0.608  1.1725  -0.606  1.1532
+ -60.00   0.000  0.5000   0.000  0.3500  -0.727  1.0376  -0.720  1.0660  -0.708  1.1156  -0.706  1.1315  -0.693  1.0919  -0.689  1.0731
+ -55.00   0.000  0.5000   0.000  0.3500  -0.792  0.9446  -0.788  0.9728  -0.781  1.0220  -0.780  1.0378  -0.764  1.0002  -0.759  0.9822
+ -50.00   0.000  0.5000   0.000  0.3500  -0.842  0.8429  -0.840  0.8705  -0.838  0.9187  -0.839  0.9341  -0.820  0.8990  -0.814  0.8820
+ -45.00   0.000  0.5000   0.000  0.3500  -0.874  0.7345  -0.875  0.7611  -0.877  0.8074  -0.879  0.8221  -0.857  0.7900  -0.850  0.7742
+ -40.00   0.000  0.5000   0.000  0.3500  -0.886  0.6215  -0.889  0.6466  -0.895  0.6904  -0.898  0.7042  -0.875  0.6754  -0.866  0.6610
+ -35.00   0.000  0.5000   0.000  0.3500  -0.875  0.5067  -0.880  0.5299  -0.889  0.5703  -0.893  0.5829  -0.869  0.5579  -0.860  0.5451
+ -30.00   0.000  0.5000   0.000  0.3500  -0.839  0.3932  -0.846  0.4141  -0.858  0.4503  -0.862  0.4616  -0.838  0.4405  -0.829  0.4295
+ -25.00   0.000  0.5000   0.000  0.3500  -0.777  0.2849  -0.784  0.3030  -0.832  0.3357  -0.803  0.3441  -0.791  0.3256  -0.853  0.3071
+ -24.00   0.000  0.5000   0.000  0.3500  -0.761  0.2642  -0.768  0.2817  -0.852  0.3147  -0.792  0.3209  -0.794  0.3013  -0.870  0.2814
+ -23.00   0.000  0.5000   0.000  0.3500  -0.744  0.2440  -0.751  0.2608  -0.882  0.2946  -0.789  0.2972  -0.805  0.2762  -0.890  0.2556
+ -22.00   0.000  0.5000   0.000  0.3500  -0.725  0.2242  -0.733  0.2404  -0.919  0.2752  -0.792  0.2730  -0.821  0.2506  -0.911  0.2297
+ -21.00   0.000  0.5000   0.000  0.3500  -0.706  0.2049  -0.714  0.2205  -0.963  0.2566  -0.801  0.2485  -0.843  0.2246  -0.934  0.2040
+ -20.00   0.000  0.5000   0.000  0.3500  -0.685  0.1861  -0.693  0.2011  -1.013  0.2388  -0.815  0.2237  -0.869  0.1983  -0.958  0.1785
+ -19.00   0.000  0.5000   0.000  0.3500  -0.662  0.1687  -0.671  0.1822  -1.067  0.2218  -0.833  0.1990  -0.899  0.1720  -0.982  0.1534
+ -18.00   0.000  0.5000   0.000  0.3500  -0.635  0.1533  -0.648  0.1640  -1.125  0.2056  -0.854  0.1743  -0.931  0.1457  -1.005  0.1288
+ -17.00   0.000  0.5000   0.000  0.3500  -0.605  0.1398  -0.624  0.1465  -1.185  0.1901  -0.879  0.1498  -0.964  0.1197  -1.082  0.1037
+ -16.00   0.000  0.5000   0.000  0.3500  -0.571  0.1281  -0.601  0.1300  -1.245  0.1754  -0.905  0.1256  -0.999  0.0940  -1.113  0.0786
+ -15.25   0.000  0.5000   0.000  0.3500  -0.543  0.1208  -0.585  0.1170  -1.290  0.1649  -0.925  0.1080  -1.025  0.0751  -1.107  0.0598
+ -15.00   0.000  0.5000   0.000  0.3500  -0.534  0.1183  -0.579  0.1145  -1.275  0.1570  -0.932  0.1020  -1.033  0.0689  -1.105  0.0535
+ -14.50   0.000  0.5000   0.000  0.3500  -0.514  0.1142  -0.569  0.1070  -1.245  0.1498  -0.945  0.0905  -1.050  0.0567  -1.092  0.0404
+ -14.24   0.000  0.5000   0.000  0.3500  -0.504  0.1121  -0.564  0.1034  -1.229  0.1461  -0.952  0.0847  -1.040  0.0536  -1.085  0.0343
+ -14.00   0.000  0.5000   0.000  0.3500  -0.494  0.1101  -0.559  0.1000  -1.212  0.1412  -0.959  0.0789  -1.030  0.0508  -1.078  0.0283
+ -13.50   0.000  0.5000   0.000  0.3500  -0.473  0.1069  -0.549  0.0932  -1.172  0.1320  -0.972  0.0678  -1.010  0.0449  -1.053  0.0158
+ -13.24   0.000  0.5000   0.000  0.3500  -0.462  0.1052  -0.544  0.0899  -1.148  0.1263  -0.979  0.0622  -1.000  0.0420  -1.034  0.0153
+ -13.00   0.000  0.5000   0.000  0.3500  -0.452  0.1036  -0.539  0.0867  -1.127  0.1210  -0.985  0.0567  -0.990  0.0390  -1.015  0.0151
+ -12.22   0.000  0.5000   0.000  0.3500  -0.418  0.0998  -0.524  0.0769  -1.052  0.1051  -0.960  0.0336  -0.960  0.0296  -0.927  0.0138
+ -12.01   0.000  0.5000   0.000  0.3500  -0.408  0.0987  -0.519  0.0745  -1.035  0.1004  -0.953  0.0271  -0.953  0.0271  -0.905  0.0134
+ -12.00   0.000  0.5000   0.000  0.3500  -0.407  0.0986  -0.519  0.0744  -1.034  0.1003  -0.952  0.0271  -0.952  0.0271  -0.904  0.0134
+ -11.22   0.000  0.5000   0.000  0.3500  -0.370  0.0959  -0.504  0.0657  -0.965  0.0888  -0.911  0.0295  -0.910  0.0293  -0.829  0.0124
+ -11.00   0.000  0.5000   0.000  0.3500  -0.360  0.0951  -0.499  0.0633  -0.943  0.0854  -0.900  0.0303  -0.900  0.0303  -0.807  0.0121
+ -10.19   0.000  0.5000   0.000  0.3500  -0.320  0.0935  -0.483  0.0553  -0.867  0.0740  -0.842  0.0291  -0.844  0.0291  -0.731  0.0113
+ -10.00   0.000  0.5000   0.000  0.3500  -0.311  0.0931  -0.480  0.0534  -0.846  0.0710  -0.828  0.0288  -0.829  0.0287  -0.711  0.0111
+  -9.98   0.000  0.5000   0.000  0.3500  -0.310  0.0931  -0.480  0.0534  -0.845  0.0709  -0.827  0.0287  -0.827  0.0287  -0.708  0.0111
+  -9.70   0.000  0.5000   0.000  0.3500  -0.295  0.0931  -0.469  0.0537  -0.822  0.0684  -0.806  0.0283  -0.784  0.0273  -0.678  0.0108
+  -9.18   0.000  0.5000   0.000  0.3500  -0.269  0.0931  -0.432  0.0545  -0.769  0.0604  -0.767  0.0275  -0.700  0.0221  -0.615  0.0101
+  -9.00   0.000  0.5000   0.000  0.3500  -0.260  0.0931  -0.420  0.0550  -0.765  0.0554  -0.754  0.0271  -0.671  0.0204  -0.595  0.0099
+  -8.98   0.000  0.5000   0.000  0.3500  -0.259  0.0930  -0.419  0.0551  -0.765  0.0551  -0.753  0.0271  -0.668  0.0201  -0.593  0.0099
+  -8.47   0.000  0.5000   0.000  0.3500  -0.233  0.0930  -0.378  0.0570  -0.759  0.0370  -0.691  0.0264  -0.580  0.0156  -0.534  0.0095
+  -8.18   0.000  0.5000   0.000  0.3500  -0.218  0.0930  -0.346  0.0582  -0.756  0.0270  -0.648  0.0218  -0.546  0.0132  -0.498  0.0093
+  -8.12   0.000  0.5000   0.000  0.3500  -0.214  0.0930  -0.341  0.0585  -0.753  0.0265  -0.640  0.0209  -0.536  0.0124  -0.491  0.0092
+  -8.00   0.000  0.5000   0.000  0.3500  -0.208  0.0930  -0.330  0.0590  -0.745  0.0255  -0.625  0.0192  -0.520  0.0120  -0.478  0.0091
+  -7.62   0.000  0.5000   0.000  0.3500  -0.190  0.0915  -0.298  0.0610  -0.724  0.0221  -0.580  0.0140  -0.467  0.0109  -0.441  0.0091
+  -7.45   0.000  0.5000   0.000  0.3500  -0.182  0.0885  -0.283  0.0617  -0.714  0.0208  -0.555  0.0114  -0.444  0.0103  -0.429  0.0091
+  -7.19   0.000  0.5000   0.000  0.3500  -0.169  0.0847  -0.245  0.0633  -0.690  0.0180  -0.508  0.0105  -0.403  0.0095  -0.404  0.0092
+  -7.11   0.000  0.5000   0.000  0.3500  -0.165  0.0825  -0.234  0.0637  -0.681  0.0178  -0.496  0.0103  -0.393  0.0092  -0.393  0.0092
+  -7.00   0.000  0.5000   0.000  0.3500  -0.160  0.0800  -0.220  0.0643  -0.666  0.0175  -0.483  0.0100  -0.386  0.0089  -0.375  0.0086
+  -6.65   0.000  0.5000   0.000  0.3500  -0.142  0.0741  -0.178  0.0659  -0.616  0.0166  -0.441  0.0096  -0.327  0.0084  -0.336  0.0085
+  -6.60   0.000  0.5000   0.000  0.3500  -0.140  0.0735  -0.172  0.0661  -0.609  0.0164  -0.435  0.0096  -0.323  0.0083  -0.331  0.0085
+  -6.50   0.000  0.5000   0.000  0.3500  -0.135  0.0726  -0.160  0.0666  -0.595  0.0161  -0.422  0.0095  -0.311  0.0089  -0.320  0.0084
+  -6.42   0.000  0.5000   0.000  0.3500  -0.131  0.0720  -0.151  0.0670  -0.585  0.0158  -0.413  0.0094  -0.300  0.0087  -0.310  0.0084
+  -6.13   0.000  0.5000   0.000  0.3500  -0.117  0.0696  -0.120  0.0683  -0.542  0.0152  -0.371  0.0092  -0.261  0.0083  -0.278  0.0083
+  -6.00   0.000  0.5000   0.000  0.3500  -0.111  0.0689  -0.111  0.0689  -0.525  0.0117  -0.355  0.0091  -0.245  0.0082  -0.264  0.0082
+  -5.54   0.000  0.5000   0.000  0.3500  -0.092  0.0620  -0.385  0.0245  -0.454  0.0106  -0.291  0.0087  -0.183  0.0075  -0.213  0.0081
+  -5.50   0.000  0.5000   0.000  0.3500  -0.090  0.0614  -0.384  0.0244  -0.451  0.0105  -0.285  0.0087  -0.178  0.0074  -0.208  0.0081
+  -5.40   0.000  0.5000   0.000  0.3500  -0.086  0.0599  -0.378  0.0240  -0.444  0.0103  -0.271  0.0086  -0.165  0.0073  -0.196  0.0080
+  -5.04   0.000  0.5000   0.000  0.3500  -0.073  0.0550  -0.359  0.0225  -0.385  0.0097  -0.225  0.0074  -0.118  0.0069  -0.156  0.0079
+  -5.00   0.000  0.5000   0.000  0.3500  -0.072  0.0547  -0.359  0.0224  -0.382  0.0097  -0.220  0.0073  -0.113  0.0069  -0.151  0.0079
+  -4.54   0.000  0.5000   0.000  0.3500  -0.066  0.0484  -0.360  0.0196  -0.317  0.0092  -0.158  0.0071  -0.053  0.0065  -0.089  0.0076
+  -4.50   0.000  0.5000   0.000  0.3500  -0.065  0.0480  -0.360  0.0195  -0.314  0.0092  -0.152  0.0071  -0.048  0.0065  -0.084  0.0076
+  -4.04   0.000  0.5000   0.000  0.3500  -0.055  0.0415  -0.355  0.0175  -0.254  0.0091  -0.090  0.0070   0.011  0.0063  -0.022  0.0072
+  -4.00   0.000  0.5000   0.000  0.3500  -0.054  0.0411  -0.353  0.0174  -0.251  0.0091  -0.084  0.0070   0.016  0.0063  -0.017  0.0072
+  -3.54   0.000  0.5000   0.000  0.3500  -0.020  0.0354  -0.307  0.0162  -0.192  0.0089  -0.023  0.0069   0.075  0.0061   0.031  0.0068
+  -3.50   0.000  0.5000   0.000  0.3500  -0.017  0.0349  -0.304  0.0161  -0.189  0.0089  -0.018  0.0069   0.080  0.0061   0.035  0.0068
+  -3.04   0.000  0.5000   0.000  0.3500   0.002  0.0303  -0.246  0.0144  -0.123  0.0089   0.044  0.0068   0.140  0.0058   0.084  0.0064
+  -3.00   0.000  0.5000   0.000  0.3500   0.003  0.0299  -0.240  0.0240  -0.120  0.0089   0.049  0.0068   0.145  0.0058   0.088  0.0064
+  -2.50   0.000  0.5000   0.000  0.3500   0.014  0.0255  -0.163  0.0188  -0.051  0.0088   0.115  0.0068   0.208  0.0057   0.150  0.0059
+  -2.00   0.000  0.5000   0.000  0.3500   0.009  0.0198  -0.091  0.0160   0.017  0.0088   0.181  0.0068   0.270  0.0057   0.213  0.0054
+  -1.50   0.000  0.5000   0.000  0.3500   0.004  0.0164  -0.019  0.0137   0.085  0.0088   0.247  0.0067   0.333  0.0057   0.270  0.0053
+  -1.00   0.000  0.5000   0.000  0.3500   0.036  0.0147   0.052  0.0118   0.152  0.0088   0.312  0.0067   0.396  0.0057   0.328  0.0052
+  -0.50   0.000  0.5000   0.000  0.3500   0.073  0.0137   0.121  0.0104   0.219  0.0088   0.377  0.0067   0.458  0.0057   0.385  0.0052
+   0.00   0.000  0.5000   0.000  0.3500   0.137  0.0113   0.196  0.0094   0.288  0.0087   0.444  0.0065   0.521  0.0057   0.442  0.0052
+   0.50   0.000  0.5000   0.000  0.3500   0.213  0.0114   0.265  0.0096   0.354  0.0087   0.508  0.0065   0.583  0.0057   0.499  0.0052
+   1.00   0.000  0.5000   0.000  0.3500   0.292  0.0118   0.335  0.0098   0.421  0.0088   0.573  0.0066   0.645  0.0058   0.556  0.0052
+   1.50   0.000  0.5000   0.000  0.3500   0.369  0.0122   0.404  0.0099   0.487  0.0089   0.636  0.0067   0.706  0.0058   0.613  0.0052
+   2.00   0.000  0.5000   0.000  0.3500   0.444  0.0124   0.472  0.0100   0.554  0.0090   0.701  0.0068   0.768  0.0059   0.670  0.0053
+   2.50   0.000  0.5000   0.000  0.3500   0.514  0.0124   0.540  0.0102   0.619  0.0091   0.765  0.0069   0.828  0.0061   0.727  0.0053
+   3.00   0.000  0.5000   0.000  0.3500   0.580  0.0123   0.608  0.0103   0.685  0.0092   0.827  0.0070   0.888  0.0063   0.784  0.0053
+   3.50   0.000  0.5000   0.000  0.3500   0.645  0.0120   0.674  0.0104   0.749  0.0093   0.890  0.0071   0.948  0.0066   0.841  0.0054
+   4.00   0.000  0.5000   0.000  0.3500   0.710  0.0119   0.742  0.0105   0.815  0.0095   0.952  0.0073   0.996  0.0071   0.898  0.0054
+   4.50   0.000  0.5000   0.000  0.3500   0.776  0.0122   0.809  0.0107   0.879  0.0096   1.013  0.0076   1.046  0.0079   0.955  0.0056
+   5.00   0.000  0.5000   0.000  0.3500   0.841  0.0125   0.875  0.0108   0.944  0.0097   1.062  0.0079   1.095  0.0090   1.011  0.0058
+   5.50   0.000  0.5000   0.000  0.3500   0.904  0.0129   0.941  0.0109   1.008  0.0099   1.111  0.0089   1.145  0.0103   1.057  0.0074
+   6.00   0.000  0.5000   0.000  0.3500   0.967  0.0135   1.007  0.0110   1.072  0.0101   1.161  0.0099   1.192  0.0113   1.103  0.0091
+   6.50   0.000  0.5000   0.000  0.3500   1.027  0.0144   1.071  0.0113   1.135  0.0103   1.208  0.0117   1.239  0.0122   1.041  0.0102
+   7.00   0.000  0.5000   0.000  0.3500   1.084  0.0158   1.134  0.0115   1.197  0.0107   1.254  0.0132   1.282  0.0131   1.181  0.0113
+   7.50   0.000  0.5000   0.000  0.3500   1.140  0.0174   1.198  0.0117   1.256  0.0112   1.301  0.0143   1.324  0.0139   1.219  0.0119
+   8.00   0.000  0.5000   0.000  0.3500   1.193  0.0198   1.260  0.0120   1.305  0.0125   1.336  0.0153   1.358  0.0147   1.257  0.0124
+   8.50   0.000  0.5000   0.000  0.3500   1.242  0.0231   1.318  0.0126   1.348  0.0140   1.369  0.0165   1.385  0.0158   1.293  0.0130
+   9.00   0.000  0.5000   0.000  0.3500   1.287  0.0275   1.368  0.0133   1.390  0.0155   1.400  0.0181   1.403  0.0181   1.326  0.0136
+   9.50   0.000  0.5000   0.000  0.3500   1.333  0.0323   1.422  0.0143   1.424  0.0171   1.428  0.0211   1.401  0.0211   1.356  0.0143
+  10.00   0.000  0.5000   0.000  0.3500   1.368  0.0393   1.475  0.0156   1.458  0.0192   1.442  0.0262   1.358  0.0255   1.382  0.0150
+  10.50   0.000  0.5000   0.000  0.3500   1.400  0.0475   1.523  0.0174   1.488  0.0219   1.427  0.0336   1.313  0.0301   1.400  0.0267
+  11.00   0.000  0.5000   0.000  0.3500   1.425  0.0580   1.570  0.0194   1.512  0.0255   1.374  0.0420   1.287  0.0347   1.415  0.0383
+  11.50   0.000  0.5000   0.000  0.3500   1.449  0.0691   1.609  0.0227   1.533  0.0307   1.316  0.0515   1.274  0.0401   1.425  0.0498
+  12.00   0.000  0.5000   0.000  0.3500   1.473  0.0816   1.642  0.0269   1.549  0.0370   1.277  0.0601   1.272  0.0468   1.434  0.0613
+  12.50   0.000  0.5000   0.000  0.3500   1.494  0.0973   1.675  0.0319   1.558  0.0452   1.250  0.0693   1.273  0.0545   1.443  0.0727
+  13.00   0.000  0.5000   0.000  0.3500   1.513  0.1129   1.700  0.0398   1.470  0.0630   1.246  0.0785   1.273  0.0633   1.451  0.0841
+  13.50   0.000  0.5000   0.000  0.3500   1.538  0.1288   1.717  0.0488   1.398  0.0784   1.247  0.0888   1.273  0.0722   1.453  0.0954
+  14.00   0.000  0.5000   0.000  0.3500   1.563  0.1462   1.712  0.0614   1.354  0.0931   1.256  0.1000   1.272  0.0806   1.448  0.1065
+  14.50   0.000  0.5000   0.000  0.3500   1.587  0.1650   1.703  0.0786   1.336  0.1081   1.260  0.1108   1.273  0.0900   1.444  0.1176
+  15.00   0.000  0.5000   0.000  0.3500   1.614  0.1845   1.692  0.0968   1.333  0.1239   1.271  0.1219   1.275  0.0987   1.445  0.1287
+  15.50   0.000  0.5000   0.000  0.3500   1.631  0.2052   1.671  0.1173   1.326  0.1415   1.281  0.1325   1.281  0.1075   1.447  0.1398
+  16.00   0.000  0.5000   0.000  0.3500   1.649  0.2250   1.649  0.1377   1.329  0.1592   1.289  0.1433   1.284  0.1170   1.448  0.1509
+  16.50   0.000  0.5000   0.000  0.3500   1.666  0.2467   1.621  0.1600   1.326  0.1743   1.294  0.1541   1.296  0.1270   1.444  0.1619
+  17.00   0.000  0.5000   0.000  0.3500   1.681  0.2684   1.598  0.1814   1.321  0.1903   1.304  0.1649   1.306  0.1368   1.438  0.1728
+  17.50   0.000  0.5000   0.000  0.3500   1.699  0.2900   1.571  0.2042   1.331  0.2044   1.309  0.1754   1.308  0.1464   1.439  0.1837
+  18.00   0.000  0.5000   0.000  0.3500   1.719  0.3121   1.549  0.2316   1.333  0.2186   1.315  0.1845   1.308  0.1562   1.448  0.1947
+  18.50   0.000  0.5000   0.000  0.3500   1.735  0.3335   1.545  0.2516   1.340  0.2324   1.320  0.1953   1.308  0.1664   1.452  0.2057
+  19.00   0.000  0.5000   0.000  0.3500   1.751  0.3554   1.544  0.2719   1.362  0.2455   1.330  0.2061   1.308  0.1770   1.448  0.2165
+  19.50   0.000  0.5000   0.000  0.3500   1.767  0.3783   1.549  0.2906   1.382  0.2584   1.343  0.2170   1.307  0.1878   1.438  0.2272
+  20.00   0.000  0.5000   0.000  0.3500   1.782  0.4000   1.565  0.3085   1.398  0.2689   1.354  0.2280   1.311  0.1987   1.428  0.2379
+  20.50   0.000  0.5000   0.000  0.3500   1.798  0.4212   1.565  0.3265   1.426  0.2814   1.359  0.2390   1.325  0.2100   1.415  0.2485
+  21.00   0.000  0.5000   0.000  0.3500   1.810  0.4415   1.565  0.3447   1.437  0.2943   1.360  0.2536   1.324  0.2214   1.401  0.2590
+  22.00   0.000  0.5000   0.000  0.3500   1.830  0.4830   1.563  0.3820   1.418  0.3246   1.325  0.2814   1.277  0.2499   1.359  0.2799
+  23.00   0.000  0.5000   0.000  0.3500   1.847  0.5257   1.558  0.4203   1.397  0.3557   1.288  0.3098   1.229  0.2786   1.300  0.3004
+  24.00   0.000  0.5000   0.000  0.3500   1.861  0.5694   1.552  0.4593   1.376  0.3875   1.251  0.3386   1.182  0.3077   1.220  0.3204
+  25.00   0.000  0.5000   0.000  0.3500   1.872  0.6141   1.546  0.4988   1.354  0.4198   1.215  0.3678   1.136  0.3371   1.168  0.3377
+  26.00   0.000  0.5000   0.000  0.3500   1.881  0.6593   1.539  0.5387   1.332  0.4524   1.181  0.3972   1.093  0.3664   1.116  0.3554
+  28.00   0.000  0.5000   0.000  0.3500   1.894  0.7513   1.527  0.6187   1.293  0.5183   1.120  0.4563   1.017  0.4246   1.015  0.3916
+  30.00   0.000  0.5000   0.000  0.3500   1.904  0.8441   1.522  0.6978   1.265  0.5843   1.076  0.5149   0.962  0.4813   0.926  0.4294
+  32.00   0.000  0.5000   0.000  0.3500   1.915  0.9364   1.529  0.7747   1.253  0.6492   1.056  0.5720   0.937  0.5356   0.855  0.4690
+  35.00   0.000  0.5000   0.000  0.3500   1.929  1.0722   1.544  0.8869   1.264  0.7438   1.066  0.6548   0.947  0.6127   0.800  0.5324
+  40.00   0.000  0.5000   0.000  0.3500   1.903  1.2873   1.529  1.0671   1.258  0.8970   1.064  0.7901   0.950  0.7396   0.804  0.6452
+  45.00   0.000  0.5000   0.000  0.3500   1.820  1.4796   1.471  1.2319   1.217  1.0402   1.035  0.9190   0.928  0.8623   0.793  0.7573
+  50.00   0.000  0.5000   0.000  0.3500   1.690  1.6401   1.376  1.3747   1.146  1.1686   0.980  1.0378   0.884  0.9781   0.763  0.8664
+  55.00   0.000  0.5000   0.000  0.3500   1.522  1.7609   1.249  1.4899   1.049  1.2779   0.904  1.1434   0.821  1.0846   0.717  0.9708
+  60.00   0.000  0.5000   0.000  0.3500   1.323  1.8360   1.097  1.5728   0.932  1.3647   0.810  1.2333   0.740  1.1796   0.656  1.0693
+  65.00   0.000  0.5000   0.000  0.3500   1.106  1.8614   0.928  1.6202   0.799  1.4267   0.702  1.3055   0.646  1.2617   0.582  1.1606
+  70.00   0.000  0.5000   0.000  0.3500   0.880  1.8347   0.750  1.6302   0.657  1.4621   0.582  1.3587   0.540  1.3297   0.495  1.2438
+  75.00   0.000  0.5000   0.000  0.3500   0.658  1.7567   0.570  1.6031   0.509  1.4708   0.456  1.3922   0.425  1.3827   0.398  1.3178
+  80.00   0.000  0.5000   0.000  0.3500   0.449  1.6334   0.396  1.5423   0.362  1.4544   0.326  1.4063   0.304  1.4202   0.291  1.3809
+  85.00   0.000  0.5000   0.000  0.3500   0.267  1.4847   0.237  1.4598   0.221  1.4196   0.197  1.4042   0.179  1.4423   0.176  1.4304
+  90.00   0.000  0.5000   0.000  0.3500   0.124  1.3879   0.101  1.4041   0.092  1.3938   0.072  1.3985   0.053  1.4512   0.053  1.4565
+  95.00   0.000  0.5000   0.000  0.3500   0.002  1.3912  -0.022  1.4053  -0.030  1.3943  -0.050  1.3973  -0.073  1.4480  -0.074  1.4533
+ 100.00   0.000  0.5000   0.000  0.3500  -0.118  1.3795  -0.143  1.3914  -0.150  1.3798  -0.170  1.3810  -0.198  1.4294  -0.199  1.4345
+ 105.00   0.000  0.5000   0.000  0.3500  -0.235  1.3528  -0.261  1.3625  -0.267  1.3504  -0.287  1.3498  -0.319  1.3954  -0.321  1.4004
+ 110.00   0.000  0.5000   0.000  0.3500  -0.348  1.3114  -0.374  1.3188  -0.379  1.3063  -0.399  1.3041  -0.434  1.3464  -0.436  1.3512
+ 115.00   0.000  0.5000   0.000  0.3500  -0.453  1.2557  -0.480  1.2608  -0.483  1.2481  -0.502  1.2442  -0.541  1.2829  -0.543  1.2874
+ 120.00   0.000  0.5000   0.000  0.3500  -0.549  1.1864  -0.575  1.1891  -0.578  1.1763  -0.596  1.1709  -0.637  1.2057  -0.640  1.2099
+ 125.00   0.000  0.5000   0.000  0.3500  -0.633  1.1041  -0.659  1.1046  -0.660  1.0919  -0.677  1.0852  -0.720  1.1157  -0.723  1.1196
+ 130.00   0.000  0.5000   0.000  0.3500  -0.702  1.0102  -0.727  1.0086  -0.727  0.9962  -0.743  0.9883  -0.787  1.0144  -0.790  1.0179
+ 135.00   0.000  0.5000   0.000  0.3500  -0.754  0.9060  -0.778  0.9025  -0.777  0.8906  -0.792  0.8818  -0.836  0.9033  -0.840  0.9064
+ 140.00   0.000  0.5000   0.000  0.3500  -0.787  0.7935  -0.809  0.7883  -0.807  0.7771  -0.821  0.7676  -0.864  0.7845  -0.868  0.7871
+ 145.00   0.000  0.5000   0.000  0.3500  -0.797  0.6750  -0.818  0.6684  -0.815  0.6581  -0.826  0.6481  -0.869  0.6605  -0.872  0.6627
+ 150.00   0.000  0.5000   0.000  0.3500  -0.782  0.5532  -0.800  0.5457  -0.797  0.5364  -0.806  0.5264  -0.847  0.5346  -0.850  0.5363
+ 155.00   0.000  0.5000   0.000  0.3500  -0.739  0.4318  -0.754  0.4236  -0.750  0.4157  -0.758  0.4060  -0.795  0.4103  -0.798  0.4116
+ 160.00   0.000  0.5000   0.000  0.3500  -0.664  0.3147  -0.677  0.3066  -0.673  0.3000  -0.679  0.2912  -0.711  0.2922  -0.714  0.2931
+ 170.00   0.000  0.5000   0.000  0.3500  -0.410  0.1144  -0.417  0.1085  -0.547  0.1051  -0.735  0.0995  -0.788  0.0969  -0.749  0.0971
+ 175.00   0.000  0.5000   0.000  0.3500  -0.226  0.0702  -0.229  0.0510  -0.274  0.0388  -0.368  0.0356  -0.394  0.0334  -0.374  0.0334
+ 180.00   0.000  0.5000   0.000  0.3500   0.000  0.0602   0.000  0.0407   0.000  0.0267   0.000  0.0202   0.000  0.0185   0.000  0.0198
Index: /palm/trunk/SCRIPTS/.mrun.config.csc_sisu
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.csc_sisu	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.csc_sisu	(revision 1914)
@@ -79,4 +79,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f      $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART  _rprt
@@ -104,4 +105,8 @@
 CPU_MEASURES      out:loc:tr   d3#     $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 #
 DATA_1D_PR_NETCDF    out:loc:tr   pr#:prf   $base_data/$fname/OUTPUT  _pr     nc
Index: /palm/trunk/SCRIPTS/.mrun.config.cuhk
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.cuhk	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.cuhk	(revision 1914)
@@ -84,4 +84,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f      $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART  _rprt
@@ -109,4 +110,8 @@
 CPU_MEASURES      out:loc:tr   d3#     $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 #
 DATA_1D_PR_NETCDF    out:loc:tr   pr#:prf   $base_data/$fname/OUTPUT  _pr     nc
Index: /palm/trunk/SCRIPTS/.mrun.config.dkrz
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.dkrz	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.dkrz	(revision 1914)
@@ -86,4 +86,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f      $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART  _rprt
@@ -111,4 +112,8 @@
 CPU_MEASURES      out:loc:tr   d3#     $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 #
 DATA_1D_PR_NETCDF    out:loc:tr   pr#:prf   $base_data/$fname/OUTPUT  _pr      nc
Index: /palm/trunk/SCRIPTS/.mrun.config.forwind_flow
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.forwind_flow	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.forwind_flow	(revision 1914)
@@ -113,4 +113,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f:rec  $base_data/$fname/RESTART   _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART   _rprt
Index: /palm/trunk/SCRIPTS/.mrun.config.forwind_hlrnIII
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.forwind_hlrnIII	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.forwind_hlrnIII	(revision 1914)
@@ -137,4 +137,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f:rec  $base_data/$fname/RESTART   _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART   _rprt
Index: /palm/trunk/SCRIPTS/.mrun.config.gfortran
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.gfortran	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.gfortran	(revision 1914)
@@ -99,4 +99,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f      $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART  _rprt
@@ -124,4 +125,8 @@
 CPU_MEASURES      out:loc:tr   d3#     $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 #
 DATA_1D_PR_NETCDF    out:loc:tr   pr#:prf   $base_data/$fname/OUTPUT  _pr     nc
Index: /palm/trunk/SCRIPTS/.mrun.config.hayaka
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.hayaka	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.hayaka	(revision 1914)
@@ -71,4 +71,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f      $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART  _rprt
@@ -96,4 +97,8 @@
 CPU_MEASURES      out:loc:tr   d3#     $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 #
 DATA_1D_PR_NETCDF    out:loc:tr   pr#:prf   $base_data/$fname/OUTPUT  _pr     nc
Index: /palm/trunk/SCRIPTS/.mrun.config.hlrnIII
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.hlrnIII	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.hlrnIII	(revision 1914)
@@ -138,4 +138,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f      $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART  _rprt
@@ -163,4 +164,8 @@
 CPU_MEASURES      out:loc:tr   d3#     $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 #
 DATA_1D_PR_NETCDF    out:loc:tr   pr#:prf   $base_data/$fname/OUTPUT  _pr     nc
Index: /palm/trunk/SCRIPTS/.mrun.config.ibmh
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.ibmh	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.ibmh	(revision 1914)
@@ -84,4 +84,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f      $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART  _rprt
@@ -109,4 +110,8 @@
 CPU_MEASURES      out:loc:tr   d3#     $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 #
 DATA_1D_PR_NETCDF    out:loc:tr   pr#:prf   $output_data/$fname/OUTPUT  _pr     nc
Index: /palm/trunk/SCRIPTS/.mrun.config.ifort
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.ifort	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.ifort	(revision 1914)
@@ -99,4 +99,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f      $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART  _rprt
@@ -124,4 +125,8 @@
 CPU_MEASURES      out:loc:tr   d3#     $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 #
 DATA_1D_PR_NETCDF    out:loc:tr   pr#:prf   $base_data/$fname/OUTPUT  _pr     nc
Index: /palm/trunk/SCRIPTS/.mrun.config.imuk
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.imuk	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.imuk	(revision 1914)
@@ -74,4 +74,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f      $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART  _rprt
@@ -99,4 +100,8 @@
 CPU_MEASURES      out:loc:tr   d3#     $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 #
 DATA_1D_PR_NETCDF    out:loc:tr   pr#:prf   $base_data/$fname/OUTPUT  _pr      nc
Index: /palm/trunk/SCRIPTS/.mrun.config.imuk_gpu
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.imuk_gpu	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.imuk_gpu	(revision 1914)
@@ -86,4 +86,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f      $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART  _rprt
@@ -111,4 +112,8 @@
 CPU_MEASURES      out:loc:tr   d3#     $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 #
 DATA_1D_PR_NETCDF    out:loc:tr   pr#:prf   $base_data/$fname/OUTPUT  _pr      nc
Index: /palm/trunk/SCRIPTS/.mrun.config.imuk_hlrnIII
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.imuk_hlrnIII	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.imuk_hlrnIII	(revision 1914)
@@ -135,4 +135,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f      $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART  _rprt
@@ -160,4 +161,8 @@
 CPU_MEASURES      out:loc:tr   d3#     $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 #
 DATA_1D_PR_NETCDF    out:loc:tr   pr#:prf   $base_data/$fname/OUTPUT  _pr      nc
Index: /palm/trunk/SCRIPTS/.mrun.config.imuk_hlrnIII_rrtmg
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.imuk_hlrnIII_rrtmg	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.imuk_hlrnIII_rrtmg	(revision 1914)
@@ -138,4 +138,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f      $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART  _rprt
@@ -163,4 +164,8 @@
 CPU_MEASURES      out:loc:tr   d3#     $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 #
 DATA_1D_PR_NETCDF    out:loc:tr   pr#:prf   $base_data/$fname/OUTPUT  _pr      nc
Index: /palm/trunk/SCRIPTS/.mrun.config.imuknb
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.imuknb	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.imuknb	(revision 1914)
@@ -83,4 +83,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f      $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART  _rprt
@@ -108,4 +109,8 @@
 CPU_MEASURES      out:loc:tr   d3#     $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 #
 DATA_1D_PR_NETCDF    out:loc:tr   pr#:prf   $base_data/$fname/OUTPUT  _pr     nc
Index: /palm/trunk/SCRIPTS/.mrun.config.kiaps
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.kiaps	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.kiaps	(revision 1914)
@@ -72,4 +72,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f      $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART  _rprt
@@ -97,4 +98,8 @@
 CPU_MEASURES      out:loc:tr   d3#     $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 #
 DATA_1D_PR_NETCDF    out:loc:tr   pr#:prf   $base_data/$fname/OUTPUT  _pr     nc
Index: /palm/trunk/SCRIPTS/.mrun.config.lcxe6
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.lcxe6	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.lcxe6	(revision 1914)
@@ -95,4 +95,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f      $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART  _rprt
@@ -120,4 +121,8 @@
 CPU_MEASURES      out:loc:tr   d3#     $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 #
 DATA_1D_PR_NETCDF    out:loc:tr   pr#:prf   $base_data/$fname/OUTPUT  _pr     nc
Index: /palm/trunk/SCRIPTS/.mrun.config.riam
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.riam	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.riam	(revision 1914)
@@ -81,4 +81,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f      $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART  _rprt
@@ -106,4 +107,8 @@
 CPU_MEASURES      out:loc:tr   d3#     $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 #
 DATA_1D_PR_NETCDF    out:loc:tr   pr#:prf   $base_data/$fname/OUTPUT  _pr     nc
Index: /palm/trunk/SCRIPTS/.mrun.config.tatara
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.tatara	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.tatara	(revision 1914)
@@ -70,4 +70,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f      $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf     $base_data/$fname/RESTART  _rprt
@@ -95,4 +96,8 @@
 CPU_MEASURES      out:loc:tr   d3#     $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 #
 DATA_1D_PR_NETCDF    out:loc:tr   pr#:prf   $base_data/$fname/OUTPUT  _pr     nc
Index: /palm/trunk/SCRIPTS/.mrun.config.yonsei2011
===================================================================
--- /palm/trunk/SCRIPTS/.mrun.config.yonsei2011	(revision 1913)
+++ /palm/trunk/SCRIPTS/.mrun.config.yonsei2011	(revision 1914)
@@ -83,4 +83,5 @@
 NUDGING_DATA             in:locopt     d3#:d3f  $base_data/$fname/INPUT    _nudge
 LSF_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _lsf
+WTM_DATA                 in:locopt     d3#:d3f  $base_data/$fname/INPUT    _wtm
 BININ                    in:loc:flpe   d3f:rec   $base_data/$fname/RESTART  _d3d
 PARTICLE_RESTART_DATA_IN in:loc:flpe   prtf  $base_data/$fname/RESTART  _rprt
@@ -108,4 +109,8 @@
 CPU_MEASURES      out:loc:tr   d3#:pcr $base_data/$fname/MONITORING  _cpu
 CPU_MEASURES      out:loc:tra  d3f     $base_data/$fname/MONITORING  _cpu
+TURBINE_PARAMETERS01  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters01
+TURBINE_PARAMETERS02  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters02
+TURBINE_PARAMETERS03  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters03
+TURBINE_PARAMETERS04  out:loc:tr  d3#:d3f   $base_data/$fname/MONITORING  _turbine_parameters04
 DVRP_LOG          out:loc:tr   dv#     $base_data/$fname/MONITORING  _dvrp_log
 DVRP_LOG          out:loc:tra  dvf     $base_data/$fname/MONITORING  _dvrp_log
Index: /palm/trunk/SCRIPTS/mrun
===================================================================
--- /palm/trunk/SCRIPTS/mrun	(revision 1913)
+++ /palm/trunk/SCRIPTS/mrun	(revision 1914)
@@ -918,5 +918,4 @@
 
 
-
        # PROVIDE VALUES OF ENVIRONMENT-VARIABLE FOR interpret_config VIA NAMELIST-FILE
     cat  >  .mrun_environment  <<  %%END%%
@@ -927,4 +926,5 @@
                     localhost = '$localhost', output_list = '$output_list' /
 
+
 %%END%%
 
@@ -958,5 +958,4 @@
     rm .mrun_environment
 
-
        # EXECUTE SHELL-COMMANDS GENERATED BY interpret_config WITHIN THIS SHELL
     chmod  u+x  $interpreted_config_file
@@ -966,5 +965,4 @@
 
  fi
-
 
     # VALUES OF MRUN-OPTIONS OVERWRITE THOSE FROM THE CONFIGURATION-FILE
Index: /palm/trunk/SCRIPTS/subjob
===================================================================
--- /palm/trunk/SCRIPTS/subjob	(revision 1913)
+++ /palm/trunk/SCRIPTS/subjob	(revision 1914)
@@ -907,7 +907,7 @@
     if [[ $numprocs != 0 ]]
     then
-      pe_set="#$ -pe impi $numprocs"
-    else
-      pe_set="#$ -pe impi 1"
+      pe_set="#$ -pe openmpi $numprocs"
+    else
+      pe_set="#$ -pe openmpi 1"
     fi
     if [[ $queue = default ]]
Index: /palm/trunk/SOURCE/Makefile
===================================================================
--- /palm/trunk/SOURCE/Makefile	(revision 1913)
+++ /palm/trunk/SOURCE/Makefile	(revision 1914)
@@ -56,4 +56,8 @@
 # Tails removed. lpm_release_set removed. calc_precipitation, impact_of_latent_heat
 # removed. 
+#
+# 1819 2016-04-06 21:05:15Z witha
+# Added wind turbine model and renamed it from wind_turbine_model to
+# wind_turbine_model_mod
 #
 # 1817 2016-04-06 15:44:20Z maronga
@@ -330,5 +334,5 @@
 	user_parin.f90 user_read_restart_data.f90 \
 	user_spectra.f90 user_statistics.f90 wall_fluxes.f90 \
-	write_3d_binary.f90 write_var_list.f90
+	wind_turbine_model_mod.f90 write_3d_binary.f90 write_var_list.f90
 
 
@@ -383,5 +387,5 @@
 check_parameters.o: modules.o mod_kinds.o land_surface_model_mod.o \
 	netcdf_interface_mod.o plant_canopy_model_mod.o pmc_interface_mod.o radiation_model_mod.o \
-	spectra_mod.o subsidence_mod.o microphysics_mod.o
+	spectra_mod.o subsidence_mod.o microphysics_mod.o wind_turbine_model_mod.o
 close_file.o: modules.o mod_kinds.o netcdf_interface_mod.o
 compute_vpt.o: modules.o mod_kinds.o
@@ -429,5 +433,6 @@
    lpm_init.o ls_forcing_mod.o netcdf_interface_mod.o plant_canopy_model_mod.o \
    radiation_model_mod.o random_function_mod.o random_generator_parallel_mod.o \
-   surface_layer_fluxes_mod.o microphysics_mod.o mod_particle_attributes.o
+   surface_layer_fluxes_mod.o microphysics_mod.o mod_particle_attributes.o \
+   wind_turbine_model_mod.o
 init_advec.o: modules.o mod_kinds.o
 init_cloud_physics.o: modules.o mod_kinds.o
@@ -486,5 +491,5 @@
 parin.o: modules.o cpulog_mod.o land_surface_model_mod.o mod_kinds.o netcdf_interface_mod.o \
    plant_canopy_model_mod.o pmc_interface_mod.o progress_bar_mod.o spectra_mod.o \
-   radiation_model_mod.o microphysics_mod.o
+   radiation_model_mod.o microphysics_mod.o wind_turbine_model_mod.o
 plant_canopy_model_mod.o: modules.o mod_kinds.o
 pmc_interface_mod.o: modules.o mod_kinds.o pmc_client_mod.o pmc_general_mod.o\
@@ -508,5 +513,5 @@
 	eqn_state_seawater.o mod_kinds.o microphysics_mod.o \
 	nudging_mod.o plant_canopy_model_mod.o production_e.o radiation_model_mod.o \
-	subsidence_mod.o user_actions.o
+	subsidence_mod.o user_actions.o wind_turbine_model_mod.o
 progress_bar_mod.o: modules.o mod_kinds.o
 radiation_model_mod.o : modules.o mod_particle_attributes.o microphysics_mod.o
@@ -536,5 +541,6 @@
 	ls_forcing_mod.o mod_kinds.o nudging_mod.o pmc_interface_mod.o production_e.o \
 	prognostic_equations.o progress_bar_mod.o radiation_model_mod.o \
-	spectra_mod.o user_actions.o surface_layer_fluxes_mod.o microphysics_mod.o
+	spectra_mod.o user_actions.o surface_layer_fluxes_mod.o microphysics_mod.o \
+        wind_turbine_model_mod.o
 time_to_string.o: mod_kinds.o
 timestep.o: modules.o cpulog_mod.o mod_kinds.o microphysics_mod.o
@@ -572,4 +578,5 @@
 user_statistics.o: modules.o mod_kinds.o netcdf_interface_mod.o user_module.o
 wall_fluxes.o: modules.o mod_kinds.o
+wind_turbine_model_mod.o: modules.o cpulog_mod.o mod_kinds.o
 write_3d_binary.o: modules.o cpulog_mod.o mod_kinds.o land_surface_model_mod.o \
 	radiation_model_mod.o random_function_mod.o random_generator_parallel_mod.o \
Index: /palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- /palm/trunk/SOURCE/check_parameters.f90	(revision 1913)
+++ /palm/trunk/SOURCE/check_parameters.f90	(revision 1914)
@@ -389,4 +389,6 @@
     USE statistics
     USE transpose_indices
+    USE wind_turbine_model_mod,                                                &
+        ONLY: wtm_check_parameters, wind_turbine
 
 
@@ -1057,6 +1059,10 @@
 
 !
+!-- If wind turbine model is used, perform additional checks
+    IF ( wind_turbine )  CALL wtm_check_parameters
+!
 !-- When radiation model is used, peform addtional checks
     IF ( radiation )  CALL radiation_check_parameters
+
 
     IF ( .NOT. ( loop_optimization == 'cache'  .OR.                            &
Index: /palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- /palm/trunk/SOURCE/init_3d_model.f90	(revision 1913)
+++ /palm/trunk/SOURCE/init_3d_model.f90	(revision 1914)
@@ -37,4 +37,7 @@
 ! nzb_2d replaced by nzb_u|v_inner
 ! 
+! 1839 2016-04-07 18:48:14Z witha
+! Renamed calls for wind turbine model
+!
 ! 1833 2016-04-07 14:23:03Z raasch
 ! initialization of spectra quantities moved to spectra_mod
@@ -50,4 +53,7 @@
 ! icloud_scheme replaced by microphysics_*
 !
+! 1819 2016-04-06 21:05:15Z witha
+! Added initialization of the wind turbine model
+! 
 ! 1817 2016-04-06 15:44:20Z maronga
 ! Renamed lsm calls.
@@ -331,4 +337,7 @@
    
     USE transpose_indices 
+
+    USE wind_turbine_model_mod,                                                &
+        ONLY:  wtm_init, wtm_init_arrays, wind_turbine
 
     IMPLICIT NONE
@@ -688,4 +697,10 @@
 
 !
+!-- Allocate wind turbine model arrays
+    IF ( wind_turbine )  THEN
+       CALL wtm_init_arrays
+    ENDIF
+
+!
 !-- Allocate arrays containing the RK coefficient for calculation of 
 !-- perturbation pressure and turbulent fluxes. At this point values are
@@ -1675,4 +1690,13 @@
        CALL location_message( 'finished', .TRUE. )
     ENDIF
+    
+!
+!-- If required, initialize quantities needed for the wind turbine model
+    IF ( wind_turbine )  THEN
+       CALL location_message( 'initializing wind turbine model', .FALSE. )
+       CALL wtm_init
+       CALL location_message( 'finished', .TRUE. )
+    ENDIF
+
 
 !
Index: /palm/trunk/SOURCE/package_parin.f90
===================================================================
--- /palm/trunk/SOURCE/package_parin.f90	(revision 1913)
+++ /palm/trunk/SOURCE/package_parin.f90	(revision 1914)
@@ -28,4 +28,7 @@
 ! Initialization of aerosols added.
 !
+! 1839 2016-04-07 18:48:14Z witha
+! Reading of &wind_turbine_par moved to wind_turbine_model_mod
+! 
 ! 1833 2016-04-07 14:23:03Z raasch
 ! reading of spectra_par moved to spectra_mod
@@ -41,4 +44,7 @@
 ! +collision_algorithm
 ! Tails removed.
+
+! 1819 2016-04-06 21:05:15Z witha
+! Added namelist for wind turbine model
 !
 ! 1817 2016-04-06 15:44:20Z maronga
Index: /palm/trunk/SOURCE/parin.f90
===================================================================
--- /palm/trunk/SOURCE/parin.f90	(revision 1913)
+++ /palm/trunk/SOURCE/parin.f90	(revision 1914)
@@ -27,4 +27,7 @@
 ! 1849 2016-04-08 11:33:18Z hoffmann
 ! Adapted for modularization of microphysics
+!
+! 1839 2016-04-07 18:48:14Z witha
+! Added call to wind turbine model for reading of &wind_turbine_par
 !
 ! 1833 2016-04-07 14:23:03Z raasch
@@ -259,4 +262,7 @@
     USE statistics,                                                            &
         ONLY:  hom, hom_sum, pr_palm, region, statistic_regions
+
+    USE wind_turbine_model_mod,                                                &
+        ONLY:  wtm_parin
 
 
@@ -504,4 +510,9 @@
 
 !
+!--       Check if wind turbine model is used and read &wind_turbine_par if
+!--       required
+          CALL wtm_parin
+
+!
 !--       Read user-defined variables
           CALL user_parin
Index: /palm/trunk/SOURCE/prognostic_equations.f90
===================================================================
--- /palm/trunk/SOURCE/prognostic_equations.f90	(revision 1913)
+++ /palm/trunk/SOURCE/prognostic_equations.f90	(revision 1914)
@@ -28,8 +28,6 @@
 ! Module renamed (removed _mod)
 ! 
-! 
 ! 1850 2016-04-08 13:29:27Z maronga
 ! Module renamed
-! 
 ! 
 ! 1826 2016-04-07 12:01:39Z maronga
@@ -38,4 +36,7 @@
 ! 1822 2016-04-07 07:49:42Z hoffmann
 ! Kessler microphysics scheme moved to microphysics.
+
+! 1819 2016-04-06 21:05:15Z witha
+! Added calls for wind turbine model
 !
 ! 1757 2016-02-22 15:49:32Z maronga
@@ -313,4 +314,7 @@
         ONLY:  user_actions
 
+    USE wind_turbine_model_mod,                                                &
+        ONLY:  wind_turbine, wtm_tendencies
+
 
     PRIVATE
@@ -428,4 +432,8 @@
              IF ( nudging )  CALL nudge( i, j, simulated_time, 'u' )
 
+!
+!--          Forces by wind turbines
+             IF ( wind_turbine )  CALL wtm_tendencies( i, j, 1 )
+
              CALL user_actions( i, j, 'u-tendency' )
 !
@@ -487,4 +495,8 @@
              IF ( nudging )  CALL nudge( i, j, simulated_time, 'v' )
 
+!
+!--          Forces by wind turbines
+             IF ( wind_turbine )  CALL wtm_tendencies( i, j, 2 )
+
              CALL user_actions( i, j, 'v-tendency' )
 !
@@ -543,4 +555,8 @@
 !--       Drag by plant canopy
           IF ( plant_canopy )  CALL pcm_tendency( i, j, 3 )
+
+!
+!--       Forces by wind turbines
+          IF ( wind_turbine )  CALL wtm_tendencies( i, j, 3 )
 
           CALL user_actions( i, j, 'w-tendency' )
@@ -1011,4 +1027,8 @@
     IF ( nudging )  CALL nudge( simulated_time, 'u' )
 
+!
+!-- Forces by wind turbines
+    IF ( wind_turbine )  CALL wtm_tendencies( 1 )
+
     CALL user_actions( 'u-tendency' )
 
@@ -1087,4 +1107,8 @@
     IF ( nudging )  CALL nudge( simulated_time, 'v' )
 
+!
+!-- Forces by wind turbines
+    IF ( wind_turbine )  CALL wtm_tendencies( 2 )
+
     CALL user_actions( 'v-tendency' )
 
@@ -1158,4 +1182,8 @@
 !-- Drag by plant canopy
     IF ( plant_canopy )  CALL pcm_tendency( 3 )
+
+!
+!-- Forces by wind turbines
+    IF ( wind_turbine )  CALL wtm_tendencies( 3 )
 
     CALL user_actions( 'w-tendency' )
@@ -1847,4 +1875,8 @@
     IF ( nudging )  CALL nudge( simulated_time, 'u' )
 
+!
+!-- Forces by wind turbines
+    IF ( wind_turbine )  CALL wtm_tendencies( 1 )
+
     CALL user_actions( 'u-tendency' )
 
@@ -1914,4 +1946,8 @@
     IF ( nudging )  CALL nudge( simulated_time, 'v' )
 
+!
+!-- Forces by wind turbines
+    IF ( wind_turbine )  CALL wtm_tendencies( 2 )
+
     CALL user_actions( 'v-tendency' )
 
@@ -1976,4 +2012,8 @@
 !-- Drag by plant canopy
     IF ( plant_canopy )  CALL pcm_tendency( 3 )
+
+!
+!-- Forces by wind turbines
+    IF ( wind_turbine )  CALL wtm_tendencies( 3 )
 
     CALL user_actions( 'w-tendency' )
Index: /palm/trunk/SOURCE/time_integration.f90
===================================================================
--- /palm/trunk/SOURCE/time_integration.f90	(revision 1913)
+++ /palm/trunk/SOURCE/time_integration.f90	(revision 1914)
@@ -42,4 +42,7 @@
 ! 1822 2016-04-07 07:49:42Z hoffmann
 ! icloud_scheme replaced by microphysics_*
+!
+! 1819 2016-04-06 21:05:15Z witha
+! Added call for wind turbine model and moved it
 !
 ! 1808 2016-04-05 19:44:00Z raasch
@@ -316,4 +319,7 @@
         ONLY:  user_actions
 
+    USE wind_turbine_model_mod,                                                &
+        ONLY:  wind_turbine, wtm_forces
+
     IMPLICIT NONE
 
@@ -405,4 +411,16 @@
        CALL user_actions( 'before_timestep' )
 
+!
+!--    Calculate forces by wind turbines
+       IF ( wind_turbine )  THEN
+
+          CALL cpu_log( log_point(55), 'wind_turbine', 'start' )
+
+          CALL wtm_forces
+
+          CALL cpu_log( log_point(55), 'wind_turbine', 'stop' )
+
+       ENDIF       
+       
 !
 !--    Start of intermediate step loop
Index: /palm/trunk/SOURCE/wind_turbine_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/wind_turbine_model_mod.f90	(revision 1914)
+++ /palm/trunk/SOURCE/wind_turbine_model_mod.f90	(revision 1914)
@@ -0,0 +1,2528 @@
+!> @file wind_turbine_model_mod.f90
+!------------------------------------------------------------------------------!
+! This file is part of PALM.
+!
+! PALM is free software: you can redistribute it and/or modify it under the terms
+! of the GNU General Public License as published by the Free Software Foundation,
+! either version 3 of the License, or (at your option) any later version.
+!
+! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
+! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along with
+! PALM. If not, see <http://www.gnu.org/licenses/>.
+!
+! Copyright 1997-2016 Leibniz Universitaet Hannover
+!------------------------------------------------------------------------------!
+!
+! Current revisions:
+! -----------------
+! 
+! 
+! Former revisions:
+! -----------------
+! $Id$
+!
+! 1912 2016-05-26 13:03:07Z witha
+! Added subroutine wtm_check_parameters
+! Renamed wtm_read_tables to wtm_read_blade_tables
+! Review of Pitch and Speed Control
+!
+! 1864 2016-04-14 17:23:11Z witha
+! Definition of PRIVATE and PUBLIC variables and functions
+! Relocation of some variables from module to the subroutines
+! Added subroutines wtm_speed_control and wtm_init_speed_control
+! Airfoil tables are now read from the input folder 
+!
+! 1843 2016-04-08 08:20:19Z witha
+! Bugfix and revision in reading mechanism
+! 
+! 1839 2016-04-07 18:48:14Z witha
+! Added subroutine for parin, renamed subroutines, witha
+! Added subroutine wtm_read_tables, changes on parin, lvo
+! 
+! 1820 2016-04-06 21:08:26Z witha
+! Initial revision
+! 
+!
+! Description:
+! ------------
+!> This module calculates the effect of wind turbines on the flow fields. The
+!> initial version contains only the advanced actuator disk with rotation method
+!> (ADM-R).
+!> The wind turbines include the tower effect, can be yawed and tilted.
+!> The wind turbine model includes controllers for rotational speed, pitch and
+!> yaw.
+!> Currently some specifications of the NREL 5 MW reference turbine
+!> are hardcoded whereas most input data comes from separate files (currently
+!> external, planned to be included as namelist which will be read in
+!> automatically).
+!>
+!> @todo Revise code according to PALM Coding Standard
+!> @todo Implement ADM and ALM turbine models
+!> @todo Generate header information
+!> @todo Implement parameter checks and error messages
+!> @todo Revise and add code documentation
+!> @todo Output turbine parameters as timeseries
+!> @todo Include additional output variables
+!> @todo Revise smearing the forces for turbines in yaw
+!> @todo Revise nacelle and tower parameterization
+!> @todo Allow different turbine types in one simulation
+!
+!------------------------------------------------------------------------------!
+ MODULE wind_turbine_model_mod
+
+    USE arrays_3d,                                                             &
+        ONLY:  dd2zu, tend, u, v, w, zu, zw
+
+    USE constants
+
+    USE control_parameters,                                                    &
+        ONLY:  dt_3d, dz, message_string, simulated_time
+
+    USE cpulog,                                                                &
+        ONLY:  cpu_log, log_point_s
+
+    USE grid_variables,                                                        &
+        ONLY:  ddx, dx, ddy, dy
+
+    USE indices,                                                               &
+        ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nz,   &
+               nzb, nzb_u_inner, nzb_v_inner, nzb_w_inner, nzt
+
+    USE kinds
+
+    USE pegrid
+
+
+    IMPLICIT NONE
+
+    PRIVATE
+
+    LOGICAL ::  wind_turbine=.FALSE.   !< switch for use of wind turbine model
+
+!
+!-- Variables specified in the namelist wind_turbine_par
+
+    INTEGER(iwp) ::  nairfoils = 8   !< number of airfoils of the used turbine model (for ADM-R and ALM)
+    INTEGER(iwp) ::  nturbines = 1   !< number of turbines
+
+    LOGICAL ::  pitch_control = .FALSE.   !< switch for use of pitch controller
+    LOGICAL ::  speed_control = .FALSE.   !< switch for use of speed controller
+    LOGICAL ::  yaw_control   = .FALSE.   !< switch for use of yaw controller
+
+    REAL(wp) ::  segment_length  = 1.0_wp          !< length of the segments, the rotor area is divided into
+                                                   !< (in tangential direction, as factor of MIN(dx,dy,dz))
+    REAL(wp) ::  segment_width   = 0.5_wp          !< width of the segments, the rotor area is divided into
+                                                   !< (in radial direction, as factor of MIN(dx,dy,dz))
+    REAL(wp) ::  time_turbine_on = 0.0_wp          !< time at which turbines are started
+    REAL(wp) ::  tilt            = 0.0_wp          !< vertical tilt of the rotor [degree] ( positive = backwards )
+
+    REAL(wp), DIMENSION(1:100) ::  dtow             = 0.0_wp  !< tower diameter [m]
+    REAL(wp), DIMENSION(1:100) ::  omega_rot        = 0.0_wp  !< inital or constant rotor speed [rad/s]
+    REAL(wp), DIMENSION(1:100) ::  phi_yaw          = 0.0_wp  !< yaw angle [degree] ( clockwise, 0 = facing west )
+    REAL(wp), DIMENSION(1:100) ::  pitch_add        = 0.0_wp  !< constant pitch angle
+    REAL(wp), DIMENSION(1:100) ::  rcx        = 9999999.9_wp  !< position of hub in x-direction
+    REAL(wp), DIMENSION(1:100) ::  rcy        = 9999999.9_wp  !< position of hub in y-direction
+    REAL(wp), DIMENSION(1:100) ::  rcz        = 9999999.9_wp  !< position of hub in z-direction
+    REAL(wp), DIMENSION(1:100) ::  rnac             = 0.0_wp  !< nacelle diameter [m]
+    REAL(wp), DIMENSION(1:100) ::  rr              = 63.0_wp  !< rotor radius [m]
+    REAL(wp), DIMENSION(1:100) ::  turb_cd_nacelle = 0.85_wp  !< drag coefficient for nacelle
+    REAL(wp), DIMENSION(1:100) ::  turb_cd_tower    = 1.2_wp  !< drag coefficient for tower
+
+!
+!-- Variables specified in the namelist for speed controller
+!-- Default values are from the NREL 5MW research turbine (Jonkman, 2008)
+
+    REAL(wp) ::  rated_power    = 5296610.0_wp    !< rated turbine power [W]
+    REAL(wp) ::  gear_ratio     = 97.0_wp         !< Gear ratio from rotor to generator
+    REAL(wp) ::  inertia_rot    = 34784179.0_wp   !< Inertia of the rotor [kg/m2]
+    REAL(wp) ::  inertia_gen    = 534.116_wp      !< Inertia of the generator [kg/m2]
+    REAL(wp) ::  gen_eff        = 0.944_wp        !< Electric efficiency of the generator
+    REAL(wp) ::  gear_eff       = 1.0_wp          !< Loss between rotor and generator
+    REAL(wp) ::  air_dens       = 1.225_wp        !< Air density to convert to W [kg/m3]
+    REAL(wp) ::  rated_genspeed = 121.6805_wp     !< Rated generator speed [rad/s]
+    REAL(wp) ::  max_torque_gen = 47402.91_wp     !< Maximum of the generator torque [Nm]
+    REAL(wp) ::  slope2         = 2.332287_wp     !< Slope constant for region 2
+    REAL(wp) ::  min_reg2       = 91.21091_wp     !< Lower generator speed boundary of region 2 [rad/s]
+    REAL(wp) ::  min_reg15      = 70.16224_wp     !< Lower generator speed boundary of region 1.5 [rad/s]
+    REAL(wp) ::  max_trq_rate   = 15000.0_wp      !< Max generator torque increase [Nm/s]
+    REAL(wp) ::  pitch_rate     = 8.0_wp          !< Max pitch rate [degree/s]
+
+
+!
+!-- Variables specified in the namelist for yaw control
+
+    REAL(wp) ::  yaw_speed = 0.005236_wp   !< speed of the yaw actuator [rad/s]
+    REAL(wp) ::  max_miss = 0.08726_wp     !< maximum tolerated yaw missalignment [rad]
+    REAL(wp) ::  min_miss = 0.008726_wp    !< minimum yaw missalignment for which the actuator stops [rad]
+
+!
+!-- Set flag for output files TURBINE_PARAMETERS
+    TYPE file_status
+       LOGICAL ::  opened, opened_before
+    END TYPE file_status
+    
+    TYPE(file_status), DIMENSION(500) :: openfile_turb_mod =                   &
+                                         file_status(.FALSE.,.FALSE.)
+
+!
+!-- Variables for initialization of the turbine model
+
+    INTEGER(iwp) ::  inot         !< turbine loop index (turbine id)
+    INTEGER(iwp) ::  nsegs_max    !< maximum number of segments (all turbines, required for allocation of arrays)
+    INTEGER(iwp) ::  nrings_max   !< maximum number of rings (all turbines, required for allocation of arrays)
+    INTEGER(iwp) ::  ring         !< ring loop index (ring number)
+    INTEGER(iwp) ::  rr_int       !<
+    INTEGER(iwp) ::  upper_end    !<
+
+    INTEGER(iwp), DIMENSION(1) ::  lct   !<
+
+    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  i_hub     !< index belonging to x-position of the turbine
+    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  i_smear   !< index defining the area for the smearing of the forces (x-direction)
+    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  j_hub     !< index belonging to y-position of the turbine
+    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  j_smear   !< index defining the area for the smearing of the forces (y-direction)
+    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  k_hub     !< index belonging to hub height
+    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  k_smear   !< index defining the area for the smearing of the forces (z-direction)
+    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  nrings    !< number of rings per turbine
+    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  nsegs_total !< total number of segments per turbine 
+
+    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nsegs   !< number of segments per ring and turbine
+
+!
+!-  parameters for the smearing from the rotor to the cartesian grid   
+    REAL(wp) ::  pol_a            !< parameter for the polynomial smearing fct
+    REAL(wp) ::  pol_b            !< parameter for the polynomial smearing fct
+    REAL(wp) ::  delta_t_factor   !< 
+    REAL(wp) ::  eps_factor       !<  
+    REAL(wp) ::  eps_min          !< 
+    REAL(wp) ::  eps_min2         !< 
+    REAL(wp) ::  sqrt_arg         !< 
+
+!
+!-- Variables for the calculation of lift and drag coefficients
+    REAL(wp), DIMENSION(:), ALLOCATABLE  ::  ard     !< 
+    REAL(wp), DIMENSION(:), ALLOCATABLE  ::  crd     !< 
+    REAL(wp), DIMENSION(:), ALLOCATABLE  ::  delta_r !< radial segment length
+    REAL(wp), DIMENSION(:), ALLOCATABLE  ::  lrd     !<
+    
+    REAL(wp) ::  accu_cl_cd_tab = 0.1_wp  !< Accuracy of the interpolation of 
+                                          !< the lift and drag coeff [deg] 
+
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE :: turb_cd_tab   !< table of the blade drag coefficient
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE :: turb_cl_tab   !< table of the blade lift coefficient
+
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  nac_cd_surf  !< 3d field of the tower drag coefficient 
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  tow_cd_surf  !< 3d field of the nacelle drag coefficient
+
+!
+!-- Variables for the calculation of the forces
+     
+    REAL(wp) ::  cur_r                       !< 
+    REAL(wp) ::  delta_t                     !<  tangential segment length
+    REAL(wp) ::  phi_rotor                   !< 
+    REAL(wp) ::  pre_factor                  !<  
+    REAL(wp) ::  torque_seg                  !< 
+    REAL(wp) ::  u_int_l                     !< 
+    REAL(wp) ::  u_int_u                     !< 
+    REAL(wp) ::  u_rot                       !< 
+    REAL(wp) ::  v_int_l                     !< 
+    REAL(wp) ::  v_int_u                     !< 
+    REAL(wp) ::  w_int_l                     !< 
+    REAL(wp) ::  w_int_u                     !<
+!
+!-  Tendencies from the nacelle and tower thrust
+    REAL(wp) ::  tend_nac_x = 0.0_wp  !< 
+    REAL(wp) ::  tend_tow_x = 0.0_wp  !< 
+    REAL(wp) ::  tend_nac_y = 0.0_wp  !< 
+    REAL(wp) ::  tend_tow_y = 0.0_wp  !<
+
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  alpha_attack !< 
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  chord        !< 
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  omega_gen    !< curr. generator speed
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  phi_rel      !< 
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  pitch_add_old!<
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  torque_total !<
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  thrust_rotor !<
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  turb_cl      !< 
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  turb_cd      !< 
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  vrel         !< 
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  vtheta       !< 
+
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  rbx, rby, rbz     !< coordinates of the blade elements
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  rotx, roty, rotz  !< normal vectors to the rotor coordinates
+
+!
+!-  Fields for the interpolation of velocities on the rotor grid
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  u_int       !< 
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  u_int_1_l   !< 
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  v_int       !< 
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  v_int_1_l   !< 
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  w_int       !< 
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  w_int_1_l   !< 
+    
+!
+!-  rotor tendencies on the segments 
+    REAL(wp), DIMENSION(:), ALLOCATABLE :: thrust_seg   !< 
+    REAL(wp), DIMENSION(:), ALLOCATABLE :: torque_seg_y !< 
+    REAL(wp), DIMENSION(:), ALLOCATABLE :: torque_seg_z !<    
+
+!
+!-  rotor tendencies on the rings
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  thrust_ring       !< 
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  torque_ring_y     !< 
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  torque_ring_z     !<
+    
+!
+!-  rotor tendencies on rotor grids for all turbines
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  thrust      !<
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  torque_y    !< 
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  torque_z    !< 
+
+!
+!-  rotor tendencies on coordinate grid
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  rot_tend_x  !< 
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  rot_tend_y  !< 
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  rot_tend_z  !< 
+!    
+!-  variables for the rotation of the rotor coordinates        
+    REAL(wp), DIMENSION(1:100,1:3,1:3) ::  rot_coord_trans  !< matrix for rotation of rotor coordinates
+    
+    REAL(wp), DIMENSION(1:3) ::  rot_eigen_rad   !< 
+    REAL(wp), DIMENSION(1:3) ::  rot_eigen_azi   !< 
+    REAL(wp), DIMENSION(1:3) ::  rot_eigen_nor   !< 
+    REAL(wp), DIMENSION(1:3) ::  re              !< 
+    REAL(wp), DIMENSION(1:3) ::  rea             !< 
+    REAL(wp), DIMENSION(1:3) ::  ren             !< 
+    REAL(wp), DIMENSION(1:3) ::  rote            !< 
+    REAL(wp), DIMENSION(1:3) ::  rota            !< 
+    REAL(wp), DIMENSION(1:3) ::  rotn            !< 
+
+!
+!-- Fixed variables for the speed controller
+
+    LOGICAL  ::  start_up = .TRUE.   !< 
+    
+    REAL(wp) ::  Fcorner             !< corner freq for the controller low pass filter
+    REAL(wp) ::  min_reg25           !< min region 2.5
+    REAL(wp) ::  om_rate             !< rotor speed change
+    REAL(wp) ::  slope15             !< slope in region 1.5
+    REAL(wp) ::  slope25             !< slope in region 2.5
+    REAL(wp) ::  trq_rate            !< torque change
+    REAL(wp) ::  vs_sysp             !< 
+    REAL(wp) ::  lp_coeff            !< coeff for the controller low pass filter 
+    
+    REAL(wp), DIMENSION(:), ALLOCATABLE :: omega_gen_old   !< last gen. speed
+    REAL(wp), DIMENSION(:), ALLOCATABLE :: omega_gen_f     !< filtered gen. sp
+    REAL(wp), DIMENSION(:), ALLOCATABLE :: omega_gen_f_old !< last filt. gen. sp
+    REAL(wp), DIMENSION(:), ALLOCATABLE :: torque_gen      !< generator torque
+    REAL(wp), DIMENSION(:), ALLOCATABLE :: torque_gen_old  !< last gen. torque
+
+    REAL(wp), DIMENSION(100) :: omega_rot_l = 0.0_wp !< local rot speed [rad/s]
+!
+!-- Fixed variables for the yaw controller
+
+    REAL(wp), DIMENSION(:)  , ALLOCATABLE ::  yawdir           !< direction to yaw
+    REAL(wp), DIMENSION(:)  , ALLOCATABLE ::  phi_yaw_l        !< local (cpu) yaw angle
+    REAL(wp), DIMENSION(:)  , ALLOCATABLE ::  wd30_l           !< local (cpu) long running avg of the wd
+    REAL(wp), DIMENSION(:)  , ALLOCATABLE ::  wd2_l            !< local (cpu) short running avg of the wd
+    REAL(wp), DIMENSION(:)  , ALLOCATABLE ::  wdir             !< wind direction at hub
+    REAL(wp), DIMENSION(:)  , ALLOCATABLE ::  u_inflow         !< wind speed at hub
+    REAL(wp), DIMENSION(:)  , ALLOCATABLE ::  wdir_l           !< 
+    REAL(wp), DIMENSION(:)  , ALLOCATABLE ::  u_inflow_l       !<
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  wd30             !<
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  wd2              !<
+    LOGICAL,  DIMENSION(1:100)            ::  doyaw = .FALSE.  !<
+    INTEGER(iwp)                          ::  WDLON            !<
+    INTEGER(iwp)                          ::  WDSHO            !<
+
+
+    SAVE
+
+
+    INTERFACE wtm_parin
+       MODULE PROCEDURE wtm_parin
+    END INTERFACE wtm_parin
+    
+    INTERFACE wtm_check_parameters
+       MODULE PROCEDURE wtm_check_parameters
+    END INTERFACE wtm_check_parameters
+        
+    INTERFACE wtm_init_arrays
+       MODULE PROCEDURE wtm_init_arrays
+    END INTERFACE wtm_init_arrays
+
+    INTERFACE wtm_init
+       MODULE PROCEDURE wtm_init
+    END INTERFACE wtm_init
+    
+    INTERFACE wtm_read_blade_tables
+       MODULE PROCEDURE wtm_read_blade_tables
+    END INTERFACE wtm_read_blade_tables
+           
+    INTERFACE wtm_forces
+       MODULE PROCEDURE wtm_forces
+       MODULE PROCEDURE wtm_yawcontrol
+    END INTERFACE wtm_forces
+    
+    INTERFACE wtm_rotate_rotor
+       MODULE PROCEDURE wtm_rotate_rotor
+    END INTERFACE wtm_rotate_rotor
+    
+    INTERFACE wtm_speed_control
+       MODULE PROCEDURE wtm_init_speed_control
+       MODULE PROCEDURE wtm_speed_control
+    END INTERFACE wtm_speed_control
+
+    INTERFACE wtm_tendencies
+       MODULE PROCEDURE wtm_tendencies
+       MODULE PROCEDURE wtm_tendencies_ij
+    END INTERFACE wtm_tendencies
+    
+    
+    PUBLIC wtm_check_parameters, wtm_forces, wtm_init, wtm_init_arrays,        &
+           wtm_parin, wtm_tendencies, wtm_tendencies_ij, wind_turbine 
+
+ CONTAINS
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Parin for &wind_turbine_par for wind turbine model
+!------------------------------------------------------------------------------!
+    SUBROUTINE wtm_parin
+
+
+       IMPLICIT NONE
+       
+       INTEGER(iwp) ::  ierrn       !<
+
+       CHARACTER (LEN=80) ::  line  !< dummy string that contains the current line of the parameter file 
+
+       NAMELIST /wind_turbine_par/   air_dens, dtow, gear_eff, gear_ratio,     &
+                                  gen_eff, inertia_gen, inertia_rot, max_miss, &
+                                  max_torque_gen, max_trq_rate, min_miss,      &
+                                  min_reg15, min_reg2, nairfoils, nturbines,   &
+                                  omega_rot, phi_yaw, pitch_add, pitch_control,&
+                                  rated_genspeed, rated_power, rcx, rcy, rcz,  &
+                                  rnac, rr, segment_length, segment_width,     &
+                                  slope2, speed_control, tilt, time_turbine_on,&
+                                  turb_cd_nacelle, turb_cd_tower,              &
+                                  yaw_control, yaw_speed
+
+!
+!--    Try to find wind turbine model package
+       REWIND ( 11 )
+       line = ' '
+       DO  WHILE ( INDEX( line, '&wind_turbine_par' ) == 0 )
+          READ ( 11, '(A)', END=10 )  line
+       ENDDO
+       BACKSPACE ( 11 )
+
+!
+!--    Read user-defined namelist
+       READ ( 11, wind_turbine_par, IOSTAT=ierrn )
+       
+       IF ( ierrn < 0 )  THEN
+          message_string = 'errors in \$wind_turbine_par'
+          CALL message( 'wtm_parin', 'PA0???', 1, 2, 0, 6, 0 )
+       ENDIF
+       
+!
+!--    Set flag that indicates that the wind turbine model is switched on
+       wind_turbine = .TRUE.
+
+ 10    CONTINUE   ! TBD Change from continue, mit ierrn machen
+
+
+    END SUBROUTINE wtm_parin
+
+    SUBROUTINE wtm_check_parameters
+
+    
+       IMPLICIT NONE
+    
+       IF ( ( .NOT.speed_control ) .AND. pitch_control )  THEN
+          message_string = 'pitch_control = .TRUE. requires '//                &
+                           'speed_control = .TRUE.'
+          CALL message( 'wtm_check_parameters', 'PA0???', 1, 2, 0, 6, 0 )
+       ENDIF
+       
+       IF ( ANY( omega_rot(1:nturbines) <= 0.0 ) )  THEN
+          message_string = 'omega_rot <= 0.0, Please set omega_rot to '     // &
+                           'a value larger than zero'
+          CALL message( 'wtm_check_parameters', 'PA0???', 1, 2, 0, 6, 0 )
+       ENDIF
+       
+       
+       IF ( ANY( rcx(1:nturbines) == 9999999.9_wp ) .OR.                       &
+            ANY( rcy(1:nturbines) == 9999999.9_wp ) .OR.                       &
+            ANY( rcz(1:nturbines) == 9999999.9_wp ) )  THEN
+          
+          message_string = 'rcx, rcy, rcz '                                 // &
+                           'have to be given for each turbine.'          
+          CALL message( 'wtm_check_parameters', 'PA0???', 1, 2, 0, 6, 0 )          
+          
+       ENDIF
+
+ 
+    END SUBROUTINE wtm_check_parameters 
+    
+                                        
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Allocate wind turbine model arrays
+!------------------------------------------------------------------------------!
+    SUBROUTINE wtm_init_arrays
+
+
+       IMPLICIT NONE
+
+       REAL(wp) ::  delta_r_factor   !< 
+       REAL(wp) ::  delta_r_init     !< 
+
+!
+!--    To be able to allocate arrays with dimension of rotor rings and segments,
+!--    the maximum possible numbers of rings and segments have to be calculated:
+
+       ALLOCATE( nrings(1:nturbines) )
+       ALLOCATE( delta_r(1:nturbines) )
+
+       nrings(:)  = 0
+       delta_r(:) = 0.0_wp
+
+!
+!--    Thickness (radial) of each ring and length (tangential) of each segment:
+       delta_r_factor = segment_width
+       delta_t_factor = segment_length
+       delta_r_init   = delta_r_factor * MIN( dx, dy, dz)
+       delta_t        = delta_t_factor * MIN( dx, dy, dz)
+
+       DO inot = 1, nturbines
+!
+!--       Determine number of rings:
+          nrings(inot) = NINT( rr(inot) / delta_r_init )
+
+          delta_r(inot) = rr(inot) / nrings(inot)
+
+       ENDDO
+
+       nrings_max = MAXVAL(nrings)
+
+       ALLOCATE( nsegs(1:nrings_max,1:nturbines) )
+       ALLOCATE( nsegs_total(1:nturbines) )
+
+       nsegs(:,:)     = 0
+       nsegs_total(:) = 0
+
+
+       DO inot = 1, nturbines
+          DO ring = 1, nrings(inot)
+!
+!--          Determine number of segments for each ring:
+             nsegs(ring,inot) = MAX( 8, CEILING( delta_r_factor * pi *         &
+                                                 ( 2.0_wp * ring - 1.0_wp ) /  &
+                                                 delta_t_factor ) )
+          ENDDO
+!
+!--       Total sum of all rotor segments:
+          nsegs_total(inot) = SUM( nsegs(:,inot) )
+
+       ENDDO
+
+!
+!--    Maximum number of segments per ring:
+       nsegs_max = MAXVAL(nsegs)
+
+!!
+!!--    TODO: Folgendes im Header ausgeben!
+!       IF ( myid == 0 )  THEN
+!          PRINT*, 'nrings(1) = ', nrings(1)
+!          PRINT*, '--------------------------------------------------'
+!          PRINT*, 'nsegs(:,1) = ', nsegs(:,1)
+!          PRINT*, '--------------------------------------------------'
+!          PRINT*, 'nrings_max = ', nrings_max
+!          PRINT*, 'nsegs_max = ', nsegs_max
+!          PRINT*, 'nsegs_total(1) = ', nsegs_total(1)
+!       ENDIF
+
+
+!
+!--    Allocate 1D arrays (dimension = number of turbines)
+       ALLOCATE( i_hub(1:nturbines) )
+       ALLOCATE( i_smear(1:nturbines) )
+       ALLOCATE( j_hub(1:nturbines) )
+       ALLOCATE( j_smear(1:nturbines) )
+       ALLOCATE( k_hub(1:nturbines) )
+       ALLOCATE( k_smear(1:nturbines) )
+       ALLOCATE( torque_total(1:nturbines) )
+       ALLOCATE( thrust_rotor(1:nturbines) )
+
+!
+!--    Allocation of the 1D arrays for speed pitch_control
+       ALLOCATE( omega_gen(1:nturbines) )
+       ALLOCATE( omega_gen_old(1:nturbines) )
+       ALLOCATE( omega_gen_f(1:nturbines) )
+       ALLOCATE( omega_gen_f_old(1:nturbines) )
+       ALLOCATE( pitch_add_old(1:nturbines) )
+       ALLOCATE( torque_gen(1:nturbines) )
+       ALLOCATE( torque_gen_old(1:nturbines) )
+
+!
+!--    Allocation of the 1D arrays for yaw control
+       ALLOCATE( yawdir(1:nturbines) )
+       ALLOCATE( u_inflow(1:nturbines) )
+       ALLOCATE( wdir(1:nturbines) )
+       ALLOCATE( u_inflow_l(1:nturbines) )
+       ALLOCATE( wdir_l(1:nturbines) )
+       ALLOCATE( phi_yaw_l(1:nturbines) )
+       
+!
+!--    Allocate 1D arrays (dimension = number of rotor segments)
+       ALLOCATE( alpha_attack(1:nsegs_max) )
+       ALLOCATE( chord(1:nsegs_max) )
+       ALLOCATE( phi_rel(1:nsegs_max) )
+       ALLOCATE( thrust_seg(1:nsegs_max) )
+       ALLOCATE( torque_seg_y(1:nsegs_max) )
+       ALLOCATE( torque_seg_z(1:nsegs_max) )
+       ALLOCATE( turb_cd(1:nsegs_max) )
+       ALLOCATE( turb_cl(1:nsegs_max) )
+       ALLOCATE( vrel(1:nsegs_max) )
+       ALLOCATE( vtheta(1:nsegs_max) )
+
+!
+!--    Allocate 2D arrays (dimension = number of rotor rings and segments)
+       ALLOCATE( rbx(1:nrings_max,1:nsegs_max) )
+       ALLOCATE( rby(1:nrings_max,1:nsegs_max) )
+       ALLOCATE( rbz(1:nrings_max,1:nsegs_max) )
+       ALLOCATE( thrust_ring(1:nrings_max,1:nsegs_max) )
+       ALLOCATE( torque_ring_y(1:nrings_max,1:nsegs_max) )
+       ALLOCATE( torque_ring_z(1:nrings_max,1:nsegs_max) )
+
+!
+!--    Allocate additional 2D arrays
+       ALLOCATE( rotx(1:nturbines,1:3) )
+       ALLOCATE( roty(1:nturbines,1:3) )
+       ALLOCATE( rotz(1:nturbines,1:3) )
+
+!
+!--    Allocate 3D arrays (dimension = number of grid points)
+       ALLOCATE( nac_cd_surf(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+       ALLOCATE( rot_tend_x(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+       ALLOCATE( rot_tend_y(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+       ALLOCATE( rot_tend_z(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+       ALLOCATE( thrust(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+       ALLOCATE( torque_y(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+       ALLOCATE( torque_z(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+       ALLOCATE( tow_cd_surf(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+
+!
+!--    Allocate additional 3D arrays
+       ALLOCATE( u_int(1:nturbines,1:nrings_max,1:nsegs_max) )
+       ALLOCATE( u_int_1_l(1:nturbines,1:nrings_max,1:nsegs_max) )
+       ALLOCATE( v_int(1:nturbines,1:nrings_max,1:nsegs_max) )
+       ALLOCATE( v_int_1_l(1:nturbines,1:nrings_max,1:nsegs_max) )
+       ALLOCATE( w_int(1:nturbines,1:nrings_max,1:nsegs_max) )
+       ALLOCATE( w_int_1_l(1:nturbines,1:nrings_max,1:nsegs_max) )
+
+!
+!--    All of the arrays are initialized with a value of zero:
+       i_hub(:)                 = 0
+       i_smear(:)               = 0
+       j_hub(:)                 = 0
+       j_smear(:)               = 0
+       k_hub(:)                 = 0
+       k_smear(:)               = 0
+       
+       torque_total(:)          = 0.0_wp
+       thrust_rotor(:)          = 0.0_wp
+
+       omega_gen(:)             = 0.0_wp
+       omega_gen_old(:)         = 0.0_wp
+       omega_gen_f(:)           = 0.0_wp
+       omega_gen_f_old(:)       = 0.0_wp
+       pitch_add_old(:)         = 0.0_wp
+       torque_gen(:)            = 0.0_wp
+       torque_gen_old(:)        = 0.0_wp
+       
+       yawdir(:)                = 0.0_wp
+       wdir(:)                  = 0.0_wp
+       u_inflow(:)              = 0.0_wp
+
+!
+!--    Allocate 1D arrays (dimension = number of rotor segments)
+       alpha_attack(:)          = 0.0_wp
+       chord(:)                 = 0.0_wp
+       phi_rel(:)               = 0.0_wp
+       thrust_seg(:)            = 0.0_wp
+       torque_seg_y(:)          = 0.0_wp
+       torque_seg_z(:)          = 0.0_wp
+       turb_cd(:)               = 0.0_wp
+       turb_cl(:)               = 0.0_wp
+       vrel(:)                  = 0.0_wp
+       vtheta(:)                = 0.0_wp
+
+       rbx(:,:)                 = 0.0_wp
+       rby(:,:)                 = 0.0_wp
+       rbz(:,:)                 = 0.0_wp
+       thrust_ring(:,:)         = 0.0_wp
+       torque_ring_y(:,:)       = 0.0_wp
+       torque_ring_z(:,:)       = 0.0_wp
+
+       rotx(:,:)                = 0.0_wp
+       roty(:,:)                = 0.0_wp
+       rotz(:,:)                = 0.0_wp
+       turb_cl_tab(:,:)         = 0.0_wp
+       turb_cd_tab(:,:)         = 0.0_wp
+
+       nac_cd_surf(:,:,:)       = 0.0_wp
+       rot_tend_x(:,:,:)        = 0.0_wp
+       rot_tend_y(:,:,:)        = 0.0_wp
+       rot_tend_z(:,:,:)        = 0.0_wp
+       thrust(:,:,:)            = 0.0_wp
+       torque_y(:,:,:)          = 0.0_wp
+       torque_z(:,:,:)          = 0.0_wp
+       tow_cd_surf(:,:,:)       = 0.0_wp
+
+       u_int(:,:,:)             = 0.0_wp
+       u_int_1_l(:,:,:)         = 0.0_wp
+       v_int(:,:,:)             = 0.0_wp
+       v_int_1_l(:,:,:)         = 0.0_wp
+       w_int(:,:,:)             = 0.0_wp
+       w_int_1_l(:,:,:)         = 0.0_wp
+
+
+    END SUBROUTINE wtm_init_arrays
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Initialization of the wind turbine model
+!------------------------------------------------------------------------------!
+    SUBROUTINE wtm_init
+
+    
+       IMPLICIT NONE
+
+       INTEGER(iwp) ::  i  !< running index
+       INTEGER(iwp) ::  j  !< running index
+       INTEGER(iwp) ::  k  !< running index
+       
+!
+!--    Help variables for the smearing function       
+       REAL(wp) ::  eps_kernel       !<       
+       
+!
+!--    Help variables for calculation of the tower drag       
+       INTEGER(iwp) ::  tower_n      !<
+       INTEGER(iwp) ::  tower_s      !<
+!
+!--    Help variables for the calulaction of the nacelle drag
+       INTEGER(iwp) ::  i_ip         !<
+       INTEGER(iwp) ::  i_ipg        !<
+       
+       REAL(wp) ::  yvalue               
+       REAL(wp) ::  dy_int           !< 
+       REAL(wp) ::  dz_int           !<
+       
+       REAL(wp), DIMENSION(:,:), ALLOCATABLE :: circle_points  !<
+              
+       INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: index_nacb       !< 
+       INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: index_nacl       !< 
+       INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: index_nacr       !< 
+       INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: index_nact       !< 
+       
+       ALLOCATE( index_nacb(1:nturbines) )
+       ALLOCATE( index_nacl(1:nturbines) )
+       ALLOCATE( index_nacr(1:nturbines) )
+       ALLOCATE( index_nact(1:nturbines) )
+
+
+       IF ( speed_control)  THEN
+       
+          CALL wtm_speed_control
+
+       ENDIF
+
+!
+!------------------------------------------------------------------------------!
+!--    Calculation of parameters for the regularization kernel
+!--    (smearing of the forces)
+!------------------------------------------------------------------------------!
+!
+!--    In the following, some of the required parameters for the smearing will
+!--    be calculated:
+
+!--    The kernel is set equal to twice the grid spacing which has turned out to
+!--    be a reasonable value (see e.g. Troldborg et al. (2013), Wind Energy,
+!--    DOI: 10.1002/we.1608):
+       eps_kernel = 2.0_wp * dx
+!
+!--    The zero point (eps_min) of the polynomial function must be the following
+!--    if the integral of the polynomial function (for values < eps_min) shall
+!--    be equal to the integral of the Gaussian function used before:
+       eps_min = ( 105.0_wp / 32.0_wp )**( 1.0_wp / 3.0_wp ) *                 &
+                 pi**( 1.0_wp / 6.0_wp ) * eps_kernel
+!
+!--    Square of eps_min:
+       eps_min2 = eps_min**2
+!
+!--    Parameters in the polynomial function:
+       pol_a = 1.0_wp / eps_min**4
+       pol_b = 2.0_wp / eps_min**2
+!
+!--    Normalization factor which is the inverse of the integral of the smearing
+!--    function:
+       eps_factor = 105.0_wp / ( 32.0_wp * pi * eps_min**3 )
+       
+!--    Change tilt angle to rad:
+       tilt = tilt * pi / 180.0_wp
+      
+!
+!--    Change yaw angle to rad:
+       phi_yaw(:) = phi_yaw(:) * pi / 180.0_wp
+
+
+       DO inot = 1, nturbines
+!
+!--       Rotate the rotor coordinates in case yaw and tilt are defined
+          CALL wtm_rotate_rotor( inot )
+          
+!
+!--       Determine the indices of the hub height
+          i_hub(inot) = INT(   rcx(inot)                 / dx )
+          j_hub(inot) = INT( ( rcy(inot) + 0.5_wp * dy ) / dy )
+          k_hub(inot) = INT( ( rcz(inot) + 0.5_wp * dz ) / dz )
+
+!
+!--       Determining the area to which the smearing of the forces is applied.
+!--       As smearing now is effectively applied only for distances smaller than
+!--       eps_min, the smearing area can be further limited and regarded as a
+!--       function of eps_min:
+          i_smear(inot) = CEILING( ( rr(inot) + eps_min ) / dx )
+          j_smear(inot) = CEILING( ( rr(inot) + eps_min ) / dy )
+          k_smear(inot) = CEILING( ( rr(inot) + eps_min ) / dz )
+       
+       ENDDO
+
+!
+!------------------------------------------------------------------------------!
+!--    Determine the area within each grid cell that overlaps with the area
+!--    of the nacelle and the tower (needed for calculation of the forces)
+!------------------------------------------------------------------------------!
+!
+!--    Note: so far this is only a 2D version, in that the mean flow is
+!--    perpendicular to the rotor area.
+
+!
+!--    Allocation of the array containing information on the intersection points
+!--    between rotor disk and the numerical grid:
+       upper_end = ( ny + 1 ) * 10000 
+
+       ALLOCATE( circle_points(1:2,1:upper_end) )
+       
+       circle_points(:,:) = 0.0_wp
+
+       
+       DO inot = 1, nturbines                     ! loop over number of turbines
+!
+!--       Determine the grid index (u-grid) that corresponds to the location of
+!--       the rotor center (reduces the amount of calculations in the case that
+!--       the mean flow is perpendicular to the rotor area):
+          i = i_hub(inot)
+
+!
+!--       Determine the left and the right edge of the nacelle (corresponding
+!--       grid point indices):
+          index_nacl(inot) = INT( ( rcy(inot) - rnac(inot) + 0.5_wp * dy ) / dy )
+          index_nacr(inot) = INT( ( rcy(inot) + rnac(inot) + 0.5_wp * dy ) / dy )
+!
+!--       Determine the bottom and the top edge of the nacelle (corresponding
+!--       grid point indices).The grid point index has to be increased by 1, as
+!--       the first level for the u-component (index 0) is situated below the
+!--       surface. All points between z=0 and z=dz/s would already be contained
+!--       in grid box 1.
+          index_nacb(inot) = INT( ( rcz(inot) - rnac(inot) ) / dz ) + 1
+          index_nact(inot) = INT( ( rcz(inot) + rnac(inot) ) / dz ) + 1
+
+!
+!--       Determine the indices of the grid boxes containing the left and 
+!--       the right boundaries of the tower:
+          tower_n = ( rcy(inot) + 0.5_wp * dtow(inot) - 0.5_wp * dy ) / dy
+          tower_s = ( rcy(inot) - 0.5_wp * dtow(inot) - 0.5_wp * dy ) / dy
+
+!
+!--       Determine the fraction of the grid box area overlapping with the tower
+!--       area and multiply it with the drag of the tower:
+          IF ( ( nxlg <= i )  .AND.  ( nxrg >= i ) )  THEN
+
+             DO  j = nys, nyn
+!
+!--             Loop from south to north boundary of tower
+                IF ( ( j >= tower_s )  .AND.  ( j <= tower_n ) )  THEN
+
+                   DO  k = nzb, nzt
+
+                      IF ( k == k_hub(inot) )  THEN
+                         IF ( tower_n - tower_s >= 1 )  THEN
+!
+!--                      leftmost and rightmost grid box:
+                            IF ( j == tower_s )  THEN
+                               tow_cd_surf(k,j,i) = ( rcz(inot) -              &
+                                    ( k_hub(inot) * dz - 0.5_wp * dz ) )  *    & ! extension in z-direction
+                                  ( ( tower_s + 1.0_wp + 0.5_wp ) * dy    -    &
+                                    ( rcy(inot) - 0.5_wp * dtow(inot) ) ) *    & ! extension in y-direction
+                                  turb_cd_tower(inot)
+                            ELSEIF ( j == tower_n )  THEN
+                               tow_cd_surf(k,j,i) = ( rcz(inot)            -   &
+                                    ( k_hub(inot) * dz - 0.5_wp * dz ) )  *    & ! extension in z-direction
+                                  ( ( rcy(inot) + 0.5_wp * dtow(inot) )   -    &
+                                    ( tower_n + 0.5_wp ) * dy )           *    & ! extension in y-direction
+                                  turb_cd_tower(inot)
+!
+!--                         grid boxes inbetween
+!--                         (where tow_cd_surf = grid box area):
+                            ELSE
+                               tow_cd_surf(k,j,i) = ( rcz(inot) -              &
+                                    ( k_hub(inot) * dz - 0.5_wp * dz ) )  *    &
+                                    dy * turb_cd_tower(inot)
+                            ENDIF
+!
+!--                      tower lies completely within one grid box:
+                         ELSE
+                            tow_cd_surf(k,j,i) = ( rcz(inot)                 - &
+                                       ( k_hub(inot) * dz - 0.5_wp * dz ) ) *  &
+                                       dtow(inot) * turb_cd_tower(inot)
+                         ENDIF
+!
+!--                  In case that k is smaller than k_hub the following actions
+!--                  are carried out:
+                      ELSEIF ( k < k_hub(inot) )  THEN
+                      
+                         IF ( ( tower_n - tower_s ) >= 1 )  THEN
+!
+!--                         leftmost and rightmost grid box:
+                            IF ( j == tower_s )  THEN                         
+                               tow_cd_surf(k,j,i) = dz * (                     &
+                                      ( tower_s + 1 + 0.5_wp ) * dy         -  &
+                                      ( rcy(inot) - 0.5_wp * dtow(inot) )      &
+                                                        ) * turb_cd_tower(inot)
+                            ELSEIF ( j == tower_n )  THEN
+                               tow_cd_surf(k,j,i) = dz * (                     &
+                                      ( rcy(inot) + 0.5_wp * dtow(inot) )   -  &
+                                      ( tower_n + 0.5_wp ) * dy                &
+                                                         ) * turb_cd_tower(inot)
+!
+!--                         grid boxes inbetween
+!--                         (where tow_cd_surf = grid box area):
+                            ELSE
+                               tow_cd_surf(k,j,i) = dz * dy * turb_cd_tower(inot)
+                            ENDIF
+!
+!--                         tower lies completely within one grid box:
+                         ELSE
+                            tow_cd_surf(k,j,i) = dz * dtow(inot) *             &
+                                                turb_cd_tower(inot)
+                         ENDIF ! end if larger than grid box
+
+                      ENDIF    ! end if k == k_hub
+
+                   ENDDO       ! end loop over k
+
+                ENDIF          ! end if inside north and south boundary of tower
+
+             ENDDO             ! end loop over j
+
+          ENDIF                ! end if hub inside domain + ghostpoints
+       
+          
+          CALL exchange_horiz( tow_cd_surf, nbgp )
+
+!
+!--       Calculation of the nacelle area
+!--       CAUTION: Currently disabled due to segmentation faults on the FLOW HPC
+!--                cluster (Oldenburg)
+!!
+!!--       Tabulate the points on the circle that are required in the following for
+!!--       the calculation of the Riemann integral (node points; they are called
+!!--       circle_points in the following):
+!
+!          dy_int = dy / 10000.0_wp
+!
+!          DO  i_ip = 1, upper_end
+!             yvalue   = dy_int * ( i_ip - 0.5_wp ) + 0.5_wp * dy           !<--- segmentation fault
+!             sqrt_arg = rnac(inot)**2 - ( yvalue - rcy(inot) )**2          !<--- segmentation fault
+!             IF ( sqrt_arg >= 0.0_wp )  THEN
+!!
+!!--             bottom intersection point
+!                circle_points(1,i_ip) = rcz(inot) - SQRT( sqrt_arg )
+!!
+!!--             top intersection point
+!                circle_points(2,i_ip) = rcz(inot) + SQRT( sqrt_arg )       !<--- segmentation fault
+!             ELSE
+!                circle_points(:,i_ip) = -111111                            !<--- segmentation fault
+!             ENDIF
+!          ENDDO
+!
+!
+!          DO  j = nys, nyn
+!!
+!!--          In case that the grid box is located completely outside the nacelle
+!!--          (y) it can automatically be stated that there is no overlap between
+!!--          the grid box and the nacelle and consequently we can set
+!!--          nac_cd_surf(:,j,i) = 0.0:
+!             IF ( ( j >= index_nacl(inot) )  .AND.  ( j <= index_nacr(inot) ) )  THEN
+!                DO  k = nzb+1, nzt
+!!
+!!--                In case that the grid box is located completely outside the
+!!--                nacelle (z) it can automatically be stated that there is no
+!!--                overlap between the grid box and the nacelle and consequently
+!!--                we can set nac_cd_surf(k,j,i) = 0.0:
+!                   IF ( ( k >= index_nacb(inot) )  .OR.                           &
+!                        ( k <= index_nact(inot) ) )  THEN
+!!
+!!--                   For all other cases Riemann integrals are calculated.
+!!--                   Here, the points on the circle that have been determined
+!!--                   above are used in order to calculate the overlap between the
+!!--                   gridbox and the nacelle area (area approached by 10000
+!!--                   rectangulars dz_int * dy_int):
+!                      DO  i_ipg = 1, 10000
+!                         dz_int = dz
+!                         i_ip = j * 10000 + i_ipg
+!!
+!!--                      Determine the vertical extension dz_int of the circle
+!!--                      within the current grid box:
+!                         IF ( ( circle_points(2,i_ip) < zw(k) ) .AND.          &  !<--- segmentation fault
+!                              ( circle_points(2,i_ip) >= zw(k-1) ) ) THEN
+!                            dz_int = dz_int -                                  &  !<--- segmentation fault
+!                                     ( zw(k) - circle_points(2,i_ip) )
+!                         ENDIF
+!                         IF ( ( circle_points(1,i_ip) <= zw(k) ) .AND.         &  !<--- segmentation fault
+!                              ( circle_points(1,i_ip) > zw(k-1) ) ) THEN
+!                            dz_int = dz_int -                                  &
+!                                     ( circle_points(1,i_ip) - zw(k-1) )
+!                         ENDIF
+!                         IF ( zw(k-1) > circle_points(2,i_ip) ) THEN
+!                            dz_int = 0.0_wp
+!                         ENDIF
+!                         IF ( zw(k) < circle_points(1,i_ip) ) THEN
+!                            dz_int = 0.0_wp                      
+!                         ENDIF 
+!                         IF ( ( nxlg <= i ) .AND. ( nxrg >= i ) ) THEN
+!                            nac_cd_surf(k,j,i) = nac_cd_surf(k,j,i) +        &  !<--- segmentation fault
+!                                                  dy_int * dz_int * turb_cd_nacelle(inot)
+!                         ENDIF   
+!                      ENDDO
+!                   ENDIF
+!                ENDDO
+!             ENDIF
+! 
+!          ENDDO
+!        
+!          CALL exchange_horiz( nac_cd_surf, nbgp )                                !<---  segmentation fault
+
+       ENDDO   ! end of loop over turbines
+
+       tow_cd_surf   = tow_cd_surf   / ( dx * dy * dz )      ! Normalize tower drag
+       nac_cd_surf = nac_cd_surf / ( dx * dy * dz )      ! Normalize nacelle drag
+
+       CALL wtm_read_blade_tables
+ 
+    END SUBROUTINE wtm_init
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Read in layout of the rotor blade , the lift and drag tables
+!> and the distribution of lift and drag tables along the blade
+!------------------------------------------------------------------------------!
+!
+    SUBROUTINE wtm_read_blade_tables
+
+
+       IMPLICIT NONE
+
+       INTEGER(iwp) ::  ii   !< running index
+       INTEGER(iwp) ::  jj   !< running index
+    
+       INTEGER(iwp) ::  ierrn       !<
+    
+       CHARACTER(200) :: chmess     !< Read in string 
+
+       INTEGER(iwp) ::  dlen        !< no. rows of local table 
+       INTEGER(iwp) ::  dlenbl      !< no. rows of cd, cl table
+       INTEGER(iwp) ::  ialpha      !< table position of current alpha value
+       INTEGER(iwp) ::  iialpha     !< 
+       INTEGER(iwp) ::  iir         !< 
+       INTEGER(iwp) ::  radres      !< radial resolution
+       INTEGER(iwp) ::  t1          !< no. of airfoil
+       INTEGER(iwp) ::  t2          !< no. of airfoil
+       INTEGER(iwp) ::  trow        !< 
+       INTEGER(iwp) ::  dlenbl_int  !< no. rows of interpolated cd, cl tables
+    
+       REAL(wp) :: alpha_attack_i   !<
+       REAL(wp) :: weight_a         !< 
+       REAL(wp) :: weight_b         !< 
+
+       INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: ttoint1    !<
+       INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: ttoint2    !<
+    
+       REAL(wp), DIMENSION(:), ALLOCATABLE :: turb_cd_sel1   !< 
+       REAL(wp), DIMENSION(:), ALLOCATABLE :: turb_cd_sel2   !<
+       REAL(wp), DIMENSION(:), ALLOCATABLE :: turb_cl_sel1   !< 
+       REAL(wp), DIMENSION(:), ALLOCATABLE :: turb_cl_sel2   !<
+       REAL(wp), DIMENSION(:), ALLOCATABLE :: read_cl_cd     !< read in var array
+              
+       REAL(wp), DIMENSION(:), ALLOCATABLE    :: alpha_attack_tab   !< 
+       REAL(wp), DIMENSION(:), ALLOCATABLE    :: trad1              !< 
+       REAL(wp), DIMENSION(:), ALLOCATABLE    :: trad2              !<          
+       REAL(wp), DIMENSION(:,:), ALLOCATABLE  :: turb_cd_table      !<
+       REAL(wp), DIMENSION(:,:), ALLOCATABLE  :: turb_cl_table      !<
+                                          
+       ALLOCATE ( read_cl_cd(1:2*nairfoils+1) )
+
+!
+!--    Read in the distribution of lift and drag tables along the blade, the
+!--    layout of the rotor blade and the lift and drag tables:
+
+       OPEN ( 201, FILE='WTM_DATA', STATUS='OLD', FORM='FORMATTED', IOSTAT=ierrn )
+
+       IF ( ierrn /= 0 )  THEN
+          message_string = 'file WTM_DATA does not exist'
+          CALL message( 'wtm_init', 'PA0???', 1, 2, 0, 6, 0 )
+       ENDIF
+!
+!--    Read distribution table:
+
+       dlen = 0
+
+       READ ( 201, '(3/)' )
+
+       rloop3: DO
+          READ ( 201, *, IOSTAT=ierrn ) chmess
+          IF ( ierrn < 0  .OR.  chmess == '#'  .OR.  chmess == '')  EXIT rloop3
+          dlen = dlen + 1
+       ENDDO rloop3
+
+       ALLOCATE( trad1(1:dlen), trad2(1:dlen), ttoint1(1:dlen), ttoint2(1:dlen))
+
+       DO jj = 1,dlen+1
+          BACKSPACE ( 201, IOSTAT=ierrn )
+       ENDDO
+
+       DO jj = 1,dlen
+          READ ( 201, * ) trad1(jj), trad2(jj), ttoint1(jj), ttoint2(jj)
+       ENDDO
+
+!
+!--    Read layout table:
+
+       dlen = 0 
+
+       READ ( 201, '(3/)')
+
+       rloop1: DO
+          READ ( 201, *, IOSTAT=ierrn ) chmess
+          IF ( ierrn < 0  .OR.  chmess == '#'  .OR.  chmess == '')  EXIT rloop1
+          dlen = dlen + 1
+       ENDDO rloop1
+
+       ALLOCATE( lrd(1:dlen), ard(1:dlen), crd(1:dlen) )
+       DO jj = 1, dlen+1
+          BACKSPACE ( 201, IOSTAT=ierrn )
+       ENDDO             
+       DO jj = 1, dlen
+          READ ( 201, * ) lrd(jj), ard(jj), crd(jj) 
+       ENDDO
+
+!
+!--    Read tables (turb_cl(alpha),turb_cd(alpha) for the different profiles:
+
+       dlen = 0
+
+       READ ( 201, '(3/)' )
+
+       rloop2: DO
+          READ ( 201, *, IOSTAT=ierrn ) chmess
+          IF ( ierrn < 0  .OR.  chmess == '#'  .OR.  chmess == '')  EXIT rloop2
+          dlen = dlen + 1
+       ENDDO rloop2 
+
+       ALLOCATE( alpha_attack_tab(1:dlen), turb_cl_table(1:dlen,1:nairfoils),  &
+                 turb_cd_table(1:dlen,1:nairfoils) )
+
+       DO jj = 1,dlen+1
+          BACKSPACE ( 201, IOSTAT=ierrn )
+       ENDDO 
+
+       DO jj = 1,dlen
+          READ ( 201, * ) read_cl_cd
+          alpha_attack_tab(jj) = read_cl_cd(1)
+          DO ii= 1, nairfoils
+             turb_cl_table(jj,ii) = read_cl_cd(ii*2)
+             turb_cd_table(jj,ii) = read_cl_cd(ii*2+1)
+          ENDDO
+
+       ENDDO
+
+       dlenbl = dlen 
+
+       CLOSE ( 201 )
+
+!
+!--    For each possible radial position (resolution: 0.1 m --> 630 values) and
+!--    each possible angle of attack (resolution: 0.01 degrees --> 36000 values!)
+!--    determine the lift and drag coefficient by interpolating between the
+!--    tabulated values of each table (interpolate to current angle of attack)
+!--    and between the tables (interpolate to current radial position):
+
+       ALLOCATE( turb_cl_sel1(0:dlenbl) )  
+       ALLOCATE( turb_cl_sel2(0:dlenbl) )  
+       ALLOCATE( turb_cd_sel1(0:dlenbl) )
+       ALLOCATE( turb_cd_sel2(0:dlenbl) )
+
+       radres     = INT( rr(1) * 10.0_wp ) + 1_iwp
+       dlenbl_int = INT( 360.0_wp / accu_cl_cd_tab ) + 1_iwp
+
+
+       ALLOCATE( turb_cl_tab(0:dlenbl_int,1:radres) )
+       ALLOCATE( turb_cd_tab(0:dlenbl_int,1:radres) )
+
+
+       DO iir = 1, radres ! loop over radius
+
+          DO iialpha = 1, dlenbl_int  ! loop over angles
+
+             cur_r = ( iir - 1_iwp ) * 0.1_wp             
+             alpha_attack_i = -180.0_wp + REAL( iialpha-1 ) * accu_cl_cd_tab
+             ialpha = 1
+
+             DO WHILE ( alpha_attack_i > alpha_attack_tab(ialpha) )
+                ialpha = ialpha + 1
+             ENDDO
+!
+!--          Find position in table
+             lct = MINLOC( ABS( trad1 - cur_r ) )
+!                lct(1) = lct(1)
+
+             IF ( ( trad1(lct(1)) - cur_r ) .GT. 0.0 )  THEN
+                lct(1) = lct(1) - 1
+             ENDIF
+
+             trow = lct(1)
+!
+!--          Calculate weights for interpolation
+             weight_a = ( trad2(trow) - cur_r ) / ( trad2(trow) - trad1(trow) )
+             weight_b = ( cur_r - trad1(trow) ) / ( trad2(trow) - trad1(trow) )
+             t1 = ttoint1(trow)
+             t2 = ttoint2(trow)
+
+             IF ( t1 .EQ. t2 ) THEN  ! if both are the same, the weights are NaN
+                weight_a = 0.5_wp    ! then do interpolate in between same twice
+                weight_b = 0.5_wp    ! using 0.5 as weight
+             ENDIF
+
+             IF ( t1 == 0 .AND. t2 == 0 ) THEN
+                turb_cd_sel1 = 0.0_wp
+                turb_cd_sel2 = 0.0_wp
+                turb_cl_sel1 = 0.0_wp
+                turb_cl_sel2 = 0.0_wp
+             ELSE
+                turb_cd_sel1 = turb_cd_table(:,t1)
+                turb_cd_sel2 = turb_cd_table(:,t2)
+                turb_cl_sel1 = turb_cl_table(:,t1)
+                turb_cl_sel2 = turb_cl_table(:,t2)
+             ENDIF
+
+!
+!--          Interpolation of lift and drag coefficiencts on fine grid of radius 
+!--          segments and angles of attack
+
+             turb_cl_tab(iialpha,iir) = ( alpha_attack_tab(ialpha) -           &
+                                          alpha_attack_i ) /                   &
+                                        ( alpha_attack_tab(ialpha) -           &
+                                          alpha_attack_tab(ialpha-1) ) *       &
+                                        ( weight_a * turb_cl_sel1(ialpha-1) +  &
+                                          weight_b * turb_cl_sel2(ialpha-1) ) +&
+                                        ( alpha_attack_i             -         &
+                                          alpha_attack_tab(ialpha-1) ) /       &
+                                        ( alpha_attack_tab(ialpha) -           &
+                                          alpha_attack_tab(ialpha-1) ) *       &
+                                        ( weight_a * turb_cl_sel1(ialpha) +    &
+                                          weight_b * turb_cl_sel2(ialpha) )
+             turb_cd_tab(iialpha,iir) = ( alpha_attack_tab(ialpha) -           &
+                                          alpha_attack_i ) /                   &
+                                        ( alpha_attack_tab(ialpha) -           &
+                                          alpha_attack_tab(ialpha-1) ) *       &
+                                        ( weight_a * turb_cd_sel1(ialpha-1) +  &
+                                          weight_b * turb_cd_sel2(ialpha-1) ) +&
+                                        ( alpha_attack_i             -         &
+                                          alpha_attack_tab(ialpha-1) ) /       &
+                                        ( alpha_attack_tab(ialpha) -           &
+                                          alpha_attack_tab(ialpha-1) ) *       &
+                                        ( weight_a * turb_cd_sel1(ialpha) +    &
+                                          weight_b * turb_cd_sel2(ialpha) )
+   
+          ENDDO   ! end loop over angles of attack
+
+       ENDDO   ! end loop over radius
+    
+    END SUBROUTINE wtm_read_blade_tables
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> The projection matrix for the coordinate system of therotor disc in respect
+!> to the yaw and tilt angle of the rotor is calculated
+!------------------------------------------------------------------------------!
+    SUBROUTINE wtm_rotate_rotor( inot )
+
+
+       IMPLICIT NONE
+
+       INTEGER(iwp) :: inot
+!
+!--    Calculation of the rotation matrix for the application of the tilt to
+!--    the rotors
+       rot_eigen_rad(1) = SIN( phi_yaw(inot) )    ! x-component of the radial eigenvector
+       rot_eigen_rad(2) = COS( phi_yaw(inot) )    ! y-component of the radial eigenvector 
+       rot_eigen_rad(3) = 0.0_wp                  ! z-component of the radial eigenvector
+
+       rot_eigen_azi(1) = 0.0_wp                  ! x-component of the azimuth eigenvector
+       rot_eigen_azi(2) = 0.0_wp                  ! y-component of the azimuth eigenvector
+       rot_eigen_azi(3) = 1.0_wp                  ! z-component of the azimuth eigenvector
+
+       rot_eigen_nor(1) =  COS( phi_yaw(inot) )   ! x-component of the normal eigenvector
+       rot_eigen_nor(2) = -SIN( phi_yaw(inot) )   ! y-component of the normal eigenvector
+       rot_eigen_nor(3) = 0.0_wp                  ! z-component of the normal eigenvector
+    
+!
+!--    Calculation of the coordinate transformation matrix to apply a tilt to
+!--    the rotor. If tilt = 0, rot_coord_trans is a unit matrix.
+
+       rot_coord_trans(inot,1,1) = rot_eigen_rad(1)**2                   *     &
+                                   ( 1.0_wp - COS( tilt ) ) + COS( tilt ) 
+       rot_coord_trans(inot,1,2) = rot_eigen_rad(1) * rot_eigen_rad(2)   *     &
+                                   ( 1.0_wp - COS( tilt ) )              -     &
+                                   rot_eigen_rad(3) * SIN( tilt )
+       rot_coord_trans(inot,1,3) = rot_eigen_rad(1) * rot_eigen_rad(3)   *     &
+                                   ( 1.0_wp - COS( tilt ) )              +     &
+                                   rot_eigen_rad(2) * SIN( tilt )
+       rot_coord_trans(inot,2,1) = rot_eigen_rad(2) * rot_eigen_rad(1)   *     &
+                                   ( 1.0_wp - COS( tilt ) )              +     &
+                                   rot_eigen_rad(3) * SIN( tilt )
+       rot_coord_trans(inot,2,2) = rot_eigen_rad(2)**2                   *     &
+                                   ( 1.0_wp - COS( tilt ) ) + COS( tilt ) 
+       rot_coord_trans(inot,2,3) = rot_eigen_rad(2) * rot_eigen_rad(3)   *     &
+                                   ( 1.0_wp - COS( tilt ) )              -     &
+                                   rot_eigen_rad(1) * SIN( tilt )
+       rot_coord_trans(inot,3,1) = rot_eigen_rad(3) * rot_eigen_rad(1)   *     &
+                                   ( 1.0_wp - COS( tilt ) )              -     &
+                                   rot_eigen_rad(2) * SIN( tilt )
+       rot_coord_trans(inot,3,2) = rot_eigen_rad(3) * rot_eigen_rad(2)   *     &
+                                   ( 1.0_wp - COS( tilt ) )              +     &
+                                   rot_eigen_rad(1) * SIN( tilt )
+       rot_coord_trans(inot,3,3) = rot_eigen_rad(3)**2                   *     &
+                                   ( 1.0_wp - COS( tilt ) ) + COS( tilt )
+
+!
+!--    Vectors for the Transformation of forces from the rotor's spheric
+!--    coordinate system to the cartesian coordinate system
+       rotx(inot,:) = MATMUL( rot_coord_trans(inot,:,:), rot_eigen_nor )
+       roty(inot,:) = MATMUL( rot_coord_trans(inot,:,:), rot_eigen_rad )
+       rotz(inot,:) = MATMUL( rot_coord_trans(inot,:,:), rot_eigen_azi )
+    
+    END SUBROUTINE wtm_rotate_rotor
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Calculation of the forces generated by the wind turbine
+!------------------------------------------------------------------------------!
+    SUBROUTINE wtm_forces
+
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=2) ::  turbine_id
+
+       INTEGER(iwp) ::  i, j, k          !< loop indices
+       INTEGER(iwp) ::  inot             !< turbine loop index (turbine id)
+       INTEGER(iwp) ::  iialpha, iir     !<
+       INTEGER(iwp) ::  rseg, rseg_int   !<
+       INTEGER(iwp) ::  ring, ring_int   !<
+       INTEGER(iwp) ::  ii, jj, kk       !<
+    
+       REAL(wp)     ::  sin_rot, cos_rot   !<
+       REAL(wp)     ::  sin_yaw, cos_yaw   !<
+       
+       REAL(wp) ::  aa, bb, cc, dd  !< interpolation distances
+       REAL(wp) ::  gg              !< interpolation volume var  
+       
+       REAL(wp) ::  dist_u_3d, dist_v_3d, dist_w_3d  !< smearing distances
+
+       
+!
+!      Variables for pitch control
+       REAL(wp)     ::  torque_max=0.0_wp
+       LOGICAL      ::  pitch_sw=.FALSE.
+
+       INTEGER(iwp), DIMENSION(1) :: lct=0
+       REAL(wp), DIMENSION(1)     :: rad_d=0.0_wp
+
+
+       CALL cpu_log( log_point_s(61), 'wtm_forces', 'start' )
+
+
+       IF ( simulated_time >= time_turbine_on ) THEN
+
+!
+!--       Set forces to zero for each new time step:
+          thrust(:,:,:)         = 0.0_wp
+          torque_y(:,:,:)       = 0.0_wp
+          torque_z(:,:,:)       = 0.0_wp
+          torque_total(:)       = 0.0_wp
+          rot_tend_x(:,:,:)     = 0.0_wp
+          rot_tend_y(:,:,:)     = 0.0_wp
+          rot_tend_z(:,:,:)     = 0.0_wp
+          thrust_rotor(:)       = 0.0_wp
+!
+!--       Loop over number of turbines:
+          DO inot = 1, nturbines
+
+             cos_yaw = COS(phi_yaw(inot))
+             sin_yaw = SIN(phi_yaw(inot))
+!
+!--          Loop over rings of each turbine:
+             DO ring = 1, nrings(inot)
+
+                thrust_seg(:)   = 0.0_wp
+                torque_seg_y(:) = 0.0_wp
+                torque_seg_z(:) = 0.0_wp
+!
+!--             Determine distance between each ring (center) and the hub:
+                cur_r = (ring - 0.5_wp) * delta_r(inot)
+
+!
+!--             Loop over segments of each ring of each turbine:
+                DO rseg = 1, nsegs(ring,inot)
+!
+!--                !-----------------------------------------------------------!
+!--                !-- Determine coordinates of the ring segments            --!
+!--                !-----------------------------------------------------------!
+!
+!--                Determine angle of ring segment towards zero degree angle of
+!--                rotor system (at zero degree rotor direction vectors aligned
+!--                with y-axis):
+                   phi_rotor = rseg * 2.0_wp * pi / nsegs(ring,inot)
+                   cos_rot   = COS( phi_rotor )
+                   sin_rot   = SIN( phi_rotor )
+
+!--                Now the direction vectors can be determined with respect to
+!--                the yaw and tilt angle:
+                   re(1) = cos_rot * sin_yaw
+                   re(2) = cos_rot * cos_yaw    
+                   re(3) = sin_rot
+
+                   rote = MATMUL( rot_coord_trans(inot,:,:), re )
+!
+!--                Coordinates of the single segments (center points):
+                   rbx(ring,rseg) = rcx(inot) + cur_r * rote(1)
+                   rby(ring,rseg) = rcy(inot) + cur_r * rote(2)
+                   rbz(ring,rseg) = rcz(inot) + cur_r * rote(3)
+
+!--                !-----------------------------------------------------------!
+!--                !-- Interpolation of the velocity components from the     --!
+!--                !-- cartesian grid point to the coordinates of each ring  --!
+!--                !-- segment (follows a method used in the particle model) --!
+!--                !-----------------------------------------------------------!
+
+                   u_int(inot,ring,rseg)     = 0.0_wp
+                   u_int_1_l(inot,ring,rseg) = 0.0_wp
+
+                   v_int(inot,ring,rseg)     = 0.0_wp
+                   v_int_1_l(inot,ring,rseg) = 0.0_wp
+
+                   w_int(inot,ring,rseg)     = 0.0_wp
+                   w_int_1_l(inot,ring,rseg) = 0.0_wp
+
+!
+!--                Interpolation of the u-component:
+
+                   ii =   rbx(ring,rseg) * ddx
+                   jj = ( rby(ring,rseg) - 0.5_wp * dy ) * ddy
+                   kk = ( rbz(ring,rseg) - 0.5_wp * dz ) / dz
+!
+!--                Interpolate only if all required information is available on
+!--                the current PE:
+                   IF ( ( ii >= nxl )  .AND.  ( ii <= nxr ) )  THEN
+                      IF ( ( jj >= nys )  .AND.  ( jj <= nyn ) )  THEN
+
+                         aa = ( ( ii + 1          ) * dx - rbx(ring,rseg) ) *  &
+                              ( ( jj + 1 + 0.5_wp ) * dy - rby(ring,rseg) )
+                         bb = ( rbx(ring,rseg) - ii * dx )                  *  &
+                              ( ( jj + 1 + 0.5_wp ) * dy - rby(ring,rseg) )
+                         cc = ( ( ii+1            ) * dx - rbx(ring,rseg) ) *  &
+                              ( rby(ring,rseg) - ( jj + 0.5_wp ) * dy )
+                         dd = ( rbx(ring,rseg) -              ii * dx )     *  &
+                              ( rby(ring,rseg) - ( jj + 0.5_wp ) * dy ) 
+                         gg = dx * dy
+
+                         u_int_l = ( aa * u(kk,jj,ii)     +                    &
+                                     bb * u(kk,jj,ii+1)   +                    &
+                                     cc * u(kk,jj+1,ii)   +                    &
+                                     dd * u(kk,jj+1,ii+1)                      &
+                                   ) / gg
+
+                         u_int_u = ( aa * u(kk+1,jj,ii)     +                  &
+                                     bb * u(kk+1,jj,ii+1)   +                  &
+                                     cc * u(kk+1,jj+1,ii)   +                  &
+                                     dd * u(kk+1,jj+1,ii+1)                    &
+                                   ) / gg
+
+                         u_int_1_l(inot,ring,rseg) = u_int_l          +        &
+                                     ( rbz(ring,rseg) - zu(kk) ) / dz *        &
+                                     ( u_int_u - u_int_l )
+
+                      ELSE 
+                         u_int_1_l(inot,ring,rseg) = 0.0_wp
+                      ENDIF
+                   ELSE
+                      u_int_1_l(inot,ring,rseg) = 0.0_wp
+                   ENDIF
+
+
+!
+!--                Interpolation of the v-component:
+                   ii = ( rbx(ring,rseg) - 0.5_wp * dx ) * ddx
+                   jj =   rby(ring,rseg)                 * ddy
+                   kk = ( rbz(ring,rseg) + 0.5_wp * dz ) / dz 
+!
+!--                Interpolate only if all required information is available on
+!--                the current PE:
+                   IF ( ( ii >= nxl )  .AND.  ( ii <= nxr ) )  THEN
+                      IF ( ( jj >= nys )  .AND.  ( jj <= nyn ) )  THEN
+
+                         aa = ( ( ii + 1 + 0.5_wp ) * dx - rbx(ring,rseg) ) *  &
+                              ( ( jj + 1 )          * dy - rby(ring,rseg) )
+                         bb = ( rbx(ring,rseg)     - ( ii + 0.5_wp ) * dx ) *  &
+                              ( ( jj + 1 ) * dy          - rby(ring,rseg) )
+                         cc = ( ( ii + 1 + 0.5_wp ) * dx - rbx(ring,rseg) ) *  &
+                              ( rby(ring,rseg)           -        jj * dy )
+                         dd = ( rbx(ring,rseg)     - ( ii + 0.5_wp ) * dx ) *  &
+                              ( rby(ring,rseg)           -        jj * dy )
+                         gg = dx * dy
+
+                         v_int_l = ( aa * v(kk,jj,ii)     +                    &
+                                     bb * v(kk,jj,ii+1)   +                    &
+                                     cc * v(kk,jj+1,ii)   +                    &
+                                     dd * v(kk,jj+1,ii+1)                      &
+                                   ) / gg
+
+                         v_int_u = ( aa * v(kk+1,jj,ii)     +                  &
+                                     bb * v(kk+1,jj,ii+1)   +                  &
+                                     cc * v(kk+1,jj+1,ii)   +                  &
+                                     dd * v(kk+1,jj+1,ii+1)                    &
+                                  ) / gg
+
+                         v_int_1_l(inot,ring,rseg) = v_int_l +                 &
+                                     ( rbz(ring,rseg) - zu(kk) ) / dz *        &
+                                     ( v_int_u - v_int_l )
+
+                      ELSE
+                         v_int_1_l(inot,ring,rseg) = 0.0_wp
+                      ENDIF
+                   ELSE
+                      v_int_1_l(inot,ring,rseg) = 0.0_wp
+                   ENDIF
+
+
+!
+!--                Interpolation of the w-component:
+                   ii = ( rbx(ring,rseg) - 0.5_wp * dx ) * ddx
+                   jj = ( rby(ring,rseg) - 0.5_wp * dy ) * ddy
+                   kk =   rbz(ring,rseg)                 / dz
+!
+!--                Interpolate only if all required information is available on
+!--                the current PE:
+                   IF ( ( ii >= nxl )  .AND.  ( ii <= nxr ) )  THEN
+                      IF ( ( jj >= nys )  .AND.  ( jj <= nyn ) )  THEN
+
+                         aa = ( ( ii + 1 + 0.5_wp ) * dx - rbx(ring,rseg) ) *  &
+                              ( ( jj + 1 + 0.5_wp ) * dy - rby(ring,rseg) )
+                         bb = ( rbx(ring,rseg)     - ( ii + 0.5_wp ) * dx ) *  &
+                              ( ( jj + 1 + 0.5_wp ) * dy - rby(ring,rseg) )
+                         cc = ( ( ii + 1 + 0.5_wp ) * dx - rbx(ring,rseg) ) *  &
+                              ( rby(ring,rseg)     - ( jj + 0.5_wp ) * dy )
+                         dd = ( rbx(ring,rseg)     - ( ii + 0.5_wp ) * dx ) *  &
+                              ( rby(ring,rseg)     - ( jj + 0.5_wp ) * dy )
+                         gg = dx * dy
+
+                         w_int_l = ( aa * w(kk,jj,ii)     +                    &
+                                     bb * w(kk,jj,ii+1)   +                    &
+                                     cc * w(kk,jj+1,ii)   +                    &
+                                     dd * w(kk,jj+1,ii+1)                      &
+                                   ) / gg
+
+                         w_int_u = ( aa * w(kk+1,jj,ii)     +                  &
+                                     bb * w(kk+1,jj,ii+1)   +                  &
+                                     cc * w(kk+1,jj+1,ii)   +                  &
+                                     dd * w(kk+1,jj+1,ii+1)                    &
+                                    ) / gg
+
+                         w_int_1_l(inot,ring,rseg) = w_int_l +                 &
+                                     ( rbz(ring,rseg) - zw(kk) ) / dz *        &
+                                     ( w_int_u - w_int_l )
+                      ELSE
+                         w_int_1_l(inot,ring,rseg) = 0.0_wp
+                      ENDIF
+                   ELSE
+                      w_int_1_l(inot,ring,rseg) = 0.0_wp
+                   ENDIF
+
+                ENDDO
+             ENDDO
+
+          ENDDO
+
+!
+!--       Exchange between PEs (information required on each PE):
+#if defined( __parallel )
+          CALL MPI_ALLREDUCE( u_int_1_l, u_int, nturbines * MAXVAL(nrings) *   &
+                              MAXVAL(nsegs), MPI_REAL, MPI_SUM, comm2d, ierr )
+          CALL MPI_ALLREDUCE( v_int_1_l, v_int, nturbines * MAXVAL(nrings) *   &
+                              MAXVAL(nsegs), MPI_REAL, MPI_SUM, comm2d, ierr )
+          CALL MPI_ALLREDUCE( w_int_1_l, w_int, nturbines * MAXVAL(nrings) *   &
+                              MAXVAL(nsegs), MPI_REAL, MPI_SUM, comm2d, ierr )
+#else
+          u_int = u_int_1_l
+          v_int = v_int_1_l
+          w_int = w_int_1_l
+#endif
+
+
+!
+!--       Loop over number of turbines:
+
+          DO inot = 1, nturbines
+pit_loop: DO
+
+             IF ( pitch_sw )  THEN
+                torque_total(inot) = 0.0_wp
+                thrust_rotor(inot) = 0.0_wp
+                pitch_add(inot)    = pitch_add(inot) + 0.25_wp
+!                 IF ( myid == 0 ) PRINT*, 'Pitch', inot, pitch_add(inot)
+             ELSE
+                cos_yaw = COS(phi_yaw(inot))
+                sin_yaw = SIN(phi_yaw(inot))
+                IF ( pitch_control )  THEN
+                   pitch_add(inot) = MAX(pitch_add_old(inot) - pitch_rate *    &
+                                         dt_3d , 0.0_wp )
+                ENDIF
+             ENDIF
+
+!
+!--          Loop over rings of each turbine:
+             DO ring = 1, nrings(inot)
+!
+!--             Determine distance between each ring (center) and the hub:
+                cur_r = (ring - 0.5_wp) * delta_r(inot)
+!
+!--             Loop over segments of each ring of each turbine:
+                DO rseg = 1, nsegs(ring,inot)
+!
+!--                Determine angle of ring segment towards zero degree angle of
+!--                rotor system (at zero degree rotor direction vectors aligned
+!--                with y-axis):
+                   phi_rotor = rseg * 2.0_wp * pi / nsegs(ring,inot)
+                   cos_rot   = COS(phi_rotor)
+                   sin_rot   = SIN(phi_rotor)
+!
+!--                Now the direction vectors can be determined with respect to
+!--                the yaw and tilt angle:
+                   re(1) = cos_rot * sin_yaw
+                   re(2) = cos_rot * cos_yaw
+                   re(3) = sin_rot
+
+!                  The current unit vector in azimuthal direction:                         
+                   rea(1) = - sin_rot * sin_yaw
+                   rea(2) = - sin_rot * cos_yaw
+                   rea(3) =   cos_rot
+
+!
+!--                To respect the yawing angle for the calculations of
+!--                velocities and forces the unit vectors perpendicular to the
+!--                rotor area in direction of the positive yaw angle are defined:
+                   ren(1) =   cos_yaw
+                   ren(2) = - sin_yaw
+                   ren(3) = 0.0_wp
+!
+!--                Multiplication with the coordinate transformation matrix
+!--                gives the final unit vector with consideration of the rotor
+!--                tilt:
+                   rote = MATMUL( rot_coord_trans(inot,:,:), re )
+                   rota = MATMUL( rot_coord_trans(inot,:,:), rea )
+                   rotn = MATMUL( rot_coord_trans(inot,:,:), ren )
+!
+!--                Coordinates of the single segments (center points):
+                   rbx(ring,rseg) = rcx(inot) + cur_r * rote(1)
+
+                   rby(ring,rseg) = rcy(inot) + cur_r * rote(2)
+
+                   rbz(ring,rseg) = rcz(inot) + cur_r * rote(3)
+
+!
+!--                !-----------------------------------------------------------!
+!--                !-- Calculation of various angles and relative velocities --!
+!--                !-----------------------------------------------------------!
+!
+!--                In the following the 3D-velocity field is projected its
+!--                components perpedicular and parallel to the rotor area
+!--                The calculation of forces will be done in the rotor-
+!--                coordinates y' and z.
+!--                The yaw angle will be reintroduced when the force is applied
+!--                on the hydrodynamic equations
+!
+!--                Projection of the xy-velocities relative to the rotor area
+!
+!--                Velocity perpendicular to the rotor area:
+                   u_rot = u_int(inot,ring,rseg)*rotn(1) +                     &
+                   v_int(inot,ring,rseg)*rotn(2) +                             &
+                   w_int(inot,ring,rseg)*rotn(3)
+!
+!--                Projection of the 3D-velocity vector in the azimuthal
+!--                direction:
+                   vtheta(rseg) = rota(1) * u_int(inot,ring,rseg) +            & 
+                                  rota(2) * v_int(inot,ring,rseg) +            &
+                                  rota(3) * w_int(inot,ring,rseg)
+!
+!--                Determination of the angle phi_rel between the rotor plane
+!--                and the direction of the flow relative to the rotor:
+
+                   phi_rel(rseg) = ATAN( u_rot /                               &
+                                         ( omega_rot(inot) * cur_r -           &
+                                           vtheta(rseg) ) )
+
+!
+!--                Interpolation of the local pitch angle from tabulated values
+!--                to the current radial position:
+
+                   lct=minloc(ABS(cur_r-lrd))
+                   rad_d=cur_r-lrd(lct)
+                   
+                   IF (cur_r == 0.0_wp) THEN
+                      alpha_attack(rseg) = 0.0_wp
+                   ELSE IF (cur_r >= lrd(size(ard))) THEN
+                      alpha_attack(rseg) = ( ard(size(ard)) +                  &
+                                             ard(size(ard)-1) ) / 2.0_wp
+                   ELSE 
+                      alpha_attack(rseg) = ( ard(lct(1)) *  &
+                                             ( ( lrd(lct(1)+1) - cur_r ) /     &
+                                               ( lrd(lct(1)+1) - lrd(lct(1)) ) &
+                                             ) ) + ( ard(lct(1)+1) *           &
+                                             ( ( cur_r - lrd(lct(1)) ) /       &
+                                               ( lrd(lct(1)+1) - lrd(lct(1)) ) ) )
+                   ENDIF
+
+!
+!--                In Fortran radian instead of degree is used as unit for all
+!--                angles. Therefore, a transformation from angles given in
+!--                degree to angles given in radian is necessary here:
+                   alpha_attack(rseg) = alpha_attack(rseg) *                   &
+                                        ( (2.0_wp*pi) / 360.0_wp )
+!
+!--                Substraction of the local pitch angle to obtain the local
+!--                angle of attack:
+                   alpha_attack(rseg) = phi_rel(rseg) - alpha_attack(rseg)
+!
+!--                Preliminary transformation back from angles given in radian
+!--                to angles given in degree:
+                   alpha_attack(rseg) = alpha_attack(rseg) *                   &
+                                        ( 360.0_wp / (2.0_wp*pi) )
+!
+!--                Correct with collective pitch angle:
+                   alpha_attack = alpha_attack + pitch_add(inot)
+
+!
+!--                Determination of the magnitude of the flow velocity relative
+!--                to the rotor:
+                   vrel(rseg) = SQRT( u_rot**2 +                               &
+                                      ( omega_rot(inot) * cur_r -              &
+                                        vtheta(rseg) )**2 )
+
+!
+!--                !-----------------------------------------------------------!
+!--                !-- Interpolation of chord as well as lift and drag       --!
+!--                !-- coefficients from tabulated values                    --!
+!--                !-----------------------------------------------------------!
+
+!
+!--                Interpolation of the chord_length from tabulated values to
+!--                the current radial position:
+
+                   IF (cur_r == 0.0_wp) THEN
+                      chord(rseg) = 0.0_wp
+                   ELSE IF (cur_r >= lrd(size(crd))) THEN
+                      chord(rseg) = (crd(size(crd)) + ard(size(crd)-1)) / 2.0_wp
+                   ELSE 
+                      chord(rseg) = ( crd(lct(1)) *                            &
+                            ( ( lrd(lct(1)+1) - cur_r ) /                      &
+                              ( lrd(lct(1)+1) - lrd(lct(1)) ) ) ) +            &
+                            ( crd(lct(1)+1) *                                  &
+                            ( ( cur_r-lrd(lct(1)) ) /                          &
+                              ( lrd(lct(1)+1) - lrd(lct(1)) ) ) )
+                   ENDIF
+
+!
+!--                Determine index of current angle of attack, needed for
+!--                finding the appropriate interpolated values of the lift and
+!--                drag coefficients (-180.0 degrees = 0, +180.0 degrees = 36000,
+!--                so one index every 0.01 degrees):
+                   iialpha = CEILING( ( alpha_attack(rseg) + 180.0_wp )        &
+                                      * ( 1.0_wp / accu_cl_cd_tab ) )
+!
+!--                Determine index of current radial position, needed for
+!--                finding the appropriate interpolated values of the lift and
+!--                drag coefficients (one index every 0.1 m):
+                   iir = CEILING( cur_r * 10.0_wp )
+!
+!--                Read in interpolated values of the lift and drag coefficients
+!--                for the current radial position and angle of attack:
+                   turb_cl(rseg) = turb_cl_tab(iialpha,iir)
+                   turb_cd(rseg) = turb_cd_tab(iialpha,iir)
+
+!
+!--                Final transformation back from angles given in degree to
+!--                angles given in radian:
+                   alpha_attack(rseg) = alpha_attack(rseg) *                   &
+                                        ( (2.0_wp*pi) / 360.0_wp )
+
+!
+!--                !-----------------------------------------------------!
+!--                !-- Calculation of the forces                       --!
+!--                !-----------------------------------------------------!
+
+!
+!--                Calculate the pre_factor for the thrust and torque forces:
+
+                   pre_factor = 0.5_wp * (vrel(rseg)**2) * 3.0_wp *  &
+                                chord(rseg) * delta_r(inot) / nsegs(ring,inot)
+
+!
+!--                Calculate the thrust force (x-component of the total force)
+!--                for each ring segment:
+                   thrust_seg(rseg) = pre_factor *                             &
+                                      ( turb_cl(rseg) * COS(phi_rel(rseg)) +   &
+                                        turb_cd(rseg) * SIN(phi_rel(rseg)) )
+
+!
+!--                Determination of the second of the additional forces acting
+!--                on the flow in the azimuthal direction: force vector as basis
+!--                for torque (torque itself would be the vector product of the
+!--                radius vector and the force vector):
+                   torque_seg = pre_factor *                                   &
+                                ( turb_cl(rseg) * SIN(phi_rel(rseg)) -         &
+                                  turb_cd(rseg) * COS(phi_rel(rseg)) )
+!
+!--                Decomposition of the force vector into two parts:
+!--                One acting along the y-direction and one acting along the
+!--                z-direction of the rotor coordinate system:
+
+                   torque_seg_y(rseg) = -torque_seg * sin_rot
+                   torque_seg_z(rseg) =  torque_seg * cos_rot
+
+!
+!--                Add the segment thrust to the thrust of the whole rotor
+                   thrust_rotor(inot) = thrust_rotor(inot) +                   &
+                                        thrust_seg(rseg)                   
+                   
+
+                   torque_total(inot) = torque_total(inot) + (torque_seg * cur_r)
+
+                ENDDO   !-- end of loop over ring segments
+
+!
+!--             Restore the forces into arrays containing all the segments of
+!--             each ring:
+                thrust_ring(ring,:)   = thrust_seg(:)
+                torque_ring_y(ring,:) = torque_seg_y(:)
+                torque_ring_z(ring,:) = torque_seg_z(:)
+
+
+             ENDDO   !-- end of loop over rings
+
+
+             CALL cpu_log( log_point_s(62), 'wtm_controller', 'start' )
+
+             
+             IF ( speed_control )  THEN
+!
+!--             Calculation of the current generator speed for rotor speed control
+             
+!                                     
+!--             The acceleration of the rotor speed is calculated from 
+!--             the force balance of the accelerating torque
+!--             and the torque of the rotating rotor and generator
+                om_rate = ( torque_total(inot) * air_dens * gear_eff -         &
+                            gear_ratio * torque_gen_old(inot) ) /              &
+                          ( inertia_rot +                                      & 
+                            gear_ratio * gear_ratio * inertia_gen ) * dt_3d
+
+!
+!--             The generator speed is given by the product of gear gear_ratio
+!--             and rotor speed
+                omega_gen(inot) = gear_ratio * ( omega_rot(inot) + om_rate )     
+             
+             ENDIF
+             
+             IF ( pitch_control )  THEN
+
+!
+!--             If the current generator speed is above rated, the pitch is not
+!--             saturated and the change from the last time step is within the 
+!--             maximum pitch rate, then the pitch loop is repeated with a pitch
+!--             gain
+                IF ( (  omega_gen(inot)  > rated_genspeed   )  .AND.           &
+                     ( pitch_add(inot) < 25.0_wp ) .AND.                       &
+                     ( pitch_add(inot) < pitch_add_old(inot) +                 & 
+                       pitch_rate * dt_3d  ) ) THEN 
+                   pitch_sw = .TRUE.
+!
+!--                Go back to beginning of pit_loop                   
+                   CYCLE pit_loop
+                ENDIF
+                
+!
+!--             The current pitch is saved for the next time step
+                pitch_add_old(inot) = pitch_add(inot)
+                pitch_sw = .FALSE.
+             ENDIF
+             EXIT pit_loop             
+          ENDDO pit_loop ! Recursive pitch control loop
+
+
+!
+!--          Call the rotor speed controller
+             
+             IF ( speed_control )  THEN
+!
+!--             Find processor at i_hub, j_hub             
+                IF ( ( nxl <= i_hub(inot) )  .AND.  ( nxr >= i_hub(inot) ) )   &
+                   THEN
+                   IF ( ( nys <= j_hub(inot) )  .AND.  ( nyn >= j_hub(inot) ) )&
+                      THEN
+                      CALL wtm_speed_control( inot )
+                   ENDIF
+                ENDIF
+                               
+             ENDIF
+
+
+             CALL cpu_log( log_point_s(62), 'wtm_controller', 'stop' )
+
+             CALL cpu_log( log_point_s(63), 'wtm_smearing', 'start' )
+
+
+!--          !-----------------------------------------------------------------!
+!--          !--                  Regularization kernel                      --!
+!--          !-- Smearing of the forces and interpolation to cartesian grid  --!
+!--          !-----------------------------------------------------------------!
+!
+!--          The aerodynamic blade forces need to be distributed smoothly on
+!--          several mesh points in order to avoid singular behaviour
+!
+!--          Summation over sum of weighted forces. The weighting factor
+!--          (calculated in user_init) includes information on the distance
+!--          between the center of the grid cell and the rotor segment under
+!--          consideration
+!
+!--          To save computing time, apply smearing only for the relevant part
+!--          of the model domain:
+!
+!--
+!--          Calculation of the boundaries:
+             i_smear(inot) = CEILING( ( rr(inot) * ABS( roty(inot,1) ) +       &
+                                        eps_min ) / dx )
+             j_smear(inot) = CEILING( ( rr(inot) * ABS( roty(inot,2) ) +       &
+                                        eps_min ) / dy )
+
+             DO i = MAX( nxl, i_hub(inot) - i_smear(inot) ),                   &
+                    MIN( nxr, i_hub(inot) + i_smear(inot) )
+                DO j = MAX( nys, j_hub(inot) - j_smear(inot) ),                &
+                        MIN( nyn, j_hub(inot) + j_smear(inot) )
+                   DO k = MAX( nzb_u_inner(j,i)+1, k_hub(inot) - k_smear(inot) ), &
+                                k_hub(inot) + k_smear(inot)
+                      DO ring = 1, nrings(inot)
+                         DO rseg = 1, nsegs(ring,inot)
+!
+!--                         Determine the square of the distance between the
+!--                         current grid point and each rotor area segment:
+                            dist_u_3d = ( i * dx               - rbx(ring,rseg) )**2 + &
+                                        ( j * dy + 0.5_wp * dy - rby(ring,rseg) )**2 + &
+                                        ( k * dz - 0.5_wp * dz - rbz(ring,rseg) )**2
+                            dist_v_3d = ( i * dx + 0.5_wp * dx - rbx(ring,rseg) )**2 + &
+                                        ( j * dy               - rby(ring,rseg) )**2 + &
+                                        ( k * dz - 0.5_wp * dz - rbz(ring,rseg) )**2
+                            dist_w_3d = ( i * dx + 0.5_wp * dx - rbx(ring,rseg) )**2 + &
+                                        ( j * dy + 0.5_wp * dy - rby(ring,rseg) )**2 + &
+                                        ( k * dz               - rbz(ring,rseg) )**2
+
+!
+!--                         3D-smearing of the forces with a polynomial function
+!--                         (much faster than the old Gaussian function), using
+!--                         some parameters that have been calculated in user_init.
+!--                         The function is only similar to Gaussian function for
+!--                         squared distances <= eps_min2:
+                            IF ( dist_u_3d <= eps_min2 ) THEN
+                            thrust(k,j,i) = thrust(k,j,i) +                    &
+                                            thrust_ring(ring,rseg) *           &
+                                            ( ( pol_a * dist_u_3d - pol_b ) *  & 
+                                             dist_u_3d + 1.0_wp ) * eps_factor
+                            ENDIF
+                            IF ( dist_v_3d <= eps_min2 ) THEN
+                            torque_y(k,j,i) = torque_y(k,j,i) +                &
+                                              torque_ring_y(ring,rseg) *       &
+                                              ( ( pol_a * dist_v_3d - pol_b ) *&
+                                               dist_v_3d + 1.0_wp ) * eps_factor
+                            ENDIF
+                            IF ( dist_w_3d <= eps_min2 ) THEN
+                            torque_z(k,j,i) = torque_z(k,j,i) +                &
+                                              torque_ring_z(ring,rseg) *       &
+                                              ( ( pol_a * dist_w_3d - pol_b ) *&
+                                               dist_w_3d + 1.0_wp ) * eps_factor
+                            ENDIF
+
+                         ENDDO  ! End of loop over rseg
+                      ENDDO     ! End of loop over ring
+              
+!
+!--                   Rotation of force components:
+                      rot_tend_x(k,j,i) = rot_tend_x(k,j,i) +                  &
+                                      thrust(k,j,i)*rotx(inot,1) +             &
+                                      torque_y(k,j,i)*roty(inot,1) +           &
+                                      torque_z(k,j,i)*rotz(inot,1)
+                                
+                      rot_tend_y(k,j,i) = rot_tend_y(k,j,i) +                  &
+                                      thrust(k,j,i)*rotx(inot,2) +             &
+                                      torque_y(k,j,i)*roty(inot,2) +           &
+                                      torque_z(k,j,i)*rotz(inot,2)
+                                
+                      rot_tend_z(k,j,i) = rot_tend_z(k,j,i) +                  &
+                                      thrust(k,j,i)*rotx(inot,3) +             &
+                                      torque_y(k,j,i)*roty(inot,3) +           &
+                                      torque_z(k,j,i)*rotz(inot,3)                               
+
+                   ENDDO        ! End of loop over k
+                ENDDO           ! End of loop over j
+             ENDDO              ! End of loop over i
+
+             CALL cpu_log( log_point_s(63), 'wtm_smearing', 'stop' )          
+                   
+          ENDDO                  !-- end of loop over turbines
+
+                
+          IF ( yaw_control )  THEN
+!
+!--          Allocate arrays for yaw control at first call
+!--          Can't be allocated before dt_3d is set
+             IF ( start_up )  THEN
+                WDLON = NINT( 30.0_wp / dt_3d )  ! 30s running mean array
+                ALLOCATE( wd30(1:nturbines,1:WDLON) )
+                wd30 = 999.0_wp                  ! Set to dummy value
+                ALLOCATE( wd30_l(1:WDLON) )
+                
+                WDSHO = NINT( 2.0_wp / dt_3d )   ! 2s running mean array
+                ALLOCATE( wd2(1:nturbines,1:WDSHO) )
+                wd2 = 999.0_wp                   ! Set to dummy value
+                ALLOCATE( wd2_l(1:WDSHO) )
+                start_up = .FALSE.
+             ENDIF          
+
+!
+!--          Calculate the inflow wind speed 
+!--
+!--          Loop over number of turbines:
+             DO inot = 1, nturbines
+!
+!--             Find processor at i_hub, j_hub             
+                IF ( ( nxl <= i_hub(inot) )  .AND.  ( nxr >= i_hub(inot) ) )   &
+                   THEN
+                   IF ( ( nys <= j_hub(inot) )  .AND.  ( nyn >= j_hub(inot) ) )&
+                      THEN
+
+                      u_inflow_l(inot) = u(k_hub(inot),j_hub(inot),i_hub(inot))
+
+                      wdir_l(inot) = -1.0_wp * ATAN2(                          &
+                         0.5_wp * ( v(k_hub(inot),j_hub(inot),i_hub(inot)+1) + &
+                                    v(k_hub(inot),j_hub(inot),i_hub(inot)) ) , &
+                         0.5_wp * ( u(k_hub(inot),j_hub(inot)+1,i_hub(inot)) + &
+                                    u(k_hub(inot),j_hub(inot),i_hub(inot)) ) )
+
+                      CALL wtm_yawcontrol( inot )
+
+                      phi_yaw_l(inot) = phi_yaw(inot)
+
+                   ENDIF
+                ENDIF
+                   
+             ENDDO                                 !-- end of loop over turbines
+
+!
+!--          Transfer of information to the other cpus            
+             CALL MPI_ALLREDUCE( u_inflow_l, u_inflow, nturbines, MPI_REAL,    &
+                                 MPI_SUM, comm2d, ierr )
+             CALL MPI_ALLREDUCE( wdir_l, wdir, nturbines, MPI_REAL, MPI_SUM,   &
+                                 comm2d, ierr )
+             CALL MPI_ALLREDUCE( phi_yaw_l, phi_yaw, nturbines, MPI_REAL,      &
+                                 MPI_SUM, comm2d, ierr )
+             
+             DO inot = 1, nturbines
+!             
+!--             Update rotor orientation                
+                CALL wtm_rotate_rotor( inot )
+
+             ENDDO ! End of loop over turbines
+                           
+          END IF 
+          
+          IF ( speed_control )  THEN
+!
+!--          Transfer of information to the other cpus
+!              CALL MPI_ALLREDUCE( omega_gen, omega_gen_old, nturbines,        &
+!                                  MPI_REAL,MPI_SUM, comm2d, ierr )
+             CALL MPI_ALLREDUCE( torque_gen, torque_gen_old, nturbines,        &
+                                 MPI_REAL, MPI_SUM, comm2d, ierr )
+             CALL MPI_ALLREDUCE( omega_rot_l, omega_rot, nturbines,            &
+                                 MPI_REAL, MPI_SUM, comm2d, ierr )
+             CALL MPI_ALLREDUCE( omega_gen_f, omega_gen_f_old, nturbines,      &
+                                 MPI_REAL, MPI_SUM, comm2d, ierr )
+            
+          ENDIF
+
+          DO inot = 1, nturbines
+
+             IF ( myid == 0 ) THEN
+                IF ( openfile_turb_mod(400+inot)%opened )  THEN
+                   WRITE ( 400+inot, 106 ) simulated_time, omega_rot(inot),    &
+                             omega_gen(inot), torque_gen_old(inot),            &
+                             torque_total(inot), pitch_add(inot),              &
+                             torque_gen_old(inot)*omega_gen(inot)*gen_eff,     &
+                             torque_total(inot)*omega_rot(inot)*air_dens,      &
+                             thrust_rotor(inot),                               & 
+                             wdir(inot)*180.0_wp/pi,                           &
+                             (phi_yaw(inot))*180.0_wp/pi                   
+                             
+                ELSE
+
+                   WRITE ( turbine_id,'(I2.2)')  inot
+                   OPEN ( 400+inot, FILE=( 'TURBINE_PARAMETERS'//turbine_id ), &
+                                            FORM='FORMATTED' )
+                   WRITE ( 400+inot, 105 ) inot
+                   WRITE ( 400+inot, 106 ) simulated_time, omega_rot(inot),    &
+                             omega_gen(inot), torque_gen_old(inot),            &
+                             torque_total(inot), pitch_add(inot),              &
+                             torque_gen_old(inot)*omega_gen(inot)*gen_eff,     &
+                             torque_total(inot)*omega_rot(inot)*air_dens,      &
+                             thrust_rotor(inot),                               & 
+                             wdir(inot)*180.0_wp/pi,                           &                   
+                             (phi_yaw(inot))*180.0_wp/pi
+                ENDIF
+             ENDIF
+
+!--          Set open flag
+             openfile_turb_mod(400+inot)%opened = .TRUE.
+          ENDDO                                    !-- end of loop over turbines
+
+       ENDIF
+
+       CALL cpu_log( log_point_s(61), 'wtm_forces', 'stop' )
+       
+!
+!--    Formats
+       105 FORMAT ('Turbine control data for turbine ',I2,1X,':'/ &
+              &'----------------------------------------'/ &
+              &'   Time   RSpeed  GSpeed  ', &
+               'GenTorque  AeroTorque  Pitch  Power(Gen)  Power(Rot)  ',       &
+               'RotThrust  WDirection  YawOrient')
+
+       106 FORMAT (F9.3,2X,F7.3,2X,F7.2,2X,F9.1,3X,F9.1,1X,F6.2,2X,F10.1,2X,   &
+                   F10.1,1X,F9.1,2X,F7.2,1X,F7.2)
+
+
+    END SUBROUTINE wtm_forces
+
+    
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Yaw controller for the wind turbine model
+!------------------------------------------------------------------------------!
+    SUBROUTINE wtm_yawcontrol( inot )
+    
+       USE constants
+       USE kinds
+                
+       IMPLICIT NONE
+      
+       INTEGER(iwp)             :: inot
+       INTEGER(iwp)             :: i_wd_30
+       REAL(wp)                 :: missal
+
+       i_wd_30 = 0_iwp
+
+!  
+!--    The yaw controller computes a 30s running mean of the wind direction.
+!--    If the difference between turbine alignment and wind direction exceeds
+!--    5Â°, the turbine is yawed. The mechanism stops as soon as the 2s-running
+!--    mean of the missalignment is smaller than 0.5Â°.
+!--    Attention: If the timestep during the simulation changes significantly
+!--    the lengths of the running means change and it does not correspond to
+!--    30s/2s anymore.
+!--    ! Needs to be modified for these situations !
+!--    For wind from the east, the averaging of the wind direction could cause
+!--    problems and the yaw controller is probably flawed. -> Routine for
+!--    averaging needs to be improved!
+!
+!--    Check if turbine is not yawing
+       IF ( .NOT. doyaw(inot) )  THEN
+!
+!--       Write current wind direction into array
+          wd30_l    = wd30(inot,:)
+          wd30_l    = CSHIFT( wd30_l, SHIFT=-1 )
+          wd30_l(1) = wdir(inot)
+!
+!--       Check if array is full ( no more dummies )
+          IF ( .NOT. ANY( wd30_l == 999.) ) THEN 
+
+             missal = SUM( wd30_l ) / SIZE( wd30_l ) - phi_yaw(inot)
+!
+!--          Check if turbine is missaligned by more than max_miss
+             IF ( ABS( missal ) > max_miss )  THEN
+!
+!--             Check in which direction to yaw          
+                yawdir(inot) = SIGN( 1.0_wp, missal )
+!
+!--             Start yawing of turbine
+                phi_yaw(inot) = phi_yaw(inot) + yawdir(inot) * yaw_speed * dt_3d
+                doyaw(inot) = .TRUE.
+                wd30_l = 999.  ! fill with dummies again
+             ENDIF
+          ENDIF
+         
+          wd30(inot,:) = wd30_l
+
+!      
+!--    If turbine is already yawing:
+!--    Initialize 2 s running mean and yaw until the missalignment is smaller
+!--    than min_miss
+
+       ELSE
+!
+!--       Initialize 2 s running mean
+          wd2_l = wd2(inot,:)
+          wd2_l = CSHIFT( wd2_l, SHIFT = -1 )
+          wd2_l(1) = wdir(inot)
+!      
+!--       Check if array is full ( no more dummies )
+          IF ( .NOT. ANY( wd2_l == 999.0_wp ) ) THEN
+!
+!--          Calculate missalignment of turbine        
+             missal = SUM( wd2_l - phi_yaw(inot) ) / SIZE( wd2_l )
+!
+!--          Check if missalignment is still larger than 0.5 degree and if the
+!--          yaw direction is still right
+             IF ( ( ABS( missal ) > min_miss )  .AND.                          &
+                  ( yawdir(inot) == SIGN( 1.0_wp, missal ) ) )  THEN
+!
+!--             Continue yawing        
+                phi_yaw(inot) = phi_yaw(inot) + yawdir(inot) * yaw_speed * dt_3d
+             ELSE
+!
+!--             Stop yawing        
+                doyaw(inot) = .FALSE.
+                wd2_l = 999.0_wp ! fill with dummies again
+             ENDIF
+          ELSE
+!
+!--          Continue yawing
+             phi_yaw(inot) = phi_yaw(inot) + yawdir(inot) * yaw_speed * dt_3d
+          ENDIF
+      
+          wd2(inot,:) = wd2_l
+            
+       ENDIF
+     
+    END SUBROUTINE wtm_yawcontrol 
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Initialization of the speed control
+!------------------------------------------------------------------------------!
+    SUBROUTINE wtm_init_speed_control
+
+
+       IMPLICIT NONE
+
+!
+!--    If speed control is set, remaining variables and control_parameters for 
+!--    the control algorithm are calculated
+!
+!--    Calculate slope constant for region 15
+       slope15   = ( slope2 * min_reg2 * min_reg2 ) / ( min_reg2 - min_reg15 )
+!
+!--    Calculate upper limit of slipage region
+       vs_sysp   = rated_genspeed / 1.1_wp
+!
+!--    Calculate slope of slipage region
+       slope25   = ( rated_power / rated_genspeed ) /                          &
+                   ( rated_genspeed - vs_sysp )
+!
+!--    Calculate lower limit of slipage region
+       min_reg25 = ( slope25 - SQRT( slope25 * ( slope25 - 4.0_wp *            &
+                                                 slope2 * vs_sysp ) ) ) /      &
+                   ( 2.0_wp * slope2 )
+!
+!--    Frequency for the simple low pass filter
+       Fcorner   = 0.25_wp
+! 
+!--    At the first timestep the torque is set to its maximum to prevent
+!--    an overspeeding of the rotor
+       torque_gen_old(:) = max_torque_gen  
+     
+    END SUBROUTINE wtm_init_speed_control
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Simple controller for the regulation of the rotor speed
+!------------------------------------------------------------------------------!
+    SUBROUTINE wtm_speed_control( inot )
+
+
+       IMPLICIT NONE
+
+       INTEGER(iwp)             :: inot
+       
+         
+
+!
+!--    The controller is based on the fortran script from Jonkman 
+!--    et al. 2009 "Definition of a 5 MW Reference Wind Turbine for
+!--    offshore system developement"
+
+!
+!--    The generator speed is filtered by a low pass filter 
+!--    for the control of the generator torque       
+       lp_coeff = EXP( -2.0_wp * 3.14_wp * dt_3d * Fcorner )
+       omega_gen_f(inot) = ( 1.0_wp - lp_coeff ) * omega_gen(inot) + lp_coeff *&
+                           omega_gen_f_old(inot)
+
+       IF ( omega_gen_f(inot) <= min_reg15 )  THEN
+!                        
+!--       Region 1: Generator torque is set to zero to accelerate the rotor:
+          torque_gen(inot) = 0
+       
+       ELSEIF ( omega_gen_f(inot) <= min_reg2 )  THEN
+!                        
+!--       Region 1.5: Generator torque is increasing linearly with rotor speed:
+          torque_gen(inot) = slope15 * ( omega_gen_f(inot) - min_reg15 )
+                         
+       ELSEIF ( omega_gen_f(inot) <= min_reg25 )  THEN
+!
+!--       Region 2: Generator torque is increased by the square of the generator
+!--                 speed to keep the TSR optimal:
+          torque_gen(inot) = slope2 * omega_gen_f(inot) * omega_gen_f(inot)
+       
+       ELSEIF ( omega_gen_f(inot) < rated_genspeed )  THEN
+!                        
+!--       Region 2.5: Slipage region between 2 and 3:
+          torque_gen(inot) = slope25 * ( omega_gen_f(inot) - vs_sysp )
+       
+       ELSE
+!                        
+!--       Region 3: Generator torque is antiproportional to the rotor speed to
+!--                 keep the power constant:
+          torque_gen(inot) = rated_power / omega_gen_f(inot)
+       
+       ENDIF
+!                        
+!--    Calculate torque rate and confine with a max
+       trq_rate = ( torque_gen(inot) - torque_gen_old(inot) ) / dt_3d
+       trq_rate = MIN( MAX( trq_rate, -1.0_wp * max_trq_rate ), max_trq_rate )
+!                        
+!--    Calculate new gen torque and confine with max torque                         
+       torque_gen(inot) = torque_gen_old(inot) + trq_rate * dt_3d
+       torque_gen(inot) = MIN( torque_gen(inot), max_torque_gen )                                             
+!
+!--    Overwrite values for next timestep                        
+       omega_rot_l(inot) = omega_gen(inot) / gear_ratio
+
+    
+    END SUBROUTINE wtm_speed_control    
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Application of the additional forces generated by the wind turbine on the 
+!> flow components (tendency terms)
+!> Call for all grid points
+!------------------------------------------------------------------------------!
+    SUBROUTINE wtm_tendencies( component )
+
+    
+       IMPLICIT NONE
+
+       INTEGER(iwp) ::  component   !< prognostic variable (u,v,w)
+       INTEGER(iwp) ::  i           !< running index
+       INTEGER(iwp) ::  j           !< running index
+       INTEGER(iwp) ::  k           !< running index
+
+
+       SELECT CASE ( component )
+
+       CASE ( 1 )
+!
+!--       Apply the x-component of the force to the u-component of the flow:
+          IF ( simulated_time >= time_turbine_on )  THEN
+             DO  i = nxlg, nxrg
+                DO  j = nysg, nyng
+                   DO  k = nzb_u_inner(j,i)+1, k_hub(1) + k_smear(1)
+!
+!--                   Calculate the thrust generated by the nacelle and the tower
+                      tend_nac_x = 0.5_wp * nac_cd_surf(k,j,i) *               &
+                                         SIGN( u(k,j,i)**2 , u(k,j,i) )     
+                      tend_tow_x   = 0.5_wp * tow_cd_surf(k,j,i) *             &
+                                         SIGN( u(k,j,i)**2 , u(k,j,i) ) 
+                                                   
+                      tend(k,j,i) = tend(k,j,i) - rot_tend_x(k,j,i)            &
+                                  - tend_nac_x - tend_tow_x
+                   ENDDO
+                ENDDO
+             ENDDO
+          ENDIF
+
+       CASE ( 2 )
+!
+!--       Apply the y-component of the force to the v-component of the flow:
+          IF ( simulated_time >= time_turbine_on )  THEN
+             DO  i = nxlg, nxrg
+                DO  j = nysg, nyng
+                   DO  k = nzb_v_inner(j,i)+1, k_hub(1) + k_smear(1)
+                      tend_nac_y = 0.5_wp * nac_cd_surf(k,j,i) *               &
+                                         SIGN( v(k,j,i)**2 , v(k,j,i) )     
+                      tend_tow_y   = 0.5_wp * tow_cd_surf(k,j,i) *             &
+                                         SIGN( v(k,j,i)**2 , v(k,j,i) )                      
+                      tend(k,j,i) = tend(k,j,i) - rot_tend_y(k,j,i)            &
+                                  - tend_nac_y - tend_tow_y
+                   ENDDO
+                ENDDO
+             ENDDO
+          ENDIF
+
+       CASE ( 3 )
+!
+!--       Apply the z-component of the force to the w-component of the flow:
+          IF ( simulated_time >= time_turbine_on )  THEN
+             DO  i = nxlg, nxrg
+                DO  j = nysg, nyng
+                   DO  k = nzb_w_inner(j,i)+1,  k_hub(1) + k_smear(1)
+                      tend(k,j,i) = tend(k,j,i) - rot_tend_z(k,j,i)
+                   ENDDO
+                ENDDO
+             ENDDO
+          ENDIF
+
+
+       CASE DEFAULT
+
+          WRITE( message_string, * ) 'unknown prognostic variable: ', component
+          CALL message( 'wtm_tendencies', 'PA04??', 1, 2, 0, 6, 0 ) 
+
+       END SELECT
+
+
+    END SUBROUTINE wtm_tendencies
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Application of the additional forces generated by the wind turbine on the 
+!> flow components (tendency terms)
+!> Call for grid point i,j
+!------------------------------------------------------------------------------!
+    SUBROUTINE wtm_tendencies_ij( i, j, component )
+
+
+       IMPLICIT NONE
+
+       INTEGER(iwp) ::  component   !< prognostic variable (u,v,w)
+       INTEGER(iwp) ::  i           !< running index
+       INTEGER(iwp) ::  j           !< running index
+       INTEGER(iwp) ::  k           !< running index
+
+       SELECT CASE ( component )
+
+       CASE ( 1 )
+!
+!--       Apply the x-component of the force to the u-component of the flow:
+          IF ( simulated_time >= time_turbine_on )  THEN
+
+             DO  k = nzb_u_inner(j,i)+1,  k_hub(1) + k_smear(1)
+!
+!--             Calculate the thrust generated by the nacelle and the tower 
+                tend_nac_x = 0.5_wp * nac_cd_surf(k,j,i) *                     &
+                                   SIGN( u(k,j,i)**2 , u(k,j,i) )     
+                tend_tow_x   = 0.5_wp * tow_cd_surf(k,j,i) *                   &
+                                   SIGN( u(k,j,i)**2 , u(k,j,i) ) 
+                tend(k,j,i) = tend(k,j,i) - rot_tend_x(k,j,i)                  &
+                            - tend_nac_x - tend_tow_x
+             ENDDO
+          ENDIF
+
+       CASE ( 2 )
+!
+!--       Apply the y-component of the force to the v-component of the flow:
+          IF ( simulated_time >= time_turbine_on )  THEN
+             DO  k = nzb_v_inner(j,i)+1,  k_hub(1) + k_smear(1)
+                tend_nac_y = 0.5_wp * nac_cd_surf(k,j,i) *                     &
+                                   SIGN( v(k,j,i)**2 , v(k,j,i) )     
+                tend_tow_y   = 0.5_wp * tow_cd_surf(k,j,i) *                   &
+                                   SIGN( v(k,j,i)**2 , v(k,j,i) )                      
+                tend(k,j,i) = tend(k,j,i) - rot_tend_y(k,j,i)                  &
+                            - tend_nac_y - tend_tow_y
+             ENDDO
+          ENDIF
+
+       CASE ( 3 )
+!
+!--       Apply the z-component of the force to the w-component of the flow:
+          IF ( simulated_time >= time_turbine_on )  THEN
+             DO  k = nzb_w_inner(j,i)+1,  k_hub(1) + k_smear(1)
+                tend(k,j,i) = tend(k,j,i) - rot_tend_z(k,j,i)
+             ENDDO
+          ENDIF
+
+
+       CASE DEFAULT
+
+          WRITE( message_string, * ) 'unknown prognostic variable: ', component
+          CALL message( 'wtm_tendencies', 'PA04??', 1, 2, 0, 6, 0 ) 
+
+       END SELECT
+
+
+    END SUBROUTINE wtm_tendencies_ij
+
+ END MODULE wind_turbine_model_mod
