Index: documentation/Sphinx/build/html/_modules/EcFlexpart.html
===================================================================
--- documentation/Sphinx/build/html/_modules/EcFlexpart.html	(revision 274f9efe4b8438ab5238967e39adc200c624b56e)
+++ documentation/Sphinx/build/html/_modules/EcFlexpart.html	(revision 2625ca8faac35d65699e83e37bb42cdc24163490)
@@ -194,29 +194,11 @@
 <span class="c1">#</span>
 <span class="c1"># @License:</span>
-<span class="c1">#    (C) Copyright 2014-2018.</span>
+<span class="c1">#    (C) Copyright 2014-2019.</span>
+<span class="c1">#    Anne Philipp, Leopold Haimberger</span>
 <span class="c1">#</span>
-<span class="c1">#    This software is licensed under the terms of the Apache Licence Version 2.0</span>
-<span class="c1">#    which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.</span>
-<span class="c1">#</span>
-<span class="c1"># @Class Description:</span>
-<span class="c1">#    FLEXPART needs grib files in a specifc format. All necessary data fields</span>
-<span class="c1">#    for one time step are stored in a single file. The class represents an</span>
-<span class="c1">#    instance with all the parameter and settings necessary for retrieving</span>
-<span class="c1">#    MARS data and modifing them so they are fitting FLEXPART need. The class</span>
-<span class="c1">#    is able to disaggregate the fluxes and convert grid types to the one needed</span>
-<span class="c1">#    by FLEXPART, therefore using the FORTRAN program.</span>
-<span class="c1">#</span>
-<span class="c1"># @Class Content:</span>
-<span class="c1">#    - __init__</span>
-<span class="c1">#    - write_namelist</span>
-<span class="c1">#    - retrieve</span>
-<span class="c1">#    - process_output</span>
-<span class="c1">#    - create</span>
-<span class="c1">#    - deacc_fluxes</span>
-<span class="c1">#</span>
-<span class="c1"># @Class Attributes:</span>
-<span class="c1">#</span>
-<span class="c1">#  TODO</span>
-<span class="c1">#</span>
+<span class="c1">#    This work is licensed under the Creative Commons Attribution 4.0</span>
+<span class="c1">#    International License. To view a copy of this license, visit</span>
+<span class="c1">#    http://creativecommons.org/licenses/by/4.0/ or send a letter to</span>
+<span class="c1">#    Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.</span>
 <span class="c1">#*******************************************************************************</span>
 <span class="c1">#pylint: disable=unsupported-assignment-operation</span>
@@ -235,19 +217,16 @@
 <span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
 
-<span class="kn">from</span> <span class="nn">gribapi</span> <span class="k">import</span> <span class="p">(</span><span class="n">grib_set</span><span class="p">,</span> <span class="n">grib_index_select</span><span class="p">,</span> <span class="n">grib_new_from_index</span><span class="p">,</span> <span class="n">grib_get</span><span class="p">,</span>
-                     <span class="n">grib_write</span><span class="p">,</span> <span class="n">grib_get_values</span><span class="p">,</span> <span class="n">grib_set_values</span><span class="p">,</span> <span class="n">grib_release</span><span class="p">,</span>
-                     <span class="n">grib_index_release</span><span class="p">,</span> <span class="n">grib_index_get</span><span class="p">)</span>
-
-<span class="c1"># from eccodes import (codes_index_select, codes_new_from_index, codes_get,</span>
-                     <span class="c1"># codes_get_values, codes_set_values, codes_set,</span>
-                     <span class="c1"># codes_write, codes_release, codes_new_from_index,</span>
-                     <span class="c1"># codes_index_release, codes_index_get)</span>
+<span class="kn">from</span> <span class="nn">eccodes</span> <span class="k">import</span> <span class="p">(</span><span class="n">codes_index_select</span><span class="p">,</span> <span class="n">codes_new_from_index</span><span class="p">,</span> <span class="n">codes_get</span><span class="p">,</span>
+                     <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="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="kn">from</span> <span class="nn">GribTools</span> <span class="k">import</span> <span class="n">GribTools</span>
+<span class="kn">from</span> <span class="nn">GribUtil</span> <span class="k">import</span> <span class="n">GribUtil</span>
 <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">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="kn">from</span> <span class="nn">MarsRetrieval</span> <span class="k">import</span> <span class="n">MarsRetrieval</span>
 <span class="kn">import</span> <span class="nn">mods.disaggregation</span> <span class="k">as</span> <span class="nn">disaggregation</span>
@@ -258,6 +237,110 @@
 <div class="viewcode-block" id="EcFlexpart"><a class="viewcode-back" href="../api.html#EcFlexpart.EcFlexpart">[docs]</a><span class="k">class</span> <span class="nc">EcFlexpart</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
     <span class="sd">&#39;&#39;&#39;</span>
-<span class="sd">    Class to retrieve FLEXPART specific ECMWF data.</span>
+<span class="sd">    Class to represent FLEXPART specific ECMWF data.</span>
+
+<span class="sd">    FLEXPART needs grib files in a specifc format. All necessary data fields</span>
+<span class="sd">    for one time step are stored in a single file. The class represents an</span>
+<span class="sd">    instance with all the parameter and settings necessary for retrieving</span>
+<span class="sd">    MARS data and modifing them so they are fitting FLEXPART needs. The class</span>
+<span class="sd">    is able to disaggregate the fluxes and convert grid types to the one needed</span>
+<span class="sd">    by FLEXPART, therefore using the FORTRAN program.</span>
+
+<span class="sd">    Attributes</span>
+<span class="sd">    ----------</span>
+<span class="sd">    mreq_count : int</span>
+<span class="sd">        Counter for the number of generated mars requests.</span>
+
+<span class="sd">    inputdir : str</span>
+<span class="sd">        Path to the directory where the retrieved data is stored.</span>
+
+<span class="sd">    dataset : str</span>
+<span class="sd">        For public datasets there is the specific naming and parameter</span>
+<span class="sd">        dataset which has to be used to characterize the type of</span>
+<span class="sd">        data.</span>
+
+<span class="sd">    basetime : str</span>
+<span class="sd">        The time for a half day retrieval. The 12 hours upfront are to be</span>
+<span class="sd">        retrieved.</span>
+
+<span class="sd">    dtime : str</span>
+<span class="sd">        Time step in hours.</span>
+
+<span class="sd">    acctype : str</span>
+<span class="sd">        The field type for the accumulated forecast fields.</span>
+
+<span class="sd">    acctime : str</span>
+<span class="sd">        The starting time from the accumulated forecasts.</span>
+
+<span class="sd">    accmaxstep : str</span>
+<span class="sd">        The maximum forecast step for the accumulated forecast fields.</span>
+
+<span class="sd">    marsclass : str</span>
+<span class="sd">        Characterisation of dataset.</span>
+
+<span class="sd">    stream : str</span>
+<span class="sd">        Identifies the forecasting system used to generate the data.</span>
+
+<span class="sd">    number : str</span>
+<span class="sd">        Selects the member in ensemble forecast run.</span>
+
+<span class="sd">    resol : str</span>
+<span class="sd">        Specifies the desired triangular truncation of retrieved data,</span>
+<span class="sd">        before carrying out any other selected post-processing.</span>
+
+<span class="sd">    accuracy : str</span>
+<span class="sd">        Specifies the number of bits per value to be used in the</span>
+<span class="sd">        generated GRIB coded fields.</span>
+
+<span class="sd">    addpar : str</span>
+<span class="sd">        List of additional parameters to be retrieved.</span>
+
+<span class="sd">    level : str</span>
+<span class="sd">        Specifies the maximum level.</span>
+
+<span class="sd">    expver : str</span>
+<span class="sd">        The version of the dataset.</span>
+
+<span class="sd">    levelist : str</span>
+<span class="sd">        Specifies the required levels.</span>
+
+<span class="sd">    glevelist : str</span>
+<span class="sd">        Specifies the required levels for gaussian grids.</span>
+
+<span class="sd">    gaussian : str</span>
+<span class="sd">        This parameter is deprecated and should no longer be used.</span>
+<span class="sd">        Specifies the desired type of Gaussian grid for the output.</span>
+
+<span class="sd">    grid : str</span>
+<span class="sd">        Specifies the output grid which can be either a Gaussian grid</span>
+<span class="sd">        or a Latitude/Longitude grid.</span>
+
+<span class="sd">    area : str</span>
+<span class="sd">        Specifies the desired sub-area of data to be extracted.</span>
+
+<span class="sd">    purefc : int</span>
+<span class="sd">        Switch for definition of pure forecast mode or not.</span>
+
+<span class="sd">    outputfilelist : list of str</span>
+<span class="sd">        The final list of FLEXPART ready input files.</span>
+
+<span class="sd">    types : dictionary</span>
+<span class="sd">        Determines the combination of type of fields, time and forecast step</span>
+<span class="sd">        to be retrieved.</span>
+
+<span class="sd">    params : dictionary</span>
+<span class="sd">        Collection of grid types and their corresponding parameters,</span>
+<span class="sd">        levels, level types and the grid definition.</span>
+
+<span class="sd">    server : ECMWFService or ECMWFDataServer</span>
+<span class="sd">        This is the connection to the ECMWF data servers.</span>
+
+<span class="sd">    public : int</span>
+<span class="sd">        Decides which Web API Server version is used.</span>
+
+<span class="sd">    dates : str</span>
+<span class="sd">        Contains start and end date of the retrieval in the format</span>
+<span class="sd">        &quot;YYYYMMDD/to/YYYYMMDD&quot;</span>
 <span class="sd">    &#39;&#39;&#39;</span>
+
     <span class="c1"># --------------------------------------------------------------------------</span>
     <span class="c1"># CLASS FUNCTIONS</span>
@@ -269,9 +352,9 @@
 <span class="sd">        Parameters:</span>
 <span class="sd">        -----------</span>
-<span class="sd">        c : :obj:`ControlFile`</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">        fluxes : :obj:`boolean`, optional</span>
+<span class="sd">        fluxes : boolean, optional</span>
 <span class="sd">            Decides if the flux parameter settings are stored or</span>
 <span class="sd">            the rest of the parameter list.</span>
@@ -282,19 +365,6 @@
 
 <span class="sd">        &#39;&#39;&#39;</span>
-        <span class="c1"># set a counter for the number of mars requests generated</span>
+        <span class="c1"># set a counter for the number of generated mars requests</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">mreq_count</span> <span class="o">=</span> <span class="mi">0</span>
-
-        <span class="c1"># different mars types for retrieving data for flexpart</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">types</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">()</span>
-
-        <span class="c1"># Pure forecast mode</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="nb">len</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="ow">and</span> <span class="s1">&#39;AN&#39;</span> <span class="ow">not</span> <span class="ow">in</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">type</span> <span class="o">=</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="mi">0</span><span class="p">]]</span>
-            <span class="n">c</span><span class="o">.</span><span class="n">step</span> <span class="o">=</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="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">c</span><span class="o">.</span><span class="n">time</span> <span class="o">=</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="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">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
-                <span class="n">c</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">append</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="mi">0</span><span class="p">])</span>
-                <span class="n">c</span><span class="o">.</span><span class="n">step</span><span class="o">.</span><span class="n">append</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">i</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="n">append</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="mi">0</span><span class="p">])</span>
 
         <span class="bp">self</span><span class="o">.</span><span class="n">inputdir</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">inputdir</span>
@@ -302,42 +372,7 @@
         <span class="bp">self</span><span class="o">.</span><span class="n">basetime</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">basetime</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">dtime</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">dtime</span>
-        <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
-        <span class="k">if</span> <span class="n">fluxes</span> <span class="ow">and</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span> <span class="o">&lt;=</span> <span class="mi">24</span><span class="p">:</span>
-            <span class="c1"># no forecast beyond one day is needed!</span>
-            <span class="c1"># Thus, prepare flux data manually as usual</span>
-            <span class="c1"># with only forecast fields with start times at 00/12</span>
-            <span class="c1"># (but without 00/12 fields since these are</span>
-            <span class="c1"># the initialisation times of the flux fields</span>
-            <span class="c1"># and therefore are zero all the time)</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">acctype</span><span class="p">)]</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;times&#39;</span><span class="p">:</span> <span class="nb">str</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">acctime</span><span class="p">),</span>
-                                          <span class="s1">&#39;steps&#39;</span><span class="p">:</span> <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">/to/</span><span class="si">{}</span><span class="s1">/by/</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="n">c</span><span class="o">.</span><span class="n">dtime</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">accmaxstep</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="k">else</span><span class="p">:</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">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">step</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">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="n">c</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="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="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">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>
-
-                <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">c</span><span class="o">.</span><span class="n">time</span><span class="p">[</span><span class="n">i</span><span class="p">])</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="mi">0</span><span class="p">)</span> <span class="ow">or</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">c</span><span class="o">.</span><span class="n">step</span><span class="p">[</span><span class="n">i</span><span class="p">])</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="mi">0</span> <span class="ow">and</span>
-                     <span class="p">(</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="n">i</span><span class="p">])</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="mi">0</span><span class="p">))</span> <span class="p">)</span> <span class="ow">and</span> \
-                    <span class="p">(</span><span class="nb">int</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">i</span><span class="p">])</span> <span class="ow">in</span> <span class="n">btlist</span> <span class="ow">or</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="k">if</span> <span class="n">ty</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
-                        <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="o">=</span> <span class="p">{</span><span class="s1">&#39;times&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;steps&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">}</span>
-
-                    <span class="k">if</span> <span class="n">ti</span> <span class="ow">not</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="n">ty</span><span class="p">][</span><span class="s1">&#39;times&#39;</span><span class="p">]:</span>
-                        <span class="k">if</span> <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;times&#39;</span><span class="p">]:</span>
-                            <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;times&#39;</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/&#39;</span>
-                        <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;times&#39;</span><span class="p">]</span> <span class="o">+=</span> <span class="n">ti</span>
-
-                    <span class="k">if</span> <span class="n">st</span> <span class="ow">not</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="n">ty</span><span class="p">][</span><span class="s1">&#39;steps&#39;</span><span class="p">]:</span>
-                        <span class="k">if</span> <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="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="s1">&#39;/&#39;</span>
-                        <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="bp">self</span><span class="o">.</span><span class="n">acctype</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">acctype</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">acctime</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">acctime</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">accmaxstep</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">accmaxstep</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">marsclass</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">marsclass</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">stream</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">stream</span>
@@ -345,109 +380,228 @@
         <span class="bp">self</span><span class="o">.</span><span class="n">resol</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">resol</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">accuracy</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">accuracy</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">addpar</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">addpar</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">level</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">level</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">expver</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">expver</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">levelist</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">levelist</span>
-        <span class="c1"># for gaussian grid retrieval</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">glevelist</span> <span class="o">=</span> <span class="s1">&#39;1/to/&#39;</span> <span class="o">+</span> <span class="n">c</span><span class="o">.</span><span class="n">level</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">glevelist</span> <span class="o">=</span> <span class="s1">&#39;1/to/&#39;</span> <span class="o">+</span> <span class="n">c</span><span class="o">.</span><span class="n">level</span> <span class="c1"># in case of gaussian grid</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">gaussian</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">gaussian</span>
-
-        <span class="k">if</span> <span class="s1">&#39;N&#39;</span> <span class="ow">in</span> <span class="n">c</span><span class="o">.</span><span class="n">grid</span><span class="p">:</span>  <span class="c1"># Gaussian output grid</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">grid</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">grid</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">area</span> <span class="o">=</span> <span class="s1">&#39;G&#39;</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">grid</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">grid</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">area</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">area</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">purefc</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">outputfilelist</span> <span class="o">=</span> <span class="p">[]</span>
+
+        <span class="c1"># Define the different types of field combinations (type, time, step)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">types</span> <span class="o">=</span> <span class="p">{}</span>
+        <span class="c1"># Define the parameters and their level types, level list and</span>
+        <span class="c1"># grid resolution for the retrieval job</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">params</span> <span class="o">=</span> <span class="p">{}</span>
+
+        <span class="k">if</span> <span class="n">fluxes</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">_create_params_fluxes</span><span class="p">()</span>
         <span class="k">else</span><span class="p">:</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">grid</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">/</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="n">c</span><span class="o">.</span><span class="n">grid</span><span class="p">)</span> <span class="o">/</span> <span class="mf">1000.</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">grid</span><span class="p">)</span> <span class="o">/</span> <span class="mf">1000.</span><span class="p">)</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">area</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">/</span><span class="si">{}</span><span class="s1">/</span><span class="si">{}</span><span class="s1">/</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="n">c</span><span class="o">.</span><span class="n">upper</span><span class="p">)</span> <span class="o">/</span> <span class="mf">1000.</span><span class="p">,</span>
-                                             <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">left</span><span class="p">)</span> <span class="o">/</span> <span class="mf">1000.</span><span class="p">,</span>
-                                             <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">lower</span><span class="p">)</span> <span class="o">/</span> <span class="mf">1000.</span><span class="p">,</span>
-                                             <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">right</span><span class="p">)</span> <span class="o">/</span> <span class="mf">1000.</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="p">[]</span>
-
-
-        <span class="c1"># Now comes the nasty part that deals with the different</span>
-        <span class="c1"># scenarios we have:</span>
-        <span class="c1"># 1) Calculation of etadot on</span>
-        <span class="c1">#    a) Gaussian grid</span>
-        <span class="c1">#    b) Output grid</span>
-        <span class="c1">#    c) Output grid using parameter 77 retrieved from MARS</span>
-        <span class="c1"># 3) Calculation/Retrieval of omega</span>
-        <span class="c1"># 4) Download also data for WRF</span>
-
-        <span class="c1"># Different grids need different retrievals</span>
-        <span class="c1"># SH = Spherical Harmonics, GG = Gaussian Grid,</span>
-        <span class="c1"># OG = Output Grid, ML = MultiLevel, SL = SingleLevel</span>
-        <span class="bp">self</span><span class="o">.</span><span class="n">params</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;SH__ML&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;SH__SL&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span>
-                       <span class="s1">&#39;GG__ML&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;GG__SL&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span>
-                       <span class="s1">&#39;OG__ML&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;OG__SL&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span>
-                       <span class="s1">&#39;OG_OROLSM_SL&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;OG_acc_SL&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">}</span>
-        <span class="c1"># the self.params dictionary stores a list of</span>
-        <span class="c1"># [param, levtype, levelist, grid] per key</span>
-
-        <span class="k">if</span> <span class="n">fluxes</span> <span class="ow">is</span> <span class="kc">False</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;SH__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;LNSP&#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;OFF&#39;</span><span class="p">]</span>
-            <span class="c1">#                        &quot;SD/MSL/TCC/10U/10V/2T/2D/129/172&quot;</span>
-            <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;OG__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;141/151/164/165/166/167/168/129/172&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">if</span> <span class="n">c</span><span class="o">.</span><span class="n">addpar</span><span class="p">:</span>
-                <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">addpar</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">addpar</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">addpar</span><span class="p">[</span><span class="mi">1</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__SL&#39;</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="o">+</span> <span class="s1">&#39;/&#39;</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">addpar</span><span class="p">)</span>
-
-            <span class="k">if</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="ow">or</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;EP&#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;OG_OROLSM__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;160/27/28/244&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">else</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_OROLSM__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;160/27/28/173&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="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="o">=</span> <span class="p">[</span><span class="s1">&#39;T/Q&#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">levelist</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="c1">#if c.gauss == &#39;0&#39; and c.eta == &#39;1&#39;:</span>
-            <span class="k">if</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">gauss</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="c1"># the simplest case</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/77&#39;</span>
-            <span class="c1">#elif c.gauss == &#39;0&#39; and c.eta == &#39;0&#39;:</span>
-            <span class="k">elif</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">gauss</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">eta</span><span class="p">:</span>
-            <span class="c1"># this is not recommended (inaccurate)</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="c1">#elif c.gauss == &#39;1&#39; and c.eta == &#39;0&#39;:</span>
-            <span class="k">elif</span> <span class="n">c</span><span class="o">.</span><span class="n">gauss</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">eta</span><span class="p">:</span>
-                <span class="c1"># this is needed for data before 2008, or for reanalysis data</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;SH__ML&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;U/V/D&#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;OFF&#39;</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;Warning: This is a very costly parameter combination, </span><span class="se">\</span>
-<span class="s1">                      use 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="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="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">omega</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;/W&#39;</span>
-
-            <span class="c1"># add cloud water content if necessary</span>
-            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">cwc</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;/CLWC/CIWC&#39;</span>
-
-            <span class="c1"># add vorticity and geopotential height for WRF if necessary</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="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="c1">#wrf_sfc = &#39;sp/msl/skt/2t/10u/10v/2d/z/lsm/sst/ci/sd/stl1/ /</span>
-                <span class="c1">#           stl2/stl3/stl4/swvl1/swvl2/swvl3/swvl4&#39;.upper()</span>
-                <span class="n">wrf_sfc</span> <span class="o">=</span> <span class="s1">&#39;134/235/167/165/166/168/129/172/34/31/141/ </span><span class="se">\</span>
-<span class="s1">                           139/170/183/236/39/40/41/42&#39;</span>
-                <span class="n">lwrt_sfc</span> <span class="o">=</span> <span class="n">wrf_sfc</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">for</span> <span class="n">par</span> <span class="ow">in</span> <span class="n">lwrt_sfc</span><span class="p">:</span>
-                    <span class="k">if</span> <span class="n">par</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__SL&#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__SL&#39;</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="o">+</span> <span class="n">par</span>
-
+            <span class="bp">self</span><span class="o">.</span><span class="n">_create_params</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">gauss</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">eta</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">omega</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">cwc</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">wrf</span><span class="p">)</span>
+
+        <span class="k">if</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">purefc</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">_create_field_types_fluxes</span><span class="p">()</span>
         <span class="k">else</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="bp">self</span><span class="o">.</span><span class="n">_create_field_types</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">c</span><span class="o">.</span><span class="n">step</span><span class="p">)</span>
+        <span class="k">return</span>
+
+    <span class="k">def</span> <span class="nf">_create_field_types</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ftype</span><span class="p">,</span> <span class="n">ftime</span><span class="p">,</span> <span class="n">fstep</span><span class="p">):</span>
+        <span class="sd">&#39;&#39;&#39;Create the combination of field type, time and forecast step.</span>
+
+<span class="sd">        Parameters:</span>
+<span class="sd">        -----------</span>
+<span class="sd">        ftype : list of str</span>
+<span class="sd">            List of field types.</span>
+
+<span class="sd">        ftime : list of str</span>
+<span class="sd">            The time in hours of the field.</span>
+
+<span class="sd">        fstep : str</span>
+<span class="sd">            Specifies the forecast time step from forecast base time.</span>
+<span class="sd">            Valid values are hours (HH) from forecast base time.</span>
+
+<span class="sd">        Return</span>
+<span class="sd">        ------</span>
+
+<span class="sd">        &#39;&#39;&#39;</span>
+        <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="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="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>
+
+            <span class="c1"># if ((ty.upper() == &#39;AN&#39; and (int(c.time[i]) % int(c.dtime)) == 0) or</span>
+                <span class="c1"># (ty.upper() != &#39;AN&#39; and (int(c.step[i]) % int(c.dtime)) == 0 and</span>
+                 <span class="c1"># (int(c.step[i]) % int(c.dtime) == 0)) ) and \</span>
+                 <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">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>
+                    <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">st</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="k">if</span> <span class="n">ty</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
+                        <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="o">=</span> <span class="p">{</span><span class="s1">&#39;times&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;steps&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">}</span>
+
+                    <span class="k">if</span> <span class="n">ti</span> <span class="ow">not</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="n">ty</span><span class="p">][</span><span class="s1">&#39;times&#39;</span><span class="p">]:</span>
+                        <span class="k">if</span> <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;times&#39;</span><span class="p">]:</span>
+                            <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;times&#39;</span><span class="p">]</span> <span class="o">+=</span> <span class="s1">&#39;/&#39;</span>
+                        <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;times&#39;</span><span class="p">]</span> <span class="o">+=</span> <span class="n">ti</span>
+
+                    <span class="k">if</span> <span class="n">st</span> <span class="ow">not</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="n">ty</span><span class="p">][</span><span class="s1">&#39;steps&#39;</span><span class="p">]:</span>
+                        <span class="k">if</span> <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="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="s1">&#39;/&#39;</span>
+                        <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>
+
+    <span class="k">def</span> <span class="nf">_create_field_types_fluxes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="sd">&#39;&#39;&#39;Create the combination of field type, time and forecast step</span>
+<span class="sd">        for the flux data.</span>
+
+<span class="sd">        Parameters:</span>
+<span class="sd">        -----------</span>
+
+<span class="sd">        Return</span>
+<span class="sd">        ------</span>
+
+<span class="sd">        &#39;&#39;&#39;</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="p">[</span><span class="nb">str</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="o">=</span> <span class="p">{</span><span class="s1">&#39;times&#39;</span><span class="p">:</span> <span class="nb">str</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="s1">&#39;steps&#39;</span><span class="p">:</span> <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">/to/</span><span class="si">{}</span><span class="s1">/by/</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="bp">self</span><span class="o">.</span><span class="n">dtime</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">dtime</span><span class="p">)}</span>
+        <span class="k">return</span>
+
+    <span class="k">def</span> <span class="nf">_create_params</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">gauss</span><span class="p">,</span> <span class="n">eta</span><span class="p">,</span> <span class="n">omega</span><span class="p">,</span> <span class="n">cwc</span><span class="p">,</span> <span class="n">wrf</span><span class="p">):</span>
+        <span class="sd">&#39;&#39;&#39;Define the specific parameter settings for retrievment.</span>
+
+<span class="sd">        The different parameters need specific grid types and level types</span>
+<span class="sd">        for retrievement. We might get following combination of types</span>
+<span class="sd">        (depending on selection and availability):</span>
+<span class="sd">        (These are short cuts for the grib file names (leading sequence)</span>
+<span class="sd">        SH__ML, OG__ML, GG__ML, SH__SL, OG__SL, GG__SL, OG_OROLSM_SL</span>
+<span class="sd">        where:</span>
+<span class="sd">            SH = Spherical Harmonics, GG = Gaussian Grid, OG = Output Grid,</span>
+<span class="sd">            ML = Model Level, SL = Surface Level</span>
+
+<span class="sd">        For each of this combination there is a list of parameter names,</span>
+<span class="sd">        the level type, the level list and the grid resolution.</span>
+
+<span class="sd">        There are different scenarios for data extraction from MARS:</span>
+<span class="sd">        1) Retrieval of etadot</span>
+<span class="sd">           eta=1, gauss=0, omega=0</span>
+<span class="sd">        2) Calculation of etadot from divergence</span>
+<span class="sd">           eta=0, gauss=1, omega=0</span>
+<span class="sd">        3) Calculation of etadot from omega (for makes sense for debugging)</span>
+<span class="sd">           eta=0, gauss=0, omega=1</span>
+<span class="sd">        4) Retrieval and Calculation of etadot (only for debugging)</span>
+<span class="sd">           eta=1, gauss=1, omega=0</span>
+<span class="sd">        5) Download also specific model and surface level data for FLEXPART-WRF</span>
+
+<span class="sd">        Parameters:</span>
+<span class="sd">        -----------</span>
+<span class="sd">        gauss : int</span>
+<span class="sd">            Gaussian grid is retrieved.</span>
+
+<span class="sd">        eta : int</span>
+<span class="sd">            Etadot parameter will be directly retrieved.</span>
+
+<span class="sd">        omega : int</span>
+<span class="sd">            The omega paramterwill be retrieved.</span>
+
+<span class="sd">        cwc : int</span>
+<span class="sd">            The cloud liquid and ice water content will be retrieved.</span>
+
+<span class="sd">        wrf : int</span>
+<span class="sd">            Additional model level and surface level data will be retrieved for</span>
+<span class="sd">            WRF/FLEXPART-WRF simulations.</span>
+
+<span class="sd">        Return</span>
+<span class="sd">        ------</span>
+
+<span class="sd">        &#39;&#39;&#39;</span>
+        <span class="c1"># SURFACE FIELDS</span>
+        <span class="c1">#-----------------------------------------------------------------------</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s1">&#39;SH__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;LNSP&#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;OFF&#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;OG__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;SD/MSL/TCC/10U/10V/2T/2D/Z/LSM&#39;</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">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">addpar</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__SL&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">addpar</span>
+
+        <span class="k">if</span> <span class="bp">self</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="ow">or</span> <span class="bp">self</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;EP&#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;OG_OROLSM__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;SDOR/CVL/CVH/FSR&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">else</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_OROLSM__SL&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;SDOR/CVL/CVH/SR&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="c1"># MODEL LEVEL FIELDS</span>
+        <span class="c1">#-----------------------------------------------------------------------</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="o">=</span> <span class="p">[</span><span class="s1">&#39;T/Q&#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">levelist</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">if</span> <span class="ow">not</span> <span class="n">gauss</span> <span class="ow">and</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/ETADOT&#39;</span>
+        <span class="k">elif</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;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;SH__ML&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;U/V/D&#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;OFF&#39;</span><span class="p">]</span>
+        <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="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="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="k">if</span> <span class="n">omega</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;/W&#39;</span>
+
+        <span class="k">if</span> <span class="n">cwc</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;/CLWC/CIWC&#39;</span>
+
+        <span class="c1"># ADDITIONAL FIELDS FOR FLEXPART-WRF MODEL (IF QUESTIONED)</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>
+            <span class="k">for</span> <span class="n">par</span> <span class="ow">in</span> <span class="n">wrf_sfc</span><span class="p">:</span>
+                <span class="k">if</span> <span class="n">par</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__SL&#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__SL&#39;</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="o">+</span> <span class="n">par</span>
+
+        <span class="k">return</span>
+
+
+    <span class="k">def</span> <span class="nf">_create_params_fluxes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="sd">&#39;&#39;&#39;Define the parameter setting for flux data.</span>
+
+<span class="sd">        Flux data are accumulated fields in time and are stored on the</span>
+<span class="sd">        surface level. The leading short cut name for the grib files is:</span>
+<span class="sd">        &quot;OG_acc_SL&quot; with OG for Regular Output Grid, SL for Surface Level, and</span>
+<span class="sd">        acc for Accumulated Grid.</span>
+<span class="sd">        The params dictionary stores a list of parameter names, the level type,</span>
+<span class="sd">        the level list and the grid resolution.</span>
+
+<span class="sd">        The flux data are: LSP/CP/SSHF/EWSS/NSSS/SSR</span>
+
+<span class="sd">        Parameters:</span>
+<span class="sd">        -----------</span>
+
+<span class="sd">        Return</span>
+<span class="sd">        ------</span>
+
+<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="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>
 
@@ -459,17 +613,17 @@
 <span class="sd">        Parameters</span>
 <span class="sd">        ----------</span>
-<span class="sd">        ftype : :obj:`string`</span>
+<span class="sd">        ftype : str</span>
 <span class="sd">            Shortcut name of the type of the field. E.g. AN, FC, PF, ...</span>
 
-<span class="sd">        param : :obj:`string`</span>
+<span class="sd">        param : str</span>
 <span class="sd">            Shortcut of the grid type. E.g. SH__ML, SH__SL, GG__ML,</span>
 <span class="sd">            GG__SL, OG__ML, OG__SL, OG_OROLSM_SL, OG_acc_SL</span>
 
-<span class="sd">        date : :obj:`string`</span>
+<span class="sd">        date : str</span>
 <span class="sd">            The date period of the grib data to be stored in this file.</span>
 
 <span class="sd">        Return</span>
 <span class="sd">        ------</span>
-<span class="sd">        targetname : :obj:`string`</span>
+<span class="sd">        targetname : str</span>
 <span class="sd">            The target filename for the grib data.</span>
 <span class="sd">        &#39;&#39;&#39;</span>
@@ -486,5 +640,5 @@
 <span class="sd">        Parameters</span>
 <span class="sd">        ----------</span>
-<span class="sd">        request : :obj:`integer`</span>
+<span class="sd">        request : int</span>
 <span class="sd">            Selects the mode of retrieval.</span>
 <span class="sd">            0: Retrieves the data from ECMWF.</span>
@@ -492,5 +646,5 @@
 <span class="sd">            2: Retrieves the data and prints the mars request.</span>
 
-<span class="sd">        par_dict : :obj:`dictionary`</span>
+<span class="sd">        par_dict : dictionary</span>
 <span class="sd">            Contains all parameter which have to be set for creating the</span>
 <span class="sd">            Mars Retrievals. The parameter are:</span>
@@ -548,17 +702,17 @@
 <span class="sd">        Parameters</span>
 <span class="sd">        ----------</span>
-<span class="sd">        keys : :obj:`dictionary`</span>
+<span class="sd">        keys : dictionary</span>
 <span class="sd">            List of parameter names which serves as index.</span>
 
-<span class="sd">        inputfiles : :obj:`UioFiles`</span>
+<span class="sd">        inputfiles : UioFiles</span>
 <span class="sd">            Contains a list of files.</span>
 
 <span class="sd">        Return</span>
 <span class="sd">        ------</span>
-<span class="sd">        iid : :obj:`grib_index`</span>
+<span class="sd">        iid : codes_index</span>
 <span class="sd">            This is a grib specific index structure to access</span>
 <span class="sd">            messages in a file.</span>
 
-<span class="sd">        index_vals : :obj:`list`</span>
+<span class="sd">        index_vals : list of list  of str</span>
 <span class="sd">            Contains the values from the keys used for a distinct selection</span>
 <span class="sd">            of grib messages in processing  the grib files.</span>
@@ -573,5 +727,5 @@
         <span class="n">indexfile</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">inputdir</span><span class="p">,</span> <span class="n">_config</span><span class="o">.</span><span class="n">FILE_GRIB_INDEX</span><span class="p">)</span>
         <span class="n">silent_remove</span><span class="p">(</span><span class="n">indexfile</span><span class="p">)</span>
-        <span class="n">grib</span> <span class="o">=</span> <span class="n">GribTools</span><span class="p">(</span><span class="n">inputfiles</span><span class="o">.</span><span class="n">files</span><span class="p">)</span>
+        <span class="n">grib</span> <span class="o">=</span> <span class="n">GribUtil</span><span class="p">(</span><span class="n">inputfiles</span><span class="o">.</span><span class="n">files</span><span class="p">)</span>
         <span class="c1"># creates new index file</span>
         <span class="n">iid</span> <span class="o">=</span> <span class="n">grib</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">index_keys</span><span class="o">=</span><span class="n">index_keys</span><span class="p">,</span> <span class="n">index_file</span><span class="o">=</span><span class="n">indexfile</span><span class="p">)</span>
@@ -580,14 +734,10 @@
         <span class="n">index_vals</span> <span class="o">=</span> <span class="p">[]</span>
         <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">index_keys</span><span class="p">:</span>
-            <span class="c1">#index_vals.append(grib_index_get(iid, key))</span>
-            <span class="c1">#print(index_vals[-1])</span>
-            <span class="n">key_vals</span> <span class="o">=</span> <span class="n">grib_index_get</span><span class="p">(</span><span class="n">iid</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span>
-            <span class="nb">print</span><span class="p">(</span><span class="n">key_vals</span><span class="p">)</span>
-            <span class="c1"># have to sort the steps for disaggregation,</span>
+            <span class="n">key_vals</span> <span class="o">=</span> <span class="n">codes_index_get</span><span class="p">(</span><span class="n">iid</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span>
+            <span class="c1"># have to sort the key values for correct disaggregation,</span>
             <span class="c1"># therefore convert to int first</span>
-            <span class="k">if</span> <span class="n">key</span> <span class="o">==</span> <span class="s1">&#39;step&#39;</span><span class="p">:</span>
-                <span class="n">key_vals</span> <span class="o">=</span> <span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">key_vals</span><span class="p">]</span>
-                <span class="n">key_vals</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
-                <span class="n">key_vals</span> <span class="o">=</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">key_vals</span><span class="p">]</span>
+            <span class="n">key_vals</span> <span class="o">=</span> <span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">key_vals</span><span class="p">]</span>
+            <span class="n">key_vals</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
+            <span class="n">key_vals</span> <span class="o">=</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">key_vals</span><span class="p">]</span>
             <span class="n">index_vals</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">key_vals</span><span class="p">)</span>
             <span class="c1"># index_vals looks for example like:</span>
@@ -606,5 +756,5 @@
 <span class="sd">        Parameters</span>
 <span class="sd">        ----------</span>
-<span class="sd">        server : :obj:`ECMWFService` or :obj:`ECMWFDataServer`</span>
+<span class="sd">        server : ECMWFService or ECMWFDataServer</span>
 <span class="sd">            The connection to the ECMWF server. This is different</span>
 <span class="sd">            for member state users which have full access and non</span>
@@ -614,9 +764,9 @@
 <span class="sd">            for member state users its False (ECMWFService)</span>
 
-<span class="sd">        dates : :obj:`string`</span>
+<span class="sd">        dates : str</span>
 <span class="sd">            Contains start and end date of the retrieval in the format</span>
 <span class="sd">            &quot;YYYYMMDD/to/YYYYMMDD&quot;</span>
 
-<span class="sd">        request : :obj:`integer`</span>
+<span class="sd">        request : int</span>
 <span class="sd">            Selects the mode of retrieval.</span>
 <span class="sd">            0: Retrieves the data from ECMWF.</span>
@@ -624,5 +774,5 @@
 <span class="sd">            2: Retrieves the data and prints the mars request.</span>
 
-<span class="sd">        inputdir : :obj:`string`, optional</span>
+<span class="sd">        inputdir : str, optional</span>
 <span class="sd">            Path to the directory where the retrieved data is about</span>
 <span class="sd">            to be stored. The default is the current directory (&#39;.&#39;).</span>
@@ -693,6 +843,4 @@
                 <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="bp">self</span><span class="o">.</span><span class="n">gaussian</span>
 
-                <span class="k">if</span> <span class="n">pk</span> <span class="o">==</span> <span class="s1">&#39;OG__SL&#39;</span><span class="p">:</span>
-                    <span class="k">pass</span>
                 <span class="k">if</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="ow">not</span> <span class="n">oro</span><span class="p">:</span>
                     <span class="n">oro</span> <span class="o">=</span> <span class="kc">True</span>
@@ -814,9 +962,9 @@
 <span class="sd">        Parameters</span>
 <span class="sd">        ----------</span>
-<span class="sd">        c : :obj:`ControlFile`</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">        filename : :obj:`string`</span>
+<span class="sd">        filename : str</span>
 <span class="sd">                Name of the namelist file.</span>
 
@@ -828,42 +976,62 @@
         <span class="kn">from</span> <span class="nn">genshi.template.text</span> <span class="k">import</span> <span class="n">NewTextTemplate</span>
         <span class="kn">from</span> <span class="nn">genshi.template</span> <span class="k">import</span>  <span class="n">TemplateLoader</span>
-
-        <span class="n">loader</span> <span class="o">=</span> <span class="n">TemplateLoader</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">PATH_TEMPLATES</span><span class="p">,</span> <span class="n">auto_reload</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
-        <span class="n">namelist_template</span> <span class="o">=</span> <span class="n">loader</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">TEMPFILE_NAMELIST</span><span class="p">,</span>
-                                       <span class="bp">cls</span><span class="o">=</span><span class="n">NewTextTemplate</span><span class="p">)</span>
-
-        <span class="bp">self</span><span class="o">.</span><span class="n">inputdir</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">inputdir</span>
-        <span class="n">area</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">area</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="n">astype</span><span class="p">(</span><span class="nb">float</span><span class="p">)</span>
-        <span class="n">grid</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid</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="n">astype</span><span class="p">(</span><span class="nb">float</span><span class="p">)</span>
-
-        <span class="k">if</span> <span class="n">area</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">&gt;</span> <span class="n">area</span><span class="p">[</span><span class="mi">3</span><span class="p">]:</span>
-            <span class="n">area</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-=</span> <span class="mi">360</span>
-        <span class="n">maxl</span> <span class="o">=</span> <span class="nb">int</span><span class="p">((</span><span class="n">area</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">-</span> <span class="n">area</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="o">/</span> <span class="n">grid</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="o">+</span> <span class="mi">1</span>
-        <span class="n">maxb</span> <span class="o">=</span> <span class="nb">int</span><span class="p">((</span><span class="n">area</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="n">area</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span> <span class="o">/</span> <span class="n">grid</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="mi">1</span>
-
-        <span class="n">stream</span> <span class="o">=</span> <span class="n">namelist_template</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span>
-            <span class="n">maxl</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">maxl</span><span class="p">),</span>
-            <span class="n">maxb</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">maxb</span><span class="p">),</span>
-            <span class="n">mlevel</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">level</span><span class="p">),</span>
-            <span class="n">mlevelist</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">levelist</span><span class="p">),</span>
-            <span class="n">mnauf</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">resol</span><span class="p">),</span>
-            <span class="n">metapar</span> <span class="o">=</span> <span class="s1">&#39;77&#39;</span><span class="p">,</span>
-            <span class="n">rlo0</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">area</span><span class="p">[</span><span class="mi">1</span><span class="p">]),</span>
-            <span class="n">rlo1</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">area</span><span class="p">[</span><span class="mi">3</span><span class="p">]),</span>
-            <span class="n">rla0</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">area</span><span class="p">[</span><span class="mi">2</span><span class="p">]),</span>
-            <span class="n">rla1</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">area</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span>
-            <span class="n">momega</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">omega</span><span class="p">),</span>
-            <span class="n">momegadiff</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">omegadiff</span><span class="p">),</span>
-            <span class="n">mgauss</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">gauss</span><span class="p">),</span>
-            <span class="n">msmooth</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">smooth</span><span class="p">),</span>
-            <span class="n">meta</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">eta</span><span class="p">),</span>
-            <span class="n">metadiff</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">etadiff</span><span class="p">),</span>
-            <span class="n">mdpdeta</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">dpdeta</span><span class="p">)</span>
-        <span class="p">)</span>
-
-        <span class="n">namelistfile</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="bp">self</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="n">_config</span><span class="o">.</span><span class="n">FILE_NAMELIST</span><span class="p">)</span>
-
-        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">namelistfile</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
-            <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">stream</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="s1">&#39;text&#39;</span><span class="p">))</span>
+        <span class="kn">from</span> <span class="nn">genshi.template.eval</span> <span class="k">import</span>  <span class="n">UndefinedError</span>
+
+        <span class="k">try</span><span class="p">:</span>
+            <span class="n">loader</span> <span class="o">=</span> <span class="n">TemplateLoader</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">PATH_TEMPLATES</span><span class="p">,</span> <span class="n">auto_reload</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
+            <span class="n">namelist_template</span> <span class="o">=</span> <span class="n">loader</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">TEMPFILE_NAMELIST</span><span class="p">,</span>
+                                            <span class="bp">cls</span><span class="o">=</span><span class="n">NewTextTemplate</span><span class="p">)</span>
+
+            <span class="bp">self</span><span class="o">.</span><span class="n">inputdir</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">inputdir</span>
+            <span class="n">area</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">area</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="n">astype</span><span class="p">(</span><span class="nb">float</span><span class="p">)</span>
+            <span class="n">grid</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">grid</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="n">astype</span><span class="p">(</span><span class="nb">float</span><span class="p">)</span>
+
+            <span class="k">if</span> <span class="n">area</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">&gt;</span> <span class="n">area</span><span class="p">[</span><span class="mi">3</span><span class="p">]:</span>
+                <span class="n">area</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-=</span> <span class="mi">360</span>
+            <span class="n">maxl</span> <span class="o">=</span> <span class="nb">int</span><span class="p">((</span><span class="n">area</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">-</span> <span class="n">area</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="o">/</span> <span class="n">grid</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="o">+</span> <span class="mi">1</span>
+            <span class="n">maxb</span> <span class="o">=</span> <span class="nb">int</span><span class="p">((</span><span class="n">area</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="n">area</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span> <span class="o">/</span> <span class="n">grid</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="mi">1</span>
+
+            <span class="n">stream</span> <span class="o">=</span> <span class="n">namelist_template</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span>
+                <span class="n">maxl</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">maxl</span><span class="p">),</span>
+                <span class="n">maxb</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">maxb</span><span class="p">),</span>
+                <span class="n">mlevel</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">level</span><span class="p">),</span>
+                <span class="n">mlevelist</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">levelist</span><span class="p">),</span>
+                <span class="n">mnauf</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">resol</span><span class="p">),</span>
+                <span class="n">metapar</span> <span class="o">=</span> <span class="s1">&#39;77&#39;</span><span class="p">,</span>
+                <span class="n">rlo0</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">area</span><span class="p">[</span><span class="mi">1</span><span class="p">]),</span>
+                <span class="n">rlo1</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">area</span><span class="p">[</span><span class="mi">3</span><span class="p">]),</span>
+                <span class="n">rla0</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">area</span><span class="p">[</span><span class="mi">2</span><span class="p">]),</span>
+                <span class="n">rla1</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">area</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span>
+                <span class="n">momega</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">omega</span><span class="p">),</span>
+                <span class="n">momegadiff</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">omegadiff</span><span class="p">),</span>
+                <span class="n">mgauss</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">gauss</span><span class="p">),</span>
+                <span class="n">msmooth</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">smooth</span><span class="p">),</span>
+                <span class="n">meta</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">eta</span><span class="p">),</span>
+                <span class="n">metadiff</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">etadiff</span><span class="p">),</span>
+                <span class="n">mdpdeta</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">dpdeta</span><span class="p">)</span>
+            <span class="p">)</span>
+        <span class="k">except</span> <span class="n">UndefinedError</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;... ERROR &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</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="s1">&#39;</span><span class="se">\n</span><span class="s1">... error occured while trying to generate namelist &#39;</span> <span class="o">+</span>
+                     <span class="n">_config</span><span class="o">.</span><span class="n">TEMPFILE_NAMELIST</span><span class="p">)</span>
+        <span class="k">except</span> <span class="ne">OSError</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;... ERROR CODE: &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">errno</span><span class="p">))</span>
+            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;... ERROR MESSAGE:</span><span class="se">\n</span><span class="s1"> </span><span class="se">\t</span><span class="s1"> &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">strerror</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="s1">&#39;</span><span class="se">\n</span><span class="s1">... error occured while trying to generate template &#39;</span> <span class="o">+</span>
+                     <span class="n">_config</span><span class="o">.</span><span class="n">TEMPFILE_NAMELIST</span><span class="p">)</span>
+
+        <span class="k">try</span><span class="p">:</span>
+            <span class="n">namelistfile</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="bp">self</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="n">_config</span><span class="o">.</span><span class="n">FILE_NAMELIST</span><span class="p">)</span>
+
+            <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">namelistfile</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
+                <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">stream</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="s1">&#39;text&#39;</span><span class="p">))</span>
+        <span class="k">except</span> <span class="ne">OSError</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;... ERROR CODE: &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">errno</span><span class="p">))</span>
+            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;... ERROR MESSAGE:</span><span class="se">\n</span><span class="s1"> </span><span class="se">\t</span><span class="s1"> &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">strerror</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="s1">&#39;</span><span class="se">\n</span><span class="s1">... error occured while trying to write &#39;</span> <span class="o">+</span>
+                     <span class="n">namelistfile</span><span class="p">)</span>
 
         <span class="k">return</span></div>
@@ -871,5 +1039,7 @@
 
 <div class="viewcode-block" id="EcFlexpart.deacc_fluxes"><a class="viewcode-back" href="../api.html#EcFlexpart.EcFlexpart.deacc_fluxes">[docs]</a>    <span class="k">def</span> <span class="nf">deacc_fluxes</span><span class="p">(</span><span class="bp">self</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="sd">&#39;&#39;&#39;Goes through all flux fields in ordered time and de-accumulate</span>
+        <span class="sd">&#39;&#39;&#39;De-accumulate and disaggregate flux data.</span>
+
+<span class="sd">        Goes through all flux fields in ordered time and de-accumulate</span>
 <span class="sd">        the fields. Afterwards the fields are disaggregated in time.</span>
 <span class="sd">        Different versions of disaggregation is provided for rainfall</span>
@@ -879,8 +1049,8 @@
 <span class="sd">        Parameters</span>
 <span class="sd">        ----------</span>
-<span class="sd">        inputfiles : :obj:`UioFiles`</span>
-<span class="sd">            Contains a list of files.</span>
-
-<span class="sd">        c : :obj:`ControlFile`</span>
+<span class="sd">        inputfiles : UioFiles</span>
+<span class="sd">            Contains the list of files that contain flux data.</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>
@@ -905,16 +1075,36 @@
         <span class="c1"># index_vals looks like e.g.:</span>
         <span class="c1"># index_vals[0]: (&#39;20171106&#39;, &#39;20171107&#39;, &#39;20171108&#39;) ; date</span>
-        <span class="c1"># index_vals[1]: (&#39;0&#39;, &#39;1200&#39;, &#39;1800&#39;, &#39;600&#39;) ; time</span>
-        <span class="c1"># index_vals[2]: (&#39;0&#39;, &#39;12&#39;, &#39;3&#39;, &#39;6&#39;, &#39;9&#39;) ; stepRange</span>
-
-        <span class="n">valsdict</span> <span class="o">=</span> <span class="p">{}</span>
-        <span class="n">svalsdict</span> <span class="o">=</span> <span class="p">{}</span>
-<span class="c1">#        stepsdict = {}</span>
+        <span class="c1"># index_vals[1]: (&#39;0&#39;, &#39;600&#39;, &#39;1200&#39;, &#39;1800&#39;) ; time</span>
+        <span class="c1"># index_vals[2]: (&#39;0&#39;, &#39;3&#39;, &#39;6&#39;, &#39;9&#39;, &#39;12&#39;) ; stepRange</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="k">if</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</span><span class="p">:</span>
+                <span class="n">start_date</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="s1">&#39;00&#39;</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_date</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="s1">&#39;23&#39;</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">sdate_str</span> <span class="o">=</span> <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">{:0&gt;2}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">index_vals</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
+                <span class="n">start_date</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">sdate_str</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">edate_str</span> <span class="o">=</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">{:0&gt;2}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">index_vals</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
+                <span class="n">end_date</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">edate_str</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_date</span> <span class="o">=</span> <span class="n">end_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">c</span><span class="o">.</span><span class="n">maxstep</span><span class="p">)</span>
+
+            <span class="n">info</span> <span class="o">=</span> <span class="n">get_informations</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="n">inputfiles</span><span class="o">.</span><span class="n">files</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span>
+            <span class="n">dims</span> <span class="o">=</span> <span class="n">get_dimensions</span><span class="p">(</span><span class="n">info</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">purefc</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">index_vals</span><span class="p">,</span>
+                                  <span class="n">start_date</span><span class="p">,</span> <span class="n">end_date</span><span class="p">)</span>
+            <span class="c1"># create numpy array</span>
+            <span class="n">lsp_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">dims</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="n">dims</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">dims</span><span class="p">[</span><span class="mi">2</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_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">dims</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="n">dims</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">dims</span><span class="p">[</span><span class="mi">2</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">it_lsp</span> <span class="o">=</span> <span class="mi">0</span>
+            <span class="n">it_cp</span> <span class="o">=</span> <span class="mi">0</span>
+            <span class="n">date_list</span> <span class="o">=</span> <span class="p">[]</span>
+            <span class="n">step_list</span> <span class="o">=</span> <span class="p">[]</span>
+
+        <span class="c1"># initialize dictionaries to store values</span>
+        <span class="n">orig_vals</span> <span class="o">=</span> <span class="p">{}</span>
+        <span class="n">deac_vals</span> <span class="o">=</span> <span class="p">{}</span>
         <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">pars</span><span class="p">:</span>
-            <span class="n">valsdict</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">p</span><span class="p">)]</span> <span class="o">=</span> <span class="p">[]</span>
-            <span class="n">svalsdict</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">p</span><span class="p">)]</span> <span class="o">=</span> <span class="p">[]</span>
-<span class="c1">#            stepsdict[str(p)] = []</span>
-
-        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;maxstep: &#39;</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">maxstep</span><span class="p">)</span>
+            <span class="n">orig_vals</span><span class="p">[</span><span class="n">p</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
+            <span class="n">deac_vals</span><span class="p">[</span><span class="n">p</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
 
         <span class="c1"># &quot;product&quot; genereates each possible combination between the</span>
@@ -924,11 +1114,11 @@
             <span class="c1">#             (  date    ,time, step)</span>
 
-            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;current product: &#39;</span><span class="p">,</span> <span class="n">prod</span><span class="p">)</span>
+            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;CURRENT PRODUCT: &#39;</span><span class="p">,</span> <span class="n">prod</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="nb">len</span><span class="p">(</span><span class="n">index_keys</span><span class="p">)):</span>
-                <span class="n">grib_index_select</span><span class="p">(</span><span class="n">iid</span><span class="p">,</span> <span class="n">index_keys</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">prod</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
+                <span class="n">codes_index_select</span><span class="p">(</span><span class="n">iid</span><span class="p">,</span> <span class="n">index_keys</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">prod</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
 
             <span class="c1"># get first id from current product</span>
-            <span class="n">gid</span> <span class="o">=</span> <span class="n">grib_new_from_index</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
+            <span class="n">gid</span> <span class="o">=</span> <span class="n">codes_new_from_index</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
 
             <span class="c1"># if there is no data for this specific time combination / product</span>
@@ -938,14 +1128,17 @@
 
             <span class="c1"># create correct timestamp from the three time informations</span>
-            <span class="n">cdate</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">grib_get</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="n">ctime</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{:0&gt;2}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grib_get</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="o">/</span><span class="mi">100</span><span class="p">)</span>
-            <span class="n">cstep</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">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;step&#39;</span><span class="p">))</span>
+            <span class="n">cdate</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">codes_get</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="n">time</span> <span class="o">=</span> <span class="n">codes_get</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="o">/</span><span class="mi">100</span> <span class="c1"># integer</span>
+            <span class="n">step</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;step&#39;</span><span class="p">)</span> <span class="c1"># integer</span>
+            <span class="n">ctime</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{:0&gt;2}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">time</span><span class="p">)</span>
+            <span class="n">cstep</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="n">t_date</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">cdate</span> <span class="o">+</span> <span class="n">ctime</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">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="nb">int</span><span class="p">(</span><span class="n">cstep</span><span class="p">))</span>
-            <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="nb">int</span><span class="p">(</span><span class="n">cstep</span><span class="p">)</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="nb">int</span><span class="p">(</span><span class="n">cstep</span><span class="p">)</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_dt</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="p">)</span>
+            <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">maxstep</span> <span class="o">&gt;</span> <span class="mi">12</span><span class="p">:</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>
@@ -966,120 +1159,321 @@
 
             <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"># read message for message and store relevant data fields</span>
+            <span class="n">f_handle</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">fnout</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span>
+            <span class="n">h_handle</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">hnout</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span>
+            <span class="n">g_handle</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">gnout</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span>
+
+            <span class="c1"># read message for message and store relevant data fields, where</span>
             <span class="c1"># data keywords are stored in pars</span>
-            <span class="k">while</span> <span class="mi">1</span><span class="p">:</span>
+            <span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
                 <span class="k">if</span> <span class="ow">not</span> <span class="n">gid</span><span class="p">:</span>
                     <span class="k">break</span>
-                <span class="n">cparamId</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;paramId&#39;</span><span class="p">))</span>
-                <span class="n">step</span> <span class="o">=</span> <span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;step&#39;</span><span class="p">)</span>
-                <span class="n">time</span> <span class="o">=</span> <span class="n">grib_get</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">ni</span> <span class="o">=</span> <span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;Ni&#39;</span><span class="p">)</span>
-                <span class="n">nj</span> <span class="o">=</span> <span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;Nj&#39;</span><span class="p">)</span>
-                <span class="k">if</span> <span class="n">cparamId</span> <span class="ow">in</span> <span class="n">valsdict</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
-                    <span class="n">values</span> <span class="o">=</span> <span class="n">grib_get_values</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
-                    <span class="n">vdp</span> <span class="o">=</span> <span class="n">valsdict</span><span class="p">[</span><span class="n">cparamId</span><span class="p">]</span>
-                    <span class="n">svdp</span> <span class="o">=</span> <span class="n">svalsdict</span><span class="p">[</span><span class="n">cparamId</span><span class="p">]</span>
- <span class="c1">#                   sd = stepsdict[cparamId]</span>
-
-                    <span class="k">if</span> <span class="n">cparamId</span> <span class="o">==</span> <span class="s1">&#39;142&#39;</span> <span class="ow">or</span> <span class="n">cparamId</span> <span class="o">==</span> <span class="s1">&#39;143&#39;</span><span class="p">:</span>
-                        <span class="n">fak</span> <span class="o">=</span> <span class="mf">1.</span> <span class="o">/</span> <span class="mf">1000.</span>
+                <span class="n">parId</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;paramId&#39;</span><span class="p">)</span> <span class="c1"># integer</span>
+                <span class="n">step</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;step&#39;</span><span class="p">)</span> <span class="c1"># integer</span>
+                <span class="n">time</span> <span class="o">=</span> <span class="n">codes_get</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="c1"># integer</span>
+                <span class="n">ni</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;Ni&#39;</span><span class="p">)</span> <span class="c1"># integer</span>
+                <span class="n">nj</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;Nj&#39;</span><span class="p">)</span> <span class="c1"># integer</span>
+                <span class="k">if</span> <span class="n">parId</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">orig_vals</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
+                    <span class="c1"># parameter is not a flux, find next one</span>
+                    <span class="k">continue</span>
+
+                <span class="c1"># define conversion factor</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">fak</span> <span class="o">=</span> <span class="mf">1.</span> <span class="o">/</span> <span class="mf">1000.</span>
+                <span class="k">else</span><span class="p">:</span>
+                    <span class="n">fak</span> <span class="o">=</span> <span class="mf">3600.</span>
+
+                <span class="c1"># get parameter values and reshape</span>
+                <span class="n">values</span> <span class="o">=</span> <span class="n">codes_get_values</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
+                <span class="n">values</span> <span class="o">=</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">values</span><span class="p">,</span> <span class="p">(</span><span class="n">nj</span><span class="p">,</span> <span class="n">ni</span><span class="p">)))</span><span class="o">.</span><span class="n">flatten</span><span class="p">()</span> <span class="o">/</span> <span class="n">fak</span>
+
+                <span class="c1"># save the original and accumulated values</span>
+                <span class="n">orig_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">values</span><span class="p">[:])</span>
+
+                <span class="k">if</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="ow">or</span> <span class="n">step</span> <span class="o">&lt;=</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"># no de-accumulation needed</span>
+                    <span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">values</span><span class="p">[:]</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="k">else</span><span class="p">:</span>
+                    <span class="c1"># do de-accumulation</span>
+                    <span class="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
+                        <span class="p">(</span><span class="n">orig_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">orig_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">][</span><span class="o">-</span><span class="mi">2</span><span class="p">])</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"># store precipitation if new disaggregation method is selected</span>
+                <span class="c1"># only the exact days are needed</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="k">if</span> <span class="n">start_date</span> <span class="o">&lt;=</span> <span class="n">t_dt</span> <span class="o">&lt;=</span> <span class="n">end_date</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="p">:</span>
+                            <span class="k">if</span> <span class="n">t_dt</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">date_list</span><span class="p">:</span>
+                                <span class="n">date_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">t_dt</span><span class="p">)</span>
+                                <span class="n">step_list</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">]</span>
+                        <span class="k">else</span><span class="p">:</span>
+                            <span class="k">if</span> <span class="n">t_date</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">date_list</span><span class="p">:</span>
+                                <span class="n">date_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">t_date</span><span class="p">)</span>
+                            <span class="k">if</span> <span class="n">step</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">step_list</span><span class="p">:</span>
+                                <span class="n">step_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">step</span><span class="p">)</span>
+                        <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">rrint</span> <span class="ow">and</span> <span class="n">parId</span> <span class="o">==</span> <span class="mi">142</span><span class="p">:</span>
+                            <span class="n">lsp_np</span><span class="p">[:,</span><span class="n">it_lsp</span><span class="p">]</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="o">-</span><span class="mi">1</span><span class="p">][:]</span>
+                            <span class="n">it_lsp</span> <span class="o">+=</span> <span class="mi">1</span>
+                        <span class="k">elif</span> <span class="n">c</span><span class="o">.</span><span class="n">rrint</span> <span class="ow">and</span> <span class="n">parId</span> <span class="o">==</span> <span class="mi">143</span><span class="p">:</span>
+                            <span class="n">cp_np</span><span class="p">[:,</span><span class="n">it_cp</span><span class="p">]</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="o">-</span><span class="mi">1</span><span class="p">][:]</span>
+                            <span class="n">it_cp</span> <span class="o">+=</span> <span class="mi">1</span>
+
+                <span class="c1"># information printout</span>
+                <span class="nb">print</span><span class="p">(</span><span class="n">parId</span><span class="p">,</span> <span class="n">time</span><span class="p">,</span> <span class="n">step</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">values</span><span class="p">),</span> <span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">np</span><span class="o">.</span><span class="n">std</span><span class="p">(</span><span class="n">values</span><span class="p">))</span>
+
+                <span class="c1"># length of deac_vals[parId] corresponds to the</span>
+                <span class="c1"># number of time steps, max. 4 are needed for disaggegration</span>
+                <span class="c1"># with the old and original method</span>
+                <span class="c1"># run over all grib messages and perform</span>
+                <span class="c1"># shifting in time</span>
+                <span class="k">if</span> <span class="nb">len</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="o">&gt;=</span> <span class="mi">3</span><span class="p">:</span>
+                    <span class="k">if</span> <span class="nb">len</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="o">&gt;</span> <span class="mi">3</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">rrint</span> <span class="ow">and</span> <span class="p">(</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="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="n">deac_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">])</span>
+
+                        <span class="k">if</span> <span class="ow">not</span> <span class="p">(</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"># remove first time step in list to shift</span>
+                            <span class="c1"># time line</span>
+                            <span class="n">orig_vals</span><span class="p">[</span><span class="n">parId</span><span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</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="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
                     <span class="k">else</span><span class="p">:</span>
-                        <span class="n">fak</span> <span class="o">=</span> <span class="mf">3600.</span>
-
-                    <span class="n">values</span> <span class="o">=</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">values</span><span class="p">,</span> <span class="p">(</span><span class="n">nj</span><span class="p">,</span> <span class="n">ni</span><span class="p">)))</span><span class="o">.</span><span class="n">flatten</span><span class="p">()</span> <span class="o">/</span> <span class="n">fak</span>
-                    <span class="n">vdp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">values</span><span class="p">[:])</span>  <span class="c1"># save the accumulated values</span>
-                    <span class="k">if</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="ow">or</span> \
-                       <span class="n">step</span> <span class="o">&lt;=</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">svdp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">values</span><span class="p">[:]</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="k">else</span><span class="p">:</span>  <span class="c1"># deaccumulate values</span>
-                        <span class="n">svdp</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">vdp</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">vdp</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">])</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="nb">print</span><span class="p">(</span><span class="n">cparamId</span><span class="p">,</span> <span class="n">time</span><span class="p">,</span> <span class="n">step</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">values</span><span class="p">),</span>
-                          <span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">np</span><span class="o">.</span><span class="n">std</span><span class="p">(</span><span class="n">values</span><span class="p">))</span>
-
-                    <span class="c1"># len(svdp) correspond to the time</span>
-                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">svdp</span><span class="p">)</span> <span class="o">&gt;=</span> <span class="mi">3</span><span class="p">:</span>
-                        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">svdp</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">3</span><span class="p">:</span>
-                            <span class="k">if</span> <span class="n">cparamId</span> <span class="o">==</span> <span class="s1">&#39;142&#39;</span> <span class="ow">or</span> <span class="n">cparamId</span> <span class="o">==</span> <span class="s1">&#39;143&#39;</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="n">svdp</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="n">svdp</span><span class="p">)</span>
-
-                            <span class="k">if</span> <span class="ow">not</span> <span class="p">(</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">maxstep</span> <span class="o">&gt;</span> <span class="mi">12</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="n">vdp</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
-                                <span class="n">svdp</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
+                        <span class="c1"># if the third time step is read (per parId),</span>
+                        <span class="c1"># write out the first one as a boundary value</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">1</span><span class="p">]</span>
                         <span class="k">else</span><span class="p">:</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">12</span><span class="p">:</span>
-                                <span class="n">values</span> <span class="o">=</span> <span class="n">svdp</span><span class="p">[</span><span class="mi">1</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">svdp</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
-
-                        <span class="n">grib_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="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">12</span><span class="p">:</span>
-                            <span class="n">grib_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;step&#39;</span><span class="p">,</span> <span class="nb">max</span><span class="p">(</span><span class="mi">0</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="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">0</span><span class="p">]</span>
+
+                    <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">rrint</span> <span class="ow">and</span> <span class="p">(</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">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="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="nb">max</span><span class="p">(</span><span class="mi">0</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="k">else</span><span class="p">:</span>
-                            <span class="n">grib_set</span><span class="p">(</span><span class="n">gid</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="n">grib_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">t_m2dt</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">grib_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">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">&#39;</span><span class="p">)))</span>
-
-                        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">fnout</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f_handle</span><span class="p">:</span>
-                            <span class="n">grib_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="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">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">t_m2dt</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">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">&#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">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="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 contained</span>
-                        <span class="c1"># in svdp</span>
-                        <span class="c1"># if step+int(c.dtime) == c.maxstep and c.maxstep&gt;12</span>
-                        <span class="c1"># or t_dt+timedelta(hours = int(c.dtime))</span>
-                        <span class="c1"># &gt;= t_enddate:</span>
-                        <span class="c1"># Note that svdp[0] has not been popped 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">maxstep</span> <span class="o">&gt;</span> <span class="mi">12</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="n">values</span> <span class="o">=</span> <span class="n">svdp</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span>
-                            <span class="n">grib_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">grib_set</span><span class="p">(</span><span class="n">gid</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="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">grib_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">grib_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="n">truedatetime</span><span class="o">.</span><span class="n">year</span> <span class="o">*</span> <span class="mi">10000</span> <span class="o">+</span>
-                                      <span class="n">truedatetime</span><span class="o">.</span><span class="n">month</span> <span class="o">*</span> <span class="mi">100</span> <span class="o">+</span>
-                                      <span class="n">truedatetime</span><span class="o">.</span><span class="n">day</span><span class="p">)</span>
-                            <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">hnout</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">h_handle</span><span class="p">:</span>
-                                <span class="n">grib_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="c1">#values = (svdp[1]+svdp[2])/2.</span>
-                            <span class="k">if</span> <span class="n">cparamId</span> <span class="o">==</span> <span class="s1">&#39;142&#39;</span> <span class="ow">or</span> <span class="n">cparamId</span> <span class="o">==</span> <span class="s1">&#39;143&#39;</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">svdp</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">svdp</span><span class="p">)))</span>
-
-                            <span class="n">grib_set</span><span class="p">(</span><span class="n">gid</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="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">grib_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">grib_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="n">truedatetime</span><span class="o">.</span><span class="n">year</span> <span class="o">*</span> <span class="mi">10000</span> <span class="o">+</span>
-                                     <span class="n">truedatetime</span><span class="o">.</span><span class="n">month</span> <span class="o">*</span> <span class="mi">100</span> <span class="o">+</span>
-                                     <span class="n">truedatetime</span><span class="o">.</span><span class="n">day</span><span class="p">)</span>
-                            <span class="n">grib_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="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">gnout</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">g_handle</span><span class="p">:</span>
-                                <span class="n">grib_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">grib_release</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
-
-                <span class="n">gid</span> <span class="o">=</span> <span class="n">grib_new_from_index</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
-
-        <span class="n">grib_index_release</span><span class="p">(</span><span class="n">iid</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>
+
+                <span class="n">gid</span> <span class="o">=</span> <span class="n">codes_new_from_index</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
+
+            <span class="n">f_handle</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
+            <span class="n">g_handle</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
+            <span class="n">h_handle</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">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">_create_rr_grib_dummy</span><span class="p">(</span><span class="n">inputfiles</span><span class="o">.</span><span class="n">files</span><span class="p">[</span><span class="mi">0</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="bp">self</span><span class="o">.</span><span class="n">_prep_new_rrint</span><span class="p">(</span><span class="n">ni</span><span class="p">,</span> <span class="n">nj</span><span class="p">,</span> <span class="n">lsp_np</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">lsp_np</span><span class="p">,</span>
+                                 <span class="n">cp_np</span><span class="p">,</span> <span class="n">date_list</span><span class="p">,</span> <span class="n">step_list</span><span class="p">,</span> <span class="n">c</span><span class="p">)</span>
 
         <span class="k">return</span></div>
 
+    <span class="k">def</span> <span class="nf">_prep_new_rrint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ni</span><span class="p">,</span> <span class="n">nj</span><span class="p">,</span> <span class="n">nt</span><span class="p">,</span> <span class="n">lsp_np</span><span class="p">,</span> <span class="n">cp_np</span><span class="p">,</span> <span class="n">date_list</span><span class="p">,</span> <span class="n">step_list</span><span class="p">,</span> <span class="n">c</span><span class="p">):</span>
+        <span class="sd">&#39;&#39;&#39;Calculates and writes out the disaggregated precipitation fields.</span>
+
+<span class="sd">        Disaggregation is done in time and original times are written to the</span>
+<span class="sd">        flux files, while the additional subgrid times are written to</span>
+<span class="sd">        extra files.</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        ni : int</span>
+<span class="sd">            Amount of zonal grid points.</span>
+
+<span class="sd">        nj : int</span>
+<span class="sd">            Amount of meridional grid points.</span>
+
+<span class="sd">        nt : int</span>
+<span class="sd">            Number of time steps.</span>
+
+<span class="sd">        lsp_np : numpy array of float</span>
+<span class="sd">            The large scale precipitation fields for each time step.</span>
+<span class="sd">            Shape (ni * nj, nt).</span>
+
+<span class="sd">        cp_np : numpy array of float</span>
+<span class="sd">            The convective precipitation fields for each time step.</span>
+<span class="sd">            Shape (ni * nj, nt).</span>
+
+<span class="sd">        date_list : list of datetime</span>
+<span class="sd">            The list of dates for which the disaggregation is to be done.</span>
+
+<span class="sd">        step_list : list of int</span>
+<span class="sd">            The list of steps for a single forecast time.</span>
+<span class="sd">            Only necessary for pure forecasts.</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">        Return</span>
+<span class="sd">        ------</span>
+
+<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="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>
+
+        <span class="c1"># do the disaggregation, but neglect the last value of the</span>
+        <span class="c1"># time series. This one corresponds for example to 24 hour,</span>
+        <span class="c1"># which we don&#39;t need.</span>
+        <span class="k">for</span> <span class="n">ix</span> <span class="ow">in</span> <span class="nb">range</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">lsp_new_np</span><span class="p">[</span><span class="n">ix</span><span class="p">,:]</span> <span class="o">=</span> <span class="n">disaggregation</span><span class="o">.</span><span class="n">IA3</span><span class="p">(</span><span class="n">lsp_np</span><span class="p">[</span><span class="n">ix</span><span class="p">,:])[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
+            <span class="n">cp_new_np</span><span class="p">[</span><span class="n">ix</span><span class="p">,:]</span> <span class="o">=</span> <span class="n">disaggregation</span><span class="o">.</span><span class="n">IA3</span><span class="p">(</span><span class="n">cp_np</span><span class="p">[</span><span class="n">ix</span><span class="p">,:])[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
+
+        <span class="c1"># write to grib files (full/orig times to flux file and inbetween</span>
+        <span class="c1"># times into seperate end files)</span>
+        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;... write disaggregated precipitation to files.&#39;</span><span class="p">)</span>
+        <span class="n">it</span> <span class="o">=</span> <span class="mi">0</span>
+        <span class="k">for</span> <span class="n">date</span> <span class="ow">in</span> <span class="n">date_list</span><span class="p">:</span>
+            <span class="k">for</span> <span class="n">step</span> <span class="ow">in</span> <span class="n">step_list</span><span class="p">:</span>
+                <span class="n">tmpfile</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;rr_grib_dummy.grb&#39;</span><span class="p">)</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">fluxfilename</span> <span class="o">=</span> <span class="s1">&#39;flux&#39;</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;.</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="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;.</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="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;.</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="s1">&#39;_2&#39;</span>
+                <span class="k">else</span><span class="p">:</span>
+                    <span class="n">fluxfilename</span> <span class="o">=</span> <span class="s1">&#39;flux&#39;</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="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>
+                <span class="n">fluxfile</span> <span class="o">=</span> <span class="n">GribUtil</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="n">fluxfilename</span><span class="p">))</span>
+                <span class="n">fluxfile</span><span class="o">.</span><span class="n">set_keys</span><span class="p">(</span><span class="n">tmpfile</span><span class="p">,</span> <span class="n">filemode</span><span class="o">=</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="n">strict</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
+                                  <span class="n">wherekeynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;paramId&#39;</span><span class="p">],</span> <span class="n">wherekeyvalues</span><span class="o">=</span><span class="p">[</span><span class="mi">142</span><span class="p">],</span>
+                                  <span class="n">keynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">,</span><span class="s1">&#39;time&#39;</span><span class="p">,</span><span class="s1">&#39;stepRange&#39;</span><span class="p">,</span><span class="s1">&#39;values&#39;</span><span class="p">],</span>
+                                  <span class="n">keyvalues</span><span class="o">=</span><span class="p">[</span><span class="nb">int</span><span class="p">(</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">&#39;</span><span class="p">)),</span>
+                                             <span class="n">date</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">step</span><span class="p">,</span> <span class="n">lsp_new_np</span><span class="p">[:,</span><span class="n">it</span><span class="p">]],</span>
+                                 <span class="p">)</span>
+                <span class="n">fluxfile</span><span class="o">.</span><span class="n">set_keys</span><span class="p">(</span><span class="n">tmpfile</span><span class="p">,</span> <span class="n">filemode</span><span class="o">=</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="n">strict</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
+                                  <span class="n">wherekeynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;paramId&#39;</span><span class="p">],</span> <span class="n">wherekeyvalues</span><span class="o">=</span><span class="p">[</span><span class="mi">143</span><span class="p">],</span>
+                                  <span class="n">keynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">,</span><span class="s1">&#39;time&#39;</span><span class="p">,</span><span class="s1">&#39;stepRange&#39;</span><span class="p">,</span><span class="s1">&#39;values&#39;</span><span class="p">],</span>
+                                  <span class="n">keyvalues</span><span class="o">=</span><span class="p">[</span><span class="nb">int</span><span class="p">(</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">&#39;</span><span class="p">)),</span>
+                                             <span class="n">date</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">step</span><span class="p">,</span> <span class="n">cp_new_np</span><span class="p">[:,</span><span class="n">it</span><span class="p">]]</span>
+                                 <span class="p">)</span>
+
+                <span class="c1"># write first subgrid time step</span>
+                <span class="n">endfile1</span> <span class="o">=</span> <span class="n">GribUtil</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="n">filename1</span><span class="p">))</span>
+                <span class="n">endfile1</span><span class="o">.</span><span class="n">set_keys</span><span class="p">(</span><span class="n">tmpfile</span><span class="p">,</span> <span class="n">filemode</span><span class="o">=</span><span class="s1">&#39;w&#39;</span><span class="p">,</span> <span class="n">strict</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
+                                  <span class="n">wherekeynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;paramId&#39;</span><span class="p">],</span> <span class="n">wherekeyvalues</span><span class="o">=</span><span class="p">[</span><span class="mi">142</span><span class="p">],</span>
+                                  <span class="n">keynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">,</span><span class="s1">&#39;time&#39;</span><span class="p">,</span><span class="s1">&#39;stepRange&#39;</span><span class="p">,</span><span class="s1">&#39;values&#39;</span><span class="p">],</span>
+                                  <span class="n">keyvalues</span><span class="o">=</span><span class="p">[</span><span class="nb">int</span><span class="p">(</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">&#39;</span><span class="p">)),</span>
+                                             <span class="n">date</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">step</span><span class="p">,</span> <span class="n">lsp_new_np</span><span class="p">[:,</span><span class="n">it</span><span class="o">+</span><span class="mi">1</span><span class="p">]]</span>
+                                  <span class="p">)</span>
+                <span class="n">endfile1</span><span class="o">.</span><span class="n">set_keys</span><span class="p">(</span><span class="n">tmpfile</span><span class="p">,</span> <span class="n">filemode</span><span class="o">=</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="n">strict</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
+                                  <span class="n">wherekeynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;paramId&#39;</span><span class="p">],</span> <span class="n">wherekeyvalues</span><span class="o">=</span><span class="p">[</span><span class="mi">143</span><span class="p">],</span>
+                                  <span class="n">keynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">,</span><span class="s1">&#39;time&#39;</span><span class="p">,</span><span class="s1">&#39;stepRange&#39;</span><span class="p">,</span><span class="s1">&#39;values&#39;</span><span class="p">],</span>
+                                  <span class="n">keyvalues</span><span class="o">=</span><span class="p">[</span><span class="nb">int</span><span class="p">(</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">&#39;</span><span class="p">)),</span>
+                                             <span class="n">date</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">step</span><span class="p">,</span> <span class="n">cp_new_np</span><span class="p">[:,</span><span class="n">it</span><span class="o">+</span><span class="mi">1</span><span class="p">]]</span>
+                                 <span class="p">)</span>
+
+                <span class="c1"># write second subgrid time step</span>
+                <span class="n">endfile2</span> <span class="o">=</span> <span class="n">GribUtil</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="n">filename2</span><span class="p">))</span>
+                <span class="n">endfile2</span><span class="o">.</span><span class="n">set_keys</span><span class="p">(</span><span class="n">tmpfile</span><span class="p">,</span> <span class="n">filemode</span><span class="o">=</span><span class="s1">&#39;w&#39;</span><span class="p">,</span> <span class="n">strict</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
+                                  <span class="n">wherekeynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;paramId&#39;</span><span class="p">],</span> <span class="n">wherekeyvalues</span><span class="o">=</span><span class="p">[</span><span class="mi">142</span><span class="p">],</span>
+                                  <span class="n">keynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">,</span><span class="s1">&#39;time&#39;</span><span class="p">,</span><span class="s1">&#39;stepRange&#39;</span><span class="p">,</span><span class="s1">&#39;values&#39;</span><span class="p">],</span>
+                                  <span class="n">keyvalues</span><span class="o">=</span><span class="p">[</span><span class="nb">int</span><span class="p">(</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">&#39;</span><span class="p">)),</span>
+                                             <span class="n">date</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">step</span><span class="p">,</span> <span class="n">lsp_new_np</span><span class="p">[:,</span><span class="n">it</span><span class="o">+</span><span class="mi">2</span><span class="p">]]</span>
+                                 <span class="p">)</span>
+                <span class="n">endfile2</span><span class="o">.</span><span class="n">set_keys</span><span class="p">(</span><span class="n">tmpfile</span><span class="p">,</span> <span class="n">filemode</span><span class="o">=</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="n">strict</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
+                                  <span class="n">wherekeynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;paramId&#39;</span><span class="p">],</span> <span class="n">wherekeyvalues</span><span class="o">=</span><span class="p">[</span><span class="mi">143</span><span class="p">],</span>
+                                  <span class="n">keynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">,</span><span class="s1">&#39;time&#39;</span><span class="p">,</span><span class="s1">&#39;stepRange&#39;</span><span class="p">,</span><span class="s1">&#39;values&#39;</span><span class="p">],</span>
+                                  <span class="n">keyvalues</span><span class="o">=</span><span class="p">[</span><span class="nb">int</span><span class="p">(</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">&#39;</span><span class="p">)),</span>
+                                             <span class="n">date</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">step</span><span class="p">,</span> <span class="n">cp_new_np</span><span class="p">[:,</span><span class="n">it</span><span class="o">+</span><span class="mi">2</span><span class="p">]]</span>
+                                 <span class="p">)</span>
+                <span class="n">it</span> <span class="o">=</span> <span class="n">it</span> <span class="o">+</span> <span class="mi">3</span> <span class="c1"># jump to next original time step</span>
+        <span class="k">return</span>
+
+    <span class="k">def</span> <span class="nf">_create_rr_grib_dummy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ifile</span><span class="p">,</span> <span class="n">inputdir</span><span class="p">):</span>
+        <span class="sd">&#39;&#39;&#39;Creates a grib file with a dummy message for the two precipitation</span>
+<span class="sd">        types lsp and cp each.</span>
+
+<span class="sd">        Parameters</span>
+<span class="sd">        ----------</span>
+<span class="sd">        ifile : str</span>
+<span class="sd">            Filename of the input file to read the grib messages from.</span>
+
+<span class="sd">        inputdir : str, optional</span>
+<span class="sd">            Path to the directory where the retrieved data is stored.</span>
+
+<span class="sd">        Return</span>
+<span class="sd">        ------</span>
+
+<span class="sd">        &#39;&#39;&#39;</span>
+
+        <span class="n">gribfile</span> <span class="o">=</span> <span class="n">GribUtil</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">inputdir</span><span class="p">,</span><span class="s1">&#39;rr_grib_dummy.grb&#39;</span><span class="p">))</span>
+
+        <span class="n">gribfile</span><span class="o">.</span><span class="n">copy_dummy_msg</span><span class="p">(</span><span class="n">ifile</span><span class="p">,</span> <span class="n">keynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;paramId&#39;</span><span class="p">],</span>
+                      <span class="n">keyvalues</span><span class="o">=</span><span class="p">[</span><span class="mi">142</span><span class="p">],</span> <span class="n">filemode</span><span class="o">=</span><span class="s1">&#39;w&#39;</span><span class="p">)</span>
+
+        <span class="n">gribfile</span><span class="o">.</span><span class="n">copy_dummy_msg</span><span class="p">(</span><span class="n">ifile</span><span class="p">,</span> <span class="n">keynames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;paramId&#39;</span><span class="p">],</span>
+                      <span class="n">keyvalues</span><span class="o">=</span><span class="p">[</span><span class="mi">143</span><span class="p">],</span> <span class="n">filemode</span><span class="o">=</span><span class="s1">&#39;a&#39;</span><span class="p">)</span>
+
+        <span class="k">return</span>
 
 <div class="viewcode-block" id="EcFlexpart.create"><a class="viewcode-back" href="../api.html#EcFlexpart.EcFlexpart.create">[docs]</a>    <span class="k">def</span> <span class="nf">create</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">inputfiles</span><span class="p">,</span> <span class="n">c</span><span class="p">):</span>
@@ -1100,8 +1494,8 @@
 <span class="sd">        Parameters</span>
 <span class="sd">        ----------</span>
-<span class="sd">        inputfiles : :obj:`UioFiles`</span>
+<span class="sd">        inputfiles : UioFiles</span>
 <span class="sd">            Contains a list of files.</span>
 
-<span class="sd">        c : :obj:`ControlFile`</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>
@@ -1137,5 +1531,5 @@
         <span class="c1"># index_vals looks like e.g.:</span>
         <span class="c1"># index_vals[0]: (&#39;20171106&#39;, &#39;20171107&#39;, &#39;20171108&#39;) ; date</span>
-        <span class="c1"># index_vals[1]: (&#39;0&#39;, &#39;1200&#39;, &#39;1800&#39;, &#39;600&#39;) ; time</span>
+        <span class="c1"># index_vals[1]: (&#39;0&#39;, &#39;600&#39;, &#39;1200&#39;, &#39;1800&#39;) ; time</span>
         <span class="c1"># index_vals[2]: (&#39;0&#39;, &#39;12&#39;, &#39;3&#39;, &#39;6&#39;, &#39;9&#39;) ; stepRange</span>
 
@@ -1149,8 +1543,8 @@
 
             <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="nb">len</span><span class="p">(</span><span class="n">index_keys</span><span class="p">)):</span>
-                <span class="n">grib_index_select</span><span class="p">(</span><span class="n">iid</span><span class="p">,</span> <span class="n">index_keys</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">prod</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
+                <span class="n">codes_index_select</span><span class="p">(</span><span class="n">iid</span><span class="p">,</span> <span class="n">index_keys</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">prod</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
 
             <span class="c1"># get first id from current product</span>
-            <span class="n">gid</span> <span class="o">=</span> <span class="n">grib_new_from_index</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
+            <span class="n">gid</span> <span class="o">=</span> <span class="n">codes_new_from_index</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
 
             <span class="c1"># if there is no data for this specific time combination / product</span>
@@ -1158,5 +1552,5 @@
             <span class="k">if</span> <span class="ow">not</span> <span class="n">gid</span><span class="p">:</span>
                 <span class="k">continue</span>
-
+<span class="c1">#============================================================================================</span>
             <span class="c1"># remove old fort.* files and open new ones</span>
             <span class="c1"># they are just valid for a single product</span>
@@ -1165,9 +1559,9 @@
                 <span class="n">silent_remove</span><span class="p">(</span><span class="n">fortfile</span><span class="p">)</span>
                 <span class="n">fdict</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">fortfile</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span>
-
+<span class="c1">#============================================================================================</span>
             <span class="c1"># create correct timestamp from the three time informations</span>
-            <span class="n">cdate</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">grib_get</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="n">ctime</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{:0&gt;2}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">grib_get</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="o">/</span><span class="mi">100</span><span class="p">)</span>
-            <span class="n">cstep</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">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;step&#39;</span><span class="p">))</span>
+            <span class="n">cdate</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">codes_get</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="n">ctime</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{:0&gt;2}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">codes_get</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="o">/</span><span class="mi">100</span><span class="p">)</span>
+            <span class="n">cstep</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">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;step&#39;</span><span class="p">))</span>
             <span class="n">timestamp</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">cdate</span> <span class="o">+</span> <span class="n">ctime</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">timestamp</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">cstep</span><span class="p">))</span>
@@ -1189,5 +1583,5 @@
                                 <span class="s1">&#39;WRF&#39;</span> <span class="o">+</span> <span class="n">cdate</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="n">ctime</span> <span class="o">+</span> <span class="s1">&#39;.000.grb2&#39;</span><span class="p">),</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span>
                     <span class="n">olddate</span> <span class="o">=</span> <span class="n">cdate</span><span class="p">[:]</span>
-
+<span class="c1">#============================================================================================</span>
             <span class="c1"># savedfields remembers which fields were already used.</span>
             <span class="n">savedfields</span> <span class="o">=</span> <span class="p">[]</span>
@@ -1197,32 +1591,33 @@
                 <span class="k">if</span> <span class="ow">not</span> <span class="n">gid</span><span class="p">:</span>
                     <span class="k">break</span>
-                <span class="n">paramId</span> <span class="o">=</span> <span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;paramId&#39;</span><span class="p">)</span>
-                <span class="n">gridtype</span> <span class="o">=</span> <span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;gridType&#39;</span><span class="p">)</span>
-                <span class="n">levtype</span> <span class="o">=</span> <span class="n">grib_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;typeOfLevel&#39;</span><span class="p">)</span>
+                <span class="n">paramId</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;paramId&#39;</span><span class="p">)</span>
+                <span class="n">gridtype</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;gridType&#39;</span><span class="p">)</span>
+                <span class="n">levtype</span> <span class="o">=</span> <span class="n">codes_get</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;typeOfLevel&#39;</span><span class="p">)</span>
                 <span class="k">if</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">77</span><span class="p">:</span> <span class="c1"># ETADOT</span>
-                    <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;21&#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">fdict</span><span class="p">[</span><span class="s1">&#39;21&#39;</span><span class="p">])</span>
                 <span class="k">elif</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">130</span><span class="p">:</span> <span class="c1"># T</span>
-                    <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;11&#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">fdict</span><span class="p">[</span><span class="s1">&#39;11&#39;</span><span class="p">])</span>
                 <span class="k">elif</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">131</span> <span class="ow">or</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">132</span><span class="p">:</span> <span class="c1"># U, V wind component</span>
-                    <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;10&#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">fdict</span><span class="p">[</span><span class="s1">&#39;10&#39;</span><span class="p">])</span>
                 <span class="k">elif</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">133</span> <span class="ow">and</span> <span class="n">gridtype</span> <span class="o">!=</span> <span class="s1">&#39;reduced_gg&#39;</span><span class="p">:</span> <span class="c1"># Q</span>
-                    <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;17&#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">fdict</span><span class="p">[</span><span class="s1">&#39;17&#39;</span><span class="p">])</span>
                 <span class="k">elif</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">133</span> <span class="ow">and</span> <span class="n">gridtype</span> <span class="o">==</span> <span class="s1">&#39;reduced_gg&#39;</span><span class="p">:</span> <span class="c1"># Q, gaussian</span>
-                    <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;18&#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">fdict</span><span class="p">[</span><span class="s1">&#39;18&#39;</span><span class="p">])</span>
                 <span class="k">elif</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">135</span><span class="p">:</span> <span class="c1"># W</span>
-                    <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;19&#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">fdict</span><span class="p">[</span><span class="s1">&#39;19&#39;</span><span class="p">])</span>
                 <span class="k">elif</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">152</span><span class="p">:</span> <span class="c1"># LNSP</span>
-                    <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;12&#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">fdict</span><span class="p">[</span><span class="s1">&#39;12&#39;</span><span class="p">])</span>
                 <span class="k">elif</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">155</span> <span class="ow">and</span> <span class="n">gridtype</span> <span class="o">==</span> <span class="s1">&#39;sh&#39;</span><span class="p">:</span> <span class="c1"># D</span>
-                    <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;13&#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">fdict</span><span class="p">[</span><span class="s1">&#39;13&#39;</span><span class="p">])</span>
                 <span class="k">elif</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">246</span> <span class="ow">or</span> <span class="n">paramId</span> <span class="o">==</span> <span class="mi">247</span><span class="p">:</span> <span class="c1"># CLWC, CIWC</span>
                     <span class="c1"># sum cloud liquid water and ice</span>
                     <span class="k">if</span> <span class="n">scwc</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
-                        <span class="n">scwc</span> <span class="o">=</span> <span class="n">grib_get_values</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
+                        <span class="n">scwc</span> <span class="o">=</span> <span class="n">codes_get_values</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
                     <span class="k">else</span><span class="p">:</span>
-                        <span class="n">scwc</span> <span class="o">+=</span> <span class="n">grib_get_values</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
-                        <span class="n">grib_set_values</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">scwc</span><span class="p">)</span>
-                        <span class="n">grib_set</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="s1">&#39;paramId&#39;</span><span class="p">,</span> <span class="mi">201031</span><span class="p">)</span>
-                        <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;22&#39;</span><span class="p">])</span>
+                        <span class="n">scwc</span> <span class="o">+=</span> <span class="n">codes_get_values</span><span class="p">(</span><span class="n">gid</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">scwc</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;paramId&#39;</span><span class="p">,</span> <span class="mi">201031</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">fdict</span><span class="p">[</span><span class="s1">&#39;22&#39;</span><span class="p">])</span>
+                        <span class="n">scwc</span> <span class="o">=</span> <span class="kc">None</span>
                 <span class="k">elif</span> <span class="n">c</span><span class="o">.</span><span class="n">wrf</span> <span class="ow">and</span> <span class="n">paramId</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">129</span><span class="p">,</span> <span class="mi">138</span><span class="p">,</span> <span class="mi">155</span><span class="p">]</span> <span class="ow">and</span> \
                       <span class="n">levtype</span> <span class="o">==</span> <span class="s1">&#39;hybrid&#39;</span><span class="p">:</span> <span class="c1"># Z, VO, D</span>
@@ -1234,5 +1629,5 @@
                         <span class="c1"># SD/MSL/TCC/10U/10V/2T/2D/Z/LSM/SDOR/CVL/CVH/SR</span>
                         <span class="c1"># and all ADDPAR parameter</span>
-                        <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fdict</span><span class="p">[</span><span class="s1">&#39;16&#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">fdict</span><span class="p">[</span><span class="s1">&#39;16&#39;</span><span class="p">])</span>
                         <span class="n">savedfields</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">paramId</span><span class="p">)</span>
                     <span class="k">else</span><span class="p">:</span>
@@ -1244,17 +1639,17 @@
                         <span class="k">if</span> <span class="n">levtype</span> <span class="o">==</span> <span class="s1">&#39;hybrid&#39;</span> <span class="ow">and</span> \
                            <span class="n">paramId</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">129</span><span class="p">,</span> <span class="mi">130</span><span class="p">,</span> <span class="mi">131</span><span class="p">,</span> <span class="mi">132</span><span class="p">,</span> <span class="mi">133</span><span class="p">,</span> <span class="mi">138</span><span class="p">,</span> <span class="mi">155</span><span class="p">]:</span>
-                            <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fwrf</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">fwrf</span><span class="p">)</span>
                         <span class="c1"># sfc layer</span>
                         <span class="k">elif</span> <span class="n">paramId</span> <span class="ow">in</span> <span class="n">wrfpars</span><span class="p">:</span>
-                            <span class="n">grib_write</span><span class="p">(</span><span class="n">gid</span><span class="p">,</span> <span class="n">fwrf</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">fwrf</span><span class="p">)</span>
                 <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
                     <span class="k">pass</span>
 
-                <span class="n">grib_release</span><span class="p">(</span><span class="n">gid</span><span class="p">)</span>
-                <span class="n">gid</span> <span class="o">=</span> <span class="n">grib_new_from_index</span><span class="p">(</span><span class="n">iid</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">gid</span> <span class="o">=</span> <span class="n">codes_new_from_index</span><span class="p">(</span><span class="n">iid</span><span class="p">)</span>
+<span class="c1">#============================================================================================</span>
             <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">fdict</span><span class="o">.</span><span class="n">values</span><span class="p">():</span>
                 <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
-
+<span class="c1">#============================================================================================</span>
             <span class="c1"># call for Fortran program to convert e.g. reduced_gg grids to</span>
             <span class="c1"># regular_ll and calculate detadot/dp</span>
@@ -1267,12 +1662,17 @@
                 <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="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>
 
             <span class="c1"># Fortran program creates file fort.15 (with u,v,etadot,t,sp,q)</span>
-            <span class="n">p</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">check_call</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">exedir</span><span class="p">,</span> <span class="n">_config</span><span class="o">.</span><span class="n">FORTRAN_EXECUTABLE</span><span class="p">)],</span> <span class="n">shell</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
+            <span class="n">execute_subprocess</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">exedir</span><span class="p">,</span>
+                                <span class="n">_config</span><span class="o">.</span><span class="n">FORTRAN_EXECUTABLE</span><span class="p">)],</span>
+                               <span class="n">error_msg</span><span class="o">=</span><span class="s1">&#39;FORTRAN PROGRAM FAILED!&#39;</span><span class="p">)</span><span class="c1">#shell=True)</span>
+
             <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"># 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">maxstep</span> <span class="o">&gt;</span> <span class="mi">12</span><span class="p">:</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">suffix</span> <span class="o">=</span> <span class="n">cdate</span><span class="p">[</span><span class="mi">2</span><span class="p">:</span><span class="mi">8</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="n">ctime</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="n">cstep</span>
             <span class="k">else</span><span class="p">:</span>
@@ -1282,5 +1682,5 @@
             <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"># create outputfile and copy all data from intermediate files</span>
             <span class="c1"># to the outputfile (final GRIB input files for FLEXPART)</span>
@@ -1302,9 +1702,9 @@
                     <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="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">grib_index_release</span><span class="p">(</span><span class="n">iid</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>
@@ -1312,5 +1712,7 @@
 
 <div class="viewcode-block" id="EcFlexpart.process_output"><a class="viewcode-back" href="../api.html#EcFlexpart.EcFlexpart.process_output">[docs]</a>    <span class="k">def</span> <span class="nf">process_output</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">c</span><span class="p">):</span>
-        <span class="sd">&#39;&#39;&#39;The grib files are postprocessed depending on the selection in</span>
+        <span class="sd">&#39;&#39;&#39;Postprocessing of FLEXPART input files.</span>
+
+<span class="sd">        The grib files are postprocessed depending on the selection in</span>
 <span class="sd">        CONTROL file. The resulting files are moved to the output</span>
 <span class="sd">        directory if its not equal to the input directory.</span>
@@ -1323,5 +1725,5 @@
 <span class="sd">        Parameters</span>
 <span class="sd">        ----------</span>
-<span class="sd">        c : :obj:`ControlFile`</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>
@@ -1347,22 +1749,30 @@
 
             <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">format</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;grib2&#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">check_call</span><span class="p">([</span><span class="s1">&#39;grib_set&#39;</span><span class="p">,</span> <span class="s1">&#39;-s&#39;</span><span class="p">,</span> <span class="s1">&#39;edition=2, </span><span class="se">\</span>
-<span class="s1">                                           productDefinitionTemplateNumber=8&#39;</span><span class="p">,</span>
-                                           <span class="n">ofile</span><span class="p">,</span> <span class="n">ofile</span> <span class="o">+</span> <span class="s1">&#39;_2&#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">check_call</span><span class="p">([</span><span class="s1">&#39;mv&#39;</span><span class="p">,</span> <span class="n">ofile</span> <span class="o">+</span> <span class="s1">&#39;_2&#39;</span><span class="p">,</span> <span class="n">ofile</span><span class="p">])</span>
+                <span class="n">execute_subprocess</span><span class="p">([</span><span class="s1">&#39;grib_set&#39;</span><span class="p">,</span> <span class="s1">&#39;-s&#39;</span><span class="p">,</span> <span class="s1">&#39;edition=2,&#39;</span> <span class="o">+</span>
+                                    <span class="s1">&#39;productDefinitionTemplateNumber=8&#39;</span><span class="p">,</span>
+                                    <span class="n">ofile</span><span class="p">,</span> <span class="n">ofile</span> <span class="o">+</span> <span class="s1">&#39;_2&#39;</span><span class="p">],</span>
+                                   <span class="n">error_msg</span><span class="o">=</span><span class="s1">&#39;GRIB2 CONVERSION FAILED!&#39;</span><span class="p">)</span>
+
+                <span class="n">execute_subprocess</span><span class="p">([</span><span class="s1">&#39;mv&#39;</span><span class="p">,</span> <span class="n">ofile</span> <span class="o">+</span> <span class="s1">&#39;_2&#39;</span><span class="p">,</span> <span class="n">ofile</span><span class="p">],</span>
+                                   <span class="n">error_msg</span><span class="o">=</span><span class="s1">&#39;RENAMING FOR NEW GRIB2 FORMAT &#39;</span>
+                                   <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="n">p</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">check_call</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>
-                                           <span class="s1">&#39;-source&#39;</span><span class="p">,</span> <span class="n">ofile</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>
+                                    <span class="s1">&#39;-source&#39;</span><span class="p">,</span> <span class="n">ofile</span><span class="p">],</span>
+                                   <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="n">p</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">check_call</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>
+                <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>
+                                   <span class="n">error_msg</span><span class="o">=</span><span class="s1">&#39;COPY OF FILES TO ECSTORAGE &#39;</span>
+                                   <span class="s1">&#39;AREA FAILED!&#39;</span><span class="p">)</span>
 
             <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">outputdir</span> <span class="o">!=</span> <span class="n">c</span><span class="o">.</span><span class="n">inputdir</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">check_call</span><span class="p">([</span><span class="s1">&#39;mv&#39;</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="n">ofile</span><span class="p">),</span>
-                                           <span class="n">c</span><span class="o">.</span><span class="n">outputdir</span><span class="p">])</span>
+                <span class="n">execute_subprocess</span><span class="p">([</span><span class="s1">&#39;mv&#39;</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="n">ofile</span><span class="p">),</span>
+                                    <span class="n">c</span><span class="o">.</span><span class="n">outputdir</span><span class="p">],</span>
+                                   <span class="n">error_msg</span><span class="o">=</span><span class="s1">&#39;RELOCATION OF OUTPUT FILES &#39;</span>
+                                   <span class="s1">&#39;TO OUTPUTDIR FAILED!&#39;</span><span class="p">)</span>
 
         <span class="k">return</span></div>
@@ -1374,5 +1784,5 @@
 <span class="sd">        Parameters</span>
 <span class="sd">        ----------</span>
-<span class="sd">        c : :obj:`ControlFile`</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>
@@ -1419,5 +1829,5 @@
         <span class="c1"># read template COMMAND file</span>
         <span class="k">with</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">expandvars</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">expanduser</span><span class="p">(</span>
-            <span class="n">c</span><span class="o">.</span><span class="n">flexpart_root_scripts</span><span class="p">))</span> <span class="o">+</span> <span class="s1">&#39;/../Options/COMMAND&#39;</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
+            <span class="n">c</span><span class="o">.</span><span class="n">flexpartdir</span><span class="p">))</span> <span class="o">+</span> <span class="s1">&#39;/../Options/COMMAND&#39;</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
             <span class="n">lflist</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
 
@@ -1444,7 +1854,7 @@
         <span class="c1"># afterwards switch back to the working dir</span>
         <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">outputdir</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">check_call</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">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expanduser</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">flexpart_root_scripts</span><span class="p">))</span>
-            <span class="o">+</span> <span class="s1">&#39;/../FLEXPART_PROGRAM/grib2flexpart&#39;</span><span class="p">,</span> <span class="s1">&#39;useAvailable&#39;</span><span class="p">,</span> <span class="s1">&#39;.&#39;</span><span class="p">])</span>
+        <span class="n">cmd</span> <span class="o">=</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">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expanduser</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">flexpartdir</span><span class="p">))</span> <span class="o">+</span>
+         <span class="s1">&#39;/../FLEXPART_PROGRAM/grib2flexpart&#39;</span><span class="p">,</span> <span class="s1">&#39;useAvailable&#39;</span><span class="p">,</span> <span class="s1">&#39;.&#39;</span><span class="p">]</span>
+        <span class="n">execute_subprocess</span><span class="p">(</span><span class="n">cmd</span><span class="p">)</span>
         <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>
 
@@ -1462,5 +1872,5 @@
   <div role="contentinfo">
     <p>
-        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
+        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
 
     </p>
@@ -1481,19 +1891,11 @@
   
 
-    <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>
+    
+    
+      <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>
+    
 
   
