source: flex_extract.git/For_developers/Sphinx/source/Installation/local.rst @ f20342a

ctbtodev
Last change on this file since f20342a was f20342a, checked in by Petra Seibert <petra.seibert [at) univie.ac.at>, 4 years ago

Language corrections for the Sections Developers, Support, Changelog, and the home directory (index.html)

further improvment of documentation, close to final

  • Property mode set to 100644
File size: 15.3 KB
RevLine 
[30f7911]1***********************
2Local mode installation
3***********************
4
5.. role:: underline
6    :class: underline
7   
8.. toctree::
9    :hidden:
10    :maxdepth: 2
11         
12   
13.. _Python 3: https://docs.python.org/3/
14.. _Python3: https://www.python.org/downloads/
15.. _Anaconda Python3: https://www.anaconda.com/distribution/#download-section
16
17.. _numpy: http://www.numpy.org/
18.. _ecmwf-api-client: https://confluence.ecmwf.int/display/WEBAPI/ECMWF+Web+API+Home
19.. _cdsapi: https://cds.climate.copernicus.eu/api-how-to
20.. _genshi: https://genshi.edgewall.org/
21.. _eccodes for python: https://packages.debian.org/sid/python3-eccodes
22.. _eccodes for conda: https://anaconda.org/conda-forge/eccodes
23.. _gfortran: https://gcc.gnu.org/wiki/GFortran
24.. _fftw3: http://www.fftw.org
25.. _eccodes: https://software.ecmwf.int/wiki/display/ECC
26.. _emoslib: https://software.ecmwf.int/wiki/display/EMOS/Emoslib
27.. _member state: https://www.ecmwf.int/en/about/who-we-are/member-states
28.. _registration form: https://apps.ecmwf.int/registration/
29.. _CDS API registration: https://cds.climate.copernicus.eu/user/register
30.. _ECMWF ectrans site: https://confluence.ecmwf.int/display/ECAC/Unattended+file+transfer+-+ectrans
31.. _ECaccess Presentation: https://confluence.ecmwf.int/download/attachments/45759146/ECaccess.pdf
32.. _ECMWF's instructions on gateway server: https://confluence.ecmwf.int/display/ECAC/ECaccess+Home
33.. _Computing Representative: https://www.ecmwf.int/en/about/contact-us/computing-representatives
34.. _MARS access: https://confluence.ecmwf.int//display/WEBAPI/Access+MARS
35
36.. _download section: https://www.flexpart.eu/downloads
37
38 
39   
40   
41   
42.. _ref-local-mode:
43
44
45
46.. _ref-req-local: 
47 
48Local mode - dependencies
49=========================
50
51The installation is the same for the access modes **member** and **public**.
52
[f20342a]53The environment on your local system has to provide the following software packages
[30f7911]54and libraries, since the preparation of the extraction and the post-processing is done on the local machine:
55
[f20342a]56+-------------------------------------------------+-----------------+
57|  Python part                                    | Fortran part    |
58+-------------------------------------------------+-----------------+
59| 1. `Python3`_                                   | 1. `gfortran`_  |
60| 2. `numpy`_                                     | 2. `fftw3`_     |
61| 3. `genshi`_                                    | 3. `eccodes`_   |
62| 4. `eccodes for python`_                        | 4. `emoslib`_   |
63| 5. `ecmwf-api-client`_ (everything except ERA5) |                 |
64| 6. `cdsapi`_ (just for ERA5 and member user)    |                 |
65+-------------------------------------------------+-----------------+
[30f7911]66
67
68.. _ref-prep-local:
69
[f20342a]70Preparing the local environment
71===============================
[30f7911]72
[f20342a]73The easiest way to install all required packages is to use the package management system of your Linux distribution which requires admin rights.
[30f7911]74The installation was tested on a *Debian GNU/Linux buster* and an *Ubuntu 18.04 Bionic Beaver* system.
75
76.. code-block:: sh
77
[f20342a]78  # On a Debian or Debian-derived (e. g. Ubuntu) system,
79  # you may use the following commands (or equivalent commands of your preferred package manager):
80  # (if respective packages are not already available):
[30f7911]81   apt-get install python3 (usually already available on GNU/Linux systems)
82   apt-get install python3-eccodes
83   apt-get install python3-genshi
84   apt-get install python3-numpy
85   apt-get install gfortran
86   apt-get install fftw3-dev
87   apt-get install libeccodes-dev
88   apt-get install libemos-dev
[f20342a]89  # Some of these packages will pull in further packages as dependencies.
90  # This is fine, and some are even needed by ``flex_extract''.
[30f7911]91
[f20342a]92  # As currently the CDS and ECMWF API packages are not available as Debian packages,
93  # they need to be installed outside of the Debian (Ubuntu etc.) package management system.
94  # The recommended way is:
[30f7911]95   apt-get install pip
96   pip install cdsapi
97   pip install ecmwf-api-client
98   
99.. note::
100
[f20342a]101    If you are using Anaconda Python, we recommend to follow the installation instructions of
102    `Anaconda Python Installation for Linux <https://docs.anaconda.com/anaconda/install/linux/>`_ 
103    and then install the ``eccodes`` package from ``conda`` with:
[30f7911]104
105    .. code-block:: bash
106
107       conda install conda-forge::python-eccodes   
108   
[f20342a]109The CDS API (``cdsapi``) is required for ERA5 data and the ECMWF Web API (ecmwf-api-client) for all other public datasets.   
[30f7911]110   
111.. note:: 
112
[f20342a]113    Since **public users** currently don't have access to the full *ERA5* dataset, they can skip the installation of the CDS API.
[30f7911]114
[f20342a]115Both user groups have to provide keys with their credentials for the Web APIs in their home directory, following these instructions:
[30f7911]116       
117ECMWF Web API:
[f20342a]118   Go to the `MARS access`_ website and log in with your credentials. Afterwards, go to the section "Install ECMWF KEY", where the key for the ECMWF Web API should be listed. Please follow the instructions in this section under 1 (save the key in a file ``.ecmwfapirc`` in your home directory).
[30f7911]119     
120CDS API:
[f20342a]121   Go to `CDS API registration`_ and register there, too. Log in on the `cdsapi`_ website and follow the instructions in the section "Install the CDS API key" to save your credentials in file ``.cdsapirc``.
[30f7911]122
123   
124.. _ref-test-local:
125   
[f20342a]126Testing the local environment
127=============================
[30f7911]128
[f20342a]129Check the availability of the python packages by typing ``python3`` in a terminal window and run the ``import`` commands in the python shell:
[30f7911]130.. code-block:: python
131   
132   # check in python3 console
133   import eccodes
134   import genshi
135   import numpy
136   import cdsapi
137   import ecmwfapi
138   
[f20342a]139If there are no error messages, you succeeded in setting up the environment.
[30f7911]140
141
[f20342a]142Testing the Web APIs
143--------------------
[30f7911]144
145You can start very simple test retrievals for both Web APIs to be sure that everything works. This is recommended to minimise the range of possible errors using ``flex_extract`` later on.
146
147
148ECMWF Web API
149^^^^^^^^^^^^^
150
151
152+----------------------------------------------------------+----------------------------------------------------------+
[f20342a]153|Please use this Python code snippet as a **Member user**: |Please use this Python code snippet as a **Public user**: |
[30f7911]154+----------------------------------------------------------+----------------------------------------------------------+
155|.. code-block:: python                                    |.. code-block:: python                                    |
156|                                                          |                                                          |
157|    from ecmwfapi import ECMWFService                     |    from ecmwfapi import ECMWFDataServer                  |
158|                                                          |                                                          |
159|    server = ECMWFService('mars')                         |    server = ECMWFDataServer()                            |
160|                                                          |                                                          |
161|    server.retrieve({                                     |    server.retrieve({                                     |
162|        'stream'    : "oper",                             |        'stream'    : "enda",                             |
163|        'levtype'   : "sfc",                              |        'levtype'   : "sfc",                              |
164|        'param'     : "165.128/166.128/167.128",          |        'param'     : "165.128/166.128/167.128",          |
165|        'dataset'   : "interim",                          |        'dataset'   : "cera20c",                          |
166|        'step'      : "0",                                |        'step'      : "0",                                |
167|        'grid'      : "0.75/0.75",                        |        'grid'      : "1./1.",                            |
168|        'time'      : "00/06/12/18",                      |        'time'      : "00/06/12/18",                      |
169|        'date'      : "2014-07-01/to/2014-07-31",         |        'date'      : "2000-07-01/to/2000-07-31",         |
170|        'type'      : "an",                               |        'type'      : "an",                               |
171|        'class'     : "ei",                               |        'class'     : "ep",                               |
172|        'target'    : "download_erainterim_ecmwfapi.grib" |        'target'    : "download_cera20c_ecmwfapi.grib"    |
173|    })                                                    |    })                                                    |
174+----------------------------------------------------------+----------------------------------------------------------+
175
176           
177   
178CDS API
179^^^^^^^
180
181Extraction of ERA5 data via CDS API might take time as currently there is a high demand for ERA5 data. Therefore, as a simple test for the API just retrieve pressure-level data (even if that is NOT what we need for FLEXPART), as they are stored on disk and don't need to be retrieved from MARS (which is the time-consuming action):
182
[f20342a]183Please use the following Python code snippet to retrieve a small sample of *ERA5* pressure level data:
[30f7911]184
185.. code-block:: python
186
187    import cdsapi
188   
189    c = cdsapi.Client()
190   
191    c.retrieve("reanalysis-era5-pressure-levels",
192    {
193    "variable": "temperature",
194    "pressure_level": "1000",
195    "product_type": "reanalysis",
196    "year": "2008",
197    "month": "01",
198    "day": "01",
199    "time": "12:00",
200    "format": "grib"
201    },
202    "download_cdsapi.grib")
203
204   
205If you know that your CDS API works, you can try to extract some data from MARS.
206
207.. **Member-state user**
208
[f20342a]209Please use the following Python code snippet to retrieve a small *ERA5* data sample as a **member-state user**! The **Public user** do not have access to the full *ERA5* dataset!
[30f7911]210
211.. code-block:: python
212
213   import cdsapi
214   
215   c = cdsapi.Client()
216   
217   c.retrieve('reanalysis-era5-complete',
218   {
219       'class'   : 'ea',
220       'expver'  : '1',
221       'stream'  : 'oper',
222       'type'    : 'fc',
223       'step'    : '3/to/12/by/3',
224       'param'   : '130.128',
225       'levtype' : 'ml',
226       'levelist': '135/to/137',
227       'date'    : '2013-01-01',
228       'time'    : '06/18',
229       'area'    : '50/-5/40/5',
230       'grid'    : '1.0/1.0', 
231       'format'  : 'grib',
232   }, 'download_era5_cdsapi.grib')
233
234
235..  ********************** COMMENTED OUT FOR FUTURE
236    ********************** PUBLIC RETRIEVAL IS CURRENTLY NOT ACCESSIBLE
237   
238    **Public user**
239    Please use this piece of Python code:
240
241    .. code-block:: python
242
243       import cdsapi
244       
245       c = cdsapi.Client()
246       
247       c.retrieve('reanalysis-era5-complete',
248       {
249           'class'   : 'ea',
250           'dataset' : 'era5',
251           'expver'  : '1',
252           'stream'  : 'oper',
253           'type'    : 'fc',
254           'step'    : '3/to/12/by/3',
255           'param'   : '130.128',
256           'levtype' : 'ml',
257           'levelist': '135/to/137',
258           'date'    : '2013-01-01',
259           'time'    : '06/18',
260           'area'    : '50/-5/40/5',
261           'grid'    : '1.0/1.0',
262           'format'  : 'grib',
263       }, 'download_era5_cdsapi.grib')
264
265
266
267
268.. _ref-install-local:
269
270Local installation
271==================
272
[f20342a]273First, adapt the Fortran ``makefile`` for your environment (if necessary) and insert it into ``setup.sh`` script (see :ref:`Fortran Makefile <ref-convert>` for more information).
274They can be found at ``flex_extract_vX.X/Source/Fortran/``, where ``vX.X`` should be substituted by the current flex_extract version number.
[30f7911]275
276.. caution::   
277   It is necessary to adapt **ECCODES_INCLUDE_DIR** and **ECCODES_LIB** in these
278   ``makefiles`` if other than standard paths are used.
279
[f20342a]280Thus, go to the ``Fortran`` source directory and open the ``makefile`` of your
281choice, and check / modify with an editor of your choice:
[30f7911]282
283.. code-block:: bash
284
285   cd flex_extract_vX.X/Source/Fortran
[b1674ed]286   nedit makefile_fast
[30f7911]287 
[f20342a]288Set the paths to the ``eccodes`` library on your local machine, if necessary.
[30f7911]289
290.. caution::
291   This can vary from system to system.
292   It is suggested to use a command like
293
294   .. code-block:: bash
295
296      # for the ECCODES_INCLUDE_DIR path do:
297      $ dpkg -L libeccodes-dev | grep eccodes.mod
298      # for the ECCODES_LIB path do:
299      $ dpkg -L libeccodes-dev | grep libeccodes.so
300     
301   to find out the path to the ``eccodes`` library.
302   
[f20342a]303Assign these paths to the parameters **ECCODES_INCLUDE_DIR**
304and **ECCODES_LIB** in the makefile, and save it.
[30f7911]305
306.. code-block:: bash
307
[f20342a]308   # these are the paths on Debian Buster:
[30f7911]309   ECCODES_INCLUDE_DIR=/usr/lib/x86_64-linux-gnu/fortran/gfortran-mod-15/
310   ECCODES_LIB= -L/usr/lib -leccodes_f90 -leccodes -lm 
311   
312   
[b1674ed]313The Fortran program called ``calc_etadot`` will be compiled during the
[f20342a]314installation process. Therefore, the name of the ``makefile`` to be used needs to be given in  ``setup.sh``.
[30f7911]315
316In the root directory of ``flex_extract``, open the ``setup.sh`` script
[f20342a]317with an editor and adapt the installation parameters in the section labelled with
318"AVAILABLE COMMANDLINE ARGUMENTS TO SET" as shown below:
[30f7911]319
320
321.. code-block:: bash
322   :caption: 'Example settings for a local installation.'
323   :name: setup.sh
324   
325   ...
326   # -----------------------------------------------------------------
327   # AVAILABLE COMMANDLINE ARGUMENTS TO SET
328   #
329   # THE USER HAS TO SPECIFY THESE PARAMETER
330   #
331   TARGET='local'
[b1674ed]332   MAKEFILE='makefile_fast'
[30f7911]333   ECUID=None
334   ECGID=None
335   GATEWAY=None
336   DESTINATION=None
337   INSTALLDIR=None
338   JOB_TEMPLATE='job.template'
339   CONTROLFILE='CONTROL_EA5'
340   ...
341
342
343Afterwards, type:
344
345.. code-block:: bash
346
347   $ ./setup.sh
348   
349to start the installation. You should see the following standard output.
350   
351   
352.. code-block:: bash
353
[b1674ed]354    # Output of setup.sh   
355        WARNING: installdir has not been specified
356        flex_extract will be installed in here by compiling the Fortran source in <path-to-flex_extract>/flex_extract_v7.1/Source/Fortran
357        Install flex_extract_v7.1 software at local in directory <path-to-flex_extract>/flex_extract_v7.1
358
359        Using makefile: makefile_fast
360        gfortran   -O3 -march=native -Bstatic -leccodes_f90 -leccodes -Bdynamic -lm -ljasper -lemosR64 -I. -I/usr/local/include -fdefault-real-8 -fopenmp -fconvert=big-endian   -c     ./rwgrib2.f90
361        gfortran   -O3 -march=native -Bstatic -leccodes_f90 -leccodes -Bdynamic -lm -ljasper -lemosR64 -I. -I/usr/local/include -fdefault-real-8 -fopenmp -fconvert=big-endian   -c     ./phgrreal.f90
362        gfortran   -O3 -march=native -Bstatic -leccodes_f90 -leccodes -Bdynamic -lm -ljasper -lemosR64 -I. -I/usr/local/include -fdefault-real-8 -fopenmp -fconvert=big-endian   -c     ./grphreal.f90
363        gfortran   -O3 -march=native -Bstatic -leccodes_f90 -leccodes -Bdynamic -lm -ljasper -lemosR64 -I. -I/usr/local/include -fdefault-real-8 -fopenmp -fconvert=big-endian   -c     ./ftrafo.f90
364        gfortran   -O3 -march=native -Bstatic -leccodes_f90 -leccodes -Bdynamic -lm -ljasper -lemosR64 -I. -I/usr/local/include -fdefault-real-8 -fopenmp -fconvert=big-endian   -c     ./calc_etadot.f90
365        gfortran   -O3 -march=native -Bstatic -leccodes_f90 -leccodes -Bdynamic -lm -ljasper -lemosR64 -I. -I/usr/local/include -fdefault-real-8 -fopenmp -fconvert=big-endian   -c     ./posnam.f90
366        gfortran  rwgrib2.o calc_etadot.o ftrafo.o grphreal.o posnam.o phgrreal.o -o calc_etadot_fast.out  -O3 -march=native -Bstatic -leccodes_f90 -leccodes -Bdynamic -lm -ljasper -lemosR64 -fopenmp
367        ln -sf calc_etadot_fast.out calc_etadot
368
369        lrwxrwxrwx. 1 <username> tmc 20 15. Mär 13:31 ./calc_etadot -> calc_etadot_fast.out
[30f7911]370
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG