Index: palm/trunk/SOURCE/land_surface_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 2938)
+++ palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 2963)
@@ -25,4 +25,10 @@
 ! -----------------
 ! $Id$
+! - In initialization of surface types, consider the case that surface_fractions
+!   is not given in static input file.
+! - Introduce index for vegetation/wall, pavement/green-wall and water/window 
+!   surfaces, for clearer access of surface fraction, albedo, emissivity, etc. .
+! 
+! 2938 2018-03-27 15:52:42Z suehring
 ! Initialization of soil moisture and temperature via Inifor-provided data also
 ! in nested child domains, even if no dynamic input file is available for 
@@ -416,5 +422,6 @@
 
     USE surface_mod,                                                           &
-        ONLY :  surf_lsm_h, surf_lsm_v, surf_type, surface_restore_elements
+        ONLY :  ind_pav_green, ind_veg_wall, ind_wat_win, surf_lsm_h,          &
+                surf_lsm_v, surf_type, surface_restore_elements
 
     IMPLICIT NONE
@@ -711,10 +718,5 @@
                                    'pond        ',                   & ! 4
                                    'fountain    '                    & ! 5
-                                                                  /)                                                                  
-!
-!-- IDs for vegetation, pavement and water surfaces
-    INTEGER(iwp) ::  ind_veg = 0    !< index for vegetation surfaces, used to assess surface-fraction, albedo, etc.      
-    INTEGER(iwp) ::  ind_pav = 1    !< index for pavement surfaces, used to assess surface-fraction, albedo, etc.        
-    INTEGER(iwp) ::  ind_wat = 2    !< index for vegetation surfaces, used to assess surface-fraction, albedo, etc.                          
+                                                                  /)                                                                                  
                     
 !
@@ -2560,8 +2562,8 @@
          
              surf_lsm_h%vegetation_surface = .TRUE.
-             surf_lsm_h%frac(ind_veg,:) = 1.0_wp
+             surf_lsm_h%frac(ind_veg_wall,:) = 1.0_wp
              DO  l = 0, 3
                 surf_lsm_v(l)%vegetation_surface = .TRUE.
-                surf_lsm_v(l)%frac(ind_veg,:) = 1.0_wp
+                surf_lsm_v(l)%frac(ind_veg_wall,:) = 1.0_wp
              ENDDO
    
@@ -2569,10 +2571,10 @@
              
              surf_lsm_h%water_surface = .TRUE.
-             surf_lsm_h%frac(ind_wat,:) = 1.0_wp
+             surf_lsm_h%frac(ind_wat_win,:) = 1.0_wp
 !
 !--          Note, vertical water surface does not really make sense.
              DO  l = 0, 3  
                 surf_lsm_v(l)%water_surface   = .TRUE.
-                surf_lsm_v(l)%frac(ind_wat,:) = 1.0_wp
+                surf_lsm_v(l)%frac(ind_wat_win,:) = 1.0_wp
              ENDDO
 
@@ -2580,8 +2582,8 @@
              
              surf_lsm_h%pavement_surface = .TRUE.
-                surf_lsm_h%frac(ind_pav,:) = 1.0_wp
+                surf_lsm_h%frac(ind_pav_green,:) = 1.0_wp
              DO  l = 0, 3
                 surf_lsm_v(l)%pavement_surface   = .TRUE.
-                surf_lsm_v(l)%frac(ind_pav,:) = 1.0_wp
+                surf_lsm_v(l)%frac(ind_pav_green,:) = 1.0_wp
              ENDDO
 
@@ -2631,6 +2633,9 @@
 !--    In case of netcdf input file, further initialize surface fractions. 
 !--    At the moment only 1 surface is given at a location, so that the fraction
-!--    is either 0 or 1. This will be revised later. 
-       IF ( input_pids_static )  THEN
+!--    is either 0 or 1. This will be revised later. If surface fraction 
+!--    is not given in static input file, relative fractions will be derived
+!--    from given surface type. In this case, only 1 type is given at a certain
+!--    location (already checked).  
+       IF ( input_pids_static  .AND.  surface_fraction_f%from_file )  THEN
           DO  m = 1, surf_lsm_h%ns
              i = surf_lsm_h%i(m)
@@ -2638,7 +2643,10 @@
 !
 !--          0 - vegetation fraction, 1 - pavement fraction, 2 - water fraction             
-             surf_lsm_h%frac(ind_veg,m) = surface_fraction_f%frac(ind_veg,j,i)         
-             surf_lsm_h%frac(ind_pav,m) = surface_fraction_f%frac(ind_pav,j,i)        
-             surf_lsm_h%frac(ind_wat,m) = surface_fraction_f%frac(ind_wat,j,i)
+             surf_lsm_h%frac(ind_veg_wall,m)  =                                &
+                                    surface_fraction_f%frac(ind_veg_wall,j,i)         
+             surf_lsm_h%frac(ind_pav_green,m) =                                &
+                                    surface_fraction_f%frac(ind_pav_green,j,i)        
+             surf_lsm_h%frac(ind_wat_win,m)   =                                &
+                                    surface_fraction_f%frac(ind_wat_win,j,i)
 
           ENDDO
@@ -2651,8 +2659,39 @@
 !
 !--             0 - vegetation fraction, 1 - pavement fraction, 2 - water fraction        
-                surf_lsm_v(l)%frac(ind_veg,m) = surface_fraction_f%frac(ind_veg,j,i)         
-                surf_lsm_v(l)%frac(ind_pav,m) = surface_fraction_f%frac(ind_pav,j,i)        
-                surf_lsm_v(l)%frac(ind_wat,m) = surface_fraction_f%frac(ind_wat,j,i)
-
+                surf_lsm_v(l)%frac(ind_veg_wall,m)  =                          &
+                                    surface_fraction_f%frac(ind_veg_wall,j,i)         
+                surf_lsm_v(l)%frac(ind_pav_green,m) =                          &
+                                    surface_fraction_f%frac(ind_pav_green,j,i)        
+                surf_lsm_v(l)%frac(ind_wat_win,m)   =                          &
+                                    surface_fraction_f%frac(ind_wat_win,j,i)
+
+             ENDDO
+          ENDDO
+       ELSEIF ( input_pids_static  .AND.  .NOT. surface_fraction_f%from_file ) &
+       THEN
+          DO  m = 1, surf_lsm_h%ns
+             i = surf_lsm_h%i(m)
+             j = surf_lsm_h%j(m)
+
+             IF ( vegetation_type_f%var(j,i) /= vegetation_type_f%fill )       &        
+                surf_lsm_h%frac(ind_veg_wall,m)  = 1.0_wp
+             IF ( pavement_type_f%var(j,i)   /= pavement_type_f%fill   )       &        
+                surf_lsm_h%frac(ind_pav_green,m) = 1.0_wp 
+             IF ( water_type_f%var(j,i)      /= water_type_f%fill      )       &        
+                surf_lsm_h%frac(ind_wat_win,m)   = 1.0_wp       
+          ENDDO
+          DO  l = 0, 3
+             DO  m = 1, surf_lsm_v(l)%ns
+                i = surf_lsm_v(l)%i(m) + MERGE( 0, surf_lsm_v(l)%ioff,         &
+                                                surf_lsm_v(l)%building_covered(m) ) 
+                j = surf_lsm_v(l)%j(m) + MERGE( 0, surf_lsm_v(l)%joff,         &
+                                                surf_lsm_v(l)%building_covered(m) ) 
+     
+                IF ( vegetation_type_f%var(j,i) /= vegetation_type_f%fill )    &        
+                   surf_lsm_v(l)%frac(ind_veg_wall,m)  = 1.0_wp
+                IF ( pavement_type_f%var(j,i)   /= pavement_type_f%fill   )    &        
+                   surf_lsm_v(l)%frac(ind_pav_green,m) = 1.0_wp 
+                IF ( water_type_f%var(j,i)      /= water_type_f%fill      )    &        
+                   surf_lsm_v(l)%frac(ind_wat_win,m)   = 1.0_wp     
              ENDDO
           ENDDO
@@ -3016,6 +3055,6 @@
              surf_lsm_h%f_sw_in(m)          = f_shortwave_incoming
              surf_lsm_h%c_surface(m)        = c_surface
-             surf_lsm_h%albedo_type(ind_veg,m) = albedo_type
-             surf_lsm_h%emissivity(ind_veg,m)  = emissivity
+             surf_lsm_h%albedo_type(ind_veg_wall,m) = albedo_type
+             surf_lsm_h%emissivity(ind_veg_wall,m)  = emissivity
           ELSE
              surf_lsm_h%lai(m)   = 0.0_wp
@@ -3042,6 +3081,6 @@
                 surf_lsm_v(l)%f_sw_in(m)          = f_shortwave_incoming
                 surf_lsm_v(l)%c_surface(m)        = c_surface
-                surf_lsm_v(l)%albedo_type(ind_veg,m) = albedo_type
-                surf_lsm_v(l)%emissivity(ind_veg,m)  = emissivity
+                surf_lsm_v(l)%albedo_type(ind_veg_wall,m) = albedo_type
+                surf_lsm_v(l)%emissivity(ind_veg_wall,m)  = emissivity
              ELSE
                 surf_lsm_v(l)%lai(m)   = 0.0_wp
@@ -3077,6 +3116,6 @@
                 surf_lsm_h%f_sw_in(m)          = vegetation_pars(ind_v_f_sw_in,st)
                 surf_lsm_h%c_surface(m)        = vegetation_pars(ind_v_c_surf,st)
-                surf_lsm_h%albedo_type(ind_veg,m) = INT( vegetation_pars(ind_v_at,st) )
-                surf_lsm_h%emissivity(ind_veg,m)  = vegetation_pars(ind_v_emis,st)
+                surf_lsm_h%albedo_type(ind_veg_wall,m) = INT( vegetation_pars(ind_v_at,st) )
+                surf_lsm_h%emissivity(ind_veg_wall,m)  = vegetation_pars(ind_v_emis,st)
              ENDIF
           ENDDO
@@ -3103,6 +3142,6 @@
                    surf_lsm_v(l)%f_sw_in(m)          = vegetation_pars(ind_v_f_sw_in,st)
                    surf_lsm_v(l)%c_surface(m)        = vegetation_pars(ind_v_c_surf,st)
-                   surf_lsm_v(l)%albedo_type(ind_veg,m) = INT( vegetation_pars(ind_v_at,st) )
-                   surf_lsm_v(l)%emissivity(ind_veg,m)  = vegetation_pars(ind_v_emis,st)
+                   surf_lsm_v(l)%albedo_type(ind_veg_wall,m) = INT( vegetation_pars(ind_v_at,st) )
+                   surf_lsm_v(l)%emissivity(ind_veg_wall,m)  = vegetation_pars(ind_v_emis,st)
                 ENDIF
              ENDDO
@@ -3179,9 +3218,9 @@
                 IF ( vegetation_pars_f%pars_xy(ind_v_at,j,i) /=                &
                      vegetation_pars_f%fill )                                  &
-                   surf_lsm_h%albedo_type(ind_veg,m) =                         &
+                   surf_lsm_h%albedo_type(ind_veg_wall,m) =                    &
                                    INT( vegetation_pars_f%pars_xy(ind_v_at,j,i) )
                 IF ( vegetation_pars_f%pars_xy(ind_v_emis,j,i) /=              &
                      vegetation_pars_f%fill )                                  &
-                   surf_lsm_h%emissivity(ind_veg,m)  =                         &
+                   surf_lsm_h%emissivity(ind_veg_wall,m)  =                    &
                                    vegetation_pars_f%pars_xy(ind_v_emis,j,i)
              ENDIF
@@ -3255,9 +3294,9 @@
                    IF ( vegetation_pars_f%pars_xy(ind_v_at,j,i) /=             &
                         vegetation_pars_f%fill )                               &
-                      surf_lsm_v(l)%albedo_type(ind_veg,m) =                   &
+                      surf_lsm_v(l)%albedo_type(ind_veg_wall,m) =              &
                                    INT( vegetation_pars_f%pars_xy(ind_v_at,j,i) )
                    IF ( vegetation_pars_f%pars_xy(ind_v_emis,j,i) /=           &
                         vegetation_pars_f%fill )                               &
-                      surf_lsm_v(l)%emissivity(ind_veg,m)  =                   &
+                      surf_lsm_v(l)%emissivity(ind_veg_wall,m)  =              &
                                    vegetation_pars_f%pars_xy(ind_v_emis,j,i)
                 ENDIF
@@ -3305,6 +3344,6 @@
              surf_lsm_h%lambda_surface_u(m) = 1.0E10_wp               
              surf_lsm_h%c_surface(m)        = 0.0_wp
-             surf_lsm_h%albedo_type(ind_wat,m) = albedo_type
-             surf_lsm_h%emissivity(ind_wat,m)  = emissivity
+             surf_lsm_h%albedo_type(ind_wat_win,m) = albedo_type
+             surf_lsm_h%emissivity(ind_wat_win,m)  = emissivity
           ENDIF
        ENDDO
@@ -3323,6 +3362,6 @@
                 surf_lsm_v(l)%lambda_surface_u(m) = 1.0E10_wp               
                 surf_lsm_v(l)%c_surface(m)        = 0.0_wp
-                surf_lsm_v(l)%albedo_type(ind_wat,m) = albedo_type
-                surf_lsm_v(l)%emissivity(ind_wat,m)  = emissivity
+                surf_lsm_v(l)%albedo_type(ind_wat_win,m) = albedo_type
+                surf_lsm_v(l)%emissivity(ind_wat_win,m)  = emissivity
              ENDIF 
           ENDDO
@@ -3353,6 +3392,6 @@
                 surf_lsm_h%lambda_surface_u(m) = water_pars(ind_w_lambda_u,st)              
                 surf_lsm_h%c_surface(m)        = 0.0_wp
-                surf_lsm_h%albedo_type(ind_wat,m) = INT( water_pars(ind_w_at,st) )
-                surf_lsm_h%emissivity(ind_wat,m)  = water_pars(ind_w_emis,st)
+                surf_lsm_h%albedo_type(ind_wat_win,m) = INT( water_pars(ind_w_at,st) )
+                surf_lsm_h%emissivity(ind_wat_win,m)  = water_pars(ind_w_emis,st)
              ENDIF
           ENDDO
@@ -3378,7 +3417,7 @@
                                                    water_pars(ind_w_lambda_u,st)           
                    surf_lsm_v(l)%c_surface(m)     = 0.0_wp
-                   surf_lsm_v(l)%albedo_type(ind_wat,m) =                      &
+                   surf_lsm_v(l)%albedo_type(ind_wat_win,m) =                  &
                                                   INT( water_pars(ind_w_at,st) )
-                   surf_lsm_v(l)%emissivity(ind_wat,m)  =                      &
+                   surf_lsm_v(l)%emissivity(ind_wat_win,m)  =                  &
                                                   water_pars(ind_w_emis,st)
                 ENDIF
@@ -3434,10 +3473,10 @@
                 IF ( water_pars_f%pars_xy(ind_w_at,j,i) /=                     &
                      water_pars_f%fill )                                       &
-                   surf_lsm_h%albedo_type(ind_wat,m) =                         &
+                   surf_lsm_h%albedo_type(ind_wat_win,m) =                     &
                                        INT( water_pars_f%pars_xy(ind_w_at,j,i) )
 
                 IF ( water_pars_f%pars_xy(ind_w_emis,j,i) /=                   &
                      water_pars_f%fill )                                       &
-                   surf_lsm_h%emissivity(ind_wat,m) =                          &
+                   surf_lsm_h%emissivity(ind_wat_win,m) =                      &
                    water_pars_f%pars_xy(ind_w_emis,j,i)  
              ENDIF
@@ -3494,10 +3533,10 @@
                    IF ( water_pars_f%pars_xy(ind_w_at,j,i) /=                  &
                         water_pars_f%fill )                                    &
-                      surf_lsm_v(l)%albedo_type(ind_wat,m)    =                &
+                      surf_lsm_v(l)%albedo_type(ind_wat_win,m) =               &
                                       INT( water_pars_f%pars_xy(ind_w_at,j,i) )
 
                    IF ( water_pars_f%pars_xy(ind_w_emis,j,i) /=                &
                         water_pars_f%fill )                                    &
-                      surf_lsm_v(l)%emissivity(ind_wat,m)     =                &
+                      surf_lsm_v(l)%emissivity(ind_wat_win,m)  =               &
                                       water_pars_f%pars_xy(ind_w_emis,j,i)  
                 ENDIF
@@ -3576,6 +3615,6 @@
                                                         * 0.25_wp                                   
 
-             surf_lsm_h%albedo_type(ind_pav,m) = albedo_type
-             surf_lsm_h%emissivity(ind_pav,m)  = emissivity      
+             surf_lsm_h%albedo_type(ind_pav_green,m) = albedo_type
+             surf_lsm_h%emissivity(ind_pav_green,m)  = emissivity      
       
              IF ( pavement_type /= 0 )  THEN
@@ -3611,6 +3650,6 @@
                                                         * 0.25_wp                                      
 
-                surf_lsm_v(l)%albedo_type(ind_pav,m) = albedo_type
-                surf_lsm_v(l)%emissivity(ind_pav,m)  = emissivity
+                surf_lsm_v(l)%albedo_type(ind_pav_green,m) = albedo_type
+                surf_lsm_v(l)%emissivity(ind_pav_green,m)  = emissivity
 
                 IF ( pavement_type /= 0 )  THEN
@@ -3668,6 +3707,6 @@
                                                         * dz_soil(nzb_soil)    &
                                                         * 0.25_wp                               
-                surf_lsm_h%albedo_type(ind_pav,m) = INT( pavement_pars(ind_p_at,st) )
-                surf_lsm_h%emissivity(ind_pav,m)  = pavement_pars(ind_p_emis,st)  
+                surf_lsm_h%albedo_type(ind_pav_green,m) = INT( pavement_pars(ind_p_at,st) )
+                surf_lsm_h%emissivity(ind_pav_green,m)  = pavement_pars(ind_p_emis,st)  
 
                 DO  k = nzb_soil, surf_lsm_h%nzt_pavement(m)
@@ -3718,13 +3757,13 @@
                                                         * dz_soil(nzb_soil)    &
                                                         * 0.25_wp                                    
-                   surf_lsm_v(l)%albedo_type(ind_pav,m) =                      &
+                   surf_lsm_v(l)%albedo_type(ind_pav_green,m) =                &
                                               INT( pavement_pars(ind_p_at,st) )
-                   surf_lsm_v(l)%emissivity(ind_pav,m)  =                      &
+                   surf_lsm_v(l)%emissivity(ind_pav_green,m)  =                &
                                               pavement_pars(ind_p_emis,st)    
 
                    DO  k = nzb_soil, surf_lsm_h%nzt_pavement(m)
-                      surf_lsm_v(l)%lambda_h_def(k,m)    =                    &
+                      surf_lsm_v(l)%lambda_h_def(k,m)    =                     &
                                     pavement_subsurface_pars_1(k,pavement_type)                       
-                      surf_lsm_v(l)%rho_c_total_def(k,m) =                    &
+                      surf_lsm_v(l)%rho_c_total_def(k,m) =                     &
                                     pavement_subsurface_pars_2(k,pavement_type) 
                    ENDDO   
@@ -3784,9 +3823,9 @@
                 IF ( pavement_pars_f%pars_xy(ind_p_at,j,i) /=                  &
                      pavement_pars_f%fill )                                    &
-                   surf_lsm_h%albedo_type(ind_pav,m) =                         &
+                   surf_lsm_h%albedo_type(ind_pav_green,m) =                   &
                                               INT( pavement_pars(ind_p_at,st) )
                 IF ( pavement_pars_f%pars_xy(ind_p_emis,j,i) /=                &
                      pavement_pars_f%fill )                                    &
-                   surf_lsm_h%emissivity(ind_pav,m)  =                         &
+                   surf_lsm_h%emissivity(ind_pav_green,m)  =                   &
                                               pavement_pars(ind_p_emis,st) 
              ENDIF 
@@ -3844,10 +3883,10 @@
                    IF ( pavement_pars_f%pars_xy(ind_p_at,j,i) /=               &
                         pavement_pars_f%fill )                                 &
-                      surf_lsm_v(l)%albedo_type(ind_pav,m) =                   &
+                      surf_lsm_v(l)%albedo_type(ind_pav_green,m) =             &
                                             INT( pavement_pars(ind_p_at,st) )
 
                    IF ( pavement_pars_f%pars_xy(ind_p_emis,j,i) /=             &
                         pavement_pars_f%fill )                                 &
-                      surf_lsm_v(l)%emissivity(ind_pav,m)  =                   &
+                      surf_lsm_v(l)%emissivity(ind_pav_green,m)  =             &
                                             pavement_pars(ind_p_emis,st)  
                 ENDIF 
