Index: palm/trunk/UTIL/read_palm_2d_netcdf_data.f90
===================================================================
--- palm/trunk/UTIL/read_palm_2d_netcdf_data.f90	(revision 1)
+++ 	(revision )
@@ -1,169 +1,0 @@
- PROGRAM read_palm_2d_netcdf_data
-
-!------------------------------------------------------------------------------!
-! Actual revisions:
-! -----------------
-! 
-!
-! Former revisions:
-! -----------------
-!
-! This routine must be compiled with:
-! decalpha:
-!    f95 -cpp -D__netcdf -fast -r8 -I/usr/local/netcdf-3.5.1/include
-!    -L/usr/local/netcdf-3.5.1/lib -lnetcdf
-! IBM-Regatta:
-!    xlf95 -qsuffix=cpp=f90 -WF,-D__netcdf -qrealsize=8 -q64 -qmaxmem=-1 -Q
-!    -I /aws/dataformats/netcdf-3.6.0-p1/64-32/include
-!    -L/aws/dataformats/netcdf-3.6.0-p1/64-32/lib -lnetcdf -O3
-! IBM-Regatta KISTI:
-!    xlf95 -qsuffix=cpp=f90 -WF,-D__netcdf -qrealsize=8 -q64 -qmaxmem=-1 -Q
-!    -I /applic/netcdf64/src/f90
-!    -L/applic/lib/NETCDF64 -lnetcdf -O3
-! IBM-Regatta Yonsei (gfdl5):
-!    xlf95 -qsuffix=cpp=f90 -WF,-D__netcdf -qrealsize=8 -q64 -qmaxmem=-1 -Q
-!    -I /usr1/users/raasch/pub/netcdf-3.6.0-p1/include
-!    -L/usr1/users/raasch/pub/netcdf-3.6.0-p1/lib -lnetcdf -O3
-! IMUK:
-!    ifort combine...f90 -o combine...x
-!    -cpp -D__netcdf -I /muksoft/packages/netcdf/linux/include -axW -r8 -nbs
-!    -Vaxlib -L /muksoft/packages/netcdf/linux/lib -lnetcdf
-! NEC-SX6:
-!    sxf90 combine...f90 -o combine...x 
-!    -I /pool/SX-6/netcdf/netcdf-3.6.0-p1/include  -C hopt -Wf '-A idbl4'
-!    -D__netcdf -L/pool/SX-6/netcdf/netcdf-3.6.0-p1/lib -lnetcdf
-!------------------------------------------------------------------------------!
-
-    USE netcdf
-
-    IMPLICIT NONE
-
-!
-!-- Local variables
-    CHARACTER (LEN=10)   ::  dimname, var_name
-    CHARACTER (LEN=40)   ::  filename
-
-    CHARACTER (LEN=2000) ::  var_list
-
-    INTEGER ::  i, j, k, nc_stat, pos, time_step
-
-    INTEGER ::  current_level, current_var, id_set, id_var_time, num_var
-
-    INTEGER, DIMENSION(4) ::  id_dims_loc
-
-    INTEGER, DIMENSION(4) ::  id_dims
-
-    INTEGER, DIMENSION(1000) ::  id_var, levels
-
-!    REAL, DIMENSION(0:576,0:128,3,6) ::  pf
-    REAL, DIMENSION(0:576,2,0:64,6) ::  pf
-
-
-
-    filename = 'ibmh_rinne_xz_av.nc'
-    nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set )
-    IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 1 )
-
-!
-!-- Get the list of variables (order of variables corresponds with the
-!-- order of data on the binary file)
-    var_list = ' '    ! GET_ATT does not assign trailing blanks
-    nc_stat = NF90_GET_ATT( id_set, NF90_GLOBAL, 'VAR_LIST', var_list )
-    IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 2 )
-
-!
-!-- Inquire id of the time coordinate variable
-    nc_stat = NF90_INQ_VARID( id_set, 'time', id_var_time )
-    IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 3 )
-
-!
-!-- Count number of variables; there is one more semicolon in the
-!-- string than variable names
-    num_var = -1
-    DO  i = 1, LEN( var_list )
-       IF ( var_list(i:i) == ';' )  num_var = num_var + 1
-    ENDDO
-
-!
-!-- Extract the variable names from the list and inquire their NetCDF IDs
-    pos = INDEX( var_list, ';' )
-!
-!-- Loop over all variables
-    DO  i = 1, num_var
-
-!
-!--    Extract variable name from list
-       var_list = var_list(pos+1:)
-       pos = INDEX( var_list, ';' )
-       var_name = var_list(1:pos-1)
-
-!
-!--    Get variable ID from name
-       nc_stat = NF90_INQ_VARID( id_set, TRIM( var_name ), id_var(i) )
-       IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 4 )
-
-!
-!--    Get number of x/y/z levels for that variable
-       nc_stat = NF90_INQUIRE_VARIABLE( id_set, id_var(i), &
-                                        dimids = id_dims_loc )
-       IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 5 )
-       id_dims = id_dims_loc
-
-!
-!--    Inquire dimension ID
-       DO  j = 1, 4
-          nc_stat = NF90_INQUIRE_DIMENSION( id_set, id_dims(j),&
-                                            dimname, levels(i) )
-          IF ( nc_stat /= NF90_NOERR ) CALL handle_netcdf_error( 6 )
-       ENDDO
-
-       PRINT*, '*** reading array ', i
-!       nc_stat = NF90_GET_VAR( id_set, id_var(i), pf(0:576,0:128,1:3,i), &
-!                                start = (/ 1, 1, 1, 1 /), &
-!                                count = (/ 577, 129, 3, 1 /) )
-       nc_stat = NF90_GET_VAR( id_set, id_var(i), pf(0:576,1:2,0:64,i), &
-                                start = (/ 1, 1, 1, 1 /), &
-                                count = (/ 577, 2, 65, 1 /) )
-       IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 7+i )
-                  
-    ENDDO
-
-    PRINT*, ' '
-    i = 190
-    j =  60
-
-!    DO  k = 3, 1, -1
-!       WRITE ( *, '(F5.2,1X,F5.2,1X,F6.3,1X,F6.2,1X,F6.4,1X,F6.4)' )  &
-!          pf(i,j,k,1), pf(i,j,k,2), pf(i,j,k,3), pf(i,j,k,4), pf(i,j,k,5), &
-!          pf(i,j,k,6)
-!    ENDDO
-    DO  k = 2, 0, -1
-       WRITE ( *, '(F5.2,1X,F5.2,1X,F6.3,1X,F6.2,1X,F6.4,1X,F6.4)' )  &
-          pf(i,1,k,1), pf(i,1,k,2), pf(i,1,k,3), pf(i,1,k,4), pf(i,1,k,5), &
-          pf(i,1,k,6)
-    ENDDO
-
-
- CONTAINS
-
-
-    SUBROUTINE handle_netcdf_error( errno )
-!
-!--    Prints out a text message corresponding to the current NetCDF status
-
-       IMPLICIT NONE
-
-       INTEGER, INTENT(IN) ::  errno
-
-       IF ( nc_stat /= NF90_NOERR )  THEN
-          PRINT*, '+++ read_palm_2d_netcdf_data  netcdf: ', errno, &
-                  TRIM( nf90_strerror( nc_stat ) )
-       ENDIF
-
-    END SUBROUTINE handle_netcdf_error
-
-
- END PROGRAM read_palm_2d_netcdf_data
-
-
-
Index: palm/trunk/UTIL/read_palm_netcdf_data.f90
===================================================================
--- palm/trunk/UTIL/read_palm_netcdf_data.f90	(revision 6)
+++ palm/trunk/UTIL/read_palm_netcdf_data.f90	(revision 6)
@@ -0,0 +1,198 @@
+ PROGRAM read_palm_netcdf_data
+
+!------------------------------------------------------------------------------!
+! This is an example program for reading PALM 2d/3d NetCDF datasets
+!
+! The user has to add his own code for further storing and analyzing of
+! these data!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! The NetCDF include file and library has to be given with the respective
+! compiler options. Please find out the respective paths on your system and
+! set them appropriately.
+!
+! Here are some examples how this routine should be compiled:
+!
+! decalpha:
+!    f95 -fast -r8 -I/usr/local/netcdf-3.5.1/include
+!    -L/usr/local/netcdf-3.5.1/lib -lnetcdf
+! IBM-Regatta:
+!    xlf95 -qrealsize=8 -q64 -qmaxmem=-1 -Q
+!    -I /aws/dataformats/netcdf-3.6.0-p1/64-32/include
+!    -L/aws/dataformats/netcdf-3.6.0-p1/64-32/lib -lnetcdf -O3
+! IBM-Regatta KISTI:
+!    xlf95 -qrealsize=8 -q64 -qmaxmem=-1 -Q
+!    -I /applic/netcdf64/src/f90
+!    -L/applic/lib/NETCDF64 -lnetcdf -O3
+! IBM-Regatta Yonsei (gfdl5):
+!    xlf95 -qrealsize=8 -q64 -qmaxmem=-1 -Q
+!    -I /usr1/users/raasch/pub/netcdf-3.6.0-p1/include
+!    -L/usr1/users/raasch/pub/netcdf-3.6.0-p1/lib -lnetcdf -O3
+! IMUK:
+!    ifort read_palm...f90 -o read_palm...x
+!    -I /muksoft/packages/netcdf/linux/include -axW -r8 -nbs
+!    -Vaxlib -L /muksoft/packages/netcdf/linux/lib -lnetcdf
+! NEC-SX6:
+!    sxf90 read_palm...f90 -o read_palm...x 
+!    -I /pool/SX-6/netcdf/netcdf-3.6.0-p1/include  -C hopt -Wf '-A idbl4'
+!    -L/pool/SX-6/netcdf/netcdf-3.6.0-p1/lib -lnetcdf
+!------------------------------------------------------------------------------!
+
+    USE netcdf
+
+    IMPLICIT NONE
+
+!
+!-- Local variables
+    CHARACTER (LEN=10)   ::  dimname(4), var_name
+    CHARACTER (LEN=40)   ::  filename
+
+    CHARACTER (LEN=2000) ::  title, var_list
+
+    INTEGER ::  i, j, k, nc_stat, pos, time_step
+
+    INTEGER ::  current_level, current_var, id_set, id_var_time, num_var
+
+    INTEGER, DIMENSION(4) ::  id_dims, id_dims_loc, levels
+
+    INTEGER, DIMENSION(1000) ::  id_var
+
+    REAL ::  time(1)
+
+    REAL, DIMENSION(:,:,:), ALLOCATABLE ::  data_array
+
+
+    PRINT*, '*** Please type NetCDF filename to be read:'
+    READ*, filename
+
+    nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set )
+    IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 1 )
+
+!
+!-- Get the run description header and output
+    title = ' '
+    nc_stat = NF90_GET_ATT( id_set, NF90_GLOBAL, 'title', title )
+    IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 2 )
+    WRITE (*,'(/A/A)')  '*** file created by:', TRIM( title )
+
+!
+!-- Get the list of variables (order of variables corresponds with the
+!-- order of data on the binary file)
+    var_list = ' '    ! GET_ATT does not assign trailing blanks
+    nc_stat = NF90_GET_ATT( id_set, NF90_GLOBAL, 'VAR_LIST', var_list )
+    IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 3 )
+
+!
+!-- Inquire id of the time coordinate variable
+    nc_stat = NF90_INQ_VARID( id_set, 'time', id_var_time )
+    IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 4 )
+
+!
+!-- Count number of variables; there is one more semicolon in the
+!-- string than variable names
+    num_var = -1
+    DO  i = 1, LEN( var_list )
+       IF ( var_list(i:i) == ';' )  num_var = num_var + 1
+    ENDDO
+    WRITE (*,'(/A,I3,A/)')  '*** file contains ', num_var, ' variable(s)'
+
+
+    pos = INDEX( var_list, ';' )
+!
+!-- Loop over all variables
+    DO  i = 1, num_var
+
+!
+!--    Extract variable name from list
+       var_list = var_list(pos+1:)
+       pos = INDEX( var_list, ';' )
+       var_name = var_list(1:pos-1)
+
+!
+!--    Get variable ID from name
+       nc_stat = NF90_INQ_VARID( id_set, TRIM( var_name ), id_var(i) )
+       IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 5 )
+
+!
+!--    Inquire the dimension IDs
+       nc_stat = NF90_INQUIRE_VARIABLE( id_set, id_var(i), &
+                                        dimids = id_dims_loc )
+       IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 6 )
+       id_dims = id_dims_loc
+
+!
+!--    Get number of x/y/z/time levels(gridpoints) for that variable
+       DO  j = 1, 4
+          nc_stat = NF90_INQUIRE_DIMENSION( id_set, id_dims(j),&
+                                            dimname(j), levels(j) )
+          IF ( nc_stat /= NF90_NOERR ) CALL handle_netcdf_error( 7 )
+       ENDDO
+
+       WRITE (*,100)  '*** reading variable "', TRIM(var_name),         &
+                      '", dimensioned as', TRIM(var_name), levels(1)-1, &
+                      levels(2)-1, levels(3)-1
+100    FORMAT (A,A,A/4X,A,'(0:',I4,',0:',I4,',0:',I4,')   (x/y/z)'/)
+
+!
+!--    Allocate the data array to be read
+       ALLOCATE( data_array(0:levels(1)-1,0:levels(2)-1,0:levels(3)-1) )
+
+!
+!--    Read the data from file for each timestep
+       DO  j = 1, levels(4)
+
+!
+!--        Get the time of the current timelevel and output
+           nc_stat = NF90_GET_VAR( id_set, id_var_time, time, start = (/ j /), &
+                                   count = (/ 1 /) )
+
+           IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 7+i )
+
+           WRITE (*,'(A,I3,A,F8.1,A)')  '    reading timelevel ', i, &
+                                        '    time = ', time(1), ' s'     
+
+           nc_stat = NF90_GET_VAR( id_set, id_var(i),                    &
+                                   data_array, start = (/ 1, 1, 1, j /), &
+                             count = (/ levels(1), levels(2), levels(3), 1 /) )
+
+           IF ( nc_stat /= NF90_NOERR )  &
+                                       CALL handle_netcdf_error( 7+levels(4)+i )
+!
+!--        ADD YOUR OWN CODE FOR FURTHER STORING OF THESE DATA HERE
+!--        --------------------------------------------------------
+
+
+       ENDDO
+
+       WRITE (*,'(/)')
+
+       DEALLOCATE( data_array )
+
+    ENDDO
+
+
+
+ CONTAINS
+
+
+    SUBROUTINE handle_netcdf_error( errno )
+!
+!--    Prints out a text message corresponding to the current NetCDF status
+
+       IMPLICIT NONE
+
+       INTEGER, INTENT(IN) ::  errno
+
+       IF ( nc_stat /= NF90_NOERR )  THEN
+          WRITE (*,'(A,1X,I3/4X,A)')                                           &
+                                   '+++ read_palm_netcdf_data  error handle:', &
+                                   errno, TRIM( nf90_strerror( nc_stat ) )
+          STOP
+       ENDIF
+
+    END SUBROUTINE handle_netcdf_error
+
+
+ END PROGRAM read_palm_netcdf_data
+
+
+
