Start(): Error when retrieve = F and parameter is an object that is NULL
The error occurs at https://earth.bsc.es/gitlab/es/startR/-/blob/v2.2.0/R/Start.R#L3942 start_call[[i]] <- eval.parent(start_call[[i]])
, which is under retrieve = F
only. If Start() call has a parameter that is assigned by an object that is NULL, this object is listed in the list start_call
and will disappear after being eval(). So the list will be shorter than before and the error occurs at the end of for loop. If the parameter is directly specified as NULL, the class is not 'name' or 'call', so it doesn't need to be eval(), therefore, no problem happens.
library(startR)
regrid_params <- list(transform = NULL, grid = NULL)
# 1. transform is an object that is NULL
data <- Start(dat = '/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc',
var = 'tas',
sdate = c('20170101', '20180101'),
ensemble = indices(1),
time = indices(1),
latitude = indices(1:10),
longitude = indices(1:10),
transform = regrid_params$transform, #NULL,
transform_params = NULL,
transform_vars = c('latitude', 'longitude'),
return_vars = list(latitude = NULL, longitude = NULL),
retrieve = F)
Error in start_call[[i]] : subscript out of bounds
# 2. transform is directly NULL
data <- Start(dat = '/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc',
var = 'tas',
sdate = c('20170101', '20180101'),
ensemble = indices(1),
time = indices(1),
latitude = indices(1:10),
longitude = indices(1:10),
transform = NULL,
transform_params = NULL,
transform_vars = c('latitude', 'longitude'),
return_vars = list(latitude = NULL, longitude = NULL),
retrieve = F)
# no error