library(startR)

  repos <- "/esarchive/exp/ecmwf/system5_m1/monthly_mean/tas_f6h/$var$_$sdate$.nc"
  var <- 'tas'
  sdate <- c('20170101', '20170201')
  data <- Start(dat = repos,
                var = var,
                sdate = indices(1:32),
                ensemble = 'all',
                time = 'all',
                latitude = 'all', #indices(1:100),
                longitude = 'all', #indices(1:100),
                return_vars = list(time = c('sdate'), longitude = NULL, latitude = NULL),
                retrieve = FALSE
               )
  func <- function(x) {
    a <- apply(x + 1, 2, mean)
    b <- mean(a)
    dim(b) <- c(time = length(b))   #give it a name!!!!
    return(b)
  }

  step <- Step(func, target_dims = c('ensemble', 'time'),
                    output_dims = c('time'))
  wf <- AddStep(data, step)


  res <- Compute(wf,
                 #chunks = list(latitude = 2,
                 #              longitude = 2),#$output1
                 chunks = list(sdate = 8),
                 threads_load = 2,
                 threads_compute = 4,
                 cluster = list(queue_host = 'fat',
                                queue_type = 'slurm',
                                cores_per_job = 2,
                                job_wallclock = '01:00:00',
                                max_jobs = 8,
                                bidirectional = TRUE
                 ),
                 ecflow_suite_dir = '/home/Earth/aho/startR_local/',
                 wait = TRUE
         )

  saveRDS(res, file = 'test_data_fat.Rds')

