Index: documentation/Sphinx/build/html/_modules/ControlFile.html
===================================================================
--- documentation/Sphinx/build/html/_modules/ControlFile.html	(revision 2625ca8faac35d65699e83e37bb42cdc24163490)
+++ documentation/Sphinx/build/html/_modules/ControlFile.html	(revision f66f9905a36e7b0a824c539e948b15ca55615e47)
@@ -212,5 +212,5 @@
                          <span class="n">check_acctime</span><span class="p">,</span> <span class="n">check_accmaxstep</span><span class="p">,</span> <span class="n">check_time</span><span class="p">,</span>
                          <span class="n">check_logicals_type</span><span class="p">,</span> <span class="n">check_len_type_time_step</span><span class="p">,</span>
-                         <span class="n">check_addpar</span><span class="p">,</span> <span class="n">check_job_chunk</span><span class="p">)</span>
+                         <span class="n">check_addpar</span><span class="p">,</span> <span class="n">check_job_chunk</span><span class="p">,</span> <span class="n">check_number</span><span class="p">)</span>
 
 <span class="c1"># ------------------------------------------------------------------------------</span>
@@ -246,5 +246,5 @@
 <span class="sd">        The time step in hours. Default value is None.</span>
 
-<span class="sd">    basetime : str</span>
+<span class="sd">    basetime : int</span>
 <span class="sd">        The time for a half day retrieval. The 12 hours upfront are to be</span>
 <span class="sd">        retrieved. Default value is None.</span>
@@ -456,4 +456,9 @@
 <span class="sd">        Default value is 0.</span>
 
+<span class="sd">    oper : int</span>
+<span class="sd">        Switch to prepare the operational job script. Start date, end date and</span>
+<span class="sd">        basetime will be prepared with environment variables.</span>
+<span class="sd">        Default value is 0.</span>
+
 <span class="sd">    request : int</span>
 <span class="sd">        Switch to select between just retrieving the data (0), writing the mars</span>
@@ -466,6 +471,10 @@
 <span class="sd">        Default value is 0.</span>
 
-<span class="sd">    ecapi : boolean</span>
-<span class="sd">        Tells wether the ECMWF Web APi was able to load or not.</span>
+<span class="sd">    ec_api : boolean</span>
+<span class="sd">        Tells wether the ECMWF Web API was able to load or not.</span>
+<span class="sd">        Default value is None.</span>
+
+<span class="sd">    cds_api : boolean</span>
+<span class="sd">        Tells wether the CDS API was able to load or not.</span>
 <span class="sd">        Default value is None.</span>
 
@@ -562,7 +571,9 @@
         <span class="bp">self</span><span class="o">.</span><span class="n">install_target</span> <span class="o">=</span> <span class="kc">None</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">debug</span> <span class="o">=</span> <span class="mi">0</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">oper</span> <span class="o">=</span> <span class="mi">0</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">request</span> <span class="o">=</span> <span class="mi">0</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">public</span> <span class="o">=</span> <span class="mi">0</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">ecapi</span> <span class="o">=</span> <span class="kc">None</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">ec_api</span> <span class="o">=</span> <span class="kc">None</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">cds_api</span> <span class="o">=</span> <span class="kc">None</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">purefc</span> <span class="o">=</span> <span class="mi">0</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">rrint</span> <span class="o">=</span> <span class="mi">0</span>
@@ -570,6 +581,6 @@
         <span class="bp">self</span><span class="o">.</span><span class="n">logicals</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;gauss&#39;</span><span class="p">,</span> <span class="s1">&#39;omega&#39;</span><span class="p">,</span> <span class="s1">&#39;omegadiff&#39;</span><span class="p">,</span> <span class="s1">&#39;eta&#39;</span><span class="p">,</span> <span class="s1">&#39;etadiff&#39;</span><span class="p">,</span>
                          <span class="s1">&#39;dpdeta&#39;</span><span class="p">,</span> <span class="s1">&#39;cwc&#39;</span><span class="p">,</span> <span class="s1">&#39;wrf&#39;</span><span class="p">,</span> <span class="s1">&#39;grib2flexpart&#39;</span><span class="p">,</span> <span class="s1">&#39;ecstorage&#39;</span><span class="p">,</span>
-                         <span class="s1">&#39;ectrans&#39;</span><span class="p">,</span> <span class="s1">&#39;debug&#39;</span><span class="p">,</span> <span class="s1">&#39;request&#39;</span><span class="p">,</span> <span class="s1">&#39;public&#39;</span><span class="p">,</span> <span class="s1">&#39;purefc&#39;</span><span class="p">,</span>
-                         <span class="s1">&#39;rrint&#39;</span><span class="p">]</span>
+                         <span class="s1">&#39;ectrans&#39;</span><span class="p">,</span> <span class="s1">&#39;debug&#39;</span><span class="p">,</span> <span class="s1">&#39;oper&#39;</span><span class="p">,</span> <span class="s1">&#39;request&#39;</span><span class="p">,</span> <span class="s1">&#39;public&#39;</span><span class="p">,</span>
+                         <span class="s1">&#39;purefc&#39;</span><span class="p">,</span> <span class="s1">&#39;rrint&#39;</span><span class="p">]</span>
 
         <span class="bp">self</span><span class="o">.</span><span class="n">_read_controlfile</span><span class="p">()</span>
@@ -628,6 +639,5 @@
                                 <span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">][:</span><span class="n">i</span><span class="p">]</span> <span class="o">+</span> <span class="n">var</span> <span class="o">+</span> <span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="n">k</span><span class="o">+</span><span class="mi">1</span><span class="p">:]</span>
                             <span class="k">else</span><span class="p">:</span>
-                                <span class="n">my_error</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mailfail</span><span class="p">,</span>
-                                         <span class="s1">&#39;Could not find variable &#39;</span>
+                                <span class="n">my_error</span><span class="p">(</span><span class="s1">&#39;Could not find variable &#39;</span>
                                          <span class="o">+</span> <span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="n">j</span><span class="o">+</span><span class="mi">1</span><span class="p">:</span><span class="n">k</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39; while reading &#39;</span> <span class="o">+</span>
                                          <span class="bp">self</span><span class="o">.</span><span class="n">controlfile</span><span class="p">)</span>
@@ -752,5 +762,5 @@
                                                      <span class="bp">self</span><span class="o">.</span><span class="n">end_date</span><span class="p">)</span>
 
-        <span class="n">check_basetime</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">basetime</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span> <span class="o">=</span> <span class="n">check_basetime</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">basetime</span><span class="p">)</span>
 
         <span class="bp">self</span><span class="o">.</span><span class="n">levelist</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">level</span> <span class="o">=</span> <span class="n">check_levels</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">levelist</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">level</span><span class="p">)</span>
@@ -777,7 +787,7 @@
         <span class="bp">self</span><span class="o">.</span><span class="n">acctype</span> <span class="o">=</span> <span class="n">check_acctype</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">acctype</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">)</span>
 
-        <span class="bp">self</span><span class="o">.</span><span class="n">acctime</span> <span class="o">=</span> <span class="n">check_acctime</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">acctime</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">acctype</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">purefc</span><span class="p">)</span>
-
-        <span class="bp">self</span><span class="o">.</span><span class="n">accmaxstep</span> <span class="o">=</span> <span class="n">check_accmaxstep</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">accmaxstep</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">acctype</span><span class="p">,</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">acctime</span> <span class="o">=</span> <span class="n">check_acctime</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">acctime</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">marsclass</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">purefc</span><span class="p">)</span>
+
+        <span class="bp">self</span><span class="o">.</span><span class="n">accmaxstep</span> <span class="o">=</span> <span class="n">check_accmaxstep</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">accmaxstep</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">marsclass</span><span class="p">,</span>
                                            <span class="bp">self</span><span class="o">.</span><span class="n">purefc</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">maxstep</span><span class="p">)</span>
 
@@ -792,4 +802,6 @@
 
         <span class="bp">self</span><span class="o">.</span><span class="n">job_chunk</span> <span class="o">=</span> <span class="n">check_job_chunk</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">job_chunk</span><span class="p">)</span>
+
+        <span class="bp">self</span><span class="o">.</span><span class="n">number</span> <span class="o">=</span> <span class="n">check_number</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">number</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">mailfail</span><span class="p">)</span>
 
         <span class="k">return</span></div>
@@ -850,5 +862,5 @@
   <div role="contentinfo">
     <p>
-        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
+        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
 
     </p>
@@ -869,11 +881,19 @@
   
 
-    
-    
-      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
-        <script type="text/javascript" src="../_static/jquery.js"></script>
-        <script type="text/javascript" src="../_static/underscore.js"></script>
-        <script type="text/javascript" src="../_static/doctools.js"></script>
-    
+    <script type="text/javascript">
+        var DOCUMENTATION_OPTIONS = {
+            URL_ROOT:'../',
+            VERSION:'7.1 alpha',
+            LANGUAGE:'None',
+            COLLAPSE_INDEX:false,
+            FILE_SUFFIX:'.html',
+            HAS_SOURCE:  true,
+            SOURCELINK_SUFFIX: '.txt'
+        };
+    </script>
+      <script type="text/javascript" src="../_static/jquery.js"></script>
+      <script type="text/javascript" src="../_static/underscore.js"></script>
+      <script type="text/javascript" src="../_static/doctools.js"></script>
+      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
 
   
Index: documentation/Sphinx/build/html/_modules/EcFlexpart.html
===================================================================
--- documentation/Sphinx/build/html/_modules/EcFlexpart.html	(revision 2625ca8faac35d65699e83e37bb42cdc24163490)
+++ documentation/Sphinx/build/html/_modules/EcFlexpart.html	(revision f66f9905a36e7b0a824c539e948b15ca55615e47)
@@ -220,5 +220,6 @@
                      <span class="n">codes_get_values</span><span class="p">,</span> <span class="n">codes_set_values</span><span class="p">,</span> <span class="n">codes_set</span><span class="p">,</span>
                      <span class="n">codes_write</span><span class="p">,</span> <span class="n">codes_release</span><span class="p">,</span> <span class="n">codes_new_from_index</span><span class="p">,</span>
-                     <span class="n">codes_index_release</span><span class="p">,</span> <span class="n">codes_index_get</span><span class="p">)</span>
+                     <span class="n">codes_index_release</span><span class="p">,</span> <span class="n">codes_index_get</span><span class="p">,</span> <span class="n">codes_get_array</span><span class="p">,</span>
+                     <span class="n">codes_set_array</span><span class="p">,</span> <span class="n">codes_grib_new_from_file</span><span class="p">)</span>
 
 <span class="c1"># software specific classes and modules from flex_extract</span>
@@ -228,6 +229,7 @@
 <span class="kn">from</span> <span class="nn">mods.tools</span> <span class="k">import</span> <span class="p">(</span><span class="n">init128</span><span class="p">,</span> <span class="n">to_param_id</span><span class="p">,</span> <span class="n">silent_remove</span><span class="p">,</span> <span class="n">product</span><span class="p">,</span>
                         <span class="n">my_error</span><span class="p">,</span> <span class="n">make_dir</span><span class="p">,</span> <span class="n">get_informations</span><span class="p">,</span> <span class="n">get_dimensions</span><span class="p">,</span>
-                        <span class="n">execute_subprocess</span><span class="p">)</span>
+                        <span class="n">execute_subprocess</span><span class="p">,</span> <span class="n">to_param_id_with_tablenumber</span><span class="p">)</span>
 <span class="kn">from</span> <span class="nn">MarsRetrieval</span> <span class="k">import</span> <span class="n">MarsRetrieval</span>
+<span class="kn">from</span> <span class="nn">UioFiles</span> <span class="k">import</span> <span class="n">UioFiles</span>
 <span class="kn">import</span> <span class="nn">mods.disaggregation</span> <span class="k">as</span> <span class="nn">disaggregation</span>
 
@@ -259,5 +261,5 @@
 <span class="sd">        data.</span>
 
-<span class="sd">    basetime : str</span>
+<span class="sd">    basetime : int</span>
 <span class="sd">        The time for a half day retrieval. The 12 hours upfront are to be</span>
 <span class="sd">        retrieved.</span>
@@ -429,8 +431,8 @@
         <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
         <span class="k">for</span> <span class="n">ty</span><span class="p">,</span> <span class="n">st</span><span class="p">,</span> <span class="n">ti</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">ftype</span><span class="p">,</span> <span class="n">fstep</span><span class="p">,</span> <span class="n">ftime</span><span class="p">):</span>
-            <span class="n">btlist</span> <span class="o">=</span> <span class="nb">range</span><span class="p">(</span><span class="mi">24</span><span class="p">)</span>
-            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span> <span class="o">==</span> <span class="s1">&#39;12&#39;</span><span class="p">:</span>
+            <span class="n">btlist</span> <span class="o">=</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">ftime</span><span class="p">))</span>
+            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span> <span class="o">==</span> <span class="mi">12</span><span class="p">:</span>
                 <span class="n">btlist</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="mi">12</span><span class="p">]</span>
-            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span> <span class="o">==</span> <span class="s1">&#39;00&#39;</span><span class="p">:</span>
+            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                 <span class="n">btlist</span> <span class="o">=</span> <span class="p">[</span><span class="mi">13</span><span class="p">,</span> <span class="mi">14</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="mi">16</span><span class="p">,</span> <span class="mi">17</span><span class="p">,</span> <span class="mi">18</span><span class="p">,</span> <span class="mi">19</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="mi">21</span><span class="p">,</span> <span class="mi">22</span><span class="p">,</span> <span class="mi">23</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span>
 
@@ -440,5 +442,5 @@
                  <span class="c1"># (int(c.time[i]) in btlist or c.purefc):</span>
 
-            <span class="k">if</span> <span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">ti</span><span class="p">)</span> <span class="ow">in</span> <span class="n">btlist</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
+            <span class="k">if</span> <span class="p">(</span><span class="n">i</span> <span class="ow">in</span> <span class="n">btlist</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
 
                 <span class="k">if</span> <span class="p">((</span><span class="n">ty</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;AN&#39;</span> <span class="ow">and</span> <span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">ti</span><span class="p">)</span> <span class="o">%</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">or</span>
@@ -458,4 +460,5 @@
                         <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="n">ty</span><span class="p">][</span><span class="s1">&#39;steps&#39;</span><span class="p">]</span> <span class="o">+=</span> <span class="n">st</span>
             <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>
+
         <span class="k">return</span>
 
@@ -553,11 +556,11 @@
         <span class="k">elif</span> <span class="ow">not</span> <span class="n">gauss</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">eta</span><span class="p">:</span>
             <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/U/V&#39;</span>
-        <span class="k">else</span><span class="p">:</span>
-            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Warning: Collecting etadot and parameters for gaussian grid </span><span class="se">\</span>
-<span class="s1">                            is a very costly parameter combination, </span><span class="se">\</span>
-<span class="s1">                            use this combination only for debugging!&#39;</span><span class="p">)</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;GG__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;Q&#39;</span><span class="p">,</span> <span class="s1">&#39;ML&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span> \
+        <span class="k">else</span><span class="p">:</span>  <span class="c1"># GAUSS and ETA</span>
+            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Warning: Collecting etadot and parameters for gaussian grid &#39;</span>
+                           <span class="s1">&#39;is a very costly parameter combination, &#39;</span>
+                           <span class="s1">&#39;use this combination only for debugging!&#39;</span><span class="p">)</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;GG__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;Q&#39;</span><span class="p">,</span> <span class="s1">&#39;ML&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span>
                                      <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">((</span><span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">resol</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)]</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;GG__ML&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;U/V/D/77&#39;</span><span class="p">,</span> <span class="s1">&#39;ML&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">glevelist</span><span class="p">,</span> \
+            <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;GG__ML&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;U/V/D/ETADOT&#39;</span><span class="p">,</span> <span class="s1">&#39;ML&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">glevelist</span><span class="p">,</span>
                                      <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">((</span><span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">resol</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)]</span>
 
@@ -569,9 +572,10 @@
 
         <span class="c1"># ADDITIONAL FIELDS FOR FLEXPART-WRF MODEL (IF QUESTIONED)</span>
-        <span class="c1">#-----------------------------------------------------------------------</span>
+        <span class="c1"># -----------------------------------------------------------------------</span>
         <span class="k">if</span> <span class="n">wrf</span><span class="p">:</span>
             <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/Z/VO&#39;</span>
             <span class="k">if</span> <span class="s1">&#39;/D&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]:</span>
                 <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__ML&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/D&#39;</span>
+
             <span class="n">wrf_sfc</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;SP&#39;</span><span class="p">,</span><span class="s1">&#39;SKT&#39;</span><span class="p">,</span><span class="s1">&#39;SST&#39;</span><span class="p">,</span><span class="s1">&#39;CI&#39;</span><span class="p">,</span><span class="s1">&#39;STL1&#39;</span><span class="p">,</span><span class="s1">&#39;STL2&#39;</span><span class="p">,</span> <span class="s1">&#39;STL3&#39;</span><span class="p">,</span><span class="s1">&#39;STL4&#39;</span><span class="p">,</span>
                        <span class="s1">&#39;SWVL1&#39;</span><span class="p">,</span><span class="s1">&#39;SWVL2&#39;</span><span class="p">,</span><span class="s1">&#39;SWVL3&#39;</span><span class="p">,</span><span class="s1">&#39;SWVL4&#39;</span><span class="p">]</span>
@@ -602,5 +606,5 @@
 
 <span class="sd">        &#39;&#39;&#39;</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG_acc_SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;LSP/CP/SSHF/EWSS/NSSS/SSR&quot;</span><span class="p">,</span> \
+        <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG_acc_SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;LSP/CP/SSHF/EWSS/NSSS/SSR&quot;</span><span class="p">,</span>
                                     <span class="s1">&#39;SFC&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">]</span>
         <span class="k">return</span>
@@ -815,8 +819,6 @@
 
         <span class="k">for</span> <span class="n">ftype</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">:</span>
-            <span class="c1"># fk contains field types such as</span>
+            <span class="c1"># ftype contains field types such as</span>
             <span class="c1">#     [AN, FC, PF, CV]</span>
-            <span class="c1"># fv contains all of the items of the belonging key</span>
-            <span class="c1">#     [times, steps]</span>
             <span class="k">for</span> <span class="n">pk</span><span class="p">,</span> <span class="n">pv</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="o">.</span><span class="n">iteritems</span><span class="p">():</span>
                 <span class="c1"># pk contains one of these keys of params</span>
@@ -836,5 +838,7 @@
                                         <span class="n">pk</span><span class="p">,</span>
                                         <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">])</span>
-                <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;param&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">pv</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
+                <span class="n">table128</span> <span class="o">=</span> <span class="n">init128</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">PATH_GRIBTABLE</span><span class="p">)</span>
+                <span class="n">ids</span> <span class="o">=</span> <span class="n">to_param_id_with_tablenumber</span><span class="p">(</span><span class="n">pv</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">table128</span><span class="p">)</span>
+                <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;param&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">ids</span>
                 <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;levtype&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">pv</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                 <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;levelist&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">pv</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
@@ -859,7 +863,24 @@
                     <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;area&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
                     <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;gaussian&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;reduced&#39;</span>
+                <span class="k">if</span> <span class="n">ftype</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;FC&#39;</span> <span class="ow">and</span> \
+                    <span class="s1">&#39;acc&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;target&#39;</span><span class="p">]:</span>
+                    <span class="k">if</span> <span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;time&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span>
+                        <span class="nb">int</span><span class="p">(</span><span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;step&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]))</span> <span class="o">&gt;</span> <span class="mi">23</span><span class="p">:</span>
+                        <span class="n">dates</span> <span class="o">=</span> <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)</span>
+                        <span class="n">sdate</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">dates</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span>
+                        <span class="n">sdate</span> <span class="o">=</span> <span class="n">sdate</span> <span class="o">-</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">days</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
+                        <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;/&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
+                            <span class="p">[</span><span class="n">sdate</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">&quot;%Y%m</span><span class="si">%d</span><span class="s2">&quot;</span><span class="p">)]</span> <span class="o">+</span>
+                            <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">:])</span>
+
+                        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;CHANGED FC start date to &#39;</span> <span class="o">+</span>
+                              <span class="n">sdate</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">&quot;%Y%m</span><span class="si">%d</span><span class="s2">&quot;</span><span class="p">)</span> <span class="o">+</span>
+                              <span class="s1">&#39; to accomodate TIME=&#39;</span> <span class="o">+</span>
+                              <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;time&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span>
+                              <span class="s1">&#39;, STEP=&#39;</span> <span class="o">+</span>
+                              <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;time&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
 
     <span class="c1"># ------  on demand path  --------------------------------------------------</span>
-                <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span><span class="p">:</span>
+                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                     <span class="c1"># ******* start retrievement</span>
                     <span class="bp">self</span><span class="o">.</span><span class="n">_start_retrievement</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">retr_param_dict</span><span class="p">)</span>
@@ -871,18 +892,10 @@
 
                     <span class="n">enddate</span> <span class="o">=</span> <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
-                    <span class="n">elimit</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">enddate</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span><span class="p">,</span>
+                    <span class="n">elimit</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">enddate</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">basetime</span><span class="p">),</span>
                                                <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span>
 
-                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span> <span class="o">==</span> <span class="s1">&#39;12&#39;</span><span class="p">:</span>
+                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span> <span class="o">==</span> <span class="mi">12</span><span class="p">:</span>
                         <span class="c1"># --------------  flux data ----------------------------</span>
                         <span class="k">if</span> <span class="s1">&#39;acc&#39;</span> <span class="ow">in</span> <span class="n">pk</span><span class="p">:</span>
-
-                        <span class="c1"># Strategy:</span>
-                        <span class="c1"># if maxtime-elimit &gt;= 24h reduce date by 1,</span>
-                        <span class="c1"># if 12h &lt;= maxtime-elimit&lt;12h reduce time for last date</span>
-                        <span class="c1"># if maxtime-elimit&lt;12h reduce step for last time</span>
-                        <span class="c1"># A split of the MARS job into 2 is likely necessary.</span>
-
-
                             <span class="n">startdate</span> <span class="o">=</span> <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                             <span class="n">enddate</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="n">elimit</span> <span class="o">-</span> <span class="n">t24h</span><span class="p">,</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">&#39;</span><span class="p">)</span>
@@ -909,5 +922,5 @@
                             <span class="bp">self</span><span class="o">.</span><span class="n">_start_retrievement</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">retr_param_dict</span><span class="p">)</span>
 
-                    <span class="k">else</span><span class="p">:</span> <span class="c1"># basetime = 0</span>
+                    <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                         <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">]</span> <span class="o">=</span> \
                             <span class="n">datetime</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="n">elimit</span> <span class="o">-</span> <span class="n">t24h</span><span class="p">,</span> <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">&#39;</span><span class="p">)</span>
@@ -915,19 +928,16 @@
                         <span class="n">timesave</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;time&#39;</span><span class="p">])</span>
 
-                        <span class="k">if</span> <span class="s1">&#39;/&#39;</span> <span class="ow">in</span> <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;time&#39;</span><span class="p">]:</span>
+                        <span class="k">if</span> <span class="p">(</span><span class="s1">&#39;/&#39;</span> <span class="ow">in</span> <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;time&#39;</span><span class="p">]</span> <span class="ow">and</span>
+                            <span class="n">pk</span> <span class="o">!=</span> <span class="s1">&#39;OG_OROLSM__SL&#39;</span> <span class="ow">and</span>
+                            <span class="s1">&#39;acc&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">pk</span> <span class="p">)</span> <span class="p">:</span>
                             <span class="n">times</span> <span class="o">=</span> <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;time&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)</span>
                             <span class="n">steps</span> <span class="o">=</span> <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;step&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)</span>
-                            <span class="k">while</span> <span class="p">(</span><span class="n">pk</span> <span class="o">!=</span> <span class="s1">&#39;OG_OROLSM__SL&#39;</span> <span class="ow">and</span>
-                                   <span class="s1">&#39;acc&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">pk</span> <span class="ow">and</span>
-                                   <span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">times</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="nb">int</span><span class="p">(</span><span class="n">steps</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span> <span class="o">&lt;=</span> <span class="mi">12</span><span class="p">):</span>
+
+                            <span class="k">while</span> <span class="nb">int</span><span class="p">(</span><span class="n">times</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="nb">int</span><span class="p">(</span><span class="n">steps</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">&lt;=</span> <span class="mi">12</span><span class="p">:</span>
                                 <span class="n">times</span> <span class="o">=</span> <span class="n">times</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
-
-                            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">times</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
-                                <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;time&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;/&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">times</span><span class="p">)</span>
-                            <span class="k">else</span><span class="p">:</span>
-                                <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;time&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">times</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
-
-                        <span class="c1"># ******* start retrievement</span>
-                        <span class="bp">self</span><span class="o">.</span><span class="n">_start_retrievement</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">retr_param_dict</span><span class="p">)</span>
+                                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">times</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
+                                    <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;time&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;/&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">times</span><span class="p">)</span>
+                                <span class="k">else</span><span class="p">:</span>
+                                    <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;time&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">times</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
 
                         <span class="k">if</span> <span class="p">(</span><span class="n">pk</span> <span class="o">!=</span> <span class="s1">&#39;OG_OROLSM__SL&#39;</span> <span class="ow">and</span>
@@ -943,6 +953,9 @@
                                                     <span class="n">retr_param_dict</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">])</span>
 
-                            <span class="c1"># ******* start retrievement</span>
-                            <span class="bp">self</span><span class="o">.</span><span class="n">_start_retrievement</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">retr_param_dict</span><span class="p">)</span>
+                        <span class="c1"># ******* start retrievement</span>
+                        <span class="bp">self</span><span class="o">.</span><span class="n">_start_retrievement</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">retr_param_dict</span><span class="p">)</span>
+                    <span class="k">else</span><span class="p">:</span>
+                        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;ERROR: Basetime has an invalid value &#39;</span>
+                                                 <span class="s1">&#39;-&gt; </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">basetime</span><span class="p">)))</span>
 
         <span class="k">if</span> <span class="n">request</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">or</span> <span class="n">request</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
@@ -1069,5 +1082,9 @@
         <span class="c1"># get the values of the keys which are used for distinct access</span>
         <span class="c1"># of grib messages via product</span>
-        <span class="n">index_keys</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;date&quot;</span><span class="p">,</span> <span class="s2">&quot;time&quot;</span><span class="p">,</span> <span class="s2">&quot;step&quot;</span><span class="p">]</span>
+        <span class="k">if</span> <span class="s1">&#39;/&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">number</span><span class="p">:</span>
+            <span class="c1"># more than one ensemble member is selected</span>
+            <span class="n">index_keys</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;number&quot;</span><span class="p">,</span> <span class="s2">&quot;date&quot;</span><span class="p">,</span> <span class="s2">&quot;time&quot;</span><span class="p">,</span> <span class="s2">&quot;step&quot;</span><span class="p">]</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="n">index_keys</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;date&quot;</span><span class="p">,</span> <span class="s2">&quot;time&quot;</span><span class="p">,</span> <span class="s2">&quot;step&quot;</span><span class="p">]</span>
         <span class="n">iid</span><span class="p">,</span> <span class="n">index_vals</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_mk_index_values</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span>
                                                 <span class="n">inputfiles</span><span class="p">,</span>
@@ -1138,23 +1155,39 @@
             <span class="n">t_m1dt</span> <span class="o">=</span> <span class="n">t_date</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="n">step</span><span class="o">-</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
             <span class="n">t_m2dt</span> <span class="o">=</span> <span class="n">t_date</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="n">step</span><span class="o">-</span><span class="mi">2</span><span class="o">*</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
-            <span class="n">t_enddate</span> <span class="o">=</span> <span class="kc">None</span>
+            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
+                <span class="n">t_enddate</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">end_date</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">basetime</span><span class="p">),</span>
+                                              <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span>
+            <span class="k">else</span><span class="p">:</span>
+                <span class="n">t_enddate</span> <span class="o">=</span> <span class="n">t_date</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
+
+            <span class="c1"># if necessary, add ensemble member number to filename suffix</span>
+            <span class="c1"># otherwise, add empty string</span>
+            <span class="k">if</span> <span class="s1">&#39;number&#39;</span> <span class="ow">in</span> <span class="n">index_keys</span><span class="p">:</span>
+                <span class="n">index_number</span> <span class="o">=</span> <span class="n">index_keys</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="s1">&#39;number&#39;</span><span class="p">)</span>
+                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">index_vals</span><span class="p">[</span><span class="n">index_number</span><span class="p">])</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
+                    <span class="n">numbersuffix</span> <span class="o">=</span> <span class="s1">&#39;.N</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">prod</span><span class="p">[</span><span class="n">index_number</span><span class="p">]))</span>
+            <span class="k">else</span><span class="p">:</span>
+                <span class="n">numbersuffix</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
 
             <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
                 <span class="n">fnout</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="s1">&#39;flux&#39;</span> <span class="o">+</span>
                                      <span class="n">t_date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">.%H&#39;</span><span class="p">)</span> <span class="o">+</span>
-                                     <span class="s1">&#39;.</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">step</span><span class="o">-</span><span class="mi">2</span><span class="o">*</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">)))</span>
+                                     <span class="s1">&#39;.</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">step</span><span class="o">-</span><span class="mi">2</span><span class="o">*</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span> <span class="o">+</span>
+                                     <span class="n">numbersuffix</span><span class="p">)</span>
                 <span class="n">gnout</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="s1">&#39;flux&#39;</span> <span class="o">+</span>
                                      <span class="n">t_date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">.%H&#39;</span><span class="p">)</span> <span class="o">+</span>
-                                     <span class="s1">&#39;.</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">step</span><span class="o">-</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">)))</span>
+                                     <span class="s1">&#39;.</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">step</span><span class="o">-</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span> <span class="o">+</span>
+                                     <span class="n">numbersuffix</span><span class="p">)</span>
                 <span class="n">hnout</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="s1">&#39;flux&#39;</span> <span class="o">+</span>
                                      <span class="n">t_date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">.%H&#39;</span><span class="p">)</span> <span class="o">+</span>
-                                     <span class="s1">&#39;.</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">step</span><span class="p">))</span>
+                                     <span class="s1">&#39;.</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">step</span><span class="p">)</span> <span class="o">+</span>
+                                     <span class="n">numbersuffix</span><span class="p">)</span>
             <span class="k">else</span><span class="p">:</span>
                 <span class="n">fnout</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="s1">&#39;flux&#39;</span> <span class="o">+</span>
-                                     <span class="n">t_m2dt</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">))</span>
+                                     <span class="n">t_m2dt</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="n">numbersuffix</span><span class="p">)</span>
                 <span class="n">gnout</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="s1">&#39;flux&#39;</span> <span class="o">+</span>
-                                     <span class="n">t_m1dt</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">))</span>
+                                     <span class="n">t_m1dt</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="n">numbersuffix</span><span class="p">)</span>
                 <span class="n">hnout</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="s1">&#39;flux&#39;</span> <span class="o">+</span>
-                                     <span class="n">t_dt</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">))</span>
+                                     <span class="n">t_dt</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="n">numbersuffix</span><span class="p">)</span>
 
             <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;outputfile = &quot;</span> <span class="o">+</span> <span class="n">fnout</span><span class="p">)</span>
@@ -1260,51 +1293,45 @@
                         <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">f_handle</span><span class="p">)</span>
 
-                        <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span><span class="p">:</span>
-                            <span class="n">t_enddate</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">end_date</span> <span class="o">+</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span><span class="p">,</span>
-                                                          <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span>
-                        <span class="k">else</span><span class="p">:</span>
-                            <span class="n">t_enddate</span> <span class="o">=</span> <span class="n">t_date</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
-
-                            <span class="c1"># squeeze out information of last two steps</span>
-                            <span class="c1"># contained in deac_vals[parId]</span>
-                            <span class="c1"># Note that deac_vals[parId][0] has not been popped</span>
-                            <span class="c1"># in this case</span>
-
-                            <span class="k">if</span> <span class="n">step</span> <span class="o">==</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="ow">and</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span> <span class="ow">or</span> \
-                               <span class="n">t_dt</span> <span class="o">==</span> <span class="n">t_enddate</span><span class="p">:</span>
-                                <span class="c1"># last step</span>
-                                <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
-                                    <span class="n">values</span> <span class="o">=</span> <span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">][</span><span class="mi">3</span><span class="p">]</span>
-                                    <span class="n">codes_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span>
-                                    <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;stepRange&#39;</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span>
-                                    <span class="c1">#truedatetime = t_m2dt + timedelta(hours=2*int(c.dtime))</span>
-                                    <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">h_handle</span><span class="p">)</span>
-                                <span class="k">else</span><span class="p">:</span>
-                                    <span class="n">values</span> <span class="o">=</span> <span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">][</span><span class="mi">3</span><span class="p">]</span>
-                                    <span class="n">codes_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span>
-                                    <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;stepRange&#39;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
-                                    <span class="n">truedatetime</span> <span class="o">=</span> <span class="n">t_m2dt</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="mi">2</span><span class="o">*</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
-                                    <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;time&#39;</span><span class="p">,</span> <span class="n">truedatetime</span><span class="o">.</span><span class="n">hour</span> <span class="o">*</span> <span class="mi">100</span><span class="p">)</span>
-                                    <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;date&#39;</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">truedatetime</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">&#39;</span><span class="p">)))</span>
-                                    <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">h_handle</span><span class="p">)</span>
-
-                                <span class="k">if</span> <span class="n">parId</span> <span class="o">==</span> <span class="mi">142</span> <span class="ow">or</span> <span class="n">parId</span> <span class="o">==</span> <span class="mi">143</span><span class="p">:</span>
-                                    <span class="n">values</span> <span class="o">=</span> <span class="n">disaggregation</span><span class="o">.</span><span class="n">darain</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">reversed</span><span class="p">(</span><span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">])))</span>
-                                <span class="k">else</span><span class="p">:</span>
-                                    <span class="n">values</span> <span class="o">=</span> <span class="n">disaggregation</span><span class="o">.</span><span class="n">dapoly</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">reversed</span><span class="p">(</span><span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">])))</span>
-
-                                <span class="c1"># step before last step</span>
-                                <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
-                                    <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;stepRange&#39;</span><span class="p">,</span> <span class="n">step</span><span class="o">-</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
-                                    <span class="c1">#truedatetime = t_m2dt + timedelta(hours=int(c.dtime))</span>
-                                    <span class="n">codes_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span>
-                                    <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">g_handle</span><span class="p">)</span>
-                                <span class="k">else</span><span class="p">:</span>
-                                    <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;stepRange&#39;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
-                                    <span class="n">truedatetime</span> <span class="o">=</span> <span class="n">t_m2dt</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
-                                    <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;time&#39;</span><span class="p">,</span> <span class="n">truedatetime</span><span class="o">.</span><span class="n">hour</span> <span class="o">*</span> <span class="mi">100</span><span class="p">)</span>
-                                    <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;date&#39;</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">truedatetime</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">&#39;</span><span class="p">)))</span>
-                                    <span class="n">codes_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span>
-                                    <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">g_handle</span><span class="p">)</span>
+                        <span class="c1"># squeeze out information of last two steps</span>
+                        <span class="c1"># contained in deac_vals[parId]</span>
+                        <span class="c1"># Note that deac_vals[parId][0] has not been popped</span>
+                        <span class="c1"># in this case</span>
+
+                        <span class="k">if</span> <span class="n">step</span> <span class="o">==</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="ow">and</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span> <span class="ow">or</span> \
+                           <span class="n">t_dt</span> <span class="o">==</span> <span class="n">t_enddate</span><span class="p">:</span>
+                            <span class="c1"># last step</span>
+                            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
+                                <span class="n">values</span> <span class="o">=</span> <span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">][</span><span class="mi">3</span><span class="p">]</span>
+                                <span class="n">codes_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span>
+                                <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;stepRange&#39;</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span>
+                                <span class="c1">#truedatetime = t_m2dt + timedelta(hours=2*int(c.dtime))</span>
+                                <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">h_handle</span><span class="p">)</span>
+                            <span class="k">else</span><span class="p">:</span>
+                                <span class="n">values</span> <span class="o">=</span> <span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">][</span><span class="mi">3</span><span class="p">]</span>
+                                <span class="n">codes_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span>
+                                <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;stepRange&#39;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
+                                <span class="n">truedatetime</span> <span class="o">=</span> <span class="n">t_m2dt</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="mi">2</span><span class="o">*</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
+                                <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;time&#39;</span><span class="p">,</span> <span class="n">truedatetime</span><span class="o">.</span><span class="n">hour</span> <span class="o">*</span> <span class="mi">100</span><span class="p">)</span>
+                                <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;date&#39;</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">truedatetime</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">&#39;</span><span class="p">)))</span>
+                                <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">h_handle</span><span class="p">)</span>
+
+                            <span class="k">if</span> <span class="n">parId</span> <span class="o">==</span> <span class="mi">142</span> <span class="ow">or</span> <span class="n">parId</span> <span class="o">==</span> <span class="mi">143</span><span class="p">:</span>
+                                <span class="n">values</span> <span class="o">=</span> <span class="n">disaggregation</span><span class="o">.</span><span class="n">darain</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">reversed</span><span class="p">(</span><span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">])))</span>
+                            <span class="k">else</span><span class="p">:</span>
+                                <span class="n">values</span> <span class="o">=</span> <span class="n">disaggregation</span><span class="o">.</span><span class="n">dapoly</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">reversed</span><span class="p">(</span><span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">])))</span>
+
+                            <span class="c1"># step before last step</span>
+                            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
+                                <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;stepRange&#39;</span><span class="p">,</span> <span class="n">step</span><span class="o">-</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
+                                <span class="c1">#truedatetime = t_m2dt + timedelta(hours=int(c.dtime))</span>
+                                <span class="n">codes_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span>
+                                <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">g_handle</span><span class="p">)</span>
+                            <span class="k">else</span><span class="p">:</span>
+                                <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;stepRange&#39;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
+                                <span class="n">truedatetime</span> <span class="o">=</span> <span class="n">t_m2dt</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
+                                <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;time&#39;</span><span class="p">,</span> <span class="n">truedatetime</span><span class="o">.</span><span class="n">hour</span> <span class="o">*</span> <span class="mi">100</span><span class="p">)</span>
+                                <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;date&#39;</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">truedatetime</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">&#39;</span><span class="p">)))</span>
+                                <span class="n">codes_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span>
+                                <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">g_handle</span><span class="p">)</span>
 
                 <span class="n">codes_release</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
@@ -1367,5 +1394,5 @@
 
 <span class="sd">        &#39;&#39;&#39;</span>
-        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;... disaggregation or precipitation with new method.&#39;</span><span class="p">)</span>
+        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;... disaggregation of precipitation with new method.&#39;</span><span class="p">)</span>
         <span class="n">lsp_new_np</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="n">ni</span> <span class="o">*</span> <span class="n">nj</span><span class="p">,</span> <span class="n">nt</span> <span class="o">*</span> <span class="mi">3</span><span class="p">),</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float64</span><span class="p">)</span>
         <span class="n">cp_new_np</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="n">ni</span> <span class="o">*</span> <span class="n">nj</span><span class="p">,</span> <span class="n">nt</span> <span class="o">*</span> <span class="mi">3</span><span class="p">),</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float64</span><span class="p">)</span>
@@ -1397,9 +1424,4 @@
                     <span class="n">filename1</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;_1&#39;</span>
                     <span class="n">filename2</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">date</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;_2&#39;</span>
-
-                <span class="c1"># collect for final processing</span>
-                <span class="bp">self</span><span class="o">.</span><span class="n">outputfilelist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">fluxfilename</span><span class="p">))</span>
-                <span class="bp">self</span><span class="o">.</span><span class="n">outputfilelist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">filename1</span><span class="p">))</span>
-                <span class="bp">self</span><span class="o">.</span><span class="n">outputfilelist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">filename2</span><span class="p">))</span>
 
                 <span class="c1"># write original time step to flux file as usual</span>
@@ -1506,4 +1528,10 @@
 <span class="sd">        &#39;&#39;&#39;</span>
 
+        <span class="c1"># generate start and end timestamp of the retrieval period</span>
+        <span class="n">start_period</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">start_date</span> <span class="o">+</span> <span class="n">c</span><span class="o">.</span><span class="n">time</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span>
+        <span class="n">start_period</span> <span class="o">=</span> <span class="n">start_period</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">step</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span>
+        <span class="n">end_period</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">end_date</span> <span class="o">+</span> <span class="n">c</span><span class="o">.</span><span class="n">time</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span>
+        <span class="n">end_period</span> <span class="o">=</span> <span class="n">end_period</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">step</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]))</span>
+
         <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">wrf</span><span class="p">:</span>
             <span class="n">table128</span> <span class="o">=</span> <span class="n">init128</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">PATH_GRIBTABLE</span><span class="p">)</span>
@@ -1525,5 +1553,9 @@
         <span class="c1"># get the values of the keys which are used for distinct access</span>
         <span class="c1"># of grib messages via product</span>
-        <span class="n">index_keys</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;date&quot;</span><span class="p">,</span> <span class="s2">&quot;time&quot;</span><span class="p">,</span> <span class="s2">&quot;step&quot;</span><span class="p">]</span>
+        <span class="k">if</span> <span class="s1">&#39;/&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">number</span><span class="p">:</span>
+            <span class="c1"># more than one ensemble member is selected</span>
+            <span class="n">index_keys</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;number&quot;</span><span class="p">,</span> <span class="s2">&quot;date&quot;</span><span class="p">,</span> <span class="s2">&quot;time&quot;</span><span class="p">,</span> <span class="s2">&quot;step&quot;</span><span class="p">]</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="n">index_keys</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;date&quot;</span><span class="p">,</span> <span class="s2">&quot;time&quot;</span><span class="p">,</span> <span class="s2">&quot;step&quot;</span><span class="p">]</span>
         <span class="n">iid</span><span class="p">,</span> <span class="n">index_vals</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_mk_index_values</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span>
                                                 <span class="n">inputfiles</span><span class="p">,</span>
@@ -1568,10 +1600,17 @@
             <span class="n">cdate_hour</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="n">timestamp</span><span class="p">,</span> <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span>
 
+            <span class="c1"># skip all temporary times</span>
+            <span class="c1"># which are outside the retrieval period</span>
+            <span class="k">if</span> <span class="n">timestamp</span> <span class="o">&lt;</span> <span class="n">start_period</span> <span class="ow">or</span> \
+               <span class="n">timestamp</span> <span class="o">&gt;</span> <span class="n">end_period</span><span class="p">:</span>
+                <span class="k">continue</span>
+
             <span class="c1"># if the timestamp is out of basetime start/end date period,</span>
             <span class="c1"># skip this specific product</span>
-            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span><span class="p">:</span>
-                <span class="n">start_time</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">end_date</span> <span class="o">+</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span><span class="p">,</span>
+            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
+                <span class="n">time_delta</span> <span class="o">=</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="mi">12</span><span class="o">-</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">))</span>
+                <span class="n">start_time</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">end_date</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">basetime</span><span class="p">),</span>
                                                 <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span> <span class="o">-</span> <span class="n">time_delta</span>
-                <span class="n">end_time</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">end_date</span> <span class="o">+</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span><span class="p">,</span>
+                <span class="n">end_time</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">end_date</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">basetime</span><span class="p">),</span>
                                              <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">%H&#39;</span><span class="p">)</span>
                 <span class="k">if</span> <span class="n">timestamp</span> <span class="o">&lt;</span> <span class="n">start_time</span> <span class="ow">or</span> <span class="n">timestamp</span> <span class="o">&gt;</span> <span class="n">end_time</span><span class="p">:</span>
@@ -1657,10 +1696,10 @@
             <span class="n">os</span><span class="o">.</span><span class="n">chdir</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">)</span>
             <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">stat</span><span class="p">(</span><span class="s1">&#39;fort.21&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">st_size</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">c</span><span class="o">.</span><span class="n">eta</span><span class="p">:</span>
-                <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Parameter 77 (etadot) is missing, most likely it is </span><span class="se">\</span>
-<span class="s1">                       not available for this type or date/time</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
+                <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Parameter 77 (etadot) is missing, most likely it is &#39;</span>
+                      <span class="s1">&#39;not available for this type or date / time</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
                 <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Check parameters CLASS, TYPE, STREAM, START_DATE</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
-                <span class="n">my_error</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">mailfail</span><span class="p">,</span> <span class="s1">&#39;fort.21 is empty while parameter eta </span><span class="se">\</span>
-<span class="s1">                         is set to 1 in CONTROL file&#39;</span><span class="p">)</span>
-<span class="c1">#============================================================================================</span>
+                <span class="n">my_error</span><span class="p">(</span><span class="s1">&#39;fort.21 is empty while parameter eta &#39;</span>
+                         <span class="s1">&#39;is set to 1 in CONTROL file&#39;</span><span class="p">)</span>
+<span class="c1"># ============================================================================================</span>
             <span class="c1"># write out all output to log file before starting fortran programm</span>
             <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">flush</span><span class="p">()</span>
@@ -1672,5 +1711,5 @@
 
             <span class="n">os</span><span class="o">.</span><span class="n">chdir</span><span class="p">(</span><span class="n">pwd</span><span class="p">)</span>
-<span class="c1">#============================================================================================</span>
+<span class="c1"># ============================================================================================</span>
             <span class="c1"># create name of final output file, e.g. EN13040500 (ENYYMMDDHH)</span>
             <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
@@ -1678,9 +1717,20 @@
             <span class="k">else</span><span class="p">:</span>
                 <span class="n">suffix</span> <span class="o">=</span> <span class="n">cdate_hour</span><span class="p">[</span><span class="mi">2</span><span class="p">:</span><span class="mi">10</span><span class="p">]</span>
+
+            <span class="c1"># if necessary, add ensemble member number to filename suffix</span>
+            <span class="k">if</span> <span class="s1">&#39;number&#39;</span> <span class="ow">in</span> <span class="n">index_keys</span><span class="p">:</span>
+                <span class="n">index_number</span> <span class="o">=</span> <span class="n">index_keys</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="s1">&#39;number&#39;</span><span class="p">)</span>
+                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">index_vals</span><span class="p">[</span><span class="n">index_number</span><span class="p">])</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
+                    <span class="n">suffix</span> <span class="o">=</span> <span class="n">suffix</span> <span class="o">+</span> <span class="s1">&#39;.N</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">prod</span><span class="p">[</span><span class="n">index_number</span><span class="p">]))</span>
+
             <span class="n">fnout</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">suffix</span><span class="p">)</span>
             <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;outputfile = &quot;</span> <span class="o">+</span> <span class="n">fnout</span><span class="p">)</span>
             <span class="c1"># collect for final processing</span>
             <span class="bp">self</span><span class="o">.</span><span class="n">outputfilelist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">fnout</span><span class="p">))</span>
-<span class="c1">#============================================================================================</span>
+            <span class="c1"># get additional precipitation subgrid data if available</span>
+            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">rrint</span><span class="p">:</span>
+                <span class="bp">self</span><span class="o">.</span><span class="n">outputfilelist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">fnout</span> <span class="o">+</span> <span class="s1">&#39;_1&#39;</span><span class="p">))</span>
+                <span class="bp">self</span><span class="o">.</span><span class="n">outputfilelist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">fnout</span> <span class="o">+</span> <span class="s1">&#39;_2&#39;</span><span class="p">))</span>
+<span class="c1"># ============================================================================================</span>
             <span class="c1"># create outputfile and copy all data from intermediate files</span>
             <span class="c1"># to the outputfile (final GRIB input files for FLEXPART)</span>
@@ -1702,9 +1752,70 @@
                     <span class="n">shutil</span><span class="o">.</span><span class="n">copyfileobj</span><span class="p">(</span><span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="s1">&#39;fort.25&#39;</span><span class="p">),</span>
                                             <span class="s1">&#39;rb&#39;</span><span class="p">),</span> <span class="n">fout</span><span class="p">)</span>
-<span class="c1">#============================================================================================</span>
+<span class="c1"># ============================================================================================</span>
         <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">wrf</span><span class="p">:</span>
             <span class="n">fwrf</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
 
         <span class="n">codes_index_release</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
+
+        <span class="k">return</span></div>
+
+
+<div class="viewcode-block" id="EcFlexpart.calc_extra_elda"><a class="viewcode-back" href="../api.html#EcFlexpart.EcFlexpart.calc_extra_elda">[docs]</a>    <span class="k">def</span> <span class="nf">calc_extra_elda</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="n">prefix</span><span class="p">):</span>
+        <span class="sd">&#39;&#39;&#39; Calculates extra ensemble members for ELDA - Stream.</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        path : str</span>
+<span class="sd">            Path to the output files.</span>
+
+<span class="sd">        prefix : str</span>
+<span class="sd">            The prefix of the output filenames as defined in Control file.</span>
+
+<span class="sd">        Return</span>
+<span class="sd">        ------</span>
+
+<span class="sd">        &#39;&#39;&#39;</span>
+        <span class="c1"># max number</span>
+        <span class="n">maxnum</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">number</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
+
+        <span class="c1"># get a list of all prepared output files with control forecast (CF)</span>
+        <span class="n">CF_filelist</span> <span class="o">=</span> <span class="n">UioFiles</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">prefix</span> <span class="o">+</span> <span class="s1">&#39;*.N000&#39;</span><span class="p">)</span>
+
+        <span class="k">for</span> <span class="n">cffile</span> <span class="ow">in</span> <span class="n">CF_filelist</span><span class="o">.</span><span class="n">files</span><span class="p">:</span>
+            <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">cffile</span><span class="p">,</span> <span class="s1">&#39;rb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
+                <span class="n">cfvalues</span><span class="o">=</span><span class="p">[]</span>
+                <span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
+                    <span class="n">fid</span> <span class="o">=</span> <span class="n">codes_grib_new_from_file</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
+                    <span class="k">if</span> <span class="n">fid</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
+                        <span class="k">break</span>
+                    <span class="n">cfvalues</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">codes_get_array</span><span class="p">(</span><span class="n">fid</span><span class="p">,</span> <span class="s1">&#39;values&#39;</span><span class="p">))</span>
+                    <span class="n">codes_release</span><span class="p">(</span><span class="n">fid</span><span class="p">)</span>
+
+            <span class="n">filename</span> <span class="o">=</span> <span class="n">cffile</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;N000&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
+            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">maxnum</span><span class="o">+</span><span class="mi">1</span><span class="p">):</span> <span class="c1"># max number nehmen</span>
+
+                <span class="c1"># read an ensemble member</span>
+                <span class="n">g</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">filename</span> <span class="o">+</span> <span class="s1">&#39;N</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i</span><span class="p">),</span> <span class="s1">&#39;rb&#39;</span><span class="p">)</span>
+                <span class="c1"># create file for newly calculated ensemble member</span>
+                <span class="n">h</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">filename</span> <span class="o">+</span> <span class="s1">&#39;N</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="n">maxnum</span><span class="p">),</span> <span class="s1">&#39;wb&#39;</span><span class="p">)</span>
+                <span class="c1"># number of message in grib file</span>
+                <span class="n">j</span> <span class="o">=</span> <span class="mi">0</span>
+                <span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
+                    <span class="n">gid</span> <span class="o">=</span> <span class="n">codes_grib_new_from_file</span><span class="p">(</span><span class="n">g</span><span class="p">)</span>
+                    <span class="k">if</span> <span class="n">gid</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
+                        <span class="k">break</span>
+                    <span class="n">values</span> <span class="o">=</span> <span class="n">codes_get_array</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;values&#39;</span><span class="p">)</span>
+                    <span class="n">codes_set_array</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;values&#39;</span><span class="p">,</span>
+                                    <span class="n">values</span><span class="o">-</span><span class="mi">2</span><span class="o">*</span><span class="p">(</span><span class="n">values</span><span class="o">-</span><span class="n">cfvalues</span><span class="p">[</span><span class="n">j</span><span class="p">]))</span>
+                    <span class="n">codes_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;number&#39;</span><span class="p">,</span> <span class="n">i</span><span class="o">+</span><span class="n">maxnum</span><span class="p">)</span>
+                    <span class="n">codes_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">h</span><span class="p">)</span>
+                    <span class="n">codes_release</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
+                    <span class="n">j</span> <span class="o">+=</span> <span class="mi">1</span>
+
+                <span class="n">g</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
+                <span class="n">h</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
+                <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;wrote &#39;</span> <span class="o">+</span> <span class="n">filename</span> <span class="o">+</span> <span class="s1">&#39;N</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="n">maxnum</span><span class="p">))</span>
+                <span class="bp">self</span><span class="o">.</span><span class="n">outputfilelist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
+                    <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">filename</span> <span class="o">+</span> <span class="s1">&#39;N</span><span class="si">{:0&gt;3}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="n">maxnum</span><span class="p">)))</span>
 
         <span class="k">return</span></div>
@@ -1736,5 +1847,5 @@
         <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">Postprocessing:</span><span class="se">\n</span><span class="s1"> Format: </span><span class="si">{}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">format</span><span class="p">))</span>
 
-        <span class="k">if</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">ecapi</span><span class="p">:</span>
+        <span class="k">if</span> <span class="n">_config</span><span class="o">.</span><span class="n">FLAG_ON_ECMWFSERVER</span><span class="p">:</span>
             <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;ecstorage: </span><span class="si">{}</span><span class="se">\n</span><span class="s1"> ecfsdir: </span><span class="si">{}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span>
                   <span class="nb">format</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">ecstorage</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">ecfsdir</span><span class="p">))</span>
@@ -1758,5 +1869,5 @@
                                    <span class="s1">&#39;FILES FAILED!&#39;</span><span class="p">)</span>
 
-            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">ectrans</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">ecapi</span><span class="p">:</span>
+            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">ectrans</span> <span class="ow">and</span> <span class="n">_config</span><span class="o">.</span><span class="n">FLAG_ON_ECMWFSERVER</span><span class="p">:</span>
                 <span class="n">execute_subprocess</span><span class="p">([</span><span class="s1">&#39;ectrans&#39;</span><span class="p">,</span> <span class="s1">&#39;-overwrite&#39;</span><span class="p">,</span> <span class="s1">&#39;-gateway&#39;</span><span class="p">,</span>
                                     <span class="n">c</span><span class="o">.</span><span class="n">gateway</span><span class="p">,</span> <span class="s1">&#39;-remote&#39;</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">destination</span><span class="p">,</span>
@@ -1764,5 +1875,5 @@
                                    <span class="n">error_msg</span><span class="o">=</span><span class="s1">&#39;TRANSFER TO LOCAL SERVER FAILED!&#39;</span><span class="p">)</span>
 
-            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">ecstorage</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">ecapi</span><span class="p">:</span>
+            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">ecstorage</span> <span class="ow">and</span> <span class="n">_config</span><span class="o">.</span><span class="n">FLAG_ON_ECMWFSERVER</span><span class="p">:</span>
                 <span class="n">execute_subprocess</span><span class="p">([</span><span class="s1">&#39;ecp&#39;</span><span class="p">,</span> <span class="s1">&#39;-o&#39;</span><span class="p">,</span> <span class="n">ofile</span><span class="p">,</span>
                                     <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expandvars</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">ecfsdir</span><span class="p">)],</span>
@@ -1872,5 +1983,5 @@
   <div role="contentinfo">
     <p>
-        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
+        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
 
     </p>
@@ -1891,11 +2002,19 @@
   
 
-    
-    
-      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
-        <script type="text/javascript" src="../_static/jquery.js"></script>
-        <script type="text/javascript" src="../_static/underscore.js"></script>
-        <script type="text/javascript" src="../_static/doctools.js"></script>
-    
+    <script type="text/javascript">
+        var DOCUMENTATION_OPTIONS = {
+            URL_ROOT:'../',
+            VERSION:'7.1 alpha',
+            LANGUAGE:'None',
+            COLLAPSE_INDEX:false,
+            FILE_SUFFIX:'.html',
+            HAS_SOURCE:  true,
+            SOURCELINK_SUFFIX: '.txt'
+        };
+    </script>
+      <script type="text/javascript" src="../_static/jquery.js"></script>
+      <script type="text/javascript" src="../_static/underscore.js"></script>
+      <script type="text/javascript" src="../_static/doctools.js"></script>
+      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
 
   
Index: documentation/Sphinx/build/html/_modules/GribUtil.html
===================================================================
--- documentation/Sphinx/build/html/_modules/GribUtil.html	(revision 2625ca8faac35d65699e83e37bb42cdc24163490)
+++ documentation/Sphinx/build/html/_modules/GribUtil.html	(revision f66f9905a36e7b0a824c539e948b15ca55615e47)
@@ -489,5 +489,5 @@
   <div role="contentinfo">
     <p>
-        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
+        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
 
     </p>
@@ -508,11 +508,19 @@
   
 
-    
-    
-      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
-        <script type="text/javascript" src="../_static/jquery.js"></script>
-        <script type="text/javascript" src="../_static/underscore.js"></script>
-        <script type="text/javascript" src="../_static/doctools.js"></script>
-    
+    <script type="text/javascript">
+        var DOCUMENTATION_OPTIONS = {
+            URL_ROOT:'../',
+            VERSION:'7.1 alpha',
+            LANGUAGE:'None',
+            COLLAPSE_INDEX:false,
+            FILE_SUFFIX:'.html',
+            HAS_SOURCE:  true,
+            SOURCELINK_SUFFIX: '.txt'
+        };
+    </script>
+      <script type="text/javascript" src="../_static/jquery.js"></script>
+      <script type="text/javascript" src="../_static/underscore.js"></script>
+      <script type="text/javascript" src="../_static/doctools.js"></script>
+      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
 
   
Index: documentation/Sphinx/build/html/_modules/MarsRetrieval.html
===================================================================
--- documentation/Sphinx/build/html/_modules/MarsRetrieval.html	(revision 2625ca8faac35d65699e83e37bb42cdc24163490)
+++ documentation/Sphinx/build/html/_modules/MarsRetrieval.html	(revision f66f9905a36e7b0a824c539e948b15ca55615e47)
@@ -188,8 +188,20 @@
 <span class="kn">import</span> <span class="nn">sys</span>
 <span class="kn">import</span> <span class="nn">subprocess</span>
+<span class="kn">import</span> <span class="nn">traceback</span>
 
 <span class="c1"># software specific classes and modules from flex_extract</span>
 <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../&#39;</span><span class="p">)</span>
 <span class="kn">import</span> <span class="nn">_config</span>
+<span class="k">try</span><span class="p">:</span>
+    <span class="n">ec_api</span> <span class="o">=</span> <span class="kc">True</span>
+    <span class="kn">import</span> <span class="nn">ecmwfapi</span>
+<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
+    <span class="n">ec_api</span> <span class="o">=</span> <span class="kc">False</span>
+
+<span class="k">try</span><span class="p">:</span>
+    <span class="n">cds_api</span> <span class="o">=</span> <span class="kc">True</span>
+    <span class="kn">import</span> <span class="nn">cdsapi</span>
+<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
+    <span class="n">cds_api</span> <span class="o">=</span> <span class="kc">False</span>
 <span class="c1"># ------------------------------------------------------------------------------</span>
 <span class="c1"># CLASS</span>
@@ -283,5 +295,5 @@
 <span class="sd">    &#39;&#39;&#39;</span>
 
-    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">server</span><span class="p">,</span> <span class="n">public</span><span class="p">,</span> <span class="n">marsclass</span><span class="o">=</span><span class="s2">&quot;ei&quot;</span><span class="p">,</span> <span class="n">dataset</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
+    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">server</span><span class="p">,</span> <span class="n">public</span><span class="p">,</span> <span class="n">marsclass</span><span class="o">=</span><span class="s2">&quot;EA&quot;</span><span class="p">,</span> <span class="n">dataset</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
                  <span class="n">levtype</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">levelist</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">repres</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">date</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">resol</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
                  <span class="n">stream</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">area</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">time</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">step</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">expver</span><span class="o">=</span><span class="s2">&quot;1&quot;</span><span class="p">,</span>
@@ -311,6 +323,6 @@
 <span class="sd">        marsclass : str, optional</span>
 <span class="sd">            Characterisation of dataset. E.g. EI (ERA-Interim),</span>
-<span class="sd">            E4 (ERA40), OD (Operational archive), ea (ERA5).</span>
-<span class="sd">            Default is the ERA-Interim dataset &quot;ei&quot;.</span>
+<span class="sd">            E4 (ERA40), OD (Operational archive), EA (ERA5).</span>
+<span class="sd">            Default is the ERA5 dataset &quot;EA&quot;.</span>
 
 <span class="sd">        dataset : str, optional</span>
@@ -582,5 +594,5 @@
 <div class="viewcode-block" id="MarsRetrieval.data_retrieve"><a class="viewcode-back" href="../api.html#MarsRetrieval.MarsRetrieval.data_retrieve">[docs]</a>    <span class="k">def</span> <span class="nf">data_retrieve</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
         <span class="sd">&#39;&#39;&#39;Submits a MARS retrieval. Depending on the existence of</span>
-<span class="sd">        ECMWF Web-API it is submitted via Python or a</span>
+<span class="sd">        ECMWF Web-API or CDS API it is submitted via Python or a</span>
 <span class="sd">        subprocess in the Shell. The parameter for the mars retrieval</span>
 <span class="sd">        are taken from the defined class attributes.</span>
@@ -605,5 +617,5 @@
         <span class="n">attrs</span><span class="p">[</span><span class="s1">&#39;class&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">mclass</span>
 
-        <span class="c1"># prepare target variable as needed for the Web API mode</span>
+        <span class="c1"># prepare target variable as needed for the Web API or CDS API mode</span>
         <span class="c1"># within the dictionary for full access</span>
         <span class="c1"># as a single variable for public access</span>
@@ -628,25 +640,26 @@
         <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="p">:</span>
             <span class="k">try</span><span class="p">:</span>
-                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">public</span><span class="p">:</span>
-                    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;RETRIEVE PUBLIC DATA!&#39;</span><span class="p">)</span>
+                <span class="k">if</span> <span class="n">cds_api</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="p">,</span> <span class="n">cdsapi</span><span class="o">.</span><span class="n">Client</span><span class="p">):</span>
+                    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;RETRIEVE ERA5 WITH CDS API!&#39;</span><span class="p">)</span>
+                    <span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">retrieve</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">CDS_DATASET</span><span class="p">,</span>
+                                         <span class="n">attrs</span><span class="p">,</span> <span class="n">target</span><span class="p">)</span>
+                <span class="k">elif</span> <span class="n">ec_api</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="p">,</span> <span class="n">ecmwfapi</span><span class="o">.</span><span class="n">ECMWFDataServer</span><span class="p">):</span>
+                    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;RETRIEVE PUBLIC DATA (NOT ERA5)!&#39;</span><span class="p">)</span>
                     <span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">retrieve</span><span class="p">(</span><span class="n">attrs</span><span class="p">)</span>
+                <span class="k">elif</span> <span class="n">ec_api</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="p">,</span> <span class="n">ecmwfapi</span><span class="o">.</span><span class="n">ECMWFService</span><span class="p">):</span>
+                    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;EXECUTE NON-PUBLIC RETRIEVAL (NOT ERA5)!&#39;</span><span class="p">)</span>
+                    <span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="n">attrs</span><span class="p">,</span> <span class="n">target</span><span class="p">)</span>
                 <span class="k">else</span><span class="p">:</span>
-                    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;EXECUTE NON-PUBLIC RETRIEVAL!&#39;</span><span class="p">)</span>
-                    <span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="n">attrs</span><span class="p">,</span> <span class="n">target</span><span class="p">)</span>
-            <span class="k">except</span><span class="p">:</span>
-                <span class="n">e</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">exc_info</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span>
-                <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;ERROR: &quot;</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span>
-                <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;MARS Request failed!&#39;</span><span class="p">)</span>
-                <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">public</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">stat</span><span class="p">(</span><span class="n">target</span><span class="p">)</span><span class="o">.</span><span class="n">st_size</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
-                    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;MARS Request returned no data - &#39;</span>
-                          <span class="s1">&#39;please check request&#39;</span><span class="p">)</span>
+                    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;ERROR:&#39;</span><span class="p">)</span>
+                    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;No match for Web API instance!&#39;</span><span class="p">)</span>
                     <span class="k">raise</span> <span class="ne">IOError</span>
-                <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">public</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">stat</span><span class="p">(</span><span class="n">target</span><span class="p">)</span><span class="o">.</span><span class="n">st_size</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
-                    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Public MARS Request returned no data - &#39;</span>
-                          <span class="s1">&#39;please check request&#39;</span><span class="p">)</span>
-                    <span class="k">raise</span> <span class="ne">IOError</span>
-                <span class="k">else</span><span class="p">:</span>
-                    <span class="k">raise</span> <span class="ne">IOError</span>
-        <span class="c1"># MARS request via extra process in shell</span>
+            <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
+                <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">MARS Request failed!&#39;</span><span class="p">)</span>
+                <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span>
+                <span class="n">tb</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">exc_info</span><span class="p">()[</span><span class="mi">2</span><span class="p">]</span>
+                <span class="nb">print</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
+                <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">()</span>
+
+        <span class="c1"># MARS request via call in shell</span>
         <span class="k">else</span><span class="p">:</span>
             <span class="n">request_str</span> <span class="o">=</span> <span class="s1">&#39;ret&#39;</span>
@@ -654,5 +667,5 @@
                 <span class="n">request_str</span> <span class="o">=</span> <span class="n">request_str</span> <span class="o">+</span> <span class="s1">&#39;,&#39;</span> <span class="o">+</span> <span class="n">key</span> <span class="o">+</span> <span class="s1">&#39;=&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
             <span class="n">request_str</span> <span class="o">+=</span> <span class="s1">&#39;,target=&quot;&#39;</span> <span class="o">+</span> <span class="n">target</span> <span class="o">+</span> <span class="s1">&#39;&quot;&#39;</span>
-            <span class="n">p</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">([</span><span class="s1">&#39;mars&#39;</span><span class="p">],</span>
+            <span class="n">p</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">([</span><span class="s1">&#39;mars&#39;</span><span class="p">,</span> <span class="s1">&#39;-p&#39;</span><span class="p">],</span>
                                  <span class="n">stdin</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">,</span>
                                  <span class="n">stdout</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">,</span>
@@ -682,5 +695,5 @@
   <div role="contentinfo">
     <p>
-        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
+        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
 
     </p>
@@ -701,11 +714,19 @@
   
 
-    
-    
-      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
-        <script type="text/javascript" src="../_static/jquery.js"></script>
-        <script type="text/javascript" src="../_static/underscore.js"></script>
-        <script type="text/javascript" src="../_static/doctools.js"></script>
-    
+    <script type="text/javascript">
+        var DOCUMENTATION_OPTIONS = {
+            URL_ROOT:'../',
+            VERSION:'7.1 alpha',
+            LANGUAGE:'None',
+            COLLAPSE_INDEX:false,
+            FILE_SUFFIX:'.html',
+            HAS_SOURCE:  true,
+            SOURCELINK_SUFFIX: '.txt'
+        };
+    </script>
+      <script type="text/javascript" src="../_static/jquery.js"></script>
+      <script type="text/javascript" src="../_static/underscore.js"></script>
+      <script type="text/javascript" src="../_static/doctools.js"></script>
+      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
 
   
Index: documentation/Sphinx/build/html/_modules/UioFiles.html
===================================================================
--- documentation/Sphinx/build/html/_modules/UioFiles.html	(revision 2625ca8faac35d65699e83e37bb42cdc24163490)
+++ documentation/Sphinx/build/html/_modules/UioFiles.html	(revision f66f9905a36e7b0a824c539e948b15ca55615e47)
@@ -316,5 +316,5 @@
   <div role="contentinfo">
     <p>
-        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
+        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
 
     </p>
@@ -335,11 +335,19 @@
   
 
-    
-    
-      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
-        <script type="text/javascript" src="../_static/jquery.js"></script>
-        <script type="text/javascript" src="../_static/underscore.js"></script>
-        <script type="text/javascript" src="../_static/doctools.js"></script>
-    
+    <script type="text/javascript">
+        var DOCUMENTATION_OPTIONS = {
+            URL_ROOT:'../',
+            VERSION:'7.1 alpha',
+            LANGUAGE:'None',
+            COLLAPSE_INDEX:false,
+            FILE_SUFFIX:'.html',
+            HAS_SOURCE:  true,
+            SOURCELINK_SUFFIX: '.txt'
+        };
+    </script>
+      <script type="text/javascript" src="../_static/jquery.js"></script>
+      <script type="text/javascript" src="../_static/underscore.js"></script>
+      <script type="text/javascript" src="../_static/doctools.js"></script>
+      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
 
   
Index: documentation/Sphinx/build/html/_modules/disaggregation.html
===================================================================
--- documentation/Sphinx/build/html/_modules/disaggregation.html	(revision 2625ca8faac35d65699e83e37bb42cdc24163490)
+++ documentation/Sphinx/build/html/_modules/disaggregation.html	(revision f66f9905a36e7b0a824c539e948b15ca55615e47)
@@ -580,5 +580,5 @@
   <div role="contentinfo">
     <p>
-        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
+        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
 
     </p>
@@ -599,11 +599,19 @@
   
 
-    
-    
-      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
-        <script type="text/javascript" src="../_static/jquery.js"></script>
-        <script type="text/javascript" src="../_static/underscore.js"></script>
-        <script type="text/javascript" src="../_static/doctools.js"></script>
-    
+    <script type="text/javascript">
+        var DOCUMENTATION_OPTIONS = {
+            URL_ROOT:'../',
+            VERSION:'7.1 alpha',
+            LANGUAGE:'None',
+            COLLAPSE_INDEX:false,
+            FILE_SUFFIX:'.html',
+            HAS_SOURCE:  true,
+            SOURCELINK_SUFFIX: '.txt'
+        };
+    </script>
+      <script type="text/javascript" src="../_static/jquery.js"></script>
+      <script type="text/javascript" src="../_static/underscore.js"></script>
+      <script type="text/javascript" src="../_static/doctools.js"></script>
+      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
 
   
Index: documentation/Sphinx/build/html/_modules/get_mars_data.html
===================================================================
--- documentation/Sphinx/build/html/_modules/get_mars_data.html	(revision 2625ca8faac35d65699e83e37bb42cdc24163490)
+++ documentation/Sphinx/build/html/_modules/get_mars_data.html	(revision f66f9905a36e7b0a824c539e948b15ca55615e47)
@@ -220,5 +220,5 @@
     <span class="n">inspect</span><span class="o">.</span><span class="n">getfile</span><span class="p">(</span><span class="n">inspect</span><span class="o">.</span><span class="n">currentframe</span><span class="p">())))</span> <span class="o">+</span> <span class="s1">&#39;/../&#39;</span><span class="p">)</span>
 <span class="kn">import</span> <span class="nn">_config</span>
-<span class="kn">from</span> <span class="nn">tools</span> <span class="k">import</span> <span class="p">(</span><span class="n">my_error</span><span class="p">,</span> <span class="n">normal_exit</span><span class="p">,</span> <span class="n">get_cmdline_args</span><span class="p">,</span>
+<span class="kn">from</span> <span class="nn">tools</span> <span class="k">import</span> <span class="p">(</span><span class="n">setup_controldata</span><span class="p">,</span> <span class="n">my_error</span><span class="p">,</span> <span class="n">normal_exit</span><span class="p">,</span> <span class="n">get_cmdline_args</span><span class="p">,</span>
                    <span class="n">read_ecenv</span><span class="p">,</span> <span class="n">make_dir</span><span class="p">)</span>
 <span class="kn">from</span> <span class="nn">classes.EcFlexpart</span> <span class="k">import</span> <span class="n">EcFlexpart</span>
@@ -227,8 +227,14 @@
 
 <span class="k">try</span><span class="p">:</span>
-    <span class="n">ecapi</span> <span class="o">=</span> <span class="kc">True</span>
+    <span class="n">ec_api</span> <span class="o">=</span> <span class="kc">True</span>
     <span class="kn">import</span> <span class="nn">ecmwfapi</span>
 <span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
-    <span class="n">ecapi</span> <span class="o">=</span> <span class="kc">False</span>
+    <span class="n">ec_api</span> <span class="o">=</span> <span class="kc">False</span>
+
+<span class="k">try</span><span class="p">:</span>
+    <span class="n">cds_api</span> <span class="o">=</span> <span class="kc">True</span>
+    <span class="kn">import</span> <span class="nn">cdsapi</span>
+<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
+    <span class="n">cds_api</span> <span class="o">=</span> <span class="kc">False</span>
 <span class="c1"># ------------------------------------------------------------------------------</span>
 <span class="c1"># FUNCTION</span>
@@ -248,14 +254,7 @@
 <span class="sd">    &#39;&#39;&#39;</span>
 
-    <span class="n">args</span> <span class="o">=</span> <span class="n">get_cmdline_args</span><span class="p">()</span>
-    <span class="n">c</span> <span class="o">=</span> <span class="n">ControlFile</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">controlfile</span><span class="p">)</span>
-
-    <span class="n">env_parameter</span> <span class="o">=</span> <span class="n">read_ecenv</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">PATH_ECMWF_ENV</span><span class="p">)</span>
-    <span class="n">c</span><span class="o">.</span><span class="n">assign_args_to_control</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>
-    <span class="n">c</span><span class="o">.</span><span class="n">assign_envs_to_control</span><span class="p">(</span><span class="n">env_parameter</span><span class="p">)</span>
-    <span class="n">c</span><span class="o">.</span><span class="n">check_conditions</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">queue</span><span class="p">)</span>
-
+    <span class="n">c</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">setup_controldata</span><span class="p">()</span>
     <span class="n">get_mars_data</span><span class="p">(</span><span class="n">c</span><span class="p">)</span>
-    <span class="n">normal_exit</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">mailops</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">queue</span><span class="p">,</span> <span class="s1">&#39;Done!&#39;</span><span class="p">)</span>
+    <span class="n">normal_exit</span><span class="p">(</span><span class="s1">&#39;Retrieving MARS data: Done!&#39;</span><span class="p">)</span>
 
     <span class="k">return</span></div>
@@ -278,5 +277,6 @@
 
 <span class="sd">    &#39;&#39;&#39;</span>
-    <span class="n">c</span><span class="o">.</span><span class="n">ecapi</span> <span class="o">=</span> <span class="n">ecapi</span>
+    <span class="n">c</span><span class="o">.</span><span class="n">ec_api</span> <span class="o">=</span> <span class="n">ec_api</span>
+    <span class="n">c</span><span class="o">.</span><span class="n">cds_api</span> <span class="o">=</span> <span class="n">cds_api</span>
 
     <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">):</span>
@@ -335,5 +335,9 @@
 
 <div class="viewcode-block" id="mk_server"><a class="viewcode-back" href="../api.html#get_mars_data.mk_server">[docs]</a><span class="k">def</span> <span class="nf">mk_server</span><span class="p">(</span><span class="n">c</span><span class="p">):</span>
-    <span class="sd">&#39;&#39;&#39;Creates server connection if ECMWF WebAPI is available.</span>
+    <span class="sd">&#39;&#39;&#39;Creates a server connection with available python API.</span>
+
+<span class="sd">    Which API is used depends on availability and the dataset to be retrieved.</span>
+<span class="sd">    The CDS API is used for ERA5 dataset no matter if the user is a member or</span>
+<span class="sd">    a public user. ECMWF WebAPI is used for all other available datasets.</span>
 
 <span class="sd">    Parameters</span>
@@ -345,19 +349,33 @@
 <span class="sd">    Return</span>
 <span class="sd">    ------</span>
-<span class="sd">    server : ECMWFDataServer or ECMWFService</span>
-<span class="sd">        Connection to ECMWF server via python interface ECMWF WebAPI.</span>
-
-<span class="sd">    &#39;&#39;&#39;</span>
-    <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">ecapi</span><span class="p">:</span>
+<span class="sd">    server : ECMWFDataServer, ECMWFService or Client</span>
+<span class="sd">        Connection to ECMWF server via python interface ECMWF WebAPI or CDS API.</span>
+
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">if</span> <span class="n">cds_api</span> <span class="ow">and</span> <span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">marsclass</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;EA&#39;</span><span class="p">):</span>
+        <span class="n">server</span> <span class="o">=</span> <span class="n">cdsapi</span><span class="o">.</span><span class="n">Client</span><span class="p">()</span>
+        <span class="n">c</span><span class="o">.</span><span class="n">ec_api</span> <span class="o">=</span> <span class="kc">False</span>
+    <span class="k">elif</span> <span class="n">c</span><span class="o">.</span><span class="n">ec_api</span><span class="p">:</span>
         <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">public</span><span class="p">:</span>
             <span class="n">server</span> <span class="o">=</span> <span class="n">ecmwfapi</span><span class="o">.</span><span class="n">ECMWFDataServer</span><span class="p">()</span>
         <span class="k">else</span><span class="p">:</span>
             <span class="n">server</span> <span class="o">=</span> <span class="n">ecmwfapi</span><span class="o">.</span><span class="n">ECMWFService</span><span class="p">(</span><span class="s2">&quot;mars&quot;</span><span class="p">)</span>
+        <span class="n">c</span><span class="o">.</span><span class="n">cds_api</span> <span class="o">=</span> <span class="kc">False</span>
     <span class="k">else</span><span class="p">:</span>
         <span class="n">server</span> <span class="o">=</span> <span class="kc">False</span>
 
-    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Using ECMWF WebAPI: &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">ecapi</span><span class="p">))</span>
+    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Using ECMWF WebAPI: &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">ec_api</span><span class="p">))</span>
+    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Using CDS API: &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">cds_api</span><span class="p">))</span>
 
     <span class="k">return</span> <span class="n">server</span></div>
+
+
+<div class="viewcode-block" id="check_dates_for_nonflux_fc_times"><a class="viewcode-back" href="../api.html#get_mars_data.check_dates_for_nonflux_fc_times">[docs]</a><span class="k">def</span> <span class="nf">check_dates_for_nonflux_fc_times</span><span class="p">(</span><span class="n">types</span><span class="p">,</span> <span class="n">times</span><span class="p">):</span>
+    <span class="sd">&#39;&#39;&#39;</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">for</span> <span class="n">ty</span><span class="p">,</span> <span class="n">ti</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">types</span><span class="p">,</span><span class="n">times</span><span class="p">):</span>
+        <span class="k">if</span> <span class="n">ty</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;FC&#39;</span> <span class="ow">and</span> <span class="nb">int</span><span class="p">(</span><span class="n">ti</span><span class="p">)</span> <span class="o">==</span> <span class="mi">18</span><span class="p">:</span>
+            <span class="k">return</span> <span class="kc">True</span>
+    <span class="k">return</span> <span class="kc">False</span></div>
 
 
@@ -405,11 +423,15 @@
     <span class="n">chunk</span> <span class="o">=</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">days</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">date_chunk</span><span class="p">))</span>
 
-    <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span><span class="p">:</span>
-        <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span> <span class="o">==</span> <span class="s1">&#39;00&#39;</span><span class="p">:</span>
-            <span class="n">start</span> <span class="o">=</span> <span class="n">start</span> <span class="o">-</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">days</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
-
-    <span class="k">if</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span> <span class="ow">and</span> <span class="n">fluxes</span><span class="p">:</span>
+    <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
+        <span class="n">start</span> <span class="o">=</span> <span class="n">start</span> <span class="o">-</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">days</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
+
+    <span class="k">if</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span> <span class="ow">and</span> <span class="n">fluxes</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
         <span class="n">start</span> <span class="o">=</span> <span class="n">start</span> <span class="o">-</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">days</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
         <span class="n">end</span> <span class="o">=</span> <span class="n">end</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">days</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
+
+    <span class="c1"># if we have non-flux forecast data starting at 18 UTC</span>
+    <span class="c1"># we need to start retrieving data one day in advance</span>
+    <span class="k">if</span> <span class="ow">not</span> <span class="n">fluxes</span> <span class="ow">and</span> <span class="n">check_dates_for_nonflux_fc_times</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">time</span><span class="p">):</span>
+        <span class="n">start</span> <span class="o">=</span> <span class="n">start</span> <span class="o">-</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">days</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
 
     <span class="k">return</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">chunk</span></div>
@@ -493,5 +515,5 @@
             <span class="n">flexpart</span><span class="o">.</span><span class="n">retrieve</span><span class="p">(</span><span class="n">server</span><span class="p">,</span> <span class="n">dates</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">public</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">request</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">)</span>
         <span class="k">except</span> <span class="ne">IOError</span><span class="p">:</span>
-            <span class="n">my_error</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">mailfail</span><span class="p">,</span> <span class="s1">&#39;MARS request failed&#39;</span><span class="p">)</span>
+            <span class="n">my_error</span><span class="p">(</span><span class="s1">&#39;MARS request failed&#39;</span><span class="p">)</span>
 
         <span class="n">day</span> <span class="o">+=</span> <span class="n">delta_t</span>
@@ -513,5 +535,5 @@
   <div role="contentinfo">
     <p>
-        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
+        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
 
     </p>
@@ -532,11 +554,19 @@
   
 
-    
-    
-      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
-        <script type="text/javascript" src="../_static/jquery.js"></script>
-        <script type="text/javascript" src="../_static/underscore.js"></script>
-        <script type="text/javascript" src="../_static/doctools.js"></script>
-    
+    <script type="text/javascript">
+        var DOCUMENTATION_OPTIONS = {
+            URL_ROOT:'../',
+            VERSION:'7.1 alpha',
+            LANGUAGE:'None',
+            COLLAPSE_INDEX:false,
+            FILE_SUFFIX:'.html',
+            HAS_SOURCE:  true,
+            SOURCELINK_SUFFIX: '.txt'
+        };
+    </script>
+      <script type="text/javascript" src="../_static/jquery.js"></script>
+      <script type="text/javascript" src="../_static/underscore.js"></script>
+      <script type="text/javascript" src="../_static/doctools.js"></script>
+      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
 
   
Index: documentation/Sphinx/build/html/_modules/index.html
===================================================================
--- documentation/Sphinx/build/html/_modules/index.html	(revision 2625ca8faac35d65699e83e37bb42cdc24163490)
+++ documentation/Sphinx/build/html/_modules/index.html	(revision f66f9905a36e7b0a824c539e948b15ca55615e47)
@@ -173,5 +173,5 @@
   <div role="contentinfo">
     <p>
-        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
+        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
 
     </p>
@@ -192,11 +192,19 @@
   
 
-    
-    
-      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
-        <script type="text/javascript" src="../_static/jquery.js"></script>
-        <script type="text/javascript" src="../_static/underscore.js"></script>
-        <script type="text/javascript" src="../_static/doctools.js"></script>
-    
+    <script type="text/javascript">
+        var DOCUMENTATION_OPTIONS = {
+            URL_ROOT:'../',
+            VERSION:'7.1 alpha',
+            LANGUAGE:'None',
+            COLLAPSE_INDEX:false,
+            FILE_SUFFIX:'.html',
+            HAS_SOURCE:  true,
+            SOURCELINK_SUFFIX: '.txt'
+        };
+    </script>
+      <script type="text/javascript" src="../_static/jquery.js"></script>
+      <script type="text/javascript" src="../_static/underscore.js"></script>
+      <script type="text/javascript" src="../_static/doctools.js"></script>
+      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
 
   
Index: documentation/Sphinx/build/html/_modules/install.html
===================================================================
--- documentation/Sphinx/build/html/_modules/install.html	(revision 2625ca8faac35d65699e83e37bb42cdc24163490)
+++ documentation/Sphinx/build/html/_modules/install.html	(revision f66f9905a36e7b0a824c539e948b15ca55615e47)
@@ -866,5 +866,5 @@
   <div role="contentinfo">
     <p>
-        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
+        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
 
     </p>
@@ -885,11 +885,19 @@
   
 
-    
-    
-      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
-        <script type="text/javascript" src="../_static/jquery.js"></script>
-        <script type="text/javascript" src="../_static/underscore.js"></script>
-        <script type="text/javascript" src="../_static/doctools.js"></script>
-    
+    <script type="text/javascript">
+        var DOCUMENTATION_OPTIONS = {
+            URL_ROOT:'../',
+            VERSION:'7.1 alpha',
+            LANGUAGE:'None',
+            COLLAPSE_INDEX:false,
+            FILE_SUFFIX:'.html',
+            HAS_SOURCE:  true,
+            SOURCELINK_SUFFIX: '.txt'
+        };
+    </script>
+      <script type="text/javascript" src="../_static/jquery.js"></script>
+      <script type="text/javascript" src="../_static/underscore.js"></script>
+      <script type="text/javascript" src="../_static/doctools.js"></script>
+      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
 
   
Index: documentation/Sphinx/build/html/_modules/prepare_flexpart.html
===================================================================
--- documentation/Sphinx/build/html/_modules/prepare_flexpart.html	(revision 2625ca8faac35d65699e83e37bb42cdc24163490)
+++ documentation/Sphinx/build/html/_modules/prepare_flexpart.html	(revision f66f9905a36e7b0a824c539e948b15ca55615e47)
@@ -227,13 +227,7 @@
 <span class="kn">from</span> <span class="nn">classes.UioFiles</span> <span class="k">import</span> <span class="n">UioFiles</span>
 <span class="kn">from</span> <span class="nn">classes.ControlFile</span> <span class="k">import</span> <span class="n">ControlFile</span>
-<span class="kn">from</span> <span class="nn">tools</span> <span class="k">import</span> <span class="n">clean_up</span><span class="p">,</span> <span class="n">get_cmdline_args</span><span class="p">,</span> <span class="n">read_ecenv</span><span class="p">,</span> <span class="n">make_dir</span>
+<span class="kn">from</span> <span class="nn">tools</span> <span class="k">import</span> <span class="p">(</span><span class="n">setup_controldata</span><span class="p">,</span> <span class="n">clean_up</span><span class="p">,</span> <span class="n">get_cmdline_args</span><span class="p">,</span>
+                   <span class="n">read_ecenv</span><span class="p">,</span> <span class="n">make_dir</span><span class="p">)</span>
 <span class="kn">from</span> <span class="nn">classes.EcFlexpart</span> <span class="k">import</span> <span class="n">EcFlexpart</span>
-
-<span class="n">ecapi</span> <span class="o">=</span> <span class="s1">&#39;ecmwf&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">socket</span><span class="o">.</span><span class="n">gethostname</span><span class="p">()</span>
-<span class="k">try</span><span class="p">:</span>
-    <span class="k">if</span> <span class="n">ecapi</span><span class="p">:</span>
-        <span class="kn">import</span> <span class="nn">ecmwfapi</span>
-<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
-    <span class="n">ecapi</span> <span class="o">=</span> <span class="kc">False</span>
 
 <span class="c1"># ------------------------------------------------------------------------------</span>
@@ -254,13 +248,7 @@
 <span class="sd">    &#39;&#39;&#39;</span>
 
-    <span class="n">args</span> <span class="o">=</span> <span class="n">get_cmdline_args</span><span class="p">()</span>
-    <span class="n">c</span> <span class="o">=</span> <span class="n">ControlFile</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">controlfile</span><span class="p">)</span>
-
-    <span class="n">env_parameter</span> <span class="o">=</span> <span class="n">read_ecenv</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">PATH_ECMWF_ENV</span><span class="p">)</span>
-    <span class="n">c</span><span class="o">.</span><span class="n">assign_args_to_control</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>
-    <span class="n">c</span><span class="o">.</span><span class="n">assign_envs_to_control</span><span class="p">(</span><span class="n">env_parameter</span><span class="p">)</span>
-    <span class="n">c</span><span class="o">.</span><span class="n">check_conditions</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">queue</span><span class="p">)</span>
-
-    <span class="n">prepare_flexpart</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">ppid</span><span class="p">,</span> <span class="n">c</span><span class="p">)</span>
+    <span class="n">c</span><span class="p">,</span> <span class="n">ppid</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">setup_controldata</span><span class="p">()</span>
+    <span class="n">prepare_flexpart</span><span class="p">(</span><span class="n">ppid</span><span class="p">,</span> <span class="n">c</span><span class="p">)</span>
+    <span class="n">normal_exit</span><span class="p">(</span><span class="s1">&#39;Preparing FLEXPART output files: Done!&#39;</span><span class="p">)</span>
 
     <span class="k">return</span></div>
@@ -290,6 +278,4 @@
     <span class="n">check_ppid</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="n">ppid</span><span class="p">)</span>
 
-    <span class="n">c</span><span class="o">.</span><span class="n">ecapi</span> <span class="o">=</span> <span class="n">ecapi</span>
-
     <span class="c1"># create the start and end date</span>
     <span class="n">start</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">date</span><span class="p">(</span><span class="n">year</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">start_date</span><span class="p">[:</span><span class="mi">4</span><span class="p">]),</span>
@@ -305,5 +291,5 @@
     <span class="c1"># since we need the 12 hours upfront</span>
     <span class="c1"># (the day before from 12 UTC to current day 00 UTC)</span>
-    <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span> <span class="o">==</span> <span class="s1">&#39;00&#39;</span><span class="p">:</span>
+    <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
         <span class="n">start</span> <span class="o">=</span> <span class="n">start</span> <span class="o">-</span> <span class="n">datetime</span><span class="o">.</span><span class="n">timedelta</span><span class="p">(</span><span class="n">days</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
 
@@ -330,4 +316,6 @@
     <span class="n">flexpart</span> <span class="o">=</span> <span class="n">EcFlexpart</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="n">fluxes</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
     <span class="n">flexpart</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="n">inputfiles</span><span class="p">,</span> <span class="n">c</span><span class="p">)</span>
+    <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">stream</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;elda&#39;</span><span class="p">:</span>
+        <span class="n">flexpart</span><span class="o">.</span><span class="n">calc_extra_elda</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">prefix</span><span class="p">)</span>
     <span class="n">flexpart</span><span class="o">.</span><span class="n">process_output</span><span class="p">(</span><span class="n">c</span><span class="p">)</span>
 
@@ -360,5 +348,5 @@
   <div role="contentinfo">
     <p>
-        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
+        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
 
     </p>
@@ -379,11 +367,19 @@
   
 
-    
-    
-      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
-        <script type="text/javascript" src="../_static/jquery.js"></script>
-        <script type="text/javascript" src="../_static/underscore.js"></script>
-        <script type="text/javascript" src="../_static/doctools.js"></script>
-    
+    <script type="text/javascript">
+        var DOCUMENTATION_OPTIONS = {
+            URL_ROOT:'../',
+            VERSION:'7.1 alpha',
+            LANGUAGE:'None',
+            COLLAPSE_INDEX:false,
+            FILE_SUFFIX:'.html',
+            HAS_SOURCE:  true,
+            SOURCELINK_SUFFIX: '.txt'
+        };
+    </script>
+      <script type="text/javascript" src="../_static/jquery.js"></script>
+      <script type="text/javascript" src="../_static/underscore.js"></script>
+      <script type="text/javascript" src="../_static/doctools.js"></script>
+      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
 
   
Index: documentation/Sphinx/build/html/_modules/submit.html
===================================================================
--- documentation/Sphinx/build/html/_modules/submit.html	(revision 2625ca8faac35d65699e83e37bb42cdc24163490)
+++ documentation/Sphinx/build/html/_modules/submit.html	(revision f66f9905a36e7b0a824c539e948b15ca55615e47)
@@ -220,5 +220,5 @@
 <span class="c1"># software specific classes and modules from flex_extract</span>
 <span class="kn">import</span> <span class="nn">_config</span>
-<span class="kn">from</span> <span class="nn">mods.tools</span> <span class="k">import</span> <span class="p">(</span><span class="n">normal_exit</span><span class="p">,</span> <span class="n">get_cmdline_args</span><span class="p">,</span>
+<span class="kn">from</span> <span class="nn">mods.tools</span> <span class="k">import</span> <span class="p">(</span><span class="n">setup_controldata</span><span class="p">,</span> <span class="n">normal_exit</span><span class="p">,</span> <span class="n">get_cmdline_args</span><span class="p">,</span>
                         <span class="n">submit_job_to_ecserver</span><span class="p">,</span> <span class="n">read_ecenv</span><span class="p">)</span>
 <span class="kn">from</span> <span class="nn">mods.get_mars_data</span> <span class="k">import</span> <span class="n">get_mars_data</span>
@@ -244,16 +244,10 @@
 <span class="sd">    &#39;&#39;&#39;</span>
 
-    <span class="n">args</span> <span class="o">=</span> <span class="n">get_cmdline_args</span><span class="p">()</span>
-    <span class="n">c</span> <span class="o">=</span> <span class="n">ControlFile</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">controlfile</span><span class="p">)</span>
-
-    <span class="n">env_parameter</span> <span class="o">=</span> <span class="n">read_ecenv</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">PATH_ECMWF_ENV</span><span class="p">)</span>
-    <span class="n">c</span><span class="o">.</span><span class="n">assign_args_to_control</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>
-    <span class="n">c</span><span class="o">.</span><span class="n">assign_envs_to_control</span><span class="p">(</span><span class="n">env_parameter</span><span class="p">)</span>
-    <span class="n">c</span><span class="o">.</span><span class="n">check_conditions</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">queue</span><span class="p">)</span>
+    <span class="n">c</span><span class="p">,</span> <span class="n">ppid</span><span class="p">,</span> <span class="n">queue</span><span class="p">,</span> <span class="n">job_template</span> <span class="o">=</span> <span class="n">setup_controldata</span><span class="p">()</span>
 
     <span class="c1"># on local side</span>
-    <span class="c1"># on ECMWF server this would also be the local side</span>
+    <span class="c1"># starting from an ECMWF server this would also be the local side</span>
     <span class="n">called_from_dir</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getcwd</span><span class="p">()</span>
-    <span class="k">if</span> <span class="n">args</span><span class="o">.</span><span class="n">queue</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
+    <span class="k">if</span> <span class="n">queue</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
         <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="s1">&#39;/&#39;</span><span class="p">:</span>
             <span class="n">c</span><span class="o">.</span><span class="n">inputdir</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">called_from_dir</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">)</span>
@@ -262,5 +256,5 @@
         <span class="n">get_mars_data</span><span class="p">(</span><span class="n">c</span><span class="p">)</span>
         <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">request</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">or</span> <span class="n">c</span><span class="o">.</span><span class="n">request</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
-            <span class="n">prepare_flexpart</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">ppid</span><span class="p">,</span> <span class="n">c</span><span class="p">)</span>
+            <span class="n">prepare_flexpart</span><span class="p">(</span><span class="n">ppid</span><span class="p">,</span> <span class="n">c</span><span class="p">)</span>
             <span class="n">exit_message</span> <span class="o">=</span> <span class="s1">&#39;FLEX_EXTRACT IS DONE!&#39;</span>
         <span class="k">else</span><span class="p">:</span>
@@ -268,5 +262,5 @@
     <span class="c1"># send files to ECMWF server</span>
     <span class="k">else</span><span class="p">:</span>
-        <span class="n">submit</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">job_template</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">args</span><span class="o">.</span><span class="n">queue</span><span class="p">)</span>
+        <span class="n">submit</span><span class="p">(</span><span class="n">job_template</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">queue</span><span class="p">)</span>
         <span class="n">exit_message</span> <span class="o">=</span> <span class="s1">&#39;FLEX_EXTRACT JOB SCRIPT IS SUBMITED!&#39;</span>
 
@@ -299,5 +293,5 @@
 <span class="sd">    &#39;&#39;&#39;</span>
 
-    <span class="k">if</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span><span class="p">:</span>
+    <span class="k">if</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">oper</span><span class="p">:</span>
     <span class="c1"># --------- create on demand job script ------------------------------------</span>
         <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
@@ -315,13 +309,13 @@
             <span class="n">end</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">end_date</span><span class="p">,</span> <span class="s1">&#39;%Y%m</span><span class="si">%d</span><span class="s1">&#39;</span><span class="p">)</span>
             <span class="n">chunk</span> <span class="o">=</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">days</span><span class="o">=</span><span class="n">c</span><span class="o">.</span><span class="n">job_chunk</span><span class="p">)</span>
+            <span class="n">oneday</span> <span class="o">=</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">days</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
 
             <span class="k">while</span> <span class="n">start</span> <span class="o">&lt;=</span> <span class="n">end</span><span class="p">:</span>
                 <span class="k">if</span> <span class="p">(</span><span class="n">start</span> <span class="o">+</span> <span class="n">chunk</span><span class="p">)</span> <span class="o">&lt;=</span> <span class="n">end</span><span class="p">:</span>
-                    <span class="n">c</span><span class="o">.</span><span class="n">end_date</span> <span class="o">=</span> <span class="p">(</span><span class="n">start</span> <span class="o">+</span> <span class="n">chunk</span><span class="p">)</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">&quot;%Y%m</span><span class="si">%d</span><span class="s2">&quot;</span><span class="p">)</span>
+                    <span class="n">c</span><span class="o">.</span><span class="n">end_date</span> <span class="o">=</span> <span class="p">(</span><span class="n">start</span> <span class="o">+</span> <span class="n">chunk</span> <span class="o">-</span> <span class="n">oneday</span><span class="p">)</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">&quot;%Y%m</span><span class="si">%d</span><span class="s2">&quot;</span><span class="p">)</span>
                 <span class="k">else</span><span class="p">:</span>
                     <span class="n">c</span><span class="o">.</span><span class="n">end_date</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">&quot;%Y%m</span><span class="si">%d</span><span class="s2">&quot;</span><span class="p">)</span>
 
                 <span class="n">clist</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">to_list</span><span class="p">()</span>
-
                 <span class="n">mk_jobscript</span><span class="p">(</span><span class="n">jtemplate</span><span class="p">,</span> <span class="n">job_file</span><span class="p">,</span> <span class="n">clist</span><span class="p">)</span>
 
@@ -349,5 +343,5 @@
         <span class="n">c</span><span class="o">.</span><span class="n">start_date</span> <span class="o">=</span> <span class="s1">&#39;$</span><span class="si">{MSJ_YEAR}</span><span class="s1">$</span><span class="si">{MSJ_MONTH}</span><span class="s1">$</span><span class="si">{MSJ_DAY}</span><span class="s1">&#39;</span>
         <span class="n">c</span><span class="o">.</span><span class="n">end_date</span> <span class="o">=</span> <span class="s1">&#39;$</span><span class="si">{MSJ_YEAR}</span><span class="s1">$</span><span class="si">{MSJ_MONTH}</span><span class="s1">$</span><span class="si">{MSJ_DAY}</span><span class="s1">&#39;</span>
-        <span class="n">c</span><span class="o">.</span><span class="n">base_time</span> <span class="o">=</span> <span class="s1">&#39;$</span><span class="si">{MSJ_BASETIME}</span><span class="s1">&#39;</span>
+        <span class="n">c</span><span class="o">.</span><span class="n">basetime</span> <span class="o">=</span> <span class="s1">&#39;$</span><span class="si">{MSJ_BASETIME}</span><span class="s1">&#39;</span>
         <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">&gt;</span> <span class="mi">24</span><span class="p">:</span>
             <span class="n">c</span><span class="o">.</span><span class="n">time</span> <span class="o">=</span> <span class="s1">&#39;$</span><span class="si">{MSJ_BASETIME}</span><span class="s1"> </span><span class="si">{MSJ_BASETIME}</span><span class="s1">&#39;</span>
@@ -434,5 +428,5 @@
   <div role="contentinfo">
     <p>
-        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
+        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
 
     </p>
@@ -453,11 +447,19 @@
   
 
-    
-    
-      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
-        <script type="text/javascript" src="../_static/jquery.js"></script>
-        <script type="text/javascript" src="../_static/underscore.js"></script>
-        <script type="text/javascript" src="../_static/doctools.js"></script>
-    
+    <script type="text/javascript">
+        var DOCUMENTATION_OPTIONS = {
+            URL_ROOT:'../',
+            VERSION:'7.1 alpha',
+            LANGUAGE:'None',
+            COLLAPSE_INDEX:false,
+            FILE_SUFFIX:'.html',
+            HAS_SOURCE:  true,
+            SOURCELINK_SUFFIX: '.txt'
+        };
+    </script>
+      <script type="text/javascript" src="../_static/jquery.js"></script>
+      <script type="text/javascript" src="../_static/underscore.js"></script>
+      <script type="text/javascript" src="../_static/doctools.js"></script>
+      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
 
   
Index: documentation/Sphinx/build/html/_modules/tools.html
===================================================================
--- documentation/Sphinx/build/html/_modules/tools.html	(revision 2625ca8faac35d65699e83e37bb42cdc24163490)
+++ documentation/Sphinx/build/html/_modules/tools.html	(revision f66f9905a36e7b0a824c539e948b15ca55615e47)
@@ -222,7 +222,44 @@
 <span class="kn">from</span> <span class="nn">argparse</span> <span class="k">import</span> <span class="n">ArgumentParser</span><span class="p">,</span> <span class="n">ArgumentDefaultsHelpFormatter</span>
 
+
+
 <span class="c1"># ------------------------------------------------------------------------------</span>
 <span class="c1"># METHODS</span>
 <span class="c1"># ------------------------------------------------------------------------------</span>
+
+<div class="viewcode-block" id="setup_controldata"><a class="viewcode-back" href="../api.html#tools.setup_controldata">[docs]</a><span class="k">def</span> <span class="nf">setup_controldata</span><span class="p">():</span>
+    <span class="sd">&#39;&#39;&#39;Collects, stores and checks controlling arguments from command line,</span>
+<span class="sd">    CONTROL file and ECMWF_ENV file.</span>
+
+<span class="sd">    Parameters</span>
+<span class="sd">    ----------</span>
+
+<span class="sd">    Return</span>
+<span class="sd">    ------</span>
+<span class="sd">    c : ControlFile</span>
+<span class="sd">        Contains all the parameters of CONTROL file and</span>
+<span class="sd">        command line.</span>
+
+<span class="sd">    ppid : str</span>
+<span class="sd">        Parent process id.</span>
+
+<span class="sd">    queue : str</span>
+<span class="sd">        Name of queue for submission to ECMWF (e.g. ecgate or cca )</span>
+
+<span class="sd">    job_template : str</span>
+<span class="sd">        Name of the job template file for submission to ECMWF server.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="kn">import</span> <span class="nn">_config</span>
+    <span class="kn">from</span> <span class="nn">classes.ControlFile</span> <span class="k">import</span> <span class="n">ControlFile</span>
+
+    <span class="n">args</span> <span class="o">=</span> <span class="n">get_cmdline_args</span><span class="p">()</span>
+    <span class="n">c</span> <span class="o">=</span> <span class="n">ControlFile</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">controlfile</span><span class="p">)</span>
+    <span class="n">c</span><span class="o">.</span><span class="n">assign_args_to_control</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>
+    <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">PATH_ECMWF_ENV</span><span class="p">):</span>
+        <span class="n">env_parameter</span> <span class="o">=</span> <span class="n">read_ecenv</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">PATH_ECMWF_ENV</span><span class="p">)</span>
+        <span class="n">c</span><span class="o">.</span><span class="n">assign_envs_to_control</span><span class="p">(</span><span class="n">env_parameter</span><span class="p">)</span>
+    <span class="n">c</span><span class="o">.</span><span class="n">check_conditions</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">queue</span><span class="p">)</span>
+
+    <span class="k">return</span> <span class="n">c</span><span class="p">,</span> <span class="n">args</span><span class="o">.</span><span class="n">ppid</span><span class="p">,</span> <span class="n">args</span><span class="o">.</span><span class="n">queue</span><span class="p">,</span> <span class="n">args</span><span class="o">.</span><span class="n">job_template</span></div>
 
 <div class="viewcode-block" id="none_or_str"><a class="viewcode-back" href="../api.html#tools.none_or_str">[docs]</a><span class="k">def</span> <span class="nf">none_or_str</span><span class="p">(</span><span class="n">value</span><span class="p">):</span>
@@ -300,5 +337,5 @@
     <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">&quot;--basetime&quot;</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s2">&quot;basetime&quot;</span><span class="p">,</span>
                         <span class="nb">type</span><span class="o">=</span><span class="n">none_or_int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
-                        <span class="n">help</span><span class="o">=</span><span class="s2">&quot;base such as 00 or 12 (for half day retrievals)&quot;</span><span class="p">)</span>
+                        <span class="n">help</span><span class="o">=</span><span class="s2">&quot;base such as 0 or 12 (for half day retrievals)&quot;</span><span class="p">)</span>
     <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">&quot;--step&quot;</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s2">&quot;step&quot;</span><span class="p">,</span>
                         <span class="nb">type</span><span class="o">=</span><span class="n">none_or_str</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
@@ -315,4 +352,8 @@
                         <span class="nb">type</span><span class="o">=</span><span class="n">none_or_int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                         <span class="n">help</span><span class="o">=</span><span class="s2">&quot;debug mode - leave temporary files intact&quot;</span><span class="p">)</span>
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">&quot;--oper&quot;</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s2">&quot;oper&quot;</span><span class="p">,</span>
+                        <span class="nb">type</span><span class="o">=</span><span class="n">none_or_int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
+                        <span class="n">help</span><span class="o">=</span><span class="s2">&quot;operational mode - prepares dates with </span><span class="se">\</span>
+<span class="s2">                        environment variables&quot;</span><span class="p">)</span>
     <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">&quot;--request&quot;</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s2">&quot;request&quot;</span><span class="p">,</span>
                         <span class="nb">type</span><span class="o">=</span><span class="n">none_or_int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
@@ -408,12 +449,10 @@
     <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;... clean inputdir!&quot;</span><span class="p">)</span>
 
-    <span class="n">cleanlist</span> <span class="o">=</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="s2">&quot;*&quot;</span><span class="p">))</span>
+    <span class="n">cleanlist</span> <span class="o">=</span> <span class="p">[</span><span class="n">file</span> <span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="s2">&quot;*&quot;</span><span class="p">))</span>
+                 <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">file</span><span class="p">)</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">prefix</span><span class="p">)]</span>
 
     <span class="k">if</span> <span class="n">cleanlist</span><span class="p">:</span>
         <span class="k">for</span> <span class="n">element</span> <span class="ow">in</span> <span class="n">cleanlist</span><span class="p">:</span>
-            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">prefix</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">element</span><span class="p">:</span>
-                <span class="n">silent_remove</span><span class="p">(</span><span class="n">element</span><span class="p">)</span>
-            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">ecapi</span> <span class="ow">is</span> <span class="kc">False</span> <span class="ow">and</span> <span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">ectrans</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">or</span> <span class="n">c</span><span class="o">.</span><span class="n">ecstorage</span> <span class="o">==</span> <span class="mi">1</span><span class="p">):</span>
-                <span class="n">silent_remove</span><span class="p">(</span><span class="n">element</span><span class="p">)</span>
+            <span class="n">silent_remove</span><span class="p">(</span><span class="n">element</span><span class="p">)</span>
         <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;... done!&quot;</span><span class="p">)</span>
     <span class="k">else</span><span class="p">:</span>
@@ -423,5 +462,5 @@
 
 
-<div class="viewcode-block" id="my_error"><a class="viewcode-back" href="../api.html#tools.my_error">[docs]</a><span class="k">def</span> <span class="nf">my_error</span><span class="p">(</span><span class="n">users</span><span class="p">,</span> <span class="n">message</span><span class="o">=</span><span class="s1">&#39;ERROR&#39;</span><span class="p">):</span>
+<div class="viewcode-block" id="my_error"><a class="viewcode-back" href="../api.html#tools.my_error">[docs]</a><span class="k">def</span> <span class="nf">my_error</span><span class="p">(</span><span class="n">message</span><span class="o">=</span><span class="s1">&#39;ERROR&#39;</span><span class="p">):</span>
     <span class="sd">&#39;&#39;&#39;Prints a specified error message which can be passed to the function</span>
 <span class="sd">    before exiting the program.</span>
@@ -429,9 +468,4 @@
 <span class="sd">    Parameters</span>
 <span class="sd">    ----------</span>
-<span class="sd">    user : list of str</span>
-<span class="sd">        Contains all email addresses which should be notified.</span>
-<span class="sd">        It might also contain just the ecmwf user name which wil trigger</span>
-<span class="sd">        mailing to the associated email address for this user.</span>
-
 <span class="sd">    message : str, optional</span>
 <span class="sd">        Error message. Default value is &quot;ERROR&quot;.</span>
@@ -446,6 +480,4 @@
 
     <span class="nb">print</span><span class="p">(</span><span class="n">full_message</span><span class="p">)</span>
-
-    <span class="n">send_mail</span><span class="p">(</span><span class="n">users</span><span class="p">,</span> <span class="s1">&#39;ERROR&#39;</span><span class="p">,</span> <span class="n">full_message</span><span class="p">)</span>
 
     <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
@@ -615,6 +647,6 @@
     <span class="k">else</span><span class="p">:</span>
         <span class="k">for</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">fdata</span><span class="p">:</span>
-            <span class="k">if</span> <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="s1">&#39;!&#39;</span><span class="p">:</span>
-                <span class="n">table128</span><span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">3</span><span class="p">]]</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="mi">59</span><span class="p">:</span><span class="mi">64</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
+            <span class="k">if</span> <span class="n">data</span> <span class="o">!=</span> <span class="s1">&#39;&#39;</span> <span class="ow">and</span> <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="s1">&#39;!&#39;</span><span class="p">:</span>
+                <span class="n">table128</span><span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">3</span><span class="p">]]</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="mi">59</span><span class="p">:</span><span class="mi">65</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
 
     <span class="k">return</span> <span class="n">table128</span></div>
@@ -659,4 +691,45 @@
 
     <span class="k">return</span> <span class="n">ipar</span></div>
+
+<div class="viewcode-block" id="to_param_id_with_tablenumber"><a class="viewcode-back" href="../api.html#tools.to_param_id_with_tablenumber">[docs]</a><span class="k">def</span> <span class="nf">to_param_id_with_tablenumber</span><span class="p">(</span><span class="n">pars</span><span class="p">,</span> <span class="n">table</span><span class="p">):</span>
+    <span class="sd">&#39;&#39;&#39;Transform parameter names to parameter ids and add table id.</span>
+
+<span class="sd">    Conversion with ECMWF grib table 128.</span>
+
+<span class="sd">    Parameters</span>
+<span class="sd">    ----------</span>
+<span class="sd">    pars : str</span>
+<span class="sd">        Addpar argument from CONTROL file in the format of</span>
+<span class="sd">        parameter names instead of ids. The parameter short</span>
+<span class="sd">        names are sepearted with &quot;/&quot; and they are passed as</span>
+<span class="sd">        one single string.</span>
+
+<span class="sd">    table : dict</span>
+<span class="sd">        Contains the ECMWF grib table 128 information.</span>
+<span class="sd">        The key is the parameter number and the value is the</span>
+<span class="sd">        short name of the parameter.</span>
+
+<span class="sd">    Return</span>
+<span class="sd">    ------</span>
+<span class="sd">    spar : str</span>
+<span class="sd">        List of addpar parameters from CONTROL file transformed to</span>
+<span class="sd">        parameter ids in the format of integer.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">if</span> <span class="ow">not</span> <span class="n">pars</span><span class="p">:</span>
+        <span class="k">return</span> <span class="p">[]</span>
+    <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">pars</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
+        <span class="n">pars</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">pars</span><span class="p">)</span>
+
+    <span class="n">cpar</span> <span class="o">=</span> <span class="n">pars</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)</span>
+    <span class="n">spar</span> <span class="o">=</span> <span class="p">[]</span>
+    <span class="k">for</span> <span class="n">par</span> <span class="ow">in</span> <span class="n">cpar</span><span class="p">:</span>
+        <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">iteritems</span><span class="p">():</span>
+            <span class="k">if</span> <span class="n">par</span> <span class="o">==</span> <span class="n">k</span> <span class="ow">or</span> <span class="n">par</span> <span class="o">==</span> <span class="n">v</span><span class="p">:</span>
+                <span class="n">spar</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span> <span class="o">+</span> <span class="s1">&#39;.128&#39;</span><span class="p">)</span>
+                <span class="k">break</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n\n\t\t</span><span class="s1">Warning: par &#39;</span> <span class="o">+</span> <span class="n">par</span> <span class="o">+</span> <span class="s1">&#39; not found in table 128</span><span class="se">\n\n</span><span class="s1">&#39;</span><span class="p">)</span>
+
+    <span class="k">return</span> <span class="s1">&#39;/&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">spar</span><span class="p">)</span></div>
 
 <div class="viewcode-block" id="get_list_as_string"><a class="viewcode-back" href="../api.html#tools.get_list_as_string">[docs]</a><span class="k">def</span> <span class="nf">get_list_as_string</span><span class="p">(</span><span class="n">list_obj</span><span class="p">,</span> <span class="n">concatenate_sign</span><span class="o">=</span><span class="s1">&#39;, &#39;</span><span class="p">):</span>
@@ -958,5 +1031,5 @@
   <div role="contentinfo">
     <p>
-        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
+        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
 
     </p>
@@ -977,11 +1050,19 @@
   
 
-    
-    
-      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
-        <script type="text/javascript" src="../_static/jquery.js"></script>
-        <script type="text/javascript" src="../_static/underscore.js"></script>
-        <script type="text/javascript" src="../_static/doctools.js"></script>
-    
+    <script type="text/javascript">
+        var DOCUMENTATION_OPTIONS = {
+            URL_ROOT:'../',
+            VERSION:'7.1 alpha',
+            LANGUAGE:'None',
+            COLLAPSE_INDEX:false,
+            FILE_SUFFIX:'.html',
+            HAS_SOURCE:  true,
+            SOURCELINK_SUFFIX: '.txt'
+        };
+    </script>
+      <script type="text/javascript" src="../_static/jquery.js"></script>
+      <script type="text/javascript" src="../_static/underscore.js"></script>
+      <script type="text/javascript" src="../_static/doctools.js"></script>
+      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
 
   
