Index: palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 3052)
+++ palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 3053)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Revise checks for variable surface_fraction
+! 
+! 3051 2018-05-30 17:43:55Z suehring
 ! - Speed-up NetCDF input
 ! - Revise input routines and remove NetCDF input via IO-blocks since this is 
@@ -955,5 +958,5 @@
        ENDIF
 !
-!--    Read surface fractions and related information
+!--    Read relative surface fractions of vegetation, pavement and water.
        IF ( check_existence( var_names, 'surface_fraction' ) )  THEN
           surface_fraction_f%from_file = .TRUE.
@@ -3061,6 +3064,12 @@
 
              IF ( n_surf > 1 )  THEN
-                IF ( ANY ( surface_fraction_f%frac(:,j,i) ==                   &
-                     surface_fraction_f%fill ) )  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', 'NDI027',            &
+                                  2, 2, 0, 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 ' //   &
@@ -3069,4 +3078,12 @@
                                   2, 2, 0, 6, 0 )
                 ENDIF
+             ENDIF
+!
+!--          Check for further mismatches. e.g. relative fractions exceed 1 or
+!--          vegetation_type is set but surface vegetation fraction is zero, 
+!--          etc..
+             IF ( surface_fraction_f%from_file )  THEN
+!
+!--             Sum of relative fractions must not exceed 1.
                 IF ( SUM ( surface_fraction_f%frac(:,j,i) ) > 1.0_wp )  THEN
                    message_string = 'surface_fraction must not exceed 1'
@@ -3074,9 +3091,9 @@
                                   2, 2, 0, 6, 0 )
                 ENDIF
-             ENDIF
-!
-!--          Check for further mismatches, e.g. vegetation_type is set but
-!--          surface vegetation fraction is zero.
-             IF ( ( vegetation_type_f%var(j,i) /= vegetation_type_f%fill  .AND.&
+!
+!--             Relative fraction for a type must not be zero at locations where 
+!--             this type is set. 
+                IF (                                                           &
+                  ( vegetation_type_f%var(j,i) /= vegetation_type_f%fill  .AND.&
                  ( surface_fraction_f%frac(ind_veg_wall,j,i) == 0.0_wp .OR.    &
                    surface_fraction_f%frac(ind_veg_wall,j,i) ==                &
@@ -3093,15 +3110,16 @@
                                                      surface_fraction_f%fill ) &
                   ) )  THEN
-                WRITE( message_string, * ) 'Mismatch in setting of '     //    &
+                   WRITE( message_string, * ) 'Mismatch in setting of '     // &
                              'surface_fraction. Vegetation-, pavement-, or '// &
                              'water surface is given at (i,j) = ( ', i, j,     &
                              ' ), but surface fraction is 0 for the given type.'
-                CALL message( 'netcdf_data_input_mod', 'NDI029',               &
-                               2, 2, 0, 6, 0 )
-             ENDIF
-!
-!--          Check for further mismatches, e.g. vegetation_type is not set
-!--          surface vegetation fraction is non-zero.
-             IF ( ( vegetation_type_f%var(j,i) == vegetation_type_f%fill  .AND.&
+                   CALL message( 'netcdf_data_input_mod', 'NDI029',            &
+                                  2, 2, 0, 6, 0 )
+                ENDIF
+!
+!--             Relative fraction for a type must not contain non-zero values
+!--             if this type is not set. 
+                IF (                                                           &
+                  ( vegetation_type_f%var(j,i) == vegetation_type_f%fill  .AND.&
                  ( surface_fraction_f%frac(ind_veg_wall,j,i) /= 0.0_wp .AND.   &
                    surface_fraction_f%frac(ind_veg_wall,j,i) /=                &
@@ -3118,11 +3136,12 @@
                                                      surface_fraction_f%fill ) &
                   ) )  THEN
-                WRITE( message_string, * ) 'Mismatch in setting of '     //    &
+                   WRITE( message_string, * ) 'Mismatch in setting of '     // &
                              'surface_fraction. Vegetation-, pavement-, or '// &
                              'water surface is not given at (i,j) = ( ', i, j, &
                              ' ), but surface fraction is not 0 for the ' //   &
                              'given type.'
-                CALL message( 'netcdf_data_input_mod', 'NDI030',               &
-                               2, 2, 0, 6, 0 )
+                   CALL message( 'netcdf_data_input_mod', 'NDI030',            &
+                                  2, 2, 0, 6, 0 )
+                ENDIF
              ENDIF
 !
