Index: documentation/Sphinx/build/html/_modules/tools.html
===================================================================
--- documentation/Sphinx/build/html/_modules/tools.html	(revision 2625ca8faac35d65699e83e37bb42cdc24163490)
+++ documentation/Sphinx/build/html/_modules/tools.html	(revision f66f9905a36e7b0a824c539e948b15ca55615e47)
@@ -222,7 +222,44 @@
 <span class="kn">from</span> <span class="nn">argparse</span> <span class="k">import</span> <span class="n">ArgumentParser</span><span class="p">,</span> <span class="n">ArgumentDefaultsHelpFormatter</span>
 
+
+
 <span class="c1"># ------------------------------------------------------------------------------</span>
 <span class="c1"># METHODS</span>
 <span class="c1"># ------------------------------------------------------------------------------</span>
+
+<div class="viewcode-block" id="setup_controldata"><a class="viewcode-back" href="../api.html#tools.setup_controldata">[docs]</a><span class="k">def</span> <span class="nf">setup_controldata</span><span class="p">():</span>
+    <span class="sd">&#39;&#39;&#39;Collects, stores and checks controlling arguments from command line,</span>
+<span class="sd">    CONTROL file and ECMWF_ENV file.</span>
+
+<span class="sd">    Parameters</span>
+<span class="sd">    ----------</span>
+
+<span class="sd">    Return</span>
+<span class="sd">    ------</span>
+<span class="sd">    c : ControlFile</span>
+<span class="sd">        Contains all the parameters of CONTROL file and</span>
+<span class="sd">        command line.</span>
+
+<span class="sd">    ppid : str</span>
+<span class="sd">        Parent process id.</span>
+
+<span class="sd">    queue : str</span>
+<span class="sd">        Name of queue for submission to ECMWF (e.g. ecgate or cca )</span>
+
+<span class="sd">    job_template : str</span>
+<span class="sd">        Name of the job template file for submission to ECMWF server.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="kn">import</span> <span class="nn">_config</span>
+    <span class="kn">from</span> <span class="nn">classes.ControlFile</span> <span class="k">import</span> <span class="n">ControlFile</span>
+
+    <span class="n">args</span> <span class="o">=</span> <span class="n">get_cmdline_args</span><span class="p">()</span>
+    <span class="n">c</span> <span class="o">=</span> <span class="n">ControlFile</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">controlfile</span><span class="p">)</span>
+    <span class="n">c</span><span class="o">.</span><span class="n">assign_args_to_control</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>
+    <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">PATH_ECMWF_ENV</span><span class="p">):</span>
+        <span class="n">env_parameter</span> <span class="o">=</span> <span class="n">read_ecenv</span><span class="p">(</span><span class="n">_config</span><span class="o">.</span><span class="n">PATH_ECMWF_ENV</span><span class="p">)</span>
+        <span class="n">c</span><span class="o">.</span><span class="n">assign_envs_to_control</span><span class="p">(</span><span class="n">env_parameter</span><span class="p">)</span>
+    <span class="n">c</span><span class="o">.</span><span class="n">check_conditions</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">queue</span><span class="p">)</span>
+
+    <span class="k">return</span> <span class="n">c</span><span class="p">,</span> <span class="n">args</span><span class="o">.</span><span class="n">ppid</span><span class="p">,</span> <span class="n">args</span><span class="o">.</span><span class="n">queue</span><span class="p">,</span> <span class="n">args</span><span class="o">.</span><span class="n">job_template</span></div>
 
 <div class="viewcode-block" id="none_or_str"><a class="viewcode-back" href="../api.html#tools.none_or_str">[docs]</a><span class="k">def</span> <span class="nf">none_or_str</span><span class="p">(</span><span class="n">value</span><span class="p">):</span>
@@ -300,5 +337,5 @@
     <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">&quot;--basetime&quot;</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s2">&quot;basetime&quot;</span><span class="p">,</span>
                         <span class="nb">type</span><span class="o">=</span><span class="n">none_or_int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
-                        <span class="n">help</span><span class="o">=</span><span class="s2">&quot;base such as 00 or 12 (for half day retrievals)&quot;</span><span class="p">)</span>
+                        <span class="n">help</span><span class="o">=</span><span class="s2">&quot;base such as 0 or 12 (for half day retrievals)&quot;</span><span class="p">)</span>
     <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">&quot;--step&quot;</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s2">&quot;step&quot;</span><span class="p">,</span>
                         <span class="nb">type</span><span class="o">=</span><span class="n">none_or_str</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
@@ -315,4 +352,8 @@
                         <span class="nb">type</span><span class="o">=</span><span class="n">none_or_int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                         <span class="n">help</span><span class="o">=</span><span class="s2">&quot;debug mode - leave temporary files intact&quot;</span><span class="p">)</span>
+    <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">&quot;--oper&quot;</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s2">&quot;oper&quot;</span><span class="p">,</span>
+                        <span class="nb">type</span><span class="o">=</span><span class="n">none_or_int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
+                        <span class="n">help</span><span class="o">=</span><span class="s2">&quot;operational mode - prepares dates with </span><span class="se">\</span>
+<span class="s2">                        environment variables&quot;</span><span class="p">)</span>
     <span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">&quot;--request&quot;</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s2">&quot;request&quot;</span><span class="p">,</span>
                         <span class="nb">type</span><span class="o">=</span><span class="n">none_or_int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
@@ -408,12 +449,10 @@
     <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;... clean inputdir!&quot;</span><span class="p">)</span>
 
-    <span class="n">cleanlist</span> <span class="o">=</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="s2">&quot;*&quot;</span><span class="p">))</span>
+    <span class="n">cleanlist</span> <span class="o">=</span> <span class="p">[</span><span class="n">file</span> <span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">inputdir</span><span class="p">,</span> <span class="s2">&quot;*&quot;</span><span class="p">))</span>
+                 <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">file</span><span class="p">)</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">prefix</span><span class="p">)]</span>
 
     <span class="k">if</span> <span class="n">cleanlist</span><span class="p">:</span>
         <span class="k">for</span> <span class="n">element</span> <span class="ow">in</span> <span class="n">cleanlist</span><span class="p">:</span>
-            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">prefix</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">element</span><span class="p">:</span>
-                <span class="n">silent_remove</span><span class="p">(</span><span class="n">element</span><span class="p">)</span>
-            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">ecapi</span> <span class="ow">is</span> <span class="kc">False</span> <span class="ow">and</span> <span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">ectrans</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">or</span> <span class="n">c</span><span class="o">.</span><span class="n">ecstorage</span> <span class="o">==</span> <span class="mi">1</span><span class="p">):</span>
-                <span class="n">silent_remove</span><span class="p">(</span><span class="n">element</span><span class="p">)</span>
+            <span class="n">silent_remove</span><span class="p">(</span><span class="n">element</span><span class="p">)</span>
         <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;... done!&quot;</span><span class="p">)</span>
     <span class="k">else</span><span class="p">:</span>
@@ -423,5 +462,5 @@
 
 
-<div class="viewcode-block" id="my_error"><a class="viewcode-back" href="../api.html#tools.my_error">[docs]</a><span class="k">def</span> <span class="nf">my_error</span><span class="p">(</span><span class="n">users</span><span class="p">,</span> <span class="n">message</span><span class="o">=</span><span class="s1">&#39;ERROR&#39;</span><span class="p">):</span>
+<div class="viewcode-block" id="my_error"><a class="viewcode-back" href="../api.html#tools.my_error">[docs]</a><span class="k">def</span> <span class="nf">my_error</span><span class="p">(</span><span class="n">message</span><span class="o">=</span><span class="s1">&#39;ERROR&#39;</span><span class="p">):</span>
     <span class="sd">&#39;&#39;&#39;Prints a specified error message which can be passed to the function</span>
 <span class="sd">    before exiting the program.</span>
@@ -429,9 +468,4 @@
 <span class="sd">    Parameters</span>
 <span class="sd">    ----------</span>
-<span class="sd">    user : list of str</span>
-<span class="sd">        Contains all email addresses which should be notified.</span>
-<span class="sd">        It might also contain just the ecmwf user name which wil trigger</span>
-<span class="sd">        mailing to the associated email address for this user.</span>
-
 <span class="sd">    message : str, optional</span>
 <span class="sd">        Error message. Default value is &quot;ERROR&quot;.</span>
@@ -446,6 +480,4 @@
 
     <span class="nb">print</span><span class="p">(</span><span class="n">full_message</span><span class="p">)</span>
-
-    <span class="n">send_mail</span><span class="p">(</span><span class="n">users</span><span class="p">,</span> <span class="s1">&#39;ERROR&#39;</span><span class="p">,</span> <span class="n">full_message</span><span class="p">)</span>
 
     <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
@@ -615,6 +647,6 @@
     <span class="k">else</span><span class="p">:</span>
         <span class="k">for</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">fdata</span><span class="p">:</span>
-            <span class="k">if</span> <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="s1">&#39;!&#39;</span><span class="p">:</span>
-                <span class="n">table128</span><span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">3</span><span class="p">]]</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="mi">59</span><span class="p">:</span><span class="mi">64</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
+            <span class="k">if</span> <span class="n">data</span> <span class="o">!=</span> <span class="s1">&#39;&#39;</span> <span class="ow">and</span> <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="s1">&#39;!&#39;</span><span class="p">:</span>
+                <span class="n">table128</span><span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">3</span><span class="p">]]</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="mi">59</span><span class="p">:</span><span class="mi">65</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
 
     <span class="k">return</span> <span class="n">table128</span></div>
@@ -659,4 +691,45 @@
 
     <span class="k">return</span> <span class="n">ipar</span></div>
+
+<div class="viewcode-block" id="to_param_id_with_tablenumber"><a class="viewcode-back" href="../api.html#tools.to_param_id_with_tablenumber">[docs]</a><span class="k">def</span> <span class="nf">to_param_id_with_tablenumber</span><span class="p">(</span><span class="n">pars</span><span class="p">,</span> <span class="n">table</span><span class="p">):</span>
+    <span class="sd">&#39;&#39;&#39;Transform parameter names to parameter ids and add table id.</span>
+
+<span class="sd">    Conversion with ECMWF grib table 128.</span>
+
+<span class="sd">    Parameters</span>
+<span class="sd">    ----------</span>
+<span class="sd">    pars : str</span>
+<span class="sd">        Addpar argument from CONTROL file in the format of</span>
+<span class="sd">        parameter names instead of ids. The parameter short</span>
+<span class="sd">        names are sepearted with &quot;/&quot; and they are passed as</span>
+<span class="sd">        one single string.</span>
+
+<span class="sd">    table : dict</span>
+<span class="sd">        Contains the ECMWF grib table 128 information.</span>
+<span class="sd">        The key is the parameter number and the value is the</span>
+<span class="sd">        short name of the parameter.</span>
+
+<span class="sd">    Return</span>
+<span class="sd">    ------</span>
+<span class="sd">    spar : str</span>
+<span class="sd">        List of addpar parameters from CONTROL file transformed to</span>
+<span class="sd">        parameter ids in the format of integer.</span>
+<span class="sd">    &#39;&#39;&#39;</span>
+    <span class="k">if</span> <span class="ow">not</span> <span class="n">pars</span><span class="p">:</span>
+        <span class="k">return</span> <span class="p">[]</span>
+    <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">pars</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
+        <span class="n">pars</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">pars</span><span class="p">)</span>
+
+    <span class="n">cpar</span> <span class="o">=</span> <span class="n">pars</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)</span>
+    <span class="n">spar</span> <span class="o">=</span> <span class="p">[]</span>
+    <span class="k">for</span> <span class="n">par</span> <span class="ow">in</span> <span class="n">cpar</span><span class="p">:</span>
+        <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">iteritems</span><span class="p">():</span>
+            <span class="k">if</span> <span class="n">par</span> <span class="o">==</span> <span class="n">k</span> <span class="ow">or</span> <span class="n">par</span> <span class="o">==</span> <span class="n">v</span><span class="p">:</span>
+                <span class="n">spar</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span> <span class="o">+</span> <span class="s1">&#39;.128&#39;</span><span class="p">)</span>
+                <span class="k">break</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n\n\t\t</span><span class="s1">Warning: par &#39;</span> <span class="o">+</span> <span class="n">par</span> <span class="o">+</span> <span class="s1">&#39; not found in table 128</span><span class="se">\n\n</span><span class="s1">&#39;</span><span class="p">)</span>
+
+    <span class="k">return</span> <span class="s1">&#39;/&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">spar</span><span class="p">)</span></div>
 
 <div class="viewcode-block" id="get_list_as_string"><a class="viewcode-back" href="../api.html#tools.get_list_as_string">[docs]</a><span class="k">def</span> <span class="nf">get_list_as_string</span><span class="p">(</span><span class="n">list_obj</span><span class="p">,</span> <span class="n">concatenate_sign</span><span class="o">=</span><span class="s1">&#39;, &#39;</span><span class="p">):</span>
@@ -958,5 +1031,5 @@
   <div role="contentinfo">
     <p>
-        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger
+        &copy; Copyright 2018, Anne Philipp and Leopold Haimberger.
 
     </p>
@@ -977,11 +1050,19 @@
   
 
-    
-    
-      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
-        <script type="text/javascript" src="../_static/jquery.js"></script>
-        <script type="text/javascript" src="../_static/underscore.js"></script>
-        <script type="text/javascript" src="../_static/doctools.js"></script>
-    
+    <script type="text/javascript">
+        var DOCUMENTATION_OPTIONS = {
+            URL_ROOT:'../',
+            VERSION:'7.1 alpha',
+            LANGUAGE:'None',
+            COLLAPSE_INDEX:false,
+            FILE_SUFFIX:'.html',
+            HAS_SOURCE:  true,
+            SOURCELINK_SUFFIX: '.txt'
+        };
+    </script>
+      <script type="text/javascript" src="../_static/jquery.js"></script>
+      <script type="text/javascript" src="../_static/underscore.js"></script>
+      <script type="text/javascript" src="../_static/doctools.js"></script>
+      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
 
   
