Changeset 4502


Ignore:
Timestamp:
Apr 17, 2020 4:14:16 PM (4 years ago)
Author:
schwenkel
Message:

Implementation of ice microphysics

Location:
palm/trunk/SOURCE
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/advec_s_bc.f90

    r4488 r4502  
    2424! -----------------
    2525! $Id$
     26! Implementation of ice microphysics
     27!
     28! 4488 2020-04-03 11:34:29Z raasch
    2629! file re-formatted to follow the PALM coding standard
    2730!
     
    957960          ENDDO
    958961
    959        ELSEIF ( sk_char == 'qr' )  THEN
    960 
    961 !
    962 !--       Rain water content boundary condition at the bottom boundary: Dirichlet (fixed surface
    963 !--       rain water content).
     962       ELSEIF ( sk_char == 'qi' )  THEN
     963
     964!
     965!--       Ice crystal content boundary condition at the bottom boundary:
     966!--       Dirichlet (fixed surface rain water content).
    964967          DO  i = nxl, nxr
    965968             DO  j = nys, nyn
     
    971974
    972975!
    973 !--       Rain water content boundary condition at the top boundary: Dirichlet
     976!--       Ice crystal content boundary condition at the top boundary: Dirichlet
    974977          DO  i = nxl, nxr
    975978             DO  j = nys, nyn
     
    979982          ENDDO
    980983
    981        ELSEIF ( sk_char == 'nc' )  THEN
    982 
    983 !
    984 !--       Cloud drop concentration boundary condition at the bottom boundary: Dirichlet (fixed
    985 !--       surface cloud drop concentration).
     984       ELSEIF ( sk_char == 'qr' )  THEN
     985
     986!
     987!--       Rain water content boundary condition at the bottom boundary: Dirichlet (fixed surface
     988!--       rain water content).
    986989          DO  i = nxl, nxr
    987990             DO  j = nys, nyn
     
    993996
    994997!
     998!--       Rain water content boundary condition at the top boundary: Dirichlet
     999          DO  i = nxl, nxr
     1000             DO  j = nys, nyn
     1001                sk_p(nzt+2,j,i)   = sk_p(nzt+1,j,i)
     1002                sk_p(nzt+3,j,i)   = sk_p(nzt+1,j,i)
     1003             ENDDO
     1004          ENDDO
     1005
     1006       ELSEIF ( sk_char == 'nc' )  THEN
     1007
     1008!
     1009!--       Cloud drop concentration boundary condition at the bottom boundary: Dirichlet (fixed
     1010!--       surface cloud drop concentration).
     1011          DO  i = nxl, nxr
     1012             DO  j = nys, nyn
     1013                sk_p(nzb,j,i)   = sk_p(nzb+1,j,i)
     1014                sk_p(nzb-1,j,i) = sk_p(nzb,j,i)
     1015                sk_p(nzb-2,j,i) = sk_p(nzb,j,i)
     1016             ENDDO
     1017          ENDDO
     1018
     1019!
    9951020!--       Cloud drop concentration boundary condition at the top boundary: Dirichlet
     1021          DO  i = nxl, nxr
     1022             DO  j = nys, nyn
     1023                sk_p(nzt+2,j,i)   = sk_p(nzt+1,j,i)
     1024                sk_p(nzt+3,j,i)   = sk_p(nzt+1,j,i)
     1025             ENDDO
     1026          ENDDO
     1027
     1028       ELSEIF ( sk_char == 'ni' )  THEN
     1029
     1030!
     1031!--       Ice crystal concentration boundary condition at the bottom boundary:
     1032!--       Dirichlet (fixed surface cloud drop concentration).
     1033          DO  i = nxl, nxr
     1034             DO  j = nys, nyn
     1035                sk_p(nzb,j,i)   = sk_p(nzb+1,j,i)
     1036                sk_p(nzb-1,j,i) = sk_p(nzb,j,i)
     1037                sk_p(nzb-2,j,i) = sk_p(nzb,j,i)
     1038             ENDDO
     1039          ENDDO
     1040
     1041!
     1042!--       Ice crystal concentration boundary condition at the top boundary: Dirichlet
    9961043          DO  i = nxl, nxr
    9971044             DO  j = nys, nyn
  • palm/trunk/SOURCE/advec_ws.f90

    r4469 r4502  
    2525! -----------------
    2626! $Id$
     27! Implementation of ice microphysics
     28!
     29! 4469 2020-03-23 14:31:00Z suehring
    2730! fix mistakenly committed version
    2831!
     
    240243               sums_wssas_ws_l, sums_wsus_ws_l, sums_wsvs_ws_l,                &
    241244               sums_wsqcs_ws_l, sums_wsqrs_ws_l,                               &
     245               sums_wsqis_ws_l, sums_wsnis_ws_l,                               &
    242246               sums_wsncs_ws_l, sums_wsnrs_ws_l,                               &
    243247               hom, weight_substep
     
    19381942             ENDDO
    19391943
     1944          CASE ( 'qi' )
     1945
     1946             DO  k = nzb, nzt
     1947                sums_wsqis_ws_l(k,tn)  = sums_wsqis_ws_l(k,tn) +               &
     1948                    ( flux_t(k) / ( w(k,j,i) + SIGN( 1.0E-20_wp, w(k,j,i) ) )  &
     1949                                * ( w(k,j,i) - hom(k,1,3,0)                 )  &
     1950                    + diss_t(k) / ( ABS(w(k,j,i)) + 1.0E-20_wp              )  &
     1951                                *   ABS( w(k,j,i) - hom(k,1,3,0)            )  &
     1952                    ) * weight_substep(intermediate_timestep_count)
     1953             ENDDO
    19401954
    19411955          CASE ( 'qr' )
     
    19541968             DO  k = nzb, nzt
    19551969                sums_wsncs_ws_l(k,tn)  = sums_wsncs_ws_l(k,tn) +               &
     1970                    ( flux_t(k) / ( w(k,j,i) + SIGN( 1.0E-20_wp, w(k,j,i) ) )  &
     1971                                * ( w(k,j,i) - hom(k,1,3,0)                 )  &
     1972                    + diss_t(k) / ( ABS(w(k,j,i)) + 1.0E-20_wp              )  &
     1973                                *   ABS( w(k,j,i) - hom(k,1,3,0)            )  &
     1974                    ) * weight_substep(intermediate_timestep_count)
     1975             ENDDO
     1976
     1977          CASE ( 'ni' )
     1978
     1979             DO  k = nzb, nzt
     1980                sums_wsnis_ws_l(k,tn)  = sums_wsnis_ws_l(k,tn) +               &
    19561981                    ( flux_t(k) / ( w(k,j,i) + SIGN( 1.0E-20_wp, w(k,j,i) ) )  &
    19571982                                * ( w(k,j,i) - hom(k,1,3,0)                 )  &
     
    37983823           CASE ( 'aerosol_mass', 'aerosol_number', 'salsa_gas' )
    37993824              sk_num = 9
     3825           CASE ( 'ni' )
     3826              sk_num = 10
     3827           CASE ( 'qi' )
     3828              sk_num = 11
    38003829           CASE DEFAULT
    38013830              sk_num = 0
     
    38243853       !$ACC PRESENT(sums_wsqrs_ws_l, sums_wsncs_ws_l) &
    38253854       !$ACC PRESENT(sums_wsnrs_ws_l, sums_wsss_ws_l) &
     3855       !$ACC PRESENT(sums_wsnis_ws_l, sums_wsqis_ws_l) &
    38263856       !$ACC PRESENT(sums_salsa_ws_l)
    38273857       DO  i = nxl, nxr
     
    45174547                               *   ABS(w(k,j,i) - hom(k,1,3,0)             )   &
    45184548                           ) * weight_substep(intermediate_timestep_count)
     4549                    CASE ( 10 )
     4550                       !$ACC ATOMIC
     4551                       sums_wsnis_ws_l(k,tn)  = sums_wsnis_ws_l(k,tn)          &
     4552                          + ( flux_t(k)                                        &
     4553                                / ( w(k,j,i) + SIGN( 1.0E-20_wp, w(k,j,i) ) )  &
     4554                                * ( w(k,j,i) - hom(k,1,3,0)                 )  &
     4555                            + diss_t(k)                                        &
     4556                                / ( ABS(w(k,j,i)) + 1.0E-20_wp              )  &
     4557                                *   ABS(w(k,j,i) - hom(k,1,3,0)             )  &
     4558                            ) * weight_substep(intermediate_timestep_count)
     4559                    CASE ( 11 )
     4560                       !$ACC ATOMIC
     4561                       sums_wsqis_ws_l(k,tn)  = sums_wsqis_ws_l(k,tn)          &
     4562                          + ( flux_t(k)                                        &
     4563                                / ( w(k,j,i) + SIGN( 1.0E-20_wp, w(k,j,i) ) )  &
     4564                                * ( w(k,j,i) - hom(k,1,3,0)                 )  &
     4565                            + diss_t(k)                                        &
     4566                                / ( ABS(w(k,j,i)) + 1.0E-20_wp              )  &
     4567                                *   ABS(w(k,j,i) - hom(k,1,3,0)             )  &
     4568                            ) * weight_substep(intermediate_timestep_count)
    45194569
    45204570                END SELECT
  • palm/trunk/SOURCE/basic_constants_and_equations_mod.f90

    r4400 r4502  
    2525! -----------------
    2626! $Id$
     27! Implementation of ice microphysics
     28!
     29! 4400 2020-02-10 20:32:41Z suehring
    2730! Move routine to transform coordinates from netcdf_interface_mod to
    2831! basic_constants_and_equations_mod
     
    9295    REAL(wp), PARAMETER ::  g_d_cp  = g   / c_p   !< precomputed g / c_p
    9396    REAL(wp), PARAMETER ::  lv_d_cp = l_v / c_p   !< precomputed l_v / c_p
     97    REAL(wp), PARAMETER ::  ls_d_cp = l_s / c_p   !< precomputed l_s / c_p
    9498    REAL(wp), PARAMETER ::  lv_d_rd = l_v / r_d   !< precomputed l_v / r_d
    9599    REAL(wp), PARAMETER ::  rd_d_rv = r_d / r_v   !< precomputed r_d / r_v
     
    106110    PRIVATE magnus_0d, &
    107111            magnus_1d, &
     112            magnus_tl_0d, &
     113            magnus_tl_1d, &
     114            magnus_0d_ice, &
     115            magnus_1d_ice, &
    108116            ideal_gas_law_rho_0d, &
    109117            ideal_gas_law_rho_1d, &
     
    126134       MODULE PROCEDURE magnus_1d
    127135    END INTERFACE magnus
     136
     137    INTERFACE magnus_tl
     138       MODULE PROCEDURE magnus_tl_0d
     139       MODULE PROCEDURE magnus_tl_1d
     140    END INTERFACE magnus_tl
     141
     142    INTERFACE magnus_ice
     143       MODULE PROCEDURE magnus_0d_ice
     144       MODULE PROCEDURE magnus_1d_ice
     145    END INTERFACE magnus_ice
    128146
    129147    INTERFACE ideal_gas_law_rho
     
    337355! Description:
    338356! ------------
     357!> This function computes the magnus formula (Press et al., 1992) using the
     358!> (ice-) liquid water potential temperature.
     359!> The magnus formula is needed to calculate the saturation vapor pressure over
     360!> a plane liquid water surface
     361!------------------------------------------------------------------------------!
     362    FUNCTION magnus_tl_0d( t_l )
     363
     364       IMPLICIT NONE
     365
     366       REAL(wp), INTENT(IN) ::  t_l  !< liquid water temperature (K)
     367
     368       REAL(wp) ::  magnus_tl_0d
     369!
     370!--    Saturation vapor pressure for a specific temperature:
     371       magnus_tl_0d =  610.78_wp * EXP( 17.269_wp * ( t_l - 273.16_wp ) /             &
     372                                                    ( t_l - 35.86_wp  ) )
     373
     374    END FUNCTION magnus_tl_0d
     375
     376!------------------------------------------------------------------------------!
     377! Description:
     378! ------------
     379!> This function computes the magnus formula (Press et al., 1992) using the
     380!> (ice-) liquid water potential temperature.
     381!> The magnus formula is needed to calculate the saturation vapor pressure over
     382!> a plane liquid water surface
     383!------------------------------------------------------------------------------!
     384    FUNCTION magnus_tl_1d( t_l )
     385
     386       IMPLICIT NONE
     387
     388       REAL(wp), INTENT(IN), DIMENSION(:) ::  t_l  !< liquid water temperature (K)
     389
     390       REAL(wp), DIMENSION(size(t_l)) ::  magnus_tl_1d
     391!
     392!--    Saturation vapor pressure for a specific temperature:
     393       magnus_tl_1d =  610.78_wp * EXP( 17.269_wp * ( t_l - 273.16_wp ) /      &
     394                                                    ( t_l - 35.86_wp  ) )
     395
     396    END FUNCTION magnus_tl_1d
     397
     398!------------------------------------------------------------------------------!
     399! Description:
     400! ------------
     401!> This function computes the magnus formula (Press et al., 1992).
     402!> The magnus formula is needed to calculate the saturation vapor pressure over
     403!> a plane ice surface
     404!------------------------------------------------------------------------------!
     405    FUNCTION magnus_0d_ice( t )
     406
     407       IMPLICIT NONE
     408
     409       REAL(wp), INTENT(IN) ::  t  !< temperature (K)
     410
     411       REAL(wp) ::  magnus_0d_ice
     412!
     413!--    Saturation vapor pressure for a specific temperature:
     414       magnus_0d_ice =  611.2_wp * EXP( 22.46_wp * ( t - degc_to_k ) /         &
     415                                                   ( t - 0.53_wp  ) )
     416
     417    END FUNCTION magnus_0d_ice
     418
     419!------------------------------------------------------------------------------!
     420! Description:
     421! ------------
     422!> This function computes the magnus formula (Press et al., 1992).
     423!> The magnus formula is needed to calculate the saturation vapor pressure over
     424!> a plane ice surface
     425!------------------------------------------------------------------------------!
     426    FUNCTION magnus_1d_ice( t )
     427
     428       IMPLICIT NONE
     429
     430       REAL(wp), INTENT(IN), DIMENSION(:) ::  t  !< temperature (K)
     431
     432       REAL(wp), DIMENSION(size(t)) ::  magnus_1d_ice
     433!
     434!--    Saturation vapor pressure for a specific temperature:
     435       magnus_1d_ice =  611.2_wp * EXP( 22.46_wp * ( t - degc_to_k ) /          &
     436                                                   ( t - 0.53_wp  ) )
     437
     438    END FUNCTION magnus_1d_ice
     439
     440!------------------------------------------------------------------------------!
     441! Description:
     442! ------------
    339443!> Compute the ideal gas law for scalar arguments.
    340444!------------------------------------------------------------------------------!
  • palm/trunk/SOURCE/bulk_cloud_model_mod.f90

    r4495 r4502  
    2525! -----------------
    2626! $Id$
     27! Implementation of ice microphysics
     28!
     29! 4495 2020-04-13 20:11:20Z raasch
    2730! restart data handling with MPI-IO added
    2831!
     
    116119               precipitation_amount, prr, pt, d_exner, pt_init, q, ql, ql_1,   &
    117120               qc, qc_1, qc_2, qc_3, qc_p, qr, qr_1, qr_2, qr_3, qr_p,         &
    118                exner, zu, tnc_m, tnr_m, tqc_m, tqr_m, tend, rdf_sc, &
    119                flux_l_qc, flux_l_qr, flux_l_nc, flux_l_nr, &
    120                flux_s_qc, flux_s_qr, flux_s_nc, flux_s_nr, &
    121                diss_l_qc, diss_l_qr, diss_l_nc, diss_l_nr, &
    122                diss_s_qc, diss_s_qr, diss_s_nc, diss_s_nr
     121               exner, zu, tnc_m, tnr_m, tqc_m, tqr_m, tend, rdf_sc,            &
     122               flux_l_qc, flux_l_qr, flux_l_nc, flux_l_nr,                     &
     123               flux_s_qc, flux_s_qr, flux_s_nc, flux_s_nr,                     &
     124               diss_l_qc, diss_l_qr, diss_l_nc, diss_l_nr,                     &
     125               diss_s_qc, diss_s_qr, diss_s_nc, diss_s_nr,                     &
     126               ni, ni_1, ni_2, ni_3, ni_p, tni_m,                              &
     127               qi, qi_1, qi_2, qi_3, qi_p, tqi_m,                              &
     128               flux_l_qi, flux_l_ni, flux_s_qi, flux_s_ni,                     &
     129               diss_l_qi, diss_l_ni, diss_s_qi, diss_s_ni
     130
    123131
    124132    USE averaging,                                                             &
    125         ONLY:  nc_av, nr_av, prr_av, qc_av, ql_av, qr_av
     133        ONLY:  nc_av, nr_av, prr_av, qc_av, ql_av, qr_av, ni_av, qi_av
    126134
    127135    USE basic_constants_and_equations_mod,                                     &
    128         ONLY:  c_p, g, lv_d_cp, lv_d_rd, l_v, magnus, molecular_weight_of_solute,&
     136        ONLY:  c_p, g, lv_d_cp, lv_d_rd, l_v, magnus, magnus_ice,              &
     137               molecular_weight_of_solute,                                     &
    129138               molecular_weight_of_water, pi, rho_l, rho_s, r_d, r_v, vanthoff,&
    130139               exner_function, exner_function_invers, ideal_gas_law_rho,       &
    131                ideal_gas_law_rho_pt, barometric_formula, rd_d_rv
     140               ideal_gas_law_rho_pt, barometric_formula, rd_d_rv, l_s,         &
     141               ls_d_cp
    132142
    133143    USE control_parameters,                                                    &
     
    143153               dt_3d, dt_do2d_xy, intermediate_timestep_count,                 &
    144154               intermediate_timestep_count_max, large_scale_forcing,           &
    145                lsf_surf, pt_surface, restart_data_format_output, rho_surface, surface_pressure,   &
     155               lsf_surf, pt_surface, restart_data_format_output, rho_surface,  &
     156               surface_pressure,                                               &
    146157               time_do2d_xy, message_string, initializing_actions,             &
    147                ws_scheme_sca, scalar_advec, timestep_scheme, tsc, loop_optimization
     158               ws_scheme_sca, scalar_advec, timestep_scheme, tsc,              &
     159               loop_optimization, simulated_time
    148160
    149161    USE cpulog,                                                                &
     
    167179        ONLY:  threads_per_task
    168180
    169     USE restart_data_mpi_io_mod,                                                                   &
     181    USE restart_data_mpi_io_mod,                                               &
    170182        ONLY:  rrd_mpi_io, wrd_mpi_io
    171183
    172184    USE statistics,                                                            &
    173185        ONLY:  weight_pres, weight_substep, sums_wsncs_ws_l, sums_wsnrs_ws_l,  &
    174                sums_wsqcs_ws_l, sums_wsqrs_ws_l
     186               sums_wsqcs_ws_l, sums_wsqrs_ws_l,                               &
     187               sums_wsqis_ws_l, sums_wsnis_ws_l
    175188
    176189    USE surface_mod,                                                           &
    177190        ONLY :  bc_h,                                                          &
    178191                surf_bulk_cloud_model,                                         &
    179                 surf_microphysics_morrison, surf_microphysics_seifert, &
    180                 surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, surf_usm_v
     192                surf_microphysics_morrison, surf_microphysics_seifert,         &
     193                surf_microphysics_ice_extension,                               &
     194                surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h,    &
     195                surf_usm_v
    181196
    182197    IMPLICIT NONE
     
    193208    LOGICAL ::  cloud_water_sedimentation = .FALSE.       !< cloud water sedimentation
    194209    LOGICAL ::  curvature_solution_effects_bulk = .FALSE. !< flag for considering koehler theory
     210    LOGICAL ::  ice_crystal_sedimentation = .FALSE.        !< flag for ice crystal sedimentation
    195211    LOGICAL ::  limiter_sedimentation = .TRUE.            !< sedimentation limiter
    196212    LOGICAL ::  collision_turbulence = .FALSE.            !< turbulence effects
     
    198214
    199215    LOGICAL ::  call_microphysics_at_all_substeps = .FALSE.      !< namelist parameter
     216    LOGICAL ::  microphysics_ice_extension = .FALSE.              !< use ice microphysics scheme
    200217    LOGICAL ::  microphysics_sat_adjust = .FALSE.                !< use saturation adjust bulk scheme?
    201218    LOGICAL ::  microphysics_kessler = .FALSE.                   !< use kessler bulk scheme?
    202219    LOGICAL ::  microphysics_morrison = .FALSE.                  !< use 2-moment Morrison (add. prog. eq. for nc and qc)
    203220    LOGICAL ::  microphysics_seifert = .FALSE.                   !< use 2-moment Seifert and Beheng scheme
    204     LOGICAL ::  microphysics_morrison_no_rain = .FALSE.          !< use 2-moment Morrison     
     221    LOGICAL ::  microphysics_morrison_no_rain = .FALSE.          !< use 2-moment Morrison
    205222    LOGICAL ::  precipitation = .FALSE.                          !< namelist parameter
    206223
     
    240257    REAL(wp) ::  w_precipitation = 9.65_wp  !< maximum terminal velocity (m s-1)
    241258    REAL(wp) ::  x0 = 2.6E-10_wp           !< separating drop mass (kg)
    242 !    REAL(wp) ::  xamin = 5.24E-19_wp       !< average aerosol mass (kg) (~ 0.05µm)
     259    REAL(wp) ::  ximin = 4.42E-14_wp       !< minimum mass of ice crystal (kg) (D~10µm)
    243260    REAL(wp) ::  xcmin = 4.18E-15_wp       !< minimum cloud drop size (kg) (~ 1µm)
    244261    REAL(wp) ::  xrmin = 2.6E-10_wp        !< minimum rain drop size (kg)
     
    249266    REAL(wp) ::  dry_aerosol_radius = 0.05E-6_wp !< dry aerosol radius
    250267    REAL(wp) ::  dt_micro                        !< microphysics time step
     268    REAL(wp) ::  in_init = 1000.0_wp             !< initial number of potential ice nucleii
    251269    REAL(wp) ::  sigma_bulk = 2.0_wp             !< width of aerosol spectrum
    252270    REAL(wp) ::  na_init = 100.0E6_wp            !< Total particle/aerosol concentration (cm-3)
     
    254272    REAL(wp) ::  dt_precipitation = 100.0_wp     !< timestep precipitation (s)
    255273    REAL(wp) ::  sed_qc_const                    !< const. for sedimentation of cloud water
    256     REAL(wp) ::  pirho_l                         !< pi * rho_l / 6.0;
     274    REAL(wp) ::  pirho_l                         !< pi * rho_l / 6.0
     275    REAL(wp) ::  start_ice_microphysics = 0.0_wp !< time from which on ice microhysics are executed
    257276
    258277    REAL(wp) ::  e_s     !< saturation water vapor pressure
     278    REAL(wp) ::  e_si    !< saturation water vapor pressure over ice
    259279    REAL(wp) ::  q_s     !< saturation mixing ratio
     280    REAL(wp) ::  q_si    !< saturation mixing ratio over ice
    260281    REAL(wp) ::  sat     !< supersaturation
    261     REAL(wp) ::  t_l     !< actual temperature
     282    REAL(wp) ::  sat_ice !< supersaturation over ice
     283    REAL(wp) ::  t_l     !< liquid-(ice) water temperature
    262284
    263285    SAVE
     
    294316           dt_precipitation, &
    295317           microphysics_morrison, &
    296            microphysics_morrison_no_rain, &           
     318           microphysics_morrison_no_rain, &
    297319           microphysics_sat_adjust, &
    298320           microphysics_seifert, &
     321           microphysics_ice_extension, &
    299322           na_init, &
    300323           nc_const, &
    301324           precipitation, &
    302            sigma_gc
    303 
     325           sigma_gc, &
     326           start_ice_microphysics, &
     327           ice_crystal_sedimentation, &
     328           in_init
    304329
    305330    INTERFACE bcm_parin
     
    420445          nc_const, &
    421446          sigma_bulk, &
    422           ventilation_effect
     447          ventilation_effect, &
     448          ice_crystal_sedimentation, &
     449          microphysics_ice_extension, &
     450          start_ice_microphysics, &
     451          in_init
    423452
    424453       line = ' '
     
    517546          microphysics_kessler    = .FALSE.
    518547          microphysics_morrison   = .TRUE.
    519           microphysics_morrison_no_rain = .TRUE.         
    520           precipitation           = .FALSE.     
     548          microphysics_morrison_no_rain = .TRUE.
     549          precipitation           = .FALSE.
    521550       ELSE
    522551          message_string = 'unknown cloud microphysics scheme cloud_scheme ="' // &
     
    546575       surf_microphysics_morrison = microphysics_morrison
    547576       surf_microphysics_seifert = microphysics_seifert
    548 
     577       surf_microphysics_ice_extension = microphysics_ice_extension
    549578!
    550579!--    Check aerosol
     
    592621             unit = '1/m3'
    593622
     623          CASE ( 'ni' )
     624             IF ( .NOT.  microphysics_ice_extension )  THEN
     625                message_string = 'output of "' // TRIM( var ) // '" ' //       &
     626                                 'requires ' //                                &
     627                                 'microphysics_ice_extension = ".TRUE."'
     628                CALL message( 'check_parameters', 'PA0359', 1, 2, 0, 6, 0 )
     629             ENDIF
     630             unit = '1/m3'
     631
    594632          CASE ( 'nr' )
    595633             IF ( .NOT.  microphysics_seifert )  THEN
     
    611649
    612650          CASE ( 'qc' )
     651             unit = 'kg/kg'
     652
     653          CASE ( 'qi' )
     654             IF ( .NOT.  microphysics_ice_extension ) THEN
     655                message_string = 'output of "' // TRIM( var ) // '" ' //       &
     656                                 'requires ' //                                &
     657                                 'microphysics_ice_extension = ".TRUE."'
     658                CALL message( 'check_parameters', 'PA0359', 1, 2, 0, 6, 0 )
     659             ENDIF
    613660             unit = 'kg/kg'
    614661
     
    698745             ENDIF
    699746             pr_index = 123
     747             dopr_index(var_count) = pr_index
     748             dopr_unit     = '1/m3'
     749             unit = dopr_unit
     750             hom(:,2,pr_index,:)  = SPREAD( zu, 2, statistic_regions+1 )
     751
     752          CASE ( 'ni' )
     753             IF ( .NOT.  microphysics_ice_extension )  THEN
     754                message_string = 'data_output_pr = ' //                        &
     755                                 TRIM( data_output_pr(var_count) ) //          &
     756                                 ' is not implemented for' //                  &
     757                                 ' microphysics_ice_extension = ".F."'
     758                CALL message( 'check_parameters', 'PA0358', 1, 2, 0, 6, 0 )
     759             ENDIF
     760             pr_index = 124
    700761             dopr_index(var_count) = pr_index
    701762             dopr_unit     = '1/m3'
     
    730791             unit = dopr_unit
    731792             hom(:,2,pr_index,:)  = SPREAD( zu, 2, statistic_regions+1 )
     793
    732794          CASE ( 'qc' )
    733795             pr_index = 75
     796             dopr_index(var_count) = pr_index
     797             dopr_unit     = 'kg/kg'
     798             unit = dopr_unit
     799             hom(:,2,pr_index,:)  = SPREAD( zu, 2, statistic_regions+1 )
     800
     801          CASE ( 'qi' )
     802             IF ( .NOT.  microphysics_ice_extension )  THEN
     803                message_string = 'data_output_pr = ' //                        &
     804                                 TRIM( data_output_pr(var_count) ) //          &
     805                                 ' is not implemented for' //                  &
     806                                 ' microphysics_ice_extension = ".F."'
     807                CALL message( 'check_parameters', 'PA0358', 1, 2, 0, 6, 0 )
     808             ENDIF
     809             pr_index = 125
    734810             dopr_index(var_count) = pr_index
    735811             dopr_unit     = 'kg/kg'
     
    792868!
    793869!--       3D-cloud drop water content, cloud drop concentration arrays
    794           ALLOCATE( nc_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    795                     nc_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    796                     nc_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    797                     qc_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    798                     qc_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
     870          ALLOCATE( nc_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
     871                    nc_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
     872                    nc_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
     873                    qc_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
     874                    qc_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
    799875                    qc_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    800876       ENDIF
     
    803879!
    804880!--       3D-rain water content, rain drop concentration arrays
    805           ALLOCATE( nr_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    806                     nr_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    807                     nr_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    808                     qr_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
    809                     qr_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                    &
     881          ALLOCATE( nr_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
     882                    nr_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
     883                    nr_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
     884                    qr_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
     885                    qr_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
    810886                    qr_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    811887       ENDIF
    812888
     889       IF ( microphysics_ice_extension )  THEN
     890!
     891!--       3D-cloud drop water content, cloud drop concentration arrays
     892          ALLOCATE( ni_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
     893                    ni_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
     894                    ni_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
     895                    qi_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
     896                    qi_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
     897                    qi_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     898       ENDIF
     899
    813900       IF ( ws_scheme_sca )  THEN
    814 
    815901          IF ( microphysics_morrison )  THEN
    816902             ALLOCATE( sums_wsqcs_ws_l(nzb:nzt+1,0:threads_per_task-1) )
     
    819905             sums_wsncs_ws_l = 0.0_wp
    820906          ENDIF
    821 
    822907          IF ( microphysics_seifert )  THEN
    823908             ALLOCATE( sums_wsqrs_ws_l(nzb:nzt+1,0:threads_per_task-1) )
     
    826911             sums_wsnrs_ws_l = 0.0_wp
    827912          ENDIF
    828 
     913          IF ( microphysics_ice_extension )  THEN
     914             ALLOCATE( sums_wsqis_ws_l(nzb:nzt+1,0:threads_per_task-1) )
     915             ALLOCATE( sums_wsnis_ws_l(nzb:nzt+1,0:threads_per_task-1) )
     916             sums_wsqis_ws_l = 0.0_wp
     917             sums_wsnis_ws_l = 0.0_wp
     918          ENDIF
    829919       ENDIF
    830920
     
    835925!--    advection routines.
    836926       IF ( loop_optimization /= 'vector' )  THEN
    837 
    838927          IF ( ws_scheme_sca )  THEN
    839 
    840928             IF ( microphysics_morrison )  THEN
    841929                ALLOCATE( flux_s_qc(nzb+1:nzt,0:threads_per_task-1),           &
     
    848936                          diss_l_nc(nzb+1:nzt,nys:nyn,0:threads_per_task-1) )
    849937             ENDIF
    850 
    851938             IF ( microphysics_seifert )  THEN
    852939                ALLOCATE( flux_s_qr(nzb+1:nzt,0:threads_per_task-1),           &
     
    859946                          diss_l_nr(nzb+1:nzt,nys:nyn,0:threads_per_task-1) )
    860947             ENDIF
    861 
    862           ENDIF
    863 
     948             IF ( microphysics_ice_extension )  THEN
     949                ALLOCATE( flux_s_qi(nzb+1:nzt,0:threads_per_task-1),           &
     950                          diss_s_qi(nzb+1:nzt,0:threads_per_task-1),           &
     951                          flux_s_ni(nzb+1:nzt,0:threads_per_task-1),           &
     952                          diss_s_ni(nzb+1:nzt,0:threads_per_task-1) )
     953                ALLOCATE( flux_l_qi(nzb+1:nzt,nys:nyn,0:threads_per_task-1),   &
     954                          diss_l_qi(nzb+1:nzt,nys:nyn,0:threads_per_task-1),   &
     955                          flux_l_ni(nzb+1:nzt,nys:nyn,0:threads_per_task-1),   &
     956                          diss_l_ni(nzb+1:nzt,nys:nyn,0:threads_per_task-1) )
     957             ENDIF
     958          ENDIF
    864959       ENDIF
    865960
     
    878973          nr => nr_1;  nr_p  => nr_2;  tnr_m  => nr_3
    879974       ENDIF
     975       IF ( microphysics_ice_extension )  THEN
     976          qi => qi_1;  qi_p  => qi_2;  tqi_m  => qi_3
     977          ni => ni_1;  ni_p  => ni_2;  tni_m  => ni_3
     978       ENDIF
     979
    880980
    881981
     
    9191019             ENDIF
    9201020!
     1021!--          Initialize the remaining quantities
     1022             IF ( microphysics_ice_extension )  THEN
     1023                DO  i = nxlg, nxrg
     1024                   DO  j = nysg, nyng
     1025                      qi(:,j,i) = 0.0_wp
     1026                      ni(:,j,i) = 0.0_wp
     1027                   ENDDO
     1028                ENDDO
     1029             ENDIF
     1030!
    9211031!--          Liquid water content and precipitation amount
    9221032!--          are zero at beginning of the simulation
     
    9381048                qr_p  = qr
    9391049                nr_p  = nr
     1050             ENDIF
     1051             IF ( microphysics_ice_extension )  THEN
     1052                tqi_m = 0.0_wp
     1053                tni_m = 0.0_wp
     1054                qi_p  = qi
     1055                ni_p  = ni
    9401056             ENDIF
    9411057          ENDIF ! Only if not read_restart_data
     
    10801196                sums_wsnrs_ws_l = 0.0_wp
    10811197             ENDIF
     1198             IF ( microphysics_ice_extension )  THEN
     1199                sums_wsqis_ws_l = 0.0_wp
     1200                sums_wsnis_ws_l = 0.0_wp
     1201             ENDIF
    10821202
    10831203          ENDIF
     
    10961216!> Control of microphysics for grid points i,j
    10971217!------------------------------------------------------------------------------!
    1098 
    10991218    SUBROUTINE bcm_actions_ij( i, j, location )
    11001219
     
    11211240                sums_wsnrs_ws_l = 0.0_wp
    11221241             ENDIF
     1242             IF ( microphysics_ice_extension )  THEN
     1243                sums_wsqis_ws_l = 0.0_wp
     1244                sums_wsnis_ws_l = 0.0_wp
     1245             ENDIF
     1246
    11231247
    11241248          ENDIF
     
    11431267       CALL cpu_log( log_point(51), 'microphysics', 'start' )
    11441268
    1145        IF ( .NOT. microphysics_sat_adjust  .AND.         &
    1146             ( intermediate_timestep_count == 1  .OR.                              &
    1147               call_microphysics_at_all_substeps ) )                               &
     1269       IF ( .NOT. microphysics_sat_adjust  .AND.                               &
     1270            ( intermediate_timestep_count == 1  .OR.                           &
     1271              call_microphysics_at_all_substeps ) )                            &
    11481272       THEN
    11491273
     
    11511275!
    11521276!--          Calculate vertical profile of the hydrostatic pressure (hyp)
    1153              hyp    = barometric_formula(zu, pt_surface * exner_function(surface_pressure * 100.0_wp), surface_pressure * 100.0_wp)
     1277             hyp    = barometric_formula(zu, pt_surface *                      &
     1278                      exner_function(surface_pressure * 100.0_wp),             &
     1279                      surface_pressure * 100.0_wp)
    11541280             d_exner = exner_function_invers(hyp)
    11551281             exner = 1.0_wp / exner_function_invers(hyp)
    1156              hyrho  = ideal_gas_law_rho_pt(hyp, pt_init)
     1282             hyrho  = ideal_gas_law_rho_pt(hyp, pt(:, nys, nxl) )
    11571283!
    11581284!--          Compute reference density
    1159              rho_surface = ideal_gas_law_rho(surface_pressure * 100.0_wp, pt_surface * exner_function(surface_pressure * 100.0_wp))
     1285             rho_surface = ideal_gas_law_rho(surface_pressure * 100.0_wp,      &
     1286                           pt_surface *                                        &
     1287                           exner_function(surface_pressure * 100.0_wp))
    11601288          ENDIF
    11611289
     
    11781306             CALL autoconversion_kessler
    11791307             IF ( cloud_water_sedimentation )  CALL sedimentation_cloud
    1180              
     1308
    11811309!
    11821310!--       Here the seifert beheng scheme is used. Cloud concentration is assumed to
     
    11841312          ELSEIF ( microphysics_seifert  .AND.  .NOT. microphysics_morrison )  THEN
    11851313             CALL adjust_cloud
     1314             IF ( microphysics_ice_extension  .AND.  simulated_time > start_ice_microphysics )     &
     1315             CALL ice_nucleation
     1316             IF ( microphysics_ice_extension  .AND.  simulated_time > start_ice_microphysics )     &
     1317             CALL ice_deposition
    11861318             CALL autoconversion
    11871319             CALL accretion
     
    11901322             CALL sedimentation_rain
    11911323             IF ( cloud_water_sedimentation )  CALL sedimentation_cloud
    1192              
    1193 !
    1194 !--       Here the morrison scheme is used. No rain processes are considered and qr and nr
     1324             IF ( microphysics_ice_extension  .AND.  simulated_time > start_ice_microphysics )     &
     1325             CALL adjust_ice
     1326             IF ( ice_crystal_sedimentation .AND. microphysics_ice_extension &
     1327                  .AND. simulated_time > start_ice_microphysics ) CALL sedimentation_ice
     1328
     1329!
     1330!--       Here the morrison scheme is used. No rain processes are considered and qr and nr
    11951331!--       are not allocated
    11961332          ELSEIF ( microphysics_morrison_no_rain  .AND.  .NOT. microphysics_seifert )  THEN
    11971333             CALL activation
    11981334             CALL condensation
    1199              IF ( cloud_water_sedimentation )  CALL sedimentation_cloud   
    1200              
    1201 !
    1202 !--       Here the full morrison scheme is used and all processes of Seifert and Beheng are
     1335             IF ( microphysics_ice_extension  .AND.  simulated_time > start_ice_microphysics )     &
     1336             CALL adjust_ice
     1337             IF ( microphysics_ice_extension  .AND.  simulated_time > start_ice_microphysics )     &
     1338             CALL ice_nucleation
     1339             IF ( microphysics_ice_extension  .AND.  simulated_time > start_ice_microphysics )     &
     1340             CALL ice_deposition
     1341             IF ( cloud_water_sedimentation )  CALL sedimentation_cloud
     1342
     1343!
     1344!--       Here the full morrison scheme is used and all processes of Seifert and Beheng are
    12031345!--       included
    12041346          ELSEIF ( microphysics_morrison  .AND.  microphysics_seifert )  THEN
     
    12061348             CALL activation
    12071349             CALL condensation
     1350             IF ( microphysics_ice_extension  .AND.  simulated_time > start_ice_microphysics )     &
     1351             CALL adjust_ice
     1352             IF ( microphysics_ice_extension  .AND.  simulated_time > start_ice_microphysics )     &
     1353             CALL ice_nucleation
     1354             IF ( microphysics_ice_extension  .AND.  simulated_time > start_ice_microphysics )     &
     1355             CALL ice_deposition
    12081356             CALL autoconversion
    12091357             CALL accretion
     
    12111359             CALL evaporation_rain
    12121360             CALL sedimentation_rain
    1213              IF ( cloud_water_sedimentation )  CALL sedimentation_cloud           
     1361             IF ( cloud_water_sedimentation )  CALL sedimentation_cloud
    12141362
    12151363          ENDIF
     
    12291377!> Control of microphysics for grid points i,j
    12301378!------------------------------------------------------------------------------!
    1231 
    12321379    SUBROUTINE bcm_non_advective_processes_ij( i, j )
    12331380
     
    12361383       INTEGER(iwp) ::  j                 !<
    12371384
    1238        IF ( .NOT. microphysics_sat_adjust  .AND.         &
    1239             ( intermediate_timestep_count == 1  .OR.                              &
    1240               call_microphysics_at_all_substeps ) )                               &
     1385       IF ( .NOT. microphysics_sat_adjust  .AND.                               &
     1386            ( intermediate_timestep_count == 1  .OR.                           &
     1387              call_microphysics_at_all_substeps ) )                            &
    12411388       THEN
    12421389
     
    12441391!
    12451392!--          Calculate vertical profile of the hydrostatic pressure (hyp)
    1246              hyp    = barometric_formula(zu, pt_surface * exner_function(surface_pressure * 100.0_wp), surface_pressure * 100.0_wp)
     1393             hyp    = barometric_formula(zu, pt_surface *                      &
     1394                      exner_function(surface_pressure * 100.0_wp),             &
     1395                      surface_pressure * 100.0_wp)
    12471396             d_exner = exner_function_invers(hyp)
    12481397             exner = 1.0_wp / exner_function_invers(hyp)
    1249              hyrho  = ideal_gas_law_rho_pt(hyp, pt_init)
     1398             hyrho  = ideal_gas_law_rho_pt(hyp, pt(:, nys, nxl) )
    12501399!
    12511400!--          Compute reference density
    1252              rho_surface = ideal_gas_law_rho(surface_pressure * 100.0_wp, pt_surface * exner_function(surface_pressure * 100.0_wp))
     1401             rho_surface = ideal_gas_law_rho(surface_pressure * 100.0_wp,      &
     1402                           pt_surface *                                        &
     1403                           exner_function(surface_pressure * 100.0_wp))
    12531404          ENDIF
    12541405
     
    12731424!
    12741425!--       Here the seifert beheng scheme is used. Cloud concentration is assumed to
    1275 !--       a constant value an qc a diagnostic value.             
     1426!--       a constant value an qc a diagnostic value.
    12761427          ELSEIF ( microphysics_seifert  .AND.  .NOT. microphysics_morrison )  THEN
    12771428             CALL adjust_cloud_ij( i,j )
     1429             IF ( microphysics_ice_extension .AND. simulated_time > start_ice_microphysics )       &
     1430                 CALL ice_nucleation_ij( i,j )
     1431             IF ( microphysics_ice_extension .AND. simulated_time > start_ice_microphysics )       &
     1432                 CALL ice_deposition_ij( i,j )
    12781433             CALL autoconversion_ij( i,j )
    12791434             CALL accretion_ij( i,j )
     
    12821437             CALL sedimentation_rain_ij( i,j )
    12831438             IF ( cloud_water_sedimentation )  CALL sedimentation_cloud_ij( i,j )
    1284              
    1285 !
    1286 !--       Here the morrison scheme is used. No rain processes are considered and qr and nr
     1439             IF ( microphysics_ice_extension .AND. simulated_time > start_ice_microphysics )       &
     1440                 CALL adjust_ice_ij ( i,j )
     1441             IF ( ice_crystal_sedimentation .AND. microphysics_ice_extension &
     1442                  .AND. simulated_time > start_ice_microphysics )  CALL sedimentation_ice_ij ( i,j )
     1443!
     1444!--       Here the morrison scheme is used. No rain processes are considered and qr and nr
    12871445!--       are not allocated
    12881446          ELSEIF ( microphysics_morrison_no_rain  .AND.  .NOT. microphysics_seifert )  THEN
    12891447             CALL activation_ij( i,j )
    12901448             CALL condensation_ij( i,j )
    1291              IF ( cloud_water_sedimentation )  CALL sedimentation_cloud_ij( i,j )
    1292              
    1293 !
    1294 !--       Here the full morrison scheme is used and all processes of Seifert and Beheng are
    1295 !--       included             
     1449             IF ( microphysics_ice_extension .AND. simulated_time > start_ice_microphysics )       &
     1450                 CALL adjust_ice_ij ( i,j )
     1451             IF ( microphysics_ice_extension .AND. simulated_time > start_ice_microphysics )       &
     1452                 CALL ice_nucleation_ij( i,j )
     1453             IF ( microphysics_ice_extension .AND. simulated_time > start_ice_microphysics )       &
     1454                 CALL ice_deposition_ij( i,j )
     1455             IF ( cloud_water_sedimentation )  CALL sedimentation_cloud_ij( i,j )
     1456
     1457!
     1458!--       Here the full morrison scheme is used and all processes of Seifert and Beheng are
     1459!--       included
    12961460          ELSEIF ( microphysics_morrison  .AND.  microphysics_seifert )  THEN
    12971461             CALL adjust_cloud_ij( i,j )
    12981462             CALL activation_ij( i,j )
    12991463             CALL condensation_ij( i,j )
     1464             IF ( microphysics_ice_extension .AND. simulated_time > start_ice_microphysics )       &
     1465                 CALL adjust_ice_ij ( i,j )
     1466             IF ( microphysics_ice_extension .AND. simulated_time > start_ice_microphysics )       &
     1467                 CALL ice_nucleation_ij( i,j )
     1468             IF ( microphysics_ice_extension .AND. simulated_time > start_ice_microphysics )       &
     1469                 CALL ice_deposition_ij( i,j )
    13001470             CALL autoconversion_ij( i,j )
    13011471             CALL accretion_ij( i,j )
     
    13031473             CALL evaporation_rain_ij( i,j )
    13041474             CALL sedimentation_rain_ij( i,j )
    1305              IF ( cloud_water_sedimentation )  CALL sedimentation_cloud_ij( i,j )           
     1475             IF ( cloud_water_sedimentation )  CALL sedimentation_cloud_ij( i,j )
    13061476
    13071477          ENDIF
     
    13311501          IF ( microphysics_morrison )  THEN
    13321502             CALL exchange_horiz( nc, nbgp )
    1333              CALL exchange_horiz( qc, nbgp )         
     1503             CALL exchange_horiz( qc, nbgp )
    13341504          ENDIF
    13351505          IF ( microphysics_seifert ) THEN
     
    13371507             CALL exchange_horiz( nr, nbgp )
    13381508          ENDIF
     1509          IF ( microphysics_ice_extension ) THEN
     1510             CALL exchange_horiz( qi, nbgp )
     1511             CALL exchange_horiz( ni, nbgp )
     1512          ENDIF
    13391513          CALL exchange_horiz( q, nbgp )
    1340           CALL exchange_horiz( pt, nbgp )         
     1514          CALL exchange_horiz( pt, nbgp )
    13411515       ENDIF
    13421516
    13431517
    13441518    END SUBROUTINE bcm_exchange_horiz
    1345    
     1519
    13461520
    13471521
     
    14251599                                             )                                 &
    14261600                                    * MERGE( 1.0_wp, 0.0_wp,                   &
    1427                                        BTEST( wall_flags_total_0(k,j,i), 0 )   &
     1601                                             BTEST( wall_flags_total_0(k,j,i), 0 )   &
    14281602                                          )
    14291603                   IF ( qc_p(k,j,i) < 0.0_wp )  qc_p(k,j,i) = 0.0_wp
     
    15171691                                             )                                 &
    15181692                                   * MERGE( 1.0_wp, 0.0_wp,                    &
    1519                                        BTEST( wall_flags_total_0(k,j,i), 0 )   &
     1693                                             BTEST( wall_flags_total_0(k,j,i), 0 )   &
    15201694                                          )
    15211695                   IF ( nc_p(k,j,i) < 0.0_wp )  nc_p(k,j,i) = 0.0_wp
     
    15511725
    15521726       ENDIF
     1727
     1728!
     1729!--    If required, calculate prognostic equations for ice crystal content
     1730!--    and ice crystal concentration
     1731       IF ( microphysics_ice_extension )  THEN
     1732
     1733          CALL cpu_log( log_point(70), 'qi-equation', 'start' )
     1734
     1735!
     1736!--       Calculate prognostic equation for ice crystal content
     1737          sbt = tsc(2)
     1738          IF ( scalar_advec == 'bc-scheme' )  THEN
     1739
     1740             IF ( timestep_scheme(1:5) /= 'runge' )  THEN
     1741!
     1742!--             Bott-Chlond scheme always uses Euler time step. Thus:
     1743                sbt = 1.0_wp
     1744             ENDIF
     1745             tend = 0.0_wp
     1746             CALL advec_s_bc( qi, 'qi' )
     1747
     1748          ENDIF
     1749
     1750!
     1751!--       qi-tendency terms with no communication
     1752          IF ( scalar_advec /= 'bc-scheme' )  THEN
     1753             tend = 0.0_wp
     1754             IF ( timestep_scheme(1:5) == 'runge' )  THEN
     1755                IF ( ws_scheme_sca )  THEN
     1756                   CALL advec_s_ws( advc_flags_s, qi, 'qi',                    &
     1757                                    bc_dirichlet_l  .OR.  bc_radiation_l,      &
     1758                                    bc_dirichlet_n  .OR.  bc_radiation_n,      &
     1759                                    bc_dirichlet_r  .OR.  bc_radiation_r,      &
     1760                                    bc_dirichlet_s  .OR.  bc_radiation_s )
     1761                ELSE
     1762                   CALL advec_s_pw( qi )
     1763                ENDIF
     1764             ELSE
     1765                CALL advec_s_up( qi )
     1766             ENDIF
     1767          ENDIF
     1768
     1769          CALL diffusion_s( qi,                                                &
     1770                            surf_def_h(0)%qisws, surf_def_h(1)%qisws,          &
     1771                            surf_def_h(2)%qisws,                               &
     1772                            surf_lsm_h%qisws,    surf_usm_h%qisws,             &
     1773                            surf_def_v(0)%qisws, surf_def_v(1)%qisws,          &
     1774                            surf_def_v(2)%qisws, surf_def_v(3)%qisws,          &
     1775                            surf_lsm_v(0)%qisws, surf_lsm_v(1)%qisws,          &
     1776                            surf_lsm_v(2)%qisws, surf_lsm_v(3)%qisws,          &
     1777                            surf_usm_v(0)%qisws, surf_usm_v(1)%qisws,          &
     1778                            surf_usm_v(2)%qisws, surf_usm_v(3)%qisws )
     1779
     1780!
     1781!--       Prognostic equation for ice crystal mixing ratio
     1782          DO  i = nxl, nxr
     1783             DO  j = nys, nyn
     1784                !following directive is required to vectorize on Intel19
     1785                !DIR$ IVDEP
     1786                DO  k = nzb+1, nzt
     1787                   qi_p(k,j,i) = qi(k,j,i) + ( dt_3d * ( sbt * tend(k,j,i) +   &
     1788                                                      tsc(3) * tqi_m(k,j,i) )  &
     1789                                                    - tsc(5) * rdf_sc(k) *     &
     1790                                                               qi(k,j,i)       &
     1791                                             )                                 &
     1792                                    * MERGE( 1.0_wp, 0.0_wp,                   &
     1793                                             BTEST( wall_flags_total_0(k,j,i), 0 )   &
     1794                                          )
     1795                   IF ( qi_p(k,j,i) < 0.0_wp )  qi_p(k,j,i) = 0.0_wp
     1796                ENDDO
     1797             ENDDO
     1798          ENDDO
     1799
     1800!
     1801!--       Calculate tendencies for the next Runge-Kutta step
     1802          IF ( timestep_scheme(1:5) == 'runge' )  THEN
     1803             IF ( intermediate_timestep_count == 1 )  THEN
     1804                DO  i = nxl, nxr
     1805                   DO  j = nys, nyn
     1806                      DO  k = nzb+1, nzt
     1807                         tqi_m(k,j,i) = tend(k,j,i)
     1808                      ENDDO
     1809                   ENDDO
     1810                ENDDO
     1811             ELSEIF ( intermediate_timestep_count < &
     1812                      intermediate_timestep_count_max )  THEN
     1813                DO  i = nxl, nxr
     1814                   DO  j = nys, nyn
     1815                      DO  k = nzb+1, nzt
     1816                         tqi_m(k,j,i) =   -9.5625_wp * tend(k,j,i)             &
     1817                                         + 5.3125_wp * tqi_m(k,j,i)
     1818                      ENDDO
     1819                   ENDDO
     1820                ENDDO
     1821             ENDIF
     1822          ENDIF
     1823
     1824          CALL cpu_log( log_point(70), 'qi-equation', 'stop' )
     1825
     1826          CALL cpu_log( log_point(69), 'ni-equation', 'start' )
     1827!
     1828!--       Calculate prognostic equation for ice crystal concentration
     1829          sbt = tsc(2)
     1830          IF ( scalar_advec == 'bc-scheme' )  THEN
     1831
     1832             IF ( timestep_scheme(1:5) /= 'runge' )  THEN
     1833!
     1834!--             Bott-Chlond scheme always uses Euler time step. Thus:
     1835                sbt = 1.0_wp
     1836             ENDIF
     1837             tend = 0.0_wp
     1838             CALL advec_s_bc( ni, 'ni' )
     1839
     1840          ENDIF
     1841
     1842!
     1843!--       ni-tendency terms with no communication
     1844          IF ( scalar_advec /= 'bc-scheme' )  THEN
     1845             tend = 0.0_wp
     1846             IF ( timestep_scheme(1:5) == 'runge' )  THEN
     1847                IF ( ws_scheme_sca )  THEN
     1848                   CALL advec_s_ws( advc_flags_s, ni, 'ni',                    &
     1849                                    bc_dirichlet_l  .OR.  bc_radiation_l,      &
     1850                                    bc_dirichlet_n  .OR.  bc_radiation_n,      &
     1851                                    bc_dirichlet_r  .OR.  bc_radiation_r,      &
     1852                                    bc_dirichlet_s  .OR.  bc_radiation_s )
     1853                ELSE
     1854                   CALL advec_s_pw( ni )
     1855                ENDIF
     1856             ELSE
     1857                CALL advec_s_up( ni )
     1858             ENDIF
     1859          ENDIF
     1860
     1861          CALL diffusion_s( ni,                                                &
     1862                            surf_def_h(0)%nisws, surf_def_h(1)%nisws,          &
     1863                            surf_def_h(2)%nisws,                               &
     1864                            surf_lsm_h%nisws,    surf_usm_h%nisws,             &
     1865                            surf_def_v(0)%nisws, surf_def_v(1)%nisws,          &
     1866                            surf_def_v(2)%nisws, surf_def_v(3)%nisws,          &
     1867                            surf_lsm_v(0)%nisws, surf_lsm_v(1)%nisws,          &
     1868                            surf_lsm_v(2)%nisws, surf_lsm_v(3)%nisws,          &
     1869                            surf_usm_v(0)%nisws, surf_usm_v(1)%nisws,          &
     1870                            surf_usm_v(2)%nisws, surf_usm_v(3)%nisws )
     1871
     1872!
     1873!--       Prognostic equation for ice crystal concentration
     1874          DO  i = nxl, nxr
     1875             DO  j = nys, nyn
     1876                !following directive is required to vectorize on Intel19
     1877                !DIR$ IVDEP
     1878                DO  k = nzb+1, nzt
     1879                   ni_p(k,j,i) = ni(k,j,i) + ( dt_3d * ( sbt * tend(k,j,i) +   &
     1880                                                      tsc(3) * tni_m(k,j,i) )  &
     1881                                                    - tsc(5) * rdf_sc(k) *     &
     1882                                                               ni(k,j,i)       &
     1883                                             )                                 &
     1884                                   * MERGE( 1.0_wp, 0.0_wp,                    &
     1885                                             BTEST( wall_flags_total_0(k,j,i), 0 )   &
     1886                                          )
     1887                   IF ( ni_p(k,j,i) < 0.0_wp )  ni_p(k,j,i) = 0.0_wp
     1888                ENDDO
     1889             ENDDO
     1890          ENDDO
     1891
     1892!
     1893!--       Calculate tendencies for the next Runge-Kutta step
     1894          IF ( timestep_scheme(1:5) == 'runge' )  THEN
     1895             IF ( intermediate_timestep_count == 1 )  THEN
     1896                DO  i = nxl, nxr
     1897                   DO  j = nys, nyn
     1898                      DO  k = nzb+1, nzt
     1899                         tni_m(k,j,i) = tend(k,j,i)
     1900                      ENDDO
     1901                   ENDDO
     1902                ENDDO
     1903             ELSEIF ( intermediate_timestep_count < &
     1904                      intermediate_timestep_count_max )  THEN
     1905                DO  i = nxl, nxr
     1906                   DO  j = nys, nyn
     1907                      DO  k = nzb+1, nzt
     1908                         tni_m(k,j,i) =  -9.5625_wp * tend(k,j,i)             &
     1909                                         + 5.3125_wp * tni_m(k,j,i)
     1910                      ENDDO
     1911                   ENDDO
     1912                ENDDO
     1913             ENDIF
     1914          ENDIF
     1915
     1916          CALL cpu_log( log_point(69), 'ni-equation', 'stop' )
     1917
     1918       ENDIF
     1919
    15531920!
    15541921!--    If required, calculate prognostic equations for rain water content
     
    16161983                                             )                                 &
    16171984                                    * MERGE( 1.0_wp, 0.0_wp,                   &
    1618                                        BTEST( wall_flags_total_0(k,j,i), 0 )   &
     1985                                             BTEST( wall_flags_total_0(k,j,i), 0 )   &
    16191986                                          )
    16201987                   IF ( qr_p(k,j,i) < 0.0_wp )  qr_p(k,j,i) = 0.0_wp
     
    17082075                                             )                                 &
    17092076                                   * MERGE( 1.0_wp, 0.0_wp,                    &
    1710                                        BTEST( wall_flags_total_0(k,j,i), 0 )   &
     2077                                             BTEST( wall_flags_total_0(k,j,i), 0 )   &
    17112078                                          )
    17122079                   IF ( nr_p(k,j,i) < 0.0_wp )  nr_p(k,j,i) = 0.0_wp
     
    17512118!> Control of microphysics for grid points i,j
    17522119!------------------------------------------------------------------------------!
    1753 
    17542120    SUBROUTINE bcm_prognostic_equations_ij( i, j, i_omp_start, tn )
    17552121
     
    18052171                                       )                                 &
    18062172                                 * MERGE( 1.0_wp, 0.0_wp,                &
    1807                                     BTEST( wall_flags_total_0(k,j,i), 0 )&
     2173                                          BTEST( wall_flags_total_0(k,j,i), 0 )&
    18082174                                        )
    18092175             IF ( qc_p(k,j,i) < 0.0_wp )  qc_p(k,j,i) = 0.0_wp
     
    18642230                                       )                                 &
    18652231                                 * MERGE( 1.0_wp, 0.0_wp,                &
    1866                                     BTEST( wall_flags_total_0(k,j,i), 0 )&
     2232                                          BTEST( wall_flags_total_0(k,j,i), 0 )&
    18672233                                        )
    18682234             IF ( nc_p(k,j,i) < 0.0_wp )  nc_p(k,j,i) = 0.0_wp
     
    18852251
    18862252       ENDIF
     2253
     2254!
     2255!--    If required, calculate prognostic equations for ice crystal mixing ratio
     2256!--    and ice crystal concentration
     2257       IF ( microphysics_ice_extension )  THEN
     2258!
     2259!--       Calculate prognostic equation for ice crystal mixing ratio
     2260          tend(:,j,i) = 0.0_wp
     2261          IF ( timestep_scheme(1:5) == 'runge' ) &
     2262          THEN
     2263             IF ( ws_scheme_sca )  THEN
     2264                CALL advec_s_ws( advc_flags_s, i, j, qi, 'qi', flux_s_qi,      &
     2265                                 diss_s_qi, flux_l_qi, diss_l_qi,              &
     2266                                 i_omp_start, tn,                              &
     2267                                 bc_dirichlet_l  .OR.  bc_radiation_l,         &
     2268                                 bc_dirichlet_n  .OR.  bc_radiation_n,         &
     2269                                 bc_dirichlet_r  .OR.  bc_radiation_r,         &
     2270                                 bc_dirichlet_s  .OR.  bc_radiation_s )
     2271             ELSE
     2272                CALL advec_s_pw( i, j, qi )
     2273             ENDIF
     2274          ELSE
     2275             CALL advec_s_up( i, j, qi )
     2276          ENDIF
     2277          CALL diffusion_s( i, j, qi,                                   &
     2278                            surf_def_h(0)%qisws, surf_def_h(1)%qisws,   &
     2279                            surf_def_h(2)%qisws,                        &
     2280                            surf_lsm_h%qisws,    surf_usm_h%qisws,      &
     2281                            surf_def_v(0)%qisws, surf_def_v(1)%qisws,   &
     2282                            surf_def_v(2)%qisws, surf_def_v(3)%qisws,   &
     2283                            surf_lsm_v(0)%qisws, surf_lsm_v(1)%qisws,   &
     2284                            surf_lsm_v(2)%qisws, surf_lsm_v(3)%qisws,   &
     2285                            surf_usm_v(0)%qisws, surf_usm_v(1)%qisws,   &
     2286                            surf_usm_v(2)%qisws, surf_usm_v(3)%qisws )
     2287
     2288!
     2289!--       Prognostic equation for ice crystal mixing ratio
     2290          DO  k = nzb+1, nzt
     2291             qi_p(k,j,i) = qi(k,j,i) + ( dt_3d *                         &
     2292                                                ( tsc(2) * tend(k,j,i) + &
     2293                                                  tsc(3) * tqi_m(k,j,i) )&
     2294                                                - tsc(5) * rdf_sc(k)     &
     2295                                                         * qi(k,j,i)     &
     2296                                       )                                 &
     2297                                 * MERGE( 1.0_wp, 0.0_wp,                &
     2298                                          BTEST( wall_flags_total_0(k,j,i), 0 )&
     2299                                        )
     2300             IF ( qi_p(k,j,i) < 0.0_wp )  qi_p(k,j,i) = 0.0_wp
     2301          ENDDO
     2302!
     2303!--       Calculate tendencies for the next Runge-Kutta step
     2304          IF ( timestep_scheme(1:5) == 'runge' )  THEN
     2305             IF ( intermediate_timestep_count == 1 )  THEN
     2306                DO  k = nzb+1, nzt
     2307                   tqi_m(k,j,i) = tend(k,j,i)
     2308                ENDDO
     2309             ELSEIF ( intermediate_timestep_count < &
     2310                      intermediate_timestep_count_max )  THEN
     2311                DO  k = nzb+1, nzt
     2312                   tqi_m(k,j,i) =   -9.5625_wp * tend(k,j,i) +           &
     2313                                     5.3125_wp * tqi_m(k,j,i)
     2314                ENDDO
     2315             ENDIF
     2316          ENDIF
     2317
     2318!
     2319!--       Calculate prognostic equation for ice crystal concentration.
     2320          tend(:,j,i) = 0.0_wp
     2321          IF ( timestep_scheme(1:5) == 'runge' )  THEN
     2322             IF ( ws_scheme_sca )  THEN
     2323                CALL advec_s_ws( advc_flags_s, i, j, ni, 'ni', flux_s_ni,      &
     2324                                 diss_s_ni, flux_l_ni, diss_l_ni,              &
     2325                                 i_omp_start, tn,                              &
     2326                                 bc_dirichlet_l  .OR.  bc_radiation_l,         &
     2327                                 bc_dirichlet_n  .OR.  bc_radiation_n,         &
     2328                                 bc_dirichlet_r  .OR.  bc_radiation_r,         &
     2329                                 bc_dirichlet_s  .OR.  bc_radiation_s )
     2330             ELSE
     2331                CALL advec_s_pw( i, j, ni )
     2332             ENDIF
     2333          ELSE
     2334             CALL advec_s_up( i, j, ni )
     2335          ENDIF
     2336          CALL diffusion_s( i, j, ni,                                    &
     2337                            surf_def_h(0)%nisws, surf_def_h(1)%nisws,    &
     2338                            surf_def_h(2)%nisws,                         &
     2339                            surf_lsm_h%nisws,    surf_usm_h%nisws,       &
     2340                            surf_def_v(0)%nisws, surf_def_v(1)%nisws,    &
     2341                            surf_def_v(2)%nisws, surf_def_v(3)%nisws,    &
     2342                            surf_lsm_v(0)%nisws, surf_lsm_v(1)%nisws,    &
     2343                            surf_lsm_v(2)%nisws, surf_lsm_v(3)%nisws,    &
     2344                            surf_usm_v(0)%nisws, surf_usm_v(1)%nisws,    &
     2345                            surf_usm_v(2)%nisws, surf_usm_v(3)%nisws )
     2346
     2347!
     2348!--       Prognostic equation for ice crystal concentration
     2349          DO  k = nzb+1, nzt
     2350             ni_p(k,j,i) = ni(k,j,i) + ( dt_3d *                         &
     2351                                                ( tsc(2) * tend(k,j,i) + &
     2352                                                  tsc(3) * tni_m(k,j,i) )&
     2353                                                - tsc(5) * rdf_sc(k)     &
     2354                                                         * ni(k,j,i)     &
     2355                                       )                                 &
     2356                                 * MERGE( 1.0_wp, 0.0_wp,                &
     2357                                          BTEST( wall_flags_total_0(k,j,i), 0 )&
     2358                                        )
     2359             IF ( ni_p(k,j,i) < 0.0_wp )  ni_p(k,j,i) = 0.0_wp
     2360          ENDDO
     2361!
     2362!--       Calculate tendencies for the next Runge-Kutta step
     2363          IF ( timestep_scheme(1:5) == 'runge' )  THEN
     2364             IF ( intermediate_timestep_count == 1 )  THEN
     2365                DO  k = nzb+1, nzt
     2366                   tni_m(k,j,i) = tend(k,j,i)
     2367                ENDDO
     2368             ELSEIF ( intermediate_timestep_count < &
     2369                      intermediate_timestep_count_max )  THEN
     2370                DO  k = nzb+1, nzt
     2371                   tni_m(k,j,i) =   -9.5625_wp * tend(k,j,i) +           &
     2372                                     5.3125_wp * tni_m(k,j,i)
     2373                ENDDO
     2374             ENDIF
     2375          ENDIF
     2376
     2377       ENDIF
     2378
    18872379!
    18882380!--    If required, calculate prognostic equations for rain water content
     
    19292421                                       )                                 &
    19302422                                 * MERGE( 1.0_wp, 0.0_wp,                &
    1931                                     BTEST( wall_flags_total_0(k,j,i), 0 )&
     2423                                          BTEST( wall_flags_total_0(k,j,i), 0 )&
    19322424                                        )
    19332425             IF ( qr_p(k,j,i) < 0.0_wp )  qr_p(k,j,i) = 0.0_wp
     
    19882480                                       )                                 &
    19892481                                 * MERGE( 1.0_wp, 0.0_wp,                &
    1990                                     BTEST( wall_flags_total_0(k,j,i), 0 )&
     2482                                          BTEST( wall_flags_total_0(k,j,i), 0 )&
    19912483                                        )
    19922484             IF ( nr_p(k,j,i) < 0.0_wp )  nr_p(k,j,i) = 0.0_wp
     
    20382530                   nr => nr_1;    nr_p => nr_2
    20392531                ENDIF
     2532                IF ( microphysics_ice_extension )  THEN
     2533                   qi => qi_1;    qi_p => qi_2
     2534                   ni => ni_1;    ni_p => ni_2
     2535                ENDIF
    20402536
    20412537             CASE ( 1 )
     
    20492545                   nr => nr_2;    nr_p => nr_1
    20502546                ENDIF
     2547                IF ( microphysics_ice_extension )  THEN
     2548                   qi => qi_2;    qi_p => qi_1
     2549                   ni => ni_2;    ni_p => ni_1
     2550                ENDIF
     2551
    20512552
    20522553          END SELECT
     
    20932594       ENDIF
    20942595
     2596       IF ( microphysics_ice_extension )  THEN
     2597!
     2598!--       Surface conditions ice crysral (Dirichlet)
     2599!--       Run loop over all non-natural and natural walls. Note, in wall-datatype
     2600!--       the k coordinate belongs to the atmospheric grid point, therefore, set
     2601!--       qr_p and nr_p at upward (k-1) and downward-facing (k+1) walls
     2602          DO  l = 0, 1
     2603          !$OMP PARALLEL DO PRIVATE( i, j, k )
     2604             DO  m = 1, bc_h(l)%ns
     2605                i = bc_h(l)%i(m)
     2606                j = bc_h(l)%j(m)
     2607                k = bc_h(l)%k(m)
     2608                qi_p(k+bc_h(l)%koff,j,i) = 0.0_wp
     2609                ni_p(k+bc_h(l)%koff,j,i) = 0.0_wp
     2610             ENDDO
     2611          ENDDO
     2612!
     2613!--       Top boundary condition for ice crystal (Dirichlet)
     2614          qi_p(nzt+1,:,:) = 0.0_wp
     2615          ni_p(nzt+1,:,:) = 0.0_wp
     2616
     2617       ENDIF
     2618
     2619
    20952620       IF ( microphysics_seifert )  THEN
    20962621!
     
    21292654             nr_p(:,nys-1,:) = nr_p(:,nys,:)
    21302655          ENDIF
     2656          IF ( microphysics_ice_extension )  THEN
     2657             qi_p(:,nys-1,:) = qi_p(:,nys,:)
     2658             ni_p(:,nys-1,:) = ni_p(:,nys,:)
     2659          ENDIF
    21312660       ELSEIF ( bc_radiation_n )  THEN
    21322661          IF ( microphysics_morrison )  THEN
     
    21382667             nr_p(:,nyn+1,:) = nr_p(:,nyn,:)
    21392668          ENDIF
     2669          IF ( microphysics_ice_extension )  THEN
     2670             qi_p(:,nyn+1,:) = qi_p(:,nyn,:)
     2671             ni_p(:,nyn+1,:) = ni_p(:,nyn,:)
     2672          ENDIF
    21402673       ELSEIF ( bc_radiation_l )  THEN
    21412674          IF ( microphysics_morrison )  THEN
     
    21472680             nr_p(:,:,nxl-1) = nr_p(:,:,nxl)
    21482681          ENDIF
     2682          IF ( microphysics_ice_extension )  THEN
     2683             qi_p(:,:,nxl-1) = qi_p(:,:,nxl)
     2684             ni_p(:,:,nxl-1) = ni_p(:,:,nxl)
     2685          ENDIF
    21492686       ELSEIF ( bc_radiation_r )  THEN
    21502687          IF ( microphysics_morrison )  THEN
     
    21552692             qr_p(:,:,nxr+1) = qr_p(:,:,nxr)
    21562693             nr_p(:,:,nxr+1) = nr_p(:,:,nxr)
     2694          ENDIF
     2695          IF ( microphysics_ice_extension )  THEN
     2696             qi_p(:,:,nxr+1) = qi_p(:,:,nxr)
     2697             ni_p(:,:,nxr+1) = ni_p(:,:,nxr)
    21572698          ENDIF
    21582699       ENDIF
     
    24332974             ENDIF
    24342975             to_be_resorted => nc_av
     2976          ENDIF
     2977          IF ( mode == 'xy' ) grid = 'zu'
     2978
     2979       CASE ( 'ni_xy', 'ni_xz', 'ni_yz' )
     2980          IF ( av == 0 )  THEN
     2981             to_be_resorted => ni
     2982          ELSE
     2983             IF ( .NOT. ALLOCATED( ni_av ) ) THEN
     2984                ALLOCATE( ni_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     2985                ni_av = REAL( fill_value, KIND = wp )
     2986             ENDIF
     2987             to_be_resorted => ni_av
    24352988          ENDIF
    24362989          IF ( mode == 'xy' ) grid = 'zu'
     
    24993052          IF ( mode == 'xy' ) grid = 'zu'
    25003053
     3054       CASE ( 'qi_xy', 'qi_xz', 'qi_yz' )
     3055          IF ( av == 0 )  THEN
     3056             to_be_resorted => qi
     3057          ELSE
     3058             IF ( .NOT. ALLOCATED( qi_av ) ) THEN
     3059                ALLOCATE( qi_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     3060                qi_av = REAL( fill_value, KIND = wp )
     3061             ENDIF
     3062             to_be_resorted => qi_av
     3063          ENDIF
     3064          IF ( mode == 'xy' ) grid = 'zu'
     3065
    25013066       CASE ( 'ql_xy', 'ql_xz', 'ql_yz' )
    25023067          IF ( av == 0 )  THEN
     
    25343099             DO  k = nzb_do, nzt_do
    25353100                local_pf(i,j,k) = MERGE( &
    2536                                      to_be_resorted(k,j,i),                      &
    2537                                      REAL( fill_value, KIND = wp ),              &
    2538                                      BTEST( wall_flags_total_0(k,j,i), flag_nr ) &
     3101                                     to_be_resorted(k,j,i),                    &
     3102                                     REAL( fill_value, KIND = wp ),            &
     3103                                     BTEST( wall_flags_total_0(k,j,i), flag_nr )     &
    25393104                                  )
    25403105             ENDDO
     
    25953160             ENDIF
    25963161             to_be_resorted => nc_av
     3162          ENDIF
     3163
     3164       CASE ( 'ni' )
     3165          IF ( av == 0 )  THEN
     3166             to_be_resorted => ni
     3167          ELSE
     3168             IF ( .NOT. ALLOCATED( ni_av ) ) THEN
     3169                ALLOCATE( ni_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     3170                ni_av = REAL( fill_value, KIND = wp )
     3171             ENDIF
     3172             to_be_resorted => ni_av
    25973173          ENDIF
    25983174
     
    26433219          ENDIF
    26443220
     3221       CASE ( 'qi' )
     3222          IF ( av == 0 )  THEN
     3223             to_be_resorted => qi
     3224          ELSE
     3225             IF ( .NOT. ALLOCATED( qi_av ) ) THEN
     3226                ALLOCATE( qi_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     3227                qi_av = REAL( fill_value, KIND = wp )
     3228             ENDIF
     3229             to_be_resorted => qi_av
     3230          ENDIF
     3231
    26453232       CASE ( 'ql' )
    26463233          IF ( av == 0 )  THEN
     
    26753262          DO  j = nys, nyn
    26763263             DO  k = nzb_do, nzt_do
    2677                 local_pf(i,j,k) = MERGE(                                         &
    2678                                      to_be_resorted(k,j,i),                      &
    2679                                      REAL( fill_value, KIND = wp ),              &
    2680                                      BTEST( wall_flags_total_0(k,j,i), flag_nr ) &
     3264                local_pf(i,j,k) = MERGE(                                       &
     3265                                     to_be_resorted(k,j,i),                    &
     3266                                     REAL( fill_value, KIND = wp ),            &
     3267                                     BTEST( wall_flags_total_0(k,j,i), flag_nr )     &
    26813268                                  )
    26823269             ENDDO
     
    27503337          CASE ( 'curvature_solution_effects_bulk' )
    27513338             READ ( 13 )  curvature_solution_effects_bulk
     3339
     3340          CASE ( 'microphysics_ice_extension' )
     3341             READ ( 13 )  microphysics_ice_extension
     3342
     3343          CASE ( 'ice_crystal_sedimentation' )
     3344             READ ( 13 )  ice_crystal_sedimentation
     3345
     3346          CASE ( 'in_init' )
     3347             READ ( 13 )  in_init
     3348
     3349          CASE ( 'start_ice_microphysics' )
     3350             READ ( 13 )  start_ice_microphysics
    27523351
    27533352          CASE DEFAULT
     
    27823381       CALL rrd_mpi_io( 'aerosol_bulk', aerosol_bulk )
    27833382       CALL rrd_mpi_io( 'curvature_solution_effects_bulk', curvature_solution_effects_bulk )
     3383       CALL rrd_mpi_io( 'start_ice_microphysics', start_ice_microphysics )
     3384       CALL rrd_mpi_io( 'microphysics_ice_extension', microphysics_ice_extension )
     3385       CALL rrd_mpi_io( 'in_init', in_init )
     3386       CALL rrd_mpi_io( 'ice_crystal_sedimentation', ice_crystal_sedimentation )
     3387
     3388
    27843389
    27853390    END SUBROUTINE bcm_rrd_global_mpi
     
    28463451                tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    28473452
     3453          CASE ( 'ni' )
     3454             IF ( k == 1 )  READ ( 13 )  tmp_3d
     3455             ni(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =             &
     3456                tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     3457
     3458          CASE ( 'ni_av' )
     3459             IF ( .NOT. ALLOCATED( ni_av ) )  THEN
     3460                ALLOCATE( ni_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     3461             ENDIF
     3462             IF ( k == 1 )  READ ( 13 )  tmp_3d
     3463             ni_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =          &
     3464                tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     3465
    28483466          CASE ( 'nr' )
    28493467             IF ( k == 1 )  READ ( 13 )  tmp_3d
     
    28863504                tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    28873505
     3506          CASE ( 'qi' )
     3507             IF ( k == 1 )  READ ( 13 )  tmp_3d
     3508             qi(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =             &
     3509                tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     3510
     3511          CASE ( 'qi_av' )
     3512             IF ( .NOT. ALLOCATED( qi_av ) )  THEN
     3513                ALLOCATE( qi_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     3514             ENDIF
     3515             IF ( k == 1 )  READ ( 13 )  tmp_3d
     3516             qi_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =          &
     3517                tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     3518
    28883519          CASE ( 'qc_av' )
    28893520             IF ( .NOT. ALLOCATED( qc_av ) )  THEN
     
    29843615          CALL wrd_write_string( 'curvature_solution_effects_bulk' )
    29853616          WRITE ( 14 )  curvature_solution_effects_bulk
     3617
     3618          CALL wrd_write_string( 'start_ice_microphysics' )
     3619          WRITE ( 14 )  start_ice_microphysics
     3620
     3621          CALL wrd_write_string( 'microphysics_ice_extension' )
     3622          WRITE ( 14 )  microphysics_ice_extension
     3623
     3624          CALL wrd_write_string( 'in_init' )
     3625          WRITE ( 14 )  in_init
     3626
     3627          CALL wrd_write_string( 'ice_crystal_sedimentation' )
     3628          WRITE ( 14 )  ice_crystal_sedimentation
    29863629
    29873630       ELSEIF ( TRIM( restart_data_format_output ) == 'mpi' )  THEN
     
    30013644          CALL wrd_mpi_io( 'aerosol_bulk', aerosol_bulk )
    30023645          CALL wrd_mpi_io( 'curvature_solution_effects_bulk', curvature_solution_effects_bulk )
     3646          CALL wrd_mpi_io( 'start_ice_microphysics', start_ice_microphysics )
     3647          CALL wrd_mpi_io( 'microphysics_ice_extension', microphysics_ice_extension )
     3648          CALL wrd_mpi_io( 'in_init', in_init )
     3649          CALL wrd_mpi_io( 'ice_crystal_sedimentation', ice_crystal_sedimentation )
    30033650
    30043651       ENDIF
     
    30623709
    30633710          ENDIF
     3711
     3712          IF ( microphysics_ice_extension )  THEN
     3713
     3714             CALL wrd_write_string( 'ni' )
     3715             WRITE ( 14 )  ni
     3716
     3717             IF ( ALLOCATED( ni_av ) )  THEN
     3718                CALL wrd_write_string( 'ni_av' )
     3719                WRITE ( 14 )  ni_av
     3720             ENDIF
     3721
     3722             CALL wrd_write_string( 'qi' )
     3723             WRITE ( 14 )  qi
     3724
     3725             IF ( ALLOCATED( qi_av ) )  THEN
     3726                CALL wrd_write_string( 'qi_av' )
     3727                WRITE ( 14 )  qi_av
     3728             ENDIF
     3729
     3730          ENDIF
     3731
    30643732
    30653733          IF ( microphysics_seifert )  THEN
     
    31043772             IF ( ALLOCATED( qr_av ) )  CALL wrd_mpi_io( 'qr_av', qr_av )
    31053773          ENDIF
     3774          IF ( microphysics_ice_extension )  THEN
     3775             CALL wrd_mpi_io( 'ni', ni )
     3776             IF ( ALLOCATED( ni_av ) )  CALL wrd_mpi_io( 'ni_av', ni_av )
     3777             CALL wrd_mpi_io( 'qi', qi )
     3778             IF ( ALLOCATED( qi_av ) )  CALL wrd_mpi_io( 'qi_av', qi_av )
     3779          ENDIF
    31063780
    31073781       ENDIF
     
    31343808!--             Predetermine flag to mask topography
    31353809                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
    3136 
    3137                 IF ( qr(k,j,i) <= eps_sb )  THEN
    3138                    qr(k,j,i) = 0.0_wp
    3139                    nr(k,j,i) = 0.0_wp
    3140                 ELSE
    3141                    IF ( nr(k,j,i) * xrmin > qr(k,j,i) * hyrho(k) )  THEN
    3142                       nr(k,j,i) = qr(k,j,i) * hyrho(k) / xrmin * flag
    3143                    ELSEIF ( nr(k,j,i) * xrmax < qr(k,j,i) * hyrho(k) )  THEN
    3144                       nr(k,j,i) = qr(k,j,i) * hyrho(k) / xrmax * flag
     3810                IF ( .NOT. microphysics_morrison_no_rain )  THEN
     3811                   IF ( qr(k,j,i) <= eps_sb )  THEN
     3812                      qr(k,j,i) = 0.0_wp
     3813                      nr(k,j,i) = 0.0_wp
     3814                   ELSE
     3815                      IF ( nr(k,j,i) * xrmin > qr(k,j,i) * hyrho(k) )  THEN
     3816                         nr(k,j,i) = qr(k,j,i) * hyrho(k) / xrmin * flag
     3817                      ELSEIF ( nr(k,j,i) * xrmax < qr(k,j,i) * hyrho(k) )  THEN
     3818                         nr(k,j,i) = qr(k,j,i) * hyrho(k) / xrmax * flag
     3819                      ENDIF
    31453820                   ENDIF
    31463821                ENDIF
     
    31893864          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
    31903865
    3191           IF ( qr(k,j,i) <= eps_sb )  THEN
    3192              qr(k,j,i) = 0.0_wp
    3193              nr(k,j,i) = 0.0_wp
    3194           ELSE
    3195 !
    3196 !--          Adjust number of raindrops to avoid nonlinear effects in
    3197 !--          sedimentation and evaporation of rain drops due to too small or
    3198 !--          too big weights of rain drops (Stevens and Seifert, 2008).
    3199              IF ( nr(k,j,i) * xrmin > qr(k,j,i) * hyrho(k) )  THEN
    3200                 nr(k,j,i) = qr(k,j,i) * hyrho(k) / xrmin * flag
    3201              ELSEIF ( nr(k,j,i) * xrmax < qr(k,j,i) * hyrho(k) )  THEN
    3202                 nr(k,j,i) = qr(k,j,i) * hyrho(k) / xrmax * flag
    3203              ENDIF
    3204 
     3866          IF ( .NOT.  microphysics_morrison_no_rain )  THEN
     3867             IF ( qr(k,j,i) <= eps_sb )  THEN
     3868                qr(k,j,i) = 0.0_wp
     3869                nr(k,j,i) = 0.0_wp
     3870             ELSE
     3871!
     3872!--             Adjust number of raindrops to avoid nonlinear effects in
     3873!--             sedimentation and evaporation of rain drops due to too small or
     3874!--             too big weights of rain drops (Stevens and Seifert, 2008).
     3875                IF ( nr(k,j,i) * xrmin > qr(k,j,i) * hyrho(k) )  THEN
     3876                   nr(k,j,i) = qr(k,j,i) * hyrho(k) / xrmin * flag
     3877                ELSEIF ( nr(k,j,i) * xrmax < qr(k,j,i) * hyrho(k) )  THEN
     3878                   nr(k,j,i) = qr(k,j,i) * hyrho(k) / xrmax * flag
     3879                ENDIF
     3880             ENDIF
    32053881          ENDIF
    32063882
     
    32193895
    32203896    END SUBROUTINE adjust_cloud_ij
     3897
     3898!------------------------------------------------------------------------------!
     3899! Description:
     3900! ------------
     3901!> Adjust number of ice crystal to avoid nonlinear effects in sedimentation and
     3902!> evaporation of ice crytals due to too small or too big weights
     3903!> of ice crytals (Stevens and Seifert, 2008).
     3904!------------------------------------------------------------------------------!
     3905    SUBROUTINE adjust_ice
     3906
     3907       IMPLICIT NONE
     3908
     3909       INTEGER(iwp) ::  i                 !<
     3910       INTEGER(iwp) ::  j                 !<
     3911       INTEGER(iwp) ::  k                 !<
     3912
     3913       REAL(wp) ::  flag                  !< flag to indicate first grid level above
     3914
     3915       CALL cpu_log( log_point_s(97), 'adjust_ice', 'start' )
     3916
     3917       DO  i = nxl, nxr
     3918          DO  j = nys, nyn
     3919             DO  k = nzb+1, nzt
     3920!
     3921!--             Predetermine flag to mask topography
     3922                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
     3923                IF ( qi(k,j,i) <= ximin )  THEN
     3924                   qi(k,j,i) = 0.0_wp
     3925                   ni(k,j,i) = 0.0_wp
     3926                ELSE
     3927                   IF ( ni(k,j,i) * ximin > qi(k,j,i) * hyrho(k) )  THEN
     3928                      ni(k,j,i) = qi(k,j,i) * hyrho(k) / ximin * flag
     3929                   ENDIF
     3930                ENDIF
     3931             ENDDO
     3932          ENDDO
     3933       ENDDO
     3934
     3935       CALL cpu_log( log_point_s(97), 'adjust_ice', 'stop' )
     3936
     3937    END SUBROUTINE adjust_ice
     3938
     3939!------------------------------------------------------------------------------!
     3940! Description:
     3941! ------------
     3942!> Adjust number of of ice crystal to avoid nonlinear effects in
     3943!> sedimentation and evaporation of ice crystals due to too small or
     3944!> too big weights of ice crytals (Stevens and Seifert, 2008).
     3945!> The same procedure is applied to cloud droplets if they are determined
     3946!> prognostically. Call for grid point i,j
     3947!------------------------------------------------------------------------------!
     3948    SUBROUTINE adjust_ice_ij( i, j )
     3949
     3950       IMPLICIT NONE
     3951
     3952       INTEGER(iwp) ::  i                 !<
     3953       INTEGER(iwp) ::  j                 !<
     3954       INTEGER(iwp) ::  k                 !<
     3955
     3956       REAL(wp) ::  flag                  !< flag to indicate first grid level above surface
     3957
     3958       DO  k = nzb+1, nzt
     3959!
     3960!--       Predetermine flag to mask topography
     3961          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
     3962          IF ( qi(k,j,i) <= ximin )  THEN
     3963             qi(k,j,i) = 0.0_wp
     3964             ni(k,j,i) = 0.0_wp
     3965          ELSE
     3966             IF ( ni(k,j,i) * ximin > qi(k,j,i) * hyrho(k) )  THEN
     3967                ni(k,j,i) = qi(k,j,i) * hyrho(k) / ximin * flag
     3968             ENDIF
     3969          ENDIF
     3970       ENDDO
     3971
     3972    END SUBROUTINE adjust_ice_ij
     3973
    32213974
    32223975!------------------------------------------------------------------------------!
     
    34234176    END SUBROUTINE activation_ij
    34244177
     4178!------------------------------------------------------------------------------!
     4179! Description:
     4180! ------------
     4181!> Calculate ice nucleation by applying the deposition-condensation formula as
     4182!> given by Meyers et al 1992 and as described in Seifert and Beheng 2006
     4183!------------------------------------------------------------------------------!
     4184    SUBROUTINE ice_nucleation
     4185
     4186       INTEGER(iwp) ::  i             !< loop index
     4187       INTEGER(iwp) ::  j             !< loop index
     4188       INTEGER(iwp) ::  k             !< loop index
     4189
     4190       LOGICAL :: isdac = .TRUE.
     4191
     4192       REAL(wp) ::  a_m92 = -0.639_wp !< parameter for nucleation
     4193       REAL(wp) ::  b_m92 = 12.96_wp  !< parameter for nucleation
     4194       REAL(wp) ::  flag              !< flag to indicate first grid level
     4195       REAL(wp) ::  n_in              !< number of ice nucleii
     4196       REAL(wp) ::  nucle = 0.0_wp    !< nucleation rate
     4197
     4198       CALL cpu_log( log_point_s(93), 'ice_nucleation', 'start' )
     4199
     4200       IF  ( isdac )  THEN
     4201          DO  i = nxl, nxr
     4202             DO  j = nys, nyn
     4203                DO  k = nzb+1, nzt
     4204!
     4205!--                Predetermine flag to mask topography
     4206                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
     4207!
     4208!--                Call calculation of supersaturation located in subroutine
     4209                   CALL supersaturation_ice ( i, j, k )
     4210                   nucle = 0.0_wp
     4211                   !IF ( zu(k) >= 1500.0_wp ) CYCLE
     4212                   IF ( sat_ice >= 0.05_wp  .OR.  ql(k,j,i) >= 0.001E-3_wp  ) THEN
     4213!
     4214!--                   Calculate ice nucleation
     4215                      nucle = MAX( ( in_init - ni(k,j,i) ) / dt_micro, 0.0_wp )
     4216                      !qi(k,j,i) = qi(k,j,i) + nucle * dt_micro * ximin
     4217                      ni(k,j,i) = MIN( (ni(k,j,i) + nucle * dt_micro * flag), in_init)
     4218                   ENDIF
     4219
     4220                ENDDO
     4221             ENDDO
     4222          ENDDO
     4223       ELSE
     4224          DO  i = nxl, nxr
     4225             DO  j = nys, nyn
     4226                DO  k = nzb+1, nzt
     4227!
     4228!--                Predetermine flag to mask topography
     4229                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
     4230!
     4231!--                Call calculation of supersaturation located in subroutine
     4232                   CALL supersaturation_ice ( i, j, k )
     4233                   nucle = 0.0_wp
     4234                   IF ( sat_ice > 0.0 ) THEN
     4235!
     4236!--                   Calculate ice nucleation
     4237                      n_in = in_init * EXP( a_m92 + b_m92 * sat_ice )
     4238                      nucle = MAX( ( n_in - ni(k,j,i) ) / dt_micro, 0.0_wp )
     4239                   ENDIF
     4240                   ni(k,j,i) = MIN( (ni(k,j,i) + nucle * dt_micro * flag), 1.0E10_wp )
     4241                ENDDO
     4242             ENDDO
     4243          ENDDO
     4244       ENDIF
     4245
     4246       CALL cpu_log( log_point_s(93), 'ice_nucleation', 'stop' )
     4247
     4248    END SUBROUTINE ice_nucleation
     4249
     4250
     4251!------------------------------------------------------------------------------!
     4252! Description:
     4253! ------------
     4254!> Calculate ice nucleation by applying the deposition-condensation formula as
     4255!> given by Meyers et al 1992 and as described in Seifert and Beheng 2006
     4256!------------------------------------------------------------------------------!
     4257    SUBROUTINE ice_nucleation_ij( i, j )
     4258
     4259       INTEGER(iwp) ::  i             !< loop index
     4260       INTEGER(iwp) ::  j             !< loop index
     4261       INTEGER(iwp) ::  k             !< loop index
     4262
     4263       LOGICAL :: isdac = .TRUE.
     4264
     4265       REAL(wp) ::  a_m92 = -0.639_wp !< parameter for nucleation
     4266       REAL(wp) ::  b_m92 = 12.96_wp  !< parameter for nucleation
     4267       REAL(wp) ::  flag              !< flag to indicate first grid level
     4268       REAL(wp) ::  n_in              !< number of ice nucleii
     4269       REAL(wp) ::  nucle = 0.0_wp    !< nucleation rate
     4270
     4271       IF ( isdac )  THEN
     4272          DO  k = nzb+1, nzt
     4273!
     4274!--          Predetermine flag to mask topography
     4275             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
     4276!
     4277!--          Call calculation of supersaturation located in subroutine
     4278             CALL supersaturation_ice ( i, j, k )
     4279             nucle = 0.0_wp
     4280             !IF ( zu(k) >= 1500.0_wp ) CYCLE
     4281             IF ( sat_ice >= 0.05_wp  .OR.  ql(k,j,i) >= 0.001E-3_wp ) THEN
     4282!
     4283!--             Calculate ice nucleation
     4284                nucle = MAX( ( in_init - ni(k,j,i) ) / dt_micro, 0.0_wp )
     4285                !qi(k,j,i) = qi(k,j,i) + nucle * dt_micro * ximin
     4286                ni(k,j,i) = MIN( (ni(k,j,i) + nucle * dt_micro * flag), in_init)
     4287             ENDIF
     4288          ENDDO
     4289       ELSE
     4290          DO  k = nzb+1, nzt
     4291!
     4292!--          Predetermine flag to mask topography
     4293             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
     4294!
     4295!--          Call calculation of supersaturation located in subroutine
     4296             CALL supersaturation_ice ( i, j, k )
     4297             nucle = 0.0_wp
     4298             IF ( sat_ice > 0.0 ) THEN
     4299!
     4300!--             Calculate ice nucleation
     4301                n_in = in_init * EXP( a_m92 + b_m92 * sat_ice )
     4302                nucle = MAX( ( n_in - ni(k,j,i) ) / dt_micro, 0.0_wp )
     4303             ENDIF
     4304             ni(k,j,i) = MIN( (ni(k,j,i) + nucle * dt_micro * flag), 1.0E10_wp )
     4305          ENDDO
     4306       ENDIF
     4307
     4308
     4309    END SUBROUTINE ice_nucleation_ij
    34254310
    34264311!------------------------------------------------------------------------------!
     
    34344319       IMPLICIT NONE
    34354320
    3436        INTEGER(iwp) ::  i                 !<
    3437        INTEGER(iwp) ::  j                 !<
    3438        INTEGER(iwp) ::  k                 !<
    3439 
    3440        REAL(wp)     ::  cond              !<
    3441        REAL(wp)     ::  cond_max          !<
    3442        REAL(wp)     ::  dc                !<
    3443        REAL(wp)     ::  evap              !<
    3444        REAL(wp)     ::  g_fac             !<
    3445        REAL(wp)     ::  nc_0              !<
    3446        REAL(wp)     ::  temp              !<
    3447        REAL(wp)     ::  xc                !<
    3448 
    3449        REAL(wp) ::  flag                  !< flag to indicate first grid level above
     4321       INTEGER(iwp) ::  i                 !< loop index
     4322       INTEGER(iwp) ::  j                 !< loop index
     4323       INTEGER(iwp) ::  k                 !< loop index
     4324
     4325       REAL(wp)     ::  cond              !< condensation rate
     4326       REAL(wp)     ::  cond_max          !< maximum condensation rate
     4327       REAL(wp)     ::  dc                !< weight avageraed diameter
     4328       REAL(wp)     ::  evap              !< evaporation rate
     4329       REAL(wp)     ::  flag              !< flag to indicate first grid level above surface
     4330       REAL(wp)     ::  g_fac             !< factor 1 / Fk + Fd
     4331       REAL(wp)     ::  nc_0              !< integral diameter
     4332       REAL(wp)     ::  temp              !< actual temperature
     4333       REAL(wp)     ::  xc                !< mean mass droplets
    34504334
    34514335       CALL cpu_log( log_point_s(66), 'condensation', 'start' )
     
    34614345                CALL supersaturation ( i, j, k )
    34624346!
    3463 !--             Actual temperature:
    3464                 IF ( microphysics_seifert ) THEN
    3465                    temp = t_l + lv_d_cp * ( qc(k,j,i) + qr(k,j,i) )
    3466                 ELSEIF ( microphysics_morrison_no_rain ) THEN
    3467                    temp = t_l + lv_d_cp * qc(k,j,i)
    3468                 ENDIF 
     4347!--             Actual temperature, t_l is calculated directly before
     4348!--             in supersaturation
     4349                IF ( microphysics_ice_extension ) THEN
     4350                   temp = t_l + lv_d_cp * ql(k,j,i) + ls_d_cp * qi(k,j,i)
     4351                ELSE
     4352                   temp = t_l + lv_d_cp * ql(k,j,i)
     4353                ENDIF
    34694354
    34704355                g_fac  = 1.0_wp / ( ( l_v / ( r_v * temp ) - 1.0_wp ) *        &
     
    35254410       IMPLICIT NONE
    35264411
    3527        INTEGER(iwp) ::  i                 !<
    3528        INTEGER(iwp) ::  j                 !<
    3529        INTEGER(iwp) ::  k                 !<
    3530 
    3531        REAL(wp)     ::  cond              !<
    3532        REAL(wp)     ::  cond_max          !<
    3533        REAL(wp)     ::  dc                !<
    3534        REAL(wp)     ::  evap              !<
     4412       INTEGER(iwp) ::  i                 !< loop index
     4413       INTEGER(iwp) ::  j                 !< loop index
     4414       INTEGER(iwp) ::  k                 !< loop index
     4415
     4416       REAL(wp)     ::  cond              !< condensation rate
     4417       REAL(wp)     ::  cond_max          !< maximum condensation rate
     4418       REAL(wp)     ::  dc                !< weight avageraed diameter
     4419       REAL(wp)     ::  evap              !< evaporation rate
    35354420       REAL(wp)     ::  flag              !< flag to indicate first grid level above surface
    3536        REAL(wp)     ::  g_fac             !<
    3537        REAL(wp)     ::  nc_0              !<
    3538        REAL(wp)     ::  temp              !<
    3539        REAL(wp)     ::  xc                !<
    3540 
     4421       REAL(wp)     ::  g_fac             !< factor 1 / Fk + Fd
     4422       REAL(wp)     ::  nc_0              !< integral diameter
     4423       REAL(wp)     ::  temp              !< actual temperature
     4424       REAL(wp)     ::  xc                !< mean mass droplets
    35414425
    35424426       DO  k = nzb+1, nzt
     
    35484432          CALL supersaturation ( i, j, k )
    35494433!
    3550 !--       Actual temperature:
    3551           IF ( microphysics_seifert ) THEN
    3552              temp = t_l + lv_d_cp * ( qc(k,j,i) + qr(k,j,i) )
    3553           ELSEIF ( microphysics_morrison_no_rain ) THEN
    3554              temp = t_l + lv_d_cp * qc(k,j,i)
    3555           ENDIF 
    3556 
    3557           g_fac  = 1.0_wp / ( ( l_v / ( r_v * temp ) - 1.0_wp ) *        &
    3558                               l_v / ( thermal_conductivity_l * temp )    &
    3559                               + r_v * temp / ( diff_coeff_l * e_s )      &
     4434!--       Actual temperature, t_l is calculated directly before
     4435!--       in supersaturation
     4436          IF ( microphysics_ice_extension ) THEN
     4437             temp = t_l + lv_d_cp * ql(k,j,i) + ls_d_cp * qi(k,j,i)
     4438          ELSE
     4439             temp = t_l + lv_d_cp * ql(k,j,i)
     4440          ENDIF
     4441
     4442          g_fac  = 1.0_wp / ( ( l_v / ( r_v * temp ) - 1.0_wp ) *              &
     4443                              l_v / ( thermal_conductivity_l * temp )          &
     4444                              + r_v * temp / ( diff_coeff_l * e_s )            &
    35604445                            )
    35614446!
     
    35944479
    35954480    END SUBROUTINE condensation_ij
     4481
     4482!------------------------------------------------------------------------------!
     4483! Description:
     4484! ------------
     4485!> Calculate the growth of ice particles by water vapor deposition (after
     4486!> Seifert and Beheng, 2006).
     4487!------------------------------------------------------------------------------!
     4488    SUBROUTINE ice_deposition
     4489
     4490       INTEGER(iwp) ::  i                 !< loop index
     4491       INTEGER(iwp) ::  j                 !< loop index
     4492       INTEGER(iwp) ::  k                 !< loop index
     4493
     4494       REAL(wp) ::  ac = 0.09_wp        !< parameter for ice capacitance
     4495       REAL(wp) ::  bc = 0.33_wp        !< parameter for ice capacitance
     4496       REAL(wp) ::  fac_gamma = 0.76_wp !< parameter to describe spectral
     4497                                        !< distribution, here following gamma
     4498                                        !< size distribution with µ =1/3 and nu=0
     4499       REAL(wp) ::  deposition_rate     !< depositions rate
     4500       REAL(wp) ::  deposition_rate_max !< maximum deposition rate
     4501       REAL(wp) ::  sublimation_rate    !< sublimations rate
     4502       REAL(wp) ::  gfac_dep            !< factor
     4503       REAL(wp) ::  temp                !< actual temperature
     4504       REAL(wp) ::  xi                  !< mean mass of ice crystal
     4505       REAL(wp) ::  flag                !< flag to indicate first grid level above
     4506
     4507       CALL cpu_log( log_point_s(95), 'ice deposition', 'start' )
     4508
     4509       DO  i = nxl, nxr
     4510          DO  j = nys, nyn
     4511             DO  k = nzb+1, nzt
     4512!
     4513!--             Predetermine flag to mask topography
     4514                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
     4515!
     4516!--             Call calculation of supersaturation over a plane ice surface
     4517                CALL supersaturation_ice ( i, j, k )
     4518!
     4519!--             Actual temperature:
     4520                temp = t_l + lv_d_cp * ql(k,j,i) + ls_d_cp * qi(k,j,i)
     4521
     4522                IF ( temp >= 273.15_wp ) CYCLE
     4523!
     4524!--             calculating gfac_dep ( 1/ (Fk + Fd) ) see e.g.
     4525!--             Rogers and Yau, 1989
     4526                gfac_dep  = 1.0_wp / ( ( l_s / ( r_v * temp ) - 1.0_wp ) *     &
     4527                                    l_s / ( thermal_conductivity_l * temp )    &
     4528                                    + r_v * temp / ( diff_coeff_l * e_si )     &
     4529                                    )
     4530!
     4531!--             If there is nothing nucleated, than there is also no
     4532!--             deposition (above -38°C)
     4533                IF ( ni(k,j,i) <= 0.0_wp ) CYCLE
     4534!
     4535!--             calculate mean mass of ice crystal
     4536                xi = 0.0_wp
     4537                xi = MAX( ( qi(k,j,i) * hyrho(k) / ni(k,j,i)), ximin )
     4538!
     4539!--             Condensation needs only to be calculated in supersaturated
     4540!--             regions (regarding ice)
     4541                IF ( sat_ice > 0.0_wp )  THEN
     4542!
     4543!--                Calculate deposition rate assuming ice crystal shape as
     4544!--                prescribed in Ovchinnikov et al., 2014 and a gamma size
     4545!--                distribution according to Seifert and Beheng with to
     4546!--                µ =1/3 and nu=0
     4547                   deposition_rate  = 4.0_wp * pi * sat_ice * gfac_dep *       &
     4548                                      fac_gamma * ac * xi**bc * ni(k,j,i)
     4549                   IF ( microphysics_seifert ) THEN
     4550                      deposition_rate_max  = q(k,j,i) -                        &
     4551                                             q_si - qr(k,j,i) - qi(k,j,i)
     4552                   ELSEIF ( microphysics_morrison_no_rain ) THEN
     4553                      deposition_rate_max  = q(k,j,i) -                        &
     4554                                             q_si - qc(k,j,i) - qi(k,j,i)
     4555                   ENDIF
     4556                   deposition_rate = MIN( deposition_rate,                     &
     4557                                          deposition_rate_max / dt_micro )
     4558
     4559                   qi(k,j,i) = qi(k,j,i) + deposition_rate * dt_micro * flag
     4560                ELSEIF ( sat_ice < 0.0_wp ) THEN
     4561                   sublimation_rate = 4.0_wp * pi * sat_ice * gfac_dep *       &
     4562                                      fac_gamma * ac * xi**bc * ni(k,j,i)
     4563                   sublimation_rate = MAX( sublimation_rate,                   &
     4564                                           -qi(k,j,i) / dt_micro )
     4565                   qi(k,j,i) = qi(k,j,i) + sublimation_rate * dt_micro * flag
     4566                ENDIF
     4567             ENDDO
     4568          ENDDO
     4569       ENDDO
     4570
     4571       CALL cpu_log( log_point_s(95), 'ice deposition', 'stop' )
     4572
     4573    END SUBROUTINE ice_deposition
     4574
     4575!------------------------------------------------------------------------------!
     4576! Description:
     4577! ------------
     4578!> Calculate condensation rate for cloud water content (after Khairoutdinov and
     4579!> Kogan, 2000).
     4580!------------------------------------------------------------------------------!
     4581    SUBROUTINE ice_deposition_ij( i, j )
     4582
     4583       INTEGER(iwp) ::  i                 !< loop index
     4584       INTEGER(iwp) ::  j                 !< loop index
     4585       INTEGER(iwp) ::  k                 !< loop index
     4586
     4587       REAL(wp) ::  ac = 0.09_wp        !< parameter for ice capacitance
     4588       REAL(wp) ::  bc = 0.33_wp        !< parameter for ice capacitance
     4589       REAL(wp) ::  fac_gamma = 0.76_wp !< parameter to describe spectral
     4590                                        !< distribution, here following gamma
     4591                                        !< size distribution with nu=1, v=0
     4592       REAL(wp) ::  deposition_rate     !< depositions rate
     4593       REAL(wp) ::  deposition_rate_max !< maximum deposition rate
     4594       REAL(wp) ::  sublimation_rate    !< sublimations rate
     4595       REAL(wp) ::  gfac_dep            !< factor
     4596       REAL(wp) ::  temp                !< actual temperature
     4597       REAL(wp) ::  xi                  !< mean mass of ice crystal
     4598       REAL(wp) ::  flag                !< flag to indicate first grid level above
     4599
     4600       DO  k = nzb+1, nzt
     4601!
     4602!--       Predetermine flag to mask topography
     4603          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
     4604!
     4605!--       Call calculation of supersaturation over a plane ice surface
     4606          CALL supersaturation_ice ( i, j, k )
     4607!
     4608!--       Actual temperature:
     4609          temp = t_l + lv_d_cp * ql(k,j,i) + ls_d_cp * qi(k,j,i)
     4610
     4611          IF ( temp >= 273.15_wp ) CYCLE
     4612!
     4613!--       calculating gfac_dep ( 1/ (Fk + Fd) ) see e.g.
     4614!--       Rogers and Yau, 1989
     4615          gfac_dep  = 1.0_wp / ( ( l_s / ( r_v * temp ) - 1.0_wp ) *           &
     4616                              l_s / ( thermal_conductivity_l * temp )          &
     4617                              + r_v * temp / ( diff_coeff_l * e_si )           &
     4618                              )
     4619!
     4620!--       If there is nothing nucleated, than there is also no
     4621!--       deposition (above -38°C)
     4622          IF ( ni(k,j,i) <= 0.0_wp ) CYCLE
     4623!
     4624!--       calculate mean mass of ice crystal
     4625          xi = 0.0_wp
     4626          xi = MAX( ( qi(k,j,i) * hyrho(k) / ni(k,j,i)), ximin )
     4627!
     4628!--       Condensation needs only to be calculated in supersaturated
     4629!--       regions (regarding ice)
     4630          IF ( sat_ice > 0.0_wp )  THEN
     4631!
     4632!--          Calculate deposition rate assuming ice crystal shape as
     4633!--          prescribed in Ovchinnikov et al., 2014 and a gamma size
     4634!--          distribution according to Seifert and Beheng with to
     4635!--          µ =1/3 and nu=0
     4636             deposition_rate  = 4.0_wp * pi * sat_ice * gfac_dep *             &
     4637                                fac_gamma * ac * xi**bc * ni(k,j,i)
     4638             IF ( microphysics_seifert ) THEN
     4639                deposition_rate_max  = q(k,j,i) -                              &
     4640                                       q_si - qr(k,j,i) - qi(k,j,i)
     4641             ELSEIF ( microphysics_morrison_no_rain ) THEN
     4642                deposition_rate_max  = q(k,j,i) -                              &
     4643                                       q_si - qc(k,j,i) - qi(k,j,i)
     4644             ENDIF
     4645             deposition_rate = MIN( deposition_rate,                           &
     4646                                    deposition_rate_max / dt_micro )
     4647
     4648             qi(k,j,i) = qi(k,j,i) + deposition_rate * dt_micro * flag
     4649          ELSEIF ( sat_ice < 0.0_wp ) THEN
     4650             sublimation_rate = 4.0_wp * pi * sat_ice * gfac_dep *             &
     4651                                fac_gamma * ac * xi**bc * ni(k,j,i)
     4652             sublimation_rate = MAX( sublimation_rate,                         &
     4653                                     -qi(k,j,i) / dt_micro )
     4654             qi(k,j,i) = qi(k,j,i) + sublimation_rate * dt_micro * flag
     4655          ENDIF
     4656       ENDDO
     4657
     4658    END SUBROUTINE ice_deposition_ij
    35964659
    35974660
     
    38234886!--          Autoconversion rate (Seifert and Beheng, 2006):
    38244887             autocon = k_au * ( nu_c + 2.0_wp ) * ( nu_c + 4.0_wp ) /          &
    3825                        ( nu_c + 1.0_wp )**2 * qc(k,j,i)**2 * xc**2 *            &
     4888                       ( nu_c + 1.0_wp )**2 * qc(k,j,i)**2 * xc**2 *           &
    38264889                       ( 1.0_wp + phi_au / ( 1.0_wp - tau_cloud )**2 ) *       &
    38274890                       rho_surface
     
    40555118          ENDIF
    40565119
    4057           IF ( ( qc(k,j,i) > eps_sb )  .AND.  ( qr(k,j,i) > eps_sb )  .AND.  &
     5120          IF ( ( qc(k,j,i) > eps_sb )  .AND.  ( qr(k,j,i) > eps_sb )  .AND.    &
    40585121               ( nc_accr > eps_mr ) )  THEN
    40595122!
     
    40825145!
    40835146!--          Accretion rate (Seifert and Beheng, 2006):
    4084              accr = k_cr * qc(k,j,i) * qr(k,j,i) * phi_ac *                      &
     5147             accr = k_cr * qc(k,j,i) * qr(k,j,i) * phi_ac *                    &
    40855148                    SQRT( rho_surface * hyrho(k) )
    40865149             accr = MIN( accr, qc(k,j,i) / dt_micro )
     
    40895152             qc(k,j,i) = qc(k,j,i) - accr * dt_micro * flag
    40905153             IF ( microphysics_morrison )  THEN
    4091                 nc(k,j,i) = nc(k,j,i) - MIN( nc(k,j,i), accr / xc *               &
     5154                nc(k,j,i) = nc(k,j,i) - MIN( nc(k,j,i), accr / xc *            &
    40925155                                             hyrho(k) * dt_micro * flag        &
    40935156                                         )
     
    45875650             IF ( qc(k,j,i) > eps_sb  .AND.  nc(k,j,i) > eps_mr )  THEN
    45885651                sed_nc(k) = sed_qc_const *                                     &
    4589                             ( qc(k,j,i) * hyrho(k) )**( 2.0_wp / 3.0_wp ) *     &
     5652                            ( qc(k,j,i) * hyrho(k) )**( 2.0_wp / 3.0_wp ) *    &
    45905653                            ( nc(k,j,i) )**( 1.0_wp / 3.0_wp )
    45915654             ELSE
     
    45945657
    45955658             sed_nc(k) = MIN( sed_nc(k), hyrho(k) * dzu(k+1) *                 &
    4596                               nc(k,j,i) / dt_micro + sed_nc(k+1)                &
     5659                              nc(k,j,i) / dt_micro + sed_nc(k+1)               &
    45975660                            ) * flag
    45985661
    4599              nc(k,j,i) = nc(k,j,i) + ( sed_nc(k+1) - sed_nc(k) ) *               &
     5662             nc(k,j,i) = nc(k,j,i) + ( sed_nc(k+1) - sed_nc(k) ) *             &
    46005663                                         ddzu(k+1) / hyrho(k) * dt_micro * flag
    46015664          ENDIF
     
    46085671          ENDIF
    46095672
    4610           sed_qc(k) = MIN( sed_qc(k), hyrho(k) * dzu(k+1) * q(k,j,i) /          &
     5673          sed_qc(k) = MIN( sed_qc(k), hyrho(k) * dzu(k+1) * q(k,j,i) /         &
    46115674                                      dt_micro + sed_qc(k+1)                   &
    46125675                         ) * flag
    46135676
    4614           q(k,j,i)  = q(k,j,i)  + ( sed_qc(k+1) - sed_qc(k) ) * ddzu(k+1) /      &
     5677          q(k,j,i)  = q(k,j,i)  + ( sed_qc(k+1) - sed_qc(k) ) * ddzu(k+1) /    &
    46155678                                hyrho(k) * dt_micro * flag
    4616           qc(k,j,i) = qc(k,j,i) + ( sed_qc(k+1) - sed_qc(k) ) * ddzu(k+1) /      &
     5679          qc(k,j,i) = qc(k,j,i) + ( sed_qc(k+1) - sed_qc(k) ) * ddzu(k+1) /    &
    46175680                                hyrho(k) * dt_micro * flag
    4618           pt(k,j,i) = pt(k,j,i) - ( sed_qc(k+1) - sed_qc(k) ) * ddzu(k+1) /      &
     5681          pt(k,j,i) = pt(k,j,i) - ( sed_qc(k+1) - sed_qc(k) ) * ddzu(k+1) /    &
    46195682                                hyrho(k) * lv_d_cp * d_exner(k) * dt_micro     &
    46205683                                                                * flag
     
    46325695
    46335696    END SUBROUTINE sedimentation_cloud_ij
     5697
     5698!------------------------------------------------------------------------------!
     5699! Description:
     5700! ------------
     5701!> Sedimentation of ice crystals
     5702!------------------------------------------------------------------------------!
     5703    SUBROUTINE sedimentation_ice
     5704
     5705       INTEGER(iwp) ::  i             !< loop index
     5706       INTEGER(iwp) ::  j             !< loop index
     5707       INTEGER(iwp) ::  k             !< loop index
     5708
     5709       REAL(wp) ::  flag              !< flag to indicate first grid level
     5710       REAL(wp) ::  av = 6.39_wp      !< parameter for calculating fall speed
     5711       REAL(wp) ::  bv = 0.1666_wp    !< parameter (1/6)
     5712       REAL(wp) ::  xi = 0.0_wp       !< mean mass of ice crystal
     5713       REAL(wp) ::  vi = 0.0_wp       !< mean fall speed of ice crystal
     5714       REAL(wp) ::  factor_sed_gamma_k0 = 0.76_wp !< factor for zeroth moment and
     5715                                                  !< µ =1/3 and nu=0
     5716       REAL(wp) ::  factor_sed_gamma_k1 = 1.61_wp !< factor for first moment and
     5717                                                  !< µ =1/3 and nu=0
     5718
     5719       REAL(wp), DIMENSION(nzb:nzt+1) ::  sed_ni  !< sedimentation rate zeroth moment
     5720       REAL(wp), DIMENSION(nzb:nzt+1) ::  sed_qi  !< sedimentation rate fist moment
     5721
     5722       CALL cpu_log( log_point_s(96), 'sed_ice', 'start' )
     5723
     5724       sed_qi(nzt+1) = 0.0_wp
     5725       sed_ni(nzt+1) = 0.0_wp
     5726
     5727       DO  i = nxl, nxr
     5728          DO  j = nys, nyn
     5729             DO  k = nzt, nzb+1, -1
     5730
     5731                IF ( ni(k,j,i) <= 0.0_wp ) THEN
     5732                   xi = 0.0_wp
     5733                ELSE
     5734!--                Calculate mean mass of ice crystal
     5735                   xi = MAX( (hyrho(k) * qi(k,j,i) / ni(k,j,i)), ximin)
     5736                ENDIF
     5737!
     5738!--             calculate fall speed of ice crystal
     5739                vi = av * xi**bv
     5740!
     5741!--             Predetermine flag to mask topography
     5742                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
     5743!
     5744!--             Calculate sedimentation rate for each grid box, factors are
     5745!--             calculated using
     5746                IF ( qi(k,j,i) > eps_sb  .AND.  ni(k,j,i) >= 0.0_wp )  THEN
     5747                   sed_qi(k) = qi(k,j,i) * vi * factor_sed_gamma_k1 * flag
     5748                   sed_ni(k) = ni(k,j,i) * vi * factor_sed_gamma_k0 * flag
     5749                ELSE
     5750                   sed_qi(k) = 0.0_wp
     5751                   sed_ni(k) = 0.0_wp
     5752                ENDIF
     5753!
     5754!--             Calculate sedimentation: divergence of sedimentation flux
     5755                sed_qi(k) = MIN( sed_qi(k), hyrho(k) * dzu(k+1) * q(k,j,i) /   &
     5756                                            dt_micro + sed_qi(k+1)             &
     5757                               ) * flag
     5758
     5759                q(k,j,i)  = q(k,j,i)  + ( sed_qi(k+1) - sed_qi(k) ) * ddzu(k+1)&
     5760                                      / hyrho(k) * dt_micro * flag
     5761                qi(k,j,i) = qi(k,j,i) + ( sed_qi(k+1) - sed_qi(k) ) * ddzu(k+1)&
     5762                                      / hyrho(k) * dt_micro * flag
     5763                ni(k,j,i) = ni(k,j,i) + ( sed_ni(k+1) - sed_ni(k) ) * ddzu(k+1)&
     5764                                      / hyrho(k) * dt_micro * flag
     5765
     5766                pt(k,j,i) = pt(k,j,i) - ( sed_qi(k+1) - sed_qi(k) ) * ddzu(k+1)&
     5767                                      / hyrho(k) * l_s / c_p * d_exner(k) *    &
     5768                                        dt_micro * flag
     5769!
     5770!--             Compute the precipitation rate of cloud (fog) droplets
     5771                IF ( call_microphysics_at_all_substeps )  THEN
     5772                   prr(k,j,i) = prr(k,j,i) + sed_qi(k) / hyrho(k) *            &
     5773                                weight_substep(intermediate_timestep_count) *  &
     5774                                flag
     5775                ELSE
     5776                   prr(k,j,i) = prr(k,j,i) + sed_qi(k) / hyrho(k) * flag
     5777                ENDIF
     5778
     5779             ENDDO
     5780          ENDDO
     5781       ENDDO
     5782
     5783       CALL cpu_log( log_point_s(96), 'sed_ice', 'stop' )
     5784
     5785    END SUBROUTINE sedimentation_ice
     5786
     5787
     5788!------------------------------------------------------------------------------!
     5789! Description:
     5790! ------------
     5791!> Sedimentation of ice crystals
     5792!------------------------------------------------------------------------------!
     5793    SUBROUTINE sedimentation_ice_ij( i, j )
     5794
     5795       INTEGER(iwp) ::  i             !<
     5796       INTEGER(iwp) ::  j             !<
     5797       INTEGER(iwp) ::  k             !<
     5798
     5799       REAL(wp) ::  flag           !< flag to indicate first grid level
     5800       REAL(wp) ::  av = 6.39_wp   !< parameter for calculating fall speed
     5801       REAL(wp) ::  bv = 0.1666_wp !<
     5802       REAL(wp) ::  xi = 0.0_wp    !< mean mass of ice crystal
     5803       REAL(wp) ::  vi = 0.0_wp    !< mean fall speed of ice crystal
     5804       REAL(wp) ::  factor_sed_gamma_k0 = 0.76_wp
     5805       REAL(wp) ::  factor_sed_gamma_k1 = 1.61_wp
     5806
     5807       REAL(wp), DIMENSION(nzb:nzt+1) ::  sed_ni  !<
     5808       REAL(wp), DIMENSION(nzb:nzt+1) ::  sed_qi  !<
     5809
     5810       sed_qi(nzt+1) = 0.0_wp
     5811       sed_ni(nzt+1) = 0.0_wp
     5812
     5813       DO  k = nzt, nzb+1, -1
     5814          IF ( ni(k,j,i) <= 0.0_wp ) THEN
     5815             xi = 0.0_wp
     5816          ELSE
     5817!--          Calculate mean mass of ice crystal
     5818             xi = MAX( (hyrho(k) * qi(k,j,i) / ni(k,j,i)), ximin)
     5819          ENDIF
     5820!
     5821!--       calculate fall speed of ice crystal
     5822          vi = av * xi**bv
     5823!
     5824!--       Predetermine flag to mask topography
     5825          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
     5826!
     5827!--       Calculate sedimentation rate for each grid box, factors are
     5828!--       calculated using
     5829          IF ( qi(k,j,i) > eps_sb  .AND.  ni(k,j,i) >= 0.0_wp )  THEN
     5830             sed_qi(k) = qi(k,j,i) * vi * factor_sed_gamma_k1 * flag
     5831             sed_ni(k) = ni(k,j,i) * vi * factor_sed_gamma_k0 * flag
     5832          ELSE
     5833             sed_qi(k) = 0.0_wp
     5834             sed_ni(k) = 0.0_wp
     5835          ENDIF
     5836!
     5837!--       calculate fall speed of ice crystal
     5838          vi = av * xi**bv
     5839!
     5840!--       Predetermine flag to mask topography
     5841          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
     5842
     5843          IF ( qi(k,j,i) > eps_sb  .AND.  ni(k,j,i) >= 0.0_wp )  THEN
     5844             sed_qi(k) = qi(k,j,i) * vi * factor_sed_gamma_k1 * flag
     5845             sed_ni(k) = ni(k,j,i) * vi * factor_sed_gamma_k0 * flag
     5846          ELSE
     5847             sed_qi(k) = 0.0_wp
     5848             sed_ni(k) = 0.0_wp
     5849          ENDIF
     5850
     5851          sed_qi(k) = MIN( sed_qi(k), hyrho(k) * dzu(k+1) * q(k,j,i) /         &
     5852                                      dt_micro + sed_qi(k+1)                   &
     5853                         ) * flag
     5854
     5855          q(k,j,i)  = q(k,j,i)  + ( sed_qi(k+1) - sed_qi(k) ) * ddzu(k+1) /    &
     5856                                hyrho(k) * dt_micro * flag
     5857          qi(k,j,i) = qi(k,j,i) + ( sed_qi(k+1) - sed_qi(k) ) * ddzu(k+1) /    &
     5858                                hyrho(k) * dt_micro * flag
     5859          ni(k,j,i) = ni(k,j,i) + ( sed_ni(k+1) - sed_ni(k) ) * ddzu(k+1) /    &
     5860                                hyrho(k) * dt_micro * flag
     5861          pt(k,j,i) = pt(k,j,i) - ( sed_qi(k+1) - sed_qi(k) ) * ddzu(k+1) /    &
     5862                                hyrho(k) * l_s / c_p * d_exner(k) * dt_micro   &
     5863                                                                  * flag
     5864!
     5865!--       Compute the precipitation rate of cloud (fog) droplets
     5866          IF ( call_microphysics_at_all_substeps )  THEN
     5867             prr(k,j,i) = prr(k,j,i) + sed_qi(k) / hyrho(k) *                  &
     5868                              weight_substep(intermediate_timestep_count) * flag
     5869          ELSE
     5870             prr(k,j,i) = prr(k,j,i) + sed_qi(k) / hyrho(k) * flag
     5871          ENDIF
     5872
     5873       ENDDO
     5874
     5875    END SUBROUTINE sedimentation_ice_ij
     5876
    46345877
    46355878
     
    50536296
    50546297          sed_nr(k) = flux / dt_micro * flag
    5055           nr(k,j,i)  = nr(k,j,i) + ( sed_nr(k+1) - sed_nr(k) ) * ddzu(k+1) /     &
     6298          nr(k,j,i)  = nr(k,j,i) + ( sed_nr(k+1) - sed_nr(k) ) * ddzu(k+1) /   &
    50566299                                    hyrho(k) * dt_micro * flag
    50576300!
     
    50806323          sed_qr(k) = flux / dt_micro * flag
    50816324
    5082           qr(k,j,i) = qr(k,j,i) + ( sed_qr(k+1) - sed_qr(k) ) * ddzu(k+1) /      &
     6325          qr(k,j,i) = qr(k,j,i) + ( sed_qr(k+1) - sed_qr(k) ) * ddzu(k+1) /    &
    50836326                                hyrho(k) * dt_micro * flag
    5084           q(k,j,i)  = q(k,j,i)  + ( sed_qr(k+1) - sed_qr(k) ) * ddzu(k+1) /      &
     6327          q(k,j,i)  = q(k,j,i)  + ( sed_qr(k+1) - sed_qr(k) ) * ddzu(k+1) /    &
    50856328                                hyrho(k) * dt_micro * flag
    5086           pt(k,j,i) = pt(k,j,i) - ( sed_qr(k+1) - sed_qr(k) ) * ddzu(k+1) /      &
     6329          pt(k,j,i) = pt(k,j,i) - ( sed_qr(k+1) - sed_qr(k) ) * ddzu(k+1) /    &
    50876330                                hyrho(k) * lv_d_cp * d_exner(k) * dt_micro     &
    50886331                                                                * flag
     
    52026445!--    (see: Cuijpers + Duynkerke, 1993, JAS, 23)
    52036446       q_s   = q_s * ( 1.0_wp + alpha * q(k,j,i) ) / ( 1.0_wp + alpha * q_s )
     6447
     6448       IF ( .NOT. microphysics_ice_extension ) THEN
     6449          IF ( microphysics_seifert ) THEN
     6450             sat = ( q(k,j,i) - qr(k,j,i) - qc(k,j,i) ) / q_s - 1.0_wp
     6451          ELSEIF ( microphysics_morrison_no_rain ) THEN
     6452             sat = ( q(k,j,i) - qc(k,j,i) ) / q_s - 1.0_wp
     6453          ENDIF
     6454       ELSE
     6455          IF ( microphysics_seifert ) THEN
     6456             sat = ( q(k,j,i) - qr(k,j,i) - qc(k,j,i) - qi(k,j,i) ) / q_s - 1.0_wp
     6457          ELSEIF ( microphysics_morrison_no_rain ) THEN
     6458             sat = ( q(k,j,i) - qc(k,j,i) - qi(k,j,i) ) / q_s - 1.0_wp
     6459          ENDIF
     6460       ENDIF
     6461
     6462    END SUBROUTINE supersaturation
     6463
     6464!------------------------------------------------------------------------------!
     6465! Description:
     6466! ------------
     6467!> Computation of the diagnostic supersaturation sat, actual liquid water
     6468!< temperature t_l and saturation water vapor mixing ratio q_s
     6469!------------------------------------------------------------------------------!
     6470    SUBROUTINE supersaturation_ice ( i, j, k )
     6471
     6472       INTEGER(iwp) ::  i   !< running index
     6473       INTEGER(iwp) ::  j   !< running index
     6474       INTEGER(iwp) ::  k   !< running index
     6475
     6476       REAL(wp) ::  e_a     !< water vapor pressure
     6477       REAL(wp) ::  temp    !< actual temperature
     6478!
     6479!--    Actual liquid water temperature:
     6480       t_l = exner(k) * pt(k,j,i)
     6481!
     6482!--    Actual temperature:
     6483       temp = t_l + lv_d_cp * ql(k,j,i) + ls_d_cp * qi(k,j,i)
     6484!
     6485!--    Calculate water vapor saturation pressure with formular using actual
     6486!--    temperature
     6487       e_si = magnus_ice( temp )
     6488!
     6489!--    Computation of ice saturation mixing ratio:
     6490       q_si = rd_d_rv * e_si / ( hyp(k) - e_si )
     6491!
     6492!--    Current vapor pressure
     6493       e_a = (   q(k,j,i) - qr(k,j,i) - qc(k,j,i) - qi(k,j,i) ) * hyp(k) /     &
     6494             ( ( q(k,j,i) - qr(k,j,i) - qc(k,j,i) - qi(k,j,i) ) + rd_d_rv )
    52046495!
    52056496!--    Supersaturation:
    52066497!--    Not in case of microphysics_kessler or microphysics_sat_adjust
    52076498!--    since qr is unallocated
    5208        IF ( microphysics_seifert ) THEN
    5209           sat = ( q(k,j,i) - qr(k,j,i) - qc(k,j,i) ) / q_s - 1.0_wp
    5210        ELSEIF ( microphysics_morrison_no_rain ) THEN
    5211           sat = ( q(k,j,i) - qc(k,j,i) ) / q_s - 1.0_wp
    5212        ENDIF
    5213 
    5214     END SUBROUTINE supersaturation
     6499       sat_ice = e_a / e_si - 1.0_wp
     6500
     6501    END SUBROUTINE supersaturation_ice
    52156502
    52166503
     
    52246511    SUBROUTINE calc_liquid_water_content
    52256512
    5226 
    5227 
    5228        IMPLICIT NONE
    5229 
    52306513       INTEGER(iwp) ::  i !<
    52316514       INTEGER(iwp) ::  j !<
     
    52346517       REAL(wp)     ::  flag !< flag to indicate first grid level above surface
    52356518
    5236 
    52376519       DO  i = nxlg, nxrg
    52386520          DO  j = nysg, nyng
     
    52416523!--             Predetermine flag to mask topography
    52426524                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
    5243 
    52446525!
    52456526!--             Call calculation of supersaturation located
    52466527                CALL supersaturation( i, j, k )
    5247 
    52486528!
    52496529!--             Compute the liquid water content
    5250                 IF ( microphysics_seifert  .AND. .NOT. microphysics_morrison ) &
    5251                 THEN
    5252                    IF ( ( q(k,j,i) - q_s - qr(k,j,i) ) > 0.0_wp )  THEN
    5253                       qc(k,j,i) = ( q(k,j,i) - q_s - qr(k,j,i) ) * flag
    5254                       ql(k,j,i) = ( qc(k,j,i) + qr(k,j,i) ) * flag
     6530                IF ( .NOT. microphysics_ice_extension ) THEN
     6531                   IF ( microphysics_seifert  .AND. .NOT.                      &
     6532                        microphysics_morrison )  THEN
     6533!--                   Seifert and Beheng scheme: saturation adjustment
     6534                      IF ( ( q(k,j,i) - q_s - qr(k,j,i) ) > 0.0_wp )  THEN
     6535                         qc(k,j,i) = ( q(k,j,i) - q_s - qr(k,j,i) ) * flag
     6536                         ql(k,j,i) = ( qc(k,j,i) + qr(k,j,i) ) * flag
     6537                      ELSE
     6538                         IF ( q(k,j,i) < qr(k,j,i) )  q(k,j,i) = qr(k,j,i)
     6539                         qc(k,j,i) = 0.0_wp
     6540                         ql(k,j,i) = qr(k,j,i) * flag
     6541                      ENDIF
     6542!
     6543!--                Morrison scheme: explicit condensation (see above)
     6544                   ELSEIF ( microphysics_morrison  .AND.                       &
     6545                            microphysics_seifert )  THEN
     6546                      ql(k,j,i) = qc(k,j,i) + qr(k,j,i) * flag
     6547!--                Morrison without rain: explicit condensation
     6548                   ELSEIF ( microphysics_morrison  .AND.                       &
     6549                            .NOT. microphysics_seifert )  THEN
     6550                      ql(k,j,i) = qc(k,j,i)
     6551!--                Kessler and saturation adjustment scheme
    52556552                   ELSE
    5256                       IF ( q(k,j,i) < qr(k,j,i) )  q(k,j,i) = qr(k,j,i)
    5257                       qc(k,j,i) = 0.0_wp
    5258                       ql(k,j,i) = qr(k,j,i) * flag
     6553                      IF ( ( q(k,j,i) - q_s ) > 0.0_wp )  THEN
     6554                         qc(k,j,i) = ( q(k,j,i) - q_s ) * flag
     6555                         ql(k,j,i) = qc(k,j,i) * flag
     6556                      ELSE
     6557                         qc(k,j,i) = 0.0_wp
     6558                         ql(k,j,i) = 0.0_wp
     6559                      ENDIF
    52596560                   ENDIF
    5260                 ELSEIF ( microphysics_morrison  .AND.  microphysics_seifert )  THEN
    5261                    ql(k,j,i) = qc(k,j,i) + qr(k,j,i) * flag
    5262                 ELSEIF ( microphysics_morrison  .AND.  .NOT. microphysics_seifert )  THEN
    5263                    ql(k,j,i) = qc(k,j,i)                   
     6561!--             Calculations of liquid water content in case of mixed-phase
     6562!--             cloud microphyics
    52646563                ELSE
    5265                    IF ( ( q(k,j,i) - q_s ) > 0.0_wp )  THEN
    5266                       qc(k,j,i) = ( q(k,j,i) - q_s ) * flag
    5267                       ql(k,j,i) = qc(k,j,i) * flag
     6564                   IF ( microphysics_seifert  .AND.                            &
     6565                        .NOT. microphysics_morrison ) &
     6566                   THEN
     6567!
     6568!--                   Seifert and Beheng scheme: saturation adjustment
     6569                      IF ( ( q(k,j,i)                                          &
     6570                             - q_s - qr(k,j,i) - qi(k,j,i) ) > 0.0_wp )  THEN
     6571                         qc(k,j,i) = ( q(k,j,i) - q_s - qr(k,j,i) - qi(k,j,i) )&
     6572                                       * flag
     6573                         ql(k,j,i) = ( qc(k,j,i) + qr(k,j,i) ) * flag
     6574                      ELSE
     6575                         IF ( q(k,j,i) < ( qr(k,j,i) + qi(k,j,i) ) )  THEN
     6576                            q(k,j,i) = qr(k,j,i) + qi(k,j,i)
     6577                         ENDIF
     6578                         qc(k,j,i) = 0.0_wp
     6579                         ql(k,j,i) = qr(k,j,i) * flag
     6580                      ENDIF
     6581!--                Morrison scheme: explicit condensation (see above)
     6582                   ELSEIF ( microphysics_morrison  .AND.                       &
     6583                            microphysics_seifert )  THEN
     6584                      ql(k,j,i) = qc(k,j,i) + qr(k,j,i) * flag
     6585!--                Morrison without rain: explicit condensation
     6586                   ELSEIF ( microphysics_morrison  .AND.                       &
     6587                            .NOT. microphysics_seifert )  THEN
     6588                      ql(k,j,i) = qc(k,j,i)
     6589!--                Kessler and saturation adjustment scheme
    52686590                   ELSE
    5269                       qc(k,j,i) = 0.0_wp
    5270                       ql(k,j,i) = 0.0_wp
     6591                      IF ( ( q(k,j,i) - q_s ) > 0.0_wp )  THEN
     6592                         qc(k,j,i) = ( q(k,j,i) - q_s ) * flag
     6593                         ql(k,j,i) = qc(k,j,i) * flag
     6594                      ELSE
     6595                         qc(k,j,i) = 0.0_wp
     6596                         ql(k,j,i) = 0.0_wp
     6597                      ENDIF
    52716598                   ENDIF
    52726599                ENDIF
  • palm/trunk/SOURCE/compute_vpt.f90

    r4360 r4502  
    2525! -----------------
    2626! $Id$
     27! Implementation of ice microphysics
     28!
     29! 4360 2020-01-07 11:25:50Z suehring
    2730! Corrected "Former revisions" section
    2831!
     
    4245
    4346    USE arrays_3d,                                                             &
    44         ONLY:  pt, q, ql, vpt, d_exner
     47        ONLY:  pt, q, ql, vpt, d_exner, qi
    4548
    4649    USE basic_constants_and_equations_mod,                                     &
    47         ONLY:  lv_d_cp
     50        ONLY:  lv_d_cp, ls_d_cp
    4851
    4952    USE control_parameters,                                                    &
     
    5659
    5760    USE bulk_cloud_model_mod,                                                  &
    58         ONLY:  bulk_cloud_model
     61        ONLY:  bulk_cloud_model, microphysics_ice_extension
    5962
    6063    IMPLICIT NONE
     
    6467    IF ( .NOT. bulk_cloud_model  .AND.  .NOT. cloud_droplets )  THEN
    6568       vpt = pt * ( 1.0_wp + 0.61_wp * q )
    66     ELSE IF (bulk_cloud_model)  THEN
     69    ELSEIF ( bulk_cloud_model  .AND.  .NOT. microphysics_ice_extension )  THEN
    6770       DO  k = nzb, nzt+1
    68           vpt(k,:,:) = ( pt(k,:,:) + d_exner(k) * lv_d_cp * ql(k,:,:) ) *      &
    69                        ( 1.0_wp + 0.61_wp * q(k,:,:) - 1.61_wp * ql(k,:,:) )
     71              vpt(k,:,:) = ( pt(k,:,:) + d_exner(k) * lv_d_cp * ql(k,:,:) ) *  &
     72                       ( 1.0_wp + 0.61_wp * q(k,:,:) - 1.61_wp *  ql(k,:,:)  )
     73       ENDDO
     74    ELSEIF ( bulk_cloud_model  .AND.  microphysics_ice_extension ) THEN
     75       DO  k = nzb, nzt+1
     76          vpt(k,:,:) = ( pt(k,:,:) + d_exner(k) * lv_d_cp * ql(k,:,:)   +      &
     77                                     d_exner(k) * ls_d_cp * qi(k,:,:) ) *      &
     78                       ( 1.0_wp + 0.61_wp * q(k,:,:) - 1.61_wp          *      &
     79                                           ( ql(k,:,:) + qi(k,:,:) ) )
    7080       ENDDO
    7181    ELSE
  • palm/trunk/SOURCE/flow_statistics.f90

    r4472 r4502  
    2525! -----------------
    2626! $Id$
     27! Implementation of ice microphysics
     28!
     29! 4472 2020-03-24 12:21:00Z Giersch
    2730! Calculations of the Kolmogorov lengt scale eta implemented
    2831!
     
    8487    USE arrays_3d,                                                             &
    8588        ONLY:  ddzu, ddzw, e, heatflux_output_conversion, hyp, km, kh,         &
    86                momentumflux_output_conversion, nc, nr, p, prho, prr, pt, q,    &
    87                qc, ql, qr, rho_air, rho_air_zw, rho_ocean, s,                  &
     89               momentumflux_output_conversion, nc, ni, nr, p, prho, prr, pt, q,&
     90               qc, qi, ql, qr, rho_air, rho_air_zw, rho_ocean, s,              &
    8891               sa, u, ug, v, vg, vpt, w, w_subs, waterflux_output_conversion,  &
    8992               zw, d_exner
     
    9396
    9497    USE bulk_cloud_model_mod,                                                  &
    95         ONLY: bulk_cloud_model, microphysics_morrison, microphysics_seifert
     98        ONLY: bulk_cloud_model, microphysics_morrison, microphysics_seifert,   &
     99              microphysics_ice_extension
    96100
    97101    USE chem_modules,                                                          &
     
    14141418                                                                flag
    14151419                         ENDIF
     1420                         IF ( microphysics_ice_extension )  THEN
     1421                            sums_l(k,124,tn) = sums_l(k,124,tn) + ni(k,j,i) *  &
     1422                                                                rmask(j,i,sr) *&
     1423                                                                flag
     1424                            sums_l(k,125,tn) = sums_l(k,125,tn) + qi(k,j,i) *  &
     1425                                                                rmask(j,i,sr) *&
     1426                                                                flag
     1427                         ENDIF
     1428
    14161429                         IF ( microphysics_seifert )  THEN
    14171430                            sums_l(k,73,tn) = sums_l(k,73,tn) + nr(k,j,i) *    &
     
    19151928             sums(k,116)           = sums(k,116)           / ngp_2dh_s_inner(k,sr)
    19161929             sums(k,118:pr_palm-2) = sums(k,118:pr_palm-2) / ngp_2dh_s_inner(k,sr)
    1917              sums(k,123)           = sums(k,123) * ngp_2dh_s_inner(k,sr)  / ngp_2dh(sr)
     1930             sums(k,123:125)       = sums(k,123:125) * ngp_2dh_s_inner(k,sr)  / ngp_2dh(sr)
    19181931          ENDIF
    19191932       ENDDO
     
    20292042       hom(:,1,72,sr) = hyp * 1E-2_wp  ! hyp in hPa
    20302043       hom(:,1,123,sr) = sums(:,123)   ! nc
     2044       hom(:,1,124,sr) = sums(:,124)   ! ni
     2045       hom(:,1,125,sr) = sums(:,125)   ! qi
    20312046       hom(:,1,73,sr) = sums(:,73)     ! nr
    20322047       hom(:,1,74,sr) = sums(:,74)     ! qr
  • palm/trunk/SOURCE/init_masks.f90

    r4444 r4502  
    2525! -----------------
    2626! $Id$
     27! Implementation of ice microphysics
     28!
     29! 4444 2020-03-05 15:59:50Z raasch
    2730! bugfix: cpp-directives for serial mode added
    2831!
     
    5861
    5962    USE bulk_cloud_model_mod,                                                  &
    60         ONLY: bulk_cloud_model, microphysics_morrison, microphysics_seifert
     63        ONLY: bulk_cloud_model, microphysics_morrison, microphysics_seifert,   &
     64              microphysics_ice_extension
    6165
    6266    USE control_parameters,                                                    &
     
    268272                unit = '1/m3'
    269273
     274             CASE ( 'ni' )
     275                IF ( .NOT. bulk_cloud_model )  THEN
     276                   WRITE ( message_string, * ) 'output of "', TRIM( var ),     &
     277                        '" requires bulk_cloud_model = .TRUE.'
     278                   CALL message( 'init_masks', 'PA0108', 1, 2, 0, 6, 0 )
     279                 ELSEIF ( .NOT. microphysics_ice_extension ) THEN
     280                   message_string = 'output of "' // TRIM( var ) // '" ' //    &
     281                         'requires  microphysics_ice_extension = .TRUE.'
     282                   CALL message( 'check_parameters', 'PA0359', 1, 2, 0, 6, 0 )
     283                ENDIF
     284                unit = '1/m3'
     285
    270286             CASE ( 'nr' )
    271287                IF ( .NOT. bulk_cloud_model )  THEN
     
    331347                        '" requires bulk_cloud_model = .TRUE.'
    332348                   CALL message( 'init_masks', 'PA0108', 1, 2, 0, 6, 0 )
     349                ENDIF
     350                unit = 'kg/kg'
     351
     352             CASE ( 'qi' )
     353                IF ( .NOT. bulk_cloud_model )  THEN
     354                   message_string = 'output of "' // TRIM( var ) // '" ' //    &
     355                            'requires bulk_cloud_model = .TRUE.'
     356                   CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
     357                ELSEIF ( .NOT. microphysics_ice_extension ) THEN
     358                   message_string = 'output of "' // TRIM( var ) // '" ' //    &
     359                            'requires microphysics_ice_extension = .TRUE.'
     360                   CALL message( 'check_parameters', 'PA0359', 1, 2, 0, 6, 0 )
    333361                ENDIF
    334362                unit = 'kg/kg'
  • palm/trunk/SOURCE/modules.f90

    r4495 r4502  
    2525! -----------------
    2626! $Id$
     27! Implementation of ice microphysics
     28!
     29! 4495 2020-04-13 20:11:20Z raasch
    2730! +restart_data_format, restart_data_format_input|output, include_total_domain_boundaries
    2831!
     
    229232    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_e              !< artificial numerical dissipation flux at south face of grid box - subgrid-scale TKE
    230233    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_nc             !< artificial numerical dissipation flux at south face of grid box - clouddrop-number concentration
     234    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_ni             !< artificial numerical dissipation flux at south face of grid box - ice crystal-number concentration
    231235    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_nr             !< artificial numerical dissipation flux at south face of grid box - raindrop-number concentration
    232236    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_pt             !< artificial numerical dissipation flux at south face of grid box - potential temperature
    233237    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_q              !< artificial numerical dissipation flux at south face of grid box - mixing ratio
    234238    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_qc             !< artificial numerical dissipation flux at south face of grid box - cloudwater
     239    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_qi             !< artificial numerical dissipation flux at south face of grid box - ice crystal mixing ratio
    235240    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_qr             !< artificial numerical dissipation flux at south face of grid box - rainwater
    236241    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  diss_s_s              !< artificial numerical dissipation flux at south face of grid box - passive scalar
     
    244249    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_e              !< 6th-order advective flux at south face of grid box - subgrid-scale TKE
    245250    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_nc             !< 6th-order advective flux at south face of grid box - clouddrop-number concentration
     251    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_ni             !< 6th-order advective flux at south face of grid box - icecrystal-number concentration
    246252    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_nr             !< 6th-order advective flux at south face of grid box - raindrop-number concentration
    247253    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_pt             !< 6th-order advective flux at south face of grid box - potential temperature
    248254    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_q              !< 6th-order advective flux at south face of grid box - mixing ratio
    249255    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_qc             !< 6th-order advective flux at south face of grid box - cloudwater
     256    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_qi             !< 6th-order advective flux at south face of grid box - ice crystal
    250257    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_qr             !< 6th-order advective flux at south face of grid box - rainwater
    251258    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  flux_s_s              !< 6th-order advective flux at south face of grid box - passive scalar
     
    271278    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_e    !< artificial numerical dissipation flux at left face of grid box - subgrid-scale TKE
    272279    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_nc   !< artificial numerical dissipation flux at left face of grid box - clouddrop-number concentration
     280    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_ni   !< artificial numerical dissipation flux at left face of grid box - ice crystal-number concentration
    273281    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_nr   !< artificial numerical dissipation flux at left face of grid box - raindrop-number concentration
    274282    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_pt   !< artificial numerical dissipation flux at left face of grid box - potential temperature
    275283    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_q    !< artificial numerical dissipation flux at left face of grid box - mixing ratio
    276284    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_qc   !< artificial numerical dissipation flux at left face of grid box - cloudwater
     285    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_qi   !< artificial numerical dissipation flux at left face of grid box - ice crystal
    277286    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_qr   !< artificial numerical dissipation flux at left face of grid box - rainwater
    278287    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  diss_l_s    !< artificial numerical dissipation flux at left face of grid box - passive scalar
     
    284293    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_e    !< 6th-order advective flux at south face of grid box - subgrid-scale TKE
    285294    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_nc   !< 6th-order advective flux at south face of grid box - clouddrop-number concentration
     295    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_ni   !< 6th-order advective flux at south face of grid box - ice crystal-number concentration
    286296    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_nr   !< 6th-order advective flux at south face of grid box - raindrop-number concentration
    287297    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_pt   !< 6th-order advective flux at south face of grid box - potential temperature
    288298    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_q    !< 6th-order advective flux at south face of grid box - mixing ratio
    289299    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_qc   !< 6th-order advective flux at south face of grid box - cloudwater
     300    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_qi   !< 6th-order advective flux at south face of grid box - ice crystal
    290301    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_qr   !< 6th-order advective flux at south face of grid box - rainwater
    291302    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  flux_l_s    !< 6th-order advective flux at south face of grid box - passive scalar
     
    324335    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  nc_2    !< pointer for swapping of timelevels for respective quantity
    325336    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  nc_3    !< pointer for swapping of timelevels for respective quantity
     337    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  ni_1    !< pointer for swapping of timelevels for respective quantity
     338    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  ni_2    !< pointer for swapping of timelevels for respective quantity
     339    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  ni_3    !< pointer for swapping of timelevels for respective quantity
    326340    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  nr_1    !< pointer for swapping of timelevels for respective quantity
    327341    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  nr_2    !< pointer for swapping of timelevels for respective quantity
     
    336350    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  qc_2    !< pointer for swapping of timelevels for respective quantity
    337351    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  qc_3    !< pointer for swapping of timelevels for respective quantity
     352    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  qi_1    !< pointer for swapping of timelevels for respective quantity
     353    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  qi_2    !< pointer for swapping of timelevels for respective quantity
     354    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  qi_3    !< pointer for swapping of timelevels for respective quantity
    338355    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  ql_v    !< pointer: volume of liquid water
    339356    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  ql_vp   !< pointer: liquid water weighting factor
     
    367384    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  nc         !< pointer: cloud drop number density
    368385    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  nc_p       !< pointer: prognostic value of cloud drop number density
     386    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  ni         !< pointer: ice crystal number density
     387    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  ni_p       !< pointer: prognostic value of ice crystal number density
    369388    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  nr         !< pointer: rain drop number density
    370389    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  nr_p       !< pointer: prognostic value of rain drop number density
     
    375394    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  q_p        !< pointer: prognostic value of mixing ratio
    376395    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  qc         !< pointer: cloud water content
    377     REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  qc_p       !< pointer: cloud water content
     396    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  qc_p       !< pointer: prognostic value cloud water content
     397    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  qi         !< pointer: ice crystal content
     398    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  qi_p       !< pointer: prognostic value ice crystal content
    378399    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  ql         !< pointer: liquid water content
    379400    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  ql_c       !< pointer: change in liquid water content due to
     
    389410    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  te_m       !< pointer: weighted tendency of e for previous sub-timestep (Runge-Kutta)
    390411    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tnc_m      !< pointer: weighted tendency of nc for previous sub-timestep (Runge-Kutta)
     412    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tni_m      !< pointer: weighted tendency of ni for previous sub-timestep (Runge-Kutta)
    391413    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tnr_m      !< pointer: weighted tendency of nr for previous sub-timestep (Runge-Kutta)
    392414    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tpt_m      !< pointer: weighted tendency of pt for previous sub-timestep (Runge-Kutta)
    393415    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tq_m       !< pointer: weighted tendency of q for previous sub-timestep (Runge-Kutta)
    394416    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tqc_m      !< pointer: weighted tendency of qc for previous sub-timestep (Runge-Kutta)
     417    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tqi_m      !< pointer: weighted tendency of qi for previous sub-timestep (Runge-Kutta)
    395418    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  tqr_m      !< pointer: weighted tendency of qr for previous sub-timestep (Runge-Kutta)
    396419    REAL(wp), DIMENSION(:,:,:), POINTER, CONTIGUOUS ::  ts_m       !< pointer: weighted tendency of s for previous sub-timestep (Runge-Kutta)
     
    462485    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  lpt_av        !< avg. liquid water potential temperature
    463486    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  nc_av         !< avg. cloud drop number density
     487    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  ni_av         !< avg. ice crystal number density
    464488    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  nr_av         !< avg. rain drop number density
    465489    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  p_av          !< avg. perturbation pressure
     
    471495                                                                      !< (or total water content with active cloud physics)
    472496    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  qc_av         !< avg. cloud water content
     497    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  qi_av         !< avg. ice crystal content
    473498    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  ql_av         !< avg. liquid water content
    474499    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  ql_c_av       !< avg. change in liquid water content due to
     
    14231448    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_ws2_ws_l    !< subdomain sum of vertical momentum flux w'w' (5th-order advection scheme only)
    14241449    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wsncs_ws_l  !< subdomain sum of vertical clouddrop-number concentration flux w'nc' (5th-order advection scheme only)
     1450    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wsnis_ws_l  !< subdomain sum of vertical ice crystal concentration flux w'ni' (5th-order advection scheme only)
    14251451    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wsnrs_ws_l  !< subdomain sum of vertical raindrop-number concentration flux w'nr' (5th-order advection scheme only)
    14261452    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wspts_ws_l  !< subdomain sum of vertical sensible heat flux w'pt' (5th-order advection scheme only)
    14271453    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wsqs_ws_l   !< subdomain sum of vertical latent heat flux w'q' (5th-order advection scheme only)
    14281454    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wsqcs_ws_l  !< subdomain sum of vertical cloudwater flux w'qc' (5th-order advection scheme only)
     1455    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wsqis_ws_l  !< subdomain sum of vertical ice crystal flux w'qi' (5th-order advection scheme only)
    14291456    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wsqrs_ws_l  !< subdomain sum of vertical rainwater flux w'qr' (5th-order advection scheme only)
    14301457    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wssas_ws_l  !< subdomain sum of vertical salinity flux w'sa' (5th-order advection scheme only)
  • palm/trunk/SOURCE/netcdf_interface_mod.f90

    r4455 r4502  
    2525! -----------------
    2626! $Id$
     27! Implementation of ice microphysics
     28!
     29! 4455 2020-03-11 12:20:29Z Giersch
    2730! Axis attribute added to netcdf output
    2831!
     
    880883                CASE ( 'e', 'nc', 'nr', 'p', 'pc', 'pr', 'prr',                &
    881884                       'q', 'qc', 'ql', 'ql_c', 'ql_v', 'ql_vp', 'qr', 'qv',   &
    882                        's', 'theta', 'thetal', 'thetav' )
     885                       's', 'theta', 'thetal', 'thetav', 'qi', 'ni' )
    883886
    884887                   grid_x = 'x'
     
    16441647                CASE ( 'e', 'nc', 'nr', 'p', 'pc', 'pr', 'prr',   &
    16451648                       'q', 'qc', 'ql', 'ql_c', 'ql_v', 'ql_vp', 'qr', 'qv',   &
    1646                        's', 'theta', 'thetal', 'thetav' )
     1649                       's', 'theta', 'thetal', 'thetav', 'qi', 'ni' )
    16471650
    16481651                   grid_x = 'x'
     
    26592662!
    26602663!--                   Most variables are defined on the zu grid
    2661                       CASE ( 'e_xy', 'nc_xy', 'nr_xy', 'p_xy',                 &
     2664                      CASE ( 'e_xy', 'nc_xy', 'ni_xy', 'nr_xy', 'p_xy',        &
    26622665                             'pc_xy', 'pr_xy', 'prr_xy', 'q_xy',               &
    2663                              'qc_xy', 'ql_xy', 'ql_c_xy', 'ql_v_xy',           &
     2666                             'qc_xy', 'qi_xy', 'ql_xy', 'ql_c_xy', 'ql_v_xy',  &
    26642667                             'ql_vp_xy', 'qr_xy', 'qv_xy',                     &
    26652668                             's_xy',                                           &
     
    35833586!
    35843587!--                Most variables are defined on the zu grid
    3585                    CASE ( 'e_xz', 'nc_xz', 'nr_xz', 'p_xz', 'pc_xz',           &
    3586                           'pr_xz', 'prr_xz', 'q_xz', 'qc_xz',                  &
     3588                   CASE ( 'e_xz', 'nc_xz', 'ni_xz', 'nr_xz', 'p_xz', 'pc_xz',  &
     3589                          'pr_xz', 'prr_xz', 'q_xz', 'qc_xz', 'qi_xz',         &
    35873590                          'ql_xz', 'ql_c_xz', 'ql_v_xz', 'ql_vp_xz', 'qr_xz',  &
    35883591                          'qv_xz', 's_xz',                                     &
     
    44604463!
    44614464!--                Most variables are defined on the zu grid
    4462                    CASE ( 'e_yz', 'nc_yz', 'nr_yz', 'p_yz', 'pc_yz',           &
    4463                           'pr_yz','prr_yz', 'q_yz', 'qc_yz', 'ql_yz',          &
     4465                   CASE ( 'e_yz', 'nc_yz', 'ni_yz', 'nr_yz', 'p_yz', 'pc_yz',  &
     4466                          'pr_yz','prr_yz', 'q_yz', 'qc_yz', 'qi_yz', 'ql_yz', &
    44644467                          'ql_c_yz', 'ql_v_yz', 'ql_vp_yz', 'qr_yz', 'qv_yz',  &
    44654468                          's_yz',                                              &
     
    58535856!
    58545857!--             Most variables are defined on the zu levels
    5855                 CASE ( 'e', 'nc', 'nr', 'p', 'pc', 'pr', 'prr',   &
     5858                CASE ( 'e', 'nc', 'nr', 'p', 'pc', 'pr', 'prr', 'ni', 'qi',    &
    58565859                       'q', 'qc', 'ql', 'ql_c', 'ql_v', 'ql_vp', 'qr', 'qv',   &
    58575860                       'rho_sea_water', 's', 'sa', &
  • palm/trunk/SOURCE/surface_data_output_mod.f90

    r4500 r4502  
    2525! -----------------
    2626! $Id$
     27! Implementation of ice microphysics
     28!
     29! 4500 2020-04-17 10:12:45Z suehring
    2730! - Correct output of ground/wall heat flux at USM surfaces
    2831! - Add conversion factor to heat and momentum-flux output
     
    16951698               ENDIF
    16961699
     1700            CASE ( 'qis' )
     1701!
     1702!--            Output of instantaneous data
     1703               IF ( av == 0 )  THEN
     1704                  CALL surface_data_output_collect( surf_def_h(0)%qis,         &
     1705                                               surf_def_h(1)%qis,              &
     1706                                               surf_lsm_h%qis,                 &
     1707                                               surf_usm_h%qis,                 &
     1708                                               surf_def_v(0)%qis,              &
     1709                                               surf_lsm_v(0)%qis,              &
     1710                                               surf_usm_v(0)%qis,              &
     1711                                               surf_def_v(1)%qis,              &
     1712                                               surf_lsm_v(1)%qis,              &
     1713                                               surf_usm_v(1)%qis,              &
     1714                                               surf_def_v(2)%qis,              &
     1715                                               surf_lsm_v(2)%qis,              &
     1716                                               surf_usm_v(2)%qis,              &
     1717                                               surf_def_v(3)%qis,              &
     1718                                               surf_lsm_v(3)%qis,              &
     1719                                               surf_usm_v(3)%qis )
     1720               ELSE
     1721!
     1722!--               Output of averaged data
     1723                  surfaces%var_out(:) = surfaces%var_av(:,n_out) /             &
     1724                                        REAL( average_count_surf, KIND=wp )
     1725                  surfaces%var_av(:,n_out) = 0.0_wp
     1726
     1727               ENDIF
     1728
     1729            CASE ( 'nis' )
     1730!
     1731!--            Output of instantaneous data
     1732               IF ( av == 0 )  THEN
     1733                  CALL surface_data_output_collect( surf_def_h(0)%nis,         &
     1734                                               surf_def_h(1)%nis,              &
     1735                                               surf_lsm_h%nis,                 &
     1736                                               surf_usm_h%nis,                 &
     1737                                               surf_def_v(0)%nis,              &
     1738                                               surf_lsm_v(0)%nis,              &
     1739                                               surf_usm_v(0)%nis,              &
     1740                                               surf_def_v(1)%nis,              &
     1741                                               surf_lsm_v(1)%nis,              &
     1742                                               surf_usm_v(1)%nis,              &
     1743                                               surf_def_v(2)%nis,              &
     1744                                               surf_lsm_v(2)%nis,              &
     1745                                               surf_usm_v(2)%nis,              &
     1746                                               surf_def_v(3)%nis,              &
     1747                                               surf_lsm_v(3)%nis,              &
     1748                                               surf_usm_v(3)%nis )
     1749               ELSE
     1750!
     1751!--               Output of averaged data
     1752                  surfaces%var_out(:) = surfaces%var_av(:,n_out) /             &
     1753                                        REAL( average_count_surf, KIND=wp )
     1754                  surfaces%var_av(:,n_out) = 0.0_wp
     1755
     1756               ENDIF
     1757
    16971758            CASE ( 'qrs' )
    16981759!
     
    21532214                                               surf_lsm_v(3)%ncsws,            &
    21542215                                               surf_usm_v(3)%ncsws )
     2216               ELSE
     2217!
     2218!--               Output of averaged data
     2219                  surfaces%var_out(:) = surfaces%var_av(:,n_out) /             &
     2220                                        REAL( average_count_surf, KIND=wp )
     2221                  surfaces%var_av(:,n_out) = 0.0_wp
     2222
     2223               ENDIF
     2224
     2225
     2226            CASE ( 'qisws' )
     2227!
     2228!--            Output of instantaneous data
     2229               IF ( av == 0 )  THEN
     2230                  CALL surface_data_output_collect( surf_def_h(0)%qisws,       &
     2231                                               surf_def_h(1)%qisws,            &
     2232                                               surf_lsm_h%qisws,               &
     2233                                               surf_usm_h%qisws,               &
     2234                                               surf_def_v(0)%qisws,            &
     2235                                               surf_lsm_v(0)%qisws,            &
     2236                                               surf_usm_v(0)%qisws,            &
     2237                                               surf_def_v(1)%qisws,            &
     2238                                               surf_lsm_v(1)%qisws,            &
     2239                                               surf_usm_v(1)%qisws,            &
     2240                                               surf_def_v(2)%qisws,            &
     2241                                               surf_lsm_v(2)%qisws,            &
     2242                                               surf_usm_v(2)%qisws,            &
     2243                                               surf_def_v(3)%qisws,            &
     2244                                               surf_lsm_v(3)%qisws,            &
     2245                                               surf_usm_v(3)%qisws )
     2246               ELSE
     2247!
     2248!--               Output of averaged data
     2249                  surfaces%var_out(:) = surfaces%var_av(:,n_out) /             &
     2250                                        REAL( average_count_surf, KIND=wp )
     2251                  surfaces%var_av(:,n_out) = 0.0_wp
     2252
     2253               ENDIF
     2254
     2255            CASE ( 'nisws' )
     2256!
     2257!--            Output of instantaneous data
     2258               IF ( av == 0 )  THEN
     2259                  CALL surface_data_output_collect( surf_def_h(0)%nisws,       &
     2260                                               surf_def_h(1)%nisws,            &
     2261                                               surf_lsm_h%nisws,               &
     2262                                               surf_usm_h%nisws,               &
     2263                                               surf_def_v(0)%nisws,            &
     2264                                               surf_lsm_v(0)%nisws,            &
     2265                                               surf_usm_v(0)%nisws,            &
     2266                                               surf_def_v(1)%nisws,            &
     2267                                               surf_lsm_v(1)%nisws,            &
     2268                                               surf_usm_v(1)%nisws,            &
     2269                                               surf_def_v(2)%nisws,            &
     2270                                               surf_lsm_v(2)%nisws,            &
     2271                                               surf_usm_v(2)%nisws,            &
     2272                                               surf_def_v(3)%nisws,            &
     2273                                               surf_lsm_v(3)%nisws,            &
     2274                                               surf_usm_v(3)%nisws )
    21552275               ELSE
    21562276!
     
    31203240                                           surf_usm_v(3)%ncs, n_out )
    31213241
     3242            CASE ( 'qis' )
     3243               CALL surface_data_output_sum_up( surf_def_h(0)%qis,             &
     3244                                           surf_def_h(1)%qis,                  &
     3245                                           surf_lsm_h%qis,                     &
     3246                                           surf_usm_h%qis,                     &
     3247                                           surf_def_v(0)%qis,                  &
     3248                                           surf_lsm_v(0)%qis,                  &
     3249                                           surf_usm_v(0)%qis,                  &
     3250                                           surf_def_v(1)%qis,                  &
     3251                                           surf_lsm_v(1)%qis,                  &
     3252                                           surf_usm_v(1)%qis,                  &
     3253                                           surf_def_v(2)%qis,                  &
     3254                                           surf_lsm_v(2)%qis,                  &
     3255                                           surf_usm_v(2)%qis,                  &
     3256                                           surf_def_v(3)%qis,                  &
     3257                                           surf_lsm_v(3)%qis,                  &
     3258                                           surf_usm_v(3)%qrs, n_out )
     3259
     3260            CASE ( 'nis' )
     3261               CALL surface_data_output_sum_up( surf_def_h(0)%nis,             &
     3262                                           surf_def_h(1)%nis,                  &
     3263                                           surf_lsm_h%nis,                     &
     3264                                           surf_usm_h%nis,                     &
     3265                                           surf_def_v(0)%nis,                  &
     3266                                           surf_lsm_v(0)%nis,                  &
     3267                                           surf_usm_v(0)%nis,                  &
     3268                                           surf_def_v(1)%nis,                  &
     3269                                           surf_lsm_v(1)%nis,                  &
     3270                                           surf_usm_v(1)%nis,                  &
     3271                                           surf_def_v(2)%nis,                  &
     3272                                           surf_lsm_v(2)%nis,                  &
     3273                                           surf_usm_v(2)%nis,                  &
     3274                                           surf_def_v(3)%nis,                  &
     3275                                           surf_lsm_v(3)%nis,                  &
     3276                                           surf_usm_v(3)%nis, n_out )
     3277
    31223278            CASE ( 'qrs' )
    31233279               CALL surface_data_output_sum_up( surf_def_h(0)%qrs,             &
     
    34113567                                           surf_lsm_v(3)%ncsws,                &
    34123568                                           surf_usm_v(3)%ncsws, n_out )
     3569
     3570            CASE ( 'qisws' )
     3571               CALL surface_data_output_sum_up( surf_def_h(0)%qisws,           &
     3572                                           surf_def_h(1)%qisws,                &
     3573                                           surf_lsm_h%qisws,                   &
     3574                                           surf_usm_h%qisws,                   &
     3575                                           surf_def_v(0)%qisws,                &
     3576                                           surf_lsm_v(0)%qisws,                &
     3577                                           surf_usm_v(0)%qisws,                &
     3578                                           surf_def_v(1)%qisws,                &
     3579                                           surf_lsm_v(1)%qisws,                &
     3580                                           surf_usm_v(1)%qisws,                &
     3581                                           surf_def_v(2)%qisws,                &
     3582                                           surf_lsm_v(2)%qisws,                &
     3583                                           surf_usm_v(2)%qisws,                &
     3584                                           surf_def_v(3)%qisws,                &
     3585                                           surf_lsm_v(3)%qisws,                &
     3586                                           surf_usm_v(3)%qisws, n_out )
     3587
     3588            CASE ( 'nisws' )
     3589               CALL surface_data_output_sum_up( surf_def_h(0)%nisws,           &
     3590                                           surf_def_h(1)%nisws,                &
     3591                                           surf_lsm_h%nisws,                   &
     3592                                           surf_usm_h%nisws,                   &
     3593                                           surf_def_v(0)%nisws,                &
     3594                                           surf_lsm_v(0)%nisws,                &
     3595                                           surf_usm_v(0)%nisws,                &
     3596                                           surf_def_v(1)%nisws,                &
     3597                                           surf_lsm_v(1)%nisws,                &
     3598                                           surf_usm_v(1)%nisws,                &
     3599                                           surf_def_v(2)%nisws,                &
     3600                                           surf_lsm_v(2)%nisws,                &
     3601                                           surf_usm_v(2)%nisws,                &
     3602                                           surf_def_v(3)%nisws,                &
     3603                                           surf_lsm_v(3)%nisws,                &
     3604                                           surf_usm_v(3)%nisws, n_out )
    34133605
    34143606            CASE ( 'qrsws' )
     
    45334725               unit = 'm/s'
    45344726
    4535             CASE ( 'ss', 'qcs', 'ncs', 'qrs', 'nrs' )
     4727            CASE ( 'ss', 'qcs', 'ncs', 'qis', 'nis', 'qrs', 'nrs' )
    45364728               unit = '1'
    45374729
     
    45454737               unit = 'm2/s2'
    45464738
    4547             CASE ( 'qcsws', 'ncsws', 'qrsws', 'nrsws', 'sasws' )
     4739            CASE ( 'qcsws', 'ncsws', 'qisws', 'nisws', 'qrsws', 'nrsws', 'sasws' )
    45484740
    45494741            CASE ( 'shf' )
  • palm/trunk/SOURCE/surface_mod.f90

    r4495 r4502  
    2626! -----------------
    2727! $Id$
     28! Implementation of ice microphysics
     29!
     30! 4495 2020-04-13 20:11:20Z raasch
    2831! restart data handling with MPI-IO added
    2932!
     
    148151
    149152!
    150 !-- Data type used to identify grid-points where horizontal boundary conditions 
    151 !-- are applied 
     153!-- Data type used to identify grid-points where horizontal boundary conditions
     154!-- are applied
    152155    TYPE bc_type
    153156       INTEGER(iwp) :: ioff !< offset value in x-direction, used to determine index of surface element
     
    156159       INTEGER(iwp) :: ns   !< number of surface elements on the PE
    157160
    158        INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  i !< x-index linking to the PALM 3D-grid 
    159        INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  j !< y-index linking to the PALM 3D-grid   
    160        INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  k !< z-index linking to the PALM 3D-grid   
    161 
    162        INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: start_index !< start index within surface data type for given (j,i) 
    163        INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: end_index   !< end index within surface data type for given (j,i) 
     161       INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  i !< x-index linking to the PALM 3D-grid
     162       INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  j !< y-index linking to the PALM 3D-grid
     163       INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  k !< z-index linking to the PALM 3D-grid
     164
     165       INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: start_index !< start index within surface data type for given (j,i)
     166       INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: end_index   !< end index within surface data type for given (j,i)
    164167
    165168    END TYPE bc_type
    166169!
    167 !-- Data type used to identify and treat surface-bounded grid points 
     170!-- Data type used to identify and treat surface-bounded grid points
    168171    TYPE surf_type
    169172
    170173       LOGICAL ::  albedo_from_ascii = .FALSE. !< flag indicating that albedo for urban surfaces is input via ASCII format (just for a workaround)
    171    
     174
    172175       INTEGER(iwp) :: ioff                                !< offset value in x-direction, used to determine index of surface element
    173176       INTEGER(iwp) :: joff                                !< offset value in y-direction, used to determine index of surface element
     
    175178       INTEGER(iwp) :: ns                                  !< number of surface elements on the PE
    176179
    177        INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  i       !< x-index linking to the PALM 3D-grid 
    178        INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  j       !< y-index linking to the PALM 3D-grid   
    179        INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  k       !< z-index linking to the PALM 3D-grid       
    180 
    181        INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  facing  !< Bit indicating surface orientation 
    182      
    183        INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: start_index !< Start index within surface data type for given (j,i) 
    184        INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: end_index   !< End index within surface data type for given (j,i) 
    185 
    186        REAL(wp), DIMENSION(:), ALLOCATABLE ::  z_mo      !< surface-layer height 
     180       INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  i       !< x-index linking to the PALM 3D-grid
     181       INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  j       !< y-index linking to the PALM 3D-grid
     182       INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  k       !< z-index linking to the PALM 3D-grid
     183
     184       INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  facing  !< Bit indicating surface orientation
     185
     186       INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: start_index !< Start index within surface data type for given (j,i)
     187       INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: end_index   !< End index within surface data type for given (j,i)
     188
     189       REAL(wp), DIMENSION(:), ALLOCATABLE ::  z_mo      !< surface-layer height
    187190       REAL(wp), DIMENSION(:), ALLOCATABLE ::  uvw_abs   !< absolute surface-parallel velocity
    188191       REAL(wp), DIMENSION(:), ALLOCATABLE ::  us        !< friction velocity
     
    192195       REAL(wp), DIMENSION(:), ALLOCATABLE ::  qcs       !< scaling parameter qc
    193196       REAL(wp), DIMENSION(:), ALLOCATABLE ::  ncs       !< scaling parameter nc
     197       REAL(wp), DIMENSION(:), ALLOCATABLE ::  qis       !< scaling parameter qi
     198       REAL(wp), DIMENSION(:), ALLOCATABLE ::  nis       !< scaling parameter ni
    194199       REAL(wp), DIMENSION(:), ALLOCATABLE ::  qrs       !< scaling parameter qr
    195200       REAL(wp), DIMENSION(:), ALLOCATABLE ::  nrs       !< scaling parameter nr
     
    205210       REAL(wp), DIMENSION(:), ALLOCATABLE ::  qv1       !< mixing ratio at first grid level
    206211       REAL(wp), DIMENSION(:), ALLOCATABLE ::  vpt1      !< virtual potential temperature at first grid level
    207        
     212
    208213       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  css     !< scaling parameter chemical species
    209214!
    210215!--    Define arrays for surface fluxes
    211216       REAL(wp), DIMENSION(:), ALLOCATABLE ::  usws      !< vertical momentum flux for u-component at horizontal surfaces
    212        REAL(wp), DIMENSION(:), ALLOCATABLE ::  vsws      !< vertical momentum flux for v-component at horizontal surfaces 
     217       REAL(wp), DIMENSION(:), ALLOCATABLE ::  vsws      !< vertical momentum flux for v-component at horizontal surfaces
    213218
    214219       REAL(wp), DIMENSION(:), ALLOCATABLE ::  shf       !< surface flux sensible heat
    215        REAL(wp), DIMENSION(:), ALLOCATABLE ::  qsws      !< surface flux latent heat 
     220       REAL(wp), DIMENSION(:), ALLOCATABLE ::  qsws      !< surface flux latent heat
    216221       REAL(wp), DIMENSION(:), ALLOCATABLE ::  ssws      !< surface flux passive scalar
    217222       REAL(wp), DIMENSION(:), ALLOCATABLE ::  qcsws     !< surface flux qc
    218223       REAL(wp), DIMENSION(:), ALLOCATABLE ::  ncsws     !< surface flux nc
     224       REAL(wp), DIMENSION(:), ALLOCATABLE ::  qisws     !< surface flux qi
     225       REAL(wp), DIMENSION(:), ALLOCATABLE ::  nisws     !< surface flux ni
    219226       REAL(wp), DIMENSION(:), ALLOCATABLE ::  qrsws     !< surface flux qr
    220227       REAL(wp), DIMENSION(:), ALLOCATABLE ::  nrsws     !< surface flux nr
     
    224231       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  amsws   !< surface flux aerosol mass:   dim 1: flux, dim 2: bin
    225232       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  gtsws   !< surface flux gesous tracers: dim 1: flux, dim 2: gas
    226        
     233
    227234       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  cssws   !< surface flux chemical species
    228235!
     
    240247       CHARACTER(LEN=40), DIMENSION(:), ALLOCATABLE ::  vegetation_type_name  !< water type at name surface element
    241248       CHARACTER(LEN=40), DIMENSION(:), ALLOCATABLE ::  water_type_name       !< water type at name surface element
    242        
     249
    243250       INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  nzt_pavement     !< top index for pavement in soil
    244251       INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  building_type    !< building type at surface element
     
    246253       INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  vegetation_type  !< vegetation type at surface element
    247254       INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  water_type       !< water type at surface element
    248        
     255
    249256       INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  albedo_type   !< albedo type, for each fraction (wall,green,window or vegetation,pavement water)
    250257
     
    254261       LOGICAL, DIMENSION(:), ALLOCATABLE  ::  water_surface       !< flag parameter for water surfaces
    255262       LOGICAL, DIMENSION(:), ALLOCATABLE  ::  vegetation_surface  !< flag parameter for natural land surfaces
    256        
     263
    257264       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  albedo            !< broadband albedo for each surface fraction (LSM: vegetation, water, pavement; USM: wall, green, window)
    258265       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  emissivity        !< emissivity of the surface, for each fraction  (LSM: vegetation, water, pavement; USM: wall, green, window)
     
    271278       REAL(wp), DIMENSION(:), ALLOCATABLE   ::  pt_surface        !< skin-surface temperature
    272279       REAL(wp), DIMENSION(:), ALLOCATABLE   ::  vpt_surface       !< skin-surface virtual temperature
    273        REAL(wp), DIMENSION(:), ALLOCATABLE   ::  rad_net           !< net radiation 
     280       REAL(wp), DIMENSION(:), ALLOCATABLE   ::  rad_net           !< net radiation
    274281       REAL(wp), DIMENSION(:), ALLOCATABLE   ::  rad_net_l         !< net radiation, used in USM
    275        REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  lambda_h          !< heat conductivity of soil/ wall (W/m/K) 
    276        REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  lambda_h_green    !< heat conductivity of green soil (W/m/K) 
    277        REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  lambda_h_window   !< heat conductivity of windows (W/m/K) 
    278        REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  lambda_h_def      !< default heat conductivity of soil (W/m/K)   
     282       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  lambda_h          !< heat conductivity of soil/ wall (W/m/K)
     283       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  lambda_h_green    !< heat conductivity of green soil (W/m/K)
     284       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  lambda_h_window   !< heat conductivity of windows (W/m/K)
     285       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  lambda_h_def      !< default heat conductivity of soil (W/m/K)
    279286
    280287       REAL(wp), DIMENSION(:), ALLOCATABLE ::  rad_lw_in           !< incoming longwave radiation
     
    302309       REAL(wp), DIMENSION(:), ALLOCATABLE ::  qsws_veg            !< surface flux of latent heat (vegetation portion)
    303310
    304        REAL(wp), DIMENSION(:), ALLOCATABLE ::  r_a                 !< aerodynamic resistance 
     311       REAL(wp), DIMENSION(:), ALLOCATABLE ::  r_a                 !< aerodynamic resistance
    305312       REAL(wp), DIMENSION(:), ALLOCATABLE ::  r_a_green           !< aerodynamic resistance at green fraction
    306313       REAL(wp), DIMENSION(:), ALLOCATABLE ::  r_a_window          !< aerodynamic resistance at window fraction
     
    310317       REAL(wp), DIMENSION(:), ALLOCATABLE ::  r_s                 !< total surface resistance (combination of r_soil and r_canopy)
    311318       REAL(wp), DIMENSION(:), ALLOCATABLE ::  r_canopy_min        !< minimum canopy (stomatal) resistance
    312        
     319
    313320       REAL(wp), DIMENSION(:), ALLOCATABLE ::  pt_10cm             !< near surface air potential temperature at distance 10 cm from the surface (K)
    314        
     321
    315322       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  alpha_vg          !< coef. of Van Genuchten
    316323       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  lambda_w          !< hydraulic diffusivity of soil (?)
     
    322329       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  m_sat             !< saturation soil moisture (m3/m3)
    323330       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  m_wilt            !< soil moisture at permanent wilting point (m3/m3)
    324        REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  n_vg              !< coef. Van Genuchten 
     331       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  n_vg              !< coef. Van Genuchten
    325332       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  rho_c_total_def   !< default volumetric heat capacity of the (soil) layer (J/m3/K)
    326333       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  rho_c_total       !< volumetric heat capacity of the actual soil matrix (J/m3/K)
    327334       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  root_fr           !< root fraction within the soil layers
    328        
     335
    329336!--    Indoor model variables
    330        REAL(wp), DIMENSION(:), ALLOCATABLE ::  waste_heat          !< waste heat 
     337       REAL(wp), DIMENSION(:), ALLOCATABLE ::  waste_heat          !< waste heat
    331338!
    332339!--    Urban surface variables
     
    334341
    335342       LOGICAL, DIMENSION(:), ALLOCATABLE  ::  isroof_surf          !< flag indicating roof surfaces
    336        LOGICAL, DIMENSION(:), ALLOCATABLE  ::  ground_level         !< flag indicating ground floor level surfaces 
     343       LOGICAL, DIMENSION(:), ALLOCATABLE  ::  ground_level         !< flag indicating ground floor level surfaces
    337344
    338345       REAL(wp), DIMENSION(:), ALLOCATABLE ::  target_temp_summer  !< indoor target temperature summer
    339        REAL(wp), DIMENSION(:), ALLOCATABLE ::  target_temp_winter  !< indoor target temperature summer       
     346       REAL(wp), DIMENSION(:), ALLOCATABLE ::  target_temp_winter  !< indoor target temperature summer
    340347
    341348       REAL(wp), DIMENSION(:), ALLOCATABLE ::  c_surface           !< heat capacity of the wall surface skin (J/m2/K)
     
    373380       REAL(wp), DIMENSION(:), ALLOCATABLE ::  surfinlw            !< longwave radiation falling to local surface including radiation from reflections
    374381       REAL(wp), DIMENSION(:), ALLOCATABLE ::  surfoutlw           !< total longwave radiation outgoing from nonvirtual surfaces surfaces after all reflection
    375        
     382
    376383       REAL(wp), DIMENSION(:), ALLOCATABLE ::  n_vg_green          !< vangenuchten parameters
    377384       REAL(wp), DIMENSION(:), ALLOCATABLE ::  alpha_vg_green      !< vangenuchten parameters
     
    384391       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  dz_wall_stag      !< wall grid spacing (edge-edge)
    385392       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  ddz_wall_stag     !< 1/dz_wall_stag
    386        REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  tt_wall_m         !< t_wall prognostic array 
     393       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  tt_wall_m         !< t_wall prognostic array
    387394       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  zw                !< wall layer depths (m)
    388395       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  rho_c_window      !< volumetric heat capacity of the window material ( J m-3 K-1 ) (= 2.19E6)
     
    391398       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  dz_window_stag    !< window grid spacing (edge-edge)
    392399       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  ddz_window_stag   !< 1/dz_window_stag
    393        REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  tt_window_m       !< t_window prognostic array 
     400       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  tt_window_m       !< t_window prognostic array
    394401       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  zw_window         !< window layer depths (m)
    395402       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  rho_c_green       !< volumetric heat capacity of the green material ( J m-3 K-1 ) (= 2.19E6)
     
    399406       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  dz_green_stag     !< green grid spacing (edge-edge)
    400407       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  ddz_green_stag    !< 1/dz_green_stag
    401        REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  tt_green_m        !< t_green prognostic array 
     408       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  tt_green_m        !< t_green prognostic array
    402409       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  zw_green          !< green layer depths (m)
    403410
     
    421428       REAL(wp), DIMENSION(:), ALLOCATABLE ::  surfins_av       !< average of array of residua of sw radiation absorbed in surface after last reflection
    422429       REAL(wp), DIMENSION(:), ALLOCATABLE ::  surfinl_av       !< average of array of residua of lw radiation absorbed in surface after last reflection
    423        REAL(wp), DIMENSION(:), ALLOCATABLE ::  surfhf_av        !< average of total radiation flux incoming to minus outgoing from local surface 
     430       REAL(wp), DIMENSION(:), ALLOCATABLE ::  surfhf_av        !< average of total radiation flux incoming to minus outgoing from local surface
    424431       REAL(wp), DIMENSION(:), ALLOCATABLE ::  wghf_eb_av       !< average of wghf_eb
    425432       REAL(wp), DIMENSION(:), ALLOCATABLE ::  wghf_eb_window_av  !< average of wghf_eb window
     
    437444
    438445       REAL(wp), DIMENSION(:), ALLOCATABLE ::  pt_10cm_av       !< average of theta_10cm (K)
    439        
     446
    440447       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  t_wall_av      !< Average of t_wall
    441448       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  t_window_av    !< Average of t_window
     
    455462    TYPE (surf_type), DIMENSION(0:3), TARGET ::  surf_usm_v  !< vertical urban surfaces (North, South, East, West)
    456463
    457     INTEGER(iwp), PARAMETER ::  ind_veg_wall  = 0            !< index for vegetation / wall-surface fraction, used for access of albedo, emissivity, etc., for each surface type   
     464    INTEGER(iwp), PARAMETER ::  ind_veg_wall  = 0            !< index for vegetation / wall-surface fraction, used for access of albedo, emissivity, etc., for each surface type
    458465    INTEGER(iwp), PARAMETER ::  ind_pav_green = 1            !< index for pavement / green-wall surface fraction, used for access of albedo, emissivity, etc., for each surface type
    459466    INTEGER(iwp), PARAMETER ::  ind_wat_win   = 2            !< index for water / window-surface fraction, used for access of albedo, emissivity, etc., for each surface type
    460467
    461     INTEGER(iwp) ::  ns_h_on_file(0:2)                       !< total number of horizontal surfaces with the same facing, required for writing restart data 
    462     INTEGER(iwp) ::  ns_v_on_file(0:3)                       !< total number of vertical surfaces with the same facing, required for writing restart data 
    463 
    464     LOGICAL ::  vertical_surfaces_exist = .FALSE.   !< flag indicating that there are vertical urban/land surfaces 
     468    INTEGER(iwp) ::  ns_h_on_file(0:2)                       !< total number of horizontal surfaces with the same facing, required for writing restart data
     469    INTEGER(iwp) ::  ns_v_on_file(0:3)                       !< total number of vertical surfaces with the same facing, required for writing restart data
     470
     471    LOGICAL ::  vertical_surfaces_exist = .FALSE.   !< flag indicating that there are vertical urban/land surfaces
    465472                                                    !< in the domain (required to activiate RTM)
    466473
     
    468475    LOGICAL ::  surf_microphysics_morrison = .FALSE.   !< use 2-moment Morrison (add. prog. eq. for nc and qc)
    469476    LOGICAL ::  surf_microphysics_seifert = .FALSE.    !< use 2-moment Seifert and Beheng scheme
     477    LOGICAL ::  surf_microphysics_ice_extension = .FALSE. !< use 2-moment Seifert and Beheng scheme
    470478
    471479
     
    473481
    474482    PRIVATE
    475    
     483
    476484    INTERFACE init_bc
    477485       MODULE PROCEDURE init_bc
     
    481489       MODULE PROCEDURE init_single_surface_properties
    482490    END INTERFACE init_single_surface_properties
    483    
     491
    484492    INTERFACE init_surfaces
    485493       MODULE PROCEDURE init_surfaces
     
    522530           surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, surf_usm_v, surf_type,      &
    523531           vertical_surfaces_exist, surf_bulk_cloud_model, surf_microphysics_morrison,             &
    524            surf_microphysics_seifert
     532           surf_microphysics_seifert, surf_microphysics_ice_extension
    525533!
    526534!-- Public subroutines and functions
     
    544552! Description:
    545553! ------------
    546 !> Initialize data type for setting boundary conditions at horizontal and 
    547 !> vertical surfaces. 
     554!> Initialize data type for setting boundary conditions at horizontal and
     555!> vertical surfaces.
    548556!------------------------------------------------------------------------------!
    549557    SUBROUTINE init_bc
     
    559567       INTEGER(iwp), DIMENSION(0:1) ::  num_h_kji     !< number of horizontal surfaces at (j,i)-grid point
    560568       INTEGER(iwp), DIMENSION(0:1) ::  start_index_h !< local start index of horizontal surface elements
    561        
     569
    562570       INTEGER(iwp), DIMENSION(0:3) ::  num_v         !< number of vertical surfaces on subdomain
    563571       INTEGER(iwp), DIMENSION(0:3) ::  num_v_kji     !< number of vertical surfaces at (j,i)-grid point
    564572       INTEGER(iwp), DIMENSION(0:3) ::  start_index_v !< local start index of vertical surface elements
    565573!
    566 !--    Set offset indices, i.e. index difference between surface element and 
     574!--    Set offset indices, i.e. index difference between surface element and
    567575!--    surface-bounded grid point.
    568576!--    Horizontal surfaces - no horizontal offsets
     
    596604!
    597605!--    Initialize data structure for horizontal surfaces, i.e. count the number
    598 !--    of surface elements, allocate and initialize the respective index arrays, 
    599 !--    and set the respective start and end indices at each (j,i)-location. 
    600 !--    The index space is defined also over the ghost points, so that e.g. 
    601 !--    boundary conditions for diagnostic quanitities can be set on ghost 
    602 !--    points so that no exchange is required any more. 
     606!--    of surface elements, allocate and initialize the respective index arrays,
     607!--    and set the respective start and end indices at each (j,i)-location.
     608!--    The index space is defined also over the ghost points, so that e.g.
     609!--    boundary conditions for diagnostic quanitities can be set on ghost
     610!--    points so that no exchange is required any more.
    603611       DO  l = 0, 1
    604612!
     
    608616             DO  j = nysg, nyng
    609617                DO  k = nzb+1, nzt
    610 !         
     618!
    611619!--                Check if current gridpoint belongs to the atmosphere
    612620                   IF ( BTEST( wall_flags_total_0(k,j,i), 0 ) )  THEN
     
    619627             ENDDO
    620628          ENDDO
    621 !         
     629!
    622630!--       Save the number of horizontal surface elements
    623631          bc_h(l)%ns = num_h(l)
     
    631639          bc_h(l)%start_index = 1
    632640          bc_h(l)%end_index   = 0
    633          
     641
    634642          num_h(l)         = 1
    635643          start_index_h(l) = 1
    636644          DO  i = nxlg, nxrg
    637645             DO  j = nysg, nyng
    638          
     646
    639647                num_h_kji(l) = 0
    640648                DO  k = nzb+1, nzt
    641 !         
     649!
    642650!--                Check if current gridpoint belongs to the atmosphere
    643651                   IF ( BTEST( wall_flags_total_0(k,j,i), 0 ) )  THEN
    644 !         
     652!
    645653!--                   Upward-facing
    646654                      IF ( .NOT. BTEST( wall_flags_total_0(k+bc_h(l)%koff,     &
     
    666674!
    667675!--    Initialize data structure for vertical surfaces, i.e. count the number
    668 !--    of surface elements, allocate and initialize the respective index arrays, 
     676!--    of surface elements, allocate and initialize the respective index arrays,
    669677!--    and set the respective start and end indices at each (j,i)-location.
    670678       DO  l = 0, 3
     
    675683             DO  j = nys, nyn
    676684                DO  k = nzb+1, nzt
    677 !         
     685!
    678686!--                Check if current gridpoint belongs to the atmosphere
    679687                   IF ( BTEST( wall_flags_total_0(k,j,i), 0 ) )  THEN
     
    686694             ENDDO
    687695          ENDDO
    688 !         
     696!
    689697!--       Save the number of horizontal surface elements
    690698          bc_v(l)%ns = num_v(l)
    691699!
    692700!--       ALLOCATE arrays for horizontal surfaces. In contrast to the
    693 !--       horizontal surfaces, the index space is not defined over the 
    694 !--       ghost points. 
     701!--       horizontal surfaces, the index space is not defined over the
     702!--       ghost points.
    695703          ALLOCATE( bc_v(l)%i(1:bc_v(l)%ns) )
    696704          ALLOCATE( bc_v(l)%j(1:bc_v(l)%ns) )
     
    700708          bc_v(l)%start_index = 1
    701709          bc_v(l)%end_index   = 0
    702          
     710
    703711          num_v(l)         = 1
    704712          start_index_v(l) = 1
    705713          DO  i = nxl, nxr
    706714             DO  j = nys, nyn
    707          
     715
    708716                num_v_kji(l) = 0
    709717                DO  k = nzb+1, nzt
    710 !         
     718!
    711719!--                Check if current gridpoint belongs to the atmosphere
    712720                   IF ( BTEST( wall_flags_total_0(k,j,i), 0 ) )  THEN
    713 !         
     721!
    714722!--                   Upward-facing
    715723                      IF ( .NOT. BTEST( wall_flags_total_0(k+bc_v(l)%koff,     &
     
    741749! ------------
    742750!> Initialize horizontal and vertical surfaces. Counts the number of default-,
    743 !> natural and urban surfaces and allocates memory, respectively. 
     751!> natural and urban surfaces and allocates memory, respectively.
    744752!------------------------------------------------------------------------------!
    745753    SUBROUTINE init_surface_arrays
     
    751759       IMPLICIT NONE
    752760
    753        INTEGER(iwp)                 ::  i         !< running index x-direction 
     761       INTEGER(iwp)                 ::  i         !< running index x-direction
    754762       INTEGER(iwp)                 ::  j         !< running index y-direction
    755763       INTEGER(iwp)                 ::  k         !< running index z-direction
    756764       INTEGER(iwp)                 ::  l         !< index variable for surface facing
    757        INTEGER(iwp)                 ::  num_lsm_h !< number of horizontally-aligned natural surfaces 
    758        INTEGER(iwp)                 ::  num_usm_h !< number of horizontally-aligned urban surfaces 
    759 
    760        INTEGER(iwp), DIMENSION(0:2) ::  num_def_h !< number of horizontally-aligned default surfaces 
    761        INTEGER(iwp), DIMENSION(0:3) ::  num_def_v !< number of vertically-aligned default surfaces 
    762        INTEGER(iwp), DIMENSION(0:3) ::  num_lsm_v !< number of vertically-aligned natural surfaces 
    763        INTEGER(iwp), DIMENSION(0:3) ::  num_usm_v !< number of vertically-aligned urban surfaces 
     765       INTEGER(iwp)                 ::  num_lsm_h !< number of horizontally-aligned natural surfaces
     766       INTEGER(iwp)                 ::  num_usm_h !< number of horizontally-aligned urban surfaces
     767
     768       INTEGER(iwp), DIMENSION(0:2) ::  num_def_h !< number of horizontally-aligned default surfaces
     769       INTEGER(iwp), DIMENSION(0:3) ::  num_def_v !< number of vertically-aligned default surfaces
     770       INTEGER(iwp), DIMENSION(0:3) ::  num_lsm_v !< number of vertically-aligned natural surfaces
     771       INTEGER(iwp), DIMENSION(0:3) ::  num_usm_v !< number of vertically-aligned urban surfaces
    764772
    765773       INTEGER(iwp)              ::  num_surf_v_l !< number of vertically-aligned local urban/land surfaces
     
    768776       LOGICAL ::  building                       !< flag indicating building grid point
    769777       LOGICAL ::  terrain                        !< flag indicating natural terrain grid point
    770        LOGICAL ::  unresolved_building            !< flag indicating a grid point where actually a building is 
    771                                                   !< defined but not resolved by the vertical grid 
     778       LOGICAL ::  unresolved_building            !< flag indicating a grid point where actually a building is
     779                                                  !< defined but not resolved by the vertical grid
    772780
    773781       num_def_h = 0
     
    780788!--    Surfaces are classified according to the input data read from static
    781789!--    input file. If no input file is present, all surfaces are classified
    782 !--    either as natural, urban, or default, depending on the setting of 
     790!--    either as natural, urban, or default, depending on the setting of
    783791!--    land_surface and urban_surface. To control this, use the control
    784792!--    flag topo_no_distinct
    785793!
    786 !--    Count number of horizontal surfaces on local domain 
     794!--    Count number of horizontal surfaces on local domain
    787795       DO  i = nxl, nxr
    788796          DO  j = nys, nyn
     
    798806!
    799807!--                   Determine flags indicating a terrain surface, a building
    800 !--                   surface, 
     808!--                   surface,
    801809                      terrain  = BTEST( wall_flags_total_0(k-1,j,i), 5 )  .OR.       &
    802810                                 topo_no_distinct
     
    804812                                 topo_no_distinct
    805813!
    806 !--                   unresolved_building indicates a surface with equal height 
     814!--                   unresolved_building indicates a surface with equal height
    807815!--                   as terrain but with a non-grid resolved building on top.
    808816!--                   These surfaces will be flagged as urban surfaces.
     
    813821                      IF ( land_surface  .AND.  terrain  .AND.                 &
    814822                           .NOT. unresolved_building )  THEN
    815                          num_lsm_h    = num_lsm_h    + 1 
     823                         num_lsm_h    = num_lsm_h    + 1
    816824!
    817825!--                   Urban surface tpye
    818826                      ELSEIF ( urban_surface  .AND.  building )  THEN
    819                          num_usm_h    = num_usm_h    + 1 
     827                         num_usm_h    = num_usm_h    + 1
    820828!
    821829!--                   Default-surface type
    822830                      ELSEIF ( .NOT. land_surface    .AND.                     &
    823831                               .NOT. urban_surface )  THEN
    824                                
     832
    825833                         num_def_h(0) = num_def_h(0) + 1
    826834!
    827835!--                   Unclassifified surface-grid point. Give error message.
    828                       ELSE 
     836                      ELSE
    829837                         WRITE( message_string, * )                           &
    830838                                          'Unclassified upward-facing ' //    &
     
    840848                      num_def_h(2) = num_def_h(2) + 1
    841849!
    842 !--                Check for any other downward-facing surface. So far only for 
     850!--                Check for any other downward-facing surface. So far only for
    843851!--                default surface type.
    844852                   ELSEIF ( .NOT. BTEST( wall_flags_total_0(k+1,j,i), 0 ) )  THEN
    845853                      num_def_h(1) = num_def_h(1) + 1
    846                    ENDIF 
     854                   ENDIF
    847855
    848856                ENDIF
     
    851859       ENDDO
    852860!
    853 !--    Count number of vertical surfaces on local domain 
     861!--    Count number of vertical surfaces on local domain
    854862       DO  i = nxl, nxr
    855863          DO  j = nys, nyn
     
    869877                      unresolved_building = BTEST( wall_flags_total_0(k,j-1,i), 5 )  &
    870878                                     .AND.  BTEST( wall_flags_total_0(k,j-1,i), 6 )
    871                                      
     879
    872880                      IF (  land_surface  .AND.  terrain  .AND.                &
    873881                           .NOT. unresolved_building )  THEN
    874                          num_lsm_v(0) = num_lsm_v(0) + 1 
     882                         num_lsm_v(0) = num_lsm_v(0) + 1
    875883                      ELSEIF ( urban_surface  .AND.  building )  THEN
    876                          num_usm_v(0) = num_usm_v(0) + 1 
     884                         num_usm_v(0) = num_usm_v(0) + 1
    877885!
    878886!--                   Default-surface type
    879887                      ELSEIF ( .NOT. land_surface    .AND.                     &
    880888                               .NOT. urban_surface )  THEN
    881                          num_def_v(0) = num_def_v(0) + 1 
     889                         num_def_v(0) = num_def_v(0) + 1
    882890!
    883891!--                   Unclassifified surface-grid point. Give error message.
    884                       ELSE 
     892                      ELSE
    885893                         WRITE( message_string, * )                            &
    886894                                          'Unclassified northward-facing ' //  &
     
    900908                      building = BTEST( wall_flags_total_0(k,j+1,i), 6 )  .OR.       &
    901909                                 topo_no_distinct
    902                                  
     910
    903911                      unresolved_building = BTEST( wall_flags_total_0(k,j+1,i), 5 )  &
    904                                      .AND.  BTEST( wall_flags_total_0(k,j+1,i), 6 ) 
    905                                
     912                                     .AND.  BTEST( wall_flags_total_0(k,j+1,i), 6 )
     913
    906914                      IF (  land_surface  .AND.  terrain  .AND.                &
    907915                           .NOT. unresolved_building )  THEN
    908                          num_lsm_v(1) = num_lsm_v(1) + 1 
     916                         num_lsm_v(1) = num_lsm_v(1) + 1
    909917                      ELSEIF ( urban_surface  .AND.  building )  THEN
    910                          num_usm_v(1) = num_usm_v(1) + 1 
     918                         num_usm_v(1) = num_usm_v(1) + 1
    911919!
    912920!--                   Default-surface type
    913921                      ELSEIF ( .NOT. land_surface    .AND.                     &
    914922                               .NOT. urban_surface )  THEN
    915                          num_def_v(1) = num_def_v(1) + 1 
     923                         num_def_v(1) = num_def_v(1) + 1
    916924!
    917925!--                   Unclassifified surface-grid point. Give error message.
    918                       ELSE 
     926                      ELSE
    919927                         WRITE( message_string, * )                            &
    920928                                          'Unclassified southward-facing ' //  &
     
    934942                      building = BTEST( wall_flags_total_0(k,j,i-1), 6 )  .OR.       &
    935943                                 topo_no_distinct
    936                                  
     944
    937945                      unresolved_building = BTEST( wall_flags_total_0(k,j,i-1), 5 )  &
    938946                                     .AND.  BTEST( wall_flags_total_0(k,j,i-1), 6 )
    939                                      
     947
    940948                      IF (  land_surface  .AND.  terrain  .AND.                &
    941949                           .NOT. unresolved_building )  THEN
    942                          num_lsm_v(2) = num_lsm_v(2) + 1 
     950                         num_lsm_v(2) = num_lsm_v(2) + 1
    943951                      ELSEIF ( urban_surface  .AND.  building )  THEN
    944                          num_usm_v(2) = num_usm_v(2) + 1 
     952                         num_usm_v(2) = num_usm_v(2) + 1
    945953!
    946954!--                   Default-surface type
    947955                      ELSEIF ( .NOT. land_surface    .AND.                     &
    948956                               .NOT. urban_surface )  THEN
    949                          num_def_v(2) = num_def_v(2) + 1 
     957                         num_def_v(2) = num_def_v(2) + 1
    950958!
    951959!--                   Unclassifified surface-grid point. Give error message.
    952                       ELSE 
     960                      ELSE
    953961                         WRITE( message_string, * )                            &
    954962                                          'Unclassified eastward-facing ' //   &
     
    968976                      building = BTEST( wall_flags_total_0(k,j,i+1), 6 )  .OR.       &
    969977                                 topo_no_distinct
    970                                  
     978
    971979                      unresolved_building = BTEST( wall_flags_total_0(k,j,i+1), 5 )  &
    972980                                     .AND.  BTEST( wall_flags_total_0(k,j,i+1), 6 )
    973                                  
     981
    974982                      IF (  land_surface  .AND.  terrain  .AND.                &
    975983                           .NOT. unresolved_building )  THEN
    976                          num_lsm_v(3) = num_lsm_v(3) + 1 
     984                         num_lsm_v(3) = num_lsm_v(3) + 1
    977985                      ELSEIF ( urban_surface  .AND.  building )  THEN
    978                          num_usm_v(3) = num_usm_v(3) + 1 
     986                         num_usm_v(3) = num_usm_v(3) + 1
    979987!
    980988!--                   Default-surface type
    981989                      ELSEIF ( .NOT. land_surface    .AND.                     &
    982990                               .NOT. urban_surface )  THEN
    983                          num_def_v(3) = num_def_v(3) + 1 
     991                         num_def_v(3) = num_def_v(3) + 1
    984992!
    985993!--                   Unclassifified surface-grid point. Give error message.
    986                       ELSE 
     994                      ELSE
    987995                         WRITE( message_string, * )                            &
    988996                                          'Unclassified westward-facing ' //   &
     
    10101018!
    10111019!--    Horizontal surface, natural type, so far only upward-facing
    1012        surf_lsm_h%ns    = num_lsm_h 
     1020       surf_lsm_h%ns    = num_lsm_h
    10131021!
    10141022!--    Horizontal surface, urban type, so far only upward-facing
    1015        surf_usm_h%ns    = num_usm_h   
     1023       surf_usm_h%ns    = num_usm_h
    10161024!
    10171025!--    Vertical surface, default type, northward facing
     
    10511059       surf_usm_v(3)%ns = num_usm_v(3)
    10521060!
    1053 !--    Allocate required attributes for horizontal surfaces - default type. 
     1061!--    Allocate required attributes for horizontal surfaces - default type.
    10541062!--    Upward-facing (l=0) and downward-facing (l=1).
    10551063       DO  l = 0, 1
     
    10601068       CALL allocate_surface_attributes_h_top ( surf_def_h(2), nys, nyn, nxl, nxr )
    10611069!
    1062 !--    Allocate required attributes for horizontal surfaces - natural type. 
     1070!--    Allocate required attributes for horizontal surfaces - natural type.
    10631071       CALL allocate_surface_attributes_h ( surf_lsm_h, nys, nyn, nxl, nxr )
    10641072!
    1065 !--    Allocate required attributes for horizontal surfaces - urban type. 
     1073!--    Allocate required attributes for horizontal surfaces - urban type.
    10661074       CALL allocate_surface_attributes_h ( surf_usm_h, nys, nyn, nxl, nxr )
    10671075
    10681076!
    1069 !--    Allocate required attributes for vertical surfaces. 
     1077!--    Allocate required attributes for vertical surfaces.
    10701078!--    Northward-facing (l=0), southward-facing (l=1), eastward-facing (l=2)
    10711079!--    and westward-facing (l=3).
     
    11011109#endif
    11021110       IF ( num_surf_v > 0 )  vertical_surfaces_exist = .TRUE.
    1103        
     1111
    11041112
    11051113    END SUBROUTINE init_surface_arrays
     
    11171125
    11181126       INTEGER(iwp) ::  l     !<
    1119        
     1127
    11201128       !$ACC ENTER DATA &
    11211129       !$ACC COPYIN(surf_def_h(0:2)) &
     
    11621170
    11631171       INTEGER(iwp) ::  l     !<
    1164        
     1172
    11651173       ! Delete data in surf_def_h(0:2)
    11661174       DO  l = 0, 1
     
    11991207! Description:
    12001208! ------------
    1201 !> Deallocating memory for upward and downward-facing horizontal surface types, 
    1202 !> except for top fluxes. 
     1209!> Deallocating memory for upward and downward-facing horizontal surface types,
     1210!> except for top fluxes.
    12031211!------------------------------------------------------------------------------!
    12041212    SUBROUTINE deallocate_surface_attributes_h( surfaces )
     
    12421250!
    12431251!--    Vertical momentum fluxes of u and v
    1244        DEALLOCATE ( surfaces%usws ) 
    1245        DEALLOCATE ( surfaces%vsws ) 
     1252       DEALLOCATE ( surfaces%usws )
     1253       DEALLOCATE ( surfaces%vsws )
    12461254!
    12471255!--    Required in production_e
    1248        IF ( .NOT. constant_diffusion )  THEN   
    1249           DEALLOCATE ( surfaces%u_0 ) 
     1256       IF ( .NOT. constant_diffusion )  THEN
     1257          DEALLOCATE ( surfaces%u_0 )
    12501258          DEALLOCATE ( surfaces%v_0 )
    1251        ENDIF 
     1259       ENDIF
    12521260!
    12531261!--    Characteristic temperature and surface flux of sensible heat
    1254        DEALLOCATE ( surfaces%ts )   
     1262       DEALLOCATE ( surfaces%ts )
    12551263       DEALLOCATE ( surfaces%shf )
    12561264!
    12571265!--    surface temperature
    1258        DEALLOCATE ( surfaces%pt_surface ) 
     1266       DEALLOCATE ( surfaces%pt_surface )
    12591267!
    12601268!--    Characteristic humidity and surface flux of latent heat
    1261        IF ( humidity )  THEN         
    1262           DEALLOCATE ( surfaces%qs ) 
    1263           DEALLOCATE ( surfaces%qsws ) 
     1269       IF ( humidity )  THEN
     1270          DEALLOCATE ( surfaces%qs )
     1271          DEALLOCATE ( surfaces%qsws )
    12641272          DEALLOCATE ( surfaces%q_surface   )
    12651273          DEALLOCATE ( surfaces%vpt_surface )
    1266        ENDIF 
     1274       ENDIF
    12671275!
    12681276!--    Characteristic scalar and surface flux of scalar
    12691277       IF ( passive_scalar )  THEN
    1270           DEALLOCATE ( surfaces%ss )   
    1271           DEALLOCATE ( surfaces%ssws ) 
    1272        ENDIF 
     1278          DEALLOCATE ( surfaces%ss )
     1279          DEALLOCATE ( surfaces%ssws )
     1280       ENDIF
    12731281!
    12741282!--    Scaling parameter (cs*) and surface flux of chemical species
    12751283       IF ( air_chemistry )  THEN
    1276           DEALLOCATE ( surfaces%css )   
    1277           DEALLOCATE ( surfaces%cssws ) 
    1278        ENDIF 
     1284          DEALLOCATE ( surfaces%css )
     1285          DEALLOCATE ( surfaces%cssws )
     1286       ENDIF
    12791287!
    12801288!--    Arrays for storing potential temperature and
     
    12831291       DEALLOCATE ( surfaces%qv1 )
    12841292       DEALLOCATE ( surfaces%vpt1 )
    1285        
    1286 !
    1287 !--       
     1293
     1294!
     1295!--
    12881296       IF ( surf_bulk_cloud_model .AND. surf_microphysics_morrison)  THEN
    12891297          DEALLOCATE ( surfaces%qcs )
     
    12931301       ENDIF
    12941302!
    1295 !--       
     1303!--
    12961304       IF ( surf_bulk_cloud_model .AND. surf_microphysics_seifert)  THEN
    12971305          DEALLOCATE ( surfaces%qrs )
     
    13011309       ENDIF
    13021310!
     1311!--
     1312       IF ( surf_bulk_cloud_model .AND. surf_microphysics_ice_extension)  THEN
     1313          DEALLOCATE ( surfaces%qis )
     1314          DEALLOCATE ( surfaces%nis )
     1315          DEALLOCATE ( surfaces%qisws )
     1316          DEALLOCATE ( surfaces%nisws )
     1317       ENDIF
     1318!
    13031319!--    Salinity surface flux
    13041320       IF ( ocean_mode )  DEALLOCATE ( surfaces%sasws )
     
    13101326! Description:
    13111327! ------------
    1312 !> Allocating memory for upward and downward-facing horizontal surface types, 
    1313 !> except for top fluxes. 
     1328!> Allocating memory for upward and downward-facing horizontal surface types,
     1329!> except for top fluxes.
    13141330!------------------------------------------------------------------------------!
    13151331    SUBROUTINE allocate_surface_attributes_h( surfaces,                        &
     
    13261342
    13271343!
    1328 !--    Allocate arrays for start and end index of horizontal surface type 
     1344!--    Allocate arrays for start and end index of horizontal surface type
    13291345!--    for each (j,i)-grid point. This is required e.g. in diffion_x, which is
    1330 !--    called for each (j,i). In order to find the location where the 
    1331 !--    respective flux is store within the surface-type, start- and end- 
     1346!--    called for each (j,i). In order to find the location where the
     1347!--    respective flux is store within the surface-type, start- and end-
    13321348!--    index are stored for each (j,i). For example, each (j,i) can have
    13331349!--    several entries where fluxes for horizontal surfaces might be stored,
     
    13701386!
    13711387!--    Vertical momentum fluxes of u and v
    1372        ALLOCATE ( surfaces%usws(1:surfaces%ns) ) 
    1373        ALLOCATE ( surfaces%vsws(1:surfaces%ns) ) 
     1388       ALLOCATE ( surfaces%usws(1:surfaces%ns) )
     1389       ALLOCATE ( surfaces%vsws(1:surfaces%ns) )
    13741390!
    13751391!--    Required in production_e
    1376        IF ( .NOT. constant_diffusion )  THEN   
    1377           ALLOCATE ( surfaces%u_0(1:surfaces%ns) ) 
     1392       IF ( .NOT. constant_diffusion )  THEN
     1393          ALLOCATE ( surfaces%u_0(1:surfaces%ns) )
    13781394          ALLOCATE ( surfaces%v_0(1:surfaces%ns) )
    1379        ENDIF 
     1395       ENDIF
    13801396!
    13811397!--    Characteristic temperature and surface flux of sensible heat
    1382        ALLOCATE ( surfaces%ts(1:surfaces%ns)  )   
     1398       ALLOCATE ( surfaces%ts(1:surfaces%ns)  )
    13831399       ALLOCATE ( surfaces%shf(1:surfaces%ns) )
    13841400!
    13851401!--    Surface temperature
    1386        ALLOCATE ( surfaces%pt_surface(1:surfaces%ns) ) 
     1402       ALLOCATE ( surfaces%pt_surface(1:surfaces%ns) )
    13871403!
    13881404!--    Characteristic humidity, surface flux of latent heat, and surface virtual potential temperature
    13891405       IF ( humidity )  THEN
    1390           ALLOCATE ( surfaces%qs(1:surfaces%ns)   ) 
    1391           ALLOCATE ( surfaces%qsws(1:surfaces%ns) )     
    1392           ALLOCATE ( surfaces%q_surface(1:surfaces%ns)   ) 
    1393           ALLOCATE ( surfaces%vpt_surface(1:surfaces%ns) ) 
    1394        ENDIF 
     1406          ALLOCATE ( surfaces%qs(1:surfaces%ns)   )
     1407          ALLOCATE ( surfaces%qsws(1:surfaces%ns) )
     1408          ALLOCATE ( surfaces%q_surface(1:surfaces%ns)   )
     1409          ALLOCATE ( surfaces%vpt_surface(1:surfaces%ns) )
     1410       ENDIF
    13951411
    13961412!
    13971413!--    Characteristic scalar and surface flux of scalar
    13981414       IF ( passive_scalar )  THEN
    1399           ALLOCATE ( surfaces%ss(1:surfaces%ns)   )   
    1400           ALLOCATE ( surfaces%ssws(1:surfaces%ns) ) 
    1401        ENDIF 
     1415          ALLOCATE ( surfaces%ss(1:surfaces%ns)   )
     1416          ALLOCATE ( surfaces%ssws(1:surfaces%ns) )
     1417       ENDIF
    14021418!
    14031419!--    Scaling parameter (cs*) and surface flux of chemical species
    14041420       IF ( air_chemistry )  THEN
    1405           ALLOCATE ( surfaces%css(1:nvar,1:surfaces%ns)   )   
    1406           ALLOCATE ( surfaces%cssws(1:nvar,1:surfaces%ns) ) 
    1407        ENDIF 
     1421          ALLOCATE ( surfaces%css(1:nvar,1:surfaces%ns)   )
     1422          ALLOCATE ( surfaces%cssws(1:nvar,1:surfaces%ns) )
     1423       ENDIF
    14081424!
    14091425!--    Arrays for storing potential temperature and
     
    14131429       ALLOCATE ( surfaces%vpt1(1:surfaces%ns) )
    14141430!
    1415 !--       
     1431!--
    14161432       IF ( surf_bulk_cloud_model .AND. surf_microphysics_morrison)  THEN
    14171433          ALLOCATE ( surfaces%qcs(1:surfaces%ns)   )
     
    14211437       ENDIF
    14221438!
    1423 !--       
     1439!--
    14241440       IF ( surf_bulk_cloud_model .AND. surf_microphysics_seifert)  THEN
    14251441          ALLOCATE ( surfaces%qrs(1:surfaces%ns)   )
     
    14281444          ALLOCATE ( surfaces%nrsws(1:surfaces%ns) )
    14291445       ENDIF
     1446
     1447!
     1448!--
     1449       IF ( surf_bulk_cloud_model .AND. surf_microphysics_ice_extension)  THEN
     1450          ALLOCATE ( surfaces%qis(1:surfaces%ns)   )
     1451          ALLOCATE ( surfaces%nis(1:surfaces%ns)   )
     1452          ALLOCATE ( surfaces%qisws(1:surfaces%ns) )
     1453          ALLOCATE ( surfaces%nisws(1:surfaces%ns) )
     1454       ENDIF
     1455
    14301456!
    14311457!--    Salinity surface flux
     
    14451471
    14461472       IMPLICIT NONE
    1447    
     1473
    14481474       TYPE(surf_type) ::  surfaces  !< respective surface type
    1449    
     1475
    14501476       !$ACC EXIT DATA &
    14511477       !$ACC DELETE(surfaces%start_index(nys:nyn,nxl:nxr)) &
     
    14731499          !$ACC DELETE(surfaces%v_0(1:surfaces%ns))
    14741500       ENDIF
    1475    
     1501
    14761502    END SUBROUTINE exit_surface_attributes_h
    14771503#endif
     
    15221548! Description:
    15231549! ------------
    1524 !> Deallocating memory for model-top fluxes 
     1550!> Deallocating memory for model-top fluxes
    15251551!------------------------------------------------------------------------------!
    15261552    SUBROUTINE deallocate_surface_attributes_h_top( surfaces )
     
    15391565       DEALLOCATE ( surfaces%k )
    15401566
    1541        IF ( .NOT. constant_diffusion )  THEN   
    1542           DEALLOCATE ( surfaces%u_0 ) 
     1567       IF ( .NOT. constant_diffusion )  THEN
     1568          DEALLOCATE ( surfaces%u_0 )
    15431569          DEALLOCATE ( surfaces%v_0 )
    1544        ENDIF 
     1570       ENDIF
    15451571!
    15461572!--    Vertical momentum fluxes of u and v
    1547        DEALLOCATE ( surfaces%usws ) 
    1548        DEALLOCATE ( surfaces%vsws ) 
     1573       DEALLOCATE ( surfaces%usws )
     1574       DEALLOCATE ( surfaces%vsws )
    15491575!
    15501576!--    Sensible heat flux
     
    15531579!--    Latent heat flux
    15541580       IF ( humidity .OR. coupling_mode == 'ocean_to_atmosphere')  THEN
    1555           DEALLOCATE ( surfaces%qsws )     
    1556        ENDIF 
     1581          DEALLOCATE ( surfaces%qsws )
     1582       ENDIF
    15571583!
    15581584!--    Scalar flux
    15591585       IF ( passive_scalar )  THEN
    1560           DEALLOCATE ( surfaces%ssws ) 
    1561        ENDIF 
     1586          DEALLOCATE ( surfaces%ssws )
     1587       ENDIF
    15621588!
    15631589!--    Chemical species flux
    15641590       IF ( air_chemistry )  THEN
    1565           DEALLOCATE ( surfaces%cssws ) 
    1566        ENDIF 
    1567 !
    1568 !--       
     1591          DEALLOCATE ( surfaces%cssws )
     1592       ENDIF
     1593!
     1594!--
    15691595       IF ( surf_bulk_cloud_model .AND. surf_microphysics_morrison)  THEN
    15701596          DEALLOCATE ( surfaces%qcsws )
     
    15721598       ENDIF
    15731599!
    1574 !--       
     1600!--
    15751601       IF ( surf_bulk_cloud_model .AND. surf_microphysics_seifert)  THEN
    15761602          DEALLOCATE ( surfaces%qrsws )
    15771603          DEALLOCATE ( surfaces%nrsws )
    15781604       ENDIF
     1605
     1606!
     1607!--
     1608       IF ( surf_bulk_cloud_model .AND. surf_microphysics_ice_extension)  THEN
     1609          DEALLOCATE ( surfaces%qisws )
     1610          DEALLOCATE ( surfaces%nisws )
     1611       ENDIF
    15791612!
    15801613!--    Salinity flux
     
    15871620! Description:
    15881621! ------------
    1589 !> Allocating memory for model-top fluxes 
     1622!> Allocating memory for model-top fluxes
    15901623!------------------------------------------------------------------------------!
    15911624    SUBROUTINE allocate_surface_attributes_h_top( surfaces,                    &
     
    16111644       ALLOCATE ( surfaces%k(1:surfaces%ns)  )
    16121645
    1613        IF ( .NOT. constant_diffusion )  THEN   
    1614           ALLOCATE ( surfaces%u_0(1:surfaces%ns) ) 
     1646       IF ( .NOT. constant_diffusion )  THEN
     1647          ALLOCATE ( surfaces%u_0(1:surfaces%ns) )
    16151648          ALLOCATE ( surfaces%v_0(1:surfaces%ns) )
    1616        ENDIF 
     1649       ENDIF
    16171650!
    16181651!--    Vertical momentum fluxes of u and v
    1619        ALLOCATE ( surfaces%usws(1:surfaces%ns) ) 
    1620        ALLOCATE ( surfaces%vsws(1:surfaces%ns) ) 
     1652       ALLOCATE ( surfaces%usws(1:surfaces%ns) )
     1653       ALLOCATE ( surfaces%vsws(1:surfaces%ns) )
    16211654!
    16221655!--    Sensible heat flux
     
    16251658!--    Latent heat flux
    16261659       IF ( humidity .OR. coupling_mode == 'ocean_to_atmosphere')  THEN
    1627           ALLOCATE ( surfaces%qsws(1:surfaces%ns) )     
    1628        ENDIF 
     1660          ALLOCATE ( surfaces%qsws(1:surfaces%ns) )
     1661       ENDIF
    16291662!
    16301663!--    Scalar flux
    16311664       IF ( passive_scalar )  THEN
    1632           ALLOCATE ( surfaces%ssws(1:surfaces%ns) ) 
    1633        ENDIF 
     1665          ALLOCATE ( surfaces%ssws(1:surfaces%ns) )
     1666       ENDIF
    16341667!
    16351668!--    Chemical species flux
    16361669       IF ( air_chemistry )  THEN
    1637           ALLOCATE ( surfaces%cssws(1:nvar,1:surfaces%ns) ) 
    1638        ENDIF 
    1639 !
    1640 !--       
     1670          ALLOCATE ( surfaces%cssws(1:nvar,1:surfaces%ns) )
     1671       ENDIF
     1672!
     1673!--
    16411674       IF ( surf_bulk_cloud_model .AND. surf_microphysics_morrison)  THEN
    16421675          ALLOCATE ( surfaces%qcsws(1:surfaces%ns) )
     
    16441677       ENDIF
    16451678!
    1646 !--       
     1679!--
    16471680       IF ( surf_bulk_cloud_model .AND. surf_microphysics_seifert)  THEN
    16481681          ALLOCATE ( surfaces%qrsws(1:surfaces%ns) )
    16491682          ALLOCATE ( surfaces%nrsws(1:surfaces%ns) )
     1683       ENDIF
     1684
     1685!
     1686!--
     1687       IF ( surf_bulk_cloud_model .AND. surf_microphysics_ice_extension)  THEN
     1688          ALLOCATE ( surfaces%qisws(1:surfaces%ns) )
     1689          ALLOCATE ( surfaces%nisws(1:surfaces%ns) )
    16501690       ENDIF
    16511691!
     
    16651705
    16661706       IMPLICIT NONE
    1667    
     1707
    16681708       TYPE(surf_type) ::  surfaces  !< respective surface type
    1669    
     1709
    16701710       !$ACC EXIT DATA &
    16711711       !$ACC DELETE(surfaces%start_index(nys:nyn,nxl:nxr)) &
     
    16831723          !$ACC DELETE(surfaces%v_0(1:surfaces%ns))
    16841724       ENDIF
    1685    
     1725
    16861726    END SUBROUTINE exit_surface_attributes_h_top
    16871727#endif
     
    17211761! Description:
    17221762! ------------
    1723 !> Deallocating memory for vertical surface types. 
     1763!> Deallocating memory for vertical surface types.
    17241764!------------------------------------------------------------------------------!
    17251765    SUBROUTINE deallocate_surface_attributes_v( surfaces )
     
    17311771
    17321772!
    1733 !--    Allocate arrays for start and end index of vertical surface type 
     1773!--    Allocate arrays for start and end index of vertical surface type
    17341774!--    for each (j,i)-grid point. This is required in diffion_x, which is
    1735 !--    called for each (j,i). In order to find the location where the 
    1736 !--    respective flux is store within the surface-type, start- and end- 
     1775!--    called for each (j,i). In order to find the location where the
     1776!--    respective flux is store within the surface-type, start- and end-
    17371777!--    index are stored for each (j,i). For example, each (j,i) can have
    1738 !--    several entries where fluxes for vertical surfaces might be stored. 
    1739 !--    In the flat case, where no vertical walls exit, set indicies such 
    1740 !--    that loop in diffusion routines will not be entered. 
     1778!--    several entries where fluxes for vertical surfaces might be stored.
     1779!--    In the flat case, where no vertical walls exit, set indicies such
     1780!--    that loop in diffusion routines will not be entered.
    17411781       DEALLOCATE ( surfaces%start_index )
    17421782       DEALLOCATE ( surfaces%end_index )
     
    17661806!
    17671807!--    Allocate Obukhov length and bulk Richardson number. Actually, at
    1768 !--    vertical surfaces these are only required for natural surfaces. 
     1808!--    vertical surfaces these are only required for natural surfaces.
    17691809!--    for natural land surfaces
    1770        DEALLOCATE( surfaces%ol ) 
    1771        DEALLOCATE( surfaces%rib ) 
    1772 !
    1773 !--    Allocate arrays for surface momentum fluxes for u and v. For u at north- 
     1810       DEALLOCATE( surfaces%ol )
     1811       DEALLOCATE( surfaces%rib )
     1812!
     1813!--    Allocate arrays for surface momentum fluxes for u and v. For u at north-
    17741814!--    and south-facing surfaces, for v at east- and west-facing surfaces.
    17751815       DEALLOCATE ( surfaces%mom_flux_uv )
    17761816!
    17771817!--    Allocate array for surface momentum flux for w - wsus and wsvs
    1778        DEALLOCATE ( surfaces%mom_flux_w ) 
    1779 !
    1780 !--    Allocate array for surface momentum flux for subgrid-scale tke wsus and 
     1818       DEALLOCATE ( surfaces%mom_flux_w )
     1819!
     1820!--    Allocate array for surface momentum flux for subgrid-scale tke wsus and
    17811821!--    wsvs; first index usvs or vsws, second index for wsus or wsvs, depending
    17821822!--    on surface.
    1783        DEALLOCATE ( surfaces%mom_flux_tke ) 
     1823       DEALLOCATE ( surfaces%mom_flux_tke )
    17841824!
    17851825!--    Characteristic temperature and surface flux of sensible heat
    1786        DEALLOCATE ( surfaces%ts )   
     1826       DEALLOCATE ( surfaces%ts )
    17871827       DEALLOCATE ( surfaces%shf )
    17881828!
    17891829!--    surface temperature
    1790        DEALLOCATE ( surfaces%pt_surface ) 
     1830       DEALLOCATE ( surfaces%pt_surface )
    17911831!
    17921832!--    Characteristic humidity and surface flux of latent heat
    17931833       IF ( humidity )  THEN
    1794           DEALLOCATE ( surfaces%qs ) 
    1795           DEALLOCATE ( surfaces%qsws ) 
     1834          DEALLOCATE ( surfaces%qs )
     1835          DEALLOCATE ( surfaces%qsws )
    17961836          DEALLOCATE ( surfaces%q_surface   )
    17971837          DEALLOCATE ( surfaces%vpt_surface )
    1798        ENDIF 
     1838       ENDIF
    17991839!
    18001840!--    Characteristic scalar and surface flux of scalar
    18011841       IF ( passive_scalar )  THEN
    1802           DEALLOCATE ( surfaces%ss )   
    1803           DEALLOCATE ( surfaces%ssws ) 
     1842          DEALLOCATE ( surfaces%ss )
     1843          DEALLOCATE ( surfaces%ssws )
    18041844       ENDIF
    18051845!
    18061846!--    Scaling parameter (cs*) and surface flux of chemical species
    18071847       IF ( air_chemistry )  THEN
    1808              DEALLOCATE ( surfaces%css )   
    1809              DEALLOCATE ( surfaces%cssws ) 
    1810        ENDIF 
     1848             DEALLOCATE ( surfaces%css )
     1849             DEALLOCATE ( surfaces%cssws )
     1850       ENDIF
    18111851!
    18121852!--    Arrays for storing potential temperature and
     
    18291869          DEALLOCATE ( surfaces%nrsws )
    18301870       ENDIF
     1871
     1872       IF ( surf_bulk_cloud_model .AND. surf_microphysics_ice_extension)  THEN
     1873          DEALLOCATE ( surfaces%qis )
     1874          DEALLOCATE ( surfaces%nis )
     1875          DEALLOCATE ( surfaces%qisws )
     1876          DEALLOCATE ( surfaces%nisws )
     1877       ENDIF
     1878
    18311879!
    18321880!--    Salinity surface flux
     
    18391887! Description:
    18401888! ------------
    1841 !> Allocating memory for vertical surface types. 
     1889!> Allocating memory for vertical surface types.
    18421890!------------------------------------------------------------------------------!
    18431891    SUBROUTINE allocate_surface_attributes_v( surfaces,                        &
     
    18541902
    18551903!
    1856 !--    Allocate arrays for start and end index of vertical surface type 
     1904!--    Allocate arrays for start and end index of vertical surface type
    18571905!--    for each (j,i)-grid point. This is required in diffion_x, which is
    1858 !--    called for each (j,i). In order to find the location where the 
    1859 !--    respective flux is store within the surface-type, start- and end- 
     1906!--    called for each (j,i). In order to find the location where the
     1907!--    respective flux is store within the surface-type, start- and end-
    18601908!--    index are stored for each (j,i). For example, each (j,i) can have
    1861 !--    several entries where fluxes for vertical surfaces might be stored. 
    1862 !--    In the flat case, where no vertical walls exit, set indicies such 
    1863 !--    that loop in diffusion routines will not be entered. 
     1909!--    several entries where fluxes for vertical surfaces might be stored.
     1910!--    In the flat case, where no vertical walls exit, set indicies such
     1911!--    that loop in diffusion routines will not be entered.
    18641912       ALLOCATE ( surfaces%start_index(nys_l:nyn_l,nxl_l:nxr_l) )
    18651913       ALLOCATE ( surfaces%end_index(nys_l:nyn_l,nxl_l:nxr_l)   )
     
    18911939!
    18921940!--    Allocate Obukhov length and bulk Richardson number. Actually, at
    1893 !--    vertical surfaces these are only required for natural surfaces. 
     1941!--    vertical surfaces these are only required for natural surfaces.
    18941942!--    for natural land surfaces
    1895        ALLOCATE( surfaces%ol(1:surfaces%ns)  ) 
    1896        ALLOCATE( surfaces%rib(1:surfaces%ns) ) 
    1897 !
    1898 !--    Allocate arrays for surface momentum fluxes for u and v. For u at north- 
     1943       ALLOCATE( surfaces%ol(1:surfaces%ns)  )
     1944       ALLOCATE( surfaces%rib(1:surfaces%ns) )
     1945!
     1946!--    Allocate arrays for surface momentum fluxes for u and v. For u at north-
    18991947!--    and south-facing surfaces, for v at east- and west-facing surfaces.
    19001948       ALLOCATE ( surfaces%mom_flux_uv(1:surfaces%ns) )
    19011949!
    19021950!--    Allocate array for surface momentum flux for w - wsus and wsvs
    1903        ALLOCATE ( surfaces%mom_flux_w(1:surfaces%ns) ) 
    1904 !
    1905 !--    Allocate array for surface momentum flux for subgrid-scale tke wsus and 
     1951       ALLOCATE ( surfaces%mom_flux_w(1:surfaces%ns) )
     1952!
     1953!--    Allocate array for surface momentum flux for subgrid-scale tke wsus and
    19061954!--    wsvs; first index usvs or vsws, second index for wsus or wsvs, depending
    19071955!--    on surface.
    1908        ALLOCATE ( surfaces%mom_flux_tke(0:1,1:surfaces%ns) ) 
     1956       ALLOCATE ( surfaces%mom_flux_tke(0:1,1:surfaces%ns) )
    19091957!
    19101958!--    Characteristic temperature and surface flux of sensible heat
    1911        ALLOCATE ( surfaces%ts(1:surfaces%ns)  )   
     1959       ALLOCATE ( surfaces%ts(1:surfaces%ns)  )
    19121960       ALLOCATE ( surfaces%shf(1:surfaces%ns) )
    19131961!
    19141962!--    surface temperature
    1915        ALLOCATE ( surfaces%pt_surface(1:surfaces%ns) ) 
     1963       ALLOCATE ( surfaces%pt_surface(1:surfaces%ns) )
    19161964!
    19171965!--    Characteristic humidity and surface flux of latent heat
    19181966       IF ( humidity )  THEN
    1919           ALLOCATE ( surfaces%qs(1:surfaces%ns)          ) 
    1920           ALLOCATE ( surfaces%qsws(1:surfaces%ns)        )   
     1967          ALLOCATE ( surfaces%qs(1:surfaces%ns)          )
     1968          ALLOCATE ( surfaces%qsws(1:surfaces%ns)        )
    19211969          ALLOCATE ( surfaces%q_surface(1:surfaces%ns)   )
    1922           ALLOCATE ( surfaces%vpt_surface(1:surfaces%ns) )           
    1923        ENDIF 
     1970          ALLOCATE ( surfaces%vpt_surface(1:surfaces%ns) )
     1971       ENDIF
    19241972!
    19251973!--    Characteristic scalar and surface flux of scalar
    19261974       IF ( passive_scalar )  THEN
    1927           ALLOCATE ( surfaces%ss(1:surfaces%ns)   )   
    1928           ALLOCATE ( surfaces%ssws(1:surfaces%ns) ) 
     1975          ALLOCATE ( surfaces%ss(1:surfaces%ns)   )
     1976          ALLOCATE ( surfaces%ssws(1:surfaces%ns) )
    19291977       ENDIF
    19301978!
    19311979!--    Scaling parameter (cs*) and surface flux of chemical species
    19321980       IF ( air_chemistry )  THEN
    1933              ALLOCATE ( surfaces%css(1:nvar,1:surfaces%ns)   )   
    1934              ALLOCATE ( surfaces%cssws(1:nvar,1:surfaces%ns) ) 
    1935        ENDIF 
     1981             ALLOCATE ( surfaces%css(1:nvar,1:surfaces%ns)   )
     1982             ALLOCATE ( surfaces%cssws(1:nvar,1:surfaces%ns) )
     1983       ENDIF
    19361984!
    19371985!--    Arrays for storing potential temperature and
     
    19542002          ALLOCATE ( surfaces%nrsws(1:surfaces%ns) )
    19552003       ENDIF
     2004
     2005       IF ( surf_bulk_cloud_model .AND. surf_microphysics_ice_extension)  THEN
     2006          ALLOCATE ( surfaces%qis(1:surfaces%ns)   )
     2007          ALLOCATE ( surfaces%nis(1:surfaces%ns)   )
     2008          ALLOCATE ( surfaces%qisws(1:surfaces%ns) )
     2009          ALLOCATE ( surfaces%nisws(1:surfaces%ns) )
     2010       ENDIF
    19562011!
    19572012!--    Salinity surface flux
     
    19642019! Description:
    19652020! ------------
    1966 !> Exit memory for vertical surface types. 
     2021!> Exit memory for vertical surface types.
    19672022!------------------------------------------------------------------------------!
    19682023#if defined( _OPENACC )
     
    19962051! Description:
    19972052! ------------
    1998 !> Enter memory for vertical surface types. 
     2053!> Enter memory for vertical surface types.
    19992054!------------------------------------------------------------------------------!
    20002055#if defined( _OPENACC )
    20012056    SUBROUTINE enter_surface_attributes_v( surfaces )
    2002    
     2057
    20032058       IMPLICIT NONE
    2004    
     2059
    20052060       TYPE(surf_type) ::  surfaces  !< respective surface type
    2006    
     2061
    20072062       !$ACC ENTER DATA &
    20082063       !$ACC COPYIN(surfaces%start_index(nys:nyn,nxl:nxr)) &
     
    20212076       !$ACC COPYIN(surfaces%pt1(1:surfaces%ns)) &
    20222077       !$ACC COPYIN(surfaces%qv1(1:surfaces%ns))
    2023    
     2078
    20242079    END SUBROUTINE enter_surface_attributes_v
    20252080#endif
     
    20282083! Description:
    20292084! ------------
    2030 !> Initialize surface elements, i.e. set initial values for surface fluxes, 
    2031 !> friction velocity, calcuation of start/end indices, etc. . 
    2032 !> Please note, further initialization concerning 
    2033 !> special surface characteristics, e.g. soil- and vegatation type, 
    2034 !> building type, etc., is done in the land-surface and urban-surface module, 
    2035 !> respectively. 
     2085!> Initialize surface elements, i.e. set initial values for surface fluxes,
     2086!> friction velocity, calcuation of start/end indices, etc. .
     2087!> Please note, further initialization concerning
     2088!> special surface characteristics, e.g. soil- and vegatation type,
     2089!> building type, etc., is done in the land-surface and urban-surface module,
     2090!> respectively.
    20362091!------------------------------------------------------------------------------!
    20372092    SUBROUTINE init_surfaces
     
    20542109       INTEGER(iwp), DIMENSION(0:2) ::  num_def_h_kji !< dummy to determing local end index in surface type for given (j,i), for horizonal default surfaces
    20552110       INTEGER(iwp), DIMENSION(0:2) ::  start_index_def_h !< dummy to determing local start index in surface type for given (j,i), for horizontal default surfaces
    2056      
     2111
    20572112       INTEGER(iwp), DIMENSION(0:3) ::  num_def_v     !< current number of vertical surface element, default type
    20582113       INTEGER(iwp), DIMENSION(0:3) ::  num_def_v_kji !< dummy to determing local end index in surface type for given (j,i), for vertical default surfaces
     
    20682123       LOGICAL ::  building            !< flag indicating building grid point
    20692124       LOGICAL ::  terrain             !< flag indicating natural terrain grid point
    2070        LOGICAL ::  unresolved_building !< flag indicating a grid point where actually a building is defined but not resolved by the vertical grid 
    2071 !
    2072 !--    Set offset indices, i.e. index difference between surface element and 
     2125       LOGICAL ::  unresolved_building !< flag indicating a grid point where actually a building is defined but not resolved by the vertical grid
     2126!
     2127!--    Set offset indices, i.e. index difference between surface element and
    20732128!--    surface-bounded grid point.
    20742129!--    Upward facing - no horizontal offsets
     
    21272182
    21282183!
    2129 !--    Initialize surface attributes, store indicies, surfaces orientation, etc., 
     2184!--    Initialize surface attributes, store indicies, surfaces orientation, etc.,
    21302185       num_def_h(0:2) = 1
    21312186       num_def_v(0:3) = 1
     
    21622217!
    21632218!--                Upward-facing surface. Distinguish between differet surface types.
    2164 !--                To do, think about method to flag natural and non-natural 
    2165 !--                surfaces. 
    2166                    IF ( .NOT. BTEST( wall_flags_total_0(k-1,j,i), 0 ) )  THEN 
     2219!--                To do, think about method to flag natural and non-natural
     2220!--                surfaces.
     2221                   IF ( .NOT. BTEST( wall_flags_total_0(k-1,j,i), 0 ) )  THEN
    21672222!
    21682223!--                   Determine flags indicating terrain or building
     
    21712226                      building = BTEST( wall_flags_total_0(k-1,j,i), 6 )  .OR.       &
    21722227                                 topo_no_distinct
    2173                                  
    2174 !
    2175 !--                   unresolved_building indicates a surface with equal height 
     2228
     2229!
     2230!--                   unresolved_building indicates a surface with equal height
    21762231!--                   as terrain but with a non-grid resolved building on top.
    21772232!--                   These surfaces will be flagged as urban surfaces.
     
    21792234                                     .AND.  BTEST( wall_flags_total_0(k-1,j,i), 6 )
    21802235!
    2181 !--                   Natural surface type         
     2236!--                   Natural surface type
    21822237                      IF ( land_surface  .AND.  terrain  .AND.                 &
    21832238                           .NOT. unresolved_building )  THEN
     
    21862241                                                              num_lsm_h,       &
    21872242                                                              num_lsm_h_kji,   &
    2188                                                               .TRUE., .FALSE. ) 
     2243                                                              .TRUE., .FALSE. )
    21892244!
    21902245!--                   Urban surface tpye
     
    21942249                                                              num_usm_h,       &
    21952250                                                              num_usm_h_kji,   &
    2196                                                               .TRUE., .FALSE. ) 
     2251                                                              .TRUE., .FALSE. )
    21972252!
    21982253!--                   Default surface type
     
    22022257                                                              num_def_h(0),    &
    22032258                                                              num_def_h_kji(0),&
    2204                                                               .TRUE., .FALSE. ) 
     2259                                                              .TRUE., .FALSE. )
    22052260                      ENDIF
    2206                    ENDIF 
    2207 !
    2208 !--                downward-facing surface, first, model top. Please note, 
    2209 !--                for the moment, downward-facing surfaces are always of 
     2261                   ENDIF
     2262!
     2263!--                downward-facing surface, first, model top. Please note,
     2264!--                for the moment, downward-facing surfaces are always of
    22102265!--                default type
    22112266                   IF ( k == nzt  .AND.  use_top_fluxes )  THEN
     
    22132268                                           num_def_h(2), num_def_h_kji(2) )
    22142269!
    2215 !--                Check for any other downward-facing surface. So far only for 
     2270!--                Check for any other downward-facing surface. So far only for
    22162271!--                default surface type.
    22172272                   ELSEIF ( .NOT. BTEST( wall_flags_total_0(k+1,j,i), 0 ) )  THEN
     
    22202275                                                           num_def_h(1),       &
    22212276                                                           num_def_h_kji(1),   &
    2222                                                            .FALSE., .TRUE. )   
    2223                    ENDIF 
     2277                                                           .FALSE., .TRUE. )
     2278                   ENDIF
    22242279!
    22252280!--                Check for vertical walls and, if required, initialize it.
     
    22352290                      unresolved_building = BTEST( wall_flags_total_0(k,j-1,i), 5 )  &
    22362291                                     .AND.  BTEST( wall_flags_total_0(k,j-1,i), 6 )
    2237                                      
     2292
    22382293                      IF ( land_surface  .AND.  terrain  .AND.                 &
    22392294                           .NOT. unresolved_building )  THEN
     
    22422297                                                            num_lsm_v(0),      &
    22432298                                                            num_lsm_v_kji(0),  &
    2244                                                             .FALSE., .FALSE.,  &             
     2299                                                            .FALSE., .FALSE.,  &
    22452300                                                            .FALSE., .TRUE. )
    22462301                      ELSEIF ( urban_surface  .AND.  building )  THEN
     
    22492304                                                            num_usm_v(0),      &
    22502305                                                            num_usm_v_kji(0),  &
    2251                                                             .FALSE., .FALSE.,  &             
     2306                                                            .FALSE., .FALSE.,  &
    22522307                                                            .FALSE., .TRUE. )
    22532308                      ELSE
     
    22562311                                                            num_def_v(0),      &
    22572312                                                            num_def_v_kji(0),  &
    2258                                                             .FALSE., .FALSE.,  &             
    2259                                                             .FALSE., .TRUE. ) 
     2313                                                            .FALSE., .FALSE.,  &
     2314                                                            .FALSE., .TRUE. )
    22602315                      ENDIF
    22612316                   ENDIF
     
    22692324                      building = BTEST( wall_flags_total_0(k,j+1,i), 6 )  .OR.       &
    22702325                                 topo_no_distinct
    2271                                  
     2326
    22722327                      unresolved_building = BTEST( wall_flags_total_0(k,j+1,i), 5 )  &
    22732328                                     .AND.  BTEST( wall_flags_total_0(k,j+1,i), 6 )
    2274                                      
     2329
    22752330                      IF ( land_surface  .AND.  terrain  .AND.                 &
    22762331                           .NOT. unresolved_building )  THEN
     
    22942349                                                            num_def_v_kji(1),  &
    22952350                                                            .FALSE., .FALSE.,  &
    2296                                                             .TRUE., .FALSE. ) 
     2351                                                            .TRUE., .FALSE. )
    22972352                      ENDIF
    22982353                   ENDIF
     
    23062361                      building = BTEST( wall_flags_total_0(k,j,i-1), 6 )  .OR.       &
    23072362                                 topo_no_distinct
    2308                                  
     2363
    23092364                      unresolved_building = BTEST( wall_flags_total_0(k,j,i-1), 5 )  &
    23102365                                     .AND.  BTEST( wall_flags_total_0(k,j,i-1), 6 )
    2311                                  
     2366
    23122367                      IF ( land_surface  .AND.  terrain  .AND.                 &
    23132368                           .NOT. unresolved_building )  THEN
     
    23312386                                                            num_def_v_kji(2),  &
    23322387                                                            .TRUE., .FALSE.,   &
    2333                                                             .FALSE., .FALSE. ) 
     2388                                                            .FALSE., .FALSE. )
    23342389                      ENDIF
    2335                    ENDIF 
    2336 !   
     2390                   ENDIF
     2391!
    23372392!--                westward-facing surface
    23382393                   IF ( .NOT. BTEST( wall_flags_total_0(k,j,i+1), 0 ) )  THEN
     
    23432398                      building = BTEST( wall_flags_total_0(k,j,i+1), 6 )  .OR.       &
    23442399                                 topo_no_distinct
    2345                                  
     2400
    23462401                      unresolved_building = BTEST( wall_flags_total_0(k,j,i+1), 5 )  &
    23472402                                     .AND.  BTEST( wall_flags_total_0(k,j,i+1), 6 )
    2348                                  
     2403
    23492404                      IF ( land_surface  .AND.  terrain  .AND.                 &
    23502405                           .NOT. unresolved_building )  THEN
     
    23682423                                                            num_def_v_kji(3),  &
    23692424                                                           .FALSE., .TRUE.,    &
    2370                                                            .FALSE., .FALSE. ) 
     2425                                                           .FALSE., .FALSE. )
    23712426                      ENDIF
    23722427                   ENDIF
    23732428                ENDIF
    23742429
    2375  
     2430
    23762431             ENDDO
    23772432!
    2378 !--          Determine start- and end-index at grid point (j,i). Also, for 
    2379 !--          horizontal surfaces more than 1 horizontal surface element can 
     2433!--          Determine start- and end-index at grid point (j,i). Also, for
     2434!--          horizontal surfaces more than 1 horizontal surface element can
    23802435!--          exist at grid point (j,i) if overhanging structures are present.
    23812436!--          Upward-facing surfaces
     
    23932448!
    23942449!--          Downward-facing surfaces, except model top
    2395              surf_def_h(1)%start_index(j,i) = start_index_def_h(1)                                                 
     2450             surf_def_h(1)%start_index(j,i) = start_index_def_h(1)
    23962451             surf_def_h(1)%end_index(j,i)   = surf_def_h(1)%start_index(j,i) + &
    23972452                                                 num_def_h_kji(1) - 1
     
    23992454!
    24002455!--          Downward-facing surfaces -- model top fluxes
    2401              surf_def_h(2)%start_index(j,i) = start_index_def_h(2)                                                 
     2456             surf_def_h(2)%start_index(j,i) = start_index_def_h(2)
    24022457             surf_def_h(2)%end_index(j,i)   = surf_def_h(2)%start_index(j,i) + &
    24032458                                                 num_def_h_kji(2) - 1
     
    24222477             surf_def_v(2)%start_index(j,i) = start_index_def_v(2)
    24232478             surf_def_v(3)%start_index(j,i) = start_index_def_v(3)
    2424              surf_def_v(0)%end_index(j,i)   = start_index_def_v(0) +           & 
     2479             surf_def_v(0)%end_index(j,i)   = start_index_def_v(0) +           &
    24252480                                              num_def_v_kji(0) - 1
    24262481             surf_def_v(1)%end_index(j,i)   = start_index_def_v(1) +           &
     
    24402495             surf_lsm_v(2)%start_index(j,i) = start_index_lsm_v(2)
    24412496             surf_lsm_v(3)%start_index(j,i) = start_index_lsm_v(3)
    2442              surf_lsm_v(0)%end_index(j,i)   = start_index_lsm_v(0) +           & 
     2497             surf_lsm_v(0)%end_index(j,i)   = start_index_lsm_v(0) +           &
    24432498                                              num_lsm_v_kji(0) - 1
    24442499             surf_lsm_v(1)%end_index(j,i)   = start_index_lsm_v(1) +           &
     
    24582513             surf_usm_v(2)%start_index(j,i) = start_index_usm_v(2)
    24592514             surf_usm_v(3)%start_index(j,i) = start_index_usm_v(3)
    2460              surf_usm_v(0)%end_index(j,i)   = start_index_usm_v(0) +           & 
     2515             surf_usm_v(0)%end_index(j,i)   = start_index_usm_v(0) +           &
    24612516                                              num_usm_v_kji(0) - 1
    24622517             surf_usm_v(1)%end_index(j,i)   = start_index_usm_v(1) +           &
     
    24802535! Description:
    24812536! ------------
    2482 !> Initialize horizontal surface elements, upward- and downward-facing. 
     2537!> Initialize horizontal surface elements, upward- and downward-facing.
    24832538!> Note, horizontal surface type alsw comprises model-top fluxes, which are,
    2484 !> initialized in a different routine. 
     2539!> initialized in a different routine.
    24852540!------------------------------------------------------------------------------!
    24862541          SUBROUTINE initialize_horizontal_surfaces( k, j, i, surf, num_h,     &
    24872542                                                     num_h_kji, upward_facing, &
    2488                                                      downward_facing )       
    2489 
    2490              IMPLICIT NONE 
     2543                                                     downward_facing )
     2544
     2545             IMPLICIT NONE
    24912546
    24922547             INTEGER(iwp)  ::  i                !< running index x-direction
     
    25092564             surf%k(num_h) = k
    25102565!
    2511 !--          Surface orientation, bit 0 is set to 1 for upward-facing surfaces, 
     2566!--          Surface orientation, bit 0 is set to 1 for upward-facing surfaces,
    25122567!--          bit 1 is for downward-facing surfaces.
    25132568             IF ( upward_facing   )  surf%facing(num_h) = IBSET( surf%facing(num_h), 0 )
     
    25202575                surf%z_mo(num_h)  = zw(k) - zu(k)
    25212576             ENDIF
    2522  
     2577
    25232578             surf%z0(num_h)    = roughness_length
    25242579             surf%z0h(num_h)   = z0h_factor * roughness_length
    2525              surf%z0q(num_h)   = z0h_factor * roughness_length         
     2580             surf%z0q(num_h)   = z0h_factor * roughness_length
    25262581!
    25272582!--          Initialization in case of 1D pre-cursor run
     
    25532608                surf%ol(num_h)   = surf%z_mo(num_h) / zeta_min
    25542609!
    2555 !--             Very small number is required for calculation of Obukhov length 
    2556 !--             at first timestep     
    2557                 surf%us(num_h)    = 1E-30_wp 
     2610!--             Very small number is required for calculation of Obukhov length
     2611!--             at first timestep
     2612                surf%us(num_h)    = 1E-30_wp
    25582613                surf%usws(num_h)  = 0.0_wp
    25592614                surf%vsws(num_h)  = 0.0_wp
    2560        
    2561              ENDIF
    2562 
    2563              surf%rib(num_h)     = 0.0_wp 
     2615
     2616             ENDIF
     2617
     2618             surf%rib(num_h)     = 0.0_wp
    25642619             surf%uvw_abs(num_h) = 0.0_wp
    25652620
    2566              IF ( .NOT. constant_diffusion )  THEN   
    2567                 surf%u_0(num_h)     = 0.0_wp 
     2621             IF ( .NOT. constant_diffusion )  THEN
     2622                surf%u_0(num_h)     = 0.0_wp
    25682623                surf%v_0(num_h)     = 0.0_wp
    2569              ENDIF 
     2624             ENDIF
    25702625
    25712626             surf%ts(num_h)   = 0.0_wp
     
    25732628!--          Set initial value for surface temperature
    25742629             surf%pt_surface(num_h) = pt_surface
    2575              
     2630
    25762631             IF ( humidity )  THEN
    25772632                surf%qs(num_h)   = 0.0_wp
     
    25792634                   surf%qcs(num_h) = 0.0_wp
    25802635                   surf%ncs(num_h) = 0.0_wp
    2581    
     2636
    25822637                   surf%qcsws(num_h) = 0.0_wp
    25832638                   surf%ncsws(num_h) = 0.0_wp
     
    25872642                   surf%qrs(num_h) = 0.0_wp
    25882643                   surf%nrs(num_h) = 0.0_wp
    2589    
     2644
    25902645                   surf%qrsws(num_h) = 0.0_wp
    25912646                   surf%nrsws(num_h) = 0.0_wp
     
    25942649                   surf%qv1(num_h)  = 0.0_wp
    25952650                   surf%vpt1(num_h) = 0.0_wp
    2596                    
     2651
    25972652                ENDIF
    2598                
     2653
     2654                IF ( surf_bulk_cloud_model .AND. surf_microphysics_ice_extension)  THEN
     2655                   surf%qis(num_h) = 0.0_wp
     2656                   surf%nis(num_h) = 0.0_wp
     2657
     2658                   surf%qisws(num_h) = 0.0_wp
     2659                   surf%nisws(num_h) = 0.0_wp
     2660                ENDIF
     2661
     2662
    25992663                surf%q_surface(num_h)   = q_surface
    26002664                surf%vpt_surface(num_h) = surf%pt_surface(num_h) *             &
     
    26072671                IF ( air_chemistry )  surf%css(lsp,num_h)   = 0.0_wp
    26082672!
    2609 !--             Ensure that fluxes of compounds which are not specified in 
     2673!--             Ensure that fluxes of compounds which are not specified in
    26102674!--             namelist are all zero --> kanani: revise
    26112675                IF ( air_chemistry )  surf%cssws(lsp,num_h) = 0.0_wp
     
    26182682                IF ( upward_facing )  THEN
    26192683                   IF ( constant_heatflux )  THEN
    2620 !   
    2621 !--                   Initialize surface heatflux. However, skip this for now if 
     2684!
     2685!--                   Initialize surface heatflux. However, skip this for now if
    26222686!--                   if random_heatflux is set. This case, shf is initialized later.
    26232687                      IF ( .NOT. random_heatflux )  THEN
     
    26252689                                                 heatflux_input_conversion(k-1)
    26262690!
    2627 !--                      Check if surface heat flux might be replaced by 
     2691!--                      Check if surface heat flux might be replaced by
    26282692!--                      prescribed wall heatflux
    26292693                         IF ( k-1 /= 0 )  THEN
     
    26832747!
    26842748!--                      Assign surface flux for each variable species
    2685                          IF ( TRIM( spc_names(lsp) ) == TRIM( surface_csflux_name(lsp_pr) ) )  THEN   
     2749                         IF ( TRIM( spc_names(lsp) ) == TRIM( surface_csflux_name(lsp_pr) ) )  THEN
    26862750                            IF ( upward_facing )  THEN
    26872751                               IF ( constant_csflux(lsp_pr) )  THEN
     
    26932757                                     surf%cssws(lsp,num_h) =                   &
    26942758                                                       wall_csflux(lsp,0) *    &
    2695                                                        rho_air_zw(k-1) 
     2759                                                       rho_air_zw(k-1)
    26962760                               ELSE
    26972761                                  surf%cssws(lsp,num_h) = 0.0_wp
     
    27082772
    27092773                IF ( ocean_mode )  THEN
    2710                    IF ( upward_facing )  THEN 
     2774                   IF ( upward_facing )  THEN
    27112775                      surf%sasws(num_h) = bottom_salinityflux * rho_air_zw(k-1)
    27122776                   ELSE
     
    27182782!--          Increment surface indices
    27192783             num_h     = num_h + 1
    2720              num_h_kji = num_h_kji + 1     
     2784             num_h_kji = num_h_kji + 1
    27212785
    27222786
    27232787          END SUBROUTINE initialize_horizontal_surfaces
    2724        
     2788
    27252789
    27262790!------------------------------------------------------------------------------!
    27272791! Description:
    27282792! ------------
    2729 !> Initialize model-top fluxes. Currently, only the heatflux and salinity flux 
     2793!> Initialize model-top fluxes. Currently, only the heatflux and salinity flux
    27302794!> can be prescribed, latent flux is zero in this case!
    27312795!------------------------------------------------------------------------------!
    2732           SUBROUTINE initialize_top( k, j, i, surf, num_h, num_h_kji )       
    2733 
    2734              IMPLICIT NONE 
     2796          SUBROUTINE initialize_top( k, j, i, surf, num_h, num_h_kji )
     2797
     2798             IMPLICIT NONE
    27352799
    27362800             INTEGER(iwp)  ::  i                !< running index x-direction
     
    27582822             ENDIF
    27592823!
    2760 !--          Prescribe latent heat flux at the top     
     2824!--          Prescribe latent heat flux at the top
    27612825             IF ( humidity )  THEN
    27622826                surf%qsws(num_h) = 0.0_wp
     
    27692833                   surf%qrsws(num_h) = 0.0_wp
    27702834                ENDIF
     2835                IF ( surf_bulk_cloud_model  .AND.  surf_microphysics_ice_extension ) THEN
     2836                   surf%nisws(num_h) = 0.0_wp
     2837                   surf%qisws(num_h) = 0.0_wp
     2838                ENDIF
    27712839             ENDIF
    27722840!
     
    27772845!--          Prescribe top chemical species' flux
    27782846             DO  lsp = 1, nvar
    2779                 IF ( air_chemistry  .AND.  constant_top_csflux(lsp) )  THEN 
     2847                IF ( air_chemistry  .AND.  constant_top_csflux(lsp) )  THEN
    27802848                   surf%cssws(lsp,num_h) = top_csflux(lsp) * rho_air_zw(nzt+1)
    27812849                ENDIF
     
    27962864!--          Increment surface indices
    27972865             num_h     = num_h + 1
    2798              num_h_kji = num_h_kji + 1     
     2866             num_h_kji = num_h_kji + 1
    27992867
    28002868
     
    28052873! Description:
    28062874! ------------
    2807 !> Initialize vertical surface elements. 
     2875!> Initialize vertical surface elements.
    28082876!------------------------------------------------------------------------------!
    28092877          SUBROUTINE initialize_vertical_surfaces( k, j, i, surf, num_v,       &
    28102878                                                   num_v_kji, east_facing,     &
    28112879                                                   west_facing, south_facing,  &
    2812                                                    north_facing )       
    2813 
    2814              IMPLICIT NONE 
    2815 
    2816              INTEGER(iwp)  ::  component       !< index of wall_fluxes_ array for respective orientation 
     2880                                                   north_facing )
     2881
     2882             IMPLICIT NONE
     2883
     2884             INTEGER(iwp)  ::  component       !< index of wall_fluxes_ array for respective orientation
    28172885             INTEGER(iwp)  ::  i               !< running index x-direction
    28182886             INTEGER(iwp)  ::  j               !< running index x-direction
     
    28452913             surf%facing(num_v)  = 0
    28462914!
    2847 !--          Surface orientation. Moreover, set component id to map wall_heatflux, 
     2915!--          Surface orientation. Moreover, set component id to map wall_heatflux,
    28482916!--          etc., on surface type (further below)
    28492917             IF ( north_facing )  THEN
    2850                 surf%facing(num_v) = 5 !IBSET( surf%facing(num_v), 0 ) 
     2918                surf%facing(num_v) = 5 !IBSET( surf%facing(num_v), 0 )
    28512919                component          = 4
    28522920             ENDIF
    28532921
    28542922             IF ( south_facing )  THEN
    2855                 surf%facing(num_v) = 6 !IBSET( surf%facing(num_v), 1 ) 
     2923                surf%facing(num_v) = 6 !IBSET( surf%facing(num_v), 1 )
    28562924                component          = 3
    28572925             ENDIF
     
    28632931
    28642932             IF ( west_facing )  THEN
    2865                 surf%facing(num_v) = 8 !IBSET( surf%facing(num_v), 3 ) 
     2933                surf%facing(num_v) = 8 !IBSET( surf%facing(num_v), 3 )
    28662934                component          = 1
    28672935             ENDIF
    28682936
    2869  
     2937
    28702938             surf%z0(num_v)  = roughness_length
    28712939             surf%z0h(num_v) = z0h_factor * roughness_length
     
    28942962                surf%qsws(num_v) = wall_humidityflux(component)
    28952963!
    2896 !--             Following wall fluxes are assumed to be zero 
     2964!--             Following wall fluxes are assumed to be zero
    28972965                IF ( surf_bulk_cloud_model .AND. surf_microphysics_morrison)  THEN
    28982966                   surf%qcs(num_v) = 0.0_wp
    28992967                   surf%ncs(num_v) = 0.0_wp
    2900    
     2968
    29012969                   surf%qcsws(num_v) = 0.0_wp
    29022970                   surf%ncsws(num_v) = 0.0_wp
     
    29052973                   surf%qrs(num_v) = 0.0_wp
    29062974                   surf%nrs(num_v) = 0.0_wp
    2907    
     2975
    29082976                   surf%qrsws(num_v) = 0.0_wp
    29092977                   surf%nrsws(num_v) = 0.0_wp
    29102978                ENDIF
     2979                IF ( surf_bulk_cloud_model .AND. surf_microphysics_ice_extension)  THEN
     2980                   surf%qis(num_v) = 0.0_wp
     2981                   surf%nis(num_v) = 0.0_wp
     2982
     2983                   surf%qisws(num_v) = 0.0_wp
     2984                   surf%nisws(num_v) = 0.0_wp
     2985                ENDIF
    29112986             ENDIF
    29122987
     
    29162991             ENDIF
    29172992
    2918              IF ( air_chemistry )  THEN       
     2993             IF ( air_chemistry )  THEN
    29192994                DO  lsp = 1, nvar
    29202995                   surf%css(lsp,num_v)   = 0.0_wp
     
    29242999
    29253000!
    2926 !--          So far, salinityflux at vertical surfaces is simply zero 
    2927 !--          at the moment 
     3001!--          So far, salinityflux at vertical surfaces is simply zero
     3002!--          at the moment
    29283003             IF ( ocean_mode )  surf%sasws(num_v) = wall_salinityflux(component)
    29293004!
     
    29453020                                               index_space_j                   &
    29463021                                             )
    2947    
     3022
    29483023       INTEGER(iwp) ::  m  !< running index over surface elements
    29493024       INTEGER(iwp) ::  ns !< number of surface elements in var_surf
    29503025
    29513026       INTEGER(iwp), DIMENSION(1:ns) ::  index_space_i !< grid indices along x direction where surface properties should be defined
    2952        INTEGER(iwp), DIMENSION(1:ns) ::  index_space_j !< grid indices along y direction where surface properties should be defined 
    2953        
     3027       INTEGER(iwp), DIMENSION(1:ns) ::  index_space_j !< grid indices along y direction where surface properties should be defined
     3028
    29543029       REAL(wp) ::  fill_value !< fill value in var_2d
    2955        
     3030
    29563031       REAL(wp), DIMENSION(1:ns) ::  var_surf !< 1D surface variable that should be initialized
    29573032       REAL(wp), DIMENSION(nys:nyn,nxl:nxr) ::  var_2d !< input variable
     
    29623037          ENDIF
    29633038       ENDDO
    2964        
     3039
    29653040    END SUBROUTINE init_single_surface_properties
    29663041
     
    30193094       ENDDO
    30203095!
    3021 !--    In the following, gather data from surfaces elements with the same 
     3096!--    In the following, gather data from surfaces elements with the same
    30223097!--    facing (but possibly differt type) on 1 data-type array.
    30233098       mm(0:2) = 1
     
    30393114                   IF ( ALLOCATED( surf_def_h(l)%ncs ) )                       &
    30403115                      surf_h(l)%ncs(mm(l))     = surf_def_h(l)%ncs(m)
     3116                   IF ( ALLOCATED( surf_def_h(l)%qis ) )                       &
     3117                      surf_h(l)%qis(mm(l))     = surf_def_h(l)%qis(m)
     3118                   IF ( ALLOCATED( surf_def_h(l)%nis ) )                       &
     3119                      surf_h(l)%nis(mm(l))     = surf_def_h(l)%nis(m)
    30413120                   IF ( ALLOCATED( surf_def_h(l)%qrs ) )                       &
    30423121                      surf_h(l)%qrs(mm(l))     = surf_def_h(l)%qrs(m)
     
    30503129                      surf_h(l)%pt_surface(mm(l)) = surf_def_h(l)%pt_surface(m)
    30513130                   IF ( ALLOCATED( surf_def_h(l)%q_surface ) )                 &
    3052                       surf_h(l)%q_surface(mm(l)) = surf_def_h(l)%q_surface(m) 
     3131                      surf_h(l)%q_surface(mm(l)) = surf_def_h(l)%q_surface(m)
    30533132                   IF ( ALLOCATED( surf_def_h(l)%vpt_surface ) )               &
    3054                       surf_h(l)%vpt_surface(mm(l)) = surf_def_h(l)%vpt_surface(m)                     
     3133                      surf_h(l)%vpt_surface(mm(l)) = surf_def_h(l)%vpt_surface(m)
    30553134                   IF ( ALLOCATED( surf_def_h(l)%usws ) )                      &
    30563135                      surf_h(l)%usws(mm(l))    = surf_def_h(l)%usws(m)
     
    30633142                   IF ( ALLOCATED( surf_def_h(l)%ssws ) )                      &
    30643143                      surf_h(l)%ssws(mm(l))    = surf_def_h(l)%ssws(m)
    3065                    IF ( ALLOCATED( surf_def_h(l)%css ) )  THEN 
     3144                   IF ( ALLOCATED( surf_def_h(l)%css ) )  THEN
    30663145                      DO  lsp = 1,nvar
    30673146                         surf_h(l)%css(lsp,mm(l)) = surf_def_h(l)%css(lsp,m)
    30683147                      ENDDO
    30693148                   ENDIF
    3070                    IF ( ALLOCATED( surf_def_h(l)%cssws ) )  THEN 
     3149                   IF ( ALLOCATED( surf_def_h(l)%cssws ) )  THEN
    30713150                      DO  lsp = 1,nvar
    30723151                         surf_h(l)%cssws(lsp,mm(l)) = surf_def_h(l)%cssws(lsp,m)
     
    30773156                   IF ( ALLOCATED( surf_def_h(l)%qrsws ) )                     &
    30783157                      surf_h(l)%qrsws(mm(l))   = surf_def_h(l)%qrsws(m)
     3158                   IF ( ALLOCATED( surf_def_h(l)%qisws ) )                     &
     3159                      surf_h(l)%qisws(mm(l))   = surf_def_h(l)%qisws(m)
    30793160                   IF ( ALLOCATED( surf_def_h(l)%ncsws ) )                     &
    30803161                      surf_h(l)%ncsws(mm(l))   = surf_def_h(l)%ncsws(m)
     3162                   IF ( ALLOCATED( surf_def_h(l)%nisws ) )                     &
     3163                      surf_h(l)%nisws(mm(l))   = surf_def_h(l)%nisws(m)
    30813164                   IF ( ALLOCATED( surf_def_h(l)%nrsws ) )                     &
    30823165                      surf_h(l)%nrsws(mm(l))   = surf_def_h(l)%nrsws(m)
    30833166                   IF ( ALLOCATED( surf_def_h(l)%sasws ) )                     &
    30843167                      surf_h(l)%sasws(mm(l))   = surf_def_h(l)%sasws(m)
    3085                
     3168
    30863169                   mm(l) = mm(l) + 1
    30873170                ENDDO
     
    31023185                      IF ( ALLOCATED( surf_lsm_h%ncs ) )                       &
    31033186                         surf_h(0)%ncs(mm(0))     = surf_lsm_h%ncs(m)
     3187                      IF ( ALLOCATED( surf_lsm_h%qis ) )                       &
     3188                         surf_h(0)%qis(mm(0))     = surf_lsm_h%qis(m)
     3189                      IF ( ALLOCATED( surf_lsm_h%nis ) )                       &
     3190                         surf_h(0)%nis(mm(0))     = surf_lsm_h%nis(m)
    31043191                      IF ( ALLOCATED( surf_lsm_h%qrs ) )                       &
    31053192                         surf_h(0)%qrs(mm(0))     = surf_lsm_h%qrs(m)
     
    31263213                      IF ( ALLOCATED( surf_lsm_h%ssws ) )                      &
    31273214                         surf_h(0)%ssws(mm(0))    = surf_lsm_h%ssws(m)
    3128                       IF ( ALLOCATED( surf_lsm_h%css ) )  THEN                 
     3215                      IF ( ALLOCATED( surf_lsm_h%css ) )  THEN
    31293216                         DO  lsp = 1, nvar
    31303217                            surf_h(0)%css(lsp,mm(0)) = surf_lsm_h%css(lsp,m)
     
    31343221                         DO  lsp = 1, nvar
    31353222                            surf_h(0)%cssws(lsp,mm(0)) = surf_lsm_h%cssws(lsp,m)
    3136                          ENDDO 
     3223                         ENDDO
    31373224                      ENDIF
    31383225                      IF ( ALLOCATED( surf_lsm_h%qcsws ) )                     &
    31393226                         surf_h(0)%qcsws(mm(0))   = surf_lsm_h%qcsws(m)
     3227                      IF ( ALLOCATED( surf_lsm_h%qisws ) )                     &
     3228                         surf_h(0)%qisws(mm(0))   = surf_lsm_h%qisws(m)
    31403229                      IF ( ALLOCATED( surf_lsm_h%qrsws ) )                     &
    31413230                         surf_h(0)%qrsws(mm(0))   = surf_lsm_h%qrsws(m)
    31423231                      IF ( ALLOCATED( surf_lsm_h%ncsws ) )                     &
    31433232                         surf_h(0)%ncsws(mm(0))   = surf_lsm_h%ncsws(m)
     3233                      IF ( ALLOCATED( surf_lsm_h%nisws ) )                     &
     3234                         surf_h(0)%nisws(mm(0))   = surf_lsm_h%nisws(m)
    31443235                      IF ( ALLOCATED( surf_lsm_h%nrsws ) )                     &
    31453236                         surf_h(0)%nrsws(mm(0))   = surf_lsm_h%nrsws(m)
    31463237                      IF ( ALLOCATED( surf_lsm_h%sasws ) )                     &
    31473238                        surf_h(0)%sasws(mm(0))   = surf_lsm_h%sasws(m)
    3148                
     3239
    31493240                      mm(0) = mm(0) + 1
    3150              
     3241
    31513242                   ENDDO
    31523243
     
    31653256                      IF ( ALLOCATED( surf_usm_h%ncs ) )                       &
    31663257                         surf_h(0)%ncs(mm(0))     = surf_usm_h%ncs(m)
     3258                      IF ( ALLOCATED( surf_usm_h%qis ) )                       &
     3259                         surf_h(0)%qis(mm(0))     = surf_usm_h%qis(m)
     3260                      IF ( ALLOCATED( surf_usm_h%nis ) )                       &
     3261                         surf_h(0)%nis(mm(0))     = surf_usm_h%nis(m)
    31673262                      IF ( ALLOCATED( surf_usm_h%qrs ) )                       &
    31683263                         surf_h(0)%qrs(mm(0))     = surf_usm_h%qrs(m)
     
    31753270                      IF ( ALLOCATED( surf_usm_h%pt_surface ) )                &
    31763271                         surf_h(l)%pt_surface(mm(l)) = surf_usm_h%pt_surface(m)
    3177                       IF ( ALLOCATED( surf_usm_h%q_surface ) )                 &
     3272                       IF ( ALLOCATED( surf_usm_h%q_surface ) )                &
    31783273                         surf_h(l)%q_surface(mm(l)) = surf_usm_h%q_surface(m)
    31793274                      IF ( ALLOCATED( surf_usm_h%vpt_surface ) )               &
     
    31893284                      IF ( ALLOCATED( surf_usm_h%ssws ) )                      &
    31903285                         surf_h(0)%ssws(mm(0))    = surf_usm_h%ssws(m)
    3191                       IF ( ALLOCATED( surf_usm_h%css ) )  THEN             
     3286                      IF ( ALLOCATED( surf_usm_h%css ) )  THEN
    31923287                         DO lsp = 1, nvar
    31933288                            surf_h(0)%css(lsp,mm(0)) = surf_usm_h%css(lsp,m)
    31943289                         ENDDO
    31953290                      ENDIF
    3196                       IF ( ALLOCATED( surf_usm_h%cssws ) )  THEN             
     3291                      IF ( ALLOCATED( surf_usm_h%cssws ) )  THEN
    31973292                         DO lsp = 1, nvar
    31983293                            surf_h(0)%cssws(lsp,mm(0)) = surf_usm_h%cssws(lsp,m)
     
    32013296                      IF ( ALLOCATED( surf_usm_h%qcsws ) )                     &
    32023297                         surf_h(0)%qcsws(mm(0))   = surf_usm_h%qcsws(m)
     3298                      IF ( ALLOCATED( surf_usm_h%qisws ) )                     &
     3299                         surf_h(0)%qisws(mm(0))   = surf_usm_h%qisws(m)
    32033300                      IF ( ALLOCATED( surf_usm_h%qrsws ) )                     &
    32043301                         surf_h(0)%qrsws(mm(0))   = surf_usm_h%qrsws(m)
     
    32073304                      IF ( ALLOCATED( surf_usm_h%nrsws ) )                     &
    32083305                         surf_h(0)%nrsws(mm(0))   = surf_usm_h%nrsws(m)
     3306                      IF ( ALLOCATED( surf_usm_h%nisws ) )                     &
     3307                         surf_h(0)%nisws(mm(0))   = surf_usm_h%nisws(m)
    32093308                      IF ( ALLOCATED( surf_usm_h%sasws ) )                     &
    32103309                        surf_h(0)%sasws(mm(0))   = surf_usm_h%sasws(m)
    3211                
     3310
    32123311                      mm(0) = mm(0) + 1
    3213              
     3312
    32143313                   ENDDO
    32153314
     
    32223321!
    32233322!--       Recalculate start- and end indices for gathered surface type.
    3224           start_index_h(l) = 1                                       
     3323          start_index_h(l) = 1
    32253324          DO  i = nxl, nxr
    32263325             DO  j = nys, nyn
     
    32523351!--    Treat vertically orientated surface. Again, gather data from different
    32533352!--    surfaces types but identical orientation (e.g. northward-facing) onto
    3254 !--    one surface type which is output afterwards. 
     3353!--    one surface type which is output afterwards.
    32553354       mm(0:3) = 1
    32563355       DO  l = 0, 3
     
    32713370                   IF ( ALLOCATED( surf_def_v(l)%ncs ) )                       &
    32723371                      surf_v(l)%ncs(mm(l))     = surf_def_v(l)%ncs(m)
     3372                   IF ( ALLOCATED( surf_def_v(l)%qis ) )                       &
     3373                      surf_v(l)%qis(mm(l))     = surf_def_v(l)%qis(m)
     3374                   IF ( ALLOCATED( surf_def_v(l)%nis ) )                       &
     3375                      surf_v(l)%nis(mm(l))     = surf_def_v(l)%nis(m)
    32733376                   IF ( ALLOCATED( surf_def_v(l)%qrs ) )                       &
    32743377                      surf_v(l)%qrs(mm(l))     = surf_def_v(l)%qrs(m)
     
    32913394                   IF ( ALLOCATED( surf_def_v(l)%ssws ) )                      &
    32923395                      surf_v(l)%ssws(mm(l))    = surf_def_v(l)%ssws(m)
    3293                    IF ( ALLOCATED( surf_def_v(l)%css ) )  THEN               
     3396                   IF ( ALLOCATED( surf_def_v(l)%css ) )  THEN
    32943397                      DO  lsp = 1, nvar
    32953398                         surf_v(l)%css(lsp,mm(l)) = surf_def_v(l)%css(lsp,m)
    32963399                      ENDDO
    32973400                   ENDIF
    3298                    IF ( ALLOCATED( surf_def_v(l)%cssws ) )  THEN               
     3401                   IF ( ALLOCATED( surf_def_v(l)%cssws ) )  THEN
    32993402                      DO  lsp = 1, nvar
    33003403                         surf_v(l)%cssws(lsp,mm(l)) = surf_def_v(l)%cssws(lsp,m)
     
    33033406                   IF ( ALLOCATED( surf_def_v(l)%qcsws ) )                     &
    33043407                      surf_v(l)%qcsws(mm(l))   = surf_def_v(l)%qcsws(m)
     3408                   IF ( ALLOCATED( surf_def_v(l)%qisws ) )                     &
     3409                      surf_v(l)%qisws(mm(l))   = surf_def_v(l)%qisws(m)
    33053410                   IF ( ALLOCATED( surf_def_v(l)%qrsws ) )                     &
    33063411                      surf_v(l)%qrsws(mm(l))   = surf_def_v(l)%qrsws(m)
    33073412                   IF ( ALLOCATED( surf_def_v(l)%ncsws ) )                     &
    33083413                      surf_v(l)%ncsws(mm(l))   = surf_def_v(l)%ncsws(m)
     3414                   IF ( ALLOCATED( surf_def_v(l)%nisws ) )                     &
     3415                      surf_v(l)%nisws(mm(l))   = surf_def_v(l)%nisws(m)
    33093416                   IF ( ALLOCATED( surf_def_v(l)%nrsws ) )                     &
    33103417                      surf_v(l)%nrsws(mm(l))   = surf_def_v(l)%nrsws(m)
     
    33173424                   IF ( ALLOCATED( surf_def_v(l)%mom_flux_tke) )               &
    33183425                      surf_v(l)%mom_flux_tke(0:1,mm(l)) = surf_def_v(l)%mom_flux_tke(0:1,m)
    3319                
     3426
    33203427                   mm(l) = mm(l) + 1
    33213428                ENDDO
     
    33353442                   IF ( ALLOCATED( surf_lsm_v(l)%ncs ) )                       &
    33363443                      surf_v(l)%ncs(mm(l))     = surf_lsm_v(l)%ncs(m)
     3444                   IF ( ALLOCATED( surf_lsm_v(l)%qis ) )                       &
     3445                      surf_v(l)%qis(mm(l))     = surf_lsm_v(l)%qis(m)
     3446                   IF ( ALLOCATED( surf_lsm_v(l)%nis ) )                       &
     3447                      surf_v(l)%nis(mm(l))     = surf_lsm_v(l)%nis(m)
    33373448                   IF ( ALLOCATED( surf_lsm_v(l)%qrs ) )                       &
    33383449                      surf_v(l)%qrs(mm(l))     = surf_lsm_v(l)%qrs(m)
     
    33593470                   IF ( ALLOCATED( surf_lsm_v(l)%ssws ) )                      &
    33603471                      surf_v(l)%ssws(mm(l))    = surf_lsm_v(l)%ssws(m)
    3361                    IF ( ALLOCATED( surf_lsm_v(l)%css ) )  THEN             
     3472                   IF ( ALLOCATED( surf_lsm_v(l)%css ) )  THEN
    33623473                      DO  lsp = 1, nvar
    33633474                         surf_v(l)%css(lsp,mm(l)) = surf_lsm_v(l)%css(lsp,m)
    33643475                      ENDDO
    33653476                   ENDIF
    3366                    IF ( ALLOCATED( surf_lsm_v(l)%cssws ) )  THEN             
     3477                   IF ( ALLOCATED( surf_lsm_v(l)%cssws ) )  THEN
    33673478                      DO  lsp = 1, nvar
    33683479                         surf_v(l)%cssws(lsp,mm(l)) = surf_lsm_v(l)%cssws(lsp,m)
     
    33733484                   IF ( ALLOCATED( surf_lsm_v(l)%qrsws ) )                     &
    33743485                      surf_v(l)%qrsws(mm(l))   = surf_lsm_v(l)%qrsws(m)
     3486                   IF ( ALLOCATED( surf_lsm_v(l)%qisws ) )                     &
     3487                      surf_v(l)%qisws(mm(l))   = surf_lsm_v(l)%qisws(m)
    33753488                   IF ( ALLOCATED( surf_lsm_v(l)%ncsws ) )                     &
    33763489                      surf_v(l)%ncsws(mm(l))   = surf_lsm_v(l)%ncsws(m)
     3490                   IF ( ALLOCATED( surf_lsm_v(l)%nisws ) )                     &
     3491                      surf_v(l)%nisws(mm(l))   = surf_lsm_v(l)%nisws(m)
    33773492                   IF ( ALLOCATED( surf_lsm_v(l)%nrsws ) )                     &
    33783493                      surf_v(l)%nrsws(mm(l))   = surf_lsm_v(l)%nrsws(m)
     
    33853500                   IF ( ALLOCATED( surf_lsm_v(l)%mom_flux_tke) )               &
    33863501                      surf_v(l)%mom_flux_tke(0:1,mm(l)) = surf_lsm_v(l)%mom_flux_tke(0:1,m)
    3387                
     3502
    33883503                   mm(l) = mm(l) + 1
    33893504                ENDDO
     
    34033518                   IF ( ALLOCATED( surf_usm_v(l)%ncs ) )                       &
    34043519                      surf_v(l)%ncs(mm(l))     = surf_usm_v(l)%ncs(m)
     3520                   IF ( ALLOCATED( surf_usm_v(l)%qis ) )                       &
     3521                      surf_v(l)%qis(mm(l))     = surf_usm_v(l)%qis(m)
     3522                   IF ( ALLOCATED( surf_usm_v(l)%nis ) )                       &
     3523                      surf_v(l)%nis(mm(l))     = surf_usm_v(l)%nis(m)
    34053524                   IF ( ALLOCATED( surf_usm_v(l)%qrs ) )                       &
    34063525                      surf_v(l)%qrs(mm(l))     = surf_usm_v(l)%qrs(m)
     
    34273546                   IF ( ALLOCATED( surf_usm_v(l)%ssws ) )                      &
    34283547                      surf_v(l)%ssws(mm(l))    = surf_usm_v(l)%ssws(m)
    3429                    IF ( ALLOCATED( surf_usm_v(l)%css ) )  THEN             
     3548                   IF ( ALLOCATED( surf_usm_v(l)%css ) )  THEN
    34303549                      DO  lsp = 1, nvar
    34313550                         surf_v(l)%css(lsp,mm(l)) = surf_usm_v(l)%css(lsp,m)
    34323551                      ENDDO
    34333552                   ENDIF
    3434                    IF ( ALLOCATED( surf_usm_v(l)%cssws ) )  THEN             
     3553                   IF ( ALLOCATED( surf_usm_v(l)%cssws ) )  THEN
    34353554                      DO  lsp = 1, nvar
    34363555                         surf_v(l)%cssws(lsp,mm(l)) = surf_usm_v(l)%cssws(lsp,m)
     
    34413560                   IF ( ALLOCATED( surf_usm_v(l)%qrsws ) )                     &
    34423561                      surf_v(l)%qrsws(mm(l))   = surf_usm_v(l)%qrsws(m)
     3562                   IF ( ALLOCATED( surf_usm_v(l)%qisws ) )                     &
     3563                      surf_v(l)%qisws(mm(l))   = surf_usm_v(l)%qisws(m)
    34433564                   IF ( ALLOCATED( surf_usm_v(l)%ncsws ) )                     &
    34443565                      surf_v(l)%ncsws(mm(l))   = surf_usm_v(l)%ncsws(m)
     3566                   IF ( ALLOCATED( surf_usm_v(l)%nisws ) )                     &
     3567                      surf_v(l)%nisws(mm(l))   = surf_usm_v(l)%nisws(m)
    34453568                   IF ( ALLOCATED( surf_usm_v(l)%nrsws ) )                     &
    34463569                      surf_v(l)%nrsws(mm(l))   = surf_usm_v(l)%nrsws(m)
     
    34533576                   IF ( ALLOCATED( surf_usm_v(l)%mom_flux_tke) )               &
    34543577                      surf_v(l)%mom_flux_tke(0:1,mm(l)) = surf_usm_v(l)%mom_flux_tke(0:1,m)
    3455                
     3578
    34563579                   mm(l) = mm(l) + 1
    34573580                ENDDO
    3458              
     3581
    34593582             ENDDO
    34603583          ENDDO
     
    35443667             ENDIF
    35453668
     3669             IF ( ALLOCATED ( surf_h(l)%qis ) )  THEN
     3670                CALL wrd_write_string( 'surf_h(' // dum // ')%qis' )
     3671                WRITE ( 14 )  surf_h(l)%qis
     3672             ENDIF
     3673
     3674             IF ( ALLOCATED ( surf_h(l)%nis ) )  THEN
     3675                CALL wrd_write_string( 'surf_h(' // dum // ')%nis' )
     3676                WRITE ( 14 )  surf_h(l)%nis
     3677             ENDIF
     3678
    35463679             IF ( ALLOCATED ( surf_h(l)%qrs ) )  THEN
    35473680                CALL wrd_write_string( 'surf_h(' // dum // ')%qrs' )
     
    36243757             ENDIF
    36253758
     3759             IF ( ALLOCATED ( surf_h(l)%qisws ) )  THEN
     3760                CALL wrd_write_string( 'surf_h(' // dum // ')%qisws' )
     3761                WRITE ( 14 )  surf_h(l)%qisws
     3762             ENDIF
     3763
     3764             IF ( ALLOCATED ( surf_h(l)%nisws ) )  THEN
     3765                CALL wrd_write_string( 'surf_h(' // dum // ')%nisws' )
     3766                WRITE ( 14 )  surf_h(l)%nisws
     3767             ENDIF
     3768
    36263769             IF ( ALLOCATED ( surf_h(l)%qrsws ) )  THEN
    36273770                CALL wrd_write_string( 'surf_h(' // dum // ')%qrsws' )
     
    36713814                WRITE ( 14 )  surf_v(l)%ss
    36723815             ENDIF
    3673          
     3816
    36743817             IF ( ALLOCATED ( surf_v(l)%qcs ) )  THEN
    36753818                CALL wrd_write_string( 'surf_v(' // dum // ')%qcs' )
     
    36823825             ENDIF
    36833826
     3827             IF ( ALLOCATED ( surf_v(l)%qis ) )  THEN
     3828                CALL wrd_write_string( 'surf_v(' // dum // ')%qis' )
     3829                WRITE ( 14 )  surf_v(l)%qis
     3830             ENDIF
     3831
     3832             IF ( ALLOCATED ( surf_v(l)%nis ) )  THEN
     3833                CALL wrd_write_string( 'surf_v(' // dum // ')%nis' )
     3834                WRITE ( 14 )  surf_v(l)%nis
     3835             ENDIF
     3836
    36843837             IF ( ALLOCATED ( surf_v(l)%qrs ) )  THEN
    36853838                CALL wrd_write_string( 'surf_v(' // dum // ')%qrs' )
     
    37063859                WRITE ( 14 )  surf_v(l)%pt_surface
    37073860             ENDIF
    3708          
     3861
    37093862             IF ( ALLOCATED ( surf_v(l)%q_surface ) )  THEN
    37103863                CALL wrd_write_string( 'surf_v(' // dum // ')%q_surface' )
     
    37503903                CALL wrd_write_string( 'surf_v(' // dum // ')%ncsws' )
    37513904                WRITE ( 14 )  surf_v(l)%ncsws
     3905             ENDIF
     3906
     3907             IF ( ALLOCATED ( surf_v(l)%qisws ) )  THEN
     3908                CALL wrd_write_string( 'surf_v(' // dum // ')%qisws' )
     3909                WRITE ( 14 )  surf_v(l)%qisws
     3910             ENDIF
     3911
     3912             IF ( ALLOCATED ( surf_v(l)%nisws ) )  THEN
     3913                CALL wrd_write_string( 'surf_v(' // dum // ')%nisws' )
     3914                WRITE ( 14 )  surf_v(l)%nisws
    37523915             ENDIF
    37533916
     
    38303993             ENDIF
    38313994
     3995             IF ( ALLOCATED ( surf_h(l)%qis ) )  THEN
     3996                CALL wrd_mpi_io_surface( 'surf_h(' // dum // ')%qis', surf_h(l)%qis )
     3997             ENDIF
     3998
     3999             IF ( ALLOCATED ( surf_h(l)%nis ) )  THEN
     4000                CALL wrd_mpi_io_surface( 'surf_h(' // dum // ')%nis', surf_h(l)%nis )
     4001             ENDIF
     4002
    38324003             IF ( ALLOCATED ( surf_h(l)%qrs ) )  THEN
    38334004                CALL wrd_mpi_io_surface( 'surf_h(' // dum // ')%qrs', surf_h(l)%qrs )
     
    38924063             IF ( ALLOCATED ( surf_h(l)%ncsws ) )  THEN
    38934064                CALL wrd_mpi_io_surface( 'surf_h(' // dum // ')%ncsws', surf_h(l)%ncsws )
     4065             ENDIF
     4066
     4067             IF ( ALLOCATED ( surf_h(l)%qisws ) )  THEN
     4068                CALL wrd_mpi_io_surface( 'surf_h(' // dum // ')%qisws', surf_h(l)%qisws )
     4069             ENDIF
     4070
     4071             IF ( ALLOCATED ( surf_h(l)%nisws ) )  THEN
     4072                CALL wrd_mpi_io_surface( 'surf_h(' // dum // ')%nisws', surf_h(l)%nisws )
    38944073             ENDIF
    38954074
     
    39484127             ENDIF
    39494128
     4129             IF ( ALLOCATED ( surf_v(l)%qis ) )  THEN
     4130                CALL wrd_mpi_io_surface( 'surf_v(' // dum // ')%qis', surf_v(l)%qis )
     4131             ENDIF
     4132
     4133             IF ( ALLOCATED ( surf_v(l)%nis ) )  THEN
     4134                CALL wrd_mpi_io_surface( 'surf_v(' // dum // ')%nis', surf_v(l)%nis )
     4135             ENDIF
     4136
    39504137             IF ( ALLOCATED ( surf_v(l)%qrs ) )  THEN
    39514138                CALL wrd_mpi_io_surface( 'surf_v(' // dum // ')%qrs', surf_v(l)%qrs )
     
    40024189             IF ( ALLOCATED ( surf_v(l)%ncsws ) )  THEN
    40034190                CALL wrd_mpi_io_surface( 'surf_v(' // dum // ')%ncsws', surf_v(l)%ncsws )
     4191             ENDIF
     4192
     4193             IF ( ALLOCATED ( surf_v(l)%qisws ) )  THEN
     4194                CALL wrd_mpi_io_surface( 'surf_v(' // dum // ')%qisws', surf_v(l)%qisws )
     4195             ENDIF
     4196
     4197             IF ( ALLOCATED ( surf_v(l)%nisws ) )  THEN
     4198                CALL wrd_mpi_io_surface( 'surf_v(' // dum // ')%nisws', surf_v(l)%nisws )
    40044199             ENDIF
    40054200
     
    40424237! ------------
    40434238!> Reads surface-related restart data. Please note, restart data for a certain
    4044 !> surface orientation (e.g. horizontal upward-facing) is stored in one 
    4045 !> array, even if surface elements may belong to different surface types 
     4239!> surface orientation (e.g. horizontal upward-facing) is stored in one
     4240!> array, even if surface elements may belong to different surface types
    40464241!> natural or urban for example). Surface elements are redistributed into its
    4047 !> respective surface types within this routine. This allows e.g. changing the 
    4048 !> surface type after reading the restart data, which might be required in case 
    4049 !> of cyclic_fill mode. 
     4242!> respective surface types within this routine. This allows e.g. changing the
     4243!> surface type after reading the restart data, which might be required in case
     4244!> of cyclic_fill mode.
    40504245!------------------------------------------------------------------------------!
    40514246    SUBROUTINE surface_rrd_local( kk, nxlf, nxlc, nxl_on_file, nxrf,           &
     
    40644259       INTEGER(iwp)       ::  kk          !< running index over previous input files covering current local domain
    40654260       INTEGER(iwp)       ::  nxlc        !< index of left boundary on current subdomain
    4066        INTEGER(iwp)       ::  nxlf        !< index of left boundary on former subdomain 
    4067        INTEGER(iwp)       ::  nxl_on_file !< index of left boundary on former local domain 
     4261       INTEGER(iwp)       ::  nxlf        !< index of left boundary on former subdomain
     4262       INTEGER(iwp)       ::  nxl_on_file !< index of left boundary on former local domain
    40684263       INTEGER(iwp)       ::  nxrf        !< index of right boundary on former subdomain
    4069        INTEGER(iwp)       ::  nxr_on_file !< index of right boundary on former local domain 
     4264       INTEGER(iwp)       ::  nxr_on_file !< index of right boundary on former local domain
    40704265       INTEGER(iwp)       ::  nynf        !< index of north boundary on former subdomain
    4071        INTEGER(iwp)       ::  nyn_on_file !< index of norht boundary on former local domain 
    4072        INTEGER(iwp)       ::  nysc        !< index of south boundary on current subdomain 
     4266       INTEGER(iwp)       ::  nyn_on_file !< index of norht boundary on former local domain
     4267       INTEGER(iwp)       ::  nysc        !< index of south boundary on current subdomain
    40734268       INTEGER(iwp)       ::  nysf        !< index of south boundary on former subdomain
    4074        INTEGER(iwp)       ::  nys_on_file !< index of south boundary on former local domain 
     4269       INTEGER(iwp)       ::  nys_on_file !< index of south boundary on former local domain
    40754270
    40764271       INTEGER(iwp), SAVE ::  l           !< index variable for surface type
     
    40934288       SELECT CASE ( restart_string(1:length) )
    40944289!
    4095 !--       Read the number of horizontally orientated surface elements and 
     4290!--       Read the number of horizontally orientated surface elements and
    40964291!--       allocate arrays
    40974292          CASE ( 'ns_h_on_file' )
     
    41004295
    41014296                IF ( ALLOCATED( surf_h(0)%start_index ) )                      &
    4102                    CALL deallocate_surface_attributes_h( surf_h(0) )           
     4297                   CALL deallocate_surface_attributes_h( surf_h(0) )
    41034298                IF ( ALLOCATED( surf_h(1)%start_index ) )                      &
    4104                    CALL deallocate_surface_attributes_h( surf_h(1) )           
     4299                   CALL deallocate_surface_attributes_h( surf_h(1) )
    41054300                IF ( ALLOCATED( surf_h(2)%start_index ) )                      &
    4106                    CALL deallocate_surface_attributes_h_top( surf_h(2) )       
    4107 !
    4108 !--             Allocate memory for number of surface elements on file. 
    4109 !--             Please note, these number is not necessarily the same as 
     4301                   CALL deallocate_surface_attributes_h_top( surf_h(2) )
     4302!
     4303!--             Allocate memory for number of surface elements on file.
     4304!--             Please note, these number is not necessarily the same as
    41104305!--             the final number of surface elements on local domain,
    41114306!--             which is the case if processor topology changes during
    4112 !--             restart runs. 
     4307!--             restart runs.
    41134308!--             Horizontal upward facing
    41144309                surf_h(0)%ns = ns_h_on_file(0)
     
    41314326!
    41324327!--             Initial setting of flags for horizontal and vertical surfaces,
    4133 !--             will be set after start- and end-indices are read. 
     4328!--             will be set after start- and end-indices are read.
    41344329                horizontal_surface = .FALSE.
    41354330                vertical_surface   = .FALSE.
    41364331
    4137              ENDIF   
    4138 !
    4139 !--       Read the number of vertically orientated surface elements and 
     4332             ENDIF
     4333!
     4334!--       Read the number of vertically orientated surface elements and
    41404335!--       allocate arrays
    41414336          CASE ( 'ns_v_on_file' )
     
    41624357                READ ( 13 )  surf_h(0)%start_index
    41634358             l = 0
    4164           CASE ( 'surf_h(0)%end_index' )   
     4359          CASE ( 'surf_h(0)%end_index' )
    41654360             IF ( kk == 1 )                                                    &
    41664361                READ ( 13 )  surf_h(0)%end_index
     
    41694364!
    41704365!--       Read specific attributes
    4171           CASE ( 'surf_h(0)%us' )         
     4366          CASE ( 'surf_h(0)%us' )
    41724367             IF ( ALLOCATED( surf_h(0)%us )  .AND.  kk == 1 )                  &
    41734368                READ ( 13 )  surf_h(0)%us
    4174           CASE ( 'surf_h(0)%ts' )         
     4369          CASE ( 'surf_h(0)%ts' )
    41754370             IF ( ALLOCATED( surf_h(0)%ts )  .AND.  kk == 1 )                  &
    41764371                READ ( 13 )  surf_h(0)%ts
    4177           CASE ( 'surf_h(0)%qs' )         
     4372          CASE ( 'surf_h(0)%qs' )
    41784373             IF ( ALLOCATED( surf_h(0)%qs )  .AND.  kk == 1 )                  &
    41794374                READ ( 13 )  surf_h(0)%qs
    4180           CASE ( 'surf_h(0)%ss' )         
     4375          CASE ( 'surf_h(0)%ss' )
    41814376             IF ( ALLOCATED( surf_h(0)%ss )  .AND.  kk == 1 )                  &
    41824377                READ ( 13 )  surf_h(0)%ss
    4183           CASE ( 'surf_h(0)%qcs' )         
     4378          CASE ( 'surf_h(0)%qcs' )
    41844379             IF ( ALLOCATED( surf_h(0)%qcs )  .AND.  kk == 1 )                 &
    41854380                READ ( 13 )  surf_h(0)%qcs
    4186           CASE ( 'surf_h(0)%ncs' )         
     4381          CASE ( 'surf_h(0)%ncs' )
    41874382             IF ( ALLOCATED( surf_h(0)%ncs )  .AND.  kk == 1 )                 &
    41884383                READ ( 13 )  surf_h(0)%ncs
    4189           CASE ( 'surf_h(0)%qrs' )         
     4384          CASE ( 'surf_h(0)%qis' )
     4385             IF ( ALLOCATED( surf_h(0)%qis )  .AND.  kk == 1 )                 &
     4386                READ ( 13 )  surf_h(0)%qis
     4387          CASE ( 'surf_h(0)%nis' )
     4388             IF ( ALLOCATED( surf_h(0)%nis )  .AND.  kk == 1 )                 &
     4389                READ ( 13 )  surf_h(0)%nis
     4390          CASE ( 'surf_h(0)%qrs' )
    41904391             IF ( ALLOCATED( surf_h(0)%qrs )  .AND.  kk == 1 )                 &
    41914392                READ ( 13 )  surf_h(0)%qrs
    4192           CASE ( 'surf_h(0)%nrs' )         
     4393          CASE ( 'surf_h(0)%nrs' )
    41934394             IF ( ALLOCATED( surf_h(0)%nrs )  .AND.  kk == 1 )                 &
    41944395                READ ( 13 )  surf_h(0)%nrs
    4195           CASE ( 'surf_h(0)%ol' )         
     4396          CASE ( 'surf_h(0)%ol' )
    41964397             IF ( ALLOCATED( surf_h(0)%ol )  .AND.  kk == 1 )                  &
    41974398                READ ( 13 )  surf_h(0)%ol
    4198           CASE ( 'surf_h(0)%rib' )         
     4399          CASE ( 'surf_h(0)%rib' )
    41994400             IF ( ALLOCATED( surf_h(0)%rib )  .AND.  kk == 1 )                 &
    42004401                READ ( 13 )  surf_h(0)%rib
    4201           CASE ( 'surf_h(0)%pt_surface' )         
     4402          CASE ( 'surf_h(0)%pt_surface' )
    42024403             IF ( ALLOCATED( surf_h(0)%pt_surface )  .AND.  kk == 1 )          &
    42034404                READ ( 13 )  surf_h(0)%pt_surface
    4204           CASE ( 'surf_h(0)%q_surface' )         
     4405          CASE ( 'surf_h(0)%q_surface' )
    42054406             IF ( ALLOCATED( surf_h(0)%q_surface )  .AND.  kk == 1 )           &
    42064407                READ ( 13 )  surf_h(0)%q_surface
    4207           CASE ( 'surf_h(0)%vpt_surface' )         
     4408          CASE ( 'surf_h(0)%vpt_surface' )
    42084409             IF ( ALLOCATED( surf_h(0)%vpt_surface )  .AND.  kk == 1 )         &
    42094410                READ ( 13 )  surf_h(0)%vpt_surface
    4210           CASE ( 'surf_h(0)%usws' )         
     4411          CASE ( 'surf_h(0)%usws' )
    42114412             IF ( ALLOCATED( surf_h(0)%usws )  .AND.  kk == 1 )                &
    42124413                READ ( 13 )  surf_h(0)%usws
    4213           CASE ( 'surf_h(0)%vsws' )         
     4414          CASE ( 'surf_h(0)%vsws' )
    42144415             IF ( ALLOCATED( surf_h(0)%vsws )  .AND.  kk == 1 )                &
    42154416                READ ( 13 )  surf_h(0)%vsws
    4216           CASE ( 'surf_h(0)%shf' )         
     4417          CASE ( 'surf_h(0)%shf' )
    42174418             IF ( ALLOCATED( surf_h(0)%shf )  .AND.  kk == 1 )                 &
    42184419                READ ( 13 )  surf_h(0)%shf
    4219           CASE ( 'surf_h(0)%qsws' )         
     4420          CASE ( 'surf_h(0)%qsws' )
    42204421             IF ( ALLOCATED( surf_h(0)%qsws )  .AND.  kk == 1 )                &
    42214422                READ ( 13 )  surf_h(0)%qsws
    4222           CASE ( 'surf_h(0)%ssws' )         
     4423          CASE ( 'surf_h(0)%ssws' )
    42234424             IF ( ALLOCATED( surf_h(0)%ssws )  .AND.  kk == 1 )                &
    42244425                READ ( 13 )  surf_h(0)%ssws
     
    42264427             IF ( ALLOCATED( surf_h(0)%css )  .AND.  kk == 1 )                 &
    42274428                READ ( 13 )  surf_h(0)%css
    4228           CASE ( 'surf_h(0)%cssws' )         
     4429          CASE ( 'surf_h(0)%cssws' )
    42294430             IF ( ALLOCATED( surf_h(0)%cssws )  .AND.  kk == 1 )               &
    42304431                READ ( 13 )  surf_h(0)%cssws
    4231           CASE ( 'surf_h(0)%qcsws' )         
     4432          CASE ( 'surf_h(0)%qcsws' )
    42324433             IF ( ALLOCATED( surf_h(0)%qcsws )  .AND.  kk == 1 )               &
    42334434                READ ( 13 )  surf_h(0)%qcsws
    4234           CASE ( 'surf_h(0)%ncsws' )         
     4435          CASE ( 'surf_h(0)%ncsws' )
    42354436             IF ( ALLOCATED( surf_h(0)%ncsws )  .AND.  kk == 1 )               &
    42364437                READ ( 13 )  surf_h(0)%ncsws
    4237           CASE ( 'surf_h(0)%qrsws' )         
     4438          CASE ( 'surf_h(0)%qisws' )
     4439             IF ( ALLOCATED( surf_h(0)%qisws )  .AND.  kk == 1 )               &
     4440                READ ( 13 )  surf_h(0)%qisws
     4441          CASE ( 'surf_h(0)%nisws' )
     4442             IF ( ALLOCATED( surf_h(0)%nisws )  .AND.  kk == 1 )               &
     4443                READ ( 13 )  surf_h(0)%nisws
     4444          CASE ( 'surf_h(0)%qrsws' )
    42384445             IF ( ALLOCATED( surf_h(0)%qrsws )  .AND.  kk == 1 )               &
    42394446                READ ( 13 )  surf_h(0)%qrsws
    4240           CASE ( 'surf_h(0)%nrsws' )         
     4447          CASE ( 'surf_h(0)%nrsws' )
    42414448             IF ( ALLOCATED( surf_h(0)%nrsws )  .AND.  kk == 1 )               &
    42424449                READ ( 13 )  surf_h(0)%nrsws
    4243           CASE ( 'surf_h(0)%sasws' )         
     4450          CASE ( 'surf_h(0)%sasws' )
    42444451             IF ( ALLOCATED( surf_h(0)%sasws )  .AND.  kk == 1 )               &
    42454452                READ ( 13 )  surf_h(0)%sasws
    42464453
    4247           CASE ( 'surf_h(1)%start_index' )   
     4454          CASE ( 'surf_h(1)%start_index' )
    42484455             IF ( kk == 1 )                                                    &
    42494456                READ ( 13 )  surf_h(1)%start_index
    42504457             l = 1
    4251           CASE ( 'surf_h(1)%end_index' )   
     4458          CASE ( 'surf_h(1)%end_index' )
    42524459             IF ( kk == 1 )                                                    &
    42534460                READ ( 13 )  surf_h(1)%end_index
    4254           CASE ( 'surf_h(1)%us' )         
     4461          CASE ( 'surf_h(1)%us' )
    42554462             IF ( ALLOCATED( surf_h(1)%us )  .AND.  kk == 1 )                  &
    42564463                READ ( 13 )  surf_h(1)%us
    4257           CASE ( 'surf_h(1)%ts' )         
     4464          CASE ( 'surf_h(1)%ts' )
    42584465             IF ( ALLOCATED( surf_h(1)%ts )  .AND.  kk == 1 )                  &
    42594466                READ ( 13 )  surf_h(1)%ts
    4260           CASE ( 'surf_h(1)%qs' )         
     4467          CASE ( 'surf_h(1)%qs' )
    42614468             IF ( ALLOCATED( surf_h(1)%qs )  .AND.  kk == 1 )                  &
    42624469                READ ( 13 )  surf_h(1)%qs
    4263           CASE ( 'surf_h(1)%ss' )         
     4470          CASE ( 'surf_h(1)%ss' )
    42644471             IF ( ALLOCATED( surf_h(1)%ss )  .AND.  kk == 1 )                  &
    42654472                READ ( 13 )  surf_h(1)%ss
    4266           CASE ( 'surf_h(1)%qcs' )         
     4473          CASE ( 'surf_h(1)%qcs' )
    42674474             IF ( ALLOCATED( surf_h(1)%qcs )  .AND.  kk == 1 )                 &
    42684475                READ ( 13 )  surf_h(1)%qcs
    4269           CASE ( 'surf_h(1)%ncs' )         
     4476          CASE ( 'surf_h(1)%ncs' )
    42704477             IF ( ALLOCATED( surf_h(1)%ncs )  .AND.  kk == 1 )                 &
    42714478                READ ( 13 )  surf_h(1)%ncs
    4272           CASE ( 'surf_h(1)%qrs' )         
     4479          CASE ( 'surf_h(1)%qis' )
     4480             IF ( ALLOCATED( surf_h(1)%qis )  .AND.  kk == 1 )                 &
     4481                READ ( 13 )  surf_h(1)%qis
     4482          CASE ( 'surf_h(1)%nis' )
     4483             IF ( ALLOCATED( surf_h(1)%nis )  .AND.  kk == 1 )                 &
     4484                READ ( 13 )  surf_h(1)%nis
     4485          CASE ( 'surf_h(1)%qrs' )
    42734486             IF ( ALLOCATED( surf_h(1)%qrs )  .AND.  kk == 1 )                 &
    42744487                READ ( 13 )  surf_h(1)%qrs
    4275           CASE ( 'surf_h(1)%nrs' )         
     4488          CASE ( 'surf_h(1)%nrs' )
    42764489             IF ( ALLOCATED( surf_h(1)%nrs )  .AND.  kk == 1 )                 &
    42774490                READ ( 13 )  surf_h(1)%nrs
    4278           CASE ( 'surf_h(1)%ol' )         
     4491          CASE ( 'surf_h(1)%ol' )
    42794492             IF ( ALLOCATED( surf_h(1)%ol )  .AND.  kk == 1 )                  &
    42804493                READ ( 13 )  surf_h(1)%ol
    4281           CASE ( 'surf_h(1)%rib' )         
     4494          CASE ( 'surf_h(1)%rib' )
    42824495             IF ( ALLOCATED( surf_h(1)%rib )  .AND.  kk == 1 )                 &
    42834496                READ ( 13 )  surf_h(1)%rib
    4284           CASE ( 'surf_h(1)%pt_surface' )         
     4497          CASE ( 'surf_h(1)%pt_surface' )
    42854498             IF ( ALLOCATED( surf_h(1)%pt_surface )  .AND.  kk == 1 )          &
    42864499                READ ( 13 )  surf_h(1)%pt_surface
    4287           CASE ( 'surf_h(1)%q_surface' )         
     4500          CASE ( 'surf_h(1)%q_surface' )
    42884501             IF ( ALLOCATED( surf_h(1)%q_surface )  .AND.  kk == 1 )           &
    42894502                READ ( 13 )  surf_h(1)%q_surface
    4290           CASE ( 'surf_h(1)%vpt_surface' )         
     4503          CASE ( 'surf_h(1)%vpt_surface' )
    42914504             IF ( ALLOCATED( surf_h(1)%vpt_surface )  .AND.  kk == 1 )         &
    42924505                READ ( 13 )  surf_h(1)%vpt_surface
    4293           CASE ( 'surf_h(1)%usws' )         
     4506          CASE ( 'surf_h(1)%usws' )
    42944507             IF ( ALLOCATED( surf_h(1)%usws )  .AND.  kk == 1 )                &
    42954508                READ ( 13 )  surf_h(1)%usws
    4296           CASE ( 'surf_h(1)%vsws' )         
     4509          CASE ( 'surf_h(1)%vsws' )
    42974510             IF ( ALLOCATED( surf_h(1)%vsws )  .AND.  kk == 1 )                &
    42984511                READ ( 13 )  surf_h(1)%vsws
    4299           CASE ( 'surf_h(1)%shf' )         
     4512          CASE ( 'surf_h(1)%shf' )
    43004513             IF ( ALLOCATED( surf_h(1)%shf )  .AND.  kk == 1 )                 &
    43014514                READ ( 13 )  surf_h(1)%shf
    4302           CASE ( 'surf_h(1)%qsws' )         
     4515          CASE ( 'surf_h(1)%qsws' )
    43034516             IF ( ALLOCATED( surf_h(1)%qsws )  .AND.  kk == 1 )                &
    43044517                READ ( 13 )  surf_h(1)%qsws
    4305           CASE ( 'surf_h(1)%ssws' )         
     4518          CASE ( 'surf_h(1)%ssws' )
    43064519             IF ( ALLOCATED( surf_h(1)%ssws )  .AND.  kk == 1 )                &
    43074520                READ ( 13 )  surf_h(1)%ssws
     
    43094522             IF ( ALLOCATED( surf_h(1)%css )  .AND.  kk == 1 )                 &
    43104523                READ ( 13 )  surf_h(1)%css
    4311           CASE ( 'surf_h(1)%cssws' )         
     4524          CASE ( 'surf_h(1)%cssws' )
    43124525             IF ( ALLOCATED( surf_h(1)%cssws )  .AND.  kk == 1 )               &
    43134526                READ ( 13 )  surf_h(1)%cssws
    4314           CASE ( 'surf_h(1)%qcsws' )         
     4527          CASE ( 'surf_h(1)%qcsws' )
    43154528             IF ( ALLOCATED( surf_h(1)%qcsws )  .AND.  kk == 1 )               &
    43164529                READ ( 13 )  surf_h(1)%qcsws
    4317           CASE ( 'surf_h(1)%ncsws' )         
     4530          CASE ( 'surf_h(1)%ncsws' )
    43184531             IF ( ALLOCATED( surf_h(1)%ncsws )  .AND.  kk == 1 )               &
    43194532                READ ( 13 )  surf_h(1)%ncsws
    4320           CASE ( 'surf_h(1)%qrsws' )         
     4533          CASE ( 'surf_h(1)%qisws' )
     4534             IF ( ALLOCATED( surf_h(1)%qisws )  .AND.  kk == 1 )               &
     4535                READ ( 13 )  surf_h(1)%qisws
     4536          CASE ( 'surf_h(1)%nisws' )
     4537             IF ( ALLOCATED( surf_h(1)%nisws )  .AND.  kk == 1 )               &
     4538                READ ( 13 )  surf_h(1)%nisws
     4539          CASE ( 'surf_h(1)%qrsws' )
    43214540             IF ( ALLOCATED( surf_h(1)%qrsws )  .AND.  kk == 1 )               &
    43224541                READ ( 13 )  surf_h(1)%qrsws
    4323           CASE ( 'surf_h(1)%nrsws' )         
     4542          CASE ( 'surf_h(1)%nrsws' )
    43244543             IF ( ALLOCATED( surf_h(1)%nrsws )  .AND.  kk == 1 )               &
    43254544                READ ( 13 )  surf_h(1)%nrsws
    4326           CASE ( 'surf_h(1)%sasws' )         
     4545          CASE ( 'surf_h(1)%sasws' )
    43274546             IF ( ALLOCATED( surf_h(1)%sasws )  .AND.  kk == 1 )               &
    43284547                READ ( 13 )  surf_h(1)%sasws
    43294548
    4330           CASE ( 'surf_h(2)%start_index' )   
     4549          CASE ( 'surf_h(2)%start_index' )
    43314550             IF ( kk == 1 )                                                    &
    43324551                READ ( 13 )  surf_h(2)%start_index
    43334552             l = 2
    4334           CASE ( 'surf_h(2)%end_index' )   
     4553          CASE ( 'surf_h(2)%end_index' )
    43354554             IF ( kk == 1 )                                                    &
    43364555                READ ( 13 )  surf_h(2)%end_index
    4337           CASE ( 'surf_h(2)%us' )         
     4556          CASE ( 'surf_h(2)%us' )
    43384557             IF ( ALLOCATED( surf_h(2)%us )  .AND.  kk == 1 )                  &
    43394558                READ ( 13 )  surf_h(2)%us
    4340           CASE ( 'surf_h(2)%ts' )         
     4559          CASE ( 'surf_h(2)%ts' )
    43414560             IF ( ALLOCATED( surf_h(2)%ts )  .AND.  kk == 1 )                  &
    43424561                READ ( 13 )  surf_h(2)%ts
    4343           CASE ( 'surf_h(2)%qs' )       
     4562          CASE ( 'surf_h(2)%qs' )
    43444563             IF ( ALLOCATED( surf_h(2)%qs )  .AND.  kk == 1 )                  &
    43454564                READ ( 13 )  surf_h(2)%qs
    4346           CASE ( 'surf_h(2)%ss' )         
     4565          CASE ( 'surf_h(2)%ss' )
    43474566             IF ( ALLOCATED( surf_h(2)%ss )  .AND.  kk == 1 )                  &
    43484567                READ ( 13 )  surf_h(2)%ss
    4349           CASE ( 'surf_h(2)%qcs' )         
     4568          CASE ( 'surf_h(2)%qcs' )
    43504569             IF ( ALLOCATED( surf_h(2)%qcs )  .AND.  kk == 1 )                 &
    43514570                READ ( 13 )  surf_h(2)%qcs
    4352           CASE ( 'surf_h(2)%ncs' )         
     4571          CASE ( 'surf_h(2)%ncs' )
    43534572             IF ( ALLOCATED( surf_h(2)%ncs )  .AND.  kk == 1 )                 &
    43544573                READ ( 13 )  surf_h(2)%ncs
    4355           CASE ( 'surf_h(2)%qrs' )         
     4574          CASE ( 'surf_h(2)%qis' )
     4575             IF ( ALLOCATED( surf_h(2)%qis )  .AND.  kk == 1 )                 &
     4576                READ ( 13 )  surf_h(2)%qis
     4577          CASE ( 'surf_h(2)%nis' )
     4578             IF ( ALLOCATED( surf_h(2)%nis )  .AND.  kk == 1 )                 &
     4579                READ ( 13 )  surf_h(2)%nis
     4580          CASE ( 'surf_h(2)%qrs' )
    43564581             IF ( ALLOCATED( surf_h(2)%qrs )  .AND.  kk == 1 )                 &
    43574582                READ ( 13 )  surf_h(2)%qrs
    4358           CASE ( 'surf_h(2)%nrs' )         
     4583          CASE ( 'surf_h(2)%nrs' )
    43594584             IF ( ALLOCATED( surf_h(2)%nrs )  .AND.  kk == 1 )                 &
    43604585                READ ( 13 )  surf_h(2)%nrs
    4361           CASE ( 'surf_h(2)%ol' )         
     4586          CASE ( 'surf_h(2)%ol' )
    43624587             IF ( ALLOCATED( surf_h(2)%ol )  .AND.  kk == 1 )                  &
    43634588                READ ( 13 )  surf_h(2)%ol
    4364           CASE ( 'surf_h(2)%rib' )         
     4589          CASE ( 'surf_h(2)%rib' )
    43654590             IF ( ALLOCATED( surf_h(2)%rib )  .AND.  kk == 1 )                 &
    43664591                READ ( 13 )  surf_h(2)%rib
    4367           CASE ( 'surf_h(2)%pt_surface' )         
     4592          CASE ( 'surf_h(2)%pt_surface' )
    43684593             IF ( ALLOCATED( surf_h(2)%pt_surface )  .AND.  kk == 1 )          &
    43694594                READ ( 13 )  surf_h(2)%pt_surface
    4370           CASE ( 'surf_h(2)%q_surface' )         
     4595          CASE ( 'surf_h(2)%q_surface' )
    43714596             IF ( ALLOCATED( surf_h(2)%q_surface )  .AND.  kk == 1 )           &
    43724597                READ ( 13 )  surf_h(2)%q_surface
    4373           CASE ( 'surf_h(2)%vpt_surface' )         
     4598          CASE ( 'surf_h(2)%vpt_surface' )
    43744599             IF ( ALLOCATED( surf_h(2)%vpt_surface )  .AND.  kk == 1 )         &
    43754600                READ ( 13 )  surf_h(2)%vpt_surface
    4376           CASE ( 'surf_h(2)%usws' )         
     4601          CASE ( 'surf_h(2)%usws' )
    43774602             IF ( ALLOCATED( surf_h(2)%usws )  .AND.  kk == 1 )                &
    43784603                READ ( 13 )  surf_h(2)%usws
    4379           CASE ( 'surf_h(2)%vsws' )         
     4604          CASE ( 'surf_h(2)%vsws' )
    43804605             IF ( ALLOCATED( surf_h(2)%vsws )  .AND.  kk == 1 )                &
    43814606                READ ( 13 )  surf_h(2)%vsws
    4382           CASE ( 'surf_h(2)%shf' )         
     4607          CASE ( 'surf_h(2)%shf' )
    43834608             IF ( ALLOCATED( surf_h(2)%shf )  .AND.  kk == 1 )                 &
    43844609                READ ( 13 )  surf_h(2)%shf
    4385           CASE ( 'surf_h(2)%qsws' )         
     4610          CASE ( 'surf_h(2)%qsws' )
    43864611             IF ( ALLOCATED( surf_h(2)%qsws )  .AND.  kk == 1 )                &
    43874612                READ ( 13 )  surf_h(2)%qsws
    4388           CASE ( 'surf_h(2)%ssws' )         
     4613          CASE ( 'surf_h(2)%ssws' )
    43894614             IF ( ALLOCATED( surf_h(2)%ssws )  .AND.  kk == 1 )                &
    43904615                READ ( 13 )  surf_h(2)%ssws
     
    43924617             IF ( ALLOCATED( surf_h(2)%css )  .AND.  kk == 1 )                 &
    43934618                READ ( 13 )  surf_h(2)%css
    4394           CASE ( 'surf_h(2)%cssws' )         
     4619          CASE ( 'surf_h(2)%cssws' )
    43954620             IF ( ALLOCATED( surf_h(2)%cssws )  .AND.  kk == 1 )               &
    43964621                READ ( 13 )  surf_h(2)%cssws
    4397           CASE ( 'surf_h(2)%qcsws' )         
     4622          CASE ( 'surf_h(2)%qcsws' )
    43984623             IF ( ALLOCATED( surf_h(2)%qcsws )  .AND.  kk == 1 )               &
    43994624                READ ( 13 )  surf_h(2)%qcsws
    4400           CASE ( 'surf_h(2)%ncsws' )         
     4625          CASE ( 'surf_h(2)%ncsws' )
    44014626             IF ( ALLOCATED( surf_h(2)%ncsws )  .AND.  kk == 1 )               &
    44024627                READ ( 13 )  surf_h(2)%ncsws
    4403           CASE ( 'surf_h(2)%qrsws' )         
     4628          CASE ( 'surf_h(2)%qisws' )
     4629             IF ( ALLOCATED( surf_h(2)%qisws )  .AND.  kk == 1 )               &
     4630                READ ( 13 )  surf_h(2)%qisws
     4631          CASE ( 'surf_h(2)%nisws' )
     4632             IF ( ALLOCATED( surf_h(2)%nisws )  .AND.  kk == 1 )               &
     4633                READ ( 13 )  surf_h(2)%nisws
     4634          CASE ( 'surf_h(2)%qrsws' )
    44044635             IF ( ALLOCATED( surf_h(2)%qrsws )  .AND.  kk == 1 )               &
    44054636                READ ( 13 )  surf_h(2)%qrsws
    4406           CASE ( 'surf_h(2)%nrsws' )         
     4637          CASE ( 'surf_h(2)%nrsws' )
    44074638             IF ( ALLOCATED( surf_h(2)%nrsws )  .AND.  kk == 1 )               &
    44084639                READ ( 13 )  surf_h(2)%nrsws
    4409           CASE ( 'surf_h(2)%sasws' )         
     4640          CASE ( 'surf_h(2)%sasws' )
    44104641             IF ( ALLOCATED( surf_h(2)%sasws )  .AND.  kk == 1 )               &
    44114642                READ ( 13 )  surf_h(2)%sasws
    44124643
    4413           CASE ( 'surf_v(0)%start_index' )   
     4644          CASE ( 'surf_v(0)%start_index' )
    44144645             IF ( kk == 1 )                                                    &
    44154646                READ ( 13 )  surf_v(0)%start_index
     
    44174648             horizontal_surface = .FALSE.
    44184649             vertical_surface   = .TRUE.
    4419           CASE ( 'surf_v(0)%end_index' )   
     4650          CASE ( 'surf_v(0)%end_index' )
    44204651             IF ( kk == 1 )                                                    &
    44214652                READ ( 13 )  surf_v(0)%end_index
    4422           CASE ( 'surf_v(0)%us' )         
     4653          CASE ( 'surf_v(0)%us' )
    44234654             IF ( ALLOCATED( surf_v(0)%us )  .AND.  kk == 1 )                  &
    44244655                READ ( 13 )  surf_v(0)%us
    4425           CASE ( 'surf_v(0)%ts' )         
     4656          CASE ( 'surf_v(0)%ts' )
    44264657             IF ( ALLOCATED( surf_v(0)%ts )  .AND.  kk == 1 )                  &
    44274658                READ ( 13 )  surf_v(0)%ts
    4428           CASE ( 'surf_v(0)%qs' )         
     4659          CASE ( 'surf_v(0)%qs' )
    44294660             IF ( ALLOCATED( surf_v(0)%qs )  .AND.  kk == 1 )                  &
    44304661                READ ( 13 )  surf_v(0)%qs
    4431           CASE ( 'surf_v(0)%ss' )         
     4662          CASE ( 'surf_v(0)%ss' )
    44324663             IF ( ALLOCATED( surf_v(0)%ss )  .AND.  kk == 1 )                  &
    44334664                READ ( 13 )  surf_v(0)%ss
    4434           CASE ( 'surf_v(0)%qcs' )         
     4665          CASE ( 'surf_v(0)%qcs' )
    44354666             IF ( ALLOCATED( surf_v(0)%qcs )  .AND.  kk == 1 )                 &
    44364667                READ ( 13 )  surf_v(0)%qcs
    4437           CASE ( 'surf_v(0)%ncs' )         
     4668          CASE ( 'surf_v(0)%ncs' )
    44384669             IF ( ALLOCATED( surf_v(0)%ncs )  .AND.  kk == 1 )                 &
    44394670                READ ( 13 )  surf_v(0)%ncs
    4440           CASE ( 'surf_v(0)%qrs' )         
     4671          CASE ( 'surf_v(0)%qis' )
     4672             IF ( ALLOCATED( surf_v(0)%qis )  .AND.  kk == 1 )                 &
     4673                READ ( 13 )  surf_v(0)%qis
     4674          CASE ( 'surf_v(0)%nis' )
     4675             IF ( ALLOCATED( surf_v(0)%nis )  .AND.  kk == 1 )                 &
     4676                READ ( 13 )  surf_v(0)%nis
     4677          CASE ( 'surf_v(0)%qrs' )
    44414678             IF ( ALLOCATED( surf_v(0)%qrs )  .AND.  kk == 1 )                 &
    44424679                READ ( 13 )  surf_v(0)%qrs
    4443           CASE ( 'surf_v(0)%nrs' )         
     4680          CASE ( 'surf_v(0)%nrs' )
    44444681             IF ( ALLOCATED( surf_v(0)%nrs )  .AND.  kk == 1 )                 &
    44454682                READ ( 13 )  surf_v(0)%nrs
    4446           CASE ( 'surf_v(0)%ol' )         
     4683          CASE ( 'surf_v(0)%ol' )
    44474684             IF ( ALLOCATED( surf_v(0)%ol )  .AND.  kk == 1 )                  &
    44484685                READ ( 13 )  surf_v(0)%ol
    4449           CASE ( 'surf_v(0)%rib' )         
     4686          CASE ( 'surf_v(0)%rib' )
    44504687             IF ( ALLOCATED( surf_v(0)%rib )  .AND.  kk == 1 )                 &
    44514688                READ ( 13 )  surf_v(0)%rib
    4452           CASE ( 'surf_v(0)%pt_surface' )         
     4689          CASE ( 'surf_v(0)%pt_surface' )
    44534690             IF ( ALLOCATED( surf_v(0)%pt_surface )  .AND.  kk == 1 )          &
    44544691                READ ( 13 )  surf_v(0)%pt_surface
    4455           CASE ( 'surf_v(0)%q_surface' )         
     4692          CASE ( 'surf_v(0)%q_surface' )
    44564693             IF ( ALLOCATED( surf_v(0)%q_surface )  .AND.  kk == 1 )           &
    44574694                READ ( 13 )  surf_v(0)%q_surface
    4458           CASE ( 'surf_v(0)%vpt_surface' )         
     4695          CASE ( 'surf_v(0)%vpt_surface' )
    44594696             IF ( ALLOCATED( surf_v(0)%vpt_surface )  .AND.  kk == 1 )         &
    44604697                READ ( 13 )  surf_v(0)%vpt_surface
    4461           CASE ( 'surf_v(0)%shf' )         
     4698          CASE ( 'surf_v(0)%shf' )
    44624699             IF ( ALLOCATED( surf_v(0)%shf )  .AND.  kk == 1 )                 &
    44634700                READ ( 13 )  surf_v(0)%shf
    4464           CASE ( 'surf_v(0)%qsws' )         
     4701          CASE ( 'surf_v(0)%qsws' )
    44654702             IF ( ALLOCATED( surf_v(0)%qsws )  .AND.  kk == 1 )                &
    44664703                READ ( 13 )  surf_v(0)%qsws
    4467           CASE ( 'surf_v(0)%ssws' )         
     4704          CASE ( 'surf_v(0)%ssws' )
    44684705             IF ( ALLOCATED( surf_v(0)%ssws )  .AND.  kk == 1 )                &
    44694706                READ ( 13 )  surf_v(0)%ssws
    4470           CASE ( 'surf_v(0)%css' ) 
     4707          CASE ( 'surf_v(0)%css' )
    44714708             IF ( ALLOCATED( surf_v(0)%css )  .AND.  kk == 1 )                 &
    44724709                READ ( 13 )  surf_v(0)%css
    4473           CASE ( 'surf_v(0)%cssws' )         
     4710          CASE ( 'surf_v(0)%cssws' )
    44744711             IF ( ALLOCATED( surf_v(0)%cssws )  .AND.  kk == 1 )               &
    44754712                READ ( 13 )  surf_v(0)%cssws
    4476           CASE ( 'surf_v(0)%qcsws' )         
     4713          CASE ( 'surf_v(0)%qcsws' )
    44774714             IF ( ALLOCATED( surf_v(0)%qcsws )  .AND.  kk == 1 )               &
    44784715                READ ( 13 )  surf_v(0)%qcsws
    4479           CASE ( 'surf_v(0)%ncsws' )         
     4716          CASE ( 'surf_v(0)%ncsws' )
    44804717             IF ( ALLOCATED( surf_v(0)%ncsws )  .AND.  kk == 1 )               &
    44814718                READ ( 13 )  surf_v(0)%ncsws
    4482           CASE ( 'surf_v(0)%qrsws' )         
     4719          CASE ( 'surf_v(0)%qisws' )
     4720             IF ( ALLOCATED( surf_v(0)%qisws )  .AND.  kk == 1 )               &
     4721                READ ( 13 )  surf_v(0)%qisws
     4722          CASE ( 'surf_v(0)%nisws' )
     4723             IF ( ALLOCATED( surf_v(0)%nisws )  .AND.  kk == 1 )               &
     4724                READ ( 13 )  surf_v(0)%nisws
     4725          CASE ( 'surf_v(0)%qrsws' )
    44834726             IF ( ALLOCATED( surf_v(0)%qrsws )  .AND.  kk == 1 )               &
    44844727                READ ( 13 )  surf_v(0)%qrsws
    4485           CASE ( 'surf_v(0)%nrsws' )         
     4728          CASE ( 'surf_v(0)%nrsws' )
    44864729             IF ( ALLOCATED( surf_v(0)%nrsws )  .AND.  kk == 1 )               &
    44874730                READ ( 13 )  surf_v(0)%nrsws
    4488           CASE ( 'surf_v(0)%sasws' )         
     4731          CASE ( 'surf_v(0)%sasws' )
    44894732             IF ( ALLOCATED( surf_v(0)%sasws )  .AND.  kk == 1 )               &
    44904733                READ ( 13 )  surf_v(0)%sasws
    4491           CASE ( 'surf_v(0)%mom_uv' )         
     4734          CASE ( 'surf_v(0)%mom_uv' )
    44924735             IF ( ALLOCATED( surf_v(0)%mom_flux_uv )  .AND.  kk == 1 )         &
    44934736                READ ( 13 )  surf_v(0)%mom_flux_uv
    4494           CASE ( 'surf_v(0)%mom_w' )         
     4737          CASE ( 'surf_v(0)%mom_w' )
    44954738             IF ( ALLOCATED( surf_v(0)%mom_flux_w )  .AND.  kk == 1 )          &
    44964739                READ ( 13 )  surf_v(0)%mom_flux_w
    4497           CASE ( 'surf_v(0)%mom_tke' )         
     4740          CASE ( 'surf_v(0)%mom_tke' )
    44984741             IF ( ALLOCATED( surf_v(0)%mom_flux_tke )  .AND.  kk == 1 )        &
    44994742                READ ( 13 )  surf_v(0)%mom_flux_tke
    45004743
    4501           CASE ( 'surf_v(1)%start_index' )   
     4744          CASE ( 'surf_v(1)%start_index' )
    45024745             IF ( kk == 1 )                                                    &
    45034746                READ ( 13 )  surf_v(1)%start_index
    45044747             l = 1
    4505           CASE ( 'surf_v(1)%end_index' )   
     4748          CASE ( 'surf_v(1)%end_index' )
    45064749             IF ( kk == 1 )                                                    &
    45074750                READ ( 13 )  surf_v(1)%end_index
    4508           CASE ( 'surf_v(1)%us' )         
     4751          CASE ( 'surf_v(1)%us' )
    45094752             IF ( ALLOCATED( surf_v(1)%us )  .AND.  kk == 1 )                  &
    45104753                READ ( 13 )  surf_v(1)%us
    4511           CASE ( 'surf_v(1)%ts' )         
     4754          CASE ( 'surf_v(1)%ts' )
    45124755             IF ( ALLOCATED( surf_v(1)%ts )  .AND.  kk == 1 )                  &
    45134756                READ ( 13 )  surf_v(1)%ts
    4514           CASE ( 'surf_v(1)%qs' )         
     4757          CASE ( 'surf_v(1)%qs' )
    45154758             IF ( ALLOCATED( surf_v(1)%qs )  .AND.  kk == 1 )                  &
    45164759                READ ( 13 )  surf_v(1)%qs
    4517           CASE ( 'surf_v(1)%ss' )         
     4760          CASE ( 'surf_v(1)%ss' )
    45184761             IF ( ALLOCATED( surf_v(1)%ss )  .AND.  kk == 1 )                  &
    45194762                READ ( 13 )  surf_v(1)%ss
    4520           CASE ( 'surf_v(1)%qcs' )         
     4763          CASE ( 'surf_v(1)%qcs' )
    45214764             IF ( ALLOCATED( surf_v(1)%qcs )  .AND.  kk == 1 )                 &
    45224765                READ ( 13 )  surf_v(1)%qcs
    4523           CASE ( 'surf_v(1)%ncs' )         
     4766          CASE ( 'surf_v(1)%ncs' )
    45244767             IF ( ALLOCATED( surf_v(1)%ncs )  .AND.  kk == 1 )                 &
    45254768                READ ( 13 )  surf_v(1)%ncs
    4526           CASE ( 'surf_v(1)%qrs' )         
     4769          CASE ( 'surf_v(1)%qis' )
     4770             IF ( ALLOCATED( surf_v(1)%qis )  .AND.  kk == 1 )                 &
     4771                READ ( 13 )  surf_v(1)%qis
     4772          CASE ( 'surf_v(1)%nis' )
     4773             IF ( ALLOCATED( surf_v(1)%nis )  .AND.  kk == 1 )                 &
     4774                READ ( 13 )  surf_v(1)%nis
     4775          CASE ( 'surf_v(1)%qrs' )
    45274776             IF ( ALLOCATED( surf_v(1)%qrs )  .AND.  kk == 1 )                 &
    45284777                READ ( 13 )  surf_v(1)%qrs
    4529           CASE ( 'surf_v(1)%nrs' )         
     4778          CASE ( 'surf_v(1)%nrs' )
    45304779             IF ( ALLOCATED( surf_v(1)%nrs )  .AND.  kk == 1 )                 &
    45314780                READ ( 13 )  surf_v(1)%nrs
    4532           CASE ( 'surf_v(1)%ol' )         
     4781          CASE ( 'surf_v(1)%ol' )
    45334782             IF ( ALLOCATED( surf_v(1)%ol )  .AND.  kk == 1 )                  &
    45344783                READ ( 13 )  surf_v(1)%ol
    4535           CASE ( 'surf_v(1)%rib' )         
     4784          CASE ( 'surf_v(1)%rib' )
    45364785             IF ( ALLOCATED( surf_v(1)%rib )  .AND.  kk == 1 )                 &
    45374786                READ ( 13 )  surf_v(1)%rib
    4538           CASE ( 'surf_v(1)%pt_surface' )         
     4787          CASE ( 'surf_v(1)%pt_surface' )
    45394788             IF ( ALLOCATED( surf_v(1)%pt_surface )  .AND.  kk == 1 )          &
    45404789                READ ( 13 )  surf_v(1)%pt_surface
    4541           CASE ( 'surf_v(1)%q_surface' )         
     4790          CASE ( 'surf_v(1)%q_surface' )
    45424791             IF ( ALLOCATED( surf_v(1)%q_surface )  .AND.  kk == 1 )           &
    45434792                READ ( 13 )  surf_v(1)%q_surface
    4544           CASE ( 'surf_v(1)%vpt_surface' )         
     4793          CASE ( 'surf_v(1)%vpt_surface' )
    45454794             IF ( ALLOCATED( surf_v(1)%vpt_surface )  .AND.  kk == 1 )         &
    45464795                READ ( 13 )  surf_v(1)%vpt_surface
    4547           CASE ( 'surf_v(1)%shf' )         
     4796          CASE ( 'surf_v(1)%shf' )
    45484797             IF ( ALLOCATED( surf_v(1)%shf )  .AND.  kk == 1 )                 &
    45494798                READ ( 13 )  surf_v(1)%shf
    4550           CASE ( 'surf_v(1)%qsws' )         
     4799          CASE ( 'surf_v(1)%qsws' )
    45514800             IF ( ALLOCATED( surf_v(1)%qsws )  .AND.  kk == 1 )                &
    45524801                READ ( 13 )  surf_v(1)%qsws
    4553           CASE ( 'surf_v(1)%ssws' )         
     4802          CASE ( 'surf_v(1)%ssws' )
    45544803             IF ( ALLOCATED( surf_v(1)%ssws )  .AND.  kk == 1 )                &
    45554804                READ ( 13 )  surf_v(1)%ssws
    4556           CASE ( 'surf_v(1)%css' ) 
     4805          CASE ( 'surf_v(1)%css' )
    45574806             IF ( ALLOCATED( surf_v(1)%css )  .AND.  kk == 1 )                 &
    45584807                READ ( 13 )  surf_v(1)%css
    4559           CASE ( 'surf_v(1)%cssws' )         
     4808          CASE ( 'surf_v(1)%cssws' )
    45604809             IF ( ALLOCATED( surf_v(1)%cssws )  .AND.  kk == 1 )               &
    45614810                READ ( 13 )  surf_v(1)%cssws
    4562           CASE ( 'surf_v(1)%qcsws' )         
     4811          CASE ( 'surf_v(1)%qcsws' )
    45634812             IF ( ALLOCATED( surf_v(1)%qcsws )  .AND.  kk == 1 )               &
    45644813                READ ( 13 )  surf_v(1)%qcsws
    4565           CASE ( 'surf_v(1)%ncsws' )         
     4814          CASE ( 'surf_v(1)%ncsws' )
    45664815             IF ( ALLOCATED( surf_v(1)%ncsws )  .AND.  kk == 1 )               &
    45674816                READ ( 13 )  surf_v(1)%ncsws
    4568           CASE ( 'surf_v(1)%qrsws' )         
     4817          CASE ( 'surf_v(1)%qisws' )
     4818             IF ( ALLOCATED( surf_v(1)%qisws )  .AND.  kk == 1 )               &
     4819                READ ( 13 )  surf_v(1)%qisws
     4820          CASE ( 'surf_v(1)%nisws' )
     4821             IF ( ALLOCATED( surf_v(1)%nisws )  .AND.  kk == 1 )               &
     4822                READ ( 13 )  surf_v(1)%nisws
     4823          CASE ( 'surf_v(1)%qrsws' )
    45694824             IF ( ALLOCATED( surf_v(1)%qrsws )  .AND.  kk == 1 )               &
    45704825                READ ( 13 )  surf_v(1)%qrsws
    4571           CASE ( 'surf_v(1)%nrsws' )         
     4826          CASE ( 'surf_v(1)%nrsws' )
    45724827             IF ( ALLOCATED( surf_v(1)%nrsws )  .AND.  kk == 1 )               &
    45734828                READ ( 13 )  surf_v(1)%nrsws
    4574           CASE ( 'surf_v(1)%sasws' )         
     4829          CASE ( 'surf_v(1)%sasws' )
    45754830             IF ( ALLOCATED( surf_v(1)%sasws )  .AND.  kk == 1 )               &
    45764831                READ ( 13 )  surf_v(1)%sasws
    4577           CASE ( 'surf_v(1)%mom_uv' )         
     4832          CASE ( 'surf_v(1)%mom_uv' )
    45784833             IF ( ALLOCATED( surf_v(1)%mom_flux_uv )  .AND.  kk == 1 )         &
    45794834                READ ( 13 )  surf_v(1)%mom_flux_uv
    4580           CASE ( 'surf_v(1)%mom_w' )         
     4835          CASE ( 'surf_v(1)%mom_w' )
    45814836             IF ( ALLOCATED( surf_v(1)%mom_flux_w )  .AND.  kk == 1 )          &
    45824837                READ ( 13 )  surf_v(1)%mom_flux_w
    4583           CASE ( 'surf_v(1)%mom_tke' )         
     4838          CASE ( 'surf_v(1)%mom_tke' )
    45844839             IF ( ALLOCATED( surf_v(1)%mom_flux_tke )  .AND.  kk == 1 )        &
    45854840                READ ( 13 )  surf_v(1)%mom_flux_tke
    45864841
    4587           CASE ( 'surf_v(2)%start_index' )   
     4842          CASE ( 'surf_v(2)%start_index' )
    45884843             IF ( kk == 1 )                                                    &
    45894844                READ ( 13 )  surf_v(2)%start_index
    45904845             l = 2
    4591           CASE ( 'surf_v(2)%end_index' )   
     4846          CASE ( 'surf_v(2)%end_index' )
    45924847             IF ( kk == 1 )                                                    &
    45934848                READ ( 13 )  surf_v(2)%end_index
    4594           CASE ( 'surf_v(2)%us' )         
     4849          CASE ( 'surf_v(2)%us' )
    45954850             IF ( ALLOCATED( surf_v(2)%us )  .AND.  kk == 1 )                  &
    45964851                READ ( 13 )  surf_v(2)%us
    4597           CASE ( 'surf_v(2)%ts' )         
     4852          CASE ( 'surf_v(2)%ts' )
    45984853             IF ( ALLOCATED( surf_v(2)%ts )  .AND.  kk == 1 )                  &
    45994854                READ ( 13 )  surf_v(2)%ts
    4600           CASE ( 'surf_v(2)%qs' )         
     4855          CASE ( 'surf_v(2)%qs' )
    46014856             IF ( ALLOCATED( surf_v(2)%qs )  .AND.  kk == 1 )                  &
    46024857                READ ( 13 )  surf_v(2)%qs
    4603           CASE ( 'surf_v(2)%ss' )         
     4858          CASE ( 'surf_v(2)%ss' )
    46044859             IF ( ALLOCATED( surf_v(2)%ss )  .AND.  kk == 1 )                  &
    46054860                READ ( 13 )  surf_v(2)%ss
    4606           CASE ( 'surf_v(2)%qcs' )         
     4861          CASE ( 'surf_v(2)%qcs' )
    46074862             IF ( ALLOCATED( surf_v(2)%qcs )  .AND.  kk == 1 )                 &
    46084863                READ ( 13 )  surf_v(2)%qcs
    4609           CASE ( 'surf_v(2)%ncs' )         
     4864          CASE ( 'surf_v(2)%ncs' )
    46104865             IF ( ALLOCATED( surf_v(2)%ncs )  .AND.  kk == 1 )                 &
    46114866                READ ( 13 )  surf_v(2)%ncs
    4612           CASE ( 'surf_v(2)%qrs' )         
     4867          CASE ( 'surf_v(2)%qis' )
     4868             IF ( ALLOCATED( surf_v(2)%qis )  .AND.  kk == 1 )                 &
     4869                READ ( 13 )  surf_v(2)%qis
     4870          CASE ( 'surf_v(2)%nis' )
     4871             IF ( ALLOCATED( surf_v(2)%nis )  .AND.  kk == 1 )                 &
     4872                READ ( 13 )  surf_v(2)%nis
     4873          CASE ( 'surf_v(2)%qrs' )
    46134874             IF ( ALLOCATED( surf_v(2)%qrs )  .AND.  kk == 1 )                 &
    46144875                READ ( 13 )  surf_v(2)%qrs
    4615           CASE ( 'surf_v(2)%nrs' )         
     4876          CASE ( 'surf_v(2)%nrs' )
    46164877             IF ( ALLOCATED( surf_v(2)%nrs )  .AND.  kk == 1 )                 &
    46174878                READ ( 13 )  surf_v(2)%nrs
    4618           CASE ( 'surf_v(2)%ol' )         
     4879          CASE ( 'surf_v(2)%ol' )
    46194880             IF ( ALLOCATED( surf_v(2)%ol )  .AND.  kk == 1 )                  &
    46204881                READ ( 13 )  surf_v(2)%ol
    4621           CASE ( 'surf_v(2)%rib' )         
     4882          CASE ( 'surf_v(2)%rib' )
    46224883             IF ( ALLOCATED( surf_v(2)%rib )  .AND.  kk == 1 )                 &
    46234884                READ ( 13 )  surf_v(2)%rib
    4624           CASE ( 'surf_v(2)%pt_surface' )         
     4885          CASE ( 'surf_v(2)%pt_surface' )
    46254886             IF ( ALLOCATED( surf_v(2)%pt_surface )  .AND.  kk == 1 )          &
    46264887                READ ( 13 )  surf_v(2)%pt_surface
    4627           CASE ( 'surf_v(2)%q_surface' )         
     4888          CASE ( 'surf_v(2)%q_surface' )
    46284889             IF ( ALLOCATED( surf_v(2)%q_surface )  .AND.  kk == 1 )           &
    46294890                READ ( 13 )  surf_v(2)%q_surface
    4630           CASE ( 'surf_v(2)%vpt_surface' )         
     4891          CASE ( 'surf_v(2)%vpt_surface' )
    46314892             IF ( ALLOCATED( surf_v(2)%vpt_surface )  .AND.  kk == 1 )         &
    46324893                READ ( 13 )  surf_v(2)%vpt_surface
    4633           CASE ( 'surf_v(2)%shf' )         
     4894          CASE ( 'surf_v(2)%shf' )
    46344895             IF ( ALLOCATED( surf_v(2)%shf )  .AND.  kk == 1 )                 &
    46354896                READ ( 13 )  surf_v(2)%shf
    4636           CASE ( 'surf_v(2)%qsws' )         
     4897          CASE ( 'surf_v(2)%qsws' )
    46374898             IF ( ALLOCATED( surf_v(2)%qsws )  .AND.  kk == 1 )                &
    46384899                READ ( 13 )  surf_v(2)%qsws
    4639           CASE ( 'surf_v(2)%ssws' )         
     4900          CASE ( 'surf_v(2)%ssws' )
    46404901             IF ( ALLOCATED( surf_v(2)%ssws )  .AND.  kk == 1 )                &
    46414902                READ ( 13 )  surf_v(2)%ssws
    4642           CASE ( 'surf_v(2)%css' ) 
     4903          CASE ( 'surf_v(2)%css' )
    46434904             IF ( ALLOCATED( surf_v(2)%css )  .AND.  kk == 1 )                 &
    46444905                READ ( 13 )  surf_v(2)%css
    4645           CASE ( 'surf_v(2)%cssws' )         
     4906          CASE ( 'surf_v(2)%cssws' )
    46464907             IF ( ALLOCATED( surf_v(2)%cssws )  .AND.  kk == 1 )               &
    46474908                READ ( 13 )  surf_v(2)%cssws
    4648           CASE ( 'surf_v(2)%qcsws' )         
     4909          CASE ( 'surf_v(2)%qcsws' )
    46494910             IF ( ALLOCATED( surf_v(2)%qcsws )  .AND.  kk == 1 )               &
    46504911                READ ( 13 )  surf_v(2)%qcsws
    4651           CASE ( 'surf_v(2)%ncsws' )         
     4912          CASE ( 'surf_v(2)%ncsws' )
    46524913             IF ( ALLOCATED( surf_v(2)%ncsws )  .AND.  kk == 1 )               &
    46534914                READ ( 13 )  surf_v(2)%ncsws
    4654           CASE ( 'surf_v(2)%qrsws' )         
     4915          CASE ( 'surf_v(2)%qisws' )
     4916             IF ( ALLOCATED( surf_v(2)%qisws )  .AND.  kk == 1 )               &
     4917                READ ( 13 )  surf_v(2)%qisws
     4918          CASE ( 'surf_v(2)%nisws' )
     4919             IF ( ALLOCATED( surf_v(2)%nisws )  .AND.  kk == 1 )               &
     4920                READ ( 13 )  surf_v(2)%nisws
     4921          CASE ( 'surf_v(2)%qrsws' )
    46554922             IF ( ALLOCATED( surf_v(2)%qrsws )  .AND.  kk == 1 )               &
    46564923                READ ( 13 )  surf_v(2)%qrsws
    4657           CASE ( 'surf_v(2)%nrsws' )         
     4924          CASE ( 'surf_v(2)%nrsws' )
    46584925             IF ( ALLOCATED( surf_v(2)%nrsws )  .AND.  kk == 1 )               &
    46594926                READ ( 13 )  surf_v(2)%nrsws
    4660           CASE ( 'surf_v(2)%sasws' )         
     4927          CASE ( 'surf_v(2)%sasws' )
    46614928             IF ( ALLOCATED( surf_v(2)%sasws )  .AND.  kk == 1 )               &
    46624929                READ ( 13 )  surf_v(2)%sasws
    4663           CASE ( 'surf_v(2)%mom_uv' )         
     4930          CASE ( 'surf_v(2)%mom_uv' )
    46644931             IF ( ALLOCATED( surf_v(2)%mom_flux_uv )  .AND.  kk == 1 )         &
    46654932                READ ( 13 )  surf_v(2)%mom_flux_uv
    4666           CASE ( 'surf_v(2)%mom_w' )         
     4933          CASE ( 'surf_v(2)%mom_w' )
    46674934             IF ( ALLOCATED( surf_v(2)%mom_flux_w )  .AND.  kk == 1 )          &
    46684935                READ ( 13 )  surf_v(2)%mom_flux_w
    4669           CASE ( 'surf_v(2)%mom_tke' )         
     4936          CASE ( 'surf_v(2)%mom_tke' )
    46704937             IF ( ALLOCATED( surf_v(2)%mom_flux_tke )  .AND.  kk == 1 )        &
    46714938                READ ( 13 )  surf_v(2)%mom_flux_tke
    46724939
    4673           CASE ( 'surf_v(3)%start_index' )   
     4940          CASE ( 'surf_v(3)%start_index' )
    46744941             IF ( kk == 1 )                                                    &
    46754942                READ ( 13 )  surf_v(3)%start_index
    46764943             l = 3
    4677           CASE ( 'surf_v(3)%end_index' )   
     4944          CASE ( 'surf_v(3)%end_index' )
    46784945             IF ( kk == 1 )                                                    &
    46794946                READ ( 13 )  surf_v(3)%end_index
    4680           CASE ( 'surf_v(3)%us' )         
     4947          CASE ( 'surf_v(3)%us' )
    46814948             IF ( ALLOCATED( surf_v(3)%us )  .AND.  kk == 1 )                  &
    46824949                READ ( 13 )  surf_v(3)%us
    4683           CASE ( 'surf_v(3)%ts' )         
     4950          CASE ( 'surf_v(3)%ts' )
    46844951             IF ( ALLOCATED( surf_v(3)%ts )  .AND.  kk == 1 )                  &
    46854952                READ ( 13 )  surf_v(3)%ts
    4686           CASE ( 'surf_v(3)%qs' )       
     4953          CASE ( 'surf_v(3)%qs' )
    46874954             IF ( ALLOCATED( surf_v(3)%qs )  .AND.  kk == 1 )                  &
    46884955                READ ( 13 )  surf_v(3)%qs
    4689           CASE ( 'surf_v(3)%ss' )         
     4956          CASE ( 'surf_v(3)%ss' )
    46904957             IF ( ALLOCATED( surf_v(3)%ss )  .AND.  kk == 1 )                  &
    46914958                READ ( 13 )  surf_v(3)%ss
    4692           CASE ( 'surf_v(3)%qcs' )         
     4959          CASE ( 'surf_v(3)%qcs' )
    46934960             IF ( ALLOCATED( surf_v(3)%qcs )  .AND.  kk == 1 )                 &
    46944961                READ ( 13 )  surf_v(3)%qcs
    4695           CASE ( 'surf_v(3)%ncs' )         
     4962          CASE ( 'surf_v(3)%ncs' )
    46964963             IF ( ALLOCATED( surf_v(3)%ncs )  .AND.  kk == 1 )                 &
    46974964                READ ( 13 )  surf_v(3)%ncs
    4698           CASE ( 'surf_v(3)%qrs' )         
     4965          CASE ( 'surf_v(3)%qis' )
     4966             IF ( ALLOCATED( surf_v(3)%qis )  .AND.  kk == 1 )                 &
     4967                READ ( 13 )  surf_v(3)%qis
     4968          CASE ( 'surf_v(3)%nis' )
     4969             IF ( ALLOCATED( surf_v(3)%nis )  .AND.  kk == 1 )                 &
     4970                READ ( 13 )  surf_v(3)%nis
     4971          CASE ( 'surf_v(3)%qrs' )
    46994972             IF ( ALLOCATED( surf_v(3)%qrs )  .AND.  kk == 1 )                 &
    47004973                READ ( 13 )  surf_v(3)%qrs
    4701           CASE ( 'surf_v(3)%nrs' )         
     4974          CASE ( 'surf_v(3)%nrs' )
    47024975             IF ( ALLOCATED( surf_v(3)%nrs )  .AND.  kk == 1 )                 &
    47034976                READ ( 13 )  surf_v(3)%nrs
    4704           CASE ( 'surf_v(3)%ol' )         
     4977          CASE ( 'surf_v(3)%ol' )
    47054978             IF ( ALLOCATED( surf_v(3)%ol )  .AND.  kk == 1 )                  &
    47064979                READ ( 13 )  surf_v(3)%ol
    4707           CASE ( 'surf_v(3)%rib' )         
     4980          CASE ( 'surf_v(3)%rib' )
    47084981             IF ( ALLOCATED( surf_v(3)%rib )  .AND.  kk == 1 )                 &
    47094982                READ ( 13 )  surf_v(3)%rib
    4710           CASE ( 'surf_v(3)%pt_surface' )         
     4983          CASE ( 'surf_v(3)%pt_surface' )
    47114984             IF ( ALLOCATED( surf_v(3)%pt_surface )  .AND.  kk == 1 )          &
    47124985                READ ( 13 )  surf_v(3)%pt_surface
    4713           CASE ( 'surf_v(3)%q_surface' )         
     4986          CASE ( 'surf_v(3)%q_surface' )
    47144987             IF ( ALLOCATED( surf_v(3)%q_surface )  .AND.  kk == 1 )           &
    47154988                READ ( 13 )  surf_v(3)%q_surface
    4716           CASE ( 'surf_v(3)%vpt_surface' )         
     4989          CASE ( 'surf_v(3)%vpt_surface' )
    47174990             IF ( ALLOCATED( surf_v(3)%vpt_surface )  .AND.  kk == 1 )         &
    47184991                READ ( 13 )  surf_v(3)%vpt_surface
    4719           CASE ( 'surf_v(3)%shf' )         
     4992          CASE ( 'surf_v(3)%shf' )
    47204993             IF ( ALLOCATED( surf_v(3)%shf )  .AND.  kk == 1 )                 &
    47214994                READ ( 13 )  surf_v(3)%shf
    4722           CASE ( 'surf_v(3)%qsws' )         
    4723              IF ( ALLOCATED( surf_v(3)%qsws )  .AND.  kk == 1 )                & 
     4995          CASE ( 'surf_v(3)%qsws' )
     4996             IF ( ALLOCATED( surf_v(3)%qsws )  .AND.  kk == 1 )                &
    47244997                READ ( 13 )  surf_v(3)%qsws
    4725           CASE ( 'surf_v(3)%ssws' )         
     4998          CASE ( 'surf_v(3)%ssws' )
    47264999             IF ( ALLOCATED( surf_v(3)%ssws )  .AND.  kk == 1 )                &
    47275000                READ ( 13 )  surf_v(3)%ssws
    4728           CASE ( 'surf_v(3)%css' ) 
     5001          CASE ( 'surf_v(3)%css' )
    47295002             IF ( ALLOCATED( surf_v(3)%css )  .AND.  kk == 1 )                 &
    47305003                READ ( 13 )  surf_v(3)%css
    4731           CASE ( 'surf_v(3)%cssws' )         
     5004          CASE ( 'surf_v(3)%cssws' )
    47325005             IF ( ALLOCATED( surf_v(3)%cssws )  .AND.  kk == 1 )               &
    47335006                READ ( 13 )  surf_v(3)%cssws
    4734           CASE ( 'surf_v(3)%qcsws' )         
     5007          CASE ( 'surf_v(3)%qcsws' )
    47355008             IF ( ALLOCATED( surf_v(3)%qcsws )  .AND.  kk == 1 )               &
    47365009                READ ( 13 )  surf_v(3)%qcsws
    4737           CASE ( 'surf_v(3)%ncsws' )         
     5010          CASE ( 'surf_v(3)%ncsws' )
    47385011             IF ( ALLOCATED( surf_v(3)%ncsws )  .AND.  kk == 1 )               &
    47395012                READ ( 13 )  surf_v(3)%ncsws
    4740           CASE ( 'surf_v(3)%qrsws' )         
     5013          CASE ( 'surf_v(3)%qisws' )
     5014             IF ( ALLOCATED( surf_v(3)%qisws )  .AND.  kk == 1 )               &
     5015                READ ( 13 )  surf_v(3)%qisws
     5016          CASE ( 'surf_v(3)%nisws' )
     5017             IF ( ALLOCATED( surf_v(3)%nisws )  .AND.  kk == 1 )               &
     5018                READ ( 13 )  surf_v(3)%nisws
     5019          CASE ( 'surf_v(3)%qrsws' )
    47415020             IF ( ALLOCATED( surf_v(3)%qrsws )  .AND.  kk == 1 )               &
    47425021                READ ( 13 )  surf_v(3)%qrsws
    4743           CASE ( 'surf_v(3)%nrsws' )         
     5022          CASE ( 'surf_v(3)%nrsws' )
    47445023             IF ( ALLOCATED( surf_v(3)%nrsws )  .AND.  kk == 1 )               &
    47455024                READ ( 13 )  surf_v(3)%nrsws
    4746           CASE ( 'surf_v(3)%sasws' )         
     5025          CASE ( 'surf_v(3)%sasws' )
    47475026             IF ( ALLOCATED( surf_v(3)%sasws )  .AND.  kk == 1 )               &
    47485027                READ ( 13 )  surf_v(3)%sasws
    4749           CASE ( 'surf_v(3)%mom_uv' )         
     5028          CASE ( 'surf_v(3)%mom_uv' )
    47505029             IF ( ALLOCATED( surf_v(3)%mom_flux_uv )  .AND.  kk == 1 )         &
    47515030                READ ( 13 )  surf_v(3)%mom_flux_uv
    4752           CASE ( 'surf_v(3)%mom_w' )         
     5031          CASE ( 'surf_v(3)%mom_w' )
    47535032             IF ( ALLOCATED( surf_v(3)%mom_flux_w )  .AND.  kk == 1 )          &
    47545033                READ ( 13 )  surf_v(3)%mom_flux_w
    4755           CASE ( 'surf_v(3)%mom_tke' )         
     5034          CASE ( 'surf_v(3)%mom_tke' )
    47565035             IF ( ALLOCATED( surf_v(3)%mom_flux_tke )  .AND.  kk == 1 )        &
    47575036                READ ( 13 )  surf_v(3)%mom_flux_tke
     
    47635042       END SELECT
    47645043!
    4765 !--    Redistribute surface elements on its respective type. Start with 
     5044!--    Redistribute surface elements on its respective type. Start with
    47665045!--    horizontally orientated surfaces.
    47675046       IF ( horizontal_surface  .AND.                                          &
    47685047            .NOT. INDEX( restart_string(1:length), '%start_index' ) /= 0 )     &
    47695048       THEN
    4770        
     5049
    47715050          ic = nxlc
    47725051          DO  i = nxlf, nxrf
     
    47745053             DO  j = nysf, nynf
    47755054!
    4776 !--             Determine type of surface element, i.e. default, natural, 
    4777 !--             urban, at current grid point. 
     5055!--             Determine type of surface element, i.e. default, natural,
     5056!--             urban, at current grid point.
    47785057                surf_match_def  = surf_def_h(l)%end_index(jc,ic) >=            &
    47795058                                  surf_def_h(l)%start_index(jc,ic)
    47805059                surf_match_lsm  = ( surf_lsm_h%end_index(jc,ic)  >=            &
    47815060                                    surf_lsm_h%start_index(jc,ic) )            &
    4782                              .AND.  l == 0 
     5061                             .AND.  l == 0
    47835062                surf_match_usm  = ( surf_usm_h%end_index(jc,ic)  >=            &
    47845063                                    surf_usm_h%start_index(jc,ic) )            &
    4785                              .AND.  l == 0 
     5064                             .AND.  l == 0
    47865065!
    47875066!--             Write restart data onto default-type surfaces if required.
    47885067                IF ( surf_match_def )  THEN
    47895068!
    4790 !--                Set the start index for the local surface element 
     5069!--                Set the start index for the local surface element
    47915070                   mm = surf_def_h(l)%start_index(jc,ic)
    47925071!
     
    47945073!--                and in case the local surface element mm is smaller than
    47955074!--                the local end index, assign the respective surface data
    4796 !--                to this element. 
     5075!--                to this element.
    47975076                   DO  m = surf_h(l)%start_index(j,i),                         &
    47985077                           surf_h(l)%end_index(j,i)
     
    48055084!
    48065085!--             Same for natural-type surfaces. Please note, it is implicitly
    4807 !--             assumed that natural surface elements are below urban 
     5086!--             assumed that natural surface elements are below urban
    48085087!--             urban surface elements if there are several horizontal surfaces
    4809 !--             at (j,i). An example would be bridges. 
     5088!--             at (j,i). An example would be bridges.
    48105089                IF ( surf_match_lsm )  THEN
    48115090                   mm = surf_lsm_h%start_index(jc,ic)
     
    48435122             DO  j = nysf, nynf
    48445123!
    4845 !--             Determine type of surface element, i.e. default, natural, 
    4846 !--             urban, at current grid point. 
     5124!--             Determine type of surface element, i.e. default, natural,
     5125!--             urban, at current grid point.
    48475126                surf_match_def  = surf_def_v(l)%end_index(jc,ic) >=            &
    48485127                                  surf_def_v(l)%start_index(jc,ic)
     
    48525131                                  surf_usm_v(l)%start_index(jc,ic)
    48535132!
    4854 !--             Write restart data onto default-type surfaces if required.               
     5133!--             Write restart data onto default-type surfaces if required.
    48555134                IF ( surf_match_def )  THEN
    48565135!
    4857 !--                Set the start index for the local surface element 
     5136!--                Set the start index for the local surface element
    48585137                   mm = surf_def_v(l)%start_index(jc,ic)
    48595138!
     
    48615140!--                and in case the local surface element mm is smaller than
    48625141!--                the local end index, assign the respective surface data
    4863 !--                to this element. 
     5142!--                to this element.
    48645143                   DO  m = surf_v(l)%start_index(j,i),                         &
    48655144                           surf_v(l)%end_index(j,i)
     
    48725151!
    48735152!--             Same for natural-type surfaces. Please note, it is implicitly
    4874 !--             assumed that natural surface elements are below urban 
     5153!--             assumed that natural surface elements are below urban
    48755154!--             urban surface elements if there are several vertical surfaces
    4876 !--             at (j,i). An example a terrain elevations with a building on 
     5155!--             at (j,i). An example a terrain elevations with a building on
    48775156!--             top. So far, initialization of urban surfaces below natural
    48785157!--             surfaces on the same (j,i) is not possible, so that this case
    4879 !--             cannot occur. 
     5158!--             cannot occur.
    48805159                IF ( surf_match_lsm )  THEN
    48815160                   mm = surf_lsm_v(l)%start_index(jc,ic)
     
    49185197             IMPLICIT NONE
    49195198
    4920              INTEGER(iwp)      ::  m_file      !< respective surface-element index of current surface array 
     5199             INTEGER(iwp)      ::  m_file      !< respective surface-element index of current surface array
    49215200             INTEGER(iwp)      ::  m_target    !< respecitve surface-element index of surface array on file
    49225201             INTEGER(iwp)      ::  lsp         !< running index chemical species
     
    49265205
    49275206
    4928              IF ( INDEX( restart_string(1:length), '%us' ) /= 0 )  THEN 
     5207             IF ( INDEX( restart_string(1:length), '%us' ) /= 0 )  THEN
    49295208                IF ( ALLOCATED( surf_target%us )  .AND.                        &
    4930                      ALLOCATED( surf_file%us   ) )                             & 
     5209                     ALLOCATED( surf_file%us   ) )                             &
    49315210                   surf_target%us(m_target) = surf_file%us(m_file)
    49325211             ENDIF
    49335212
    4934              IF ( INDEX( restart_string(1:length), '%ol' ) /= 0 )  THEN 
     5213             IF ( INDEX( restart_string(1:length), '%ol' ) /= 0 )  THEN
    49355214                IF ( ALLOCATED( surf_target%ol )  .AND.                        &
    4936                      ALLOCATED( surf_file%ol   ) )                             & 
     5215                     ALLOCATED( surf_file%ol   ) )                             &
    49375216                   surf_target%ol(m_target) = surf_file%ol(m_file)
    49385217             ENDIF
    49395218
    4940              IF ( INDEX( restart_string(1:length), '%pt_surface' ) /= 0 )  THEN 
     5219             IF ( INDEX( restart_string(1:length), '%pt_surface' ) /= 0 )  THEN
    49415220                IF ( ALLOCATED( surf_target%pt_surface )  .AND.                &
    4942                      ALLOCATED( surf_file%pt_surface   ) )                     & 
     5221                     ALLOCATED( surf_file%pt_surface   ) )                     &
    49435222                   surf_target%pt_surface(m_target) = surf_file%pt_surface(m_file)
    49445223             ENDIF
    4945              
    4946              IF ( INDEX( restart_string(1:length), '%q_surface' ) /= 0 )  THEN 
     5224
     5225             IF ( INDEX( restart_string(1:length), '%q_surface' ) /= 0 )  THEN
    49475226                IF ( ALLOCATED( surf_target%q_surface )  .AND.                 &
    4948                      ALLOCATED( surf_file%q_surface   ) )                      & 
     5227                     ALLOCATED( surf_file%q_surface   ) )                      &
    49495228                   surf_target%q_surface(m_target) = surf_file%q_surface(m_file)
    49505229             ENDIF
    49515230
    4952              IF ( INDEX( restart_string(1:length), '%vpt_surface' ) /= 0 )  THEN 
     5231             IF ( INDEX( restart_string(1:length), '%vpt_surface' ) /= 0 )  THEN
    49535232                IF ( ALLOCATED( surf_target%vpt_surface )  .AND.               &
    4954                      ALLOCATED( surf_file%vpt_surface   ) )                    & 
     5233                     ALLOCATED( surf_file%vpt_surface   ) )                    &
    49555234                   surf_target%vpt_surface(m_target) = surf_file%vpt_surface(m_file)
    49565235             ENDIF
    4957              
    4958              IF ( INDEX( restart_string(1:length), '%usws' ) /= 0 )  THEN 
     5236
     5237             IF ( INDEX( restart_string(1:length), '%usws' ) /= 0 )  THEN
    49595238                IF ( ALLOCATED( surf_target%usws )  .AND.                      &
    4960                      ALLOCATED( surf_file%usws   ) )                           & 
     5239                     ALLOCATED( surf_file%usws   ) )                           &
    49615240                   surf_target%usws(m_target) = surf_file%usws(m_file)
    49625241             ENDIF
    49635242
    4964              IF ( INDEX( restart_string(1:length), '%vsws' ) /= 0 )  THEN 
     5243             IF ( INDEX( restart_string(1:length), '%vsws' ) /= 0 )  THEN
    49655244                IF ( ALLOCATED( surf_target%vsws )  .AND.                      &
    4966                      ALLOCATED( surf_file%vsws   ) )                           & 
     5245                     ALLOCATED( surf_file%vsws   ) )                           &
    49675246                   surf_target%vsws(m_target) = surf_file%vsws(m_file)
    49685247             ENDIF
    49695248
    4970              IF ( INDEX( restart_string(1:length), '%ts' ) /= 0 )  THEN 
     5249             IF ( INDEX( restart_string(1:length), '%ts' ) /= 0 )  THEN
    49715250                IF ( ALLOCATED( surf_target%ts )  .AND.                        &
    4972                      ALLOCATED( surf_file%ts   ) )                             & 
     5251                     ALLOCATED( surf_file%ts   ) )                             &
    49735252                   surf_target%ts(m_target) = surf_file%ts(m_file)
    49745253             ENDIF
    49755254
    4976              IF ( INDEX( restart_string(1:length), '%shf' ) /= 0 )  THEN 
     5255             IF ( INDEX( restart_string(1:length), '%shf' ) /= 0 )  THEN
    49775256                IF ( ALLOCATED( surf_target%shf )  .AND.                       &
    4978                      ALLOCATED( surf_file%shf   ) )                            & 
     5257                     ALLOCATED( surf_file%shf   ) )                            &
    49795258                   surf_target%shf(m_target) = surf_file%shf(m_file)
    49805259             ENDIF
    49815260
    4982              IF ( INDEX( restart_string(1:length), '%qs' ) /= 0 )  THEN 
     5261             IF ( INDEX( restart_string(1:length), '%qs' ) /= 0 )  THEN
    49835262                IF ( ALLOCATED( surf_target%qs )  .AND.                        &
    4984                      ALLOCATED( surf_file%qs   ) )                             & 
     5263                     ALLOCATED( surf_file%qs   ) )                             &
    49855264                   surf_target%qs(m_target) = surf_file%qs(m_file)
    49865265             ENDIF
    49875266
    4988              IF ( INDEX( restart_string(1:length), '%qsws' ) /= 0 )  THEN 
     5267             IF ( INDEX( restart_string(1:length), '%qsws' ) /= 0 )  THEN
    49895268                IF ( ALLOCATED( surf_target%qsws )  .AND.                      &
    4990                      ALLOCATED( surf_file%qsws   ) )                           & 
     5269                     ALLOCATED( surf_file%qsws   ) )                           &
    49915270                   surf_target%qsws(m_target) = surf_file%qsws(m_file)
    49925271             ENDIF
    49935272
    4994              IF ( INDEX( restart_string(1:length), '%ss' ) /= 0 )  THEN 
     5273             IF ( INDEX( restart_string(1:length), '%ss' ) /= 0 )  THEN
    49955274                IF ( ALLOCATED( surf_target%ss )  .AND.                        &
    4996                      ALLOCATED( surf_file%ss   ) )                             & 
     5275                     ALLOCATED( surf_file%ss   ) )                             &
    49975276                   surf_target%ss(m_target) = surf_file%ss(m_file)
    49985277             ENDIF
    49995278
    5000              IF ( INDEX( restart_string(1:length), '%ssws' ) /= 0 )  THEN 
     5279             IF ( INDEX( restart_string(1:length), '%ssws' ) /= 0 )  THEN
    50015280                IF ( ALLOCATED( surf_target%ssws )  .AND.                      &
    5002                      ALLOCATED( surf_file%ssws   ) )                           & 
     5281                     ALLOCATED( surf_file%ssws   ) )                           &
    50035282                   surf_target%ssws(m_target) = surf_file%ssws(m_file)
    50045283             ENDIF
    50055284
    5006              IF ( INDEX( restart_string(1:length), '%css' ) /= 0 )  THEN 
     5285             IF ( INDEX( restart_string(1:length), '%css' ) /= 0 )  THEN
    50075286                IF ( ALLOCATED( surf_target%css )  .AND.                     &
    5008                      ALLOCATED( surf_file%css   ) )  THEN                 
     5287                     ALLOCATED( surf_file%css   ) )  THEN
    50095288                   DO  lsp = 1, nvar
    50105289                      surf_target%css(lsp,m_target) = surf_file%css(lsp,m_file)
     
    50125291                ENDIF
    50135292             ENDIF
    5014              IF ( INDEX( restart_string(1:length), '%cssws' ) /= 0 )  THEN 
     5293             IF ( INDEX( restart_string(1:length), '%cssws' ) /= 0 )  THEN
    50155294                IF ( ALLOCATED( surf_target%cssws )  .AND.                     &
    5016                      ALLOCATED( surf_file%cssws   ) )  THEN                 
     5295                     ALLOCATED( surf_file%cssws   ) )  THEN
    50175296                   DO  lsp = 1, nvar
    50185297                      surf_target%cssws(lsp,m_target) = surf_file%cssws(lsp,m_file)
     
    50215300             ENDIF
    50225301
    5023              IF ( INDEX( restart_string(1:length), '%qcs' ) /= 0 )  THEN 
     5302             IF ( INDEX( restart_string(1:length), '%qcs' ) /= 0 )  THEN
    50245303                IF ( ALLOCATED( surf_target%qcs )  .AND.                       &
    5025                      ALLOCATED( surf_file%qcs   ) )                            & 
     5304                     ALLOCATED( surf_file%qcs   ) )                            &
    50265305                  surf_target%qcs(m_target) = surf_file%qcs(m_file)
    50275306             ENDIF
    50285307
    5029              IF ( INDEX( restart_string(1:length), '%qcsws' ) /= 0 )  THEN 
     5308             IF ( INDEX( restart_string(1:length), '%qcsws' ) /= 0 )  THEN
    50305309                IF ( ALLOCATED( surf_target%qcsws )  .AND.                     &
    5031                      ALLOCATED( surf_file%qcsws   ) )                          & 
     5310                     ALLOCATED( surf_file%qcsws   ) )                          &
    50325311                   surf_target%qcsws(m_target) = surf_file%qcsws(m_file)
    50335312             ENDIF
    50345313
    5035              IF ( INDEX( restart_string(1:length), '%ncs' ) /= 0 )  THEN 
     5314             IF ( INDEX( restart_string(1:length), '%ncs' ) /= 0 )  THEN
    50365315                IF ( ALLOCATED( surf_target%ncs )  .AND.                       &
    5037                      ALLOCATED( surf_file%ncs   ) )                            & 
     5316                     ALLOCATED( surf_file%ncs   ) )                            &
    50385317                   surf_target%ncs(m_target) = surf_file%ncs(m_file)
    50395318             ENDIF
    50405319
    5041              IF ( INDEX( restart_string(1:length), '%ncsws' ) /= 0 )  THEN 
     5320             IF ( INDEX( restart_string(1:length), '%ncsws' ) /= 0 )  THEN
    50425321                IF ( ALLOCATED( surf_target%ncsws )  .AND.                     &
    5043                      ALLOCATED( surf_file%ncsws   ) )                          & 
     5322                     ALLOCATED( surf_file%ncsws   ) )                          &
    50445323                   surf_target%ncsws(m_target) = surf_file%ncsws(m_file)
    50455324             ENDIF
    50465325
    5047              IF ( INDEX( restart_string(1:length), '%qrs' ) /= 0 )  THEN
     5326             IF ( INDEX( restart_string(1:length), '%qis' ) /= 0 )  THEN
     5327                IF ( ALLOCATED( surf_target%qis )  .AND.                       &
     5328                     ALLOCATED( surf_file%qis   ) )                            &
     5329                  surf_target%qis(m_target) = surf_file%qis(m_file)
     5330             ENDIF
     5331
     5332             IF ( INDEX( restart_string(1:length), '%qisws' ) /= 0 )  THEN
     5333                IF ( ALLOCATED( surf_target%qisws )  .AND.                     &
     5334                     ALLOCATED( surf_file%qisws   ) )                          &
     5335                   surf_target%qisws(m_target) = surf_file%qisws(m_file)
     5336             ENDIF
     5337
     5338             IF ( INDEX( restart_string(1:length), '%nis' ) /= 0 )  THEN
     5339                IF ( ALLOCATED( surf_target%nis )  .AND.                       &
     5340                     ALLOCATED( surf_file%nis   ) )                            &
     5341                   surf_target%nis(m_target) = surf_file%nis(m_file)
     5342             ENDIF
     5343
     5344             IF ( INDEX( restart_string(1:length), '%nisws' ) /= 0 )  THEN
     5345                IF ( ALLOCATED( surf_target%nisws )  .AND.                     &
     5346                     ALLOCATED( surf_file%nisws   ) )                          &
     5347                   surf_target%nisws(m_target) = surf_file%nisws(m_file)
     5348             ENDIF
     5349
     5350             IF ( INDEX( restart_string(1:length), '%qrs' ) /= 0 )  THEN
    50485351                IF ( ALLOCATED( surf_target%qrs )  .AND.                       &
    5049                      ALLOCATED( surf_file%qrs   ) )                            & 
     5352                     ALLOCATED( surf_file%qrs   ) )                            &
    50505353                  surf_target%qrs(m_target) = surf_file%qrs(m_file)
    50515354             ENDIF
    50525355
    5053              IF ( INDEX( restart_string(1:length), '%qrsws' ) /= 0 )  THEN 
     5356             IF ( INDEX( restart_string(1:length), '%qrsws' ) /= 0 )  THEN
    50545357                IF ( ALLOCATED( surf_target%qrsws )  .AND.                     &
    5055                      ALLOCATED( surf_file%qrsws   ) )                          & 
     5358                     ALLOCATED( surf_file%qrsws   ) )                          &
    50565359                   surf_target%qrsws(m_target) = surf_file%qrsws(m_file)
    50575360             ENDIF
    50585361
    5059              IF ( INDEX( restart_string(1:length), '%nrs' ) /= 0 )  THEN 
     5362             IF ( INDEX( restart_string(1:length), '%nrs' ) /= 0 )  THEN
    50605363                IF ( ALLOCATED( surf_target%nrs )  .AND.                       &
    5061                      ALLOCATED( surf_file%nrs   ) )                            & 
     5364                     ALLOCATED( surf_file%nrs   ) )                            &
    50625365                   surf_target%nrs(m_target) = surf_file%nrs(m_file)
    50635366             ENDIF
    50645367
    5065              IF ( INDEX( restart_string(1:length), '%nrsws' ) /= 0 )  THEN 
     5368             IF ( INDEX( restart_string(1:length), '%nrsws' ) /= 0 )  THEN
    50665369                IF ( ALLOCATED( surf_target%nrsws )  .AND.                     &
    5067                      ALLOCATED( surf_file%nrsws   ) )                          & 
     5370                     ALLOCATED( surf_file%nrsws   ) )                          &
    50685371                   surf_target%nrsws(m_target) = surf_file%nrsws(m_file)
    50695372             ENDIF
    50705373
    5071              IF ( INDEX( restart_string(1:length), '%sasws' ) /= 0 )  THEN 
     5374             IF ( INDEX( restart_string(1:length), '%sasws' ) /= 0 )  THEN
    50725375                IF ( ALLOCATED( surf_target%sasws )  .AND.                     &
    5073                      ALLOCATED( surf_file%sasws   ) )                          & 
     5376                     ALLOCATED( surf_file%sasws   ) )                          &
    50745377                   surf_target%sasws(m_target) = surf_file%sasws(m_file)
    50755378             ENDIF
    50765379
    5077              IF ( INDEX( restart_string(1:length), '%mom_uv' ) /= 0 )  THEN 
     5380             IF ( INDEX( restart_string(1:length), '%mom_uv' ) /= 0 )  THEN
    50785381                IF ( ALLOCATED( surf_target%mom_flux_uv )  .AND.               &
    5079                      ALLOCATED( surf_file%mom_flux_uv   ) )                    & 
     5382                     ALLOCATED( surf_file%mom_flux_uv   ) )                    &
    50805383                   surf_target%mom_flux_uv(m_target) =                         &
    50815384                                           surf_file%mom_flux_uv(m_file)
    50825385             ENDIF
    50835386
    5084              IF ( INDEX( restart_string(1:length), '%mom_w' ) /= 0 )  THEN 
     5387             IF ( INDEX( restart_string(1:length), '%mom_w' ) /= 0 )  THEN
    50855388                IF ( ALLOCATED( surf_target%mom_flux_w )  .AND.                &
    5086                      ALLOCATED( surf_file%mom_flux_w   ) )                     & 
     5389                     ALLOCATED( surf_file%mom_flux_w   ) )                     &
    50875390                   surf_target%mom_flux_w(m_target) =                          &
    50885391                                           surf_file%mom_flux_w(m_file)
    50895392             ENDIF
    50905393
    5091              IF ( INDEX( restart_string(1:length), '%mom_tke' ) /= 0 )  THEN 
     5394             IF ( INDEX( restart_string(1:length), '%mom_tke' ) /= 0 )  THEN
    50925395                IF ( ALLOCATED( surf_target%mom_flux_tke )  .AND.              &
    5093                      ALLOCATED( surf_file%mom_flux_tke   ) )                   & 
     5396                     ALLOCATED( surf_file%mom_flux_tke   ) )                   &
    50945397                   surf_target%mom_flux_tke(0:1,m_target) =                    &
    50955398                                           surf_file%mom_flux_tke(0:1,m_file)
     
    51025405    END SUBROUTINE surface_rrd_local
    51035406
    5104  
     5407
    51055408!------------------------------------------------------------------------------!
    51065409! Description:
    51075410! ------------
    5108 !> Counts the number of surface elements with the same facing, required for 
     5411!> Counts the number of surface elements with the same facing, required for
    51095412!> reading and writing restart data.
    51105413!------------------------------------------------------------------------------!
     
    51295432! Description:
    51305433! ------------
    5131 !> Routine maps surface data read from file after restart - 1D arrays. 
     5434!> Routine maps surface data read from file after restart - 1D arrays.
    51325435!------------------------------------------------------------------------------!
    51335436    SUBROUTINE surface_restore_elements_1d( surf_target, surf_file,            &
     
    51405443
    51415444       IMPLICIT NONE
    5142    
     5445
    51435446       INTEGER(iwp) ::  i         !< running index along x-direction, refers to former domain size
    51445447       INTEGER(iwp) ::  ic        !< running index along x-direction, refers to current domain size
    51455448       INTEGER(iwp) ::  j         !< running index along y-direction, refers to former domain size
    5146        INTEGER(iwp) ::  jc        !< running index along y-direction, refers to former domain size       
     5449       INTEGER(iwp) ::  jc        !< running index along y-direction, refers to former domain size
    51475450       INTEGER(iwp) ::  m         !< surface-element index on file
    51485451       INTEGER(iwp) ::  mm        !< surface-element index on current subdomain
    51495452       INTEGER(iwp) ::  nxlc      !< index of left boundary on current subdomain
    5150        INTEGER(iwp) ::  nxlf      !< index of left boundary on former subdomain 
     5453       INTEGER(iwp) ::  nxlf      !< index of left boundary on former subdomain
    51515454       INTEGER(iwp) ::  nxrf      !< index of right boundary on former subdomain
    51525455       INTEGER(iwp) ::  nysc      !< index of north boundary on current subdomain
     
    51595462       INTEGER(iwp) ::  nys_on_file !< southmost index on file
    51605463
    5161        INTEGER(iwp), DIMENSION(nys:nyn,nxl:nxr) ::  start_index_c             
    5162        INTEGER(iwp), DIMENSION(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) :: & 
     5464       INTEGER(iwp), DIMENSION(nys:nyn,nxl:nxr) ::  start_index_c
     5465       INTEGER(iwp), DIMENSION(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) :: &
    51635466                            start_index_on_file   !< start index of surface elements on file
    5164        INTEGER(iwp), DIMENSION(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) :: & 
     5467       INTEGER(iwp), DIMENSION(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) :: &
    51655468                            end_index_on_file     !< end index of surface elements on file
    5166        
     5469
    51675470       REAL(wp), DIMENSION(:) ::  surf_target !< target surface type
    51685471       REAL(wp), DIMENSION(:) ::  surf_file   !< surface type on file
     
    51865489
    51875490    END SUBROUTINE surface_restore_elements_1d
    5188    
     5491
    51895492!------------------------------------------------------------------------------!
    51905493! Description:
    51915494! ------------
    51925495!> Routine maps surface data read from file after restart - 2D arrays
    5193 !------------------------------------------------------------------------------! 
     5496!------------------------------------------------------------------------------!
    51945497    SUBROUTINE surface_restore_elements_2d( surf_target, surf_file,            &
    51955498                                            start_index_c,                     &
     
    52015504
    52025505       IMPLICIT NONE
    5203    
     5506
    52045507       INTEGER(iwp) ::  i         !< running index along x-direction, refers to former domain size
    52055508       INTEGER(iwp) ::  ic        !< running index along x-direction, refers to current domain size
    52065509       INTEGER(iwp) ::  j         !< running index along y-direction, refers to former domain size
    5207        INTEGER(iwp) ::  jc        !< running index along y-direction, refers to former domain size       
     5510       INTEGER(iwp) ::  jc        !< running index along y-direction, refers to former domain size
    52085511       INTEGER(iwp) ::  m         !< surface-element index on file
    52095512       INTEGER(iwp) ::  mm        !< surface-element index on current subdomain
    52105513       INTEGER(iwp) ::  nxlc      !< index of left boundary on current subdomain
    5211        INTEGER(iwp) ::  nxlf      !< index of left boundary on former subdomain 
     5514       INTEGER(iwp) ::  nxlf      !< index of left boundary on former subdomain
    52125515       INTEGER(iwp) ::  nxrf      !< index of right boundary on former subdomain
    52135516       INTEGER(iwp) ::  nysc      !< index of north boundary on current subdomain
     
    52215524
    52225525       INTEGER(iwp), DIMENSION(nys:nyn,nxl:nxr) ::  start_index_c !< start index of surface type
    5223        INTEGER(iwp), DIMENSION(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) :: & 
     5526       INTEGER(iwp), DIMENSION(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) :: &
    52245527                            start_index_on_file   !< start index of surface elements on file
    5225        INTEGER(iwp), DIMENSION(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) :: & 
     5528       INTEGER(iwp), DIMENSION(nys_on_file:nyn_on_file,nxl_on_file:nxr_on_file) :: &
    52265529                            end_index_on_file     !< end index of surface elements on file
    5227        
     5530
    52285531       REAL(wp), DIMENSION(:,:) ::  surf_target !< target surface type
    52295532       REAL(wp), DIMENSION(:,:) ::  surf_file   !< surface type on file
    5230        
     5533
    52315534       ic = nxlc
    52325535       DO  i = nxlf, nxrf
  • palm/trunk/SOURCE/time_integration.f90

    r4472 r4502  
    2020! Current revisions:
    2121! ------------------
    22 !
    23 !
     22! 
     23! 
    2424! Former revisions:
    2525! -----------------
    2626! $Id$
     27! Implementation of ice microphysics
     28!
     29! 4472 2020-03-24 12:21:00Z Giersch
    2730! OPENACC COPYIN directive for ddx and ddy added
    2831!
     
    211214    USE arrays_3d,                                                                                 &
    212215        ONLY:  diss, diss_p, dzu, e_p, nc_p, nr_p, prho, pt, pt_p, pt_init, q, qc_p, qr_p, q_init, &
    213                q_p, ref_state, rho_ocean, sa_p, s_p, tend, u, u_p, v, vpt, v_p, w_p
     216               q_p, ref_state, rho_ocean, sa_p, s_p, tend, u, u_p, v, vpt, v_p, w_p,               &
     217               qi_p, ni_p
    214218
    215219#if defined( __parallel )  &&  ! defined( _OPENACC )
    216220    USE arrays_3d,                                                                                 &
    217         ONLY:  e, nc, nr, qc, qr, s, w
     221        ONLY:  e, nc, nr, qc, qr, s, w, qi, ni
    218222#endif
    219223
     
    224228    USE bulk_cloud_model_mod,                                                                      &
    225229        ONLY: bulk_cloud_model, calc_liquid_water_content, collision_turbulence,                   &
    226               microphysics_morrison, microphysics_seifert
     230              microphysics_morrison, microphysics_seifert, microphysics_ice_extension
    227231
    228232    USE calc_mean_profile_mod,                                                                     &
     
    432436               kh, km, momentumflux_output_conversion, nc, nr, p, ptdf_x, ptdf_y, qc, qr, rdf,     &
    433437               rdf_sc, rho_air, rho_air_zw, s, tdiss_m, te_m, tpt_m, tu_m, tv_m, tw_m, ug, u_init, &
    434                u_stokes_zu, vg, v_init, v_stokes_zu, w, zu
     438               u_stokes_zu, vg, v_init, v_stokes_zu, w, zu, qi, ni
    435439
    436440    USE control_parameters,                                                                        &
     
    444448               sums_wsus_ws_l, sums_vs2_ws_l, sums_wsvs_ws_l, sums_ws2_ws_l, sums_wspts_ws_l,      &
    445449               sums_wsqs_ws_l, sums_wssas_ws_l, sums_wsqcs_ws_l, sums_wsqrs_ws_l, sums_wsncs_ws_l, &
    446                sums_wsnrs_ws_l, sums_wsss_ws_l, weight_substep, sums_salsa_ws_l
     450               sums_wsnrs_ws_l, sums_wsss_ws_l, weight_substep, sums_salsa_ws_l,                   &
     451               sums_wsqis_ws_l, sums_wsnis_ws_l
    447452
    448453    USE surface_mod,                                                                               &
     
    571576!$ACC COPY(sums_wsqs_ws_l(nzb:nzt+1,0)) &
    572577!$ACC COPY(sums_wsqcs_ws_l(nzb:nzt+1,0)) &
     578!$ACC COPY(sums_wsqis_ws_l(nzb:nzt+1,0)) &
    573579!$ACC COPY(sums_wsqrs_ws_l(nzb:nzt+1,0)) &
    574580!$ACC COPY(sums_wsncs_ws_l(nzb:nzt+1,0)) &
     581!$ACC COPY(sums_wsnis_ws_l(nzb:nzt+1,0)) &
    575582!$ACC COPY(sums_wsnrs_ws_l(nzb:nzt+1,0)) &
    576583!$ACC COPY(sums_wsss_ws_l(nzb:nzt+1,0)) &
     
    805812                CALL exchange_horiz( nr_p, nbgp )
    806813             ENDIF
     814             IF ( bulk_cloud_model .AND. microphysics_ice_extension )  THEN
     815                CALL exchange_horiz( qi_p, nbgp )
     816                CALL exchange_horiz( ni_p, nbgp )
     817             ENDIF
    807818          ENDIF
    808819          IF ( passive_scalar )  CALL exchange_horiz( s_p, nbgp )
     
    894905                       CALL exchange_horiz( nr, nbgp )
    895906                   ENDIF
    896 
     907                   IF ( bulk_cloud_model  .AND.  microphysics_ice_extension )  THEN
     908                       CALL exchange_horiz( qi, nbgp )
     909                       CALL exchange_horiz( ni, nbgp )
     910                   ENDIF
    897911                ENDIF
    898912
     
    12191233       !$ACC HOST(sums_wsqs_ws_l(nzb:nzt+1,0)) &
    12201234       !$ACC HOST(sums_wsqcs_ws_l(nzb:nzt+1,0)) &
     1235       !$ACC HOST(sums_wsqis_ws_l(nzb:nzt+1,0)) &
    12211236       !$ACC HOST(sums_wsqrs_ws_l(nzb:nzt+1,0)) &
    12221237       !$ACC HOST(sums_wsncs_ws_l(nzb:nzt+1,0)) &
     1238       !$ACC HOST(sums_wsnis_ws_l(nzb:nzt+1,0)) &
    12231239       !$ACC HOST(sums_wsnrs_ws_l(nzb:nzt+1,0)) &
    12241240       !$ACC HOST(sums_wsss_ws_l(nzb:nzt+1,0)) &
Note: See TracChangeset for help on using the changeset viewer.