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

ctbtodev
Last change on this file since b1674ed was b1674ed, checked in by Anne Philipp <anne.philipp@…>, 4 years ago

updated online documentation FIX for tickets #265 and #262

  • Property mode set to 100644
File size: 15.6 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
53The environment on your local system has to provide these software packages
54and libraries, since the preparation of the extraction and the post-processing is done on the local machine:
55
56+------------------------------------------------+-----------------+
57|  Python part                                   | Fortran part    |
58+------------------------------------------------+-----------------+
59| * `Python3`_                                   | * `gfortran`_   |
60| * `numpy`_                                     | * `fftw3`_      |
61| * `genshi`_                                    | * `eccodes`_    |
62| * `eccodes for python`_                        | * `emoslib`_    |
63| * `ecmwf-api-client`_ (everything except ERA5) |                 |
[b1674ed]64| * `cdsapi`_ (just for ERA5 and member user)    |                 |
[30f7911]65+------------------------------------------------+-----------------+
66
67
68.. _ref-prep-local:
69
70Prepare local environment
71=========================
72
73The easiest way to install all required packages is to use the package management system of your Linux distribution  which requires admin rights.
74The installation was tested on a *Debian GNU/Linux buster* and an *Ubuntu 18.04 Bionic Beaver* system.
75
76.. code-block:: sh
77
78  # On a Debian or Debian-derived sytem (e. g. Ubuntu) system you may use the following commands (or equivalent commands of your preferred package manager):
79  # (if not already available):
80   apt-get install python3 (usually already available on GNU/Linux systems)
81   apt-get install python3-eccodes
82   apt-get install python3-genshi
83   apt-get install python3-numpy
84   apt-get install gfortran
85   apt-get install fftw3-dev
86   apt-get install libeccodes-dev
87   apt-get install libemos-dev
88  # Some of these packages will pull in further packages as dependencies. This is fine, and some are even needed by ``flex_extract''.
89 
90
91  # As currently the CDS and ECMWF API packages are not available as Debian packages, they need to be installed outside of the Debian (Ubuntu etc.) package management system. The recommended way is:
92   apt-get install pip
93   pip install cdsapi
94   pip install ecmwf-api-client
95   
96.. note::
97
98    In case you would like to use Anaconda Python we recommend you follow the installation instructions of
99    `Anaconda Python Installation for Linux <https://docs.anaconda.com/anaconda/install/linux/>`_ and then install the
100    ``eccodes`` package from ``conda`` with:
101
102    .. code-block:: bash
103
104       conda install conda-forge::python-eccodes   
105   
106The CDS API (cdsapi) is required for ERA5 data and the ECMWF Web API (ecmwf-api-client) for all other public datasets.   
107   
108.. note:: 
109
110    Since **public users** currently don't have access to the full *ERA5* dataset they can skip the installation of the ``CDS API``.
111
112Both user groups have to provide keys with their credentials for the Web API's in their home directory. Therefore, follow these instructions:
113       
114ECMWF Web API:
115   Go to `MARS access`_ website and log in with your credentials. Afterwards, on this site in section "Install ECMWF KEY" 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).
116     
117CDS API:
[b1674ed]118   Go to `CDS API registration`_ and register there too. Log in at the `cdsapi`_ website and follow the instructions at section "Install the CDS API key" to save your credentials in a `.cdsapirc` file.
[30f7911]119
120   
121.. _ref-test-local:
122   
123Test local environment
124======================
125
126Check the availability of the python packages by typing ``python3`` in a terminal window and run the ``import`` commands in the python shell. If there are no error messages, you succeeded in setting up the environment.
127
128.. code-block:: python
129   
130   # check in python3 console
131   import eccodes
132   import genshi
133   import numpy
134   import cdsapi
135   import ecmwfapi
136   
137
138
139Test the Web API's
140------------------
141
142You 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.
143
144
145ECMWF Web API
146^^^^^^^^^^^^^
147
148
149+----------------------------------------------------------+----------------------------------------------------------+
150|Please use this piece of Python code for **Member user**: |Please use this piece of Python code for **Public user**: |
151+----------------------------------------------------------+----------------------------------------------------------+
152|.. code-block:: python                                    |.. code-block:: python                                    |
153|                                                          |                                                          |
154|    from ecmwfapi import ECMWFService                     |    from ecmwfapi import ECMWFDataServer                  |
155|                                                          |                                                          |
156|    server = ECMWFService('mars')                         |    server = ECMWFDataServer()                            |
157|                                                          |                                                          |
158|    server.retrieve({                                     |    server.retrieve({                                     |
159|        'stream'    : "oper",                             |        'stream'    : "enda",                             |
160|        'levtype'   : "sfc",                              |        'levtype'   : "sfc",                              |
161|        'param'     : "165.128/166.128/167.128",          |        'param'     : "165.128/166.128/167.128",          |
162|        'dataset'   : "interim",                          |        'dataset'   : "cera20c",                          |
163|        'step'      : "0",                                |        'step'      : "0",                                |
164|        'grid'      : "0.75/0.75",                        |        'grid'      : "1./1.",                            |
165|        'time'      : "00/06/12/18",                      |        'time'      : "00/06/12/18",                      |
166|        'date'      : "2014-07-01/to/2014-07-31",         |        'date'      : "2000-07-01/to/2000-07-31",         |
167|        'type'      : "an",                               |        'type'      : "an",                               |
168|        'class'     : "ei",                               |        'class'     : "ep",                               |
169|        'target'    : "download_erainterim_ecmwfapi.grib" |        'target'    : "download_cera20c_ecmwfapi.grib"    |
170|    })                                                    |    })                                                    |
171+----------------------------------------------------------+----------------------------------------------------------+
172
173           
174   
175CDS API
176^^^^^^^
177
178Extraction 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):
179
180Please use this piece of Python code to retrieve a small sample of *ERA5* pressure levels:
181
182.. code-block:: python
183
184    import cdsapi
185   
186    c = cdsapi.Client()
187   
188    c.retrieve("reanalysis-era5-pressure-levels",
189    {
190    "variable": "temperature",
191    "pressure_level": "1000",
192    "product_type": "reanalysis",
193    "year": "2008",
194    "month": "01",
195    "day": "01",
196    "time": "12:00",
197    "format": "grib"
198    },
199    "download_cdsapi.grib")
200
201   
202If you know that your CDS API works, you can try to extract some data from MARS.
203
204.. **Member-state user**
205
206Please use this piece of Python code to retrieve a small *ERA5* data sample as a **member-state user**! The **Public user** do not have access to the full *ERA5* dataset!
207
208.. code-block:: python
209
210   import cdsapi
211   
212   c = cdsapi.Client()
213   
214   c.retrieve('reanalysis-era5-complete',
215   {
216       'class'   : 'ea',
217       'expver'  : '1',
218       'stream'  : 'oper',
219       'type'    : 'fc',
220       'step'    : '3/to/12/by/3',
221       'param'   : '130.128',
222       'levtype' : 'ml',
223       'levelist': '135/to/137',
224       'date'    : '2013-01-01',
225       'time'    : '06/18',
226       'area'    : '50/-5/40/5',
227       'grid'    : '1.0/1.0', 
228       'format'  : 'grib',
229   }, 'download_era5_cdsapi.grib')
230
231
232..  ********************** COMMENTED OUT FOR FUTURE
233    ********************** PUBLIC RETRIEVAL IS CURRENTLY NOT ACCESSIBLE
234   
235    **Public user**
236    Please use this piece of Python code:
237
238    .. code-block:: python
239
240       import cdsapi
241       
242       c = cdsapi.Client()
243       
244       c.retrieve('reanalysis-era5-complete',
245       {
246           'class'   : 'ea',
247           'dataset' : 'era5',
248           'expver'  : '1',
249           'stream'  : 'oper',
250           'type'    : 'fc',
251           'step'    : '3/to/12/by/3',
252           'param'   : '130.128',
253           'levtype' : 'ml',
254           'levelist': '135/to/137',
255           'date'    : '2013-01-01',
256           'time'    : '06/18',
257           'area'    : '50/-5/40/5',
258           'grid'    : '1.0/1.0',
259           'format'  : 'grib',
260       }, 'download_era5_cdsapi.grib')
261
262
263
264
265.. _ref-install-local:
266
267Local installation
268==================
269
[b1674ed]270First prepare the Fortran ``makefile`` for your environment and set it in the ``setup.sh`` script. (See section :ref:`Fortran Makefile <ref-convert>` for more information.)
271``flex_extract`` comes with two ``makefiles`` prepared for the ``gfortran`` compiler. One for the normal use ``makefile_fast`` and one for debugging ``makefile_debug`` which is usually only resonable for developers.
[30f7911]272 
[b1674ed]273They assume that ``eccodes`` and ``emoslib`` are installed as distribution packages and can be found at ``flex_extract_vX.X/Source/Fortran``, where ``vX.X`` should be substituted with the current version number.
[30f7911]274
275.. caution::   
276   It is necessary to adapt **ECCODES_INCLUDE_DIR** and **ECCODES_LIB** in these
277   ``makefiles`` if other than standard paths are used.
278
279So starting from the root directory of ``flex_extract``,
280go to the ``Fortran`` source directory and open the ``makefile`` of your
281choice to modify with an editor of your choice. We use the ``nedit`` in this case.
282
283.. code-block:: bash
284
285   cd flex_extract_vX.X/Source/Fortran
[b1674ed]286   nedit makefile_fast
[30f7911]287 
288Edit the paths to the ``eccodes`` library on your local machine.
289
290
291.. caution::
292   This can vary from system to system.
293   It is suggested to use a command like
294
295   .. code-block:: bash
296
297      # for the ECCODES_INCLUDE_DIR path do:
298      $ dpkg -L libeccodes-dev | grep eccodes.mod
299      # for the ECCODES_LIB path do:
300      $ dpkg -L libeccodes-dev | grep libeccodes.so
301     
302   to find out the path to the ``eccodes`` library.
303   
304Substitute these paths in the ``makefile`` for parameters **ECCODES_INCLUDE_DIR**
305and **ECCODES_LIB** and save it.
306
307.. code-block:: bash
308
309   # these are the paths on a current Debian 10 Testing system (May 2019)
310   ECCODES_INCLUDE_DIR=/usr/lib/x86_64-linux-gnu/fortran/gfortran-mod-15/
311   ECCODES_LIB= -L/usr/lib -leccodes_f90 -leccodes -lm 
312   
313   
[b1674ed]314The Fortran program called ``calc_etadot`` will be compiled during the
[30f7911]315installation process.Therefore the name of the ``makefile`` to be used needs to be given in  ``setup.sh``.
316
317In the root directory of ``flex_extract``, open the ``setup.sh`` script
318and adapt the installation parameters in the section labelled with
319"AVAILABLE COMMANDLINE ARGUMENTS TO SET" like shown below.
320
321
322.. code-block:: bash
323   :caption: 'Example settings for a local installation.'
324   :name: setup.sh
325   
326   ...
327   # -----------------------------------------------------------------
328   # AVAILABLE COMMANDLINE ARGUMENTS TO SET
329   #
330   # THE USER HAS TO SPECIFY THESE PARAMETER
331   #
332   TARGET='local'
[b1674ed]333   MAKEFILE='makefile_fast'
[30f7911]334   ECUID=None
335   ECGID=None
336   GATEWAY=None
337   DESTINATION=None
338   INSTALLDIR=None
339   JOB_TEMPLATE='job.template'
340   CONTROLFILE='CONTROL_EA5'
341   ...
342
343
344Afterwards, type:
345
346.. code-block:: bash
347
348   $ ./setup.sh
349   
350to start the installation. You should see the following standard output.
351   
352   
353.. code-block:: bash
354
[b1674ed]355    # Output of setup.sh   
356        WARNING: installdir has not been specified
357        flex_extract will be installed in here by compiling the Fortran source in <path-to-flex_extract>/flex_extract_v7.1/Source/Fortran
358        Install flex_extract_v7.1 software at local in directory <path-to-flex_extract>/flex_extract_v7.1
359
360        Using makefile: makefile_fast
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     ./rwgrib2.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     ./phgrreal.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     ./grphreal.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     ./ftrafo.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     ./calc_etadot.f90
366        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
367        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
368        ln -sf calc_etadot_fast.out calc_etadot
369
370        lrwxrwxrwx. 1 <username> tmc 20 15. Mär 13:31 ./calc_etadot -> calc_etadot_fast.out
[30f7911]371
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG