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

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

reviewed installation section of online documentation; minor corrections

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