#-------------------------------------------------
# This case doesn't make much sense to insert an NA. But it shows the availability
# of multiStart() to deal with NAs while reshaping. If you have a more meaningful
# example, please let us know.

#NOTE: It may not work with 'split_multiselected_dims'. Need further tests.
#-------------------------------------------------

#===================================
# merge_across_dims; two variables
#===================================

path <- '/esarchive/recon/ecmwf/erainterim/monthly_mean/$var$_f6h/$var$_$sdate$.nc'
sdate <- c('199801', '199802', '199803')
time <- indices(c(1, 2, NA, 3))
res <- multiStart(
         dat = list(list(name = 'erainterim', path = path)),
         var = c('ps', 'tas'),
         sdate = sdate,
         time = list(list(name = 'erainterim', time = time)),
         time_across = 'sdate',
         merge_across_dims = TRUE,
         lat = indices(1), lon = indices(1),
         synonims = list(lat = c('lat', 'latitude'),
                         lon = c('lon', 'longitude')),
         return_vars = list(lat = NULL, lon = NULL, time = 'sdate'),
         retrieve = TRUE)

dim(res)
# dat  var time  lat  lon 
#   1    2    4    1    1 
res[1, , , 1, 1]
            [,1]        [,2] [,3]        [,4]
[1,] 102528.9219 101670.4375   NA 102194.1484
[2,]    244.3599    242.1576   NA    243.7157

