mirror of https://github.com/ecmwf/eccodes.git
Merge branch 'develop' into feature/GRIB2-discipline192-legacy
This commit is contained in:
commit
36cd38a833
|
@ -24,6 +24,7 @@
|
|||
22 22 Version implemented on 7 November 2018
|
||||
23 23 Version implemented on 15 May 2019
|
||||
24 24 Version implemented on 6 November 2019
|
||||
25 25 Pre-operational to be implemented by next amendment
|
||||
# 25-254 Future versions
|
||||
25 25 Version implemented on 6 May 2020
|
||||
26 26 Pre-operational to be implemented by next amendment
|
||||
# 27-254 Future versions
|
||||
255 255 Master tables not used. Local table entries and local templates may use the entire range of the table, not just those sections marked Reserved for local used.
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
2 2 Land surface products
|
||||
3 3 Satellite remote sensing products (formerly Space products)
|
||||
4 4 Space weather products
|
||||
# 5-9 Reserved
|
||||
10 10 Oceanographic products
|
||||
# 11-19 Reserved
|
||||
20 20 Health and socioeconomic impacts
|
||||
# 21-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
||||
|
|
|
@ -24,5 +24,6 @@
|
|||
22 22 Version implemented on 7 November 2018
|
||||
23 23 Version implemented on 15 May 2019
|
||||
24 24 Version implemented on 6 November 2019
|
||||
# 25-254 Future versions
|
||||
25 25 Version implemented on 6 May 2020
|
||||
# 26-254 Future versions
|
||||
255 255 Master tables not used. Local table entries and local templates may use the entire range of the table, not just those sections marked Reserved for local used.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Code table 3.2 - Shape of the Earth
|
||||
# Code table 3.2 - Shape of the reference system
|
||||
0 0 Earth assumed spherical with radius = 6 367 470.0 m
|
||||
1 1 Earth assumed spherical with radius specified (in m) by data producer
|
||||
2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0)
|
||||
|
@ -9,6 +9,8 @@
|
|||
7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer
|
||||
8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS-84 reference frame
|
||||
9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height
|
||||
# 10-191 Reserved
|
||||
10 10 Earth model assumed WGS84 with corrected geomagnetic coordinates (latitude and longitude) defined by Gustafsson et al., 1992
|
||||
11 11 Sun assumed spherical with radius = 695,990,000 m (Allen, C.W., 1976 Astrophysical Quantities (3rd Ed.; London: Athlone) and Stonyhurst latitude and longitude system with origin at the intersection of the solar central meridian (as seen from Earth) and the solar equator (Thompson, W, Coordinate systems for solar image data, A&A 449, 791–803 (2006))
|
||||
# 12-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
# Code table 4.1 - Parameter category by product discipline
|
||||
0 0 Temperature
|
||||
1 1 Momentum
|
||||
2 2 Charged particle mass and number
|
||||
3 3 Electric and magnetic fields
|
||||
4 4 Energetic particles
|
||||
5 5 Waves
|
||||
6 6 Solar electromagnetic emissions
|
||||
7 7 Terrestrial electromagnetic emissions
|
||||
8 8 Imagery
|
||||
9 9 Ion-neutral coupling
|
||||
10 10 Space weather indices
|
||||
# 11-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
|
@ -36,6 +36,7 @@
|
|||
34 34 Visibility through ice fog (m)
|
||||
35 35 Visibility through blowing snow (m)
|
||||
36 36 Presence of snow squalls (Code table 4.222)
|
||||
# 37-191 Reserved
|
||||
37 37 Icing severity (Code table 4.228)
|
||||
# 38-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
25 25 Snow depth at elevation bands (kg m-2)
|
||||
26 26 Soil heat flux (W m-2)
|
||||
27 27 Soil depth (m)
|
||||
# 28-191 Reserved
|
||||
28 28 Snow temperature (K)
|
||||
# 29-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
2 2 Haines index (Numeric)
|
||||
3 3 Fire burned area (%)
|
||||
4 4 Fosberg index (Numeric)
|
||||
5 5 Forest Fire Weather Index (Canadian Forest Service) (Numeric)
|
||||
6 6 Fine Fuel Moisture Code (Canadian Forest Service) (Numeric)
|
||||
7 7 Duff Moisture Code (Canadian Forest Service) (Numeric)
|
||||
8 8 Drought Code (Canadian Forest Service) (Numeric)
|
||||
9 9 Initial Fire Spread Index (Canadian Forest Service) (Numeric)
|
||||
10 10 Fire Buildup Index (Canadian Forest Service) (Numeric)
|
||||
11 11 Fire Daily Severity Rating (Canadian Forest Service) (Numeric)
|
||||
5 5 Forest Fire Weather Index (as defined by the Canadian Forest Service) (Numeric)
|
||||
6 6 Fine Fuel Moisture Code (as defined by the Canadian Forest Service) (Numeric)
|
||||
7 7 Duff Moisture Code (as defined by the Canadian Forest Service) (Numeric)
|
||||
8 8 Drought Code (as defined by the Canadian Forest Service) (Numeric)
|
||||
9 9 Initial Fire Spread Index (as defined by the Canadian Forest Service) (Numeric)
|
||||
10 10 Fire Buildup Index (as defined by the Canadian Forest Service) (Numeric)
|
||||
11 11 Fire Daily Severity Rating (as defined by the Canadian Forest Service) (Numeric)
|
||||
# 12-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
# Code table 4.2 - Parameter number by product discipline and parameter category
|
||||
0 0 Glacier cover (Proportion)
|
||||
1 1 Glacier temperature (K)
|
||||
# 2-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
0 0 Malaria cases (Fraction)
|
||||
1 1 Malaria circumsporozoite protein rate (Fraction)
|
||||
2 2 Plasmodium falciparum entomological inoculation rate (Bites per day per person)
|
||||
3 3 Human bite rate by anopheles vectors (Bites per day per person)
|
||||
4 4 Malaria immunity (Fraction)
|
||||
5 5 Falciparum parasite rates (Fraction)
|
||||
3 3 Human bite rate by anopheles vectors (Bites per day per person)
|
||||
4 4 Malaria immunity (Fraction)
|
||||
5 5 Falciparum parasite rates (Fraction)
|
||||
6 6 Detectable falciparum parasite ratio (after day 10) (Fraction)
|
||||
7 7 Anopheles vector to host ratio (Fraction)
|
||||
8 8 Anopheles vector number (Number m-2)
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
# Code table 4.2 - Parameter number by product discipline and parameter category
|
||||
0 0 Temperature (K)
|
||||
1 1 Electron temperature (K)
|
||||
2 2 Proton temperature (K)
|
||||
3 3 Ion temperature (K)
|
||||
4 4 Parallel temperature (K)
|
||||
5 5 Perpendicular temperature (K)
|
||||
# 6-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
|
@ -0,0 +1,8 @@
|
|||
# Code table 4.2 - Parameter number by product discipline and parameter category
|
||||
0 0 Velocity magnitude (speed) (m s-1)
|
||||
1 1 1st vector component of velocity (coordinate system dependent) (m s-1)
|
||||
2 2 2nd vector component of velocity (coordinate system dependent) (m s-1)
|
||||
3 3 3rd vector component of velocity (coordinate system dependent) (m s-1)
|
||||
# 4-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
|
@ -0,0 +1,12 @@
|
|||
# Code table 4.2 - Parameter number by product discipline and parameter category
|
||||
0 0 Scintillation index (sigma phi) (rad)
|
||||
1 1 Scintillation index S4 (Numeric)
|
||||
2 2 Rate of Change of TEC Index (ROTI) (TECU/min)
|
||||
3 3 Disturbance Ionosphere Index Spatial Gradient (DIXSG) (Numeric)
|
||||
4 4 Along Arc TEC Rate (AATR) (TECU/min)
|
||||
5 5 Kp (Numeric)
|
||||
6 6 Equatorial disturbance storm time index (Dst) (nT)
|
||||
7 7 Auroral Electrojet (AE) (nT)
|
||||
# 8-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
|
@ -0,0 +1,18 @@
|
|||
# Code table 4.2 - Parameter number by product discipline and parameter category
|
||||
0 0 Particle number density (m-3)
|
||||
1 1 Electron density (m-3)
|
||||
2 2 Proton density (m-3)
|
||||
3 3 Ion density (m-3)
|
||||
4 4 Vertical total electron content (TECU)
|
||||
5 5 HF absorption frequency (Hz)
|
||||
6 6 HF absorption (dB)
|
||||
7 7 Spread F (m)
|
||||
8 8 h’ (m)
|
||||
9 9 Critical frequency (Hz)
|
||||
10 10 Maximal usable frequency (MUF) (Hz)
|
||||
11 11 Peak height (hm) (m)
|
||||
12 12 Peak density (Nm) (m-3)
|
||||
13 13 Equivalent slab thickness (tau) (km)
|
||||
# 14-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
|
@ -0,0 +1,12 @@
|
|||
# Code table 4.2 - Parameter number by product discipline and parameter category
|
||||
0 0 Magnetic field magnitude (T)
|
||||
1 1 1st vector component of magnetic field (T)
|
||||
2 2 2nd vector component of magnetic field (T)
|
||||
3 3 3rd vector component of magnetic field (T)
|
||||
4 4 Electric field magnitude (V m-1)
|
||||
5 5 1st vector component of electric field (V m-1)
|
||||
6 6 2nd vector component of electric field (V m-1)
|
||||
7 7 3rd vector component of electric field (V m-1)
|
||||
# 8-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
|
@ -0,0 +1,11 @@
|
|||
# Code table 4.2 - Parameter number by product discipline and parameter category
|
||||
0 0 Proton flux (differential) ((m2 s sr eV)-1)
|
||||
1 1 Proton flux (integral) ((m2 s sr )-1)
|
||||
2 2 Electron flux (differential) ((m2 s sr eV)-1)
|
||||
3 3 Electron flux (integral) ((m2 s sr)-1)
|
||||
4 4 Heavy ion flux (differential) ((m2 s sr eV/nuc)-1)
|
||||
5 5 Heavy ion flux (integral) ((m2 s sr)-1)
|
||||
6 6 Cosmic ray neutron flux (/h)
|
||||
# 7-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
|
@ -0,0 +1,8 @@
|
|||
# Code table 4.2 - Parameter number by product discipline and parameter category
|
||||
0 0 Amplitude (dB)
|
||||
1 1 Phase (rad)
|
||||
2 2 Frequency (Hz)
|
||||
3 3 Wave length (m)
|
||||
# 4-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
|
@ -0,0 +1,11 @@
|
|||
# Code table 4.2 - Parameter number by product discipline and parameter category
|
||||
0 0 Integrated solar irradiance (W m-2)
|
||||
1 1 Solar X-ray flux (XRS long) (W m-2)
|
||||
2 2 Solar X-ray flux (XRS short) (W m-2)
|
||||
3 3 Solar EUV irradiance (W m-2)
|
||||
4 4 Solar spectral irradiance (W m-2 nm-1)
|
||||
5 5 F10.7 (W m-2 Hz-1)
|
||||
6 6 Solar radio emissions (W m-2 Hz-1)
|
||||
# 7-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
|
@ -0,0 +1,8 @@
|
|||
# Code table 4.2 - Parameter number by product discipline and parameter category
|
||||
0 0 Limb intensity (J m-2 s-1)
|
||||
1 1 Disk intensity (J m-2 s-1)
|
||||
2 2 Disk intensity day (J m-2 s-1)
|
||||
3 3 Disk intensity night (J m-2 s-1)
|
||||
# 4-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
|
@ -0,0 +1,12 @@
|
|||
# Code table 4.2 - Parameter number by product discipline and parameter category
|
||||
0 0 X-ray radiance (W sr-1 m-2)
|
||||
1 1 EUV radiance (W sr-1 m-2)
|
||||
2 2 H-alpha radiance (W sr-1 m-2)
|
||||
3 3 White light radiance (W sr-1 m-2)
|
||||
4 4 CaII-K radiance (W sr-1 m-2)
|
||||
5 5 White light coronagraph radiance (W sr-1 m-2)
|
||||
6 6 Heliospheric radiance (W sr-1 m-2)
|
||||
7 7 Thematic mask (Numeric)
|
||||
# 8-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
|
@ -0,0 +1,7 @@
|
|||
# Code table 4.2 - Parameter number by product discipline and parameter category
|
||||
0 0 Pedersen conductivity (S m-1)
|
||||
1 1 Hall conductivity (S m-1)
|
||||
2 2 Parallel conductivity (S m-1)
|
||||
# 3-191 Reserved
|
||||
# 192-254 Reserved for local use
|
||||
255 255 Missing
|
|
@ -0,0 +1,8 @@
|
|||
# Code table 4.228 - Icing severity
|
||||
0 0 None
|
||||
1 1 Trace
|
||||
2 2 Light
|
||||
3 3 Moderate
|
||||
4 4 Severe
|
||||
# 5-254 Reserved
|
||||
255 255 Missing value
|
|
@ -23,7 +23,14 @@
|
|||
23 23 Lowest level where air concentration exceeds the specified value (base for a given threshold of air concentration) (Bq m-3)
|
||||
24 24 Highest level where air concentration exceeds the specified value (top for a given threshold of air concentration) (Bq m-3)
|
||||
25 25 Highest level where radar reflectivity exceeds the specified value (echo top for a given threshold of reflectivity) (dBZ)
|
||||
# 26-99 Reserved
|
||||
# 26-29 Reserved
|
||||
30 30 Specified radius from the center of the Sun (m)
|
||||
31 31 Solar photosphere
|
||||
32 32 Ionospheric D-region level
|
||||
33 33 Ionospheric E-region level
|
||||
34 34 Ionospheric F1-region level
|
||||
35 35 Ionospheric F2-region level
|
||||
# 36-99 Reserved
|
||||
100 pl Isobaric surface (Pa)
|
||||
101 sfc Mean sea level
|
||||
102 102 Specific altitude above mean sea level (m)
|
||||
|
@ -47,7 +54,8 @@
|
|||
# 120-149 Reserved
|
||||
150 150 Generalized vertical height coordinate
|
||||
151 sol Soil level (Numeric)
|
||||
# 152-159 Reserved
|
||||
152 152 Sea ice level (Numeric)
|
||||
# 153-159 Reserved
|
||||
160 160 Depth below sea level (m)
|
||||
161 161 Depth below water surface (m)
|
||||
162 162 Lake or river bottom (-)
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
# 201-49151 Reserved
|
||||
# 49152-65534 Reserved for local use
|
||||
40000 40000 JPEG2000 Packing
|
||||
40010 40010 PNG pacling
|
||||
40010 40010 PNG packing
|
||||
50000 50000 Sperical harmonics ieee packing
|
||||
50001 50001 Second order packing
|
||||
50002 50002 Second order packing
|
||||
|
|
72
memfs.py
72
memfs.py
|
@ -12,7 +12,7 @@ assert len(sys.argv) > 2
|
|||
# METAR and TAF are also experimental
|
||||
EXCLUDED = ['grib3', 'codetables', 'taf', 'metar']
|
||||
|
||||
pos=1
|
||||
pos = 1
|
||||
if sys.argv[1] == '-exclude':
|
||||
product = sys.argv[2]
|
||||
if product == 'bufr':
|
||||
|
@ -28,7 +28,9 @@ print('Directories: ', dirs)
|
|||
print('Excluding: ', EXCLUDED)
|
||||
|
||||
FILES = {}
|
||||
SIZES = {}
|
||||
NAMES = []
|
||||
CHUNK = 5500 * 1000 # chunk size in bytes
|
||||
|
||||
# Binary to ASCII function. Different in Python 2 and 3
|
||||
try:
|
||||
|
@ -38,20 +40,28 @@ except:
|
|||
ascii = lambda x: str(x) # Python 2
|
||||
|
||||
|
||||
# The last argument is the path of the generated C file
|
||||
output_file_path = sys.argv[-1]
|
||||
g = open(output_file_path, "w")
|
||||
def get_outfile_name(base, count):
|
||||
return base + "_" + str(count).zfill(3) + ".c"
|
||||
|
||||
|
||||
# The last argument is the base name of the generated C file(s)
|
||||
output_file_base = sys.argv[-1]
|
||||
totsize = 0 # amount written
|
||||
fcount = 0
|
||||
opath = get_outfile_name(output_file_base, fcount)
|
||||
print('MEMFS: Generating output: ', opath)
|
||||
g = open(opath, "w")
|
||||
|
||||
for directory in dirs:
|
||||
|
||||
# print("---->", directory)
|
||||
# print("MEMFS: directory=", directory)
|
||||
dname = os.path.basename(directory)
|
||||
NAMES.append(dname)
|
||||
|
||||
for dirpath, dirnames, files in os.walk(directory, followlinks=True):
|
||||
for ex in EXCLUDED:
|
||||
if ex in dirnames:
|
||||
print('Note: eccodes memfs.py script: %s/%s will not be included.' % (dirpath,ex))
|
||||
# for ex in EXCLUDED:
|
||||
# if ex in dirnames:
|
||||
# print('Note: eccodes memfs.py script: %s/%s will not be included.' % (dirpath,ex))
|
||||
|
||||
# Prune the walk by modifying the dirnames in-place
|
||||
dirnames[:] = [dirname for dirname in dirnames if dirname not in EXCLUDED]
|
||||
|
@ -61,34 +71,51 @@ for directory in dirs:
|
|||
if ext not in ['.def', '.table', '.tmpl']:
|
||||
continue
|
||||
|
||||
full = full.replace("\\","/")
|
||||
fsize = os.path.getsize(full)
|
||||
totsize += fsize
|
||||
full = full.replace("\\", "/")
|
||||
fname = full[full.find("/%s/" % (dname,)):]
|
||||
#print("MEMFS add", fname)
|
||||
#print("MEMFS: Add ", fname)
|
||||
name = re.sub(r'\W', '_', fname)
|
||||
|
||||
assert name not in FILES
|
||||
assert name not in SIZES
|
||||
FILES[name] = fname
|
||||
SIZES[name] = fsize
|
||||
|
||||
print('static const unsigned char %s[] = {' % (name,), file=g)
|
||||
print('const unsigned char %s[] = {' % (name,), file=g)
|
||||
|
||||
with open(full, 'rb') as f:
|
||||
i = 0
|
||||
#Python 2
|
||||
#fcont = f.read().encode("hex")
|
||||
# Python 2
|
||||
#contents_hex = f.read().encode("hex")
|
||||
|
||||
#Python 2 and 3
|
||||
fcont = binascii.hexlify(f.read())
|
||||
# Python 2 and 3
|
||||
contents_hex = binascii.hexlify(f.read())
|
||||
|
||||
# Read two characters at a time and convert to C hex
|
||||
# e.g. 23 -> 0x23
|
||||
for n in range(0, len(fcont), 2):
|
||||
twoChars = ascii(fcont[n:n+2])
|
||||
for n in range(0, len(contents_hex), 2):
|
||||
twoChars = ascii(contents_hex[n:n + 2])
|
||||
print("0x%s," % (twoChars,), end="", file=g)
|
||||
i += 1
|
||||
if (i % 20) == 0:
|
||||
print("", file=g)
|
||||
|
||||
print('};', file=g)
|
||||
if totsize >= CHUNK:
|
||||
g.close()
|
||||
fcount += 1
|
||||
opath = get_outfile_name(output_file_base, fcount)
|
||||
print('MEMFS: Generating output: ', opath)
|
||||
g = open(opath, "w")
|
||||
totsize = 0
|
||||
|
||||
g.close()
|
||||
assert fcount == 3
|
||||
opath = output_file_base + "_final.c"
|
||||
print('MEMFS: Generating output: ', opath)
|
||||
g = open(opath, "w")
|
||||
|
||||
print("""
|
||||
#include "eccodes_config.h"
|
||||
|
@ -101,7 +128,13 @@ print("""
|
|||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include "eccodes_windef.h"
|
||||
""", file=g)
|
||||
|
||||
# Write extern variables with sizes
|
||||
for k, v in SIZES.items():
|
||||
print('extern const unsigned char %s[%d];' % (k, v), file=g)
|
||||
|
||||
print("""
|
||||
struct entry {
|
||||
const char* path;
|
||||
const unsigned char* content;
|
||||
|
@ -111,7 +144,7 @@ struct entry {
|
|||
items = [(v, k) for k, v in FILES.items()]
|
||||
|
||||
for k, v in sorted(items):
|
||||
print ('{"/MEMFS%s", &%s[0], sizeof(%s) / sizeof(%s[0]) },' % (k, v, v, v), file=g)
|
||||
print('{"/MEMFS%s", &%s[0], sizeof(%s) / sizeof(%s[0]) },' % (k, v, v, v), file=g)
|
||||
|
||||
|
||||
print("""};
|
||||
|
@ -264,4 +297,5 @@ FILE* codes_memfs_open(const char* path) {
|
|||
}
|
||||
|
||||
""", file=g)
|
||||
print ('Created ',output_file_path)
|
||||
|
||||
print('Finished')
|
||||
|
|
|
@ -4,18 +4,26 @@ if( NOT HAVE_PRODUCT_BUFR )
|
|||
elseif( NOT HAVE_PRODUCT_GRIB )
|
||||
set( exclude -exclude grib )
|
||||
endif()
|
||||
|
||||
set( generated_c_files
|
||||
${CMAKE_CURRENT_BINARY_DIR}/memfs_gen_000.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/memfs_gen_001.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/memfs_gen_002.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/memfs_gen_003.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/memfs_gen_final.c)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/memfs.c
|
||||
OUTPUT ${generated_c_files}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/memfs.py
|
||||
${exclude}
|
||||
${PROJECT_SOURCE_DIR}/definitions
|
||||
${PROJECT_SOURCE_DIR}/samples
|
||||
${PROJECT_SOURCE_DIR}/ifs_samples
|
||||
${CMAKE_CURRENT_BINARY_DIR}/memfs.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/memfs_gen
|
||||
DEPENDS ${PROJECT_SOURCE_DIR}/memfs.py)
|
||||
|
||||
set_source_files_properties(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/memfs.c PROPERTIES OBJECT_DEPENDS
|
||||
${generated_c_files} PROPERTIES OBJECT_DEPENDS
|
||||
"${PROJECT_SOURCE_DIR}/memfs.py"
|
||||
# "${PROJECT_SOURCE_DIR}/memfs.py" ${definition_files}"
|
||||
)
|
||||
|
@ -28,6 +36,6 @@ endif()
|
|||
|
||||
if( HAVE_MEMFS )
|
||||
ecbuild_add_library(TARGET eccodes_memfs
|
||||
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/memfs.c
|
||||
GENERATED ${CMAKE_CURRENT_BINARY_DIR}/memfs.c)
|
||||
SOURCES ${generated_c_files}
|
||||
GENERATED ${generated_c_files})
|
||||
endif()
|
||||
|
|
|
@ -10,6 +10,17 @@
|
|||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
/* Input lon must be in degrees not radians */
|
||||
/* Not to be used for latitudes as they can be -ve */
|
||||
double normalise_longitude_in_degrees(double lon)
|
||||
{
|
||||
while (lon < 0)
|
||||
lon += 360;
|
||||
while (lon > 360)
|
||||
lon -= 360;
|
||||
return lon;
|
||||
}
|
||||
|
||||
|
||||
#ifdef ECCODES_ON_WINDOWS
|
||||
/* Replace C99/Unix rint() for Windows Visual C++ (only before VC++ 2013 versions) */
|
||||
|
|
|
@ -2450,7 +2450,7 @@ static int create_keys(grib_accessor* a, long onlySubset, long startSubset, long
|
|||
grib_sarray_delete(c, self->tempStrings);
|
||||
self->tempStrings = NULL;
|
||||
}
|
||||
self->tempStrings = grib_sarray_new(c, self->numberOfSubsets, 500);
|
||||
self->tempStrings = self->numberOfSubsets? grib_sarray_new(c, self->numberOfSubsets, 500) : NULL;
|
||||
|
||||
end = self->compressedData ? 1 : self->numberOfSubsets;
|
||||
groupNumber = 1;
|
||||
|
|
|
@ -384,6 +384,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
|
|||
}
|
||||
|
||||
if (str == 0 || strlen(str) == 0) {
|
||||
grib_context_free(c, str);
|
||||
*len = 0;
|
||||
*val = 0;
|
||||
return ret;
|
||||
|
|
|
@ -191,6 +191,7 @@ static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err)
|
|||
char dictName[1024] = {0,};
|
||||
char* localFilename = 0;
|
||||
char** list = 0;
|
||||
char** cached_list = 0;
|
||||
size_t len = 1024;
|
||||
grib_trie* dictionary = NULL;
|
||||
FILE* f = NULL;
|
||||
|
@ -261,6 +262,8 @@ static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err)
|
|||
dictionary = grib_trie_new(c);
|
||||
|
||||
while (fgets(line, sizeof(line) - 1, f)) {
|
||||
DebugAssert( strlen(line) > 0 );
|
||||
if (line[0] == '#') continue; /* Ignore first line with column titles */
|
||||
list = string_split(line, "|");
|
||||
grib_trie_insert(dictionary, list[0], list);
|
||||
}
|
||||
|
@ -276,7 +279,16 @@ static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err)
|
|||
}
|
||||
|
||||
while (fgets(line, sizeof(line) - 1, f)) {
|
||||
DebugAssert( strlen(line) > 0 );
|
||||
if (line[0] == '#') continue; /* Ignore first line with column titles */
|
||||
list = string_split(line, "|");
|
||||
/* Look for the descriptor code in the trie. It might be there from before */
|
||||
cached_list = (char**)grib_trie_get(dictionary, list[0]);
|
||||
if (cached_list) { /* If found, we are about to overwrite it. So free memory */
|
||||
int i;
|
||||
for (i = 0; cached_list[i] != NULL; ++i) free(cached_list[i]);
|
||||
free(cached_list);
|
||||
}
|
||||
grib_trie_insert(dictionary, list[0], list);
|
||||
}
|
||||
|
||||
|
|
|
@ -181,16 +181,6 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
|||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
static double normalise_longitude(double a_lon)
|
||||
{
|
||||
/* WMO regulation: The longitude values shall be limited to the range 0 to 360 degrees inclusive */
|
||||
while (a_lon < 0)
|
||||
a_lon += 360;
|
||||
while (a_lon > 360)
|
||||
a_lon -= 360;
|
||||
return a_lon;
|
||||
}
|
||||
|
||||
static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
||||
{
|
||||
grib_accessor_g2latlon* self = (grib_accessor_g2latlon*)a;
|
||||
|
@ -218,7 +208,9 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
|||
* index 3 is longitudeOfLastGridPointInDegrees
|
||||
*/
|
||||
if ((self->index == 1 || self->index == 3)) {
|
||||
new_val = normalise_longitude(*val);
|
||||
/* WMO regulation for GRIB edition 2:
|
||||
* The longitude values shall be limited to the range 0 to 360 degrees inclusive */
|
||||
new_val = normalise_longitude_in_degrees(*val);
|
||||
}
|
||||
grid[self->index] = new_val;
|
||||
|
||||
|
|
|
@ -1462,6 +1462,7 @@ double grib_arguments_get_double(grib_handle* h, grib_arguments* args, int n);
|
|||
grib_expression* grib_arguments_get_expression(grib_handle* h, grib_arguments* args, int n);
|
||||
|
||||
/* codes_util.c */
|
||||
double normalise_longitude_in_degrees(double lon);
|
||||
char get_dir_separator_char(void);
|
||||
int path_is_directory(const char* filename);
|
||||
char* codes_getenv(const char* name);
|
||||
|
|
|
@ -456,10 +456,9 @@ grib_context* grib_context_get_default()
|
|||
default_grib_context.grib_definition_files_path = codes_getenv("ECCODES_DEFINITION_PATH");
|
||||
#ifdef ECCODES_DEFINITION_PATH
|
||||
if (!default_grib_context.grib_definition_files_path) {
|
||||
default_grib_context.grib_definition_files_path = ECCODES_DEFINITION_PATH;
|
||||
default_grib_context.grib_definition_files_path = strdup(ECCODES_DEFINITION_PATH);
|
||||
}
|
||||
else {
|
||||
/* Temp bug fix when putenv() is called from program that moves getenv() stuff around */
|
||||
default_grib_context.grib_definition_files_path = strdup(default_grib_context.grib_definition_files_path);
|
||||
}
|
||||
#endif
|
||||
|
@ -471,16 +470,21 @@ grib_context* grib_context_get_default()
|
|||
const char* test_samp = codes_getenv("_ECCODES_ECMWF_TEST_SAMPLES_PATH");
|
||||
if (test_defs) {
|
||||
char buffer[ECC_PATH_MAXLEN];
|
||||
strcpy(buffer, default_grib_context.grib_definition_files_path);
|
||||
strcat(buffer, ":");
|
||||
strcat(buffer, strdup(test_defs));
|
||||
if (default_grib_context.grib_definition_files_path) {
|
||||
strcpy(buffer, default_grib_context.grib_definition_files_path);
|
||||
strcat(buffer, ":");
|
||||
}
|
||||
strcat(buffer, test_defs);
|
||||
free(default_grib_context.grib_definition_files_path);
|
||||
default_grib_context.grib_definition_files_path = strdup(buffer);
|
||||
}
|
||||
if (test_samp) {
|
||||
char buffer[ECC_PATH_MAXLEN];
|
||||
strcpy(buffer, default_grib_context.grib_samples_path);
|
||||
strcat(buffer, ":");
|
||||
strcat(buffer, strdup(test_samp));
|
||||
if (default_grib_context.grib_samples_path) {
|
||||
strcpy(buffer, default_grib_context.grib_samples_path);
|
||||
strcat(buffer, ":");
|
||||
}
|
||||
strcat(buffer, test_samp);
|
||||
default_grib_context.grib_samples_path = strdup(buffer);
|
||||
}
|
||||
}
|
||||
|
@ -491,6 +495,7 @@ grib_context* grib_context_get_default()
|
|||
if (defs_extra) {
|
||||
char buffer[ECC_PATH_MAXLEN];
|
||||
ecc_snprintf(buffer, ECC_PATH_MAXLEN, "%s%c%s", defs_extra, ECC_PATH_DELIMITER_CHAR, default_grib_context.grib_definition_files_path);
|
||||
free(default_grib_context.grib_definition_files_path);
|
||||
default_grib_context.grib_definition_files_path = strdup(buffer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -482,13 +482,13 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment)
|
|||
static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comment)
|
||||
{
|
||||
grib_dumper_bufr_decode_C* self = (grib_dumper_bufr_decode_C*)d;
|
||||
char** values = NULL;
|
||||
size_t size = 0;
|
||||
grib_context* c = NULL;
|
||||
int err = 0;
|
||||
long count = 0;
|
||||
int r = 0;
|
||||
grib_handle* h = grib_handle_of_accessor(a);
|
||||
char** values;
|
||||
size_t size = 0, i = 0;
|
||||
grib_context* c = NULL;
|
||||
int err = 0;
|
||||
long count = 0;
|
||||
int r = 0;
|
||||
grib_handle* h = grib_handle_of_accessor(a);
|
||||
|
||||
c = a->context;
|
||||
|
||||
|
@ -542,6 +542,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
|
|||
depth -= 2;
|
||||
}
|
||||
|
||||
for (i = 0; i < size; i++) grib_context_free(c, values[i]);
|
||||
grib_context_free(c, values);
|
||||
(void)err; /* TODO */
|
||||
}
|
||||
|
@ -574,8 +575,10 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
|
|||
err = grib_unpack_string(a, value, &size);
|
||||
p = value;
|
||||
r = compute_bufr_key_rank(h, self->keys, a->name);
|
||||
if (grib_is_missing_string(a, (unsigned char*)value, size))
|
||||
if (grib_is_missing_string(a, (unsigned char*)value, size)) {
|
||||
grib_context_free(c, value);
|
||||
return;
|
||||
}
|
||||
|
||||
while (*p) {
|
||||
if (!isprint(*p))
|
||||
|
|
|
@ -665,6 +665,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
|
|||
depth -= 2;
|
||||
}
|
||||
|
||||
for (i = 0; i < size; i++) grib_context_free(c, values[i]);
|
||||
grib_context_free(c, values);
|
||||
(void)err; /* TODO */
|
||||
}
|
||||
|
|
|
@ -1776,8 +1776,11 @@ int grib_index_dump_file(FILE* fout, const char* filename)
|
|||
return err;
|
||||
f = file;
|
||||
while (f) {
|
||||
grib_file *prev = f;
|
||||
fprintf(fout, "GRIB File: %s\n", f->name);
|
||||
grib_context_free(c, f->name);
|
||||
f = f->next;
|
||||
grib_context_free(c, prev);
|
||||
}
|
||||
fclose(fh);
|
||||
}
|
||||
|
|
|
@ -49,9 +49,9 @@ static void init()
|
|||
#define HDF5 0x89484446
|
||||
#define WRAP 0x57524150
|
||||
|
||||
#define GRIB_API_READS_BUFR 1
|
||||
#define GRIB_API_READS_HDF5 1
|
||||
#define GRIB_API_READS_WRAP 1
|
||||
#define ECCODES_READS_BUFR 1
|
||||
#define ECCODES_READS_HDF5 1
|
||||
#define ECCODES_READS_WRAP 1
|
||||
|
||||
|
||||
typedef struct alloc_buffer
|
||||
|
@ -1517,7 +1517,7 @@ int grib_read_any_headers_only_from_file(grib_context* ctx, FILE* f, void* buffe
|
|||
r.alloc = &user_provider_buffer;
|
||||
r.headers_only = 1;
|
||||
|
||||
err = read_any(&r, 1, GRIB_API_READS_BUFR, GRIB_API_READS_HDF5, GRIB_API_READS_WRAP);
|
||||
err = read_any(&r, 1, ECCODES_READS_BUFR, ECCODES_READS_HDF5, ECCODES_READS_WRAP);
|
||||
|
||||
*len = r.message_size;
|
||||
|
||||
|
@ -1546,7 +1546,7 @@ int grib_read_any_from_file(grib_context* ctx, FILE* f, void* buffer, size_t* le
|
|||
|
||||
offset = ftello(f);
|
||||
|
||||
err = read_any(&r, 1, GRIB_API_READS_BUFR, GRIB_API_READS_HDF5, GRIB_API_READS_WRAP);
|
||||
err = read_any(&r, 1, ECCODES_READS_BUFR, ECCODES_READS_HDF5, ECCODES_READS_WRAP);
|
||||
|
||||
if (err == GRIB_BUFFER_TOO_SMALL) {
|
||||
if (fseeko(f, offset, SEEK_SET))
|
||||
|
@ -1616,7 +1616,7 @@ int grib_read_any_from_memory_alloc(grib_context* ctx, unsigned char** data, siz
|
|||
r.alloc = &context_allocate_buffer;
|
||||
r.headers_only = 0;
|
||||
|
||||
err = read_any(&r, 1, GRIB_API_READS_BUFR, GRIB_API_READS_HDF5, GRIB_API_READS_WRAP);
|
||||
err = read_any(&r, 1, ECCODES_READS_BUFR, ECCODES_READS_HDF5, ECCODES_READS_WRAP);
|
||||
*buffer = u.buffer;
|
||||
*length = u.length;
|
||||
|
||||
|
@ -1649,7 +1649,7 @@ int grib_read_any_from_memory(grib_context* ctx, unsigned char** data, size_t* d
|
|||
r.alloc = &user_provider_buffer;
|
||||
r.headers_only = 0;
|
||||
|
||||
err = read_any(&r, 1, GRIB_API_READS_BUFR, GRIB_API_READS_HDF5, GRIB_API_READS_WRAP);
|
||||
err = read_any(&r, 1, ECCODES_READS_BUFR, ECCODES_READS_HDF5, ECCODES_READS_WRAP);
|
||||
*len = r.message_size;
|
||||
|
||||
*data_length = m.data_len;
|
||||
|
|
|
@ -107,8 +107,14 @@ static double adjust_lon_radians(double lon)
|
|||
return lon;
|
||||
}
|
||||
|
||||
/* Function to compute the latitude angle, phi2, for the inverse */
|
||||
static double compute_phi2(
|
||||
/* Function to compute the latitude angle, phi2, for the inverse
|
||||
* From the book "Map Projections-A Working Manual-John P. Snyder (1987)"
|
||||
* Equation (7–9) involves rapidly converging iteration: Calculate t from (15-11)
|
||||
* Then, assuming an initial trial phi equal to (pi/2 - 2*arctan t) in the right side of equation (7–9),
|
||||
* calculate phi on the left side. Substitute the calculated phi) into the right side,
|
||||
* calculate a new phi, etc., until phi does not change significantly from the preceding trial value of phi
|
||||
*/
|
||||
static double compute_phi(
|
||||
double eccent, /* Spheroid eccentricity */
|
||||
double ts, /* Constant value t */
|
||||
int* error)
|
||||
|
@ -123,7 +129,7 @@ static double compute_phi2(
|
|||
con = eccent * sinpi;
|
||||
dphi = M_PI_2 - 2 * atan(ts * (pow(((1.0 - con) / (1.0 + con)), eccnth))) - phi;
|
||||
phi += dphi;
|
||||
if (fabs(dphi) <= .0000000001)
|
||||
if (fabs(dphi) <= 0.0000000001)
|
||||
return (phi);
|
||||
}
|
||||
*error = GRIB_INTERNAL_ERROR;
|
||||
|
@ -227,8 +233,7 @@ static int init_sphere(grib_handle* h,
|
|||
if (n <= 0) rho = -rho;
|
||||
lonDeg = LoVInDegrees + (angle / n) * RAD2DEG;
|
||||
latDeg = (2.0 * atan(pow(radius * f / rho, 1.0 / n)) - M_PI_2) * RAD2DEG;
|
||||
while (lonDeg >= 360.0) lonDeg -= 360.0;
|
||||
while (lonDeg < 0.0) lonDeg += 360.0;
|
||||
lonDeg = normalise_longitude_in_degrees(lonDeg);
|
||||
self->lons[index] = lonDeg;
|
||||
self->lats[index] = latDeg;
|
||||
}
|
||||
|
@ -254,7 +259,7 @@ static int init_oblate(grib_handle* h,
|
|||
double false_northing; /* y offset in meters */
|
||||
|
||||
double ns; /* ratio of angle between meridian */
|
||||
double f0; /* flattening of ellipsoid */
|
||||
double F; /* flattening of ellipsoid */
|
||||
double rh; /* height above ellipsoid */
|
||||
double sin_po; /* sin value */
|
||||
double cos_po; /* cos value */
|
||||
|
@ -285,15 +290,15 @@ static int init_oblate(grib_handle* h,
|
|||
} else {
|
||||
ns = con;
|
||||
}
|
||||
f0 = ms1 / (ns * pow(ts1, ns));
|
||||
rh = earthMajorAxisInMetres * f0 * pow(ts0, ns);
|
||||
F = ms1 / (ns * pow(ts1, ns));
|
||||
rh = earthMajorAxisInMetres * F * pow(ts0, ns);
|
||||
|
||||
/* Forward projection: convert lat,lon to x,y */
|
||||
con = fabs(fabs(latFirstInRadians) - M_PI_2);
|
||||
if (con > EPSILON) {
|
||||
sinphi = sin(latFirstInRadians);
|
||||
ts = compute_t(e, latFirstInRadians, sinphi);
|
||||
rh1 = earthMajorAxisInMetres * f0 * pow(ts, ns);
|
||||
rh1 = earthMajorAxisInMetres * F * pow(ts, ns);
|
||||
} else {
|
||||
con = latFirstInRadians * ns;
|
||||
if (con <= 0) {
|
||||
|
@ -332,20 +337,19 @@ static int init_oblate(grib_handle* h,
|
|||
/* Inverse projection to convert from x,y to lat,lon */
|
||||
_x = x - false_easting;
|
||||
_y = rh - y + false_northing;
|
||||
if (ns > 0) {
|
||||
rh1 = sqrt(_x * _x + _y * _y);
|
||||
con = 1.0;
|
||||
} else {
|
||||
rh1 = -sqrt(_x * _x + _y * _y);
|
||||
con = -1.0;
|
||||
rh1 = sqrt(_x * _x + _y * _y);
|
||||
con = 1.0;
|
||||
if (ns <= 0) {
|
||||
rh1 = -rh1;
|
||||
con = -con;
|
||||
}
|
||||
theta = 0.0;
|
||||
if (rh1 != 0)
|
||||
theta = atan2((con * _x), (con * _y));
|
||||
if ((rh1 != 0) || (ns > 0.0)) {
|
||||
con = 1.0 / ns;
|
||||
ts = pow((rh1 / (earthMajorAxisInMetres * f0)), con);
|
||||
latRad = compute_phi2(e, ts, &err);
|
||||
ts = pow((rh1 / (earthMajorAxisInMetres * F)), con);
|
||||
latRad = compute_phi(e, ts, &err);
|
||||
if (err) {
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR, "Failed to compute the latitude angle, phi2, for the inverse");
|
||||
grib_context_free(h->context, self->lats);
|
||||
|
@ -358,8 +362,7 @@ static int init_oblate(grib_handle* h,
|
|||
lonRad = adjust_lon_radians(theta / ns + LoVInRadians);
|
||||
latDeg = latRad * RAD2DEG; /* Convert to degrees */
|
||||
lonDeg = lonRad * RAD2DEG;
|
||||
while (lonDeg >= 360.0) lonDeg -= 360.0;
|
||||
while (lonDeg < 0.0) lonDeg += 360.0;
|
||||
lonDeg = normalise_longitude_in_degrees(lonDeg);
|
||||
self->lons[index] = lonDeg;
|
||||
self->lats[index] = latDeg;
|
||||
}
|
||||
|
|
|
@ -162,10 +162,7 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
|||
/* array of candidates for nearest neighbours */
|
||||
PointStore* neighbours = NULL;
|
||||
|
||||
while (inlon < 0)
|
||||
inlon += 360;
|
||||
while (inlon > 360)
|
||||
inlon -= 360;
|
||||
inlon = normalise_longitude_in_degrees(inlon);
|
||||
|
||||
if ((ret = grib_get_size(h, self->values_key, &nvalues)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
|
|
|
@ -230,10 +230,7 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
|||
long row_count, ilon_first, ilon_last;
|
||||
|
||||
if (self->global) {
|
||||
while (inlon < 0)
|
||||
inlon += 360;
|
||||
while (inlon > 360)
|
||||
inlon -= 360;
|
||||
inlon = normalise_longitude_in_degrees(inlon);
|
||||
}
|
||||
else {
|
||||
/* TODO: Experimental */
|
||||
|
|
|
@ -37,7 +37,7 @@ fRules=${label}.filter
|
|||
#-----------------------------------------------------------
|
||||
files=`cat ${data_dir}/bufr/bufr_data_files.txt`
|
||||
|
||||
# Exclude BUFR files for various reasosn:
|
||||
# Exclude BUFR files for various reasons:
|
||||
# ias1_240.bufr: Too large. The filter rules file generated is too big for the parser!
|
||||
# tropical_cyclone.bufr: multi-message
|
||||
# syno_multi.bufr: multi-message
|
||||
|
|
|
@ -19,205 +19,40 @@ tempLog=temp.${label}.log
|
|||
tempSupp=temp.${label}.supp
|
||||
|
||||
if test "x$ECCODES_TEST_WITH_VALGRIND" = "x"; then
|
||||
echo "Environment variable ECCODES_TEST_WITH_VALGRIND not defined. Test disabled"
|
||||
exit 0
|
||||
echo "Environment variable ECCODES_TEST_WITH_VALGRIND not defined. Test disabled"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# The presence of ECCODES_TEST_WITH_VALGRIND environment variable redefines
|
||||
# tools_dir so we reset it to its original
|
||||
tools_dir=$build_dir/bin
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Test 1: Set of BUFR files which have zero leaks.
|
||||
# Over time this list should increase
|
||||
# ---------------------------------------------------------
|
||||
bufr_files_zero_leaks="
|
||||
207003.bufr
|
||||
PraticaTemp.bufr
|
||||
aaen_55.bufr
|
||||
aben_55.bufr
|
||||
aeolus_wmo_26.bufr
|
||||
delayed_repl_01.bufr
|
||||
goes16_nm.bufr
|
||||
israel_observations_2017041010.bufr
|
||||
mhen_55.bufr
|
||||
modw_87.bufr
|
||||
sentinel1.bufr
|
||||
synop_multi_subset.bufr
|
||||
tropical_cyclone.bufr
|
||||
uegabe.bufr
|
||||
"
|
||||
|
||||
files=`cat ${data_dir}/bufr/bufr_data_files.txt`
|
||||
VALGRIND_OPTIONS="--error-exitcode=1 --leak-check=full --log-file=$tempLog"
|
||||
|
||||
# bufr_filter has a small leak to do with parsing and action files not related to BUFR decoding,
|
||||
# So instead we use bufr_ls to do the unpacking
|
||||
for bf in $bufr_files_zero_leaks; do
|
||||
valgrind $VALGRIND_OPTIONS ${tools_dir}/bufr_ls -s unpack=1 ${data_dir}/bufr/$bf >/dev/null
|
||||
for bf in $files; do
|
||||
valgrind $VALGRIND_OPTIONS ${tools_dir}/bufr_ls -s unpack=1 ${data_dir}/bufr/$bf >/dev/null
|
||||
done
|
||||
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Test 2: Set of BUFR files which have a small known leak.
|
||||
# Over time this list should decrease
|
||||
# ---------------------------------------------------------
|
||||
bufr_files_known_leaks="
|
||||
ahws_139.bufr
|
||||
airc_142.bufr
|
||||
airc_144.bufr
|
||||
airs_57.bufr
|
||||
alws_139.bufr
|
||||
amda_144.bufr
|
||||
amsa_55.bufr
|
||||
amsb_55.bufr
|
||||
amse_55.bufr
|
||||
amsu_55.bufr
|
||||
amv2_87.bufr
|
||||
amv3_87.bufr
|
||||
asbh_139.bufr
|
||||
asbl_139.bufr
|
||||
asca_139.bufr
|
||||
asch_139.bufr
|
||||
ascs_139.bufr
|
||||
aseh_139.bufr
|
||||
asel_139.bufr
|
||||
ashs_139.bufr
|
||||
atap_55.bufr
|
||||
ateu_155.bufr
|
||||
atms_201.bufr
|
||||
atov_55.bufr
|
||||
avhm_87.bufr
|
||||
avhn_87.bufr
|
||||
avhr_58.bufr
|
||||
b002_95.bufr
|
||||
b002_96.bufr
|
||||
b003_56.bufr
|
||||
b004_145.bufr
|
||||
b005_87.bufr
|
||||
b005_89.bufr
|
||||
b006_96.bufr
|
||||
b007_31.bufr
|
||||
bssh_170.bufr
|
||||
bssh_176.bufr
|
||||
bssh_178.bufr
|
||||
bssh_180.bufr
|
||||
btem_109.bufr
|
||||
buoy_27.bufr
|
||||
cmwi_87.bufr
|
||||
cmwn_87.bufr
|
||||
cnow_28.bufr
|
||||
cori_156.bufr
|
||||
crit_202.bufr
|
||||
csrh_189.bufr
|
||||
emsg_189.bufr
|
||||
emsg_87.bufr
|
||||
eum_iasi_twt.bufr
|
||||
eumetsat_iasi_co.bufr
|
||||
euwv_87.bufr
|
||||
fy3a_154.bufr
|
||||
fy3b_154.bufr
|
||||
g2nd_208.bufr
|
||||
g2to_206.bufr
|
||||
go15_87.bufr
|
||||
goee_87.bufr
|
||||
goes_87.bufr
|
||||
goga_89.bufr
|
||||
gosat.bufr
|
||||
grst_26.bufr
|
||||
gsd1_208.bufr
|
||||
gsd2_208.bufr
|
||||
gsd3_208.bufr
|
||||
gst4_26.bufr
|
||||
hirb_55.bufr
|
||||
hirs_55.bufr
|
||||
ias1_240.bufr
|
||||
iasi_241.bufr
|
||||
ifco_208.bufr
|
||||
ikco_217.bufr
|
||||
imssnow.bufr
|
||||
itrg_208.bufr
|
||||
itwt_233.bufr
|
||||
j2eo_216.bufr
|
||||
j2nb_216.bufr
|
||||
jaso_214.bufr
|
||||
kond_209.bufr
|
||||
maer_207.bufr
|
||||
meta_140.bufr
|
||||
metar_with_2_bias.bufr
|
||||
mhsa_55.bufr
|
||||
mhsb_55.bufr
|
||||
mhse_55.bufr
|
||||
mloz_206.bufr
|
||||
modi_87.bufr
|
||||
monw_87.bufr
|
||||
new.bufr
|
||||
nomi_206.bufr
|
||||
nos1_208.bufr
|
||||
nos2_208.bufr
|
||||
nos3_208.bufr
|
||||
nos4_208.bufr
|
||||
nos5_208.bufr
|
||||
nos6_208.bufr
|
||||
nos7_208.bufr
|
||||
nos8_208.bufr
|
||||
ocea_131.bufr
|
||||
ocea_132.bufr
|
||||
ocea_133.bufr
|
||||
ocea_21.bufr
|
||||
pgps_110.bufr
|
||||
pilo_91.bufr
|
||||
profiler_european.bufr
|
||||
rada_250.bufr
|
||||
rado_250.bufr
|
||||
s4kn_165.bufr
|
||||
sb19_206.bufr
|
||||
sbu8_206.bufr
|
||||
ship_13.bufr
|
||||
ship_19.bufr
|
||||
ship_9.bufr
|
||||
smin_49.bufr
|
||||
smis_49.bufr
|
||||
smiu_49.bufr
|
||||
smos_203.bufr
|
||||
sn4k_165.bufr
|
||||
soil_7.bufr
|
||||
srals3_ecmwf4.bufr
|
||||
srals3_eumetsat.bufr
|
||||
ssbt_127.bufr
|
||||
stuk_7.bufr
|
||||
syno_1.bufr
|
||||
syno_3.bufr
|
||||
syno_4.bufr
|
||||
syno_multi.bufr
|
||||
temp-land-with-substituted-values.bufr
|
||||
temp_101.bufr
|
||||
temp_102.bufr
|
||||
temp_106.bufr
|
||||
tmr7_129.bufr
|
||||
tros_31.bufr
|
||||
wavb_134.bufr
|
||||
"
|
||||
|
||||
cat > $tempSupp << EOF
|
||||
{
|
||||
eccodes_string_split_suppression
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: definite
|
||||
fun:malloc
|
||||
fun:string_split
|
||||
fun:load_bufr_elements_table*
|
||||
fun:bufr_get_from_table
|
||||
fun:accessor_bufr_elements_table_get_descriptor
|
||||
fun:grib_bufr_descriptor_new
|
||||
}
|
||||
EOF
|
||||
VALGRIND_OPTIONS="--error-exitcode=1 --leak-check=full --log-file=$tempLog --suppressions=$tempSupp"
|
||||
|
||||
# bufr_filter has a small leak to do with parsing and action files not related to BUFR decoding,
|
||||
# So instead we use bufr_ls to do the unpacking
|
||||
for bf in $bufr_files_known_leaks; do
|
||||
valgrind $VALGRIND_OPTIONS ${tools_dir}/bufr_ls -s unpack=1 ${data_dir}/bufr/$bf >/dev/null
|
||||
done
|
||||
# Suppressions file
|
||||
# ------------------
|
||||
#cat > $tempSupp << EOF
|
||||
#{
|
||||
# eccodes_string_split_suppression
|
||||
# Memcheck:Leak
|
||||
# match-leak-kinds: definite
|
||||
# fun:malloc
|
||||
# fun:string_split
|
||||
# fun:load_bufr_elements_table*
|
||||
# fun:bufr_get_from_table
|
||||
# fun:accessor_bufr_elements_table_get_descriptor
|
||||
# fun:grib_bufr_descriptor_new
|
||||
#}
|
||||
#EOF
|
||||
#VALGRIND_OPTIONS="--error-exitcode=1 --leak-check=full --log-file=$tempLog --suppressions=$tempSupp "
|
||||
|
||||
|
||||
# Clean up
|
||||
|
|
|
@ -80,6 +80,8 @@ if [ -x "${tools_dir}/grib_check_gaussian_grid" ]; then
|
|||
${tools_dir}/grib_check_gaussian_grid $input $output
|
||||
fi
|
||||
|
||||
rm -f $output
|
||||
|
||||
#sed "s:toolsdir:${tools_dir}/:" ${tools_dir}/grib1to2.txt > ${tools_dir}/grib1to2.test
|
||||
#chmod +x ${tools_dir}/grib1to2.test
|
||||
#${tools_dir}/grib1to2.test -f ${data_dir}/test.grib1 ${data_dir}/test.grib2
|
||||
|
|
|
@ -30,7 +30,7 @@ rm -f out.gribidx $temp
|
|||
tempIndex=temp.$label.$$.idx
|
||||
tempOut=temp.$label.$$.out
|
||||
tempRef=temp.$label.$$.ref
|
||||
${tools_dir}/grib_index_build -o $tempIndex ${infile} >/dev/null
|
||||
${tools_dir}/grib_index_build -N -o $tempIndex ${infile} >/dev/null
|
||||
|
||||
# Must remove first two lines and the last (filename specifics)
|
||||
${tools_dir}/grib_dump -D ${tempIndex} | sed '1,2d' | sed '$d' > $tempOut
|
||||
|
@ -38,23 +38,63 @@ cat $tempOut
|
|||
|
||||
cat > $tempRef <<EOF
|
||||
Index keys:
|
||||
key name = mars.date
|
||||
values = 20090129
|
||||
key name = mars.time
|
||||
values = 0
|
||||
key name = mars.expver
|
||||
values = 0001
|
||||
key name = mars.stream
|
||||
values = enfo
|
||||
key name = mars.class
|
||||
values = od
|
||||
key name = mars.type
|
||||
values = pf
|
||||
key name = mars.step
|
||||
values = 12, 24, 48, 60
|
||||
key name = mars.param
|
||||
values = 130.128, 129.128
|
||||
key name = mars.levtype
|
||||
values = pl
|
||||
key name = mars.levelist
|
||||
values = 10, 50, 100, 200, 250, 300, 400, 500, 700, 850, 925, 1000
|
||||
key name = mars.number
|
||||
values = 1, 2, 3, 4
|
||||
key name = mars.iteration
|
||||
values = undef
|
||||
key name = mars.domain
|
||||
values = g
|
||||
key name = mars.fcmonth
|
||||
values = undef
|
||||
key name = mars.fcperiod
|
||||
values = undef
|
||||
key name = mars.hdate
|
||||
values = undef
|
||||
key name = mars.method
|
||||
values = undef
|
||||
key name = mars.model
|
||||
values = undef
|
||||
key name = mars.origin
|
||||
values = undef
|
||||
key name = mars.quantile
|
||||
values = undef
|
||||
key name = mars.range
|
||||
values = undef
|
||||
key name = mars.refdate
|
||||
values = undef
|
||||
key name = mars.direction
|
||||
values = undef
|
||||
key name = mars.frequency
|
||||
values = undef
|
||||
Index count = 384
|
||||
EOF
|
||||
|
||||
diff $tempRef $tempOut
|
||||
|
||||
${tools_dir}/grib_index_build -k mars.levtype -o $tempIndex ${data_dir}/tigge_cf_ecmwf.grib2 |\
|
||||
${tools_dir}/grib_index_build -N -k mars.levtype -o $tempIndex ${data_dir}/tigge_cf_ecmwf.grib2 |\
|
||||
grep -q "mars.levtype = { sfc, pl, pv, pt }"
|
||||
|
||||
${tools_dir}/grib_index_build -k mars.levtype:i -o $tempIndex ${data_dir}/tigge_cf_ecmwf.grib2 |\
|
||||
${tools_dir}/grib_index_build -N -k mars.levtype:i -o $tempIndex ${data_dir}/tigge_cf_ecmwf.grib2 |\
|
||||
grep -q "mars.levtype = { 103, 1, 106, 100, 101, 8, 109, 107 }"
|
||||
|
||||
# grib_compare with index files
|
||||
|
@ -66,8 +106,8 @@ tempGribFile2=temp.$label.$$.file2.grib
|
|||
cat ${data_dir}/high_level_api.grib2 ${data_dir}/sample.grib2 > $tempGribFile1
|
||||
cat ${data_dir}/sample.grib2 ${data_dir}/high_level_api.grib2 > $tempGribFile2
|
||||
|
||||
${tools_dir}/grib_index_build -o $tempIndex1 $tempGribFile1
|
||||
${tools_dir}/grib_index_build -o $tempIndex2 $tempGribFile2
|
||||
${tools_dir}/grib_index_build -N -o $tempIndex1 $tempGribFile1
|
||||
${tools_dir}/grib_index_build -N -o $tempIndex2 $tempGribFile2
|
||||
${tools_dir}/grib_compare $tempIndex1 $tempIndex2
|
||||
rm -f $tempIndex1 $tempIndex2 $tempGribFile1 $tempGribFile2
|
||||
|
||||
|
|
|
@ -117,6 +117,7 @@ int main(int argc, char** argv)
|
|||
void* runner(void* ptr)
|
||||
{
|
||||
do_encode(ptr);
|
||||
free(ptr);
|
||||
pthread_exit(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -169,6 +169,7 @@ int main(int argc, char** argv)
|
|||
void* runner(void* ptr)
|
||||
{
|
||||
do_stuff(ptr);
|
||||
free(ptr);
|
||||
pthread_exit(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -104,3 +104,4 @@ ${tools_dir}/grib_get_data $outfile > /dev/null
|
|||
|
||||
### Clean up
|
||||
rm -f $outfile $tempOut
|
||||
rm -f error.data
|
||||
|
|
|
@ -86,4 +86,4 @@ grep -q "'E', 'C', 'M', 'W', 'F', ' '" $tempTxt
|
|||
|
||||
|
||||
# Clean up
|
||||
rm -f $tempOut $tempRef
|
||||
rm -f $tempOut $tempRef $tempTxt
|
||||
|
|
|
@ -559,7 +559,9 @@ static int grib_tool_index(grib_runtime_options* options)
|
|||
}
|
||||
|
||||
navigate(options->index2->fields, options);
|
||||
|
||||
/* TODO(masn): memleak
|
||||
* grib_context_free(c, options->index2->current);
|
||||
*/
|
||||
grib_tool_finalise_action(options);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue