@@ -55,7 +55,7 @@ def __init__(
5555 self .funcvars = funcvars
5656 self .funccode = funccode
5757 self .py_ast = py_ast # TODO v4: check if this is needed
58- self .scipy_positionupdate_kernels_added = False
58+ self ._positionupdate_kernels_added = False
5959
6060 @property
6161 def ptype (self ):
@@ -181,7 +181,7 @@ def pyfunc(self):
181181 def fieldset (self ):
182182 return self ._fieldset
183183
184- def add_scipy_positionupdate_kernels (self ):
184+ def add_positionupdate_kernels (self ):
185185 # Adding kernels that set and update the coordinate changes
186186 def Setcoords (particle , fieldset , time ): # pragma: no cover
187187 particle_dlon = 0 # noqa
@@ -324,23 +324,6 @@ def from_list(cls, fieldset, ptype, pyfunc_list, *args, **kwargs):
324324 pyfunc_list [0 ] = cls (fieldset , ptype , pyfunc_list [0 ], * args , ** kwargs )
325325 return functools .reduce (lambda x , y : x + y , pyfunc_list )
326326
327- def execute_python (self , pset , endtime , dt ):
328- """Performs the core update loop via Python."""
329- if self .fieldset is not None :
330- for f in self .fieldset .get_fields ():
331- if isinstance (f , (VectorField , NestedField )):
332- continue
333- f .data = np .array (f .data )
334-
335- if not self .scipy_positionupdate_kernels_added :
336- self .add_scipy_positionupdate_kernels ()
337- self .scipy_positionupdate_kernels_added = True
338-
339- for p in pset :
340- self .evaluate_particle (p , endtime )
341- if p .state == StatusCode .StopAllExecution :
342- return StatusCode .StopAllExecution
343-
344327 def execute (self , pset , endtime , dt ):
345328 """Execute this Kernel over a ParticleSet for several timesteps."""
346329 pset .particledata .state [:] = StatusCode .Evaluate
@@ -359,7 +342,19 @@ def execute(self, pset, endtime, dt):
359342 g ._load_chunk == g ._chunk_loaded_touched , g ._chunk_deprecated , g ._load_chunk
360343 )
361344
362- self .execute_python (pset , endtime , dt )
345+ for f in self .fieldset .get_fields ():
346+ if isinstance (f , (VectorField , NestedField )):
347+ continue
348+ f .data = np .array (f .data )
349+
350+ if not self ._positionupdate_kernels_added :
351+ self .add_positionupdate_kernels ()
352+ self ._positionupdate_kernels_added = True
353+
354+ for p in pset :
355+ self .evaluate_particle (p , endtime )
356+ if p .state == StatusCode .StopAllExecution :
357+ return StatusCode .StopAllExecution
363358
364359 # Remove all particles that signalled deletion
365360 self .remove_deleted (pset )
0 commit comments