source: flex_extract.git/python/README.md @ 9e660c4

ctbtodev
Last change on this file since 9e660c4 was 5d3d09b, checked in by anphi <anne.philipp@…>, 6 years ago

Updated the README for full installation and basic execution instructions

  • Property mode set to 100644
File size: 17.7 KB
Line 
1#README
2
3This documentation shows how to install and use the ***flex_extract*** software package to extract ECMWF data and generate the ***FLEXPART*** specific input files.
4
5Introduction
6=================
7
8To run ***FLEXPART*** with ECMWF data, you first need to retrieve ECMWF GRIB fields and generate ***FLEXPART*** specific input files afterwards. ***FLEXPART*** needs the GRIB data seperated by time so that ***flex_extract*** will combine all data in output files seperated for each time step. The format of these output filenames looks like: `prefixYYMMDDHH`, where prefix can be defined in ***flex_extract*** (usually it should be limited to "2" characters because of further processing reasons).
9
10There are 4 different modes of running ***flex_extract*** :
111. Remote (**): ***flex_extract*** is installed and executed directly on the ECMWF Linux member state server ecgate. Users have to be a registered member-state user.
122. Gateway (**): ***flex_extract*** is installed on a local machine and the scripts are submitted to ECMWF
13computer facilities via a member-state gateway server. Users have to be a registered member-state user.
143. Local member state (**): ***flex_extract*** is installed and executed on a local machine. Users have to be a registered member-state user.
154. Local public (***): ***flex_extract*** is installed and executed on a local machine. Users do not have to be a member-state user. A normal registration at the ECMWF website is enough. See also the instruction to install the ECMWF Web API
16
17*(\*\*) To get a ms (member-state) user access, users have to be a resident of a [member state](https://www.ecmwf.int/en/about/who-we-are/member-states) and have to contact their national meteorological center for granting access.*
18
19*(\*\*\*) To get a public user account, the user can just register at the ECMWF website following the instructions [here](https://software.ecmwf.int/wiki/display/WEBAPI/ECMWF+Web+API+Home)!*
20
21For setting up a complete ***FLEXPART*** environment it is recommended to build a directory structure such as:
22
23 ![FLEXPART directory structure](../docs/Fp_extract_strukt.png)
24
25For installation instructions and usage of ***FLEXPART*** please see ***FLEXPART***-Documentation!
26
27Data sets archived at ECMWF
28===========================
29
30There are two modes for accessing ECMWF data sets: the **_full access_** and the **_public access_** mode.
31A description of these two modes and links to the available data sets is available here: https://www.ecmwf.int/en/forecasts/datasets/archive-datasets
32
33####  Important note for public users
34
35If you want to extract public data sets from the ECMWF servers you first have to register at the ECMWF. Do this by following the instructions at: https://software.ecmwf.int/wiki/display/WEBAPI/Access+MARS
36
37Afterwards you **_need to accept the licenses_** of the data sets you want to extract:
38
39https://software.ecmwf.int/wiki/display/WEBAPI/Available+ECMWF+Public+Datasets
40
41Now your able to use ***flex_extract*** in public mode (command line parameter "*--public=1*").
42
43Installation
44===================
45
46### Some important notes for the installation process:
47- Use the same compiler and compiler version for all libraries and the fortran program.
48- Don't forget to set all library paths to the LD_LIBRARY_PATH variable.
49- Don't forget to adapt the makefile for the Fortran program.
50
51### Requirements ###
52
53| Python Support        | Link            | Notes |
54| --------------------- |:----------------------:|:-------------------------|
55| python                | [http://www.python.org](http://www.python.org)  | We have used [Anaconda python](https://store.continuum.io/cshop/anaconda/) for our testing |
56| python-numpy          | [http://www.numpy.org/](http://www.numpy.org/)  | Not necessary if you have installed python Anaconda
57| ecmwfapi              | [https://software.ecmwf.int/wiki/display/WEBAPI/ECMWF+Web+API+Home](https://software.ecmwf.int/wiki/display/WEBAPI/ECMWF+Web+API+Home) | You also need to install your API key (as explained in the documentation)
58
59| Utilities             | Link            | Notes |
60| --------------------- |:----------------------:|:-------------------------|
61|gfortran|[https://gcc.gnu.org/wiki/GFortran](https://gcc.gnu.org/wiki/GFortran)| Make sure that you are using the same compiler version for all libraries in connection with flex_extract, GRIB_API and FLEXPART, otherwise you will have problems.|
62|  grib-api or eccodes             | [https://software.ecmwf.int/wiki/display/GRIB/Home](https://software.ecmwf.int/wiki/display/GRIB/Home) / [https://software.ecmwf.int/wiki/display/ECC](https://software.ecmwf.int/wiki/display/ECC) | Make sure you install grib_api/eccodes with JPEG support and python.|
63|FFTW|[http://www.fftw.org](http://www.fftw.org)|This is needed by the Emos library, as is mentioned in the installation instructions for Emos|
64|  Emos                 | [https://software.ecmwf.int/wiki/display/EMOS/Emoslib](https://software.ecmwf.int/wiki/display/EMOS/Emoslib) | Make sure you carefully read the instructions and have installed the FFTW package before installing Emos.|
65| CONVERT2     | |to run prepareFLEXPART.py, you need to compile the Fortran program CONVERT2 (located in the src directory). See separate README file in this directory to get instructions on how to compile this code.|
66
67###  Prepare the environment for using ***flex_extract*** on a local machine
68
69Please follow the instructions on the websites of the libraries. The installation of these libraries can be done by package installation or from scratch, for either case it is useful to consider the official documentation (and also the hints from the ECMWF) rather than trying to explain every detail in here. Nevertheless, we recommend doing the installation in the following order (see links to the libraries in the table above):
70
711. Read Emoslib installation instructions.
722. Read ECMWF blog about gfortran (https://software.ecmwf.int/wiki/display/SUP/2015/05/11/Building+ECMWF+software+with+gfortran).
733. Install FFTW.
744. Install EMOSLIB (Hint: Apply make 2 times! One time without any options and one time with single precision option.).
755. Install ECCODES OR GRIB_API (for python and fortran). ECCODES is downward compatible with GRIB_API and GRIB_API support will expire at the end of 2018.
766. Register at Mars (see link to ecmwfapi).
777. Install ECMWF_WEBAPI.
788. Check LD_LIBRARY_PATH environment variable if it contains all paths to the libs.
799. Check available python packages (e.g. check in python console the commands: import eccodes / import grib_api / import ecmwfapi)
8010. Start a simple test retrieval (following the instructions at ECMWF Web API website).
8111. Install ***flex_extract*** (see next section).
82
83### Installation of ***flex_extract***
84
85To install ***flex_extract*** you have to go to the python directory and call the `install.py` script. It has the following options:
86
87```
88usage: install.py [-h] [--target INSTALL_TARGET] [--makefile MAKEFILE]
89                  [--ecuid ECUID] [--ecgid ECGID] [--gateway GATEWAY]
90                  [--destination DESTINATION]
91                  [--flexpart_root_scripts FLEXPART_ROOT_SCRIPTS]
92                  [--job_template JOB_TEMPLATE] [--controlfile CONTROLFILE]
93
94Install flex_extract software locally or on ECMWF machines
95
96optional arguments:
97  -h, --help            show this help message and exit
98  --target INSTALL_TARGET
99                        Valid targets: local | ecgate | cca , the latter two
100                        are at ECMWF (default: None)
101  --makefile MAKEFILE   Name of Makefile to use for compiling CONVERT2
102                        (default: None)
103  --ecuid ECUID         user id at ECMWF (default: None)
104  --ecgid ECGID         group id at ECMWF (default: None)
105  --gateway GATEWAY     name of local gateway server (default: None)
106  --destination DESTINATION
107                        ecaccess destination, e.g. leo@genericSftp (default:
108                        None)
109  --flexpart_root_scripts FLEXPART_ROOT_SCRIPTS
110                        FLEXPART root directory on ECMWF servers (to find
111                        grib2flexpart and COMMAND file) Normally flex_extract
112                        resides in the scripts directory of the FLEXPART
113                        distribution, thus the: (default: None)
114  --job_template JOB_TEMPLATE
115                        job template file for submission to ECMWF (default:
116                        job.temp.o)
117  --controlfile CONTROLFILE
118                        file with control parameters (default: CONTROL.temp)
119```
120
121
122#### Local installation of ***flex_extract*** (***flex_extract*** modes 1 (on ECMWF servers), 3 and 4)
123
124---
125
126For a local installation of ***flex_extract*** the user has to adapt the makefile for the Fortran program first. Set the paths to the grib_api or eccodes library and emoslib. Then the installation script should be called as follows:
127
128```
129./install.py --target=local --makefile=Makefile.local.gfortan
130```
131
132where the makefile name can differ if the user prepared another makefile for his environment.
133On ECMWF servers a makefile named "Makefile.gfortran" is already provided in the "src"-directory. It is also the default makefile, so that the parameter does not have to be set when calling "install.py".
134
135If the ***flex_extract*** is to be installed within a ***FLEXPART*** environment it should be called with the parameter `flexpart_root_scripts` to let ***flex_extract*** know about the path to ***FLEXPART***.
136
137The installation was successful if the compilation of the Fortran program ``CONVERT2`` didn't fail and is displayed in the terminal.
138
139#### Installation using a gateway server (***flex_extract*** mode 2 only)
140
141---
142
143If the user has a gateway server and the Ecaccess toolkit available, ***flex_extract*** can be installed such that it is executed on the local machine and a job script is submitted to the ECMWF server. The final ***FLEXPART*** input files are then send back via the Ecaccess command line tool "ectrans". To use this tool, the user has to create an association directly on the local gateway server via the localhost ecaccess.ecmwf.int and provide the association name as the "destination"-parameter when calling "install.py".
144
145The gateway server has to be registered at ECMWF. For information about a gateway server see:
146- https://software.ecmwf.int/wiki/display/ECAC/Releases+-+Gateway+package
147- and the Software Installation Plan (SIP.pdf) in the docs/ directory.
148
149Afterwards ***flex_extract*** can be installed with the following command:
150```
151./install.py --target=local --makefile=Makefile.gfortan --ecuid=<id> --ecgid=<gid> --gateway=<servername> --destination=<destinationname>
152```
153
154If the installation was successful the user gets an email with a success note!
155
156
157Using ***flex_extract***
158===================
159
160This section provides the absolut basics on how ***flex_extract*** is to be used. For more information about possible settings, performance, parameter combinations and so one, the user is referred to the SIP.pdf and SUT.pdf documents and the www.flexpart.eu community website. It is also possible to ask for help by writing to the ***FLEXPART*** user email list (registration needed) or by creating a ticket on the community website.
161
162#### CONTROL file
163
164***flex_extract*** is controlled by providing "CONTROL"-files with a list of parameter settings. These parameter are described in detail in the *Software User Tutorial (SUT.pdf)*.
165The "CONTROL"-files specifies which ECMWF data set is to be retrieved, the time and spatial resolution, the format of the grib file and many more. In the `python` directory are some example `CONTROL` files for the different data sets and access modes which can be retrieved with ***flex_extract***:
166
167```
168CONTROL_CERA
169CONTROL_CV
170CONTROL_EA5.public
171CONTROL_FC.pure
172CONTROL_OD.highres.gauss
173CONTROL_CERA.public
174CONTROL_EA5
175CONTROL_EI.global
176CONTROL_FC.twiceaday
177CONTROL_OPS.4V
178CONTROL_CF
179CONTROL_EA5.highres
180CONTROL_EI.public
181CONTROL_OD.highres.eta
182CONTROL.temp
183```
184
185For information about all the possible parameter settings and explanation, please see the SUT.pdf document in the `docs/` directory.
186
187`CONTROL`-files with a `.public` ending is usable for the public access mode. The main difference is the parameter ``dataset`` which explicitly specifies the public data sets. Additionally, not all meteorological fields and times were archived in the public data sets and are considered in the public `CONTROL`-files.
188
189#### Python scripts
190
191* `submit.py`
192
193This is the main program for doing both, retrieving ECMWF data and generating the ***FLEXPART*** input files. It combines the two sub-programs `getMARSdata.py` and `prepareFLEXPART.py` which can also be run by themselves for debugging purposes.
194Use the `-h` option to get the parameter options:
195
196```
197usage: submit.py [-h] [--start_date START_DATE] [--end_date END_DATE]
198                 [--date_chunk DATE_CHUNK] [--basetime BASETIME] [--step STEP]
199                 [--levelist LEVELIST] [--area AREA] [--inputdir INPUTDIR]
200                 [--outputdir OUTPUTDIR]
201                 [--flexpart_root_scripts FLEXPART_ROOT_SCRIPTS] [--ppid PPID]
202                 [--job_template JOB_TEMPLATE] [--queue QUEUE]
203                 [--controlfile CONTROLFILE] [--debug DEBUG] [--public PUBLIC]
204
205Retrieve FLEXPART input from ECMWF MARS archive
206
207optional arguments:
208  -h, --help            show this help message and exit
209  --start_date START_DATE
210                        start date YYYYMMDD (default: None)
211  --end_date END_DATE   end_date YYYYMMDD (default: None)
212  --date_chunk DATE_CHUNK
213                        # of days to be retrieved at once (default: None)
214  --basetime BASETIME   base such as 00/12 (for half day retrievals) (default:
215                        None)
216  --step STEP           steps such as 00/to/48 (default: None)
217  --levelist LEVELIST   Vertical levels to be retrieved, e.g. 30/to/60
218                        (default: None)
219  --area AREA           area defined as north/west/south/east (default: None)
220  --inputdir INPUTDIR   root directory for storing intermediate files
221                        (default: None)
222  --outputdir OUTPUTDIR
223                        root directory for storing output files (default:
224                        None)
225  --flexpart_root_scripts FLEXPART_ROOT_SCRIPTS
226                        FLEXPART root directory (to find grib2flexpart and
227                        COMMAND file) Normally flex_extract resides in the
228                        scripts directory of the FLEXPART distribution
229                        (default: None)
230  --ppid PPID           Specify parent process id for rerun of prepareFLEXPART
231                        (default: None)
232  --job_template JOB_TEMPLATE
233                        job template file for submission to ECMWF (default:
234                        job.temp)
235  --queue QUEUE         queue for submission to ECMWF (e.g. ecgate or cca )
236                        (default: None)
237  --controlfile CONTROLFILE
238                        file with control parameters (default: CONTROL.temp)
239  --debug DEBUG         Debug mode - leave temporary files intact (default: 0)
240  --public PUBLIC       Public mode - retrieves the public datasets (default:
241                        0)
242```
243
244*Optional arguments are listed in squared brackets.*
245
246
247* `getMARSdata.py`
248
249This program retrieves the ECMWF data from ECMWF servers using [ECMWF WebApi](https://software.ecmwf.int/wiki/display/WEBAPI/ECMWF+Web+API+Home) or [Mars](https://software.ecmwf.int/wiki/display/UDOC/MARS+user+documentation), depending on your user status and your selection of the running mode. It requires the `ECMWF WebApi` python library (see Requirements below). Check with your local IT group as it may be already available.
250
251
252* `prepareFLEXPART.py`
253
254This program generates FLEXPART input files from the retrieved meteorological fields. It requires python interface to grib_api or eccodes and the Fortran program `CONVERT2` (located in `src` directory). `CONVERT2` needs a namelist which is generated from the python program.
255
256#### execute flex_extract locally (member-state user)
257
258Almost every command line parameter for the `submit.py` script call has a default value or is read from the specified `CONTROL` file.
259Therefore, for a local extraction of ERA-Interim data as a member-state user the script can be called simply by passing a `CONTROL` file and a starting date with the following command:
260```
261./submit.py --controlfile=CONTROL_EI.global --start_date=20101201
262```
263If there was just a starting date without an end date, ***flex_extract*** retrieves just this one day of meteorological data. The `CONTROL_EI.global` file has a set of default values which needs to be adjusted regarding users needs. It is also possible to set the dates within the `CONTROL`-file instead of passing it via command line parameter.
264
265
266#### execute flex_extract locally (public user)
267
268As a public user one has to use the `CONTROL` file with the `.public` extension and the parameter `public`:
269```
270./submit.py --controlfile=CONTROL_EI.public --start_date=20101201 --public=1
271```
272Otherwise, except of the different data available, the usage of ***flex_extract*** is the same as for member-state users.
273
274#### execute flex_extract via gateway server
275
276If ***flex_extract*** was installed via a gateway server and a file "*ECMWF_ENV*" is available in the ``python``-directory, the ``submit.py`` script can be called with the `--queue` option. A job script is then prepared and submitted to the ECMWF server (in this case, "ecgate") .
277
278```
279./submit.py --queue=ecgate --controlfile=CONTROL_EI.global --start_date=20101201
280```
281
282The job status can then be checked by typing:
283````
284ecaccess-job-list
285````
286
287If the parameters *ecuid*, *ecgid*, *gateway* and *destination* were set correctly during installation and the gateway server is running, the resulting ***FLEXPART*** input files can be directly transferred to the local gateway by setting the paramter ``ectrans`` in the ``CONTROL``-file to ``1``.
288
289Regardless of the job being successful or not, the user will receive an email with the log messages.
290
291#  Installation FAQ
292
293
294
295
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG