Index: palm/trunk/SOURCE/land_surface_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 4311)
+++ palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 4312)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Initialization of relative surface fractions revised
 ! 
 ! Former revisions:
@@ -2656,8 +2656,7 @@
                          soil_type_f%var_2d(j,i)                    = 1 
 !                         
-!--                      Set surface_fraction if provided in static input, 
-!--                      else, in case no tiles are used, this will be done
-!--                      on basis of the prescribed types (vegetation/pavement/
-!--                      water_type). 
+!--                      If surface_fraction is provided in static input, 
+!--                      set fraction for vegetation to one at building-covered
+!--                      surfaces.
                          IF ( surface_fraction_f%from_file )  THEN
                             surface_fraction_f%frac(ind_veg_wall,j,i)  = 1.0_wp
@@ -2708,11 +2707,41 @@
              j = surf_lsm_h%j(m)
 !
-!--          0 - vegetation fraction, 1 - pavement fraction, 2 - water fraction             
-             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)   =                                &
+!--          0 - vegetation fraction, 1 - pavement fraction, 2 - water fraction
+             IF ( surface_fraction_f%frac(ind_veg_wall,j,i) /=                 &
+                  surface_fraction_f%fill )  THEN
+                surf_lsm_h%frac(ind_veg_wall,m)  =                             &
+                                    surface_fraction_f%frac(ind_veg_wall,j,i)
+             ENDIF
+             IF ( surface_fraction_f%frac(ind_pav_green,j,i) /=                &
+                  surface_fraction_f%fill )  THEN
+                surf_lsm_h%frac(ind_pav_green,m) =                             &
+                                    surface_fraction_f%frac(ind_pav_green,j,i)
+             ENDIF
+             IF ( surface_fraction_f%frac(ind_wat_win,j,i) /=                  &
+                  surface_fraction_f%fill )  THEN
+                surf_lsm_h%frac(ind_wat_win,m)   =                             &
                                     surface_fraction_f%frac(ind_wat_win,j,i)
+             ENDIF
+!
+!--          Check if sum of relative fractions is zero. This case, give an
+!--          error message.
+             IF ( SUM ( surf_lsm_h%frac(:,m) ) == 0.0_wp )  THEN
+                WRITE( message_string, * )                                     &
+                                 'surface fractions at grid point (j,i) = (',  &
+                                 j, i, ') are all zero.'
+                CALL message( 'land_surface_model_mod', 'PA0688',              &
+                               2, 2, myid, 6, 0 ) 
+             ENDIF
+!
+!--          In case the sum of all surfaces is not 1, which may happen
+!--          due to rounding errors or type conversions, normalize the
+!--          fractions to one. Note, at the moment no tile approach is 
+!--          implemented, so that relative fractions are either 1 or zero.
+             IF ( SUM ( surf_lsm_h%frac(:,m) ) > 1.0_wp  .OR.                  &
+                  SUM ( surf_lsm_h%frac(:,m) ) < 1.0_wp  )  THEN
+                surf_lsm_h%frac(:,m) = surf_lsm_h%frac(:,m) /                  &
+                                       SUM ( surf_lsm_h%frac(:,m) )
+
+             ENDIF
 
           ENDDO
@@ -2725,11 +2754,40 @@
 !
 !--             0 - vegetation fraction, 1 - pavement fraction, 2 - water fraction        
-                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)   =                          &
+                IF ( surface_fraction_f%frac(ind_veg_wall,j,i) /=              &
+                     surface_fraction_f%fill )  THEN
+                   surf_lsm_v(l)%frac(ind_veg_wall,m)  =                       &
+                                    surface_fraction_f%frac(ind_veg_wall,j,i)
+                ENDIF
+                IF ( surface_fraction_f%frac(ind_pav_green,j,i) /=             &
+                     surface_fraction_f%fill )  THEN
+                   surf_lsm_v(l)%frac(ind_pav_green,m)  =                      &
+                                    surface_fraction_f%frac(ind_pav_green,j,i)
+                ENDIF
+                IF ( surface_fraction_f%frac(ind_wat_win,j,i) /=               &
+                     surface_fraction_f%fill )  THEN
+                   surf_lsm_v(l)%frac(ind_wat_win,m)  =                        &
                                     surface_fraction_f%frac(ind_wat_win,j,i)
-
+                ENDIF
+!
+!--             Check if sum of relative fractions is zero. This case, give an
+!--             error message.
+                IF ( SUM ( surf_lsm_v(l)%frac(:,m) ) == 0.0_wp )  THEN
+                   WRITE( message_string, * )                                  &
+                                 'surface fractions at grid point (j,i) = (',  &
+                                 j, i, ') are all zero.'
+                   CALL message( 'land_surface_model_mod', 'PA0688',           &
+                                  2, 2, myid, 6, 0 ) 
+                ENDIF
+!
+!--             In case the sum of all surfaces is not 1, which may happen
+!--             due to rounding errors or type conversions, normalize the
+!--             fractions to one. Note, at the moment no tile approach is 
+!--             implemented, so that relative fractions are either 1 or zero.
+                IF ( SUM ( surf_lsm_v(l)%frac(:,m) ) > 1.0_wp  .OR.            &
+                     SUM ( surf_lsm_v(l)%frac(:,m) ) < 1.0_wp  )  THEN
+                   surf_lsm_v(l)%frac(:,m) = surf_lsm_v(l)%frac(:,m) /         &
+                                             SUM ( surf_lsm_v(l)%frac(:,m) )
+
+                ENDIF
              ENDDO
           ENDDO
Index: palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4311)
+++ palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4312)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Checks for surface fractions revised
 ! 
 ! Former revisions:
@@ -3643,9 +3643,13 @@
                                   2, 2, myid, 6, 0 )
                 ENDIF
-             ENDIF
-!
-!--          Check for consistency of surface fraction. If more than one type
-!--          is set, surface fraction need to be given and the sum must not
-!--          be larger than 1.
+             ENDIF 
+!
+!--          Check for consistency of given types. At the moment, only one 
+!--          of vegetation, pavement, or water-type can be set. This is 
+!--          because no tile approach is yet implemented in the land-surface
+!--          model. Later, when this is possible, surface fraction need to be 
+!--          given and the sum must not  be larger than 1. Please note, in case
+!--          more than one type is given at a pixel, an error message will be 
+!--          given. 
              n_surf = 0
              IF ( vegetation_type_f%var(j,i) /= vegetation_type_f%fill )       &
@@ -3657,18 +3661,32 @@
 
              IF ( n_surf > 1 )  THEN
-                IF ( .NOT. surface_fraction_f%from_file )  THEN
-                   message_string = 'If more than one surface type is ' //     &
-                                 'given at a location, surface_fraction ' //   &
-                                 'must be provided.'
-                   CALL message( 'netcdf_data_input_mod', 'PA0565',            &
-                                  2, 2, myid, 6, 0 )
-                ELSEIF ( ANY ( surface_fraction_f%frac(:,j,i) ==               &
-                               surface_fraction_f%fill ) )  THEN
-                   message_string = 'If more than one surface type is ' //     &
-                                 'given at a location, surface_fraction ' //   &
-                                 'must be provided.'
-                   CALL message( 'netcdf_data_input_mod', 'PA0565',            &
-                                  2, 2, myid, 6, 0 )
-                ENDIF
+                WRITE( message_string, * )                                     &
+                                 'More than one surface type (vegetation, '//  &
+                                 'pavement, water) is given at a location. '// &
+                                 'Please note, this is not possible at ' //    &
+                                 'the moment as no tile approach has been ' // &
+                                 'yet implemented. (i,j) = ', i, j
+                CALL message( 'netcdf_data_input_mod', 'PA0565',               &
+                               2, 2, myid, 6, 0 )
+
+!                 IF ( .NOT. surface_fraction_f%from_file )  THEN
+!                    message_string = 'More than one surface type (vegetation '//&
+!                                  'pavement, water) is given at a location. '// &
+!                                  'Please note, this is not possible at ' //    &
+!                                  'the moment as no tile approach is yet ' //   &
+!                                  'implemented.'
+!                    message_string = 'If more than one surface type is ' //     &
+!                                  'given at a location, surface_fraction ' //   &
+!                                  'must be provided.'
+!                    CALL message( 'netcdf_data_input_mod', 'PA0565',            &
+!                                   2, 2, myid, 6, 0 )
+!                 ELSEIF ( ANY ( surface_fraction_f%frac(:,j,i) ==               &
+!                                surface_fraction_f%fill ) )  THEN
+!                    message_string = 'If more than one surface type is ' //     &
+!                                  'given at a location, surface_fraction ' //   &
+!                                  'must be provided.'
+!                    CALL message( 'netcdf_data_input_mod', 'PA0565',            &
+!                                   2, 2, myid, 6, 0 )
+!                 ENDIF
              ENDIF
 !
@@ -3678,9 +3696,36 @@
              IF ( surface_fraction_f%from_file )  THEN
 !
-!--             Sum of relative fractions must not exceed 1.
-                IF ( SUM ( surface_fraction_f%frac(0:2,j,i) ) > 1.0_wp )  THEN
-                   message_string = 'surface_fraction must not exceed 1'
-                   CALL message( 'netcdf_data_input_mod', 'PA0566',            &
+!--             If surface fractions is given, also check that only one type 
+!--             is given.
+                IF ( SUM( MERGE( 1, 0, surface_fraction_f%frac(:,j,i) /= 0.0_wp&
+                                .AND.  surface_fraction_f%frac(:,j,i) /=       &
+                                       surface_fraction_f%fill  ) ) > 1 )  THEN
+                   WRITE( message_string, * )                                  &
+                                    'surface_fraction is given for more ' //   &
+                                    'than one type. ' //                       &
+                                    'Please note, this is not possible at ' // &
+                                    'the moment as no tile approach has '//    &
+                                    'yet been implemented. (i, j) = ', i, j
+                   CALL message( 'netcdf_data_input_mod', 'PA0676',            &
                                   2, 2, myid, 6, 0 )
+                ENDIF
+!
+!--             Sum of relative fractions must be 1. Note, due to type 
+!--             type conversions due to reading, the sum of surface fractions 
+!--             might be not exactly 1. Hence, the sum is check with a
+!--             tolerance. Later, in the land-surface model, the relative 
+!--             fractions are normalized to one.
+                IF ( ANY( surface_fraction_f%frac(:,j,i) /=                    &
+                          surface_fraction_f%fill ) )  THEN
+                   IF ( SUM ( surface_fraction_f%frac(0:2,j,i) ) >             &
+                        1.0_wp + 1E-8_wp  .OR.                                 &
+                        SUM ( surface_fraction_f%frac(0:2,j,i) ) <             &
+                        1.0_wp - 1E-8_wp )  THEN
+                      WRITE( message_string, * )                               &
+                                    'The sum of all land-surface fractions ' //&
+                                    'must equal 1. ', i, j
+                      CALL message( 'netcdf_data_input_mod', 'PA0566',         &
+                                     2, 2, myid, 6, 0 )
+                   ENDIF
                 ENDIF
 !
