#!/bin/csh 
# 
#set -xv
#-----------------------------------------------------------------------------------
# retrieve RCM ENSEMBLES A1B simulations from ENSEMBLES database
#----------------------------------------------------------------------------------- 
# Define your username and you password, to modify
set user = "your_user_name"
set password = "your_password"

# Type of experiments: sresa1b
set expid = "sresa1b"

# Pathout to store the datas, modify this one
set Pathout = "/home/caminade"

# Name of the variable to be retrieved, here temperature (tas)
set varin = "tas"

# web adress of the server
set web = "http://ensemblesrt3.dmi.dk/data/A1B/"

# files to retrieve
# here is a subset of 7 models

set filelist = ( \
  CNRM/MM/CNRM-RM4.5_SCN_ARPEGE_MM_25km-CRU_$varin.nc.gz \
  C4I/MM/C4IRCA3_A1B_HadCM3-e1_MM_25km-CRU_1951-2099_$varin.nc.gz \
  KNMI/MM/KNMI-RACMO2_A1B_ECHAM5-r3_MM_25km-CRU_$varin.nc.gz \
  OURANOS/MM/OURANOSMRCC4.2.1_A1B_CGCM3_MM_25km-CRU_1951-2050_$varin.nc.gz \
  MPI/MM/MPI-M-REMO_SCN_ECHAM5_MM_25km_1951-2100_$varin.nc.gz \
  METNO/MM/METNOHIRHAM_SRESA1B_BCM_MM_25km_1951_2050_$varin.nc.gz \
  ETHZ/MM/ETHZ-CLM_SCN_HadCM3Q0_CRU_MM_25km_$varin.nc.gz \
)

# get the file using wget, unzip the files with gunzip and move the files to Pathout

while($#filelist > 0)
  echo "wget $web$filelist[1]..."
  wget --no-check-certificate --no-cookies --http-user=$user --http-password=$password -nc $web$filelist[1]
  gunzip *.gz
  mv *.nc $Pathout
  shift filelist
end


