save_metrics_scorecards <- function(recipe,
                                    skill,
                                    data_cube,
                                    agg = "global",
                                    outdir = NULL) {
  # Time indices and metadata
  fcst.horizon <- tolower(recipe$Analysis$Horizon)
  store.freq <- recipe$Analysis$Variables$freq

  # archive <- get_archive(recipe)
  # global_attributes <- .get_global_attributes(recipe, archive)
  # ## TODO: Sort out the logic once default behavior is decided
  # if ((!is.null(recipe$Analysis$Workflow$Anomalies$compute)) && 
  #     (recipe$Analysis$Workflow$Anomalies$compute)) {
  #   global_attributes <- c(list(from_anomalies = "Yes"),
  #                          global_attributes)
  # } else {
  #   global_attributes <- c(list(from_anomalies = "No"),
  #                          global_attributes)
  # }

  # Select start date
  # If a fcst is provided, use that as the ref. year. Otherwise use 1970.
  if (fcst.horizon == 'decadal') {
    if (!is.null(recipe$Analysis$Time$fcst_year)) {
      #PROBLEM: May be more than one fcst_year
      fcst.sdate <- paste0(recipe$Analysis$Time$fcst_year[1],
                           sprintf('%02d', init_month), '01')
    } else {
      fcst.sdate <- paste0("1970", sprintf('%02d', init_month), '01')
    }
  } else {
    if (!is.null(recipe$Analysis$Time$fcst_year)) {
      fcst.sdate <- paste0(recipe$Analysis$Time$fcst_year,
                           recipe$Analysis$Time$sdate)
    } else {
      fcst.sdate <- paste0("1970", recipe$Analysis$Time$sdate)
    }
  }

  # This needs to be developed:
  coords <- c(data_cube$coords['longitude'],
              data_cube$coords['latitude'])
  # Loop over variable dimension
  for (var in 1:data_cube$dims[['var']]) {
    # Subset skill arrays
    subset_skill <- lapply(skill, function(x) {
                           ClimProjDiags::Subset(x, along = 'var',
                                                 indices = var,
                                                 drop = 'selected')})
    variable <- data_cube$attrs$Variable$varName[[var]]
    outdir <- get_dir(recipe = recipe, variable = variable)
    if (!dir.exists(outdir)) {
      dir.create(outdir, recursive = T)
    }

    for (i in 1:length(subset_skill)) {
      if (any('syear' %in% names(dim(subset_skill[[i]])))) {
        sdate_dim_save = 'syear'
        dates <- data_cube$attrs$Dates
      } else {
        sdate_dim_save = NULL
        dates <- Subset(data_cube$attrs$Dates, along = 'syear', indices = 1)
      }
      extra_string <- get_filename(NULL, recipe, variable,
                                   fcst.sdate, agg, names(subset_skill)[[i]])
      SaveExp(data = subset_skill[[i]], destination = outdir, 
              Dates = dates, 
              coords = coords, 
              varname = names(subset_skill)[[i]], 
              metadata = data_cube$attrs$Variable$metadata, Datasets = NULL, 
              startdates = NULL, dat_dim = NULL, sdate_dim = sdate_dim_save, 
              ftime_dim = 'time', var_dim = NULL, memb_dim = NULL,
              drop_dims = NULL, single_file = TRUE, 
              extra_string = extra_string)
    }
  }
  info(recipe$Run$logger, "##### SKILL METRICS SAVED TO NETCDF FILE #####")
}