Index: palm/trunk/SOURCE/inflow_turbulence.f90
===================================================================
--- palm/trunk/SOURCE/inflow_turbulence.f90	(revision 3655)
+++ palm/trunk/SOURCE/inflow_turbulence.f90	(revision 4172)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! added optional recycling of absolute values for pt and q
+! 
+! 3655 2019-01-07 16:51:22Z knoop
 ! Corrected "Former revisions" section
 ! 
@@ -87,5 +90,5 @@
         
     USE control_parameters,                                                    &
-        ONLY:  humidity, passive_scalar, recycling_plane, recycling_yshift
+        ONLY:  humidity, passive_scalar, recycling_plane, recycling_yshift, raq
         
     USE cpulog,                                                                &
@@ -101,5 +104,5 @@
 
     IMPLICIT NONE
-
+    
     INTEGER(iwp) ::  i        !< loop index
     INTEGER(iwp) ::  j        !< loop index
@@ -119,7 +122,7 @@
     REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,7,nbgp) ::                         &
        local_inflow_dist  !< auxiliary variable for inflow_dist, used for yshift
-
+    
     CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' )
-
+    
 !
 !-- Carry out spanwise averaging in the recycling plane
@@ -187,4 +190,6 @@
 !
 !-- Calculate the disturbances at the recycling plane
+!-- for recycling of absolute quantities, the disturbance is defined as the absolute value
+!-- (and not as the deviation from the mean profile)
     i = recycling_plane
 
@@ -198,8 +203,17 @@
                 inflow_dist(k,j,2,l) = v(k,j,i)   - avpr(k,2,l)
                 inflow_dist(k,j,3,l) = w(k,j,i)   - avpr(k,3,l)
-                inflow_dist(k,j,4,l) = pt(k,j,i)  - avpr(k,4,l)
+                IF ( raq(4) )  THEN
+                   inflow_dist(k,j,4,l) = pt(k,j,i)
+                ELSE
+                   inflow_dist(k,j,4,l) = pt(k,j,i) - avpr(k,4,l)
+                ENDIF
                 inflow_dist(k,j,5,l) = e(k,j,i)   - avpr(k,5,l)
-                IF ( humidity )                                                &
-                   inflow_dist(k,j,6,l) = q(k,j,i) - avpr(k,6,l)
+                IF ( humidity ) THEN
+                   IF ( raq(6) ) THEN
+                      inflow_dist(k,j,6,l) = q(k,j,i)
+                   ELSE
+                      inflow_dist(k,j,6,l) = q(k,j,i) - avpr(k,6,l)
+                   ENDIF
+                ENDIF
                 IF ( passive_scalar )                                          &
                    inflow_dist(k,j,7,l) = s(k,j,i) - avpr(k,7,l)
@@ -214,12 +228,20 @@
        DO  j = nysg, nyng
           DO  k = nzb, nzt+1
-
              inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l)
              inflow_dist(k,j,2,l) = v(k,j,i)   - avpr(k,2,l)
              inflow_dist(k,j,3,l) = w(k,j,i)   - avpr(k,3,l)
-             inflow_dist(k,j,4,l) = pt(k,j,i)  - avpr(k,4,l)
+             IF ( raq(4) )  THEN
+                inflow_dist(k,j,4,l) = pt(k,j,i)
+             ELSE
+                inflow_dist(k,j,4,l) = pt(k,j,i) - avpr(k,4,l) 
+             ENDIF
              inflow_dist(k,j,5,l) = e(k,j,i)   - avpr(k,5,l)
-             IF ( humidity )                                                   &
-                inflow_dist(k,j,6,l) = q(k,j,i) - avpr(k,6,l)
+             IF ( humidity )  THEN
+                IF ( raq(6) ) THEN
+                   inflow_dist(k,j,6,l) = q(k,j,i)
+                ELSE
+                   inflow_dist(k,j,6,l) = q(k,j,i) - avpr(k,6,l)
+                ENDIF
+             ENDIF
              IF ( passive_scalar )                                             &
                 inflow_dist(k,j,7,l) = s(k,j,i) - avpr(k,7,l)
@@ -291,17 +313,25 @@
              w(k,j,-nbgp:-1)  =                                             &
                         inflow_dist(k,j,3,1:nbgp) * inflow_damping_factor(k)
-             pt(k,j,-nbgp:-1) = mean_inflow_profiles(k,4) +                 &
-                        inflow_dist(k,j,4,1:nbgp) * inflow_damping_factor(k)
-             e(k,j,-nbgp:-1)  = mean_inflow_profiles(k,5) +                 &
+             IF ( raq(4) )  THEN
+                pt(k,j,-nbgp:-1) = inflow_dist(k,j,4,1:nbgp)
+             ELSE
+                pt(k,j,-nbgp:-1) = mean_inflow_profiles(k,4) +               &
+                inflow_dist(k,j,4,1:nbgp) * inflow_damping_factor(k)
+             ENDIF
+             e(k,j,-nbgp:-1)  = mean_inflow_profiles(k,5) +                  &
                         inflow_dist(k,j,5,1:nbgp) * inflow_damping_factor(k)
              e(k,j,-nbgp:-1)  = MAX( e(k,j,-nbgp:-1), 0.0_wp )
 
-             IF ( humidity )                                                &
-                q(k,j,-nbgp:-1)  = mean_inflow_profiles(k,6) +              &
+             IF ( humidity )  THEN
+                IF ( raq(6) )  THEN
+                   q(k,j,-nbgp:-1)  = inflow_dist(k,j,6,1:nbgp)
+                ELSE 
+                   q(k,j,-nbgp:-1)  = mean_inflow_profiles(k,6) +           & 
                         inflow_dist(k,j,6,1:nbgp) * inflow_damping_factor(k)
+                ENDIF
+             ENDIF
              IF ( passive_scalar )                                          &
                 s(k,j,-nbgp:-1)  = mean_inflow_profiles(k,7) +              &
                         inflow_dist(k,j,7,1:nbgp) * inflow_damping_factor(k)
-
           ENDDO
        ENDDO
