Index: palm/trunk/SOURCE/init_grid.f90
===================================================================
--- palm/trunk/SOURCE/init_grid.f90	(revision 240)
+++ palm/trunk/SOURCE/init_grid.f90	(revision 254)
@@ -2,6 +2,7 @@
 
 !------------------------------------------------------------------------------!
-! Actual revisions:
+! Current revisions:
 ! -----------------
+! Output of messages replaced by message handling routine.
 ! new topography case 'single_street_canyon'
 !
@@ -78,9 +79,9 @@
 !-- Compute height of u-levels from constant grid length and dz stretch factors
     IF ( dz == -1.0 )  THEN
-       IF ( myid == 0 )  PRINT*,'+++ init_grid:  missing dz'
-       CALL local_stop
+       message_string = 'missing dz'
+       CALL message( 'init_grid', 'PA0200', 1, 2, 0, 6, 0 ) 
     ELSEIF ( dz <= 0.0 )  THEN
-       IF ( myid == 0 )  PRINT*,'+++ init_grid:  dz=',dz,' <= 0.0'
-       CALL local_stop
+       WRITE( message_string, * ) 'dz=',dz,' <= 0.0'
+       CALL message( 'init_grid', 'PA0201', 1, 2, 0, 6, 0 )
     ENDIF
 
@@ -309,11 +310,10 @@
        IF ( l_grid(k) > 1.5 * dx * wall_adjustment_factor .OR.  &
             l_grid(k) > 1.5 * dy * wall_adjustment_factor )  THEN
-          IF ( myid == 0 )  THEN
-             PRINT*, '+++ WARNING: grid anisotropy exceeds '// &
-                           'threshold given by only local'
-             PRINT*, '             horizontal reduction of near_wall '// &
-                           'mixing length l_wall'
-             PRINT*, '             starting from height level k = ', k, '.'
-          ENDIF
+          WRITE( message_string, * ) 'grid anisotropy exceeds ', &
+                                     'threshold given by only local', &
+                                     ' &horizontal reduction of near_wall ', &
+                                     'mixing length l_wall', &
+                                     ' &starting from height level k = ', k, '.'
+          CALL message( 'init_grid', 'PA0202', 0, 1, 0, 6, 0 )
           EXIT
        ENDIF
@@ -367,10 +367,8 @@
           IF ( ( bxl < 1 ) .OR. ( bxr > nx-1 ) .OR. ( bxr < bxl+3 ) .OR.  &
                ( bys < 1 ) .OR. ( byn > ny-1 ) .OR. ( byn < bys+3 ) )  THEN
-             IF ( myid == 0 )  THEN
-                PRINT*, '+++ init_grid: inconsistent building parameters:'
-                PRINT*, '               bxl=', bxl, 'bxr=', bxr, 'bys=', bys, &
-                                      'byn=', byn, 'nx=', nx, 'ny=', ny
-             ENDIF
-             CALL local_stop
+             WRITE( message_string, * ) 'inconsistent building parameters:', &
+                                        '& bxl=', bxl, 'bxr=', bxr, 'bys=', bys, &
+                                        'byn=', byn, 'nx=', nx, 'ny=', ny
+             CALL message( 'init_grid', 'PA0203', 1, 2, 0, 6, 0 )
           ENDIF
 
@@ -405,8 +403,8 @@
 
           ELSE
-             IF ( myid == 0 )  THEN
-                PRINT*, '+++ user_init_grid: no street canyon width given'
-             ENDIF
-             CALL local_stop
+             
+             message_string = 'no street canyon width given'
+             CALL message( 'init_grid', 'PA0204', 1, 2, 0, 6, 0 )
+  
           ENDIF
 
@@ -418,32 +416,26 @@
              IF ( ( cxl < 1 ) .OR. ( cxr > nx-1 ) .OR. ( cwx < 3 ) .OR.  &
                ( ch < 3 ) )  THEN
-                IF ( myid == 0 )  THEN
-                   PRINT*, '+++ user_init_grid: inconsistent canyon parameters:'
-                   PRINT*, '                    cxl=', cxl, 'cxr=', cxr,  &
-                                              'cwx=', cwx,  &
-                                              'ch=', ch, 'nx=', nx, 'ny=', ny
-                ENDIF
-                CALL local_stop
+                WRITE( message_string, * ) 'inconsistent canyon parameters:', &
+                                           '&cxl=', cxl, 'cxr=', cxr,  &
+                                           'cwx=', cwx,  &
+                                           'ch=', ch, 'nx=', nx, 'ny=', ny
+                CALL message( 'init_grid', 'PA0205', 1, 2, 0, 6, 0 ) 
              ENDIF
           ELSEIF ( canyon_width_y /= 9999999.9 )  THEN
              IF ( ( cys < 1 ) .OR. ( cyn > ny-1 ) .OR. ( cwy < 3 ) .OR.  &
                ( ch < 3 ) )  THEN
-                IF ( myid == 0 )  THEN
-                   PRINT*, '+++ user_init_grid: inconsistent canyon parameters:'
-                   PRINT*, '                    cys=', cys, 'cyn=', cyn,  &
-                                              'cwy=', cwy,  &
-                                              'ch=', ch, 'nx=', nx, 'ny=', ny
-                ENDIF
-                CALL local_stop
+                WRITE( message_string, * ) 'inconsistent canyon parameters:', &
+                                           '&cys=', cys, 'cyn=', cyn,  &
+                                           'cwy=', cwy,  &
+                                           'ch=', ch, 'nx=', nx, 'ny=', ny
+                CALL message( 'init_grid', 'PA0206', 1, 2, 0, 6, 0 ) 
              ENDIF
           ENDIF
           IF ( canyon_width_x /= 9999999.9 .AND. canyon_width_y /= 9999999.9 )  &
                THEN
-             IF ( myid == 0 )  THEN
-                PRINT*, '+++ user_init_grid: inconsistent canyon parameters:'
-                PRINT*, '                    street canyon can only be oriented'
-                PRINT*, '                    either in x- or in y-direction'
-             ENDIF
-             CALL local_stop
+             message_string = 'inconsistent canyon parameters:' // &
+                              '&street canyon can only be oriented' // &
+                              '&either in x- or in y-direction'
+             CALL message( 'init_grid', 'PA0207', 1, 2, 0, 6, 0 )
           ENDIF
 
@@ -480,14 +472,10 @@
       
           GOTO 12
-
- 10       IF ( myid == 0 )  THEN
-             PRINT*, '+++ init_grid: file TOPOGRAPHY_DATA does not exist'
-          ENDIF
-          CALL local_stop
-
- 11       IF ( myid == 0 )  THEN
-             PRINT*, '+++ init_grid: errors in file TOPOGRAPHY_DATA'
-          ENDIF
-          CALL local_stop
+          
+ 10       message_string = 'file TOPOGRAPHY_DATA does not exist'
+          CALL message( 'init_grid', 'PA0208', 1, 2, 0, 6, 0 )
+
+ 11       message_string = 'errors in file TOPOGRAPHY_DATA'
+          CALL message( 'init_grid', 'PA0209', 1, 2, 0, 6, 0 )
 
  12       CLOSE( 90 )
@@ -519,11 +507,9 @@
 !--    Consistency checks
        IF ( MINVAL( nzb_local ) < 0  .OR.  MAXVAL( nzb_local ) > nz + 1 )  THEN
-          IF ( myid == 0 )  THEN
-             PRINT*, '+++ init_grid: nzb_local values are outside the', &
-                          'model domain'
-             PRINT*, '               MINVAL( nzb_local ) = ', MINVAL(nzb_local)
-             PRINT*, '               MAXVAL( nzb_local ) = ', MAXVAL(nzb_local)
-          ENDIF
-          CALL local_stop
+          WRITE( message_string, * ) 'nzb_local values are outside the', &
+                                     'model domain', &
+                                     '&MINVAL( nzb_local ) = ', MINVAL(nzb_local), &
+                                     '&MAXVAL( nzb_local ) = ', MAXVAL(nzb_local)
+          CALL message( 'init_grid', 'PA0210', 1, 2, 0, 6, 0 )
        ENDIF
 
@@ -531,9 +517,7 @@
           IF ( ANY( nzb_local(:,-1) /= nzb_local(:,nx)   )  .OR. &
                ANY( nzb_local(:,0)  /= nzb_local(:,nx+1) ) )  THEN
-             IF ( myid == 0 )  THEN
-                PRINT*, '+++ init_grid: nzb_local does not fulfill cyclic', &
-                        '               boundary condition in x-direction'
-             ENDIF
-             CALL local_stop
+             message_string = 'nzb_local does not fulfill cyclic' // &
+                              ' boundary condition in x-direction'
+             CALL message( 'init_grid', 'PA0211', 1, 2, 0, 6, 0 )
           ENDIF
        ENDIF
@@ -541,9 +525,7 @@
           IF ( ANY( nzb_local(-1,:) /= nzb_local(ny,:)   )  .OR. &
                ANY( nzb_local(0,:)  /= nzb_local(ny+1,:) ) )  THEN
-             IF ( myid == 0 )  THEN
-                PRINT*, '+++ init_grid: nzb_local does not fulfill cyclic', &
-                        '               boundary condition in y-direction'
-             ENDIF
-             CALL local_stop
+             message_string = 'nzb_local does not fulfill cyclic' // &
+                              ' boundary condition in y-direction'
+             CALL message( 'init_grid', 'PA0212', 1, 2, 0, 6, 0 )
           ENDIF
        ENDIF
