Index: /palm/trunk/SOURCE/bulk_cloud_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/bulk_cloud_model_mod.f90	(revision 3444)
+++ /palm/trunk/SOURCE/bulk_cloud_model_mod.f90	(revision 3445)
@@ -25,6 +25,9 @@
 ! -----------------
 ! $Id$
+! Minor bugfix and use of subroutine for supersaturation calculation in case
+! of cache version
+! 
+! 3383 2018-10-19 14:22:58Z knoop
 ! Modularization of all bulk cloud physics code components
-! 
 ! 
 ! unused variables removed
@@ -2163,6 +2166,5 @@
 
 !
-!--             Call calculation of supersaturation located 
-!--             in diagnostic_quantities_mod
+!--             Call calculation of supersaturation located in subroutine
                 CALL supersaturation ( i, j, k )
 !
@@ -2267,6 +2269,5 @@
                 flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i), 0 ) )
 !
-!--             Call calculation of supersaturation located 
-!--             in diagnostic_quantities_mod
+!--             Call calculation of supersaturation 
                 CALL supersaturation ( i, j, k )
 !
@@ -2683,6 +2684,5 @@
 
 !
-!--                Call calculation of supersaturation located 
-!--                in diagnostic_quantities_mod
+!--                Call calculation of supersaturation  
                    CALL supersaturation ( i, j, k )
 !
@@ -3281,20 +3281,14 @@
        REAL(wp)     ::  activ             !<
        REAL(wp)     ::  afactor           !<
-       REAL(wp)     ::  alpha             !<
        REAL(wp)     ::  beta_act          !<
        REAL(wp)     ::  bfactor           !<
-       REAL(wp)     ::  e_s               !<
        REAL(wp)     ::  flag              !< flag to indicate first grid level above surface
        REAL(wp)     ::  k_act             !<
        REAL(wp)     ::  n_act             !<
        REAL(wp)     ::  n_ccn             !<
-       REAL(wp)     ::  q_s               !<
        REAL(wp)     ::  s_0               !<
-       REAL(wp)     ::  sat               !<
        REAL(wp)     ::  sat_max           !<
        REAL(wp)     ::  sigma             !<
        REAL(wp)     ::  sigma_act         !<
-       REAL(wp)     ::  t_int             !<
-       REAL(wp)     ::  t_l               !<
 
        DO  k = nzb+1, nzt
@@ -3303,25 +3297,6 @@
           flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i), 0 ) )
 !
-!--       Actual liquid water temperature:
-          t_l = exner(k) * pt(k,j,i)
-
-!
-!--       Calculate actual temperature
-          t_int = pt(k,j,i) * exner_function( hyp(k) )
-!
-!--             Saturation vapor pressure at t_l:
-          e_s = 610.78_wp * EXP( 17.269_wp * ( t_l - 273.16_wp ) /             &
-                                 ( t_l - 35.86_wp )                            &
-                                 )
-!
-!--       Computation of saturation mixing ratio:
-          q_s   = rd_d_rv * e_s / ( hyp(k) -  e_s )
-          alpha = rd_d_rv * lv_d_rd * lv_d_cp / ( t_l * t_l )
-          q_s   = q_s * ( 1.0_wp + alpha * q(k,j,i) ) /                        &
-                        ( 1.0_wp + alpha * q_s )
-
-!--       Supersaturation:
-          sat   = ( q(k,j,i) - qr(k,j,i) - qc(k,j,i) ) / q_s - 1.0_wp
-
+!--       Call calculation of supersaturation  
+          CALL supersaturation ( i, j, k )
 !
 !--       Prescribe parameters for activation
@@ -3330,5 +3305,5 @@
           activ  = 0.0_wp
 
-          IF ( sat >= 0.0 .AND. .NOT. curvature_solution_effects_bulk )  THEN
+          IF ( sat > 0.0 .AND. .NOT. curvature_solution_effects_bulk )  THEN
 !
 !--          Compute the number of activated Aerosols
@@ -3349,10 +3324,10 @@
 
              nc(k,j,i) = MIN( (nc(k,j,i) + activ * dt_micro), na_init)
-          ELSEIF ( sat >= 0.0 .AND. curvature_solution_effects_bulk )  THEN
+          ELSEIF ( sat > 0.0 .AND. curvature_solution_effects_bulk )  THEN
 !
 !--          Curvature effect (afactor) with surface tension
 !--          parameterization by Straka (2009)
-             sigma = 0.0761_wp - 0.000155_wp * ( t_int - 273.15_wp )
-             afactor = 2.0_wp * sigma / ( rho_l * r_v * t_int )
+             sigma = 0.0761_wp - 0.000155_wp * ( t_l - 273.15_wp )
+             afactor = 2.0_wp * sigma / ( rho_l * r_v * t_l )
 !
 !--          Solute effect (bfactor)
@@ -3401,16 +3376,11 @@
        INTEGER(iwp) ::  k                 !<
 
-       REAL(wp)     ::  alpha             !<
        REAL(wp)     ::  cond              !<
        REAL(wp)     ::  cond_max          !<
        REAL(wp)     ::  dc                !<
-       REAL(wp)     ::  e_s               !<
        REAL(wp)     ::  evap              !<
        REAL(wp)     ::  flag              !< flag to indicate first grid level above surface
        REAL(wp)     ::  g_fac             !<
        REAL(wp)     ::  nc_0              !<
-       REAL(wp)     ::  q_s               !<
-       REAL(wp)     ::  sat               !<
-       REAL(wp)     ::  t_l               !<
        REAL(wp)     ::  temp              !<
        REAL(wp)     ::  xc                !<
@@ -3422,22 +3392,6 @@
           flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i), 0 ) )
 !
-!--       Actual liquid water temperature:
-          t_l = exner(k) * pt(k,j,i)
-!
-!--             Saturation vapor pressure at t_l:
-          e_s = 610.78_wp * EXP( 17.269_wp * ( t_l - 273.16_wp ) /    &
-                                 ( t_l - 35.86_wp )                   &
-                                 )
-!
-!--       Computation of saturation mixing ratio:
-          q_s   = rd_d_rv * e_s / ( hyp(k) - e_s )
-          alpha = rd_d_rv * lv_d_rd * lv_d_cp / ( t_l * t_l )
-          q_s   = q_s * ( 1.0_wp + alpha * q(k,j,i) ) /               &
-                        ( 1.0_wp + alpha * q_s )
-
-!--       Supersaturation:
-          sat   = ( q(k,j,i) - qr(k,j,i) - qc(k,j,i) ) / q_s - 1.0_wp
-
-
+!--       Call calculation of supersaturation  
+          CALL supersaturation ( i, j, k )
 !
 !--       Actual temperature:
@@ -3776,7 +3730,5 @@
        INTEGER(iwp) ::  k                 !<
 
-       REAL(wp)     ::  alpha             !<
        REAL(wp)     ::  dr                !<
-       REAL(wp)     ::  e_s               !<
        REAL(wp)     ::  evap              !<
        REAL(wp)     ::  evap_nr           !<
@@ -3789,7 +3741,4 @@
        REAL(wp)     ::  mu_r_5d2          !<
        REAL(wp)     ::  nr_0              !<
-       REAL(wp)     ::  q_s               !<
-       REAL(wp)     ::  sat               !<
-       REAL(wp)     ::  t_l               !<
        REAL(wp)     ::  temp              !<
        REAL(wp)     ::  xr                !<
@@ -3802,19 +3751,6 @@
           IF ( qr(k,j,i) > eps_sb )  THEN
 !
-!--          Actual liquid water temperature:
-             t_l = exner(k) * pt(k,j,i)
-!
-!--          Saturation vapor pressure at t_l:
-             e_s = 610.78_wp * EXP( 17.269_wp * ( t_l - 273.16_wp ) /          &
-                                    ( t_l - 35.86_wp )                         &
-                                  )
-!
-!--          Computation of saturation mixing ratio:
-             q_s   = rd_d_rv * e_s / ( hyp(k) - e_s )
-             alpha = rd_d_rv * lv_d_rd * lv_d_cp / ( t_l * t_l )
-             q_s   = q_s * ( 1.0_wp + alpha * q(k,j,i) ) / ( 1.0_wp + alpha * q_s )
-!
-!--          Supersaturation:
-             sat   = ( q(k,j,i) - qr(k,j,i) - qc(k,j,i) ) / q_s - 1.0_wp
+!--          Call calculation of supersaturation  
+             CALL supersaturation ( i, j, k )
 !
 !--          Evaporation needs only to be calculated in subsaturated regions
@@ -4304,5 +4240,4 @@
    !
    !--          Call calculation of supersaturation located
-   !--          in diagnostic_quantities_mod
                 CALL supersaturation( i, j, k )
 
