source: flex_extract.git/Documentation/html/_sources/installation.rst.txt @ 6bc4b42

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

capitalize all directory names and adapt pathes in files

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