Index: palm/trunk/EXAMPLES/agents/canyon/INPUT/canyon_p3d
===================================================================
--- palm/trunk/EXAMPLES/agents/canyon/INPUT/canyon_p3d	(revision 3159)
+++ palm/trunk/EXAMPLES/agents/canyon/INPUT/canyon_p3d	(revision 3159)
@@ -0,0 +1,70 @@
+&initialization_parameters
+   !-- grid setup
+      nx = 19,
+      ny = 19,
+      nz = 20,
+
+      dx = 2.0,
+      dy = 2.0,
+      dz = 2.0,
+
+   !-- pressure solver
+      fft_method = 'temperton-algorithm',
+    loop_optimization    = 'cache',
+
+   !-- initialization
+      initializing_actions = 'set_constant_profiles',  ! constant vertical profiles are used,
+      pt_surface = 300.,                               ! based on given "*_surface" values
+      ug_surface = 1.0,
+      vg_surface = 0.0, 
+
+   !-- boundary conditions
+      bc_uv_t = 'neumann',                    ! free-slip boundary condition
+      bc_pt_b = 'dirichlet',                  ! surface temperature is calculated by e-balance solver in USM  
+      bc_pt_t = 'neumann',      
+      roughness_length = 0.1,                 ! applies to all surfaces
+
+   !-- topography   
+      topography = 'read_from_file',                ! file: generic_canyon_topo
+      
+   !-- other
+    most_method          = 'newton',
+      /                                       ! end of inipar-namelist
+
+
+ &runtime_parameters
+   !-- simulation time
+      end_time                = 200.0, 
+
+   !-- others
+      create_disturbances = .T.,
+
+      netcdf_data_format = 5,
+      dt_dots = 9999999.,
+                    
+      /                                        ! end of canopy_par-namelist
+
+
+ &agents_par
+    dt_arel                = 3.1,
+    dt_write_agent_data    = .1,
+    dt_agent = 0.02,
+    number_of_agent_groups = 2,
+    adx                    = 1.8,1.8,
+    ady                    = 1.,1.,
+    asl                    = 13.,13.,
+    asr                    = 27.,27.,
+    ass                    = .5,38.,
+    asn                    = 2.,39.5,
+    at_x                   = 20.,20.,
+    at_y                   = 999.,-999.,  ! chosen far out of domain so that agents walk nearly parallel
+
+
+    /
+
+
+
+ &prepro_par
+      tolerance_dp  = 1.41, 1.41,
+
+    /
Index: palm/trunk/EXAMPLES/agents/canyon/INPUT/canyon_topo
===================================================================
--- palm/trunk/EXAMPLES/agents/canyon/INPUT/canyon_topo	(revision 3159)
+++ palm/trunk/EXAMPLES/agents/canyon/INPUT/canyon_topo	(revision 3159)
@@ -0,0 +1,20 @@
+  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+ 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0
+  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
Index: palm/trunk/EXAMPLES/agents/canyon/OUTPUT/ani_agt.py
===================================================================
--- palm/trunk/EXAMPLES/agents/canyon/OUTPUT/ani_agt.py	(revision 3159)
+++ palm/trunk/EXAMPLES/agents/canyon/OUTPUT/ani_agt.py	(revision 3159)
@@ -0,0 +1,85 @@
+#!/usr/bin/env python3
+
+import matplotlib
+import sys
+from matplotlib import colors, ticker, cm
+from matplotlib.backends.backend_pdf import PdfPages
+from netCDF4 import Dataset
+import matplotlib.pyplot as plt
+import numpy as np
+import math
+from matplotlib import animation
+import matplotlib.gridspec as gridspec
+from matplotlib.lines import Line2D
+from matplotlib.collections import PatchCollection
+from matplotlib.patches import Polygon
+matplotlib.rcParams['text.usetex'] = True
+
+
+input_file_name  = './canyon_agt.001.nc'
+
+file_content     = Dataset(input_file_name, mode='r') # load entire netCDF file
+print(file_content)
+time          = file_content.variables['time'][:] # extract variable
+agx           = file_content.variables['ag_x'][:,:]
+agy           = file_content.variables['ag_y'][:,:]
+grp           = file_content.variables['ag_group'][:,:]
+file_content.close() # close netCDF file
+
+input_file_name  = './topo.txt'
+f     = open(input_file_name, mode='r')
+data = []
+building_id = []
+vertex_id = []
+polygon = []
+gons = []
+p_last = 1
+for line in f:
+  line = line.strip()
+  columns = line.split()
+  if (int(columns[0]) > p_last):
+    gons.append(polygon)
+    polygon = []
+  polygon.append([float(columns[2]),float(columns[3])])
+  p_last = int(columns[0])
+gons.append(polygon)
+nop = int(columns[0])
+patches = []
+
+for i in range(nop):
+  poly = Polygon(gons[i-1], True)
+  patches.append(poly)
+p = PatchCollection(patches,facecolors='grey')
+
+Nt = np.shape(time)[0]
+print(Nt)
+Nt = Nt -1
+Nags = np.shape(agx[1,:])
+Nx = 40
+Ny = 40
+
+x = np.linspace(0.0, 40.0, Nx)
+y = np.linspace(0.0, 40.0, Ny)
+X, Y = np.meshgrid(x, y)
+
+fig,ax = plt.subplots()
+fig.set_size_inches(4., 8.)
+xrange = [10, 30]
+yrange = [0, 40]
+
+
+def animate(i):
+    ax.clear()
+    ax.add_collection(p)
+    x = agx[i,:]
+    y = agy[i,:]
+    ax.set_xlim(*xrange)
+    ax.set_ylim(*yrange)
+    ax.scatter(x,y,s=15,c=grp[i,:])
+    plt.title(r'simulated time: %i s' % time[i])
+    k = i/Nt*100.
+    print("Done: %6.2f percent\r" % k, file=sys.stdout, end=" ")
+    return ax,
+
+anim = animation.FuncAnimation(fig, animate, frames=Nt, interval=60, blit=False,save_count=0)
+anim.save('ags.mp4', dpi=200, writer='ffmpeg')
Index: palm/trunk/EXAMPLES/agents/canyon/OUTPUT/topo.txt
===================================================================
--- palm/trunk/EXAMPLES/agents/canyon/OUTPUT/topo.txt	(revision 3159)
+++ palm/trunk/EXAMPLES/agents/canyon/OUTPUT/topo.txt	(revision 3159)
@@ -0,0 +1,8 @@
+      1       1     12.00      2.00
+      1       2     12.00     38.00
+      1       3      0.00     38.00
+      1       4      0.00      2.00
+      2       1     28.00      2.00
+      2       2     40.00      2.00
+      2       3     40.00     38.00
+      2       4     28.00     38.00
Index: palm/trunk/EXAMPLES/agents/corners/INPUT/corners_p3d
===================================================================
--- palm/trunk/EXAMPLES/agents/corners/INPUT/corners_p3d	(revision 3159)
+++ palm/trunk/EXAMPLES/agents/corners/INPUT/corners_p3d	(revision 3159)
@@ -0,0 +1,61 @@
+&initialization_parameters
+   !-- grid setup
+      nx = 19,
+      ny = 19,
+      nz = 30,
+
+      dx = 1.0,
+      dy = 1.0,
+      dz = 1.0,
+
+   !-- pressure solver
+      fft_method = 'temperton-algorithm',
+    loop_optimization    = 'cache',
+
+   !-- initialization
+      initializing_actions = 'set_constant_profiles',  ! constant vertical profiles are used,
+      pt_surface = 300.,                               ! based on given "*_surface" values
+      ug_surface = 1.0,
+      vg_surface = 0.0, 
+
+   !-- boundary conditions
+      bc_uv_t = 'neumann',                    ! free-slip boundary condition
+      bc_pt_b = 'dirichlet',                  ! surface temperature is calculated by e-balance solver in USM  
+      bc_pt_t = 'neumann',      
+      roughness_length = 0.01,                 ! applies to all surfaces
+
+   !-- topography   
+      topography = 'read_from_file',                ! file: generic_canyon_topo
+      
+   !-- other
+    most_method          = 'newton',
+      /                                       ! end of inipar-namelist
+
+
+ &runtime_parameters  
+   !-- simulation time
+      end_time                = 150.0, 
+
+   !-- others
+      create_disturbances = .T.,
+
+      netcdf_data_format = 5,
+      dt_dots            = 9999999.,
+                    
+      /                                        ! end of canopy_par-namelist
+
+
+ &agents_par
+    dt_arel                = 12.,
+    dt_write_agent_data    = .05,
+    number_of_agent_groups = 4,
+    adx                    =   .9,   .9,   4.,   4.,
+    ady                    =   4.,   4.,   .9,   .9,
+    asl                    =   8.,   8.,  1.5,  18.,
+    asr                    =  12.,  12.,   2., 18.5,
+    ass                    =  1.5,  18.,   8.,   8., 
+    asn                    =   2., 18.5,  12.,  12.,
+    at_x                   =  10.,  10.,  16.,   4.,
+    at_y                   =  16.,   4.,  10.,  10.,
+
+    /
Index: palm/trunk/EXAMPLES/agents/corners/INPUT/corners_topo
===================================================================
--- palm/trunk/EXAMPLES/agents/corners/INPUT/corners_topo	(revision 3159)
+++ palm/trunk/EXAMPLES/agents/corners/INPUT/corners_topo	(revision 3159)
@@ -0,0 +1,20 @@
+  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0 20.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
+  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
Index: palm/trunk/EXAMPLES/agents/corners/OUTPUT/ani_agt.py
===================================================================
--- palm/trunk/EXAMPLES/agents/corners/OUTPUT/ani_agt.py	(revision 3159)
+++ palm/trunk/EXAMPLES/agents/corners/OUTPUT/ani_agt.py	(revision 3159)
@@ -0,0 +1,103 @@
+#!/usr/bin/env python3
+
+import matplotlib
+import sys
+from matplotlib import colors, ticker, cm
+from matplotlib.backends.backend_pdf import PdfPages
+from netCDF4 import Dataset
+import matplotlib.pyplot as plt
+import numpy as np
+import math
+from matplotlib import animation
+import matplotlib.gridspec as gridspec
+from matplotlib.lines import Line2D
+from matplotlib.collections import PatchCollection
+from matplotlib.patches import Polygon
+matplotlib.rcParams['text.usetex'] = True
+
+
+input_file_name  = './corners_agt.059.nc'
+
+file_content     = Dataset(input_file_name, mode='r') # load entire netCDF file
+print(file_content)
+time          = file_content.variables['time'][:] # extract variable
+agx           = file_content.variables['ag_x'][:,:]
+agy           = file_content.variables['ag_y'][:,:]
+group           = file_content.variables['ag_group'][:,:]
+file_content.close() # close netCDF file
+
+input_file_name  = './topo.txt'
+f     = open(input_file_name, mode='r')
+data = []
+building_id = []
+vertex_id = []
+polygon = []
+gons = []
+p_last = 1
+for line in f:
+  line = line.strip()
+  columns = line.split()
+  if (int(columns[0]) > p_last):
+    gons.append(polygon)
+    polygon = []
+  polygon.append([float(columns[2]),float(columns[3])])
+  p_last = int(columns[0])
+gons.append(polygon)
+nop = int(columns[0])
+patches = []
+
+for i in range(nop):
+  poly = Polygon(gons[i-1], True)
+  patches.append(poly)
+p = PatchCollection(patches,facecolors='grey')
+
+input_file_name  = './topo_nav.txt'
+f     = open(input_file_name, mode='r')
+t_x = []
+t_y = []
+
+l_count = 0
+for line in f:
+  l_count = l_count + 1
+  line = line.strip()
+  columns_t = line.split()
+  t_x.append(columns_t[2])
+  t_y.append(columns_t[3])
+
+Nt = np.shape(time)[0]
+print(Nt)
+Nt = Nt -1
+Nags = np.shape(agx[1,:])
+Nx = 20
+Ny = 20
+
+x = np.linspace(0.0, 20.0, Nx)
+y = np.linspace(0.0, 20.0, Ny)
+X, Y = np.meshgrid(x, y)
+
+fig,ax = plt.subplots()
+fig.set_size_inches(7., 7.)
+xrange = [0, 20]
+yrange = [0, 20]
+colors = ['yellow','red','blue']
+
+
+def animate(i):
+    ax.clear()
+    ax.add_collection(p)
+    x = agx[i,:]
+    y = agy[i,:]
+    ax.set_xlim(*xrange)
+    ax.set_ylim(*yrange)
+    ax.scatter(x,y,s=3,c=group[i,:])
+    ax.scatter(t_x,t_y,s=1,c='red')
+    plt.title(r'simulated time: %i s' % time[i])
+    k = i/Nt*100.
+    print("Done: %6.2f percent\r" % k, file=sys.stdout, end=" ")
+    return ax,
+
+anim = animation.FuncAnimation(fig, animate, frames=Nt, interval=60, blit=False,save_count=0)
+anim.save('ags.mp4', dpi=200, writer='ffmpeg')
+#anim.save('basic_animation.gif', fps=1, extra_args=['-vcodec', 'libx264'])
+
+#plt.show()
Index: palm/trunk/EXAMPLES/agents/corners/OUTPUT/topo.txt
===================================================================
--- palm/trunk/EXAMPLES/agents/corners/OUTPUT/topo.txt	(revision 3159)
+++ palm/trunk/EXAMPLES/agents/corners/OUTPUT/topo.txt	(revision 3159)
@@ -0,0 +1,4 @@
+      1       1     15.00     13.00
+      1       2      6.00     13.00
+      1       3      6.00      7.00
+      1       4     15.00      7.00
