# Set working directory:

setwd("~/")


# Accession numbers of datasets:

accnumber <- c("E-GEOD-60542",  
 "E-GEOD-71571",  
 "E-GEOD-64415",  
 "E-GEOD-48278",  
 "E-GEOD-58697",  
 "E-GEOD-68720",  
 "E-GEOD-67851",  
 "E-GEOD-64857",  
 "E-GEOD-53224",  
 "E-GEOD-49697",  
 "E-GEOD-28654",  
 "E-GEOD-54543",  
 "E-GEOD-63626",  
 "E-GEOD-57065",  
 "E-GEOD-61804",  
 "E-GEOD-33532",  
 "E-GEOD-19722",  
 "E-GEOD-59312",  
 "E-GEOD-39084",  
 "E-GEOD-60028",  
 "E-GEOD-45670",  
 "E-GEOD-38662",  
 "E-GEOD-58558",  
 "E-GEOD-49243",  
 "E-GEOD-54837",  
 "E-GEOD-50774",  
 "E-GEOD-46474",  
 "E-GEOD-48780",  
 "E-GEOD-48350",  
 "E-GEOD-53890",  
 "E-GEOD-45216",  
 "E-GEOD-53987",  
 "E-GEOD-29623",  
 "E-GEOD-45867")
 

# Make table of settings: 
 
scenariogrid <- expand.grid(accnumber=accnumber)[,1:1, drop=FALSE]
  
set.seed(1234)
seeds <- sample(1000:10000000, size=nrow(scenariogrid))

scenariogrid$seed <- seeds


# Source the functions to perform the calculations on the server:

source("./ICSVCodeData/Functions/FunctionsForClusters.R")


# Here, other than in the case of all other calculations, 
# we uses the "parallel"-package instead of the "snowfall"-package
# for parallel computing, because we used a different architecture
# to perform the calculations here. 


# Load "parallel"-package:

library("parallel")


# Use random number generator "L'Ecuyer-CMRG":

RNGkind("L'Ecuyer-CMRG")

# Set seed:

set.seed(1234)


# Download the datasets:

results <- mclapply(1:nrow(scenariogrid), function(z) try({DownloadData(z)}), 
  mc.silent=TRUE, mc.preschedule = FALSE, mc.cores = 20) 


# Clear the workspace:

rm(list=ls());gc()