
load_multimodel_splitted <- function(recipe){
  
  # Retrieve data dimension only without loading data
  dims <- dims_multimodel(recipe)    
  data_order <- names(dims$dim.hcst)
  
  # Create empty array with desired dimensions
  data <- list(hcst = NULL, fcst = NULL, obs = NULL)
  data$hcst$data <- array(data = NA, dim = dims$dim.hcst)
  if (!is.null(recipe$Analysis$Time$fcst_year)) {
    data$fcst$data <- array(data = NA, dim = dims$dim.fcst)
  }
  files_hcst <- list()
  files_fcst <- list()
  files_obs <- list()
  
  
  # Loop over system to load hindcast and forecast data
  for (sys in 1:length(recipe$Analysis$Datasets$System$models)){
    
    recipe_aux <- recipe
    system_load <- recipe$Analysis$Datasets$System$models[sys]
    recipe_aux$Analysis$Datasets$System$models <- system_load
    
    data_aux <- load_multimodel(recipe_aux)
    
    data$hcst$data[,,,,,which(recipe$Analysis$Datasets$System$models == system_load),,,,1:dim(data_aux$hcst$data)['ensemble']] <- s2dv::Reorder(data = data_aux$hcst$data, order = data_order)
    
    if(!is.null(recipe$Analysis$Time$fcst_year)){
      data$fcst$data[,,,,,which(recipe$Analysis$Datasets$System$models == system_load),,,,1:dim(data_aux$fcst$data)['ensemble']] <- s2dv::Reorder(data = data_aux$fcst$data, order = data_order)
    }
    
    files_hcst <- append(files_hcst, data_aux$hcst$attrs$source_files, after = length(files_hcst))
    files_fcst <- append(files_fcst, data_aux$fcst$attrs$source_files, after = length(files_fcst))
    files_obs <- append(files_obs, data_aux$obs$attrs$source_files, after = length(files_obs))

  } # close loop on sys
  
  # Define obs data
  data$obs$data <- data_aux$obs$data
  
  # Include data attributes
  data$hcst$attrs <- data_aux$hcst$attrs
  data$fcst$attrs <- data_aux$fcst$attrs
  data$obs$attrs <- data_aux$obs$attrs
  data$hcst$coords <- data_aux$hcst$coords
  data$fcst$coords <- data_aux$fcst$coords
  data$obs$coords <- data_aux$obs$coords
  
  # Remove temporary data_aux
  rm(data_aux)
  
  return(list(data = data, 
              files_hcst = files_hcst, 
              files_fcst = files_fcst, 
              files_obs = files_obs))
}
