Index: palm/trunk/SOURCE/multi_agent_system_mod.f90
===================================================================
--- palm/trunk/SOURCE/multi_agent_system_mod.f90	(revision 3235)
+++ palm/trunk/SOURCE/multi_agent_system_mod.f90	(revision 3241)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! unused variables removed
+! 
+! 3235 2018-09-07 14:06:15Z sward
 ! Bugfix in output, added agent-number dimension and related messages and
 ! input parameters, updated cpu logging, added mas_last_actions
@@ -96,6 +99,6 @@
     INTEGER(iwp) ::  ibc_mas_lr                        !< agent left/right boundary condition dummy
     INTEGER(iwp) ::  ibc_mas_ns                        !< agent north/south boundary condition dummy
-    INTEGER(iwp) ::  ind_pm10 = -9                     !< chemical species index of PM10
-    INTEGER(iwp) ::  ind_pm25 = -9                     !< chemical species index of PM2.5
+!    INTEGER(iwp) ::  ind_pm10 = -9                     !< chemical species index of PM10
+!    INTEGER(iwp) ::  ind_pm25 = -9                     !< chemical species index of PM2.5
     INTEGER(iwp) ::  iran_agent = -1234567             !< number for random generator
     INTEGER(iwp) ::  min_nr_agent = 2                  !< namelist parameter (see documentation)
@@ -536,16 +539,15 @@
        INTEGER(iwp) ::  n  !< loop variable over all agents in a grid box
        INTEGER(iwp) ::  pc !< agent path counter
-       INTEGER(iwp) ::  nobo !< agent path counter
 
        REAL(wp) ::  abs_dir         !< length of direction vector (for normalization)
-       REAL(wp) ::  d_curr_target   !< rounding influence expressed as x speed component
-       REAL(wp) ::  d_prev_target   !< rounding influence expressed as x speed component
+!       REAL(wp) ::  d_curr_target   !< rounding influence expressed as x speed component
+!       REAL(wp) ::  d_prev_target   !< rounding influence expressed as x speed component
        REAL(wp) ::  dir_x           !< direction of agent (x)
        REAL(wp) ::  dir_y           !< direction of agent (y)
-       REAL(wp) ::  dist_round = 3. !< distance at which agents start rounding a corner
+!       REAL(wp) ::  dist_round = 3. !< distance at which agents start rounding a corner
        REAL(wp) ::  dtit            !< distance to intermittent target
-       REAL(wp) ::  round_fac  = .2 !< factor for rounding influence
-       REAL(wp) ::  speed_round_x   !< rounding influence expressed as x speed component
-       REAL(wp) ::  speed_round_y   !< rounding influence expressed as x speed component
+!       REAL(wp) ::  round_fac  = 0.2 !< factor for rounding influence
+!       REAL(wp) ::  speed_round_x   !< rounding influence expressed as x speed component
+!       REAL(wp) ::  speed_round_y   !< rounding influence expressed as x speed component
 
 !
@@ -728,5 +730,4 @@
        INTEGER(iwp) ::  i           !< loop variable ( agent groups )
        INTEGER(iwp) ::  ip          !< index variable along x
-       INTEGER(iwp) ::  j           !< loop variable ( agents per point )
        INTEGER(iwp) ::  jp          !< index variable along y
        INTEGER(iwp) ::  loop_stride !< loop variable for initialization
@@ -1010,6 +1011,4 @@
        IMPLICIT NONE
 
-       INTEGER(iwp) ::  agt_size !< Agent size in bytes
-       INTEGER(iwp) ::  dummy    !< dummy
        INTEGER(iwp) ::  il
        INTEGER(iwp) ::  jl
@@ -1130,5 +1129,5 @@
 
        USE netcdf_interface,                                                   &
-           ONLY:  nc_stat, id_set_agt, id_var_time_agt, id_var_rnoa_agt,       &
+           ONLY:  nc_stat, id_set_agt, id_var_time_agt,        &
                   id_var_agt, netcdf_handle_error
 
@@ -1235,7 +1234,7 @@
        IF ( myid == 0 ) THEN
 #if defined( __parallel )
-          agents=>out_agents
+          agents => out_agents
 #else
-          agents=>trf_agents
+          agents => trf_agents
 #endif
 
@@ -1530,5 +1529,4 @@
 
        TYPE(agent_type), DIMENSION(:), INTENT(IN)  ::  agent_array !< new agents in a grid box
-       TYPE(agent_type), DIMENSION(:), ALLOCATABLE ::  temp_ns     !< temporary agent array for reallocation
 
        pack_done     = .FALSE.
@@ -1662,5 +1660,4 @@
        INTEGER(iwp) ::  j                !< grid index (y) of agent positition
        INTEGER(iwp) ::  jp               !< index variable along y
-       INTEGER(iwp) ::  kp               !< index variable along z
        INTEGER(iwp) ::  n                !< agent index variable 
        INTEGER(iwp) ::  par_size         !< Agent size in bytes
@@ -2252,7 +2249,5 @@
 #if defined( __parallel )
 
-       INTEGER(iwp) ::  i           !< grid index (x) of agent positition
        INTEGER(iwp) ::  ip          !< index variable along x
-       INTEGER(iwp) ::  j           !< grid index (y) of agent positition
        INTEGER(iwp) ::  jp          !< index variable along y
        INTEGER(iwp) ::  agt_size    !< Bit size of agent datatype
@@ -2684,12 +2679,9 @@
            ONLY:  u, v, pt, hyp
 
-       USE chem_gasphase_mod,                                                  &
-           ONLY:  nvar
-
-       USE chemistry_model_mod,                                                &
-           ONLY:  chem_species
-
-       USE control_parameters,                                                 &
-              ONLY:  air_chemistry
+!       USE chemistry_model_mod,                                                &
+!           ONLY:  chem_species
+
+!       USE control_parameters,                                                 &
+!              ONLY:  air_chemistry
 
        IMPLICIT NONE
@@ -2707,6 +2699,4 @@
        REAL(wp) ::  u_a  !< windspeed at agent position (x)
        REAL(wp) ::  v_a  !< windspeed at agent position (y)
-       REAL(wp) ::  x_a  !< agent position (x)
-       REAL(wp) ::  y_a  !< agent position (y)
 
        DO  il = nxl, nxr
@@ -2932,13 +2922,12 @@
     SUBROUTINE mas_init
 
-       USE chem_gasphase_mod,                                                  &
-           ONLY:  nspec
-
-       USE chemistry_model_mod,                                                &
-           ONLY:  chem_species
+!       USE chem_gasphase_mod,                                                  &
+!           ONLY:  nspec
+
+!       USE chemistry_model_mod,                                                &
+!           ONLY:  chem_species
 
        USE control_parameters,                                                 &
-           ONLY:  air_chemistry, coupling_char, initializing_actions,          &
-                  io_blocks, io_group
+           ONLY:  coupling_char, initializing_actions, io_blocks, io_group
 
        USE surface_mod,                                                        &
@@ -2968,5 +2957,4 @@
        REAL(wp) ::  avg_agt_height = 1.8_wp
 
-       INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  noc !< temp: number of connections in nav_mesh
 
 !
@@ -3244,12 +3232,9 @@
 
        INTEGER(iwp) ::  cur_node     !< current node of binary heap
-       INTEGER(iwp) ::  i_ag         !< agent index
        INTEGER(iwp) ::  il           !< counter (x)
-       INTEGER(iwp) ::  jl           !< counter (y)
        INTEGER(iwp) ::  neigh_node   !< neighbor node
        INTEGER(iwp) ::  node_counter !< binary heap node counter
        INTEGER(iwp) ::  path_ag      !< index of agent path
        INTEGER(iwp) ::  som          !< size of mesh
-       INTEGER(iwp) ::  rn_side      !< index of agent path
        INTEGER(iwp) ::  steps        !< steps along the path
        INTEGER(iwp) ::  nsteps        !< number of steps
@@ -3259,5 +3244,4 @@
        REAL(wp) ::  new_cost     !< updated cost to reach node
        REAL(wp) ::  new_priority !< priority of node to be added to queue
-       REAL(wp) ::  rand_nr      !< x-coordinate target
        REAL(wp) ::  rn_gate      !< random number for corner gate
        REAL(wp) ::  target_x     !< x-coordinate target
@@ -3927,82 +3911,82 @@
 !> complete the LES timestep.
 !------------------------------------------------------------------------------!
-    SUBROUTINE mas_ps_sort_timeloop_done
-
-       IMPLICIT NONE
-
-       INTEGER(iwp) :: end_index     !< agent end index for each sub-box
-       INTEGER(iwp) :: i             !< index of agent grid box in x-direction
-       INTEGER(iwp) :: j             !< index of agent grid box in y-direction
-       INTEGER(iwp) :: n             !< running index for number of agents
-       INTEGER(iwp) :: nb            !< index of subgrid boux
-       INTEGER(iwp) :: nf            !< indices for agents in each sub-box that already finalized their substeps
-       INTEGER(iwp) :: nnf           !< indices for agents in each sub-box that need further treatment
-       INTEGER(iwp) :: num_finalized !< number of agents in each sub-box that already finalized their substeps
-       INTEGER(iwp) :: start_index   !< agent start index for each sub-box
-
-       TYPE(agent_type), DIMENSION(:), ALLOCATABLE :: sort_agents  !< temporary agent array 
-
-       DO  i = nxl, nxr
-          DO  j = nys, nyn
-
-             number_of_agents = agt_count(j,i)
-             IF ( number_of_agents <= 0 )  CYCLE
-
-             agents => grid_agents(j,i)%agents(1:number_of_agents)
-
-             DO  nb = 0, 3
+!    SUBROUTINE mas_ps_sort_timeloop_done
+!
+!       IMPLICIT NONE
+!
+!       INTEGER(iwp) :: end_index     !< agent end index for each sub-box
+!       INTEGER(iwp) :: i             !< index of agent grid box in x-direction
+!       INTEGER(iwp) :: j             !< index of agent grid box in y-direction
+!       INTEGER(iwp) :: n             !< running index for number of agents
+!       INTEGER(iwp) :: nb            !< index of subgrid boux
+!       INTEGER(iwp) :: nf            !< indices for agents in each sub-box that already finalized their substeps
+!       INTEGER(iwp) :: nnf           !< indices for agents in each sub-box that need further treatment
+!       INTEGER(iwp) :: num_finalized !< number of agents in each sub-box that already finalized their substeps
+!       INTEGER(iwp) :: start_index   !< agent start index for each sub-box
+!
+!       TYPE(agent_type), DIMENSION(:), ALLOCATABLE :: sort_agents  !< temporary agent array
+!
+!       DO  i = nxl, nxr
+!          DO  j = nys, nyn
+!
+!             number_of_agents = agt_count(j,i)
+!             IF ( number_of_agents <= 0 )  CYCLE
+!
+!             agents => grid_agents(j,i)%agents(1:number_of_agents)
+!
+!             DO  nb = 0, 3
 !
 !--             Obtain start and end index for each subgrid box
-                start_index = grid_agents(j,i)%start_index(nb)
-                end_index   = grid_agents(j,i)%end_index(nb)
+!                start_index = grid_agents(j,i)%start_index(nb)
+!                end_index   = grid_agents(j,i)%end_index(nb)
 !
 !--             Allocate temporary array used for sorting
-                ALLOCATE( sort_agents(start_index:end_index) )
+!                ALLOCATE( sort_agents(start_index:end_index) )
 !
 !--             Determine number of agents already completed the LES 
 !--             timestep, and write them into a temporary array
-                nf = start_index
-                num_finalized = 0
-                DO  n = start_index, end_index
-                   IF ( dt_3d - agents(n)%dt_sum < 1E-8_wp )  THEN
-                      sort_agents(nf) = agents(n)
-                      nf              = nf + 1
-                      num_finalized   = num_finalized + 1
-                   ENDIF
-                ENDDO
+!                nf = start_index
+!                num_finalized = 0
+!                DO  n = start_index, end_index
+!                   IF ( dt_3d - agents(n)%dt_sum < 1E-8_wp )  THEN
+!                      sort_agents(nf) = agents(n)
+!                      nf              = nf + 1
+!                      num_finalized   = num_finalized + 1
+!                   ENDIF
+!                ENDDO
 !
 !--             Determine number of agents that not completed the LES 
 !--             timestep, and write them into a temporary array
-                nnf = nf
-                DO  n = start_index, end_index
-                   IF ( dt_3d - agents(n)%dt_sum > 1E-8_wp )  THEN
-                      sort_agents(nnf) = agents(n)
-                      nnf              = nnf + 1
-                   ENDIF
-                ENDDO
+!                nnf = nf
+!                DO  n = start_index, end_index
+!                   IF ( dt_3d - agents(n)%dt_sum > 1E-8_wp )  THEN
+!                      sort_agents(nnf) = agents(n)
+!                      nnf              = nnf + 1
+!                   ENDIF
+!                ENDDO
 !
 !--             Write back sorted agents
-                agents(start_index:end_index) =                          &
-                                        sort_agents(start_index:end_index)
+!                agents(start_index:end_index) =                          &
+!                                        sort_agents(start_index:end_index)
 !
 !--             Determine updated start_index, used to masked already 
 !--             completed agents. 
-                grid_agents(j,i)%start_index(nb) =                     &
-                                   grid_agents(j,i)%start_index(nb)    &
-                                 + num_finalized
+!                grid_agents(j,i)%start_index(nb) =                     &
+!                                   grid_agents(j,i)%start_index(nb)    &
+!                                 + num_finalized
 !
 !--             Deallocate dummy array
-                DEALLOCATE ( sort_agents )
+!                DEALLOCATE ( sort_agents )
 !
 !--             Finally, if number of non-completed agents is non zero 
 !--             in any of the sub-boxes, set control flag appropriately. 
-                IF ( nnf > nf )                                             &
-                   grid_agents(j,i)%time_loop_done = .FALSE.
-
-             ENDDO
-          ENDDO
-       ENDDO
-
-    END SUBROUTINE mas_ps_sort_timeloop_done
+!                IF ( nnf > nf )                                             &
+!                   grid_agents(j,i)%time_loop_done = .FALSE.
+!
+!             ENDDO
+!          ENDDO
+!       ENDDO
+!
+!    END SUBROUTINE mas_ps_sort_timeloop_done
 
 !------------------------------------------------------------------------------!
@@ -4106,6 +4090,6 @@
     SUBROUTINE mas_timestep_social_forces ( mode, nl, ip, jp )
 
-       USE constants,                                                          &
-           ONLY:  pi
+!       USE constants,                                                          &
+!           ONLY:  pi
 
        IMPLICIT NONE
@@ -4138,5 +4122,4 @@
        REAL(wp) ::  dist             !< distance to obstacle
        REAL(wp) ::  dist_sq          !< distance to obstacle squared
-       REAL(wp) ::  dummy_coll_time  !< dummy for collision time
        REAL(wp) ::  pos_rel_x        !< relative position of two agents (x)
        REAL(wp) ::  pos_rel_y        !< relative position of two agents (y)
@@ -4311,6 +4294,6 @@
 !
 !--                   Calculate force of found wall on agent
-                      CALL mas_timestep_wall_corner_force ( nl, x_a, x_wall,   &
-                                                            y_a, y_a )
+                      CALL mas_timestep_wall_corner_force( x_a, x_wall, y_a,   &
+                                                           y_a )
 !
 !--                   calculate new x starting index for later scan for corners
@@ -4335,6 +4318,6 @@
 !
 !--                   Calculate force of found wall on agent
-                      CALL mas_timestep_wall_corner_force ( nl, x_a, x_wall,   &
-                                                            y_a, y_a )
+                      CALL mas_timestep_wall_corner_force( x_a, x_wall, y_a,   &
+                                                           y_a )
 !
 !--                   calculate new x end index for later scan for corners
@@ -4358,6 +4341,6 @@
                       y_wall = (jl+1)*dy
 
-                      CALL mas_timestep_wall_corner_force ( nl, x_a, x_a, y_a, &
-                                                            y_wall )
+                      CALL mas_timestep_wall_corner_force( x_a, x_a, y_a,      &
+                                                           y_wall )
 !
 !--                   calculate new y starting index for later scan for corners
@@ -4381,6 +4364,6 @@
                       y_wall = jl*dy
 
-                      CALL mas_timestep_wall_corner_force ( nl, x_a, x_a, y_a, &
-                                                            y_wall )
+                      CALL mas_timestep_wall_corner_force( x_a, x_a, y_a,      &
+                                                           y_wall )
 !
 !--                   calculate new y end index for later scan for corners
@@ -4412,6 +4395,6 @@
                             y_wall = (jl+1)*dy
 
-                            CALL mas_timestep_wall_corner_force ( nl, x_a,     &
-                                                           x_wall, y_a, y_wall )
+                            CALL mas_timestep_wall_corner_force( x_a, x_wall,  &
+                                                                 y_a, y_wall )
 
                          ENDIF
@@ -4426,6 +4409,6 @@
                             y_wall = jl*dy
 
-                            CALL mas_timestep_wall_corner_force ( nl, x_a,     &
-                                                         x_wall, y_a, y_wall )
+                            CALL mas_timestep_wall_corner_force( x_a, x_wall,  &
+                                                                 y_a, y_wall )
 
                          ENDIF
@@ -4442,6 +4425,6 @@
                             y_wall = (jl+1)*dy
 
-                            CALL mas_timestep_wall_corner_force ( nl, x_a,     &
-                                                           x_wall, y_a, y_wall )
+                            CALL mas_timestep_wall_corner_force( x_a, x_wall,  &
+                                                                 y_a, y_wall )
 
                          ENDIF
@@ -4456,6 +4439,6 @@
                             y_wall = jl*dy
 
-                            CALL mas_timestep_wall_corner_force ( nl, x_a,     &
-                                                           x_wall, y_a, y_wall )
+                            CALL mas_timestep_wall_corner_force( x_a, x_wall,  &
+                                                                 y_a, y_wall )
 
                          ENDIF
@@ -4477,9 +4460,7 @@
 !> or wall exerts on that agent
 !------------------------------------------------------------------------------!
-    SUBROUTINE mas_timestep_wall_corner_force ( nl, xa, xw, ya, yw )
+    SUBROUTINE mas_timestep_wall_corner_force( xa, xw, ya, yw )
 
        IMPLICIT NONE
-
-       INTEGER(iwp) ::  nl !< loop variable over all agents in a grid box
 
        REAL(wp) ::  dist_l     !< distance to obstacle
