Index: palm/trunk/SOURCE/netcdf.f90
===================================================================
--- palm/trunk/SOURCE/netcdf.f90	(revision 1310)
+++ palm/trunk/SOURCE/netcdf.f90	(revision 1320)
@@ -23,5 +23,10 @@
 ! 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,
+! revision history before 2012 removed,
+! comment fields (!:) to be used for variable explanations added to
+! all variable declaration statements
 !
 ! Former revisions:
@@ -70,62 +75,4 @@
 ! cross_profiles, profile_rows, profile_columns are written to netCDF header
 !
-! 771 2011-10-27 10:56:21Z heinze
-! +lpt
-!
-! 600 2010-11-24 16:10:51Z raasch
-! bugfix concerning check of cross-section levels on netcdf-files to be
-! extended (xz,yz)
-!
-! 564 2010-09-30 13:18:59Z helmke
-! nc_precision changed from 40 masks to 1 mask, start number of mask output
-! files changed to 201, netcdf message identifiers of masked output changed 
-!
-! 519 2010-03-19 05:30:02Z raasch
-! particle number defined as unlimited dimension in case of netCDF4 output,
-! special characters like * and " are now allowed for netCDF variable names,
-! replacement of these characters removed, routine clean_netcdf_varname
-! removed
-!
-! 493 2010-03-01 08:30:24Z raasch
-! Extensions for netCDF4 output
-!
-! 410 2009-12-04 17:05:40Z letzel
-! masked data output
-!
-! 359 2009-08-19 16:56:44Z letzel
-! for extended netCDF files, the updated title attribute includes an update of
-! time_average_text where appropriate.
-! Bugfix for extended netCDF files: In order to avoid 'data mode' errors if
-! updated attributes are larger than their original size, NF90_PUT_ATT is called
-! in 'define mode' enclosed by NF90_REDEF and NF90_ENDDEF calls. This implies a
-! possible performance loss; an alternative strategy would be to ensure equal
-! attribute size in a job chain.
-! netCDF unit attribute in timeseries output in case of statistic
-! regions added.
-! Output of netCDF messages with aid of message handling routine.
-! Output of messages replaced by message handling routine.
-! Typographical errors fixed.
-!
-! 216 2008-11-25 07:12:43Z raasch
-! Origin of the xy-coordinate system shifted from the center of the first
-! grid cell (indices i=0, j=0) to the south-left corner of this cell.
-!
-! 189 2008-08-13 17:09:26Z letzel
-! consistently allow 100 spectra levels instead of 10
-! bug fix in the determination of the number of output heights for spectra,
-! +user-defined spectra
-!
-! 97 2007-06-21 08:23:15Z raasch
-! Grids defined for rho and sa
-!
-! 48 2007-03-06 12:28:36Z raasch
-! Output topography height information (zu_s_inner, zw_s_inner) to 2d-xy and 3d
-! datasets
-!
-! RCS Log replace by Id keyword, revision history cleaned up
-!
-! Revision 1.12  2006/09/26 19:35:16  raasch
-! Bugfix yv coordinates for yz cross sections
-!
 ! Revision 1.1  2005/05/18 15:37:16  raasch
 ! Initial revision
@@ -149,54 +96,107 @@
 #if defined( __netcdf )
 
-    USE arrays_3d
-    USE constants
-    USE control_parameters
-    USE grid_variables
-    USE indices
+    USE arrays_3d,                                                              &
+        ONLY:  zu, zw
+
+    USE constants,                                                              &
+        ONLY:  pi
+
+    USE control_parameters,                                                     &
+        ONLY:  averaging_interval, averaging_interval_pr, averaging_interval_sp,&
+        data_output_pr,  domask,  dopr_n,dopr_time_count, dopts_time_count,     &
+        dots_time_count, dosp_time_count, do2d, do2d_xz_time_count, do3d,       &
+        do2d_yz_time_count, mask_size, do2d_xy_time_count, do3d_time_count,     &
+        domask_time_count, mask_i_global, mask_j_global,mask_k_global,          &
+        message_string, mid, netcdf_data_format, netcdf_precision, ntdim_2d_xy, &
+        ntdim_2d_xz, ntdim_2d_yz, ntdim_3d, nz_do3d, prt_time_count,            &
+        run_description_header, section, simulated_time, topography
+
+    USE grid_variables,                                                         &
+        ONLY:  dx, dy, zu_s_inner, zw_w_inner
+
+    USE indices,                                                                &
+        ONLY:  nx, ny, nz ,nzb, nzt
+
     USE netcdf_control
+
+    USE kinds
+
     USE pegrid
-    USE particle_attributes
-    USE profil_parameter
-    USE spectrum
-    USE statistics
+
+    USE particle_attributes,                                                    &
+        ONLY:  maximum_number_of_particles, number_of_particle_groups
+
+    USE profil_parameter,                                                       &
+        ONLY:  crmax, cross_profiles, dopr_index,profile_columns, profile_rows
+
+    USE spectrum,                                                               &
+        ONLY:  comp_spectra_level, data_output_sp, spectra_direction
+
+    USE statistics,                                                             &
+        ONLY:  hom, statistic_regions
 
 
     IMPLICIT NONE
 
-    CHARACTER (LEN=2)              ::  suffix
-    CHARACTER (LEN=2), INTENT (IN) ::  callmode
-    CHARACTER (LEN=3)              ::  suffix1
-    CHARACTER (LEN=4)              ::  grid_x, grid_y, grid_z
-    CHARACTER (LEN=6)              ::  mode
-    CHARACTER (LEN=10)             ::  netcdf_var_name, precision, var
-    CHARACTER (LEN=80)             ::  time_average_text
-    CHARACTER (LEN=2000)           ::  char_cross_profiles, var_list, var_list_old
-
-    CHARACTER (LEN=100), DIMENSION(1:crmax) ::  cross_profiles_adj,   &
-                                                cross_profiles_char
-
-    INTEGER ::  av, cross_profiles_count, cross_profiles_maxi, delim, &
-                delim_old, file_id, i, id_last, id_x, id_y, id_z, j,  &
-                k, kk, ns, ns_old, ntime_count, nz_old
-
-    INTEGER, SAVE ::  oldmode
-
-    INTEGER, DIMENSION(1) ::  id_dim_time_old, id_dim_x_yz_old,  &
-                              id_dim_y_xz_old, id_dim_zu_sp_old, &
-                              id_dim_zu_xy_old, id_dim_zu_3d_old, &
-                              id_dim_zu_mask_old
-
-    INTEGER, DIMENSION(1:crmax) ::  cross_profiles_numb
-
-    LOGICAL ::  found
-
-    LOGICAL, INTENT (INOUT) ::  extend
-
-    LOGICAL, SAVE ::  init_netcdf = .FALSE.
-
-    REAL, DIMENSION(1) ::  last_time_coordinate
-
-    REAL, DIMENSION(:), ALLOCATABLE   ::  netcdf_data
-    REAL, DIMENSION(:,:), ALLOCATABLE ::  netcdf_data_2d
+    CHARACTER (LEN=2)              ::  suffix                !:
+    CHARACTER (LEN=2), INTENT (IN) ::  callmode              !:
+    CHARACTER (LEN=3)              ::  suffix1               !:
+    CHARACTER (LEN=4)              ::  grid_x                !:
+    CHARACTER (LEN=4)              ::  grid_y                !:
+    CHARACTER (LEN=4)              ::  grid_z                !:
+    CHARACTER (LEN=6)              ::  mode                  !:
+    CHARACTER (LEN=10)             ::  netcdf_var_name       !:
+    CHARACTER (LEN=10)             ::  precision             !:
+    CHARACTER (LEN=10)             ::  var                   !:
+    CHARACTER (LEN=80)             ::  time_average_text     !:
+    CHARACTER (LEN=2000)           ::  char_cross_profiles   !:
+    CHARACTER (LEN=2000)           ::  var_list              !:
+    CHARACTER (LEN=2000)           ::  var_list_old          !:
+
+    CHARACTER (LEN=100), DIMENSION(1:crmax) ::  cross_profiles_adj   !:
+    CHARACTER (LEN=100), DIMENSION(1:crmax) ::  cross_profiles_char  !:
+
+    INTEGER(iwp) ::  av                                      !:
+    INTEGER(iwp) ::  cross_profiles_count                    !:
+    INTEGER(iwp) ::  cross_profiles_maxi                     !:
+    INTEGER(iwp) ::  delim                                   !:
+    INTEGER(iwp) ::  delim_old                               !:
+    INTEGER(iwp) ::  file_id                                 !:
+    INTEGER(iwp) ::  i                                       !:
+    INTEGER(iwp) ::  id_last                                 !:
+    INTEGER(iwp) ::  id_x                                    !:
+    INTEGER(iwp) ::  id_y                                    !:
+    INTEGER(iwp) ::  id_z                                    !:
+    INTEGER(iwp) ::  j                                       !:
+    INTEGER(iwp) ::  k                                       !:
+    INTEGER(iwp) ::  kk                                      !:
+    INTEGER(iwp) ::  ns                                      !:
+    INTEGER(iwp) ::  ns_old                                  !:
+    INTEGER(iwp) ::  ntime_count                             !:
+    INTEGER(iwp) ::  nz_old                                  !:
+
+    INTEGER(iwp), SAVE ::  oldmode                           !:
+
+    INTEGER(iwp), DIMENSION(1) ::  id_dim_time_old           !:
+    INTEGER(iwp), DIMENSION(1) ::  id_dim_x_yz_old           !:
+    INTEGER(iwp), DIMENSION(1) ::  id_dim_y_xz_old           !:
+    INTEGER(iwp), DIMENSION(1) ::  id_dim_zu_sp_old          !:
+    INTEGER(iwp), DIMENSION(1) ::  id_dim_zu_xy_old          !:
+    INTEGER(iwp), DIMENSION(1) ::  id_dim_zu_3d_old          !:
+    INTEGER(iwp), DIMENSION(1) ::  id_dim_zu_mask_old        !:
+
+
+    INTEGER(iwp), DIMENSION(1:crmax) ::  cross_profiles_numb !:
+
+    LOGICAL ::  found                                        !:
+
+    LOGICAL, INTENT (INOUT) ::  extend                       !:
+
+    LOGICAL, SAVE ::  init_netcdf = .FALSE.                  !:
+
+    REAL(wp), DIMENSION(1) ::  last_time_coordinate          !:
+
+    REAL(wp), DIMENSION(:), ALLOCATABLE   ::  netcdf_data    !:
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  netcdf_data_2d !:
 
 !
@@ -4969,5 +4969,5 @@
     CHARACTER(LEN=*) ::  routine_name
 
-    INTEGER ::  errno
+    INTEGER(iwp) ::  errno
 
     IF ( nc_stat /= NF90_NOERR )  THEN
