Index: itignore
===================================================================
--- .gitignore	(revision 27d9d3c1233ee7af17d6a215acfec31d5339d155)
+++ 	(revision )
@@ -1,14 +1,0 @@
-#
-# gitignore lists all directories and files which should not be versionized!!! 
-#
-
-# these dirs and files shouldn't be versionized at any time in this project!!!
-*.pyc
-*.o
-*.mod
-*.tar*
-*.ksh
-mk_upload_tarball.sh
-/work*
-/src/CONVERT2
-/python/ECMWF_ENV
Index: README.md
===================================================================
--- README.md	(revision e18f4b5f53f063ab746e1307bdd3162d31cb3e8a)
+++ README.md	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -1,25 +1,12 @@
 # README #
 
-This software retrieves ECMWF data and generates FLEXPART specific data files. 
-For each time stamp the software combines all model level and surface level 
-data fields which were modified to match FLEXPART's needs and were then 
-stored in single files with the format prefixYYMMDDHH.
+This directory contains programs to generate FLEXPART WINDFIELDS from ECMWF ERA-Interim data.
 
++ `python  contains python scripts to extract and generate WINDFIELDS
++ `src contains Fortran source code to create CONVERT2 executable (used by the python scripts)
++ `grib_templates contains GRIB-API templates for running CONVERT2 program.
 
-This directory contains the following sub-directories:
++ `please read SIP.doc and SUT.doc for detailed installation and usage instructions
 
-+ `python: It contains the python scripts which manage the extraction and 
-           the generation of FLEXPART input data files. It also includes the 
-           CONTROL files which contain the controlling parameters.
-+ `src:    It contains the Fortran source code and Makefile templates 
-           to create the CONVERT2 executable (used by the python scripts) to
-           process the ECMWF grib fields, e.g. convert from reduced gaussian to 
-           regular latitude-longitude grid.
-+ `grib_templates: It contains a reference table for the ECMWF parameter.
+Please report any problems.
 
-
-For more detailed installation instructions and the user guide please read 
-SIP.pdf and SUT.pdf.
-
-Please report any problems via the ticket system at www.flexpart.eu.
-
Index: cs/linksECMWF
===================================================================
--- docs/linksECMWF	(revision e18f4b5f53f063ab746e1307bdd3162d31cb3e8a)
+++ 	(revision )
@@ -1,86 +1,0 @@
-USEFUL LINKS FOR WORKING WITH ECMWF ARCHIVE AND FLEX_EXTRACT
-============================================================
-
-general overview
-----------------
-https://software.ecmwf.int/wiki/display/WEBAPI/ECMWF+Web+API+Home
-https://software.ecmwf.int/wiki/display/SUP/Home
-
-follow instructions to register
--------------------------------
-https://software.ecmwf.int/wiki/display/WEBAPI/Access+MARS
-
-available public datasets and accept licence
---------------------------------------------
-https://software.ecmwf.int/wiki/display/WEBAPI/Available+ECMWF+Public+Datasets
-
-member-state WebApi access
---------------------------
-http://apps.ecmwf.int/archive-catalogue/
-
-website to download directly public datasets and check webapi activity
-----------------------------------------------------------------------
-http://apps.ecmwf.int/datasets/
-
-general user documentation
---------------------------
-https://software.ecmwf.int/wiki/display/UDOC/User+Documentation
-
-mars user documentation
------------------------
-https://software.ecmwf.int/wiki/display/UDOC/MARS+user+documentation
-  -> specifically the keywords!!!!
-  https://software.ecmwf.int/wiki/display/UDOC/MARS+keywords
-  
-libraries:
----------
-https://software.ecmwf.int/wiki/display/SUP/2015/05/11/Building+ECMWF+software+with+gfortran
-http://www.fftw.org
-https://software.ecmwf.int/wiki/display/EMOS/Emoslib
-https://software.ecmwf.int/wiki/display/GRIB
-https://software.ecmwf.int/wiki/display/ECC
-
-
-Information to datasets:
-========================
-https://www.ecmwf.int/en/forecasts/datasets/archive-datasets
-
-EA5
-----
-https://software.ecmwf.int/wiki/display/CKB/What+is+ERA5
-https://software.ecmwf.int/wiki/display/CKB/How+to+download+ERA5+data+via+the+ECMWF+Web+API
-https://software.ecmwf.int/wiki/display/CKB/ERA5+data+documentation
-
-CERA-20C
----------
-https://software.ecmwf.int/wiki/display/CKB/What+is+CERA-20C
-https://www.ecmwf.int/en/forecasts/datasets/archive-datasets/reanalysis-datasets/cera-20c
-
-ERA-Interim
-------------
-https://www.ecmwf.int/en/forecasts/datasets/archive-datasets/reanalysis-datasets/era-interim
-
-Plotting GRIB fields:
------------------------
-https://software.ecmwf.int/wiki/display/CKB/How+to+plot+GRIB+files+with+Python+and+matplotlib
-
-
-Installation hints:
-===================
-1. Read Emoslib installation instructions
-2. Read ECMWF blog about gfortran
-3. Install FFTW
-4. Install EMOSLIB (2 times make! one without any options and one with single precision option)
-5. Install ECCODES OR GRIB_API
-6. Register at Mars
-7. Install WEBAPI
-8. Check LD_LIBRARY_PATH environment variable if it contains all paths to the libs
-9. Check available python packages (e.g. import eccodes / import grib_api / import ecmwfapi)
-10. Start test retrieval
-11. Install flex_extract
-
-Notes:
---------
-- use the same compiler and compiler version all the time
-- don't forget to set all Library paths to the LD_LIBRARY_PATH variable
-- adapt makefile
Index: python/CONTROL.temp
===================================================================
--- python/CONTROL.temp	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ python/CONTROL.temp	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -1,37 +1,33 @@
 DAY1
 DAY2
-DTIME 1
-TYPE AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN
-TIME 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
-STEP 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-ACCTYPE FC
-ACCTIME 06/18
-ACCMAXSTEP 12
-CLASS EA
+DTIME 3
+TYPE AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC
+TIME 00 00 00 00 00 00 06 00 00 00 00 00 12 12 12 12 12 12 18 12 12 12 12 12
+STEP 00 01 02 03 04 05 00 07 08 09 10 11 00 01 02 03 04 05 00 07 08 09 10 11
+CLASS EI
 STREAM OPER
 NUMBER OFF
 EXPVER 1
-GRID 1000  
-LEFT -179000
+GRID 5000  
+LEFT -175000
 LOWER -90000
 UPPER 90000
 RIGHT 180000
-LEVEL 137
-LEVELIST 1/to/137
-CWC 1
-RESOL 159
-GAUSS 0
-ACCURACY 24
+LEVEL 60
+LEVELIST 1/to/60
+RESOL 63
+GAUSS 1
+ACCURACY 16
 OMEGA 0
 OMEGADIFF 0
-ETA 1
+ETA 0
 ETADIFF 0
 DPDETA 1
 SMOOTH 0
-FORMAT GRIB2
+FORMAT GRIB1
 ADDPAR 186/187/188/235/139/39
-PREFIX EA
-ECSTORAGE 0
-ECTRANS 1
+PREFIX EN
+ECSTORAGE 1
+ECTRANS 0
 ECFSDIR ectmp:/${USER}/econdemand/
 MAILFAIL ${USER} 
Index: thon/CONTROL_CERA
===================================================================
--- python/CONTROL_CERA	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,40 +1,0 @@
-DAY1
-DAY2
-DTIME 3
-TYPE AN AN AN AN AN AN AN AN
-TIME 00 03 06 09 12 15 18 21 
-STEP 00 00 00 00 00 00 00 00
-ACCTYPE FC
-ACCTIME 18
-ACCMAXSTEP 24
-CLASS EP
-STREAM ENDA
-NUMBER 0
-EXPVER 1
-GRID 1000  
-LEFT -179000
-LOWER -90000
-UPPER 90000
-RIGHT 180000
-LEVEL 91
-LEVELIST 1/to/91
-RESOL 159
-GAUSS 0
-ACCURACY 24
-OMEGA 0
-OMEGADIFF 0
-ETA 1
-ETADIFF 0
-DPDETA 1
-SMOOTH 0
-FORMAT GRIB2
-ADDPAR 27/28/173/186/187/188/235/139/39
-CWC 1
-PREFIX CE
-ECSTORAGE 0
-ECTRANS 1
-ECFSDIR ectmp:/${USER}/econdemand/
-MAILFAIL ${USER}
-MAILOPS ${USER}
-GRIB2FLEXPART 0
-EOF
Index: thon/CONTROL_CERA.public
===================================================================
--- python/CONTROL_CERA.public	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,41 +1,0 @@
-DAY1
-DAY2
-DTIME 3
-TYPE AN AN AN AN AN AN AN AN
-TIME 00 03 06 09 12 15 18 21 
-STEP 00 00 00 00 00 00 00 00
-ACCTYPE FC
-ACCTIME 18
-ACCMAXSTEP 24
-CLASS EP
-DATASET cera20c
-STREAM ENDA
-NUMBER 0
-EXPVER 1
-GRID 1000  
-LEFT -179000
-LOWER -90000
-UPPER 90000
-RIGHT 180000
-LEVEL 91
-LEVELIST 1/to/91
-RESOL 159
-GAUSS 0
-ACCURACY 24
-OMEGA 0
-OMEGADIFF 0
-ETA 1
-ETADIFF 0
-DPDETA 1
-SMOOTH 0
-FORMAT GRIB2
-ADDPAR 27/28/173/186/187/188/235/139/39
-CWC 1
-PREFIX CE
-ECSTORAGE 0
-ECTRANS 1
-ECFSDIR ectmp:/${USER}/econdemand/
-MAILFAIL ${USER}
-MAILOPS ${USER}
-GRIB2FLEXPART 0
-EOF
Index: thon/CONTROL_CF
===================================================================
--- python/CONTROL_CF	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,41 +1,0 @@
-DAY1
-DAY2
-DTIME 3
-MAXSTEP 36
-TYPE CF
-TIME 12
-STEP 00
-ACCTYPE CF
-ACCTIME 12
-ACCMAXSTEP 36
-CLASS OD
-STREAM ENFO
-NUMBER OFF
-EXPVER 1
-GRID 1000  
-LEFT -179000
-LOWER -90000
-UPPER 90000
-RIGHT 180000
-LEVEL 91
-LEVELIST 89/to/91
-CWC 1
-RESOL 159
-GAUSS 1
-ACCURACY 24
-OMEGA 1
-OMEGADIFF 0
-ETA 0
-ETADIFF 0
-DPDETA 1
-SMOOTH 0
-FORMAT GRIB2
-ADDPAR /186/187/188/235/139/39
-PREFIX CF
-ECSTORAGE 0
-ECTRANS 1
-ECFSDIR ectmp:/${USER}/econdemand/
-MAILOPS ${USER}
-MAILFAIL ${USER}
-GRIB2FLEXPART 0
-EOF
Index: python/CONTROL_CV
===================================================================
--- python/CONTROL_CV	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ python/CONTROL_CV	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -3,13 +3,10 @@
 DTIME 3
 MAXSTEP 36
-TYPE CV 
-TIME 12 
-STEP 00 
-ACCTYPE CV
-ACCTIME 12
-ACCMAXSTEP 36
+TYPE CF CF 
+TIME 12 12 
+STEP 00 01 
 CLASS OD
 STREAM ENFO
-NUMBER 1
+NUMBER OFF
 EXPVER 1
 GRID 1000  
@@ -20,8 +17,7 @@
 LEVEL 62
 LEVELIST 1/to/62
-CWC 1
 RESOL 159
 GAUSS 1
-ACCURACY 24
+ACCURACY 16
 OMEGA 1
 OMEGADIFF 0
@@ -30,12 +26,12 @@
 DPDETA 1
 SMOOTH 0
-FORMAT GRIB2
+FORMAT GRIB1
 ADDPAR /186/187/188/235/139/39
-PREFIX CV
-ECSTORAGE 0
+PREFIX EE
+ECSTORAGE 1
 ECTRANS 1
 ECFSDIR ectmp:/${USER}/econdemand/
 MAILOPS ${USER}
 MAILFAIL ${USER}
-GRIB2FLEXPART 0
+GRIB2FLEXPART 1
 EOF
Index: python/CONTROL_CV_PREOP
===================================================================
--- python/CONTROL_CV_PREOP	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/CONTROL_CV_PREOP	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,37 @@
+DAY1
+DAY2
+DTIME 3
+MAXSTEP 36
+TYPE CV CV 
+TIME 12 12 
+STEP 00 01 
+CLASS OD
+STREAM ENFO
+NUMBER 1
+EXPVER 1
+GRID 1000  
+LEFT -179000
+LOWER -90000
+UPPER 90000
+RIGHT 180000
+LEVEL 91
+LEVELIST 1/to/91
+RESOL 159
+GAUSS 1
+ACCURACY 16
+OMEGA 1
+OMEGADIFF 0
+ETA 0
+ETADIFF 0
+DPDETA 1
+SMOOTH 0
+FORMAT GRIB1
+ADDPAR /186/187/188/235/139/39
+PREFIX EN
+ECSTORAGE 1
+ECTRANS 1
+ECFSDIR ectmp:/${USER}/econdemand/
+MAILOPS ${USER}
+MAILFAIL ${USER}
+GRIB2FLEXPART 1
+EOF
Index: python/CONTROL_DELIA_HR
===================================================================
--- python/CONTROL_DELIA_HR	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/CONTROL_DELIA_HR	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,34 @@
+DAY1 20140918
+DAY2 20140920
+DTIME 3
+M_TYPE AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC
+M_TIME 00 00 00 00 00 00 06 00 00 00 00 00 12 12 12 12 12 12 18 12 12 12 12 12
+M_STEP 00 01 02 03 04 05 00 07 08 09 10 11 00 01 02 03 04 05 00 07 08 09 10 11
+M_CLASS OD
+M_STREAM OPER
+M_NUMBER OFF
+M_EXPVER 1
+M_GRID 500  
+M_LEFT  12000
+M_LOWER 47000
+M_UPPER 52000
+M_RIGHT 17000
+M_LEVEL 137
+M_RESOL 511
+M_GAUSS 0
+M_ACCURACY 24
+M_OMEGA 0
+M_OMEGADIFF 0
+M_ETA 1
+M_ETADIFF 0
+M_DPDETA 1
+M_SMOOTH 0
+M_FORMAT GRIB2
+M_ADDPAR 186/187/188/235/139/39
+PREFIX EN
+ECSTORAGE 1
+ECTRANS 0
+ECFSDIR ectmp:/${USER}/econdemand/
+MAILOPS ${USER}
+MAILFAIL ${USER}
+EOF
Index: python/CONTROL_DELIA_LR
===================================================================
--- python/CONTROL_DELIA_LR	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/CONTROL_DELIA_LR	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,34 @@
+DAY1 20140918
+DAY2 20140920
+DTIME 3
+M_TYPE AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC
+M_TIME 00 00 00 00 00 00 06 00 00 00 00 00 12 12 12 12 12 12 18 12 12 12 12 12
+M_STEP 00 01 02 03 04 05 00 07 08 09 10 11 00 01 02 03 04 05 00 07 08 09 10 11
+M_CLASS OD
+M_STREAM OPER
+M_NUMBER OFF
+M_EXPVER 1
+M_GRID 1000  
+M_LEFT  10000
+M_LOWER 45000
+M_UPPER 55000
+M_RIGHT 20000
+M_LEVEL 137
+M_RESOL 511
+M_GAUSS 0
+M_ACCURACY 24
+M_OMEGA 0
+M_OMEGADIFF 0
+M_ETA 1
+M_ETADIFF 0
+M_DPDETA 1
+M_SMOOTH 0
+M_FORMAT GRIB2
+M_ADDPAR 186/187/188/235/139/39
+PREFIX EN
+ECSTORAGE 1
+ECTRANS 0
+ECFSDIR ectmp:/${USER}/econdemand/
+MAILOPS ${USER}
+MAILFAIL ${USER}
+EOF
Index: thon/CONTROL_EA5
===================================================================
--- python/CONTROL_EA5	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,41 +1,0 @@
-DAY1
-DAY2
-DTIME 1
-TYPE AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN
-TIME 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
-STEP 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-ACCTYPE FC
-ACCTIME 06/18
-ACCMAXSTEP 12
-CLASS EA
-STREAM OPER
-NUMBER OFF
-EXPVER 1
-GRID 1000  
-LEFT -179000
-LOWER -90000
-UPPER 90000
-RIGHT 180000
-LEVEL 137
-LEVELIST 1/to/137
-CWC 1
-RESOL 159
-GAUSS 0
-ACCURACY 24
-OMEGA 0
-OMEGADIFF 0
-ETA 1
-ETADIFF 0
-DPDETA 1
-SMOOTH 0
-FORMAT GRIB2
-ADDPAR 186/187/188/235/139/39
-PREFIX EA
-ECSTORAGE 0
-ECTRANS 1
-ECFSDIR ectmp:/${USER}/econdemand/
-MAILFAIL ${USER} 
-MAILOPS ${USER}
-GRIB2FLEXPART 0
-EOF
-
Index: thon/CONTROL_EA5.highres
===================================================================
--- python/CONTROL_EA5.highres	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,37 +1,0 @@
-DAY1
-DAY2
-DTIME 1
-TYPE AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN
-TIME 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
-STEP 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-ACCTYPE FC
-ACCTIME 06/18
-ACCMAXSTEP 12
-M_CLASS EA
-M_STREAM OPER
-M_NUMBER OFF
-M_EXPVER 1
-GRID 500  
-LEFT -179500
-LOWER -90000
-UPPER 90000
-RIGHT 180000
-M_LEVELIST 1/to/137
-M_RESOL 319
-M_GAUSS 0
-M_ACCURACY 24
-M_OMEGA 0
-M_OMEGADIFF 0
-M_ETA 1
-M_ETADIFF 0
-M_DPDETA 1
-M_SMOOTH 0
-M_FORMAT GRIB2
-M_ADDPAR /186/187/188/235/139/39
-PREFIX EA
-ECSTORAGE 0
-ECTRANS 1
-ECFSDIR ectmp:/${USER}/econdemand/
-MAILOPS ${USER}
-MAILFAIL ${USER}
-EOF
Index: thon/CONTROL_EA5.public
===================================================================
--- python/CONTROL_EA5.public	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,41 +1,0 @@
-DAY1 
-DAY2 
-DTIME 1
-TYPE AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN AN
-TIME 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
-STEP 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-ACCTYPE FC
-ACCTIME 06/18
-ACCMAXSTEP 12
-CLASS EA
-DATASET ERA5
-STREAM OPER
-NUMBER OFF
-EXPVER 1
-GRID 1000  
-LEFT -179000
-LOWER -90000
-UPPER 90000
-RIGHT 180000
-LEVELIST 1/to/137
-CWC 1
-RESOL 159
-ACCURACY 24
-GAUSS 0
-OMEGA 0
-OMEGADIFF 0
-ETA 1
-ETADIFF 0
-DPDETA 1
-SMOOTH 0
-FORMAT GRIB2
-ADDPAR 186/187/188/235/139/39
-PREFIX EA  
-ECSTORAGE 0
-ECTRANS 1
-ECFSDIR ectmp:/${USER}/econdemand/
-MAILFAIL ${USER} 
-MAILOPS ${USER}
-GRIB2FLEXPART 0
-EOF
-
Index: thon/CONTROL_EI
===================================================================
--- python/CONTROL_EI	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,40 +1,0 @@
-DAY1 
-DAY2 
-DTIME 3
-TYPE AN FC FC FC AN FC FC FC
-TIME 00 00 00 00 12 12 12 12 
-STEP 00 03 06 09 00 03 06 09
-ACCTYPE FC
-ACCTIME 00/12
-ACCMAXSTEP 12
-CLASS EI
-STREAM OPER
-NUMBER OFF
-EXPVER 1
-GRID 1000  
-LEFT -179000
-LOWER -90000
-UPPER 90000
-RIGHT 180000
-LEVEL 60
-LEVELIST 1/to/60
-CWC 1
-RESOL 159
-GAUSS 1
-ACCURACY 24
-OMEGA 0
-OMEGADIFF 0
-ETA 0
-ETADIFF 0
-DPDETA 1
-SMOOTH 0
-FORMAT GRIB2
-ADDPAR /186/187/188/235/139/39
-PREFIX EI
-ECSTORAGE 0
-ECTRANS 1
-ECFSDIR ectmp:/${USER}/econdemand/
-MAILOPS ${USER}
-MAILFAIL ${USER}
-GRIB2FLEXPART 0
-EOF
Index: thon/CONTROL_EI.global
===================================================================
--- python/CONTROL_EI.global	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,40 +1,0 @@
-DAY1
-DAY2
-DTIME 3
-TYPE AN AN AN AN AN AN AN AN
-TIME 00 03 06 09 12 15 18 21 
-STEP 00 00 00 00 00 00 00 00
-ACCTYPE FC
-ACCTIME 00/12
-ACCMAXSTEP 12
-CLASS EI
-STREAM OPER
-NUMBER OFF
-EXPVER 1
-GRID 1000  
-LEFT -179000
-LOWER -90000
-UPPER 90000
-RIGHT 180000
-CWC 1
-LEVEL 60
-LEVELIST 1/to/60
-RESOL 159
-GAUSS 1
-ACCURACY 24
-OMEGA 0
-OMEGADIFF 0
-ETA 0
-ETADIFF 0
-DPDETA 1
-SMOOTH 0
-FORMAT GRIB2
-ADDPAR /186/187/188/235/139/39
-PREFIX EI
-ECSTORAGE 0
-ECTRANS 1
-ECFSDIR ectmp:/${USER}/econdemand/
-MAILOPS ${USER}
-MAILFAIL ${USER}
-GRIB2FLEXPART 0
-EOF
Index: thon/CONTROL_EI.public
===================================================================
--- python/CONTROL_EI.public	(revision b7c1c04a204c91e53759ef590504bf52dfaece64)
+++ 	(revision )
@@ -1,41 +1,0 @@
-DAY1 
-DAY2 
-DTIME 6
-TYPE AN AN AN AN 
-TIME 00 06 12 18 
-STEP 00 00 00 00 
-ACCTYPE FC
-ACCTIME 00/12
-ACCMAXSTEP 12
-CLASS EI
-DATASET interim
-STREAM OPER
-NUMBER OFF
-EXPVER 1
-GRID 1000  
-LEFT -179000
-LOWER -90000
-UPPER 90000
-RIGHT 180000
-LEVELIST 1/to/60
-RESOL 159
-CWC 1
-ACCURACY 24
-GAUSS 1
-OMEGA 0
-OMEGADIFF 0
-ETA 0
-ETADIFF 0
-DPDETA 1
-SMOOTH 0
-FORMAT GRIB1
-ADDPAR 186/187/188/235/139/39
-PREFIX EI  
-ECSTORAGE 0
-ECTRANS 1
-ECFSDIR ectmp:/${USER}/econdemand/
-MAILFAIL ${USER} 
-MAILOPS ${USER}
-GRIB2FLEXPART 0
-EOF
-
Index: python/CONTROL_ERA_HAIYAN
===================================================================
--- python/CONTROL_ERA_HAIYAN	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/CONTROL_ERA_HAIYAN	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,34 @@
+DAY1 20131107
+DAY2 20131108
+DTIME 3
+M_TYPE AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC
+M_TIME 00 00 00 00 00 00 06 00 00 00 00 00 12 12 12 12 12 12 18 12 12 12 12 12
+M_STEP 00 01 02 03 04 05 00 07 08 09 10 11 00 01 02 03 04 05 00 07 08 09 10 11
+M_CLASS OD
+M_STREAM OPER
+M_NUMBER OFF
+M_EXPVER 1
+M_GRID 200  
+M_LEFT 113000
+M_LOWER 00000
+M_UPPER 30000
+M_RIGHT 190000
+M_LEVEL 137
+M_RESOL 799
+M_GAUSS 0
+M_ACCURACY 24
+M_OMEGA 0
+M_OMEGADIFF 0
+M_ETA 1
+M_ETADIFF 0
+M_DPDETA 1
+M_SMOOTH 0
+M_FORMAT GRIB1
+M_ADDPAR /186/187/188/235/139/39
+PREFIX EH
+ECSTORAGE 1
+ECTRANS 0
+ECFSDIR ectmp:/${USER}/econdemand/
+MAILOPS ${USER}
+MAILFAIL ${USER}
+EOF
Index: python/CONTROL_ERA__GLOBALETA
===================================================================
--- python/CONTROL_ERA__GLOBALETA	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/CONTROL_ERA__GLOBALETA	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,37 @@
+DAY1 20131105
+DAY2 20131105
+DTIME 3
+TYPE AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC
+TIME 00 00 00 00 00 00 06 00 00 00 00 00 12 12 12 12 12 12 18 12 12 12 12 12
+STEP 00 01 02 03 04 05 00 07 08 09 10 11 00 01 02 03 04 05 00 07 08 09 10 11
+CLASS EI
+STREAM OPER
+NUMBER OFF
+EXPVER 1
+GRID 1000  
+LEFT -179000
+LOWER -90000
+UPPER 90000
+RIGHT 180000
+LEVEL 60
+LEVELIST 1/to/60
+RESOL 159
+GAUSS 1
+ACCURACY 16
+OMEGA 0
+OMEGADIFF 0
+ETA 0
+ETADIFF 0
+DPDETA 1
+SMOOTH 0
+FORMAT GRIB1
+ADDPAR /186/187/188/235/139/39
+PREFIX EE
+ECSTORAGE 1
+ECTRANS 1
+ECFSDIR ectmp:/${USER}/econdemand/
+MAILOPS ${USER}
+MAILFAIL ${USER}
+FLEXPARTDIR ${HOME}/ECMWFDATA7.0/flexpart_code
+GRIB2FLEXPART grib2flexpart
+EOF
Index: python/CONTROL_ERA__HIRES
===================================================================
--- python/CONTROL_ERA__HIRES	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/CONTROL_ERA__HIRES	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,34 @@
+DAY1 20151007
+DAY2 20151007
+DTIME 1
+M_TYPE AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC
+M_TIME 00 00 00 00 00 00 06 00 00 00 00 00 12 12 12 12 12 12 18 12 12 12 12 12
+M_STEP 00 01 02 03 04 05 00 07 08 09 10 11 00 01 02 03 04 05 00 07 08 09 10 11
+M_CLASS OD
+M_STREAM OPER
+M_NUMBER OFF
+M_EXPVER 1
+M_GRID 200  
+M_LEFT -10000
+M_LOWER 30000
+M_UPPER 60000
+M_RIGHT 30000
+M_LEVEL 137
+M_RESOL 799
+M_GAUSS 1
+M_ACCURACY 24
+M_OMEGA 0
+M_OMEGADIFF 0
+M_ETA 0
+M_ETADIFF 0
+M_DPDETA 1
+M_SMOOTH 0
+M_FORMAT GRIB1
+M_ADDPAR /186/187/188/235/139/39
+PREFIX EH
+ECSTORAGE 1
+ECTRANS 0
+ECFSDIR ectmp:/${USER}/econdemand/
+MAILOPS ${USER}
+MAILFAIL ${USER}
+EOF
Index: python/CONTROL_FC
===================================================================
--- python/CONTROL_FC	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/CONTROL_FC	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,38 @@
+DAY1 20131107
+DAY2 20131108
+DTIME 1
+M_TYPE FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC
+M_TIME 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+M_STEP 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
+M_MAXSTEP 36
+M_LEVEL 137
+M_LEVELIST 136/to/137
+M_CLASS OD
+M_STREAM OPER
+M_NUMBER OFF
+M_EXPVER 1
+M_GRID 1000  
+M_LEFT -179000
+M_LOWER -90000
+M_UPPER 90000
+M_RIGHT 180000
+M_RESOL 159
+M_GAUSS 0
+M_ACCURACY 16
+M_OMEGA 0
+M_OMEGADIFF 0
+M_ETA 1
+M_ETADIFF 0
+M_DPDETA 1
+M_SMOOTH 0
+M_FORMAT GRIB1
+M_ADDPAR /186/187/188/235/139/39
+M_WRF 1
+M_CWC 1
+PREFIX EE
+ECSTORAGE 1
+ECTRANS 0
+ECFSDIR ectmp:/${USER}/econdemand/
+MAILOPS ${USER}
+MAILFAIL ${USER}
+EOF
Index: thon/CONTROL_FC.pure
===================================================================
--- python/CONTROL_FC.pure	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,41 +1,0 @@
-DAY1 
-DAY2 
-DTIME 3
-M_TYPE FC
-M_TIME 00
-M_STEP 00
-M_MAXSTEP 36
-ACCTYPE FC
-ACCTIME 00
-ACCMAXSTEP 36
-M_LEVEL 137
-M_LEVELIST 1/to/137
-M_CLASS OD
-M_STREAM OPER
-M_NUMBER OFF
-M_EXPVER 1
-M_GRID 1000  
-M_LEFT -179000
-M_LOWER -90000
-M_UPPER 90000
-M_RIGHT 180000
-M_RESOL 159
-M_GAUSS 0
-M_ACCURACY 24
-M_OMEGA 0
-M_OMEGADIFF 0
-M_ETA 1
-M_ETADIFF 0
-M_DPDETA 1
-M_SMOOTH 0
-M_FORMAT GRIB2
-M_ADDPAR /186/187/188/235/139/39
-M_WRF 0
-M_CWC 1
-PREFIX FC
-ECSTORAGE 0
-ECTRANS 1
-ECFSDIR ectmp:/${USER}/econdemand/
-MAILOPS ${USER}
-MAILFAIL ${USER}
-EOF
Index: thon/CONTROL_FC.twiceaday
===================================================================
--- python/CONTROL_FC.twiceaday	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,41 +1,0 @@
-DAY1 
-DAY2 
-DTIME 3
-M_TYPE FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC
-M_TIME 00 00 00 00 00 00 00 00 00 00 00 00 12 12 12 12 12 12 12 12 12 12 12 12 
-M_STEP 00 01 02 03 04 05 06 07 08 09 10 11 00 01 02 03 04 05 06 07 08 09 10 11
-M_MAXSTEP 12
-ACCTYPE FC
-ACCTIME 00/12
-ACCMAXSTEP 12
-M_LEVEL 137
-M_LEVELIST 1/to/137
-M_CLASS OD
-M_STREAM OPER
-M_NUMBER OFF
-M_EXPVER 1
-M_GRID 1000  
-M_LEFT -179000
-M_LOWER -90000
-M_UPPER 90000
-M_RIGHT 180000
-M_RESOL 159
-M_GAUSS 0
-M_ACCURACY 24
-M_OMEGA 0
-M_OMEGADIFF 0
-M_ETA 1
-M_ETADIFF 0
-M_DPDETA 1
-M_SMOOTH 0
-M_FORMAT GRIB2
-M_ADDPAR /186/187/188/235/139/39
-M_WRF 0
-M_CWC 1
-PREFIX FC
-ECSTORAGE 0
-ECTRANS 1
-ECFSDIR ectmp:/${USER}/econdemand/
-MAILOPS ${USER}
-MAILFAIL ${USER}
-EOF
Index: python/CONTROL_FC12
===================================================================
--- python/CONTROL_FC12	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/CONTROL_FC12	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,38 @@
+DAY1 20131107
+DAY2 20131108
+DTIME 3
+M_TYPE FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC FC
+M_TIME 00 00 00 00 00 00 00 00 00 00 00 00 12 12 12 12 12 12 12 12 12 12 12 12 
+M_STEP 00 01 02 03 04 05 06 07 08 09 10 11 00 01 02 03 04 05 06 07 08 09 10 11
+M_MAXSTEP 12
+M_LEVEL 137
+M_LEVELIST 120/to/121
+M_CLASS OD
+M_STREAM OPER
+M_NUMBER OFF
+M_EXPVER 1
+M_GRID 1000  
+M_LEFT -179000
+M_LOWER -90000
+M_UPPER 90000
+M_RIGHT 180000
+M_RESOL 159
+M_GAUSS 0
+M_ACCURACY 24
+M_OMEGA 0
+M_OMEGADIFF 0
+M_ETA 1
+M_ETADIFF 0
+M_DPDETA 1
+M_SMOOTH 0
+M_FORMAT GRIB1
+M_ADDPAR /186/187/188/235/139/39
+M_WRF 1
+M_CWC 1
+PREFIX EE
+ECSTORAGE 1
+ECTRANS 0
+ECFSDIR ectmp:/${USER}/econdemand/
+MAILOPS ${USER}
+MAILFAIL ${USER}
+EOF
Index: python/CONTROL_HIRES
===================================================================
--- python/CONTROL_HIRES	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/CONTROL_HIRES	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,34 @@
+DAY1 20151007
+DAY2 20151007
+DTIME 1
+M_TYPE AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC
+M_TIME 00 00 00 00 00 00 06 00 00 00 00 00 12 12 12 12 12 12 18 12 12 12 12 12
+M_STEP 00 01 02 03 04 05 00 07 08 09 10 11 00 01 02 03 04 05 00 07 08 09 10 11
+M_CLASS OD
+M_STREAM OPER
+M_NUMBER OFF
+M_EXPVER 1
+M_GRID 200  
+M_LEFT -10000
+M_LOWER 30000
+M_UPPER 60000
+M_RIGHT 30000
+M_LEVEL 137
+M_RESOL 1279
+M_GAUSS 0
+M_ACCURACY 16
+M_OMEGA 0
+M_OMEGADIFF 0
+M_ETA 1
+M_ETADIFF 0
+M_DPDETA 1
+M_SMOOTH 0
+M_FORMAT GRIB1
+M_ADDPAR 186/187/188/235/139/39
+PREFIX EH
+ECSTORAGE 1
+ECTRANS 0
+ECFSDIR ectmp:/${USER}/econdemand/
+MAILOPS ${USER}
+MAILFAIL ${USER}
+EOF
Index: python/CONTROL_HIRESGAUSS
===================================================================
--- python/CONTROL_HIRESGAUSS	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/CONTROL_HIRESGAUSS	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,34 @@
+DAY1 20151007
+DAY2 20151007
+DTIME 3
+M_TYPE AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC
+M_TIME 00 00 00 00 00 00 06 00 00 00 00 00 12 12 12 12 12 12 18 12 12 12 12 12
+M_STEP 00 01 02 03 04 05 00 07 08 09 10 11 00 01 02 03 04 05 00 07 08 09 10 11
+M_CLASS OD
+M_STREAM OPER
+M_NUMBER OFF
+M_EXPVER 1
+M_GRID 200  
+M_LEFT -10000
+M_LOWER 30000
+M_UPPER 60000
+M_RIGHT 30000
+M_LEVEL 137
+M_RESOL 1279
+M_GAUSS 1
+M_ACCURACY 16
+M_OMEGA 0
+M_OMEGADIFF 0
+M_ETA 0
+M_ETADIFF 0
+M_DPDETA 1
+M_SMOOTH 0
+M_FORMAT GRIB1
+M_ADDPAR 186/187/188/235/139/39
+PREFIX EH
+ECSTORAGE 1
+ECTRANS 0
+ECFSDIR ectmp:/${USER}/econdemand/
+MAILOPS ${USER}
+MAILFAIL ${USER}
+EOF
Index: thon/CONTROL_OD.glob.025
===================================================================
--- python/CONTROL_OD.glob.025	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,35 +1,0 @@
-DAY1 
-DAY2 
-DTIME 1
-M_TYPE AN FC FC FC FC FC FC FC FC FC FC FC AN FC FC FC FC FC FC FC FC FC FC FC
-M_TIME 00 00 00 00 00 00 00 00 00 00 00 00 12 12 12 12 12 12 12 12 12 12 12 12
-M_STEP 00 01 02 03 04 05 06 07 08 09 10 11 00 01 02 03 04 05 06 07 08 09 10 11
-M_CLASS OD
-M_STREAM OPER
-M_NUMBER OFF
-M_EXPVER 
-M_GRID 250 
-M_LEFT -179750
-M_LOWER -90000
-M_UPPER 90000
-M_RIGHT 180000
-M_LEVEL 137
-M_RESOL 799
-M_GAUSS 0
-M_ACCURACY 24
-M_OMEGA 0
-M_OMEGADIFF 0
-M_ETA 1
-M_ETADIFF 0
-M_DPDETA 1
-M_SMOOTH 0
-M_FORMAT GRIB2
-M_ADDPAR /186/187/188/235/139/39
-M_CWC 1
-PREFIX ENH
-ECSTORAGE 0
-ECTRANS 1
-ECFSDIR ectmp:/${USER}/econdemand/
-MAILOPS ${USER}
-MAILFAIL ${USER}
-EOF
Index: thon/CONTROL_OD.highres.eta
===================================================================
--- python/CONTROL_OD.highres.eta	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,35 +1,0 @@
-DAY1 
-DAY2 
-DTIME 1
-M_TYPE AN FC FC FC FC FC FC FC FC FC FC FC AN FC FC FC FC FC FC FC FC FC FC FC
-M_TIME 00 00 00 00 00 00 00 00 00 00 00 00 12 12 12 12 12 12 12 12 12 12 12 12
-M_STEP 00 01 02 03 04 05 06 07 08 09 10 11 00 01 02 03 04 05 06 07 08 09 10 11
-M_CLASS OD
-M_STREAM OPER
-M_NUMBER OFF
-M_EXPVER 1
-M_GRID 200  
-M_LEFT -10000
-M_LOWER 30000
-M_UPPER 60000
-M_RIGHT 30000
-M_LEVEL 137
-M_RESOL 799
-M_GAUSS 0
-M_ACCURACY 24
-M_OMEGA 0
-M_OMEGADIFF 0
-M_ETA 1
-M_ETADIFF 0
-M_DPDETA 1
-M_SMOOTH 0
-M_FORMAT GRIB2
-M_ADDPAR /186/187/188/235/139/39
-M_CWC 1
-PREFIX ENH
-ECSTORAGE 0
-ECTRANS 1
-ECFSDIR ectmp:/${USER}/econdemand/
-MAILOPS ${USER}
-MAILFAIL ${USER}
-EOF
Index: thon/CONTROL_OD.highres.gauss
===================================================================
--- python/CONTROL_OD.highres.gauss	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,38 +1,0 @@
-DAY1 
-DAY2 
-DTIME 1
-M_TYPE AN FC FC FC FC FC FC FC FC FC FC FC AN FC FC FC FC FC FC FC FC FC FC FC
-M_TIME 00 00 00 00 00 00 00 00 00 00 00 00 12 12 12 12 12 12 12 12 12 12 12 12
-M_STEP 00 01 02 03 04 05 06 07 08 09 10 11 00 01 02 03 04 05 06 07 08 09 10 11
-ACCTIME 00/12
-ACCTYPE FC
-ACCMAXSTEP 12
-M_CLASS OD
-M_STREAM OPER
-M_NUMBER OFF
-M_EXPVER 1
-M_GRID 200  
-M_LEFT -10000
-M_LOWER 30000
-M_UPPER 60000
-M_RIGHT 30000
-M_LEVEL 137
-M_RESOL 1279
-M_GAUSS 1
-M_ACCURACY 24
-M_OMEGA 0
-M_OMEGADIFF 0
-M_ETA 0
-M_ETADIFF 0
-M_DPDETA 1
-M_SMOOTH 0
-M_FORMAT GRIB2
-M_ADDPAR 186/187/188/235/139/39
-M_CWC 1
-PREFIX ENHG
-ECSTORAGE 0
-ECTRANS 1
-ECFSDIR ectmp:/${USER}/econdemand/
-MAILOPS ${USER}
-MAILFAIL ${USER}
-EOF
Index: thon/CONTROL_OPS
===================================================================
--- python/CONTROL_OPS	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,29 +1,0 @@
-M_TYPE AN FC FC FC FC FC FC FC FC FC FC FC AN FC FC FC FC FC FC FC FC FC FC FC
-M_TIME 00 00 00 00 00 00 00 00 00 00 00 00 12 12 12 12 12 12 12 12 12 12 12 12
-M_STEP 00 01 02 03 04 05 06 07 08 09 10 11 00 01 02 03 04 05 06 07 08 09 10 11
-DTIME 3
-PREFIX EN
-M_UPPER 90000
-M_LOWER -90000
-M_LEFT -179000
-M_RIGHT 180000
-M_CLASS OD
-M_STREAM OPER
-M_NUMBER OFF
-M_GRID 1000
-M_RESOL 159
-M_SMOOTH 0
-M_GAUSS 0
-M_ETA 1
-M_ETAPAR 77
-M_DPDETA 1
-M_LEVEL 137
-M_LEVELIST 130/to/137
-M_ADDPAR /186/187/188/235/139/39
-M_FORMAT GRIB2
-ECSTORAGE 0
-ECTRANS 1
-ECFSDIR ectmp:/${USER}/ecops
-MAILOPS ${USER}
-MAILFAIL ${USER}
-M_CWC 1
Index: thon/CONTROL_OPS.4V
===================================================================
--- python/CONTROL_OPS.4V	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,31 +1,0 @@
-DAY1
-DAY2
-DTIME 1
-M_TYPE AN FC FC FC FC FC AN FC FC 4V FC FC 4V FC FC FC FC FC AN FC FC 4V FC FC 4V
-M_TIME 00 00 00 00 00 00 06 00 00 09 00 00 09 12 12 12 12 12 18 12 12 21 12 12 21
-M_STEP 00 01 02 03 04 05 00 07 08 00 10 11 03 01 02 03 04 05 00 07 08 00 10 11 03
-PREFIX OP
-M_UPPER 60000
-M_LOWER 10000
-M_LEFT  -25000
-M_RIGHT 60000
-M_CLASS OD
-M_STREAM OPER
-M_NUMBER OFF
-M_GRID 1000
-M_RESOL 255
-M_SMOOTH 0
-M_GAUSS 1
-M_ETA 0
-M_ETAPAR 77
-M_DPDETA 1
-M_LEVEL 137
-M_LEVELIST 1/to/137
-M_ADDPAR 186/187/188/235/139/39
-M_FORMAT GRIB1
-ECSTORAGE 0
-ECTRANS 1
-ECFSDIR ectmp:/${USER}/ecops
-MAILOPS ${USER}
-MAILFAIL ${USER}
-CWC 1
Index: python/CONTROL_OPS_V4.temp
===================================================================
--- python/CONTROL_OPS_V4.temp	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/CONTROL_OPS_V4.temp	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,17 @@
+M_GRID 50
+M_LEFT -17950
+M_RESOL 399
+M_GAUSS 0
+M_ETA 1
+M_EXPVER 1
+M_LEVEL 137
+M_LEVELIST 1/to/137
+M_LEVMAX=137
+M_FORMAT GRIB1
+M_ADDPAR /186/187/188/235/139/39
+ECSTORAGE 1
+ECTRANS 1
+ECFSDIR ectmp:/${USER}/ecops
+MAILOPS ${USER}
+MAILFAIL ${USER}
+
Index: python/CONTROL_OPS_V6.0
===================================================================
--- python/CONTROL_OPS_V6.0	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/CONTROL_OPS_V6.0	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,29 @@
+M_TYPE AN FC FC FC FC FC FC FC FC FC FC FC AN FC FC FC FC FC FC FC FC FC FC FC FC
+M_TIME 00 00 00 00 00 00 00 00 00 00 00 00 12 12 12 12 12 12 12 12 12 12 12 12 12
+M_STEP 00 01 02 03 04 05 06 07 08 09 10 11 00 01 02 03 04 05 06 07 08 09 10 11 12
+DTIME 3
+PREFIX EN
+M_UPPER 90000
+M_LOWER -90000
+M_LEFT -179000
+M_RIGHT 180000
+M_CLASS OD
+M_STREAM OPER
+M_NUMBER OFF
+M_GRID 1000
+M_RESOL 255
+M_SMOOTH 0
+M_GAUSS 0
+M_ETA 1
+CWC 1
+M_ETAPAR 77
+M_DPDETA 1
+M_LEVEL 137
+M_LEVELIST 136/to/137
+M_ADDPAR /186/187/188/235/139/39
+M_FORMAT GRIB2
+ECSTORAGE 0
+ECTRANS 1
+ECFSDIR ectmp:/${USER}/ecops
+MAILOPS ${USER}
+MAILFAIL ${USER}
Index: python/CONTROL_OPS_V6.0_4V.temp
===================================================================
--- python/CONTROL_OPS_V6.0_4V.temp	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/CONTROL_OPS_V6.0_4V.temp	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,28 @@
+M_TYPE AN FC FC FC FC FC AN FC FC 4V FC FC 4V FC FC FC FC FC AN FC FC 4V FC FC 4V
+M_TIME 00 00 00 00 00 00 06 00 00 09 00 00 09 12 12 12 12 12 18 12 12 21 12 12 21
+M_STEP 00 01 02 03 04 05 00 07 08 00 10 11 03 01 02 03 04 05 00 07 08 00 10 11 03
+DTIME 1
+PREFIX EN
+M_UPPER 90000
+M_LOWER -90000
+M_LEFT  -179000
+M_RIGHT 180000
+M_CLASS OD
+M_STREAM OPER
+M_NUMBER OFF
+M_GRID 1000
+M_RESOL 255
+M_SMOOTH 0
+M_GAUSS 1
+M_ETA 0
+M_ETAPAR 77
+M_DPDETA 1
+M_LEVEL 137
+M_LEVELIST 136/to/137
+M_ADDPAR 186/187/188/235/139/39
+M_FORMAT GRIB1
+ECSTORAGE 1
+ECTRANS 1
+ECFSDIR ectmp:/${USER}/ecops
+MAILOPS ${USER}
+MAILFAIL ${USER}
Index: python/CONTROL_PF.temp
===================================================================
--- python/CONTROL_PF.temp	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/CONTROL_PF.temp	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,38 @@
+DAY1
+DAY2
+DTIME 3
+MAXSTEP 36
+TYPE PF PF
+TIME 12 12
+STEP 00 03
+CLASS OD
+STREAM ENFO
+NUMBER 0/to/9
+EXPVER 1
+GRID 1000  
+LEFT -179000
+LOWER -90000
+UPPER 90000
+RIGHT 180000
+LEVEL 62
+LEVELIST 60-62
+RESOL 159
+GAUSS 1
+ACCURACY 16
+OMEGA 0
+OMEGADIFF 0
+ETA 0
+ETADIFF 0
+DPDETA 1
+SMOOTH 0
+FORMAT GRIB1
+ADDPAR /186/187/188/235/139/39
+PREFIX EE
+ECSTORAGE 1
+ECTRANS 1
+ECFSDIR ectmp:/${USER}/econdemand/
+MAILOPS ${USER}
+MAILFAIL ${USER}
+FLEXPARTDIR ${HOME}/ECMWFDATA7.0/flexpart_code
+GRIB2FLEXPART grib2flexpart
+EOF
Index: thon/CONTROL_ZAMG_SYNTH_ELDA
===================================================================
--- python/CONTROL_ZAMG_SYNTH_ELDA	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,34 +1,0 @@
-DAY1
-DAY2
-DTIME 3
-M_TYPE AN FC AN FC AN FC AN FC 
-M_TIME 00 18 06 06 12 06 18 18 
-M_STEP 00 09 00 03 00 09 00 03
-M_ACCTIME 06/18
-M_ACCMAXSTEP 12
-M_STREAM ELDA 
-PREFIX EN
-M_UPPER 30000
-M_LOWER 10000
-M_LEFT -10000
-M_RIGHT 10000
-M_CLASS OD
-M_NUMBER 0/to/25
-M_GRID 1000
-M_RESOL 159
-M_SMOOTH 0
-M_GAUSS 0
-M_ETA 1
-M_CWC 1
-M_ETAPAR 77
-M_DPDETA 1
-M_LEVEL 137
-M_LEVELIST 1/TO/137
-M_ADDPAR 186/187/188/235/139/39/134
-M_FORMAT GRIB1
-ECSTORAGE 0
-ECTRANS 1
-DEBUG 1
-ECFSDIR ectmp:/${USER}/ecops
-MAILOPS ${USER}
-MAILFAIL ${USER}
Index: thon/CONTROL_ZAMG_SYNTH_ENFO
===================================================================
--- python/CONTROL_ZAMG_SYNTH_ENFO	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,31 +1,0 @@
-DAY1
-DAY2
-DTIME 3
-M_TYPE PF PF PF PF PF PF PF PF 
-M_TIME 00 00 00 00 12 12 12 12 
-M_STEP 00 03 06 09 00 03 06 09 
-M_STREAM ENFO 
-PREFIX EN
-M_UPPER 90000
-M_LOWER -90000
-M_LEFT -179000
-M_RIGHT 180000
-M_CLASS OD
-M_NUMBER 1/TO/50
-M_GRID 1000
-M_RESOL 159
-M_SMOOTH 0
-M_GAUSS 1
-M_ETA 0
-M_ETAPAR 77
-M_DPDETA 1
-M_LEVEL 91
-M_LEVELIST 85/TO/91
-M_ADDPAR 186/187/188/235/139/39/134
-M_FORMAT GRIB1
-ECSTORAGE 1
-ECTRANS 0
-DEBUG  1
-ECFSDIR ectmp:/${USER}/ecops
-MAILOPS ${USER}
-MAILFAIL ${USER}
Index: thon/CONTROL_ZAMG_SYNTH_ENFOCF
===================================================================
--- python/CONTROL_ZAMG_SYNTH_ENFOCF	(revision 20577dc5e03880e1a3ac888d7ac339fa1504edf6)
+++ 	(revision )
@@ -1,35 +1,0 @@
-DAY1
-DAY2
-DTIME 3
-M_TYPE CF CF CF CF CF CF CF CF 
-M_TIME 00 00 00 00 12 12 12 12 
-M_STEP 00 03 06 09 00 03 06 09 
-ACCTYPE CF
-ACCTIME 00/12
-ACCMAXSTEP 12
-M_STREAM ENFO 
-PREFIX EN
-M_UPPER 90000
-M_LOWER -90000
-M_LEFT -179000
-M_RIGHT 180000
-M_CLASS OD
-M_NUMBER 0
-M_GRID 1000
-M_RESOL 159
-M_SMOOTH 0
-M_GAUSS 1
-M_ETA 0
-M_ETAPAR 77
-M_DPDETA 1
-M_CWC 1
-M_LEVEL 91
-M_LEVELIST 1/TO/91
-M_ADDPAR 186/187/188/235/139/39/134
-M_FORMAT GRIB1
-ECSTORAGE 0
-ECTRANS 1
-DEBUG  1
-ECFSDIR ectmp:/${USER}/ecops
-MAILOPS ${USER}
-MAILFAIL ${USER}
Index: python/ECMWF_ENV
===================================================================
--- python/ECMWF_ENV	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/ECMWF_ENV	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,4 @@
+ECUID lh0
+ECGID spatlh00
+GATEWAY srvx7.img.univie.ac.at
+DESTINATION leo@genericSftp
Index: python/FlexpartTools.py
===================================================================
--- python/FlexpartTools.py	(revision 9e660c47faa9ca2b9e19d5da43ad0027c730a960)
+++ python/FlexpartTools.py	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -1,10 +1,10 @@
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-#
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
+# 
 # Functionality provided: Prepare input 3D-wind fields in hybrid coordinates + surface fields for FLEXPART runs
 #
 # Creation: October  2014 - Anne Fouilloux - University of Oslo
-# Extension November 2015 - Leopold Haimberger - University of Vienna for:
+# Extension November 2015 - Leopold Haimberger - University of Vienna for: 
 # - using the WebAPI also for general MARS retrievals
 # - job submission on ecgate and cca
@@ -14,16 +14,6 @@
 # - conversion into GRIB2
 # - conversion into .fp format for faster execution of FLEXPART
-#
-# Extension May 2018 - Anne Philipp - University of Vienna
-# - introduced new CONTROL parameter to seperate accumulation and other
-#   data specification
-# - modified code to be able to retrieve ERA-5 data
-# - modified code to be able to retrieve CERA-20C data
-# - added possibility to retrieve data from public data server als as
-#   public user
-# - allow specifying TIME/TYPE/STEP combinations only with needed data instead
-#   of the full 24 hours
-#
-# Requirements:
+# 
+# Requirements: 
 # in addition to a standard python 2.6 or 2.7 installation the following packages need to be installed
 # ECMWF WebMARS, gribAPI with python enabled, emoslib, ecaccess web toolkit, all available from https://software.ecmwf.int/
@@ -38,8 +28,12 @@
 import os, errno,sys,inspect,glob
 import datetime
+#import re
+#import copy
 
 from string import atoi
 from numpy  import *
 
+#sys.stdout=open('ECMWFDATA_'+str(os.getpid()),'w')
+#from ecmwfapi import ECMWFDataServer
 ecapi=True
 try:
@@ -49,5 +43,4 @@
 from gribapi import *
 from GribTools import GribTools
-from opposite import opposite
 
 def interpret_args_and_control(*args,**kwargs):
@@ -56,5 +49,5 @@
                             formatter_class=ArgumentDefaultsHelpFormatter)
 
-# the most important arguments
+# the most important arguments	
     parser.add_argument("--start_date", dest="start_date",
                         help="start date YYYYMMDD")
@@ -63,5 +56,5 @@
     parser.add_argument( "--date_chunk", dest="date_chunk",default=None,
                          help="# of days to be retrieved at once")
-
+    
 # some arguments that override the default in the control file
     parser.add_argument("--basetime", dest="basetime", help="base such as 00/12 (for half day retrievals)")
@@ -69,5 +62,5 @@
     parser.add_argument("--levelist", dest="levelist",help="Vertical levels to be retrieved, e.g. 30/to/60")
     parser.add_argument("--area", dest="area", help="area defined as north/west/south/east")
-
+    
 # set the working directories
     parser.add_argument("--inputdir", dest="inputdir",default=None,
@@ -77,6 +70,6 @@
     parser.add_argument("--flexpart_root_scripts", dest="flexpart_root_scripts",
                         help="FLEXPART root directory (to find grib2flexpart and COMMAND file)\n\
-                              Normally flex_extract resides in the scripts directory of the FLEXPART distribution")
-
+                              Normally ECMWFDATA resides in the scripts directory of the FLEXPART distribution")
+    
 # this is only used by prepareFLEXPART.py to rerun a postprocessing step
     parser.add_argument("--ppid", dest="ppid",
@@ -87,5 +80,5 @@
                         help="job template file for submission to ECMWF")
     #parser.add_argument("--remote", dest="remote",
-                        #help="target for submission to ECMWF (ecgate or cca etc.)")
+			#help="target for submission to ECMWF (ecgate or cca etc.)")
     parser.add_argument("--queue", dest="queue",
                         help="queue for submission to ECMWF (e.g. ecgate or cca )")
@@ -96,120 +89,100 @@
     parser.add_argument("--debug", dest="debug",default=0,
                         help="Debug mode - leave temporary files intact")
-    parser.add_argument("--public", dest="public", default=0,
-                        help="Public mode - retrieves the public datasets")
-
-    parser.add_argument("--request", dest="request", default=None,
-                        help="list all mars request in file mars_requests.dat \
-                        and skip submission to mars")
-
     args = parser.parse_args()
 
     try:
-        c=Control(args.controlfile)
+	c=Control(args.controlfile)
     except IOError:
-        try:
-            c=Control(localpythonpath+args.controlfile)
-
-        except:
-            print 'Could not read control file "'+args.controlfile+'"'
-            print 'Either it does not exist or its syntax is wrong.'
-            print 'Try "'+sys.argv[0].split('/')[-1]+' -h" to print usage information'
-            exit(1)
+	try:
+	    c=Control(localpythonpath+args.controlfile)
+    
+	except:
+	    print 'Could not read control file "'+args.controlfile+'"'
+	    print 'Either it does not exist or its syntax is wrong.'
+	    print 'Try "'+sys.argv[0].split('/')[-1]+' -h" to print usage information'
+	    exit(1)
 
     if  args.start_date==None and getattr(c,'start_date')==None:
-        print 'start_date specified neither in command line nor in control file '+args.controlfile
-        print 'Try "'+sys.argv[0].split('/')[-1]+' -h" to print usage information'
-        exit(1)
+	print 'start_date specified neither in command line nor in control file '+args.controlfile
+	print 'Try "'+sys.argv[0].split('/')[-1]+' -h" to print usage information'
+	exit(1)
 
     if args.start_date!=None:
-        c.start_date=args.start_date
+	c.start_date=args.start_date  
     if args.end_date!=None:
-        c.end_date=args.end_date
+	c.end_date=args.end_date
     if c.end_date==None:
-        c.end_date=c.start_date
+	c.end_date=c.start_date
     if args.date_chunk!=None:
-        c.date_chunk=args.date_chunk
-
+	c.date_chunk=args.date_chunk  
+    
     if not hasattr(c,'debug'):
-        c.debug=args.debug
-
-    if not hasattr(c, 'public'):
-        setattr(c, 'public', args.public)
+	c.debug=args.debug  
+	
 
     if args.inputdir==None and args.outputdir==None:
-        c.inputdir='../work'
-        c.outputdir='../work'
+	c.inputdir='../work'
+	c.outputdir='../work'
     else:
-        if args.inputdir!=None:
-            c.inputdir=args.inputdir
-            if args.outputdir==None:
-                c.outputdir=args.inputdir
-        if args.outputdir!=None:
-            c.outputdir=args.outputdir
-            if args.inputdir==None:
-                c.inputdir=args.outputdir
-
+	if args.inputdir!=None:
+	    c.inputdir=args.inputdir
+	    if args.outputdir==None:
+		c.outputdir=args.inputdir
+	if args.outputdir!=None:
+	    c.outputdir=args.outputdir
+	    if args.inputdir==None:
+		c.inputdir=args.outputdir
+    
     if hasattr(c,'outputdir')==False and args.outputdir==None:
-        c.outputdir=c.inputdir
+	c.outputdir=c.inputdir
     else:
-        if args.outputdir!=None:
-            c.outputdir=args.outputdir
-
+	if args.outputdir!=None:
+	    c.outputdir=args.outputdir
+	    
     if args.area!=None:
-        afloat='.' in args.area
-        l=args.area.split('/')
-        if afloat:
-            for i in range(len(l)):
-                l[i]=str(int(float(l[i])*1000))
-        c.upper,c.left,c.lower,c.right=l
-
-# basetime aktiviert den ''operational mode''
+	afloat='.' in args.area
+	l=args.area.split('/')
+	if afloat:
+	    for i in range(len(l)):
+		l[i]=str(int(float(l[i])*1000))
+	c.upper,c.left,c.lower,c.right=l
+
+# basetime aktiviert den ''operational mode''	
     if args.basetime!=None:
-        c.basetime=args.basetime
+	c.basetime=args.basetime
     #if int(c.basetime)==0:
-        #c.start_date=datetime.datetime.strftime(datetime.datetime.strptime(c.start_date,'%Y%m%d')-datetime.timedelta(days=1),'%Y%m%d')
-        #c.end_date=c.start_date
-
+	#c.start_date=datetime.datetime.strftime(datetime.datetime.strptime(c.start_date,'%Y%m%d')-datetime.timedelta(days=1),'%Y%m%d')
+	#c.end_date=c.start_date
+	
     if args.step!=None:
-        l=args.step.split('/')
-        if 'to' in args.step.lower():
-            if 'by' in args.step.lower():
-                ilist=arange(int(l[0]),int(l[2])+1,int(l[4]))
-                c.step=['{:0>3}'.format(i) for i in ilist]
-            else:
-                myerror(None,args.step+':\n'+'please use "by" as well if "to" is used')
-        else:
-            c.step=l
-
+	l=args.step.split('/')
+	if 'to' in args.step.lower():
+	    if 'by' in args.step.lower():
+		ilist=arange(int(l[0]),int(l[2])+1,int(l[4]))
+		c.step=['{:0>3}'.format(i) for i in ilist]
+	    else:
+		myerror(None,args.step+':\n'+'please use "by" as well if "to" is used')
+	else:
+	    c.step=l
+	
     if args.levelist!=None:
-        c.levelist=args.levelist
-        if 'to' in c.levelist:
-            c.level=c.levelist.split('/')[2]
-        else:
-            c.level=c.levelist.split('/')[-1]
-
-
+	c.levelist=args.levelist
+	if 'to' in c.levelist:
+	    c.level=c.levelist.split('/')[2]
+	else:
+	    c.level=c.levelist.split('/')[-1]
+		    
+    
     if args.flexpart_root_scripts!=None:
-        c.flexpart_root_scripts=args.flexpart_root_scripts
-
-    # set request attribute to control file
-    if args.request != None:
-        c.request=int(args.request)
-    else:
-        c.request = 0
-
-    if c.request != 0:
-        marsfile = os.path.join(c.inputdir, 'mars_requests.csv')
-        if os.path.isfile(marsfile):
-            os.remove(marsfile)
-
+	c.flexpart_root_scripts=args.flexpart_root_scripts
+	
     return args,c
 
 def install_args_and_control():
 
-    parser = ArgumentParser(description='Install flex_extract software locally or on ECMWF machines',
+    parser = ArgumentParser(description='Install ECMWFDATA software locally or on ECMWF machines',
                             formatter_class=ArgumentDefaultsHelpFormatter)
     parser.add_argument('--target',dest='install_target',
-                        help="Valid targets: local | ecgate | cca , the latter two are at ECMWF")
+                    help="Valid targets: local | ecgate | cca , the latter two are at ECMWF")
     parser.add_argument("--makefile", dest="makefile",help='Name of Makefile to use for compiling CONVERT2')
     parser.add_argument("--ecuid", dest="ecuid",help='user id at ECMWF')
@@ -220,6 +193,6 @@
     parser.add_argument("--flexpart_root_scripts", dest="flexpart_root_scripts",
                         help="FLEXPART root directory on ECMWF servers (to find grib2flexpart and COMMAND file)\n\
-                              Normally flex_extract resides in the scripts directory of the FLEXPART distribution, thus the:")
-
+                              Normally ECMWFDATA resides in the scripts directory of the FLEXPART distribution, thus the:")
+    
 # arguments for job submission to ECMWF, only needed by submit.py
     parser.add_argument("--job_template", dest='job_template',default="job.temp.o",
@@ -232,42 +205,42 @@
     try:
 #    if True:
-        c=Control(args.controlfile)
+	c=Control(args.controlfile)
 #    else:
     except:
-        print 'Could not read control file "'+args.controlfile+'"'
-        print 'Either it does not exist or its syntax is wrong.'
-        print 'Try "'+sys.argv[0].split('/')[-1]+' -h" to print usage information'
-        exit(1)
+	print 'Could not read control file "'+args.controlfile+'"'
+	print 'Either it does not exist or its syntax is wrong.'
+	print 'Try "'+sys.argv[0].split('/')[-1]+' -h" to print usage information'
+	exit(1)
 
     if args.install_target!='local':
-        if args.ecgid==None or args.ecuid==None or args.gateway==None or args.destination==None :
-            print 'Please enter your ECMWF user id and group id as well as the \nname of the local gateway and the ectrans destination '
-            print 'with command line options --ecuid --ecgid --gateway --destination'
-            print 'Try "'+sys.argv[0].split('/')[-1]+' -h" to print usage information'
-            print 'Please consult ecaccess documentation or ECMWF user support for further details'
-            sys.exit(1)
-        else:
-            c.ecuid=args.ecuid
-            c.ecgid=args.ecgid
-            c.gateway=args.gateway
-            c.destination=args.destination
-
+	if args.ecgid==None or args.ecuid==None or args.gateway==None or args.destination==None :
+	    print 'Please enter your ECMWF user id and group id as well as the \nname of the local gateway and the ectrans destination '
+	    print 'with command line options --ecuid --ecgid --gateway --destination'
+	    print 'Try "'+sys.argv[0].split('/')[-1]+' -h" to print usage information'
+	    print 'Please consult ecaccess documentation or ECMWF user support for further details'
+	    sys.exit(1)
+	else:
+	    c.ecuid=args.ecuid
+	    c.ecgid=args.ecgid
+	    c.gateway=args.gateway
+	    c.destination=args.destination
+	    
     try:
-        c.makefile=args.makefile
+	c.makefile=args.makefile
     except:
-        pass
-
+	pass
+    
     if args.install_target=='local':
-        if args.flexpart_root_scripts==None:
-            c.flexpart_root_scripts='../'
-        else:
-            c.flexpart_root_scripts=args.flexpart_root_scripts
-
+	if args.flexpart_root_scripts==None:
+	    c.flexpart_root_scripts='../'
+	else:
+	    c.flexpart_root_scripts=args.flexpart_root_scripts
+	
     if args.install_target!='local':
-        if args.flexpart_root_scripts==None:
-            c.ec_flexpart_root_scripts='${HOME}'
-        else:
-            c.ec_flexpart_root_scripts=args.flexpart_root_scripts
-
+	if args.flexpart_root_scripts==None:
+	    c.ec_flexpart_root_scripts='${HOME}'
+	else:
+	    c.ec_flexpart_root_scripts=args.flexpart_root_scripts
+	
     return args,c
 
@@ -280,54 +253,54 @@
 #	cleanlist[-1:-1]=glob.glob(c.inputdir+"/"+c.prefix+"*")
 
-
+    
 #    silentremove(c.inputdir+"/VERTICAL.EC")
 #    silentremove(c.inputdir+"/date_time_stepRange.idx")
     for cl in cleanlist:
-        if c.prefix not in cl:
-            silentremove(cl)
-        if c.ecapi==False and (c.ectrans=='1' or c.ecstorage=='1'):
-            silentremove(cl)
-
-
-
+	if c.prefix not in cl:
+	    silentremove(cl)
+	if c.ecapi==False and (c.ectrans=='1' or c.ecstorage=='1'):
+	    silentremove(cl)
+	
+	
+	
     print "Done"
 
 
 def myerror(c,message='ERROR'):
-
+    
     try:
-        target=c.mailfail
+	target=c.mailfail
     except AttributeError:
-        target=os.getenv('USER')
-
+	target=os.getenv('USER')
+	
     if(type(target) is not list):
-        target=[target]
+	target=[target]
     print message
     # uncomment if user wants email notification directly from python
     #for t in target:
-        #p=subprocess.Popen(['mail','-s flex_extract v7.0.4 ERROR', os.path.expandvars(t)], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,bufsize=1)
-        #tr='\n'.join(traceback.format_stack())
-        #pout=p.communicate(input=message+'\n\n'+tr)[0]
-        #print 'Email sent to '+os.path.expandvars(t) # +' '+pout.decode()
-
+	#p=subprocess.Popen(['mail','-s ECMWFDATA v7.0 ERROR', os.path.expandvars(t)], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,bufsize=1)
+	#tr='\n'.join(traceback.format_stack())
+	#pout=p.communicate(input=message+'\n\n'+tr)[0]
+	#print 'Email sent to '+os.path.expandvars(t) # +' '+pout.decode()
+    
     exit(1)
-
+    
 def normalexit(c,message='Done!'):
-
+    
     try:
-        target=c.mailops
-
-
-        if(type(target) is not list):
-            target=[target]
-        # Uncomment if user wants notification directly from python
-        #for t in target:
-            #p=subprocess.Popen(['mail','-s flex_extract v7.0.4 normal exit', os.path.expandvars(t)], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,bufsize=1)
-            #pout=p.communicate(input=message+'\n\n')[0]
-            #print pout.decode()
-
+	target=c.mailops
+	    
+    
+	if(type(target) is not list):
+	    target=[target]
+	# Uncomment if user wants notification directly from python
+	#for t in target:
+	    #p=subprocess.Popen(['mail','-s ECMWFDATA v7.0 normal exit', os.path.expandvars(t)], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,bufsize=1)
+	    #pout=p.communicate(input=message+'\n\n')[0]
+	    #print pout.decode()
+		
     except:
-        pass
-
+	pass
+    
     print message
 
@@ -357,32 +330,32 @@
 
 def init128(fn):
-
+    
     table128=dict()
     with open(fn) as f:
-        fdata = f.read().split('\n')
-        for data in fdata:
-            if data[0]!='!':
-                table128[data[0:3]]=data[59:64].strip()
-
+	fdata = f.read().split('\n')
+	for data in fdata:
+	    if data[0]!='!':
+		table128[data[0:3]]=data[59:64].strip()
+		
     return table128
 
 def toparamId(pars,table):
-
+    
     cpar=pars.upper().split('/')
     ipar=[]
     for par in cpar:
-        found=False
-        for k,v in table.iteritems():
-            if par==k or par==v:
-                ipar.append(int(k))
-                found=True
-                break
-        if found==False:
-            print 'Warning: par '+par+' not found in table 128'
+	found=False
+	for k,v in table.iteritems():
+	    if par==k or par==v:
+		ipar.append(int(k))
+		found=True
+		break
+	if found==False:
+	    print 'Warning: par '+par+' not found in table 128'
     return ipar
 
 def dapoly(alist):
 
-
+    
     pya=(alist[3]-alist[0]+3.*(alist[1]-alist[2]))/6.
     pyb=(alist[2]+alist[0])/2.-alist[1]-9.*pya/2.
@@ -390,5 +363,5 @@
     pyd=alist[0]-pya/4.-pyb/3.-pyc/2.
     sfeld=8.*pya+4.*pyb+2.*pyc+pyd
-
+    
     return sfeld
 
@@ -410,244 +383,147 @@
     xbd[mask]=xb[mask]*xc[mask]/(xb[mask]+xd[mask])
     sfeld=xac+xbd
-
+    
     return sfeld
-
-def add_previousday_ifneeded(attrs):
-
-    if attrs['type']=='FC' and 'acc' not in attrs['target']:
-        steps=attrs['step'].split('/')
-        times=attrs['time'].split('/')
-        addpday=False
-        #for t in times:
-            #for s in steps:
-        if int(times[0])+int(steps[0])>23:
-            addpday=True
-        if(addpday):
-            dates=attrs['date'].split('/')
-            start_date=dates[0]
-            syear=int(start_date[:4])
-            smonth=int(start_date[4:6])
-            sday=int(start_date[6:])
-            start = datetime.date( year = syear, month = smonth, day = sday )
-            startm1=start- datetime.timedelta(days=1)
-
-            attrs['date']='/'.join([startm1.strftime("%Y%m%d")]+dates[1:])
-            print('CHANGED FC start date to '+startm1.strftime("%Y%m%d")+'to accomodate TIME='+times[0]+', STEP='+steps[0])
-
-    return
-
-
-
+    
 class Control:
-    'class containing the information of the flex_extract control file'
-
+    'class containing the information of the ECMWFDATA control file'
+    
     def __init__(self,filename):
-
-        #try:
-        with open(filename) as f:
-            fdata = f.read().split('\n')
-            for ldata in fdata:
-                data=ldata.split()
-                if len(data)>1:
-                    if 'm_' in data[0].lower():
-                        data[0]=data[0][2:]
-                    if data[0].lower()=='class':
-                        data[0]='marsclass'
-                    if data[0].lower()=='day1':
-                        data[0]='start_date'
-                    if data[0].lower()=='day2':
-                        data[0]='end_date'
-                    if data[0].lower()=='addpar':
-                        if '/' in data[1]:
-                            if data[1][0]=='/':
-                                data[1]=data[1][1:]
-                            dd=data[1].split('/')
-                            data=[data[0]]
-                            for d in dd:
-                                data.append(d)
-                        pass
-                    if len(data)==2:
-                        if '$' in data[1]:
+	
+	#try:
+	    with open(filename) as f:
+		fdata = f.read().split('\n')
+		for ldata in fdata:
+		    data=ldata.split()
+		    if len(data)>1:
+			if 'm_' in data[0].lower():
+			    data[0]=data[0][2:]
+			if data[0].lower()=='class':
+			    data[0]='marsclass'
+			if data[0].lower()=='day1':
+			    data[0]='start_date'
+			if data[0].lower()=='day2':
+			    data[0]='end_date'
+			if data[0].lower()=='addpar':
+			    if '/' in data[1]:
+				if data[1][0]=='/':
+				    data[1]=data[1][1:]
+				dd=data[1].split('/')
+				data=[data[0]]
+				for d in dd:
+				    data.append(d)
+			    pass
+			if len(data)==2:
+			    if '$' in data[1]:
 #				print data[1]
-                            setattr(self,data[0].lower(),data[1])
-                            while '$' in data[1]:
-                                i=data[1].index('$')
-                                j=data[1].find('{')
-                                k=data[1].find('}')
-                                var=os.getenv(data[1][j+1:k])
-                                if var is not None:
-                                    data[1]=data[1][:i]+var+data[1][k+1:]
-                                else:
-                                    myerror(None,'Could not find variable '+data[1][j+1:k]+' while reading '+filename)
-
+				setattr(self,data[0].lower(),data[1])				
+				while '$' in data[1]:
+				    i=data[1].index('$')
+				    j=data[1].find('{')
+				    k=data[1].find('}')
+				    var=os.getenv(data[1][j+1:k])
+				    if var is not None:
+					data[1]=data[1][:i]+var+data[1][k+1:]
+				    else:
+					myerror(None,'Could not find variable '+data[1][j+1:k]+' while reading '+filename)
+					
 #				    print data[0],data[1]
-                            setattr(self,data[0].lower()+'_expanded',data[1])
-                        else:
-                            if data[1].lower()!='none':
-                                setattr(self,data[0].lower(),data[1])
-                            else:
-                                setattr(self,data[0].lower(),None)
-
-                    elif len(data)>2:
-                        setattr(self,data[0].lower(),(data[1:]))
-                else:
-                    pass
-
-            if not hasattr(self,'start_date'):
-                self.start_date=None
-            if not hasattr(self,'end_date'):
-                self.end_date=self.start_date
-            if not hasattr(self,'accuracy'):
-                self.accuracy=24
-            if not hasattr(self,'omega'):
-                self.omega='0'
-            if not hasattr(self,'cwc'):
-                self.cwc='0'
-            if not hasattr(self,'omegadiff'):
-                self.omegadiff='0'
-            if not hasattr(self,'etadiff'):
-                self.etadiff='0'
-
-            if not hasattr(self,'addpar'):
-                self.addpar=''
-            if not isinstance(self.type, list):
-                self.type = [self.type]
-            if not isinstance(self.time, list):
-                self.time = [self.time]
-            if not isinstance(self.step, list):
-                self.step = [self.step]
-
-            max_level_list = [16, 19, 31, 40, 50, 60, 62, 91, 137]
-            if not hasattr(self,'levelist'):
-                if not hasattr(self,'level'):
-                    print 'WARNING: neither levelist nor level specified in CONTROL file'
-                else:
-                    if self.level in max_level_list:
-                        self.levelist='1/to/'+self.level
-            else:
-                if not hasattr(self, 'level'):
-                    if 'to' in self.levelist.lower():
-                        max_level = self.levelist.split('/')[2]
-                        if int(max_level) in max_level_list:
-                            self.level = max_level
-                        else:
-                            print 'ERROR: LEVEL-parameter could not be set'
-                            print 'LEVEL must be the maximum level of a specified level list from ECMWF, e.g.'
-                            print '16, 19, 31, 40, 50, 60, 62, 91 or 137'
-                            sys.exit(1)
-                    else:
-                        max_level = self.levelist.split('/')[-1]
-                        if int(max_level) in max_level_list:
-                            self.level = max_level
-                        else:
-                            print 'ERROR: LEVEL-parameter could not be set'
-                            print 'LEVEL must be the maximum level of a specified level list from ECMWF, e.g.'
-                            print '16, 19, 31, 40, 50, 60, 62, 91 or 137'
-                            sys.exit(1)
-                else:
-                    # check if consistent
-                    if int(self.level) in max_level_list:
-                        pass
-                    else:
-                        print 'ERROR: LEVEL-parameter is not properly selected'
-                        print 'LEVEL must be the maximum level of a specified level list from ECMWF, e.g.'
-                        print '16, 19, 31, 40, 50, 60, 62, 91 or 137'
-                        sys.exit(1)
-
-            if not hasattr(self,'maxstep'):
-                self.maxstep=0
-                for s in self.step:
-                    if int(s)>self.maxstep:
-                        self.maxstep=int(s)
-            else:
-                self.maxstep=int(self.maxstep)
-            if not hasattr(self,'prefix'):
-                self.prefix='EN'
-            if not hasattr(self,'makefile'):
-                self.makefile=None
-            if not hasattr(self,'basetime'):
-                self.basetime=None
-            if not hasattr(self,'date_chunk'):
-                self.date_chunk='3'
-
-            self.flexextractdir=os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))+'/../' # script directory
+				setattr(self,data[0].lower()+'_expanded',data[1])				
+			    else:
+				if data[1].lower()!='none': 
+				    setattr(self,data[0].lower(),data[1])
+				else:
+				    setattr(self,data[0].lower(),None)
+				    
+			elif len(data)>2:
+			    setattr(self,data[0].lower(),(data[1:]))
+		    else:
+			pass
+		    
+		if not hasattr(self,'start_date'):
+		    self.start_date=None
+		if not hasattr(self,'end_date'):
+		    self.end_date=self.start_date
+		if not hasattr(self,'accuracy'):
+		    self.accuracy=24
+		if not hasattr(self,'omega'):
+		    self.omega='0'
+		if not hasattr(self,'cwc'):
+		    self.cwc='0'
+		if not hasattr(self,'omegadiff'):
+		    self.omegadiff='0'
+		if not hasattr(self,'etadiff'):
+		    self.etadiff='0'
+		if not hasattr(self,'levelist'):
+		    if not hasattr(self,'level'):
+			print 'Warning: neither levelist nor level specified in CONTROL file'	
+		    else:
+			self.levelist='1/to/'+self.level
+		else:
+		    if 'to' in self.levelist:
+			self.level=self.levelist.split('/')[2]
+		    else:
+			self.level=self.levelist.split('/')[-1]
+		    
+		if not hasattr(self,'maxstep'):
+		    self.maxstep=0
+		    for s in self.step:
+			if int(s)>self.maxstep:
+			    self.maxstep=int(s)
+		else:
+		    self.maxstep=int(self.maxstep)
+		if not hasattr(self,'prefix'):
+		    self.prefix='EN'
+		if not hasattr(self,'makefile'):
+		    self.makefile=None
+		if not hasattr(self,'basetime'):
+		    self.basetime=None
+		if not hasattr(self,'date_chunk'):
+		    self.date_chunk='3'
+		    
+		self.ecmwfdatadir=os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))+'/../' # script directory
 #		if not hasattr(self,'exedir'):
-            self.exedir=self.flexextractdir+'src/'
-            if not hasattr(self,'grib2flexpart'):
-                self.grib2flexpart='0'
-            if not hasattr(self,'flexpart_root_scripts'):
-                self.flexpart_root_scripts=self.flexextractdir
-
-            if not hasattr(self,'acctype'):
-                print('... Control paramter ACCTYPE was not defined in CONTROL file.')
-                print('Important for (forecast) flux data extraction.')
-                try:
-                    if len(self.type) > 1 and self.type[1] != 'AN':
-                        print('Use old setting by using TYPE[1].')
-                        self.acctype = self.type[1]
-                except:
-                    print('Use default value "FC"!')
-                    self.acctype='FC'
-
-            if not hasattr(self,'acctime'):
-                print('... Control paramter ACCTIME was not defined in CONTROL file.')
-                print('Use default value "00/12" for flux forecast!')
-                print('This may be different for single data sets, see documentation if retrieval fails!')
-                self.acctime='00/12'
-
-            if not hasattr(self, 'accmaxstep'):
-                print('... Control paramter ACCMAXSTEP was not defined in CONTROL file.')
-                print('Use default value "12" for flux forecast!')
-                print('This may be different for single data sets, see documentation if retrieval fails!')
-                self.accmaxstep='12'
-
-            for i in range(len(self.type)):
-                if self.type[i] == 'AN' and int(self.step[i]) != 0:
-                    print('Analysis retrievals must have STEP = 0 (setting to 0)')
-                    self.type[i] = 0
-
-            if not hasattr(self,'request'):
-                self.request=0
-            elif int(self.request) != 0:
-                self.request=int(self.request)
-                marsfile = os.path.join(self.inputdir,
-                                        'mars_requests.csv')
-                if os.path.isfile(marsfile):
-                    silentremove(marsfile)
-
-        return
+  	        self.exedir=self.ecmwfdatadir+'src/'
+		if not hasattr(self,'grib2flexpart'):
+		    self.grib2flexpart='0'
+		if not hasattr(self,'flexpart_root_scripts'):
+		    self.flexpart_root_scripts=self.ecmwfdatadir
+		
+	    
+
+	    return
     def __str__(self):
-
-        attrs = vars(self)
-        # {'kids': 0, 'name': 'Dog', 'color': 'Spotted', 'age': 10, 'legs': 2, 'smell': 'Alot'}
-        # now dump this in some way or another
-        return ', '.join("%s: %s" % item for item in attrs.items())
-
+	
+	attrs = vars(self)
+	# {'kids': 0, 'name': 'Dog', 'color': 'Spotted', 'age': 10, 'legs': 2, 'smell': 'Alot'}
+	# now dump this in some way or another
+	return ', '.join("%s: %s" % item for item in attrs.items())
+    
     def tolist(self):
-        attrs=vars(self)
-        l=list()
-        for item in attrs.items():
-            if '_expanded' in item[0]:
-                pass
-            elif 'exedir' in item[0]:
-                pass
-            elif 'flexpart_root_scripts' in item[0]:
-                pass
-            elif 'flexextractdir' in item[0]:
-                pass
-
-            else:
-                if type(item[1]) is list:
-                    stot=''
-                    for s in item[1]:
-                        stot+=s+' '
-
-                    l.append("%s %s" % (item[0],stot))
-                else:
-                    l.append("%s %s" % item )
-        return sorted(l)
-
-
-
+	attrs=vars(self)
+	l=list()
+	for item in attrs.items():
+	    if '_expanded' in item[0]:
+		pass
+	    elif 'exedir' in item[0]:
+		pass
+	    elif 'flexpart_root_scripts' in item[0]:
+		pass
+	    elif 'ecmwfdatadir' in item[0]:
+		pass
+	    
+	    else:
+		if type(item[1]) is list:
+		    stot=''
+		    for s in item[1]:
+			stot+=s+' '
+			
+		    l.append("%s %s" % (item[0],stot))
+		else:
+		    l.append("%s %s" % item )
+	return sorted(l)
+    
+    
+	
 ##############################################################
 # MARSretrieval class
@@ -656,8 +532,8 @@
     'class for MARS retrievals'
 
-    def __init__(self,server, public, marsclass="ei",type="",levtype="",levelist="",
+    def __init__(self,server, marsclass="ei",type="",levtype="",levelist="", 
                  repres="", date="",resol="",stream="",area="",time="",step="",expver="1",
                  number="",accuracy="", grid="", gaussian="", target="",param="",dataset="",expect=""):
-        self.dataset=dataset
+#        self.dataset=dataset
         self.marsclass=marsclass
         self.type=type
@@ -680,113 +556,57 @@
 #	self.expect=expect
         self.server=server
-        self.public=public
 
     def displayInfo(self):
-        attrs=vars(self)
-        for item in attrs.items():
-            if item[0] in ('server'):
-                pass
-            else:
-                print item[0]+': '+str(item[1])
-
-        return
-
-    def print_infodata_csv(self, inputdir, request_number):
-        '''
-        @Description:
-            Write all request parameter in alpabetical order into a "csv" file.
-
-        @Input:
-            self: instance of MarsRetrieval
-                For description see class documentation.
-
-            inputdir: string
-                The path where all data from the retrievals are stored.
-
-            request_number: integer
-                Number of mars requests for flux and non-flux data.
-
-        @Return:
-            <nothing>
-        '''
-
-        # Get all class attributes and their values as a dictionary
-        attrs = vars(self).copy()
-        del attrs['server']
-        del attrs['public']
-
-        # open a file to store all requests to
-        with open(os.path.join(inputdir, 'mars_requests.csv'), 'a') as f:
-            f.write(str(request_number) + ', ')
-            f.write(', '.join(str(attrs[key])
-                        for key in sorted(attrs.iterkeys())))
-            f.write('\n')
-
-        return
+	attrs=vars(self)
+	for item in attrs.items():
+	    if item[0] in ('server'):
+		pass
+	    else:
+		print item[0]+': '+str(item[1])
+	
+	return
 
     def dataRetrieve(self):
-        attrs=vars(self).copy()
-
-        del attrs['server']
-        del attrs['public']
-        mclass = attrs.get('marsclass')
-        del attrs['marsclass']
-        attrs['class'] = mclass
-
-        add_previousday_ifneeded(attrs)
-
-        target = attrs.get('target')
-        if not int(self.public):
-            del attrs['target']
-        print 'target: ', target
-
-        delete_keys = []
-        for k, v in attrs.iteritems():
-            if v == '':
-                delete_keys.append(str(k))
-            else:
-                attrs[k] = str(v)
-
-        for k in delete_keys:
-            del attrs[k]
+	attrs=vars(self)
+
+#        self.server.retrieve(dicolist)
+	s='ret'
+        for k,v in attrs.iteritems():
+	    if k in ('server'):
+		continue
+            if k=='marsclass':
+                k='class'
+	    if v=='':
+		continue
+	    if k.lower()=='target':
+		target=v
+	    else:
+		s=s+','+k+'='+str(v)
 
         if self.server != False:
-            try:
-                if int(self.public):
-                    print 'RETRIEVE DATA!'
-                    self.server.retrieve(attrs)
-                else:
-                    print 'EXECUTE RETRIEVAL!'
-                    self.server.execute(attrs, target)
-            except:
-                e = sys.exc_info()[0]
-                print "Error: ", e
-                print 'MARS Request failed'#, have you already registered at apps.ecmwf.int?'
-                #raise IOError
-            if not int(self.public) and os.stat(target).st_size==0:
-                print 'MARS Request returned no data - please check request'
-                raise IOError
-            elif int(self.public) and os.stat(attrs.get('target')).st_size==0:
-                print 'MARS Request returned no data - please check request'
-                raise IOError
+	    try:
+		self.server.execute(s,target)
+	    except:
+		print 'MARS Request failed, have you already registered at apps.ecmwf.int?'
+		raise IOError
+	    if os.stat(target).st_size==0:
+		print 'MARS Request returned no data - please check request'
+		raise IOError
         else:
-            s='ret'
-            for k,v in attrs.iteritems():
-                s=s+','+k+'='+str(v)
-
+            
             s+=',target="'+target+'"'
             p=subprocess.Popen(['mars'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,bufsize=1)
             pout=p.communicate(input=s)[0]
             print pout.decode()
-            if 'Some errors reported' in pout.decode():
-                print 'MARS Request failed - please check request'
-                raise IOError
-
-            if os.stat(target).st_size==0:
-                print 'MARS Request returned no data - please check request'
-                raise IOError
-
-        return
-
+	    if 'Some errors reported' in pout.decode():
+		print 'MARS Request failed - please check request'
+		raise IOError
+	    
+	    if os.stat(target).st_size==0:
+		print 'MARS Request returned no data - please check request'
+		raise IOError
+	    
+	return
+            
 ##############################################################
 class EIFlexpart:
@@ -795,414 +615,363 @@
 
     def __init__(self,c,fluxes=False):
-        # different mars types for retrieving reanalysis data for flexpart
-
-        # set a counter for the number of mars requests generated
-        self.mreq_count = 0
-        self.types=dict()
-        try:
-            if c.maxstep>24: #len(c.type):    # Pure forecast mode
-                c.type=[c.type[0]] # AP changed this index from 1 to 0
-                c.step=['{:0>3}'.format(int(c.step[0]))]
-                c.time=[c.time[0]]
-                for i in range(1,c.maxstep+1):
-                    c.type.append(c.type[0])
-                    c.step.append('{:0>3}'.format(i))
-                    c.time.append(c.time[0])
-        except:
-            pass
-
-        self.inputdir=c.inputdir
-        self.basetime=c.basetime
-        self.dtime=c.dtime
-        self.mars={}
-        i=0
-        j=0
-        if fluxes==True and c.maxstep<=24:
-            self.types[str(c.acctype)]={'times':str(c.acctime),
-                                        'steps':'{}/to/{}/by/{}'.format(
-                                               c.dtime,c.accmaxstep,c.dtime)}
-            i=1
-            for k in [0,12]:
-                for j in range(int(c.dtime),13,int(c.dtime)):
-                    self.mars['{:0>3}'.format(i*int(c.dtime))]=[c.type[1],'{:0>2}'.format(k),'{:0>3}'.format(j)]
-                    i+=1
-        else:
-            for ty,st,ti in zip(c.type,c.step,c.time):
-                btlist=range(len(c.time))
-                if c.basetime=='12':
-                    btlist=[1,2,3,4,5,6,7,8,9,10,11,12]
-                if c.basetime=='00':
-                    btlist=[13,14,15,16,17,18,19,20,21,22,23,0]
-
-
-                if ((ty.upper() == 'AN' and mod(int(c.time[i]),int(c.dtime))==0 and int(c.step[i])==0) or \
-                   (ty.upper() != 'AN' and mod(int(c.step[i]),int(c.dtime))==0 and \
-                    mod(int(c.step[i]),int(c.dtime))==0) ) and \
-                   (i in btlist or c.maxstep>24):
-                    if ty not in self.types.keys():
-                        self.types[ty]={'times':'','steps':''}
-                    if ti not in self.types[ty]['times']:
-                        if len(self.types[ty]['times'])>0:
-                            self.types[ty]['times']+='/'
-                        self.types[ty]['times']+=ti
-                    if st not in self.types[ty]['steps']:
-                        if len(self.types[ty]['steps'])>0:
-                            self.types[ty]['steps']+='/'
-                        self.types[ty]['steps']+=st
-
-                    self.mars['{:0>3}'.format(j)]=[ty,'{:0>2}'.format(int(ti)),'{:0>3}'.format(int(st))]
-                    j+=int(c.dtime)
-
-                i+=1
-
-# Different grids need different retrievals
+# different mars types for retrieving reanalysis data for flexpart
+	
+	self.types=dict()
+	try:
+	    if c.maxstep>len(c.type):    # Pure forecast mode
+		c.type=[c.type[1]]
+		c.step=['{:0>3}'.format(int(c.step[0]))]
+		c.time=[c.time[0]]
+		for i in range(1,c.maxstep+1):
+		    c.type.append(c.type[0])
+		    c.step.append('{:0>3}'.format(i))
+		    c.time.append(c.time[0])
+	except:
+	    pass
+	
+	self.inputdir=c.inputdir
+	self.basetime=c.basetime
+	self.dtime=c.dtime
+	self.mars={}			    
+	i=0
+	j=0
+	if fluxes==True and c.maxstep<24:
+	    self.types[c.type[1]]={'times':'00/12','steps':'{}/to/12/by/{}'.format(c.dtime,c.dtime)}
+	    i=1
+	    for k in [0,12]:
+		for j in range(int(c.dtime),13,int(c.dtime)):
+		    self.mars['{:0>3}'.format(i*int(c.dtime))]=[c.type[1],'{:0>2}'.format(k),'{:0>3}'.format(j)]
+		    i+=1
+	else:
+	    for ty,st,ti in zip(c.type,c.step,c.time):
+		btlist=range(24)
+		if c.basetime=='12':
+		    btlist=[1,2,3,4,5,6,7,8,9,10,11,12]
+#		    btday =[0,0,0,0,0,0,0,0,0, 0, 0, 0]
+		if c.basetime=='00':
+		    btlist=[13,14,15,16,17,18,19,20,21,22,23,0]
+#		    btday =[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]
+#		    if c.step[0]=='00':
+#			btday[-1]=0
+		
+		if mod(i,int(c.dtime))==0 and (i in btlist or c.maxstep>24):
+		    if ty not in self.types.keys():
+			self.types[ty]={'times':'','steps':''}
+		    if ti not in self.types[ty]['times']:
+			if len(self.types[ty]['times'])>0:
+			    self.types[ty]['times']+='/'
+			self.types[ty]['times']+=ti
+		    if st not in self.types[ty]['steps']:
+			if len(self.types[ty]['steps'])>0:
+			    self.types[ty]['steps']+='/'
+			self.types[ty]['steps']+=st
+		    
+		    self.mars['{:0>3}'.format(j)]=[ty,'{:0>2}'.format(int(ti)),'{:0>3}'.format(int(st))]
+		    j+=int(c.dtime)
+		
+		i+=1
+		
+# Different grids need different retrievals	
 # SH=Spherical Harmonics, GG=Gaussian Grid, OG=Output Grid, ML=MultiLevel, SL=SingleLevel
-        self.params={'SH__ML':'','SH__SL':'',
+	self.params={'SH__ML':'','SH__SL':'',
                      'GG__ML':'','GG__SL':'',
                      'OG__ML':'','OG__SL':'',
-                     'OG_OROLSM_SL':'','OG_acc_SL':''}
-
-        self.marsclass=c.marsclass
-        self.stream=c.stream
-        self.number=c.number
-        self.resol=c.resol
-        if 'N' in c.grid:  # Gaussian output grid
-            self.grid=c.grid
-            self.area='G'
-        else:
-            self.grid='{}/{}'.format(int(c.grid)/1000.,int(c.grid)/1000.)
-            self.area='{}/{}/{}/{}'.format(int(c.upper)/1000.,int(c.left)/1000.,int(c.lower)/1000.,int(c.right)/1000.)
-
-        self.accuracy=c.accuracy
-        self.level=c.level
-        try:
-            self.levelist=c.levelist
-        except:
-            self.levelist='1/to/'+c.level
-        self.glevelist='1/to/'+c.level
-        try:
-            self.gaussian=c.gaussian
-        except:
-            self.gaussian=''
-        try:
-            self.dataset=c.dataset
-        except:
-            self.dataset=''
-        try:
-            self.expver=c.expver
-        except:
-            self.expver='1'
-        try:
-            self.number=c.number
-        except:
-            self.number='0'
-
-        self.outputfilelist=[]
-
-
+	             'OG_OROLSM_SL':'','OG_acc_SL':''}
+	
+	self.marsclass=c.marsclass
+	self.stream=c.stream
+	self.number=c.number
+	self.resol=c.resol
+	if 'N' in c.grid:  # Gaussian output grid
+	    self.grid=c.grid
+	    self.area='G'
+	else:
+	    self.grid='{}/{}'.format(int(c.grid)/1000.,int(c.grid)/1000.)
+	    self.area='{}/{}/{}/{}'.format(int(c.upper)/1000.,int(c.left)/1000.,int(c.lower)/1000.,int(c.right)/1000.)
+
+	self.accuracy=c.accuracy
+	self.level=c.level
+	try:
+	    self.levelist=c.levelist
+	except:
+	    self.levelist='1/to/'+c.level
+	self.glevelist='1/to/'+c.level
+	try:
+	    self.gaussian=c.gaussian
+	except:
+	    self.gaussian=''
+	try:
+	    self.dataset=c.dataset
+	except:
+	    self.dataset=''
+	try:
+	    self.expver=c.expver
+	except:
+	    self.expver='1'
+	try:
+	    self.number=c.number
+	except:
+	    self.number='0'
+	
+	self.outputfilelist=[]
+	    
+	
 # Now comes the nasty part that deals with the different scenarios we have:
-# 1) Calculation of etadot on
+# 1) Calculation of etadot on 
 #    a) Gaussian grid
 #    b) Output grid
 #    c) Output grid using parameter 77 retrieved from MARS
-# 3) Calculation/Retrieval of omega
+# 3) Calculation/Retrieval of omega 
 # 4) Download also data for WRF
 
         if fluxes==False:
-            self.params['SH__SL']=['LNSP','ML','1','OFF']
+	    self.params['SH__SL']=['LNSP','ML','1','OFF']
 #	    self.params['OG__SL']=["SD/MSL/TCC/10U/10V/2T/2D/129/172",'SFC','1',self.grid]
-            self.params['OG__SL']=["141/151/164/165/166/167/168/129/172",'SFC','1',self.grid]
-            if c.marsclass.upper() == 'EA' or c.marsclass.upper() == 'EP':
-                self.params['OG_OROLSM__SL']=["160/27/28/244",'SFC','1',self.grid]
-            else:
-                self.params['OG_OROLSM__SL']=["160/27/28/173",'SFC','1',self.grid]
-
-            if len(c.addpar)>0:
-                if c.addpar[0]=='/':
-                    c.addpar=c.addpar[1:]
-                self.params['OG__SL'][0]+='/'+'/'.join(c.addpar)
-            self.params['OG__ML']=['T/Q','ML',self.levelist,self.grid]
-
-            if c.gauss=='0' and c.eta=='1': # the simplest case
-                self.params['OG__ML'][0]+='/U/V/77'
-            elif c.gauss=='0' and c.eta=='0': # this is not recommended (inaccurate)
-                self.params['OG__ML'][0]+='/U/V'
-            elif c.gauss=='1' and c.eta=='0': # this is needed for data before 2008, or for reanalysis data
-                self.params['GG__SL']=['Q','ML','1','{}'.format((int(self.resol)+1)/2)]
-                self.params['SH__ML']=['U/V/D','ML',self.glevelist,'OFF']
-            else:
-                print 'Warning: This is a very costly parameter combination, use only for debugging!'
-                self.params['GG__SL']=['Q','ML','1','{}'.format((int(self.resol)+1)/2)]
-                self.params['GG__ML']=['U/V/D/77','ML',self.glevelist,'{}'.format((int(self.resol)+1)/2)]
-
-            if c.omega=='1':
-                self.params['OG__ML'][0]+='/W'
-
-            try:            # add cloud water content if necessary
-                if c.cwc=='1':
-                    self.params['OG__ML'][0]+='/CLWC/CIWC'
-            except:
-                pass
-
-            try:            # add vorticity and geopotential height for WRF if necessary
-                if c.wrf=='1':
-                    self.params['OG__ML'][0]+='/Z/VO'
-                    if '/D' not in self.params['OG__ML'][0]:
-                        self.params['OG__ML'][0]+='/D'
+	    self.params['OG__SL']=["141/151/164/165/166/167/168/129/172",'SFC','1',self.grid]
+	    self.params['OG_OROLSM__SL']=["160/27/28/173",'SFC','1',self.grid]
+	    
+	    if len(c.addpar)>0:
+	        if c.addpar[0]=='/':
+		    c.addpar=c.addpar[1:]
+		self.params['OG__SL'][0]+='/'+'/'.join(c.addpar)
+	    self.params['OG__ML']=['T/Q','ML',self.levelist,self.grid]
+	    
+	    if c.gauss=='0' and c.eta=='1': # the simplest case
+		self.params['OG__ML'][0]+='/U/V/77'
+	    elif c.gauss=='0' and c.eta=='0': # this is not recommended (inaccurate)
+		self.params['OG__ML'][0]+='/U/V'
+	    elif c.gauss=='1' and c.eta=='0': # this is needed for data before 2008, or for reanalysis data
+		self.params['GG__SL']=['Q','ML','1','{}'.format((int(self.resol)+1)/2)]
+		self.params['SH__ML']=['U/V/D','ML',self.glevelist,'OFF']
+	    else:
+		print 'Warning: This is a very costly parameter combination, use only for debugging!'
+		self.params['GG__SL']=['Q','ML','1','{}'.format((int(self.resol)+1)/2)]
+		self.params['GG__ML']=['U/V/D/77','ML',self.glevelist,'{}'.format((int(self.resol)+1)/2)]
+		
+	    if c.omega=='1':
+		self.params['OG__ML'][0]+='/W'
+		
+	    try:            # add cloud water content if necessary
+		if c.cwc=='1':
+		    self.params['OG__ML'][0]+='/CLWC/CIWC'
+	    except:
+		pass
+	    
+	    try:            # add vorticity and geopotential height for WRF if necessary
+		if c.wrf=='1':
+		    self.params['OG__ML'][0]+='/Z/VO'
+		    if '/D' not in self.params['OG__ML'][0]:
+			self.params['OG__ML'][0]+='/D'
 #		    wrf_sfc='sp/msl/skt/2t/10u/10v/2d/z/lsm/sst/ci/sd/stl1/stl2/stl3/stl4/swvl1/swvl2/swvl3/swvl4'.upper()
 #                            134/151/235/167/165/166/168/129/172/034/031/141/139/170/183/236/039/040/041/042
-                    wrf_sfc='134/235/167/165/166/168/129/172/34/31/141/139/170/183/236/39/40/41/42'.upper()
-                    lwrt_sfc=wrf_sfc.split('/')
-                    for par in lwrt_sfc:
-                        if par not in self.params['OG__SL'][0]:
-                            self.params['OG__SL'][0]+='/'+par
-
-            except:
-                pass
-        else:
-            self.params['OG_acc_SL']=["LSP/CP/SSHF/EWSS/NSSS/SSR",'SFC','1',self.grid]
-
-
-        return
-        # add additional WRF specific parameters here
-
+		    wrf_sfc='134/235/167/165/166/168/129/172/34/31/141/139/170/183/236/39/40/41/42'.upper()
+		    lwrt_sfc=wrf_sfc.split('/')
+		    for par in lwrt_sfc:
+			if par not in self.params['OG__SL'][0]:
+			    self.params['OG__SL'][0]+='/'+par 
+		    
+	    except:
+		pass
+	else:
+	    self.params['OG_acc_SL']=["LSP/CP/SSHF/EWSS/NSSS/SSR",'SFC','1',self.grid]
+		
+		
+	return
+	# add additional WRF specific parameters here
+		
     def create_namelist(self,c,filename):
-
+	
 #	if inputdir=="":
 #	    self.inputdir='.'
 #	else:
 #	    self.inputdir=inputdir
-
-        self.inputdir=c.inputdir
-        area=asarray(self.area.split('/')).astype(float)
-        grid=asarray(self.grid.split('/')).astype(float)
-
+	
+	self.inputdir=c.inputdir
+	area=asarray(self.area.split('/')).astype(float)
+	grid=asarray(self.grid.split('/')).astype(float)
+	
 #	if area[3]<0:
 #	    area[3]+=360
-        if area[1]>area[3]:
-            area[1]-=360
-        zyk=abs((area[3]-area[1]-360.)+grid[1])<1.e-6
-        maxl=int((area[3]-area[1])/grid[1])+1
-        maxb=int((area[0]-area[2])/grid[0])+1
-
-        f=open(self.inputdir+'/'+filename,'w')
-        f.write('&NAMGEN\n')
-        f.write(',\n  '.join(['maxl='+str(maxl),'maxb='+str(maxb),
-                              'mlevel='+self.level,'mlevelist='+'"'+self.levelist+'"',
-                    'mnauf='+self.resol,'metapar='+'77',
-                    'rlo0='+str(area[1]),'rlo1='+str(area[3]),'rla0='+str(area[2]),'rla1='+str(area[0]),
-                    'momega='+c.omega,'momegadiff='+c.omegadiff,'mgauss='+c.gauss,
-                    'msmooth='+c.smooth,'meta='+c.eta,'metadiff='+c.etadiff,'mdpdeta='+c.dpdeta]))
-
-        f.write('\n/\n')
-        f.close()
-        return
-
-
-    def retrieve(self, server, public, dates, request, times, inputdir=''):
+	if area[1]>area[3]:
+	    area[1]-=360
+	zyk=abs((area[3]-area[1]-360.)+grid[1])<1.e-6
+	maxl=int((area[3]-area[1])/grid[1])+1
+	maxb=int((area[0]-area[2])/grid[0])+1
+
+	f=open(self.inputdir+'/'+filename,'w')
+	f.write('&NAMGEN\n')
+	f.write(',\n  '.join(['maxl='+str(maxl),'maxb='+str(maxb),
+	            'mlevel='+self.level,'mlevelist='+'"'+self.levelist+'"',
+	            'mnauf='+self.resol,'metapar='+'77',
+	            'rlo0='+str(area[1]),'rlo1='+str(area[3]),'rla0='+str(area[2]),'rla1='+str(area[0]),
+	            'momega='+c.omega,'momegadiff='+c.omegadiff,'mgauss='+c.gauss,
+	            'msmooth='+c.smooth,'meta='+c.eta,'metadiff='+c.etadiff,'mdpdeta='+c.dpdeta]))
+	
+	f.write('\n/\n')
+	f.close()
+	return
+	
+             
+    def retrieve(self, server, dates,times, inputdir=''):
         self.dates=dates
         self.server=server
-        self.public=public
-
-        if inputdir=="":
-            self.inputdir='.'
-        else:
-            self.inputdir=inputdir
-
-            # Retrieve Q not for using Q but as a template for a reduced gaussian grid one date and time is enough
+
+	if inputdir=="":
+	    self.inputdir='.'
+	else:
+	    self.inputdir=inputdir
+
+	  # Retrieve Q not for using Q but as a template for a reduced gaussian grid one date and time is enough
 # Take analysis at 00
-#        qdate=self.dates
-#        idx=qdate.find("/")
-#        if (idx >0):
-#            qdate=self.dates[:idx]
-
-        #QG= MARSretrieval(self.server, self.public, dataset=self.dataset, marsclass=self.marsclass, stream=self.stream, type="an", levtype="ML", levelist="1",
-                            #gaussian="reduced",grid='{}'.format((int(self.resol)+1)/2), resol=self.resol,accuracy=self.accuracy,target=self.inputdir+"/"+"QG.grb",
-                            #date=qdate, time="00",expver=self.expver, param="133.128")
+        qdate=self.dates
+        idx=qdate.find("/")
+        if (idx >0):
+          qdate=self.dates[:idx]
+        
+        #QG= MARSretrieval(self.server, dataset=self.dataset, marsclass=self.marsclass, stream=self.stream, type="an", levtype="ML", levelist="1",
+                         #gaussian="reduced",grid='{}'.format((int(self.resol)+1)/2), resol=self.resol,accuracy=self.accuracy,target=self.inputdir+"/"+"QG.grb",
+                         #date=qdate, time="00",expver=self.expver, param="133.128")
         #QG.displayInfo()
         #QG.dataRetrieve()
 
-        oro=False
+	oro=False
         for ftype in self.types:
-            for pk,pv in self.params.iteritems():
-                if isinstance(pv,str):     # or pk!='GG__SL' :
-                    continue
-                mftype=''+ftype
-                mftime=self.types[ftype]['times']
-                mfstep=self.types[ftype]['steps']
-                mfdate=self.dates
-                mfstream=self.stream
-                mftarget=self.inputdir+"/"+ftype+pk+'.'+self.dates.split('/')[0]+'.'+str(os.getppid())+'.'+str(os.getpid())+".grb"
-
-                if pk=='OG__SL':
-                    pass
-                if pk=='OG_OROLSM__SL':
-                    if oro==False:
-                        # in CERA20C there is no stream "OPER"!
-                        if self.marsclass.upper() != 'EP':
-                            mfstream='OPER'
-                        mftype='AN'
-                        mftime='00'
-                        mfstep='000'
-                        mfdate=self.dates.split('/')[0]
-                        mftarget=self.inputdir+"/"+pk+'.'+mfdate+'.'+str(os.getppid())+'.'+str(os.getpid())+".grb"
-                        oro=True
-                    else:
-                        continue
-
-                if pk=='GG__SL' and pv[0]=='Q':
-                    area=""
-                    gaussian='reduced'
-                else:
-                    area=self.area
-                    gaussian=self.gaussian
-
-                if self.basetime==None:
-                    # increase number of mars requests
-                    self.mreq_count += 1
-                    MR= MARSretrieval(self.server, self.public, dataset=self.dataset, marsclass=self.marsclass, stream=mfstream,
-                                      type=mftype, levtype=pv[1], levelist=pv[2],resol=self.resol, gaussian=gaussian,
-                                  accuracy=self.accuracy,grid=pv[3],target=mftarget,area=area,
-                                  date=mfdate, time=mftime,number=self.number,step=mfstep, expver=self.expver, param=pv[0])
-
-                    if request == 0:
-                        MR.displayInfo()
-                        MR.dataRetrieve()
-                    elif request == 1:
-                        MR.print_infodata_csv(self.inputdir, self.mreq_count)
-                    elif request == 2:
-                        MR.print_infodata_csv(self.inputdir, self.mreq_count)
-                        MR.displayInfo()
-                        MR.dataRetrieve()
-# The whole else section is only necessary for operational scripts. It could be removed
-                else: # check if mars job requests fields beyond basetime. If yes eliminate those fields since they may not
-                        # be accessible with user's credentials
-                    sm1=-1
-                    if 'by' in mfstep:
-                        sm1=2
-                    tm1=-1
-                    if 'by' in mftime:
-                        tm1=2
-                    maxtime=datetime.datetime.strptime(mfdate.split('/')[-1]+mftime.split('/')[tm1],'%Y%m%d%H')+ \
-                        datetime.timedelta(hours=int(mfstep.split('/')[sm1]))
-
-                    elimit=datetime.datetime.strptime(mfdate.split('/')[-1]+self.basetime,'%Y%m%d%H')
-
-                    if self.basetime=='12':
-                        if 'acc' in pk:
-
-                    # Strategy: if maxtime-elimit>=24h reduce date by 1,
-                    # if 12h<=maxtime-elimit<12h reduce time for last date
-                    # if maxtime-elimit<12h reduce step for last time
-                    # A split of the MARS job into 2 is likely necessary.
-                            maxtime=elimit-datetime.timedelta(hours=24)
-                            mfdate='/'.join(('/'.join(mfdate.split('/')[:-1]),datetime.datetime.strftime(maxtime,'%Y%m%d')))
-                            # increase number of mars requests
-                            self.mreq_count += 1
-                            MR= MARSretrieval(self.server, self.public, dataset=self.dataset, marsclass=self.marsclass, stream=self.stream,
-                                              type=mftype, levtype=pv[1], levelist=pv[2],resol=self.resol, gaussian=gaussian,
-                                                accuracy=self.accuracy,grid=pv[3],target=mftarget,area=area,
-                                                date=mfdate, time=mftime,number=self.number,step=mfstep, expver=self.expver, param=pv[0])
-
-                            if request == 0:
-                                MR.displayInfo()
-                                MR.dataRetrieve()
-                            elif request == 1:
-                                MR.print_infodata_csv(self.inputdir, self.mreq_count)
-                            elif request == 2:
-                                MR.print_infodata_csv(self.inputdir, self.mreq_count)
-                                MR.displayInfo()
-                                MR.dataRetrieve()
-
-                            maxtime=elimit-datetime.timedelta(hours=12)
-                            mfdate=datetime.datetime.strftime(maxtime,'%Y%m%d')
-                            mftime='00'
-                            mftarget=self.inputdir+"/"+ftype+pk+'.'+mfdate+'.'+str(os.getppid())+'.'+str(os.getpid())+".grb"
-                            # increase number of mars requests
-                            self.mreq_count += 1
-                            MR= MARSretrieval(self.server, self.public, dataset=self.dataset, marsclass=self.marsclass, stream=self.stream,
-                                              type=mftype, levtype=pv[1], levelist=pv[2],resol=self.resol, gaussian=gaussian,
-                                                accuracy=self.accuracy,grid=pv[3],target=mftarget,area=area,
-                                                date=mfdate, time=mftime,number=self.number,step=mfstep, expver=self.expver, param=pv[0])
-                            if request == 0:
-                                MR.displayInfo()
-                                MR.dataRetrieve()
-                            elif request == 1:
-                                MR.print_infodata_csv(self.inputdir, self.mreq_count)
-                            elif request == 2:
-                                MR.print_infodata_csv(self.inputdir, self.mreq_count)
-                                MR.displayInfo()
-                                MR.dataRetrieve()
-                        else:
-                            # increase number of mars requests
-                            self.mreq_count += 1
-                            MR= MARSretrieval(self.server, self.public, dataset=self.dataset, marsclass=self.marsclass, stream=self.stream,
-                                              type=mftype, levtype=pv[1], levelist=pv[2],resol=self.resol, gaussian=gaussian,
-                                                accuracy=self.accuracy,grid=pv[3],target=mftarget,area=area,
-                                                date=mfdate, time=mftime,number=self.number,step=mfstep, expver=self.expver, param=pv[0])
-
-                            if request == 0:
-                                MR.displayInfo()
-                                MR.dataRetrieve()
-                            elif request == 1:
-                                MR.print_infodata_csv(self.inputdir, self.mreq_count)
-                            elif request == 2:
-                                MR.print_infodata_csv(self.inputdir, self.mreq_count)
-                                MR.displayInfo()
-                                MR.dataRetrieve()
-                    else:
-                        maxtime=elimit-datetime.timedelta(hours=24)
-                        mfdate=datetime.datetime.strftime(maxtime,'%Y%m%d')
-
-                        mftimesave=''.join(mftime)
-
-                        if pk=='OG_OROLSM__SL':
-                            mfdate=self.dates.split('/')[0]
-                            mftarget=self.inputdir+"/"+pk+'.'+mfdate+'.'+str(os.getppid())+'.'+str(os.getpid())+".grb"
-
-                        if '/' in mftime:
-                            times=mftime.split('/')
-                            while int(times[0])+int(mfstep.split('/')[0])<=12 and pk!='OG_OROLSM__SL' and 'acc' not in pk:
-                                times=times[1:]
-                                if len(times)>1:
-                                    mftime='/'.join(times)
-                                else:
-                                    mftime=times[0]
-
-                        if int(mftimesave.split('/')[0])==0 and int(mfstep.split('/')[0])==0 and pk!='OG_OROLSM__SL':
-                            mfdate=datetime.datetime.strftime(elimit,'%Y%m%d')
-                            mftime='00'
-                            mfstep='000'
-                            mftarget=self.inputdir+"/"+ftype+pk+'.'+mfdate+'.'+str(os.getppid())+'.'+str(os.getpid())+".grb"
-
-                        # increase number of mars requests
-                        self.mreq_count += 1
-                        MR= MARSretrieval(self.server, self.public, dataset=self.dataset, marsclass=self.marsclass, stream=self.stream,
-                                          type=mftype, levtype=pv[1], levelist=pv[2],resol=self.resol, gaussian=gaussian,
-                                      accuracy=self.accuracy,grid=pv[3],target=mftarget,area=area,
-                                      date=mfdate, time=mftime,number=self.number,step=mfstep, expver=self.expver, param=pv[0])
-
-                        if request == 0:
-                            MR.displayInfo()
-                            MR.dataRetrieve()
-                        elif request == 1:
-                            MR.print_infodata_csv(self.inputdir, self.mreq_count)
-                        elif request == 2:
-                            MR.print_infodata_csv(self.inputdir, self.mreq_count)
-                            MR.displayInfo()
-                            MR.dataRetrieve()
-
-
-        if request == 0 or request == 2:
-            print('MARS retrieve done ... ')
-        elif request == 1:
-            print('MARS request printed ...')
-
+	    for pk,pv in self.params.iteritems():
+		if isinstance(pv,str):     # or pk!='GG__SL' :
+		    continue
+		mftype=''+ftype
+		mftime=self.types[ftype]['times']
+		mfstep=self.types[ftype]['steps']
+		mfdate=self.dates
+		mfstream=self.stream
+		mftarget=self.inputdir+"/"+ftype+pk+'.'+self.dates.split('/')[0]+'.'+str(os.getppid())+'.'+str(os.getpid())+".grb"
+		if pk=='OG__SL':
+		    pass
+		if pk=='OG_OROLSM__SL':
+		    if oro==False:
+			mfstream='OPER'
+			mftype='AN'
+			mftime='00'
+			mfstep='000'
+			mfdate=self.dates.split('/')[0]
+			mftarget=self.inputdir+"/"+pk+'.'+mfdate+'.'+str(os.getppid())+'.'+str(os.getpid())+".grb"
+			oro=True
+		    else:
+			continue
+		
+	        if pk=='GG__SL' and pv[0]=='Q':
+		    area=""
+		    gaussian='reduced'
+		else:
+		    area=self.area
+		    gaussian=self.gaussian
+
+		if self.basetime==None:
+		    MR= MARSretrieval(self.server, dataset=self.dataset, marsclass=self.marsclass, stream=mfstream, 
+		                  type=mftype, levtype=pv[1], levelist=pv[2],resol=self.resol, gaussian=gaussian,
+		                  accuracy=self.accuracy,grid=pv[3],target=mftarget,area=area, 
+		                  date=mfdate, time=mftime,number=self.number,step=mfstep, expver=self.expver, param=pv[0])
+		
+		    MR.displayInfo()
+		    MR.dataRetrieve()
+# The whole else section is only necessary for operational scripts. It could be removed 
+		else: # check if mars job requests fields beyond basetime. If yes eliminate those fields since they may not
+		      # be accessible with user's credentials
+		    sm1=-1
+		    if 'by' in mfstep:
+			sm1=2
+		    tm1=-1
+		    if 'by' in mftime:
+			tm1=2
+		    maxtime=datetime.datetime.strptime(mfdate.split('/')[-1]+mftime.split('/')[tm1],'%Y%m%d%H')+ \
+		    datetime.timedelta(hours=int(mfstep.split('/')[sm1]))
+		    
+		    elimit=datetime.datetime.strptime(mfdate.split('/')[-1]+self.basetime,'%Y%m%d%H')
+
+		    if self.basetime=='12':
+			if 'acc' in pk:
+
+		    # Strategy: if maxtime-elimit>=24h reduce date by 1, 
+		    # if 12h<=maxtime-elimit<12h reduce time for last date
+		    # if maxtime-elimit<12h reduce step for last time
+		    # A split of the MARS job into 2 is likely necessary.
+			    maxtime=elimit-datetime.timedelta(hours=24)
+			    mfdate='/'.join(('/'.join(mfdate.split('/')[:-1]),datetime.datetime.strftime(maxtime,'%Y%m%d')))
+		    
+			    MR= MARSretrieval(self.server, dataset=self.dataset, marsclass=self.marsclass, stream=self.stream, 
+			                        type=mftype, levtype=pv[1], levelist=pv[2],resol=self.resol, gaussian=gaussian,
+			                        accuracy=self.accuracy,grid=pv[3],target=mftarget,area=area, 
+			                        date=mfdate, time=mftime,number=self.number,step=mfstep, expver=self.expver, param=pv[0])
+		
+			    MR.displayInfo()
+			    MR.dataRetrieve()
+		    
+			    maxtime=elimit-datetime.timedelta(hours=12)
+			    mfdate=datetime.datetime.strftime(maxtime,'%Y%m%d')
+			    mftime='00'
+			    mftarget=self.inputdir+"/"+ftype+pk+'.'+mfdate+'.'+str(os.getppid())+'.'+str(os.getpid())+".grb"
+
+			    MR= MARSretrieval(self.server, dataset=self.dataset, marsclass=self.marsclass, stream=self.stream, 
+			                        type=mftype, levtype=pv[1], levelist=pv[2],resol=self.resol, gaussian=gaussian,
+			                        accuracy=self.accuracy,grid=pv[3],target=mftarget,area=area, 
+			                        date=mfdate, time=mftime,number=self.number,step=mfstep, expver=self.expver, param=pv[0])
+		
+			    MR.displayInfo()
+			    MR.dataRetrieve()
+			else:
+			    MR= MARSretrieval(self.server, dataset=self.dataset, marsclass=self.marsclass, stream=self.stream, 
+			                        type=mftype, levtype=pv[1], levelist=pv[2],resol=self.resol, gaussian=gaussian,
+			                        accuracy=self.accuracy,grid=pv[3],target=mftarget,area=area, 
+			                        date=mfdate, time=mftime,number=self.number,step=mfstep, expver=self.expver, param=pv[0])
+		
+			    MR.displayInfo()
+			    MR.dataRetrieve()
+		    else:
+			maxtime=elimit-datetime.timedelta(hours=24)
+			mfdate=datetime.datetime.strftime(maxtime,'%Y%m%d')
+			
+			mftimesave=''.join(mftime)
+			
+			if '/' in mftime:
+			    times=mftime.split('/')
+			    while int(times[0])+int(mfstep.split('/')[0])<=12 and pk!='OG_OROLSM__SL' and 'acc' not in pk:
+				times=times[1:]
+				if len(times)>1:
+				    mftime='/'.join(times)
+				else:
+				    mftime=times[0]
+			    
+			MR= MARSretrieval(self.server, dataset=self.dataset, marsclass=self.marsclass, stream=self.stream, 
+		                      type=mftype, levtype=pv[1], levelist=pv[2],resol=self.resol, gaussian=gaussian,
+		                      accuracy=self.accuracy,grid=pv[3],target=mftarget,area=area, 
+		                      date=mfdate, time=mftime,number=self.number,step=mfstep, expver=self.expver, param=pv[0])
+		    
+			MR.displayInfo()
+			MR.dataRetrieve()
+			
+			if int(mftimesave.split('/')[0])==0 and int(mfstep.split('/')[0])==0 and pk!='OG_OROLSM__SL':
+			    mfdate=datetime.datetime.strftime(elimit,'%Y%m%d')
+			    mftime='00'
+			    mfstep='000'
+			    mftarget=self.inputdir+"/"+ftype+pk+'.'+mfdate+'.'+str(os.getppid())+'.'+str(os.getpid())+".grb"
+		    
+			    MR= MARSretrieval(self.server, dataset=self.dataset, marsclass=self.marsclass, stream=self.stream, 
+			                  type=mftype, levtype=pv[1], levelist=pv[2],resol=self.resol, gaussian=gaussian,
+			                  accuracy=self.accuracy,grid=pv[3],target=mftarget,area=area, 
+			                  date=mfdate, time=mftime,number=self.number,step=mfstep, expver=self.expver, param=pv[0])
+			
+			    MR.displayInfo()
+			    MR.dataRetrieve()
+							
+		    
+		    
+        print "MARS retrieve done... "
+        
     def getFlexpartTime(self, type,step, time):
-        cstep='{:0>3}'.format(step)
-        ctime='{:0>2}'.format(int(time/100))
+	cstep='{:0>3}'.format(step)
+	ctime='{:0>2}'.format(int(time/100))
 
         ctype = str(type).upper()
-        myinfo = [ctype,ctime, cstep]
+	myinfo = [ctype,ctime, cstep]
         cflextime = None
         for t, marsinfo in self.mars.items():
@@ -1212,107 +981,90 @@
 
     def process_output(self, c):
-
-        print 'Postprocessing:\n Format: {}\n'.format(c.format)
-        if c.ecapi==False:
-            print 'ecstorage: {}\n ecfsdir: {}\n'.format(c.ecstorage,c.ecfsdir)
-            if not hasattr(c,'gateway'):
-                c.gateway=os.getenv('GATEWAY')
-            if not hasattr(c,'destination'):
-                c.destination=os.getenv('DESTINATION')
-            print 'ectrans: {}\n gateway: {}\n destination: {}\n '.format(c.ectrans, c.gateway,c.destination)
-        print 'Output filelist: \n',self.outputfilelist
-
-        if c.format.lower()=='grib2':
-            for ofile in self.outputfilelist:
-                p=subprocess.check_call(['grib_set','-s','edition=2,productDefinitionTemplateNumber=8',ofile,ofile+'_2'])
-                p=subprocess.check_call(['mv',ofile+'_2',ofile])
-        if c.debug==0:
-            inputfiles=glob.glob('*.grb')
-            for grb in inputfiles:
-                try:
-                    os.remove(grb)
-                except:
-                    pass
-        if c.stream=='ELDA':
-            opposite(self.inputdir+'/'+c.prefix)
-            for i in range(len(self.outputfilelist)):
-                if self.outputfilelist[i][-4:]!='N000' :
-                    j=int(self.outputfilelist[i][-3:])
-                    self.outputfilelist.append(self.outputfilelist[i][:-3]+'{:0>3}'.format(j+25))
-
-        if int(c.ectrans)==1 and c.ecapi==False:
-            for ofile in self.outputfilelist:
-                p=subprocess.check_call(['ectrans','-overwrite','-gateway',c.gateway,
-                                         '-remote',c.destination,'-source',ofile])
-                print 'ectrans:',p
-        if int(c.ecstorage)==1 and c.ecapi==False:
-            for ofile in self.outputfilelist:
-                p=subprocess.check_call(['ecp','-o',ofile,os.path.expandvars(c.ecfsdir)])
+	
+	print 'Postprocessing:\n Format: {}\n'.format(c.format)
+	if c.ecapi==False:
+	    print 'ecstorage: {}\n ecfsdir: {}\n'.format(c.ecstorage,c.ecfsdir)
+	    if not hasattr(c,'gateway'):
+		c.gateway=os.getenv('GATEWAY')
+	    if not hasattr(c,'destination'):
+		c.destination=os.getenv('DESTINATION')
+	    print 'ectrans: {}\n gateway: {}\n destination: {}\n '.format(c.ectrans, c.gateway,c.destination)
+	print 'Output filelist: \n',self.outputfilelist
+	
+	if c.format.lower()=='grib2':
+	    for ofile in self.outputfilelist:
+		p=subprocess.check_call(['grib_set','-s','edition=2,productDefinitionTemplateNumber=8',ofile,ofile+'_2'])
+		p=subprocess.check_call(['mv',ofile+'_2',ofile])
+	
+	if int(c.ectrans)==1 and c.ecapi==False:
+	    for ofile in self.outputfilelist:
+		p=subprocess.check_call(['ectrans','-overwrite','-gateway',c.gateway,
+		                         '-remote',c.destination,'-source',ofile])
+		print 'ectrans:',p
+	if int(c.ecstorage)==1 and c.ecapi==False:
+	    for ofile in self.outputfilelist:
+		p=subprocess.check_call(['ecp','-o',ofile,os.path.expandvars(c.ecfsdir)])
 
 #20131107 000000      EN13110700              ON DISC
-        if c.outputdir!=c.inputdir:
-            for ofile in self.outputfilelist:
-                p=subprocess.check_call(['mv',ofile,c.outputdir])
-
-        if c.grib2flexpart=='1':
-            f=open(c.outputdir+'/'+'AVAILABLE','w')
-            clist=[]
-            for ofile in self.outputfilelist: # generate AVAILABLE file
-                fname=ofile.split('/')
-                if '.' in fname[-1]:
-                    l=fname[-1].split('.')
-                    timestamp=datetime.datetime.strptime(l[0][-6:]+l[1],'%y%m%d%H')
-                    timestamp+=datetime.timedelta(hours=int(l[2]))
-                    cdate=datetime.datetime.strftime(timestamp,'%Y%m%d')
-                    chms=datetime.datetime.strftime(timestamp,'%H%M%S')
-
-                else:
-                    cdate='20'+fname[-1][-8:-2]
-                    chms=fname[-1][-2:]+'0000'
-                clist.append(cdate+' '+chms+' '*6+fname[-1]+' '*14+'ON DISC')
-            clist.sort()
-            f.write('\n'.join(clist)+'\n')
-            f.close()
-
-            pwd=os.path.abspath(c.outputdir)
-            f=open(pwd+'/pathnames','w')
-            f.write(pwd+'/Options/\n')
-            f.write(pwd+'/\n')
-            f.write(pwd+'/\n')
-            f.write(pwd+'/AVAILABLE\n')
-            f.write('==================\n')
-            f.close()
-
-            if not os.path.exists(pwd+'/Options'):
-                os.makedirs(pwd+'/Options')
-            f=open(os.path.expandvars(os.path.expanduser(c.flexpart_root_scripts))+'/../Options/COMMAND','r')
-            lflist=f.read().split('\n')
-            i=0
-            for l in lflist:
-                if 'LDIRECT' in l.upper():
-                    break
-                i+=1
-
-            clist.sort()
-            lflist=lflist[:i+1]+[clist[0][:16],clist[-1][:16]]+lflist[i+3:]
-            g=open(pwd+'/Options/COMMAND','w')
-            g.write('\n'.join(lflist)+'\n')
-            g.close()
-
-            os.chdir(c.outputdir)
-            p=subprocess.check_call([os.path.expandvars(os.path.expanduser(c.flexpart_root_scripts))+'/../FLEXPART_PROGRAM/grib2flexpart',
-                                     'useAvailable','.'])
-            os.chdir(pwd)
-
+	if c.outputdir!=c.inputdir:
+	    for ofile in self.outputfilelist:
+		p=subprocess.check_call(['mv',ofile,c.outputdir])
+	    
+	if c.grib2flexpart=='1':
+	    f=open(c.outputdir+'/'+'AVAILABLE','w')
+	    clist=[]
+	    for ofile in self.outputfilelist: # generate AVAILABLE file
+		fname=ofile.split('/')
+		if '.' in fname[-1]:
+		    l=fname[-1].split('.')
+		    timestamp=datetime.datetime.strptime(l[0][-6:]+l[1],'%y%m%d%H')
+		    timestamp+=datetime.timedelta(hours=int(l[2]))
+		    cdate=datetime.datetime.strftime(timestamp,'%Y%m%d')
+		    chms=datetime.datetime.strftime(timestamp,'%H%M%S')
+		    
+		else:
+		    cdate='20'+fname[-1][-8:-2]
+		    chms=fname[-1][-2:]+'0000'
+		clist.append(cdate+' '+chms+' '*6+fname[-1]+' '*14+'ON DISC')
+	    clist.sort()
+	    f.write('\n'.join(clist)+'\n')
+	    f.close()
+	    
+	    pwd=os.path.abspath(c.outputdir)
+	    f=open(pwd+'/pathnames','w')
+	    f.write(pwd+'/Options/\n')
+	    f.write(pwd+'/\n')
+	    f.write(pwd+'/\n')
+	    f.write(pwd+'/AVAILABLE\n')
+	    f.write('==================\n')
+	    f.close()
+	    
+	    if not os.path.exists(pwd+'/Options'):
+		os.makedirs(pwd+'/Options')
+	    f=open(os.path.expandvars(os.path.expanduser(c.flexpart_root_scripts))+'/../Options/COMMAND','r')
+	    lflist=f.read().split('\n')
+	    i=0
+	    for l in lflist:
+		if 'LDIRECT' in l.upper():
+		    break
+		i+=1
+		
+	    clist.sort()
+	    lflist=lflist[:i+1]+[clist[0][:16],clist[-1][:16]]+lflist[i+3:]
+	    g=open(pwd+'/Options/COMMAND','w')
+	    g.write('\n'.join(lflist)+'\n')
+	    g.close()
+	    
+	    os.chdir(c.outputdir)
+	    p=subprocess.check_call([os.path.expandvars(os.path.expanduser(c.flexpart_root_scripts))+'/../FLEXPART_PROGRAM/grib2flexpart',
+	                             'useAvailable','.'])
+	    os.chdir(pwd)
+	    
     def create(self, inputfiles, c,):
-
-        table128=init128(c.flexextractdir+'/grib_templates/ecmwf_grib1_table_128')
-        wrfpars=toparamId('sp/mslp/skt/2t/10u/10v/2d/z/lsm/sst/ci/sd/stl1/stl2/stl3/stl4/swvl1/swvl2/swvl3/swvl4',table128)
+	
+	table128=init128(c.ecmwfdatadir+'/grib_templates/ecmwf_grib1_table_128')
+	wrfpars=toparamId('sp/mslp/skt/2t/10u/10v/2d/z/lsm/sst/ci/sd/stl1/stl2/stl3/stl4/swvl1/swvl2/swvl3/swvl4',table128)
 #        index_keys=["date","time","stepRange"]
-        if '/' in c.number:
-            index_keys=["number","date","time","step"]
-        else:
-            index_keys=["date","time","step"]
-
+	index_keys=["date","time","step"]
         indexfile=c.inputdir+"/date_time_stepRange.idx"
         silentremove(indexfile)
@@ -1320,13 +1072,13 @@
         iid=grib.index(index_keys=index_keys, index_file = indexfile)
 
-        print 'index done...'
-        fdict={'10':None,'11':None,'12':None,'13':None,'16':None,'17':None,'19':None,'21':None,'22':None,'20':None}
-        for f in fdict.keys():
-            silentremove(c.inputdir+"/fort."+f)
+        print 'index done...' 
+	fdict={'10':None,'11':None,'12':None,'13':None,'16':None,'17':None,'19':None,'21':None,'22':None,'20':None}
+	for f in fdict.keys():
+	    silentremove(c.inputdir+"/fort."+f)
 
         index_vals = []
         for key in index_keys:
             key_vals = grib_index_get(iid,key)
-            print key_vals
+	    print key_vals
 
             index_vals.append(key_vals)
@@ -1336,188 +1088,171 @@
                 grib_index_select(iid,index_keys[i],prod[i])
 
-
-            gid = grib_new_from_index(iid)
-            hid = gid
-            cflextime = None
-            for k,f in fdict.iteritems():
-                fdict[k] = open(c.inputdir+'/fort.'+k,'w')
-            if gid is not None:
-                cdate = str(grib_get(gid, 'date'))
-                time = grib_get(gid, 'time')
-                type = grib_get(gid, 'type')
-                step = grib_get(gid, 'step')
+	    	    
+	    gid = grib_new_from_index(iid)
+	    hid = gid
+	    cflextime = None
+	    for k,f in fdict.iteritems():
+		fdict[k] = open(c.inputdir+'/fort.'+k,'w')
+	    if gid is not None: 
+		cdate = str(grib_get(gid, 'date'))
+		time = grib_get(gid, 'time')
+		type = grib_get(gid, 'type')
+		step = grib_get(gid, 'step')
 #                step = grib_get(gid, 'stepRange')
 #		cflextime = self.getFlexpartTime(type,step, time)
-                timestamp=datetime.datetime.strptime(cdate+'{:0>2}'.format(time/100),'%Y%m%d%H')
-                timestamp+=datetime.timedelta(hours=int(step))
+		timestamp=datetime.datetime.strptime(cdate+'{:0>2}'.format(time/100),'%Y%m%d%H')
+		timestamp+=datetime.timedelta(hours=int(step))
 #		print gid,index_keys[i],prod[i],cdate,time,step,timestamp
-
+		
                 cdateH=datetime.datetime.strftime(timestamp,'%Y%m%d%H')
                 chms=datetime.datetime.strftime(timestamp,'%H%M%S')
 
-                if c.basetime !=None:
-                    slimit=datetime.datetime.strptime(c.start_date+'00','%Y%m%d%H')
-                    bt='23'
-                    if c.basetime=='00':
-                        bt='00'
-                        slimit=datetime.datetime.strptime(c.end_date+bt,'%Y%m%d%H')-datetime.timedelta(hours=12-int(c.dtime))
-
-                    if c.basetime=='12':
-                        bt='12'
-                        slimit=datetime.datetime.strptime(c.end_date+bt,'%Y%m%d%H')-datetime.timedelta(hours=12-int(c.dtime))
-
-                    elimit=datetime.datetime.strptime(c.end_date+bt,'%Y%m%d%H')
-
-                    if timestamp<slimit or timestamp>elimit:
-                        continue
-                else:
-                    if c.maxstep<24:
-                        if cdateH<c.start_date+'00':
-                            continue
-                        if cdateH>c.end_date+'23':
-                            continue
-
-
-
-            try:
-                if c.wrf=='1':
-                    if 'olddate' not in locals():
-                        fwrf = open(c.outputdir+'/WRF'+cdate+'.{:0>2}'.format(time)+'.000.grb2','w')
-                        olddate=cdate[:]
-                    else:
-                        if cdate!=olddate:
-                            fwrf = open(c.outputdir+'/WRF'+cdate+'.{:0>2}'.format(time)+'.000.grb2','w')
-                            olddate=cdate[:]
-            except AttributeError:
-                pass
-
+		if c.basetime !=None:
+		    slimit=datetime.datetime.strptime(c.start_date+'00','%Y%m%d%H')
+		    bt='23'
+		    if c.basetime=='00':
+			bt='00'
+			slimit=datetime.datetime.strptime(c.end_date+bt,'%Y%m%d%H')-datetime.timedelta(hours=12-int(c.dtime))
+			
+		    if c.basetime=='12':
+			bt='12'
+			slimit=datetime.datetime.strptime(c.end_date+bt,'%Y%m%d%H')-datetime.timedelta(hours=12-int(c.dtime))
+			
+		    elimit=datetime.datetime.strptime(c.end_date+bt,'%Y%m%d%H')
+		    
+		    if timestamp<slimit or timestamp>elimit:
+			continue
+		    
+		    
+	    
+	    try:
+		if c.wrf=='1':
+		    if 'olddate' not in locals():
+			fwrf = open(c.outputdir+'/WRF'+cdate+'.{:0>2}'.format(time)+'.000.grb2','w')
+			olddate=cdate[:]
+		    else:
+			if cdate!=olddate:
+			    fwrf = open(c.outputdir+'/WRF'+cdate+'.{:0>2}'.format(time)+'.000.grb2','w')
+			    olddate=cdate[:]
+	    except AttributeError:
+		pass
+			
 #                print 'cyear '+cyear+'/'+cmonth+'/'+'/EI'+cyear[2:4]+cmonth+cday+cflextime
 
             savedfields=[]
-            while 1:
-                if gid is None: break
-                paramId = grib_get(gid, 'paramId')
-                gridtype = grib_get(gid, 'gridType')
-                datatype = grib_get(gid, 'dataType')
-                levtype = grib_get(gid, 'typeOfLevel')
-                if paramId == 133 and gridtype=='reduced_gg':
+	    while 1: 
+		if gid is None: break
+		paramId = grib_get(gid, 'paramId')
+		gridtype = grib_get(gid, 'gridType')
+		datatype = grib_get(gid, 'dataType')
+		levtype = grib_get(gid, 'typeOfLevel')
+		if paramId == 133 and gridtype=='reduced_gg':
 # Relative humidity (Q.grb) is used as a template only so we need the first we "meet"
-                    fout=open(c.inputdir+'/fort.18','w')
-                    grib_write(gid,fout)
-                    fout.close()
-                elif paramId == 131 or paramId == 132:
-                    grib_write(gid, fdict['10'])
-                elif paramId == 130:
-                    grib_write(gid, fdict['11'])
-                elif paramId == 133 and gridtype!='reduced_gg':
-                    grib_write(gid, fdict['17'])
-                elif paramId == 152:
-                    grib_write(gid, fdict['12'])
-                elif paramId == 155 and gridtype=='sh':
-                    grib_write(gid, fdict['13'])
-                elif paramId in [129,138,155] and levtype=='hybrid' and c.wrf=='1':
+		    fout=open(c.inputdir+'/fort.18','w')
+		    grib_write(gid,fout)
+		    fout.close()
+		elif paramId == 131 or paramId == 132:
+		    grib_write(gid, fdict['10'])
+		elif paramId == 130:
+		    grib_write(gid, fdict['11'])
+		elif paramId == 133 and gridtype!='reduced_gg':
+		    grib_write(gid, fdict['17'])
+		elif paramId == 152:
+		    grib_write(gid, fdict['12'])
+		elif paramId == 155 and gridtype=='sh':
+		    grib_write(gid, fdict['13'])
+		elif paramId in [129,138,155] and levtype=='hybrid' and c.wrf=='1':
 #		    print paramId,'not written'
-                    pass
-                elif paramId == 246 or paramId == 247:  # cloud liquid water and ice
-                    if paramId==246:
-                        clwc=grib_get_values(gid)
-                    else:
-                        clwc+=grib_get_values(gid)
-                        grib_set_values(gid,clwc)
+		    pass
+		elif paramId == 246 or paramId == 247:  # cloud liquid water and ice
+		    if paramId==246:
+			clwc=grib_get_values(gid)
+		    else:
+			clwc+=grib_get_values(gid)
+			grib_set_values(gid,clwc)
 #			grib_set(gid,'shortName','qc')
-                        grib_set(gid,'paramId',201031)
-                        grib_write(gid, fdict['22'])
-
-                elif paramId == 135:
-                    grib_write(gid, fdict['19'])
-                elif paramId == 77:
-                    grib_write(gid, fdict['21'])
-                else:
-                    if paramId not in savedfields:
-                        grib_write(gid, fdict['16'])
-                        savedfields.append(paramId)
-                    else:
-                        print 'duplicate '+str(paramId)+' not written'
-
-                try:
-                    if c.wrf=='1':
-                        if levtype=='hybrid':
-                            if paramId in [129,130,131,132,133,138,155]:
-                                grib_write(gid,fwrf)
-                        else:
-                            if paramId in wrfpars:
-                                grib_write(gid,fwrf)
-                except AttributeError:
-                    pass
-
-
-
-                grib_release(gid)
-                gid = grib_new_from_index(iid)
+			grib_set(gid,'paramId',201031)
+			grib_write(gid, fdict['22'])
+		    
+		elif paramId == 135:
+		    grib_write(gid, fdict['19'])
+		elif paramId == 77:
+		    grib_write(gid, fdict['21'])
+		else:
+		    if paramId not in savedfields:
+			grib_write(gid, fdict['16'])
+			savedfields.append(paramId)
+		    else:
+			print 'duplicate '+str(paramId)+' not written'
+		
+		try:
+		    if c.wrf=='1':
+			if levtype=='hybrid':
+			    if paramId in [129,130,131,132,133,138,155]:
+				grib_write(gid,fwrf)
+			else:
+			    if paramId in wrfpars:
+				grib_write(gid,fwrf)
+		except AttributeError:
+		    pass
+			    
+			    
+		
+		grib_release(gid)
+		gid = grib_new_from_index(iid)
 # call for CONVERT2
-
-            for f in fdict.values():
-                f.close()
-
-            if hid is not None:
-                pwd=os.getcwd()
-                os.chdir(c.inputdir)
-                if os.stat('fort.21').st_size==0 and int(c.eta)==1:
-                    print 'Parameter 77 (etadot) is missing, most likely it is not available for this type or date/time\n'
-                    print 'Check parameters CLASS, TYPE, STREAM, START_DATE\n'
-                    myerror(c,'fort.21 is empty while parameter eta is set to 1 in CONTROL file')
-
+	    
+	    for f in fdict.values():
+		f.close()
+
+	    if hid is not None:
+		pwd=os.getcwd()
+		os.chdir(c.inputdir)
+	        if os.stat('fort.21').st_size==0 and int(c.eta)==1:
+		    print 'Parameter 77 (etadot) is missing, most likely it is not available for this type or date/time\n'
+		    print 'Check parameters CLASS, TYPE, STREAM, START_DATE\n'		    
+		    myerror(c,'fort.21 is empty while parameter eta is set to 1 in CONTROL file')
+		
                 p=subprocess.check_call([os.path.expandvars(os.path.expanduser(c.exedir))+'/CONVERT2'],shell=True)
-                os.chdir(pwd)
-# create the corresponding output file  fort.15 (generated by CONVERT2) + fort.16 (paramId 167 and paramId 168)
-                fnout=c.inputdir+'/'+c.prefix
-                if c.maxstep>12:
-                    suffix=cdate[2:8]+'.{:0>2}'.format(time/100)+'.{:0>3}'.format(step)
-                else:
-                    suffix=cdateH[2:10]
-                try:
-                    numberindex=index_keys.index('number')
-                    if len(index_vals[numberindex])>1:
-                        suffix=suffix+'.N{:0>3}'.format(int(prod[numberindex]))
-                except:
-                    pass
-
-                fnout+=suffix
-                print "outputfile = " + fnout
-                self.outputfilelist.append(fnout) # needed for final processing
-                fout = open(fnout,'wb')
-                shutil.copyfileobj(open(c.inputdir+'/fort.15','rb'), fout)
-                if c.cwc=='1':
-                    shutil.copyfileobj(open(c.inputdir+'/fort.22','rb'), fout)
-                shutil.copyfileobj(open(c.inputdir+'/flux'+cdate[0:2]+suffix,'rb'), fout)
-                shutil.copyfileobj(open(c.inputdir+'/fort.16','rb'), fout)
-                orolsm=glob.glob(c.inputdir+'/OG_OROLSM__SL.*.'+c.ppid+'*')[0]
-                shutil.copyfileobj(open(orolsm,'rb'), fout)
-                fout.close()
-                if c.omega=='1':
-                    fnout=c.outputdir+'/OMEGA'+suffix
-                    fout = open(fnout,'wb')
-                    shutil.copyfileobj(open(c.inputdir+'/fort.25','rb'), fout)
-
-
-
-        try:
-            if c.wrf=='1':
-                fwrf.close()
-        except:
-            pass
+		os.chdir(pwd)
+# create the corresponding output file  fort.15 (generated by CONVERT2) + fort.16 (paramId 167 and paramId 168)  
+		fnout=c.inputdir+'/'+c.prefix
+		if c.maxstep>12:
+		    suffix=cdate[2:8]+'.{:0>2}'.format(time/100)+'.{:0>3}'.format(step)
+		else:
+		    suffix=cdateH[2:10]
+		    
+		fnout+=suffix
+		print "outputfile = " + fnout
+		self.outputfilelist.append(fnout) # needed for final processing
+		fout = open(fnout,'wb')    
+		shutil.copyfileobj(open(c.inputdir+'/fort.15','rb'), fout)     
+		if c.cwc=='1':
+		    shutil.copyfileobj(open(c.inputdir+'/fort.22','rb'), fout)     
+		shutil.copyfileobj(open(c.inputdir+'/flux'+cdate[0:2]+suffix,'rb'), fout)     
+		shutil.copyfileobj(open(c.inputdir+'/fort.16','rb'), fout)
+		orolsm=glob.glob(c.inputdir+'/OG_OROLSM__SL.*.'+c.ppid+'*')[0]
+		shutil.copyfileobj(open(orolsm,'rb'), fout)
+		fout.close()
+		if c.omega=='1':
+		    fnout=c.outputdir+'/OMEGA'
+		    fout = open(fnout,'wb')    
+		    shutil.copyfileobj(open(c.inputdir+'/fort.25','rb'), fout)    
+		    
+		
+		    
+	try:	
+	    if c.wrf=='1':
+		fwrf.close()
+	except:
+	    pass
 
         grib_index_release(iid)
 
-        return
-
     def deacc_fluxes(self, inputfiles, c):
-
-        table128=init128(c.flexextractdir+'/grib_templates/ecmwf_grib1_table_128')
-        pars=toparamId(self.params['OG_acc_SL'][0],table128)
-        if '/' in c.number:
-            index_keys=["number","date","time","step"]
-        else:
-            index_keys=["date","time","step"]
+	
+	table128=init128(c.ecmwfdatadir+'/grib_templates/ecmwf_grib1_table_128')
+	pars=toparamId(self.params['OG_acc_SL'][0],table128)
+	index_keys=["date","time","step"]
         indexfile=c.inputdir+"/date_time_stepRange.idx"
         silentremove(indexfile)
@@ -1525,39 +1260,40 @@
         iid=grib.index(index_keys=index_keys, index_file = indexfile)
 
-        print 'index done...'
+        print 'index done...' 
 
         index_vals = []
         for key in index_keys:
             key_vals = grib_index_get(iid,key)
-            print(key_vals)
-            l=[]
-            for k in key_vals:
-                l.append(int(k))
-            l.sort()
-            key_vals=[]
-            for k in l:
-                key_vals.append(str(k))
-            print key_vals
+	    print key_vals
+	    if key=='step':
+		l=[]
+		for k in key_vals:
+		    l.append(int(k))
+		l.sort()
+		key_vals=[]
+		for k in l:
+		    key_vals.append(str(k))
+
             index_vals.append(key_vals)
 
 
-        valsdict={}
-        svalsdict={}
-        stepsdict={}
-        for p in pars:
-            valsdict[str(p)]=[]
-            svalsdict[str(p)]=[]
-            stepsdict[str(p)]=[]
-
+	valsdict={}
+	svalsdict={}
+	stepsdict={}
+	for p in pars:
+	    valsdict[str(p)]=[]
+	    svalsdict[str(p)]=[]
+	    stepsdict[str(p)]=[]
+	    
         for prod in product(*index_vals):
             for i in range(len(index_keys)):
                 grib_index_select(iid,index_keys[i],prod[i])
 
-            #for k,f in fdict.iteritems():
-                #fdict[k] = open('fort.'+k,'w')
+	    #for k,f in fdict.iteritems():
+		#fdict[k] = open('fort.'+k,'w')
             gid = grib_new_from_index(iid)
             hid = gid
             cflextime = None
-            if gid is not None:
+            if gid is not None: 
                 cdate = grib_get(gid, 'date')
                 #cyear = cdate[:4]
@@ -1567,130 +1303,123 @@
                 type = grib_get(gid, 'type')
                 step = grib_get(gid, 'step')
-                # date+time+step-2*dtime (since interpolated value valid for step-2*dtime)
-                sdate=datetime.datetime(year=cdate/10000,month=mod(cdate,10000)/100,
-                                        day=mod(cdate,100),hour=time/100)
-                fdate=sdate+datetime.timedelta(hours=step-2*int(c.dtime))
-                sdates=sdate+datetime.timedelta(hours=step)
-            else:
-                break
-
-            fnout=c.inputdir+'/'
-            numbersuffix=''
-            try:
-                numberindex=index_keys.index('number')
-                if len(index_vals[numberindex])>1:
-                    numbersuffix='.N{:0>3}'.format(int(prod[numberindex]))
-            except:
-                pass
-
-            if c.maxstep>12:
-                fnout+='flux'+sdate.strftime('%Y%m%d')+'.{:0>2}'.format(time/100)+'.{:0>3}'.format(step-2*int(c.dtime))+numbersuffix
-                gnout=c.inputdir+'/flux'+sdate.strftime('%Y%m%d')+'.{:0>2}'.format(time/100)+'.{:0>3}'.format(step-int(c.dtime))+numbersuffix
-                hnout=c.inputdir+'/flux'+sdate.strftime('%Y%m%d')+'.{:0>2}'.format(time/100)+'.{:0>3}'.format(step)+numbersuffix
-                g=open(gnout,'w')
-                h=open(hnout,'w')
-            else:
-                fnout+='flux'+fdate.strftime('%Y%m%d%H')+numbersuffix
-                gnout=c.inputdir+'/flux'+(fdate+datetime.timedelta(hours=int(c.dtime))).strftime('%Y%m%d%H')+numbersuffix
-                hnout=c.inputdir+'/flux'+sdates.strftime('%Y%m%d%H')+numbersuffix
-                g=open(gnout,'w')
-                h=open(hnout,'w')
-            print "outputfile = " + fnout
-            f=open(fnout,'w')
-
-            while 1:
+		# date+time+step-2*dtime (since interpolated value valid for step-2*dtime)
+		sdate=datetime.datetime(year=cdate/10000,month=mod(cdate,10000)/100,
+		                        day=mod(cdate,100),hour=time/100)
+		fdate=sdate+datetime.timedelta(hours=step-2*int(c.dtime))
+		sdates=sdate+datetime.timedelta(hours=step)
+	    else:
+		break
+	    
+	    fnout=c.inputdir+'/'
+	    if c.maxstep>12:
+		fnout+='flux'+sdate.strftime('%Y%m%d')+'.{:0>2}'.format(time/100)+'.{:0>3}'.format(step-2*int(c.dtime))
+		gnout=c.inputdir+'/flux'+sdate.strftime('%Y%m%d')+'.{:0>2}'.format(time/100)+'.{:0>3}'.format(step-int(c.dtime))
+		hnout=c.inputdir+'/flux'+sdate.strftime('%Y%m%d')+'.{:0>2}'.format(time/100)+'.{:0>3}'.format(step)
+		g=open(gnout,'w')	    
+		h=open(hnout,'w')	    
+	    else:
+		fnout+='flux'+fdate.strftime('%Y%m%d%H')
+		gnout=c.inputdir+'/flux'+(fdate+datetime.timedelta(hours=int(c.dtime))).strftime('%Y%m%d%H')
+		hnout=c.inputdir+'/flux'+sdates.strftime('%Y%m%d%H')
+		g=open(gnout,'w')	    
+		h=open(hnout,'w')	    
+	    print "outputfile = " + fnout
+	    f=open(fnout,'w')	    
+			
+#                print 'cyear '+cyear+'/'+cmonth+'/'+'/EI'+cyear[2:4]+cmonth+cday+cflextime
+            while 1: 
                 if gid is None: break
                 cparamId = str(grib_get(gid, 'paramId'))
                 step = grib_get(gid, 'step')
                 atime = grib_get(gid, 'time')
-                ni=grib_get(gid, 'Ni')
-                nj=grib_get(gid, 'Nj')
-                if cparamId in valsdict.keys():
-                    values = grib_get_values(gid)
-                    vdp=valsdict[cparamId]
-                    svdp=svalsdict[cparamId]
-                    sd=stepsdict[cparamId]
-
-                    if cparamId=='142' or cparamId=='143':
-                        fak=1./1000.
-                    else:
-                        fak=3600.
-
-                    values=(reshape(values,(nj,ni))).flatten()/fak
-                    vdp.append(values[:]) # save the accumulated values
-                    if c.marsclass.upper() in ('EA') or \
-                       step<=int(c.dtime):
-                        svdp.append(values[:]/int(c.dtime))
-                    else:
-                        svdp.append((vdp[-1]-vdp[-2])/int(c.dtime))
-
-                    print cparamId,atime,step,len(values),values[0],std(values)
-                    #svdp.append(values[:]) # save the 1-hourly or 3-hourly specific values
-                    sd.append(step)
-                    if len(svdp)>=3:
-                        if len(svdp)>3:
-                            if cparamId=='142' or cparamId=='143':
-                                values=darain(svdp)
-                            else:
-                                values=dapoly(svdp)
-
-                            if not (step==c.maxstep and c.maxstep>12 or sdates==elimit):
-                                vdp.pop(0)
-                                svdp.pop(0)
-                        else:
-                            if c.maxstep>12:
-                                values=svdp[1]
-                            else:
-                                values=svdp[0]
-
-                        grib_set_values(gid, values)
-                        if c.maxstep>12:
-                            grib_set(gid,'stepRange',max(0,step-2*int(c.dtime)))
-                        else:
-                            grib_set(gid,'stepRange',0)
-                            grib_set(gid,'time',fdate.hour*100)
-                            grib_set(gid,'date',fdate.year*10000+fdate.month*100+fdate.day)
-                        grib_write(gid, f)
-
-                        if c.basetime is not None:
-                            elimit=datetime.datetime.strptime(c.end_date+c.basetime,'%Y%m%d%H')
-                        else:
-                            elimit=sdate+datetime.timedelta(2*int(c.dtime))
-
-                        # squeeze out information of last two steps contained in svdp
-    #			if step+int(c.dtime)==c.maxstep and c.maxstep>12 or sdates+datetime.timedelta(hours=int(c.dtime))>=elimit:
-    #                       Note that svdp[0] has not been popped in this case
-
-
-                        if step==c.maxstep and c.maxstep>12 or sdates==elimit:
-                            values=svdp[3]
-                            grib_set_values(gid, values)
-                            grib_set(gid,'stepRange',0)
-                            truedatetime=fdate+datetime.timedelta(hours=2*int(c.dtime))
-                            grib_set(gid,'time',truedatetime.hour*100)
-                            grib_set(gid,'date',truedatetime.year*10000+truedatetime.month*100+truedatetime.day)
-                            grib_write(gid, h)
-
-                            #values=(svdp[1]+svdp[2])/2.
-                            if cparamId=='142' or cparamId=='143':
-                                values=darain(list(reversed(svdp)))
-                            else:
-                                values=dapoly(list(reversed(svdp)))
-
-                            grib_set(gid,'stepRange',0)
-                            truedatetime=fdate+datetime.timedelta(hours=int(c.dtime))
-                            grib_set(gid,'time',truedatetime.hour*100)
-                            grib_set(gid,'date',truedatetime.year*10000+truedatetime.month*100+truedatetime.day)
-                            grib_set_values(gid, values)
-                            grib_write(gid, g)
-
-                    grib_release(gid)
-
-                gid = grib_new_from_index(iid)
-
-            f.close()
-            g.close()
-            h.close()
+		ni=grib_get(gid, 'Ni')
+		nj=grib_get(gid, 'Nj')
+		if cparamId in valsdict.keys():
+		    values = grib_get_values(gid)
+		    vdp=valsdict[cparamId]
+		    svdp=svalsdict[cparamId]
+		    sd=stepsdict[cparamId]
+		    
+		    if cparamId=='142' or cparamId=='143':
+			fak=1./1000.
+		    else:
+			fak=3600.
+		    
+		    values=(reshape(values,(nj,ni))).flatten()/fak
+		    vdp.append(values[:]) # save the accumulated values
+		    if step<=int(c.dtime):
+			svdp.append(values[:]/int(c.dtime))
+		    else:
+			svdp.append((vdp[-1]-vdp[-2])/int(c.dtime))
+		    
+		    print cparamId,atime,step,len(values),values[0],std(values)
+		    #svdp.append(values[:]) # save the 1-hourly or 3-hourly specific values
+		    sd.append(step)
+		    if len(svdp)>=3:
+			if len(svdp)>3:
+			    if cparamId=='142' or cparamId=='143':
+				values=darain(svdp)
+			    else:
+				values=dapoly(svdp)
+			    			    
+			    if not (step==c.maxstep and c.maxstep>12 or sdates==elimit):
+				vdp.pop(0)
+				svdp.pop(0)
+			else:
+			    if c.maxstep>12:
+				values=svdp[1]
+			    else:
+				values=svdp[0]
+			    
+			grib_set_values(gid, values)
+			if c.maxstep>12:
+			    grib_set(gid,'step',max(0,step-2*int(c.dtime)))
+			else:
+			    grib_set(gid,'step',0)
+			    grib_set(gid,'time',fdate.hour*100)
+			    grib_set(gid,'date',fdate.year*10000+fdate.month*100+fdate.day)
+			grib_write(gid, f)
+			
+			if c.basetime is not None:
+			    elimit=datetime.datetime.strptime(c.end_date+c.basetime,'%Y%m%d%H')
+			else:
+			    elimit=sdate+datetime.timedelta(2*int(c.dtime))
+			
+			# squeeze out information of last two steps contained in svdp
+#			if step+int(c.dtime)==c.maxstep and c.maxstep>12 or sdates+datetime.timedelta(hours=int(c.dtime))>=elimit:
+#                       Note that svdp[0] has not been popped in this case
+			    
+		    
+			if step==c.maxstep and c.maxstep>12 or sdates==elimit:
+			    values=svdp[3]
+			    grib_set_values(gid, values)
+			    grib_set(gid,'step',0)
+			    truedatetime=fdate+datetime.timedelta(hours=2*int(c.dtime))
+			    grib_set(gid,'time',truedatetime.hour*100)
+			    grib_set(gid,'date',truedatetime.year*10000+truedatetime.month*100+truedatetime.day)
+			    grib_write(gid, h)
+			    
+			    #values=(svdp[1]+svdp[2])/2.
+			    if cparamId=='142' or cparamId=='143':
+				values=darain(list(reversed(svdp)))
+			    else:
+				values=dapoly(list(reversed(svdp)))
+			    
+			    grib_set(gid,'step',0)
+			    truedatetime=fdate+datetime.timedelta(hours=int(c.dtime))
+			    grib_set(gid,'time',truedatetime.hour*100)
+			    grib_set(gid,'date',truedatetime.year*10000+truedatetime.month*100+truedatetime.day)
+			    grib_set_values(gid, values)
+			    grib_write(gid, g)
+			
+		    grib_release(gid)
+					
+		gid = grib_new_from_index(iid)
+		
+	    f.close()
+   	    g.close()
+	    h.close()
 
 
         grib_index_release(iid)
+
Index: python/GribTools.py
===================================================================
--- python/GribTools.py	(revision e18f4b5f53f063ab746e1307bdd3162d31cb3e8a)
+++ python/GribTools.py	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -3,7 +3,7 @@
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-#
-#
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
+# 
+# 
 # Creation: July 2014 - Anne Fouilloux - University of Oslo
 #
@@ -22,5 +22,5 @@
     def __init__(self,filename):
         self.filename=filename
-
+    
 # get keyvalues for a given list of keynames
 # a where statment can be given (list of key and list of values)
@@ -30,7 +30,7 @@
 
         return_list=[]
-
+        
         while 1:
-            gid_in = grib_new_from_file(fileid)
+            gid_in = grib_new_from_file(fileid)  
             if gid_in is None: break
             select=True
@@ -50,5 +50,5 @@
         fileid.close()
         return return_list
-
+      
 # set keyvalues for a given list of keynames
 # a where statment can be given (list of key and list of values)
@@ -60,9 +60,9 @@
         fout=open(self.filename,filemode)
         fin=open(fromfile)
-
+        
         while 1:
-            gid_in = grib_new_from_file(fin)
+            gid_in = grib_new_from_file(fin)  
             if gid_in is None: break
-
+            
             select=True
             i=0
@@ -88,14 +88,14 @@
 
 # Add the content of a grib file but only messages
-# corresponding to keys/values
+# corresponding to keys/values        
 # if selectWhere is False select fields that are different from keynames/keyvalues
     def copy(self,filename_in, selectWhere=True, keynames=[], keyvalues=[],filemode='w'):
         fin=open(filename_in)
         fout=open(self.filename,filemode)
-
+        
         while 1:
-            gid_in = grib_new_from_file(fin)
+            gid_in = grib_new_from_file(fin)  
             if gid_in is None: break
-
+            
             select=True
             i=0
@@ -104,5 +104,5 @@
             for key in keynames:
                 if not grib_is_defined(gid_in, key): raise Exception("Key was not defined")
-
+                
                 if selectWhere:
                     select=select and (str(keyvalues[i])==str(grib_get(gid_in, key)))
@@ -118,7 +118,7 @@
 # Create index from a list of files if it does not exist or read it
     def index(self,index_keys=["mars"], index_file = "my.idx"):
-        print "index to be done"
+        print "index to be done" 
         self.iid = None
-
+ 
         if (os.path.exists(index_file)):
             self.iid = grib_index_read(index_file)
@@ -130,12 +130,12 @@
                     self.iid = grib_index_new_from_file(file,index_keys)
                 else:
-                    grib_index_add_file(self.iid,file)
+                     grib_index_add_file(self.iid,file)
 
             if self.iid != None:
-                grib_index_write(self.iid,index_file)
-        return self.iid
+              grib_index_write(self.iid,index_file)
+        return self.iid 
 
 
+       
 
-
-
+        
Index: python/README.md
===================================================================
--- python/README.md	(revision 5d3d09ba3e575ebfc3c6f1527d83e2d7f4e274d5)
+++ python/README.md	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -1,295 +1,152 @@
-#README
+# README #
 
-This documentation shows how to install and use the ***flex_extract*** software package to extract ECMWF data and generate the ***FLEXPART*** specific input files. 
+This documentation shows how to use these python scripts to extract ECMWF ERA-Interim data and generate WINDFIELDS for running FLEXPART. 
 
-Introduction 
-=================
+### Overview ###
 
-To run ***FLEXPART*** with ECMWF data, you first need to retrieve ECMWF GRIB fields and generate ***FLEXPART*** specific input files afterwards. ***FLEXPART*** needs the GRIB data seperated by time so that ***flex_extract*** will combine all data in output files seperated for each time step. The format of these output filenames looks like: `prefixYYMMDDHH`, where prefix can be defined in ***flex_extract*** (usually it should be limited to "2" characters because of further processing reasons).
+To run FLEXPART with ECMWF ERA-Interim data, you first need to retrieve ECMWF ERA-Interim GRIB fields and generate FLEXPART WINDFIELDS to run FLEXPART.
 
-There are 4 different modes of running ***flex_extract*** :
-1. Remote (**): ***flex_extract*** is installed and executed directly on the ECMWF Linux member state server ecgate. Users have to be a registered member-state user.
-2. Gateway (**): ***flex_extract*** is installed on a local machine and the scripts are submitted to ECMWF
-computer facilities via a member-state gateway server. Users have to be a registered member-state user.
-3. Local member state (**): ***flex_extract*** is installed and executed on a local machine. Users have to be a registered member-state user.
-4. Local public (***): ***flex_extract*** is installed and executed on a local machine. Users do not have to be a member-state user. A normal registration at the ECMWF website is enough. See also the instruction to install the ECMWF Web API
+The two main programs are called respectively `getEIdata.py` and `prepareFLEXPART.py`. 
 
-*(\*\*) To get a ms (member-state) user access, users have to be a resident of a [member state](https://www.ecmwf.int/en/about/who-we-are/member-states) and have to contact their national meteorological center for granting access.*
+To get the usage of these programs, use `-h` option:
 
-*(\*\*\*) To get a public user account, the user can just register at the ECMWF website following the instructions [here](https://software.ecmwf.int/wiki/display/WEBAPI/ECMWF+Web+API+Home)!*
+`getEIdata.py -h`
 
-For setting up a complete ***FLEXPART*** environment it is recommended to build a directory structure such as:
+Optional arguments are mentionned in squared brackets. 
 
- ![FLEXPART directory structure](../docs/Fp_extract_strukt.png)
+* `getEIdata.py`
 
-For installation instructions and usage of ***FLEXPART*** please see ***FLEXPART***-Documentation!
-
-Data sets archived at ECMWF
-===========================
-
-There are two modes for accessing ECMWF data sets: the **_full access_** and the **_public access_** mode.
-A description of these two modes and links to the available data sets is available here: https://www.ecmwf.int/en/forecasts/datasets/archive-datasets
-
-####  Important note for public users
-
-If you want to extract public data sets from the ECMWF servers you first have to register at the ECMWF. Do this by following the instructions at: https://software.ecmwf.int/wiki/display/WEBAPI/Access+MARS
-
-Afterwards you **_need to accept the licenses_** of the data sets you want to extract: 
-
-https://software.ecmwf.int/wiki/display/WEBAPI/Available+ECMWF+Public+Datasets
-
-Now your able to use ***flex_extract*** in public mode (command line parameter "*--public=1*"). 
-
-Installation
-===================
-
-### Some important notes for the installation process:
-- Use the same compiler and compiler version for all libraries and the fortran program.
-- Don't forget to set all library paths to the LD_LIBRARY_PATH variable.
-- Don't forget to adapt the makefile for the Fortran program.
-
-### Requirements ###
-
-| Python Support        | Link            | Notes |
-| --------------------- |:----------------------:|:-------------------------|
-| python                | [http://www.python.org](http://www.python.org)  | We have used [Anaconda python](https://store.continuum.io/cshop/anaconda/) for our testing |
-| python-numpy          | [http://www.numpy.org/](http://www.numpy.org/)  | Not necessary if you have installed python Anaconda
-| ecmwfapi              | [https://software.ecmwf.int/wiki/display/WEBAPI/ECMWF+Web+API+Home](https://software.ecmwf.int/wiki/display/WEBAPI/ECMWF+Web+API+Home) | You also need to install your API key (as explained in the documentation)
-
-| Utilities             | Link            | Notes |
-| --------------------- |:----------------------:|:-------------------------|
-|gfortran|[https://gcc.gnu.org/wiki/GFortran](https://gcc.gnu.org/wiki/GFortran)| Make sure that you are using the same compiler version for all libraries in connection with flex_extract, GRIB_API and FLEXPART, otherwise you will have problems.|
-|  grib-api or eccodes             | [https://software.ecmwf.int/wiki/display/GRIB/Home](https://software.ecmwf.int/wiki/display/GRIB/Home) / [https://software.ecmwf.int/wiki/display/ECC](https://software.ecmwf.int/wiki/display/ECC) | Make sure you install grib_api/eccodes with JPEG support and python.|
-|FFTW|[http://www.fftw.org](http://www.fftw.org)|This is needed by the Emos library, as is mentioned in the installation instructions for Emos|
-|  Emos                 | [https://software.ecmwf.int/wiki/display/EMOS/Emoslib](https://software.ecmwf.int/wiki/display/EMOS/Emoslib) | Make sure you carefully read the instructions and have installed the FFTW package before installing Emos.|
-| CONVERT2     | |to run prepareFLEXPART.py, you need to compile the Fortran program CONVERT2 (located in the src directory). See separate README file in this directory to get instructions on how to compile this code.|
-
-###  Prepare the environment for using ***flex_extract*** on a local machine
-
-Please follow the instructions on the websites of the libraries. The installation of these libraries can be done by package installation or from scratch, for either case it is useful to consider the official documentation (and also the hints from the ECMWF) rather than trying to explain every detail in here. Nevertheless, we recommend doing the installation in the following order (see links to the libraries in the table above):
-
-1. Read Emoslib installation instructions.
-2. Read ECMWF blog about gfortran (https://software.ecmwf.int/wiki/display/SUP/2015/05/11/Building+ECMWF+software+with+gfortran).
-3. Install FFTW.
-4. Install EMOSLIB (Hint: Apply make 2 times! One time without any options and one time with single precision option.).
-5. Install ECCODES OR GRIB_API (for python and fortran). ECCODES is downward compatible with GRIB_API and GRIB_API support will expire at the end of 2018.
-6. Register at Mars (see link to ecmwfapi). 
-7. Install ECMWF_WEBAPI.
-8. Check LD_LIBRARY_PATH environment variable if it contains all paths to the libs. 
-9. Check available python packages (e.g. check in python console the commands: import eccodes / import grib_api / import ecmwfapi)
-10. Start a simple test retrieval (following the instructions at ECMWF Web API website). 
-11. Install ***flex_extract*** (see next section). 
-
-### Installation of ***flex_extract***
-
-To install ***flex_extract*** you have to go to the python directory and call the `install.py` script. It has the following options: 
-
-```
-usage: install.py [-h] [--target INSTALL_TARGET] [--makefile MAKEFILE]
-                  [--ecuid ECUID] [--ecgid ECGID] [--gateway GATEWAY]
-                  [--destination DESTINATION]
-                  [--flexpart_root_scripts FLEXPART_ROOT_SCRIPTS]
-                  [--job_template JOB_TEMPLATE] [--controlfile CONTROLFILE]
-
-Install flex_extract software locally or on ECMWF machines
-
-optional arguments:
-  -h, --help            show this help message and exit
-  --target INSTALL_TARGET
-                        Valid targets: local | ecgate | cca , the latter two
-                        are at ECMWF (default: None)
-  --makefile MAKEFILE   Name of Makefile to use for compiling CONVERT2
-                        (default: None)
-  --ecuid ECUID         user id at ECMWF (default: None)
-  --ecgid ECGID         group id at ECMWF (default: None)
-  --gateway GATEWAY     name of local gateway server (default: None)
-  --destination DESTINATION
-                        ecaccess destination, e.g. leo@genericSftp (default:
-                        None)
-  --flexpart_root_scripts FLEXPART_ROOT_SCRIPTS
-                        FLEXPART root directory on ECMWF servers (to find
-                        grib2flexpart and COMMAND file) Normally flex_extract
-                        resides in the scripts directory of the FLEXPART
-                        distribution, thus the: (default: None)
-  --job_template JOB_TEMPLATE
-                        job template file for submission to ECMWF (default:
-                        job.temp.o)
-  --controlfile CONTROLFILE
-                        file with control parameters (default: CONTROL.temp)
-```
+This program allows you to download ECMWF ERA-Interim data from ECMWF using [ecmwfapi](https://software.ecmwf.int/wiki/display/WEBAPI/ECMWF+Web+API+Home). 
+It requires `ecmwfapi` python library (see Requirements below). Check with your local IT group as it may be already available.
 
 
-#### Local installation of ***flex_extract*** (***flex_extract*** modes 1 (on ECMWF servers), 3 and 4)
+{{{
+Usage: getEIdata.py --start_date=YYYYMMDD [--end_date=YYYYMMDD] [--times=tt1/tt2/tt3] [--levels=nlevels]
+                                                  [--area=north/west/south/east]  [--outputdir=output_directory]
 
----
-
-For a local installation of ***flex_extract*** the user has to adapt the makefile for the Fortran program first. Set the paths to the grib_api or eccodes library and emoslib. Then the installation script should be called as follows:
-
-```
-./install.py --target=local --makefile=Makefile.local.gfortan
-```
-
-where the makefile name can differ if the user prepared another makefile for his environment. 
-On ECMWF servers a makefile named "Makefile.gfortran" is already provided in the "src"-directory. It is also the default makefile, so that the parameter does not have to be set when calling "install.py".
-
-If the ***flex_extract*** is to be installed within a ***FLEXPART*** environment it should be called with the parameter `flexpart_root_scripts` to let ***flex_extract*** know about the path to ***FLEXPART***.
-
-The installation was successful if the compilation of the Fortran program ``CONVERT2`` didn't fail and is displayed in the terminal. 
-
-#### Installation using a gateway server (***flex_extract*** mode 2 only)
-
----
-
-If the user has a gateway server and the Ecaccess toolkit available, ***flex_extract*** can be installed such that it is executed on the local machine and a job script is submitted to the ECMWF server. The final ***FLEXPART*** input files are then send back via the Ecaccess command line tool "ectrans". To use this tool, the user has to create an association directly on the local gateway server via the localhost ecaccess.ecmwf.int and provide the association name as the "destination"-parameter when calling "install.py". 
-
-The gateway server has to be registered at ECMWF. For information about a gateway server see: 
-- https://software.ecmwf.int/wiki/display/ECAC/Releases+-+Gateway+package
-- and the Software Installation Plan (SIP.pdf) in the docs/ directory.
-
-Afterwards ***flex_extract*** can be installed with the following command:
-```
-./install.py --target=local --makefile=Makefile.gfortan --ecuid=<id> --ecgid=<gid> --gateway=<servername> --destination=<destinationname>
-```
-
-If the installation was successful the user gets an email with a success note!
-
-
-Using ***flex_extract***
-===================
-
-This section provides the absolut basics on how ***flex_extract*** is to be used. For more information about possible settings, performance, parameter combinations and so one, the user is referred to the SIP.pdf and SUT.pdf documents and the www.flexpart.eu community website. It is also possible to ask for help by writing to the ***FLEXPART*** user email list (registration needed) or by creating a ticket on the community website.
-
-#### CONTROL file 
-
-***flex_extract*** is controlled by providing "CONTROL"-files with a list of parameter settings. These parameter are described in detail in the *Software User Tutorial (SUT.pdf)*. 
-The "CONTROL"-files specifies which ECMWF data set is to be retrieved, the time and spatial resolution, the format of the grib file and many more. In the `python` directory are some example `CONTROL` files for the different data sets and access modes which can be retrieved with ***flex_extract***:
-
-```
-CONTROL_CERA
-CONTROL_CV
-CONTROL_EA5.public
-CONTROL_FC.pure
-CONTROL_OD.highres.gauss
-CONTROL_CERA.public
-CONTROL_EA5
-CONTROL_EI.global
-CONTROL_FC.twiceaday
-CONTROL_OPS.4V
-CONTROL_CF
-CONTROL_EA5.highres
-CONTROL_EI.public
-CONTROL_OD.highres.eta
-CONTROL.temp
-```
-
-For information about all the possible parameter settings and explanation, please see the SUT.pdf document in the `docs/` directory.
-
-`CONTROL`-files with a `.public` ending is usable for the public access mode. The main difference is the parameter ``dataset`` which explicitly specifies the public data sets. Additionally, not all meteorological fields and times were archived in the public data sets and are considered in the public `CONTROL`-files.
-
-#### Python scripts 
-
-* `submit.py`
-
-This is the main program for doing both, retrieving ECMWF data and generating the ***FLEXPART*** input files. It combines the two sub-programs `getMARSdata.py` and `prepareFLEXPART.py` which can also be run by themselves for debugging purposes.
-Use the `-h` option to get the parameter options:
-
-```
-usage: submit.py [-h] [--start_date START_DATE] [--end_date END_DATE]
-                 [--date_chunk DATE_CHUNK] [--basetime BASETIME] [--step STEP]
-                 [--levelist LEVELIST] [--area AREA] [--inputdir INPUTDIR]
-                 [--outputdir OUTPUTDIR]
-                 [--flexpart_root_scripts FLEXPART_ROOT_SCRIPTS] [--ppid PPID]
-                 [--job_template JOB_TEMPLATE] [--queue QUEUE]
-                 [--controlfile CONTROLFILE] [--debug DEBUG] [--public PUBLIC]
-
-Retrieve FLEXPART input from ECMWF MARS archive
-
-optional arguments:
+Options:
   -h, --help            show this help message and exit
-  --start_date START_DATE
-                        start date YYYYMMDD (default: None)
-  --end_date END_DATE   end_date YYYYMMDD (default: None)
-  --date_chunk DATE_CHUNK
-                        # of days to be retrieved at once (default: None)
-  --basetime BASETIME   base such as 00/12 (for half day retrievals) (default:
-                        None)
-  --step STEP           steps such as 00/to/48 (default: None)
-  --levelist LEVELIST   Vertical levels to be retrieved, e.g. 30/to/60
-                        (default: None)
-  --area AREA           area defined as north/west/south/east (default: None)
-  --inputdir INPUTDIR   root directory for storing intermediate files
-                        (default: None)
-  --outputdir OUTPUTDIR
-                        root directory for storing output files (default:
-                        None)
-  --flexpart_root_scripts FLEXPART_ROOT_SCRIPTS
-                        FLEXPART root directory (to find grib2flexpart and
-                        COMMAND file) Normally flex_extract resides in the
-                        scripts directory of the FLEXPART distribution
-                        (default: None)
-  --ppid PPID           Specify parent process id for rerun of prepareFLEXPART
-                        (default: None)
-  --job_template JOB_TEMPLATE
-                        job template file for submission to ECMWF (default:
-                        job.temp)
-  --queue QUEUE         queue for submission to ECMWF (e.g. ecgate or cca )
-                        (default: None)
-  --controlfile CONTROLFILE
-                        file with control parameters (default: CONTROL.temp)
-  --debug DEBUG         Debug mode - leave temporary files intact (default: 0)
-  --public PUBLIC       Public mode - retrieves the public datasets (default:
-                        0)
-```
-
-*Optional arguments are listed in squared brackets.*
-
-
-* `getMARSdata.py`
-
-This program retrieves the ECMWF data from ECMWF servers using [ECMWF WebApi](https://software.ecmwf.int/wiki/display/WEBAPI/ECMWF+Web+API+Home) or [Mars](https://software.ecmwf.int/wiki/display/UDOC/MARS+user+documentation), depending on your user status and your selection of the running mode. It requires the `ECMWF WebApi` python library (see Requirements below). Check with your local IT group as it may be already available.
-
+  --start_date=start_date
+                        start date YYYYMMDD
+  --end_date=end_date   end_date YYYYMMDD
+  --times=times         times such as 00/12
+  --levels=levels       number of vertical levels
+  --area=area           area defined as north/west/south/east with default
+                        90.0/-179.0/-90.0/180.0
+  --outputdir=outputdir
+                        root directory for storing output files
+}}}
 
 * `prepareFLEXPART.py`
 
-This program generates FLEXPART input files from the retrieved meteorological fields. It requires python interface to grib_api or eccodes and the Fortran program `CONVERT2` (located in `src` directory). `CONVERT2` needs a namelist which is generated from the python program.
+This program allow you to generate FLEXPART WINDFIELDS (inputs for FLEXPART). It requires python interface to grib_api and `CONVERT2` program (located in `src` directory with instruction on how to compile it). You also need to provide a namelist for CONVERT2 (see test_1).
 
-#### execute flex_extract locally (member-state user)
+`
+Usage: prepareFLEXPART.py --start_date=YYYYMMDD [--end_date=YYYYMMDD] [--namelist=namelist_for_convert] [--inputdir=input_root_directory] [--outputdir=output_directory]
 
-Almost every command line parameter for the `submit.py` script call has a default value or is read from the specified `CONTROL` file. 
-Therefore, for a local extraction of ERA-Interim data as a member-state user the script can be called simply by passing a `CONTROL` file and a starting date with the following command:
-```
-./submit.py --controlfile=CONTROL_EI.global --start_date=20101201
-```
-If there was just a starting date without an end date, ***flex_extract*** retrieves just this one day of meteorological data. The `CONTROL_EI.global` file has a set of default values which needs to be adjusted regarding users needs. It is also possible to set the dates within the `CONTROL`-file instead of passing it via command line parameter. 
+Options:
+  -h, --help            show this help message and exit
+  --start_date=start_date
+                        start date YYYYMMDD
+  --end_date=end_date   end_date YYYYMMDD
+  --namelist=namelist   namelist used for converting
+  --inputdir=inputdir   root directory for reading input files
+  --outputdir=outputdir
+                        root directory for storing output files
+
+`
+### Requirements ###
+
+| Python Support        |
+|----------------------:| 
+| python                | [http://www.python.org](http://www.python.org)  | We have use [python Anaconda](https://store.continuum.io/cshop/anaconda/) for our testings
+| python-numpy          | [http://www.numpy.org/](http://www.numpy.org/)  | Not necessary if you have installed python Anaconda
+| ecmwfapi              | [https://software.ecmwf.int/wiki/display/WEBAPI/ECMWF+Web+API+Home](https://software.ecmwf.int/wiki/display/WEBAPI/ECMWF+Web+API+Home) | You also need to install your API key (as explained in the documentation)
+| Utilities             |
+|----------------------:| 
+|  grib-api             | [https://software.ecmwf.int/wiki/display/GRIB/Home](https://software.ecmwf.int/wiki/display/GRIB/Home) | Make sure you install GRIB-API with JPEG support and python GRIB-API.
+|----------------------:| 
+| FLEXPART programs     | to run these programs (prepareFLEXPART.py), you need to compile CONVERT2 program (located in preproc/src). See separate README file to get instructions on how to compile this code.
+|----------------------:| 
 
 
-#### execute flex_extract locally (public user)
+### Installation ###
 
-As a public user one has to use the `CONTROL` file with the `.public` extension and the parameter `public`:
-```
-./submit.py --controlfile=CONTROL_EI.public --start_date=20101201 --public=1
-```
-Otherwise, except of the different data available, the usage of ***flex_extract*** is the same as for member-state users.
+*  Environment
 
-#### execute flex_extract via gateway server
+At UIO, Red Hat 6 Linux systems (64 bits) were used for testing. We use the [Module package](http://modules.sourceforge.net/) to set-up user environment.
 
-If ***flex_extract*** was installed via a gateway server and a file "*ECMWF_ENV*" is available in the ``python``-directory, the ``submit.py`` script can be called with the `--queue` option. A job script is then prepared and submitted to the ECMWF server (in this case, "ecgate") .
+* Getting the source code
+In the directory of your choice:
 
-```
-./submit.py --queue=ecgate --controlfile=CONTROL_EI.global --start_date=20101201
-```
+`
+git clone git@bitbucket.org:flexpart/flexpart.git
+`
+This command will create a subdirectory called flexpart: it contains the latest FLEXPART version.
 
-The job status can then be checked by typing:
-````
-ecaccess-job-list
-```` 
+Set then environment variable `FLEXPART_HOME`:
 
-If the parameters *ecuid*, *ecgid*, *gateway* and *destination* were set correctly during installation and the gateway server is running, the resulting ***FLEXPART*** input files can be directly transferred to the local gateway by setting the paramter ``ectrans`` in the ``CONTROL``-file to ``1``.
+** Korn-shell or Bash users:
+`
+cd flexpart
+export FLEXPART_HOME=$PWD
+`
 
-Regardless of the job being successful or not, the user will receive an email with the log messages. 
+** C-shell users:
 
-#  Installation FAQ 
+`
+cd flexpart
+setenv FLEXPART_HOME=$PWD
+`
 
+* Installation
 
+Make sure your first generate `CONVERT2` program (see separate instructions in `preproc/src`).
 
+Users need to be able to execute prepareFLEXPART.py and getEIdata.py so make sure they have the correct unix permissions:
 
+`
+cd preproc/python
+chmod uog+rx getEIdata.py prepareFLEXPART.py
+`
+
+These two programs must be in the user PATH. At UIO this is done automatically when loading flexpart. If not, you would need to do the following:
+
+** Korn-shell or Bash users:
+`
+export PATH=$FLEXPART_HOME/preproc/python:$PATH
+`
+
+** C-shell users:
+
+`
+setenv PATH $FLEXPART_HOME/preproc/python:$PATH
+`
+
+Where `$FLEXPART_HOME` is the directory where FLEXPART 
+
+* Testing your installation
+
+First check that grib-api python interface is correctly installed on your platform:
+`
+python
+>>> from gribapi import *
+>>>
+`
+Use `CTRL-D` to quit python.
+
+Then check that `ecmwfapi` is properly installed:
+`
+python
+>>> from ecmwfapi import *
+>>>
+`
+
+If the two previous tests were successful, you can run `tests/preproc` (See separate instructions in `tests/preproc`). 
+
+If any of these two tests fail, this probably means that either `ecmwfapi` or `grib-api` have not been installed properly. 
+
+Please report any problems.
+
+###  Installation FAQ ###
+
Index: python/UIOTools.py
===================================================================
--- python/UIOTools.py	(revision e18f4b5f53f063ab746e1307bdd3162d31cb3e8a)
+++ python/UIOTools.py	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
-#
+#!/usr/bin/env python                                                                                                                                                                      
+#                                                                                                                                                                                          
 # (C) Copyright 2014 UIO.
 #
@@ -22,5 +22,5 @@
     # Get the absolute path of the pathname parameter
         pathname = os.path.abspath(pathname)
-
+ 
     # Get a list of files in pathname
         filesInCurDir0 = glob.glob(pathname+'/'+pattern)
@@ -33,5 +33,5 @@
         for file in filesInCurDir:
             curFile = os.path.join(pathname, file)
-
+ 
         # Check if it's a normal file or directory
             if os.path.isfile(curFile):
@@ -44,5 +44,5 @@
                     # add this filename in the list
                     self.files.append(curFile)
-
+                    
             else:
                 # We got a directory, enter into it for further processing
Index: python/compilejob.ksh
===================================================================
--- python/compilejob.ksh	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/compilejob.ksh	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,84 @@
+#!/bin/ksh
+
+# ON ECGB:
+# start with ecaccess-job-submit -queueName ecgb NAME_OF_THIS_FILE  on gateway server
+# start with sbatch NAME_OF_THIS_FILE directly on machine
+
+#SBATCH --workdir=/scratch/ms/spatlh00/lh0
+#SBATCH --qos=normal
+#SBATCH --job-name=flex_ecmwf
+#SBATCH --output=flex_ecmwf.%j.out
+#SBATCH --error=flex_ecmwf.%j.out
+#SBATCH --mail-type=FAIL
+#SBATCH --time=12:00:00
+
+## CRAY specific batch requests
+##PBS -N flex_ecmwf
+##PBS -q ns
+##PBS -S /usr/bin/ksh
+# -o /scratch/ms/no/sbc/flex_ecmwf.$Jobname.$Job_ID.out
+# job output is in .ecaccess_DO_NOT_REMOVE
+##PBS -j oe
+##PBS -V
+##PBS -l EC_threads_per_task=1
+##PBS -l EC_memory_per_task=3200MB
+
+set -x
+export VERSION=7.0
+case $HOST in
+  *ecg*)
+  module load python
+  module unload grib_api
+  module unload emos
+  module load grib_api/1.14.5
+  module load emos/437-r64
+export FLEXPART_ROOT_SCRIPTS=$HOME
+#  export ECMWFDATA=$FLEXPART_ROOT/ECMWFDATA7.0
+#  export PYTHONPATH=$ECMWFDATA/python
+#  export PATH=${PATH}:$ECMWFDATA/python
+  export MAKEFILE=Makefile.gfortran
+  ;;
+  *cca*)
+  module switch PrgEnv-cray PrgEnv-intel
+  module load grib_api
+  module load emos
+  module load python
+  echo ${GROUP}
+  echo ${HOME}
+  echo $HOME | awk -F / '{print $1, $2, $3, $4}'
+  export GROUP=`echo $HOME | awk -F / '{print $4}'`
+  export SCRATCH=/scratch/ms/${GROUP}/${USER}
+export FLEXPART_ROOT_SCRIPTS=$HOME
+#  export ECMWFDATA=$FLEXPART_ROOT/ECMWFDATA7.0
+#  export PYTHONPATH=$ECMWFDATA/python
+#  export PATH=${PATH}:$ECMWFDATA/python
+  export MAKEFILE=Makefile.CRAY
+  ;;
+esac
+
+mkdir -p $FLEXPART_ROOT_SCRIPTS/ECMWFDATA$VERSION
+cd $FLEXPART_ROOT_SCRIPTS/ECMWFDATA$VERSION   # if FLEXPART_ROOT is not set this means cd to the home directory
+tar -xvf $SCRATCH/ECMWFDATA$VERSION.tar
+cd src
+\rm *.o *.mod CONVERT2
+make -f $MAKEFILE >flexcompile 2>flexcompile
+
+ls -l CONVERT2 >>flexcompile
+if [ $? -eq 0 ]; then
+  echo 'SUCCESS!' >>flexcompile
+  mail -s flexcompile.$HOST.$$ $USER <flexcompile
+else
+  echo Environment: >>flexcompile
+  env >> flexcompile
+  mail -s "ERROR! flexcompile.$HOST.$$" $USER <flexcompile
+fi
+
+
+
+
+
+
+
+
+
+
Index: python/compilejob.temp
===================================================================
--- python/compilejob.temp	(revision fb8810cda0dbbf0169e05332ef2fe5632ef1214e)
+++ python/compilejob.temp	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -25,5 +25,5 @@
 
 set -x
-export VERSION=7.0.4
+export VERSION=7.0
 case $HOST in
   *ecg*)
@@ -34,4 +34,7 @@
   module load emos/437-r64
   export FLEXPART_ROOT_SCRIPTS=
+#  export ECMWFDATA=$FLEXPART_ROOT/ECMWFDATA7.0
+#  export PYTHONPATH=$ECMWFDATA/python
+#  export PATH=${PATH}:$ECMWFDATA/python
   export MAKEFILE=Makefile.gfortran
   ;;
@@ -47,11 +50,14 @@
   export SCRATCH=/scratch/ms/${GROUP}/${USER}
   export FLEXPART_ROOT_SCRIPTS=
+#  export ECMWFDATA=$FLEXPART_ROOT/ECMWFDATA7.0
+#  export PYTHONPATH=$ECMWFDATA/python
+#  export PATH=${PATH}:$ECMWFDATA/python
   export MAKEFILE=Makefile.CRAY
   ;;
 esac
 
-mkdir -p $FLEXPART_ROOT_SCRIPTS/flex_extract_v$VERSION
-cd $FLEXPART_ROOT_SCRIPTS/flex_extract_v$VERSION   # if FLEXPART_ROOT is not set this means cd to the home directory
-tar -xvf $HOME/flex_extract_v$VERSION.tar
+mkdir -p $FLEXPART_ROOT_SCRIPTS/ECMWFDATA$VERSION
+cd $FLEXPART_ROOT_SCRIPTS/ECMWFDATA$VERSION   # if FLEXPART_ROOT is not set this means cd to the home directory
+tar -xvf $SCRATCH/ECMWFDATA$VERSION.tar
 cd src
 \rm *.o *.mod CONVERT2
Index: python/getMARSdata.py
===================================================================
--- python/getMARSdata.py	(revision e879023747fe27c7a7f54905ed6f8312aac6ac21)
+++ python/getMARSdata.py	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -2,10 +2,10 @@
 #
 # This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-#
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
+# 
 # Functionality provided: Prepare input 3D-wind fields in hybrid coordinates + surface fields for FLEXPART runs
 #
 # Creation: October  2014 - Anne Fouilloux - University of Oslo
-# Extension November 2015 - Leopold Haimberger - University of Vienna for:
+# Extension November 2015 - Leopold Haimberger - University of Vienna for: 
 # - using the WebAPI also for general MARS retrievals
 # - job submission on ecgate and cca
@@ -15,9 +15,9 @@
 # - conversion into GRIB2
 # - conversion into .fp format for faster execution of FLEXPART
-#
+# 
 #
 # Further documentation may be obtained from www.flexpart.eu
-#
-# Requirements:
+# 
+# Requirements: 
 # in addition to a standard python 2.6 or 2.7 installation the following packages need to be installed
 # ECMWF WebMARS, gribAPI with python enabled, emoslib, ecaccess web toolkit, all available from https://software.ecmwf.int/
@@ -26,5 +26,5 @@
 #
 # Get MARS GRIB fields from ECMWF for FLEXPART
-#
+# 
 
 #import socket
@@ -51,40 +51,19 @@
 
 from FlexpartTools import MARSretrieval, EIFlexpart, silentremove, \
-     Control,myerror,normalexit, interpret_args_and_control
+                          Control,myerror,normalexit, interpret_args_and_control
 
 
 def getMARSdata(args,c):
-
+    
+        
     if not os.path.exists(c.inputdir):
         os.makedirs(c.inputdir)
-
-
-    if c.request == 0:
-        print("Retrieving EC data!")
-    else:
-        if c.request == 1:
-            print("Printing mars requests!")
-        elif c.request == 2:
-            print("Retrieving EC data and printing mars request!")
-        # first, write header with the mars parameter to file
-        # create a dummy MarsRetrieval to get parameter
-        MR = MARSretrieval(None, None)
-        attrs = vars(MR).copy()
-        del attrs['server']
-        del attrs['public']
-        marsfile = os.path.join(c.inputdir, 'mars_requests.csv')
-        with open(marsfile, 'w') as f:
-            f.write('request_number' + ', ')
-            f.write(', '.join(str(key) for key in sorted(attrs.iterkeys())))
-            f.write('\n')
-
     print "start date %s "%(c.start_date)
     print "end date %s "%(c.end_date)
 
+    
+#    server = ECMWFDataServer()
     if ecapi:
-        if int(c.public):
-            server = ecmwfapi.ECMWFDataServer()
-        else:
-            server = ecmwfapi.ECMWFService("mars")
+        server = ecmwfapi.ECMWFService("mars")
     else:
         server = False
@@ -110,69 +89,66 @@
     else:
         endp1=end+ datetime.timedelta(days=2)
-
+    
     datechunk=datetime.timedelta(days=int(c.date_chunk))
-    if c.request == 0 or c.request == 2:
-        print 'removing content of '+c.inputdir
-        tobecleaned=glob.glob(c.inputdir+'/*_acc_*.'+str(os.getppid())+'.*.grb')
-        for f in tobecleaned:
-            os.remove(f)
-
+    print 'removing content of '+c.inputdir
+    tobecleaned=glob.glob(c.inputdir+'/*_acc_*.'+str(os.getppid())+'.*.grb')
+    for f in tobecleaned:
+        os.remove(f)
+        
     times=None
-    if c.maxstep<=24:
+    if c.maxstep<24:
         day=startm1
         while day<endp1:
-            # we need to retrieve MARS data for this period (maximum one month)
-            flexpart = EIFlexpart(c,fluxes=True)
-            if day+datechunk-datetime.timedelta(days=1)<endp1:
-                dates= day.strftime("%Y%m%d") + "/to/" + (day+datechunk-datetime.timedelta(days=1)).strftime("%Y%m%d")
-            else:
-                dates= day.strftime("%Y%m%d") + "/to/" + end.strftime("%Y%m%d")
-
-            print "retrieve " + dates + " in dir " + c.inputdir
-            try:
-                flexpart.retrieve(server, c.public, dates, c.request, times, c.inputdir)
-            except IOError:
-                myerror(c,'MARS request failed')
-
-            day+=datechunk
+                # we need to retrieve MARS data for this period (maximum one month)
+                flexpart = EIFlexpart(c,fluxes=True)
+                if day+datechunk-datetime.timedelta(days=1)<endp1:
+                    dates= day.strftime("%Y%m%d") + "/to/" + (day+datechunk-datetime.timedelta(days=1)).strftime("%Y%m%d") 
+                else:
+                    dates= day.strftime("%Y%m%d") + "/to/" + end.strftime("%Y%m%d") 
+                    
+                print "retrieve " + dates + " in dir " + c.inputdir
+                try:
+                    flexpart.retrieve(server, dates, times, c.inputdir)
+                except IOError:
+                    myerror(c,'MARS request failed')
+                    
+                day+=datechunk
     else:
         day=start
         while day<=end:
-            # we need to retrieve MARS data for this period (maximum one month)
-            flexpart = EIFlexpart(c,fluxes=True)
-            if day+datechunk-datetime.timedelta(days=1)<end:
-                dates= day.strftime("%Y%m%d") + "/to/" + (day+datechunk-datetime.timedelta(days=1)).strftime("%Y%m%d")
-            else:
-                dates= day.strftime("%Y%m%d") + "/to/" + end.strftime("%Y%m%d")
-
-            print "retrieve " + dates + " in dir " + c.inputdir
-            flexpart.retrieve(server, c.public, dates, c.request, times, c.inputdir)
-            day+=datechunk
+                # we need to retrieve MARS data for this period (maximum one month)
+                flexpart = EIFlexpart(c,fluxes=True)
+                if day+datechunk-datetime.timedelta(days=1)<end:
+                    dates= day.strftime("%Y%m%d") + "/to/" + (day+datechunk-datetime.timedelta(days=1)).strftime("%Y%m%d") 
+                else:
+                    dates= day.strftime("%Y%m%d") + "/to/" + end.strftime("%Y%m%d") 
+                    
+                print "retrieve " + dates + " in dir " + c.inputdir
+                flexpart.retrieve(server, dates, times, c.inputdir)
+                day+=datechunk
+        
 
 
-    if c.request == 0 or c.request == 2:
-        print 'removing content of '+c.inputdir
-        tobecleaned=glob.glob(c.inputdir+'/*__*.'+str(os.getppid())+'.*.grb')
-        for f in tobecleaned:
-            os.remove(f)
-
+    tobecleaned=glob.glob(c.inputdir+'/*__*.'+str(os.getppid())+'.*.grb')
+    for f in tobecleaned:
+        os.remove(f)
     day=start
     times=None
     while day<=end:
-
-            # we need to retrieve MARS data for this period (maximum one month)
-        flexpart = EIFlexpart(c)
-        if day+datechunk-datetime.timedelta(days=1)<end:
-            dates= day.strftime("%Y%m%d") + "/to/" + (day+datechunk-datetime.timedelta(days=1)).strftime("%Y%m%d")
-        else:
-            dates= day.strftime("%Y%m%d") + "/to/" + end.strftime("%Y%m%d")
-        print "retrieve " + dates + " in dir " + c.inputdir
-
-        flexpart.retrieve(server, c.public, dates, c.request, times, c.inputdir)
-        day+=datechunk
-
+        
+               # we need to retrieve MARS data for this period (maximum one month)
+            flexpart = EIFlexpart(c)
+            if day+datechunk-datetime.timedelta(days=1)<end:
+                dates= day.strftime("%Y%m%d") + "/to/" + (day+datechunk-datetime.timedelta(days=1)).strftime("%Y%m%d") 
+            else:
+                dates= day.strftime("%Y%m%d") + "/to/" + end.strftime("%Y%m%d") 
+            print "retrieve " + dates + " in dir " + c.inputdir
+            
+            flexpart.retrieve(server, dates, times, c.inputdir)
+            day+=datechunk
+    
 
 if __name__ == "__main__":
-
+    
     args,c=interpret_args_and_control()
     getMARSdata(args,c)
Index: python/install.py
===================================================================
--- python/install.py	(revision fb8810cda0dbbf0169e05332ef2fe5632ef1214e)
+++ python/install.py	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -1,11 +1,11 @@
 #!/usr/bin/env python
-#
+#             
 # This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-#
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
+# 
 # Functionality provided: Prepare input 3D-wind fields in hybrid coordinates + surface fields for FLEXPART runs
 #
 # Creation: October  2014 - Anne Fouilloux - University of Oslo
-# Extension November 2015 - Leopold Haimberger - University of Vienna for:
+# Extension November 2015 - Leopold Haimberger - University of Vienna for: 
 # - using the WebAPI also for general MARS retrievals
 # - job submission on ecgate and cca
@@ -15,9 +15,9 @@
 # - conversion into GRIB2
 # - conversion into .fp format for faster execution of FLEXPART
-#
+# 
 #
 # Further documentation may be obtained from www.flexpart.eu
-#
-# Requirements:
+# 
+# Requirements: 
 # in addition to a standard python 2.6 or 2.7 installation the following packages need to be installed
 # ECMWF WebMARS, gribAPI with python enabled, emoslib, ecaccess web toolkit, all available from https://software.ecmwf.int/
@@ -25,5 +25,5 @@
 # matplotlib (optional, for debugging)
 #
-#
+# 
 import calendar
 import shutil
@@ -56,73 +56,73 @@
     if args.install_target!=None:
         install_via_gateway(c,args.install_target)
-
+	
     else:
-        print 'Please specify installation target (local|ecgate|cca)'
-        print 'use -h or --help for help'
+	print 'Please specify installation target (local|ecgate|cca)'
+	print 'use -h or --help for help'
     sys.exit()
-
+        
 def install_via_gateway(c,target):
-
-    ecd=c.flexextractdir
+    
+    ecd=c.ecmwfdatadir
     template=ecd+'python/compilejob.temp'
     job=ecd+'python/compilejob.ksh'
     fo=open(job,'w')
     with open(template) as f:
-        fdata = f.read().split('\n')
-        for data in fdata:
-            if 'MAKEFILE=' in data:
-                if c.makefile is not None:
-                    data='export MAKEFILE='+c.makefile
-            if 'FLEXPART_ROOT_SCRIPTS=' in data:
-                if c.flexpart_root_scripts!='../':
-                    data='export FLEXPART_ROOT_SCRIPTS='+c.flexpart_root_scripts
-                else:
-                    data='export FLEXPART_ROOT_SCRIPTS=$HOME'
-            if target.lower()!='local':
-                if '--workdir' in data:
-                    data='#SBATCH --workdir=/scratch/ms/'+c.ecgid+'/'+c.ecuid
-                if '##PBS -o' in data:
-                    data='##PBS -o /scratch/ms/'+c.ecgid+'/'+c.ecuid+'flex_ecmwf.$Jobname.$Job_ID.out'
-                if 'FLEXPART_ROOT_SCRIPTS=' in data:
-                    if c.ec_flexpart_root_scripts!='../':
-                        data='export FLEXPART_ROOT_SCRIPTS='+c.ec_flexpart_root_scripts
-                    else:
-                        data='export FLEXPART_ROOT_SCRIPTS=$HOME'
-
-            fo.write(data+'\n')
+	fdata = f.read().split('\n')
+	for data in fdata:
+	    if 'MAKEFILE=' in data:
+		if c.makefile is not None:
+		    data='export MAKEFILE='+c.makefile
+	    if 'FLEXPART_ROOT_SCRIPTS=' in data:
+		if c.flexpart_root_scripts!='../':
+		    data='export FLEXPART_ROOT_SCRIPTS='+c.flexpart_root_scripts
+		else:
+		    data='export FLEXPART_ROOT_SCRIPTS=$HOME'
+	    if target.lower()!='local':
+		if '--workdir' in data:
+		    data='#SBATCH --workdir=/scratch/ms/'+c.ecgid+'/'+c.ecuid
+		if '##PBS -o' in data:
+		    data='##PBS -o /scratch/ms/'+c.ecgid+'/'+c.ecuid+'flex_ecmwf.$Jobname.$Job_ID.out'
+		if 'FLEXPART_ROOT_SCRIPTS=' in data:
+		    if c.ec_flexpart_root_scripts!='../':
+			data='export FLEXPART_ROOT_SCRIPTS='+c.ec_flexpart_root_scripts
+		    else:
+			data='export FLEXPART_ROOT_SCRIPTS=$HOME'
+			
+	    fo.write(data+'\n')
     f.close()
     fo.close()
+    
+    if target.lower()!='local':
+	template=ecd+'python/job.temp.o'
+	with open(template) as f:
+	    fdata = f.read().split('\n')
+	f.close()
+	fo=open(template[:-2],'w')
+	for data in fdata:
+	    if '--workdir' in data:
+		data='#SBATCH --workdir=/scratch/ms/'+c.ecgid+'/'+c.ecuid
+	    if '##PBS -o' in data:
+		data='##PBS -o /scratch/ms/'+c.ecgid+'/'+c.ecuid+'flex_ecmwf.$Jobname.$Job_ID.out'
+	    if  'export PATH=${PATH}:' in data:
+		data+=c.ec_flexpart_root_scripts+'/ECMWFDATA7.0/python'
+		
+	    if 'cat>>' in data or 'cat >>' in data:
+		i=data.index('>')
+		fo.write(data[:i]+data[i+1:]+'\n')
+		fo.write('GATEWAY '+c.gateway+'\n')
+		fo.write('DESTINATION '+c.destination+'\n')
+		fo.write('EOF\n')
 
-    if target.lower()!='local':
-        template=ecd+'python/job.temp.o'
-        with open(template) as f:
-            fdata = f.read().split('\n')
-        f.close()
-        fo=open(template[:-2],'w')
-        for data in fdata:
-            if '--workdir' in data:
-                data='#SBATCH --workdir=/scratch/ms/'+c.ecgid+'/'+c.ecuid
-            if '##PBS -o' in data:
-                data='##PBS -o /scratch/ms/'+c.ecgid+'/'+c.ecuid+'flex_ecmwf.$Jobname.$Job_ID.out'
-            if  'export PATH=${PATH}:' in data:
-                data+=c.ec_flexpart_root_scripts+'/flex_extract_v7.0.4/python'
-
-            if 'cat>>' in data or 'cat >>' in data:
-                i=data.index('>')
-                fo.write(data[:i]+data[i+1:]+'\n')
-                fo.write('GATEWAY '+c.gateway+'\n')
-                fo.write('DESTINATION '+c.destination+'\n')
-                fo.write('EOF\n')
-
-            fo.write(data+'\n')
-        fo.close()
-
-        job=ecd+'python/ECMWF_ENV'
-        fo=open(job,'w')
-        fo.write('ECUID '+c.ecuid+'\n')
-        fo.write('ECGID '+c.ecgid+'\n')
-        fo.write('GATEWAY '+c.gateway+'\n')
-        fo.write('DESTINATION '+c.destination+'\n')
-        fo.close()
+	    fo.write(data+'\n')
+	fo.close()
+	
+	job=ecd+'python/ECMWF_ENV'
+	fo=open(job,'w')
+	fo.write('ECUID '+c.ecuid+'\n')
+	fo.write('ECGID '+c.ecgid+'\n')
+	fo.write('GATEWAY '+c.gateway+'\n')
+	fo.write('DESTINATION '+c.destination+'\n')
+	fo.close()
 
 
@@ -130,62 +130,62 @@
     if target.lower()=='local':
         # compile CONVERT2
-        if c.flexpart_root_scripts==None or c.flexpart_root_scripts=='../':
-            print 'Warning: FLEXPART_ROOT_SCRIPTS has not been specified'
-            print 'Only CONVERT2 will be compiled in '+ecd+'/../src'
-        else:
-            c.flexpart_root_scripts=os.path.expandvars(os.path.expanduser(c.flexpart_root_scripts))
-            if os.path.abspath(ecd)!=os.path.abspath(c.flexpart_root_scripts):
-                os.chdir('/')
-                p=subprocess.check_call(['tar','-cvf',ecd+'../flex_extract_v7.0.4.tar',ecd+'python',ecd+'grib_templates',ecd+'src'])
-                try:
-                    os.makedirs(c.flexpart_root_scripts+'/flex_extract_v7.0.4')
-                except:
-                    pass
-                os.chdir(c.flexpart_root_scripts+'/flex_extract_v7.0.4')
-                p=subprocess.check_call(['tar','-xvf',ecd+'../flex_extract_v7.0.4.tar'])
-                os.chdir(c.flexpart_root_scripts+'/flex_extract_v7.0.4/src')
-
-        os.chdir('../src')
-        print 'install flex_extract_v7.0.4 software on '+target+' in directory '+os.getcwd()
-        if c.makefile==None:
-            makefile='Makefile.local.ifort'
-        else:
-            makefile=c.makefile
-        flist=glob.glob('*.mod')+glob.glob('*.o')
-        if flist:
-            p=subprocess.check_call(['rm']+flist)
+	if c.flexpart_root_scripts==None or c.flexpart_root_scripts=='../':
+	    print 'Warning: FLEXPART_ROOT_SCRIPTS has not been specified'
+	    print 'Only CONVERT2 will be compiled in '+ecd+'/../src'
+	else:
+	    c.flexpart_root_scripts=os.path.expandvars(os.path.expanduser(c.flexpart_root_scripts))
+	    if os.path.abspath(ecd)!=os.path.abspath(c.flexpart_root_scripts):
+		os.chdir('/')
+		p=subprocess.check_call(['tar','-cvf',ecd+'../ECMWFDATA7.0.tar',ecd+'python',ecd+'grib_templates',ecd+'src'])
+		try:
+		    os.makedirs(c.flexpart_root_scripts+'/ECMWFDATA7.0')
+		except:
+		    pass
+		os.chdir(c.flexpart_root_scripts+'/ECMWFDATA7.0')
+		p=subprocess.check_call(['tar','-xvf',ecd+'../ECMWFDATA7.0.tar'])
+		os.chdir(c.flexpart_root_scripts+'/ECMWFDATA7.0/src')
+		
+	os.chdir('../src')
+	print 'install ECMWFDATA7.0 software on '+target+' in directory '+os.getcwd()
+	if c.makefile==None:
+	    makefile='Makefile.local.ifort'
+	else:
+	    makefile=c.makefile
+	flist=glob.glob('*.mod')+glob.glob('*.o')
+	if flist:
+	    p=subprocess.check_call(['rm']+flist)	    
         try:
-            print 'Using makefile: '+makefile
-            p=subprocess.check_call(['make','-f',makefile])
-            p=subprocess.check_call(['ls','-l','CONVERT2'])
-        except:
-            print 'compile failed - please edit '+makefile+' or try another Makefile in the src directory.'
-            print 'most likely GRIB_API_INCLUDE_DIR, GRIB_API_LIB and EMOSLIB must be adapted.'
-            print 'Available Makefiles:'
-            print glob.glob('Makefile*')
-
+	    print 'Using makefile: '+makefile
+	    p=subprocess.check_call(['make','-f',makefile])
+	    p=subprocess.check_call(['ls','-l','CONVERT2'])
+	except:
+	    print 'compile failed - please edit '+makefile+' or try another Makefile in the src directory.'
+	    print 'most likely GRIB_API_INCLUDE_DIR, GRIB_API_LIB and EMOSLIB must be adapted.'
+	    print 'Available Makefiles:'
+	    print glob.glob('Makefile*')
+	
     elif target.lower()=='ecgate':
         os.chdir('/')
-        p=subprocess.check_call(['tar','-cvf',ecd+'../flex_extract_v7.0.4.tar',ecd+'python',ecd+'grib_templates',ecd+'src'])
-        try:
-            p=subprocess.check_call(['ecaccess-file-put',ecd+'../flex_extract_v7.0.4.tar','ecgate:/home/ms/'+c.ecgid+'/'+c.ecuid+'/flex_extract_v7.0.4.tar'])
-        except:
-            print 'ecaccess-file-put failed! Probably the eccert key has expired.'
-            exit(1)
+        p=subprocess.check_call(['tar','-cvf',ecd+'../ECMWFDATA7.0.tar',ecd+'python',ecd+'grib_templates',ecd+'src'])
+	try:
+	    p=subprocess.check_call(['ecaccess-file-put',ecd+'../ECMWFDATA7.0.tar','ecgate:/scratch/ms/'+c.ecgid+'/'+c.ecuid+'/ECMWFDATA7.0.tar'])
+	except:
+	    print 'ecaccess-file-put failed! Probably the eccert key has expired.'
+	    exit(1)
         p=subprocess.check_call(['ecaccess-job-submit','-queueName',target,ecd+'python/compilejob.ksh'])
-        print 'compilejob.ksh has been submitted to ecgate for installation in '+c.ec_flexpart_root_scripts+'/flex_extract_v7.0.4'
-        print 'You should get an email with subject flexcompile within the next few minutes'
+	print 'compilejob.ksh has been submitted to ecgate for installation in '+c.ec_flexpart_root_scripts+'/ECMWFDATA7.0'
+	print 'You should get an email with subject flexcompile within the next few minutes'
     elif target.lower()=='cca':
         os.chdir('/')
-        p=subprocess.check_call(['tar','-cvf',ecd+'../flex_extract_v7.0.4.tar',ecd+'python',ecd+'grib_templates',ecd+'src'])
-        try:
-            p=subprocess.check_call(['ecaccess-file-put',ecd+'../flex_extract_v7.0.4.tar','cca:/home/ms/'+c.ecgid+'/'+c.ecuid+'/flex_extract_v7.0.4.tar'])
-        except:
-            print 'ecaccess-file-put failed! Probably the eccert key has expired.'
-            exit(1)
-
+        p=subprocess.check_call(['tar','-cvf',ecd+'../ECMWFDATA7.0.tar',ecd+'python',ecd+'grib_templates',ecd+'src'])
+	try:
+	    p=subprocess.check_call(['ecaccess-file-put',ecd+'../ECMWFDATA7.0.tar','cca:/scratch/ms/'+c.ecgid+'/'+c.ecuid+'/ECMWFDATA7.0.tar'])
+	except:
+	    print 'ecaccess-file-put failed! Probably the eccert key has expired.'
+	    exit(1)
+	    
         p=subprocess.check_call(['ecaccess-job-submit','-queueName',target,ecd+'python/compilejob.ksh'])
-        print 'compilejob.ksh has been submitted to cca for installation in '+c.ec_flexpart_root_scripts+'/flex_extract_v7.0.4'
-        print 'You should get an email with subject flexcompile within the next few minutes'
+	print 'compilejob.ksh has been submitted to cca for installation in '+c.ec_flexpart_root_scripts+'/ECMWFDATA7.0'
+	print 'You should get an email with subject flexcompile within the next few minutes'
     else:
         print 'ERROR: unknown installation target ',target
@@ -193,5 +193,5 @@
     return
 
-
+            
 if __name__ == "__main__":
     main()
Index: python/job.ksh
===================================================================
--- python/job.ksh	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/job.ksh	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,132 @@
+#!/bin/ksh
+
+# ON ECGB:
+# start with ecaccess-job-submit -queueName ecgb NAME_OF_THIS_FILE  on gateway server
+# start with sbatch NAME_OF_THIS_FILE directly on machine
+
+#SBATCH --workdir=/scratch/ms/spatlh00/lh0
+#SBATCH --qos=normal
+#SBATCH --job-name=flex_ecmwf
+#SBATCH --output=flex_ecmwf.%j.out
+#SBATCH --error=flex_ecmwf.%j.out
+#SBATCH --mail-type=FAIL
+#SBATCH --time=12:00:00
+
+## CRAY specific batch requests
+##PBS -N flex_ecmwf
+##PBS -q np
+##PBS -S /usr/bin/ksh
+## -o /scratch/ms/spatlh00/lh0/flex_ecmwf.$PBS_JOBID.out
+## job output is in .ecaccess_DO_NOT_REMOVE
+##PBS -j oe
+##PBS -V
+##PBS -l EC_threads_per_task=24
+##PBS -l EC_memory_per_task=32000MB
+
+set -x
+
+case $HOST in
+  *ecg*)
+  module load python
+  module unload grib_api
+  module unload emos
+  module load grib_api/1.14.5
+  module load emos/437-r64
+#  export ECMWFDATA=$HOME/ECMWFDATA7.0
+#  export PYTHONPATH=$ECMWFDATA/python
+  export PATH=${PATH}:${HOME}/ECMWFDATA7.0/python
+  ;;
+  *cca*)
+  module switch PrgEnv-cray PrgEnv-intel
+  module load grib_api
+  module load emos
+  module load python
+  export SCRATCH=$TMPDIR
+#  export ECMWFDATA=$HOME/ECMWFDATA7.0
+#  export PYTHONPATH=$ECMWFDATA/python
+  export PATH=${PATH}:${HOME}/ECMWFDATA7.0/python
+  ;;
+#  *)
+#  export ECMWFDATA=$HOME/ECMWFDATA7.0
+#  export PATH=/opt/anaconda/bin:$ECMWFDATA/python:${PATH}
+#  export PYTHONPATH=/opt/anaconda/lib/python2.7/site-packages/grib_api:$ECMWFDATA/python
+#  export SCRATCH=$ECMWFDATA/python
+#  which python
+#  ;;
+esac
+
+cd $SCRATCH
+mkdir -p python$$
+cd python$$
+
+export CONTROL=CONTROL
+
+cat >$CONTROL<<EOF
+GATEWAY srvx7.img.univie.ac.at
+DESTINATION leo@genericSftp
+accuracy 16
+addpar 186 187 188 235 139 39 
+basetime None
+cwc 0
+date_chunk 3
+debug 0
+dpdeta 1
+dtime 3
+ecfsdir ectmp:/${USER}/econdemand/
+ecstorage 1
+ectrans 0
+end_date 20131107
+eta 0
+etadiff 0
+expver 1
+format GRIB1
+gauss 1
+grib2flexpart 0
+grid 5000
+inputdir ../work
+left -175000
+level 60
+levelist 1/to/60
+lower -90000
+mailfail ${USER}
+mailops ${USER}
+makefile None
+marsclass EI
+maxstep 11
+number OFF
+omega 0
+omegadiff 0
+outputdir ../work
+prefix EN
+resol 63
+right 180000
+smooth 0
+start_date 20131107
+step 00 01 02 03 04 05 00 07 08 09 10 11 00 01 02 03 04 05 00 07 08 09 10 11 
+stream OPER
+time 00 00 00 00 00 00 06 00 00 00 00 00 12 12 12 12 12 12 18 12 12 12 12 12 
+type AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC 
+upper 90000
+EOF
+
+
+submit.py --controlfile=$CONTROL --inputdir=./work --outputdir=./work >prot
+
+if [ $? -eq 0 ] ; then
+  l=0
+  for muser in `grep -i MAILOPS $CONTROL`; do
+      if [ $l -gt 0 ] ; then 
+         mail -s flex.${HOST}.$$ $muser <prot
+      fi
+      l=$(($l+1))
+  done
+else
+  l=0
+  for muser in `grep -i MAILFAIL $CONTROL`; do
+      if [ $l -gt 0 ] ; then 
+         mail -s "ERROR! flex.${HOST}.$$" $muser <prot
+      fi
+      l=$(($l+1))
+  done
+fi
+
Index: python/job.temp
===================================================================
--- python/job.temp	(revision 21938083773b1bba2e82ee565f34eba3445dfa1a)
+++ python/job.temp	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -5,5 +5,5 @@
 # start with sbatch NAME_OF_THIS_FILE directly on machine
 
-#SBATCH --workdir=/scratch/ms/at/km4a
+#SBATCH --workdir=/scratch/ms/spatlh00/lh0
 #SBATCH --qos=normal
 #SBATCH --job-name=flex_ecmwf
@@ -11,5 +11,5 @@
 #SBATCH --error=flex_ecmwf.%j.out
 #SBATCH --mail-type=FAIL
-#SBATCH --time=24:00:00
+#SBATCH --time=12:00:00
 
 ## CRAY specific batch requests
@@ -25,5 +25,5 @@
 
 set -x
-export VERSION=7.0.4
+
 case $HOST in
   *ecg*)
@@ -33,5 +33,7 @@
   module load grib_api/1.14.5
   module load emos/437-r64
-  export PATH=${PATH}:${HOME}/flex_extract_v7.0.4/python
+#  export ECMWFDATA=$HOME/ECMWFDATA7.0
+#  export PYTHONPATH=$ECMWFDATA/python
+  export PATH=${PATH}:${HOME}/ECMWFDATA7.0/python
   ;;
   *cca*)
@@ -41,6 +43,15 @@
   module load python
   export SCRATCH=$TMPDIR
-  export PATH=${PATH}:${HOME}/flex_extract_v7.0.4/python
+#  export ECMWFDATA=$HOME/ECMWFDATA7.0
+#  export PYTHONPATH=$ECMWFDATA/python
+  export PATH=${PATH}:${HOME}/ECMWFDATA7.0/python
   ;;
+#  *)
+#  export ECMWFDATA=$HOME/ECMWFDATA7.0
+#  export PATH=/opt/anaconda/bin:$ECMWFDATA/python:${PATH}
+#  export PYTHONPATH=/opt/anaconda/lib/python2.7/site-packages/grib_api:$ECMWFDATA/python
+#  export SCRATCH=$ECMWFDATA/python
+#  which python
+#  ;;
 esac
 
@@ -52,6 +63,6 @@
 
 cat >$CONTROL<<EOF
-GATEWAY srvx8.img.univie.ac.at
-DESTINATION annep@genericSftp
+GATEWAY srvx7.img.univie.ac.at
+DESTINATION leo@genericSftp
 EOF
 cat >>$CONTROL<<EOF
@@ -59,5 +70,5 @@
 
 
-submit.py --controlfile=$CONTROL --inputdir=./work --outputdir=./work 1> prot 2>&1
+submit.py --controlfile=$CONTROL --inputdir=./work --outputdir=./work >prot
 
 if [ $? -eq 0 ] ; then
Index: python/job.temp.o
===================================================================
--- python/job.temp.o	(revision 21938083773b1bba2e82ee565f34eba3445dfa1a)
+++ python/job.temp.o	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -11,5 +11,5 @@
 #SBATCH --error=flex_ecmwf.%j.out
 #SBATCH --mail-type=FAIL
-#SBATCH --time=24:00:00
+#SBATCH --time=12:00:00
 
 ## CRAY specific batch requests
@@ -25,5 +25,5 @@
 
 set -x
-export VERSION=7.0.4
+
 case $HOST in
   *ecg*)
@@ -33,4 +33,6 @@
   module load grib_api/1.14.5
   module load emos/437-r64
+#  export ECMWFDATA=$HOME/ECMWFDATA7.0
+#  export PYTHONPATH=$ECMWFDATA/python
   export PATH=${PATH}:
   ;;
@@ -41,6 +43,15 @@
   module load python
   export SCRATCH=$TMPDIR
+#  export ECMWFDATA=$HOME/ECMWFDATA7.0
+#  export PYTHONPATH=$ECMWFDATA/python
   export PATH=${PATH}:
   ;;
+#  *)
+#  export ECMWFDATA=$HOME/ECMWFDATA7.0
+#  export PATH=/opt/anaconda/bin:$ECMWFDATA/python:${PATH}
+#  export PYTHONPATH=/opt/anaconda/lib/python2.7/site-packages/grib_api:$ECMWFDATA/python
+#  export SCRATCH=$ECMWFDATA/python
+#  which python
+#  ;;
 esac
 
@@ -55,5 +66,5 @@
 
 
-submit.py --controlfile=$CONTROL --inputdir=./work --outputdir=./work 1> prot 2>&1
+submit.py --controlfile=$CONTROL --inputdir=./work --outputdir=./work >prot
 
 if [ $? -eq 0 ] ; then
Index: python/joboper.ksh
===================================================================
--- python/joboper.ksh	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/joboper.ksh	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,132 @@
+#!/bin/ksh
+
+# ON ECGB:
+# start with ecaccess-job-submit -queueName ecgb NAME_OF_THIS_FILE  on gateway server
+# start with sbatch NAME_OF_THIS_FILE directly on machine
+
+#SBATCH --workdir=/scratch/ms/spatlh00/lh0
+#SBATCH --qos=normal
+#SBATCH --job-name=flex_ecmwf
+#SBATCH --output=flex_ecmwf.%j.out
+#SBATCH --error=flex_ecmwf.%j.out
+#SBATCH --mail-type=FAIL
+#SBATCH --time=12:00:00
+
+## CRAY specific batch requests
+##PBS -N flex_ecmwf
+##PBS -q np
+##PBS -S /usr/bin/ksh
+## -o /scratch/ms/spatlh00/lh0/flex_ecmwf.$PBS_JOBID.out
+## job output is in .ecaccess_DO_NOT_REMOVE
+##PBS -j oe
+##PBS -V
+##PBS -l EC_threads_per_task=24
+##PBS -l EC_memory_per_task=32000MB
+
+set -x
+
+case $HOST in
+  *ecg*)
+  module load python
+  module unload grib_api
+  module unload emos
+  module load grib_api/1.14.5
+  module load emos/437-r64
+#  export ECMWFDATA=$HOME/ECMWFDATA7.0
+#  export PYTHONPATH=$ECMWFDATA/python
+  export PATH=${PATH}:${HOME}/ECMWFDATA7.0/python
+  ;;
+  *cca*)
+  module switch PrgEnv-cray PrgEnv-intel
+  module load grib_api
+  module load emos
+  module load python
+  export SCRATCH=$TMPDIR
+#  export ECMWFDATA=$HOME/ECMWFDATA7.0
+#  export PYTHONPATH=$ECMWFDATA/python
+  export PATH=${PATH}:${HOME}/ECMWFDATA7.0/python
+  ;;
+#  *)
+#  export ECMWFDATA=$HOME/ECMWFDATA7.0
+#  export PATH=/opt/anaconda/bin:$ECMWFDATA/python:${PATH}
+#  export PYTHONPATH=/opt/anaconda/lib/python2.7/site-packages/grib_api:$ECMWFDATA/python
+#  export SCRATCH=$ECMWFDATA/python
+#  which python
+#  ;;
+esac
+
+cd $SCRATCH
+mkdir -p python$$
+cd python$$
+
+export CONTROL=CONTROL
+
+cat >$CONTROL<<EOF
+GATEWAY srvx7.img.univie.ac.at
+DESTINATION leo@genericSftp
+accuracy 16
+addpar 186 187 188 235 139 39 
+basetime None
+cwc 0
+date_chunk 3
+debug 0
+dpdeta 1
+dtime 3
+ecfsdir ectmp:/${USER}/econdemand/
+ecstorage 1
+ectrans 0
+start_date ${MSJ_YEAR}${MSJ_MONTH}${MSJ_DAY}
+eta 0
+etadiff 0
+expver 1
+format GRIB1
+gauss 1
+grib2flexpart 0
+grid 5000
+inputdir ../work
+left -175000
+level 60
+levelist 1/to/60
+lower -90000
+mailfail ${USER}
+mailops ${USER}
+makefile None
+marsclass EI
+maxstep 11
+number OFF
+omega 0
+omegadiff 0
+outputdir ../work
+prefix EN
+resol 63
+right 180000
+smooth 0
+start_date ${MSJ_YEAR}${MSJ_MONTH}${MSJ_DAY}
+step 00 01 02 03 04 05 00 07 08 09 10 11 00 01 02 03 04 05 00 07 08 09 10 11 
+stream OPER
+time 00 00 00 00 00 00 06 00 00 00 00 00 12 12 12 12 12 12 18 12 12 12 12 12 
+type AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC 
+upper 90000
+EOF
+
+
+submit.py --controlfile=$CONTROL --inputdir=./work --outputdir=./work >prot
+
+if [ $? -eq 0 ] ; then
+  l=0
+  for muser in `grep -i MAILOPS $CONTROL`; do
+      if [ $l -gt 0 ] ; then 
+         mail -s flex.${HOST}.$$ $muser <prot
+      fi
+      l=$(($l+1))
+  done
+else
+  l=0
+  for muser in `grep -i MAILFAIL $CONTROL`; do
+      if [ $l -gt 0 ] ; then 
+         mail -s "ERROR! flex.${HOST}.$$" $muser <prot
+      fi
+      l=$(($l+1))
+  done
+fi
+
Index: thon/opposite.py
===================================================================
--- python/opposite.py	(revision 21938083773b1bba2e82ee565f34eba3445dfa1a)
+++ 	(revision )
@@ -1,53 +1,0 @@
-import os,sys,glob
-from gribapi import *
-import numpy
-
-def opposite(prefix):
-    fclist=glob.glob(prefix+'*'+'N000')
-    
-    for fcn in fclist:
-        nprefix=fcn.split('N000')[0]
-        f=open(nprefix+'N{:0>3}'.format(0),'rb')
-        fcvalues=[]
-        while 1:
-            try:
-                fid=grib_new_from_file(f)
-                if fid is not None:
-                    fcvalues.append(grib_get_array(fid,'values'))
-                    grib_release(fid)
-                else:
-                    break
-            except:
-                break
-        for i in range(1,26):
-            try:
-                g=open(nprefix+'N{:0>3}'.format(i),'rb')
-                h=open(nprefix+'N{:0>3}'.format(i+25),'wb')
-                j=0
-                while 1:
-                    try:
-                        gid=grib_new_from_file(g)
-                        if gid is not None:
-                            values=grib_get_array(gid,'values')
-                            grib_set_array(gid,'values',values-2*(values-fcvalues[j]))
-                            grib_set(gid, 'number', i+25)
-                            grib_write(gid,h)
-                            grib_release(gid)
-                            j+=1
-                        else:
-                            break
-                    except:
-                        break
-                g.close()
-                h.close()
-                print('wrote '+nprefix+'N{:0>3}'.format(i+25))
-            except:
-                break
-        f.close()
-    return
-                
-if __name__ == "__main__":
-    opposite(os.path.expandvars('EN'))
-
-               
-        
Index: python/plot_retrieved.py
===================================================================
--- python/plot_retrieved.py	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/plot_retrieved.py	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,277 @@
+#!/usr/bin/env python
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
+# 
+# Functionality provided: Simple tool for creating maps and time series of retrieved fields.
+# 
+# Requirements: 
+# in addition to a standard python 2.6 or 2.7 installation the following packages need to be installed
+# ECMWF WebMARS, gribAPI with python enabled, emoslib, ecaccess web toolkit, all available from https://software.ecmwf.int/
+# dateutils
+# matplotlib (optional, for debugging)
+
+import datetime
+import time
+import os,inspect,sys,glob
+import socket
+# add path to submit.py to pythonpath so that python finds its buddies
+localpythonpath=os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
+if localpythonpath not in sys.path:
+    sys.path.append(localpythonpath)
+    
+from matplotlib.pylab import *
+import matplotlib.patches as mpatches
+from mpl_toolkits.basemap import Basemap,addcyclic
+import matplotlib.colors as mcolors
+from matplotlib.font_manager import FontProperties
+from matplotlib.patches import Polygon
+import matplotlib.cm as cmx
+import matplotlib.colors as colors
+from argparse import ArgumentParser,ArgumentDefaultsHelpFormatter
+
+from FlexpartTools import interpret_args_and_control,silentremove,product,Control
+from GribTools import GribTools
+from gribapi import *
+from rasotools.utils import stats
+
+def plot_retrieved(args,c):
+
+    start = datetime.datetime.strptime(c.start_date,'%Y%m%d%H')
+    end = datetime.datetime.strptime(c.end_date,'%Y%m%d%H')
+
+    c.paramIds=asarray(c.paramIds,dtype='int')
+    c.levels=asarray(c.levels,dtype='int')
+    c.area=asarray(c.area)
+    
+    index_keys=["date","time","step"]
+    indexfile=c.inputdir+"/date_time_stepRange.idx"
+    silentremove(indexfile)
+    files=glob.glob(c.inputdir+'/'+c.prefix+'*')
+    grib=GribTools(files)
+    iid=grib.index(index_keys=index_keys, index_file = indexfile)
+
+    gdict=dict(Ni = 360, Nj = 181,  iScansNegatively = 0,  jScansPositively = 0,
+               jPointsAreConsecutive = 0,  alternativeRowScanning = 0,
+               latitudeOfFirstGridPointInDegrees = 90,
+               longitudeOfFirstGridPointInDegrees = 181,
+               latitudeOfLastGridPointInDegrees = -90,
+               longitudeOfLastGridPointInDegrees = 180,
+               iDirectionIncrementInDegrees = 1,
+               jDirectionIncrementInDegrees = 1
+               )
+
+    index_vals = []
+    for key in index_keys:
+        key_vals = grib_index_get(iid,key)
+        print key_vals
+
+        index_vals.append(key_vals)
+    
+    fdict=dict()
+    fmeta=dict()
+    fstamp=dict()
+    for p in c.paramIds:
+        for l in c.levels:
+            key='{:0>3}_{:0>3}'.format(p,l)
+            fdict[key]=[]
+            fmeta[key]=[]
+            fstamp[key]=[]
+    for prod in product(*index_vals):
+        for i in range(len(index_keys)):
+            grib_index_select(iid,index_keys[i],prod[i])
+
+        gid = grib_new_from_index(iid)
+#        if gid is not None:
+
+        while(gid is not None):
+            date = grib_get(gid, 'date')
+            fdate= datetime.datetime(date/10000,mod(date,10000)/100,mod(date,100))
+            gtime = grib_get(gid, 'time')
+            step = grib_get(gid, 'step')
+            fdatetime=fdate+datetime.timedelta(hours=gtime/100)
+#            if fdatetime<start or fdatetime>end:
+#                break
+            gtype = grib_get(gid, 'type')
+            paramId = grib_get(gid, 'paramId')
+            parameterName = grib_get(gid, 'parameterName')
+            level=grib_get(gid,'level')
+            if step>=c.start_step and step <=c.end_step and fdatetime>=start and fdatetime<=end and paramId in c.paramIds and level in c.levels:
+                key='{:0>3}_{:0>3}'.format(paramId,level)
+                print key
+                fdatetimestep=fdatetime+datetime.timedelta(hours=step)
+                if len(fstamp)==0:
+                    fstamp[key].append(fdatetimestamp)    
+                    fmeta[key].append((paramId,parameterName,gtype,fdatetime,gtime,step,level))
+                    fdict[key].append(flipud(reshape(grib_get_values(gid),[gdict['Nj'],gdict['Ni']])))
+                else:
+                    i=0
+                    inserted=False
+                    for i in range(len(fstamp[key])):
+                        if fdatetimestep<fstamp[key][i]:
+                            fstamp[key][i:i]=[fdatetimestep]
+                            fmeta[key][i:i]=[(paramId,parameterName,gtype,fdatetime,gtime,step,level)]
+                            fdict[key][i:i]=[flipud(reshape(grib_get_values(gid),[gdict['Nj'],gdict['Ni']]))]
+                            inserted=True
+                            break
+                    if not inserted:
+                        fstamp[key].append(fdatetimestep)
+                        fmeta[key].append((paramId,parameterName,gtype,fdatetime,gtime,step,level))
+                        fdict[key].append(flipud(reshape(grib_get_values(gid),[gdict['Nj'],gdict['Ni']])))
+                    
+
+            grib_release(gid)
+            gid = grib_new_from_index(iid)
+            
+    for k in fdict.keys():
+        fml=fmeta[k]
+        fdl=fdict[k]
+        
+        for fd,fm in zip(fdl,fml):
+            ftitle=fm[1]+' {} '.format(fm[-1])+datetime.datetime.strftime(fm[3],'%Y%m%d%H')+' '+stats(fd)
+            pname='_'.join(fm[1].split())+'_{}_'.format(fm[-1])+datetime.datetime.strftime(fm[3],'%Y%m%d%H')+'.{:0>3}'.format(fm[5])
+            plotmap(fd, fm,gdict,ftitle,pname+'.eps')
+        
+    for k in fdict.keys():
+        fml=fmeta[k]
+        fdl=fdict[k]
+        fsl=fstamp[k]
+        if fdl:
+            fm=fml[0]
+            fd=fdl[0]
+            ftitle=fm[1]+' {} '.format(fm[-1])+datetime.datetime.strftime(fm[3],'%Y%m%d%H')+' '+stats(fd)
+            pname='_'.join(fm[1].split())+'_{}_'.format(fm[-1])+datetime.datetime.strftime(fm[3],'%Y%m%d%H')+'.{:0>3}'.format(fm[5])
+            lat=-20
+            lon=20
+            plottimeseries(fdl,fml,fsl,lat,lon, gdict, ftitle, pname+'.eps')   
+    
+def plottimeseries(flist,fmetalist,ftimestamps,lat,lon,gdict,ftitle,filename):
+    t1=time.time()
+    latindex=(lat+90)*180/(gdict['Nj']-1)
+    lonindex=(lon+179)*360/gdict['Ni']
+    farr=asarray(flist)
+    ts=farr[:,latindex,lonindex]
+    f=plt.figure(figsize=(12,6.7))
+    plt.plot(ftimestamps,ts)
+    plt.title(ftitle)
+    savefig(c.outputdir+'/'+filename)
+    print 'created ',c.outputdir+'/'+filename
+    plt.close(f)
+    print time.time()-t1,'s'
+    
+def plotmap(flist,fmetalist,gdict,ftitle,filename):
+    t1=time.time()
+    f=plt.figure(figsize=(12,6.7))
+    mbaxes = f.add_axes([0.05, 0.15, 0.8, 0.7]) 
+    m =Basemap(llcrnrlon=-180.,llcrnrlat=-90.,urcrnrlon=180,urcrnrlat=90.)
+    #if bw==0 :
+        #fill_color=rgb(0.6,0.8,1)
+    #else:
+        #fill_color=rgb(0.85,0.85,0.85)
+    
+    lw=0.3
+    m.drawmapboundary()
+    parallels = arange(-90.,91,90.)
+    # labels = [left,right,top,bottom]
+    m.drawparallels(parallels,labels=[True,True,True,True],linewidth=lw)
+    meridians = arange(-180.,181.,60.)
+    m.drawmeridians(meridians,labels=[True,True,True,True],linewidth=lw)
+    m.drawcoastlines(linewidth=lw)
+    xleft=gdict['longitudeOfFirstGridPointInDegrees']
+    if xleft>180.0:
+        xleft-=360. 
+    x=linspace(xleft,gdict['longitudeOfLastGridPointInDegrees'],gdict['Ni'])
+    y=linspace(gdict['latitudeOfLastGridPointInDegrees'],gdict['latitudeOfFirstGridPointInDegrees'],gdict['Nj'])
+    xx, yy = m(*meshgrid(x,y))
+
+    s=m.contourf(xx,yy, flist)
+    title(ftitle,y=1.1)
+    cbaxes = f.add_axes([0.9, 0.2, 0.04, 0.6]) 
+    cb=colorbar(cax=cbaxes)
+    
+    savefig(c.outputdir+'/'+filename)
+    print 'created ',c.outputdir+'/'+filename
+    plt.close(f)
+    print time.time()-t1,'s'
+
+
+def interpret_plotargs(*args,**kwargs):
+
+    parser = ArgumentParser(description='Retrieve FLEXPART input from ECMWF MARS archive',
+                            formatter_class=ArgumentDefaultsHelpFormatter)
+
+# the most important arguments	
+    parser.add_argument("--start_date", dest="start_date",
+                        help="start date YYYYMMDD")
+    parser.add_argument( "--end_date", dest="end_date",
+                         help="end_date YYYYMMDD")
+
+    parser.add_argument("--start_step", dest="start_step",
+                        help="start step in hours")
+    parser.add_argument( "--end_step", dest="end_step",
+                         help="end_step in hours")
+
+# some arguments that override the default in the control file
+    parser.add_argument("--levelist", dest="levelist",help="Vertical levels to be retrieved, e.g. 30/to/60")
+    parser.add_argument("--area", dest="area", help="area defined as north/west/south/east")
+    parser.add_argument("--paramIds", dest="paramIds", help="parameter IDs")
+    parser.add_argument("--prefix", dest="prefix",default='EN', help="output file name prefix")
+
+# set the working directories
+    parser.add_argument("--inputdir", dest="inputdir",default=None,
+                        help="root directory for storing intermediate files")
+    parser.add_argument("--outputdir", dest="outputdir",default=None,
+                        help="root directory for storing output files")
+    parser.add_argument("--flexpart_root_scripts", dest="flexpart_root_scripts",
+                        help="FLEXPART root directory (to find grib2flexpart and COMMAND file)\n\
+                              Normally ECMWFDATA resides in the scripts directory of the FLEXPART distribution")
+
+    parser.add_argument("--controlfile", dest="controlfile",default='CONTROL.temp',
+                        help="file with control parameters")
+    args = parser.parse_args()
+
+    try:
+        c=Control(args.controlfile)
+    except IOError:
+        try:
+            c=Control(localpythonpath+args.controlfile)
+
+        except:
+            print 'Could not read control file "'+args.controlfile+'"'
+            print 'Either it does not exist or its syntax is wrong.'
+            print 'Try "'+sys.argv[0].split('/')[-1]+' -h" to print usage information'
+            exit(1)
+    
+    if args.levelist:        
+        c.levels=args.levelist.split('/')
+    else:
+        c.levels=[0]
+    if args.area:
+        c.area=args.area.split('/')
+    else:
+        c.area='[0,0]'
+    
+    c.paramIds=args.paramIds.split('/')
+    if args.start_step:
+        c.start_step=int(args.start_step)
+    else:
+        c.start_step=0
+    if args.end_step:
+        c.end_step=int(args.end_step)
+    else:
+        c.end_step=0
+
+    c.start_date=args.start_date
+    c.end_date=args.end_date
+    c.prefix=args.prefix
+    c.inputdir=args.inputdir
+    if args.outputdir:
+        c.outputdir=args.outputdir
+    else:
+        c.outputdir=c.inputdir
+    
+        return args,c
+
+if __name__ == "__main__":
+    
+    args,c=interpret_plotargs()
+    plot_retrieved(args,c)
Index: python/prepareFLEXPART.py
===================================================================
--- python/prepareFLEXPART.py	(revision 21938083773b1bba2e82ee565f34eba3445dfa1a)
+++ python/prepareFLEXPART.py	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -1,11 +1,11 @@
 #!/usr/bin/env python
-#
+#             
 # This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-#
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
+# 
 # Functionality provided: Prepare input 3D-wind fields in hybrid coordinates + surface fields for FLEXPART runs
 #
 # Creation: October  2014 - Anne Fouilloux - University of Oslo
-# Extension November 2015 - Leopold Haimberger - University of Vienna for:
+# Extension November 2015 - Leopold Haimberger - University of Vienna for: 
 # - using the WebAPI also for general MARS retrievals
 # - job submission on ecgate and cca
@@ -15,11 +15,11 @@
 # - conversion into GRIB2
 # - conversion into .fp format for faster execution of FLEXPART
-#
-# Requirements:
+# 
+# Requirements: 
 # in addition to a standard python 2.6 or 2.7 installation the following packages need to be installed
 # ECMWF WebMARS, gribAPI with python enabled, emoslib, ecaccess web toolkit, all available from https://software.ecmwf.int/
 # dateutils
 # matplotlib (optional, for debugging)
-#
+# 
 import calendar
 import shutil
@@ -37,5 +37,4 @@
 from GribTools import GribTools
 from FlexpartTools import EIFlexpart, Control,interpret_args_and_control, cleanup
-from opposite import opposite
 
 hostname=socket.gethostname()
@@ -47,5 +46,5 @@
 except ImportError:
     ecapi=False
-
+    
 
 def prepareFLEXPART(args,c):
@@ -54,5 +53,5 @@
 
     namelist='fort.4'
-
+    
     if not args.ppid:
         c.ppid=str(os.getppid())
@@ -79,6 +78,6 @@
     inputfiles.listFiles(c.inputdir, '*OG_acc_SL*.'+c.ppid+'.*')
     if not os.path.exists(c.outputdir):
-        os.makedirs(c.outputdir)
-
+	os.makedirs(c.outputdir)
+	
     flexpart = EIFlexpart(c,fluxes=True)
     flexpart.create_namelist(c,'fort.4')
@@ -98,11 +97,11 @@
 
     if int(c.debug)!=0:
-        print('Temporary files left intact')
+	print('Temporary files left intact')
     else:
-        cleanup(c)
+	cleanup(c)
 
 if __name__ == "__main__":
     args,c=interpret_args_and_control()
     prepareFLEXPART(args,c)
-
-
+    cleanup(c)
+    
Index: python/set_CTBTO_env.csh
===================================================================
--- python/set_CTBTO_env.csh	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/set_CTBTO_env.csh	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,12 @@
+#!/bin/csh
+
+# script to prepare CTBTO environment for
+# ECMWFDATA7.0
+# 
+# Leo Haimberger 1.3.2016
+
+setenv PATH /dvl/atm/klinkl/software/local/bin:$PATH
+setenv PYTHONPATH /dvl/atm/klinkl/software/local/lib/python2.7/site-packages/grib_api
+setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/dvl/atm/klinkl/software/local/lib/
+setenv GRIB_API_INCLUDE_DIR /dvl/atm/klinkl/software/local/include/
+setenv GRIB_API_LIB '-L/dvl/atm/klinkl/software/local/lib -Bstatic  -lgrib_api_f77 -lgrib_api_f90 -lgrib_api -lemosR64 -Bdynamic  -lm  -ljasper'
Index: python/set_CTBTO_env.sh
===================================================================
--- python/set_CTBTO_env.sh	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/set_CTBTO_env.sh	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# script to prepare CTBTO environment for
+# ECMWFDATA7.0
+# 
+# Leo Haimberger 1.3.2016
+
+export PATH=/dvl/atm/klinkl/software/local/bin:$PATH
+export PYTHONPATH=/dvl/atm/klinkl/software/local/lib/python2.7/site-packages/grib_api
+export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/dvl/atm/klinkl/software/local/lib/
+export GRIB_API_INCLUDE_DIR=/dvl/atm/klinkl/software/local/include/
+export GRIB_API_LIB='-L/dvl/atm/klinkl/software/local/lib -Bstatic  -lgrib_api_f77 -lgrib_api_f90 -lgrib_api -lemosR64 -Bdynamic  -lm  -ljasper'
Index: python/submit.py
===================================================================
--- python/submit.py	(revision 75ed4bce3d3979471b68b6daaded3500743d31e1)
+++ python/submit.py	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -1,11 +1,11 @@
 #!/usr/bin/env python
-#
+#             
 # This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-#
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
+# 
 # Functionality provided: Prepare input 3D-wind fields in hybrid coordinates + surface fields for FLEXPART runs
 #
 # Creation: October  2014 - Anne Fouilloux - University of Oslo
-# Extension November 2015 - Leopold Haimberger - University of Vienna for:
+# Extension November 2015 - Leopold Haimberger - University of Vienna for: 
 # - using the WebAPI also for general MARS retrievals
 # - job submission on ecgate and cca
@@ -17,6 +17,6 @@
 #
 # Further documentation may be obtained from www.flexpart.eu
-#
-# Requirements:
+# 
+# Requirements: 
 # in addition to a standard python 2.6 or 2.7 installation the following packages need to be installed
 # ECMWF WebMARS, gribAPI with python enabled, emoslib, ecaccess web toolkit, all available from https://software.ecmwf.int/
@@ -24,5 +24,5 @@
 # matplotlib (optional, for debugging)
 #
-#
+# 
 import calendar
 import shutil
@@ -56,20 +56,17 @@
             c.outputdir=os.path.join(calledfromdir,c.outputdir)
         getMARSdata(args,c)
-	if c.request == 0 or c.request == 2:
-            prepareFLEXPART(args,c)
-            normalexit(c)
-        else:
-            normalexit(c)
+        prepareFLEXPART(args,c)
+        normalexit(c)
     else:
         submit(args.job_template,c,args.queue)
-
-
+        
+        
 def submit(jtemplate,c,queue):
-
+    
     f=open(jtemplate)
     lftext=f.read().split('\n')
     insert_point=lftext.index('EOF')
     f.close()
-
+    
     clist=c.tolist()
     colist=[]
@@ -78,5 +75,5 @@
         if 'maxstep' in elem:
             mt=int(elem.split(' ')[1])
-
+            
     for elem in clist:
         if 'start_date' in elem:
@@ -89,17 +86,17 @@
             elem='time '+'${MSJ_BASETIME} {MSJ_BASETIME}'
         colist.append(elem)
-
+        
     lftextondemand=lftext[:insert_point]+clist+lftext[insert_point+2:]
     lftextoper=lftext[:insert_point]+colist+lftext[insert_point+2:]
-
+    
     h=open('job.ksh','w')
-    h.write('\n'.join(lftextondemand))
+    h.write('\n'.join(lftextondemand))  
     h.close()
-
+    
     h=open('joboper.ksh','w')
-    h.write('\n'.join(lftextoper))
+    h.write('\n'.join(lftextoper))  
     h.close()
-
-    try:
+   
+    try:    
         p=subprocess.check_call(['ecaccess-job-submit','-queueName',queue,'job.ksh'])
     except:
@@ -111,5 +108,5 @@
 
 
-
+            
 if __name__ == "__main__":
     main()
Index: python/testsuite.json
===================================================================
--- python/testsuite.json	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/testsuite.json	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,79 @@
+{
+"install": {
+"script": "install.py",
+"control": null,
+"inputdir": null,
+"ecuid":"lh0",
+"ecgid":"spatlh00",
+"gateway":"srvx7.img.univie.ac.at",
+"destination":"leo@genericSftp",
+"local": {"target":"local"},
+"local_flexpart": {"target":"local","flexpart_root_scripts":"$FLEXPART_ROOT_SCRIPTS"},
+"ecgate": {"target":"ecgate"},
+"cca": {"target":"cca"}
+},
+"default": {
+"script": "submit.py",
+"control": null,
+"inputdir": null,
+"start_date": "20131107",
+"local": {},
+"local_flexpart": {"flexpart_root_scripts":"$FLEXPART_ROOT_SCRIPTS"},
+"ecgate": {"queue":"ecgate"},
+"cca": {"queue":"cca"}
+},
+"work": {
+"script": "submit.py",
+"control": null,
+"start_date": "20131107",
+"inputdir": "$SCRATCH/work",
+"local_flexpart": {"flexpart_root_scripts":"$FLEXPART_ROOT_SCRIPTS"}
+},
+"fc": {
+"script": "submit.py",
+"control": "CONTROL_FC",
+"inputdir": "$SCRATCH/workfc",
+"local_flexpart": {"flexpart_root_scripts":"$FLEXPART_ROOT_SCRIPTS"}
+},
+"cv": {
+"script": "submit.py",
+"control": "CONTROL_CV",
+"inputdir": "$SCRATCH/workcv",
+"start_date": "20131107",
+"local_flexpart": {"flexpart_root_scripts":"$FLEXPART_ROOT_SCRIPTS"}
+},
+"hires": {
+"script": "submit.py",
+"control": "CONTROL_HIRES",
+"inputdir": "$SCRATCH/workhires",
+"local_flexpart": {"flexpart_root_scripts":"$FLEXPART_ROOT_SCRIPTS"},
+"ecgate": {"queue":"ecgate"}
+},
+"hiresgauss": {
+"script": "submit.py",
+"control": "CONTROL_HIRESGAUSS",
+"inputdir": "$SCRATCH/workhiresgauss",
+"basetime": "00",
+"local_flexpart": {"flexpart_root_scripts":"$FLEXPART_ROOT_SCRIPTS"},
+"ecgate": {"queue":"ecgate"},
+"cca": {"queue":"cca"}
+},
+"ops": {
+"script": "submit.py",
+"start_date": "20131108",
+"control": "CONTROL_OPS_V6.0_4V.temp",
+"inputdir": "$SCRATCH/workops2",
+"local_flexpart": {"basetime":"00"},
+"local_flexpart12": {"basetime":"12"},
+"ecgate": {"queue":"ecgate","basetime":"00"}
+},
+"opsfc": {
+"script": "submit.py",
+"start_date": "20131108",
+"control": "CONTROL_OPS_V6.0",
+"inputdir": "$SCRATCH/workopsfc",
+"local_flexpart": {"basetime":"00"},
+"local_flexpart12": {"basetime":"12"},
+"ecgate": {"queue":"ecgate","basetime":"00"}
+}
+}
Index: python/testsuite.py
===================================================================
--- python/testsuite.py	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ python/testsuite.py	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
+# 
+# Leopold Haimberger, Dec 2015
+#
+# Functionality provided: This script triggers the ECMWFDATA test suite. Call with
+# testsuite.py [test group]
+# 
+#
+# Further documentation may be obtained from www.flexpart.eu
+# 
+# Test groups are specified in testsuite.json
+# in addition to a standard python 2.6 or 2.7 installation the following packages need to be installed
+# ECMWF WebMARS, gribAPI with python enabled, emoslib, ecaccess web toolkit, all available from https://software.ecmwf.int/
+# dateutils
+# matplotlib (optional, for debugging)
+
+import os,sys
+import json
+import subprocess
+try:
+    taskfile=open('testsuite.json')
+except:
+    print 'could not open suite definition file testsuite.json'
+    exit()
+
+if not os.path.isfile('../src/CONVERT2'):
+    print '../src/CONVERT2 could not be found'
+    print 'please run "install.py --target=local" first'
+    exit()
+
+fprs=os.getenv('FLEXPART_ROOT_SCRIPTS')
+if fprs is None:
+    print 'FLEXPART_ROOT_SCRIPTS not set .. some test jobs may fail'
+
+tasks=json.load(taskfile,encoding='latin-1')
+taskfile.close()
+if not os.path.exists('../test'):
+    os.makedirs('../test')
+if len(sys.argv)>1:
+    groups=sys.argv[1:] 
+else:
+    groups=['xinstall','default','ops','work','cv','fc']#,'hires']
+jobcounter=0
+jobfailed=0
+for g in groups:
+    try:
+        tk,tv=g,tasks[g]
+    except:
+        continue
+    garglist=[]
+    for ttk,ttv in tv.iteritems():
+        if isinstance(ttv,basestring):    
+            if ttk!='script':
+                garglist.append('--'+ttk)
+                if '$'==ttv[0]:
+                    garglist.append(os.path.expandvars(ttv))
+                else:
+                    garglist.append(ttv)
+    for ttk,ttv in tv.iteritems():
+        if isinstance(ttv,dict):
+            arglist=[]
+            for tttk,tttv in ttv.iteritems():
+                if isinstance(tttv,basestring):    
+                        arglist.append('--'+tttk)
+                        if '$' in tttv[0]:
+                            arglist.append(os.path.expandvars(tttv))                        
+                        else:
+                            arglist.append(tttv)
+            print 'Command: ',' '.join([tv['script']]+garglist+arglist)
+            o='../test/'+tk+'_'+ttk+'_'+'_'.join(ttv.keys())
+            print 'Output will be sent to ',o
+            f=open(o,'w')
+            try:
+                p=subprocess.check_call([tv['script']]+garglist+arglist,stdout=f,stderr=f)
+            except:
+                f.write('\nFAILED\n')
+                print 'FAILED'
+                jobfailed+=1
+            jobcounter+=1
+            f.close()
+
+print 'Test suite tasks completed'
+print str(jobcounter-jobfailed)+' successful, '+str(jobfailed)+' failed'
+print 'If tasks have been submitted via ECACCESS please check emails'
+                                       
+#print tasks
Index: src/Makefile.CRAY
===================================================================
--- src/Makefile.CRAY	(revision ced5d274f0e78ffb0d5892cf12addea47320a902)
+++ src/Makefile.CRAY	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -10,4 +10,9 @@
 .SUFFIXES: .o .c .c~ .f .f~ .F90 .f90 .f90~ .f95 .f95~ .F .F~ .y .y~ .l .l~ \
            .s .s~ .sh .sh~ .h .h~ .C .C~ .a
+
+
+#GRIB_API_INCLUDE_DIR=/usr/local/gcc-4.9.3/grib1.12.3//include
+#GRIB_API_LIB=-openmp -L/usr/local/gcc-4.9.3/grib1.12.3/lib -Bstatic  -lgrib_api_f77 -lgrib_api_f90 -lgrib_api -Bdynamic  -lm  -ljasper
+#EMOSLIB=-lemosR64
 
 OPT	= 
@@ -47,6 +52,6 @@
 	$(F90C) -c -g -O3 ftrafo.f
 
-$(BINDIR)/$(EXE):	phgrreal.o grphreal.o ftrafo.o rwGRIB2.o  posnam.o preconvert.o
-	$(F90C) $(DEBUG) $(OPT) -o $(BINDIR)/$(EXE) ftrafo.o phgrreal.o grphreal.o rwGRIB2.o posnam.o preconvert.o ${LIB}
+$(BINDIR)/CONVERT2:	phgrreal.o grphreal.o ftrafo.o rwGRIB2.o  posnam.o preconvert.o
+	$(F90C) $(DEBUG) $(OPT) -o $(BINDIR)/CONVERT2 ftrafo.o phgrreal.o grphreal.o rwGRIB2.o posnam.o preconvert.o ${LIB}
 
 
Index: src/Makefile.gfortran
===================================================================
--- src/Makefile.gfortran	(revision ced5d274f0e78ffb0d5892cf12addea47320a902)
+++ src/Makefile.gfortran	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -10,4 +10,9 @@
 .SUFFIXES: .o .c .c~ .f .f~ .F90 .f90 .f90~ .f95 .f95~ .F .F~ .y .y~ .l .l~ \
            .s .s~ .sh .sh~ .h .h~ .C .C~ .a
+
+
+#GRIB_API_INCLUDE_DIR=/usr/local/gcc-4.9.3/grib1.12.3//include
+#GRIB_API_LIB=-openmp -L/usr/local/gcc-4.9.3/grib1.12.3/lib -Bstatic  -lgrib_api_f77 -lgrib_api_f90 -lgrib_api -Bdynamic  -lm  -ljasper
+#EMOSLIB=-lemosR64
 
 OPT	= -g
@@ -36,5 +41,5 @@
 
 clean:
-	rm *.o *.mod ${EXE}
+	rm *.o
 
 phgrreal.o: phgrreal.f
@@ -47,6 +52,6 @@
 	$(F90C) -c -g -O3 -fopenmp ftrafo.f
 
-$(BINDIR)/${EXE}:	phgrreal.o grphreal.o ftrafo.o rwGRIB2.o  posnam.o preconvert.o
-	$(F90C) $(DEBUG) $(OPT) -o $(BINDIR)/${EXE} ftrafo.o phgrreal.o grphreal.o rwGRIB2.o posnam.o preconvert.o ${LIB}
+$(BINDIR)/CONVERT2:	phgrreal.o grphreal.o ftrafo.o rwGRIB2.o  posnam.o preconvert.o
+	$(F90C) $(DEBUG) $(OPT) -o $(BINDIR)/CONVERT2 ftrafo.o phgrreal.o grphreal.o rwGRIB2.o posnam.o preconvert.o ${LIB}
 
 
Index: src/Makefile.ifort
===================================================================
--- src/Makefile.ifort	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
+++ src/Makefile.ifort	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -0,0 +1,61 @@
+###############################################################################
+#
+# Top level Makefile for ECMWFDATA7.0 software
+#
+# Last modified:  December 1, 2015
+#
+###############################################################################
+
+
+.SUFFIXES: .o .c .c~ .f .f~ .F90 .f90 .f90~ .f95 .f95~ .F .F~ .y .y~ .l .l~ \
+           .s .s~ .sh .sh~ .h .h~ .C .C~ .a
+
+
+#GRIB_API_INCLUDE_DIR=/usr/local/ifort/grib1.12.3//include
+#GRIB_API_LIB=-openmp -L/usr/local/ifort/grib1.12.3/lib -Bstatic  -lgrib_api_f77 -lgrib_api_f90 -lgrib_api -Bdynamic  -lm  -ljasper
+
+OPT	= -g
+DEBUG	= -g
+LIB     =  $(GRIB_API_LIBS) -lemosR64 -lgfortran
+
+FC=ifort -132  -traceback -r8
+F90C=ifort -132  -traceback -r8
+
+FFLAGS =  $(OPT) -I. -I$(GRIB_API_INCLUDE_DIR)
+F90FLAGS =  $(OPT) -I. -I$(GRIB_API_INCLUDE_DIR)
+
+LDFLAGS =  $(OPT)
+
+BINDIR  =      .
+
+EXE	=      CONVERT2
+
+
+.f.o:
+	$(F90C) -c $(F90FLAGS) -132 $(DEBUG) $*.f
+.f90.o:
+	$(F90C) -c $(F90FLAGS) -132 $(DEBUG) $*.f90
+
+all:	${EXE}
+
+clean:
+	rm *.o
+
+phgrreal.o: phgrreal.f
+	$(F90C) -c -g -O3 -fopenmp phgrreal.f
+
+grphreal.o: grphreal.f
+	$(F90C) -c -g -O3 -fopenmp grphreal.f
+
+ftrafo.o: ftrafo.f
+	$(F90C) -c -g -O3 -fopenmp ftrafo.f
+
+$(BINDIR)/CONVERT2:	phgrreal.o grphreal.o ftrafo.o rwGRIB2.o  posnam.o preconvert.o
+	$(F90C) $(DEBUG) $(OPT) -o $(BINDIR)/CONVERT2 ftrafo.o phgrreal.o grphreal.o rwGRIB2.o posnam.o preconvert.o ${LIB}
+
+
+###############################################################################
+#
+# End of the Makefile
+#
+###############################################################################
Index: src/Makefile.local.gfortran
===================================================================
--- src/Makefile.local.gfortran	(revision ced5d274f0e78ffb0d5892cf12addea47320a902)
+++ src/Makefile.local.gfortran	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -12,6 +12,6 @@
 
 
-GRIB_API_INCLUDE_DIR=/usr/local/gcc-4.9.3/grib_api-1.14.3/include
-GRIB_API_LIB= -L/usr/local/gcc-4.9.3/grib_api-1.14.3/lib -Bstatic  -lgrib_api_f77 -lgrib_api_f90 -lgrib_api -Bdynamic  -lm  -ljasper
+GRIB_API_INCLUDE_DIR=/usr/local/gcc-4.9.3/grib1.12.3//include
+GRIB_API_LIB= -L/usr/local/gcc-4.9.3/grib1.12.3/lib -Bstatic  -lgrib_api_f77 -lgrib_api_f90 -lgrib_api -Bdynamic  -lm  -ljasper
 EMOSLIB=-lemosR64
 
@@ -30,5 +30,5 @@
 BINDIR  =      .
 
-EXE	=     CONVERT2
+EXE	=      CONVERT2
 
 
@@ -38,8 +38,8 @@
 	$(F90C) -c $(F90FLAGS) $(DEBUG) $*.f90
 
-all:	$(EXE)
+all:	${EXE}
 
 clean:
-	rm *.o *.mod ${EXE}
+	rm *.o
 
 phgrreal.o: phgrreal.f
@@ -52,6 +52,6 @@
 	$(F90C) -c -g -O3 -fopenmp ftrafo.f
 
-$(BINDIR)/${EXE}:	phgrreal.o grphreal.o ftrafo.o rwGRIB2.o  posnam.o preconvert.o
-	$(F90C) $(DEBUG) $(OPT) -o $(BINDIR)/${EXE} ftrafo.o phgrreal.o grphreal.o rwGRIB2.o posnam.o preconvert.o ${LIB}
+$(BINDIR)/CONVERT2:	phgrreal.o grphreal.o ftrafo.o rwGRIB2.o  posnam.o preconvert.o
+	$(F90C) $(DEBUG) $(OPT) -o $(BINDIR)/CONVERT2 ftrafo.o phgrreal.o grphreal.o rwGRIB2.o posnam.o preconvert.o ${LIB}
 
 
Index: src/Makefile.local.ifort
===================================================================
--- src/Makefile.local.ifort	(revision 9a91826baec867641ab1e0389702fd06d33816cd)
+++ src/Makefile.local.ifort	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -12,6 +12,6 @@
 
 
-GRIB_API_INCLUDE_DIR=/home/srvx1/tmc/TestEnv/Libraries/grib_api-1.12.3_ifort/include
-GRIB_API_LIB=-fopenmp -L/home/srvx1/tmc/TestEnv/Libraries/grib_api-1.12.3_ifort/lib -Bstatic  -lgrib_api_f77 -lgrib_api_f90 -lgrib_api -Bdynamic  -lm  -ljasper
+GRIB_API_INCLUDE_DIR=/usr/local/ifort/grib_api-1.14.3//include
+GRIB_API_LIB=-openmp -L/usr/local/ifort/grib_api-1.14.3/lib -Bstatic  -lgrib_api_f77 -lgrib_api_f90 -lgrib_api -Bdynamic  -lm  -ljasper #-lopenjpeg
 
 OPT	= -g
@@ -19,6 +19,6 @@
 LIB     =  $(GRIB_API_LIB) -lemosR64 -lgfortran
 
-FC=/opt/intel/bin/ifort -132  -traceback -r8
-F90C=/opt/intel/bin/ifort -132  -traceback -r8
+FC=ifort -132  -traceback -r8
+F90C=ifort -132  -traceback -r8
 
 FFLAGS =  $(OPT) -I. -I$(GRIB_API_INCLUDE_DIR)
@@ -40,5 +40,5 @@
 
 clean:
-	rm *.o *.mod ${EXE}
+	rm *.o
 
 phgrreal.o: phgrreal.f
@@ -51,6 +51,6 @@
 	$(F90C) -c -g -O3 -fopenmp ftrafo.f
 
-$(BINDIR)/${EXE}:	phgrreal.o grphreal.o ftrafo.o rwGRIB2.o  posnam.o preconvert.o
-	$(F90C) $(DEBUG) $(OPT) -o $(BINDIR)/${EXE} ftrafo.o phgrreal.o grphreal.o rwGRIB2.o posnam.o preconvert.o ${LIB}
+$(BINDIR)/CONVERT2:	phgrreal.o grphreal.o ftrafo.o rwGRIB2.o  posnam.o preconvert.o
+	$(F90C) $(DEBUG) $(OPT) -o $(BINDIR)/CONVERT2 ftrafo.o phgrreal.o grphreal.o rwGRIB2.o posnam.o preconvert.o ${LIB}
 
 
Index: src/rwGRIB2.f90
===================================================================
--- src/rwGRIB2.f90	(revision ceea034b0fe9af0c354b30972df40a3fa8e4c02f)
+++ src/rwGRIB2.f90	(revision d69b6776d6d39e0af0d38c95cbfd78284c9866e4)
@@ -23,6 +23,4 @@
    character*(*):: filename                             
 
-   feld = 0.
-   
    call grib_open_file(ifile, TRIM(FILENAME),'r')
  
