Index: palm/trunk/SOURCE/urban_surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/urban_surface_mod.f90	(revision 4238)
+++ palm/trunk/SOURCE/urban_surface_mod.f90	(revision 4245)
@@ -28,4 +28,7 @@
 ! -----------------
 ! $Id$
+! Initialize explicit per-surface parameters from building_surface_pars
+! 
+! 4238 2019-09-25 16:06:01Z suehring
 ! Indoor-model parameters for some building types adjusted in order to avoid
 ! unrealistically high indoor temperatures (S. Rissmann) 
@@ -465,5 +468,26 @@
     INTEGER(iwp) ::  ind_z0qh_gfl          = 37   !< index in input list for z0h / z0q, ground floor level
     INTEGER(iwp) ::  ind_green_type_roof   = 118  !< index in input list for type of green roof
-
+!
+!-- Indices of input attributes in building_surface_pars (except for
+!-- radiation-related, which are in radiation_model_mod)
+    INTEGER(iwp) ::  ind_s_wall_frac                 = 0  !< index for wall fraction (0-1)
+    INTEGER(iwp) ::  ind_s_win_frac                  = 1  !< index for window fraction (0-1)
+    INTEGER(iwp) ::  ind_s_green_frac_w              = 2  !< index for green fraction on wall (0-1)
+    INTEGER(iwp) ::  ind_s_green_frac_r              = 3  !< index for green fraction on roof (0-1)
+    INTEGER(iwp) ::  ind_s_lai_r                     = 4  !< index for leaf area index of green fraction
+    INTEGER(iwp) ::  ind_s_hc1                       = 5  !< index for heat capacity of wall layer 1
+    INTEGER(iwp) ::  ind_s_hc2                       = 6  !< index for heat capacity of wall layer 2
+    INTEGER(iwp) ::  ind_s_hc3                       = 7  !< index for heat capacity of wall layer 3
+    INTEGER(iwp) ::  ind_s_tc1                       = 8  !< index for thermal conducivity of wall layer 1
+    INTEGER(iwp) ::  ind_s_tc2                       = 9  !< index for thermal conducivity of wall layer 2
+    INTEGER(iwp) ::  ind_s_tc3                       = 10 !< index for thermal conducivity of wall layer 3
+    INTEGER(iwp) ::  ind_s_indoor_target_temp_summer = 11 !< index for indoor target summer temperature
+    INTEGER(iwp) ::  ind_s_indoor_target_temp_winter = 12 !< index for indoor target winter temperature
+    INTEGER(iwp) ::  ind_s_emis_wall                 = 13 !< index for emissivity of wall fraction (0-1)
+    INTEGER(iwp) ::  ind_s_emis_green                = 14 !< index for emissivity of green fraction (0-1)
+    INTEGER(iwp) ::  ind_s_emis_win                  = 15 !< index for emissivity o f window fraction (0-1)
+    INTEGER(iwp) ::  ind_s_trans                     = 16 !< index for transmissivity of window fraction (0-1)
+    INTEGER(iwp) ::  ind_s_z0                        = 17 !< index for roughness length for momentum (m)
+    INTEGER(iwp) ::  ind_s_z0qh                      = 18 !< index for roughness length for heat (m)
 
     REAL(wp)  ::  roof_height_limit = 4.0_wp         !< height for distinguish between land surfaces and roofs
@@ -3437,5 +3461,6 @@
 
         USE netcdf_data_input_mod,                                             &
-            ONLY:  building_pars_f, building_type_f, terrain_height_f
+            ONLY:  building_pars_f, building_surface_pars_f, building_type_f,  &
+                   terrain_height_f
     
         IMPLICIT NONE
@@ -3477,4 +3502,5 @@
         INTEGER(iwp) ::  ind_z0              !< index in input list for z0
         INTEGER(iwp) ::  ind_z0qh            !< index in input list for z0h / z0q
+        INTEGER(iwp) ::  is                  !< loop index input surface element
         INTEGER(iwp) ::  j                   !< loop index y-dirction
         INTEGER(iwp) ::  k                   !< loop index z-dirction
@@ -4705,4 +4731,301 @@
            ENDDO
         ENDIF 
+!
+!--     Read building surface pars. If present, they override LOD1-LOD3 building
+!--     pars where applicable
+        IF ( building_surface_pars_f%from_file )  THEN
+           DO  m = 1, surf_usm_h%ns
+              i = surf_usm_h%i(m)
+              j = surf_usm_h%j(m)
+              k = surf_usm_h%k(m)
+!
+!--           Iterate over surfaces in column, check height and orientation
+              DO  is = building_surface_pars_f%index_ji(1,j,i), &
+                       building_surface_pars_f%index_ji(2,j,i)
+                 IF ( building_surface_pars_f%coords(4,is) == -surf_usm_h%koff .AND.            &
+                      building_surface_pars_f%coords(1,is) == k )  THEN
+
+                    IF ( building_surface_pars_f%pars(ind_s_wall_frac,is) /=                     &
+                         building_surface_pars_f%fill )                                          &
+                       surf_usm_h%frac(ind_veg_wall,m) =                                         &
+                                building_surface_pars_f%pars(ind_s_wall_frac,is)
+
+                    IF ( building_surface_pars_f%pars(ind_s_green_frac_w,is) /=                  &
+                         building_surface_pars_f%fill )                                          &
+                       surf_usm_h%frac(ind_pav_green,m) =                                        &
+                                building_surface_pars_f%pars(ind_s_green_frac_w,is)
+
+                    IF ( building_surface_pars_f%pars(ind_s_green_frac_r,is) /=                  &
+                         building_surface_pars_f%fill )                                          &
+                       surf_usm_h%frac(ind_pav_green,m) =                                        &
+                                building_surface_pars_f%pars(ind_s_green_frac_r,is)
+                                !TODO clarify: why should _w and _r be on the same surface?
+
+                    IF ( building_surface_pars_f%pars(ind_s_win_frac,is) /=                      &
+                         building_surface_pars_f%fill )                                          &
+                       surf_usm_h%frac(ind_wat_win,m) =                                          &
+                                building_surface_pars_f%pars(ind_s_win_frac,is)
+
+                    IF ( building_surface_pars_f%pars(ind_s_lai_r,is) /=                         &
+                         building_surface_pars_f%fill )                                          &
+                       surf_usm_h%lai(m) =                                                       &
+                                building_surface_pars_f%pars(ind_s_lai_r,is)
+
+                    IF ( building_surface_pars_f%pars(ind_s_hc1,is) /=                           &
+                         building_surface_pars_f%fill )  THEN
+                       surf_usm_h%rho_c_wall(nzb_wall:nzb_wall+1,m) =                            &
+                                building_surface_pars_f%pars(ind_s_hc1,is)
+                       surf_usm_h%rho_c_green(nzb_wall:nzb_wall+1,m) =                           &
+                                building_surface_pars_f%pars(ind_s_hc1,is)
+                       surf_usm_h%rho_c_window(nzb_wall:nzb_wall+1,m) =                          &
+                                building_surface_pars_f%pars(ind_s_hc1,is)
+                    ENDIF
+
+                    IF ( building_surface_pars_f%pars(ind_s_hc2,is) /=                           &
+                         building_surface_pars_f%fill )  THEN
+                       surf_usm_h%rho_c_wall(nzb_wall+2,m) =                                     &
+                                building_surface_pars_f%pars(ind_s_hc2,is)
+                       surf_usm_h%rho_c_green(nzb_wall+2,m) =                                    &
+                                building_surface_pars_f%pars(ind_s_hc2,is)
+                       surf_usm_h%rho_c_window(nzb_wall+2,m) =                                   &
+                                building_surface_pars_f%pars(ind_s_hc2,is)
+                    ENDIF
+
+                    IF ( building_surface_pars_f%pars(ind_s_hc3,is) /=                           &
+                         building_surface_pars_f%fill )  THEN
+                       surf_usm_h%rho_c_wall(nzb_wall+3,m) =                                     &
+                                building_surface_pars_f%pars(ind_s_hc3,is)
+                       surf_usm_h%rho_c_green(nzb_wall+3,m) =                                    &
+                                building_surface_pars_f%pars(ind_s_hc3,is)
+                       surf_usm_h%rho_c_window(nzb_wall+3,m) =                                   &
+                                building_surface_pars_f%pars(ind_s_hc3,is)
+                    ENDIF
+
+                    IF ( building_surface_pars_f%pars(ind_s_tc1,is) /=                           &
+                         building_surface_pars_f%fill )  THEN
+                       surf_usm_h%lambda_h(nzb_wall:nzb_wall+1,m) =                              &
+                                building_surface_pars_f%pars(ind_s_tc1,is)
+                       surf_usm_h%lambda_h_green(nzb_wall:nzb_wall+1,m) =                        &
+                                building_surface_pars_f%pars(ind_s_tc1,is)
+                       surf_usm_h%lambda_h_window(nzb_wall:nzb_wall+1,m) =                       &
+                                building_surface_pars_f%pars(ind_s_tc1,is)
+                    ENDIF
+
+                    IF ( building_surface_pars_f%pars(ind_s_tc2,is) /=                           &
+                         building_surface_pars_f%fill )  THEN
+                       surf_usm_h%lambda_h(nzb_wall+2,m) =                                       &
+                                building_surface_pars_f%pars(ind_s_tc2,is)
+                       surf_usm_h%lambda_h_green(nzb_wall+2,m) =                                 &
+                                building_surface_pars_f%pars(ind_s_tc2,is)
+                       surf_usm_h%lambda_h_window(nzb_wall+2,m) =                                &
+                                building_surface_pars_f%pars(ind_s_tc2,is)
+                    ENDIF
+
+                    IF ( building_surface_pars_f%pars(ind_s_tc3,is) /=                           &
+                         building_surface_pars_f%fill )  THEN
+                       surf_usm_h%lambda_h(nzb_wall+3,m) =                                       &
+                                building_surface_pars_f%pars(ind_s_tc3,is)
+                       surf_usm_h%lambda_h_green(nzb_wall+3,m) =                                 &
+                                building_surface_pars_f%pars(ind_s_tc3,is)
+                       surf_usm_h%lambda_h_window(nzb_wall+3,m) =                                &
+                                building_surface_pars_f%pars(ind_s_tc3,is)
+                    ENDIF
+
+                    IF ( building_surface_pars_f%pars(ind_s_indoor_target_temp_summer,is) /=     &
+                         building_surface_pars_f%fill )                                          &
+                       surf_usm_h%target_temp_summer(m) =                                        &
+                                building_surface_pars_f%pars(ind_s_indoor_target_temp_summer,is)
+
+                    IF ( building_surface_pars_f%pars(ind_s_indoor_target_temp_winter,is) /=     &
+                         building_surface_pars_f%fill )                                          &
+                       surf_usm_h%target_temp_winter(m) =                                        &
+                                building_surface_pars_f%pars(ind_s_indoor_target_temp_winter,is)
+
+                    IF ( building_surface_pars_f%pars(ind_s_emis_wall,is) /=                     &
+                         building_surface_pars_f%fill )                                          &
+                       surf_usm_h%emissivity(ind_veg_wall,m) =                                   &
+                                building_surface_pars_f%pars(ind_s_emis_wall,is)
+
+                    IF ( building_surface_pars_f%pars(ind_s_emis_green,is) /=                    &
+                         building_surface_pars_f%fill )                                          &
+                       surf_usm_h%emissivity(ind_pav_green,m) =                                  &
+                                building_surface_pars_f%pars(ind_s_emis_green,is)
+
+                    IF ( building_surface_pars_f%pars(ind_s_emis_win,is) /=                      &
+                         building_surface_pars_f%fill )                                          &
+                       surf_usm_h%emissivity(ind_wat_win,m) =                                    &
+                                building_surface_pars_f%pars(ind_s_emis_win,is)
+
+                    IF ( building_surface_pars_f%pars(ind_s_trans,is) /=                         &
+                         building_surface_pars_f%fill )                                          &
+                       surf_usm_h%transmissivity(m) =                                            &
+                                building_surface_pars_f%pars(ind_s_trans,is)
+
+                    IF ( building_surface_pars_f%pars(ind_s_z0,is) /=                            &
+                         building_surface_pars_f%fill )                                          &
+                       surf_usm_h%z0(m) =                                                        &
+                                building_surface_pars_f%pars(ind_s_z0,is)
+
+                    IF ( building_surface_pars_f%pars(ind_s_z0qh,is) /=                          &
+                         building_surface_pars_f%fill )  THEN
+                       surf_usm_h%z0q(m) =                                                       &
+                                building_surface_pars_f%pars(ind_s_z0qh,is)
+                       surf_usm_h%z0h(m) =                                                       &
+                                building_surface_pars_f%pars(ind_s_z0qh,is)
+                    ENDIF
+
+                    EXIT ! surface was found and processed
+                 ENDIF
+              ENDDO
+           ENDDO
+
+           DO  l = 0, 3
+              DO  m = 1, surf_usm_v(l)%ns
+                 i = surf_usm_v(l)%i(m)
+                 j = surf_usm_v(l)%j(m)
+                 k = surf_usm_v(l)%k(m)
+!
+!--              Iterate over surfaces in column, check height and orientation
+                 DO  is = building_surface_pars_f%index_ji(1,j,i), &
+                          building_surface_pars_f%index_ji(2,j,i)
+                    IF ( building_surface_pars_f%coords(5,is) == -surf_usm_v(l)%joff .AND.    &
+                         building_surface_pars_f%coords(6,is) == -surf_usm_v(l)%ioff .AND.    &
+                         building_surface_pars_f%coords(1,is) == k )  THEN
+
+                       IF ( building_surface_pars_f%pars(ind_s_wall_frac,is) /=                &
+                            building_surface_pars_f%fill )                                     &
+                          surf_usm_v(l)%frac(ind_veg_wall,m) =                                 &
+                                   building_surface_pars_f%pars(ind_s_wall_frac,is)
+
+                       IF ( building_surface_pars_f%pars(ind_s_green_frac_w,is) /=             &
+                            building_surface_pars_f%fill )                                     &
+                          surf_usm_v(l)%frac(ind_pav_green,m) =                                &
+                                   building_surface_pars_f%pars(ind_s_green_frac_w,is)
+
+                       IF ( building_surface_pars_f%pars(ind_s_green_frac_r,is) /=             &
+                            building_surface_pars_f%fill )                                     &
+                          surf_usm_v(l)%frac(ind_pav_green,m) =                                &
+                                   building_surface_pars_f%pars(ind_s_green_frac_r,is)
+                                   !TODO clarify: why should _w and _r be on the same surface?
+
+                       IF ( building_surface_pars_f%pars(ind_s_win_frac,is) /=                 &
+                            building_surface_pars_f%fill )                                     &
+                          surf_usm_v(l)%frac(ind_wat_win,m) =                                  &
+                                   building_surface_pars_f%pars(ind_s_win_frac,is)
+
+                       IF ( building_surface_pars_f%pars(ind_s_lai_r,is) /=                    &
+                            building_surface_pars_f%fill )                                     &
+                          surf_usm_v(l)%lai(m) =                                               &
+                                   building_surface_pars_f%pars(ind_s_lai_r,is)
+
+                       IF ( building_surface_pars_f%pars(ind_s_hc1,is) /=                      &
+                            building_surface_pars_f%fill )  THEN
+                          surf_usm_v(l)%rho_c_wall(nzb_wall:nzb_wall+1,m) =                    &
+                                   building_surface_pars_f%pars(ind_s_hc1,is)
+                          surf_usm_v(l)%rho_c_green(nzb_wall:nzb_wall+1,m) =                   &
+                                   building_surface_pars_f%pars(ind_s_hc1,is)
+                          surf_usm_v(l)%rho_c_window(nzb_wall:nzb_wall+1,m) =                  &
+                                   building_surface_pars_f%pars(ind_s_hc1,is)
+                       ENDIF
+
+                       IF ( building_surface_pars_f%pars(ind_s_hc2,is) /=                      &
+                            building_surface_pars_f%fill )  THEN
+                          surf_usm_v(l)%rho_c_wall(nzb_wall+2,m) =                             &
+                                   building_surface_pars_f%pars(ind_s_hc2,is)
+                          surf_usm_v(l)%rho_c_green(nzb_wall+2,m) =                            &
+                                   building_surface_pars_f%pars(ind_s_hc2,is)
+                          surf_usm_v(l)%rho_c_window(nzb_wall+2,m) =                           &
+                                   building_surface_pars_f%pars(ind_s_hc2,is)
+                       ENDIF
+
+                       IF ( building_surface_pars_f%pars(ind_s_hc3,is) /=                      &
+                            building_surface_pars_f%fill )  THEN
+                          surf_usm_v(l)%rho_c_wall(nzb_wall+3,m) =                             &
+                                   building_surface_pars_f%pars(ind_s_hc3,is)
+                          surf_usm_v(l)%rho_c_green(nzb_wall+3,m) =                            &
+                                   building_surface_pars_f%pars(ind_s_hc3,is)
+                          surf_usm_v(l)%rho_c_window(nzb_wall+3,m) =                           &
+                                   building_surface_pars_f%pars(ind_s_hc3,is)
+                       ENDIF
+
+                       IF ( building_surface_pars_f%pars(ind_s_tc1,is) /=                      &
+                            building_surface_pars_f%fill )  THEN
+                          surf_usm_v(l)%lambda_h(nzb_wall:nzb_wall+1,m) =                      &
+                                   building_surface_pars_f%pars(ind_s_tc1,is)
+                          surf_usm_v(l)%lambda_h_green(nzb_wall:nzb_wall+1,m) =                &
+                                   building_surface_pars_f%pars(ind_s_tc1,is)
+                          surf_usm_v(l)%lambda_h_window(nzb_wall:nzb_wall+1,m) =               &
+                                   building_surface_pars_f%pars(ind_s_tc1,is)
+                       ENDIF
+
+                       IF ( building_surface_pars_f%pars(ind_s_tc2,is) /=                      &
+                            building_surface_pars_f%fill )  THEN
+                          surf_usm_v(l)%lambda_h(nzb_wall+2,m) =                               &
+                                   building_surface_pars_f%pars(ind_s_tc2,is)
+                          surf_usm_v(l)%lambda_h_green(nzb_wall+2,m) =                         &
+                                   building_surface_pars_f%pars(ind_s_tc2,is)
+                          surf_usm_v(l)%lambda_h_window(nzb_wall+2,m) =                        &
+                                   building_surface_pars_f%pars(ind_s_tc2,is)
+                       ENDIF
+
+                       IF ( building_surface_pars_f%pars(ind_s_tc3,is) /=                      &
+                            building_surface_pars_f%fill )  THEN
+                          surf_usm_v(l)%lambda_h(nzb_wall+3,m) =                               &
+                                   building_surface_pars_f%pars(ind_s_tc3,is)
+                          surf_usm_v(l)%lambda_h_green(nzb_wall+3,m) =                         &
+                                   building_surface_pars_f%pars(ind_s_tc3,is)
+                          surf_usm_v(l)%lambda_h_window(nzb_wall+3,m) =                        &
+                                   building_surface_pars_f%pars(ind_s_tc3,is)
+                       ENDIF
+
+                       IF ( building_surface_pars_f%pars(ind_s_indoor_target_temp_summer,is) /=    &
+                            building_surface_pars_f%fill )                                         &
+                          surf_usm_v(l)%target_temp_summer(m) =                                    &
+                                   building_surface_pars_f%pars(ind_s_indoor_target_temp_summer,is)
+
+                       IF ( building_surface_pars_f%pars(ind_s_indoor_target_temp_winter,is) /=    &
+                            building_surface_pars_f%fill )                                         &
+                          surf_usm_v(l)%target_temp_winter(m) =                                    &
+                                   building_surface_pars_f%pars(ind_s_indoor_target_temp_winter,is)
+
+                       IF ( building_surface_pars_f%pars(ind_s_emis_wall,is) /=      &
+                            building_surface_pars_f%fill )                           &
+                          surf_usm_v(l)%emissivity(ind_veg_wall,m) =                 &
+                                   building_surface_pars_f%pars(ind_s_emis_wall,is)
+
+                       IF ( building_surface_pars_f%pars(ind_s_emis_green,is) /=     &
+                            building_surface_pars_f%fill )                           &
+                          surf_usm_v(l)%emissivity(ind_pav_green,m) =                &
+                                   building_surface_pars_f%pars(ind_s_emis_green,is)
+
+                       IF ( building_surface_pars_f%pars(ind_s_emis_win,is) /=       &
+                            building_surface_pars_f%fill )                           &
+                          surf_usm_v(l)%emissivity(ind_wat_win,m) =                  &
+                                   building_surface_pars_f%pars(ind_s_emis_win,is)
+
+                       IF ( building_surface_pars_f%pars(ind_s_trans,is) /=          &
+                            building_surface_pars_f%fill )                           &
+                          surf_usm_v(l)%transmissivity(m) =                          &
+                                   building_surface_pars_f%pars(ind_s_trans,is)
+
+                       IF ( building_surface_pars_f%pars(ind_s_z0,is) /=             &
+                            building_surface_pars_f%fill )                           &
+                          surf_usm_v(l)%z0(m) =                                      &
+                                   building_surface_pars_f%pars(ind_s_z0,is)
+
+                       IF ( building_surface_pars_f%pars(ind_s_z0qh,is) /=           &
+                            building_surface_pars_f%fill )  THEN
+                          surf_usm_v(l)%z0q(m) =                                     &
+                                   building_surface_pars_f%pars(ind_s_z0qh,is)
+                          surf_usm_v(l)%z0h(m) =                                     &
+                                   building_surface_pars_f%pars(ind_s_z0qh,is)
+                       ENDIF
+
+                       EXIT ! surface was found and processed
+                    ENDIF
+                 ENDDO
+              ENDDO
+           ENDDO
+        ENDIF
 !       
 !--     Read the surface_types array.
