ChHaeni / bLSmodelR

R package bLSmodelR
MIT License
6 stars 4 forks source link

Optimizing maxFetch with ncores >1 gives an error since v4.7-0 #13

Closed SvenVw closed 2 years ago

SvenVw commented 2 years ago

Hi,

When I try to use the option to optimize maxFetch I get the following error printed:

Error in eval(jsub, SDenv, parent.frame()) : 
  'list' object cannot be coerced to type 'integer'

It seems that this only happens when ncore is larger than 1 as I try to test it with different configurations:

library(bLSmodelR)

Sensors1 <- genSensors(PointSensor=list(x=0,y=0,z=1.5))

Sources1 <- genSources(list(
  "Circle1" = list("c", M = c(0,0), R = 10)
))

# Without optimization of MaxFetch (gives no error)
interval1 <- genInterval()
inList1 <- genInputList(interval1, Sources1, Sensors1)
result1 <- runbLS(inList1, Cat.Path = '.', ncores = 2, asDT = TRUE, memory_limit = NULL)

# With optimization of MaxFetch with no parallelization (gives no error)
interval2 <- genInterval(MaxFetch = -1)
inList2 <- genInputList(interval2, Sources1, Sensors1)
result2 <- runbLS(inList2, Cat.Path = '.', ncores = 1, asDT = TRUE, memory_limit = NULL)

# With optimization of MaxFetch with  parallelization (gives an error)
interval3 <- genInterval(MaxFetch = -1)
inList3 <- genInputList(interval3, Sources1, Sensors1)
result3 <- runbLS(inList3, Cat.Path = '.', ncores = 2, asDT = TRUE, memory_limit = NULL)

The error seems to be introduced with v4.7-0 (43e7c7e84a091e6621afdba09ce68e72fcdf559b) as I can't reproduce it with v4.6-5 (aeea6b44c9cc1c4166cd1cf32dfff87d41cc902d).

Could you please take a look at this issue?

By the way, thanks for this helpful R package!

ChHaeni commented 2 years ago

Thanks for the nice reproducable example! Fixed with bf4eb4e5d390f8c53263e9c4d014c2ec79f85046