Skip to content
Snippets Groups Projects
Commit 81c180c9 authored by Anne Tipka's avatar Anne Tipka :headphones:
Browse files

Merge branch current master branch from CTBTO's gitlab repo into dev branch from flexpart.eu repo

parents 6857073d 78963049
No related branches found
No related tags found
No related merge requests found
Showing
with 554 additions and 68 deletions
image: python:3.7-alpine
pages:
stage: deploy
script:
- cp -r Documentation/html public
artifacts:
paths:
- public
only:
- master
......@@ -2492,6 +2492,28 @@ command line.</p></li>
<div class="section" id="module-tools">
<span id="tools"></span><h3><a class="toc-backref" href="#id15">tools</a><a class="headerlink" href="#module-tools" title="Permalink to this headline"></a></h3>
<p>This module contains a collection of diverse tasks within flex_extract.</p>
<dl class="function">
<dt id="tools.check_for_string_in_file">
<code class="sig-prename descclassname">tools.</code><code class="sig-name descname">check_for_string_in_file</code><span class="sig-paren">(</span><em class="sig-param">filepath</em>, <em class="sig-param">search_string</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/tools.html#check_for_string_in_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#tools.check_for_string_in_file" title="Permalink to this definition"></a></dt>
<dd><p>Search for a specific string in a file and return True if
the string was found.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>filepath</strong> (<em>str</em>) – The full file path which is to be examined.</p></li>
<li><p><strong>search_string</strong> (<em>str</em>) – The string which is looked up for in the file.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>True : String was found
False : String was not found</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>Boolean</p>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="tools.clean_up">
<code class="sig-prename descclassname">tools.</code><code class="sig-name descname">clean_up</code><span class="sig-paren">(</span><em class="sig-param">c</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/tools.html#clean_up"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#tools.clean_up" title="Permalink to this definition"></a></dt>
......@@ -2735,6 +2757,21 @@ then the Python type None is returned, otherwise the string itself.</p>
</dl>
</dd></dl>
<dl class="function">
<dt id="tools.overwrite_lines_in_file">
<code class="sig-prename descclassname">tools.</code><code class="sig-name descname">overwrite_lines_in_file</code><span class="sig-paren">(</span><em class="sig-param">filepath</em>, <em class="sig-param">search_string</em>, <em class="sig-param">sub_string</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/tools.html#overwrite_lines_in_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#tools.overwrite_lines_in_file" title="Permalink to this definition"></a></dt>
<dd><p>Overwrites lines which contain the given search string with the
substitution string.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>search_string</strong> (<em>str</em>) – The string which is looked up for in the file.</p></li>
<li><p><strong>sub_string</strong> (<em>str</em>) – The string which overwrites the search string.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="tools.product">
<code class="sig-prename descclassname">tools.</code><code class="sig-name descname">product</code><span class="sig-paren">(</span><em class="sig-param">*args</em>, <em class="sig-param">**kwds</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/tools.html#product"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#tools.product" title="Permalink to this definition"></a></dt>
......
......@@ -234,9 +234,9 @@ It calls the top-level Python script <code class="docutils literal notranslate">
<tbody>
<tr class="row-even"><td><p>TARGET</p></td>
<td><p>String</p></td>
<td><p>local, ecgate, cca, ccb</p></td>
<td><p>local, syslocal, ecgate, cca, ccb</p></td>
<td><p>None</p></td>
<td><p>Defines the flex_extract application mode to be used. Local = local mode; ecgate = Remote or Gateway mode, cca or ccb = Remote or Gateway mode (HPC). Whether the local mode is for public or member state users doesn’t matter here.</p></td>
<td><p>Defines the flex_extract application mode to be used. Local = local mode; ecgate = Remote or Gateway mode, cca or ccb = Remote or Gateway mode (HPC). Whether the local mode is for public or member state users doesn’t matter here. Syslocal = seperates the executables and user application files during installation. Paths are selectable through INSTALLDIR and SYSINSTALLDIR</p></td>
</tr>
<tr class="row-odd"><td><p>MAKEFILE</p></td>
<td><p>String</p></td>
......@@ -274,13 +274,19 @@ It calls the top-level Python script <code class="docutils literal notranslate">
<td><p>$HOME on ECMWF server and current flex_extract root path on local machine</p></td>
<td><p>Root path where flex_extract should be installed. It will always be $HOME on ECMWF servers and if not set for the local mode, it will be the current flex_extract root path on local servers. </p></td>
</tr>
<tr class="row-odd"><td><p>JOB_TEMPLATE</p></td>
<tr class="row-odd"><td><p>SYSINSTALLDIR</p></td>
<td><p>String</p></td>
<td><p>a full path </p></td>
<td><p>None</p></td>
<td><p>This will be the same as INSTALLDIR if TARGET=local. Otherwise, the executable files are stored in this path. If it is choosen to be in a system path, don’t forget to start the script with admin rights. </p></td>
</tr>
<tr class="row-even"><td><p>JOB_TEMPLATE</p></td>
<td><p>String</p></td>
<td><p>installscript.template</p></td>
<td><p>installscript.template</p></td>
<td><p>The rudimentary template file to create a batch job template for submission to ECMWF servers. Should not be changed because it is already optimised for ECMWF servers. (Remote and Gateway mode)</p></td>
</tr>
<tr class="row-even"><td><p>CONTROLFILE</p></td>
<tr class="row-odd"><td><p>CONTROLFILE</p></td>
<td><p>String</p></td>
<td><p>any CONTROL file</p></td>
<td><p>CONTROL_EA5</p></td>
......@@ -401,6 +407,7 @@ we see again all possible command line parameters.</p>
usage: install.py <span class="o">[</span>-h<span class="o">]</span> <span class="o">[</span>--target INSTALL_TARGET<span class="o">]</span> <span class="o">[</span>--makefile MAKEFILE<span class="o">]</span>
<span class="o">[</span>--ecuid ECUID<span class="o">]</span> <span class="o">[</span>--ecgid ECGID<span class="o">]</span> <span class="o">[</span>--gateway GATEWAY<span class="o">]</span>
<span class="o">[</span>--destination DESTINATION<span class="o">]</span> <span class="o">[</span>--installdir INSTALLDIR<span class="o">]</span>
<span class="o">[</span>--sysinstalldir SYSINSTALLDIR<span class="o">]</span>
<span class="o">[</span>--job_template JOB_TEMPLATE<span class="o">]</span> <span class="o">[</span>--controlfile CONTROLFILE<span class="o">]</span>
Install flex_extract software locally or on ECMWF machines
......@@ -408,7 +415,7 @@ Install flex_extract software locally or on ECMWF machines
optional arguments:
-h, --help show this <span class="nb">help</span> message and <span class="nb">exit</span>
--target INSTALL_TARGET
Valid targets: <span class="nb">local</span> <span class="p">|</span> ecgate <span class="p">|</span> cca , the latter two
Valid targets: syslocal <span class="p">|</span> <span class="nb">local</span> <span class="p">|</span> ecgate <span class="p">|</span> cca , the latter two
are at ECMWF <span class="o">(</span>default: None<span class="o">)</span>
--makefile MAKEFILE Name of makefile to compile the Fortran
code. <span class="o">(</span>default depends on <span class="sb">`</span>target<span class="sb">`</span>: <span class="nb">local</span> - makefile_local_gfortran,
......@@ -422,6 +429,9 @@ optional arguments:
--installdir INSTALLDIR
Root directory where flex_extract will be installed
to. <span class="o">(</span>default: None<span class="o">)</span>
--sysinstalldir SYSINSTALLDIR
System installation path<span class="p">;</span> where executables are
stored. <span class="o">(</span>default: None<span class="o">)</span>
--job_template JOB_TEMPLATE
The rudimentary template file to create a batch job
template <span class="k">for</span> submission to ECMWF servers. <span class="o">(</span>default:
......
......@@ -103,6 +103,7 @@
<li class="toctree-l4"><a class="reference internal" href="#preparing-the-local-environment">Preparing the local environment</a></li>
<li class="toctree-l4"><a class="reference internal" href="#testing-the-local-environment">Testing the local environment</a></li>
<li class="toctree-l4"><a class="reference internal" href="#local-installation">Local installation</a></li>
<li class="toctree-l4"><a class="reference internal" href="#local-system-installation">Local system installation</a></li>
</ul>
</li>
</ul>
......@@ -394,14 +395,14 @@ and then install the <code class="docutils literal notranslate"><span class="pre
<span id="ref-install-local"></span><h2>Local installation<a class="headerlink" href="#local-installation" title="Permalink to this headline"></a></h2>
<p>The Fortran program called <code class="docutils literal notranslate"><span class="pre">calc_etadot</span></code> will be compiled during the
installation process. A suitable makefile (<code class="docutils literal notranslate"><span class="pre">makefile_local_gfortran</span></code>) for the compilation is set by default.
This may be overwritten by the <code class="docutils literal notranslate"><span class="pre">MAKEFILE</span></code> parameter in <code class="docutils literal notranslate"><span class="pre">setup.sh</span></code>.</p>
<p>However, you may have to adapt the makefile for your environment (the current default makefile works on Debian stretch and similar GNU/Linux distributions). If you use a new name for it, you will have to insert it into <code class="docutils literal notranslate"><span class="pre">setup.sh</span></code>
This may be overwritten by the <code class="docutils literal notranslate"><span class="pre">MAKEFILE</span></code> parameter in <code class="docutils literal notranslate"><span class="pre">setup_local.sh</span></code>.</p>
<p>However, you may have to adapt the makefile for your environment (the current default makefile works on Debian stretch and similar GNU/Linux distributions). If you use a new name for it, you will have to insert it into <code class="docutils literal notranslate"><span class="pre">setup_local.sh</span></code>
For details on the makefile and how to adapt them, see <a class="reference internal" href="../Documentation/Input/fortran_makefile.html#ref-convert"><span class="std std-ref">Fortran Makefile</span></a>.</p>
<p>In the root directory of <code class="docutils literal notranslate"><span class="pre">flex_extract</span></code>, open the <code class="docutils literal notranslate"><span class="pre">setup.sh</span></code> script
<p>In the root directory of <code class="docutils literal notranslate"><span class="pre">flex_extract</span></code>, open the <code class="docutils literal notranslate"><span class="pre">setup_local.sh</span></code> script
with an editor and adapt the installation parameters in the section labelled with
“AVAILABLE COMMANDLINE ARGUMENTS TO SET” as shown below:</p>
<div class="literal-block-wrapper docutils container" id="setup-sh">
<div class="code-block-caption"><span class="caption-text">‘Example settings for a local installation.’</span><a class="headerlink" href="#setup-sh" title="Permalink to this code"></a></div>
<div class="literal-block-wrapper docutils container" id="setup-local-sh">
<div class="code-block-caption"><span class="caption-text">‘Example settings for a local installation.’</span><a class="headerlink" href="#setup-local-sh" title="Permalink to this code"></a></div>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>...
<span class="c1"># -----------------------------------------------------------------</span>
<span class="c1"># AVAILABLE COMMANDLINE ARGUMENTS TO SET</span>
......@@ -415,6 +416,7 @@ with an editor and adapt the installation parameters in the section labelled wit
<span class="nv">GATEWAY</span><span class="o">=</span>None
<span class="nv">DESTINATION</span><span class="o">=</span>None
<span class="nv">INSTALLDIR</span><span class="o">=</span>None
<span class="nv">SYSINSTALLDIR</span><span class="o">=</span>None
<span class="nv">JOB_TEMPLATE</span><span class="o">=</span><span class="s1">&#39;&#39;</span>
<span class="nv">CONTROLFILE</span><span class="o">=</span><span class="s1">&#39;CONTROL_EA5&#39;</span>
...
......@@ -422,11 +424,11 @@ with an editor and adapt the installation parameters in the section labelled wit
</div>
</div>
<p>Afterwards, type:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ ./setup.sh
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ ./setup_local.sh
</pre></div>
</div>
<p>to start the installation. You should see the following standard output.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># Output of setup.sh</span>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># Output of setup_local.sh</span>
WARNING: installdir has not been specified
flex_extract will be installed in here by compiling the Fortran <span class="nb">source</span> in &lt;path-to-flex_extract&gt;/flex_extract_v7.1/Source/Fortran
Install flex_extract_v7.1 software at <span class="nb">local</span> in directory &lt;path-to-flex_extract&gt;/flex_extract_v7.1
......@@ -445,6 +447,58 @@ lrwxrwxrwx. <span class="m">1</span> &lt;username&gt; tmc <span class="m">20</sp
</pre></div>
</div>
</div>
<div class="section" id="local-system-installation">
<h2>Local system installation<a class="headerlink" href="#local-system-installation" title="Permalink to this headline"></a></h2>
<p>There is also the possibility to separate the software executables from the user application files. For doing so, the <code class="docutils literal notranslate"><span class="pre">TARGET</span></code> parameter can be set to “syslocal” and the additional parameter <code class="docutils literal notranslate"><span class="pre">SYSINSTALLDIR</span></code> in the <code class="docutils literal notranslate"><span class="pre">setup_local.sh</span></code> has to be specified. This new path will contain the Fortran and Python executables of <code class="docutils literal notranslate"><span class="pre">flex_extract</span></code>. If you chose to set a system path for this, please start the script as root.
The user directory for <code class="docutils literal notranslate"><span class="pre">flex_extract</span></code>, which basically consists of everything except the <code class="docutils literal notranslate"><span class="pre">Source</span></code> directory, will be installed into <code class="docutils literal notranslate"><span class="pre">INSTALLDIR</span></code>.
In this installation mode, an extra (hidden) <code class="docutils literal notranslate"><span class="pre">.setup.rc</span></code> file will be generated in the <code class="docutils literal notranslate"><span class="pre">Run</span></code> directory. It contains the necessary settings for running the local system mode.</p>
<p>Despite the change in the <code class="docutils literal notranslate"><span class="pre">TARGET</span></code> parameter, the meaning of <code class="docutils literal notranslate"><span class="pre">INSTALLDIR</span></code> and the additional <code class="docutils literal notranslate"><span class="pre">SYSINSTALLDIR</span></code>, the steps for installation are the same as in the local installation mentioned above. For example, modify the <code class="docutils literal notranslate"><span class="pre">setup_local.sh</span></code> file as follows:</p>
<div class="literal-block-wrapper docutils container" id="id1">
<div class="code-block-caption"><span class="caption-text">‘Example settings for a local system installation.’</span><a class="headerlink" href="#id1" title="Permalink to this code"></a></div>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>...
<span class="c1"># -----------------------------------------------------------------</span>
<span class="c1"># AVAILABLE COMMANDLINE ARGUMENTS TO SET</span>
<span class="c1">#</span>
<span class="c1"># THE USER HAS TO SPECIFY THESE PARAMETER</span>
<span class="c1">#</span>
<span class="nv">TARGET</span><span class="o">=</span><span class="s1">&#39;syslocal&#39;</span>
<span class="nv">MAKEFILE</span><span class="o">=</span>&lt;name_of_your_makefile&gt;
<span class="nv">ECUID</span><span class="o">=</span>None
<span class="nv">ECGID</span><span class="o">=</span>None
<span class="nv">GATEWAY</span><span class="o">=</span>None
<span class="nv">DESTINATION</span><span class="o">=</span>None
<span class="nv">INSTALLDIR</span><span class="o">=</span><span class="nv">$HOME</span>
<span class="nv">SYSINSTALLDIR</span><span class="o">=</span>/usr/bin/
<span class="nv">JOB_TEMPLATE</span><span class="o">=</span><span class="s1">&#39;&#39;</span>
<span class="nv">CONTROLFILE</span><span class="o">=</span><span class="s1">&#39;CONTROL_EA5&#39;</span>
...
</pre></div>
</div>
</div>
<p>Afterwards, type:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ sudo ./setup_local.sh
</pre></div>
</div>
<p>to start the installation. You should see the following standard output.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>Flex_extract will be installed in &lt;<span class="nv">$HOME</span>&gt;
Install flex_extract_v7.1.2 software as syslocal in directory /usr/bin/flex_extract_v7.1.2
Using makefile: makefile_local_gfortran
/usr/local/bin/gfortran -O3 -march<span class="o">=</span>native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert<span class="o">=</span>big-endian -c ./rwgrib2.f90
/usr/local/bin/gfortran -O3 -march<span class="o">=</span>native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert<span class="o">=</span>big-endian -c ./phgrreal.f90
/usr/local/bin/gfortran -O3 -march<span class="o">=</span>native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert<span class="o">=</span>big-endian -c ./grphreal.f90
/usr/local/bin/gfortran -O3 -march<span class="o">=</span>native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert<span class="o">=</span>big-endian -c ./ftrafo.f90
/usr/local/bin/gfortran -O3 -march<span class="o">=</span>native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert<span class="o">=</span>big-endian -c ./calc_etadot.f90
/usr/local/bin/gfortran -O3 -march<span class="o">=</span>native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert<span class="o">=</span>big-endian -c ./posnam.f90
/usr/local/bin/gfortran rwgrib2.o calc_etadot.o ftrafo.o grphreal.o posnam.o phgrreal.o -o calc_etadot_fast.out -O3 -march<span class="o">=</span>native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -fopenmp
ln -sf calc_etadot_fast.out calc_etadot
lrwxrwxrwx. <span class="m">1</span> &lt;username&gt; tmc <span class="m">20</span> <span class="m">27</span>. Okt <span class="m">23</span>:25 ./calc_etadot -&gt; calc_etadot_fast.out
SUCCESS: INSTALLATION FINISHED!
</pre></div>
</div>
<p>You can now change into the user directory specified in <code class="docutils literal notranslate"><span class="pre">INSTALLDIR</span></code> and find a <code class="docutils literal notranslate"><span class="pre">flex_extract_vX.X</span></code> directory there.</p>
</div>
</div>
......
......@@ -182,6 +182,8 @@
<span class="c1"># - outsourced the commandline argument assignments to control attributes</span>
<span class="c1"># June 2020 - Anne Philipp</span>
<span class="c1"># - update default makefile to None</span>
<span class="c1"># August 2020 - Leopold Haimberger</span>
<span class="c1"># - added a class parameter for system installation path</span>
<span class="c1">#</span>
<span class="c1"># @License:</span>
<span class="c1"># (C) Copyright 2014-2020.</span>
......@@ -565,6 +567,7 @@
<span class="bp">self</span><span class="o">.</span><span class="n">flexextractdir</span> <span class="o">=</span> <span class="n">_config</span><span class="o">.</span><span class="n">PATH_FLEXEXTRACT_DIR</span>
<span class="bp">self</span><span class="o">.</span><span class="n">exedir</span> <span class="o">=</span> <span class="n">_config</span><span class="o">.</span><span class="n">PATH_FORTRAN_SRC</span>
<span class="bp">self</span><span class="o">.</span><span class="n">installdir</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">sysinstalldir</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">makefile</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">destination</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">gateway</span> <span class="o">=</span> <span class="kc">None</span>
......
This diff is collapsed.
......@@ -275,7 +275,7 @@
<span class="c1"># send files to ECMWF server</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">submit</span><span class="p">(</span><span class="n">job_template</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">queue</span><span class="p">)</span>
<span class="n">exit_message</span> <span class="o">=</span> <span class="s1">&#39;FLEX_EXTRACT JOB SCRIPT IS SUBMITED!&#39;</span>
<span class="n">exit_message</span> <span class="o">=</span> <span class="s1">&#39;FLEX_EXTRACT JOB SCRIPT IS SUBMITTED!&#39;</span>
<span class="n">normal_exit</span><span class="p">(</span><span class="n">exit_message</span><span class="p">)</span>
......
......@@ -184,6 +184,10 @@
<span class="c1"># put_file_to_ecserver, submit_job_to_ecserver, get_informations,</span>
<span class="c1"># get_dimensions, execute_subprocess, none_or_int, none_or_str</span>
<span class="c1">#</span>
<span class="c1"># August 2020 - Leopold Haimberger (University of Vienna)</span>
<span class="c1"># - added function to check if a specific string is in a file</span>
<span class="c1"># - added function to overwrite lines in a file which contain specific string</span>
<span class="c1">#</span>
<span class="c1"># @License:</span>
<span class="c1"># (C) Copyright 2014-2020.</span>
<span class="c1"># Anne Philipp, Leopold Haimberger</span>
......@@ -1071,6 +1075,62 @@
<span class="k">return</span> <span class="n">start_period</span><span class="p">,</span> <span class="n">end_period</span></div>
<div class="viewcode-block" id="check_for_string_in_file"><a class="viewcode-back" href="../Documentation/Api/api_python.html#tools.check_for_string_in_file">[docs]</a><span class="k">def</span> <span class="nf">check_for_string_in_file</span><span class="p">(</span><span class="n">filepath</span><span class="p">,</span> <span class="n">search_string</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Search for a specific string in a file and return True if</span>
<span class="sd"> the string was found.</span>
<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> filepath : str</span>
<span class="sd"> The full file path which is to be examined.</span>
<span class="sd"> search_string : str</span>
<span class="sd"> The string which is looked up for in the file.</span>
<span class="sd"> Return</span>
<span class="sd"> ------</span>
<span class="sd"> Boolean :</span>
<span class="sd"> True : String was found</span>
<span class="sd"> False : String was not found</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">filepath</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fio</span><span class="p">:</span>
<span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">fio</span><span class="p">:</span>
<span class="k">if</span> <span class="n">search_string</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">True</span>
<span class="k">return</span> <span class="kc">False</span></div>
<div class="viewcode-block" id="overwrite_lines_in_file"><a class="viewcode-back" href="../Documentation/Api/api_python.html#tools.overwrite_lines_in_file">[docs]</a><span class="k">def</span> <span class="nf">overwrite_lines_in_file</span><span class="p">(</span><span class="n">filepath</span><span class="p">,</span> <span class="n">search_string</span><span class="p">,</span> <span class="n">sub_string</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Overwrites lines which contain the given search string with the</span>
<span class="sd"> substitution string.</span>
<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> search_string : str</span>
<span class="sd"> The string which is looked up for in the file.</span>
<span class="sd"> sub_string : str</span>
<span class="sd"> The string which overwrites the search string.</span>
<span class="sd"> Return</span>
<span class="sd"> ------</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">filepath</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fio</span><span class="p">:</span>
<span class="n">data</span> <span class="o">=</span> <span class="n">fio</span><span class="o">.</span><span class="n">readlines</span><span class="p">()</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">filepath</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fio</span><span class="p">:</span>
<span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
<span class="k">if</span> <span class="n">search_string</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
<span class="n">fio</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">sub_string</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">fio</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
<span class="k">return</span></div>
</pre></div>
</div>
......
......@@ -164,6 +164,7 @@ we see again all possible command line parameters.
usage: install.py [-h] [--target INSTALL_TARGET] [--makefile MAKEFILE]
[--ecuid ECUID] [--ecgid ECGID] [--gateway GATEWAY]
[--destination DESTINATION] [--installdir INSTALLDIR]
[--sysinstalldir SYSINSTALLDIR]
[--job_template JOB_TEMPLATE] [--controlfile CONTROLFILE]
Install flex_extract software locally or on ECMWF machines
......@@ -171,7 +172,7 @@ we see again all possible command line parameters.
optional arguments:
-h, --help show this help message and exit
--target INSTALL_TARGET
Valid targets: local | ecgate | cca , the latter two
Valid targets: syslocal | local | ecgate | cca , the latter two
are at ECMWF (default: None)
--makefile MAKEFILE Name of makefile to compile the Fortran
code. (default depends on `target`: local - makefile_local_gfortran,
......@@ -185,6 +186,9 @@ we see again all possible command line parameters.
--installdir INSTALLDIR
Root directory where flex_extract will be installed
to. (default: None)
--sysinstalldir SYSINSTALLDIR
System installation path; where executables are
stored. (default: None)
--job_template JOB_TEMPLATE
The rudimentary template file to create a batch job
template for submission to ECMWF servers. (default:
......@@ -197,6 +201,7 @@ we see again all possible command line parameters.
.. toctree::
:hidden:
:maxdepth: 2
......@@ -265,20 +265,20 @@ Local installation
The Fortran program called ``calc_etadot`` will be compiled during the
installation process. A suitable makefile (``makefile_local_gfortran``) for the compilation is set by default.
This may be overwritten by the ``MAKEFILE`` parameter in ``setup.sh``.
This may be overwritten by the ``MAKEFILE`` parameter in ``setup_local.sh``.
However, you may have to adapt the makefile for your environment (the current default makefile works on Debian stretch and similar GNU/Linux distributions). If you use a new name for it, you will have to insert it into ``setup.sh``
However, you may have to adapt the makefile for your environment (the current default makefile works on Debian stretch and similar GNU/Linux distributions). If you use a new name for it, you will have to insert it into ``setup_local.sh``
For details on the makefile and how to adapt them, see :ref:`Fortran Makefile <ref-convert>`.
In the root directory of ``flex_extract``, open the ``setup.sh`` script
In the root directory of ``flex_extract``, open the ``setup_local.sh`` script
with an editor and adapt the installation parameters in the section labelled with
"AVAILABLE COMMANDLINE ARGUMENTS TO SET" as shown below:
.. code-block:: bash
:caption: 'Example settings for a local installation.'
:name: setup.sh
:name: setup_local.sh
...
# -----------------------------------------------------------------
......@@ -293,6 +293,7 @@ with an editor and adapt the installation parameters in the section labelled wit
GATEWAY=None
DESTINATION=None
INSTALLDIR=None
SYSINSTALLDIR=None
JOB_TEMPLATE=''
CONTROLFILE='CONTROL_EA5'
...
......@@ -302,14 +303,14 @@ Afterwards, type:
.. code-block:: bash
$ ./setup.sh
$ ./setup_local.sh
to start the installation. You should see the following standard output.
.. code-block:: bash
# Output of setup.sh
# Output of setup_local.sh
WARNING: installdir has not been specified
flex_extract will be installed in here by compiling the Fortran source in <path-to-flex_extract>/flex_extract_v7.1/Source/Fortran
Install flex_extract_v7.1 software at local in directory <path-to-flex_extract>/flex_extract_v7.1
......@@ -326,3 +327,65 @@ to start the installation. You should see the following standard output.
lrwxrwxrwx. 1 <username> tmc 20 Aug 12 10:59 ./calc_etadot -> calc_etadot_fast.out
Local system installation
=========================
There is also the possibility to separate the software executables from the user application files. For doing so, the ``TARGET`` parameter can be set to "syslocal" and the additional parameter ``SYSINSTALLDIR`` in the ``setup_local.sh`` has to be specified. This new path will contain the Fortran and Python executables of ``flex_extract``. If you chose to set a system path for this, please start the script as root.
The user directory for ``flex_extract``, which basically consists of everything except the ``Source`` directory, will be installed into ``INSTALLDIR``.
In this installation mode, an extra (hidden) ``.setup.rc`` file will be generated in the ``Run`` directory. It contains the necessary settings for running the local system mode.
Despite the change in the ``TARGET`` parameter, the meaning of ``INSTALLDIR`` and the additional ``SYSINSTALLDIR``, the steps for installation are the same as in the local installation mentioned above. For example, modify the ``setup_local.sh`` file as follows:
.. code-block:: bash
:caption: 'Example settings for a local system installation.'
:name: setup_local.sh
...
# -----------------------------------------------------------------
# AVAILABLE COMMANDLINE ARGUMENTS TO SET
#
# THE USER HAS TO SPECIFY THESE PARAMETER
#
TARGET='syslocal'
MAKEFILE=<name_of_your_makefile>
ECUID=None
ECGID=None
GATEWAY=None
DESTINATION=None
INSTALLDIR=$HOME
SYSINSTALLDIR=/usr/bin/
JOB_TEMPLATE=''
CONTROLFILE='CONTROL_EA5'
...
Afterwards, type:
.. code-block:: bash
$ sudo ./setup_local.sh
to start the installation. You should see the following standard output.
.. code-block:: bash
Flex_extract will be installed in <$HOME>
Install flex_extract_v7.1.2 software as syslocal in directory /usr/bin/flex_extract_v7.1.2
Using makefile: makefile_local_gfortran
/usr/local/bin/gfortran -O3 -march=native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert=big-endian -c ./rwgrib2.f90
/usr/local/bin/gfortran -O3 -march=native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert=big-endian -c ./phgrreal.f90
/usr/local/bin/gfortran -O3 -march=native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert=big-endian -c ./grphreal.f90
/usr/local/bin/gfortran -O3 -march=native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert=big-endian -c ./ftrafo.f90
/usr/local/bin/gfortran -O3 -march=native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert=big-endian -c ./calc_etadot.f90
/usr/local/bin/gfortran -O3 -march=native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert=big-endian -c ./posnam.f90
/usr/local/bin/gfortran rwgrib2.o calc_etadot.o ftrafo.o grphreal.o posnam.o phgrreal.o -o calc_etadot_fast.out -O3 -march=native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -fopenmp
ln -sf calc_etadot_fast.out calc_etadot
lrwxrwxrwx. 1 <username> tmc 20 27. Okt 23:25 ./calc_etadot -> calc_etadot_fast.out
SUCCESS: INSTALLATION FINISHED!
You can now change into the user directory specified in ``INSTALLDIR`` and find a ``flex_extract_vX.X`` directory there.
......@@ -272,6 +272,8 @@
<li><a href="Documentation/Api/api_python.html#checks.check_dates">check_dates() (in module checks)</a>
</li>
<li><a href="Documentation/Api/api_python.html#get_mars_data.check_dates_for_nonflux_fc_times">check_dates_for_nonflux_fc_times() (in module get_mars_data)</a>
</li>
<li><a href="Documentation/Api/api_python.html#tools.check_for_string_in_file">check_for_string_in_file() (in module tools)</a>
</li>
<li><a href="Documentation/Api/api_python.html#checks.check_grid">check_grid() (in module checks)</a>
</li>
......@@ -649,13 +651,15 @@
</li>
<li><a href="Documentation/Api/api_python.html#ControlFile.ControlFile.omegadiff">omegadiff (ControlFile.ControlFile attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="Documentation/Api/api_python.html#ControlFile.ControlFile.oper">oper (ControlFile.ControlFile attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="Documentation/Api/api_python.html#ControlFile.ControlFile.outputdir">outputdir (ControlFile.ControlFile attribute)</a>
</li>
<li><a href="Documentation/Api/api_python.html#EcFlexpart.EcFlexpart.outputfilelist">outputfilelist (EcFlexpart.EcFlexpart attribute)</a>
</li>
<li><a href="Documentation/Api/api_python.html#tools.overwrite_lines_in_file">overwrite_lines_in_file() (in module tools)</a>
</li>
</ul></td>
</tr></table>
......
No preview for this file type
This diff is collapsed.
No preview for this file type
......@@ -164,6 +164,7 @@ we see again all possible command line parameters.
usage: install.py [-h] [--target INSTALL_TARGET] [--makefile MAKEFILE]
[--ecuid ECUID] [--ecgid ECGID] [--gateway GATEWAY]
[--destination DESTINATION] [--installdir INSTALLDIR]
[--sysinstalldir SYSINSTALLDIR]
[--job_template JOB_TEMPLATE] [--controlfile CONTROLFILE]
Install flex_extract software locally or on ECMWF machines
......@@ -171,7 +172,7 @@ we see again all possible command line parameters.
optional arguments:
-h, --help show this help message and exit
--target INSTALL_TARGET
Valid targets: local | ecgate | cca , the latter two
Valid targets: syslocal | local | ecgate | cca , the latter two
are at ECMWF (default: None)
--makefile MAKEFILE Name of makefile to compile the Fortran
code. (default depends on `target`: local - makefile_local_gfortran,
......@@ -185,6 +186,9 @@ we see again all possible command line parameters.
--installdir INSTALLDIR
Root directory where flex_extract will be installed
to. (default: None)
--sysinstalldir SYSINSTALLDIR
System installation path; where executables are
stored. (default: None)
--job_template JOB_TEMPLATE
The rudimentary template file to create a batch job
template for submission to ECMWF servers. (default:
......@@ -197,6 +201,7 @@ we see again all possible command line parameters.
.. toctree::
:hidden:
:maxdepth: 2
......@@ -265,20 +265,20 @@ Local installation
The Fortran program called ``calc_etadot`` will be compiled during the
installation process. A suitable makefile (``makefile_local_gfortran``) for the compilation is set by default.
This may be overwritten by the ``MAKEFILE`` parameter in ``setup.sh``.
This may be overwritten by the ``MAKEFILE`` parameter in ``setup_local.sh``.
However, you may have to adapt the makefile for your environment (the current default makefile works on Debian stretch and similar GNU/Linux distributions). If you use a new name for it, you will have to insert it into ``setup.sh``
However, you may have to adapt the makefile for your environment (the current default makefile works on Debian stretch and similar GNU/Linux distributions). If you use a new name for it, you will have to insert it into ``setup_local.sh``
For details on the makefile and how to adapt them, see :ref:`Fortran Makefile <ref-convert>`.
In the root directory of ``flex_extract``, open the ``setup.sh`` script
In the root directory of ``flex_extract``, open the ``setup_local.sh`` script
with an editor and adapt the installation parameters in the section labelled with
"AVAILABLE COMMANDLINE ARGUMENTS TO SET" as shown below:
.. code-block:: bash
:caption: 'Example settings for a local installation.'
:name: setup.sh
:name: setup_local.sh
...
# -----------------------------------------------------------------
......@@ -293,6 +293,7 @@ with an editor and adapt the installation parameters in the section labelled wit
GATEWAY=None
DESTINATION=None
INSTALLDIR=None
SYSINSTALLDIR=None
JOB_TEMPLATE=''
CONTROLFILE='CONTROL_EA5'
...
......@@ -302,14 +303,14 @@ Afterwards, type:
.. code-block:: bash
$ ./setup.sh
$ ./setup_local.sh
to start the installation. You should see the following standard output.
.. code-block:: bash
# Output of setup.sh
# Output of setup_local.sh
WARNING: installdir has not been specified
flex_extract will be installed in here by compiling the Fortran source in <path-to-flex_extract>/flex_extract_v7.1/Source/Fortran
Install flex_extract_v7.1 software at local in directory <path-to-flex_extract>/flex_extract_v7.1
......@@ -326,3 +327,65 @@ to start the installation. You should see the following standard output.
lrwxrwxrwx. 1 <username> tmc 20 Aug 12 10:59 ./calc_etadot -> calc_etadot_fast.out
Local system installation
=========================
There is also the possibility to separate the software executables from the user application files. For doing so, the ``TARGET`` parameter can be set to "syslocal" and the additional parameter ``SYSINSTALLDIR`` in the ``setup_local.sh`` has to be specified. This new path will contain the Fortran and Python executables of ``flex_extract``. If you chose to set a system path for this, please start the script as root.
The user directory for ``flex_extract``, which basically consists of everything except the ``Source`` directory, will be installed into ``INSTALLDIR``.
In this installation mode, an extra (hidden) ``.setup.rc`` file will be generated in the ``Run`` directory. It contains the necessary settings for running the local system mode.
Despite the change in the ``TARGET`` parameter, the meaning of ``INSTALLDIR`` and the additional ``SYSINSTALLDIR``, the steps for installation are the same as in the local installation mentioned above. For example, modify the ``setup_local.sh`` file as follows:
.. code-block:: bash
:caption: 'Example settings for a local system installation.'
:name: setup_local.sh
...
# -----------------------------------------------------------------
# AVAILABLE COMMANDLINE ARGUMENTS TO SET
#
# THE USER HAS TO SPECIFY THESE PARAMETER
#
TARGET='syslocal'
MAKEFILE=<name_of_your_makefile>
ECUID=None
ECGID=None
GATEWAY=None
DESTINATION=None
INSTALLDIR=$HOME
SYSINSTALLDIR=/usr/bin/
JOB_TEMPLATE=''
CONTROLFILE='CONTROL_EA5'
...
Afterwards, type:
.. code-block:: bash
$ sudo ./setup_local.sh
to start the installation. You should see the following standard output.
.. code-block:: bash
Flex_extract will be installed in <$HOME>
Install flex_extract_v7.1.2 software as syslocal in directory /usr/bin/flex_extract_v7.1.2
Using makefile: makefile_local_gfortran
/usr/local/bin/gfortran -O3 -march=native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert=big-endian -c ./rwgrib2.f90
/usr/local/bin/gfortran -O3 -march=native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert=big-endian -c ./phgrreal.f90
/usr/local/bin/gfortran -O3 -march=native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert=big-endian -c ./grphreal.f90
/usr/local/bin/gfortran -O3 -march=native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert=big-endian -c ./ftrafo.f90
/usr/local/bin/gfortran -O3 -march=native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert=big-endian -c ./calc_etadot.f90
/usr/local/bin/gfortran -O3 -march=native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -I. -I/usr/local/include/ -fdefault-real-8 -fopenmp -fconvert=big-endian -c ./posnam.f90
/usr/local/bin/gfortran rwgrib2.o calc_etadot.o ftrafo.o grphreal.o posnam.o phgrreal.o -o calc_etadot_fast.out -O3 -march=native -L/usr/local/lib64/ -leccodes_f90 -leccodes -lm -lemosR64 -fopenmp
ln -sf calc_etadot_fast.out calc_etadot
lrwxrwxrwx. 1 <username> tmc 20 27. Okt 23:25 ./calc_etadot -> calc_etadot_fast.out
SUCCESS: INSTALLATION FINISHED!
You can now change into the user directory specified in ``INSTALLDIR`` and find a ``flex_extract_vX.X`` directory there.
......@@ -2,7 +2,7 @@
`flex_extract` is a software package to support retrieving meteorological fields from the European Centre for Medium-Range Weather Forecasts' (ECMWF) Meteorological Archival and Retrieval System (MARS) as input for the `FLEXTRA`/`FLEXPART` Atmospheric Transport Modelling system.
`FLEXPART` (FLEXible PARTicle dispersion model, http://flexpart.eu) is a Lagrangian transport and dispersion model suitable for the simulation of a large range of atmospheric transport processes.
`FLEXPART` ("FLEXible PARTicle dispersion model", http://flexpart.eu) is a Lagrangian transport and dispersion model suitable for the simulation of a large range of atmospheric transport processes.
## Installation and Usage
......@@ -16,10 +16,10 @@ https://www.flexpart.eu/wiki/FpInputMetEcmwf
## Authors
Anne Philipp, Leopold Haimberger and Petra Seibert
Anne Tipka (formerly Philipp), Leopold Haimberger and Petra Seibert
## License
(C) Copyright 2014-2019.
(C) Copyright 2014-2020.
SPDX-License-Identifier: CC-BY-4.0
......@@ -27,3 +27,4 @@ Anne Philipp, Leopold Haimberger and Petra Seibert
International License. To view a copy of this license, visit
http://creativecommons.org/licenses/by/4.0/ or send a letter to
Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
......@@ -11,7 +11,7 @@
# guarantee necessary parameters were set and consistent.
#
# @Licence:
# (C) Copyright 2014-2019.
# (C) Copyright 2014-2020.
#
# SPDX-License-Identifier: CC-BY-4.0
#
......
......@@ -20,6 +20,8 @@
# - outsourced the commandline argument assignments to control attributes
# June 2020 - Anne Philipp
# - update default makefile to None
# August 2020 - Leopold Haimberger
# - added a class parameter for system installation path
#
# @License:
# (C) Copyright 2014-2020.
......@@ -403,6 +405,7 @@ class ControlFile(object):
self.flexextractdir = _config.PATH_FLEXEXTRACT_DIR
self.exedir = _config.PATH_FORTRAN_SRC
self.installdir = None
self.sysinstalldir = None
self.makefile = None
self.destination = None
self.gateway = None
......
......@@ -22,6 +22,10 @@
# put_file_to_ecserver, submit_job_to_ecserver, get_informations,
# get_dimensions, execute_subprocess, none_or_int, none_or_str
#
# August 2020 - Leopold Haimberger (University of Vienna)
# - added function to check if a specific string is in a file
# - added function to overwrite lines in a file which contain specific string
#
# @License:
# (C) Copyright 2014-2020.
# Anne Philipp, Leopold Haimberger
......@@ -909,3 +913,59 @@ def generate_retrieval_period_boundary(c):
return start_period, end_period
def check_for_string_in_file(filepath, search_string):
"""
Search for a specific string in a file and return True if
the string was found.
Parameters
----------
filepath : str
The full file path which is to be examined.
search_string : str
The string which is looked up for in the file.
Return
------
Boolean :
True : String was found
False : String was not found
"""
with open(filepath, 'r') as fio:
for line in fio:
if search_string in line:
return True
return False
def overwrite_lines_in_file(filepath, search_string, sub_string):
"""
Overwrites lines which contain the given search string with the
substitution string.
Parameters
----------
search_string : str
The string which is looked up for in the file.
sub_string : str
The string which overwrites the search string.
Return
------
"""
with open(filepath, 'r') as fio:
data = fio.readlines()
with open(filepath, 'w') as fio:
for line in data:
if search_string in line:
fio.write(sub_string)
else:
fio.write(line)
return
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment