An interpolation programme coded in Fortran for irregular
Interpolation is commonly used in geophysical sciences for post-treatment processing to evaluate model performance against ground station observations. The NetCDF Operators (NCO) library
The parameterization techniques proposed to manage aerosol–droplet microphysical schemes
A Python procedure called
In order to quantify the impact of such a new interpolation programme and show examples of its use, it is implemented in the Backplumes back-trajectory model, developed by the same team as the CHIMERE model
The NterGeo programme is fit for exploring irregular but structured grids or look-up tables defined by a unique size for each dimension, which of course can be different from one to another dimension. The space intervals can vary along a dimension and the grid interval edges in each dimension can depend on other dimensions. Two versions have been developed: (i) a version for “regular” arrays with independent dimensions and (ii) a “general” version for possible interdependent dimensions, e.g. to handle 3-D meshes which have time-varying spatial coordinates. The code does not need any libraries and is written in standard Fortran.
Our interpolation code was tested with
A programme (
Description of variables for
For the particular case of a regular grid with independent dimensions, the result
Variable
The tuple
Considering the general programme called
Once the nearest neighbour is found, the result
The list of input/output arguments is provided in Appendix Find the nearest neighbour of the input data by minimizing a distance with a simple incremental method stepping every Scan the surroundings of the nearest point within the matrix on Calculate the distance to the previously selected input data. A Sort the previous block of data in ascending order and stop the sorting process when the first Calculate the weights and then the final result.
The first step consisting in finding the first neighbour is the trickiest and is broken down into several steps. Figure
The procedure initializes the process starting from the first point of the input data grid or taken from the last closest point if given in an argument as a non-null value. A delta of coordinates is applied based on an average delta on each dimension to improve the initialization. This computation step of delta is externalized as it can be time consuming and should be done once for all target points at which we want to interpolate. A test between the target value and the input data grid point coordinates determines the If the grid point falls on the edges or outside the borders, the closest coordinates within the matrix are selected. A test on the If the distance is larger than the characteristic distance of the cell, the point is considered to be outside the borders of the input data grid. Therefore, the code allows a slight extrapolation if the target point is not too far from the borders. At this stage, the procedure can stop if the distance to the closest vertex is 0, returning to the main programme with the exact value of the input data grid.
Real example in 2-D of the step-by-step procedure to find the nearest neighbour of a target point for an irregular but structured
As an example to visualize the capacity of the general programme, the 2-D function used in
Our input data grid is a regular grid with regular intervals of 0.02 from 0 to 1 for
For the three cases, the CPU time for the interpolation is evaluated and displayed in Table
Interpolation results for the three cases. Figures were generated with the Generic Mapping Tools
Performance for each case with
Evolution of performance based on the NMSE for the three cases as a function of the parameter
Still using the general programme, an example in 5-D (
Performance for the 5-D (
Another test with the 5-D case is performed to test the influence of the normalization as defined in Eq. (
The code has been tested against the Python procedure
The input data grid is a regular grid of
Table
Comparison of performance between our code for a 3-D case with the grid data Python library. Machine 2 is used (Appendix
In order to test this new interpolation programme, it is implemented in a back-trajectory model called Backplumes. This model was already used in some studies such as
An advantage of Backplumes for the WRF and CHIMERE users is that the code is dedicated to directly read output results of these models. Being developed by the CHIMERE developer teams, the code is completely homogeneous with CHIMERE in terms of numerical libraries. Another advantage is that the code is very fast and calculates hundreds of trajectories in a few minutes. Using the wind fields of WRF or CHIMERE, and running on the same grid, the results of back trajectories are fully consistent with the simulations done by the models.
Backplumes is dedicated to calculate transport but not chemistry: only passive air particles (or tracers) are released. But a distinction could be made between gaseous or particulate tracers: for the latter, a settling velocity is calculated to have a more realistic trajectory. The model is easy to use and light because a small set of meteorological parameters is required. These meteorological parameters are described in Table
The first step of the calculation is to choose a target location as a starting point. The user must select a date, longitude, latitude and altitude, obviously included in the modelled domain and during the modelled period. From this starting point, the model will calculate trajectories back in time. The number of trajectories is up to the user and may vary from one to several hundreds of tracers.
At each time step and for each trajectory, the position of the air mass is estimated by subtracting its pathway travelled as longitude
In order to respect the Courant–Friedrichs–Lewy (CFL) number, a sub-time step may be calculated. If the input data are provided hourly (as in many regional models), the meteorological variables are interpolated between the two consecutive hours to obtain refined input data.
The goal of Backplumes is to estimate all possible back trajectories. Then, starting from one unique point, it is necessary to add a pseudo-turbulence in the calculation of the altitude. Depending on the vertical position of the tracer, several hypotheses are made. Two parameters are checked for each tracer and each time step: (i) the boundary layer height enables us to know if the tracer is in the boundary layer or above in the free troposphere, (ii) the surface sensible heat fluxes enable to know if the atmosphere is stable or unstable.
When the tracer is diagnosed in the boundary layer, there are two cases: the boundary layer is stable or unstable.
If the boundary layer is stable,
If the boundary layer is unstable,
The random function “Rand” calculates a coefficient between 0 and 1 to represent stochastic vertical transport of the tracer.
It is considered that 15 mn is representative of a well-mixed convective layer
In the free troposphere, the evolution of the tracer is considered to be influenced by the vertical wind component. A random function is applied to estimate its possible vertical motion with values between 0 and
Back trajectories calculated using CHIMERE and WRF modelled meteorological fields. The starting point is at longitude 10
An example is presented for the same case and the WRF and CHIMERE models. The difference between the two models is the number of vertical levels (35 for WRF and 20 for CHIMERE, from the surface to 200 hPa). The online modelling system WRF-CHIMERE is used, meaning that the horizontal grid is the same (a large domain including Europe and Africa and with
Figure
The most important part of the plume comes from the north of the starting point. For this main plume, the calculation is similar between the two models. Another large part of Backplumes is modelled at the east of the starting point. However, this fraction is mainly modelled with WRF but not with CHIMERE, where only a few trajectories are diagnosed. One possible explanation may be found by analysing the vertical transport of the trajectories.
Projection of all back trajectories on a single time–altitude axis.
Figure
A new interpolation programme written in Fortran has been developed to interpolate on
This piece of code shows the strategy to optimize the computation of weights for the “regular case”. The idea is to minimize the number of operations to benefit from the calculation at each dimension.
A non-optimized loop would require
Note that
Description of subroutine arguments.
Some hard-coded variables can be tested by the user to improve the results. They have been tested and some results are described in this paper. A recompilation is necessary if the user changes these values.
Below is an example of a 5-D array input grid data with irregular intervals with the last dimension (5) depending on dimension (1).
Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte order: Little Endian CPU(s): 64 Online CPU(s) list: 0–63 Thread(s) per core: 2 Core(s) per socket: 8 Socket(s): 4 NUMA node(s): 8 Vendor ID: AuthenticAMD CPU family: 21 Model: 1 Model name: AMD Opteron Processor 6276 Stepping: 2 CPU MHz: 2300.000 CPU max MHz: 2300.0000 CPU min MHz: 1400.0000 BogoMIPS: 4599.83 Virtualization: AMD-V L1d cache: 16 KB L1i cache: 64 KB L2 cache: 2048 KB L3 cache: 6144 KB Memory block size: 128 MB Total online memory: 128 GB Total offline memory: 0 B Linux version 3.10.0-1062.12.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39)
Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte order: Little Endian CPU(s): 96 Online CPU(s) list: 0–47 Offline CPU(s) list: 48–95 Thread(s) per core: 1 Core(s) per socket: 24 Socket(s): 2 NUMA node(s): 2 Vendor ID: GenuineIntel CPU family: 6 Model: 85 Model name: Intel Xeon Platinum 8168 CPU at 2.70 GHz Stepping: 4 CPU MHz: 2701.000 CPU max MHz: 2701.0000 CPU min MHz: 1200.0000 BogoMIPS: 5400.00 Virtualization: VT-x L1d cache: 32 KB L1i cache: 32 KB L2 cache: 1024 KB L3 cache: 33 792 KB NUMA node0 CPU(s): 0–23 NUMA node1 CPU(s): 24–47 Memory block size: 128 MB Total online memory: 190.8 GB Linux version 3.10.0-957.41.1.el7.x86_64 (mockbuild@x86-vm-26.build.eng.bos.redhat.com) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36)
Parameters are the three-dimensional wind components, the boundary layer height
Backplumes calculates the back trajectories using longitude, latitude and altitude in metres. In the case of input data with vertical levels in pressure coordinates, the altitude is calculated from pressure levels
The altitude is computed as
List of parameters read by the Backplumes programme to calculate trajectories.
The new position of a tracer back in time is calculated as follows:
The current versions of the models are freely available. The exact version of the model used to produce the results used in this paper is archived on Zenodo for NterGeo at
BB developed the code. LM and BB co-developed and implemented the code in the Backplumes.v2020r1 model. MB supported BB for the developments.
The authors declare that they have no conflict of interest.
This research was funded by the DGA (French Directorate General of Armaments; grant no. 2018 60 0074) in the framework of the NETDESA project.
This paper was edited by Juan Antonio Añel and reviewed by two anonymous referees.