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

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

changes related to makefile, structure and names of top-level sections

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