source: flex_extract.git/Documentation/html/_sources/Installation/local.rst.txt @ d720895

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

updated online docu

  • Property mode set to 100644
File size: 15.7 KB
Line 
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) |                 |
64| * `cdsapi`_ (just for ERA5)                    |                 |
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:
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.
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
266
267.. _ref-install-local:
268
269Local installation
270==================
271
272First prepare the Fortran ``makefile`` for your environment and set it in the ``setup.sh`` script. (See section :ref:`ref-convert` for information on the Fortran program.)
273``flex_extract`` comes with two ``makefiles`` prepared for the ``gfortran`` and
274the ``ifort`` compiler. The ``gfortran`` version assumes that ``eccodes`` and ``emoslib`` are installed as distribution packages.
275
276 * makefile.local.gfortran
277 * makefile.local.ifort
278 
279They can be found at ``flex_extract_vX.X/Source/Fortran``, where
280``vX.X`` should be substituted with the current version number.
281
282.. caution::   
283   It is necessary to adapt **ECCODES_INCLUDE_DIR** and **ECCODES_LIB** in these
284   ``makefiles`` if other than standard paths are used.
285
286So starting from the root directory of ``flex_extract``,
287go to the ``Fortran`` source directory and open the ``makefile`` of your
288choice to modify with an editor of your choice. We use the ``nedit`` in this case.
289
290.. code-block:: bash
291
292   cd flex_extract_vX.X/Source/Fortran
293   nedit makefile.local.gfortran
294 
295Edit the paths to the ``eccodes`` library on your local machine.
296
297
298.. caution::
299   This can vary from system to system.
300   It is suggested to use a command like
301
302   .. code-block:: bash
303
304      # for the ECCODES_INCLUDE_DIR path do:
305      $ dpkg -L libeccodes-dev | grep eccodes.mod
306      # for the ECCODES_LIB path do:
307      $ dpkg -L libeccodes-dev | grep libeccodes.so
308     
309   to find out the path to the ``eccodes`` library.
310   
311Substitute these paths in the ``makefile`` for parameters **ECCODES_INCLUDE_DIR**
312and **ECCODES_LIB** and save it.
313
314.. code-block:: bash
315
316   # these are the paths on a current Debian 10 Testing system (May 2019)
317   ECCODES_INCLUDE_DIR=/usr/lib/x86_64-linux-gnu/fortran/gfortran-mod-15/
318   ECCODES_LIB= -L/usr/lib -leccodes_f90 -leccodes -lm 
319   
320   
321The Fortran program called ``CONVERT2`` will be compiled during the
322installation process.Therefore the name of the ``makefile`` to be used needs to be given in  ``setup.sh``.
323
324In the root directory of ``flex_extract``, open the ``setup.sh`` script
325and adapt the installation parameters in the section labelled with
326"AVAILABLE COMMANDLINE ARGUMENTS TO SET" like shown below.
327
328
329.. code-block:: bash
330   :caption: 'Example settings for a local installation.'
331   :name: setup.sh
332   
333   ...
334   # -----------------------------------------------------------------
335   # AVAILABLE COMMANDLINE ARGUMENTS TO SET
336   #
337   # THE USER HAS TO SPECIFY THESE PARAMETER
338   #
339   TARGET='local'
340   MAKEFILE='makefile.local.gfortran'
341   ECUID=None
342   ECGID=None
343   GATEWAY=None
344   DESTINATION=None
345   INSTALLDIR=None
346   JOB_TEMPLATE='job.template'
347   CONTROLFILE='CONTROL_EA5'
348   ...
349
350
351Afterwards, type:
352
353.. code-block:: bash
354
355   $ ./setup.sh
356   
357to start the installation. You should see the following standard output.
358   
359   
360.. code-block:: bash
361
362   # Output of setup.sh   
363   WARNING: installdir has not been specified
364   flex_extract will be installed in here by compiling the Fortran source in /raid60/nas/tmc/Anne/Interpolation/flexextract/flex_extract_v7.1/source/fortran
365   Install flex_extract_v7.1 software at local in directory /raid60/nas/tmc/Anne/Interpolation/flexextract/flex_extract_v7.1
366
367   Using makefile: Makefile.local.gfortran
368   gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -g -O3 -fopenmp phgrreal.f
369   gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -g -O3 -fopenmp grphreal.f
370   gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -g -O3 -fopenmp ftrafo.f
371   gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -O3 -fopenmp -I. -I/usr/local/gcc-4.9.3/grib_api-1.14.3/include -O3 rwGRIB2.f90
372   gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -O3 -fopenmp -I. -I/usr/local/gcc-4.9.3/grib_api-1.14.3/include -O3 posnam.f
373   gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -O3 -fopenmp -I. -I/usr/local/gcc-4.9.3/grib_api-1.14.3/include -O3 preconvert.f90
374   gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -O3 -O3 -fopenmp -o ./CONVERT2 ftrafo.o phgrreal.o grphreal.o rwGRIB2.o posnam.o preconvert.o -L/usr/local/gcc-4.9.3/grib_api-1.14.3/lib -Bstatic  -lgrib_api_f77 -lgrib_api_f90 -lgrib_api -Bdynamic  -lm  -ljasper -lemosR64
375
376   -rwxrwxr-x. 1 philipa8 tmc 282992 May 23 22:27 ./CONVERT2
377
378
379
380
381
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG