Index: palm/trunk/SOURCE/data_output_3d.f90
===================================================================
--- palm/trunk/SOURCE/data_output_3d.f90	(revision 1319)
+++ palm/trunk/SOURCE/data_output_3d.f90	(revision 1320)
@@ -20,5 +20,11 @@
 ! Current revisions:
 ! ------------------
-!
+! ONLY-attribute added to USE-statements,
+! kind-parameters added to all INTEGER and REAL declaration statements,
+! kinds are defined in new module kinds,
+! old module precision_kind is removed,
+! revision history before 2012 removed,
+! comment fields (!:) to be used for variable explanations added to
+! all variable declaration statements
 !
 ! Former revisions:
@@ -59,60 +65,4 @@
 ! Bugfix: missing calculation of ql_vp added
 !
-! 790 2011-11-29 03:11:20Z raasch
-! bugfix: calculation of 'pr' must depend on the particle weighting factor,
-! nzt+1 replaced by nz_do3d for 'pr'
-!
-! 771 2011-10-27 10:56:21Z heinze
-! +lpt
-!
-! 759 2011-09-15 13:58:31Z raasch
-! Splitting of parallel I/O
-!
-! 727 2011-04-20 20:05:25Z suehring
-! Exchange ghost layers also for p_av.
-!
-! 725 2011-04-11 09:37:01Z suehring
-! Exchange ghost layers for p regardless of used pressure solver (except SOR).
-!
-! 691 2011-03-04 08:45:30Z maronga
-! Replaced simulated_time by time_since_reference_point
-!
-! 673 2011-01-18 16:19:48Z suehring 
-! When using Multigrid or SOR solver an additional CALL exchange_horiz is 
-! is needed for pressure output.
-!
-! 667 2010-12-23 12:06:00Z suehring/gryschka
-! nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng in loops and 
-! allocation of arrays.  Calls of exchange_horiz are modified.
-! Skip-value skip_do_avs changed to a dynamic adaption of ghost points.
-!
-! 646 2010-12-15 13:03:52Z raasch
-! bugfix: missing define statements for netcdf added
-!
-! 493 2010-03-01 08:30:24Z raasch
-! netCDF4 support (parallel output)
-!
-! 355 2009-07-17 01:03:01Z letzel
-! simulated_time in netCDF output replaced by time_since_reference_point.
-! Output of netCDF messages with aid of message handling routine.
-! Output of messages replaced by message handling routine.
-! Bugfix: to_be_resorted => s_av for time-averaged scalars
-!
-! 96 2007-06-04 08:07:41Z raasch
-! Output of density and salinity
-!
-! 75 2007-03-22 09:54:05Z raasch
-! 2nd+3rd argument removed from exchange horiz
-!
-! RCS Log replace by Id keyword, revision history cleaned up
-!
-! Revision 1.3  2006/06/02 15:18:59  raasch
-! +argument "found", -argument grid in call of routine user_data_output_3d
-!
-! Revision 1.2  2006/02/23 10:23:07  raasch
-! Former subroutine plot_3d renamed data_output_3d, pl.. renamed do..,
-! .._anz renamed .._n,
-! output extended to (almost) all quantities, output of user-defined quantities
-!
 ! Revision 1.1  1997/09/03 06:29:36  raasch
 ! Initial revision
@@ -124,28 +74,60 @@
 !------------------------------------------------------------------------------!
 
-    USE arrays_3d
+    USE arrays_3d,                                                             &
+        ONLY:  e, nr, p, pt, q, qc, ql, ql_c, ql_v, qr, rho, sa, tend, u, v,   &
+               vpt, w
+        
     USE averaging
-    USE cloud_parameters
-    USE control_parameters
-    USE cpulog
-    USE indices
+        
+    USE cloud_parameters,                                                      &
+        ONLY:  l_d_cp, prr, pt_d_t
+        
+    USE control_parameters,                                                    &
+        ONLY:  avs_data_file,avs_output, cloud_physics, do3d, do3d_avs_n,      &
+               do3d_compress, do3d_no, do3d_time_count, io_blocks, io_group,   &
+               message_string, netcdf_output, netcdf_data_format, ntdim_3d,    &
+               nz_do3d, plot_3d_precision, psolver, simulated_time,            &
+               simulated_time_chr, skip_do_avs, time_since_reference_point
+        
+    USE cpulog,                                                                &
+        ONLY:  log_point, cpu_log
+        
+    USE indices,                                                               &
+        ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nzt,  &
+               nzb
+        
+    USE kinds
+    
     USE netcdf_control
-    USE particle_attributes
+        
+    USE particle_attributes,                                                   &
+        ONLY:  particles, prt_count, prt_start_index
+        
     USE pegrid
-    USE precision_kind
 
     IMPLICIT NONE
 
-    CHARACTER (LEN=9) ::  simulated_time_mod
-
-    INTEGER           ::  av, i, if, j, k, n, pos, prec, psi
-
-    LOGICAL           ::  found, resorted
-
-    REAL              ::  mean_r, s_r3, s_r4
-
-    REAL(spk), DIMENSION(:,:,:), ALLOCATABLE  ::  local_pf
-
-    REAL, DIMENSION(:,:,:), POINTER ::  to_be_resorted
+    CHARACTER (LEN=9) ::  simulated_time_mod  !: 
+
+    INTEGER(iwp) ::  av        !: 
+    INTEGER(iwp) ::  i         !: 
+    INTEGER(iwp) ::  if        !: 
+    INTEGER(iwp) ::  j         !: 
+    INTEGER(iwp) ::  k         !: 
+    INTEGER(iwp) ::  n         !: 
+    INTEGER(iwp) ::  pos       !: 
+    INTEGER(iwp) ::  prec      !: 
+    INTEGER(iwp) ::  psi       !: 
+
+    LOGICAL      ::  found     !: 
+    LOGICAL      ::  resorted  !: 
+
+    REAL(wp)     ::  mean_r    !: 
+    REAL(wp)     ::  s_r3      !: 
+    REAL(wp)     ::  s_r4      !: 
+
+    REAL(sp), DIMENSION(:,:,:), ALLOCATABLE ::  local_pf  !:
+
+    REAL(wp), DIMENSION(:,:,:), POINTER ::  to_be_resorted  !: 
 
 !
@@ -202,7 +184,7 @@
     IF ( myid == 0 )  THEN
        IF ( netcdf_output )  THEN
-          nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_time_3d(av), &
-                                  (/ time_since_reference_point /),  &
-                                  start = (/ do3d_time_count(av) /), &
+          nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_time_3d(av),           &
+                                  (/ time_since_reference_point /),            &
+                                  start = (/ do3d_time_count(av) /),           &
                                   count = (/ 1 /) )
           CALL handle_netcdf_error( 'data_output_3d', 376 )
@@ -288,7 +270,7 @@
                          s_r4 = 0.0
                          DO  n = psi, psi+prt_count(k,j,i)-1
-                         s_r3 = s_r3 + particles(n)%radius**3 * &
+                         s_r3 = s_r3 + particles(n)%radius**3 *                &
                                        particles(n)%weight_factor
-                         s_r4 = s_r4 + particles(n)%radius**4 * &
+                         s_r4 = s_r4 + particles(n)%radius**4 *                &
                                        particles(n)%weight_factor
                          ENDDO
@@ -346,6 +328,6 @@
                       DO  j = nysg, nyng
                          DO  k = nzb, nz_do3d
-                            local_pf(i,j,k) = pt(k,j,i) + l_d_cp *    &
-                                                          pt_d_t(k) * &
+                            local_pf(i,j,k) = pt(k,j,i) + l_d_cp *             &
+                                                          pt_d_t(k) *          &
                                                           ql(k,j,i)
                          ENDDO
@@ -400,6 +382,6 @@
                          psi = prt_start_index(k,j,i)
                          DO  n = psi, psi+prt_count(k,j,i)-1
-                            tend(k,j,i) = tend(k,j,i) + &
-                                          particles(n)%weight_factor / &
+                            tend(k,j,i) = tend(k,j,i) +                        &
+                                          particles(n)%weight_factor /         &
                                           prt_count(k,j,i)
                          ENDDO
@@ -494,10 +476,10 @@
 !
 !--          User defined quantity
-             CALL user_data_output_3d( av, do3d(av,if), found, local_pf, &
+             CALL user_data_output_3d( av, do3d(av,if), found, local_pf,       &
                                        nz_do3d )
              resorted = .TRUE.
 
              IF ( .NOT. found )  THEN
-                message_string =  'no output available for: ' //   &
+                message_string =  'no output available for: ' //               &
                                   TRIM( do3d(av,if) )
                 CALL message( 'data_output_3d', 'PA0182', 0, 0, 0, 6, 0 )
@@ -532,10 +514,10 @@
 
           IF ( av == 0 )  THEN
-             WRITE ( 33, 3300 )  do3d_avs_n, TRIM( avs_data_file ), &
-                                 skip_do_avs, TRIM( do3d(av,if) ), &
+             WRITE ( 33, 3300 )  do3d_avs_n, TRIM( avs_data_file ),            &
+                                 skip_do_avs, TRIM( do3d(av,if) ),             &
                                  TRIM( simulated_time_mod )
           ELSE
-             WRITE ( 33, 3300 )  do3d_avs_n, TRIM( avs_data_file ), &
-                                 skip_do_avs, TRIM( do3d(av,if) ) // &
+             WRITE ( 33, 3300 )  do3d_avs_n, TRIM( avs_data_file ),            &
+                                 skip_do_avs, TRIM( do3d(av,if) ) //           &
                                  ' averaged', TRIM( simulated_time_mod )
           ENDIF
@@ -543,5 +525,5 @@
 !--       Determine the Skip-value for the next array. Record end and start 
 !--       require 4 byte each.
-          skip_do_avs = skip_do_avs + ( ( ( nx+2*nbgp ) * ( ny+2*nbgp ) * &
+          skip_do_avs = skip_do_avs + ( ( ( nx+2*nbgp ) * ( ny+2*nbgp ) *      &
                                           ( nz_do3d+1 ) ) * 4 + 8 )
        ENDIF
@@ -553,5 +535,5 @@
 !--       Compression, output of compression information on FLD-file and output
 !--       of compressed data.
-          CALL write_compressed( local_pf, 30, 33, myid, nxl, nxr, nyn, nys, &
+          CALL write_compressed( local_pf, 30, 33, myid, nxl, nxr, nyn, nys,   &
                                  nzb, nz_do3d, prec, nbgp )
        ELSE
@@ -586,22 +568,22 @@
 !--             boundaries of the total domain.
                 IF ( nxr == nx  .AND.  nyn /= ny )  THEN
-                   nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), &
-                                     local_pf(nxl:nxr+1,nys:nyn,nzb:nz_do3d), &
-                      start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /), &
+                   nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if),  &
+                                     local_pf(nxl:nxr+1,nys:nyn,nzb:nz_do3d),  &
+                      start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /),  &
                       count = (/ nxr-nxl+2, nyn-nys+1, nz_do3d-nzb+1, 1 /) )
                 ELSEIF ( nxr /= nx  .AND.  nyn == ny )  THEN
-                   nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), &
-                                     local_pf(nxl:nxr,nys:nyn+1,nzb:nz_do3d), &
-                      start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /), &
+                   nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if),  &
+                                     local_pf(nxl:nxr,nys:nyn+1,nzb:nz_do3d),  &
+                      start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /),  &
                       count = (/ nxr-nxl+1, nyn-nys+2, nz_do3d-nzb+1, 1 /) )
                 ELSEIF ( nxr == nx  .AND.  nyn == ny )  THEN
-                   nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), &
-                                   local_pf(nxl:nxr+1,nys:nyn+1,nzb:nz_do3d), &
-                      start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /), &
+                   nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if),  &
+                                   local_pf(nxl:nxr+1,nys:nyn+1,nzb:nz_do3d),  &
+                      start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /),  &
                       count = (/ nxr-nxl+2, nyn-nys+2, nz_do3d-nzb+1, 1 /) )
                 ELSE
-                   nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), &
-                                       local_pf(nxl:nxr,nys:nyn,nzb:nz_do3d), &
-                      start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /), &
+                   nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if),  &
+                                       local_pf(nxl:nxr,nys:nyn,nzb:nz_do3d),  &
+                      start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /),  &
                       count = (/ nxr-nxl+1, nyn-nys+1, nz_do3d-nzb+1, 1 /) )
                 ENDIF
@@ -617,7 +599,7 @@
           IF ( netcdf_output )  THEN
 
-             nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if),    &
-                               local_pf(nxl:nxr+1,nys:nyn+1,nzb:nz_do3d),  &
-                               start = (/ 1, 1, 1, do3d_time_count(av) /), &
+             nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if),        &
+                               local_pf(nxl:nxr+1,nys:nyn+1,nzb:nz_do3d),      &
+                               start = (/ 1, 1, 1, do3d_time_count(av) /),     &
                                count = (/ nx+2, ny+2, nz_do3d-nzb+1, 1 /) )
              CALL handle_netcdf_error( 'data_output_3d', 446 )
@@ -641,5 +623,5 @@
 !
 !-- Formats.
-3300 FORMAT ('variable ',I4,'  file=',A,'  filetype=unformatted  skip=',I12/ &
+3300 FORMAT ('variable ',I4,'  file=',A,'  filetype=unformatted  skip=',I12/   &
              'label = ',A,A)
 
