#!/bin/csh 
# 
#set -xv
#-----------------------------------------------------------------------------------
# retrieve RCM ENSEMBLES CTL simulations from ENSEMBLES RCM database
#----------------------------------------------------------------------------------- 
# Define your username and you password
set user = "you_user_name"
set password = "your_password"

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

# 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/ERA40/"

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

set filelist = ( \
  CNRM/25km/MM/CNRM-RM4.5_CTL_ERA40_MM_25km-CRU_$varin.nc.gz \
  C4I/25km/MM/C4IRCA3_CTL_ERA40_MM_25km-CRU_1961-2000_$varin.nc.gz \
  KNMI/25km/MM/KNMI-RACMO2_CTL_ERA40_MM_25km-CRU_$varin.nc.gz \
  MPI/25km/MM/MPI-M-REMO_CTL_ERA40_MM_25km-CRU_1961-2000_$varin.nc.gz \
  ETHZ/25km/MM/ETHZ-CLM_CTL_ERA40_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


