When I use:
global npoints = 10
I get the same error.
That is what I started with, but then I run into benchmarking issues: Unintuitive behaviour with BenchmarkTools
EDIT
I misunderstood your suggestion. Putting global npoints
inside the do
block solves the problem.