Index: palm/trunk/SOURCE/pmc_interface_mod.f90
===================================================================
--- palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 2898)
+++ palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 2899)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Control logics improved to allow nesting also in cases with
+! constant_flux_layer = .F. or constant_diffusion = .T.
+! 
+! 2895 2018-03-15 10:26:12Z hellstea
 ! Change in the nest initialization (pmci_interp_tril_all). Bottom wall BC is no
 ! longer overwritten.
@@ -260,9 +264,11 @@
 
     USE control_parameters,                                                    &
-        ONLY:  air_chemistry, cloud_physics, coupling_char, dt_3d, dz,         &
-               humidity, message_string, microphysics_morrison,                &
-               microphysics_seifert, nest_bound_l, nest_bound_r, nest_bound_s, &
-               nest_bound_n, nest_domain, neutral, passive_scalar,             & 
-               roughness_length, simulated_time, topography, volume_flow
+        ONLY:  air_chemistry, cloud_physics,                                   &
+               constant_diffusion, constant_flux_layer,                        &
+               coupling_char, dt_3d, dz, humidity, message_string,             &
+               microphysics_morrison, microphysics_seifert,                    &
+               nest_bound_l, nest_bound_r, nest_bound_s, nest_bound_n,         &
+               nest_domain, neutral, passive_scalar, roughness_length,         & 
+               simulated_time, topography, volume_flow
 
     USE chem_modules,                                                          &
@@ -1347,8 +1353,12 @@
 !
 !--    Precompute the log-law correction index- and ratio-arrays 
-       CALL pmci_init_loglaw_correction 
+       IF ( constant_flux_layer )  THEN
+          CALL pmci_init_loglaw_correction
+       ENDIF
 !
 !--    Define the SGS-TKE scaling factor based on the grid-spacing ratio
-       CALL pmci_init_tkefactor
+       IF ( .NOT. constant_diffusion )  THEN
+          CALL pmci_init_tkefactor
+       ENDIF
 !
 !--    Two-way coupling for general and vertical nesting.
@@ -3473,7 +3483,10 @@
        CALL pmci_interp_tril_all ( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo,   &
                                    r2yo, r1zw, r2zw, 'w' )
-       CALL pmci_interp_tril_all ( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo,   &
-                                   r2yo, r1zo, r2zo, 'e' )
-
+
+       IF ( .NOT. constant_diffusion )  THEN
+          CALL pmci_interp_tril_all ( e,  ec,  ico, jco, kco, r1xo, r2xo,      &
+                                      r1yo, r2yo, r1zo, r2zo, 'e' )
+       ENDIF
+       
        IF ( .NOT. neutral )  THEN
           CALL pmci_interp_tril_all ( pt, ptc, ico, jco, kco, r1xo, r2xo,      &
@@ -3657,5 +3670,5 @@
 !--    conditions, a corresponding correction is made for all vertical walls,
 !--    too.
-       IF ( var == 'u' .OR. var == 'v' )  THEN
+       IF ( constant_flux_layer .AND. ( var == 'u' .OR. var == 'v' ) )  THEN
           z0_topo = roughness_length
           DO  i = ib, nxr
@@ -4175,4 +4188,5 @@
 !--       Left border pe:
           IF ( nest_bound_l )  THEN
+             
              CALL pmci_interp_tril_lr( u,  uc,  icu, jco, kco, r1xu, r2xu,     &
                                        r1yo, r2yo, r1zo, r2zo,                 &
@@ -4193,10 +4207,12 @@
                                        nzt_topo_nestbc_l, 'l', 'w' )
 
-             CALL pmci_interp_tril_lr( e,  ec,  ico, jco, kco, r1xo, r2xo,     &
-                                       r1yo, r2yo, r1zo, r2zo,                 &
-                                       logc_w_l, logc_ratio_w_l,               &
-                                       logc_kbounds_w_l,                       &
-                                       nzt_topo_nestbc_l, 'l', 'e' )
-
+             IF ( .NOT. constant_diffusion )  THEN
+                CALL pmci_interp_tril_lr( e,  ec,  ico, jco, kco, r1xo, r2xo,  &
+                                          r1yo, r2yo, r1zo, r2zo,              &
+                                          logc_w_l, logc_ratio_w_l,            &
+                                          logc_kbounds_w_l,                    &
+                                          nzt_topo_nestbc_l, 'l', 'e' )
+             ENDIF
+             
              IF ( .NOT. neutral )  THEN
                 CALL pmci_interp_tril_lr( pt, ptc, ico, jco, kco, r1xo, r2xo,  &
@@ -4269,4 +4285,5 @@
 !--       Right border pe
           IF ( nest_bound_r )  THEN
+             
              CALL pmci_interp_tril_lr( u,  uc,  icu, jco, kco, r1xu, r2xu,     &
                                        r1yo, r2yo, r1zo, r2zo,                 &
@@ -4287,10 +4304,11 @@
                                        nzt_topo_nestbc_r, 'r', 'w' )
 
-             CALL pmci_interp_tril_lr( e,  ec,  ico, jco, kco, r1xo, r2xo,     &
-                                       r1yo,r2yo, r1zo, r2zo,                  &
-                                       logc_w_r, logc_ratio_w_r,               &
-                                       logc_kbounds_w_r,                       &
-                                       nzt_topo_nestbc_r, 'r', 'e' )
-
+             IF ( .NOT. constant_diffusion )  THEN
+                CALL pmci_interp_tril_lr( e,  ec,  ico, jco, kco, r1xo, r2xo,  &
+                                          r1yo,r2yo, r1zo, r2zo,               &
+                                          logc_w_r, logc_ratio_w_r,            &
+                                          logc_kbounds_w_r,                    &
+                                          nzt_topo_nestbc_r, 'r', 'e' )
+             ENDIF
 
              IF ( .NOT. neutral )  THEN
@@ -4300,5 +4318,4 @@
                                           logc_kbounds_w_r,                    &
                                           nzt_topo_nestbc_r, 'r', 's' )
-
              ENDIF
 
@@ -4370,4 +4387,5 @@
 !--       South border pe
           IF ( nest_bound_s )  THEN
+
              CALL pmci_interp_tril_sn( u,  uc,  icu, jco, kco, r1xu, r2xu,     &
                                        r1yo, r2yo, r1zo, r2zo,                 &
@@ -4375,4 +4393,5 @@
                                        logc_kbounds_u_s,                       &
                                        nzt_topo_nestbc_s, 's', 'u' )
+
              CALL pmci_interp_tril_sn( v,  vc,  ico, jcv, kco, r1xo, r2xo,     &
                                        r1yv, r2yv, r1zo, r2zo,                 &
@@ -4380,4 +4399,5 @@
                                        logc_kbounds_v_s,                       &
                                        nzt_topo_nestbc_s, 's', 'v' )
+
              CALL pmci_interp_tril_sn( w,  wc,  ico, jco, kcw, r1xo, r2xo,     &
                                        r1yo, r2yo, r1zw, r2zw,                 &
@@ -4385,10 +4405,13 @@
                                        logc_kbounds_w_s,                       &
                                        nzt_topo_nestbc_s, 's','w' )
-             CALL pmci_interp_tril_sn( e,  ec,  ico, jco, kco, r1xo, r2xo,     &
-                                       r1yo, r2yo, r1zo, r2zo,                 &
-                                       logc_w_s, logc_ratio_w_s,               &
-                                       logc_kbounds_w_s,                       &
-                                       nzt_topo_nestbc_s, 's', 'e' )
-
+
+             IF ( .NOT. constant_diffusion )  THEN
+                CALL pmci_interp_tril_sn( e,  ec,  ico, jco, kco, r1xo, r2xo,  &
+                                          r1yo, r2yo, r1zo, r2zo,              &
+                                          logc_w_s, logc_ratio_w_s,            &
+                                          logc_kbounds_w_s,                    &
+                                          nzt_topo_nestbc_s, 's', 'e' )
+             ENDIF
+          
              IF ( .NOT. neutral )  THEN
                 CALL pmci_interp_tril_sn( pt, ptc, ico, jco, kco, r1xo, r2xo,  &
@@ -4464,4 +4487,5 @@
 !--       North border pe
           IF ( nest_bound_n )  THEN
+             
              CALL pmci_interp_tril_sn( u,  uc,  icu, jco, kco, r1xu, r2xu,     &
                                        r1yo, r2yo, r1zo, r2zo,                 &
@@ -4481,11 +4505,12 @@
                                        logc_kbounds_w_n,                       &
                                        nzt_topo_nestbc_n, 'n', 'w' )
-
-             CALL pmci_interp_tril_sn( e,  ec,  ico, jco, kco, r1xo, r2xo,     &
-                                       r1yo, r2yo, r1zo, r2zo,                 &
-                                       logc_w_n, logc_ratio_w_n,               &
-                                       logc_kbounds_w_n,                       &
-                                       nzt_topo_nestbc_n, 'n', 'e' )
-
+             IF ( .NOT. constant_diffusion )  THEN
+                CALL pmci_interp_tril_sn( e,  ec,  ico, jco, kco, r1xo, r2xo,  &
+                                          r1yo, r2yo, r1zo, r2zo,              &
+                                          logc_w_n, logc_ratio_w_n,            &
+                                          logc_kbounds_w_n,                    &
+                                          nzt_topo_nestbc_n, 'n', 'e' )
+             ENDIF
+          
              IF ( .NOT. neutral )  THEN
                 CALL pmci_interp_tril_sn( pt, ptc, ico, jco, kco, r1xo, r2xo,  &
@@ -4568,7 +4593,8 @@
        CALL pmci_interp_tril_t( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo,      &
                                 r2yo, r1zw, r2zw, 'w' )
-       CALL pmci_interp_tril_t( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo,      &
-                                r2yo, r1zo, r2zo, 'e' )
-
+       IF ( .NOT. constant_diffusion )  THEN
+          CALL pmci_interp_tril_t( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo,   &
+                                   r2yo, r1zo, r2zo, 'e' )
+       ENDIF
        IF ( .NOT. neutral )  THEN
           CALL pmci_interp_tril_t( pt, ptc, ico, jco, kco, r1xo, r2xo, r1yo,   &
@@ -4797,5 +4823,5 @@
 !
 !--   Solid surface below the node 
-      IF ( var == 'u' .OR. var == 'v' )  THEN           
+      IF ( constant_flux_layer .AND. ( var == 'u' .OR. var == 'v' ) )  THEN
          DO  j = nys, nyn
 !
@@ -4820,5 +4846,5 @@
       IF ( topography /= 'flat' )  THEN
 
-         IF ( var == 'u' .OR. var == 'w' )  THEN                 
+         IF ( constant_flux_layer .AND. ( var == 'u' .OR. var == 'w' ) )  THEN           
 !
 !--         Solid surface only on south/north side of the node                   
@@ -4843,5 +4869,5 @@
 !
 !--      Solid surface on both below and on south/north side of the node           
-         IF ( var == 'u' )  THEN
+         IF ( constant_flux_layer .AND. var == 'u' )  THEN
             DO  j = nys, nyn
                k = logc_kbounds(1,j)
@@ -5014,5 +5040,5 @@
 !
 !--   Solid surface below the node 
-      IF ( var == 'u'  .OR.  var == 'v' )  THEN           
+      IF ( constant_flux_layer .AND. ( var == 'u'  .OR.  var == 'v' ) )  THEN           
          DO  i = nxl, nxr
 !
@@ -5038,5 +5064,5 @@
       IF ( topography /= 'flat' )  THEN
 
-         IF ( var == 'v' .OR. var == 'w' )  THEN
+         IF ( constant_flux_layer .AND. ( var == 'v' .OR. var == 'w' ) )  THEN
             DO  i = nxl, nxr
                DO  k = logc_kbounds(1,i), logc_kbounds(2,i)
@@ -5061,5 +5087,5 @@
 !
 !--      Solid surface on both below and on left/right side of the node           
-         IF ( var == 'v' )  THEN
+         IF ( constant_flux_layer .AND. var == 'v' )  THEN
             DO  i = nxl, nxr
                k = logc_kbounds(1,i)
