Index: palm/trunk/SOURCE/lpm_data_output_particles.f90
===================================================================
--- palm/trunk/SOURCE/lpm_data_output_particles.f90	(revision 1329)
+++ palm/trunk/SOURCE/lpm_data_output_particles.f90	(revision 1359)
@@ -20,5 +20,6 @@
 ! Current revisions:
 ! ------------------
-! 
+! netCDF output currently not available
+! output of particle data in binary format adopted to new particle structure
 ! 
 ! Former revisions:
@@ -52,13 +53,22 @@
         ONLY:  cpu_log, log_point_s
 
+    USE indices,                                                               &
+        ONLY:  nxl, nxr, nyn, nys, nzb, nzt
+
+    USE kinds
+
     USE netcdf_control
 
     USE particle_attributes,                                                   &
-        ONLY:  maximum_number_of_particles, maximum_number_of_tailpoints,      &
-               maximum_number_of_tails, number_of_particles, number_of_tails,  &
-               particles, particle_tail_coordinates
+        ONLY:  grid_particles, maximum_number_of_particles,                    &
+               maximum_number_of_tailpoints, maximum_number_of_tails,          &
+               number_of_particles, number_of_tails, particles,                &
+               particle_tail_coordinates, prt_count
 
     IMPLICIT NONE
 
+    INTEGER(iwp) ::  ip !:
+    INTEGER(iwp) ::  jp !:
+    INTEGER(iwp) ::  kp !:
 
     CALL cpu_log( log_point_s(40), 'lpm_data_output', 'start' )
@@ -69,12 +79,24 @@
     CALL check_open( 85 )
 
-    WRITE ( 85 )  simulated_time, maximum_number_of_particles, &
-                  number_of_particles
-    WRITE ( 85 )  particles
-    WRITE ( 85 )  maximum_number_of_tailpoints, maximum_number_of_tails, &
-                  number_of_tails
-    IF ( maximum_number_of_tails > 0 )  THEN
-       WRITE ( 85 )  particle_tail_coordinates, prt_time_count
-    ENDIF
+    WRITE ( 85 )  simulated_time
+    WRITE ( 85 )  prt_count
+          
+    DO  ip = nxl, nxr
+       DO  jp = nys, nyn
+          DO  kp = nzb+1, nzt
+             number_of_particles = prt_count(kp,jp,ip)
+             particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles)
+             IF ( number_of_particles <= 0 )  CYCLE
+             WRITE ( 85 )  particles
+          ENDDO
+       ENDDO
+    ENDDO
+!
+!-- particle tails currently not available
+!    WRITE ( 85 )  maximum_number_of_tailpoints, maximum_number_of_tails, &
+!                  number_of_tails
+!    IF ( maximum_number_of_tails > 0 )  THEN
+!       WRITE ( 85 )  particle_tail_coordinates, prt_time_count
+!    ENDIF
 
     CALL close_file( 85 )
@@ -82,113 +104,113 @@
 
 #if defined( __netcdf )
-!
-!-- Output in netCDF format
-    CALL check_open( 108 )
-
-!
-!-- Update the NetCDF time axis
-    prt_time_count = prt_time_count + 1
-
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_time_prt, &
-                            (/ simulated_time /),        &
-                            start = (/ prt_time_count /), count = (/ 1 /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 1 )
-
-!
-!-- Output the real number of particles used
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_rnop_prt, &
-                            (/ number_of_particles /),   &
-                            start = (/ prt_time_count /), count = (/ 1 /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 2 )
-
-!
-!-- Output all particle attributes
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(1), particles%age,      &
-                            start = (/ 1, prt_time_count /),               &
-                            count = (/ maximum_number_of_particles /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 3 )
-
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(2), particles%dvrp_psize,&
-                            start = (/ 1, prt_time_count /),                &
-                            count = (/ maximum_number_of_particles /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 4 )
-
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(3), particles%origin_x, &
-                            start = (/ 1, prt_time_count /),               &
-                            count = (/ maximum_number_of_particles /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 5 )
-
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(4), particles%origin_y, &
-                            start = (/ 1, prt_time_count /),               &
-                            count = (/ maximum_number_of_particles /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 6 )
-
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(5), particles%origin_z, &
-                            start = (/ 1, prt_time_count /),               &
-                            count = (/ maximum_number_of_particles /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 7 )
-
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(6), particles%radius,   &
-                            start = (/ 1, prt_time_count /),               &
-                            count = (/ maximum_number_of_particles /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 8 )
-
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(7), particles%speed_x,  &
-                            start = (/ 1, prt_time_count /),               &
-                            count = (/ maximum_number_of_particles /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 9 )
-
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(8), particles%speed_y,  &
-                            start = (/ 1, prt_time_count /),               &
-                            count = (/ maximum_number_of_particles /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 10 )
-
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(9), particles%speed_z,  &
-                            start = (/ 1, prt_time_count /),               &
-                            count = (/ maximum_number_of_particles /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 11 )
-
-    nc_stat = NF90_PUT_VAR( id_set_prt,id_var_prt(10),                     &
-                            particles%weight_factor,                       &
-                            start = (/ 1, prt_time_count /),               &
-                            count = (/ maximum_number_of_particles /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 12 )
-
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(11), particles%x,       &
-                            start = (/ 1, prt_time_count /),               &
-                            count = (/ maximum_number_of_particles /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 13 )
-
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(12), particles%y,       &
-                            start = (/ 1, prt_time_count /),               &
-                            count = (/ maximum_number_of_particles /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 14 )
-
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(13), particles%z,       &
-                            start = (/ 1, prt_time_count /),               &
-                            count = (/ maximum_number_of_particles /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 15 )
-
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(14), particles%class,   &
-                            start = (/ 1, prt_time_count /),               &
-                            count = (/ maximum_number_of_particles /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 16 )
-
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(15), particles%group,   &
-                            start = (/ 1, prt_time_count /),               &
-                            count = (/ maximum_number_of_particles /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 17 )
-
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(16),                    &
-                            particles%tailpoints,                          &
-                            start = (/ 1, prt_time_count /),               &
-                            count = (/ maximum_number_of_particles /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 18 )
-
-    nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(17), particles%tail_id, &
-                            start = (/ 1, prt_time_count /),               &
-                            count = (/ maximum_number_of_particles /) )
-    CALL handle_netcdf_error( 'lpm_data_output_particles', 19 )
-
+! !
+! !-- Output in netCDF format
+!     CALL check_open( 108 )
+! 
+! !
+! !-- Update the NetCDF time axis
+!     prt_time_count = prt_time_count + 1
+! 
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_time_prt, &
+!                             (/ simulated_time /),        &
+!                             start = (/ prt_time_count /), count = (/ 1 /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 1 )
+! 
+! !
+! !-- Output the real number of particles used
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_rnop_prt, &
+!                             (/ number_of_particles /),   &
+!                             start = (/ prt_time_count /), count = (/ 1 /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 2 )
+! 
+! !
+! !-- Output all particle attributes
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(1), particles%age,      &
+!                             start = (/ 1, prt_time_count /),               &
+!                             count = (/ maximum_number_of_particles /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 3 )
+! 
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(2), particles%dvrp_psize,&
+!                             start = (/ 1, prt_time_count /),                &
+!                             count = (/ maximum_number_of_particles /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 4 )
+! 
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(3), particles%origin_x, &
+!                             start = (/ 1, prt_time_count /),               &
+!                             count = (/ maximum_number_of_particles /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 5 )
+! 
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(4), particles%origin_y, &
+!                             start = (/ 1, prt_time_count /),               &
+!                             count = (/ maximum_number_of_particles /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 6 )
+! 
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(5), particles%origin_z, &
+!                             start = (/ 1, prt_time_count /),               &
+!                             count = (/ maximum_number_of_particles /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 7 )
+! 
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(6), particles%radius,   &
+!                             start = (/ 1, prt_time_count /),               &
+!                             count = (/ maximum_number_of_particles /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 8 )
+! 
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(7), particles%speed_x,  &
+!                             start = (/ 1, prt_time_count /),               &
+!                             count = (/ maximum_number_of_particles /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 9 )
+! 
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(8), particles%speed_y,  &
+!                             start = (/ 1, prt_time_count /),               &
+!                             count = (/ maximum_number_of_particles /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 10 )
+! 
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(9), particles%speed_z,  &
+!                             start = (/ 1, prt_time_count /),               &
+!                             count = (/ maximum_number_of_particles /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 11 )
+! 
+!     nc_stat = NF90_PUT_VAR( id_set_prt,id_var_prt(10),                     &
+!                             particles%weight_factor,                       &
+!                             start = (/ 1, prt_time_count /),               &
+!                             count = (/ maximum_number_of_particles /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 12 )
+! 
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(11), particles%x,       &
+!                             start = (/ 1, prt_time_count /),               &
+!                             count = (/ maximum_number_of_particles /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 13 )
+! 
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(12), particles%y,       &
+!                             start = (/ 1, prt_time_count /),               &
+!                             count = (/ maximum_number_of_particles /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 14 )
+! 
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(13), particles%z,       &
+!                             start = (/ 1, prt_time_count /),               &
+!                             count = (/ maximum_number_of_particles /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 15 )
+! 
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(14), particles%class,   &
+!                             start = (/ 1, prt_time_count /),               &
+!                             count = (/ maximum_number_of_particles /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 16 )
+! 
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(15), particles%group,   &
+!                             start = (/ 1, prt_time_count /),               &
+!                             count = (/ maximum_number_of_particles /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 17 )
+! 
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(16),                    &
+!                             particles%tailpoints,                          &
+!                             start = (/ 1, prt_time_count /),               &
+!                             count = (/ maximum_number_of_particles /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 18 )
+! 
+!     nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(17), particles%tail_id, &
+!                             start = (/ 1, prt_time_count /),               &
+!                             count = (/ maximum_number_of_particles /) )
+!     CALL handle_netcdf_error( 'lpm_data_output_particles', 19 )
+! 
 #endif
 
