Index: palm/trunk/SOURCE/read_3d_binary.f90
===================================================================
--- palm/trunk/SOURCE/read_3d_binary.f90	(revision 226)
+++ palm/trunk/SOURCE/read_3d_binary.f90	(revision 257)
@@ -2,7 +2,8 @@
 
 !------------------------------------------------------------------------------!
-! Actual revisions:
+! Current revisions:
 ! -----------------
-! 
+! Output of messages replaced by message handling routine.
+!
 !
 ! Former revisions:
@@ -138,11 +139,8 @@
 !
 !--             Array bound exceeded
-                PRINT*, '+++ read_3d_binary: data from subdomain of previous', &
-                             ' run mapped more than 1000 times'
-#if defined( __parallel )
-                CALL MPI_ABORT( comm2d, 9999, ierr )
-#else
-                STOP
-#endif
+                message_string = 'data from subdomain of previous' // &
+                                 ' run mapped more than 1000 times'
+                CALL message( 'read_3d_binary', 'PA0284', 2, 2, 0, 6, 0 )
+ 
              ENDIF
 
@@ -206,7 +204,8 @@
     IF ( files_to_be_opened /= 1  .OR.  numprocs /= numprocs_previous_run ) &
     THEN
-       PRINT*, '*** number of PEs or virtual PE-grid changed in restart run'
-       PRINT*, '    PE', myid, ' will read from files ', &
-               file_list(1:files_to_be_opened)
+       WRITE( message_string, * ) 'number of PEs or virtual PE-grid changed in ',     &
+                                  'restart run&  PE', myid, ' will read from files ', &
+                                  file_list(1:files_to_be_opened)
+       CALL message( 'read_3d_binary', 'PA0285', 0, 0, 0, 6, 0 )
     ENDIF
 
@@ -238,13 +237,9 @@
        binary_version = '3.1'
        IF ( TRIM( version_on_file ) /= TRIM( binary_version ) )  THEN
-          IF ( myid == 0 )  THEN
-             PRINT*, '+++ init_3d_model: version mismatch concerning data ', &
-                     'from prior run'
-             PRINT*, '        version on file    = "', TRIM( version_on_file ),&
-                     '"'
-             PRINT*, '        version in program = "', TRIM( binary_version ), &
-                     '"'
-          ENDIF
-          CALL local_stop
+          WRITE( message_string, * ) 'version mismatch concerning data ',                    &
+                                     'from prior run',                                       &
+                                     '&version on file    = "', TRIM( version_on_file ), '"',&
+                                     '&version in program = "', TRIM( binary_version ), '"'
+          CALL message( 'read_3d_binary', 'PA0286', 1, 2, 0, 6, 0 )
        ENDIF
 
@@ -256,69 +251,54 @@
 
        IF ( nxl_on_file /= hor_index_bounds_previous_run(1,j) )  THEN
-          PRINT*, '+++ read_3d_binary: problem with index bound nxl on ', &
-                       ' restart file "', myid_char, '"'
-          PRINT*, '                    nxl = ', nxl_on_file, ' but it should be'
-          PRINT*, '                    = ', hor_index_bounds_previous_run(1,j)
-          PRINT*, '                    from the index bound information array'
-#if defined( __parallel )
-          CALL MPI_ABORT( comm2d, 9999, ierr )
-#else
-          CALL local_stop
-#endif
+          WRITE( message_string, * ) 'problem with index bound nxl on ',          &
+                                     'restart file "', myid_char, '"',            &
+                                     '&nxl = ', nxl_on_file, ' but it should be', &
+                                     '&= ', hor_index_bounds_previous_run(1,j),   &
+                                     '&from the index bound information array'
+          CALL message( 'read_3d_binary', 'PA0287', 2, 2, 0, 6, 0 )
        ENDIF
 
        IF ( nxr_on_file /= hor_index_bounds_previous_run(2,j) )  THEN
-          PRINT*, '+++ read_3d_binary: problem with index bound nxr on ', &
-                       ' restart file "', myid_char, '"'
-          PRINT*, '                    nxr = ', nxr_on_file, ' but it should be'
-          PRINT*, '                    = ', hor_index_bounds_previous_run(2,j)
-          PRINT*, '                    from the index bound information array'
-#if defined( __parallel )
-          CALL MPI_ABORT( comm2d, 9999, ierr )
-#else
-          CALL local_stop
-#endif
+           WRITE( message_string, * ) 'problem with index bound nxr on ',          &
+                                      'restart file "', myid_char, '"'  ,          &
+                                      '&nxr = ', nxr_on_file, ' but it should be', &
+                                      '&= ', hor_index_bounds_previous_run(2,j),   &
+                                      '&from the index bound information array' 
+          CALL message( 'read_3d_binary', 'PA0288', 2, 2, 0, 6, 0 )
+
        ENDIF
 
        IF ( nys_on_file /= hor_index_bounds_previous_run(3,j) )  THEN
-          PRINT*, '+++ read_3d_binary: problem with index bound nys on ', &
-                       ' restart file "', myid_char, '"'
-          PRINT*, '                    nys = ', nys_on_file, ' but it should be'
-          PRINT*, '                    = ', hor_index_bounds_previous_run(3,j)
-          PRINT*, '                    from the index bound information array'
-#if defined( __parallel )
-          CALL MPI_ABORT( comm2d, 9999, ierr )
-#else
-          CALL local_stop
-#endif
+          WRITE( message_string, * ) 'problem with index bound nys on ',          &
+                                     'restart file "', myid_char, '"',            &
+                                     '&nys = ', nys_on_file, ' but it should be', &
+                                     '&= ', hor_index_bounds_previous_run(3,j),   &
+                                     '&from the index bound information array'
+          CALL message( 'read_3d_binary', 'PA0289', 2, 2, 0, 6, 0 ) 
        ENDIF
 
        IF ( nyn_on_file /= hor_index_bounds_previous_run(4,j) )  THEN
-          PRINT*, '+++ read_3d_binary: problem with index bound nyn on ', &
-                       ' restart file "', myid_char, '"'
-          PRINT*, '                    nyn = ', nyn_on_file, ' but it should be'
-          PRINT*, '                    = ', hor_index_bounds_previous_run(4,j)
-          PRINT*, '                    from the index bound information array'
-#if defined( __parallel )
-          CALL MPI_ABORT( comm2d, 9999, ierr )
-#else
-          CALL local_stop
-#endif
+          WRITE( message_string, * ) 'problem with index bound nyn on ',          &
+                                     'restart file "', myid_char, '"',            &
+                                     '&nyn = ', nyn_on_file, ' but it should be', &
+                                     '&= ', hor_index_bounds_previous_run(4,j),   &
+                                     '&from the index bound information array'
+          CALL message( 'read_3d_binary', 'PA0290', 2, 2, 0, 6, 0 ) 
        ENDIF
 
        IF ( nzb_on_file /= nzb )  THEN
-          PRINT*, '+++ read_3d_binary: mismatch between actual data and data '
-          PRINT*, '                    from prior run on PE ', myid
-          PRINT*, '                    nzb on file = ', nzb_on_file
-          PRINT*, '                    nzb         = ', nzb
-          CALL local_stop
+          WRITE( message_string, * ) 'mismatch between actual data and data ', &
+                                     '&from prior run on PE ', myid,           &
+                                     '&nzb on file = ', nzb_on_file,           &
+                                     '&nzb         = ', nzb
+          CALL message( 'read_3d_binary', 'PA0291', 1, 2, 0, 6, 0 )  
        ENDIF
 
        IF ( nzt_on_file /= nzt )  THEN
-          PRINT*, '+++ read_3d_binary: mismatch between actual data and data '
-          PRINT*, '                    from prior run on PE ', myid
-          PRINT*, '                    nzt on file = ', nzt_on_file
-          PRINT*, '                    nzt         = ', nzt
-          CALL local_stop
+          WRITE( message_string, * ) 'mismatch between actual data and data ', &
+                                     '&from prior run on PE ', myid,           &
+                                     '&nzt on file = ', nzt_on_file,           &
+                                     '&nzt         = ', nzt
+          CALL message( 'read_3d_binary', 'PA0292', 1, 2, 0, 6, 0 )  
        ENDIF
 
@@ -634,10 +614,9 @@
                    IF ( k == 1 )  THEN
                       IF ( nx_on_file /= nx )  THEN
-                         IF ( myid == 0 )  THEN
-                            PRINT*, '+++ WARNING: read_3d_binary: spectrum_x', &
-                                         ' on restart file ignored because'
-                            PRINT*, '    total numbers of grid points (nx) ', &
-                                         'do not match'
-                         ENDIF
+                         message_string = 'read_3d_binary: spectrum_x ' //         &
+                                          'on restart file ignored because' //     &
+                                          '&total numbers of grid points (nx) ' // &
+                                          'do not match'
+                         CALL message( 'read_3d_binary', 'PA0293', 0, 1, 0, 6, 0 )  
                          READ ( 13 )  rdummy
                       ELSE
@@ -649,10 +628,9 @@
                    IF ( k == 1 )  THEN
                       IF ( ny_on_file /= ny )  THEN
-                         IF ( myid == 0 )  THEN
-                            PRINT*, '+++ WARNING: read_3d_binary: spectrum_y', &
-                                         ' on restart file ignored because'
-                            PRINT*, '    total numbers of grid points (ny) ', &
-                                         'do not match'
-                         ENDIF
+                         message_string = 'read_3d_binary: spectrum_y ' //        &
+                                          'on restart file ignored because' //    &
+                                          '&total numbers of grid points (ny) '// &
+                                          'do not match'
+                         CALL message( 'read_3d_binary', 'PA0294', 0, 1, 0, 6, 0 )  
                          READ ( 13 )  rdummy
                       ELSE
@@ -944,9 +922,9 @@
 
                 CASE DEFAULT
-                   PRINT*, '+++ read_3d_binary: unknown field named "', &
-                           TRIM( field_chr ), '" found in'
-                   PRINT*, '                    data from prior run on PE ',myid
-                   CALL local_stop
-
+                   WRITE( message_string, * ) 'unknown field named "', &
+                                              TRIM( field_chr ), '" found in', &
+                                              '&data from prior run on PE ',myid
+                    CALL message( 'read_3d_binary', 'PA0295', 1, 2, 0, 6, 0 )  
+                   
              END SELECT
 
