#!/bin/bash

if [ -z "$FLEXPART_HOME" ]; then
# if FLEXPART_HOME is not defined we assume you run this test from tests/preproc and
# flexpart is installed in $PWD/../..
#
  export FLEXPART_HOME=$PWD/../..
fi

# For this test, we generate WINDFIELDS in the current directory

FLEXPART_WINDS=$PWD/WIND_FIELDS

# You may change these dates if you want to test your installation on other dates!
# SDATE is the start date
SDATE=20070119
# EDATE is the end date
EDATE=20070120

# This directory contains GRIB templates for generating WINDFIELDS from ECMWF ERA-Interim data.
export GRIB_TEMPLATES_PATH=$FLEXPART_HOME/preproc/grib_templates

# Extract ECMWF ERA-Interim data from ECMWF Meteorological Archive (MARS) with ecmwfapi
# we do not specify the output directory so data will be stored in the current directory 
getEIdata.py  --start_date=$SDATE --end_date=$EDATE --area=90.0/-179.0/-90.0/180.0


# Generate FLEXPART WINDFIELDS from ECMWF ERA-Interim data and store them in $FLEXPART_WINDS
prepareFLEXPART.py  --start_date=$SDATE --end_date=$EDATE --namelist=convert.namelist --inputdir=./ \
                    --outputdir=$FLEXPART_WINDS
