Index: palm/trunk/SOURCE/prandtl_fluxes.f90
===================================================================
--- palm/trunk/SOURCE/prandtl_fluxes.f90	(revision 1321)
+++ palm/trunk/SOURCE/prandtl_fluxes.f90	(revision 1340)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-!
+! REAL constants defined as wp-kind
 !
 ! Former revisions:
@@ -105,10 +105,10 @@
        DO  i = nxlg, nxrg
           DO  j = nysg, nyng
-             ts(j,i) = -shf(j,i) / ( us(j,i) + 1E-30 )
+             ts(j,i) = -shf(j,i) / ( us(j,i) + 1E-30_wp )
 !
 !--          ts must be limited, because otherwise overflow may occur in case of
 !--          us=0 when computing rif further below
-             IF ( ts(j,i) < -1.05E5 )  ts(j,i) = -1.0E5
-             IF ( ts(j,i) >   1.0E5 )  ts(j,i) =  1.0E5
+             IF ( ts(j,i) < -1.05E5_wp )  ts(j,i) = -1.0E5_wp
+             IF ( ts(j,i) >   1.0E5_wp )  ts(j,i) =  1.0E5_wp
           ENDDO
        ENDDO
@@ -131,20 +131,20 @@
              z_p = zu(k+1) - zw(k)
 
-             IF ( rif(j,i) >= 0.0 )  THEN
+             IF ( rif(j,i) >= 0.0_wp )  THEN
 !
 !--             Stable stratification
                 ts(j,i) = kappa * ( pt(k+1,j,i) - pt(k,j,i) ) / (           &
                                   LOG( z_p / z0h(j,i) ) +                   &
-                                  5.0 * rif(j,i) * ( z_p - z0h(j,i) ) / z_p &
+                                  5.0_wp * rif(j,i) * ( z_p - z0h(j,i) ) / z_p &
                                                                 )
              ELSE
 !
 !--             Unstable stratification
-                a = SQRT( 1.0 - 16.0 * rif(j,i) )
-                b = SQRT( 1.0 - 16.0 * rif(j,i) * z0h(j,i) / z_p )
+                a = SQRT( 1.0_wp - 16.0_wp * rif(j,i) )
+                b = SQRT( 1.0_wp - 16.0_wp * rif(j,i) * z0h(j,i) / z_p )
 
                 ts(j,i) = kappa * ( pt(k+1,j,i) - pt(k,j,i) ) /  (          &
                           LOG( z_p / z0h(j,i) ) -                           &
-                          2.0 * LOG( ( 1.0 + a ) / ( 1.0 + b ) ) )
+                          2.0_wp * LOG( ( 1.0_wp + a ) / ( 1.0_wp + b ) ) )
              ENDIF
 
@@ -163,5 +163,5 @@
              z_p = zu(k+1) - zw(k)
              rif(j,i) = z_p * kappa * g * ts(j,i) / &
-                        ( pt(k+1,j,i) * ( us(j,i)**2 + 1E-30 ) )
+                        ( pt(k+1,j,i) * ( us(j,i)**2 + 1E-30_wp ) )
 !
 !--          Limit the value range of the Richardson numbers.
@@ -182,6 +182,6 @@
              z_p = zu(k+1) - zw(k)
              rif(j,i) = z_p * kappa * g *                            &
-                        ( ts(j,i) + 0.61 * pt(k+1,j,i) * qs(j,i) ) / &
-                        ( vpt(k+1,j,i) * ( us(j,i)**2 + 1E-30 ) )
+                        ( ts(j,i) + 0.61_wp * pt(k+1,j,i) * qs(j,i) ) / &
+                        ( vpt(k+1,j,i) * ( us(j,i)**2 + 1E-30_wp ) )
 !
 !--          Limit the value range of the Richardson numbers.
@@ -209,28 +209,28 @@
 !--       Compute the absolute value of the horizontal velocity 
 !--       (relative to the surface)
-          uv_total = SQRT( ( 0.5 * ( u(k+1,j,i) + u(k+1,j,i+1)        &
-                                   - u(k,j,i)   - u(k,j,i+1) ) )**2 + &
-                           ( 0.5 * ( v(k+1,j,i) + v(k+1,j+1,i)        &
-                                   - v(k,j,i)   - v(k,j+1,i) ) )**2 )    
-
-
-          IF ( rif(j,i) >= 0.0 )  THEN
+          uv_total = SQRT( ( 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1)        &
+                                      - u(k,j,i)   - u(k,j,i+1) ) )**2 + &
+                           ( 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i)        &
+                                      - v(k,j,i)   - v(k,j+1,i) ) )**2 )    
+
+
+          IF ( rif(j,i) >= 0.0_wp )  THEN
 !
 !--          Stable stratification
              us(j,i) = kappa * uv_total / (                                &
                                   LOG( z_p / z0(j,i) ) +                   &
-                                  5.0 * rif(j,i) * ( z_p - z0(j,i) ) / z_p &
+                                  5.0_wp * rif(j,i) * ( z_p - z0(j,i) ) / z_p &
                                           )
           ELSE
 !
 !--          Unstable stratification
-             a = SQRT( SQRT( 1.0 - 16.0 * rif(j,i) ) )
-             b = SQRT( SQRT( 1.0 - 16.0 * rif(j,i) / z_p * z0(j,i) ) )
+             a = SQRT( SQRT( 1.0_wp - 16.0_wp * rif(j,i) ) )
+             b = SQRT( SQRT( 1.0_wp - 16.0_wp * rif(j,i) / z_p * z0(j,i) ) )
 
              us(j,i) = kappa * uv_total / (                                  &
                        LOG( z_p / z0(j,i) ) -                                &
-                       LOG( ( 1.0 + a )**2 * ( 1.0 + a**2 ) / (              &
-                            ( 1.0 + b )**2 * ( 1.0 + b**2 )   ) ) +          &
-                            2.0 * ( ATAN( a ) - ATAN( b ) )                  &
+                       LOG( ( 1.0_wp + a )**2 * ( 1.0_wp + a**2 ) / (              &
+                            ( 1.0_wp + b )**2 * ( 1.0_wp + b**2 )   ) ) +          &
+                               2.0_wp * ( ATAN( a ) - ATAN( b ) )                  &
                                            )
           ENDIF
@@ -258,26 +258,26 @@
 !
 !--       Compute Richardson-flux number for this point
-          rifm = 0.5 * ( rif(j,i-1) + rif(j,i) )
-          IF ( rifm >= 0.0 )  THEN
+          rifm = 0.5_wp * ( rif(j,i-1) + rif(j,i) )
+          IF ( rifm >= 0.0_wp )  THEN
 !
 !--          Stable stratification
              usws(j,i) = kappa * ( u(k+1,j,i) - u(k,j,i) )/ (              &
                                      LOG( z_p / z0(j,i) ) +               &
-                                     5.0 * rifm * ( z_p - z0(j,i) ) / z_p &
-                                              )
+                                     5.0_wp * rifm * ( z_p - z0(j,i) ) / z_p &
+                                                            )
           ELSE
 !
 !--          Unstable stratification
-             a = SQRT( SQRT( 1.0 - 16.0 * rifm ) )
-             b = SQRT( SQRT( 1.0 - 16.0 * rifm / z_p * z0(j,i) ) )
+             a = SQRT( SQRT( 1.0_wp - 16.0_wp * rifm ) )
+             b = SQRT( SQRT( 1.0_wp - 16.0_wp * rifm / z_p * z0(j,i) ) )
 
              usws(j,i) = kappa * ( u(k+1,j,i) - u(k,j,i) ) / (            &
                          LOG( z_p / z0(j,i) ) -                           &
-                         LOG( (1.0 + a )**2 * ( 1.0 + a**2 ) / (          &
-                              (1.0 + b )**2 * ( 1.0 + b**2 )   ) ) +      &
-                              2.0 * ( ATAN( a ) - ATAN( b ) )             &
+                         LOG( (1.0_wp + a )**2 * ( 1.0_wp + a**2 ) / (          &
+                              (1.0_wp + b )**2 * ( 1.0_wp + b**2 )   ) ) +      &
+                                 2.0_wp * ( ATAN( a ) - ATAN( b ) )             &
                                                  )
           ENDIF
-          usws(j,i) = -usws(j,i) * 0.5 * ( us(j,i-1) + us(j,i) )
+          usws(j,i) = -usws(j,i) * 0.5_wp * ( us(j,i-1) + us(j,i) )
        ENDDO
     ENDDO
@@ -296,26 +296,26 @@
 !
 !--       Compute Richardson-flux number for this point
-          rifm = 0.5 * ( rif(j-1,i) + rif(j,i) )
-          IF ( rifm >= 0.0 )  THEN
+          rifm = 0.5_wp * ( rif(j-1,i) + rif(j,i) )
+          IF ( rifm >= 0.0_wp )  THEN
 !
 !--          Stable stratification
              vsws(j,i) = kappa * ( v(k+1,j,i) -  v(k,j,i) ) / (           &
                                      LOG( z_p / z0(j,i) ) +               &
-                                     5.0 * rifm * ( z_p - z0(j,i) ) / z_p &
-                                              )
+                                     5.0_wp * rifm * ( z_p - z0(j,i) ) / z_p &
+                                                              )
           ELSE
 !
 !--          Unstable stratification
-             a = SQRT( SQRT( 1.0 - 16.0 * rifm ) )
-             b = SQRT( SQRT( 1.0 - 16.0 * rifm / z_p * z0(j,i) ) )
+             a = SQRT( SQRT( 1.0_wp - 16.0_wp * rifm ) )
+             b = SQRT( SQRT( 1.0_wp - 16.0_wp * rifm / z_p * z0(j,i) ) )
 
              vsws(j,i) = kappa * ( v(k+1,j,i) - v(k,j,i) ) / (            &
                          LOG( z_p / z0(j,i) ) -                           &
-                         LOG( (1.0 + a )**2 * ( 1.0 + a**2 ) / (          &
-                              (1.0 + b )**2 * ( 1.0 + b**2 )   ) ) +      &
-                              2.0 * ( ATAN( a ) - ATAN( b ) )             &
+                         LOG( (1.0_wp + a )**2 * ( 1.0_wp + a**2 ) / (          &
+                              (1.0_wp + b )**2 * ( 1.0_wp + b**2 )   ) ) +      &
+                                 2.0_wp * ( ATAN( a ) - ATAN( b ) )             &
                                                  )
           ENDIF
-          vsws(j,i) = -vsws(j,i) * 0.5 * ( us(j-1,i) + us(j,i) )
+          vsws(j,i) = -vsws(j,i) * 0.5_wp * ( us(j-1,i) + us(j,i) )
        ENDDO
     ENDDO
@@ -331,5 +331,5 @@
           DO  i = nxlg, nxrg
              DO  j = nysg, nyng
-                qs(j,i) = -qsws(j,i) / ( us(j,i) + 1E-30 )
+                qs(j,i) = -qsws(j,i) / ( us(j,i) + 1E-30_wp )
              ENDDO
           ENDDO
@@ -355,24 +355,24 @@
 !--             in case of precursor runs)
                 IF ( coupled_run )  THEN
-                   e_q = 6.1 * &
-                        EXP( 0.07 * ( MIN(pt(0,j,i),pt(1,j,i)) - 273.15 ) )
-                   q(k,j,i) = 0.622 * e_q / ( surface_pressure - e_q )
+                   e_q = 6.1_wp * &
+                           EXP( 0.07_wp * ( MIN(pt(0,j,i),pt(1,j,i)) - 273.15_wp ) )
+                   q(k,j,i) = 0.622_wp * e_q / ( surface_pressure - e_q )
                 ENDIF
-                IF ( rif(j,i) >= 0.0 )  THEN
+                IF ( rif(j,i) >= 0.0_wp )  THEN
 !
 !--                Stable stratification
                    qs(j,i) = kappa * ( q(k+1,j,i) - q(k,j,i) ) / (          &
                                   LOG( z_p / z0h(j,i) ) +                   &
-                                  5.0 * rif(j,i) * ( z_p - z0h(j,i) ) / z_p &
+                                  5.0_wp * rif(j,i) * ( z_p - z0h(j,i) ) / z_p &
                                                                  )
                 ELSE
 !
 !--                Unstable stratification
-                   a = SQRT( 1.0 - 16.0 * rif(j,i) ) 
-                   b = SQRT( 1.0 - 16.0 * rif(j,i) * z0h(j,i) / z_p ) 
+                   a = SQRT( 1.0_wp - 16.0_wp * rif(j,i) ) 
+                   b = SQRT( 1.0_wp - 16.0_wp * rif(j,i) * z0h(j,i) / z_p ) 
  
                    qs(j,i) = kappa * ( q(k+1,j,i) - q(k,j,i) ) /   (        &
                              LOG( z_p / z0h(j,i) ) -                        &
-                              2.0 * LOG( (1.0 + a ) / ( 1.0 + b ) ) )
+                              2.0_wp * LOG( (1.0_wp + a ) / ( 1.0_wp + b ) ) )
                 ENDIF
 
@@ -429,8 +429,8 @@
           !$acc loop independent
           DO  j = nysg, nyng
-             e(nzb_s_inner(j,i)+1,j,i) = ( us(j,i) / 0.1 )**2
+             e(nzb_s_inner(j,i)+1,j,i) = ( us(j,i) / 0.1_wp )**2
 !
 !--          As a test: cm = 0.4
-!            e(nzb_s_inner(j,i)+1,j,i) = ( us(j,i) / 0.4 )**2
+!            e(nzb_s_inner(j,i)+1,j,i) = ( us(j,i) / 0.4_wp )**2
              e(nzb_s_inner(j,i),j,i)   = e(nzb_s_inner(j,i)+1,j,i)
           ENDDO
