library(startR)
hcst.path = '/esarchive/exp/ecmwf/s2s-monthly_ensforhc/weekly_mean/$var$_f24h/
hcst<-Start(dat = hcst.path,
              var = variable,
              file_date = file_dates,
              time = indices(ltmin:ltmax),
              latitude = values(list(lats.min, lats.max)),
              longitude = values(list(lons.min, lons.max)),
              synonims = list(latitude=c('lat','latitude'),
                              longitude=c('lon','longitude'),
                              member=c('ensemble')),
              member = indices(1:hcst.nmember),
              return_vars = list(latitude = 'dat',
                                 longitude = 'dat',
                                 time = 'file_date'),
              split_multiselected_dims = TRUE,
              retrieve = T)

  dates <- attr(hcst, 'Variables')$common$time
  dates_file <- sapply(dates, format, '%Y%m%d')
  dates_file <- format(as.Date(dates_file, '%Y%m%d'), "%Y%m%d")
  dim(dates_file) <- dim(Subset(hcst,
                                along=c('dat','var',
                                'latitude', 'longitude', 'member'),
                                list(1,1,1,1,1), drop=T))

