Index: palm/trunk/SOURCE/urban_surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/urban_surface_mod.f90	(revision 4245)
+++ palm/trunk/SOURCE/urban_surface_mod.f90	(revision 4258)
@@ -28,4 +28,9 @@
 ! -----------------
 ! $Id$
+! - Add checks to ensure that relative fractions of walls, windowns and green
+!   surfaces sum-up to one.
+! - Revise message calls dealing with local checks.
+! 
+! 4245 2019-09-30 08:40:37Z pavelkrc
 ! Initialize explicit per-surface parameters from building_surface_pars
 ! 
@@ -2355,6 +2360,6 @@
                 THEN
                    WRITE( message_string, * ) 'building_type = is out of ' //  &
-                                        'the valid range at (j,i) = ', j, i
-                   CALL message( 'usm_check_parameters', 'PA0529', 2, 2, 0, 6, 0 )
+                                              'the valid range at (j,i) = ', j, i
+                   CALL message( 'usm_check_parameters', 'PA0529', 2, 2, myid, 6, 0 )
                 ENDIF
              ENDDO
@@ -4434,5 +4439,7 @@
                                     building_pars_f%pars_xy(ind_lambda_surf,j,i)
               
+              write(9,*) m, SUM( surf_usm_h%frac(:,m) ), "indiv", surf_usm_h%frac(0,m), surf_usm_h%frac(1,m), surf_usm_h%frac(2,m) 
            ENDDO
+           flush(9)
 
 
@@ -5028,4 +5035,29 @@
            ENDDO
         ENDIF
+!
+!--     Run further checks to ensure that the respecitve material fractions are 
+!--     prescribed properly.
+        DO  m = 1, surf_usm_h%ns
+           IF ( SUM( surf_usm_h%frac(:,m) ) /= 1.0_wp )  THEN
+              WRITE(message_string,*) 'The relative material fractions do ' // &
+                                      'not sum-up to one at horizotal ' //     &
+                                      'surface. (i,j) = ',                     &
+                                      surf_usm_h%i(m), surf_usm_h%j(m)
+              CALL message( 'urban_surface_model_mod', 'PA0686', 2, 2, myid, 6, 0 )
+           ENDIF
+        ENDDO
+        
+        DO  l = 0, 3
+           DO  m = 1, surf_usm_v(l)%ns
+              IF ( SUM( surf_usm_v(l)%frac(:,m) ) /= 1.0_wp )  THEN
+                 WRITE(message_string,*)                                       &
+                                      'The relative material fractions do ' // &
+                                      'not sum-up to one at vertical ' //      &
+                                      'surface. (i,j) = ',                     &
+                                      surf_usm_v(l)%i(m), surf_usm_v(l)%j(m)
+                 CALL message( 'urban_surface_model_mod', 'PA0686', 2, 2, myid, 6, 0 )
+              ENDIF
+           ENDDO
+        ENDDO
 !       
 !--     Read the surface_types array.
@@ -5059,5 +5091,5 @@
                             surf_usm_h%i(m), surf_usm_h%j(m)
              CALL message( 'urban_surface_model_mod', 'PA0503',                &
-                            0, 0, 0, 6, 0 )
+                            0, 0, myid, 6, 0 )
           ENDIF
           IF ( surf_usm_h%z0h(m) >= surf_usm_h%z_mo(m) )  THEN
@@ -5071,5 +5103,5 @@
                             surf_usm_h%i(m), surf_usm_h%j(m)
              CALL message( 'urban_surface_model_mod', 'PA0507',                &
-                            0, 0, 0, 6, 0 )
+                            0, 0, myid, 6, 0 )
           ENDIF          
        ENDDO
@@ -5087,5 +5119,5 @@
                             surf_usm_v(l)%j(m)+surf_usm_v(l)%joff
                 CALL message( 'urban_surface_model_mod', 'PA0503',              &
-                            0, 0, 0, 6, 0 )
+                            0, 0, myid, 6, 0 )
              ENDIF
              IF ( surf_usm_v(l)%z0h(m) >= surf_usm_v(l)%z_mo(m) )  THEN
@@ -5100,5 +5132,5 @@
                             surf_usm_v(l)%j(m)+surf_usm_v(l)%joff
                 CALL message( 'urban_surface_model_mod', 'PA0507',               &
-                            0, 0, 0, 6, 0 )
+                            0, 0, myid, 6, 0 )
              ENDIF
           ENDDO
