source: flex_extract.git/for_developers/Sphinx/source/installation.rst @ 41c9dbc

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

Large update of Sphinx doc; moved Sphinx source to dev dir; Cleaned control files

  • Property mode set to 100644
File size: 35.0 KB
RevLine 
[41c9dbc]1************
2Installation
3************
4
5.. role:: underline
6    :class: underline
7   
8.. toctree::
9    :hidden:
10    :maxdepth: 2
11     
12.. _Python 3: https://docs.python.org/3/
13.. _Python3: https://www.python.org/downloads/
14.. _Anaconda Python3: https://www.anaconda.com/distribution/#download-section
15
16.. _numpy: http://www.numpy.org/
17.. _ecmwf-api-client: https://confluence.ecmwf.int/display/WEBAPI/ECMWF+Web+API+Home
18.. _cdsapi: https://cds.climate.copernicus.eu/api-how-to
19.. _genshi: https://genshi.edgewall.org/
20.. _eccodes for python: https://packages.debian.org/sid/python3-eccodes
21.. _eccodes for conda: https://anaconda.org/conda-forge/eccodes
22.. _gfortran: https://gcc.gnu.org/wiki/GFortran
23.. _fftw3: http://www.fftw.org
24.. _eccodes: https://software.ecmwf.int/wiki/display/ECC
25.. _emoslib: https://software.ecmwf.int/wiki/display/EMOS/Emoslib
26.. _member state: https://www.ecmwf.int/en/about/who-we-are/member-states
27.. _registration form: https://apps.ecmwf.int/registration/
28.. _CDS API registration: https://cds.climate.copernicus.eu/user/register
29.. _ECMWF ectrans site: https://confluence.ecmwf.int/display/ECAC/Unattended+file+transfer+-+ectrans
30.. _ECaccess Presentation: https://confluence.ecmwf.int/download/attachments/45759146/ECaccess.pdf
31.. _ECMWF's instructions on gateway server: https://confluence.ecmwf.int/display/ECAC/ECaccess+Home
32.. _Computing Representative: https://www.ecmwf.int/en/about/contact-us/computing-representatives
33.. _MARS access: https://confluence.ecmwf.int//display/WEBAPI/Access+MARS
34
35.. _download section: https://www.flexpart.eu/downloads
36
37
38
39``flex_extract`` is a software package which contains a mix of Python and Shell scripts as well as a Fortran program. These components rely on a couple of third party libraries which need to be prepared first before starting the installation process. For now, the software is only tested for a Linux/Unix environment. Feel free to try it out on other platforms.
40
41Start with the decision of which `user group <Ecmwf/access>`_ you belong to and follow the instructions at :ref:`ref-registration` to get an account at ECMWF. Considering your user group and the method of applying ``flex_extract`` there appear to be 4 application modes: 
42
43- Remote (for member state users only) :ref:`[installation]<ref-remote-mode>`
44- Gateway (for member state users only) :ref:`[installation]<ref-gateway-mode>`
45- Local member :ref:`[installation]<ref-local-mode>`
46- Local public :ref:`[installation]<ref-local-mode>`
47
48More information can be found in :doc:`Documentation/Overview/app_modes`.
49
50.. note::
51
52   If you encounter any problems in the installation process, you can ask for :doc:`support`.
53
54
55
56
57
58.. _ref-registration:
59
60Registration at ECMWF
61=====================
62
63Decide which user group you belong to and follow the instructions for registration:
64
65**Member state user**:
66    To get a member-state user account, users have to be a resident of a `member state`_. In that case, you can contact your `Computing Representative`_ for granting access. If you would like to use the local application mode to retrieve **ERA5** data you'd have to register at the `Copernicus Climate Data Store <https://cds.climate.copernicus.eu/user/register>`_ also.
67
68**Public user**:
69    To be able to download all intended public datasets with ``flex_extract`` such as **ERA-Interim**, **CERA-20C** and **ERA5**, the public user has to create 2 accounts.
70    At first, registration at the ECMWF website by filling out this `registration form`_ is needed to be able to retrieve *ERA-Interim* and *CERA-20C* data. For the retrievement of *ERA5* a registration at the `Copernicus Climate Data Store <https://cds.climate.copernicus.eu/user/register>`_ is needed in addition.
71   
72   
73   
74   
75   
76   
77.. _ref-licence:
78   
79Agree on Licences for Public Datasets
80=====================================
81
82Each public dataset which is intended to be downloaded by ``flex_extract`` has its own licence which has to be accepted, regardless of the user group.
83
84For the *ERA-Interim* and *CERA-20C* datasets this can be done at the ECMWF website `Available ECMWF Public Datasets <https://confluence.ecmwf.int/display/WEBAPI/Available+ECMWF+Public+Datasets>`_. Log in and follow the licence links on the right side for each dataset and accept it.
85   
86For the *ERA5* dataset this has to be done at the `Climate Data Store (CDS) website <https://cds.climate.copernicus.eu/cdsapp#!/search?type=dataset>`_. Log in with your credentials and then select on the left panel the product type "Reanalysis" for finding *ERA5* datasets. Then follow the link of a title with *ERA5* (anyone) to the full dataset record, click on tab "Download data" and scroll down. There is a section "Terms of use" where you have to click the :underline:`Accept terms` button.   
87
88   
89
90
91
92
93.. _ref-download:
94
95Download ``flex_extract``
96=========================
97
98There are 2 options to download ``flex_extract``:
99
100tar ball
101    You can download the latest prepared release tar ball from the `download section`_ 
102    of our ``FLEXPART`` community website and then untar the file. Substitute
103    the **<ID>** in the ``wget`` command with the ID-number of the ``flex_extract`` 
104    release tar ball in the list of downloads at the community website.
105   
106   
107    .. code-block:: bash
108       
109       wget https://www.flexpart.eu/downloads/<ID>
110       tar -xvf <flex_extract_vX.X.tar>
111
112git repo   
113    Or you can clone the current release version from our git repository master branch.
114
115    .. code-block:: bash
116
117       $ git clone https://www.flexpart.eu/gitmob/flexpart
118
119
120
121
122
123.. _ref-requirements: 
124 
125Environment Requirements
126========================
127
128This is a list of the general environment requirements for ``flex_extract``.
129What is required exactly for each application mode will be described in the specifc installation section.
130
131   
132To run the python part of ``flex_extract`` a `Python 3`_ environment is needed.
133We tested ``flex_extract`` with a normal Linux Python package distribution and Anaconda Python.
134Except for `Python3`_ all are python packages which can be installed via ``pip``.
135
136* `Python3`_ or `Anaconda Python3`_
137* `numpy`_
138* `ecmwf-api-client`_ (Web Interface to ECMWF servers for datasets except ERA5)
139* `cdsapi`_ (Web Interface to `C3S <https://climate.copernicus.eu/>`_ servers for ERA5)
140* `genshi`_
141* `eccodes for python`_ 
142 
143For the Fortran part of ``flex_extract`` we need the following distribution packages:
144 
145* `gfortran`_
146* `fftw3`_
147* `eccodes`_
148* `emoslib`_
149
150
151
152
153
154
155.. _ref-install-fe:
156
157Installation of ``flex_extract``
158================================
159
160The actual installation of ``flex_extract`` will be done by executing a `Shell` script called ``setup.sh``.
161It defines some parameters and calls a Python script by giving the parameters as command line arguments.
162More information on the script and its parameters can be found at :doc:`Documentation/Input/setup`.
163
164For each application mode installation section we describe the requirements for the explicit
165environment and how it is installed, test if it works and how the actual ``flex_extract``
166installation has to be done. At the users local side not all software has to be present for ``flex_extract``.
167
168
169
170
171
172
173.. _ref-remote-mode: 
174
175Remote Mode
176-----------
177
178.. _ref-req-remote: 
179 
180Remote Environment Requirements
181^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
182
183The environment for ``flex_extract`` on ECMWF servers has to provide these
184software packages and libraries:
185   
186+---------------------------+-----------------+
187|  Python part              | Fortran part    |
188+---------------------------+-----------------+
189| * `Python3`_              | * `gfortran`_   |
190| * `numpy`_                | * `fftw3`_      |
191| * `genshi`_               | * `eccodes`_    |
192| * `eccodes for python`_   | * `emoslib`_    |
193+---------------------------+-----------------+
194
195
196.. _ref-prep-remote:
197
198Prepare Remote Environment
199^^^^^^^^^^^^^^^^^^^^^^^^^^
200 
201The environment on the ECMWF server (such as *ecgate* or *cca*) is already
202prepared. ECMWF server provide all libraries via a module system which is
203going to be selected by ``flex_extract`` automatically.
204
205
206.. _ref-install-remote:
207
208Remote Installation
209^^^^^^^^^^^^^^^^^^^
210
211First, log in on one of the ECMWF Linux server, such as *ecgate* or *cca/ccb*.
212Substitute *<ecuid>* with your ECMWF user name:
213
214.. code-block:: bash
215   
216   ssh -X <ecuid>@ecaccess.ecmwf.int
217
218This will lead to the following output on the command line, asking for your
219password:
220   
221.. code-block:: bash
222
223   Authorized access only.
224
225   ***************************************************************
226      For further information, read the ECaccess documentation at:
227
228      https://software.ecmwf.int/wiki/display/ECAC/ECaccess+Home
229
230      You can also use ECaccess to load & download files from your
231      EChome, ECscratch or ECfs directories using the ECaccess FTP
232      server:
233
234      ftp://uid@ecaccess.ecmwf.int/
235
236      Please note you must use your UID and ActivID code to login!
237   ***************************************************************
238
239   <ecuid>@131.130.157.5's password: ***
240   Select hostname (ecgate, cca, ccb) [ecgate]: ecgate
241
242   [<ecuid>@ecgb11 ~]$
243   
244   
245Then, copy the ``flex_extract`` tar ball (from section :ref:`ref-download`)
246to the ``$HOME`` directory of the ECMWF Linux server via ``scp``.
247Substitute the *<localuser>* and *<server.edu>* placeholders with your credentials.
248Untar the file and change into the ``flex_extract`` root directory.
249
250.. code-block:: bash
251
252   scp <localuser>@<server.edu>:/path/to/tarfile/flex_extract_vX.X.tar.gz  $HOME/
253   cd $HOME
254   tar xvf flex_extract_vX.X.tar.gz
255   cd flex_extract_vX.X
256   
257
258On these ECMWF servers, it is not necessary to prepare the environment or the
259``Makefile`` for the Fortran program (``CONVERT2``) as described above.
260All third party libraries are available from a module system. The ``Makefile``
261is optimized for ECMWF servers and the compilation
262script ``compilejob.ksh``, which will be submitted by ``flex_extract`` to the
263batch job queue at ECMWF, does load all relevant modules from the ECMWF's module system.
264
265So there is just the need to execute the ``setup.sh`` script from the
266``flex_extract`` root directory for installation.
267Before executing it, it is necessary to adapt some parameters from ``setup.sh``
268described in :ref:`ref-setup`.
269
270Open ``setup.sh`` with your editor and adapt the values: 
271
272+----------------------------------------------+----------------------------------------------+   
273|   Take this for target = **ectrans**         |  Take this for target = **cca**              |
274+----------------------------------------------+----------------------------------------------+
275| .. code-block:: bash                         | .. code-block:: bash                         |
276|                                              |                                              |
277|   ...                                        |   ...                                        |     
278|   # -----------------------------------------|   # -----------------------------------------|
279|   # AVAILABLE COMMANDLINE ARGUMENTS TO SET   |   # AVAILABLE COMMANDLINE ARGUMENTS TO SET   |
280|   #                                          |   #                                          | 
281|   # THE USER HAS TO SPECIFY THESE PARAMETER  |   # THE USER HAS TO SPECIFY THESE PARAMETER  |
282|   #                                          |   #                                          |
283|   TARGET='ecgate'                            |   TARGET='cca'                               |
284|   MAKEFILE='Makefile.gfortran'               |   MAKEFILE='Makefile.CRAY'                   | 
285|   ECUID='uid'                                |   ECUID='uid'                                | 
286|   ECGID='gid'                                |   ECGID='gid'                                |
287|   GATEWAY=None                               |   GATEWAY=None                               |
288|   DESTINATION=None                           |   DESTINATION=None                           |
289|   INSTALLDIR=None                            |   INSTALLDIR=''                              |
290|   JOB_TEMPLATE='job.template'                |   JOB_TEMPLATE='job.template'                |
291|   CONTROLFILE='CONTROL_EA5'                  |   CONTROLFILE='CONTROL_EA5'                  |
292|   ...                                        |   ...                                        |   
293+----------------------------------------------+----------------------------------------------+
294
295:underline:`Please substitute the values of ECUID and ECGID
296with your own credentials and settings.`
297
298.. note::
299
300   If a local gateway server is available the transfer of files could be done
301   via the ``ECaccess`` commands. Therefore a valid *GATEWAY* and *DESTINATION*
302   have to be present and should be set in the ``setup.sh`` file.
303
304
305Afterwards, type:
306
307.. code-block:: bash
308
309   module load python3   
310   ./setup.sh
311   
312to start the installation. You should see the following output at the command line.
313   
314   
315.. code-block:: bash
316
317   # Output of setup.sh
318   Create tarball ...
319   Job compilation script has been submitted to ecgate for installation in ${HOME}/flex_extract_vX.X
320   You should get an email with subject "flexcompile" within the next few minutes!
321
322   
323The email content should look like this with a "SUCCESS" statement in the last line:
324
325.. code-block:: bash
326
327    gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -g -O3 -fopenmp phgrreal.f
328    gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -g -O3 -fopenmp grphreal.f
329    gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -g -O3 -fopenmp ftrafo.f
330    gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -O3 -I. -I/usr/local/apps/eccodes/2.12.0/GNU/6.3.0/include -g rwGRIB2.f90
331    gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -O3 -I. -I/usr/local/apps/eccodes/2.12.0/GNU/6.3.0/include -g posnam.f
332    gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -O3 -I. -I/usr/local/apps/eccodes/2.12.0/GNU/6.3.0/include -g preconvert.f90
333    gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -g -O3 -o ./CONVERT2 ftrafo.o phgrreal.o grphreal.o rwGRIB2.o posnam.o preconvert.o -L/usr/local/apps/eccodes/2.12.0/GNU/6.3.0/lib -Wl,-rpath,/usr/local/apps/eccodes/2.12.0/GNU/6.3.0/lib -leccodes_f90 -leccodes -ljasper -lpthread -L/usr/local/apps/jasper/1.900.1/LP64/lib -ljasper -lm -L/usr/local/apps/libemos/000455/GNU/6.3.0/lib  -Wl,-rpath,/usr/local/apps/libemos/000455/GNU/6.3.0/lib  -lemos.R64.D64.I32 -L/usr/local/apps/fftw/3.3.4/GNU/6.3.0/lib -Wl,-rpath,/usr/local/apps/fftw/3.3.4/GNU/6.3.0/lib -lfftw3   
334    -rwxr-x---. 1 USER at 353134 May 23 12:27 CONVERT2
335    SUCCESS!   
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359.. _ref-gateway-mode:
360
361Gateway Mode
362------------
363
364
365.. _ref-req-gateway: 
366 
367Gateway Environment Requirements
368^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
369
370The environment on your local system has to provide these software packages
371and libraries, since ``flex_extract`` does only prepare the job script and send
372it to the ECMWF servers:
373   
374* `Python3`_ or `Anaconda Python3`_
375* `numpy`_
376* `genshi`_
377 
378
379.. _ref-prep-gateway:
380
381Prepare Gateway Environment
382^^^^^^^^^^^^^^^^^^^^^^^^^^^
383
384The 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.
385The installation was tested on a *Debian GNU/Linux buster/sid* and an *Ubuntu 18.04 Bionic Beaver* system.
386
387.. code-block:: sh
388
389   # On a Linux Debian or Ubuntu system do
390   # (if not already available):
391   sudo apt -PV install python3
392   sudo apt -PV install pip
393   pip install genshi
394   pip install numpy
395
396
397.. _ref-test-gateway:
398
399Test Gateway Environment
400^^^^^^^^^^^^^^^^^^^^^^^^
401 
402Check the availability of the python packages by typing ``python3`` in
403a terminal window and run the ``import`` commands in the python shell.
404If there are no error messages, you succeeded in setting up the environment.
405
406.. code-block:: python
407   
408   # check in python3 console
409   import genshi
410   import numpy
411 
412
413
414.. _ref-install-gateway:
415
416Gateway Installation
417^^^^^^^^^^^^^^^^^^^^
418
419In this mode, access to the ECMWF computing and archiving facilities is enabled through an ECaccess gateway server on a local member state server. The ECaccess framework is necessary to interactively submit jobs to the ECMWF batch system and to transfer files between ECMWF and local gateway server.
420
421Please see `ECMWF's instructions on gateway server`_ to establish the gateway server if not already in place.
422Additionally, to be able to use the Ecaccess file transfer service **ectrans** please also create an association.
423The easiest way is to visit the ECaccess Member State Gateway website (e.g. msgatway.ecmwf.int) and follow the instructions in the short `ECaccess Presentation`_ (page 17 ff.). Additional documentation can be found on the `ECMWF ectrans site`_.
424
425After everything is set up you have to create an *ecaccess certificate* to be able to send and receive files from and to the ECMWF server. You can do this by using the ``ecaccess-certificate-create`` command on the gateway server. You will be prompted for your ECMWF member state user name and a password (which will be usually generated by a Token). This certificate has to be re-newed periodically (every 7 days).
426
427.. code-block:: bash
428   
429   $ ecaccess-certificate-create
430   Please enter your user-id: example_username
431   Your passcode: ***
432   
433``Flex_extract`` will be run on an ECMWF server which makes the setup the same as for the **remote mode**. In the ``setup.sh`` script :ref:`[ref] <ref-setup>`, select the ``Makefile.gfortran`` for the ``CONVERT2`` Fortran program and the ECMWF server (*target*) you would like to use.
434The job script, send to the job queue via the ECaccess software, selects again automatically the correct libraries from the module system. For enableing the file transfer you have to set the *ECUID*, *ECGID*, *GATEWAY* and *DESTINATION* parameter values.
435 
436
437.. code-block:: bash
438    :caption: 'Example settings for a gateway installation.'
439    :name: setup.sh
440   
441    # -----------------------------------------------------------------
442    # AVAILABLE COMMANDLINE ARGUMENTS TO SET
443    #
444    # THE USER HAS TO SPECIFY THESE PARAMETER
445    #
446    TARGET='ecgate'
447    MAKEFILE='Makefile.gfortran'
448    ECUID='uid'
449    ECGID='gid'
450    GATEWAY='server.example.edu'
451    DESTINATION='example@genericSftp'
452    INSTALLDIR=None
453    JOB_TEMPLATE='job.template'
454    CONTROLFILE='CONTROL_EA5'
455
456
457Afterwards, type:
458
459.. code-block:: bash
460
461   $ ./setup.sh
462   
463to start the installation. You should see the following output at the command line.
464   
465   
466.. code-block:: bash
467
468   # Output of setup.sh
469   Create tarball ...
470   Job compilation script has been submitted to ecgate for installation in ${HOME}/flex_extract_vX.X
471   You should get an email with subject "flexcompile" within the next few minutes!
472
473   
474The email content should look like this with a "SUCCESS" statement in the last line:
475
476.. code-block:: bash
477
478    gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -g -O3 -fopenmp phgrreal.f
479    gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -g -O3 -fopenmp grphreal.f
480    gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -g -O3 -fopenmp ftrafo.f
481    gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -O3 -I. -I/usr/local/apps/eccodes/2.12.0/GNU/6.3.0/include -g rwGRIB2.f90
482    gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -O3 -I. -I/usr/local/apps/eccodes/2.12.0/GNU/6.3.0/include -g posnam.f
483    gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -O3 -I. -I/usr/local/apps/eccodes/2.12.0/GNU/6.3.0/include -g preconvert.f90
484    gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -g -O3 -o ./CONVERT2 ftrafo.o phgrreal.o grphreal.o rwGRIB2.o posnam.o preconvert.o -L/usr/local/apps/eccodes/2.12.0/GNU/6.3.0/lib -Wl,-rpath,/usr/local/apps/eccodes/2.12.0/GNU/6.3.0/lib -leccodes_f90 -leccodes -ljasper -lpthread -L/usr/local/apps/jasper/1.900.1/LP64/lib -ljasper -lm -L/usr/local/apps/libemos/000455/GNU/6.3.0/lib  -Wl,-rpath,/usr/local/apps/libemos/000455/GNU/6.3.0/lib  -lemos.R64.D64.I32 -L/usr/local/apps/fftw/3.3.4/GNU/6.3.0/lib -Wl,-rpath,/usr/local/apps/fftw/3.3.4/GNU/6.3.0/lib -lfftw3   
485    -rwxr-x---. 1 USER at 353134 May 23 12:27 CONVERT2
486    SUCCESS!   
487   
488   
489   
490   
491   
492   
493   
494   
495   
496   
497   
498   
499   
500   
501   
502   
503   
504   
505   
506.. _ref-local-mode:
507
508Local Mode
509----------
510
511
512
513.. _ref-req-local: 
514 
515Local Environment Requirements
516^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
517
518For the local access modes **member** and **public** there is no difference in
519the installation process.
520
521The environment on your local system has to provide these software packages
522and libraries, since all extraction and preparation is done at the local system:
523
524+------------------------------------------------+-----------------+
525|  Python part                                   | Fortran part    |
526+------------------------------------------------+-----------------+
527| * `Python3`_                                   | * `gfortran`_   |
528| * `numpy`_                                     | * `fftw3`_      |
529| * `genshi`_                                    | * `eccodes`_    |
530| * `eccodes for python`_                        | * `emoslib`_    |
531| * `ecmwf-api-client`_ (everything except ERA5) |                 |
532| * `cdsapi`_ (just for ERA5)                    |                 |
533+------------------------------------------------+-----------------+
534
535
536.. _ref-prep-local:
537
538Prepare Local Environment
539^^^^^^^^^^^^^^^^^^^^^^^^^
540
541The 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.
542The installation was tested on a *Debian GNU/Linux buster/sid* and an *Ubuntu 18.04 Bionic Beaver* system.
543
544.. code-block:: sh
545
546   # On a Linux Debian or Ubuntu system do
547   # (if not already available):
548   sudo apt -PV install python3
549   sudo apt -PV install pip
550   sudo apt -PV install gfortran
551   sudo apt -PV install fftw3-dev
552   sudo apt -PV install libeccodes-dev
553   sudo apt -PV install libemos-dev
554   sudo apt -PV install python3-eccodes
555   pip install genshi
556   pip install numpy
557   pip install cdsapi
558   pip install ecmwf-api-client
559
560.. note::
561
562    In case you would like to use Anaconda Python we recommend you follow the installation instructions of
563    `Anaconda Python Installation for Linux <https://docs.anaconda.com/anaconda/install/linux/>`_ and then install the
564    ``eccodes`` package from ``conda`` with:
565
566    .. code-block:: bash
567
568       conda install conda-forge::python-eccodes
569
570
571The 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``.     
572       
573Both user groups have to provide key's with their credentials for the Web API's in their home directory. Therefore, follow these instructions:
574   
575ECMWF Web API:
576   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).
577     
578CDS API:
579   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.
580     
581
582.. _ref-test-local:
583   
584Test Local Environment
585^^^^^^^^^^^^^^^^^^^^^^
586
587Check the availability of the system packages with ``dpkg -s <package-name> |  grep Status`` or ``rpm -q <package_name>``, depending on your system. For example:
588
589.. code-block:: sh
590
591   $ dpkg -s libeccodes-dev |  grep Status
592   # or
593   $ rpm -q libeccodes-dev
594 
595Afterwards, check the availability of the python packages by typing ``python3`` in
596a terminal window and run the ``import`` commands in the python shell. If there are no error messages, you succeeded in setting up the environment.
597
598.. code-block:: python
599   
600   # check in python3 console
601   import eccodes
602   import genshi
603   import numpy
604   import cdsapi
605   import ecmwfapi
606   
607
608
609Test the Web API's
610""""""""""""""""""
611
612You 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.
613
614ECMWF Web API
615"""""""""""""
616
617**Member user**
618    Please use this piece of python code:
619
620    .. code-block:: python
621
622        from ecmwfapi import ECMWFService
623           
624        server = ECMWFService('mars')
625           
626        server.retrieve({
627            'stream'    : "oper",
628            'levtype'   : "sfc",
629            'param'     : "165.128/166.128/167.128",
630            'dataset'   : "interim",
631            'step'      : "0",
632            'grid'      : "0.75/0.75",
633            'time'      : "00/06/12/18",
634            'date'      : "2014-07-01/to/2014-07-31",
635            'type'      : "an",
636            'class'     : "ei",
637            'target'    : "download_erainterim_ecmwfapi.grib"
638        })
639
640
641**Public user**
642    Please use this piece of python code:
643
644    .. code-block:: python
645
646        from ecmwfapi import ECMWFDataServer
647           
648        server = ECMWFDataServer()
649           
650        server.retrieve({
651            'stream'    : "enda",
652            'levtype'   : "sfc",
653            'param'     : "165.128/166.128/167.128",
654            'dataset'   : "cera20c",
655            'step'      : "0",
656            'grid'      : "1./1.",
657            'time'      : "00/06/12/18",
658            'date'      : "2000-07-01/to/2000-07-31",
659            'type'      : "an",
660            'class'     : "ep",
661            'target'    : "download_cera20c_ecmwfapi.grib"
662        })
663   
664CDS API
665"""""""
666
667Since 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:
668
669**All users**
670    Please use this piece of python code:
671   
672    .. code-block:: python
673
674        import cdsapi
675       
676        c = cdsapi.Client()
677       
678        c.retrieve("reanalysis-era5-pressure-levels",
679        {
680        "variable": "temperature",
681        "pressure_level": "1000",
682        "product_type": "reanalysis",
683        "year": "2008",
684        "month": "01",
685        "day": "01",
686        "time": "12:00",
687        "format": "grib"
688        },
689        "download_cdsapi.grib")
690
691
692Afterwards, when you know that the CDS API generally works, you can try to extract some
693data from the MARS archive. From the latest experience this can take a while.   
694
695**Member user**
696    Please use this piece of python code:
697   
698    .. code-block:: python
699
700       import cdsapi
701       
702       c = cdsapi.Client()
703       
704       c.retrieve('reanalysis-era5-complete',
705       {
706           'class'   : 'ea',
707           'expver'  : '1',
708           'stream'  : 'oper',
709           'type'    : 'fc',
710           'step'    : '3/to/12/by/3',
711           'param'   : '130.128',
712           'levtype' : 'ml',
713           'levelist': '135/to/137',
714           'date'    : '2013-01-01',
715           'time'    : '06/18',
716           'area'    : '50/-5/40/5',
717           'grid'    : '1.0/1.0',
718           'format'  : 'grib',
719       }, 'download_era5_cdsapi.grib')
720
721
722**Public user**
723    Please use this piece of python code:
724
725    .. code-block:: python
726
727       import cdsapi
728       
729       c = cdsapi.Client()
730       
731       c.retrieve('reanalysis-era5-complete',
732       {
733           'class'   : 'ea',
734           'dataset' : 'era5',
735           'expver'  : '1',
736           'stream'  : 'oper',
737           'type'    : 'fc',
738           'step'    : '3/to/12/by/3',
739           'param'   : '130.128',
740           'levtype' : 'ml',
741           'levelist': '135/to/137',
742           'date'    : '2013-01-01',
743           'time'    : '06/18',
744           'area'    : '50/-5/40/5',
745           'grid'    : '1.0/1.0', 
746           'format'  : 'grib',
747       }, 'download_era5_cdsapi.grib')
748
749
750
751
752
753
754.. _ref-install-local:
755
756Local Installation
757^^^^^^^^^^^^^^^^^^
758
759First prepare the Fortran ``Makefile`` for your environment and set it
760in the ``setup.sh`` script. (See section :ref:`ref-convert` for information on
761the Fortran program.)
762``flex_extract`` has already two ``Makefiles`` prepared for te ``gfortran`` and
763the ``ifort`` compiler:
764
765 *Makefile.local.gfortran
766 *Makefile.local.ifort
767
768They can be found in the path ``flex_extract_vX.X/source/fortran``, where
769``vX.X`` should be substituted with the current version number.
770
771.. caution::   
772   It is necessary to adapt **ECCODES_INCLUDE_DIR** and **ECCODES_LIB** in these
773   ``Makefiles``.
774
775
776So starting from the root directory of ``flex_extract``,
777go to the ``Fortran`` source directory and open the ``Makefile`` of your
778choice to modify with an editor of your choice. We use the ``nedit`` in this case.
779
780.. code-block:: bash
781
782   cd flex_extract_vX.X/source/fortran
783   nedit Makefile.local.gfortran
784
785Edit the pathes to the ``eccodes`` library on your local machine.
786
787.. caution::
788   This can vary from system to system.
789   It is suggested to use a command like
790
791   .. code-block:: bash
792
793      # for the ECCODES_INCLUDE_DIR path do:
794      $ dpkg -L libeccodes-dev | grep eccodes.mod
795      # for the ECCODES_LIB path do:
796      $ dpkg -L libeccodes-dev | grep libeccodes.so
797     
798   to find out the path to the ``eccodes`` library.
799   
800Substitute these paths in the ``Makefile`` for parameters **ECCODES_INCLUDE_DIR**
801and **ECCODES_LIB** and save it.
802
803.. code-block:: bash
804
805   # these are the paths on a current Debian 10 Testing system (May 2019)
806   ECCODES_INCLUDE_DIR=/usr/lib/x86_64-linux-gnu/fortran/gfortran-mod-15/
807   ECCODES_LIB= -L/usr/lib -leccodes_f90 -leccodes -lm 
808   
809   
810The Fortran program called ``CONVERT2`` will be compiled during the
811installation process to get an executable. Therefore the ``Makefile``
812has to be set in the ``setup.sh`` script.
813
814In the root directory of ``flex_extract``, open the ``setup.sh`` script
815and adapt the installation parameters in the section labelled with
816"AVAILABLE COMMANDLINE ARGUMENTS TO SET" like shown below.
817
818
819.. code-block:: bash
820   :caption: 'Example settings for a local installation.'
821   :name: setup.sh
822   
823   ...
824   # -----------------------------------------------------------------
825   # AVAILABLE COMMANDLINE ARGUMENTS TO SET
826   #
827   # THE USER HAS TO SPECIFY THESE PARAMETER
828   #
829   TARGET='local'
830   MAKEFILE='Makefile.local.gfortran'
831   ECUID=None
832   ECGID=None
833   GATEWAY=None
834   DESTINATION=None
835   INSTALLDIR=None
836   JOB_TEMPLATE='job.template'
837   CONTROLFILE='CONTROL_EA5'
838   ...
839
840
841Afterwards, type:
842
843.. code-block:: bash
844
845   $ ./setup.sh
846   
847to start the installation. You should see the following output at the command line.
848   
849   
850.. code-block:: bash
851
852   # Output of setup.sh   
853   WARNING: installdir has not been specified
854   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
855   Install flex_extract_v7.1 software at local in directory /raid60/nas/tmc/Anne/Interpolation/flexextract/flex_extract_v7.1
856
857   Using makefile: Makefile.local.gfortran
858   gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -g -O3 -fopenmp phgrreal.f
859   gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -g -O3 -fopenmp grphreal.f
860   gfortran   -m64 -fdefault-real-8 -fcray-pointer -fno-second-underscore  -ffixed-line-length-132 -fopenmp  -fconvert=big-endian  -c -g -O3 -fopenmp ftrafo.f
861   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
862   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
863   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
864   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
865
866   -rwxrwxr-x. 1 philipa8 tmc 282992 May 23 22:27 ./CONVERT2
867
868
869
870
871
872
873``Flex_extract`` in combination with ``FLEXPART``
874=================================================
875
876Some users might like to incorporate ``flex_extract`` directly into the ``FLEXPART``
877distribution. Then the installation path has to be changed by setting the parameter
878`installdir` in the ``setup.sh`` file to the ``script`` directory in the ``FLEXPART`` root directoy.
879
880
881
882
883
884
885
886
887
888.. _ref-testinstallfe:
889
890Test installation
891=================
892
893Fortran program test
894--------------------
895
896To check if the compilation of the Fortran program ``CONVERT2`` was successful
897a quick program call on a minimal prepared dataset can be done.
898
899For this, go from the ``flex_extract`` root directory to the test
900directory and call the executable of the Fortran program.
901
902.. note:: 
903   Remember that you might have to log in at the ECMWF server if you used the installation for the **remote** or **gateway** mode. There you find the ``flex_extract`` root directory in your ``$HOME`` directory.
904
905.. code-block:: bash
906   
907   cd test/Installation/Convert
908   # call the Fortran progam without arguments
909   ../../../source/fortran/CONVERT2
910
911The installation was successfull if it showed the following output:
912
913.. code-block:: bash
914
915    readspectral:            1  records read
916    readlatlon:            8  records read
917   STATISTICS:  98842.4598 98709.7359  5120.5385
918    readlatlon:            4  records read
919    readlatlon:            4  records read
920    readlatlon:            4  records read
921   SUCCESSFULLY FINISHED CONVERT_PRE: CONGRATULATIONS
922
923Now go back to the root directoy:
924
925.. code-block:: bash
926   
927   $ cd ../../../
928   
929
930Mars request test
931-----------------
932
933    IN PREPARATION ...
934
935Full test
936---------
937
938    IN PREPARATION ...
939
940   
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG