Duplicate variable names across kernels in JIT mode
At present, local variables defined in Kernels that share the same name as a local variable in another Kernel crash PARCELS during the kernel compiler. No indication is given to the user that this is cause of the problem. It would be nice if this could be handled and an appropriate error message given in this case.

More generally, if different variables sharing names across kernels are present, it would be neat if they were renamed at runtime during kernel compilation to avoid this issue.
diff --git a/parcels/codegenerator.py b/parcels/codegenerator.py
index 98032718..c7c6db70 100644
--- a/parcels/codegenerator.py
+++ b/parcels/codegenerator.py
@@ -276,6 +276,15 @@ class KernelGenerator(ast.NodeVisitor):
         self.ccode = py_ast.ccode
 
         # Insert variable declarations for non-instrinsics
+        # Make sure that repeated variables are not declared more than
+        # once. If variables occur in multiple Kernels, give a warning
+        used_vars = []
+        for kvar in funcvars:
+            if kvar in used_vars:
+                print("WARNING: "+kvar+" declared in multiple Kernels")
+                funcvars.remove(kvar)
+            else:
+                used_vars.append(kvar)
         for kvar in self.kernel_vars + self.array_vars:
             if kvar in funcvars:
                 funcvars.remove(kvar)
diff --git a/tests/test_kernel_execution.py b/tests/test_kernel_execution.py
index 9896834c..632da3eb 100644
--- a/tests/test_kernel_execution.py
+++ b/tests/test_kernel_execution.py
@@ -171,3 +171,21 @@ def test_kernel_add_no_new_variables(grid, mode):
                  starttime=0., endtime=1., dt=1.)
     assert np.allclose([p.lon for p in pset], 0.6, rtol=1e-5)
     assert np.allclose([p.lat for p in pset], 0.6, rtol=1e-5)
+
+
+@pytest.mark.parametrize('mode', ['scipy', 'jit'])
+def test_multi_kernel_duplicate_varnames(grid, mode):
+    # Testing for merging of two Kernels with the same variable declared
+    # Should throw a warning, but go ahead regardless
+    def MoveEast(particle, grid, time, dt):
+        add_lon = 0.1
+        particle.lon += add_lon
+
+    def MoveWest(particle, grid, time, dt):
+        add_lon = -0.3
+        particle.lon += add_lon
+
+    pset = ParticleSet(grid, pclass=ptype[mode], lon=[0.5], lat=[0.5])
+    pset.execute(pset.Kernel(MoveEast) + pset.Kernel(MoveWest),
+                 starttime=0., endtime=1., dt=1.)
+    assert np.allclose([p.lon for p in pset], 0.3, rtol=1e-5)
['parcels/codegenerator.py', 'tests/test_kernel_execution.py']