Index: palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 2924)
+++ palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 2925)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Check for further inconsistent settings of surface_fractions. 
+! Some messages slightly rephrased and error numbers renamed.
+! 
+! 2898 2018-03-15 13:03:01Z suehring
 ! Check if each building has a type. Further, check if dimensions in static 
 ! input file match the model dimensions. 
@@ -1723,6 +1727,7 @@
                    ELSE 
                       message_string = 'NetCDF attribute lod ' //              &
-                                       '(level of detail) is not set properly.'
-                      CALL message( 'netcdf_data_input_mod', 'PA0999',         &
+                                       '(level of detail) is not set ' //      &
+                                       'properly for buildings_2D.'
+                      CALL message( 'netcdf_data_input_mod', 'NDI000',         &
                                      1, 2, 0, 6, 0 )
                    ENDIF
@@ -1760,6 +1765,7 @@
                    ELSE 
                       message_string = 'NetCDF attribute lod ' //              &
-                                       '(level of detail) is not set properly.'
-                      CALL message( 'netcdf_data_input_mod', 'PA0999',         &
+                                       '(level of detail) is not set ' //      &
+                                       'properly for buildings_3D.'
+                      CALL message( 'netcdf_data_input_mod', 'NDI001',         &
                                      1, 2, 0, 6, 0 )
                    ENDIF
@@ -1860,5 +1866,5 @@
              message_string = 'If building heigths are prescribed in ' //      &
                               'static input file, also an ID is required.'
-             CALL message( 'netcdf_data_input_mod', 'PA0999', 1, 2, 0, 6, 0 )
+             CALL message( 'netcdf_data_input_mod', 'NDI002', 1, 2, 0, 6, 0 )
           ENDIF
        ENDIF
@@ -1998,5 +2004,5 @@
                 message_string = 'Number of inifor grid points does not '  //  &
                                  'match the number of numeric grid points.'
-                CALL message( 'netcdf_data_input_mod', 'PA0999', 1, 2, 0, 6, 0 )
+                CALL message( 'netcdf_data_input_mod', 'NDI003', 1, 2, 0, 6, 0 )
              ENDIF
 !
@@ -2290,5 +2296,5 @@
              message_string = 'NetCDF input for u_init must not contain ' //   &
                               'any _FillValues'
-             CALL message( 'netcdf_data_input_mod', 'PA0999', 2, 2, 0, 6, 0 )
+             CALL message( 'netcdf_data_input_mod', 'NDI004', 2, 2, 0, 6, 0 )
           ENDIF
        ENDIF
@@ -2297,5 +2303,5 @@
              message_string = 'NetCDF input for v_init must not contain ' //   &
                               'any _FillValues'
-             CALL message( 'netcdf_data_input_mod', 'PA0999', 2, 2, 0, 6, 0 )
+             CALL message( 'netcdf_data_input_mod', 'NDI005', 2, 2, 0, 6, 0 )
           ENDIF
        ENDIF
@@ -2304,5 +2310,5 @@
              message_string = 'NetCDF input for w_init must not contain ' //   &
                               'any _FillValues'
-             CALL message( 'netcdf_data_input_mod', 'PA0999', 2, 2, 0, 6, 0 )
+             CALL message( 'netcdf_data_input_mod', 'NDI006', 2, 2, 0, 6, 0 )
           ENDIF
        ENDIF
@@ -2311,5 +2317,5 @@
              message_string = 'NetCDF input for pt_init must not contain ' //  &
                               'any _FillValues'
-             CALL message( 'netcdf_data_input_mod', 'PA0999', 2, 2, 0, 6, 0 )
+             CALL message( 'netcdf_data_input_mod', 'NDI007', 2, 2, 0, 6, 0 )
           ENDIF
        ENDIF
@@ -2318,5 +2324,5 @@
              message_string = 'NetCDF input for q_init must not contain ' //   &
                               'any _FillValues'
-             CALL message( 'netcdf_data_input_mod', 'PA0999', 2, 2, 0, 6, 0 )
+             CALL message( 'netcdf_data_input_mod', 'NDI008', 2, 2, 0, 6, 0 )
           ENDIF
        ENDIF
@@ -2741,5 +2747,5 @@
           message_string = 'forcing = .TRUE. requires dynamic input file ' //  &
                             TRIM( input_file_dynamic ) // TRIM( coupling_char )
-          CALL message( 'netcdf_data_input_mod', 'PA0430', 1, 2, 0, 6, 0 )
+          CALL message( 'netcdf_data_input_mod', 'NDI009', 1, 2, 0, 6, 0 )
        ENDIF
 !
@@ -2751,5 +2757,5 @@
                            'input file ' // TRIM( input_file_dynamic ) //      &
                            TRIM( coupling_char )
-          CALL message( 'netcdf_data_input_mod', 'PA0430', 1, 2, 0, 6, 0 )
+          CALL message( 'netcdf_data_input_mod', 'NDI010', 1, 2, 0, 6, 0 )
        ENDIF
 
@@ -2779,5 +2785,4 @@
        INTEGER(iwp) ::  i      !< loop index along x-direction
        INTEGER(iwp) ::  j      !< loop index along y-direction
-       INTEGER(iwp) ::  n_surf !< number of different surface types at given location
 
        LOGICAL      ::  check_passed !< flag indicating if a check passed 
@@ -2792,5 +2797,5 @@
                            'x- and/or y-direction ' //                         &
                            'do not match the respective model dimension'
-          CALL message( 'netcdf_data_input_mod', 'PA0999', 1, 2, 0, 6, 0 )
+          CALL message( 'netcdf_data_input_mod', 'NDI011', 1, 2, 0, 6, 0 )
        ENDIF
 !
@@ -2802,5 +2807,5 @@
                            'in x- and/or y-direction ' //                      &
                            'do not match the respective model grid spacing.'
-          CALL message( 'netcdf_data_input_mod', 'PA0999', 1, 2, 0, 6, 0 )
+          CALL message( 'netcdf_data_input_mod', 'NDI012', 1, 2, 0, 6, 0 )
        ENDIF
 !
@@ -2811,5 +2816,5 @@
           message_string = 'NetCDF variable orography_2D is not ' //           &
                            'allowed to have missing data'
-          CALL message( 'netcdf_data_input_mod', 'PA0999', 2, 2, 0, 6, 0 )
+          CALL message( 'netcdf_data_input_mod', 'NDI013', 2, 2, 0, 6, 0 )
        ENDIF
 !
@@ -2821,5 +2826,5 @@
                 message_string = 'Reading 3D building data - too much ' //     &
                                  'data points along the vertical coordinate.' 
-                CALL message( 'netcdf_data_input_mod', 'PA0999', 2, 2, 0, 6, 0 )
+                CALL message( 'netcdf_data_input_mod', 'NDI014', 2, 2, 0, 6, 0 )
              ENDIF
 
@@ -2828,5 +2833,5 @@
                 message_string = 'Reading 3D building data - vertical ' //     &
                                  'coordinate do not match numeric grid.'
-                CALL message( 'netcdf_data_input_mod', 'PA0999', 2, 2, 0, 6, 0 )
+                CALL message( 'netcdf_data_input_mod', 'NDI015', 2, 2, 0, 6, 0 )
              ENDIF
           ENDIF
@@ -2850,5 +2855,5 @@
                            'building_type, soil_type and water_type are '//    &
                            'required.'
-          CALL message( 'netcdf_data_input_mod', 'PA0999', 1, 2, 0, 6, 0 )
+          CALL message( 'netcdf_data_input_mod', 'NDI016', 1, 2, 0, 6, 0 )
        ENDIF
 !
@@ -2861,10 +2866,10 @@
                 message_string = 'If vegegation_type = 0 at any location, ' // &
                                  'vegetation_pars is required'
-                CALL message( 'netcdf_data_input_mod', 'PA0999', 2, 2, 0, 6, 0 )
+                CALL message( 'netcdf_data_input_mod', 'NDI017', 2, 2, 0, 6, 0 )
              ENDIF
              IF ( .NOT. root_area_density_lsm_f%from_file )  THEN
                 message_string = 'If vegegation_type = 0 at any location, ' // &
                                  'root_area_density_lsm is required'
-                CALL message( 'netcdf_data_input_mod', 'PA0999', 2, 2, 0, 6, 0 )
+                CALL message( 'netcdf_data_input_mod', 'NDI018', 2, 2, 0, 6, 0 )
              ENDIF
           ENDIF
@@ -2886,5 +2891,5 @@
              message_string = 'If soil_type = 0 at any location, ' //          &
                               'soil_pars is required'
-             CALL message( 'netcdf_data_input_mod', 'PA0999', 2, 2, 0, 6, 0 )          
+             CALL message( 'netcdf_data_input_mod', 'NDI019', 2, 2, 0, 6, 0 )          
           ENDIF
        ENDIF
@@ -2896,5 +2901,5 @@
                 message_string = 'If building_type = 0 at any location, ' //   &
                                  'building_pars is required'
-                CALL message( 'netcdf_data_input_mod', 'PA0999', 2, 2, 0, 6, 0 )          
+                CALL message( 'netcdf_data_input_mod', 'NDI020', 2, 2, 0, 6, 0 )          
              ENDIF
           ENDIF
@@ -2907,5 +2912,5 @@
                 message_string = 'If albedo_type = 0 at any location, ' //     &
                                  'albedo_pars is required'
-                CALL message( 'netcdf_data_input_mod', 'PA0999', 2, 2, 0, 6, 0 )     
+                CALL message( 'netcdf_data_input_mod', 'NDI021', 2, 2, 0, 6, 0 )     
              ENDIF     
           ENDIF
@@ -2918,5 +2923,5 @@
                 message_string = 'If pavement_type = 0 at any location, ' //   &
                                  'pavement_pars is required'
-                CALL message( 'netcdf_data_input_mod', 'PA0999', 2, 2, 0, 6, 0 )     
+                CALL message( 'netcdf_data_input_mod', 'NDI022', 2, 2, 0, 6, 0 )     
              ENDIF     
           ENDIF
@@ -2930,5 +2935,5 @@
                 message_string = 'If pavement_type = 0 at any location, ' //   &
                                  'pavement_subsurface_pars is required'
-                CALL message( 'netcdf_data_input_mod', 'PA0999', 2, 2, 0, 6, 0 )     
+                CALL message( 'netcdf_data_input_mod', 'NDI023', 2, 2, 0, 6, 0 )     
              ENDIF     
           ENDIF
@@ -2941,5 +2946,5 @@
                 message_string = 'If water_type = 0 at any location, ' //      &
                                  'water_pars is required'
-                CALL message( 'netcdf_data_input_mod', 'PA0999', 2, 2, 0, 6, 0 )     
+                CALL message( 'netcdf_data_input_mod', 'NDI024', 2, 2, 0, 6, 0 )     
              ENDIF     
           ENDIF
@@ -2961,5 +2966,5 @@
                                  'building_type, or water_type must be set '// &
                                  'to a non-missing value'
-                CALL message( 'netcdf_data_input_mod', 'PA0999', 2, 2, 0, 6, 0 )
+                CALL message( 'netcdf_data_input_mod', 'NDI025', 2, 2, 0, 6, 0 )
              ENDIF
 !
@@ -2981,34 +2986,56 @@
                                  'location (y,x) where vegetation_type or ' // &
                                  'pavement_type is a non-missing value.'
-                   CALL message( 'netcdf_data_input_mod', 'PA0999',            &
+                   CALL message( 'netcdf_data_input_mod', 'NDI026',            &
                                   2, 2, 0, 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.
-             n_surf = 0
-             IF ( vegetation_type_f%var(j,i) /= vegetation_type_f%fill )       &
-                n_surf = n_surf + 1
-             IF ( water_type_f%var(j,i)      /= water_type_f%fill )            &
-                n_surf = n_surf + 1
-             IF ( pavement_type_f%var(j,i)   /= pavement_type_f%fill )         &
-                n_surf = n_surf + 1
-             
-             IF ( n_surf > 1 )  THEN
-                IF ( 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', 'PA0999',            &
+!--          Check for consistency of surface fraction. 
+!--          Sum of surface fractions must not exceed one. 
+             IF ( ANY ( surface_fraction_f%frac(:,j,i) ==                      &
+                        surface_fraction_f%fill ) )  THEN
+                message_string = 'If more than one natural surface type is ' //&
+                              'given at a location, surface_fraction ' //      &
+                              'must be provided.'
+                CALL message( 'netcdf_data_input_mod', 'NDI027',               &
                                   2, 2, 0, 6, 0 )
-                ENDIF
-                IF ( SUM ( surface_fraction_f%frac(:,j,i) ) > 1.0_wp )  THEN
-                   message_string = 'surface_fraction must not exceed 1'
-                   CALL message( 'netcdf_data_input_mod', 'PA0999',            &
-                                  2, 2, 0, 6, 0 )
-                ENDIF
+             ENDIF
+             IF ( SUM ( surface_fraction_f%frac(:,j,i) ) > 1.0_wp )  THEN
+                message_string = 'surface_fraction must not exceed 1'
+                CALL message( 'netcdf_data_input_mod', 'NDI028',               &
+                               2, 2, 0, 6, 0 )
+             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.  &
+                    surface_fraction_f%frac(0,j,i) == 0.0_wp )  .OR.             &
+                  ( pavement_type_f%var(j,i) /= pavement_type_f%fill     .AND.   &
+                    surface_fraction_f%frac(1,j,i) == 0.0_wp )  .OR.             &
+                  ( water_type_f%var(j,i) /= water_type_f%fill           .AND.   &
+                    surface_fraction_f%frac(2,j,i) == 0.0_wp ) )  THEN
+                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.  &
+                    surface_fraction_f%frac(0,j,i) /= 0.0_wp )  .OR.             &
+                  ( pavement_type_f%var(j,i) == pavement_type_f%fill     .AND.   &
+                    surface_fraction_f%frac(1,j,i) /= 0.0_wp )  .OR.             &
+                  ( water_type_f%var(j,i) == water_type_f%fill           .AND.   &
+                    surface_fraction_f%frac(2,j,i) /= 0.0_wp ) )  THEN
+                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 )
              ENDIF
 !
@@ -3023,5 +3050,5 @@
                                        'parameters of vegetation_pars at '//   &  
                                        'this location must be set.' 
-                      CALL message( 'netcdf_data_input_mod', 'PA0999',         &
+                      CALL message( 'netcdf_data_input_mod', 'NDI031',         &
                                      2, 2, 0, 6, 0 )
                    ENDIF
@@ -3038,5 +3065,5 @@
                                        'levels of root_area_density_lsm ' //   &
                                        'must be set at this location.' 
-                      CALL message( 'netcdf_data_input_mod', 'PA0999',         &
+                      CALL message( 'netcdf_data_input_mod', 'NDI032',         &
                                      2, 2, 0, 6, 0 )
                    ENDIF
@@ -3062,5 +3089,5 @@
                    message_string = 'If soil_type(y,x) = 0, all levels of '  //&  
                                     'soil_pars at this location must be set.' 
-                   CALL message( 'netcdf_data_input_mod', 'PA0999',            &
+                   CALL message( 'netcdf_data_input_mod', 'NDI033',            &
                                   2, 2, 0, 6, 0 )
                 ENDIF
@@ -3077,5 +3104,5 @@
                                        'parameters of building_pars at this '//&
                                        'location must be set.' 
-                      CALL message( 'netcdf_data_input_mod', 'PA0999',         &
+                      CALL message( 'netcdf_data_input_mod', 'NDI034',         &
                                      2, 2, 0, 6, 0 )
                    ENDIF
@@ -3092,5 +3119,5 @@
                                                  'urban-surface model is ' //  &
                                                  'applied. i, j = ', i, j
-                      CALL message( 'netcdf_data_input_mod', 'PA0999',         &
+                      CALL message( 'netcdf_data_input_mod', 'NDI035',         &
                                      2, 2, 0, 6, 0 )
                    ENDIF
@@ -3103,5 +3130,5 @@
                                                  'urban-surface model is ' //  &
                                                  'applied. i, j = ', i, j
-                      CALL message( 'netcdf_data_input_mod', 'PA0999',         &
+                      CALL message( 'netcdf_data_input_mod', 'NDI036',         &
                                      2, 2, 0, 6, 0 )
                    ENDIF
@@ -3118,5 +3145,5 @@
                                        'parameters of albedo_pars at this ' // &
                                        'location must be set.' 
-                      CALL message( 'netcdf_data_input_mod', 'PA0999',         &
+                      CALL message( 'netcdf_data_input_mod', 'NDI037',         &
                                      2, 2, 0, 6, 0 )
                    ENDIF
@@ -3134,5 +3161,5 @@
                                        'parameters of pavement_pars at this '//&
                                        'location must be set.' 
-                      CALL message( 'netcdf_data_input_mod', 'PA0999',         &
+                      CALL message( 'netcdf_data_input_mod', 'NDI038',         &
                                      2, 2, 0, 6, 0 )
                    ENDIF
@@ -3151,5 +3178,5 @@
                                        'pavement_subsurface_pars at this '//   &
                                        'location must be set.' 
-                      CALL message( 'netcdf_data_input_mod', 'PA0999',         &
+                      CALL message( 'netcdf_data_input_mod', 'NDI039',         &
                                      2, 2, 0, 6, 0 )
                    ENDIF
@@ -3167,5 +3194,5 @@
                                        'parameters of water_pars at this ' //  &
                                        'location must be set.' 
-                      CALL message( 'netcdf_data_input_mod', 'PA0999',         &
+                      CALL message( 'netcdf_data_input_mod', 'NDI040',         &
                                      2, 2, 0, 6, 0 )
                    ENDIF
