Index: palm/trunk/SOURCE/CURRENT_MODIFICATIONS
===================================================================
--- palm/trunk/SOURCE/CURRENT_MODIFICATIONS	(revision 229)
+++ palm/trunk/SOURCE/CURRENT_MODIFICATIONS	(revision 230)
@@ -6,4 +6,7 @@
 -------
 
+Output of messages replaced by message handling routine 
+
+advec_particles, sort_particles
 
 Errors:
Index: palm/trunk/SOURCE/advec_particles.f90
===================================================================
--- palm/trunk/SOURCE/advec_particles.f90	(revision 229)
+++ palm/trunk/SOURCE/advec_particles.f90	(revision 230)
@@ -2,6 +2,7 @@
 
 !------------------------------------------------------------------------------!
-! Actual revisions:
+! Current revisions:
 ! -----------------
+! Output of messages replaced by message handling routine
 ! Bugfix: several tail counters are initialized, particle_tail_coordinates is
 ! only written to file if its third index is > 0
@@ -314,12 +315,8 @@
                                       ( rho_surface * dx * dy * dz )
           IF ( ql_c(k,j,i) > 100.0 )  THEN
-             print*,'+++ advec_particles k=',k,' j=',j,' i=',i, &
-                          ' ql_c=',ql_c(k,j,i), ' part(',n,')%wf=', &
+             WRITE( message_string, * ) 'k=',k,' j=',j,' i=',i, &
+                          ' ql_c=',ql_c(k,j,i), ' &part(',n,')%wf=', &
                           particles(n)%weight_factor,' delta_r=',delta_r
-#if defined( __parallel )
-             CALL MPI_ABORT( comm2d, 9999, ierr )
-#else
-             STOP
-#endif
+             CALL message( 'advec_particles', 'PA0143', 2, 2, 0, 6, 0 )
           ENDIF
 
@@ -328,13 +325,9 @@
           IF ( ( new_r - particles(n)%radius ) < 0.0  .AND.  new_r < 0.0 ) &
           THEN
-             print*,'+++ advec_particles #1 k=',k,' j=',j,' i=',i, &
+             WRITE( message_string, * ) '#1 k=',k,' j=',j,' i=',i, &
                           ' e_s=',e_s, ' e_a=',e_a,' t_int=',t_int, &
-                          ' d_radius=',d_radius,' delta_r=',delta_r,&
+                          ' &d_radius=',d_radius,' delta_r=',delta_r,&
                           ' particle_radius=',particles(n)%radius
-#if defined( __parallel )
-             CALL MPI_ABORT( comm2d, 9999, ierr )
-#else
-             STOP
-#endif
+             CALL message( 'advec_particles', 'PA0144', 2, 2, 0, 6, 0 )
           ENDIF
           particles(n)%radius = new_r
@@ -427,12 +420,8 @@
                            effective_coll_efficiency < 0.0 )     &
                       THEN
-                         print*,'+++ advec_particles  collision_efficiency ', &
-                                   'out of range:', effective_coll_efficiency
-#if defined( __parallel )
-                         CALL MPI_ABORT( comm2d, 9999, ierr )
-#else
-                         STOP
-#endif
-                      ENDIF
+                         WRITE( message_string, * )   'collision_efficiency ' , &
+                                   'out of range:' ,effective_coll_efficiency
+                         CALL message( 'advec_particles', 'PA0145', 2, 2, 0, 6, 0 )
+                      END IF
 
 !
@@ -1927,13 +1916,9 @@
                maximum_number_of_particles  )  THEN
              IF ( netcdf_output )  THEN
-                PRINT*, '+++ advec_particles:  maximum_number_of_particles ', &
-                                               'needs to be increased'
-                PRINT*, '                      but this is not allowed with ', &
-                                               'NetCDF output switched on'
-#if defined( __parallel )
-                CALL MPI_ABORT( comm2d, 9999, ierr )
-#else
-                CALL local_stop
-#endif
+                message_string = 'maximum_number_of_particles ' // &
+                                 'needs to be increased ' // &
+                                 '&but this is not allowed with ' // &
+                                 'NetCDF output switched on'
+                CALL message( 'advec_particles', 'PA0146', 2, 2, 0, 6, 0 )
              ELSE
 !    WRITE ( 9, * ) '*** advec_particles: before allocate_prt_memory dt_prel'
@@ -1951,13 +1936,9 @@
                   maximum_number_of_tails  )  THEN
                 IF ( netcdf_output )  THEN
-                   PRINT*, '+++ advec_particles:  maximum_number_of_tails ', &
-                                                  'needs to be increased'
-                   PRINT*, '                      but this is not allowed wi', &
-                                                  'th NetCDF output switched on'
-#if defined( __parallel )
-                   CALL MPI_ABORT( comm2d, 9999, ierr )
-#else
-                   CALL local_stop
-#endif
+                   message_string = 'maximum_number_of_tails ' // &
+                                    'needs to be increased ' // &
+                                    '&but this is not allowed wi' // &
+                                    'th NetCDF output switched on'
+                   CALL message( 'advec_particles', 'PA0147', 2, 2, 0, 6, 0 )
                 ELSE
 !    WRITE ( 9, * ) '*** advec_particles: before allocate_tail_memory dt_prel'
@@ -2340,9 +2321,9 @@
           THEN
              IF ( netcdf_output )  THEN
-                PRINT*, '+++ advec_particles:  maximum_number_of_particles ', &
-                                               'needs to be increased'
-                PRINT*, '                      but this is not allowed with ', &
-                                               'NetCDF output switched on'
-                CALL MPI_ABORT( comm2d, 9999, ierr )
+                 message_string = 'maximum_number_of_particles ' // &
+                                  'needs to be increased ' // &
+                                  '&but this is not allowed with ' //  &
+                                  'NetCDF output switched on'
+                CALL message( 'advec_particles', 'PA0146', 2, 2, 0, 6, 0 )
              ELSE
 !    WRITE ( 9, * ) '*** advec_particles: before allocate_prt_memory trrp'
@@ -2368,9 +2349,9 @@
              THEN
                 IF ( netcdf_output )  THEN
-                   PRINT*, '+++ advec_particles:  maximum_number_of_tails ', &
-                                                  'needs to be increased'
-                   PRINT*, '                      but this is not allowed wi', &
-                                                  'th NetCDF output switched on'
-                   CALL MPI_ABORT( comm2d, 9999, ierr )
+                   message_string = 'maximum_number_of_tails ' // &
+                                    'needs to be increased ' // &
+                                    '&but this is not allowed wi'// &
+                                    'th NetCDF output switched on'
+                CALL message( 'advec_particles', 'PA0147', 2, 2, 0, 6, 0 )
                 ELSE
 !    WRITE ( 9, * ) '*** advec_particles: before allocate_tail_memory trrpt'
@@ -2417,9 +2398,9 @@
           THEN
              IF ( netcdf_output )  THEN
-                PRINT*, '+++ advec_particles:  maximum_number_of_particles ', &
-                                               'needs to be increased'
-                PRINT*, '                      but this is not allowed with ', &
-                                               'NetCDF output switched on'
-                CALL MPI_ABORT( comm2d, 9999, ierr )
+                message_string = 'maximum_number_of_particles ' // &
+                                 'needs to be increased ' // &
+                                 '&but this is not allowed with '// &
+                                 'NetCDF output switched on'
+                CALL message( 'advec_particles', 'PA0146', 2, 2, 0, 6, 0 )
              ELSE
 !    WRITE ( 9, * ) '*** advec_particles: before allocate_prt_memory trlp'
@@ -2445,9 +2426,9 @@
              THEN
                 IF ( netcdf_output )  THEN
-                   PRINT*, '+++ advec_particles:  maximum_number_of_tails ', &
-                                                  'needs to be increased'
-                   PRINT*, '                      but this is not allowed wi', &
-                                                  'th NetCDF output switched on'
-                   CALL MPI_ABORT( comm2d, 9999, ierr )
+                   message_string = 'maximum_number_of_tails ' // &
+                                    'needs to be increased ' // &
+                                    '&but this is not allowed wi'// &
+                                    'th NetCDF output switched on'
+                   CALL message( 'advec_particles', 'PA0147', 2, 2, 0, 6, 0 ) 
                 ELSE
 !    WRITE ( 9, * ) '*** advec_particles: before allocate_tail_memory trlpt'
@@ -2781,9 +2762,9 @@
           THEN
              IF ( netcdf_output )  THEN
-                PRINT*, '+++ advec_particles:  maximum_number_of_particles ', &
-                                               'needs to be increased'
-                PRINT*, '                      but this is not allowed with ', &
-                                               'NetCDF output switched on'
-                CALL MPI_ABORT( comm2d, 9999, ierr )
+                message_string = 'maximum_number_of_particles ' // &
+                                 'needs to be increased ' // &
+                                 '&but this is not allowed with '// &
+                                 'NetCDF output switched on'
+                CALL message( 'advec_particles', 'PA0146', 2, 2, 0, 6, 0 ) 
              ELSE
 !    WRITE ( 9, * ) '*** advec_particles: before allocate_prt_memory trnp'
@@ -2809,9 +2790,9 @@
              THEN
                 IF ( netcdf_output )  THEN
-                   PRINT*, '+++ advec_particles:  maximum_number_of_tails ', &
-                                                  'needs to be increased'
-                   PRINT*, '                      but this is not allowed wi', &
-                                                  'th NetCDF output switched on'
-                   CALL MPI_ABORT( comm2d, 9999, ierr )
+                   message_string = 'maximum_number_of_tails ' // &
+                                    'needs to be increased ' // &
+                                    '&but this is not allowed wi' // &
+                                    'th NetCDF output switched on'
+                   CALL message( 'advec_particles', 'PA0147', 2, 2, 0, 6, 0 ) 
                 ELSE
 !    WRITE ( 9, * ) '*** advec_particles: before allocate_tail_memory trnpt'
@@ -2858,9 +2839,9 @@
           THEN
              IF ( netcdf_output )  THEN
-                PRINT*, '+++ advec_particles:  maximum_number_of_particles ', &
-                                               'needs to be increased'
-                PRINT*, '                      but this is not allowed with ', &
-                                               'NetCDF output switched on'
-                CALL MPI_ABORT( comm2d, 9999, ierr )
+                message_string = 'maximum_number_of_particles ' // &
+                                 'needs to be increased ' // &
+                                 '&but this is not allowed with ' // &
+                                 'NetCDF output switched on'
+               CALL message( 'advec_particles', 'PA0146', 2, 2, 0, 6, 0 )  
              ELSE
 !    WRITE ( 9, * ) '*** advec_particles: before allocate_prt_memory trsp'
@@ -2886,9 +2867,9 @@
              THEN
                 IF ( netcdf_output )  THEN
-                   PRINT*, '+++ advec_particles:  maximum_number_of_tails ', &
-                                                  'needs to be increased'
-                   PRINT*, '                      but this is not allowed wi', &
-                                                  'th NetCDF output switched on'
-                   CALL MPI_ABORT( comm2d, 9999, ierr )
+                   message_string = 'maximum_number_of_tails ' // &
+                                    'needs to be increased ' // &
+                                    '&but this is not allowed wi'// &
+                                    'th NetCDF output switched on'
+                   CALL message( 'advec_particles', 'PA0147', 2, 2, 0, 6, 0 )
                 ELSE
 !    WRITE ( 9, * ) '*** advec_particles: before allocate_tail_memory trspt'
@@ -3091,10 +3072,6 @@
                ((nyn-nys+2)*dy)/(particles(n)%age-particles(n)%age_m) )  THEN
 
-             PRINT*, '+++ advec_particles: particle too fast.  n = ', n
-#if defined( __parallel )
-             CALL MPI_ABORT( comm2d, 9999, ierr )
-#else
-             CALL local_stop
-#endif
+               WRITE( message_string, * )  'particle too fast.  n = ',  n 
+               CALL message( 'advec_particles', 'PA0148', 2, 2, 0, 6, 0 )
           ENDIF
 
@@ -3908,9 +3885,10 @@
        IF ( i < nxl .OR. i > nxr .OR. j < nys .OR. j > nyn .OR. k < nzb+1 .OR. &
             k > nzt )  THEN
-          PRINT*, '+++ sort_particles: particle out of range: i=', i, ' j=', &
-                                       j, ' k=', k
-          PRINT*, '                    nxl=', nxl, ' nxr=', nxr, &
-                                     ' nys=', nys, ' nyn=', nyn, &
-                                     ' nzb=', nzb, ' nzt=', nzt
+          WRITE( message_string, * ) ' particle out of range: i=', i, ' j=', &
+                          j, ' k=', k, &
+                          ' &nxl=', nxl, ' nxr=', nxr, &
+                          ' nys=', nys, ' nyn=', nyn, &
+                          ' nzb=', nzb, ' nzt=', nzt
+         CALL message( 'sort_particles', 'PA0149', 1, 2, 0, 6, 0 ) 
        ENDIF
 
