Index: /palm/trunk/SCRIPTS/mrun
===================================================================
--- /palm/trunk/SCRIPTS/mrun	(revision 210)
+++ /palm/trunk/SCRIPTS/mrun	(revision 211)
@@ -157,4 +157,12 @@
      # 21/10/08 - Siggi  - bugfix for the case that -K has more than one
      #                     argument
+     # 08/11/08 - Siggi  - bugfix for depository path settings in configuration
+     #                     file
+     # 11/11/08 - Siggi  - rules for using user code files changed: user
+     #                     code splitted into one file per subroutine,
+     #                     user can provide his/her own makefile, only
+     #                     default source-code filenames are allowed
+
+
  
     # VARIABLENVEREINBARUNGEN + DEFAULTWERTE
@@ -1622,4 +1630,19 @@
 
 
+       # MAKEFILE AUF VORHANDENSEIN PRUEFEN UND KOPIEREN
+       # BEI RESTART-LAEUFEN LIEGT ES SCHON IM VERZEICHNIS SOURCES_FOR_RUN...
+    if [[ "$restart_run" != true ]]
+    then
+       [[ "$makefile" = "" ]]  &&  makefile=$source_path/Makefile
+       if [[ ! -f $makefile ]]
+       then
+          printf "\n  +++ file \"$makefile\" does not exist"
+          locat=make; exit
+       else
+          cp  $makefile  SOURCES_FOR_RUN_$fname/Makefile 
+       fi
+    fi
+
+
        # DATEIEN AUS ZUSAETZLICHEM QUELLVERZEICHNIS HINZUFUEGEN
     if [[ $restart_run != true  &&  "$add_source_path" != "" ]]
@@ -1638,4 +1661,5 @@
 
           cd $add_source_path
+          found=false
 
           Names=$(ls -1 *.f90 2>&1)
@@ -1653,4 +1677,13 @@
           cd  SOURCES_FOR_RUN_$fname
 
+             # COPY MAKEFILE IF EXISTING
+          if [[ -f $add_source_path/Makefile ]]
+          then
+             printf "\n\n  *** user Makefile from directory"
+             printf "\n      \"$add_source_path\" is used \n"
+             sleep 1
+             cp  $add_source_path/Makefile  .
+          fi
+
           for  dateiname  in  $AddFilenames
           do
@@ -1659,5 +1692,6 @@
                 printf "\n  +++ source code file \"$dateiname\" found in additional"
                 printf "\n      source code directory \"$add_source_path\" "
-                printf "\n      as well as in directory \"$source_path\"."
+                printf "\n      but was also given with option \"-s\" which means that it should be taken"
+                printf "\n      from directory \"$source_path\"."
                 locat=source; exit
              fi
@@ -1666,24 +1700,36 @@
              source_list="$source_list $dateiname"
 
+                # CHECK IF FILE IS CONTAINED IN MAKEFILE
+             if [[ $(grep -c $dateiname Makefile) = 0 ]]
+             then
+                printf "\n\n  +++ user file \"$dateiname\" "
+                printf "\n      is not listed in Makefile \n"
+                locat=source; exit
+             else
+
                 # Default User-Interface von der Liste entfernen, falls Datei
                 # ein User-Interface enthaelt
-             if [[ $( cat $dateiname | grep -c "END SUBROUTINE user_parin" ) != 0 ]]
-             then
-                if [[ $dateiname != user_interface.f90  &&  -f user_interface.f90 ]]
+#             if [[ $( cat $dateiname | grep -c "END SUBROUTINE user_parin" ) != 0 ]]
+#             then
+#                if [[ $dateiname != user_interface.f90  &&  -f user_interface.f90 ]]
+#                then
+#                   rm -rf  user_interface.f90
+#                   source_list=`echo $source_list | sed -e 's/user_interface.f90//'`
+#                   printf "\n\n  *** default \"user_interface.f90\" removed from the files to be translated"
+#                   printf "\n      since a user-interface is found in file"
+#                   printf "\n      \"$add_source_path/$dateiname\" \n"
+#                   sleep 3
+#                else
+                if [[ $found = false ]]
                 then
-                   rm -rf  user_interface.f90
-                   source_list=`echo $source_list | sed -e 's/user_interface.f90//'`
-                   printf "\n\n  *** default \"user_interface.f90\" removed from the files to be translated"
-                   printf "\n      since a user-interface is found in file"
-                   printf "\n      \"$add_source_path/$dateiname\" \n"
-                   sleep 3
-                else
-                   printf "\n\n  *** user-interface file \"$dateiname\" "
-                   printf "\n      added to the files to be translated \n"
-                   sleep 3
+                   found=true
+                   printf "\n\n  *** following user file(s) added to the"
+                   printf " files to be translated:\n      "
                 fi
+                printf "$dateiname  "
+                sleep 0.5
              fi
           done
-
+          [[ $found = true ]]  &&  printf "\n"
           cd -  > /dev/null
        fi
@@ -1733,15 +1779,15 @@
        # MAKEFILE AUF VORHANDENSEIN PRUEFEN UND KOPIEREN
        # BEI RESTART-LAEUFEN LIEGT ES SCHON IM VERZEICHNIS SOURCES_FOR_RUN...
-    if [[ "$restart_run" != true ]]
-    then
-       [[ "$makefile" = "" ]]  &&  makefile=$source_path/Makefile
-       if [[ ! -f $makefile ]]
-       then
-          printf "\n  +++ file \"$makefile\" does not exist"
-          locat=make; exit
-       else
-          cp  $makefile  SOURCES_FOR_RUN_$fname/Makefile 
-       fi
-    fi
+#    if [[ "$restart_run" != true ]]
+#    then
+#       [[ "$makefile" = "" ]]  &&  makefile=$source_path/Makefile
+#       if [[ ! -f $makefile ]]
+#       then
+#          printf "\n  +++ file \"$makefile\" does not exist"
+#          locat=make; exit
+#       else
+#          cp  $makefile  SOURCES_FOR_RUN_$fname/Makefile 
+#       fi
+#    fi
 
  fi  # do_compile=true
@@ -2220,5 +2266,8 @@
           if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
           then
-             local_depository_path=`echo $line | cut -d" " -s -f2`
+             if [[ "$(echo $line | cut -d" " -s -f4)" = "$cond1"  &&  "$(echo $line | cut -d" " -s -f5)" = "$cond2" ]]
+             then
+                local_depository_path=`echo $line | cut -d" " -s -f2`
+             fi
           fi
        done < tmp_mrun
@@ -2257,13 +2306,13 @@
           # ALS user_interface.f90 LIEGT, DIESEN GEAENDERTEN NAMEN INS
           # MAKEFILE EINTRAGEN
-       cd  $TEMPDIR_COMPILE
-       interface_file=`grep -l "END SUBROUTINE user_parin" $source_list`
-       if [[ "$interface_file" != "" ]]
-       then
-          interface_file=`echo $interface_file | cut -d"." -f1`
-          mv  Makefile  Makefile_old
-          sed "s/user_interface/$interface_file/g"  Makefile_old  >  Makefile
-       fi
-       cd -  > /dev/null
+#       cd  $TEMPDIR_COMPILE
+#       interface_file=`grep -l "END SUBROUTINE user_parin" $source_list`
+#       if [[ "$interface_file" != "" ]]
+#       then
+#          interface_file=`echo $interface_file | cut -d"." -f1`
+#          mv  Makefile  Makefile_old
+#          sed "s/user_interface/$interface_file/g"  Makefile_old  >  Makefile
+#       fi
+#       cd -  > /dev/null
     else
        cp  $executable   ${TEMPDIR}/a.out
@@ -2301,4 +2350,5 @@
        printf "\n\n\n  *** compilation starts \n$striche\n"
        printf "  *** compilation with make using following options:\n"
+       printf "      make depository:          $make_depository"
        printf "      compilername:             $compiler_name\n"
        printf "      options:                  $fopts\n"
@@ -2715,7 +2765,10 @@
        if [[ "$ENVIRONMENT" = BATCH ]]
        then
-          printf "\n  +++ debug is allowed in interactive mode only"
-          locat=debug
-          exit
+          if [[ $(echo $localhost | cut -c1-5) != lcsgi ]]
+          then
+             printf "\n  +++ debug is allowed in interactive mode only"
+             locat=debug
+             exit
+          fi
        fi
        if [[ $localhost = decalpha ]]
@@ -2756,4 +2809,28 @@
              totalview   poe  -a a.out  -procs $numprocs  -rmpool 0  -nodes 1   $ROPTS
           fi
+       elif [[ $(echo $localhost | cut -c1-5) = lcsgi ]]
+       then
+             # CURRENTLY NO DEBUGGER ON LCSGI
+          if [[ $run_coupled_model = true ]]
+          then
+             printf "\n  +++ no debug in coupled mode available on \"$localhost\" "
+             locat=debug
+             exit
+          fi
+          (( ii = $numprocs / $threads_per_task ))
+          export OMP_NUM_THREADS=$threads_per_task
+          echo "OMP_NUM_THREADS=$OMP_NUM_THREADS"
+          if [[ $threads_per_task != 1 ]]
+          then
+             printf "\n      threads per task: $threads_per_task"
+          fi
+          printf "\n\n"
+#          ulimit -s 300000   # A too large stack size causes problems
+#          export MV2_NUM_PORTS=2
+#          export MV2_CPU_MAPPING=0:1:2:3
+#          mpiexec    ./a.out  $ROPTS
+#          export MPI_LAUNCH_TIMEOUT=360
+           echo "no_coupling"  >  runfile_atmos
+           mpiexec_mpt -np $ii   ./a.out  $ROPTS
        else 
           printf "\n  +++ no debug available on \"$localhost\" "
Index: /palm/trunk/SOURCE/CURRENT_MODIFICATIONS
===================================================================
--- /palm/trunk/SOURCE/CURRENT_MODIFICATIONS	(revision 210)
+++ /palm/trunk/SOURCE/CURRENT_MODIFICATIONS	(revision 211)
@@ -7,8 +7,10 @@
 (-Y option). Adjustments in mrun, mbuild, and subjob for lcxt4.
 
-DVRP arguments changed to single precision, mode pathlines added
+DVRP arguments changed to single precision, mode pathlines added.
+
+User can add additional routines in files user_additional_routines.f90
 
 
-check_for_restart, check_parameters, data_output_dvrp, init_dvrp, init_pegrid, local_stop, modules, package_parin, palm, surface_coupler, timestep
+check_for_restart, check_parameters, data_output_dvrp, init_dvrp, init_pegrid, local_stop, modules, package_parin, palm, surface_coupler, timestep, user_additional_routines
 Makefile, mrun, mbuild, subjob
 
@@ -18,5 +20,11 @@
 Changed:
 -------
+User interface has been split into single files.
 
+Makefile
+
+New: user_3d_data_averaging user_actions user_advec_particles user_check_data_output user_check_data_output_pr user_data_output_2d user_data_output_3d user_data_output_dvrp user_define_netcdf_grid user_dvrp_coltab user_header user_init user_init_3d_model user_init_grid user_init_particles user_init_plant_canopy user_last_actions user_module user_parin user_particle_attributes user_read_restart_data user_spectra user_statistics
+
+Removed: user_interface
 
 Errors:
Index: /palm/trunk/SOURCE/Makefile
===================================================================
--- /palm/trunk/SOURCE/Makefile	(revision 210)
+++ /palm/trunk/SOURCE/Makefile	(revision 211)
@@ -4,4 +4,5 @@
 # Actual revisions:
 # -----------------
+# former file user_interface split into one file per subroutine
 # +init_coupling
 #
@@ -72,7 +73,16 @@
 	sum_up_3d_data.f90 surface_coupler.f90 swap_timelevel.f90 \
 	temperton_fft.f90 time_integration.f90 time_to_string.f90 timestep.f90 \
-	timestep_scheme_steering.f90 transpose.f90 user_interface.f90 \
-	wall_fluxes.f90 write_3d_binary.f90 write_compressed.f90 \
-	write_var_list.f90
+	timestep_scheme_steering.f90 transpose.f90 user_3d_data_averaging.f90 \
+	user_actions.f90 user_additional_routines.f90 user_advec_particles.f90 \
+	user_check_data_output.f90 \
+	user_check_data_output_pr.f90 user_data_output_2d.f90 \
+	user_data_output_3d.f90 user_data_output_dvrp.f90 \
+	user_define_netcdf_grid.f90 user_dvrp_coltab.f90 user_header.f90 \
+	user_init.f90 user_init_3d_model.f90 user_init_grid.f90 \
+	user_init_particles.f90 user_init_plant_canopy.f90 \
+	user_last_actions.f90 user_module.f90 user_parin.f90 \
+	user_particle_attributes.f90 user_read_restart_data.f90 \
+	user_spectra.f90 user_statistics.f90 wall_fluxes.f90 \
+	write_3d_binary.f90 write_compressed.f90 write_var_list.f90
 
 OBJS =  advec_particles.o advec_s_bc.o advec_s_pw.o advec_s_up.o \
@@ -102,5 +112,14 @@
 	spline_x.o spline_y.o spline_z.o sum_up_3d_data.o surface_coupler.o \
 	swap_timelevel.o temperton_fft.o time_integration.o time_to_string.o \
-        timestep.o timestep_scheme_steering.o transpose.o user_interface.o \
+        timestep.o timestep_scheme_steering.o transpose.o \
+	user_3d_data_averaging.o user_actions.o user_additional_routines.o \
+	user_advec_particles.o \
+	user_check_data_output.o user_check_data_output_pr.o \
+	user_data_output_2d.o user_data_output_3d.o user_data_output_dvrp.o \
+	user_define_netcdf_grid.o user_dvrp_coltab.o user_header.o \
+	user_init.o user_init_3d_model.o user_init_grid.o \
+	user_init_particles.o user_init_plant_canopy.o user_last_actions.o \
+	user_module.o user_parin.o user_particle_attributes.o \
+	user_read_restart_data.o user_spectra.o user_statistics.o \
 	wall_fluxes.o write_3d_binary.o write_compressed.o write_var_list.o
 
@@ -224,5 +243,5 @@
 	eqn_state_seawater.o impact_of_latent_heat.o \
         plant_canopy_model.o production_e.o \
-	user_interface.o
+	user_actions.o
 random_gauss.o: random_function.o
 read_3d_binary.o: modules.o random_function.o
@@ -238,10 +257,33 @@
 swap_timelevel.o: modules.o
 temperton_fft.o: modules.o
-time_integration.o: modules.o prognostic_equations.o user_interface.o \
+time_integration.o: modules.o prognostic_equations.o user_actions.o \
 	interaction_droplets_ptq.o
 timestep.o: modules.o
 timestep_scheme_steering.o: modules.o
 transpose.o: modules.o
-user_interface.o: modules.o user_interface.f90
+user_3d_data_averaging.o: modules.o user_module.o
+user_actions.o: modules.o user_module.o
+user_additional_routines.o: modules.o user_module.o
+user_advec_particles.o: modules.o user_module.o
+user_check_data_output.o: modules.o user_module.o
+user_check_data_output_pr.o: modules.o user_module.o
+user_data_output_2d.o: modules.o user_module.o
+user_data_output_3d.o: modules.o user_module.o
+user_data_output_dvrp.o: modules.o user_module.o
+user_define_netcdf_grid.o: modules.o user_module.o
+user_dvrp_coltab.o: modules.o user_module.o
+user_header.o: modules.o user_module.o
+user_init.o: modules.o user_module.o
+user_init_3d_model.o: modules.o user_module.o
+user_init_grid.o: modules.o user_module.o
+user_init_particles.o: modules.o user_module.o
+user_init_plant_canopy.o: modules.o user_module.o
+user_last_actions.o: modules.o user_module.o
+user_module.o: user_module.f90
+user_parin.o: modules.o user_module.o
+user_particle_attributes.o: modules.o user_module.o
+user_read_restart_data.o: modules.o user_module.o
+user_spectra.o: modules.o user_module.o
+user_statistics.o: modules.o user_module.o
 wall_fluxes.o: modules.o
 write_3d_binary.o: modules.o random_function.o
Index: /palm/trunk/SOURCE/user_3d_data_averaging.f90
===================================================================
--- /palm/trunk/SOURCE/user_3d_data_averaging.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_3d_data_averaging.f90	(revision 211)
@@ -0,0 +1,95 @@
+ SUBROUTINE user_3d_data_averaging( mode, variable )
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Sum up and time-average user-defined output quantities as well as allocate
+! the array necessary for storing the average.
+!------------------------------------------------------------------------------!
+
+    USE control_parameters
+    USE indices
+    USE user
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=*) ::  mode, variable
+
+    INTEGER ::  i, j, k
+
+
+    IF ( mode == 'allocate' )  THEN
+
+       SELECT CASE ( TRIM( variable ) )
+
+!
+!--       Uncomment and extend the following lines, if necessary.
+!--       The arrays for storing the user defined quantities (here u2_av) have
+!--       to be declared and defined by the user!
+!--       Sample for user-defined output:
+!          CASE ( 'u2' )
+!             IF ( .NOT. ALLOCATED( u2_av ) )  THEN
+!                ALLOCATE( u2_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+!             ENDIF
+!             u2_av = 0.0
+
+          CASE DEFAULT
+             CONTINUE
+
+       END SELECT
+
+    ELSEIF ( mode == 'sum' )  THEN
+
+       SELECT CASE ( TRIM( variable ) )
+
+!
+!--       Uncomment and extend the following lines, if necessary.
+!--       The arrays for storing the user defined quantities (here u2 and
+!--       u2_av) have to be declared and defined by the user!
+!--       Sample for user-defined output:
+!          CASE ( 'u2' )
+!             DO  i = nxl-1, nxr+1
+!                DO  j = nys-1, nyn+1
+!                   DO  k = nzb, nzt+1
+!                      u2_av(k,j,i) = u2_av(k,j,i) + u2(k,j,i)
+!                   ENDDO
+!                ENDDO
+!             ENDDO
+
+          CASE DEFAULT
+             CONTINUE
+
+       END SELECT
+
+    ELSEIF ( mode == 'average' )  THEN
+
+       SELECT CASE ( TRIM( variable ) )
+
+!
+!--       Uncomment and extend the following lines, if necessary.
+!--       The arrays for storing the user defined quantities (here u2_av) have
+!--       to be declared and defined by the user!
+!--       Sample for user-defined output:
+!          CASE ( 'u2' )
+!             DO  i = nxl-1, nxr+1
+!                DO  j = nys-1, nyn+1
+!                   DO  k = nzb, nzt+1
+!                      u2_av(k,j,i) = u2_av(k,j,i) / REAL( average_count_3d )
+!                   ENDDO
+!                ENDDO
+!             ENDDO
+
+       END SELECT
+
+    ENDIF
+
+
+ END SUBROUTINE user_3d_data_averaging
Index: /palm/trunk/SOURCE/user_actions.f90
===================================================================
--- /palm/trunk/SOURCE/user_actions.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_actions.f90	(revision 211)
@@ -0,0 +1,184 @@
+ MODULE user_actions_mod
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Execution of user-defined actions before or after single timesteps
+!------------------------------------------------------------------------------!
+
+    PRIVATE
+    PUBLIC user_actions
+
+    INTERFACE user_actions
+       MODULE PROCEDURE user_actions
+       MODULE PROCEDURE user_actions_ij
+    END INTERFACE user_actions
+
+ CONTAINS
+
+
+!------------------------------------------------------------------------------!
+! Call for all grid points
+!------------------------------------------------------------------------------!
+    SUBROUTINE user_actions( location )
+
+       USE control_parameters
+       USE cpulog
+       USE indices
+       USE interfaces
+       USE pegrid
+       USE user
+       USE arrays_3d
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=*) ::  location
+
+       INTEGER ::  i, j, k
+
+       CALL cpu_log( log_point(24), 'user_actions', 'start' )
+
+!
+!--    Here the user-defined actions follow
+!--    No calls for single grid points are allowed at locations before and
+!--    after the timestep, since these calls are not within an i,j-loop
+       SELECT CASE ( location )
+
+          CASE ( 'before_timestep' )
+!
+!--          Enter actions to be done before every timestep here
+
+
+          CASE ( 'after_integration' )
+!
+!--          Enter actions to be done after every time integration (before
+!--          data output)
+!--          Sample for user-defined output:
+!             DO  i = nxl-1, nxr+1
+!                DO  j = nys-1, nyn+1
+!                   DO  k = nzb, nzt+1
+!                      u2(k,j,i) = u(k,j,i)**2
+!                   ENDDO
+!                ENDDO
+!             ENDDO
+!             DO  i = nxl-1, nxr
+!                DO  j = nys-1, nyn
+!                   DO  k = nzb, nzt+1
+!                      ustvst(k,j,i) =  &
+!                         ( 0.5 * ( u(k,j,i) + u(k,j,i+1) ) - hom(k,1,1,0) ) * &
+!                         ( 0.5 * ( v(k,j,i) + v(k,j+1,i) ) - hom(k,1,2,0) )
+!                   ENDDO
+!                ENDDO
+!             ENDDO
+
+
+          CASE ( 'after_timestep' )
+!
+!--          Enter actions to be done after every timestep here
+
+
+          CASE ( 'u-tendency' )
+!
+!--          Enter actions to be done in the u-tendency term here
+
+
+          CASE ( 'v-tendency' )
+
+
+          CASE ( 'w-tendency' )
+
+
+          CASE ( 'pt-tendency' )
+
+
+          CASE ( 'sa-tendency' )
+
+
+          CASE ( 'e-tendency' )
+
+
+          CASE ( 'q-tendency' )
+
+
+          CASE DEFAULT
+             IF ( myid == 0 )  PRINT*, '+++ user_actions: unknown location "', &
+                                       location, '"'
+             CALL local_stop
+
+       END SELECT
+
+       CALL cpu_log( log_point(24), 'user_actions', 'stop' )
+
+    END SUBROUTINE user_actions
+
+
+!------------------------------------------------------------------------------!
+! Call for grid point i,j
+!------------------------------------------------------------------------------!
+    SUBROUTINE user_actions_ij( i, j, location )
+
+       USE control_parameters
+       USE pegrid
+       USE user
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=*) ::  location
+
+       INTEGER ::  i, idum, j
+
+
+!
+!--    Here the user-defined actions follow
+       SELECT CASE ( location )
+
+          CASE ( 'u-tendency' )
+!
+!--          Enter actions to be done in the u-tendency term here
+
+
+          CASE ( 'v-tendency' )
+
+
+          CASE ( 'w-tendency' )
+
+
+          CASE ( 'pt-tendency' )
+
+
+          CASE ( 'sa-tendency' )
+
+
+          CASE ( 'e-tendency' )
+
+
+          CASE ( 'q-tendency' )
+
+
+          CASE ( 'before_timestep', 'after_integration', 'after_timestep' )
+             IF ( myid == 0 )  THEN
+                PRINT*, '+++ user_actions: location "', location, '" is not ', &
+                             'allowed to be called with parameters "i" and "j"'
+             ENDIF
+             CALL local_stop
+
+
+          CASE DEFAULT
+             IF ( myid == 0 )  PRINT*, '+++ user_actions: unknown location "', &
+                                       location, '"'
+             CALL local_stop
+
+
+       END SELECT
+
+    END SUBROUTINE user_actions_ij
+
+ END MODULE user_actions_mod
Index: /palm/trunk/SOURCE/user_additional_routines.f90
===================================================================
--- /palm/trunk/SOURCE/user_additional_routines.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_additional_routines.f90	(revision 211)
@@ -0,0 +1,25 @@
+ SUBROUTINE user_dummy
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Initial version
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! This file may contain additional user-defined routines.
+!------------------------------------------------------------------------------!
+
+    USE user
+
+    IMPLICIT NONE
+
+!
+!-- Here comes the code of the user-defined routine
+
+ END SUBROUTINE user_dummy
+
Index: /palm/trunk/SOURCE/user_advec_particles.f90
===================================================================
--- /palm/trunk/SOURCE/user_advec_particles.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_advec_particles.f90	(revision 211)
@@ -0,0 +1,30 @@
+ SUBROUTINE user_advec_particles
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Modification of initial particles by the user.
+!------------------------------------------------------------------------------!
+
+    USE particle_attributes
+    USE user
+
+    IMPLICIT NONE
+
+    INTEGER ::  n
+
+!
+!-- Here the user-defined actions follow
+!    DO  n = 1, number_of_initial_particles
+!    ENDDO
+
+ END SUBROUTINE user_advec_particles
+
Index: /palm/trunk/SOURCE/user_check_data_output.f90
===================================================================
--- /palm/trunk/SOURCE/user_check_data_output.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_check_data_output.f90	(revision 211)
@@ -0,0 +1,44 @@
+ SUBROUTINE user_check_data_output( variable, unit )
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Set the unit of user defined output quantities. For those variables
+! not recognized by the user, the parameter unit is set to "illegal", which
+! tells the calling routine that the output variable is not defined and leads
+! to a program abort.
+!------------------------------------------------------------------------------!
+
+    USE user
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=*) ::  unit, variable
+
+
+    SELECT CASE ( TRIM( variable ) )
+
+!
+!--    Uncomment and extend the following lines, if necessary
+!       CASE ( 'u2' )
+!          unit = 'm2/s2'
+!
+!       CASE ( 'u*v*' )
+!          unit = 'm2/s2'
+!
+       CASE DEFAULT
+          unit = 'illegal'
+
+    END SELECT
+
+
+ END SUBROUTINE user_check_data_output
+
Index: /palm/trunk/SOURCE/user_check_data_output_pr.f90
===================================================================
--- /palm/trunk/SOURCE/user_check_data_output_pr.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_check_data_output_pr.f90	(revision 211)
@@ -0,0 +1,61 @@
+ SUBROUTINE user_check_data_output_pr( variable, var_count, unit )
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Set the unit of user defined profile output quantities. For those variables
+! not recognized by the user, the parameter unit is set to "illegal", which
+! tells the calling routine that the output variable is not defined and leads
+! to a program abort.
+!------------------------------------------------------------------------------!
+
+    USE arrays_3d
+    USE indices
+    USE netcdf_control
+    USE profil_parameter
+    USE statistics
+    USE user
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=*) ::  unit, variable
+
+    INTEGER ::  index, var_count
+
+
+    SELECT CASE ( TRIM( variable ) )
+
+!
+!--    Uncomment and extend the following lines, if necessary.
+!--    Add additional CASE statements depending on the number of quantities
+!--    for which profiles are to be calculated. The respective calculations
+!--    to be performed have to be added in routine user_statistics.
+!--    The quantities are (internally) identified by a user-profile-number
+!--    (see variable "index" below). The first user-profile must be assigned
+!--    the number "pr_palm+1", the second one "pr_palm+2", etc. The respective
+!--    user-profile-numbers have also to be used in routine user_statistics!
+!       CASE ( 'u*v*' )                      ! quantity string as given in
+!                                            ! data_output_pr_user
+!          index = pr_palm + 1
+!          dopr_index(var_count)  = index    ! quantities' user-profile-number
+!          dopr_unit(var_count)   = 'm2/s2'  ! quantity unit
+!          hom(:,2,index,:)       = SPREAD( zu, 2, statistic_regions+1 )
+!                                            ! grid on which the quantity is
+!                                            ! defined (use zu or zw)
+
+       CASE DEFAULT
+          unit = 'illegal'
+
+    END SELECT
+
+
+ END SUBROUTINE user_check_data_output_pr
+
Index: /palm/trunk/SOURCE/user_data_output_2d.f90
===================================================================
--- /palm/trunk/SOURCE/user_data_output_2d.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_data_output_2d.f90	(revision 211)
@@ -0,0 +1,71 @@
+ SUBROUTINE user_data_output_2d( av, variable, found, grid, local_pf )
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Resorts the user-defined output quantity with indices (k,j,i) to a
+! temporary array with indices (i,j,k) and sets the grid on which it is defined.
+! Allowed values for grid are "zu" and "zw".
+!------------------------------------------------------------------------------!
+
+    USE indices
+    USE user
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=*) ::  grid, variable
+
+    INTEGER ::  av, i, j, k
+
+    LOGICAL ::  found
+
+    REAL, DIMENSION(nxl-1:nxr+1,nys-1:nyn+1,nzb:nzt+1) ::  local_pf
+
+
+    found = .TRUE.
+
+    SELECT CASE ( TRIM( variable ) )
+
+!
+!--    Uncomment and extend the following lines, if necessary.
+!--    The arrays for storing the user defined quantities (here u2 and u2_av)
+!--    have to be declared and defined by the user!
+!--    Sample for user-defined output:
+!       CASE ( 'u2_xy', 'u2_xz', 'u2_yz' )
+!          IF ( av == 0 )  THEN
+!             DO  i = nxl-1, nxr+1
+!                DO  j = nys-1, nyn+1
+!                   DO  k = nzb, nzt+1
+!                      local_pf(i,j,k) = u2(k,j,i)
+!                   ENDDO
+!                ENDDO
+!             ENDDO
+!          ELSE
+!             DO  i = nxl-1, nxr+1
+!                DO  j = nys-1, nyn+1
+!                   DO  k = nzb, nzt+1
+!                      local_pf(i,j,k) = u2_av(k,j,i)
+!                   ENDDO
+!                ENDDO
+!             ENDDO
+!          ENDIF
+!
+!          grid = 'zu'
+
+       CASE DEFAULT
+          found = .FALSE.
+          grid  = 'none'
+
+    END SELECT
+
+
+ END SUBROUTINE user_data_output_2d
+
Index: /palm/trunk/SOURCE/user_data_output_3d.f90
===================================================================
--- /palm/trunk/SOURCE/user_data_output_3d.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_data_output_3d.f90	(revision 211)
@@ -0,0 +1,69 @@
+ SUBROUTINE user_data_output_3d( av, variable, found, local_pf, nz_do )
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Resorts the user-defined output quantity with indices (k,j,i) to a
+! temporary array with indices (i,j,k).
+!------------------------------------------------------------------------------!
+
+    USE array_kind
+    USE indices
+    USE user
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=*) ::  variable
+
+    INTEGER ::  av, i, j, k, nz_do
+
+    LOGICAL ::  found
+
+    REAL(spk), DIMENSION(nxl-1:nxr+1,nys-1:nyn+1,nzb:nz_do) ::  local_pf
+
+
+    found = .TRUE.
+
+    SELECT CASE ( TRIM( variable ) )
+
+!
+!--    Uncomment and extend the following lines, if necessary.
+!--    The arrays for storing the user defined quantities (here u2 and u2_av)
+!--    have to be declared and defined by the user!
+!--    Sample for user-defined output:
+!       CASE ( 'u2' )
+!          IF ( av == 0 )  THEN
+!             DO  i = nxl-1, nxr+1
+!                DO  j = nys-1, nyn+1
+!                   DO  k = nzb, nz_do
+!                      local_pf(i,j,k) = u2(k,j,i)
+!                   ENDDO
+!                ENDDO
+!             ENDDO
+!          ELSE
+!             DO  i = nxl-1, nxr+1
+!                DO  j = nys-1, nyn+1
+!                   DO  k = nzb, nz_do
+!                      local_pf(i,j,k) = u2_av(k,j,i)
+!                   ENDDO
+!                ENDDO
+!             ENDDO
+!          ENDIF
+!
+
+       CASE DEFAULT
+          found = .FALSE.
+
+    END SELECT
+
+
+ END SUBROUTINE user_data_output_3d
+
Index: /palm/trunk/SOURCE/user_data_output_dvrp.f90
===================================================================
--- /palm/trunk/SOURCE/user_data_output_dvrp.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_data_output_dvrp.f90	(revision 211)
@@ -0,0 +1,64 @@
+ SUBROUTINE user_data_output_dvrp( output_variable, local_pf )
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Execution of user-defined dvrp output
+!------------------------------------------------------------------------------!
+
+    USE control_parameters
+    USE indices
+    USE pegrid
+    USE user
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=*) ::  output_variable
+
+    INTEGER ::  i, j, k
+
+    REAL, DIMENSION(nxl:nxr+1,nys:nyn+1,nzb:nz_do3d) ::  local_pf
+
+!
+!-- Here the user-defined DVRP output follows:
+
+!
+!-- Move original array to intermediate array
+    SELECT CASE ( output_variable )
+
+!       CASE ( 'u2', 'u2_xy', 'u2_xz', 'u2_yz'  )
+!!
+!!--       Here the user can add user_defined output quantities. 
+!!--       Uncomment and extend the following lines, if necessary.
+!          DO  i = nxl, nxr+1
+!             DO  j = nys, nyn+1
+!                DO  k = nzb, nz_do3d
+!                   local_pf(i,j,k) = u2(k,j,i)
+!                ENDDO
+!             ENDDO
+!          ENDDO
+
+
+       CASE DEFAULT
+!
+!--       The DEFAULT case is reached if output_variable contains a
+!--       wrong character string that is neither recognized in data_output_dvrp
+!--       nor here in user_data_output_dvrp.
+          IF ( myid == 0 )  THEN
+             PRINT*,'+++ (user_)data_output_dvrp: no output possible for: ', &
+                  output_variable
+          ENDIF
+
+    END SELECT
+
+
+ END SUBROUTINE user_data_output_dvrp
+
Index: /palm/trunk/SOURCE/user_define_netcdf_grid.f90
===================================================================
--- /palm/trunk/SOURCE/user_define_netcdf_grid.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_define_netcdf_grid.f90	(revision 211)
@@ -0,0 +1,52 @@
+ SUBROUTINE user_define_netcdf_grid( variable, found, grid_x, grid_y, grid_z )
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Set the grids on which user-defined output quantities are defined.
+! Allowed values for grid_x are "x" and "xu", for grid_y "y" and "yv", and
+! for grid_z "zu" and "zw".
+!------------------------------------------------------------------------------!
+
+    USE user
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=*) ::  grid_x, grid_y, grid_z, variable
+
+    LOGICAL ::  found
+
+
+    SELECT CASE ( TRIM( variable ) )
+
+!
+!--    Uncomment and extend the following lines, if necessary
+!       CASE ( 'u2', 'u2_xy', 'u2_xz', 'u2_yz' )
+!          grid_x = 'xu'
+!          grid_y = 'y'
+!          grid_z = 'zu'
+
+!       CASE ( 'u*v*', 'u*v*_xy', 'u*v*_xz', 'u*v*_yz' )
+!          grid_x = 'x'
+!          grid_y = 'y'
+!          grid_z = 'zu'
+
+       CASE DEFAULT
+          found  = .FALSE.
+          grid_x = 'none'
+          grid_y = 'none'
+          grid_z = 'none'
+
+    END SELECT
+
+
+ END SUBROUTINE user_define_netcdf_grid
+
Index: /palm/trunk/SOURCE/user_dvrp_coltab.f90
===================================================================
--- /palm/trunk/SOURCE/user_dvrp_coltab.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_dvrp_coltab.f90	(revision 211)
@@ -0,0 +1,43 @@
+ SUBROUTINE user_dvrp_coltab( mode, variable )
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Definition of the colour table to be used by the dvrp software.
+!------------------------------------------------------------------------------!
+
+    USE dvrp_variables
+    USE pegrid
+    USE user
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=*) ::  mode
+    CHARACTER (LEN=*) ::  variable
+
+
+!
+!-- Here the user-defined actions follow
+    SELECT CASE ( mode )
+
+       CASE ( 'particles' )
+
+       CASE ( 'slicer' )
+
+       CASE DEFAULT
+          IF ( myid == 0 )  PRINT*, '+++ user_dvrp_coltab: unknown mode "', &
+                                    mode, '"'
+          CALL local_stop
+
+    END SELECT
+
+ END SUBROUTINE user_dvrp_coltab
+
Index: /palm/trunk/SOURCE/user_header.f90
===================================================================
--- /palm/trunk/SOURCE/user_header.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_header.f90	(revision 211)
@@ -0,0 +1,56 @@
+ SUBROUTINE user_header( io )
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Print a header with user-defined informations.
+!------------------------------------------------------------------------------!
+
+    USE statistics
+    USE user
+
+    IMPLICIT NONE
+
+    INTEGER ::  i, io
+
+!
+!-- If no user-defined variables are read from the namelist-file, no
+!-- informations will be printed.
+    IF ( .NOT. user_defined_namelist_found )  THEN
+       WRITE ( io, 100 )
+       RETURN
+    ENDIF
+
+!
+!-- Printing the informations.
+    WRITE ( io, 110 )
+
+    IF ( statistic_regions /= 0 )  THEN
+       WRITE ( io, 200 )
+       DO  i = 0, statistic_regions
+          WRITE ( io, 201 )  i, region(i)
+       ENDDO
+    ENDIF
+
+
+
+!
+!-- Format-descriptors
+100 FORMAT (//' *** no user-defined variables found'/)
+110 FORMAT (//1X,78('#')                                      &
+            //' User-defined variables and actions:'/  &
+              ' -----------------------------------'//)
+200 FORMAT (' Output of profiles and time series for following regions:' /)
+201 FORMAT (4X,'Region ',I1,':   ',A)
+
+
+ END SUBROUTINE user_header
+
Index: /palm/trunk/SOURCE/user_init.f90
===================================================================
--- /palm/trunk/SOURCE/user_init.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_init.f90	(revision 211)
@@ -0,0 +1,48 @@
+ SUBROUTINE user_init
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Execution of user-defined initializing actions
+!------------------------------------------------------------------------------!
+
+    USE control_parameters
+    USE indices
+    USE netcdf_control
+    USE pegrid
+    USE user
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=20) :: field_char
+!
+!-- Here the user-defined initializing actions follow:
+!-- Sample for user-defined output
+!    ALLOCATE( u2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+!    ALLOCATE( ustvst(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) );  ustvst = 0.0
+
+!-- Sample for user-defined time series
+!-- For each time series quantity you have to give a label and a unit,
+!-- which will be used for the NetCDF file. They must not contain more than
+!-- seven characters. The value of dots_num has to be increased by the
+!-- number of new time series quantities. Its old value has to be store in
+!-- dots_num_palm. See routine user_statistics on how to output calculate
+!-- and output these quantities.
+!    dots_label(dots_num+1) = 'abs_umx'
+!    dots_unit(dots_num+1)  = 'm/s'
+!    dots_label(dots_num+2) = 'abs_vmx'
+!    dots_unit(dots_num+2)  = 'm/s'
+!
+!    dots_num_palm = dots_num
+!    dots_num = dots_num + 2
+
+ END SUBROUTINE user_init
+
Index: /palm/trunk/SOURCE/user_init_3d_model.f90
===================================================================
--- /palm/trunk/SOURCE/user_init_3d_model.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_init_3d_model.f90	(revision 211)
@@ -0,0 +1,29 @@
+ SUBROUTINE user_init_3d_model
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Allows the complete initialization of the 3d model.
+!
+! CAUTION: The user is responsible to set at least all those quantities which
+! ------   are normally set within init_3d_model!
+!------------------------------------------------------------------------------!
+
+    USE arrays_3d
+    USE control_parameters
+    USE indices
+    USE user
+
+    IMPLICIT NONE
+
+
+ END SUBROUTINE user_init_3d_model
+
Index: /palm/trunk/SOURCE/user_init_grid.f90
===================================================================
--- /palm/trunk/SOURCE/user_init_grid.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_init_grid.f90	(revision 211)
@@ -0,0 +1,62 @@
+ SUBROUTINE user_init_grid( gls, nzb_local )
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Execution of user-defined grid initializing actions
+! First argument gls contains the number of ghost layers, which is > 1 if the
+! multigrid method for the pressure solver is used
+!------------------------------------------------------------------------------!
+
+    USE control_parameters
+    USE indices
+    USE user
+
+    IMPLICIT NONE
+
+    INTEGER ::  gls
+
+    INTEGER, DIMENSION(-gls:ny+gls,-gls:nx+gls) ::  nzb_local
+
+!
+!-- Here the user-defined grid initializing actions follow:
+
+!
+!-- Set the index array nzb_local for non-flat topography.
+!-- Here consistency checks concerning domain size and periodicity are necessary
+    SELECT CASE ( TRIM( topography ) )
+
+       CASE ( 'flat', 'single_building' )
+!
+!--       Not allowed here since these are the standard cases used in init_grid.
+
+       CASE ( 'user_defined_topography_1' )
+!
+!--       Here the user can define his own topography. After definition, please
+!--       remove the following three lines!
+          PRINT*, '+++ user_init_grid: topography "', &
+               topography, '" not available yet'
+          CALL local_stop
+
+       CASE DEFAULT
+!
+!--       The DEFAULT case is reached if the parameter topography contains a
+!--       wrong character string that is neither recognized in init_grid nor 
+!--       here in user_init_grid.
+          PRINT*, '+++ (user_)init_grid: unknown topography "', &
+               topography, '"'
+          CALL local_stop
+
+    END SELECT
+
+
+ END SUBROUTINE user_init_grid
+
Index: /palm/trunk/SOURCE/user_init_particles.f90
===================================================================
--- /palm/trunk/SOURCE/user_init_particles.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_init_particles.f90	(revision 211)
@@ -0,0 +1,30 @@
+ SUBROUTINE user_init_particles
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Modification of initial particles by the user.
+!------------------------------------------------------------------------------!
+
+    USE particle_attributes
+    USE user
+
+    IMPLICIT NONE
+
+    INTEGER ::  n
+
+!
+!-- Here the user-defined actions follow
+!    DO  n = 1, number_of_initial_particles
+!    ENDDO
+
+ END SUBROUTINE user_init_particles
+
Index: /palm/trunk/SOURCE/user_init_plant_canopy.f90
===================================================================
--- /palm/trunk/SOURCE/user_init_plant_canopy.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_init_plant_canopy.f90	(revision 211)
@@ -0,0 +1,74 @@
+ SUBROUTINE user_init_plant_canopy
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Initialisation of the leaf area density array (for scalar grid points) and 
+! the array of the canopy drag coefficient, if the user has not chosen any 
+! of the default cases 
+!------------------------------------------------------------------------------!
+
+    USE arrays_3d
+    USE control_parameters
+    USE indices
+    USE user
+
+    IMPLICIT NONE
+
+    INTEGER :: i, j 
+
+!
+!-- Here the user-defined grid initializing actions follow:
+
+!
+!-- Set the 3D-arrays lad_s and cdc for user defined canopies
+    SELECT CASE ( TRIM( canopy_mode ) )
+
+       CASE ( 'block' )
+!
+!--       Not allowed here since this is the standard case used in init_3d_model.
+
+       CASE ( 'user_defined_canopy_1' )
+!
+!--       Here the user can define his own topography. 
+!--       The following lines contain an example in that the 
+!--       plant canopy extends only over the second half of the 
+!--       model domain along x
+!          DO  i = nxl-1, nxr+1
+!             IF ( i >= INT(nx+1/2) ) THEN
+!                DO  j = nys-1, nyn+1
+!                   lad_s(:,j,i) = lad(:)
+!                   cdc(:,j,i)   = drag_coefficient
+!                ENDDO
+!             ELSE
+!                lad_s(:,:,i) = 0.0
+!                cdc(:,:,i)   = 0.0
+!             ENDIF
+!          ENDDO 
+!--       After definition, please
+!--       remove the following three lines!
+          PRINT*, '+++ user_init_plant_canopy: canopy_mode "', &
+               canopy_mode, '" not available yet'
+
+       CASE DEFAULT
+!
+!--       The DEFAULT case is reached if the parameter canopy_mode contains a
+!--       wrong character string that is neither recognized in init_3d_model nor 
+!--       here in user_init_plant_canopy.
+          PRINT*, '+++ user_init_plant_canopy: unknown canopy_mode "', &
+               canopy_mode, '"'
+          CALL local_stop
+
+    END SELECT
+
+
+ END SUBROUTINE user_init_plant_canopy
+
Index: lm/trunk/SOURCE/user_interface.f90
===================================================================
--- /palm/trunk/SOURCE/user_interface.f90	(revision 210)
+++ 	(revision )
@@ -1,1344 +1,0 @@
- MODULE user
-
-!------------------------------------------------------------------------------!
-! Actual revisions:
-! -----------------
-! 
-!
-! Former revisions:
-! -----------------
-! $Id$
-!
-! 159 2008-04-09 08:06:03Z raasch
-! bugfix in user_read_restart_data
-! small bugfixes for sample code (comments):
-! - initialize ustvst with 0.0 as it is now computed only until nxr and nyn
-! - two ALLOCATE statements moved from user_read_restart_data back to user_init
-! - remove 'READ (13) u2_av' statement in user_read_restart_data
-! +routines user_read_restart_data, user_spectra
-!
-! 138 2007-11-28 10:03:58Z letzel
-! new subroutines user_init_plant_canopy, user_data_output_dvrp
-! +argument gls in user_init_grid
-!
-! 105 2007-08-08 07:12:55Z raasch
-! +dots_num_palm in module user, +module netcdf_control in user_init
-!
-! 95 2007-06-02 16:48:38Z raasch
-! user action for salinity added
-!
-! 89 2007-05-25 12:08:31Z raasch
-! Calculation and output of user-defined profiles: new routine
-! user_check_data_output_pr, +data_output_pr_user, max_pr_user in userpar,
-! routine user_statistics has got two more arguments
-! Bugfix: field_chr renamed field_char
-!
-! 60 2007-03-11 11:50:04Z raasch
-! New routine user_init_3d_model which allows the initial setting of all 3d
-! arrays under control of the user, new routine user_advec_particles,
-! routine user_statistics now has one argument (sr),
-! sample for generating time series quantities added
-! Bugfix in sample for reading user defined data from restart file (user_init)
-!
-! RCS Log replace by Id keyword, revision history cleaned up
-!
-! Revision 1.18  2006/06/02 15:25:00  raasch
-! +change of grid-defining arguments in routine user_define_netcdf_grid,
-! new argument "found" in user_data_output_2d and user_data_output_3d
-!
-! Revision 1.1  1998/03/24 15:29:04  raasch
-! Initial revision
-!
-!
-! Description:
-! ------------
-! Declaration of user-defined variables. This module may only be used
-! in the user-defined routines (contained in user_interface.f90).
-!------------------------------------------------------------------------------!
-
-    INTEGER ::  dots_num_palm, user_idummy
-    LOGICAL ::  user_defined_namelist_found = .FALSE.
-    REAL    ::  user_dummy
-
-!
-!-- Sample for user-defined output
-!    REAL, DIMENSION(:,:,:), ALLOCATABLE ::  u2, u2_av
-!    REAL, DIMENSION(:,:,:), ALLOCATABLE ::  ustvst
-
-    SAVE
-
- END MODULE user
-
-
- SUBROUTINE user_parin
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Interface to read user-defined namelist-parameters.
-!------------------------------------------------------------------------------!
-
-    USE control_parameters
-    USE pegrid
-    USE statistics
-    USE user
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=80) ::  zeile
-
-    INTEGER ::  i, j, max_pr_user_tmp
-
-
-    NAMELIST /userpar/  data_output_pr_user, data_output_user, region
-
-!
-!-- Position the namelist-file at the beginning (it was already opened in
-!-- parin), search for user-defined namelist-group ("userpar", but any other
-!-- name can be choosed) and position the file at this line.
-    REWIND ( 11 )
-
-    zeile = ' '
-    DO   WHILE ( INDEX( zeile, '&userpar' ) == 0 )
-       READ ( 11, '(A)', END=100 )  zeile
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read user-defined namelist
-    READ ( 11, userpar )
-    user_defined_namelist_found = .TRUE.
-
-!
-!-- Determine the number of user-defined profiles and append them to the
-!-- standard data output (data_output_pr)
-    max_pr_user_tmp = 0
-    IF ( data_output_pr_user(1) /= ' ' )  THEN
-       i = 1
-       DO  WHILE ( data_output_pr(i) /= ' '  .AND.  i <= 100 )
-          i = i + 1
-       ENDDO
-       j = 1
-       DO  WHILE ( data_output_pr_user(j) /= ' '  .AND.  j <= 100 )
-          data_output_pr(i) = data_output_pr_user(j)
-          max_pr_user_tmp   = max_pr_user_tmp + 1
-          i = i + 1
-          j = j + 1
-       ENDDO
-    ENDIF
-
-!
-!-- In case of a restart run, the number of user-defined profiles on the
-!-- restart file (already stored in max_pr_user) has to match the one given
-!-- for the current run
-    IF ( TRIM( initializing_actions ) == 'read_restart_data' )  THEN
-       IF ( max_pr_user /= max_pr_user_tmp )  THEN
-          PRINT*, '+++ user_parin: the number of user-defined profiles given in'
-          PRINT*, '                data_output_pr (', max_pr_user_tmp, ' doe', &
-                                   's not match the one'
-          PRINT*, '                found in the restart file (', max_pr_user, &
-                                   ')'
-          CALL local_stop
-       ENDIF
-    ELSE
-       max_pr_user = max_pr_user_tmp
-    ENDIF
-
-100 RETURN
-
- END SUBROUTINE user_parin
-
-
-
- SUBROUTINE user_header( io )
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Print a header with user-defined informations.
-!------------------------------------------------------------------------------!
-
-    USE statistics
-    USE user
-
-    IMPLICIT NONE
-
-    INTEGER ::  i, io
-
-!
-!-- If no user-defined variables are read from the namelist-file, no
-!-- informations will be printed.
-    IF ( .NOT. user_defined_namelist_found )  THEN
-       WRITE ( io, 100 )
-       RETURN
-    ENDIF
-
-!
-!-- Printing the informations.
-    WRITE ( io, 110 )
-
-    IF ( statistic_regions /= 0 )  THEN
-       WRITE ( io, 200 )
-       DO  i = 0, statistic_regions
-          WRITE ( io, 201 )  i, region(i)
-       ENDDO
-    ENDIF
-
-
-
-!
-!-- Format-descriptors
-100 FORMAT (//' *** no user-defined variables found'/)
-110 FORMAT (//1X,78('#')                                      &
-            //' User-defined variables and actions:'/  &
-              ' -----------------------------------'//)
-200 FORMAT (' Output of profiles and time series for following regions:' /)
-201 FORMAT (4X,'Region ',I1,':   ',A)
-
-
- END SUBROUTINE user_header
-
-
-
- SUBROUTINE user_read_restart_data( nxlc, nxlf, nxl_on_file, nxrc, nxrf,  &
-                                    nxr_on_file, nync, nynf, nyn_on_file, &
-                                    nysc, nysf, nys_on_file, tmp_2d, tmp_3d )
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Reading restart data from file(s)
-! Subdomain index limits on file are given by nxl_on_file, etc.
-! Indices nxlc, etc. indicate the range of gridpoints to be mapped from the
-! subdomain on file (f) to the subdomain of the current PE (c). They have been
-! calculated in routine read_3d_binary.
-!------------------------------------------------------------------------------!
-
-    USE control_parameters
-    USE indices
-    USE pegrid
-    USE user
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=20) :: field_char
-
-    INTEGER ::  nxlc, nxlf, nxl_on_file, nxrc, nxrf, nxr_on_file, nync, nynf, &
-                nyn_on_file, nysc, nysf, nys_on_file
-
-    REAL, DIMENSION(nys_on_file-1:nyn_on_file+1,nxl_on_file-1:nxr_on_file+1) ::&
-          tmp_2d
-
-    REAL, DIMENSION(nzb:nzt+1,nys_on_file-1:nyn_on_file+1, &
-                    nxl_on_file-1:nxr_on_file+1) ::        &
-          tmp_3d
-
-!
-!-- Here the reading of user-defined restart data follows:
-!-- Sample for user-defined output
-!
-!    IF ( initializing_actions == 'read_restart_data' )  THEN
-!       READ ( 13 )  field_char
-!       DO  WHILE ( TRIM( field_char ) /= '*** end user ***' )
-!
-!          SELECT CASE ( TRIM( field_char ) )
-!
-!             CASE ( 'u2_av' )
-!                IF ( .NOT. ALLOCATED( u2_av ) ) THEN
-!                   ALLOCATE( u2_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-!                ENDIF
-!                READ ( 13 )  tmp_3d
-!                u2_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
-!                                          tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1)
-!
-!             CASE DEFAULT
-!                PRINT*, '+++ user_init: unknown variable named "', &
-!                        TRIM( field_char ), '" found in'
-!                PRINT*, '               data from prior run on PE ', myid
-!                CALL local_stop
-!
-!          END SELECT
-!
-!          READ ( 13 )  field_char
-!
-!       ENDDO
-!    ENDIF
-
- END SUBROUTINE user_read_restart_data
-
-
-
- SUBROUTINE user_init
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Execution of user-defined initializing actions
-!------------------------------------------------------------------------------!
-
-    USE control_parameters
-    USE indices
-    USE netcdf_control
-    USE pegrid
-    USE user
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=20) :: field_char
-!
-!-- Here the user-defined initializing actions follow:
-!-- Sample for user-defined output
-!    ALLOCATE( u2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-!    ALLOCATE( ustvst(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) );  ustvst = 0.0
-
-!-- Sample for user-defined time series
-!-- For each time series quantity you have to give a label and a unit,
-!-- which will be used for the NetCDF file. They must not contain more than
-!-- seven characters. The value of dots_num has to be increased by the
-!-- number of new time series quantities. Its old value has to be store in
-!-- dots_num_palm. See routine user_statistics on how to output calculate
-!-- and output these quantities.
-!    dots_label(dots_num+1) = 'abs_umx'
-!    dots_unit(dots_num+1)  = 'm/s'
-!    dots_label(dots_num+2) = 'abs_vmx'
-!    dots_unit(dots_num+2)  = 'm/s'
-!
-!    dots_num_palm = dots_num
-!    dots_num = dots_num + 2
-
- END SUBROUTINE user_init
-
-
-
- SUBROUTINE user_init_grid( gls, nzb_local )
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Execution of user-defined grid initializing actions
-! First argument gls contains the number of ghost layers, which is > 1 if the
-! multigrid method for the pressure solver is used
-!------------------------------------------------------------------------------!
-
-    USE control_parameters
-    USE indices
-    USE user
-
-    IMPLICIT NONE
-
-    INTEGER ::  gls
-
-    INTEGER, DIMENSION(-gls:ny+gls,-gls:nx+gls) ::  nzb_local
-
-!
-!-- Here the user-defined grid initializing actions follow:
-
-!
-!-- Set the index array nzb_local for non-flat topography.
-!-- Here consistency checks concerning domain size and periodicity are necessary
-    SELECT CASE ( TRIM( topography ) )
-
-       CASE ( 'flat', 'single_building' )
-!
-!--       Not allowed here since these are the standard cases used in init_grid.
-
-       CASE ( 'user_defined_topography_1' )
-!
-!--       Here the user can define his own topography. After definition, please
-!--       remove the following three lines!
-          PRINT*, '+++ user_init_grid: topography "', &
-               topography, '" not available yet'
-          CALL local_stop
-
-       CASE DEFAULT
-!
-!--       The DEFAULT case is reached if the parameter topography contains a
-!--       wrong character string that is neither recognized in init_grid nor 
-!--       here in user_init_grid.
-          PRINT*, '+++ (user_)init_grid: unknown topography "', &
-               topography, '"'
-          CALL local_stop
-
-    END SELECT
-
-
- END SUBROUTINE user_init_grid
-
-
-
- SUBROUTINE user_init_plant_canopy
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Initialisation of the leaf area density array (for scalar grid points) and 
-! the array of the canopy drag coefficient, if the user has not chosen any 
-! of the default cases 
-!------------------------------------------------------------------------------!
-
-    USE arrays_3d
-    USE control_parameters
-    USE indices
-    USE user
-
-    IMPLICIT NONE
-
-    INTEGER :: i, j 
-
-!
-!-- Here the user-defined grid initializing actions follow:
-
-!
-!-- Set the 3D-arrays lad_s and cdc for user defined canopies
-    SELECT CASE ( TRIM( canopy_mode ) )
-
-       CASE ( 'block' )
-!
-!--       Not allowed here since this is the standard case used in init_3d_model.
-
-       CASE ( 'user_defined_canopy_1' )
-!
-!--       Here the user can define his own topography. 
-!--       The following lines contain an example in that the 
-!--       plant canopy extends only over the second half of the 
-!--       model domain along x
-!          DO  i = nxl-1, nxr+1
-!             IF ( i >= INT(nx+1/2) ) THEN
-!                DO  j = nys-1, nyn+1
-!                   lad_s(:,j,i) = lad(:)
-!                   cdc(:,j,i)   = drag_coefficient
-!                ENDDO
-!             ELSE
-!                lad_s(:,:,i) = 0.0
-!                cdc(:,:,i)   = 0.0
-!             ENDIF
-!          ENDDO 
-!--       After definition, please
-!--       remove the following three lines!
-          PRINT*, '+++ user_init_plant_canopy: canopy_mode "', &
-               canopy_mode, '" not available yet'
-
-       CASE DEFAULT
-!
-!--       The DEFAULT case is reached if the parameter canopy_mode contains a
-!--       wrong character string that is neither recognized in init_3d_model nor 
-!--       here in user_init_plant_canopy.
-          PRINT*, '+++ user_init_plant_canopy: unknown canopy_mode "', &
-               canopy_mode, '"'
-          CALL local_stop
-
-    END SELECT
-
-
- END SUBROUTINE user_init_plant_canopy
-
-
-
- SUBROUTINE user_init_3d_model
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Allows the complete initialization of the 3d model.
-!
-! CAUTION: The user is responsible to set at least all those quantities which
-! ------   are normally set within init_3d_model!
-!------------------------------------------------------------------------------!
-
-    USE arrays_3d
-    USE control_parameters
-    USE indices
-    USE user
-
-    IMPLICIT NONE
-
-
- END SUBROUTINE user_init_3d_model
-
-
-
- MODULE user_actions_mod
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Execution of user-defined actions before or after single timesteps
-!------------------------------------------------------------------------------!
-
-    PRIVATE
-    PUBLIC user_actions
-
-    INTERFACE user_actions
-       MODULE PROCEDURE user_actions
-       MODULE PROCEDURE user_actions_ij
-    END INTERFACE user_actions
-
- CONTAINS
-
-
-!------------------------------------------------------------------------------!
-! Call for all grid points
-!------------------------------------------------------------------------------!
-    SUBROUTINE user_actions( location )
-
-       USE control_parameters
-       USE cpulog
-       USE indices
-       USE interfaces
-       USE pegrid
-       USE user
-       USE arrays_3d
-
-       IMPLICIT NONE
-
-       CHARACTER (LEN=*) ::  location
-
-       INTEGER ::  i, j, k
-
-       CALL cpu_log( log_point(24), 'user_actions', 'start' )
-
-!
-!--    Here the user-defined actions follow
-!--    No calls for single grid points are allowed at locations before and
-!--    after the timestep, since these calls are not within an i,j-loop
-       SELECT CASE ( location )
-
-          CASE ( 'before_timestep' )
-!
-!--          Enter actions to be done before every timestep here
-
-
-          CASE ( 'after_integration' )
-!
-!--          Enter actions to be done after every time integration (before
-!--          data output)
-!--          Sample for user-defined output:
-!             DO  i = nxl-1, nxr+1
-!                DO  j = nys-1, nyn+1
-!                   DO  k = nzb, nzt+1
-!                      u2(k,j,i) = u(k,j,i)**2
-!                   ENDDO
-!                ENDDO
-!             ENDDO
-!             DO  i = nxl-1, nxr
-!                DO  j = nys-1, nyn
-!                   DO  k = nzb, nzt+1
-!                      ustvst(k,j,i) =  &
-!                         ( 0.5 * ( u(k,j,i) + u(k,j,i+1) ) - hom(k,1,1,0) ) * &
-!                         ( 0.5 * ( v(k,j,i) + v(k,j+1,i) ) - hom(k,1,2,0) )
-!                   ENDDO
-!                ENDDO
-!             ENDDO
-
-
-          CASE ( 'after_timestep' )
-!
-!--          Enter actions to be done after every timestep here
-
-
-          CASE ( 'u-tendency' )
-!
-!--          Enter actions to be done in the u-tendency term here
-
-
-          CASE ( 'v-tendency' )
-
-
-          CASE ( 'w-tendency' )
-
-
-          CASE ( 'pt-tendency' )
-
-
-          CASE ( 'sa-tendency' )
-
-
-          CASE ( 'e-tendency' )
-
-
-          CASE ( 'q-tendency' )
-
-
-          CASE DEFAULT
-             IF ( myid == 0 )  PRINT*, '+++ user_actions: unknown location "', &
-                                       location, '"'
-             CALL local_stop
-
-       END SELECT
-
-       CALL cpu_log( log_point(24), 'user_actions', 'stop' )
-
-    END SUBROUTINE user_actions
-
-
-!------------------------------------------------------------------------------!
-! Call for grid point i,j
-!------------------------------------------------------------------------------!
-    SUBROUTINE user_actions_ij( i, j, location )
-
-       USE control_parameters
-       USE pegrid
-       USE user
-
-       IMPLICIT NONE
-
-       CHARACTER (LEN=*) ::  location
-
-       INTEGER ::  i, idum, j
-
-
-!
-!--    Here the user-defined actions follow
-       SELECT CASE ( location )
-
-          CASE ( 'u-tendency' )
-!
-!--          Enter actions to be done in the u-tendency term here
-
-
-          CASE ( 'v-tendency' )
-
-
-          CASE ( 'w-tendency' )
-
-
-          CASE ( 'pt-tendency' )
-
-
-          CASE ( 'sa-tendency' )
-
-
-          CASE ( 'e-tendency' )
-
-
-          CASE ( 'q-tendency' )
-
-
-          CASE ( 'before_timestep', 'after_integration', 'after_timestep' )
-             IF ( myid == 0 )  THEN
-                PRINT*, '+++ user_actions: location "', location, '" is not ', &
-                             'allowed to be called with parameters "i" and "j"'
-             ENDIF
-             CALL local_stop
-
-
-          CASE DEFAULT
-             IF ( myid == 0 )  PRINT*, '+++ user_actions: unknown location "', &
-                                       location, '"'
-             CALL local_stop
-
-
-       END SELECT
-
-    END SUBROUTINE user_actions_ij
-
- END MODULE user_actions_mod
-
-
-
- SUBROUTINE user_spectra( mode, m, pr )
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Calculation of user-defined spectra.
-! See section 3.5.4 on how to define, calculate, and output user defined
-! quantities.
-!------------------------------------------------------------------------------!
-
-    USE arrays_3d
-    USE indices
-    USE spectrum
-    USE statistics
-    USE user
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=*) ::  mode
-
-    INTEGER ::  i, j, k, m, pr
-
-
-!
-!-- Sample on how to calculate spectra of user-defined quantities. 
-!-- Each quantity is identified by the corresponding user profile index
-!-- "pr_palm+#" where "#" is an integer starting from 1. These
-!-- user-profile-numbers must also be assigned to the respective strings
-!-- given by data_output_pr_user in routine user_check_data_output_pr.
-    IF ( mode == 'preprocess' )  THEN
-
-       SELECT CASE ( TRIM( data_output_sp(m) ) )
-          
-          CASE ( 'u', 'v', 'w', 'pt', 'q' )
-!--          Not allowed here since these are the standard quantities used in 
-!--          preprocess_spectra.
-       
-!          CASE ( 'u*v*' )
-!             pr = pr_palm+1
-!             d(nzb+1:nzt,nys:nyn,nxl:nxr) = ustvst(nzb+1:nzt,nys:nyn,nxl:nxr)
-       
-          CASE DEFAULT
-             PRINT*, '+++ user_spectra/preprocess: Spectra of ', &
-                  TRIM( data_output_sp(m) ), ' can not be calculated'
-          
-       END SELECT
-
-    ELSEIF ( mode == 'data_output' )  THEN
-
-       SELECT CASE ( TRIM( data_output_sp(m) ) )
-
-          CASE ( 'u', 'v', 'w', 'pt', 'q' )
-!--          Not allowed here since these are the standard quantities used in 
-!--          data_output_spectra.
-
-!          CASE ( 'u*v*' )
-!             pr = 6
-
-          CASE DEFAULT
-             PRINT*, '+++ user_spectra/data_output: Spectra of ', &
-                          TRIM( data_output_sp(m) ), ' are not defined'
-
-          END SELECT
-
-    ENDIF
-
- END SUBROUTINE user_spectra
-
-
- SUBROUTINE user_statistics( mode, sr, tn )
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Calculation of user-defined statistics, i.e. horizontally averaged profiles
-! and time series.
-! This routine is called for every statistic region sr defined by the user,
-! but at least for the region "total domain" (sr=0).
-! See section 3.5.4 on how to define, calculate, and output user defined
-! quantities.
-!------------------------------------------------------------------------------!
-
-    USE arrays_3d
-    USE indices
-    USE statistics
-    USE user
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=*) ::  mode
-
-    INTEGER ::  i, j, k, sr, tn
-
-
-    IF ( mode == 'profiles' )  THEN
-
-!
-!--    Sample on how to calculate horizontally averaged profiles of user-
-!--    defined quantities. Each quantity is identified by the index
-!--    "pr_palm+#" where "#" is an integer starting from 1. These
-!--    user-profile-numbers must also be assigned to the respective strings
-!--    given by data_output_pr_user in routine user_check_data_output_pr.
-!       !$OMP DO
-!       DO  i = nxl, nxr
-!          DO  j = nys, nyn
-!             DO  k = nzb_s_inner(j,i)+1, nzt
-!!
-!!--             Sample on how to calculate the profile of the resolved-scale
-!!--             horizontal momentum flux u*v*
-!                sums_l(k,pr_palm+1,tn) = sums_l(k,pr_palm+1,tn) +           &
-!                      ( 0.5 * ( u(k,j,i) + u(k,j,i+1) ) - hom(k,1,1,sr) ) * &
-!                      ( 0.5 * ( v(k,j,i) + v(k,j+1,i) ) - hom(k,1,2,sr) )   &
-!                                                 * rmask(j,i,sr)
-!!
-!!--             Further profiles can be defined and calculated by increasing
-!!--             the second index of array sums_l (replace ... appropriately)
-!                sums_l(k,pr_palm+2,tn) = sums_l(k,pr_palm+2,tn) + ... &
-!                                         * rmask(j,i,sr)
-!             ENDDO
-!          ENDDO
-!       ENDDO
-
-    ELSEIF ( mode == 'time_series' )  THEN
-
-!
-!--    Sample on how to add values for the user-defined time series quantities.
-!--    These have to be defined before in routine user_init. This sample
-!--    creates two time series for the absolut values of the horizontal
-!--    velocities u and v.
-!       ts_value(dots_num_palm+1,sr) = ABS( u_max )
-!       ts_value(dots_num_palm+2,sr) = ABS( v_max )
-
-    ENDIF
-
- END SUBROUTINE user_statistics
-
-
-
- SUBROUTINE user_last_actions
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Execution of user-defined actions at the end of a job.
-!------------------------------------------------------------------------------!
-
-    USE user
-
-    IMPLICIT NONE
-
-!
-!-- Here the user-defined actions at the end of a job follow.
-!-- Sample for user-defined output:
-!    IF ( ALLOCATED( u2_av ) )  THEN
-!       WRITE ( 14 )  'u2_av               ';  WRITE ( 14 )  u2_av
-!    ENDIF
-
-    WRITE ( 14 )  '*** end user ***    '
-
- END SUBROUTINE user_last_actions
-
-
-
- SUBROUTINE user_init_particles
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Modification of initial particles by the user.
-!------------------------------------------------------------------------------!
-
-    USE particle_attributes
-    USE user
-
-    IMPLICIT NONE
-
-    INTEGER ::  n
-
-!
-!-- Here the user-defined actions follow
-!    DO  n = 1, number_of_initial_particles
-!    ENDDO
-
- END SUBROUTINE user_init_particles
-
-
-
- SUBROUTINE user_advec_particles
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Modification of initial particles by the user.
-!------------------------------------------------------------------------------!
-
-    USE particle_attributes
-    USE user
-
-    IMPLICIT NONE
-
-    INTEGER ::  n
-
-!
-!-- Here the user-defined actions follow
-!    DO  n = 1, number_of_initial_particles
-!    ENDDO
-
- END SUBROUTINE user_advec_particles
-
-
-
- SUBROUTINE user_particle_attributes
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Define the actual particle attributes (size, colour) by the user.
-!------------------------------------------------------------------------------!
-
-    USE particle_attributes
-    USE user
-
-    IMPLICIT NONE
-
-    INTEGER ::  n
-
-!
-!-- Here the user-defined actions follow
-!    DO  n = 1, number_of_initial_particles
-!    ENDDO
-
- END SUBROUTINE user_particle_attributes
-
-
-
- SUBROUTINE user_dvrp_coltab( mode, variable )
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Definition of the colour table to be used by the dvrp software.
-!------------------------------------------------------------------------------!
-
-    USE dvrp_variables
-    USE pegrid
-    USE user
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=*) ::  mode
-    CHARACTER (LEN=*) ::  variable
-
-
-!
-!-- Here the user-defined actions follow
-    SELECT CASE ( mode )
-
-       CASE ( 'particles' )
-
-       CASE ( 'slicer' )
-
-       CASE DEFAULT
-          IF ( myid == 0 )  PRINT*, '+++ user_dvrp_coltab: unknown mode "', &
-                                    mode, '"'
-          CALL local_stop
-
-    END SELECT
-
- END SUBROUTINE user_dvrp_coltab
-
-
-
- SUBROUTINE user_check_data_output( variable, unit )
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Set the unit of user defined output quantities. For those variables
-! not recognized by the user, the parameter unit is set to "illegal", which
-! tells the calling routine that the output variable is not defined and leads
-! to a program abort.
-!------------------------------------------------------------------------------!
-
-    USE user
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=*) ::  unit, variable
-
-
-    SELECT CASE ( TRIM( variable ) )
-
-!
-!--    Uncomment and extend the following lines, if necessary
-!       CASE ( 'u2' )
-!          unit = 'm2/s2'
-!
-!       CASE ( 'u*v*' )
-!          unit = 'm2/s2'
-!
-       CASE DEFAULT
-          unit = 'illegal'
-
-    END SELECT
-
-
- END SUBROUTINE user_check_data_output
-
-
-
- SUBROUTINE user_check_data_output_pr( variable, var_count, unit )
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Set the unit of user defined profile output quantities. For those variables
-! not recognized by the user, the parameter unit is set to "illegal", which
-! tells the calling routine that the output variable is not defined and leads
-! to a program abort.
-!------------------------------------------------------------------------------!
-
-    USE arrays_3d
-    USE indices
-    USE netcdf_control
-    USE profil_parameter
-    USE statistics
-    USE user
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=*) ::  unit, variable
-
-    INTEGER ::  index, var_count
-
-
-    SELECT CASE ( TRIM( variable ) )
-
-!
-!--    Uncomment and extend the following lines, if necessary.
-!--    Add additional CASE statements depending on the number of quantities
-!--    for which profiles are to be calculated. The respective calculations
-!--    to be performed have to be added in routine user_statistics.
-!--    The quantities are (internally) identified by a user-profile-number
-!--    (see variable "index" below). The first user-profile must be assigned
-!--    the number "pr_palm+1", the second one "pr_palm+2", etc. The respective
-!--    user-profile-numbers have also to be used in routine user_statistics!
-!       CASE ( 'u*v*' )                      ! quantity string as given in
-!                                            ! data_output_pr_user
-!          index = pr_palm + 1
-!          dopr_index(var_count)  = index    ! quantities' user-profile-number
-!          dopr_unit(var_count)   = 'm2/s2'  ! quantity unit
-!          hom(:,2,index,:)       = SPREAD( zu, 2, statistic_regions+1 )
-!                                            ! grid on which the quantity is
-!                                            ! defined (use zu or zw)
-
-       CASE DEFAULT
-          unit = 'illegal'
-
-    END SELECT
-
-
- END SUBROUTINE user_check_data_output_pr
-
-
-
- SUBROUTINE user_define_netcdf_grid( variable, found, grid_x, grid_y, grid_z )
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Set the grids on which user-defined output quantities are defined.
-! Allowed values for grid_x are "x" and "xu", for grid_y "y" and "yv", and
-! for grid_z "zu" and "zw".
-!------------------------------------------------------------------------------!
-
-    USE user
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=*) ::  grid_x, grid_y, grid_z, variable
-
-    LOGICAL ::  found
-
-
-    SELECT CASE ( TRIM( variable ) )
-
-!
-!--    Uncomment and extend the following lines, if necessary
-!       CASE ( 'u2', 'u2_xy', 'u2_xz', 'u2_yz' )
-!          grid_x = 'xu'
-!          grid_y = 'y'
-!          grid_z = 'zu'
-
-!       CASE ( 'u*v*', 'u*v*_xy', 'u*v*_xz', 'u*v*_yz' )
-!          grid_x = 'x'
-!          grid_y = 'y'
-!          grid_z = 'zu'
-
-       CASE DEFAULT
-          found  = .FALSE.
-          grid_x = 'none'
-          grid_y = 'none'
-          grid_z = 'none'
-
-    END SELECT
-
-
- END SUBROUTINE user_define_netcdf_grid
-
-
-
- SUBROUTINE user_data_output_dvrp( output_variable, local_pf )
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Execution of user-defined dvrp output
-!------------------------------------------------------------------------------!
-
-    USE control_parameters
-    USE indices
-    USE pegrid
-    USE user
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=*) ::  output_variable
-
-    INTEGER ::  i, j, k
-
-    REAL, DIMENSION(nxl:nxr+1,nys:nyn+1,nzb:nz_do3d) ::  local_pf
-
-!
-!-- Here the user-defined DVRP output follows:
-
-!
-!-- Move original array to intermediate array
-    SELECT CASE ( output_variable )
-
-!       CASE ( 'u2', 'u2_xy', 'u2_xz', 'u2_yz'  )
-!!
-!!--       Here the user can add user_defined output quantities. 
-!!--       Uncomment and extend the following lines, if necessary.
-!          DO  i = nxl, nxr+1
-!             DO  j = nys, nyn+1
-!                DO  k = nzb, nz_do3d
-!                   local_pf(i,j,k) = u2(k,j,i)
-!                ENDDO
-!             ENDDO
-!          ENDDO
-
-
-       CASE DEFAULT
-!
-!--       The DEFAULT case is reached if output_variable contains a
-!--       wrong character string that is neither recognized in data_output_dvrp
-!--       nor here in user_data_output_dvrp.
-          IF ( myid == 0 )  THEN
-             PRINT*,'+++ (user_)data_output_dvrp: no output possible for: ', &
-                  output_variable
-          ENDIF
-
-    END SELECT
-
-
- END SUBROUTINE user_data_output_dvrp
-
-
-
- SUBROUTINE user_data_output_2d( av, variable, found, grid, local_pf )
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Resorts the user-defined output quantity with indices (k,j,i) to a
-! temporary array with indices (i,j,k) and sets the grid on which it is defined.
-! Allowed values for grid are "zu" and "zw".
-!------------------------------------------------------------------------------!
-
-    USE indices
-    USE user
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=*) ::  grid, variable
-
-    INTEGER ::  av, i, j, k
-
-    LOGICAL ::  found
-
-    REAL, DIMENSION(nxl-1:nxr+1,nys-1:nyn+1,nzb:nzt+1) ::  local_pf
-
-
-    found = .TRUE.
-
-    SELECT CASE ( TRIM( variable ) )
-
-!
-!--    Uncomment and extend the following lines, if necessary.
-!--    The arrays for storing the user defined quantities (here u2 and u2_av)
-!--    have to be declared and defined by the user!
-!--    Sample for user-defined output:
-!       CASE ( 'u2_xy', 'u2_xz', 'u2_yz' )
-!          IF ( av == 0 )  THEN
-!             DO  i = nxl-1, nxr+1
-!                DO  j = nys-1, nyn+1
-!                   DO  k = nzb, nzt+1
-!                      local_pf(i,j,k) = u2(k,j,i)
-!                   ENDDO
-!                ENDDO
-!             ENDDO
-!          ELSE
-!             DO  i = nxl-1, nxr+1
-!                DO  j = nys-1, nyn+1
-!                   DO  k = nzb, nzt+1
-!                      local_pf(i,j,k) = u2_av(k,j,i)
-!                   ENDDO
-!                ENDDO
-!             ENDDO
-!          ENDIF
-!
-!          grid = 'zu'
-
-       CASE DEFAULT
-          found = .FALSE.
-          grid  = 'none'
-
-    END SELECT
-
-
- END SUBROUTINE user_data_output_2d
-
-
-
- SUBROUTINE user_data_output_3d( av, variable, found, local_pf, nz_do )
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Resorts the user-defined output quantity with indices (k,j,i) to a
-! temporary array with indices (i,j,k).
-!------------------------------------------------------------------------------!
-
-    USE array_kind
-    USE indices
-    USE user
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=*) ::  variable
-
-    INTEGER ::  av, i, j, k, nz_do
-
-    LOGICAL ::  found
-
-    REAL(spk), DIMENSION(nxl-1:nxr+1,nys-1:nyn+1,nzb:nz_do) ::  local_pf
-
-
-    found = .TRUE.
-
-    SELECT CASE ( TRIM( variable ) )
-
-!
-!--    Uncomment and extend the following lines, if necessary.
-!--    The arrays for storing the user defined quantities (here u2 and u2_av)
-!--    have to be declared and defined by the user!
-!--    Sample for user-defined output:
-!       CASE ( 'u2' )
-!          IF ( av == 0 )  THEN
-!             DO  i = nxl-1, nxr+1
-!                DO  j = nys-1, nyn+1
-!                   DO  k = nzb, nz_do
-!                      local_pf(i,j,k) = u2(k,j,i)
-!                   ENDDO
-!                ENDDO
-!             ENDDO
-!          ELSE
-!             DO  i = nxl-1, nxr+1
-!                DO  j = nys-1, nyn+1
-!                   DO  k = nzb, nz_do
-!                      local_pf(i,j,k) = u2_av(k,j,i)
-!                   ENDDO
-!                ENDDO
-!             ENDDO
-!          ENDIF
-!
-
-       CASE DEFAULT
-          found = .FALSE.
-
-    END SELECT
-
-
- END SUBROUTINE user_data_output_3d
-
-
-
- SUBROUTINE user_3d_data_averaging( mode, variable )
-
-!------------------------------------------------------------------------------!
-!
-! Description:
-! ------------
-! Sum up and time-average user-defined output quantities as well as allocate
-! the array necessary for storing the average.
-!------------------------------------------------------------------------------!
-
-    USE control_parameters
-    USE indices
-    USE user
-
-    IMPLICIT NONE
-
-    CHARACTER (LEN=*) ::  mode, variable
-
-    INTEGER ::  i, j, k
-
-
-    IF ( mode == 'allocate' )  THEN
-
-       SELECT CASE ( TRIM( variable ) )
-
-!
-!--       Uncomment and extend the following lines, if necessary.
-!--       The arrays for storing the user defined quantities (here u2_av) have
-!--       to be declared and defined by the user!
-!--       Sample for user-defined output:
-!          CASE ( 'u2' )
-!             IF ( .NOT. ALLOCATED( u2_av ) )  THEN
-!                ALLOCATE( u2_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
-!             ENDIF
-!             u2_av = 0.0
-
-          CASE DEFAULT
-             CONTINUE
-
-       END SELECT
-
-    ELSEIF ( mode == 'sum' )  THEN
-
-       SELECT CASE ( TRIM( variable ) )
-
-!
-!--       Uncomment and extend the following lines, if necessary.
-!--       The arrays for storing the user defined quantities (here u2 and
-!--       u2_av) have to be declared and defined by the user!
-!--       Sample for user-defined output:
-!          CASE ( 'u2' )
-!             DO  i = nxl-1, nxr+1
-!                DO  j = nys-1, nyn+1
-!                   DO  k = nzb, nzt+1
-!                      u2_av(k,j,i) = u2_av(k,j,i) + u2(k,j,i)
-!                   ENDDO
-!                ENDDO
-!             ENDDO
-
-          CASE DEFAULT
-             CONTINUE
-
-       END SELECT
-
-    ELSEIF ( mode == 'average' )  THEN
-
-       SELECT CASE ( TRIM( variable ) )
-
-!
-!--       Uncomment and extend the following lines, if necessary.
-!--       The arrays for storing the user defined quantities (here u2_av) have
-!--       to be declared and defined by the user!
-!--       Sample for user-defined output:
-!          CASE ( 'u2' )
-!             DO  i = nxl-1, nxr+1
-!                DO  j = nys-1, nyn+1
-!                   DO  k = nzb, nzt+1
-!                      u2_av(k,j,i) = u2_av(k,j,i) / REAL( average_count_3d )
-!                   ENDDO
-!                ENDDO
-!             ENDDO
-
-       END SELECT
-
-    ENDIF
-
-
- END SUBROUTINE user_3d_data_averaging
Index: /palm/trunk/SOURCE/user_last_actions.f90
===================================================================
--- /palm/trunk/SOURCE/user_last_actions.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_last_actions.f90	(revision 211)
@@ -0,0 +1,31 @@
+ SUBROUTINE user_last_actions
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Execution of user-defined actions at the end of a job.
+!------------------------------------------------------------------------------!
+
+    USE user
+
+    IMPLICIT NONE
+
+!
+!-- Here the user-defined actions at the end of a job follow.
+!-- Sample for user-defined output:
+!    IF ( ALLOCATED( u2_av ) )  THEN
+!       WRITE ( 14 )  'u2_av               ';  WRITE ( 14 )  u2_av
+!    ENDIF
+
+    WRITE ( 14 )  '*** end user ***    '
+
+ END SUBROUTINE user_last_actions
+
Index: /palm/trunk/SOURCE/user_module.f90
===================================================================
--- /palm/trunk/SOURCE/user_module.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_module.f90	(revision 211)
@@ -0,0 +1,48 @@
+ MODULE user
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine,
+! revision history cleaned up
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! 159 2008-04-09 08:06:03Z raasch
+! bugfix in user_read_restart_data
+! small bugfixes for sample code (comments):
+! - initialize ustvst with 0.0 as it is now computed only until nxr and nyn
+! - two ALLOCATE statements moved from user_read_restart_data back to user_init
+! - remove 'READ (13) u2_av' statement in user_read_restart_data
+! +routines user_read_restart_data, user_spectra
+!
+! RCS Log replace by Id keyword, revision history cleaned up
+!
+! Revision 1.18  2006/06/02 15:25:00  raasch
+! +change of grid-defining arguments in routine user_define_netcdf_grid,
+! new argument "found" in user_data_output_2d and user_data_output_3d
+!
+! Revision 1.1  1998/03/24 15:29:04  raasch
+! Initial revision
+!
+!
+! Description:
+! ------------
+! Declaration of user-defined variables. This module may only be used
+! in the user-defined routines (contained in user_interface.f90).
+!------------------------------------------------------------------------------!
+
+    INTEGER ::  dots_num_palm, user_idummy
+    LOGICAL ::  user_defined_namelist_found = .FALSE.
+    REAL    ::  user_dummy
+
+!
+!-- Sample for user-defined output
+!    REAL, DIMENSION(:,:,:), ALLOCATABLE ::  u2, u2_av
+!    REAL, DIMENSION(:,:,:), ALLOCATABLE ::  ustvst
+
+    SAVE
+
+ END MODULE user
Index: /palm/trunk/SOURCE/user_parin.f90
===================================================================
--- /palm/trunk/SOURCE/user_parin.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_parin.f90	(revision 211)
@@ -0,0 +1,86 @@
+ SUBROUTINE user_parin
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Interface to read user-defined namelist-parameters.
+!------------------------------------------------------------------------------!
+
+    USE control_parameters
+    USE pegrid
+    USE statistics
+    USE user
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=80) ::  zeile
+
+    INTEGER ::  i, j, max_pr_user_tmp
+
+
+    NAMELIST /userpar/  data_output_pr_user, data_output_user, region
+
+!
+!-- Position the namelist-file at the beginning (it was already opened in
+!-- parin), search for user-defined namelist-group ("userpar", but any other
+!-- name can be choosed) and position the file at this line.
+    REWIND ( 11 )
+
+    zeile = ' '
+    DO   WHILE ( INDEX( zeile, '&userpar' ) == 0 )
+       READ ( 11, '(A)', END=100 )  zeile
+    ENDDO
+    BACKSPACE ( 11 )
+
+!
+!-- Read user-defined namelist
+    READ ( 11, userpar )
+    user_defined_namelist_found = .TRUE.
+
+!
+!-- Determine the number of user-defined profiles and append them to the
+!-- standard data output (data_output_pr)
+    max_pr_user_tmp = 0
+    IF ( data_output_pr_user(1) /= ' ' )  THEN
+       i = 1
+       DO  WHILE ( data_output_pr(i) /= ' '  .AND.  i <= 100 )
+          i = i + 1
+       ENDDO
+       j = 1
+       DO  WHILE ( data_output_pr_user(j) /= ' '  .AND.  j <= 100 )
+          data_output_pr(i) = data_output_pr_user(j)
+          max_pr_user_tmp   = max_pr_user_tmp + 1
+          i = i + 1
+          j = j + 1
+       ENDDO
+    ENDIF
+
+!
+!-- In case of a restart run, the number of user-defined profiles on the
+!-- restart file (already stored in max_pr_user) has to match the one given
+!-- for the current run
+    IF ( TRIM( initializing_actions ) == 'read_restart_data' )  THEN
+       IF ( max_pr_user /= max_pr_user_tmp )  THEN
+          PRINT*, '+++ user_parin: the number of user-defined profiles given in'
+          PRINT*, '                data_output_pr (', max_pr_user_tmp, ' doe', &
+                                   's not match the one'
+          PRINT*, '                found in the restart file (', max_pr_user, &
+                                   ')'
+          CALL local_stop
+       ENDIF
+    ELSE
+       max_pr_user = max_pr_user_tmp
+    ENDIF
+
+100 RETURN
+
+ END SUBROUTINE user_parin
+
Index: /palm/trunk/SOURCE/user_particle_attributes.f90
===================================================================
--- /palm/trunk/SOURCE/user_particle_attributes.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_particle_attributes.f90	(revision 211)
@@ -0,0 +1,30 @@
+ SUBROUTINE user_particle_attributes
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Define the actual particle attributes (size, colour) by the user.
+!------------------------------------------------------------------------------!
+
+    USE particle_attributes
+    USE user
+
+    IMPLICIT NONE
+
+    INTEGER ::  n
+
+!
+!-- Here the user-defined actions follow
+!    DO  n = 1, number_of_initial_particles
+!    ENDDO
+
+ END SUBROUTINE user_particle_attributes
+
Index: /palm/trunk/SOURCE/user_read_restart_data.f90
===================================================================
--- /palm/trunk/SOURCE/user_read_restart_data.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_read_restart_data.f90	(revision 211)
@@ -0,0 +1,74 @@
+ SUBROUTINE user_read_restart_data( nxlc, nxlf, nxl_on_file, nxrc, nxrf,  &
+                                    nxr_on_file, nync, nynf, nyn_on_file, &
+                                    nysc, nysf, nys_on_file, tmp_2d, tmp_3d )
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Reading restart data from file(s)
+! Subdomain index limits on file are given by nxl_on_file, etc.
+! Indices nxlc, etc. indicate the range of gridpoints to be mapped from the
+! subdomain on file (f) to the subdomain of the current PE (c). They have been
+! calculated in routine read_3d_binary.
+!------------------------------------------------------------------------------!
+
+    USE control_parameters
+    USE indices
+    USE pegrid
+    USE user
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=20) :: field_char
+
+    INTEGER ::  nxlc, nxlf, nxl_on_file, nxrc, nxrf, nxr_on_file, nync, nynf, &
+                nyn_on_file, nysc, nysf, nys_on_file
+
+    REAL, DIMENSION(nys_on_file-1:nyn_on_file+1,nxl_on_file-1:nxr_on_file+1) ::&
+          tmp_2d
+
+    REAL, DIMENSION(nzb:nzt+1,nys_on_file-1:nyn_on_file+1, &
+                    nxl_on_file-1:nxr_on_file+1) ::        &
+          tmp_3d
+
+!
+!-- Here the reading of user-defined restart data follows:
+!-- Sample for user-defined output
+!
+!    IF ( initializing_actions == 'read_restart_data' )  THEN
+!       READ ( 13 )  field_char
+!       DO  WHILE ( TRIM( field_char ) /= '*** end user ***' )
+!
+!          SELECT CASE ( TRIM( field_char ) )
+!
+!             CASE ( 'u2_av' )
+!                IF ( .NOT. ALLOCATED( u2_av ) ) THEN
+!                   ALLOCATE( u2_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) )
+!                ENDIF
+!                READ ( 13 )  tmp_3d
+!                u2_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = &
+!                                          tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1)
+!
+!             CASE DEFAULT
+!                PRINT*, '+++ user_init: unknown variable named "', &
+!                        TRIM( field_char ), '" found in'
+!                PRINT*, '               data from prior run on PE ', myid
+!                CALL local_stop
+!
+!          END SELECT
+!
+!          READ ( 13 )  field_char
+!
+!       ENDDO
+!    ENDIF
+
+ END SUBROUTINE user_read_restart_data
+
Index: /palm/trunk/SOURCE/user_spectra.f90
===================================================================
--- /palm/trunk/SOURCE/user_spectra.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_spectra.f90	(revision 211)
@@ -0,0 +1,76 @@
+ SUBROUTINE user_spectra( mode, m, pr )
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Calculation of user-defined spectra.
+! See section 3.5.4 on how to define, calculate, and output user defined
+! quantities.
+!------------------------------------------------------------------------------!
+
+    USE arrays_3d
+    USE indices
+    USE spectrum
+    USE statistics
+    USE user
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=*) ::  mode
+
+    INTEGER ::  i, j, k, m, pr
+
+
+!
+!-- Sample on how to calculate spectra of user-defined quantities. 
+!-- Each quantity is identified by the corresponding user profile index
+!-- "pr_palm+#" where "#" is an integer starting from 1. These
+!-- user-profile-numbers must also be assigned to the respective strings
+!-- given by data_output_pr_user in routine user_check_data_output_pr.
+    IF ( mode == 'preprocess' )  THEN
+
+       SELECT CASE ( TRIM( data_output_sp(m) ) )
+          
+          CASE ( 'u', 'v', 'w', 'pt', 'q' )
+!--          Not allowed here since these are the standard quantities used in 
+!--          preprocess_spectra.
+       
+!          CASE ( 'u*v*' )
+!             pr = pr_palm+1
+!             d(nzb+1:nzt,nys:nyn,nxl:nxr) = ustvst(nzb+1:nzt,nys:nyn,nxl:nxr)
+       
+          CASE DEFAULT
+             PRINT*, '+++ user_spectra/preprocess: Spectra of ', &
+                  TRIM( data_output_sp(m) ), ' can not be calculated'
+          
+       END SELECT
+
+    ELSEIF ( mode == 'data_output' )  THEN
+
+       SELECT CASE ( TRIM( data_output_sp(m) ) )
+
+          CASE ( 'u', 'v', 'w', 'pt', 'q' )
+!--          Not allowed here since these are the standard quantities used in 
+!--          data_output_spectra.
+
+!          CASE ( 'u*v*' )
+!             pr = 6
+
+          CASE DEFAULT
+             PRINT*, '+++ user_spectra/data_output: Spectra of ', &
+                          TRIM( data_output_sp(m) ), ' are not defined'
+
+          END SELECT
+
+    ENDIF
+
+ END SUBROUTINE user_spectra
+
Index: /palm/trunk/SOURCE/user_statistics.f90
===================================================================
--- /palm/trunk/SOURCE/user_statistics.f90	(revision 211)
+++ /palm/trunk/SOURCE/user_statistics.f90	(revision 211)
@@ -0,0 +1,75 @@
+ SUBROUTINE user_statistics( mode, sr, tn )
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
+! -----------------
+! Former file user_interface.f90 split into one file per subroutine
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Calculation of user-defined statistics, i.e. horizontally averaged profiles
+! and time series.
+! This routine is called for every statistic region sr defined by the user,
+! but at least for the region "total domain" (sr=0).
+! See section 3.5.4 on how to define, calculate, and output user defined
+! quantities.
+!------------------------------------------------------------------------------!
+
+    USE arrays_3d
+    USE indices
+    USE statistics
+    USE user
+
+    IMPLICIT NONE
+
+    CHARACTER (LEN=*) ::  mode
+
+    INTEGER ::  i, j, k, sr, tn
+
+
+    IF ( mode == 'profiles' )  THEN
+
+!
+!--    Sample on how to calculate horizontally averaged profiles of user-
+!--    defined quantities. Each quantity is identified by the index
+!--    "pr_palm+#" where "#" is an integer starting from 1. These
+!--    user-profile-numbers must also be assigned to the respective strings
+!--    given by data_output_pr_user in routine user_check_data_output_pr.
+!       !$OMP DO
+!       DO  i = nxl, nxr
+!          DO  j = nys, nyn
+!             DO  k = nzb_s_inner(j,i)+1, nzt
+!!
+!!--             Sample on how to calculate the profile of the resolved-scale
+!!--             horizontal momentum flux u*v*
+!                sums_l(k,pr_palm+1,tn) = sums_l(k,pr_palm+1,tn) +           &
+!                      ( 0.5 * ( u(k,j,i) + u(k,j,i+1) ) - hom(k,1,1,sr) ) * &
+!                      ( 0.5 * ( v(k,j,i) + v(k,j+1,i) ) - hom(k,1,2,sr) )   &
+!                                                 * rmask(j,i,sr)
+!!
+!!--             Further profiles can be defined and calculated by increasing
+!!--             the second index of array sums_l (replace ... appropriately)
+!                sums_l(k,pr_palm+2,tn) = sums_l(k,pr_palm+2,tn) + ... &
+!                                         * rmask(j,i,sr)
+!             ENDDO
+!          ENDDO
+!       ENDDO
+
+    ELSEIF ( mode == 'time_series' )  THEN
+
+!
+!--    Sample on how to add values for the user-defined time series quantities.
+!--    These have to be defined before in routine user_init. This sample
+!--    creates two time series for the absolut values of the horizontal
+!--    velocities u and v.
+!       ts_value(dots_num_palm+1,sr) = ABS( u_max )
+!       ts_value(dots_num_palm+2,sr) = ABS( v_max )
+
+    ENDIF
+
+ END SUBROUTINE user_statistics
+
