Index: palm/trunk/SOURCE/close_file.f90
===================================================================
--- palm/trunk/SOURCE/close_file.f90	(revision 1310)
+++ palm/trunk/SOURCE/close_file.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:
@@ -37,38 +43,4 @@
 ! 964 2012-07-26 09:14:24Z raasch
 ! old profil-units (40:49) and respective code removed
-!
-! 564 2010-09-30 13:18:59Z helmke
-! start number of mask output files changed to 201, netcdf message identifiers
-! of masked output changed
-!
-! 493 2010-03-01 08:30:24Z raasch
-! Adjustments for NetCDF parallel data output
-!
-! 410 2009-12-04 17:05:40Z letzel
-! masked data output
-!
-! 263 2009-03-18 12:26:04Z heinze
-! Output of NetCDF messages with aid of message handling routine.
-!
-! Feb. 2007
-! RCS Log replace by Id keyword, revision history cleaned up
-!
-! Revision 1.10  2006/08/22 13:50:01  raasch
-! xz and yz cross sections now up to nzt+1
-!
-! Revision 1.1  2001/01/02 17:23:41  raasch
-! Initial revision
-!
-! Last revision before renaming subroutine  2001/01/01  raasch
-! Subroutine name changed from close_files to close_file. Closing of a single
-! file is allowed by passing its file-id as an argument. Variable openfile now
-! is of type file_status and contains a flag which indicates if a file has
-! been opened before. Old revision remarks deleted.
-!
-! Revision 1.13 (close_files) 2000/12/20 09:10:24  letzel
-! All comments translated into English.
-!
-! Revision 1.12 (close_files) 1999/03/02 09:22:46  raasch
-! FLD-Header fuer komprimierte 3D-Daten
 !
 ! Revision 1.1 (close_files) 1997/08/11 06:11:18  raasch
@@ -83,25 +55,43 @@
 !------------------------------------------------------------------------------!
 
-    USE control_parameters
-    USE grid_variables
-    USE indices
+    USE control_parameters,                                                    &
+        ONLY:  do2d_xz_n, do2d_xy_n, do2d_yz_n, do3d_avs_n, do3d_compress,     &
+               host, iso2d_output, max_masks, mid, netcdf_data_format,         &
+               netcdf_output, nz_do3d, openfile, run_description_header,       &
+               z_max_do2d
+                
+    USE grid_variables,                                                        &
+        ONLY:  dy
+        
+    USE indices,                                                               &
+        ONLY:  nx, ny, nz
+        
+    USE kinds
+    
     USE netcdf_control
-    USE pegrid
-    USE profil_parameter
-    USE statistics
+                
+    USE pegrid                                           
 
     IMPLICIT NONE
 
-    CHARACTER (LEN=10)  ::  datform = 'lit_endian'
-    CHARACTER (LEN=80)  ::  title
-
-    INTEGER ::  av, dimx, dimy, &
-                fid, file_id, planz
-
-    LOGICAL ::  checkuf = .TRUE., datleg = .TRUE., dp = .FALSE.
-
-    REAL ::  sizex, sizey, yright
-
-    NAMELIST /GLOBAL/  checkuf, datform, dimx, dimy, dp, planz, &
+    CHARACTER (LEN=10)  ::  datform = 'lit_endian' !: 
+    CHARACTER (LEN=80)  ::  title                  !: 
+
+    INTEGER(iwp) ::  av           !: 
+    INTEGER(iwp) ::  dimx         !: 
+    INTEGER(iwp) ::  dimy         !: 
+    INTEGER(iwp) ::  fid          !: 
+    INTEGER(iwp) ::  file_id      !: 
+    INTEGER(iwp) ::  planz        !: 
+
+    LOGICAL ::  checkuf = .TRUE.  !: 
+    LOGICAL ::  datleg = .TRUE.   !: 
+    LOGICAL ::  dbp = .FALSE.     !: 
+
+    REAL(wp) ::  sizex            !: 
+    REAL(wp) ::  sizey            !: 
+    REAL(wp) ::  yright           !: 
+
+    NAMELIST /GLOBAL/  checkuf, datform, dimx, dimy, dbp, planz,               &
                        title
     NAMELIST /RAHMEN/  datleg
@@ -140,10 +130,10 @@
                    yright = ( ny + 1.0 ) * dy
                    IF ( host(1:3) == 'ibm'  .OR.  host(1:3) == 't3e' )  THEN
-                      checkuf = .FALSE.; dp = .TRUE.
+                      checkuf = .FALSE.; dbp = .TRUE.
                    ENDIF
                    IF ( host(1:3) == 'ibm'  .OR.  host(1:3) == 'nec' )  THEN
                       datform = 'big_endian'
                    ENDIF
-                   OPEN ( 90, FILE='PLOT2D_XY_GLOBAL', FORM='FORMATTED', &
+                   OPEN ( 90, FILE='PLOT2D_XY_GLOBAL', FORM='FORMATTED',       &
                               DELIM='APOSTROPHE' )
                    WRITE ( 90, GLOBAL )
@@ -163,10 +153,10 @@
                    yright = z_max_do2d
                    IF ( host(1:3) == 'ibm'  .OR.  host(1:3) == 't3e' )  THEN
-                      checkuf = .FALSE.; dp = .TRUE.
+                      checkuf = .FALSE.; dbp = .TRUE.
                    ENDIF
                    IF ( host(1:3) == 'ibm'  .OR.  host(1:3) == 'nec' )  THEN
                       datform = 'big_endian'
                    ENDIF
-                   OPEN ( 90, FILE='PLOT2D_XZ_GLOBAL', FORM='FORMATTED', &
+                   OPEN ( 90, FILE='PLOT2D_XZ_GLOBAL', FORM='FORMATTED',       &
                               DELIM='APOSTROPHE' )
                    WRITE ( 90, GLOBAL )
@@ -186,10 +176,10 @@
                    yright = z_max_do2d
                    IF ( host(1:3) == 'ibm'  .OR.  host(1:3) == 't3e' )  THEN
-                      checkuf = .FALSE.; dp = .TRUE.
+                      checkuf = .FALSE.; dbp = .TRUE.
                    ENDIF
                    IF ( host(1:3) == 'ibm'  .OR.  host(1:3) == 'nec' )  THEN
                       datform = 'big_endian'
                    ENDIF
-                   OPEN ( 90, FILE='PLOT2D_YZ_GLOBAL', FORM='FORMATTED', &
+                   OPEN ( 90, FILE='PLOT2D_YZ_GLOBAL', FORM='FORMATTED',       &
                               DELIM='APOSTROPHE' )
                    WRITE ( 90, GLOBAL )
@@ -201,9 +191,9 @@
 !--             Write header for FLD-file
                 IF ( do3d_compress )  THEN
-                   WRITE ( 32, 3200)  ' compressed ',                       &
-                                      TRIM( run_description_header ), nx+2, &
+                   WRITE ( 32, 3200)  ' compressed ',                          &
+                                      TRIM( run_description_header ), nx+2,    &
                                       ny+2, nz_do3d+1, do3d_avs_n
                 ELSE
-                   WRITE ( 32, 3200)  ' ', TRIM( run_description_header ), &
+                   WRITE ( 32, 3200)  ' ', TRIM( run_description_header ),     &
                                       nx+2, ny+2, nz_do3d+1, do3d_avs_n
                 ENDIF
@@ -212,5 +202,5 @@
              CASE ( 101 )
 
-                IF ( netcdf_output  .AND.  &
+                IF ( netcdf_output  .AND.                                      &
                      ( myid == 0  .OR.  netcdf_data_format > 4 ) )  THEN
                    nc_stat = NF90_CLOSE( id_set_xy(0) )
@@ -220,5 +210,5 @@
              CASE ( 102 )
 
-                IF ( netcdf_output  .AND.  &
+                IF ( netcdf_output  .AND.                                      &
                      ( myid == 0  .OR.  netcdf_data_format > 4 ) )  THEN
                    nc_stat = NF90_CLOSE( id_set_xz(0) )
@@ -228,5 +218,5 @@
              CASE ( 103 )
 
-                IF ( netcdf_output  .AND.  &
+                IF ( netcdf_output  .AND.                                      &
                      ( myid == 0  .OR.  netcdf_data_format > 4 ) )  THEN
                    nc_stat = NF90_CLOSE( id_set_yz(0) )
@@ -279,5 +269,5 @@
              CASE ( 111 )
 
-                IF ( netcdf_output  .AND.  &
+                IF ( netcdf_output  .AND.                                      &
                      ( myid == 0  .OR.  netcdf_data_format > 4 ) )  THEN
                    nc_stat = NF90_CLOSE( id_set_xy(1) )
@@ -287,5 +277,5 @@
              CASE ( 112 )
 
-                IF ( netcdf_output  .AND.  &
+                IF ( netcdf_output  .AND.                                      &
                      ( myid == 0  .OR.  netcdf_data_format > 4 ) )  THEN
                    nc_stat = NF90_CLOSE( id_set_xz(1) )
@@ -295,5 +285,5 @@
              CASE ( 113 )
 
-                IF ( netcdf_output  .AND.  &
+                IF ( netcdf_output  .AND.                                      &
                      ( myid == 0  .OR.  netcdf_data_format > 4 ) )  THEN
                    nc_stat = NF90_CLOSE( id_set_yz(1) )
@@ -303,5 +293,5 @@
              CASE ( 116 )
 
-                IF ( netcdf_output  .AND.  &
+                IF ( netcdf_output  .AND.                                      &
                      ( myid == 0  .OR.  netcdf_data_format > 4 ) )  THEN
                    nc_stat = NF90_CLOSE( id_set_3d(1) )
@@ -311,5 +301,5 @@
              CASE ( 201:200+2*max_masks )
 	     
-                IF ( netcdf_output  .AND.  &
+                IF ( netcdf_output  .AND.                                      &
                      ( myid == 0  .OR.  netcdf_data_format > 4 ) )  THEN
 !
@@ -340,14 +330,14 @@
 !
 !-- Formats
-3200 FORMAT ('# AVS',A,'field file'/ &
-             '#'/                &
-             '# ',A/             &
-             'ndim=3'/           &
-             'dim1=',I5/         &
-             'dim2=',I5/         &
-             'dim3=',I5/         &
-             'nspace=3'/         &
-             'veclen=',I5/       &
-             'data=xdr_float'/   &
+3200 FORMAT ('# AVS',A,'field file'/                                           &
+             '#'/                                                              &
+             '# ',A/                                                           &
+             'ndim=3'/                                                         &
+             'dim1=',I5/                                                       &
+             'dim2=',I5/                                                       &
+             'dim3=',I5/                                                       &
+             'nspace=3'/                                                       &
+             'veclen=',I5/                                                     &
+             'data=xdr_float'/                                                 &
              'field=rectilinear')
 4000 FORMAT ('time averaged over',F7.1,' s')
