Index: /palm/trunk/SOURCE/pmc_interface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 3019)
+++ /palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 3020)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Bugfix in pmci_define_loglaw_correction_parameters
+! 
+! 3001 2018-04-20 12:27:13Z suehring
 ! Bugfix, replace MERGE function by an if-condition in the anterpolation (in 
 ! order to avoid floating-point exceptions).
@@ -2673,23 +2676,23 @@
        IMPLICIT NONE
 
-       INTEGER(iwp), INTENT(IN)  ::  direction  !<
-       INTEGER(iwp), INTENT(IN)  ::  ij         !<
-       INTEGER(iwp), INTENT(IN)  ::  inc        !<
-       INTEGER(iwp), INTENT(IN)  ::  k          !<
-       INTEGER(iwp), INTENT(IN)  ::  kb         !<
-       INTEGER(iwp), INTENT(OUT) ::  lc         !<
-       INTEGER(iwp), INTENT(IN)  ::  ncorr      !<
-       INTEGER(iwp), INTENT(IN)  ::  wall_index !<
-
-       INTEGER(iwp) ::  alcorr       !<
-       INTEGER(iwp) ::  corr_index   !<
-       INTEGER(iwp) ::  lcorr        !<
-
-       LOGICAL      ::  more         !<
+       INTEGER(iwp), INTENT(IN)  ::  direction                 !<
+       INTEGER(iwp), INTENT(IN)  ::  ij                        !<
+       INTEGER(iwp), INTENT(IN)  ::  inc                       !<
+       INTEGER(iwp), INTENT(IN)  ::  k                         !<
+       INTEGER(iwp), INTENT(IN)  ::  kb                        !<
+       INTEGER(iwp), INTENT(OUT) ::  lc                        !<
+       INTEGER(iwp), INTENT(IN)  ::  ncorr                     !<
+       INTEGER(iwp), INTENT(IN)  ::  wall_index                !<
+
+       INTEGER(iwp) ::  alcorr                                 !<
+       INTEGER(iwp) ::  corr_index                             !<
+       INTEGER(iwp) ::  lcorr                                  !<
+
+       LOGICAL      ::  more                                   !<             
 
        REAL(wp), DIMENSION(0:ncorr-1), INTENT(OUT) ::  lcr     !<
        REAL(wp), INTENT(IN)      ::  z0_l                      !<
       
-       REAL(wp)     ::  logvelc1     !<
+       REAL(wp)     ::  logvelc1                               !<
       
 
@@ -2728,5 +2731,5 @@
 !--             The role of inc here is to make the comparison operation "<"
 !--             valid in both directions
-                IF ( inc * corr_index < inc * lc )  THEN
+                IF ( ( inc * corr_index < inc * lc ) .AND. ( lc /= -99 ) )  THEN
                    lcr(alcorr) = LOG( ABS( coord_y(corr_index) + 0.5_wp * dy   &
                                          - coord_y(wall_index) ) / z0_l )      &
@@ -2754,5 +2757,5 @@
 !--             The role of inc here is to make the comparison operation "<"
 !--             valid in both directions
-                IF ( inc * corr_index < inc * lc )  THEN
+                IF ( ( inc * corr_index < inc * lc ) .AND. ( lc /= -99 ) )  THEN
                    lcr(alcorr) = LOG( ABS( coord_x(corr_index) + 0.5_wp * dx   &
                                          - coord_x(wall_index) ) / z0_l )      &
@@ -2787,11 +2790,11 @@
        INTEGER(iwp), INTENT(OUT) ::  lc   !<
 
-       INTEGER(iwp) ::  kbc    !<
-       INTEGER(iwp) ::  k1     !<
-
-       REAL(wp), INTENT(OUT) ::  logzc1     !<
-       REAL(wp), INTENT(IN) ::  z0_l       !<
-
-       REAL(wp) ::  zuc1   !<
+       INTEGER(iwp) ::  kbc               !<
+       INTEGER(iwp) ::  k1                !<
+
+       REAL(wp), INTENT(OUT) ::  logzc1   !<
+       REAL(wp), INTENT(IN)  ::  z0_l     !<
+
+       REAL(wp) ::  zuc1                  !<
 
 !
@@ -2829,12 +2832,12 @@
        INTEGER(iwp), INTENT(OUT) ::  lc     !<
 
-       INTEGER(iwp) ::  jwc      !<
-       INTEGER(iwp) ::  j1       !<
-
-       REAL(wp), INTENT(IN) ::  z0_l   !<
-
-       REAL(wp) ::  logyc1   !<
-       REAL(wp) ::  ycb      !<       
-       REAL(wp) ::  yc1      !<
+       INTEGER(iwp) ::  jwc                 !<
+       INTEGER(iwp) ::  j1                  !<
+
+       REAL(wp), INTENT(IN)  ::  z0_l       !<
+       REAL(wp), INTENT(OUT) ::  logyc1     !<
+
+       REAL(wp) ::  ycb                     !<       
+       REAL(wp) ::  yc1                     !<
        
 !
@@ -2849,6 +2852,8 @@
        IF ( yc1 < ( REAL( nysg, KIND=wp ) + 0.5_wp ) * dy  )  THEN
           lc = -99
+          logyc1 = 1.0_wp
        ELSE IF ( yc1 > ( REAL( nyng, KIND=wp ) + 0.5_wp ) * dy )  THEN
           lc = -99
+          logyc1 = 1.0_wp
        ELSE
 !
@@ -2886,12 +2891,12 @@
        INTEGER(iwp), INTENT(OUT) ::  lc     !<
 
-       INTEGER(iwp) ::  iwc      !<
-       INTEGER(iwp) ::  i1       !<
-
-       REAL(wp), INTENT(IN) ::  z0_l   !<
-
-       REAL(wp) ::  logxc1   !<
-       REAL(wp) ::  xcb      !<
-       REAL(wp) ::  xc1      !<
+       INTEGER(iwp) ::  iwc                 !<
+       INTEGER(iwp) ::  i1                  !<
+
+       REAL(wp), INTENT(IN)  ::  z0_l       !<
+       REAL(wp), INTENT(OUT) ::  logxc1     !<
+
+       REAL(wp) ::  xcb                     !<
+       REAL(wp) ::  xc1                     !<
 
 !
@@ -2906,6 +2911,8 @@
        IF ( xc1 < ( REAL( nxlg, KIND=wp ) + 0.5_wp ) * dx  )  THEN
           lc = -99
+          logxc1 = 1.0_wp
        ELSE IF ( xc1 > ( REAL( nxrg, KIND=wp ) + 0.5_wp ) * dx )  THEN
           lc = -99
+          logxc1 = 1.0_wp
        ELSE    
 !
