diff --git a/.cproject b/.cproject
deleted file mode 100644
index 315cf1f32..000000000
--- a/.cproject
+++ /dev/null
@@ -1,132 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.project b/.project
deleted file mode 100644
index 52854bf56..000000000
--- a/.project
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
- eccodes
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml
deleted file mode 100644
index 4ca67c20d..000000000
--- a/.settings/language.settings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/data/grib_data_files.txt b/data/grib_data_files.txt
index 0647dc142..f6d3a9124 100644
--- a/data/grib_data_files.txt
+++ b/data/grib_data_files.txt
@@ -90,3 +90,5 @@ gfs.complex.mvmu.grib2
mercator.grib2
run_length_packing.grib2
boustrophedonic.grib1
+reduced_gaussian_sub_area.legacy.grib1
+
diff --git a/definitions/grib2/combinationOfAttributesOfTileConcept.def b/definitions/grib2/combinationOfAttributesOfTileConcept.def
index 465913ca8..93d23dd1e 100644
--- a/definitions/grib2/combinationOfAttributesOfTileConcept.def
+++ b/definitions/grib2/combinationOfAttributesOfTileConcept.def
@@ -1,5 +1,6 @@
# Concept combinationOfAttributesOfTile
+'UNDEF' = {attributeOfTile = [0];}
'UNMOD' = {attributeOfTile = [1];}
'SNOW' = {attributeOfTile = [2];}
'FLOOD' = {attributeOfTile = [3];}
diff --git a/definitions/grib2/template.4.point_in_time.def b/definitions/grib2/template.4.point_in_time.def
index 3e341f54b..7e188b230 100644
--- a/definitions/grib2/template.4.point_in_time.def
+++ b/definitions/grib2/template.4.point_in_time.def
@@ -21,6 +21,7 @@ meta stepHumanReadable step_human_readable(stepUnits, stepRange): hidden,no_copy
alias time.stepType=stepType;
alias time.stepRange=stepRange;
+alias time.stepUnits=stepUnits;
alias time.dataDate=dataDate;
alias time.dataTime=dataTime;
alias time.startStep=startStep;
diff --git a/definitions/gts/boot.def b/definitions/gts/boot.def
index f2a2d3d5b..02b3292e9 100644
--- a/definitions/gts/boot.def
+++ b/definitions/gts/boot.def
@@ -39,14 +39,13 @@ alias ls.CCCC=CCCC;
alias ls.YY=YY;
alias ls.GG=GG;
alias ls.gg=gg;
-position endOfHeadersMarker;
+position endOfHeadersMarker;
message[4] theMessage;
-meta lengthOfHeaders evaluate( endOfHeadersMarker-startOfHeaders);
-meta md5Headers md5(startOfHeaders,lengthOfHeaders);
+meta lengthOfHeaders evaluate(endOfHeadersMarker-startOfHeaders);
+meta md5Headers md5(startOfHeaders, lengthOfHeaders);
-ascii[4] endMark;
+ascii[4] endMark;
position totalLength;
alias ls.totalLength=totalLength;
-
diff --git a/examples/F90/CMakeLists.txt b/examples/F90/CMakeLists.txt
index 79f65e6fb..88b77e9fa 100644
--- a/examples/F90/CMakeLists.txt
+++ b/examples/F90/CMakeLists.txt
@@ -14,6 +14,7 @@ if( HAVE_BUILD_TOOLS )
codes_f90_misc
grib_set_pv
grib_set_data
+ grib_set_data_force
bufr_ecc-1284
bufr_ecc-1019
get_native_type
@@ -21,16 +22,23 @@ if( HAVE_BUILD_TOOLS )
list( APPEND tests_extra
grib_index
codes_dump
+ codes_scan_file
+ codes_load_file
grib_copy_message
bufr_copy_message
grib_get_keys
grib_get_data
+ grib_get_data_real4
grib_get_pl
grib_get_pv
grib_keys_iterator
+ grib_keys_iterator_skip
grib_multi_write
grib_multi
+ grib_elements
grib_nearest
+ grib_nearest_single
+ grib_nearest_four_single
grib_precision
grib_print_data
grib_set_keys
@@ -42,6 +50,7 @@ if( HAVE_BUILD_TOOLS )
grib_copy_namespace
grib_read_message
grib_read_from_file
+ grib_read_bytes
grib_get_set_uuid
grib_clone
grib_ecc-1316
@@ -67,6 +76,7 @@ else()
list( APPEND tests_sanity
grib_set_pv
grib_set_data
+ grib_set_data_force
codes_set_paths
codes_f90_misc
get_native_type
@@ -78,8 +88,12 @@ else()
grib_get_pl
grib_get_pv
grib_keys_iterator
+ grib_keys_iterator_skip
grib_multi
grib_nearest
+ grib_elements
+ grib_nearest_single
+ grib_nearest_four_single
grib_precision
grib_print_data
grib_set_missing
diff --git a/examples/F90/codes_load_file.f90 b/examples/F90/codes_load_file.f90
new file mode 100644
index 000000000..3572b4b4d
--- /dev/null
+++ b/examples/F90/codes_load_file.f90
@@ -0,0 +1,43 @@
+! (C) Copyright 2005- ECMWF.
+!
+! This software is licensed under the terms of the Apache Licence Version 2.0
+! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+!
+! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+!
+!
+program codes_load_file
+ use eccodes
+ implicit none
+
+ integer :: ifile, cnt, level, step
+ integer :: i, igrib, iret
+ character(len=32) :: infile_name = '../../data/index.grib'
+
+ call codes_open_file(ifile, infile_name, 'r')
+
+ call codes_any_load_all_from_file(ifile, cnt)
+
+ i = 45
+ call codes_any_new_from_loaded(i, igrib)
+ call codes_get(igrib, 'level', level)
+ call codes_get(igrib, 'stepRange', step)
+
+ print *, 'Num messages=', cnt
+ print *, 'Msg ',i,' level=',level, ' step=', step
+
+ call codes_release(igrib)
+
+ ! Invalid msg number
+ i = 450
+ call codes_any_new_from_loaded(i, igrib, iret)
+ if (iret /= GRIB_INVALID_ARGUMENT) then
+ call codes_check(iret, 'Error', 'codes_any_new_from_loaded should have failed')
+ else
+ print *,'Invalid message index returned error (as expected)'
+ end if
+
+ call codes_close_file(ifile)
+
+end program
diff --git a/examples/F90/codes_load_file.sh b/examples/F90/codes_load_file.sh
new file mode 100755
index 000000000..6a4fa78d8
--- /dev/null
+++ b/examples/F90/codes_load_file.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# (C) Copyright 2005- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+
+. ./include.ctest.sh
+
+label='eccodes_f_codes_load_file'
+temp=temp.$label.txt
+
+# The input file is hard coded => data/index.grib
+${examples_dir}/eccodes_f_codes_load_file > $temp
+
+grep -q "Num messages= *384" $temp
+grep -q "level= *700 step= *60" $temp
+
+rm -f $temp
diff --git a/examples/F90/codes_scan_file.f90 b/examples/F90/codes_scan_file.f90
new file mode 100644
index 000000000..9c21ef77b
--- /dev/null
+++ b/examples/F90/codes_scan_file.f90
@@ -0,0 +1,43 @@
+! (C) Copyright 2005- ECMWF.
+!
+! This software is licensed under the terms of the Apache Licence Version 2.0
+! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+!
+! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+!
+!
+program codes_scan_file
+ use eccodes
+ implicit none
+
+ integer :: ifile, cnt, level, step
+ integer :: i, igrib, iret
+ character(len=32) :: infile_name = '../../data/index.grib'
+
+ call codes_open_file(ifile, infile_name, 'r')
+
+ call codes_any_scan_file(ifile,cnt)
+
+ i = 45
+ call codes_any_new_from_scanned_file(ifile, i, igrib)
+ call codes_get(igrib, 'level', level)
+ call codes_get(igrib, 'stepRange', step)
+
+ print *, 'Num messages=', cnt
+ print *, 'Msg ',i,' level=',level, ' step=', step
+
+ call codes_release(igrib)
+
+ ! Invalid msg number
+ i = 450
+ call codes_any_new_from_scanned_file(ifile, i, igrib, iret)
+ if (iret /= GRIB_INVALID_ARGUMENT) then
+ call codes_check(iret, 'Error', 'codes_any_new_from_scanned_file should have failed')
+ else
+ print *,'Invalid message index returned error (as expected)'
+ end if
+
+ call codes_close_file(ifile)
+
+end program
diff --git a/examples/F90/codes_scan_file.sh b/examples/F90/codes_scan_file.sh
new file mode 100755
index 000000000..4df8398b5
--- /dev/null
+++ b/examples/F90/codes_scan_file.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# (C) Copyright 2005- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+
+. ./include.ctest.sh
+
+label='eccodes_f_codes_scan_file'
+temp=temp.$label.txt
+
+# The input file is hard coded => data/index.grib
+${examples_dir}/eccodes_f_codes_scan_file > $temp
+
+grep -q "Num messages= *384" $temp
+grep -q "level= *700 step= *60" $temp
+
+rm -f $temp
diff --git a/examples/F90/grib_elements.f90 b/examples/F90/grib_elements.f90
new file mode 100644
index 000000000..28b0526b6
--- /dev/null
+++ b/examples/F90/grib_elements.f90
@@ -0,0 +1,50 @@
+! (C) Copyright 2005- ECMWF.
+!
+! This software is licensed under the terms of the Apache Licence Version 2.0
+! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+!
+! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+!
+!
+program grib_get_elements
+ use eccodes
+ implicit none
+
+ integer :: infile, igrib, i
+ real(4) :: value_real4
+ real(8) :: value_real8
+ real(4) :: values_real4(4)
+ real(8) :: values_real8(4)
+ integer :: array_of_indexes(4)
+
+ call codes_open_file(infile, '../../data/reduced_gaussian_pressure_level.grib1', 'r')
+ call codes_grib_new_from_file(infile, igrib)
+
+ array_of_indexes = [1, 0, 2, 4]
+
+ print *,'Values as REAL(4) at specific indexes'
+ call codes_get_element(igrib, "values", array_of_indexes, values_real4)
+ do i = 1, 4
+ print *, array_of_indexes(i), values_real4(i)
+ end do
+
+ print *,'Values as REAL(8) at specific indexes'
+ call codes_get_element(igrib, "values", array_of_indexes, values_real8)
+ do i = 1, 4
+ print *, array_of_indexes(i), values_real8(i)
+ end do
+
+ i = 12
+ print *,'The Value REAL(4) at index=',i
+ call codes_get_element(igrib, "values", i, value_real4)
+ print *, value_real4
+
+ print *,'The Value REAL(8) at index=',i
+ call codes_get_element(igrib, "values", i, value_real8)
+ print *, value_real8
+
+ call codes_release(igrib)
+ call codes_close_file(infile)
+
+end program
diff --git a/examples/F90/grib_elements.sh b/examples/F90/grib_elements.sh
new file mode 100755
index 000000000..86ad91414
--- /dev/null
+++ b/examples/F90/grib_elements.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+# (C) Copyright 2005- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+
+. ./include.ctest.sh
+
+${examples_dir}/eccodes_f_grib_elements
diff --git a/examples/F90/grib_get_data_real4.f90 b/examples/F90/grib_get_data_real4.f90
new file mode 100644
index 000000000..647724245
--- /dev/null
+++ b/examples/F90/grib_get_data_real4.f90
@@ -0,0 +1,76 @@
+! (C) Copyright 2005- ECMWF.
+!
+! This software is licensed under the terms of the Apache Licence Version 2.0
+! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+!
+! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+!
+!
+!
+program get_data_real4
+ use eccodes
+ implicit none
+ integer :: ifile
+ integer :: iret, i
+ real(kind=4), dimension(:), allocatable :: lats, lons, values
+ integer, dimension(:), allocatable :: bitmap
+ integer(4) :: numberOfPoints
+ logical :: is_missing_value
+ integer :: count1 = 0, count2 = 0, bitmapPresent = 0, bmp_len = 0
+ integer :: igrib ! message identifier
+
+ ifile = 5
+
+ call codes_open_file(ifile, '../../data/reduced_latlon_surface.grib2', 'r')
+
+ ! loop on all the messages in the file
+ do while (.true.)
+ call codes_grib_new_from_file(ifile, igrib, iret)
+ if (iret == CODES_END_OF_FILE) exit
+
+ count1 = count1 + 1
+ print *, "===== Message #", count1
+ call codes_get(igrib, 'numberOfPoints', numberOfPoints)
+ call codes_get(igrib, 'bitmapPresent', bitmapPresent)
+
+ allocate (lats(numberOfPoints))
+ allocate (lons(numberOfPoints))
+ allocate (values(numberOfPoints))
+ if (bitmapPresent == 1) then
+ ! get the bitmap
+ call codes_get_size(igrib, 'bitmap', bmp_len)
+ allocate (bitmap(bmp_len))
+ call codes_get(igrib, 'bitmap', bitmap)
+ end if
+
+ call codes_grib_get_data(igrib, lats, lons, values)
+
+ do i = 1, numberOfPoints
+ ! consult bitmap to see if the i'th value is missing
+ is_missing_value = .false.
+ if (bitmapPresent == 1 .and. bitmap(i) == 0) then
+ is_missing_value = .true.
+ end if
+ ! only print non-missing values
+ if (.not. is_missing_value) then
+ print *, lats(i), lons(i), values(i)
+ count2 = count2 + 1
+ end if
+ end do
+ print *, 'count of non-missing values=', count2
+ if (count2 /= 214661) then
+ call codes_check(-2, 'incorrect number of missing', '')
+ end if
+
+ deallocate (lats)
+ deallocate (lons)
+ deallocate (values)
+
+ call codes_release(igrib)
+
+ end do
+
+ call codes_close_file(ifile)
+
+end program
diff --git a/examples/F90/grib_get_data_real4.sh b/examples/F90/grib_get_data_real4.sh
new file mode 100755
index 000000000..b251fd645
--- /dev/null
+++ b/examples/F90/grib_get_data_real4.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+# (C) Copyright 2005- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+
+. ./include.ctest.sh
+
+${examples_dir}/eccodes_f_grib_get_data_real4 > /dev/null
diff --git a/examples/F90/grib_index.f90 b/examples/F90/grib_index.f90
index d0d248978..1d928e2ea 100644
--- a/examples/F90/grib_index.f90
+++ b/examples/F90/grib_index.f90
@@ -23,7 +23,7 @@ program index
character(len=20) :: oshortName
integer :: shortNameSize, numberSize, levelSize, stepSize
integer :: i, j, k, l
- integer :: idx, igrib, count1
+ integer :: idx, idx1, igrib, count1
character(len=10) :: index_file = 'index.idx'
! uncomment following line to load index from file
@@ -107,7 +107,10 @@ program index
! save the index to a file for later reuse
call codes_index_write(idx, index_file)
+ call codes_index_read(idx1, index_file)
+
call codes_index_release(idx)
+ call codes_index_release(idx1)
deallocate (level)
deallocate (shortName)
diff --git a/examples/F90/grib_keys_iterator_skip.f90 b/examples/F90/grib_keys_iterator_skip.f90
new file mode 100644
index 000000000..f6c58d227
--- /dev/null
+++ b/examples/F90/grib_keys_iterator_skip.f90
@@ -0,0 +1,57 @@
+! (C) Copyright 2005- ECMWF.
+!
+! This software is licensed under the terms of the Apache Licence Version 2.0
+! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+!
+! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+!
+!
+program keys_iterator_skip
+ use eccodes
+ implicit none
+ character(len=20) :: name_space
+ integer :: kiter, ifile, igrib, iret
+ character(len=256) :: key
+ character(len=256) :: value
+ character(len=512) :: all1
+ integer :: grib_count
+
+ call codes_open_file(ifile, &
+ '../../data/regular_latlon_surface.grib1', 'r')
+
+ ! Loop on all the messages in a file
+ grib_count = 0
+ do while (.true.)
+ call codes_grib_new_from_file(ifile, igrib, iret)
+ if (iret == CODES_END_OF_FILE) exit
+
+ grib_count = grib_count + 1
+ write (*, *) '-- GRIB N. ', grib_count, ' --'
+
+ ! Choose a namespace. E.g. "ls", "time", "parameter", "geography", "statistics"
+ name_space = 'ls'
+
+ call codes_keys_iterator_new(igrib, kiter, name_space)
+ call codes_skip_computed(kiter)
+ call codes_skip_coded(kiter)
+ call codes_skip_duplicates(kiter)
+ call codes_skip_read_only(kiter)
+
+ do
+ call codes_keys_iterator_next(kiter, iret)
+ if (iret .ne. CODES_SUCCESS) exit !terminate the loop
+
+ call codes_keys_iterator_get_name(kiter, key)
+ call codes_get(igrib, trim(key), value)
+ all1 = trim(key)//' = '//trim(value)
+ write (*, *) trim(all1)
+ end do
+
+ call codes_keys_iterator_delete(kiter)
+ call codes_release(igrib)
+ end do
+
+ call codes_close_file(ifile)
+
+end program keys_iterator_skip
diff --git a/examples/F90/grib_keys_iterator_skip.sh b/examples/F90/grib_keys_iterator_skip.sh
new file mode 100755
index 000000000..03b05fb8b
--- /dev/null
+++ b/examples/F90/grib_keys_iterator_skip.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+# (C) Copyright 2005- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+
+. ./include.ctest.sh
+
+${examples_dir}/eccodes_f_grib_keys_iterator_skip
diff --git a/examples/F90/grib_nearest_four_single.f90 b/examples/F90/grib_nearest_four_single.f90
new file mode 100644
index 000000000..674745bfd
--- /dev/null
+++ b/examples/F90/grib_nearest_four_single.f90
@@ -0,0 +1,31 @@
+! (C) Copyright 2005- ECMWF.
+!
+! This software is licensed under the terms of the Apache Licence Version 2.0
+! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+!
+! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+!
+program find_nearest_4single
+ use eccodes
+ implicit none
+ integer :: infile, i
+ integer :: igrib
+ real(8) :: inlat = 5, inlon = 10
+ real(8) :: outlats(4), outlons(4)
+ real(8) :: values(4), distances(4)
+ integer(kind=kindOfInt) :: indexes(4)
+
+ call codes_open_file(infile, '../../data/reduced_gaussian_lsm.grib1', 'r')
+ call codes_grib_new_from_file(infile, igrib)
+
+ call codes_grib_find_nearest_four_single(igrib, .true., inlat, inlon, outlats, outlons, values, distances, indexes)
+ call codes_release(igrib)
+
+ call codes_close_file(infile)
+
+ print *, ' outlats outlons values distances indexes'
+ do i = 1, 4
+ write (*, '(F10.3, F10.3, F10.5, F10.3, I8)') outlats(i), outlons(i), values(i), distances(i), indexes(i)
+ end do
+end program
diff --git a/examples/F90/grib_nearest_four_single.sh b/examples/F90/grib_nearest_four_single.sh
new file mode 100755
index 000000000..22b07624f
--- /dev/null
+++ b/examples/F90/grib_nearest_four_single.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+# (C) Copyright 2005- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+
+. ./include.ctest.sh
+
+${examples_dir}/eccodes_f_grib_nearest_four_single
diff --git a/examples/F90/grib_nearest_single.f90 b/examples/F90/grib_nearest_single.f90
new file mode 100644
index 000000000..5be355f9b
--- /dev/null
+++ b/examples/F90/grib_nearest_single.f90
@@ -0,0 +1,30 @@
+! (C) Copyright 2005- ECMWF.
+!
+! This software is licensed under the terms of the Apache Licence Version 2.0
+! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+!
+! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+!
+program find_nearest_single
+ use eccodes
+ implicit none
+ integer :: infile
+ integer :: igrib
+ real(8) :: inlat = 5, inlon = 10
+ real(8) :: outlat, outlon
+ real(8) :: value, distance
+ integer(kind=kindOfInt) :: index
+
+ call codes_open_file(infile, '../../data/reduced_gaussian_lsm.grib1', 'r')
+ call codes_grib_new_from_file(infile, igrib)
+
+ call codes_grib_find_nearest_single(igrib, .true., inlat, inlon, outlat, outlon, value, distance, index)
+ call codes_release(igrib)
+
+ call codes_close_file(infile)
+
+ print *, ' outlat outlon value distance index'
+ write (*, '(F10.3, F10.3, F10.5, F10.3, I8)') outlat, outlon, value, distance, index
+
+end program find_nearest_single
diff --git a/examples/F90/grib_nearest_single.sh b/examples/F90/grib_nearest_single.sh
new file mode 100755
index 000000000..0443595dd
--- /dev/null
+++ b/examples/F90/grib_nearest_single.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+# (C) Copyright 2005- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+
+. ./include.ctest.sh
+
+${examples_dir}/eccodes_f_grib_nearest_single
diff --git a/examples/F90/grib_read_bytes.f90 b/examples/F90/grib_read_bytes.f90
new file mode 100644
index 000000000..950eb2924
--- /dev/null
+++ b/examples/F90/grib_read_bytes.f90
@@ -0,0 +1,27 @@
+! (C) Copyright 2005- ECMWF.
+!
+! This software is licensed under the terms of the Apache Licence Version 2.0
+! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+!
+! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+!
+!
+program grib_read_bytes
+ use eccodes
+ implicit none
+ integer :: ifile
+ integer :: intsize
+ parameter(intsize=10000)
+ character, dimension(intsize) :: bufferChar
+ character(len=32) :: input_grib_file = '../../data/v.grib2'
+
+ call codes_open_file(ifile, input_grib_file, 'r')
+
+ ! First 4 chars should be 'GRIB'
+ call codes_read_bytes(ifile, bufferChar, 4)
+ print*, bufferChar(1:5)
+
+ call codes_close_file(ifile)
+
+end program
diff --git a/examples/F90/grib_read_bytes.sh b/examples/F90/grib_read_bytes.sh
new file mode 100755
index 000000000..37858c63f
--- /dev/null
+++ b/examples/F90/grib_read_bytes.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+# (C) Copyright 2005- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+
+. ./include.ctest.sh
+
+${examples_dir}/eccodes_f_grib_read_bytes
diff --git a/examples/F90/grib_set_data_force.f90 b/examples/F90/grib_set_data_force.f90
new file mode 100644
index 000000000..d8762e649
--- /dev/null
+++ b/examples/F90/grib_set_data_force.f90
@@ -0,0 +1,55 @@
+! (C) Copyright 2005- ECMWF.
+!
+! This software is licensed under the terms of the Apache Licence Version 2.0
+! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+!
+! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+!
+!
+program set_data_force
+ use eccodes
+ implicit none
+ integer :: outfile
+ integer :: i, igrib, iret, numberOfValues, cnt
+ real :: d, e
+ real(4), dimension(:), allocatable :: values_real4
+ real(8), dimension(:), allocatable :: values_real8
+ integer, parameter :: max_strsize = 200
+ character(len=max_strsize) :: outfile_name
+
+ call getarg(1, outfile_name)
+ call codes_open_file(outfile, outfile_name, 'w')
+
+ call codes_grib_new_from_samples(igrib, 'regular_ll_pl_grib1')
+
+ call codes_get_size(igrib, 'values', numberOfValues)
+
+ allocate (values_real4(numberOfValues), stat=iret)
+ allocate (values_real8(numberOfValues), stat=iret)
+ d = 10e-8
+ e = d
+ cnt = 1
+ do i = 1, numberOfValues
+ if (cnt > 100) then
+ e = e*10
+ cnt = 1
+ end if
+ values_real4(i) = d
+ values_real8(i) = d
+ d = d + e
+ cnt = cnt + 1
+ end do
+
+ call codes_set(igrib, 'bitsPerValue', 16)
+ call codes_set(igrib, 'bitmapPresent', 1)
+
+ ! set data values
+ call codes_set_force(igrib, 'codedValues', values_real4)
+ call codes_set_force(igrib, 'codedValues', values_real8)
+ call codes_write(igrib, outfile)
+ call codes_release(igrib)
+ deallocate (values_real4)
+ deallocate (values_real8)
+
+end program set_data_force
diff --git a/examples/F90/grib_set_data_force.sh b/examples/F90/grib_set_data_force.sh
new file mode 100755
index 000000000..d4f357b3a
--- /dev/null
+++ b/examples/F90/grib_set_data_force.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+# (C) Copyright 2005- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+
+. ./include.ctest.sh
+
+OUT=temp.f_grib_set_data_force.out.grib
+
+${examples_dir}/eccodes_f_grib_set_data_force $OUT
+
+rm -f $OUT
diff --git a/examples/F90/include.sh b/examples/F90/include.sh
deleted file mode 100755
index 74403ee37..000000000
--- a/examples/F90/include.sh
+++ /dev/null
@@ -1,59 +0,0 @@
-# (C) Copyright 2005- ECMWF.
-#
-# This software is licensed under the terms of the Apache Licence Version 2.0
-# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-#
-# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
-# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
-
-CMAKE_INCLUDE_FILE=include.ctest.sh
-if [ -f "$CMAKE_INCLUDE_FILE" ]; then
- # This is the config file for Cmake tests
- . ./$CMAKE_INCLUDE_FILE
-
-else
- set -eax
-
- echo
- echo "TEST: $0"
-
- if [ -z "${data_dir}" ]
- then
- cd ../../
- cpath=`pwd`
- ECCODES_DEFINITION_PATH=$cpath/definitions
- export ECCODES_DEFINITION_PATH
- ECCODES_SAMPLES_PATH=$cpath/samples
- export ECCODES_SAMPLES_PATH
- tools_dir=$cpath/tools
- examples_dir=$cpath/examples/F90
- data_dir=$cpath/data
- samples_dir=$cpath/samples
-
- if test "x$ECCODES_TEST_WITH_VALGRIND" != "x"; then
- tools_dir="valgrind --error-exitcode=1 -q $cpath/tools"
- examples_dir="valgrind --error-exitcode=1 -q $cpath/examples/F90"
- fi
-
- else
- echo "Skipping test $0"
- exit
- fi
-
- cd "$cpath/examples/F90"
-
- if [ -z "${GRIB_API_INCLUDE}" ]
- then
- GRIB_API_INCLUDE=`pwd`/src
- fi
-
- if [ -z "${GRIB_API_LIB}" ]
- then
- GRIB_API_LIB=`pwd`/src
- fi
-
- # Download the data needed for tests
- ${data_dir}/download.sh "${data_dir}"
-
- set -u
-fi
diff --git a/examples/python/CMakeLists.txt b/examples/python/CMakeLists.txt
index 42d8a2c52..abbf8b21a 100644
--- a/examples/python/CMakeLists.txt
+++ b/examples/python/CMakeLists.txt
@@ -3,7 +3,7 @@
# Configure the file which all CMake tests will include
configure_file( include.ctest.sh.in include.ctest.sh @ONLY )
-execute_process( COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include.sh ${CMAKE_CURRENT_BINARY_DIR} )
+# execute_process( COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include.sh ${CMAKE_CURRENT_BINARY_DIR} )
# Build the executables used by test scripts
################################################
diff --git a/examples/python/include.sh b/examples/python/include.sh
deleted file mode 100644
index e91fdd3d6..000000000
--- a/examples/python/include.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-CMAKE_INCLUDE_FILE=include.ctest.sh
-if [ -f "$CMAKE_INCLUDE_FILE" ]; then
- # This is the config file for Cmake tests
- . ./$CMAKE_INCLUDE_FILE
-
-else
- set -eax
- echo
- echo "TEST: $0"
-
- cpath=$TOPBUILDDIR
- ECCODES_DEFINITION_PATH=$cpath/definitions
- export ECCODES_DEFINITION_PATH
- ECCODES_SAMPLES_PATH=$cpath/samples
- export ECCODES_SAMPLES_PATH
- tools_dir=$cpath/tools
- examples_dir=$cpath/examples/python
- data_dir=$cpath/data
- examples_src=$examples_dir
-
- PYTHONPATH=$cpath/python:$cpath/python/.libs:$PYTHONPATH
- export PYTHONPATH
-
- HAVE_MEMFS=0
- ECCODES_ON_WINDOWS=0
-
- # Download the data needed for tests
- ${data_dir}/download.sh "${data_dir}"
-
- set -u
-
-fi
diff --git a/fortran/CMakeLists.txt b/fortran/CMakeLists.txt
index 650296c06..979ad0652 100644
--- a/fortran/CMakeLists.txt
+++ b/fortran/CMakeLists.txt
@@ -38,9 +38,6 @@ if( HAVE_FORTRAN )
COMMAND cat ${srcdir}/eccodes_f90_head.f90 ${srcdir}/${_long_int_interface_ec} ${srcdir}/${_sizet_int_interface_ec} ${srcdir}/eccodes_f90_tail.f90 > eccodes_f90.f90
DEPENDS eccodes_f90_head.f90 eccodes_f90_tail.f90 grib_kinds.h ${_long_int_interface_ec} ${_sizet_int_interface_ec} )
- #ecbuild_add_library( TARGET eccodes_f77
- # SOURCES grib_fortran.c grib_f77.c
- # LIBS eccodes )
# Note: $ will be present only while building (for the whole bundle),
# whereas $ is only present once you install the package / bundle
@@ -82,7 +79,7 @@ if( HAVE_FORTRAN )
ecbuild_add_resources( TARGET fortran_resources
PACK
- grib_fortran_prototypes.h grib_api_constants.h grib_api_externals.h
+ grib_api_constants.h grib_api_externals.h
grib_api_visibility.h grib_types.f90 create_grib_f90.sh
grib_f90.f90.head grib_f90.f90.tail grib_f90_int.f90 grib_f90_long_int.f90
grib_f90_int_size_t.f90 grib_f90_long_size_t.f90
diff --git a/fortran/eccodes_f90_tail.f90 b/fortran/eccodes_f90_tail.f90
index faf4e7e36..24551f8de 100644
--- a/fortran/eccodes_f90_tail.f90
+++ b/fortran/eccodes_f90_tail.f90
@@ -2597,8 +2597,8 @@
real(kind=kindOfDouble), intent(in) :: inlon
real(kind=kindOfDouble), intent(out) :: outlat
real(kind=kindOfDouble), intent(out) :: outlon
- real(kind=kindOfDouble), intent(out) :: distance
real(kind=kindOfDouble), intent(out) :: value
+ real(kind=kindOfDouble), intent(out) :: distance
integer(kind=kindOfInt), intent(out) :: kindex
integer(kind=kindOfInt), optional, intent(out) :: status
diff --git a/fortran/fortranCtypes/sizes.c b/fortran/fortranCtypes/sizes.c
index 913437fb6..63f4e5ba8 100644
--- a/fortran/fortranCtypes/sizes.c
+++ b/fortran/fortranCtypes/sizes.c
@@ -5,41 +5,40 @@ void grib_check_fortran_char(char* a) {
*a='f';
}
void grib_check_fortran_char_(char* a) {grib_check_fortran_char(a);}
-void grib_check_fortran_char__(char* a) {grib_check_fortran_char(a);}
+
void check_double(double *x,double *y,char* ret) {
*ret = ((char*)y)-((char*)x) == sizeof(*x) ? 't' : 'f';
}
void check_double_(double *x,double *y,char* ret) {check_double(x,y,ret);}
-void check_double__(double *x,double *y,char* ret) {check_double(x,y,ret);}
+
void check_float(float *x,float *y,char* ret) {
*ret = ((char*)y)-((char*)x) == sizeof(*x) ? 't' : 'f';
}
void check_float_(float *x,float *y,char* ret) { check_float(x,y,ret); }
-void check_float__(float *x,float *y,char* ret) { check_float(x,y,ret); }
+
void check_int(int *x,int *y,char* ret) {
*ret = ((char*)y)-((char*)x) == sizeof(*x) ? 't' : 'f';
}
void check_int_(int *x,int *y,char* ret) { check_int(x,y,ret); }
-void check_int__(int *x,int *y,char* ret) { check_int(x,y,ret); }
+
void check_long(long *x,long *y,char* ret) {
*ret = ((char*)y)-((char*)x) == sizeof(*x) ? 't' : 'f';
}
void check_long_(long *x,long *y,char* ret) {check_long(x,y,ret);}
-void check_long__(long *x,long *y,char* ret) {check_long(x,y,ret);}
+
void check_size_t(size_t *x,size_t *y,char* ret) {
*ret = ((char*)y)-((char*)x) == sizeof(*x) ? 't' : 'f';
}
void check_size_t_(size_t *x,size_t *y,char* ret) {check_size_t(x,y,ret);}
-void check_size_t__(size_t *x,size_t *y,char* ret) {check_size_t(x,y,ret);}
+
void check_long_long(long long *x,long long *y,char* ret) {
*ret = ((char*)y)-((char*)x) == sizeof(*x) ? 't' : 'f';
}
void check_long_long_(long long *x,long long *y,char* ret) {check_long_long(x,y,ret);}
-void check_long_long__(long long *x,long long *y,char* ret) {check_long_long(x,y,ret);}
diff --git a/fortran/grib_f77.c b/fortran/grib_f77.c
deleted file mode 100644
index 8c10c44b9..000000000
--- a/fortran/grib_f77.c
+++ /dev/null
@@ -1,510 +0,0 @@
-/*
- * (C) Copyright 2005- ECMWF.
- *
- * This software is licensed under the terms of the Apache Licence Version 2.0
- * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
- *
- * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
- * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
- */
-
-#include "grib_api_internal.h"
-#include "grib_fortran_prototypes.h"
-
-int grib_read_file_(int* fid, char* buffer, size_t* nbytes) {
- return grib_f_read_file_(fid,buffer,nbytes);
-}
-
-int grib_read_file__(int* fid, char* buffer, size_t* nbytes) {
- return grib_f_read_file_(fid,buffer,nbytes);
-}
-
-int grib_open_file_(int* fid, char* name , char* op, int lname, int lop){
- return grib_f_open_file_( fid, name , op, lname, lop);
-}
-
-int grib_open_file__(int* fid, char* name , char* op, int lname, int lop){
- return grib_f_open_file_( fid, name , op, lname, lop);
-}
-
-int grib_close_file_(int* fid){
- return grib_f_close_file_(fid);
-}
-
-int grib_close_file__(int* fid){
- return grib_f_close_file_(fid);
-}
-
-int grib_multi_support_on_(){
- return grib_f_multi_support_on_();
-}
-
-int grib_multi_support_on__(){
- return grib_f_multi_support_on_();
-}
-
-int grib_multi_support_off_(){
- return grib_f_multi_support_off_();
-}
-
-int grib_multi_support_off__(){
- return grib_f_multi_support_off_();
-}
-
-int grib_iterator_new_(int* gid,int* iterid,int* mode) {
- return grib_f_iterator_new_(gid,iterid,mode);
-}
-
-int grib_iterator_new__(int* gid,int* iterid,int* mode) {
- return grib_f_iterator_new_(gid,iterid,mode);
-}
-
-int grib_iterator_next_(int* iterid,double* lat,double* lon,double* value) {
- return grib_f_iterator_next_(iterid,lat,lon,value);
-}
-
-int grib_iterator_next__(int* iterid,double* lat,double* lon,double* value) {
- return grib_f_iterator_next_(iterid,lat,lon,value);
-}
-
-int grib_iterator_delete_(int* iterid) {
- return grib_f_iterator_delete_(iterid);
-}
-
-int grib_iterator_delete__(int* iterid) {
- return grib_f_iterator_delete_(iterid);
-}
-
-int grib_keys_iterator_new__(int* gid,int* iterid,char* name_space,int len) {
- return grib_f_keys_iterator_new_(gid,iterid,name_space,len);
-}
-
-int grib_keys_iterator_new_(int* gid,int* iterid,char* name_space,int len) {
- return grib_f_keys_iterator_new_(gid,iterid,name_space,len);
-}
-
-int grib_keys_iterator_next_(int* iterid) {
- return grib_f_keys_iterator_next_(iterid);
-}
-
-int grib_keys_iterator_next__(int* iterid) {
- return grib_f_keys_iterator_next_(iterid);
-}
-
-int grib_keys_iterator_delete_(int* iterid) {
- return grib_f_keys_iterator_delete_(iterid);
-}
-
-int grib_keys_iterator_delete__(int* iterid) {
- return grib_f_keys_iterator_delete_(iterid);
-}
-
-int grib_gribex_mode_on_() {
- grib_gribex_mode_on(0);
- return GRIB_SUCCESS;
-}
-
-int grib_gribex_mode_on__() {
- grib_gribex_mode_on(0);
- return GRIB_SUCCESS;
-}
-
-int grib_gribex_mode_off_() {
- grib_gribex_mode_off(0);
- return GRIB_SUCCESS;
-}
-
-int grib_gribex_mode_off__() {
- grib_gribex_mode_off(0);
- return GRIB_SUCCESS;
-}
-
-int grib_skip_computed_(int* iterid) {
- return grib_skip_computed_(iterid);
-}
-
-int grib_skip_computed__(int* iterid) {
- return grib_skip_computed_(iterid);
-}
-
-int grib_skip_coded_(int* iterid) {
- return grib_f_skip_coded_(iterid);
-}
-
-int grib_skip_coded__(int* iterid) {
- return grib_f_skip_coded_(iterid);
-}
-
-int grib_skip_edition_specific_(int* iterid) {
- return grib_f_skip_edition_specific_(iterid);
-}
-
-int grib_skip_edition_specific__(int* iterid) {
- return grib_f_skip_edition_specific_(iterid);
-}
-
-int grib_skip_duplicates_(int* iterid) {
- return grib_f_skip_duplicates_(iterid);
-}
-
-int grib_skip_duplicates__(int* iterid) {
- return grib_f_skip_duplicates_(iterid);
-}
-
-int grib_skip_read_only_(int* iterid) {
- return grib_f_skip_read_only_(iterid);
-}
-
-int grib_skip_read_only__(int* iterid) {
- return grib_f_skip_read_only_(iterid);
-}
-
-int grib_skip_function_(int* iterid) {
- return grib_f_skip_function_(iterid);
-}
-
-int grib_skip_function__(int* iterid) {
- return grib_f_skip_function_(iterid);
-}
-
-int grib_keys_iterator_get_name_(int* kiter,char* name,int len) {
- return grib_f_keys_iterator_get_name_(kiter,name,len);
-}
-
-int grib_keys_iterator_get_name__(int* kiter,char* name,int len) {
- return grib_f_keys_iterator_get_name_(kiter,name,len);
-}
-
-int grib_keys_iterator_rewind_(int* kiter) {
- return grib_f_keys_iterator_rewind_(kiter);
-}
-
-int grib_keys_iterator_rewind__(int* kiter) {
- return grib_f_keys_iterator_rewind_(kiter);
-}
-
-int grib_new_from_message_(int* gid, void* buffer , size_t* bufsize){
- return grib_f_new_from_message_(gid, buffer , bufsize);
-}
-
-int grib_new_from_message__(int* gid, void* buffer , size_t* bufsize){
- return grib_f_new_from_message_(gid, buffer , bufsize);
-}
-
-int grib_new_from_message_copy_(int* gid, void* buffer , size_t* bufsize){
- return grib_f_new_from_message_copy_(gid, buffer , bufsize);
-}
-
-int grib_new_from_message_copy__(int* gid, void* buffer , size_t* bufsize){
- return grib_f_new_from_message_copy_(gid, buffer , bufsize);
-}
-
-int grib_new_from_samples_(int* gid, char* name , int lname){
- return grib_f_new_from_samples_( gid, name , lname);
-}
-
-int grib_new_from_samples__(int* gid, char* name , int lname){
- return grib_f_new_from_samples_( gid, name , lname);
-}
-
-int grib_clone_(int* gidsrc,int* giddest){
- return grib_f_clone_(gidsrc, giddest);
-}
-
-int grib_clone__(int* gidsrc,int* giddest){
- return grib_f_clone_(gidsrc, giddest);
-}
-
-int grib_new_from_file_(int* fid, int* gid){
- return grib_f_new_from_file_( fid, gid);
-}
-
-int grib_new_from_file__(int* fid, int* gid){
- return grib_f_new_from_file_( fid, gid);
-}
-
-int grib_release_(int* hid){
- return grib_f_release_( hid);
-}
-
-int grib_release__(int* hid){
- return grib_f_release_( hid);
-}
-
-int grib_dump_(int* gid){
- return grib_f_dump_( gid);
-}
-
-int grib_dump__(int* gid){
- return grib_f_dump_( gid);
-}
-
-int grib_get_error_string_(int* err, char* buf, int len){
- return grib_f_get_error_string_(err,buf,len);
-}
-
-int grib_get_error_string__(int* err, char* buf, int len){
- return grib_f_get_error_string_(err,buf,len);
-}
-
-int grib_get_size_(int* gid, char* key, int* val, int len){
- return grib_f_get_size_int_( gid, key, val, len);
-}
-
-int grib_get_size__(int* gid, char* key, int* val, int len){
- return grib_f_get_size_int_( gid, key, val, len);
-}
-
-int grib_get_int_(int* gid, char* key, int* val, int len){
- return grib_f_get_int_( gid, key, val, len);
-}
-
-int grib_get_int__(int* gid, char* key, int* val, int len){
- return grib_f_get_int_( gid, key, val, len);
-}
-
-int grib_get_int_array_(int* gid, char* key, int*val, int* size, int len){
- return grib_f_get_int_array_( gid, key, val, size, len);
-}
-
-int grib_get_int_array__(int* gid, char* key, int*val, int* size, int len){
- return grib_f_get_int_array_( gid, key, val, size, len);
-}
-
-int grib_set_int_array_(int* gid, char* key, int* val, int* size, int len){
- return grib_f_set_int_array_( gid, key, val, size, len);
-}
-
-int grib_set_int_array__(int* gid, char* key, int* val, int* size, int len){
- return grib_f_set_int_array_( gid, key, val, size, len);
-}
-
-int grib_set_int_(int* gid, char* key, int* val, int len){
- return grib_f_set_int_( gid, key, val, len);
-}
-
-int grib_set_int__(int* gid, char* key, int* val, int len){
- return grib_f_set_int_( gid, key, val, len);
-}
-
-int grib_set_missing_(int* gid, char* key, int len){
- return grib_f_set_missing_( gid, key, len);
-}
-
-int grib_set_missing__(int* gid, char* key, int len){
- return grib_f_set_missing_( gid, key, len);
-}
-
-int grib_set_real4_(int* gid, char* key, float* val, int len){
- return grib_f_set_real4_( gid, key, val, len);
-}
-
-int grib_set_real4__(int* gid, char* key, float* val, int len){
- return grib_f_set_real4_( gid, key, val, len);
-}
-
-int grib_get_real4_(int* gid, char* key, float* val, int len){
- return grib_f_get_real4_( gid, key, val, len);
-}
-
-int grib_get_real4__(int* gid, char* key, float* val, int len){
- return grib_f_get_real4_( gid, key, val, len);
-}
-
-int grib_get_real4_array_(int* gid, char* key, float* val, int* size, int len){
- return grib_f_get_real4_array_( gid, key, val, size, len);
-}
-
-int grib_get_real4_element_(int* gid, char* key, int* index,float* val, int len){
- return grib_f_get_real4_element_( gid, key, index,val, len);
-}
-
-int grib_get_real4_element__(int* gid, char* key,int* index, float* val, int len){
- return grib_f_get_real4_element_( gid, key, index, val, len);
-}
-
-int grib_get_real4_elements__(int* gid, char* key,int* index, float* val,int* len,int size){
- return grib_f_get_real4_elements_( gid, key, index, val, len,size);
-}
-
-int grib_get_real4_elements_(int* gid, char* key,int* index, float* val,int* len,int size){
- return grib_f_get_real4_elements_( gid, key, index, val, len,size);
-}
-
-int grib_get_real4_array__(int* gid, char* key, float* val, int* size, int len){
- return grib_f_get_real4_array_( gid, key, val, size, len);
-}
-
-int grib_set_real4_array_(int* gid, char* key, float*val, int* size, int len){
- return grib_f_set_real4_array_( gid, key, val, size, len);
-}
-
-int grib_set_real4_array__(int* gid, char* key, float*val, int* size, int len){
- return grib_f_set_real4_array_( gid, key, val, size, len);
-}
-
-int grib_set_real8_(int* gid, char* key, double* val, int len){
- Assert(sizeof(double) == 8);
- return grib_f_set_real8_( gid, key, val, len);
-}
-
-int grib_set_real8__(int* gid, char* key, double* val, int len){
- Assert(sizeof(double) == 8);
- return grib_f_set_real8_( gid, key, val, len);
-}
-
-int grib_get_real8_(int* gid, char* key, double* val, int len){
- Assert(sizeof(double) == 8);
- return grib_f_get_real8_( gid, key, val, len);
-}
-
-int grib_get_real8__(int* gid, char* key, double* val, int len){
- Assert(sizeof(double) == 8);
- return grib_f_get_real8_( gid, key, val, len);
-}
-
-int grib_get_real8_element_(int* gid, char* key,int* index, double* val, int len){
- Assert(sizeof(double) == 8);
- return grib_f_get_real8_element_( gid, key, index,val, len);
-}
-
-int grib_get_real8_element__(int* gid, char* key,int* index, double* val, int len){
- Assert(sizeof(double) == 8);
- return grib_f_get_real8_element_( gid, key, index,val, len);
-}
-
-int grib_get_real8_elements_(int* gid, char* key, int* index,double* val, int* len,int size){
- return grib_f_get_real8_elements_( gid, key, index, val,len,size);
-}
-
-int grib_get_real8_elements__(int* gid, char* key, int* index,double* val, int* len,int size){
- return grib_f_get_real8_elements_( gid, key, index, val,len,size);
-}
-
-
-int grib_get_real8_array_(int* gid, char* key, double*val, int* size, int len){
- Assert(sizeof(double) == 8);
- return grib_f_get_real8_array_( gid, key, val, size, len);
-}
-
-int grib_get_real8_array__(int* gid, char* key, double*val, int* size, int len){
- Assert(sizeof(double) == 8);
- return grib_f_get_real8_array_( gid, key, val, size, len);
-}
-
-int grib_set_real8_array_(int* gid, char* key, double *val, int* size, int len){
- Assert(sizeof(double) == 8);
- return grib_f_set_real8_array_( gid, key, val, size, len);
-}
-
-int grib_set_real8_array__(int* gid, char* key, double *val, int* size, int len){
- Assert(sizeof(double) == 8);
- return grib_f_set_real8_array_( gid, key, val, size, len);
-}
-
-int grib_get_string_(int* gid, char* key, char* val, int len, int len2){
- return grib_f_get_string_( gid, key, val, len, len2);
-}
-
-int grib_get_string__(int* gid, char* key, char* val, int len, int len2){
- return grib_f_get_string_( gid, key, val, len, len2);
-}
-
-int grib_set_string_(int* gid, char* key, char* val, int len, int len2){
- return grib_f_set_string_( gid, key, val, len, len2);
-}
-
-int grib_set_string__(int* gid, char* key, char* val, int len, int len2){
- return grib_f_set_string_( gid, key, val, len, len2);
-}
-
-int grib_get_message_size_(int* gid, size_t *len){
- return grib_f_get_message_size_( gid, len);
-}
-
-int grib_get_message_size__(int* gid, size_t *len){
- return grib_f_get_message_size_( gid, len);
-}
-
-void grib_check_(int* err){
- grib_f_check_(err,"","",0,0);
-}
-
-void grib_check__(int* err){
- grib_f_check_(err,"","",0,0);
-}
-
-int grib_write_(int* gid, int* fid) {
- return grib_f_write_(gid,fid);
-}
-
-int grib_write__(int* gid, int* fid) {
- return grib_f_write_(gid,fid);
-}
-
-int grib_multi_write_(int* gid, int* fid) {
- return grib_f_multi_write_(gid,fid);
-}
-
-int grib_multi_write__(int* gid, int* fid) {
- return grib_f_multi_write_(gid,fid);
-}
-
-int grib_multi_append_(int* ingid, int* sec,int* mgid) {
- return grib_f_multi_append_(ingid,sec,mgid);
-}
-
-int grib_multi_append__(int* ingid, int* sec,int* mgid) {
- return grib_f_multi_append_(ingid,sec,mgid);
-}
-
-int grib_find_nearest_multiple_(int* gid,int* is_lsm,
- double* inlats,double* inlons,
- double* outlats,double* outlons,
- double* values,double* distances,
- int* indexes, int* npoints) {
-
- return grib_f_find_nearest_multiple_(gid,is_lsm,
- inlats,inlons,outlats,outlons,values,
- distances,indexes,npoints);
-}
-int grib_find_nearest_multiple__(int* gid,int* is_lsm,
- double* inlats,double* inlons,
- double* outlats,double* outlons,
- double* values,double* distances,
- int* indexes, int* npoints) {
-
- return grib_f_find_nearest_multiple_(gid,is_lsm,
- inlats,inlons,outlats,outlons,values,
- distances,indexes,npoints);
-}
-
-int grib_find_nearest_single_(int* gid,int* is_lsm,
- double* inlats,double* inlons,
- double* outlats,double* outlons,
- double* values,double* distances,
- int* indexes) {
-
- return grib_f_find_nearest_single_(gid,is_lsm,
- inlats,inlons,outlats,outlons,values,
- distances,indexes);
-}
-int grib_find_nearest_single__(int* gid,int* is_lsm,
- double* inlats,double* inlons,
- double* outlats,double* outlons,
- double* values,double* distances,
- int* indexes) {
-
- return grib_f_find_nearest_single_(gid,is_lsm,
- inlats,inlons,outlats,outlons,values,
- distances,indexes);
-}
-
-int grib_copy_message_(int* gid, void* mess,size_t* len){
- return grib_f_copy_message_(gid, mess,len);
-}
-int grib_copy_message__(int* gid, void* mess,size_t* len){
- return grib_f_copy_message_(gid, mess,len);
-}
-
-
diff --git a/fortran/grib_f90_tail.f90 b/fortran/grib_f90_tail.f90
index c7b3f0de9..c178eedbe 100644
--- a/fortran/grib_f90_tail.f90
+++ b/fortran/grib_f90_tail.f90
@@ -2316,7 +2316,7 @@
if (present(status)) then
status = iret
else
- call grib_check(iret, 'get', key)
+ call grib_check(iret, 'get_real4_elements', key)
end if
end subroutine grib_get_real4_elements
@@ -2348,7 +2348,7 @@
if (present(status)) then
status = iret
else
- call grib_check(iret, 'get', key)
+ call grib_check(iret, 'get_real8_elements', key)
end if
end subroutine grib_get_real8_elements
@@ -2649,7 +2649,7 @@
if (present(status)) then
status = iret
else
- call grib_check(iret, 'set', key)
+ call grib_check(iret, 'set_force_real4_array', key)
end if
end subroutine grib_set_force_real4_array
@@ -2665,12 +2665,12 @@
!> @param value real(8) array value
!> @param status GRIB_SUCCESS if OK, integer value on error
subroutine grib_set_force_real8_array(gribid, key, value, status)
- integer(kind=kindOfInt), intent(in) :: gribid
- character(len=*), intent(in) :: key
- real(kind=kindOfDouble), dimension(:), intent(in) :: value
- integer(kind=kindOfInt), optional, intent(out) :: status
- integer(kind=kindOfInt) :: iret
- integer(kind=kindOfInt) :: nb_values
+ integer(kind=kindOfInt), intent(in) :: gribid
+ character(len=*), intent(in) :: key
+ real(kind=kindOfDouble), dimension(:), intent(in) :: value
+ integer(kind=kindOfInt), optional, intent(out) :: status
+ integer(kind=kindOfInt) :: iret
+ integer(kind=kindOfInt) :: nb_values
nb_values = size(value)
iret = grib_f_set_force_real8_array(gribid, key, value, nb_values)
@@ -2680,7 +2680,7 @@
if (present(status)) then
status = iret
else
- call grib_check(iret, 'set', key)
+ call grib_check(iret, 'set_force_real8_array', key)
end if
end subroutine grib_set_force_real8_array
@@ -2696,10 +2696,10 @@
!> @param status GRIB_SUCCESS if OK, integer value on error
subroutine grib_set_string(gribid, key, value, status)
integer(kind=kindOfInt), intent(in) :: gribid
- character(len=*), intent(in) :: key
- character(len=*), intent(in) :: value
+ character(len=*), intent(in) :: key
+ character(len=*), intent(in) :: value
integer(kind=kindOfInt), optional, intent(out) :: status
- integer(kind=kindOfInt) :: iret
+ integer(kind=kindOfInt) :: iret
iret = grib_f_set_string(gribid, key, value)
if (iret /= 0) then
@@ -2722,8 +2722,8 @@
!> @param nbytes size in bytes of the message
!> @param status GRIB_SUCCESS if OK, integer value on error
subroutine grib_get_message_size_int(gribid, nbytes, status)
- integer(kind=kindOfInt), intent(in) :: gribid
- integer(kind=kindOfInt), intent(out) :: nbytes
+ integer(kind=kindOfInt), intent(in) :: gribid
+ integer(kind=kindOfInt), intent(out) :: nbytes
integer(kind=kindOfInt), optional, intent(out) :: status
integer(kind=kindOfInt) :: iret
integer(kind=kindOfSize_t) :: ibytes
@@ -2753,10 +2753,10 @@
!> @param nbytes size in bytes of the message
!> @param status GRIB_SUCCESS if OK, integer value on error
subroutine grib_get_message_size_size_t(gribid, nbytes, status)
- integer(kind=kindOfInt), intent(in) :: gribid
+ integer(kind=kindOfInt), intent(in) :: gribid
integer(kind=kindOfSize_t), intent(out) :: nbytes
integer(kind=kindOfInt), optional, intent(out) :: status
- integer(kind=kindOfInt) :: iret
+ integer(kind=kindOfInt) :: iret
iret = grib_f_get_message_size(gribid, nbytes)
if (iret /= 0) then
@@ -2779,7 +2779,7 @@
!> @param message array containing the coded message to be copied
!> @param status GRIB_SUCCESS if OK, integer value on error
subroutine grib_copy_message(gribid, message, status)
- integer(kind=kindOfInt), intent(in) :: gribid
+ integer(kind=kindOfInt), intent(in) :: gribid
character(len=1), dimension(:), intent(out) :: message
integer(kind=kindOfInt), optional, intent(out) :: status
integer(kind=kindOfInt) :: iret
@@ -2810,7 +2810,6 @@
integer(kind=kindOfInt), intent(in) :: gribid
integer(kind=kindOfInt), intent(in) :: ifile
integer(kind=kindOfInt), optional, intent(out) :: status
-
integer(kind=kindOfInt) :: iret
iret = grib_f_write(gribid, ifile)
@@ -2834,7 +2833,7 @@
integer(kind=kindOfInt), intent(in) :: multigribid
integer(kind=kindOfInt), intent(in) :: ifile
integer(kind=kindOfInt), optional, intent(out) :: status
- integer(kind=kindOfInt) :: iret
+ integer(kind=kindOfInt) :: iret
iret = grib_f_multi_write(multigribid, ifile)
if (present(status)) then
@@ -2938,13 +2937,13 @@
inlat, inlon, outlat, outlon, &
value, distance, kindex, status)
integer(kind=kindOfInt), intent(in) :: gribid
- logical, intent(in) :: is_lsm
+ logical, intent(in) :: is_lsm
real(kind=kindOfDouble), intent(in) :: inlat
real(kind=kindOfDouble), intent(in) :: inlon
real(kind=kindOfDouble), intent(out) :: outlat
real(kind=kindOfDouble), intent(out) :: outlon
- real(kind=kindOfDouble), intent(out) :: distance
real(kind=kindOfDouble), intent(out) :: value
+ real(kind=kindOfDouble), intent(out) :: distance
integer(kind=kindOfInt), intent(out) :: kindex
integer(kind=kindOfInt), optional, intent(out) :: status
integer(kind=kindOfInt) :: iret
@@ -3058,7 +3057,7 @@
if (present(status)) then
status = iret
else
- call grib_check(iret, 'grib_gribex_mode_on', '')
+ call grib_check(iret, 'gribex_mode_on', '')
end if
end subroutine grib_gribex_mode_on
@@ -3078,7 +3077,7 @@
if (present(status)) then
status = iret
else
- call grib_check(iret, 'grib_gribex_mode_off', '')
+ call grib_check(iret, 'gribex_mode_off', '')
end if
end subroutine grib_gribex_mode_off
diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.c
index c8d93bd1c..d9ab1f459 100644
--- a/fortran/grib_fortran.c
+++ b/fortran/grib_fortran.c
@@ -9,7 +9,6 @@
*/
#include "grib_api_internal.h"
-#include "grib_fortran_prototypes.h"
#if HAVE_SYS_TYPES_H
# include
@@ -27,9 +26,9 @@
#include
-/* Have file ids distinct from grib ids, in order to be
- * protected against user errors where a file id is given
- * instead of a grib id or viceversa
+/* Have file ids distinct from GRIB/BUFR ids, in order to be
+ * protected against user errors where a file id is given
+ * instead of a GRIB/BUFR id or vice versa
*/
#define MIN_FILE_ID 50000
@@ -67,9 +66,8 @@ static omp_nest_lock_t keys_iterator_mutex;
static void init()
{
GRIB_OMP_CRITICAL(lock_fortran)
- {
- if (once == 0)
- {
+ {
+ if (once == 0) {
omp_init_nest_lock(&handle_mutex);
omp_init_nest_lock(&index_mutex);
omp_init_nest_lock(&read_mutex);
@@ -78,7 +76,7 @@ static void init()
omp_init_nest_lock(&keys_iterator_mutex);
once = 1;
}
- }
+ }
}
#endif
@@ -88,9 +86,8 @@ typedef enum FileMode {
FILE_MODE_APPEND
} FileMode;
-int GRIB_NULL=-1;
-int GRIB_NULL_NEAREST=-1;
-/*extern int errno;*/
+int GRIB_NULL = -1;
+int GRIB_NULL_NEAREST = -1;
typedef struct l_grib_file l_grib_file;
@@ -843,6 +840,7 @@ static int clear_bufr_keys_iterator(int keys_iterator_id)
}
/*****************************************************************************/
+#if 0
int grib_f_read_any_headers_only_from_file_(int* fid, char* buffer, size_t* nbytes) {
grib_context* c;
int err=0;
@@ -856,12 +854,7 @@ int grib_f_read_any_headers_only_from_file_(int* fid, char* buffer, size_t* nbyt
return GRIB_INVALID_FILE;
}
}
-int grib_f_read_any_headers_only_from_file__(int* fid, char* buffer, size_t* nbytes) {
- return grib_f_read_any_headers_only_from_file_(fid,buffer,nbytes);
-}
-int grib_f_read_any_headers_only_from_file(int* fid, char* buffer, size_t* nbytes) {
- return grib_f_read_any_headers_only_from_file_(fid,buffer,nbytes);
-}
+#endif
/*****************************************************************************/
int grib_f_read_any_from_file_(int* fid, void* buffer, size_t* nbytes) {
@@ -877,12 +870,6 @@ int grib_f_read_any_from_file_(int* fid, void* buffer, size_t* nbytes) {
return GRIB_INVALID_FILE;
}
}
-int grib_f_read_any_from_file__(int* fid, void* buffer, size_t* nbytes) {
- return grib_f_read_any_from_file_(fid,buffer,nbytes);
-}
-int grib_f_read_any_from_file(int* fid, void* buffer, size_t* nbytes) {
- return grib_f_read_any_from_file_(fid,buffer,nbytes);
-}
/*****************************************************************************/
int grib_f_write_file_(int* fid, void* buffer, size_t* nbytes) {
@@ -902,12 +889,6 @@ int grib_f_write_file_(int* fid, void* buffer, size_t* nbytes) {
return GRIB_INVALID_FILE;
}
}
-int grib_f_write_file__(int* fid, void* buffer, size_t* nbytes) {
- return grib_f_write_file_(fid,buffer,nbytes);
-}
-int grib_f_write_file(int* fid, void* buffer, size_t* nbytes) {
- return grib_f_write_file_(fid,buffer,nbytes);
-}
/*****************************************************************************/
int grib_f_read_file_(int* fid, void* buffer, size_t* nbytes) {
@@ -927,12 +908,6 @@ int grib_f_read_file_(int* fid, void* buffer, size_t* nbytes) {
return GRIB_INVALID_FILE;
}
}
-int grib_f_read_file__(int* fid, void* buffer, size_t* nbytes) {
- return grib_f_read_file_(fid,buffer,nbytes);
-}
-int grib_f_read_file(int* fid, void* buffer, size_t* nbytes) {
- return grib_f_read_file_(fid,buffer,nbytes);
-}
/*****************************************************************************/
int grib_f_open_file_(int* fid, char* name , char* op, int lname, int lop) {
@@ -980,23 +955,11 @@ int grib_f_open_file_(int* fid, char* name , char* op, int lname, int lop) {
}
return ret;
}
-int grib_f_open_file__(int* fid, char* name , char* op, int lname, int lop){
- return grib_f_open_file_(fid, name, op, lname, lop);
-}
-int grib_f_open_file(int* fid, char* name , char* op, int lname, int lop){
- return grib_f_open_file_(fid, name, op, lname, lop);
-}
/*****************************************************************************/
int grib_f_close_file_(int* fid){
return clear_file(*fid);
}
-int grib_f_close_file__(int* fid){
- return grib_f_close_file_(fid);
-}
-int grib_f_close_file(int* fid){
- return grib_f_close_file_(fid);
-}
/*****************************************************************************/
static int file_count=0;
@@ -1022,32 +985,16 @@ void grib_f_write_on_fail(int* gid) {
void grib_f_write_on_fail_(int* gid) {
grib_f_write_on_fail(gid);
}
-void grib_f_write_on_fail__(int* gid) {
- grib_f_write_on_fail(gid);
-}
-
/*****************************************************************************/
int grib_f_multi_support_on_(){
grib_multi_support_on(0);
return GRIB_SUCCESS;
}
-int grib_f_multi_support_on__(){
- return grib_f_multi_support_on_();
-}
-int grib_f_multi_support_on(){
- return grib_f_multi_support_on_();
-}
int grib_f_multi_support_off_(){
grib_multi_support_off(0);
return GRIB_SUCCESS;
}
-int grib_f_multi_support_off__(){
- return grib_f_multi_support_off_();
-}
-int grib_f_multi_support_off(){
- return grib_f_multi_support_off_();
-}
/*****************************************************************************/
#ifdef FORTRAN_GEOITERATOR_SUPPORT
@@ -1164,34 +1111,16 @@ int grib_f_iterator_new_(int* gid,int* iterid,int* mode) {
GRIB_MUTEX_UNLOCK(&iterator_mutex)
return ret;
}
-int grib_f_iterator_new__(int* gid,int* iterid,int* mode) {
- return grib_f_iterator_new_(gid,iterid,mode);
-}
-int grib_f_iterator_new(int* gid,int* iterid,int* mode) {
- return grib_f_iterator_new_(gid,iterid,mode);
-}
/*****************************************************************************/
int grib_f_iterator_next_(int* iterid,double* lat,double* lon,double* value) {
grib_iterator* iter=get_iterator(*iterid);
if (!iter) return GRIB_INVALID_ITERATOR;
return grib_iterator_next(iter,lat,lon,value);
}
-int grib_f_iterator_next__(int* iterid,double* lat,double* lon,double* value) {
- return grib_f_iterator_next_(iterid,lat,lon,value);
-}
-int grib_f_iterator_next(int* iterid,double* lat,double* lon,double* value) {
- return grib_f_iterator_next_(iterid,lat,lon,value);
-}
/*****************************************************************************/
int grib_f_iterator_delete_(int* iterid) {
return clear_iterator(*iterid);
}
-int grib_f_iterator_delete__(int* iterid) {
- return grib_f_iterator_delete_(iterid);
-}
-int grib_f_iterator_delete(int* iterid) {
- return grib_f_iterator_delete_(iterid);
-}
#endif /*FORTRAN_GEOITERATOR_SUPPORT*/
/*****************************************************************************/
@@ -1221,12 +1150,6 @@ int grib_f_keys_iterator_new_(int* gid,int* iterid,char* name_space,int len) {
GRIB_MUTEX_UNLOCK(&keys_iterator_mutex)
return ret;
}
-int grib_f_keys_iterator_new__(int* gid,int* iterid,char* name_space,int len) {
- return grib_f_keys_iterator_new_(gid,iterid,name_space,len);
-}
-int grib_f_keys_iterator_new(int* gid,int* iterid,char* name_space,int len) {
- return grib_f_keys_iterator_new_(gid,iterid,name_space,len);
-}
/*****************************************************************************/
int grib_f_keys_iterator_next_(int* iterid) {
@@ -1235,50 +1158,22 @@ int grib_f_keys_iterator_next_(int* iterid) {
return grib_keys_iterator_next(iter);
}
-int grib_f_keys_iterator_next__(int* iterid) {
- return grib_f_keys_iterator_next_(iterid);
-}
-int grib_f_keys_iterator_next(int* iterid) {
- return grib_f_keys_iterator_next_(iterid);
-}
/*****************************************************************************/
int grib_f_keys_iterator_delete_(int* iterid) {
return clear_keys_iterator(*iterid);
}
-int grib_f_keys_iterator_delete__(int* iterid) {
- return grib_f_keys_iterator_delete_(iterid);
-}
-int grib_f_keys_iterator_delete(int* iterid) {
- return grib_f_keys_iterator_delete_(iterid);
-}
/*****************************************************************************/
int grib_f_gribex_mode_on_() {
grib_gribex_mode_on(0);
return GRIB_SUCCESS;
}
-int grib_f_gribex_mode_on__() {
- grib_gribex_mode_on(0);
- return GRIB_SUCCESS;
-}
-int grib_f_gribex_mode_on() {
- grib_gribex_mode_on(0);
- return GRIB_SUCCESS;
-}
int grib_f_gribex_mode_off_() {
grib_gribex_mode_off(0);
return GRIB_SUCCESS;
}
-int grib_f_gribex_mode_off__() {
- grib_gribex_mode_off(0);
- return GRIB_SUCCESS;
-}
-int grib_f_gribex_mode_off() {
- grib_gribex_mode_off(0);
- return GRIB_SUCCESS;
-}
/*****************************************************************************/
int grib_f_skip_computed_(int* iterid) {
@@ -1286,72 +1181,36 @@ int grib_f_skip_computed_(int* iterid) {
if (!iter) return GRIB_INVALID_KEYS_ITERATOR;
return grib_keys_iterator_set_flags(iter,GRIB_KEYS_ITERATOR_SKIP_COMPUTED);
}
-int grib_f_skip_computed__(int* iterid) {
- return grib_f_skip_computed_(iterid);
-}
-int grib_f_skip_computed(int* iterid) {
- return grib_f_skip_computed_(iterid);
-}
int grib_f_skip_coded_(int* iterid) {
grib_keys_iterator* iter=get_keys_iterator(*iterid);
if (!iter) return GRIB_INVALID_KEYS_ITERATOR;
return grib_keys_iterator_set_flags(iter,GRIB_KEYS_ITERATOR_SKIP_CODED);
}
-int grib_f_skip_coded__(int* iterid) {
- return grib_f_skip_coded_(iterid);
-}
-int grib_f_skip_coded(int* iterid) {
- return grib_f_skip_coded_(iterid);
-}
int grib_f_skip_edition_specific_(int* iterid) {
grib_keys_iterator* iter=get_keys_iterator(*iterid);
if (!iter) return GRIB_INVALID_KEYS_ITERATOR;
return grib_keys_iterator_set_flags(iter,GRIB_KEYS_ITERATOR_SKIP_EDITION_SPECIFIC);
}
-int grib_f_skip_edition_specific__(int* iterid) {
- return grib_f_skip_edition_specific_(iterid);
-}
-int grib_f_skip_edition_specific(int* iterid) {
- return grib_f_skip_edition_specific_(iterid);
-}
int grib_f_skip_duplicates_(int* iterid) {
grib_keys_iterator* iter=get_keys_iterator(*iterid);
if (!iter) return GRIB_INVALID_KEYS_ITERATOR;
return grib_keys_iterator_set_flags(iter,GRIB_KEYS_ITERATOR_SKIP_DUPLICATES);
}
-int grib_f_skip_duplicates__(int* iterid) {
- return grib_f_skip_duplicates_(iterid);
-}
-int grib_f_skip_duplicates(int* iterid) {
- return grib_f_skip_duplicates_(iterid);
-}
int grib_f_skip_read_only_(int* iterid) {
grib_keys_iterator* iter=get_keys_iterator(*iterid);
if (!iter) return GRIB_INVALID_KEYS_ITERATOR;
return grib_keys_iterator_set_flags(iter,GRIB_KEYS_ITERATOR_SKIP_READ_ONLY);
}
-int grib_f_skip_read_only__(int* iterid) {
- return grib_f_skip_read_only_(iterid);
-}
-int grib_f_skip_read_only(int* iterid) {
- return grib_f_skip_read_only_(iterid);
-}
int grib_f_skip_function_(int* iterid) {
grib_keys_iterator* iter=get_keys_iterator(*iterid);
if (!iter) return GRIB_INVALID_KEYS_ITERATOR;
return grib_keys_iterator_set_flags(iter,GRIB_KEYS_ITERATOR_SKIP_FUNCTION);
}
-int grib_f_skip_function__(int* iterid) {
- return grib_f_skip_function_(iterid);
-}
-int grib_f_skip_function(int* iterid) {
- return grib_f_skip_function_(iterid);
-}
/*****************************************************************************/
int grib_f_keys_iterator_get_name_(int* iterid,char* name,int len) {
@@ -1374,12 +1233,6 @@ int grib_f_keys_iterator_get_name_(int* iterid,char* name,int len) {
return 0;
}
-int grib_f_keys_iterator_get_name__(int* kiter,char* name,int len) {
- return grib_f_keys_iterator_get_name_(kiter,name,len);
-}
-int grib_f_keys_iterator_get_name(int* kiter,char* name,int len) {
- return grib_f_keys_iterator_get_name_(kiter,name,len);
-}
/*****************************************************************************/
int grib_f_keys_iterator_rewind_(int* kiter) {
@@ -1388,12 +1241,6 @@ int grib_f_keys_iterator_rewind_(int* kiter) {
if (!i) return GRIB_INVALID_KEYS_ITERATOR;
return grib_keys_iterator_rewind(i);
}
-int grib_f_keys_iterator_rewind__(int* kiter) {
- return grib_f_keys_iterator_rewind_(kiter);
-}
-int grib_f_keys_iterator_rewind(int* kiter) {
- return grib_f_keys_iterator_rewind_(kiter);
-}
/* BUFR keys iterator */
/*****************************************************************************/
@@ -1423,12 +1270,6 @@ int codes_f_bufr_keys_iterator_new_(int* gid,int* iterid) {
GRIB_MUTEX_UNLOCK(&keys_iterator_mutex)
return ret;
}
-int codes_f_bufr_keys_iterator_new__(int* gid,int* iterid) {
- return codes_f_bufr_keys_iterator_new_(gid,iterid);
-}
-int codes_f_bufr_keys_iterator_new(int* gid,int* iterid) {
- return codes_f_bufr_keys_iterator_new_(gid,iterid);
-}
/*****************************************************************************/
int codes_f_bufr_keys_iterator_next_(int* iterid) {
bufr_keys_iterator* iter=get_bufr_keys_iterator(*iterid);
@@ -1436,12 +1277,7 @@ int codes_f_bufr_keys_iterator_next_(int* iterid) {
return codes_bufr_keys_iterator_next(iter);
}
-int codes_f_bufr_keys_iterator_next__(int* iterid) {
- return codes_f_bufr_keys_iterator_next_(iterid);
-}
-int codes_f_bufr_keys_iterator_next(int* iterid) {
- return codes_f_bufr_keys_iterator_next_(iterid);
-}
+
/*****************************************************************************/
int codes_f_bufr_keys_iterator_get_name_(int* iterid,char* name,int len) {
size_t lsize=len;
@@ -1463,12 +1299,6 @@ int codes_f_bufr_keys_iterator_get_name_(int* iterid,char* name,int len) {
return 0;
}
-int codes_f_bufr_keys_iterator_get_name__(int* kiter,char* name,int len) {
- return codes_f_bufr_keys_iterator_get_name_(kiter,name,len);
-}
-int codes_f_bufr_keys_iterator_get_name(int* kiter,char* name,int len) {
- return codes_f_bufr_keys_iterator_get_name_(kiter,name,len);
-}
/*****************************************************************************/
int codes_f_bufr_keys_iterator_rewind_(int* kiter) {
bufr_keys_iterator* i=get_bufr_keys_iterator(*kiter);
@@ -1476,22 +1306,11 @@ int codes_f_bufr_keys_iterator_rewind_(int* kiter) {
if (!i) return GRIB_INVALID_KEYS_ITERATOR;
return codes_bufr_keys_iterator_rewind(i);
}
-int codes_f_bufr_keys_iterator_rewind__(int* kiter) {
- return codes_f_bufr_keys_iterator_rewind_(kiter);
-}
-int codes_f_bufr_keys_iterator_rewind(int* kiter) {
- return codes_f_bufr_keys_iterator_rewind_(kiter);
-}
+
/*****************************************************************************/
int codes_f_bufr_keys_iterator_delete_(int* iterid) {
return clear_bufr_keys_iterator(*iterid);
}
-int codes_f_bufr_keys_iterator_delete__(int* iterid) {
- return codes_f_bufr_keys_iterator_delete_(iterid);
-}
-int codes_f_bufr_keys_iterator_delete(int* iterid) {
- return codes_f_bufr_keys_iterator_delete_(iterid);
-}
/*****************************************************************************/
int grib_f_new_from_message_(int* gid, void* buffer, size_t* bufsize) {
@@ -1504,24 +1323,12 @@ int grib_f_new_from_message_(int* gid, void* buffer, size_t* bufsize) {
*gid = -1;
return GRIB_INTERNAL_ERROR;
}
-int grib_f_new_from_message__(int* gid, void* buffer, size_t* bufsize){
- return grib_f_new_from_message_(gid, buffer, bufsize);
-}
-int grib_f_new_from_message(int* gid, void* buffer, size_t* bufsize){
- return grib_f_new_from_message_(gid, buffer, bufsize);
-}
/* See SUP-3893: Need to provide an 'int' version */
int grib_f_new_from_message_int_(int* gid, int* buffer , size_t* bufsize) {
/* Call the version with void pointer */
return grib_f_new_from_message_(gid, (void*)buffer, bufsize);
}
-int grib_f_new_from_message_int__(int* gid, int* buffer , size_t* bufsize){
- return grib_f_new_from_message_int_(gid, buffer, bufsize);
-}
-int grib_f_new_from_message_int(int* gid, int* buffer, size_t* bufsize){
- return grib_f_new_from_message_int_(gid, buffer, bufsize);
-}
/*****************************************************************************/
int grib_f_new_from_message_copy_(int* gid, void* buffer, size_t* bufsize){
grib_handle *h = NULL;
@@ -1533,12 +1340,6 @@ int grib_f_new_from_message_copy_(int* gid, void* buffer, size_t* bufsize){
*gid = -1;
return GRIB_INTERNAL_ERROR;
}
-int grib_f_new_from_message_copy__(int* gid, void* buffer, size_t* bufsize){
- return grib_f_new_from_message_copy_(gid, buffer, bufsize);
-}
-int grib_f_new_from_message_copy(int* gid, void* buffer, size_t* bufsize){
- return grib_f_new_from_message_copy_(gid, buffer, bufsize);
-}
/*****************************************************************************/
int grib_f_new_from_samples_(int* gid, char* name, int lname){
@@ -1553,12 +1354,6 @@ int grib_f_new_from_samples_(int* gid, char* name, int lname){
*gid = -1;
return GRIB_FILE_NOT_FOUND;
}
-int grib_f_new_from_samples__(int* gid, char* name , int lname){
- return grib_f_new_from_samples_(gid, name, lname);
-}
-int grib_f_new_from_samples(int* gid, char* name , int lname){
- return grib_f_new_from_samples_(gid, name, lname);
-}
/*****************************************************************************/
int codes_bufr_f_new_from_samples_(int* gid, char* name, int lname){
@@ -1573,12 +1368,6 @@ int codes_bufr_f_new_from_samples_(int* gid, char* name, int lname){
*gid = -1;
return GRIB_FILE_NOT_FOUND;
}
-int codes_bufr_f_new_from_samples__(int* gid, char* name, int lname){
- return codes_bufr_f_new_from_samples_(gid, name, lname);
-}
-int codes_bufr_f_new_from_samples(int* gid, char* name, int lname){
- return codes_bufr_f_new_from_samples_(gid, name, lname);
-}
/*****************************************************************************/
int grib_f_clone_(int* gidsrc,int* giddest){
@@ -1596,12 +1385,6 @@ int grib_f_clone_(int* gidsrc,int* giddest){
*giddest = -1;
return GRIB_INVALID_GRIB;
}
-int grib_f_clone__(int* gidsrc,int* giddest){
- return grib_f_clone_(gidsrc, giddest);
-}
-int grib_f_clone(int* gidsrc,int* giddest){
- return grib_f_clone_(gidsrc, giddest);
-}
/*****************************************************************************/
int grib_f_copy_key_(int* gidsrc, char* key, int* giddest, int len)
@@ -1618,12 +1401,7 @@ int grib_f_copy_key_(int* gidsrc, char* key, int* giddest, int len)
return GRIB_INVALID_GRIB;
}
-int grib_f_copy_key__(int* gidsrc, char* name, int* giddest, int len){
- return grib_f_copy_key_(gidsrc, name, giddest, len);
-}
-int grib_f_copy_key(int* gidsrc, char* name, int* giddest, int len){
- return grib_f_copy_key_(gidsrc, name, giddest, len);
-}
+
/*****************************************************************************/
int grib_f_util_sections_copy_(int* gidfrom,int* gidto,int* what,int *gidout){
int err=0;
@@ -1639,12 +1417,6 @@ int grib_f_util_sections_copy_(int* gidfrom,int* gidto,int* what,int *gidout){
return err;
}
-int grib_f_util_sections_copy__(int* gidfrom,int* gidto,int* what,int *gidout){
- return grib_f_util_sections_copy_(gidfrom,gidto,what,gidout);
-}
-int grib_f_util_sections_copy(int* gidfrom,int* gidto,int* what,int *gidout){
- return grib_f_util_sections_copy_(gidfrom,gidto,what,gidout);
-}
/*****************************************************************************/
int grib_f_copy_namespace_(int* gidsrc,char* name,int* giddest,int len){
@@ -1657,15 +1429,9 @@ int grib_f_copy_namespace_(int* gidsrc,char* name,int* giddest,int len){
return GRIB_INVALID_GRIB;
}
-int grib_f_copy_namespace__(int* gidsrc,char* name,int* giddest,int len){
- return grib_f_copy_namespace_(gidsrc,name,giddest,len);
-}
-int grib_f_copy_namespace(int* gidsrc,char* name,int* giddest,int len){
- return grib_f_copy_namespace_(gidsrc,name,giddest,len);
-}
/*****************************************************************************/
-int any_f_scan_file(int* fid,int* n) {
+int any_f_scan_file_(int* fid, int* n) {
int err = 0;
off_t offset=0;
void *data = NULL;
@@ -1675,189 +1441,157 @@ int any_f_scan_file(int* fid,int* n) {
grib_context* c=grib_context_get_default();
/* this needs a callback to a destructor*/
- /* grib_oarray_delete_content(c,binary_messages); */
+ /* grib_oarray_delete_content(c, info_messages); */
- grib_oarray_delete(c,info_messages);
- info_messages=grib_oarray_new(c,1000,1000);
+ grib_oarray_delete(c, info_messages);
+ info_messages=grib_oarray_new(c, 1000, 1000);
if (f) {
while (err!=GRIB_END_OF_FILE) {
- data = wmo_read_any_from_file_malloc ( f, 0,&olen,&offset,&err );
+ data = wmo_read_any_from_file_malloc ( f, 0, &olen, &offset, &err );
msg=(l_message_info*)grib_context_malloc_clear(c,sizeof(l_message_info));
- msg->offset=offset;
- msg->size=olen;
-
- if (err==0 && data) grib_oarray_push(c,info_messages,msg);
- grib_context_free(c,data);
+ msg->offset = offset;
+ msg->size = olen;
+
+ if (err == 0 && data) grib_oarray_push(c, info_messages, msg);
+ grib_context_free(c, data);
}
- if (err==GRIB_END_OF_FILE) err=0;
+ if (err == GRIB_END_OF_FILE) err = 0;
}
- *n=info_messages->n;
+ *n = info_messages->n;
return err;
}
-int any_f_scan_file_(int* fid,int* n) {
- return any_f_scan_file(fid,n);
-}
-int any_f_scan_file__(int* fid,int* n) {
- return any_f_scan_file(fid,n);
-}
/*****************************************************************************/
-int any_f_new_from_scanned_file(int* fid,int* msgid,int* gid)
+int any_f_new_from_scanned_file_(int* fid, int* msgid, int* gid)
{
grib_handle *h = NULL;
- grib_context* c=grib_context_get_default();
- int err=0;
+ grib_context* c = grib_context_get_default();
+ int err = 0;
FILE* f = get_file(*fid);
+ l_message_info* msg = NULL;
- /* fortran convention of 1 based index*/
- const int n=*msgid-1;
+ /* fortran convention of 1-based index */
+ const int n = *msgid - 1;
- l_message_info* msg=(l_message_info*)grib_oarray_get(info_messages,n);
+ if (info_messages == NULL) {
+ return GRIB_INVALID_ARGUMENT;
+ }
+ if (*msgid < 1 || *msgid > info_messages->n) {
+ return GRIB_INVALID_ARGUMENT;
+ }
+
+ msg = (l_message_info*)grib_oarray_get(info_messages, n);
if (msg && f) {
- GRIB_MUTEX_INIT_ONCE(&once,&init);
+ GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_LOCK(&read_mutex);
- fseeko(f,msg->offset,SEEK_SET);
- h=any_new_from_file (c,f,&err);
+ fseeko(f, msg->offset, SEEK_SET);
+ h = any_new_from_file (c, f, &err);
GRIB_MUTEX_UNLOCK(&read_mutex);
}
if (err) return err;
- if(h){
- push_handle(h,gid);
+ if (h) {
+ push_handle(h, gid);
return GRIB_SUCCESS;
} else {
- *gid=-1;
+ *gid = -1;
return GRIB_END_OF_FILE;
}
}
-int any_f_new_from_scanned_file_(int* fid,int* msgid,int* gid){
- return any_f_new_from_scanned_file(fid,msgid,gid);
-}
-int any_f_new_from_scanned_file__(int* fid,int* msgid,int* gid){
- return any_f_new_from_scanned_file(fid,msgid,gid);
-}
/*****************************************************************************/
-int any_f_load_all_from_file(int* fid,int* n) {
+int any_f_load_all_from_file_(int* fid, int* n) {
int err = 0;
off_t offset=0;
- void *data = NULL;
+ void* data = NULL;
size_t olen = 0;
l_binary_message* msg=0;
FILE* f = get_file(*fid);
- grib_context* c=grib_context_get_default();
+ grib_context* c = grib_context_get_default();
/* this needs a callback to a destructor*/
- /* grib_oarray_delete_content(c,binary_messages); */
+ /* grib_oarray_delete_content(c, binary_messages); */
- grib_oarray_delete(c,binary_messages);
- binary_messages=grib_oarray_new(c,1000,1000);
+ grib_oarray_delete(c, binary_messages);
+ binary_messages = grib_oarray_new(c, 1000, 1000);
if (f) {
- while (err!=GRIB_END_OF_FILE) {
- data = wmo_read_any_from_file_malloc ( f, 0,&olen,&offset,&err );
- msg=(l_binary_message*)grib_context_malloc_clear(c,sizeof(l_binary_message));
- msg->data=data;
- msg->size=olen;
+ while (err != GRIB_END_OF_FILE) {
+ data = wmo_read_any_from_file_malloc (f, 0,&olen, &offset, &err);
+ msg = (l_binary_message*)grib_context_malloc_clear(c,sizeof(l_binary_message));
+ msg->data = data;
+ msg->size = olen;
- if (err==0 && data) grib_oarray_push(c,binary_messages,msg);
+ if (err == 0 && data) grib_oarray_push(c, binary_messages, msg);
}
- if (err==GRIB_END_OF_FILE) err=0;
+ if (err == GRIB_END_OF_FILE) err = 0;
}
- *n=binary_messages->n;
+ *n = binary_messages->n;
return err;
}
-int any_f_load_all_from_file_(int* fid,int* n) {
- return any_f_load_all_from_file(fid,n);
-}
-int any_f_load_all_from_file__(int* fid,int* n) {
- return any_f_load_all_from_file(fid,n);
-}
/*****************************************************************************/
-int any_f_new_from_loaded(int* msgid,int* gid)
+int any_f_new_from_loaded_(int* msgid, int* gid)
{
- grib_handle *h = NULL;
- grib_context* c=grib_context_get_default();
+ grib_handle* h = NULL;
+ grib_context* c = grib_context_get_default();
/* fortran convention of 1 based index*/
- const int n=*msgid-1;
+ const int n = *msgid - 1;
- l_binary_message* msg=(l_binary_message*)grib_oarray_get(binary_messages,n);
+ l_binary_message* msg = (l_binary_message*)grib_oarray_get(binary_messages, n);
if (msg && msg->data)
- h=grib_handle_new_from_message_copy (c,msg->data,msg->size);
+ h = grib_handle_new_from_message_copy(c, msg->data, msg->size);
- if(h){
- push_handle(h,gid);
+ if (h) {
+ push_handle(h, gid);
return GRIB_SUCCESS;
- } else {
- *gid=-1;
+ }
+ else {
+ *gid = -1;
return GRIB_END_OF_FILE;
}
}
-int any_f_new_from_loaded_(int* msgid,int* gid){
- return any_f_new_from_loaded(msgid,gid);
-}
-int any_f_new_from_loaded__(int* msgid,int* gid){
- return any_f_new_from_loaded(msgid,gid);
-}
-
/*****************************************************************************/
-int codes_f_clear_loaded_from_file(void) {
- grib_context* c=grib_context_get_default();
+int codes_f_clear_loaded_from_file_(void) {
+ grib_context* c = grib_context_get_default();
/* grib_oarray_delete_content(c,binary_messages); */
- grib_oarray_delete(c,binary_messages);
+ grib_oarray_delete(c, binary_messages);
return GRIB_SUCCESS;
}
-int codes_f_clear_loaded_from_file_(void) {
- return codes_f_clear_loaded_from_file();
-}
-int codes_f_clear_loaded_from_file__(void) {
- return codes_f_clear_loaded_from_file();
-}
+
/*****************************************************************************/
-int grib_f_count_in_file(int* fid,int* n) {
+int grib_f_count_in_file_(int* fid,int* n) {
int err = 0;
FILE* f = get_file(*fid);
- if (f) err=grib_count_in_file(0, f,n);
+ if (f) err = grib_count_in_file(0, f, n);
return err;
}
-int grib_f_count_in_file_(int* fid,int* n) {
- return grib_f_count_in_file(fid,n);
-}
-int grib_f_count_in_file__(int* fid,int* n) {
- return grib_f_count_in_file(fid,n);
-}
/*****************************************************************************/
-int any_f_new_from_file_(int* fid, int* gid){
- int err = 0;
- FILE* f = get_file(*fid);
- grib_handle *h = NULL;
+int any_f_new_from_file_(int* fid, int* gid) {
+ int err = 0;
+ FILE* f = get_file(*fid);
+ grib_handle* h = NULL;
- if(f){
- h = codes_handle_new_from_file(0,f,PRODUCT_ANY,&err);
- if(h){
- push_handle(h,gid);
+ if (f) {
+ h = codes_handle_new_from_file(0, f, PRODUCT_ANY, &err);
+ if (h) {
+ push_handle(h, gid);
return GRIB_SUCCESS;
- } else {
- *gid=-1;
+ }
+ else {
+ *gid = -1;
return GRIB_END_OF_FILE;
}
}
- *gid=-1;
+ *gid = -1;
return GRIB_INVALID_FILE;
}
-int any_f_new_from_file__(int* fid, int* gid){
- return any_f_new_from_file_( fid, gid);
-}
-int any_f_new_from_file(int* fid, int* gid){
- return any_f_new_from_file_( fid, gid);
-}
/*****************************************************************************/
int bufr_f_new_from_file_(int* fid, int* gid){
@@ -1881,13 +1615,6 @@ int bufr_f_new_from_file_(int* fid, int* gid){
return GRIB_INVALID_FILE;
}
-int bufr_f_new_from_file__(int* fid, int* gid){
- return bufr_f_new_from_file_( fid, gid);
-}
-int bufr_f_new_from_file(int* fid, int* gid){
- return bufr_f_new_from_file_( fid, gid);
-}
-
/*****************************************************************************/
int grib_f_new_from_file_(int* fid, int* gid){
int err = 0;
@@ -1909,82 +1636,61 @@ int grib_f_new_from_file_(int* fid, int* gid){
*gid=-1;
return GRIB_INVALID_FILE;
}
-int grib_f_new_from_file__(int* fid, int* gid){
- return grib_f_new_from_file_( fid, gid);
-}
-int grib_f_new_from_file(int* fid, int* gid){
- return grib_f_new_from_file_( fid, gid);
-}
/*****************************************************************************/
int grib_f_headers_only_new_from_file_(int* fid, int* gid){
int err = 0;
FILE* f = get_file(*fid);
-
grib_handle *h = NULL;
+ const int headers_only = 1;
- if(f){
- h=grib_new_from_file ( 0, f,1,&err);
- if(h){
+ if (f){
+ h=grib_new_from_file (0, f, headers_only, &err);
+ if (h){
push_handle(h,gid);
return GRIB_SUCCESS;
} else {
- *gid=-1;
+ *gid = -1;
return GRIB_END_OF_FILE;
}
}
- *gid=-1;
+ *gid = -1;
return GRIB_INVALID_FILE;
}
-int grib_f_headers_only_new_from_file__(int* fid, int* gid){
- return grib_f_headers_only_new_from_file_( fid, gid);
-}
-int grib_f_headers_only_new_from_file(int* fid, int* gid){
- return grib_f_headers_only_new_from_file_( fid, gid);
-}
/*****************************************************************************/
-int grib_f_new_from_index_(int* iid, int* gid){
+int grib_f_new_from_index_(int* iid, int* gid) {
int err = 0;
grib_index* i = get_index(*iid);
-
grib_handle *h = NULL;
- if(i){
- h = grib_handle_new_from_index(i,&err);
- if(h){
+ if (i) {
+ h = grib_handle_new_from_index(i, &err);
+ if (h){
push_handle(h,gid);
return GRIB_SUCCESS;
} else {
- *gid=-1;
+ *gid = -1;
return GRIB_END_OF_INDEX;
}
}
- *gid=-1;
+ *gid = -1;
return GRIB_INVALID_INDEX;
}
-int grib_f_new_from_index__(int* iid, int* gid){
- return grib_f_new_from_index_(iid,gid);
-}
-int grib_f_new_from_index(int* iid, int* gid){
- return grib_f_new_from_index_(iid,gid);
-}
-
/*****************************************************************************/
-int grib_f_index_new_from_file_(char* file ,char* keys ,int* gid, int lfile, int lkeys){
+int grib_f_index_new_from_file_(char* file, char* keys, int* gid, int lfile, int lkeys) {
int err = 0;
- char fname[1024]={0,};
- char knames[1024]={0,};
-
+ char fname[1024] = {0,};
+ char knames[1024] = {0,};
grib_index *i = NULL;
- if(*file){
+ if (*file){
i = grib_index_new_from_file(0,cast_char(fname,file,lfile),
cast_char(knames,keys,lkeys),&err);
- if(i){
+ if (i) {
push_index(i,gid);
return GRIB_SUCCESS;
} else {
@@ -1993,15 +1699,9 @@ int grib_f_index_new_from_file_(char* file ,char* keys ,int* gid, int lfile, int
}
}
- *gid=-1;
+ *gid = -1;
return GRIB_INVALID_FILE;
}
-int grib_f_index_new_from_file__(char* file, char* keys, int* gid, int lfile, int lkeys){
- return grib_f_index_new_from_file_(file ,keys ,gid, lfile, lkeys);
-}
-int grib_f_index_new_from_file(char* file, char* keys, int* gid, int lfile, int lkeys){
- return grib_f_index_new_from_file_(file ,keys ,gid, lfile, lkeys);
-}
/*****************************************************************************/
int grib_f_index_add_file_(int* iid, char* file, int lfile) {
@@ -2017,13 +1717,6 @@ int grib_f_index_add_file_(int* iid, char* file, int lfile) {
}
}
-int grib_f_index_add_file__(int* iid, char* file, int lfile) {
- return grib_f_index_add_file_(iid,file,lfile);
-}
-int grib_f_index_add_file(int* iid, char* file, int lfile) {
- return grib_f_index_add_file_(iid,file,lfile);
-}
-
/*****************************************************************************/
int grib_f_index_read_(char* file, int* gid, int lfile) {
int err = 0;
@@ -2045,12 +1738,6 @@ int grib_f_index_read_(char* file, int* gid, int lfile) {
*gid=-1;
return GRIB_INVALID_FILE;
}
-int grib_f_index_read__(char* file, int* gid, int lfile) {
- return grib_f_index_read_(file,gid,lfile);
-}
-int grib_f_index_read(char* file, int* gid, int lfile) {
- return grib_f_index_read_(file,gid,lfile);
-}
/*****************************************************************************/
int grib_f_index_write_(int* gid, char* file, int lfile) {
@@ -2065,47 +1752,19 @@ int grib_f_index_write_(int* gid, char* file, int lfile) {
return err;
}
}
-int grib_f_index_write__(int* gid, char* file, int lfile) {
- return grib_f_index_write_(gid,file,lfile);
-}
-int grib_f_index_write(int* gid, char* file, int lfile) {
- return grib_f_index_write_(gid,file,lfile);
-}
/*****************************************************************************/
int grib_f_index_release_(int* hid){
return clear_index(*hid);
}
-int grib_f_index_release__(int* hid){
- return grib_f_index_release_(hid);
-}
-
-int grib_f_index_release(int* hid){
- return grib_f_index_release_(hid);
-}
-
int grib_f_multi_handle_release_(int* hid){
return clear_multi_handle(*hid);
}
-int grib_f_multi_handle_release__(int* hid){
- return grib_f_multi_handle_release_(hid);
-}
-
-int grib_f_multi_handle_release(int* hid){
- return grib_f_multi_handle_release_(hid);
-}
-
int grib_f_release_(int* hid){
return clear_handle(*hid);
}
-int grib_f_release__(int* hid){
- return grib_f_release_( hid);
-}
-int grib_f_release(int* hid){
- return grib_f_release_( hid);
-}
/*****************************************************************************/
static void do_the_dump(grib_handle* h)
@@ -2139,12 +1798,6 @@ int grib_f_dump_(int* gid){
return GRIB_SUCCESS;
}
-int grib_f_dump__(int* gid){
- return grib_f_dump_( gid);
-}
-int grib_f_dump(int* gid){
- return grib_f_dump_( gid);
-}
/*****************************************************************************/
#ifdef USE_GRIB_PRINT
@@ -2163,12 +1816,6 @@ int grib_f_print_(int* gid, char* key, int len){
return err;
}
}
-int grib_f_print__(int* gid, char* key, int len){
- return grib_f_print_(gid, key, len);
-}
-int grib_f_print(int* gid, char* key, int len){
- return grib_f_print_(gid, key, len);
-}
#endif
/*****************************************************************************/
int grib_f_get_error_string_(int* err, char* buf, int len){
@@ -2178,45 +1825,29 @@ int grib_f_get_error_string_(int* err, char* buf, int len){
strncpy(buf, err_msg, (size_t)erlen); /* ECC-1488 */
return GRIB_SUCCESS;
}
-int grib_f_get_error_string__(int* err, char* buf, int len){
- return grib_f_get_error_string_(err, buf, len);
-}
-int grib_f_get_error_string(int* err, char* buf, int len){
- return grib_f_get_error_string_(err, buf, len);
-}
/*****************************************************************************/
int grib_f_get_api_version_(int* apiVersion,int len){
*apiVersion = grib_get_api_version();
return GRIB_SUCCESS;
}
-int grib_f_get_api_version__(int* apiVersion, int len){
- return grib_f_get_api_version_(apiVersion, len);
-}
-int grib_f_get_api_version(int* apiVersion, int len){
- return grib_f_get_api_version_(apiVersion, len);
-}
/*****************************************************************************/
-int grib_f_get_size_int_(int* gid, char* key, int* val, int len){
- grib_handle *h = get_handle(*gid);
- int err = GRIB_SUCCESS;
+int grib_f_get_size_int_(int* gid, char* key, int* val, int len)
+{
+ grib_handle* h = get_handle(*gid);
+ int err = GRIB_SUCCESS;
char buf[1024];
size_t tsize = 0;
- if(!h){
+ if (!h) {
return GRIB_INVALID_GRIB;
- }else{
- err = grib_get_size(h, cast_char(buf,key,len), &tsize);
- *val = tsize;
- return err;
}
-}
-int grib_f_get_size_int__(int* gid, char* key, int* val, int len){
- return grib_f_get_size_int_( gid, key, val, len);
-}
-int grib_f_get_size_int(int* gid, char* key, int* val, int len){
- return grib_f_get_size_int_( gid, key, val, len);
+ else {
+ err = grib_get_size(h, cast_char(buf, key, len), &tsize);
+ *val = tsize;
+ return err;
+ }
}
int grib_f_get_size_long_(int* gid, char* key, long* val, int len){
@@ -2233,13 +1864,8 @@ int grib_f_get_size_long_(int* gid, char* key, long* val, int len){
return err;
}
}
-int grib_f_get_size_long__(int* gid, char* key, long* val, int len){
- return grib_f_get_size_long_( gid, key, val, len);
-}
-int grib_f_get_size_long(int* gid, char* key, long* val, int len){
- return grib_f_get_size_long_( gid, key, val, len);
-}
+/*****************************************************************************/
int grib_f_index_get_size_int_(int* gid, char* key, int* val, int len){
grib_index *h = get_index(*gid);
int err = GRIB_SUCCESS;
@@ -2254,12 +1880,6 @@ int grib_f_index_get_size_int_(int* gid, char* key, int* val, int len){
return err;
}
}
-int grib_f_index_get_size_int__(int* gid, char* key, int* val, int len){
- return grib_f_index_get_size_int_( gid, key, val, len);
-}
-int grib_f_index_get_size_int(int* gid, char* key, int* val, int len){
- return grib_f_index_get_size_int_( gid, key, val, len);
-}
int grib_f_index_get_size_long_(int* gid, char* key, long* val, int len){
grib_index *h = get_index(*gid);
@@ -2275,13 +1895,8 @@ int grib_f_index_get_size_long_(int* gid, char* key, long* val, int len){
return err;
}
}
-int grib_f_index_get_size_long__(int* gid, char* key, long* val, int len){
- return grib_f_index_get_size_long_( gid, key, val, len);
-}
-int grib_f_index_get_size_long(int* gid, char* key, long* val, int len){
- return grib_f_index_get_size_long_( gid, key, val, len);
-}
+/*****************************************************************************/
int grib_f_get_int_(int* gid, char* key, int* val, int len){
grib_handle *h = get_handle(*gid);
long long_val;
@@ -2293,12 +1908,6 @@ int grib_f_get_int_(int* gid, char* key, int* val, int len){
*val = long_val;
return err;
}
-int grib_f_get_int__(int* gid, char* key, int* val, int len){
- return grib_f_get_int_( gid, key, val, len);
-}
-int grib_f_get_int(int* gid, char* key, int* val, int len){
- return grib_f_get_int_( gid, key, val, len);
-}
int grib_f_get_long_(int* gid, char* key, long* val, int len){
grib_handle *h = get_handle(*gid);
@@ -2309,12 +1918,6 @@ int grib_f_get_long_(int* gid, char* key, long* val, int len){
err = grib_get_long(h, cast_char(buf,key,len),val);
return err;
}
-int grib_f_get_long__(int* gid, char* key, long* val, int len){
- return grib_f_get_long_( gid, key, val, len);
-}
-int grib_f_get_long(int* gid, char* key, long* val, int len){
- return grib_f_get_long_( gid, key, val, len);
-}
/*****************************************************************************/
int grib_f_get_native_type_(int* gid, char* key, int* val, int len){
@@ -2323,17 +1926,11 @@ int grib_f_get_native_type_(int* gid, char* key, int* val, int len){
int err = GRIB_SUCCESS;
char buf[1024];
- if(!h) return GRIB_INVALID_GRIB;
+ if (!h) return GRIB_INVALID_GRIB;
err = grib_get_native_type(h, cast_char(buf,key,len), &type_val);
*val = type_val;
return err;
}
-int grib_f_get_native_type__(int* gid, char* key, int* val, int len){
- return grib_f_get_native_type_( gid, key, val, len);
-}
-int grib_f_get_native_type(int* gid, char* key, int* val, int len){
- return grib_f_get_native_type_( gid, key, val, len);
-}
/*****************************************************************************/
int grib_f_get_int_array_(int* gid, char* key, int *val, int* size, int len){
@@ -2366,12 +1963,6 @@ int grib_f_get_int_array_(int* gid, char* key, int *val, int* size, int len){
grib_context_free(h->context,long_val);
return err;
}
-int grib_f_get_int_array__(int* gid, char* key, int*val, int* size, int len){
- return grib_f_get_int_array_( gid, key, val, size, len);
-}
-int grib_f_get_int_array(int* gid, char* key, int*val, int* size, int len){
- return grib_f_get_int_array_( gid, key, val, size, len);
-}
/*****************************************************************************/
int grib_f_get_long_array_(int* gid, char* key, long *val, int* size, int len){
@@ -2387,12 +1978,6 @@ int grib_f_get_long_array_(int* gid, char* key, long *val, int* size, int len){
return err;
}
-int grib_f_get_long_array__(int* gid, char* key, long *val, int* size, int len){
- return grib_f_get_long_array_( gid, key, val, size, len);
-}
-int grib_f_get_long_array(int* gid, char* key, long *val, int* size, int len){
- return grib_f_get_long_array_( gid, key, val, size, len);
-}
/*****************************************************************************/
int grib_f_get_byte_array_(int* gid, char* key, unsigned char *val, int* size, int len, int lenv){
@@ -2409,12 +1994,6 @@ int grib_f_get_byte_array_(int* gid, char* key, unsigned char *val, int* size, i
return err;
}
-int grib_f_get_byte_array__(int* gid, char* key, unsigned char *val, int* size, int len, int lenv){
- return grib_f_get_byte_array_( gid, key, val, size, len, lenv);
-}
-int grib_f_get_byte_array(int* gid, char* key, unsigned char *val, int* size, int len, int lenv){
- return grib_f_get_byte_array_( gid, key, val, size, len, lenv);
-}
/*****************************************************************************/
int grib_f_index_get_string_(int* gid, char* key, char* val, int *eachsize,int* size, int len){
@@ -2440,7 +2019,8 @@ int grib_f_index_get_string_(int* gid, char* key, char* val, int *eachsize,int*
int l=strlen(bufval[i]);
int j;
if (*eachsize < l ) {
- printf("eachsize=%d strlen(bufval[i])=%ld\n",*eachsize,(long)strlen(bufval[i]));
+ fprintf(stderr, "eachsize=%d strlen(bufval[i])=%zu\n",
+ *eachsize, strlen(bufval[i]));
grib_context_free(h->context,bufval);
return GRIB_ARRAY_TOO_SMALL;
}
@@ -2455,12 +2035,6 @@ int grib_f_index_get_string_(int* gid, char* key, char* val, int *eachsize,int*
return err;
}
-int grib_f_index_get_string__(int* gid, char* key, char *val, int* eachsize, int* size, int len){
- return grib_f_index_get_string_(gid,key,val,eachsize,size,len);
-}
-int grib_f_index_get_string(int* gid, char* key, char* val, int* eachsize, int* size, int len){
- return grib_f_index_get_string_(gid,key,val,eachsize,size,len);
-}
/*****************************************************************************/
int grib_f_index_get_long_(int* gid, char* key, long *val, int* size, int len){
@@ -2475,12 +2049,6 @@ int grib_f_index_get_long_(int* gid, char* key, long *val, int* size, int len){
*size = lsize;
return err;
}
-int grib_f_index_get_long__(int* gid, char* key, long *val, int* size, int len){
- return grib_f_index_get_long_(gid,key,val,size,len);
-}
-int grib_f_index_get_long(int* gid, char* key, long *val, int* size, int len){
- return grib_f_index_get_long_(gid,key,val,size,len);
-}
/*****************************************************************************/
int grib_f_index_get_int_(int* gid, char* key, int *val, int* size, int len){
@@ -2504,12 +2072,6 @@ int grib_f_index_get_int_(int* gid, char* key, int *val, int* size, int len){
grib_context_free(h->context, lval);
return err;
}
-int grib_f_index_get_int__(int* gid, char* key, int *val, int* size, int len){
- return grib_f_index_get_int_(gid,key,val,size,len);
-}
-int grib_f_index_get_int(int* gid, char* key, int *val, int* size, int len){
- return grib_f_index_get_int_(gid,key,val,size,len);
-}
/*****************************************************************************/
int grib_f_index_get_real8_(int* gid, char* key, double *val, int* size, int len){
@@ -2524,12 +2086,6 @@ int grib_f_index_get_real8_(int* gid, char* key, double *val, int* size, int len
*size = lsize;
return err;
}
-int grib_f_index_get_real8__(int* gid, char* key, double *val, int* size, int len){
- return grib_f_index_get_real8_(gid,key,val,size,len);
-}
-int grib_f_index_get_real8(int* gid, char* key, double *val, int* size, int len){
- return grib_f_index_get_real8_(gid,key,val,size,len);
-}
/*****************************************************************************/
int grib_f_set_int_array_(int* gid, char* key, int* val, int* size, int len){
@@ -2561,12 +2117,6 @@ int grib_f_set_int_array_(int* gid, char* key, int* val, int* size, int len){
grib_context_free(h->context,long_val);
return err;
}
-int grib_f_set_int_array__(int* gid, char* key, int* val, int* size, int len){
- return grib_f_set_int_array_( gid, key, val, size, len);
-}
-int grib_f_set_int_array(int* gid, char* key, int* val, int* size, int len){
- return grib_f_set_int_array_( gid, key, val, size, len);
-}
/*****************************************************************************/
int grib_f_set_long_array_(int* gid, char* key, long* val, int* size, int len){
@@ -2578,12 +2128,6 @@ int grib_f_set_long_array_(int* gid, char* key, long* val, int* size, int len){
return grib_set_long_array(h, cast_char(buf,key,len), val, lsize);
}
-int grib_f_set_long_array__(int* gid, char* key, long* val, int* size, int len){
- return grib_f_set_long_array_( gid, key, val, size, len);
-}
-int grib_f_set_long_array(int* gid, char* key, long* val, int* size, int len){
- return grib_f_set_long_array_( gid, key, val, size, len);
-}
/*****************************************************************************/
int grib_f_set_byte_array_(int* gid, char* key, unsigned char* val, int* size, int len, int lenv){
@@ -2599,12 +2143,6 @@ int grib_f_set_byte_array_(int* gid, char* key, unsigned char* val, int* size, i
return err;
}
-int grib_f_set_byte_array__(int* gid, char* key, unsigned char* val, int* size, int len, int lenv){
- return grib_f_set_byte_array_( gid, key, val, size, len, lenv);
-}
-int grib_f_set_byte_array(int* gid, char* key, unsigned char* val, int* size, int len, int lenv){
- return grib_f_set_byte_array_( gid, key, val, size, len, lenv);
-}
/*****************************************************************************/
int grib_f_set_int_(int* gid, char* key, int* val, int len){
@@ -2614,12 +2152,6 @@ int grib_f_set_int_(int* gid, char* key, int* val, int len){
if(!h) return GRIB_INVALID_GRIB;
return grib_set_long(h, cast_char(buf,key,len), long_val);
}
-int grib_f_set_int__(int* gid, char* key, int* val, int len){
- return grib_f_set_int_( gid, key, val, len);
-}
-int grib_f_set_int(int* gid, char* key, int* val, int len){
- return grib_f_set_int_( gid, key, val, len);
-}
int grib_f_set_long_(int* gid, char* key, long* val, int len){
grib_handle *h = get_handle(*gid);
@@ -2627,12 +2159,6 @@ int grib_f_set_long_(int* gid, char* key, long* val, int len){
if(!h) return GRIB_INVALID_GRIB;
return grib_set_long(h, cast_char(buf,key,len), *val);
}
-int grib_f_set_long__(int* gid, char* key, long* val, int len){
- return grib_f_set_long_( gid, key, val, len);
-}
-int grib_f_set_long(int* gid, char* key, long* val, int len){
- return grib_f_set_long_( gid, key, val, len);
-}
/*****************************************************************************/
int grib_f_set_missing_(int* gid, char* key,int len){
@@ -2643,12 +2169,6 @@ int grib_f_set_missing_(int* gid, char* key,int len){
return grib_set_missing(h, cast_char(buf,key,len));
}
-int grib_f_set_missing__(int* gid, char* key, int len){
- return grib_f_set_missing_( gid, key, len);
-}
-int grib_f_set_missing(int* gid, char* key, int len){
- return grib_f_set_missing_( gid, key, len);
-}
int grib_f_is_missing_(int* gid, char* key,int* isMissing,int len){
int err=0;
@@ -2659,12 +2179,6 @@ int grib_f_is_missing_(int* gid, char* key,int* isMissing,int len){
*isMissing=grib_is_missing(h, cast_char(buf,key,len),&err);
return err;
}
-int grib_f_is_missing__(int* gid, char* key,int* isMissing,int len){
- return grib_f_is_missing_(gid,key,isMissing,len);
-}
-int grib_f_is_missing(int* gid, char* key,int* isMissing,int len){
- return grib_f_is_missing_(gid,key,isMissing,len);
-}
/*****************************************************************************/
int grib_f_is_defined_(int* gid, char* key,int* isDefined,int len){
@@ -2675,12 +2189,6 @@ int grib_f_is_defined_(int* gid, char* key,int* isDefined,int len){
*isDefined=grib_is_defined(h, cast_char(buf,key,len));
return GRIB_SUCCESS;
}
-int grib_f_is_defined__(int* gid, char* key,int* isDefined,int len){
- return grib_f_is_defined_(gid,key,isDefined,len);
-}
-int grib_f_is_defined(int* gid, char* key,int* isDefined,int len){
- return grib_f_is_defined_(gid,key,isDefined,len);
-}
/*****************************************************************************/
int grib_f_set_real4_(int* gid, char* key, float* val, int len){
@@ -2692,12 +2200,6 @@ int grib_f_set_real4_(int* gid, char* key, float* val, int len){
return grib_set_double(h, cast_char(buf,key,len), val8);
}
-int grib_f_set_real4__(int* gid, char* key, float* val, int len){
- return grib_f_set_real4_( gid, key, val, len);
-}
-int grib_f_set_real4(int* gid, char* key, float* val, int len){
- return grib_f_set_real4_( gid, key, val, len);
-}
int grib_f_get_real4_element_(int* gid, char* key, int* index,float* val, int len){
@@ -2712,12 +2214,6 @@ int grib_f_get_real4_element_(int* gid, char* key, int* index,float* val, int le
*val = val8;
return err;
}
-int grib_f_get_real4_element__(int* gid, char* key,int* index, float* val,int len){
- return grib_f_get_real4_element_( gid, key, index, val, len);
-}
-int grib_f_get_real4_element(int* gid, char* key,int* index, float* val,int len){
- return grib_f_get_real4_element_( gid, key, index, val, len);
-}
int grib_f_get_real4_elements_(int* gid, char* key,int* index, float *val,int* size, int len){
@@ -2737,7 +2233,6 @@ int grib_f_get_real4_elements_(int* gid, char* key,int* index, float *val,int* s
if(!val8) return GRIB_OUT_OF_MEMORY;
-
err = grib_get_double_elements(h, cast_char(buf,key,len), index,(long)lsize,val8);
for(i=0;icontext,val8);
return err;
}
-int grib_f_set_force_real4_array__(int* gid, char* key, float*val, int* size, int len){
- return grib_f_set_force_real4_array_( gid, key, val, size, len);
-}
-int grib_f_set_force_real4_array(int* gid, char* key, float*val, int* size, int len){
- return grib_f_set_force_real4_array_( gid, key, val, size, len);
-}
/*****************************************************************************/
int grib_f_set_real4_array_(int* gid, char* key, float* val, int* size, int len)
@@ -2890,12 +2362,6 @@ int grib_f_set_real4_array_(int* gid, char* key, float* val, int* size, int len)
return err;
}
-int grib_f_set_real4_array__(int* gid, char* key, float* val, int* size, int len) {
- return grib_f_set_real4_array_(gid, key, val, size, len);
-}
-int grib_f_set_real4_array(int* gid, char* key, float* val, int* size, int len) {
- return grib_f_set_real4_array_(gid, key, val, size, len);
-}
/*****************************************************************************/
int grib_f_index_select_real8_(int* gid, char* key, double* val, int len)
@@ -2906,12 +2372,6 @@ int grib_f_index_select_real8_(int* gid, char* key, double* val, int len)
if(!h) return GRIB_INVALID_GRIB;
return grib_index_select_double(h, cast_char(buf,key,len), *val);
}
-int grib_f_index_select_real8__(int* gid, char* key, double* val, int len){
- return grib_f_index_select_real8_(gid,key,val,len);
-}
-int grib_f_index_select_real8(int* gid, char* key, double* val, int len){
- return grib_f_index_select_real8_(gid,key,val,len);
-}
/*****************************************************************************/
int grib_f_index_select_string_(int* gid, char* key, char* val, int len, int vallen)
@@ -2929,12 +2389,6 @@ int grib_f_index_select_string_(int* gid, char* key, char* val, int len, int val
return grib_index_select_string(h, cast_char(buf,key,len), bufval);
}
-int grib_f_index_select_string__(int* gid, char* key, char* val, int len, int vallen){
- return grib_f_index_select_string_(gid,key,val,len,vallen);
-}
-int grib_f_index_select_string(int* gid, char* key, char* val, int len, int vallen){
- return grib_f_index_select_string_(gid,key,val,len,vallen);
-}
/*****************************************************************************/
int grib_f_index_select_int_(int* gid, char* key, int* val, int len)
@@ -2946,12 +2400,6 @@ int grib_f_index_select_int_(int* gid, char* key, int* val, int len)
if(!h) return GRIB_INVALID_GRIB;
return grib_index_select_long(h, cast_char(buf,key,len), lval);
}
-int grib_f_index_select_int__(int* gid, char* key, int* val, int len){
- return grib_f_index_select_int_(gid,key,val,len);
-}
-int grib_f_index_select_int(int* gid, char* key, int* val, int len){
- return grib_f_index_select_int_(gid,key,val,len);
-}
/*****************************************************************************/
int grib_f_index_select_long_(int* gid, char* key, long* val, int len)
@@ -2962,12 +2410,6 @@ int grib_f_index_select_long_(int* gid, char* key, long* val, int len)
if(!h) return GRIB_INVALID_GRIB;
return grib_index_select_long(h, cast_char(buf,key,len), *val);
}
-int grib_f_index_select_long__(int* gid, char* key, long* val, int len){
- return grib_f_index_select_long_(gid,key,val,len);
-}
-int grib_f_index_select_long(int* gid, char* key, long* val, int len){
- return grib_f_index_select_long_(gid,key,val,len);
-}
/*****************************************************************************/
int grib_f_set_real8_(int* gid, char* key, double* val, int len)
@@ -2978,12 +2420,6 @@ int grib_f_set_real8_(int* gid, char* key, double* val, int len)
if(!h) return GRIB_INVALID_GRIB;
return grib_set_double(h, cast_char(buf,key,len), *val);
}
-int grib_f_set_real8__(int* gid, char* key, double* val, int len){
- return grib_f_set_real8_( gid, key, val, len);
-}
-int grib_f_set_real8(int* gid, char* key, double* val, int len){
- return grib_f_set_real8_( gid, key, val, len);
-}
int grib_f_get_real8_(int* gid, char* key, double* val, int len)
{
@@ -2993,15 +2429,9 @@ int grib_f_get_real8_(int* gid, char* key, double* val, int len)
if(!h) return GRIB_INVALID_GRIB;
return grib_get_double(h, cast_char(buf,key,len), val);
-
-}
-int grib_f_get_real8__(int* gid, char* key, double* val, int len){
- return grib_f_get_real8_( gid, key, val, len);
-}
-int grib_f_get_real8(int* gid, char* key, double* val, int len){
- return grib_f_get_real8_( gid, key, val, len);
}
+/*****************************************************************************/
int grib_f_get_real8_element_(int* gid, char* key,int* index, double* val, int len){
grib_handle *h = get_handle(*gid);
@@ -3010,15 +2440,9 @@ int grib_f_get_real8_element_(int* gid, char* key,int* index, double* val, int l
if(!h) return GRIB_INVALID_GRIB;
return grib_get_double_element(h, cast_char(buf,key,len), *index,val);
-
-}
-int grib_f_get_real8_element__(int* gid, char* key, int* index,double* val, int len){
- return grib_f_get_real8_element_( gid, key, index, val,len);
-}
-int grib_f_get_real8_element(int* gid, char* key, int* index,double* val, int len){
- return grib_f_get_real8_element_( gid, key, index, val,len);
}
+/*****************************************************************************/
int grib_f_get_real8_elements_(int* gid, char* key,int* index, double* val, int *size, int len){
grib_handle *h = get_handle(*gid);
@@ -3027,13 +2451,6 @@ int grib_f_get_real8_elements_(int* gid, char* key,int* index, double* val, int
if(!h) return GRIB_INVALID_GRIB;
return grib_get_double_elements(h, cast_char(buf,key,len), index,*size,val);
-
-}
-int grib_f_get_real8_elements__(int* gid, char* key, int* index,double* val, int* len,int size){
- return grib_f_get_real8_elements_( gid, key, index, val,len,size);
-}
-int grib_f_get_real8_elements(int* gid, char* key, int* index,double* val, int* len,int size){
- return grib_f_get_real8_elements_( gid, key, index, val,len,size);
}
/*****************************************************************************/
@@ -3060,26 +2477,6 @@ int grib_f_find_nearest_four_single_(int* gid,int* is_lsm,
grib_nearest_delete(nearest);
return result;
}
-int grib_f_find_nearest_four_single__(int* gid,int* is_lsm,
- double* inlats,double* inlons,
- double* outlats,double* outlons,
- double* values,double* distances,
- int* indexes) {
-
- return grib_f_find_nearest_four_single_(gid,is_lsm,
- inlats,inlons,outlats,outlons,values,
- distances,indexes);
-}
-int grib_f_find_nearest_four_single(int* gid,int* is_lsm,
- double* inlats,double* inlons,
- double* outlats,double* outlons,
- double* values,double* distances,
- int* indexes) {
-
- return grib_f_find_nearest_four_single_(gid,is_lsm,
- inlats,inlons,outlats,outlons,values,
- distances,indexes);
-}
/*****************************************************************************/
int grib_f_find_nearest_single_(int* gid,int* is_lsm,
@@ -3096,26 +2493,6 @@ int grib_f_find_nearest_single_(int* gid,int* is_lsm,
inlats,inlons,1,outlats,outlons,
values,distances,indexes);
}
-int grib_f_find_nearest_single__(int* gid,int* is_lsm,
- double* inlats,double* inlons,
- double* outlats,double* outlons,
- double* values,double* distances,
- int* indexes) {
-
- return grib_f_find_nearest_single_(gid,is_lsm,
- inlats,inlons,outlats,outlons,values,
- distances,indexes);
-}
-int grib_f_find_nearest_single(int* gid,int* is_lsm,
- double* inlats,double* inlons,
- double* outlats,double* outlons,
- double* values,double* distances,
- int* indexes) {
-
- return grib_f_find_nearest_single_(gid,is_lsm,
- inlats,inlons,outlats,outlons,values,
- distances,indexes);
-}
/*****************************************************************************/
int grib_f_find_nearest_multiple_(int* gid,int* is_lsm,
@@ -3132,26 +2509,6 @@ int grib_f_find_nearest_multiple_(int* gid,int* is_lsm,
inlats,inlons,*npoints,outlats,outlons,
values,distances,indexes);
}
-int grib_f_find_nearest_multiple__(int* gid,int* is_lsm,
- double* inlats,double* inlons,
- double* outlats,double* outlons,
- double* values,double* distances,
- int* indexes, int* npoints) {
-
- return grib_f_find_nearest_multiple_(gid,is_lsm,
- inlats,inlons,outlats,outlons,values,
- distances,indexes,npoints);
-}
-int grib_f_find_nearest_multiple(int* gid,int* is_lsm,
- double* inlats,double* inlons,
- double* outlats,double* outlons,
- double* values,double* distances,
- int* indexes, int* npoints) {
-
- return grib_f_find_nearest_multiple_(gid,is_lsm,
- inlats,inlons,outlats,outlons,values,
- distances,indexes,npoints);
-}
/*****************************************************************************/
int grib_f_get_real8_array_(int* gid, char* key, double*val, int* size, int len){
@@ -3169,20 +2526,8 @@ int grib_f_get_real8_array_(int* gid, char* key, double*val, int* size, int len)
return err;
}
}
-int grib_f_get_real8_array__(int* gid, char* key, double*val, int* size, int len){
- return grib_f_get_real8_array_( gid, key, val, size, len);
-}
-int grib_f_get_real8_array(int* gid, char* key, double*val, int* size, int len){
- return grib_f_get_real8_array_( gid, key, val, size, len);
-}
-
-int grib_f_set_force_real8_array__(int* gid, char* key, double *val, int* size, int len){
- return grib_f_set_force_real8_array_( gid, key, val, size, len);
-}
-int grib_f_set_force_real8_array(int* gid, char* key, double *val, int* size, int len){
- return grib_f_set_force_real8_array_( gid, key, val, size, len);
-}
+/*****************************************************************************/
int grib_f_set_force_real8_array_(int* gid, char* key, double*val, int* size, int len){
grib_handle *h = get_handle(*gid);
@@ -3205,12 +2550,6 @@ int grib_f_set_real8_array_(int* gid, char* key, double*val, int* size, int len)
return grib_set_double_array(h, cast_char(buf,key,len), val, lsize);
}
-int grib_f_set_real8_array__(int* gid, char* key, double *val, int* size, int len){
- return grib_f_set_real8_array_( gid, key, val, size, len);
-}
-int grib_f_set_real8_array(int* gid, char* key, double *val, int* size, int len){
- return grib_f_set_real8_array_( gid, key, val, size, len);
-}
/*****************************************************************************/
int grib_f_get_string_array_(int* gid, char* key, char* val,int* nvals,int* slen, int len)
@@ -3241,12 +2580,6 @@ int grib_f_get_string_array_(int* gid, char* key, char* val,int* nvals,int* slen
return err;
}
-int grib_f_get_string_array__(int* gid, char* key, char* val,int* nvals,int* slen, int len){
- return grib_f_get_string_array_( gid, key, val,nvals,slen,len);
-}
-int grib_f_get_string_array(int* gid, char* key, char* val,int* nvals,int* slen, int len){
- return grib_f_get_string_array_( gid, key, val, nvals, slen, len);
-}
/*****************************************************************************/
int codes_f_bufr_copy_data_(int* gid1,int* gid2)
@@ -3262,12 +2595,6 @@ int codes_f_bufr_copy_data_(int* gid1,int* gid2)
return err;
}
-int codes_f_bufr_copy_data__(int* gid1,int* gid2){
- return codes_f_bufr_copy_data_(gid1, gid2);
-}
-int codes_f_bufr_copy_data(int* gid1,int* gid2){
- return codes_f_bufr_copy_data_(gid1, gid2);
-}
/*****************************************************************************/
int grib_f_set_string_array_(int* gid, char* key, char* val,int* nvals,int* slen, int len)
@@ -3301,12 +2628,6 @@ int grib_f_set_string_array_(int* gid, char* key, char* val,int* nvals,int* slen
return err;
}
-int grib_f_set_string_array__(int* gid, char* key, char* val,int* nvals,int* slen, int len){
- return grib_f_set_string_array_( gid, key, val,nvals,slen,len);
-}
-int grib_f_set_string_array(int* gid, char* key, char* val,int* nvals,int* slen, int len){
- return grib_f_set_string_array_( gid, key, val, nvals, slen, len);
-}
/*****************************************************************************/
int grib_f_get_string_(int* gid, char* key, char* val,int len, int len2){
@@ -3326,12 +2647,6 @@ int grib_f_get_string_(int* gid, char* key, char* val,int len, int len2){
return err;
}
-int grib_f_get_string__(int* gid, char* key, char* val, int len, int len2){
- return grib_f_get_string_( gid, key, val, len, len2);
-}
-int grib_f_get_string(int* gid, char* key, char* val, int len, int len2){
- return grib_f_get_string_( gid, key, val, len, len2);
-}
static int is_all_spaces(const char *s)
{
@@ -3363,12 +2678,6 @@ int grib_f_set_string_(int* gid, char* key, char* val, int len, int len2){
return grib_set_string(h, cast_char(buf,key,len), val_str, &lsize);
}
-int grib_f_set_string__(int* gid, char* key, char* val, int len, int len2){
- return grib_f_set_string_( gid, key, val, len, len2);
-}
-int grib_f_set_string(int* gid, char* key, char* val, int len, int len2){
- return grib_f_set_string_( gid, key, val, len, len2);
-}
/*****************************************************************************/
int grib_f_get_data_real4_(int* gid,float* lats, float* lons,float* values,size_t* size) {
@@ -3401,25 +2710,12 @@ int grib_f_get_data_real4_(int* gid,float* lats, float* lons,float* values,size_
return err;
}
-int grib_f_get_data_real4__(int* gid,float* lats, float* lons,float* values,size_t* size) {
- return grib_f_get_data_real4_(gid,lats,lons,values,size);
-}
-int grib_f_get_data_real4(int* gid,float* lats, float* lons,float* values,size_t* size) {
- return grib_f_get_data_real4_(gid,lats,lons,values,size);
-}
-
int grib_f_get_data_real8_(int* gid,double* lats, double* lons,double* values,size_t* size) {
grib_handle *h = get_handle(*gid);
return grib_get_data(h,lats,lons,values);
}
-int grib_f_get_data_real8__(int* gid,double* lats, double* lons,double* values,size_t* size) {
- return grib_f_get_data_real8_(gid,lats,lons,values,size);
-}
-int grib_f_get_data_real8(int* gid,double* lats, double* lons,double* values,size_t* size) {
- return grib_f_get_data_real8_(gid,lats,lons,values,size);
-}
/*****************************************************************************/
int grib_f_get_message_size_(int* gid, size_t *len){
@@ -3428,22 +2724,16 @@ int grib_f_get_message_size_(int* gid, size_t *len){
*len = h->buffer->ulength;
return GRIB_SUCCESS;
}
-int grib_f_get_message_size__(int* gid, size_t *len){
- return grib_f_get_message_size_( gid, len);
-}
-int grib_f_get_message_size(int* gid, size_t *len){
- return grib_f_get_message_size_( gid, len);
-}
/*****************************************************************************/
-int grib_f_copy_message_(int* gid, void* mess,size_t* len){
+int grib_f_copy_message_(int* gid, void* mess, size_t* len){
grib_handle *h = get_handle(*gid);
if(!h)
return GRIB_INVALID_GRIB;
if(*len < h->buffer->ulength) {
grib_context_log(h->context,GRIB_LOG_ERROR,
- "grib_copy_message: buffer=%ld message size=%ld",*len,h->buffer->ulength);
+ "grib_copy_message: buffer=%zu message size=%zu", *len, h->buffer->ulength);
return GRIB_BUFFER_TOO_SMALL;
}
@@ -3451,12 +2741,6 @@ int grib_f_copy_message_(int* gid, void* mess,size_t* len){
*len=h->buffer->ulength;
return GRIB_SUCCESS;
}
-int grib_f_copy_message__(int* gid, void* mess,size_t* len){
- return grib_f_copy_message_( gid, mess, len);
-}
-int grib_f_copy_message(int* gid, void* mess,size_t* len){
- return grib_f_copy_message_( gid, mess, len);
-}
/*****************************************************************************/
void grib_f_check_(int* err,char* call,char* str,int lencall,int lenstr){
@@ -3472,12 +2756,6 @@ void grib_f_check_(int* err,char* call,char* str,int lencall,int lenstr){
bufcall,bufstr,grib_get_error_message(*err));
exit(*err);
}
-void grib_f_check__(int* err,char* call, char* key, int lencall, int lenkey){
- grib_f_check_(err,call,key,lencall,lenkey);
-}
-void grib_f_check(int* err,char* call, char* key, int lencall, int lenkey){
- grib_f_check_(err,call,key,lencall,lenkey);
-}
/*****************************************************************************/
int grib_f_write_(int* gid, int* fid) {
@@ -3491,18 +2769,12 @@ int grib_f_write_(int* gid, int* fid) {
grib_get_message(h,&mess,&mess_len);
if(fwrite(mess,1, mess_len,f) != mess_len) {
- perror("grib_write");
+ perror("write");
return GRIB_IO_PROBLEM;
}
return GRIB_SUCCESS;
}
-int grib_f_write__(int* gid, int* fid) {
- return grib_f_write_(gid,fid);
-}
-int grib_f_write(int* gid, int* fid) {
- return grib_f_write_(gid,fid);
-}
/*****************************************************************************/
int grib_f_multi_write_(int* gid, int* fid) {
@@ -3514,13 +2786,6 @@ int grib_f_multi_write_(int* gid, int* fid) {
return grib_multi_handle_write(h,f);
}
-int grib_f_multi_write__(int* gid, int* fid) {
- return grib_f_multi_write_(gid,fid);
-}
-int grib_f_multi_write(int* gid, int* fid) {
- return grib_f_multi_write_(gid,fid);
-}
-
int grib_f_multi_append_(int* ingid, int* sec,int* mgid) {
grib_handle *h = get_handle(*ingid);
@@ -3535,36 +2800,17 @@ int grib_f_multi_append_(int* ingid, int* sec,int* mgid) {
return grib_multi_handle_append(h,*sec,mh);
}
-int grib_f_multi_append(int* ingid, int* sec,int* mgid) {
- return grib_f_multi_append_(ingid, sec, mgid);
-}
-int grib_f_multi_append__(int* ingid, int* sec,int* mgid) {
- return grib_f_multi_append_(ingid, sec, mgid);
-}
/*****************************************************************************/
int codes_f_bufr_multi_element_constant_arrays_on_() {
codes_bufr_multi_element_constant_arrays_on(NULL);
return GRIB_SUCCESS;
}
-int codes_f_bufr_multi_element_constant_arrays_on__() {
- return codes_f_bufr_multi_element_constant_arrays_on_();
-}
-int codes_f_bufr_multi_element_constant_arrays_on() {
- return codes_f_bufr_multi_element_constant_arrays_on_();
-}
int codes_f_bufr_multi_element_constant_arrays_off_() {
codes_bufr_multi_element_constant_arrays_off(NULL);
return GRIB_SUCCESS;
}
-int codes_f_bufr_multi_element_constant_arrays_off__() {
- return codes_f_bufr_multi_element_constant_arrays_off_();
-}
-int codes_f_bufr_multi_element_constant_arrays_off() {
- return codes_f_bufr_multi_element_constant_arrays_off_();
-}
-
/*****************************************************************************/
int grib_f_set_definitions_path_(char* path, int len){
@@ -3573,13 +2819,6 @@ int grib_f_set_definitions_path_(char* path, int len){
grib_context_set_definitions_path(c, cast_char(buf,path,len));
return GRIB_SUCCESS;
}
-int grib_f_set_definitions_path__(char* path, int len){
- return grib_f_set_definitions_path_(path, len);
-}
-int grib_f_set_definitions_path(char* path, int len){
- return grib_f_set_definitions_path_(path, len);
-}
-
/*****************************************************************************/
int grib_f_set_samples_path_(char* path, int len){
@@ -3588,33 +2827,13 @@ int grib_f_set_samples_path_(char* path, int len){
grib_context_set_samples_path(c, cast_char(buf,path,len));
return GRIB_SUCCESS;
}
-int grib_f_set_samples_path__(char* path, int len){
- return grib_f_set_samples_path_(path, len);
-}
-int grib_f_set_samples_path(char* path, int len){
- return grib_f_set_samples_path_(path, len);
-}
-
/*****************************************************************************/
-int grib_f_julian_to_datetime(double* jd,long* year,long* month,long* day,long *hour,long *minute,long *second) {
- return grib_julian_to_datetime(*jd,year,month,day,hour,minute,second);
-}
int grib_f_julian_to_datetime_(double* jd,long* year,long* month,long* day,long *hour,long *minute,long *second) {
return grib_julian_to_datetime(*jd,year,month,day,hour,minute,second);
}
-int grib_f_julian_to_datetime__(double* jd,long* year,long* month,long* day,long *hour,long *minute,long *second) {
- return grib_julian_to_datetime(*jd,year,month,day,hour,minute,second);
-}
-
/*****************************************************************************/
-int grib_f_datetime_to_julian(long* year,long* month,long* day, long* hour,long* minute,long* second,double* jd) {
- return grib_datetime_to_julian(*year,*month,*day,*hour,*minute,*second,jd);
-}
int grib_f_datetime_to_julian_(long* year,long* month,long* day, long* hour,long* minute,long* second,double* jd) {
return grib_datetime_to_julian(*year,*month,*day,*hour,*minute,*second,jd);
}
-int grib_f_datetime_to_julian__(long* year,long* month,long* day, long* hour,long* minute,long* second,double* jd) {
- return grib_datetime_to_julian(*year,*month,*day,*hour,*minute,*second,jd);
-}
diff --git a/fortran/grib_fortran_kinds.c b/fortran/grib_fortran_kinds.c
index 413a0d164..5835a53d2 100644
--- a/fortran/grib_fortran_kinds.c
+++ b/fortran/grib_fortran_kinds.c
@@ -14,45 +14,29 @@
extern "C" {
#endif
-void f_sizeof(void *x,void *y, int *size) {
- *size=((char*)y)-((char*)x);
-}
-void f_sizeof_(void *x,void *y, int *size) {
- *size=((char*)y)-((char*)x);
-}
-void f_sizeof__(void *x,void *y, int *size) {
+void f_sizeof_(void *x, void *y, int *size) {
*size=((char*)y)-((char*)x);
}
-void check_double(double *x,double *y,char* ret) {
+void check_double_(double *x, double* y, char* ret) {
*ret = ((char*)y)-((char*)x) == sizeof(*x) ? 't' : 'f';
}
-void check_double_(double *x,double *y,char* ret) {check_double(x,y,ret);}
-void check_double__(double *x,double *y,char* ret) {check_double(x,y,ret);}
-void check_float(float *x,float *y,char* ret) {
+void check_float_(float* x, float* y, char* ret) {
*ret = ((char*)y)-((char*)x) == sizeof(*x) ? 't' : 'f';
}
-void check_float_(float *x,float *y,char* ret) { check_float(x,y,ret); }
-void check_float__(float *x,float *y,char* ret) { check_float(x,y,ret); }
-void check_int(int *x,int *y,char* ret) {
+void check_int_(int* x, int* y, char* ret) {
*ret = ((char*)y)-((char*)x) == sizeof(*x) ? 't' : 'f';
}
-void check_int_(int *x,int *y,char* ret) { check_int(x,y,ret); }
-void check_int__(int *x,int *y,char* ret) { check_int(x,y,ret); }
-void check_long(long *x,long *y,char* ret) {
+void check_long_(long* x, long * y, char* ret) {
*ret = ((char*)y)-((char*)x) == sizeof(*x) ? 't' : 'f';
}
-void check_long_(long *x,long *y,char* ret) {check_long(x,y,ret);}
-void check_long__(long *x,long *y,char* ret) {check_long(x,y,ret);}
-void check_size_t(size_t *x,size_t *y,char* ret) {
+void check_size_t_(size_t* x, size_t* y, char* ret) {
*ret = ((char*)y)-((char*)x) == sizeof(*x) ? 't' : 'f';
}
-void check_size_t_(size_t *x,size_t *y,char* ret) {check_size_t(x,y,ret);}
-void check_size_t__(size_t *x,size_t *y,char* ret) {check_size_t(x,y,ret);}
#ifdef __cplusplus
}
diff --git a/fortran/grib_fortran_prototypes.h b/fortran/grib_fortran_prototypes.h
deleted file mode 100644
index 0912dadc6..000000000
--- a/fortran/grib_fortran_prototypes.h
+++ /dev/null
@@ -1,405 +0,0 @@
-/*
- * (C) Copyright 2005- ECMWF.
- *
- * This software is licensed under the terms of the Apache Licence Version 2.0
- * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
- *
- * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
- * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
- */
-
-/* grib_fortran.c */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int grib_f_read_any_headers_only_from_file_(int *fid, char *buffer, size_t *nbytes);
-int grib_f_read_any_headers_only_from_file__(int *fid, char *buffer, size_t *nbytes);
-int grib_f_read_any_headers_only_from_file(int *fid, char *buffer, size_t *nbytes);
-int grib_f_read_any_from_file_(int *fid, void* buffer, size_t *nbytes);
-int grib_f_read_any_from_file__(int *fid, void* buffer, size_t *nbytes);
-int grib_f_read_any_from_file(int *fid, void* buffer, size_t *nbytes);
-int grib_f_write_file_(int *fid, void* buffer, size_t *nbytes);
-int grib_f_write_file__(int *fid, void* buffer, size_t *nbytes);
-int grib_f_write_file(int *fid, void* buffer, size_t *nbytes);
-int grib_f_read_file_(int *fid, void* buffer, size_t *nbytes);
-int grib_f_read_file__(int *fid, void* buffer, size_t *nbytes);
-int grib_f_read_file(int *fid, void* buffer, size_t *nbytes);
-int grib_f_open_file_(int *fid, char *name, char *op, int lname, int lop);
-int grib_f_open_file__(int *fid, char *name, char *op, int lname, int lop);
-int grib_f_open_file(int *fid, char *name, char *op, int lname, int lop);
-int grib_f_close_file_(int *fid);
-int grib_f_close_file__(int *fid);
-int grib_f_close_file(int *fid);
-void grib_f_write_on_fail(int *gid);
-void grib_f_write_on_fail_(int* gid);
-void grib_f_write_on_fail__(int* gid);
-int grib_f_multi_support_on_(void);
-int grib_f_multi_support_on__(void);
-int grib_f_multi_support_on(void);
-int grib_f_multi_support_off_(void);
-int grib_f_multi_support_off__(void);
-int grib_f_multi_support_off(void);
-
-/* GRIB keys iterator */
-int grib_f_keys_iterator_new_(int *gid, int *iterid, char *name_space, int len);
-int grib_f_keys_iterator_new__(int *gid, int *iterid, char *name_space, int len);
-int grib_f_keys_iterator_new(int *gid, int *iterid, char *name_space, int len);
-int grib_f_keys_iterator_next_(int *iterid);
-int grib_f_keys_iterator_next__(int *iterid);
-int grib_f_keys_iterator_next(int *iterid);
-int grib_f_keys_iterator_delete_(int *iterid);
-int grib_f_keys_iterator_delete__(int *iterid);
-int grib_f_keys_iterator_delete(int *iterid);
-int grib_f_keys_iterator_get_name_(int *iterid, char *name, int len);
-int grib_f_keys_iterator_get_name__(int *kiter, char *name, int len);
-int grib_f_keys_iterator_get_name(int *kiter, char *name, int len);
-int grib_f_keys_iterator_rewind_(int *kiter);
-int grib_f_keys_iterator_rewind__(int *kiter);
-int grib_f_keys_iterator_rewind(int *kiter);
-
-/* BUFR keys iterator */
-int codes_f_bufr_keys_iterator_new_(int *gid, int *iterid);
-int codes_f_bufr_keys_iterator_new__(int *gid, int *iterid);
-int codes_f_bufr_keys_iterator_new(int *gid, int *iterid);
-int codes_f_bufr_keys_iterator_next_(int *iterid);
-int codes_f_bufr_keys_iterator_next__(int *iterid);
-int codes_f_bufr_keys_iterator_next(int *iterid);
-int codes_f_bufr_keys_iterator_get_name_(int *iterid, char *name, int len);
-int codes_f_bufr_keys_iterator_get_name__(int *kiter, char *name, int len);
-int codes_f_bufr_keys_iterator_get_name(int *kiter, char *name, int len);
-int codes_f_bufr_keys_iterator_rewind_(int *kiter);
-int codes_f_bufr_keys_iterator_rewind__(int *kiter);
-int codes_f_bufr_keys_iterator_rewind(int *kiter);
-int codes_f_bufr_keys_iterator_delete_(int *iterid);
-int codes_f_bufr_keys_iterator_delete__(int *iterid);
-int codes_f_bufr_keys_iterator_delete(int *iterid);
-
-int grib_f_gribex_mode_on_(void);
-int grib_f_gribex_mode_on__(void);
-int grib_f_gribex_mode_on(void);
-int grib_f_gribex_mode_off_(void);
-int grib_f_gribex_mode_off__(void);
-int grib_f_gribex_mode_off(void);
-int grib_f_skip_computed_(int *iterid);
-int grib_f_skip_computed__(int *iterid);
-int grib_f_skip_computed(int *iterid);
-int grib_f_skip_coded_(int *iterid);
-int grib_f_skip_coded__(int *iterid);
-int grib_f_skip_coded(int *iterid);
-int grib_f_skip_edition_specific_(int *iterid);
-int grib_f_skip_edition_specific__(int *iterid);
-int grib_f_skip_edition_specific(int *iterid);
-int grib_f_skip_duplicates_(int *iterid);
-int grib_f_skip_duplicates__(int *iterid);
-int grib_f_skip_duplicates(int *iterid);
-int grib_f_skip_read_only_(int *iterid);
-int grib_f_skip_read_only__(int *iterid);
-int grib_f_skip_read_only(int *iterid);
-int grib_f_skip_function_(int *iterid);
-int grib_f_skip_function__(int *iterid);
-int grib_f_skip_function(int *iterid);
-
-int grib_f_new_from_message_(int *gid, void* buffer, size_t *bufsize);
-int grib_f_new_from_message__(int *gid, void* buffer, size_t *bufsize);
-int grib_f_new_from_message(int *gid, void* buffer, size_t *bufsize);
-int grib_f_new_from_message_int_(int *gid, int *buffer, size_t *bufsize);
-int grib_f_new_from_message_int__(int *gid, int *buffer, size_t *bufsize);
-int grib_f_new_from_message_int(int *gid, int *buffer, size_t *bufsize);
-
-int grib_f_new_from_message_copy_(int *gid, void* buffer, size_t *bufsize);
-int grib_f_new_from_message_copy__(int *gid, void* buffer, size_t *bufsize);
-int grib_f_new_from_message_copy(int *gid, void* buffer, size_t *bufsize);
-int grib_f_new_from_samples_(int *gid, char *name, int lname);
-int grib_f_new_from_samples__(int *gid, char *name, int lname);
-int grib_f_new_from_samples(int *gid, char *name, int lname);
-int codes_bufr_f_new_from_samples_(int *gid, char *name, int lname);
-int codes_bufr_f_new_from_samples__(int *gid, char *name, int lname);
-int codes_bufr_f_new_from_samples(int *gid, char *name, int lname);
-int grib_f_clone_(int *gidsrc, int *giddest);
-int grib_f_clone__(int *gidsrc, int *giddest);
-int grib_f_clone(int *gidsrc, int *giddest);
-int grib_f_util_sections_copy_(int *gidfrom, int *gidto, int *what, int *gidout);
-int grib_f_util_sections_copy__(int *gidfrom, int *gidto, int *what, int *gidout);
-int grib_f_util_sections_copy(int *gidfrom, int *gidto, int *what, int *gidout);
-int grib_f_copy_namespace_(int *gidsrc, char *name, int *giddest, int len);
-int grib_f_copy_namespace__(int *gidsrc, char *name, int *giddest, int len);
-int grib_f_copy_namespace(int *gidsrc, char *name, int *giddest, int len);
-
-int grib_f_copy_key_ (int *gidsrc, char *name, int *giddest, int len);
-int grib_f_copy_key__(int *gidsrc, char *name, int *giddest, int len);
-int grib_f_copy_key (int *gidsrc, char *name, int *giddest, int len);
-
-int grib_f_count_in_file(int *fid, int *n);
-int grib_f_count_in_file_(int *fid, int *n);
-int grib_f_count_in_file__(int *fid, int *n);
-
-int any_f_new_from_file_(int *fid, int *gid);
-int any_f_new_from_file__(int *fid, int *gid);
-int any_f_new_from_file(int *fid, int *gid);
-
-int any_f_scan_file_(int* fid,int* n);
-int any_f_scan_file__(int* fid,int* n);
-int any_f_scan_file(int* fid,int* n);
-
-int any_f_new_from_scanned_file_(int* fid,int* msgid,int* gid);
-int any_f_new_from_scanned_file__(int* fid,int* msgid,int* gid);
-int any_f_new_from_scanned_file(int* fid,int* msgid,int* gid);
-
-int any_f_load_all_from_file_(int* fid,int* n);
-int any_f_load_all_from_file__(int* fid,int* n);
-int any_f_load_all_from_file(int* fid,int* n);
-
-int any_f_new_from_loaded_(int* msgid,int* gid);
-int any_f_new_from_loaded__(int* msgid,int* gid);
-int any_f_new_from_loaded(int* msgid,int* gid);
-
-int codes_f_clear_loaded_from_file_(void);
-int codes_f_clear_loaded_from_file__(void);
-int codes_f_clear_loaded_from_file(void);
-
-int grib_f_new_from_file_(int *fid, int *gid);
-int grib_f_new_from_file__(int *fid, int *gid);
-int grib_f_new_from_file(int *fid, int *gid);
-
-int bufr_f_new_from_file_(int *fid, int *gid);
-int bufr_f_new_from_file__(int *fid, int *gid);
-int bufr_f_new_from_file(int *fid, int *gid);
-
-int grib_f_headers_only_new_from_file_(int *fid, int *gid);
-int grib_f_headers_only_new_from_file__(int *fid, int *gid);
-int grib_f_headers_only_new_from_file(int *fid, int *gid);
-int grib_f_new_from_index_(int *iid, int *gid);
-int grib_f_new_from_index__(int *iid, int *gid);
-int grib_f_new_from_index(int *iid, int *gid);
-int grib_f_index_new_from_file_(char *file, char *keys, int *gid, int lfile, int lkeys);
-int grib_f_index_new_from_file__(char *file, char *keys, int *gid, int lfile, int lkeys);
-int grib_f_index_new_from_file(char *file, char *keys, int *gid, int lfile, int lkeys);
-int grib_f_index_add_file_(int* iid, char* file, int lfile);
-int grib_f_index_add_file__(int* iid, char* file, int lfile);
-int grib_f_index_add_file(int* iid, char* file, int lfile);
-int grib_f_index_read_(char *file, int *gid, int lfile);
-int grib_f_index_read__(char *file, int *gid, int lfile);
-int grib_f_index_read(char *file, int *gid, int lfile);
-int grib_f_index_write_(int *gid, char *file, int lfile);
-int grib_f_index_write__(int *gid, char *file, int lfile);
-int grib_f_index_write(int *gid, char *file, int lfile);
-int grib_f_index_release_(int *hid);
-int grib_f_index_release__(int *hid);
-int grib_f_index_release(int *hid);
-int grib_f_multi_handle_release_(int *hid);
-int grib_f_multi_handle_release__(int *hid);
-int grib_f_multi_handle_release(int *hid);
-int grib_f_release_(int *hid);
-int grib_f_release__(int *hid);
-int grib_f_release(int *hid);
-int grib_f_dump_(int *gid);
-int grib_f_dump__(int *gid);
-int grib_f_dump(int *gid);
-
-int grib_f_get_api_version_(int* apiVersion,int len);
-int grib_f_get_api_version__(int* apiVersion,int len);
-int grib_f_get_api_version(int* apiVersion,int len);
-
-int grib_f_get_error_string_(int *err, char *buf, int len);
-int grib_f_get_error_string__(int *err, char *buf, int len);
-int grib_f_get_error_string(int *err, char *buf, int len);
-int grib_f_get_size_int_(int *gid, char *key, int *val, int len);
-int grib_f_get_size_int__(int *gid, char *key, int *val, int len);
-int grib_f_get_size_int(int *gid, char *key, int *val, int len);
-int grib_f_get_size_long_(int *gid, char *key, long *val, int len);
-int grib_f_get_size_long__(int *gid, char *key, long *val, int len);
-int grib_f_get_size_long(int *gid, char *key, long *val, int len);
-int grib_f_index_get_size_int_(int *gid, char *key, int *val, int len);
-int grib_f_index_get_size_int__(int *gid, char *key, int *val, int len);
-int grib_f_index_get_size_int(int *gid, char *key, int *val, int len);
-int grib_f_index_get_size_long_(int *gid, char *key, long *val, int len);
-int grib_f_index_get_size_long__(int *gid, char *key, long *val, int len);
-int grib_f_index_get_size_long(int *gid, char *key, long *val, int len);
-int grib_f_get_int_(int *gid, char *key, int *val, int len);
-int grib_f_get_int__(int *gid, char *key, int *val, int len);
-int grib_f_get_int(int *gid, char *key, int *val, int len);
-int grib_f_get_long_(int *gid, char *key, long *val, int len);
-int grib_f_get_long__(int *gid, char *key, long *val, int len);
-int grib_f_get_long(int *gid, char *key, long *val, int len);
-
-int grib_f_get_native_type_(int* gid, char* key, int* val, int len);
-int grib_f_get_native_type__(int* gid, char* key, int* val, int len);
-int grib_f_get_native_type(int* gid, char* key, int* val, int len);
-
-int grib_f_get_int_array_(int *gid, char *key, int *val, int *size, int len);
-int grib_f_get_int_array__(int *gid, char *key, int *val, int *size, int len);
-int grib_f_get_int_array(int *gid, char *key, int *val, int *size, int len);
-int grib_f_get_long_array_(int *gid, char *key, long *val, int *size, int len);
-int grib_f_get_long_array__(int *gid, char *key, long *val, int *size, int len);
-int grib_f_get_long_array(int *gid, char *key, long *val, int *size, int len);
-int grib_f_get_byte_array_(int* gid, char* key, unsigned char *val, int* size, int len, int lenv);
-int grib_f_get_byte_array__(int* gid, char* key, unsigned char *val, int* size, int len, int lenv);
-int grib_f_get_byte_array(int* gid, char* key, unsigned char *val, int* size, int len, int lenv);
-int grib_f_index_get_string_(int *gid, char *key, char *val, int *eachsize, int *size, int len);
-int grib_f_index_get_string__(int *gid, char *key, char *val, int *eachsize, int *size, int len);
-int grib_f_index_get_string(int *gid, char *key, char *val, int *eachsize, int *size, int len);
-int grib_f_index_get_long_(int *gid, char *key, long *val, int *size, int len);
-int grib_f_index_get_long__(int *gid, char *key, long *val, int *size, int len);
-int grib_f_index_get_long(int *gid, char *key, long *val, int *size, int len);
-int grib_f_index_get_int_(int *gid, char *key, int *val, int *size, int len);
-int grib_f_index_get_int__(int *gid, char *key, int *val, int *size, int len);
-int grib_f_index_get_int(int *gid, char *key, int *val, int *size, int len);
-int grib_f_index_get_real8_(int *gid, char *key, double *val, int *size, int len);
-int grib_f_index_get_real8__(int *gid, char *key, double *val, int *size, int len);
-int grib_f_index_get_real8(int *gid, char *key, double *val, int *size, int len);
-int grib_f_set_int_array_(int *gid, char *key, int *val, int *size, int len);
-int grib_f_set_int_array__(int *gid, char *key, int *val, int *size, int len);
-int grib_f_set_int_array(int *gid, char *key, int *val, int *size, int len);
-int grib_f_set_long_array_(int *gid, char *key, long *val, int *size, int len);
-int grib_f_set_long_array__(int *gid, char *key, long *val, int *size, int len);
-int grib_f_set_long_array(int *gid, char *key, long *val, int *size, int len);
-int grib_f_set_byte_array_(int* gid, char* key, unsigned char *val, int* size, int len, int lenv);
-int grib_f_set_byte_array__(int* gid, char* key, unsigned char *val, int* size, int len, int lenv);
-int grib_f_set_byte_array(int* gid, char* key, unsigned char *val, int* size, int len, int lenv);
-int grib_f_set_int_(int *gid, char *key, int *val, int len);
-int grib_f_set_int__(int *gid, char *key, int *val, int len);
-int grib_f_set_int(int *gid, char *key, int *val, int len);
-int grib_f_set_long_(int *gid, char *key, long *val, int len);
-int grib_f_set_long__(int *gid, char *key, long *val, int len);
-int grib_f_set_long(int *gid, char *key, long *val, int len);
-int grib_f_set_missing_(int *gid, char *key, int len);
-int grib_f_set_missing__(int *gid, char *key, int len);
-int grib_f_set_missing(int *gid, char *key, int len);
-int grib_f_is_missing_(int *gid, char *key, int *isMissing, int len);
-int grib_f_is_missing__(int *gid, char *key, int *isMissing, int len);
-int grib_f_is_missing(int *gid, char *key, int *isMissing, int len);
-int grib_f_is_defined_(int* gid, char* key,int* isDefined,int len);
-int grib_f_is_defined__(int* gid, char* key,int* isDefined,int len);
-int grib_f_is_defined(int* gid, char* key,int* isDefined,int len);
-int grib_f_set_real4_(int *gid, char *key, float *val, int len);
-int grib_f_set_real4__(int *gid, char *key, float *val, int len);
-int grib_f_set_real4(int *gid, char *key, float *val, int len);
-int grib_f_get_real4_element_(int *gid, char *key, int *index, float *val, int len);
-int grib_f_get_real4_element__(int *gid, char *key, int *index, float *val, int len);
-int grib_f_get_real4_element(int *gid, char *key, int *index, float *val, int len);
-int grib_f_get_real4_elements_(int *gid, char *key, int *index, float *val, int *size, int len);
-int grib_f_get_real4_elements__(int *gid, char *key, int *index, float *val, int *len, int size);
-int grib_f_get_real4_elements(int *gid, char *key, int *index, float *val, int *len, int size);
-int grib_f_get_real4_(int *gid, char *key, float *val, int len);
-int grib_f_get_real4__(int *gid, char *key, float *val, int len);
-int grib_f_get_real4(int *gid, char *key, float *val, int len);
-int grib_f_get_real4_array_(int *gid, char *key, float *val, int *size, int len);
-int grib_f_get_real4_array__(int *gid, char *key, float *val, int *size, int len);
-int grib_f_get_real4_array(int *gid, char *key, float *val, int *size, int len);
-int grib_f_set_real4_array_(int *gid, char *key, float *val, int *size, int len);
-int grib_f_set_real4_array__(int *gid, char *key, float *val, int *size, int len);
-int grib_f_set_real4_array(int *gid, char *key, float *val, int *size, int len);
-int grib_f_set_force_real4_array_(int *gid, char *key, float *val, int *size, int len);
-int grib_f_set_force_real4_array__(int *gid, char *key, float *val, int *size, int len);
-int grib_f_set_force_real4_array(int *gid, char *key, float *val, int *size, int len);
-int grib_f_index_select_real8_(int *gid, char *key, double *val, int len);
-int grib_f_index_select_real8__(int *gid, char *key, double *val, int len);
-int grib_f_index_select_real8(int *gid, char *key, double *val, int len);
-int grib_f_index_select_string_(int *gid, char *key, char *val, int len, int vallen);
-int grib_f_index_select_string__(int *gid, char *key, char *val, int len, int vallen);
-int grib_f_index_select_string(int *gid, char *key, char *val, int len, int vallen);
-int grib_f_index_select_int_(int *gid, char *key, int *val, int len);
-int grib_f_index_select_int__(int *gid, char *key, int *val, int len);
-int grib_f_index_select_int(int *gid, char *key, int *val, int len);
-int grib_f_index_select_long_(int *gid, char *key, long *val, int len);
-int grib_f_index_select_long__(int *gid, char *key, long *val, int len);
-int grib_f_index_select_long(int *gid, char *key, long *val, int len);
-int grib_f_set_real8_(int *gid, char *key, double *val, int len);
-int grib_f_set_real8__(int *gid, char *key, double *val, int len);
-int grib_f_set_real8(int *gid, char *key, double *val, int len);
-int grib_f_get_real8_(int *gid, char *key, double *val, int len);
-int grib_f_get_real8__(int *gid, char *key, double *val, int len);
-int grib_f_get_real8(int *gid, char *key, double *val, int len);
-int grib_f_get_real8_element_(int *gid, char *key, int *index, double *val, int len);
-int grib_f_get_real8_element__(int *gid, char *key, int *index, double *val, int len);
-int grib_f_get_real8_element(int *gid, char *key, int *index, double *val, int len);
-int grib_f_get_real8_elements_(int *gid, char *key, int *index, double *val, int *size, int len);
-int grib_f_get_real8_elements__(int *gid, char *key, int *index, double *val, int *len, int size);
-int grib_f_get_real8_elements(int *gid, char *key, int *index, double *val, int *len, int size);
-int grib_f_find_nearest_four_single_(int *gid, int *is_lsm, double *inlat, double *inlon, double *outlats, double *outlons, double *values, double *distances, int *indexes);
-int grib_f_find_nearest_four_single__(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes);
-int grib_f_find_nearest_four_single(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes);
-int grib_f_find_nearest_single_(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes);
-int grib_f_find_nearest_single__(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes);
-int grib_f_find_nearest_single(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes);
-int grib_f_find_nearest_multiple_(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes, int *npoints);
-int grib_f_find_nearest_multiple__(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes, int *npoints);
-int grib_f_find_nearest_multiple(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes, int *npoints);
-int grib_f_get_real8_array_(int *gid, char *key, double *val, int *size, int len);
-int grib_f_get_real8_array__(int *gid, char *key, double *val, int *size, int len);
-int grib_f_get_real8_array(int *gid, char *key, double *val, int *size, int len);
-int grib_f_set_real8_array_(int *gid, char *key, double *val, int *size, int len);
-int grib_f_set_real8_array__(int *gid, char *key, double *val, int *size, int len);
-int grib_f_set_real8_array(int *gid, char *key, double *val, int *size, int len);
-int grib_f_set_force_real8_array_(int *gid, char *key, double *val, int *size, int len);
-int grib_f_set_force_real8_array__(int *gid, char *key, double *val, int *size, int len);
-int grib_f_set_force_real8_array(int *gid, char *key, double *val, int *size, int len);
-
-int grib_f_get_string_array(int* gid, char* key, char* val,int* nvals,int* slen,int len);
-int grib_f_get_string_array_(int* gid, char* key, char* val,int* nvals,int* slen,int len);
-int grib_f_get_string_array__(int* gid, char* key, char* val,int* nvals,int* slen,int len);
-int grib_f_set_string_array(int* gid, char* key, char* val,int* nvals,int* slen, int len);
-int grib_f_set_string_array_(int* gid, char* key, char* val,int* nvals,int* slen, int len);
-int grib_f_set_string_array__(int* gid, char* key, char* val,int* nvals,int* slen, int len);
-
-int grib_f_get_string_(int *gid, char *key, char *val, int len, int len2);
-int grib_f_get_string__(int *gid, char *key, char *val, int len, int len2);
-int grib_f_get_string(int *gid, char *key, char *val, int len, int len2);
-int grib_f_set_string_(int *gid, char *key, char *val, int len, int len2);
-int grib_f_set_string__(int *gid, char *key, char *val, int len, int len2);
-int grib_f_set_string(int *gid, char *key, char *val, int len, int len2);
-int grib_f_get_data_real4_(int *gid, float *lats, float *lons, float *values, size_t *size);
-int grib_f_get_data_real4__(int *gid, float *lats, float *lons, float *values, size_t *size);
-int grib_f_get_data_real4(int *gid, float *lats, float *lons, float *values, size_t *size);
-int grib_f_get_data_real8_(int *gid, double *lats, double *lons, double *values, size_t *size);
-int grib_f_get_data_real8__(int *gid, double *lats, double *lons, double *values, size_t *size);
-int grib_f_get_data_real8(int *gid, double *lats, double *lons, double *values, size_t *size);
-int grib_f_get_message_size_(int *gid, size_t *len);
-int grib_f_get_message_size__(int *gid, size_t *len);
-int grib_f_get_message_size(int *gid, size_t *len);
-int grib_f_copy_message_(int *gid, void* mess, size_t *len);
-int grib_f_copy_message__(int *gid, void* mess, size_t *len);
-int grib_f_copy_message(int *gid, void* mess, size_t *len);
-void grib_f_check_(int *err, char *call, char *str, int lencall, int lenstr);
-void grib_f_check__(int *err, char *call, char *key, int lencall, int lenkey);
-void grib_f_check(int *err, char *call, char *key, int lencall, int lenkey);
-int grib_f_write_(int *gid, int *fid);
-int grib_f_write__(int *gid, int *fid);
-int grib_f_write(int *gid, int *fid);
-int grib_f_multi_write_(int *gid, int *fid);
-int grib_f_multi_write__(int *gid, int *fid);
-int grib_f_multi_write(int *gid, int *fid);
-int grib_f_multi_append_(int *ingid, int *sec, int *mgid);
-int grib_f_multi_append(int *ingid, int *sec, int *mgid);
-int grib_f_multi_append__(int *ingid, int *sec, int *mgid);
-
-int codes_f_bufr_copy_data(int* gid1,int* gid2);
-int codes_f_bufr_copy_data_(int* gid1,int* gid2);
-int codes_f_bufr_copy_data__(int* gid1,int* gid2);
-
-int codes_f_bufr_multi_element_constant_arrays_on_(void);
-int codes_f_bufr_multi_element_constant_arrays_on__(void);
-int codes_f_bufr_multi_element_constant_arrays_on(void);
-int codes_f_bufr_multi_element_constant_arrays_off_(void);
-int codes_f_bufr_multi_element_constant_arrays_off__(void);
-int codes_f_bufr_multi_element_constant_arrays_off(void);
-
-int grib_f_set_definitions_path_(char *path, int len);
-int grib_f_set_definitions_path__(char *path, int len);
-int grib_f_set_definitions_path(char *path, int len);
-int grib_f_set_samples_path_(char *path, int len);
-int grib_f_set_samples_path__(char *path, int len);
-int grib_f_set_samples_path(char *path, int len);
-
-int grib_f_julian_to_datetime(double* jd,long* year,long* month,long* day,long *hour,long *minute,long *second);
-int grib_f_julian_to_datetime_(double* jd,long* year,long* month,long* day,long *hour,long *minute,long *second);
-int grib_f_julian_to_datetime__(double* jd,long* year,long* month,long* day,long *hour,long *minute,long *second);
-
-int grib_f_datetime_to_julian(long* year,long* month,long* day, long* hour,long* minute,long* second,double* jd);
-int grib_f_datetime_to_julian_(long* year,long* month,long* day, long* hour,long* minute,long* second,double* jd);
-int grib_f_datetime_to_julian__(long* year,long* month,long* day, long* hour,long* minute,long* second,double* jd);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/samples/hdf5.tmpl b/samples/hdf5.tmpl
new file mode 100644
index 000000000..a517bc7dd
Binary files /dev/null and b/samples/hdf5.tmpl differ
diff --git a/src/action_class_hash_array.cc b/src/action_class_hash_array.cc
index 45223de76..b01077870 100644
--- a/src/action_class_hash_array.cc
+++ b/src/action_class_hash_array.cc
@@ -286,6 +286,12 @@ static grib_hash_array_value* get_hash_array_impl(grib_handle* h, grib_action* a
full = grib_context_full_defs_path(context, master);
if (c) {
+ if (!full) {
+ grib_context_log(context, GRIB_LOG_ERROR,
+ "unable to find definition file %s in %s:%s:%s\nDefinition files path=\"%s\"",
+ self->basename, master, ecmf, local, context->grib_definition_files_path);
+ return NULL;
+ }
grib_hash_array_value* last = c;
while (last->next)
last = last->next;
diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h
index c6e6e9e17..aba20c9b4 100644
--- a/src/eccodes_prototypes.h
+++ b/src/eccodes_prototypes.h
@@ -801,7 +801,7 @@ void grib_grow_buffer(const grib_context* c, grib_buffer* b, size_t new_size);
void grib_buffer_set_ulength_bits(const grib_context* c, grib_buffer* b, size_t length_bits);
void grib_buffer_set_ulength(const grib_context* c, grib_buffer* b, size_t length);
void grib_recompute_sections_lengths(grib_section* s);
-void grib_buffer_replace(grib_accessor* a, const unsigned char* data, size_t newsize, int update_lengths, int update_paddings);
+int grib_buffer_replace(grib_accessor* a, const unsigned char* data, size_t newsize, int update_lengths, int update_paddings);
void grib_update_sections_lengths(grib_handle* h);
/* grib_dumper.cc*/
@@ -1020,8 +1020,6 @@ int wmo_read_any_from_file(FILE* f, void* buffer, size_t* len);
int wmo_read_grib_from_file(FILE* f, void* buffer, size_t* len);
int wmo_read_bufr_from_file(FILE* f, void* buffer, size_t* len);
int wmo_read_gts_from_file(FILE* f, void* buffer, size_t* len);
-int wmo_read_taf_from_file(FILE* f, void* buffer, size_t* len);
-int wmo_read_metar_from_file(FILE* f, void* buffer, size_t* len);
int wmo_read_any_from_file_fast(FILE* f, size_t* msg_len, off_t* msg_offset);
int wmo_read_grib_from_file_fast(FILE* f, size_t* msg_len, off_t* msg_offset);
int wmo_read_bufr_from_file_fast(FILE* f, size_t* msg_len, off_t* msg_offset);
@@ -1162,8 +1160,6 @@ int grib_set_float_array(grib_handle* h, const char* name, const float* val, siz
int grib_set_long_array_internal(grib_handle* h, const char* name, const long* val, size_t length);
int grib_set_long_array(grib_handle* h, const char* name, const long* val, size_t length);
int grib_get_long_internal(grib_handle* h, const char* name, long* val);
-int grib_is_in_dump(const grib_handle* h, const char* name);
-int grib_attributes_count(const grib_accessor* a, size_t* size);
int grib_get_long(const grib_handle* h, const char* name, long* val);
int grib_get_double_internal(grib_handle* h, const char* name, double* val);
int grib_get_double(const grib_handle* h, const char* name, double* val);
@@ -1201,9 +1197,6 @@ int grib_get_string_array(const grib_handle* h, const char* name, char** val, si
int ecc__grib_get_long_array_internal(const grib_handle* h, grib_accessor* a, long* val, size_t buffer_len, size_t* decoded_length);
int grib_get_long_array_internal(grib_handle* h, const char* name, long* val, size_t* length);
int grib_get_long_array(const grib_handle* h, const char* name, long* val, size_t* length);
-grib_key_value_list* grib_key_value_list_clone(grib_context* c, grib_key_value_list* list);
-void grib_key_value_list_delete(grib_context* c, grib_key_value_list* kvl);
-int grib_get_key_value_list(grib_handle* h, grib_key_value_list* list);
int grib_get_values(grib_handle* h, grib_values* args, size_t count);
int grib_set_values(grib_handle* h, grib_values* args, size_t count);
int grib_get_nearest_smaller_value(grib_handle* h, const char* name, double val, double* nearest);
diff --git a/src/grib_accessor_class.cc b/src/grib_accessor_class.cc
index 06da7e830..524e40ecf 100644
--- a/src/grib_accessor_class.cc
+++ b/src/grib_accessor_class.cc
@@ -322,7 +322,8 @@ int grib_section_adjust_sizes(grib_section* s, int update, int depth)
if (update) {
plen = length;
lret = grib_pack_long(s->aclength, &plen, &len);
- Assert(lret == GRIB_SUCCESS);
+ if (lret != GRIB_SUCCESS)
+ return lret;
s->padding = 0;
}
else {
diff --git a/src/grib_accessor_class_bufr_data_array.cc b/src/grib_accessor_class_bufr_data_array.cc
index 50978b06f..ec0baa494 100644
--- a/src/grib_accessor_class_bufr_data_array.cc
+++ b/src/grib_accessor_class_bufr_data_array.cc
@@ -23,7 +23,6 @@
IMPLEMENTS = byte_count; value_count
IMPLEMENTS = byte_offset; unpack_double
IMPLEMENTS = get_native_type
- IMPLEMENTS = compare
IMPLEMENTS = pack_long; unpack_double; pack_double
MEMBERS = const char* bufrDataEncodedName
MEMBERS = const char* numberOfSubsetsName
@@ -98,7 +97,6 @@ static int value_count(grib_accessor*, long*);
static void destroy(grib_context*, grib_accessor*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
-static int compare(grib_accessor*, grib_accessor*);
typedef struct grib_accessor_bufr_data_array
{
@@ -194,7 +192,7 @@ static grib_accessor_class _grib_accessor_class_bufr_data_array = {
0, /* resize */
0, /* nearest_smaller_value */
0, /* next accessor */
- &compare, /* compare vs. another accessor */
+ 0, /* compare vs. another accessor */
0, /* unpack only ith value (double) */
0, /* unpack only ith value (float) */
0, /* unpack a given set of elements (double) */
@@ -474,11 +472,6 @@ static long next_offset(grib_accessor* a)
return a->offset;
}
-static int compare(grib_accessor* a, grib_accessor* b)
-{
- return GRIB_NOT_IMPLEMENTED;
-}
-
static int pack_long(grib_accessor* a, const long* val, size_t* len)
{
grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a;
diff --git a/src/grib_accessor_class_codetable.cc b/src/grib_accessor_class_codetable.cc
index 1fc92e785..d450ffd97 100644
--- a/src/grib_accessor_class_codetable.cc
+++ b/src/grib_accessor_class_codetable.cc
@@ -222,7 +222,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* params)
p = grib_expression_evaluate_string(grib_handle_of_accessor(a), expression, tmp, &s_len, &ret);
if (ret != GRIB_SUCCESS) {
grib_context_log(a->context, GRIB_LOG_FATAL,
- "unable to evaluate %s as string", a->name);
+ "Unable to evaluate %s as string", a->name);
}
s_len = strlen(p) + 1;
pack_string(a, p, &s_len);
@@ -843,7 +843,7 @@ static int pack_expression(grib_accessor* a, grib_expression* e)
if (strcmp(e->cclass->name, "long") == 0) {
grib_expression_evaluate_long(hand, e, &lval); /* TDOD: check return value */
- /*if (hand->context->debug) printf("ECCODES DEBUG grib_accessor_class_codetable::pack_expression %s %ld\n", a->name,lval);*/
+ //if (hand->context->debug) printf("ECCODES DEBUG grib_accessor_class_codetable::pack_expression %s %ld\n", a->name,lval);
ret = grib_pack_long(a, &lval, &len);
}
else {
@@ -851,12 +851,14 @@ static int pack_expression(grib_accessor* a, grib_expression* e)
len = sizeof(tmp);
cval = grib_expression_evaluate_string(hand, e, tmp, &len, &ret);
if (ret != GRIB_SUCCESS) {
- grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_codetable.pack_expression: unable to evaluate string %s to be set in %s\n", grib_expression_get_name(e), a->name);
+ grib_context_log(a->context, GRIB_LOG_ERROR,
+ "grib_accessor_codetable.%s: Unable to evaluate string %s to be set in %s",
+ __func__, grib_expression_get_name(e), a->name);
return ret;
}
len = strlen(cval) + 1;
- /*if (hand->context->debug)
- printf("ECCODES DEBUG grib_accessor_class_codetable::pack_expression %s %s\n", a->name, cval);*/
+ //if (hand->context->debug)
+ // printf("ECCODES DEBUG grib_accessor_class_codetable::pack_expression %s %s\n", a->name, cval);
ret = grib_pack_string(a, cval, &len);
}
return ret;
diff --git a/src/grib_accessor_class_data_g1simple_packing.cc b/src/grib_accessor_class_data_g1simple_packing.cc
index 0541388f6..c863f7595 100644
--- a/src/grib_accessor_class_data_g1simple_packing.cc
+++ b/src/grib_accessor_class_data_g1simple_packing.cc
@@ -313,7 +313,8 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len)
grib_context_log(a->context, GRIB_LOG_DEBUG,
"grib_accessor_data_g1simple_packing : pack_double : packing %s, %d values", a->name, n_vals);
- grib_buffer_replace(a, buf, buflen, 1, 1);
+ ret = grib_buffer_replace(a, buf, buflen, 1, 1);
+ if (ret != GRIB_SUCCESS) return ret;
grib_context_buffer_free(a->context, buf);
diff --git a/src/grib_accessor_class_data_g2secondary_bitmap.cc b/src/grib_accessor_class_data_g2secondary_bitmap.cc
index ee9f8f0be..7511b78cf 100644
--- a/src/grib_accessor_class_data_g2secondary_bitmap.cc
+++ b/src/grib_accessor_class_data_g2secondary_bitmap.cc
@@ -108,35 +108,27 @@ grib_accessor_class* grib_accessor_class_data_g2secondary_bitmap = &_grib_access
static void init(grib_accessor* a, const long v, grib_arguments* args)
{
grib_accessor_data_g2secondary_bitmap* self = (grib_accessor_data_g2secondary_bitmap*)a;
- self->number_of_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, 4);
+ self->number_of_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, 4);
}
static int value_count(grib_accessor* a, long* len)
{
grib_accessor_data_g2secondary_bitmap* self = (grib_accessor_data_g2secondary_bitmap*)a;
- *len = 0;
-
+ *len = 0;
return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, len);
}
static int pack_double(grib_accessor* a, const double* val, size_t* len)
{
grib_accessor_data_g2secondary_bitmap* self = (grib_accessor_data_g2secondary_bitmap*)a;
-
int err = 0;
- long primary_len = 0;
- long secondary_len = 0;
+ long primary_len = 0, secondary_len = 0;
double* primary_bitmap = NULL;
double* secondary_bitmap = NULL;
- long i = 0;
- long j = 0;
- long on = 0;
- long k;
- long m;
- double missing_value = 0;
- double present_value = 0;
- long expand_by = 0;
+ long i = 0, j = 0, on = 0, k = 0, m = 0;
+ double missing_value = 0, present_value = 0;
+ long expand_by = 0;
if (*len == 0)
return GRIB_NO_VALUES;
diff --git a/src/grib_accessor_class_g1_half_byte_codeflag.cc b/src/grib_accessor_class_g1_half_byte_codeflag.cc
index 522eb9ee1..c275253e5 100644
--- a/src/grib_accessor_class_g1_half_byte_codeflag.cc
+++ b/src/grib_accessor_class_g1_half_byte_codeflag.cc
@@ -19,7 +19,6 @@
IMPLEMENTS = unpack_long;pack_long
IMPLEMENTS = init;dump
IMPLEMENTS = get_native_type
- IMPLEMENTS = compare
END_CLASS_DEF
*/
@@ -39,7 +38,6 @@ static int pack_long(grib_accessor*, const long* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
-static int compare(grib_accessor*, grib_accessor*);
typedef struct grib_accessor_g1_half_byte_codeflag
{
@@ -88,7 +86,7 @@ static grib_accessor_class _grib_accessor_class_g1_half_byte_codeflag = {
0, /* resize */
0, /* nearest_smaller_value */
0, /* next accessor */
- &compare, /* compare vs. another accessor */
+ 0, /* compare vs. another accessor */
0, /* unpack only ith value (double) */
0, /* unpack only ith value (float) */
0, /* unpack a given set of elements (double) */
@@ -150,34 +148,3 @@ static int get_native_type(grib_accessor* a)
{
return GRIB_TYPE_LONG;
}
-
-static int compare(grib_accessor* a, grib_accessor* b)
-{
- long aval = 0;
- long bval = 0;
-
- long count = 0;
- size_t alen = 0;
- size_t blen = 0;
- int err = 0;
-
- err = grib_value_count(a, &count);
- if (err)
- return err;
- alen = count;
-
- err = grib_value_count(b, &count);
- if (err)
- return err;
- blen = count;
-
- if (alen != 1 || blen != 1)
- return GRIB_COUNT_MISMATCH;
-
- grib_unpack_long(a, &aval, &alen);
- grib_unpack_long(b, &bval, &blen);
-
- if (bval != aval)
- return GRIB_VALUE_MISMATCH;
- return GRIB_SUCCESS;
-}
diff --git a/src/grib_accessor_class_g1_message_length.cc b/src/grib_accessor_class_g1_message_length.cc
index adff03efe..44e2f84bc 100644
--- a/src/grib_accessor_class_g1_message_length.cc
+++ b/src/grib_accessor_class_g1_message_length.cc
@@ -203,7 +203,15 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
grib_find_accessor(grib_handle_of_accessor(a), self->sec4_length),
&total_length,
&sec4_length);
-
+ if (total_length != *val) {
+ const char* cclass_name = a->cclass->name;
+ grib_context_log(a->context, GRIB_LOG_ERROR,
+ "%s %s: Failed to set GRIB1 message length to %ld"
+ " (actual length=%ld)",
+ cclass_name, __func__, *val, total_length);
+ grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try encoding as GRIB2\n");
+ return GRIB_ENCODING_ERROR;
+ }
Assert(total_length == *val);
}
diff --git a/src/grib_accessor_class_g1bitmap.cc b/src/grib_accessor_class_g1bitmap.cc
index bfa835f01..b624d4dbe 100644
--- a/src/grib_accessor_class_g1bitmap.cc
+++ b/src/grib_accessor_class_g1bitmap.cc
@@ -149,7 +149,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->unusedBits, tlen * 8 - *len)) != GRIB_SUCCESS)
return err;
- grib_buffer_replace(a, buf, tlen, 1, 1);
+ err = grib_buffer_replace(a, buf, tlen, 1, 1);
+ if (err) return err;
grib_context_free(a->context, buf);
diff --git a/src/grib_accessor_class_gen.cc b/src/grib_accessor_class_gen.cc
index 5d2e16c3c..30d37f729 100644
--- a/src/grib_accessor_class_gen.cc
+++ b/src/grib_accessor_class_gen.cc
@@ -484,7 +484,7 @@ static int pack_double_array_as_long(grib_accessor* a, const double* v, size_t*
size_t numBytes = *len * (sizeof(long));
long* lValues = (long*)grib_context_malloc(c, numBytes);
if (!lValues) {
- grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %ld bytes\n", numBytes);
+ grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %ld bytes", numBytes);
return GRIB_OUT_OF_MEMORY;
}
for (i = 0; i < *len; i++)
diff --git a/src/grib_accessor_class_label.cc b/src/grib_accessor_class_label.cc
index c5958dd98..8d7831faf 100644
--- a/src/grib_accessor_class_label.cc
+++ b/src/grib_accessor_class_label.cc
@@ -16,7 +16,6 @@
CLASS = accessor
SUPER = grib_accessor_class_gen
IMPLEMENTS = init;dump;get_native_type;unpack_string
- IMPLEMENTS = compare
END_CLASS_DEF
*/
@@ -35,7 +34,6 @@ static int get_native_type(grib_accessor*);
static int unpack_string(grib_accessor*, char*, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
-static int compare(grib_accessor*, grib_accessor*);
typedef struct grib_accessor_label
{
@@ -84,7 +82,7 @@ static grib_accessor_class _grib_accessor_class_label = {
0, /* resize */
0, /* nearest_smaller_value */
0, /* next accessor */
- &compare, /* compare vs. another accessor */
+ 0, /* compare vs. another accessor */
0, /* unpack only ith value (double) */
0, /* unpack only ith value (float) */
0, /* unpack a given set of elements (double) */
@@ -116,11 +114,6 @@ static int get_native_type(grib_accessor* a)
return GRIB_TYPE_LABEL;
}
-static int compare(grib_accessor* a, grib_accessor* b)
-{
- return GRIB_SUCCESS;
-}
-
static int unpack_string(grib_accessor* a, char* val, size_t* len)
{
size_t vlen = strlen(a->name);
diff --git a/src/grib_accessor_class_message.cc b/src/grib_accessor_class_message.cc
index 6a87d00e5..1334209dc 100644
--- a/src/grib_accessor_class_message.cc
+++ b/src/grib_accessor_class_message.cc
@@ -8,10 +8,6 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
-/**************************************
- * Enrico Fucile
- **************************************/
-
#include "grib_api_internal.h"
/*
This is used by make_class.pl
@@ -21,7 +17,6 @@
SUPER = grib_accessor_class_bytes
IMPLEMENTS = init;update_size;resize; value_count
IMPLEMENTS = unpack_string; string_length
- IMPLEMENTS = compare
END_CLASS_DEF
*/
@@ -42,7 +37,6 @@ static int value_count(grib_accessor*, long*);
static void init(grib_accessor*, const long, grib_arguments*);
static void update_size(grib_accessor*, size_t);
static void resize(grib_accessor*,size_t);
-static int compare(grib_accessor*, grib_accessor*);
typedef struct grib_accessor_message
{
@@ -92,7 +86,7 @@ static grib_accessor_class _grib_accessor_class_message = {
&resize, /* resize */
0, /* nearest_smaller_value */
0, /* next accessor */
- &compare, /* compare vs. another accessor */
+ 0, /* compare vs. another accessor */
0, /* unpack only ith value (double) */
0, /* unpack only ith value (float) */
0, /* unpack a given set of elements (double) */
@@ -115,12 +109,12 @@ static void init(grib_accessor* a, const long len, grib_arguments* arg)
a->length = grib_handle_of_accessor(a)->buffer->ulength - len - a->offset;
}
-static int compare(grib_accessor* a, grib_accessor* b)
-{
- if (a->length != b->length)
- return GRIB_COUNT_MISMATCH;
- return GRIB_SUCCESS;
-}
+// static int compare(grib_accessor* a, grib_accessor* b)
+// {
+// if (a->length != b->length)
+// return GRIB_COUNT_MISMATCH;
+// return GRIB_SUCCESS;
+// }
static void update_size(grib_accessor* a, size_t new_size)
{
diff --git a/src/grib_accessor_class_message_copy.cc b/src/grib_accessor_class_message_copy.cc
index 4b3df8857..30806b163 100644
--- a/src/grib_accessor_class_message_copy.cc
+++ b/src/grib_accessor_class_message_copy.cc
@@ -133,6 +133,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
if (v[i] > 126)
v[i] = 32;
memcpy(val, grib_handle_of_accessor(a)->buffer->data, slen);
+ val[i] = 0;
*len = slen;
diff --git a/src/grib_accessor_class_non_alpha.cc b/src/grib_accessor_class_non_alpha.cc
index e0f52f4d9..55ee9f917 100644
--- a/src/grib_accessor_class_non_alpha.cc
+++ b/src/grib_accessor_class_non_alpha.cc
@@ -15,14 +15,13 @@
START_CLASS_DEF
CLASS = accessor
SUPER = grib_accessor_class_gen
- IMPLEMENTS = unpack_string;pack_string
- IMPLEMENTS = unpack_long;pack_long
- IMPLEMENTS = unpack_double;pack_double
+ IMPLEMENTS = unpack_string
+ IMPLEMENTS = unpack_long
+ IMPLEMENTS = unpack_double
IMPLEMENTS = init;dump;string_length
IMPLEMENTS = value_count
IMPLEMENTS = next_offset
IMPLEMENTS = get_native_type
- IMPLEMENTS = compare
END_CLASS_DEF
*/
@@ -38,9 +37,6 @@ or edit "accessor.class" and rerun ./make_class.pl
*/
static int get_native_type(grib_accessor*);
-static int pack_double(grib_accessor*, const double* val, size_t* len);
-static int pack_long(grib_accessor*, const long* val, size_t* len);
-static int pack_string(grib_accessor*, const char*, size_t* len);
static int unpack_double(grib_accessor*, double* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static int unpack_string(grib_accessor*, char*, size_t* len);
@@ -49,7 +45,6 @@ static long next_offset(grib_accessor*);
static int value_count(grib_accessor*, long*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
-static int compare(grib_accessor*, grib_accessor*);
typedef struct grib_accessor_non_alpha
{
@@ -79,13 +74,13 @@ static grib_accessor_class _grib_accessor_class_non_alpha = {
0, /* get sub_section */
0, /* pack_missing */
0, /* is_missing */
- &pack_long, /* pack_long */
+ 0, /* pack_long */
&unpack_long, /* unpack_long */
- &pack_double, /* pack_double */
+ 0, /* pack_double */
0, /* pack_float */
&unpack_double, /* unpack_double */
0, /* unpack_float */
- &pack_string, /* pack_string */
+ 0, /* pack_string */
&unpack_string, /* unpack_string */
0, /* pack_string_array */
0, /* unpack_string_array */
@@ -98,7 +93,7 @@ static grib_accessor_class _grib_accessor_class_non_alpha = {
0, /* resize */
0, /* nearest_smaller_value */
0, /* next accessor */
- &compare, /* compare vs. another accessor */
+ 0, /* compare vs. another accessor */
0, /* unpack only ith value (double) */
0, /* unpack only ith value (float) */
0, /* unpack a given set of elements (double) */
@@ -171,23 +166,6 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
return GRIB_SUCCESS;
}
-static int pack_string(grib_accessor* a, const char* val, size_t* len)
-{
- return GRIB_NOT_IMPLEMENTED;
-}
-
-static int pack_long(grib_accessor* a, const long* v, size_t* len)
-{
- grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as an integer", a->name);
- return GRIB_NOT_IMPLEMENTED;
-}
-
-static int pack_double(grib_accessor* a, const double* v, size_t* len)
-{
- grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as a double", a->name);
- return GRIB_NOT_IMPLEMENTED;
-}
-
static int unpack_long(grib_accessor* a, long* v, size_t* len)
{
char val[1024] = {0,};
@@ -233,46 +211,6 @@ static int unpack_double(grib_accessor* a, double* v, size_t* len)
return GRIB_NOT_IMPLEMENTED;
}
-static int compare(grib_accessor* a, grib_accessor* b)
-{
- int retval = 0;
- char* aval = 0;
- char* bval = 0;
- int err = 0;
-
- size_t alen = 0;
- size_t blen = 0;
- long count = 0;
-
- err = grib_value_count(a, &count);
- if (err)
- return err;
- alen = count;
-
- err = grib_value_count(b, &count);
- if (err)
- return err;
- blen = count;
-
- if (alen != blen)
- return GRIB_COUNT_MISMATCH;
-
- aval = (char*)grib_context_malloc(a->context, alen * sizeof(char));
- bval = (char*)grib_context_malloc(b->context, blen * sizeof(char));
-
- grib_unpack_string(a, aval, &alen);
- grib_unpack_string(b, bval, &blen);
-
- retval = GRIB_SUCCESS;
- if (strcmp(aval, bval))
- retval = GRIB_STRING_VALUE_MISMATCH;
-
- grib_context_free(a->context, aval);
- grib_context_free(b->context, bval);
-
- return retval;
-}
-
static long next_offset(grib_accessor* a)
{
return a->offset + a->length;
diff --git a/src/grib_accessor_class_number_of_points.cc b/src/grib_accessor_class_number_of_points.cc
index 6a270bb69..b3d1eade2 100644
--- a/src/grib_accessor_class_number_of_points.cc
+++ b/src/grib_accessor_class_number_of_points.cc
@@ -110,12 +110,14 @@ grib_accessor_class* grib_accessor_class_number_of_points = &_grib_accessor_clas
static void init(grib_accessor* a, const long l, grib_arguments* c)
{
- int n = 0;
+ int n = 0;
+ grib_handle* hand = grib_handle_of_accessor(a);
+
grib_accessor_number_of_points* self = (grib_accessor_number_of_points*)a;
- self->ni = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
- self->nj = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
- self->plpresent = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
- self->pl = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
+ self->ni = grib_arguments_get_name(hand, c, n++);
+ self->nj = grib_arguments_get_name(hand, c, n++);
+ self->plpresent = grib_arguments_get_name(hand, c, n++);
+ self->pl = grib_arguments_get_name(hand, c, n++);
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION;
a->length = 0;
@@ -123,32 +125,41 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
+ grib_accessor_number_of_points* self = (grib_accessor_number_of_points*)a;
+
int ret = GRIB_SUCCESS;
long ni = 0, nj = 0, plpresent = 0;
size_t plsize = 0;
- long* pl;
- int i;
- grib_accessor_number_of_points* self = (grib_accessor_number_of_points*)a;
- grib_context* c = a->context;
+ long* pl = NULL;
+ int i = 0;
+ grib_context* c = a->context;
+ grib_handle* hand = grib_handle_of_accessor(a);
- if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->ni, &ni)) != GRIB_SUCCESS)
+ if ((ret = grib_get_long_internal(hand, self->ni, &ni)) != GRIB_SUCCESS)
return ret;
- if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->nj, &nj)) != GRIB_SUCCESS)
+ if ((ret = grib_get_long_internal(hand, self->nj, &nj)) != GRIB_SUCCESS)
return ret;
if (self->plpresent &&
- ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->plpresent, &plpresent)) != GRIB_SUCCESS))
+ ((ret = grib_get_long_internal(hand, self->plpresent, &plpresent)) != GRIB_SUCCESS))
return ret;
- if (nj == 0)
+ if (grib_is_missing(hand, self->nj, &ret) && ret == GRIB_SUCCESS) {
+ grib_context_log(c, GRIB_LOG_ERROR, "grib_accessor_class_number_of_points: Key %s cannot be 'missing'!", self->nj);
return GRIB_GEOCALCULUS_PROBLEM;
+ }
+
+ if (nj == 0) {
+ grib_context_log(c, GRIB_LOG_ERROR, "grib_accessor_class_number_of_points: Key %s cannot be 0!", self->nj);
+ return GRIB_GEOCALCULUS_PROBLEM;
+ }
if (plpresent) {
/*reduced*/
plsize = nj;
pl = (long*)grib_context_malloc(c, sizeof(long) * plsize);
- grib_get_long_array_internal(grib_handle_of_accessor(a), self->pl, pl, &plsize);
+ grib_get_long_array_internal(hand, self->pl, pl, &plsize);
*val = 0;
for (i = 0; i < plsize; i++)
*val += pl[i];
diff --git a/src/grib_accessor_class_position.cc b/src/grib_accessor_class_position.cc
index 1aef0a94f..0f9565c37 100644
--- a/src/grib_accessor_class_position.cc
+++ b/src/grib_accessor_class_position.cc
@@ -8,11 +8,6 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
-/**************************************
- * Enrico Fucile
- **************************************/
-
-
#include "grib_api_internal.h"
/*
This is used by make_class.pl
@@ -23,7 +18,6 @@
IMPLEMENTS = unpack_long
IMPLEMENTS = get_native_type
IMPLEMENTS = init;dump
- IMPLEMENTS = compare
END_CLASS_DEF
*/
@@ -42,7 +36,6 @@ static int get_native_type(grib_accessor*);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
-static int compare(grib_accessor*, grib_accessor*);
typedef struct grib_accessor_position
{
@@ -91,7 +84,7 @@ static grib_accessor_class _grib_accessor_class_position = {
0, /* resize */
0, /* nearest_smaller_value */
0, /* next accessor */
- &compare, /* compare vs. another accessor */
+ 0, /* compare vs. another accessor */
0, /* unpack only ith value (double) */
0, /* unpack only ith value (float) */
0, /* unpack a given set of elements (double) */
@@ -136,9 +129,9 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
return GRIB_SUCCESS;
}
-static int compare(grib_accessor* a, grib_accessor* b)
-{
- if (a->offset != b->offset)
- return GRIB_OFFSET_MISMATCH;
- return GRIB_SUCCESS;
-}
+// static int compare(grib_accessor* a, grib_accessor* b)
+// {
+// if (a->offset != b->offset)
+// return GRIB_OFFSET_MISMATCH;
+// return GRIB_SUCCESS;
+// }
diff --git a/src/grib_accessor_class_to_double.cc b/src/grib_accessor_class_to_double.cc
index d0d4351c5..3f04524c6 100644
--- a/src/grib_accessor_class_to_double.cc
+++ b/src/grib_accessor_class_to_double.cc
@@ -22,7 +22,6 @@
IMPLEMENTS = value_count
IMPLEMENTS = next_offset
IMPLEMENTS = get_native_type
- IMPLEMENTS = compare
MEMBERS = const char* key
MEMBERS = long start
MEMBERS = size_t length
@@ -50,7 +49,6 @@ static long next_offset(grib_accessor*);
static int value_count(grib_accessor*, long*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
-static int compare(grib_accessor*, grib_accessor*);
typedef struct grib_accessor_to_double
{
@@ -103,7 +101,7 @@ static grib_accessor_class _grib_accessor_class_to_double = {
0, /* resize */
0, /* nearest_smaller_value */
0, /* next accessor */
- &compare, /* compare vs. another accessor */
+ 0, /* compare vs. another accessor */
0, /* unpack only ith value (double) */
0, /* unpack only ith value (float) */
0, /* unpack a given set of elements (double) */
@@ -242,43 +240,3 @@ static long next_offset(grib_accessor* a)
{
return a->offset + a->length;
}
-
-static int compare(grib_accessor* a, grib_accessor* b)
-{
- int retval = 0;
- char* aval = 0;
- char* bval = 0;
- int err = 0;
-
- size_t alen = 0;
- size_t blen = 0;
- long count = 0;
-
- err = grib_value_count(a, &count);
- if (err)
- return err;
- alen = count;
-
- err = grib_value_count(b, &count);
- if (err)
- return err;
- blen = count;
-
- if (alen != blen)
- return GRIB_COUNT_MISMATCH;
-
- aval = (char*)grib_context_malloc(a->context, alen * sizeof(char));
- bval = (char*)grib_context_malloc(b->context, blen * sizeof(char));
-
- grib_unpack_string(a, aval, &alen);
- grib_unpack_string(b, bval, &blen);
-
- retval = GRIB_SUCCESS;
- if (strcmp(aval, bval))
- retval = GRIB_STRING_VALUE_MISMATCH;
-
- grib_context_free(a->context, aval);
- grib_context_free(b->context, bval);
-
- return retval;
-}
diff --git a/src/grib_accessor_class_to_integer.cc b/src/grib_accessor_class_to_integer.cc
index 30fa00251..787b122b8 100644
--- a/src/grib_accessor_class_to_integer.cc
+++ b/src/grib_accessor_class_to_integer.cc
@@ -22,7 +22,6 @@
IMPLEMENTS = value_count
IMPLEMENTS = next_offset
IMPLEMENTS = get_native_type
- IMPLEMENTS = compare
MEMBERS = const char* key
MEMBERS = long start
MEMBERS = size_t length
@@ -52,7 +51,6 @@ static long next_offset(grib_accessor*);
static int value_count(grib_accessor*, long*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
-static int compare(grib_accessor*, grib_accessor*);
typedef struct grib_accessor_to_integer
{
@@ -104,7 +102,7 @@ static grib_accessor_class _grib_accessor_class_to_integer = {
0, /* resize */
0, /* nearest_smaller_value */
0, /* next accessor */
- &compare, /* compare vs. another accessor */
+ 0, /* compare vs. another accessor */
0, /* unpack only ith value (double) */
0, /* unpack only ith value (float) */
0, /* unpack a given set of elements (double) */
@@ -239,46 +237,6 @@ static int unpack_double(grib_accessor* a, double* v, size_t* len)
return err;
}
-static int compare(grib_accessor* a, grib_accessor* b)
-{
- int retval = 0;
- char* aval = 0;
- char* bval = 0;
- int err = 0;
-
- size_t alen = 0;
- size_t blen = 0;
- long count = 0;
-
- err = grib_value_count(a, &count);
- if (err)
- return err;
- alen = count;
-
- err = grib_value_count(b, &count);
- if (err)
- return err;
- blen = count;
-
- if (alen != blen)
- return GRIB_COUNT_MISMATCH;
-
- aval = (char*)grib_context_malloc(a->context, alen * sizeof(char));
- bval = (char*)grib_context_malloc(b->context, blen * sizeof(char));
-
- grib_unpack_string(a, aval, &alen);
- grib_unpack_string(b, bval, &blen);
-
- retval = GRIB_SUCCESS;
- if (strcmp(aval, bval))
- retval = GRIB_STRING_VALUE_MISMATCH;
-
- grib_context_free(a->context, aval);
- grib_context_free(b->context, bval);
-
- return retval;
-}
-
static long next_offset(grib_accessor* a)
{
return a->offset + a->length;
diff --git a/src/grib_accessor_class_to_string.cc b/src/grib_accessor_class_to_string.cc
index ce8bf4e74..818ad386d 100644
--- a/src/grib_accessor_class_to_string.cc
+++ b/src/grib_accessor_class_to_string.cc
@@ -22,7 +22,6 @@
IMPLEMENTS = value_count
IMPLEMENTS = next_offset
IMPLEMENTS = get_native_type
- IMPLEMENTS = compare
MEMBERS = const char* key
MEMBERS = long start
MEMBERS = size_t length
@@ -49,7 +48,6 @@ static long next_offset(grib_accessor*);
static int value_count(grib_accessor*, long*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
-static int compare(grib_accessor*, grib_accessor*);
typedef struct grib_accessor_to_string
{
@@ -101,7 +99,7 @@ static grib_accessor_class _grib_accessor_class_to_string = {
0, /* resize */
0, /* nearest_smaller_value */
0, /* next accessor */
- &compare, /* compare vs. another accessor */
+ 0, /* compare vs. another accessor */
0, /* unpack only ith value (double) */
0, /* unpack only ith value (float) */
0, /* unpack a given set of elements (double) */
@@ -221,46 +219,6 @@ static int unpack_double(grib_accessor* a, double* v, size_t* len)
return err;
}
-static int compare(grib_accessor* a, grib_accessor* b)
-{
- int retval = 0;
- char* aval = 0;
- char* bval = 0;
- int err = 0;
-
- size_t alen = 0;
- size_t blen = 0;
- long count = 0;
-
- err = grib_value_count(a, &count);
- if (err)
- return err;
- alen = count;
-
- err = grib_value_count(b, &count);
- if (err)
- return err;
- blen = count;
-
- if (alen != blen)
- return GRIB_COUNT_MISMATCH;
-
- aval = (char*)grib_context_malloc(a->context, alen * sizeof(char));
- bval = (char*)grib_context_malloc(b->context, blen * sizeof(char));
-
- grib_unpack_string(a, aval, &alen);
- grib_unpack_string(b, bval, &blen);
-
- retval = GRIB_SUCCESS;
- if (strcmp(aval, bval))
- retval = GRIB_STRING_VALUE_MISMATCH;
-
- grib_context_free(a->context, aval);
- grib_context_free(b->context, bval);
-
- return retval;
-}
-
static long next_offset(grib_accessor* a)
{
return a->offset + a->length;
diff --git a/src/grib_accessor_class_transient_darray.cc b/src/grib_accessor_class_transient_darray.cc
index 9a316459b..ba830849a 100644
--- a/src/grib_accessor_class_transient_darray.cc
+++ b/src/grib_accessor_class_transient_darray.cc
@@ -19,7 +19,7 @@
IMPLEMENTS = unpack_double;pack_double
IMPLEMENTS = unpack_long;pack_long;destroy
IMPLEMENTS = init;dump;value_count
- IMPLEMENTS = compare;get_native_type
+ IMPLEMENTS = get_native_type
MEMBERS=grib_darray* arr
MEMBERS=int type;
END_CLASS_DEF
@@ -45,7 +45,6 @@ static int value_count(grib_accessor*, long*);
static void destroy(grib_context*, grib_accessor*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
-static int compare(grib_accessor*, grib_accessor*);
typedef struct grib_accessor_transient_darray
{
@@ -96,7 +95,7 @@ static grib_accessor_class _grib_accessor_class_transient_darray = {
0, /* resize */
0, /* nearest_smaller_value */
0, /* next accessor */
- &compare, /* compare vs. another accessor */
+ 0, /* compare vs. another accessor */
0, /* unpack only ith value (double) */
0, /* unpack only ith value (float) */
0, /* unpack a given set of elements (double) */
@@ -119,23 +118,20 @@ static void init(grib_accessor* a, const long length, grib_arguments* args)
a->length = 0;
}
-
static void dump(grib_accessor* a, grib_dumper* dumper)
{
- /* grib_accessor_transient_darray *self = (grib_accessor_transient_darray*)a; */
grib_dump_double(dumper, a, NULL);
}
static int pack_double(grib_accessor* a, const double* val, size_t* len)
{
grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a;
- size_t i;
if (self->arr)
grib_darray_delete(a->context, self->arr);
self->arr = grib_darray_new(a->context, *len, 10);
- for (i = 0; i < *len; i++)
+ for (size_t i = 0; i < *len; i++)
grib_darray_push(a->context, self->arr, val[i]);
return GRIB_SUCCESS;
@@ -144,13 +140,12 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
static int pack_long(grib_accessor* a, const long* val, size_t* len)
{
grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a;
- size_t i;
if (self->arr)
grib_darray_delete(a->context, self->arr);
self->arr = grib_darray_new(a->context, *len, 10);
- for (i = 0; i < *len; i++)
+ for (size_t i = 0; i < *len; i++)
grib_darray_push(a->context, self->arr, (double)val[i]);
return GRIB_SUCCESS;
@@ -159,8 +154,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
static int unpack_double(grib_accessor* a, double* val, size_t* len)
{
grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a;
- long count = 0;
- size_t i;
+ long count = 0;
value_count(a, &count);
@@ -170,17 +164,16 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
}
*len = count;
- for (i = 0; i < *len; i++)
+ for (size_t i = 0; i < *len; i++)
val[i] = self->arr->v[i];
-
return GRIB_SUCCESS;
}
+
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a;
- long count = 0;
- size_t i;
+ long count = 0;
value_count(a, &count);
@@ -190,14 +183,12 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
}
*len = count;
- for (i = 0; i < *len; i++)
+ for (size_t i = 0; i < *len; i++)
val[i] = (long)self->arr->v[i];
-
return GRIB_SUCCESS;
}
-
static void destroy(grib_context* c, grib_accessor* a)
{
grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a;
@@ -216,51 +207,8 @@ static int value_count(grib_accessor* a, long* count)
return 0;
}
-static int compare(grib_accessor* a, grib_accessor* b)
-{
- int retval = 0;
- double* aval = 0;
- double* bval = 0;
-
- size_t alen = 0;
- size_t blen = 0;
- int err = 0;
- long count = 0;
-
- err = grib_value_count(a, &count);
- if (err)
- return err;
- alen = count;
-
- err = grib_value_count(b, &count);
- if (err)
- return err;
- blen = count;
-
- if (alen != blen)
- return GRIB_COUNT_MISMATCH;
-
- aval = (double*)grib_context_malloc(a->context, alen * sizeof(double));
- bval = (double*)grib_context_malloc(b->context, blen * sizeof(double));
-
- grib_unpack_double(a, aval, &alen);
- grib_unpack_double(b, bval, &blen);
-
- retval = GRIB_SUCCESS;
- while (alen != 0) {
- if (*bval != *aval)
- retval = GRIB_DOUBLE_VALUE_MISMATCH;
- alen--;
- }
-
- grib_context_free(a->context, aval);
- grib_context_free(b->context, bval);
-
- return retval;
-}
-
static int get_native_type(grib_accessor* a)
{
- grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a;
+ const grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a;
return self->type;
}
diff --git a/src/grib_buffer.cc b/src/grib_buffer.cc
index 43e7f7bc3..525e59f31 100644
--- a/src/grib_buffer.cc
+++ b/src/grib_buffer.cc
@@ -195,8 +195,8 @@ static void update_offsets_after(grib_accessor* a, long len)
// update_sections_lengths(s->owner->parent);
// }
-void grib_buffer_replace(grib_accessor* a, const unsigned char* data,
- size_t newsize, int update_lengths, int update_paddings)
+int grib_buffer_replace(grib_accessor* a, const unsigned char* data,
+ size_t newsize, int update_lengths, int update_paddings)
{
size_t offset = a->offset;
long oldsize = grib_get_next_position_offset(a) - offset;
@@ -232,11 +232,13 @@ void grib_buffer_replace(grib_accessor* a, const unsigned char* data,
update_offsets_after(a, increase);
if (update_lengths) {
grib_update_size(a, newsize);
- grib_section_adjust_sizes(grib_handle_of_accessor(a)->root, 1, 0);
+ int err = grib_section_adjust_sizes(grib_handle_of_accessor(a)->root, 1, 0);
+ if (err) return err;
if (update_paddings)
grib_update_paddings(grib_handle_of_accessor(a)->root);
}
}
+ return GRIB_SUCCESS;
}
void grib_update_sections_lengths(grib_handle* h)
diff --git a/src/grib_expression_class_is_in_dict.cc b/src/grib_expression_class_is_in_dict.cc
index 6cb43acb3..a2ad355ab 100644
--- a/src/grib_expression_class_is_in_dict.cc
+++ b/src/grib_expression_class_is_in_dict.cc
@@ -174,44 +174,41 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* result)
static int evaluate_double(grib_expression* g, grib_handle* h, double* result)
{
- grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g;
- int err = 0;
- char mybuf[1024] = {0,};
- size_t size = 1024;
+ return GRIB_NOT_IMPLEMENTED;
- grib_trie* list = load_dictionary(h->context, g, &err);
-
- if ((err = grib_get_string_internal(h, e->key, mybuf, &size)) != GRIB_SUCCESS)
- return err;
-
- if (grib_trie_get(list, mybuf))
- *result = 1;
- else
- *result = 0;
-
- return err;
+ // grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g;
+ // int err = 0;
+ // char mybuf[1024] = {0,};
+ // size_t size = 1024;
+ // grib_trie* list = load_dictionary(h->context, g, &err);
+ // if ((err = grib_get_string_internal(h, e->key, mybuf, &size)) != GRIB_SUCCESS)
+ // return err;
+ // if (grib_trie_get(list, mybuf))
+ // *result = 1;
+ // else
+ // *result = 0;
+ // return err;
}
static string evaluate_string(grib_expression* g, grib_handle* h, char* buf, size_t* size, int* err)
{
- grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g;
- char mybuf[1024] = {0,};
- size_t sizebuf = 1024;
- long result;
+ *err = GRIB_NOT_IMPLEMENTED;
+ return NULL;
- grib_trie* list = load_dictionary(h->context, g, err);
-
- if ((*err = grib_get_string_internal(h, e->key, mybuf, &sizebuf)) != GRIB_SUCCESS)
- return NULL;
-
- if (grib_trie_get(list, mybuf))
- result = 1;
- else
- result = 0;
-
- snprintf(buf, 32, "%ld", result);
- *size = strlen(buf);
- return buf;
+ // grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g;
+ // char mybuf[1024] = {0,};
+ // size_t sizebuf = 1024;
+ // long result;
+ // grib_trie* list = load_dictionary(h->context, g, err);
+ // if ((*err = grib_get_string_internal(h, e->key, mybuf, &sizebuf)) != GRIB_SUCCESS)
+ // return NULL;
+ // if (grib_trie_get(list, mybuf))
+ // result = 1;
+ // else
+ // result = 0;
+ // snprintf(buf, 32, "%ld", result);
+ // *size = strlen(buf);
+ // return buf;
}
static void print(grib_context* c, grib_expression* g, grib_handle* f)
diff --git a/src/grib_expression_class_string_compare.cc b/src/grib_expression_class_string_compare.cc
index 8ee196c2e..1c6202b23 100644
--- a/src/grib_expression_class_string_compare.cc
+++ b/src/grib_expression_class_string_compare.cc
@@ -100,9 +100,9 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
static int evaluate_long(grib_expression* g, grib_handle* h, long* lres)
{
int ret = 0;
- char b1[1024];
+ char b1[1024] = {0,};
size_t l1 = sizeof(b1);
- char b2[1024];
+ char b2[1024] = {0,};
size_t l2 = sizeof(b2);
const char* v1 = NULL;
const char* v2 = NULL;
diff --git a/src/grib_filepool.cc b/src/grib_filepool.cc
index 2282fe3eb..8d55f3d3d 100644
--- a/src/grib_filepool.cc
+++ b/src/grib_filepool.cc
@@ -344,6 +344,11 @@ grib_file* grib_get_file(const char* filename, int* err)
{
grib_file* file = NULL;
+ if (!file_pool.current) {
+ *err = GRIB_IO_PROBLEM;
+ return NULL;
+ }
+
if (file_pool.current->name && !grib_inline_strcmp(filename, file_pool.current->name)) {
return file_pool.current;
}
diff --git a/src/grib_handle.cc b/src/grib_handle.cc
index b84769440..f476ab9f2 100644
--- a/src/grib_handle.cc
+++ b/src/grib_handle.cc
@@ -428,6 +428,8 @@ grib_handle* codes_handle_new_from_file(grib_context* c, FILE* f, ProductKind pr
return metar_new_from_file(c, f, error);
if (product == PRODUCT_GTS)
return gts_new_from_file(c, f, error);
+ //if (product == PRODUCT_TAF)
+ // return taf_new_from_file(c, f, error);
if (product == PRODUCT_ANY)
return any_new_from_file(c, f, error);
@@ -642,7 +644,7 @@ static grib_handle* grib_handle_new_multi(grib_context* c, unsigned char** data,
if (grib_decode_unsigned_byte_long(secbegin, 5, 1) == 254) {
if (!gm->bitmap_section) {
grib_context_log(c, GRIB_LOG_ERROR,
- "grib_handle_new_multi : cannot create handle, missing bitmap\n");
+ "grib_handle_new_multi : cannot create handle, missing bitmap");
return NULL;
}
gm->sections[secnum] = gm->bitmap_section;
@@ -695,7 +697,7 @@ static grib_handle* grib_handle_new_multi(grib_context* c, unsigned char** data,
gl = grib_handle_new_from_message(c, message, olen);
if (!gl) {
*error = GRIB_DECODING_ERROR;
- grib_context_log(c, GRIB_LOG_ERROR, "grib_handle_new_multi: cannot create handle \n");
+ grib_context_log(c, GRIB_LOG_ERROR, "grib_handle_new_multi: cannot create handle");
return NULL;
}
@@ -794,7 +796,7 @@ static grib_handle* grib_handle_new_from_file_multi(grib_context* c, FILE* f, in
/* Special case for inherited bitmaps */
if (grib_decode_unsigned_byte_long(secbegin, 5, 1) == 254) {
if (!gm->bitmap_section) {
- grib_context_log(c, GRIB_LOG_ERROR, "grib_handle_new_from_file_multi: cannot create handle, missing bitmap\n");
+ grib_context_log(c, GRIB_LOG_ERROR, "grib_handle_new_from_file_multi: cannot create handle, missing bitmap");
grib_context_free(c, data);
return NULL;
}
@@ -850,7 +852,7 @@ static grib_handle* grib_handle_new_from_file_multi(grib_context* c, FILE* f, in
gl = grib_handle_new_from_message(c, data, olen);
if (!gl) {
*error = GRIB_DECODING_ERROR;
- grib_context_log(c, GRIB_LOG_ERROR, "grib_handle_new_from_file_multi: cannot create handle \n");
+ grib_context_log(c, GRIB_LOG_ERROR, "grib_handle_new_from_file_multi: cannot create handle");
grib_context_free(c, data);
return NULL;
}
@@ -930,7 +932,7 @@ grib_handle* gts_new_from_file(grib_context* c, FILE* f, int* error)
if (!gl) {
*error = GRIB_DECODING_ERROR;
- grib_context_log(c, GRIB_LOG_ERROR, "gts_new_from_file: cannot create handle \n");
+ grib_context_log(c, GRIB_LOG_ERROR, "gts_new_from_file: cannot create handle");
grib_context_free(c, data);
return NULL;
}
@@ -971,7 +973,7 @@ grib_handle* taf_new_from_file(grib_context* c, FILE* f, int* error)
if (!gl) {
*error = GRIB_DECODING_ERROR;
- grib_context_log(c, GRIB_LOG_ERROR, "taf_new_from_file: cannot create handle \n");
+ grib_context_log(c, GRIB_LOG_ERROR, "taf_new_from_file: cannot create handle");
grib_context_free(c, data);
return NULL;
}
@@ -1012,7 +1014,7 @@ grib_handle* metar_new_from_file(grib_context* c, FILE* f, int* error)
if (!gl) {
*error = GRIB_DECODING_ERROR;
- grib_context_log(c, GRIB_LOG_ERROR, "metar_new_from_file: cannot create handle \n");
+ grib_context_log(c, GRIB_LOG_ERROR, "metar_new_from_file: cannot create handle");
grib_context_free(c, data);
return NULL;
}
@@ -1080,7 +1082,7 @@ grib_handle* bufr_new_from_file(grib_context* c, FILE* f, int* error)
if (!gl) {
*error = GRIB_DECODING_ERROR;
- grib_context_log(c, GRIB_LOG_ERROR, "bufr_new_from_file: cannot create handle \n");
+ grib_context_log(c, GRIB_LOG_ERROR, "bufr_new_from_file: cannot create handle");
grib_context_free(c, data);
return NULL;
}
@@ -1132,7 +1134,7 @@ grib_handle* any_new_from_file(grib_context* c, FILE* f, int* error)
if (!gl) {
*error = GRIB_DECODING_ERROR;
- grib_context_log(c, GRIB_LOG_ERROR, "any_new_from_file : cannot create handle\n");
+ grib_context_log(c, GRIB_LOG_ERROR, "any_new_from_file: cannot create handle");
grib_context_free(c, data);
return NULL;
}
@@ -1205,7 +1207,7 @@ static grib_handle* grib_handle_new_from_file_no_multi(grib_context* c, FILE* f,
if (!gl) {
*error = GRIB_DECODING_ERROR;
- grib_context_log(c, GRIB_LOG_ERROR, "grib_handle_new_from_file_no_multi: cannot create handle\n");
+ grib_context_log(c, GRIB_LOG_ERROR, "grib_handle_new_from_file_no_multi: cannot create handle");
grib_context_free(c, data);
return NULL;
}
diff --git a/src/grib_io.cc b/src/grib_io.cc
index ce8d2aa65..d4d876cca 100644
--- a/src/grib_io.cc
+++ b/src/grib_io.cc
@@ -1267,57 +1267,49 @@ int wmo_read_gts_from_file(FILE* f, void* buffer, size_t* len)
return err;
}
-int wmo_read_taf_from_file(FILE* f, void* buffer, size_t* len)
-{
- int err;
- user_buffer_t u;
- reader r;
+// int wmo_read_taf_from_file(FILE* f, void* buffer, size_t* len)
+// {
+// int err;
+// user_buffer_t u;
+// reader r;
+// u.user_buffer = buffer;
+// u.buffer_size = *len;
+// r.read_data = f;
+// r.read = &stdio_read;
+// r.alloc_data = &u;
+// r.alloc = &user_provider_buffer;
+// r.headers_only = 0;
+// r.seek = &stdio_seek;
+// r.seek_from_start = &stdio_seek_from_start;
+// r.tell = &stdio_tell;
+// r.offset = 0;
+// r.message_size = 0;
+// err = read_any_taf(&r);
+// *len = r.message_size;
+// return err;
+// }
- u.user_buffer = buffer;
- u.buffer_size = *len;
-
- r.read_data = f;
- r.read = &stdio_read;
- r.alloc_data = &u;
- r.alloc = &user_provider_buffer;
- r.headers_only = 0;
- r.seek = &stdio_seek;
- r.seek_from_start = &stdio_seek_from_start;
- r.tell = &stdio_tell;
- r.offset = 0;
- r.message_size = 0;
-
- err = read_any_taf(&r);
- *len = r.message_size;
-
- return err;
-}
-
-int wmo_read_metar_from_file(FILE* f, void* buffer, size_t* len)
-{
- int err;
- user_buffer_t u;
- reader r;
-
- u.user_buffer = buffer;
- u.buffer_size = *len;
-
- r.read_data = f;
- r.read = &stdio_read;
- r.alloc_data = &u;
- r.alloc = &user_provider_buffer;
- r.headers_only = 0;
- r.seek = &stdio_seek;
- r.seek_from_start = &stdio_seek_from_start;
- r.tell = &stdio_tell;
- r.offset = 0;
- r.message_size = 0;
-
- err = read_any_metar(&r);
- *len = r.message_size;
-
- return err;
-}
+// int wmo_read_metar_from_file(FILE* f, void* buffer, size_t* len)
+// {
+// int err;
+// user_buffer_t u;
+// reader r;
+// u.user_buffer = buffer;
+// u.buffer_size = *len;
+// r.read_data = f;
+// r.read = &stdio_read;
+// r.alloc_data = &u;
+// r.alloc = &user_provider_buffer;
+// r.headers_only = 0;
+// r.seek = &stdio_seek;
+// r.seek_from_start = &stdio_seek_from_start;
+// r.tell = &stdio_tell;
+// r.offset = 0;
+// r.message_size = 0;
+// err = read_any_metar(&r);
+// *len = r.message_size;
+// return err;
+// }
/*================== */
@@ -1731,7 +1723,6 @@ int grib_read_any_from_memory(grib_context* ctx, unsigned char** data, size_t* d
err = read_any(&r, /*no_alloc=*/0, 1, ECCODES_READS_BUFR, ECCODES_READS_HDF5, ECCODES_READS_WRAP);
*len = r.message_size;
-
*data_length = m.data_len;
*data = m.data;
diff --git a/src/grib_jasper_encoding.cc b/src/grib_jasper_encoding.cc
index 815fe376b..ac545555a 100644
--- a/src/grib_jasper_encoding.cc
+++ b/src/grib_jasper_encoding.cc
@@ -273,19 +273,17 @@ cleanup:
return code;
}
-#else
+#else // HAVE_LIBJASPER
int grib_jasper_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* val, const size_t* n_vals)
{
- grib_context_log(c, GRIB_LOG_ERROR,
- "grib_accessor_data_jpeg2000_packing: JasPer JPEG support not enabled.");
+ grib_context_log(c, GRIB_LOG_ERROR, "grib_jasper_decode: JasPer JPEG support not enabled.");
return GRIB_FUNCTIONALITY_NOT_ENABLED;
}
int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper)
{
- grib_context_log(c, GRIB_LOG_ERROR,
- "grib_accessor_data_jpeg2000_packing: JasPer JPEG support not enabled.");
+ grib_context_log(c, GRIB_LOG_ERROR, "grib_jasper_encode: JasPer JPEG support not enabled.");
return GRIB_FUNCTIONALITY_NOT_ENABLED;
}
diff --git a/src/grib_openjpeg_encoding.cc b/src/grib_openjpeg_encoding.cc
index 1c08de603..6b726a97a 100644
--- a/src/grib_openjpeg_encoding.cc
+++ b/src/grib_openjpeg_encoding.cc
@@ -546,13 +546,13 @@ cleanup:
int grib_openjpeg_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* val, const size_t* n_vals)
{
- grib_context_log(c, GRIB_LOG_ERROR, "grib_openjpeg_encoding.c: OpenJPEG JPEG support not enabled.");
+ grib_context_log(c, GRIB_LOG_ERROR, "grib_openjpeg_decode: OpenJPEG JPEG support not enabled.");
return GRIB_FUNCTIONALITY_NOT_ENABLED;
}
int grib_openjpeg_encode(grib_context* c, j2k_encode_helper* helper)
{
- grib_context_log(c, GRIB_LOG_ERROR, "grib_openjpeg_encoding.c: OpenJPEG JPEG support not enabled.");
+ grib_context_log(c, GRIB_LOG_ERROR, "grib_openjpeg_encode: OpenJPEG JPEG support not enabled.");
return GRIB_FUNCTIONALITY_NOT_ENABLED;
}
diff --git a/src/grib_value.cc b/src/grib_value.cc
index 4cc974fd6..2ac9cb3ce 100644
--- a/src/grib_value.cc
+++ b/src/grib_value.cc
@@ -97,12 +97,12 @@ int grib_set_long_internal(grib_handle* h, const char* name, long val)
return grib_dependency_notify_change(a);
}
- grib_context_log(c, GRIB_LOG_ERROR, "unable to set %s=%ld as long (%s)",
+ grib_context_log(c, GRIB_LOG_ERROR, "Unable to set %s=%ld as long (%s)",
name, val, grib_get_error_message(ret));
return ret;
}
- grib_context_log(c, GRIB_LOG_ERROR, "unable to find accessor %s", name);
+ grib_context_log(c, GRIB_LOG_ERROR, "Unable to find accessor %s", name);
return GRIB_NOT_FOUND;
}
@@ -151,12 +151,12 @@ int grib_set_double_internal(grib_handle* h, const char* name, double val)
return grib_dependency_notify_change(a);
}
- grib_context_log(h->context, GRIB_LOG_ERROR, "unable to set %s=%g as double (%s)",
+ grib_context_log(h->context, GRIB_LOG_ERROR, "Unable to set %s=%g as double (%s)",
name, val, grib_get_error_message(ret));
return ret;
}
- grib_context_log(h->context, GRIB_LOG_ERROR, "unable to find accessor %s", name);
+ grib_context_log(h->context, GRIB_LOG_ERROR, "Unable to find accessor %s", name);
return GRIB_NOT_FOUND;
}
@@ -189,7 +189,7 @@ int grib_copy_namespace(grib_handle* dest, const char* name, grib_handle* src)
iter = grib_keys_iterator_new(src, 0, name);
if (!iter) {
- grib_context_log(src->context, GRIB_LOG_ERROR, "grib_copy_namespace: unable to get iterator for %s", name);
+ grib_context_log(src->context, GRIB_LOG_ERROR, "grib_copy_namespace: Unable to get iterator for %s", name);
return GRIB_INTERNAL_ERROR;
}
@@ -378,12 +378,12 @@ int grib_set_string_internal(grib_handle* h, const char* name,
return grib_dependency_notify_change(a);
}
- grib_context_log(h->context, GRIB_LOG_ERROR, "unable to set %s=%s as string (%s)",
+ grib_context_log(h->context, GRIB_LOG_ERROR, "Unable to set %s=%s as string (%s)",
name, val, grib_get_error_message(ret));
return ret;
}
- grib_context_log(h->context, GRIB_LOG_ERROR, "unable to find accessor %s", name);
+ grib_context_log(h->context, GRIB_LOG_ERROR, "Unable to find accessor %s", name);
return GRIB_NOT_FOUND;
}
@@ -516,12 +516,12 @@ int grib_set_bytes_internal(grib_handle* h, const char* name, const unsigned cha
return grib_dependency_notify_change(a);
}
- grib_context_log(h->context, GRIB_LOG_ERROR, "unable to set %s=%s as bytes (%s)",
+ grib_context_log(h->context, GRIB_LOG_ERROR, "Unable to set %s=%s as bytes (%s)",
name, val, grib_get_error_message(ret));
return ret;
}
- grib_context_log(h->context, GRIB_LOG_ERROR, "unable to find accessor %s", name);
+ grib_context_log(h->context, GRIB_LOG_ERROR, "Unable to find accessor %s", name);
return GRIB_NOT_FOUND;
}
@@ -552,11 +552,11 @@ int grib_set_bytes(grib_handle* h, const char* name, const unsigned char* val, s
// if (a->length == 0)
// return 0;
// if ((ret = grib_pack_zero(a)) != GRIB_SUCCESS)
-// grib_context_log(h->context, GRIB_LOG_ERROR, "unable to clear %s (%s)",
+// grib_context_log(h->context, GRIB_LOG_ERROR, "Unable to clear %s (%s)",
// name, grib_get_error_message(ret));
// return ret;
// }
-// /*grib_context_log(h->context,GRIB_LOG_ERROR,"unable to find accessor %s",name);*/
+// /*grib_context_log(h->context,GRIB_LOG_ERROR,"Unable to find accessor %s",name);*/
// return GRIB_NOT_FOUND;
// }
@@ -582,12 +582,12 @@ int grib_set_missing(grib_handle* h, const char* name)
else
ret = GRIB_VALUE_CANNOT_BE_MISSING;
- grib_context_log(h->context, GRIB_LOG_ERROR, "unable to set %s=missing (%s)",
+ grib_context_log(h->context, GRIB_LOG_ERROR, "Unable to set %s=missing (%s)",
name, grib_get_error_message(ret));
return ret;
}
- grib_context_log(h->context, GRIB_LOG_ERROR, "unable to find accessor %s", name);
+ grib_context_log(h->context, GRIB_LOG_ERROR, "Unable to find accessor %s", name);
return GRIB_NOT_FOUND;
}
@@ -743,7 +743,7 @@ int grib_set_double_array_internal(grib_handle* h, const char* name, const doubl
int ret = 0;
if (h->context->debug) {
- print_debug_info__set_array(h, "grib_set_double_array_internal", name, val, length);
+ print_debug_info__set_array(h, __func__, name, val, length);
}
if (length == 0) {
@@ -755,7 +755,7 @@ int grib_set_double_array_internal(grib_handle* h, const char* name, const doubl
}
if (ret != GRIB_SUCCESS)
- grib_context_log(h->context, GRIB_LOG_ERROR, "unable to set double array %s (%s)",
+ grib_context_log(h->context, GRIB_LOG_ERROR, "Unable to set double array '%s' (%s)",
name, grib_get_error_message(ret));
/*if (h->context->debug) fprintf(stderr,"ECCODES DEBUG grib_set_double_array_internal key=%s --DONE\n",name);*/
return ret;
@@ -772,7 +772,7 @@ static int __grib_set_double_array(grib_handle* h, const char* name, const doubl
size_t i = 0;
if (h->context->debug) {
- print_debug_info__set_array(h, "__grib_set_double_array", name, val, length);
+ print_debug_info__set_array(h, __func__, name, val, length);
}
if (length == 0) {
@@ -928,7 +928,7 @@ int grib_set_long_array_internal(grib_handle* h, const char* name, const long* v
{
int ret = _grib_set_long_array(h, name, val, length, 0);
if (ret != GRIB_SUCCESS)
- grib_context_log(h->context, GRIB_LOG_ERROR, "unable to set long array %s (%s)",
+ grib_context_log(h->context, GRIB_LOG_ERROR, "Unable to set long array '%s' (%s)",
name, grib_get_error_message(ret));
return ret;
}
@@ -944,34 +944,33 @@ int grib_get_long_internal(grib_handle* h, const char* name, long* val)
if (ret != GRIB_SUCCESS) {
grib_context_log(h->context, GRIB_LOG_ERROR,
- "unable to get %s as long (%s)",
+ "Unable to get %s as long (%s)",
name, grib_get_error_message(ret));
}
return ret;
}
-int grib_is_in_dump(const grib_handle* h, const char* name)
-{
- const grib_accessor* a = grib_find_accessor(h, name);
- if (a != NULL && (a->flags & GRIB_ACCESSOR_FLAG_DUMP))
- return 1;
- else
- return 0;
-}
+// int grib_is_in_dump(const grib_handle* h, const char* name)
+// {
+// const grib_accessor* a = grib_find_accessor(h, name);
+// if (a != NULL && (a->flags & GRIB_ACCESSOR_FLAG_DUMP))
+// return 1;
+// else
+// return 0;
+// }
-int grib_attributes_count(const grib_accessor* a, size_t* size)
-{
- if (a) {
- *size = 0;
- while (a->attributes[*size] != NULL) {
- (*size)++;
- }
- return GRIB_SUCCESS;
- }
-
- return GRIB_NOT_FOUND;
-}
+// int grib_attributes_count(const grib_accessor* a, size_t* size)
+// {
+// if (a) {
+// *size = 0;
+// while (a->attributes[*size] != NULL) {
+// (*size)++;
+// }
+// return GRIB_SUCCESS;
+// }
+// return GRIB_NOT_FOUND;
+// }
int grib_get_long(const grib_handle* h, const char* name, long* val)
{
@@ -1002,7 +1001,7 @@ int grib_get_double_internal(grib_handle* h, const char* name, double* val)
if (ret != GRIB_SUCCESS)
grib_context_log(h->context, GRIB_LOG_ERROR,
- "unable to get %s as double (%s)",
+ "Unable to get %s as double (%s)",
name, grib_get_error_message(ret));
return ret;
@@ -1060,7 +1059,7 @@ int grib_get_double_element_internal(grib_handle* h, const char* name, int i, do
if (ret != GRIB_SUCCESS)
grib_context_log(h->context, GRIB_LOG_ERROR,
- "unable to get %s as double element (%s)",
+ "Unable to get %s as double element (%s)",
name, grib_get_error_message(ret));
return ret;
@@ -1091,7 +1090,7 @@ int grib_get_double_element_set_internal(grib_handle* h, const char* name, const
if (ret != GRIB_SUCCESS)
grib_context_log(h->context, GRIB_LOG_ERROR,
- "unable to get %s as double element set (%s)",
+ "Unable to get %s as double element set (%s)",
name, grib_get_error_message(ret));
return ret;
@@ -1102,7 +1101,7 @@ int grib_get_float_element_set_internal(grib_handle* h, const char* name, const
if (ret != GRIB_SUCCESS)
grib_context_log(h->context, GRIB_LOG_ERROR,
- "unable to get %s as float element set (%s)",
+ "Unable to get %s as float element set (%s)",
name, grib_get_error_message(ret));
return ret;
@@ -1142,7 +1141,7 @@ int grib_get_double_elements(const grib_handle* h, const char* name, const int*
err = ecc__grib_get_size(h, act, &size);
if (err != GRIB_SUCCESS) {
- grib_context_log(h->context, GRIB_LOG_ERROR, "grib_get_double_elements: cannot get size of %s\n", name);
+ grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Cannot get size of %s", __func__, name);
return err;
}
@@ -1151,7 +1150,7 @@ int grib_get_double_elements(const grib_handle* h, const char* name, const int*
const int anIndex = index_array[j];
if (anIndex < 0 || anIndex >= size) {
grib_context_log(h->context, GRIB_LOG_ERROR,
- "grib_get_double_elements: index out of range: %d (should be between 0 and %ld)", anIndex, size - 1);
+ "%s: Index out of range: %d (should be between 0 and %zu)", __func__, anIndex, size - 1);
return GRIB_INVALID_ARGUMENT;
}
}
@@ -1159,7 +1158,7 @@ int grib_get_double_elements(const grib_handle* h, const char* name, const int*
num_bytes = size * sizeof(double);
values = (double*)grib_context_malloc(h->context, num_bytes);
if (!values) {
- grib_context_log(h->context, GRIB_LOG_ERROR, "grib_get_double_elements: unable to allocate %ld bytes\n", num_bytes);
+ grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, num_bytes);
return GRIB_OUT_OF_MEMORY;
}
@@ -1185,7 +1184,7 @@ int grib_get_string_internal(grib_handle* h, const char* name, char* val, size_t
if (ret != GRIB_SUCCESS)
grib_context_log(h->context, GRIB_LOG_ERROR,
- "unable to get %s as string (%s)",
+ "Unable to get %s as string (%s)",
name, grib_get_error_message(ret));
return ret;
@@ -1219,7 +1218,7 @@ int grib_get_bytes_internal(const grib_handle* h, const char* name, unsigned cha
if (ret != GRIB_SUCCESS)
grib_context_log(h->context, GRIB_LOG_ERROR,
- "unable to get %s as bytes (%s)",
+ "Unable to get %s as bytes (%s)",
name, grib_get_error_message(ret));
return ret;
@@ -1545,7 +1544,7 @@ int grib_get_long_array_internal(grib_handle* h, const char* name, long* val, si
if (ret != GRIB_SUCCESS)
grib_context_log(h->context, GRIB_LOG_ERROR,
- "unable to get %s as long array (%s)",
+ "Unable to get %s as long array (%s)",
name, grib_get_error_message(ret));
return ret;
@@ -1580,133 +1579,127 @@ int grib_get_long_array(const grib_handle* h, const char* name, long* val, size_
return ret;
}
-static void grib_clean_key_value(grib_context* c, grib_key_value_list* kv)
-{
- if (kv->long_value)
- grib_context_free(c, kv->long_value);
- kv->long_value = NULL;
- if (kv->double_value)
- grib_context_free(c, kv->double_value);
- kv->double_value = NULL;
- if (kv->string_value)
- grib_context_free(c, kv->string_value);
- kv->string_value = NULL;
- if (kv->namespace_value)
- grib_key_value_list_delete(c, kv->namespace_value);
- kv->namespace_value = NULL;
- kv->error = 0;
- kv->has_value = 0;
- kv->size = 0;
-}
+// static void grib_clean_key_value(grib_context* c, grib_key_value_list* kv)
+// {
+// if (kv->long_value)
+// grib_context_free(c, kv->long_value);
+// kv->long_value = NULL;
+// if (kv->double_value)
+// grib_context_free(c, kv->double_value);
+// kv->double_value = NULL;
+// if (kv->string_value)
+// grib_context_free(c, kv->string_value);
+// kv->string_value = NULL;
+// if (kv->namespace_value)
+// grib_key_value_list_delete(c, kv->namespace_value);
+// kv->namespace_value = NULL;
+// kv->error = 0;
+// kv->has_value = 0;
+// kv->size = 0;
+// }
-static int grib_get_key_value(grib_handle* h, grib_key_value_list* kv)
-{
- int err = 0;
- size_t size = 0;
- grib_keys_iterator* iter = NULL;
- grib_key_value_list* list = NULL;
+// static int grib_get_key_value(grib_handle* h, grib_key_value_list* kv)
+// {
+// int err = 0;
+// size_t size = 0;
+// grib_keys_iterator* iter = NULL;
+// grib_key_value_list* list = NULL;
+// if (kv->has_value)
+// grib_clean_key_value(h->context, kv);
+// err = grib_get_size(h, kv->name, &size);
+// if (err) {
+// kv->error = err;
+// return err;
+// }
+// if (size == 0)
+// size = 512;
+// switch (kv->type) {
+// case GRIB_TYPE_LONG:
+// kv->long_value = (long*)grib_context_malloc_clear(h->context, size * sizeof(long));
+// err = grib_get_long_array(h, kv->name, kv->long_value, &size);
+// kv->error = err;
+// break;
+// case GRIB_TYPE_DOUBLE:
+// kv->double_value = (double*)grib_context_malloc_clear(h->context, size * sizeof(double));
+// err = grib_get_double_array(h, kv->name, kv->double_value, &size);
+// kv->error = err;
+// break;
+// case GRIB_TYPE_STRING:
+// grib_get_string_length(h, kv->name, &size);
+// kv->string_value = (char*)grib_context_malloc_clear(h->context, size * sizeof(char));
+// err = grib_get_string(h, kv->name, kv->string_value, &size);
+// kv->error = err;
+// break;
+// case GRIB_TYPE_BYTES:
+// kv->string_value = (char*)grib_context_malloc_clear(h->context, size * sizeof(char));
+// err = grib_get_bytes(h, kv->name, (unsigned char*)kv->string_value, &size);
+// kv->error = err;
+// break;
+// case CODES_NAMESPACE:
+// iter = grib_keys_iterator_new(h, 0, kv->name);
+// list = (grib_key_value_list*)grib_context_malloc_clear(h->context, sizeof(grib_key_value_list));
+// kv->namespace_value = list;
+// while (grib_keys_iterator_next(iter)) {
+// list->name = grib_keys_iterator_get_name(iter);
+// err = grib_get_native_type(h, list->name, &(list->type));
+// if (err)
+// return err;
+// err = grib_get_key_value(h, list);
+// if (err)
+// return err;
+// list->next = (grib_key_value_list*)grib_context_malloc_clear(h->context, sizeof(grib_key_value_list));
+// list = list->next;
+// }
+// grib_keys_iterator_delete(iter);
+// break;
+// default:
+// err = grib_get_native_type(h, kv->name, &(kv->type));
+// if (err)
+// return err;
+// err = grib_get_key_value(h, kv);
+// break;
+// }
+// kv->has_value = 1;
+// return err;
+// }
- if (kv->has_value)
- grib_clean_key_value(h->context, kv);
+// grib_key_value_list* grib_key_value_list_clone(grib_context* c, grib_key_value_list* list)
+// {
+// grib_key_value_list* next = list;
+// grib_key_value_list* the_clone = (grib_key_value_list*)grib_context_malloc_clear(c, sizeof(grib_key_value_list));
+// grib_key_value_list* p = the_clone;
+// while (next && next->name) {
+// p->name = grib_context_strdup(c, next->name);
+// p->type = next->type;
+// next = next->next;
+// }
+// return the_clone;
+// }
- err = grib_get_size(h, kv->name, &size);
- if (err) {
- kv->error = err;
- return err;
- }
- if (size == 0)
- size = 512;
+// void grib_key_value_list_delete(grib_context* c, grib_key_value_list* kvl)
+// {
+// grib_key_value_list* next = kvl;
+// grib_key_value_list* p = NULL;
+// while (next) {
+// p = next->next;
+// if (next->type == CODES_NAMESPACE)
+// grib_key_value_list_delete(c, next->namespace_value);
+// grib_clean_key_value(c, next);
+// grib_context_free(c, next);
+// next = p;
+// }
+// }
- switch (kv->type) {
- case GRIB_TYPE_LONG:
- kv->long_value = (long*)grib_context_malloc_clear(h->context, size * sizeof(long));
- err = grib_get_long_array(h, kv->name, kv->long_value, &size);
- kv->error = err;
- break;
- case GRIB_TYPE_DOUBLE:
- kv->double_value = (double*)grib_context_malloc_clear(h->context, size * sizeof(double));
- err = grib_get_double_array(h, kv->name, kv->double_value, &size);
- kv->error = err;
- break;
- case GRIB_TYPE_STRING:
- grib_get_string_length(h, kv->name, &size);
- kv->string_value = (char*)grib_context_malloc_clear(h->context, size * sizeof(char));
- err = grib_get_string(h, kv->name, kv->string_value, &size);
- kv->error = err;
- break;
- case GRIB_TYPE_BYTES:
- kv->string_value = (char*)grib_context_malloc_clear(h->context, size * sizeof(char));
- err = grib_get_bytes(h, kv->name, (unsigned char*)kv->string_value, &size);
- kv->error = err;
- break;
- case CODES_NAMESPACE:
- iter = grib_keys_iterator_new(h, 0, kv->name);
- list = (grib_key_value_list*)grib_context_malloc_clear(h->context, sizeof(grib_key_value_list));
- kv->namespace_value = list;
- while (grib_keys_iterator_next(iter)) {
- list->name = grib_keys_iterator_get_name(iter);
- err = grib_get_native_type(h, list->name, &(list->type));
- if (err)
- return err;
- err = grib_get_key_value(h, list);
- if (err)
- return err;
- list->next = (grib_key_value_list*)grib_context_malloc_clear(h->context, sizeof(grib_key_value_list));
- list = list->next;
- }
- grib_keys_iterator_delete(iter);
- break;
-
- default:
- err = grib_get_native_type(h, kv->name, &(kv->type));
- if (err)
- return err;
- err = grib_get_key_value(h, kv);
- break;
- }
- kv->has_value = 1;
- return err;
-}
-
-grib_key_value_list* grib_key_value_list_clone(grib_context* c, grib_key_value_list* list)
-{
- grib_key_value_list* next = list;
- grib_key_value_list* the_clone = (grib_key_value_list*)grib_context_malloc_clear(c, sizeof(grib_key_value_list));
- grib_key_value_list* p = the_clone;
-
- while (next && next->name) {
- p->name = grib_context_strdup(c, next->name);
- p->type = next->type;
- next = next->next;
- }
- return the_clone;
-}
-
-void grib_key_value_list_delete(grib_context* c, grib_key_value_list* kvl)
-{
- grib_key_value_list* next = kvl;
- grib_key_value_list* p = NULL;
- while (next) {
- p = next->next;
- if (next->type == CODES_NAMESPACE)
- grib_key_value_list_delete(c, next->namespace_value);
-
- grib_clean_key_value(c, next);
- grib_context_free(c, next);
- next = p;
- }
-}
-
-int grib_get_key_value_list(grib_handle* h, grib_key_value_list* list)
-{
- int ret = 0;
- grib_key_value_list* kvl = list;
- while (kvl) {
- ret = grib_get_key_value(h, kvl);
- kvl = kvl->next;
- }
- return ret;
-}
+// int grib_get_key_value_list(grib_handle* h, grib_key_value_list* list)
+// {
+// int ret = 0;
+// grib_key_value_list* kvl = list;
+// while (kvl) {
+// ret = grib_get_key_value(h, kvl);
+// kvl = kvl->next;
+// }
+// return ret;
+// }
int grib_get_values(grib_handle* h, grib_values* args, size_t count)
{
@@ -1815,7 +1808,7 @@ int grib_set_values(grib_handle* h, grib_values* args, size_t count)
break;
}
/*if (args[i].error != GRIB_SUCCESS)
- grib_context_log(h->context,GRIB_LOG_ERROR,"unable to set %s (%s)",
+ grib_context_log(h->context,GRIB_LOG_ERROR,"Unable to set %s (%s)",
args[i].name,grib_get_error_message(args[i].error)); */
}
}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 86fd4e975..91513a8d0 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -19,6 +19,7 @@ list(APPEND test_c_bins
grib_multi_from_message
grib_clone_headers_only
grib_read_index
+ grib_set_large_message_fail
unit_tests
bufr_keys_iter
grib_keys_iter
@@ -96,6 +97,7 @@ if( HAVE_BUILD_TOOLS )
grib_ifsParam
grib_packing_order
filter_substr
+ filter_transient_darray
grib_uerra
grib_ecpoint
grib_s2s
@@ -143,7 +145,6 @@ if( HAVE_BUILD_TOOLS )
bufr_json_samples
bufr_ecc-359
bufr_ecc-517
- bufr_rdbSubTypes
grib_efas
grib_sh_imag
grib_spectral
@@ -153,14 +154,16 @@ if( HAVE_BUILD_TOOLS )
grib_grid_lambert_conformal
grib_grid_polar_stereographic
grib_grid_healpix
- grib_g1monthlydate
grib_g1day_of_the_year_date
- grib_g1fcperiod)
+ )
# These tests require data downloads
# and/or take much longer
list(APPEND tests_extra
grib_data_quality_checks
+ grib_set_large_message_fail
+ grib_g1monthlydate
+ grib_g1fcperiod
grib_bpv_limit
grib_complex
grib_double_cmp
@@ -174,6 +177,7 @@ if( HAVE_BUILD_TOOLS )
grib_count
grib_clone_headers_only
bufr_templates
+ bufr_rdbSubTypes
bufr_dump_data
bufr_dump_descriptors
bufr_coordinate_descriptors
@@ -188,6 +192,7 @@ if( HAVE_BUILD_TOOLS )
bufr_get
bufr_operators
bufr_filter_misc
+ bufr_filter_fail
bufr_filter_extract_subsets
bufr_filter_extract_datetime
bufr_filter_extract_area
@@ -252,10 +257,13 @@ if( HAVE_BUILD_TOOLS )
gts_ls
gts_count
gts_compare
+ gts_dump
wrap
+ hdf5
taf
pseudo_diag
metar_ls
+ metar_filter
metar_get
metar_dump
metar_compare
@@ -303,6 +311,7 @@ if( HAVE_BUILD_TOOLS )
grib_level
grib_indexing
grib_bitmap
+ grib_secondary_bitmap
grib_list
grib_second_order
grib_multi_from_message
@@ -356,6 +365,10 @@ if( HAVE_BUILD_TOOLS )
TYPE SCRIPT
CONDITION ECCODES_INSTALL_EXTRA_TOOLS
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_check_gaussian_grids.sh )
+ ecbuild_add_test( TARGET eccodes_t_grib_repair
+ TYPE SCRIPT
+ CONDITION ECCODES_INSTALL_EXTRA_TOOLS AND ENABLE_EXTRA_TESTS
+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_repair.sh )
# Note: making the test dependent on the grib files (with DEPENDS)
diff --git a/tests/bufr_compare.sh b/tests/bufr_compare.sh
index b0fe1382c..819900b15 100755
--- a/tests/bufr_compare.sh
+++ b/tests/bufr_compare.sh
@@ -45,7 +45,7 @@ f1="syno_1.bufr"
f2="aaen_55.bufr"
echo "Test: comparing two completely different files" >> $fLog
echo "file: $f" >> $fLog
-${tools_dir}/bufr_compare $f1 $f2 >> $fLog
+${tools_dir}/bufr_compare -v $f1 $f2 >> $fLog
if [ $? -eq 0 ]; then
echo "bufr_compare should have failed if files are completely different" >&2
exit 1
@@ -310,6 +310,46 @@ set -e
${tools_dir}/bufr_compare -bident -v $tempIndex1 $tempIndex2
rm -f $tempIndex1 $tempIndex2
+# Fail to unpack
+# ---------------
+bufr1=vos308014_v3_26.bufr
+bufr2=aaen_55.bufr
+set +e
+${tools_dir}/bufr_compare $bufr1 $bufr2 > $fLog 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+grep -q "Failed to unpack 1st message" $fLog
+
+set +e
+${tools_dir}/bufr_compare $bufr2 $bufr1 > $fLog 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+grep -q "Failed to unpack 2nd message" $fLog
+
+# ----------------------------------------
+# Summary mode (-f)
+# ----------------------------------------
+set +e
+${tools_dir}/bufr_compare -f aaen_55.bufr aben_55.bufr > $fLog 2>&1
+status=$?
+set -e
+[ $status -eq 1 ]
+grep -q "Summary of different key values" $fLog
+
+
+# ----------------------------------------
+# Unreadable message
+# ----------------------------------------
+echo BUFR > $fBufrTmp
+set +e
+${tools_dir}/bufr_compare $fBufrTmp $fBufrTmp > $fLog 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+grep -q "unreadable message" $fLog
+
# Clean up
# -------------
diff --git a/tests/bufr_ecc-680.sh b/tests/bufr_ecc-680.sh
index d06f56759..6669c030e 100755
--- a/tests/bufr_ecc-680.sh
+++ b/tests/bufr_ecc-680.sh
@@ -72,9 +72,38 @@ EOF
set +e
${tools_dir}/codes_bufr_filter -o $tempBufr $tempFilt $sample_bufr4 2>$tempText
status=$?
-[ $status -ne 0 ]
set -e
+[ $status -ne 0 ]
fgrep -q "Value (-416) out of range" $tempText
+# Error conditions
+# ------------------
+cat > $tempFilt < $tempText 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+fgrep -q "number of overridden reference values (2) different from number of descriptors between operator 203YYY and 203255" $tempText
+
+
+cat > $tempFilt < $tempText 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+fgrep -q "does not fit in 14 bits" $tempText
+
+
+
# Clean up
rm -f $tempBufr $tempFilt $tempText
diff --git a/tests/bufr_filter_fail.sh b/tests/bufr_filter_fail.sh
new file mode 100755
index 000000000..2ab8b3ef0
--- /dev/null
+++ b/tests/bufr_filter_fail.sh
@@ -0,0 +1,126 @@
+#!/bin/sh
+# (C) Copyright 2005- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+#
+
+. ./include.ctest.sh
+
+label="bufr_filter_fail_test"
+
+cd ${data_dir}/bufr
+
+fBufrTmp=${label}".bufr.tmp"
+fRules=${label}.filter
+fLog=${label}".log"
+tempErr=temp.$label.err
+
+#-----------------------------------------------------------
+# Test: with nonexistent keys.
+#-----------------------------------------------------------
+cat > $fRules <> $fLog 1>> $fLog
+if [ $? -eq 0 ]; then
+ echo "bufr_filter should have failed if key not found" >&2
+ exit 1
+fi
+set -e
+
+# Now repeat with -f option (do not exit on error)
+${tools_dir}/codes_bufr_filter -f $fRules $f 2>>$fLog 1>>$fLog
+
+#-----------------------------------------------------------
+# Test: with not allowed key values
+#-----------------------------------------------------------
+cat > $fRules <> $fLog 1>> $fLog
+if [ $? -eq 0 ]; then
+ echo "bufr_filter should have failed if key value is not allowed" >&2
+ exit 1
+fi
+set -e
+
+# Now repeat with -f option (do not exit on error)
+${tools_dir}/codes_bufr_filter -f $fRules $f 2>>$fLog 1>>$fLog
+
+
+#-----------------------------------------------------------
+# Test: with invalid string key
+#-----------------------------------------------------------
+cat > $fRules <> $fLog 1>> $fLog
+if [ $? -eq 0 ]; then
+ echo "bufr_filter should have failed if string key is invalid" >&2
+ exit 1
+fi
+set -e
+
+# Bad filter
+# -----------
+set +e
+${tools_dir}/bufr_filter a_non_existent_filter_file $ECCODES_SAMPLES_PATH/BUFR4.tmpl > $tempErr 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+grep -q "Cannot include file" $tempErr
+
+
+# Close
+# --------
+cat > $fRules < $tempErr 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+cat $tempErr
+grep -q "Input output problem" $tempErr
+
+
+# ------------------------
+# Unreadable message
+# ------------------------
+cat > $fRules < $outfile
+set +e
+${tools_dir}/bufr_filter $fRules $outfile > $tempErr 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+grep -q "unreadable message" $tempErr
+rm -f $outfile
+
+
+# Clean up
+rm -f $fLog $fRules $tempErr
diff --git a/tests/bufr_filter_misc.sh b/tests/bufr_filter_misc.sh
index 3e325ced1..a31cd2f0a 100755
--- a/tests/bufr_filter_misc.sh
+++ b/tests/bufr_filter_misc.sh
@@ -8,16 +8,15 @@
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#
-set -x
. ./include.ctest.sh
-cd ${data_dir}/bufr
-
# Define a common label for all the tmp files
label="bufr_filter_misc_test"
tempErr=temp.$label.err
+cd ${data_dir}/bufr
+
# Create log file
fLog=${label}".log"
rm -f $fLog
@@ -518,75 +517,6 @@ diff ${f}.ref ${f}.log
rm -f ${f}.ref ${f}.log
-#-----------------------------------------------------------
-# Test: with nonexistent keys.
-#-----------------------------------------------------------
-cat > $fRules <> $fLog
-echo "file: $f" >> $fLog
-${tools_dir}/codes_bufr_filter $fRules $f 2>> $fLog 1>> $fLog
-if [ $? -eq 0 ]; then
- echo "bufr_filter should have failed if key not found" >&2
- exit 1
-fi
-set -e
-
-# Now repeat with -f option (do not exit on error)
-${tools_dir}/codes_bufr_filter -f $fRules $f 2>>$fLog 1>>$fLog
-
-
-#-----------------------------------------------------------
-# Test: with not allowed key values
-#-----------------------------------------------------------
-cat > $fRules <> $fLog
-echo "file: $f" >> $fLog
-${tools_dir}/codes_bufr_filter $fRules $f 2>> $fLog 1>> $fLog
-if [ $? -eq 0 ]; then
- echo "bufr_filter should have failed if key value is not allowed" >&2
- exit 1
-fi
-set -e
-
-# Now repeat with -f option (do not exit on error)
-${tools_dir}/codes_bufr_filter -f $fRules $f 2>>$fLog 1>>$fLog
-
-
-#-----------------------------------------------------------
-# Test: with invalid string key
-#-----------------------------------------------------------
-cat > $fRules <> $fLog
-${tools_dir}/codes_bufr_filter $fRules $f 2>> $fLog 1>> $fLog
-if [ $? -eq 0 ]; then
- echo "bufr_filter should have failed if string key is invalid" >&2
- exit 1
-fi
-set -e
-
-
#----------------------------------------------------
# Test: format specifier for integer keys
#----------------------------------------------------
@@ -1340,14 +1270,6 @@ diff $fRef $fLog
rm -f $fRef
-# Bad filter
-set +e
-${tools_dir}/bufr_filter a_non_existent_filter_file $ECCODES_SAMPLES_PATH/BUFR4.tmpl > $tempErr 2>&1
-status=$?
-set -e
-[ $status -ne 0 ]
-grep -q "Cannot include file" $tempErr
-
# Clean up
rm -f ${f}.log ${f}.log.ref ${f}.out $fLog $fRules
diff --git a/tests/bufr_get.sh b/tests/bufr_get.sh
index 57dade77e..0449cfc92 100755
--- a/tests/bufr_get.sh
+++ b/tests/bufr_get.sh
@@ -120,6 +120,18 @@ result=`${tools_dir}/bufr_get -p unpack:s,heightOfStation aaen_55.bufr`
[ "$result" = "0 858000" ]
+# ----------------------------------------
+# Unreadable message
+# ----------------------------------------
+echo BUFR > $fTmp
+set +e
+${tools_dir}/bufr_get -p edition $fTmp > $fLog 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+grep -q "unreadable message" $fLog
+
+
# Clean up
rm -f $fLog $fTmp $res_get $tempRef
diff --git a/tests/bufr_ls.sh b/tests/bufr_ls.sh
index 2879ed36f..0aed3128e 100755
--- a/tests/bufr_ls.sh
+++ b/tests/bufr_ls.sh
@@ -64,6 +64,11 @@ ${tools_dir}/bufr_ls -s satelliteID=313 -p satelliteID aaen_55.bufr > $fTmp
grep -q "313" $fTmp
+# ------------------------
+# Test -w
+# ------------------------
+${tools_dir}/bufr_ls -w count=2 syno_multi.bufr
+
# ------------------------
# Test corner cases
# ------------------------
diff --git a/tests/bufr_set.sh b/tests/bufr_set.sh
index b0f901d95..f8224c0e1 100755
--- a/tests/bufr_set.sh
+++ b/tests/bufr_set.sh
@@ -10,8 +10,6 @@
. ./include.ctest.sh
-#set -x
-
# Enter data dir
cd ${data_dir}/bufr
@@ -26,10 +24,9 @@ touch $fLog
# Define tmp bufr file
fBufrTmp=${label}".bufr.tmp"
-#----------------------------------------------------
+#-----------------------------------------------
# Test: setting header for single message file
-#----------------------------------------------------
-
+#-----------------------------------------------
rm -f $fBufrTmp
f="syno_1.bufr"
@@ -43,7 +40,6 @@ centre=`${tools_dir}/bufr_get -p bufrHeaderCentre $fBufrTmp`
#----------------------------------------------------
# Test: setting header for multi-message file
#----------------------------------------------------
-
rm -f $fBufrTmp
f="syno_multi.bufr"
@@ -60,7 +56,6 @@ done
#-----------------------------------------------------
# Test: setting data values for single message file
#-----------------------------------------------------
-
# TODO: when ECC-37 is fixed we need to enable it.
rm -f $fBufrTmp
@@ -77,7 +72,6 @@ echo "file: $f" >> $fLog
#----------------------------------------------------
# Test: setting header for multi-message file
#----------------------------------------------------
-
# TODO: when ECC-37 is fixed we need to enable it.
rm -f $fBufrTmp
@@ -93,13 +87,22 @@ echo "file: $f" >> $fLog
#done
#-----------------------------------------------------------
-# Test: with nonexistent keys.
+# Test: No keys set
+#-----------------------------------------------------------
+set +e
+${tools_dir}/bufr_set $f $fBufrTmp > $fLog 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+grep -q "provide some keys to set" $fLog
+
+#-----------------------------------------------------------
+# Test: with nonexistent keys
#-----------------------------------------------------------
# Key "center" does not exist!!
# Invoke without -f i.e. should fail if error encountered
set +e
-
f="syno_1.bufr"
echo "Test: nonexistent keys" >> $fLog
echo "file: $f" >> $fLog
@@ -117,12 +120,10 @@ ${tools_dir}/bufr_set -f -s center=98 $f $fBufrTmp 2>>$fLog 1>>$fLog
#-----------------------------------------------------------
# Test: with not allowed key values
#-----------------------------------------------------------
-
# Here 1024 is out of range for centre (it is 8-bit only for edition=3 files)
# Invoke without -f i.e. should fail if error encountered
set +e
-
f="syno_1.bufr"
echo "Test: nonexistent keys" >> $fLog
echo "file: $f" >> $fLog
@@ -179,15 +180,16 @@ result=`${tools_dir}/bufr_get -p ident $fBufrTmp`
#-----------------------------------------------------------
# ECC-1359: string that can be converted to an integer
# ----------------------------------------------------------
-${tools_dir}/bufr_set -s messageLength:s=333 $ECCODES_SAMPLES_PATH/BUFR4_local.tmpl $fBufrTmp
+sample=$ECCODES_SAMPLES_PATH/BUFR4_local.tmpl
+${tools_dir}/bufr_set -s messageLength:s=333 $sample $fBufrTmp
result=`${tools_dir}/bufr_get -p messageLength $fBufrTmp`
[ "$result" = "333" ]
-
#-----------------------------------------------------------
# Invalid masterTablesVersionNumber
#-----------------------------------------------------------
-${tools_dir}/bufr_set -s masterTablesVersionNumber=255 $ECCODES_SAMPLES_PATH/BUFR4.tmpl $fBufrTmp
+sample=$ECCODES_SAMPLES_PATH/BUFR4.tmpl
+${tools_dir}/bufr_set -s masterTablesVersionNumber=255 $sample $fBufrTmp
set +e
${tools_dir}/bufr_dump -p $fBufrTmp 2>>$fLog 1>>$fLog
if [ $? -eq 0 ]; then
@@ -198,6 +200,25 @@ set -e
grep -q "unable to find definition file sequence.def.*bufr/tables/0/local/0/98/0/sequence.def" $fLog
grep -q "ECCODES ERROR.*unable to get hash value for sequences" $fLog
+# ECC-1739
+sample=$ECCODES_SAMPLES_PATH/BUFR3.tmpl
+${tools_dir}/bufr_set -s masterTablesVersionNumber=255,localTablesVersionNumber=1 $sample $fBufrTmp
+set +e
+${tools_dir}/bufr_dump -p $fBufrTmp >$fLog 2>&1
+status=$?
+set -e
+grep -q "ECCODES ERROR.*unable to get hash value for sequences" $fLog
+
+
+# Unreadable message
+#-----------------------------------------------------------
+echo BUFR > $fBufrTmp
+set +e
+${tools_dir}/bufr_set -s masterTablesVersionNumber=10 $fBufrTmp /dev/null > $fLog 2>&1
+status=$?
+set -e
+grep -q "unreadable message" $fLog
+
# Clean up
rm -f $fLog
diff --git a/tests/extract_offsets.sh b/tests/extract_offsets.sh
index 828a4dd3f..b36005cb9 100755
--- a/tests/extract_offsets.sh
+++ b/tests/extract_offsets.sh
@@ -48,5 +48,13 @@ set -e
[ $status -ne 0 ]
grep -q "Wrong message length" $tempLog
+set +e
+$EXEC ${test_dir}/extract_offsets nonexistentfile > $tempLog 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+grep -q "Unable to read file" $tempLog
+
+
# Clean up
rm -f $temp1 $temp2 $tempLog
diff --git a/tests/filter_transient_darray.sh b/tests/filter_transient_darray.sh
new file mode 100755
index 000000000..49024fa79
--- /dev/null
+++ b/tests/filter_transient_darray.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+# (C) Copyright 2005- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+#
+
+. ./include.ctest.sh
+
+label="filter_transient_darray_test"
+
+tempOut=temp.$label.out
+tempRef=temp.$label.ref
+tempFilt=temp.$label.filt
+sample=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
+
+cat > $tempFilt < $tempOut
+
+cat > $tempRef <$outfile 2>&1
+status=$?
+set -e
+[ $status -eq 1 ]
+grep -q "Invalid absolute error" $outfile
+
# ----------------------------------------
# ECC-355: -R with "all" option
@@ -161,6 +169,23 @@ ${tools_dir}/grib_compare -b $BLACKLIST -R referenceValue=0.03,codedValues=2 $te
# Now try the "all" option with the highest relative diff value
${tools_dir}/grib_compare -b $BLACKLIST -R all=2 $temp1 $temp2
+# ----------------------------------------
+# Use -w switch
+# ----------------------------------------
+cp ${data_dir}/tigge_cf_ecmwf.grib2 $temp1
+${tools_dir}/grib_compare -w typeOfLevel=surface ${data_dir}/tigge_cf_ecmwf.grib2 $temp1
+
+# ----------------------------------------
+# Summary mode (-f)
+# ----------------------------------------
+set +e
+${tools_dir}/grib_compare -f ${data_dir}/tigge_cf_ecmwf.grib2 ${data_dir}/tigge_pf_ecmwf.grib2 > $outfile 2>&1
+status=$?
+set -e
+[ $status -eq 1 ]
+grep -q "indicatorOfUnitForTimeIncrement . 7 different" $outfile
+
+
# ----------------------------------------
# ECC-651: Two-way (symmetric) comparison
# ----------------------------------------
@@ -217,14 +242,14 @@ sample_g2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
# --------------------------------------------
${tools_dir}/grib_set -s scaleFactorOfFirstFixedSurface=1 $sample_g2 $temp1
set +e
-${tools_dir}/grib_compare $sample_g2 $temp1 > $outfile
+${tools_dir}/grib_compare -v $sample_g2 $temp1 > $outfile
status=$?
set -e
[ $status -eq 1 ]
grep -q "scaleFactorOfFirstFixedSurface is set to missing in 1st field but is not missing in 2nd field" $outfile
set +e
-${tools_dir}/grib_compare $temp1 $sample_g2 > $outfile
+${tools_dir}/grib_compare -v $temp1 $sample_g2 > $outfile
status=$?
set -e
[ $status -eq 1 ]
@@ -271,6 +296,15 @@ set -e
[ $status -eq 1 ]
+echo GRIB > $temp1
+echo GRIB > $temp2
+set +e
+${tools_dir}/grib_compare $temp1 $temp2 > $outfile 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+grep "unreadable message" $outfile
+
# Clean up
# ---------
rm -f $temp1 $temp2
diff --git a/tests/grib_dump.sh b/tests/grib_dump.sh
index 472e11d6e..33655a60a 100755
--- a/tests/grib_dump.sh
+++ b/tests/grib_dump.sh
@@ -108,5 +108,25 @@ ${tools_dir}/grib_dump -w count=4 $file > $temp 2>&1
ECCODES_DEBUG=1 ${tools_dir}/grib_dump $data_dir/sample.grib2
+
+# Unreadable message
+#-----------------------------------------------------------
+tempOut=temp.$label.out
+echo GRIB > $temp
+
+set +e
+${tools_dir}/grib_dump $temp > $tempOut 2>&1
+status=$?
+set -e
+grep -q "unreadable message" $tempOut
+
+set +e
+${tools_dir}/grib_dump -j $temp > $tempOut 2>&1
+status=$?
+set -e
+grep -q "unreadable message" $tempOut
+
+rm -f $tempOut
+
# Clean up
rm -f $temp
diff --git a/tests/grib_ecc-1212.sh b/tests/grib_ecc-1212.sh
index 7ae426756..e1f32e596 100755
--- a/tests/grib_ecc-1212.sh
+++ b/tests/grib_ecc-1212.sh
@@ -66,7 +66,6 @@ cat > $tempRef < $tempOut
# edition centre date time dataType gridType typeOfLevel level shortName packingType
echo "2 ecmf 20200805 1200 an regular_ll surface 0 t grid_simple" > $tempRef
-cat $tempOut
diff -w $tempRef $tempOut
# Check "time" namespace
@@ -84,7 +82,6 @@ ${tools_dir}/grib_get -n time $tempGrib > $tempOut
echo "h 20200804 0000 36" > $tempRef
diff -w $tempRef $tempOut
-
# numberOfForecastsUsedInLocalTime > 1
# ------------------------------------
cat > $tempFilt < $tempOut 2
cat $tempOut
grep "rubbish must fail" $tempOut
grep "garbage must fail" $tempOut
-grep "unable to get rubbish as string" $tempOut
-grep "unable to get garbage as string" $tempOut
+grep "Unable to get rubbish as string" $tempOut
+grep "Unable to get garbage as string" $tempOut
# Use of "abs"
diff --git a/tests/grib_get_fail.sh b/tests/grib_get_fail.sh
index a94ad80f6..d7d0d5b1b 100755
--- a/tests/grib_get_fail.sh
+++ b/tests/grib_get_fail.sh
@@ -32,5 +32,54 @@ set -e
[ $status -ne 0 ]
grep -q "Nh (Key/value not found)" $tempText
+
+# Nearest
+# ---------
+set +e
+${tools_dir}/grib_get -s Nj=MISSING -l 0,0,1 $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib1.tmpl > $tempText 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+grep -q "Key Nj cannot be 'missing'" $tempText
+
+set +e
+${tools_dir}/grib_get -s Nj=0 -l 0,0,1 $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib1.tmpl > $tempText 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+grep -q "Key Nj cannot be 0" $tempText
+
+
+set +e
+${tools_dir}/grib_get -l 0,0,5 $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib1.tmpl > $tempText 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+grep -q "Wrong mode given" $tempText
+
+
+set +e
+${tools_dir}/grib_get -l 0,0,1,nonexistingmask $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib1.tmpl > $tempText 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+cat $tempText
+grep -q "unable to open mask file" $tempText
+
+
+# ------------------------
+# Unreadable message
+# ------------------------
+outfile=temp.$label.out
+echo GRIB > $outfile
+set +e
+${tools_dir}/grib_get -p edition $outfile /dev/null > $tempText 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+grep -q "unreadable message" $tempText
+rm -f $outfile
+
+
# Clean up
rm -f $tempText
diff --git a/tests/grib_indexing.sh b/tests/grib_indexing.sh
index 5fe1460ff..58980f85d 100755
--- a/tests/grib_indexing.sh
+++ b/tests/grib_indexing.sh
@@ -35,7 +35,6 @@ ${tools_dir}/grib_index_build -N -o $tempIndex ${infile} >/dev/null
# Must remove first two lines (filename specifics)
${tools_dir}/grib_dump ${tempIndex} | sed '1,2d' > $tempOut
-#cat $tempOut
cat > $tempRef <$tempOut
status=$?
set -e
[ $status -ne 0 ]
-cat $tempOut
grep -q "Indexes contained in the input files have different keys" $tempOut
rm -f $tempIndex1 $tempIndex2 $tempOut
@@ -130,7 +128,6 @@ ${tools_dir}/grib_compare -v $tempIndex2 $tempIndex1 2>$tempOut
status=$?
set -e
[ $status -ne 0 ]
-cat $tempOut
grep -q "Indexes contained in the input files have different keys" $tempOut
rm -f $tempIndex1 $tempIndex2 $tempOut
diff --git a/tests/grib_iterator.sh b/tests/grib_iterator.sh
index 4b8eec5f7..8c9a4fbf8 100755
--- a/tests/grib_iterator.sh
+++ b/tests/grib_iterator.sh
@@ -26,11 +26,11 @@ files="reduced_latlon_surface.grib1 \
regular_latlon_surface.grib2"
for f in $files; do
- file=${data_dir}/$f
- # Must exclude the first line of grib_get_data which is "Latitude Longitude Value"
- iterator_count=`${tools_dir}/grib_get_data -m 9999:missing -f -p centre -F "%g" -w count=1 $file | grep -v Lat |wc -l `
- numberOfPoints=`${tools_dir}/grib_get -w count=1 -p numberOfPoints $file`
- [ $numberOfPoints = ${iterator_count} ]
+ file=${data_dir}/$f
+ # Must exclude the first line of grib_get_data which is "Latitude Longitude Value"
+ iterator_count=`${tools_dir}/grib_get_data -m 9999:missing -f -p centre -F "%g" -w count=1 $file | grep -v Lat |wc -l `
+ numberOfPoints=`${tools_dir}/grib_get -w count=1 -p numberOfPoints $file`
+ [ $numberOfPoints = ${iterator_count} ]
done
@@ -51,7 +51,7 @@ ${tools_dir}/grib_set -s Ni=33 $samp_dir/GRIB2.tmpl $tempGrib
set +e
${tools_dir}/grib_get_data $tempGrib > $tempText 2>&1
status=$?
-set +e
+set -e
[ $status -ne 0 ]
grep -q "Grid description is wrong or inconsistent" $tempText
@@ -60,16 +60,61 @@ ${tools_dir}/grib_set -s Ni=MISSING $samp_dir/GRIB2.tmpl $tempGrib
set +e
${tools_dir}/grib_get_data $tempGrib > $tempText 2>&1
status=$?
-set +e
+set -e
[ $status -ne 0 ]
grep -q "Grid description is wrong or inconsistent" $tempText
+set +e
${tools_dir}/grib_ls -s Ni=missing -j -p latLonValues $data_dir/sample.grib2 > $tempText 2>&1
-cat $tempText
+status=$?
+set -e
+[ $status -ne 0 ]
grep -q "Key Ni cannot be 'missing' for a regular grid" $tempText
grep -q "latlonvalues: Unable to create iterator" $tempText
+# -w option
+${tools_dir}/grib_get_data -w count=11 $data_dir/tigge_cf_ecmwf.grib2 > $tempText
+
+
+# ------------------------
+# Bad key
+# ------------------------
+${tools_dir}/grib_get_data -f -p nonexistingkey $data_dir/sample.grib2 > $tempText
+grep -q "not found" $tempText
+
+
+# ------------------------
+# Unreadable message
+# ------------------------
+echo GRIB > $tempGrib
+set +e
+${tools_dir}/grib_get_data $tempGrib > $tempText 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+cat $tempText
+grep -q "unreadable message" $tempText
+
+# Legacy Gaussian sub-area (produced by old ProdGen)
+# See ECC-906:
+# grib_get_data not working correctly with old-style sub-areas of reduced grids
+# -------------------------------------------------
+input=$data_dir/reduced_gaussian_sub_area.legacy.grib1
+if [ -f "$input" ]; then
+ ${tools_dir}/grib_get_data $input > $tempText
+ grib_check_key_equals $input legacyGaussSubarea 1
+
+ ECCODES_DEBUG=-1 ${tools_dir}/grib_ls -p numberOfDataPoints $input > $tempText 2>&1
+ grep -q "LEGACY MODE activated. Count.=253982. changed to num values.=254139" $tempText
+fi
+
+# Iterate with DEBUG on
+input=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl
+ECCODES_DEBUG=1 ${tools_dir}/grib_get_data $input > $tempText 2>&1
+grep "global num points=6114" $tempText
+
+
# Clean up
rm -f $tempText $tempGrib
diff --git a/tests/grib_jpeg.sh b/tests/grib_jpeg.sh
index dfe8a8f61..69210430e 100755
--- a/tests/grib_jpeg.sh
+++ b/tests/grib_jpeg.sh
@@ -156,5 +156,15 @@ ECCODES_GRIB_DUMP_JPG_FILE=$tempDump ${tools_dir}/grib_copy -r $data_dir/jpeg.g
[ -f $tempDump ]
rm -f $tempDump
+# Check Jasper decoding when it is disabled
+if [ $HAVE_LIBJASPER -eq 0 ]; then
+ set +e
+ ECCODES_GRIB_JPEG=jasper ${tools_dir}/grib_get -n statistics $data_dir/jpeg.grib2 > $tempDump 2>&1
+ status=$?
+ set -e
+ [ $status -ne 0 ]
+ grep -q "JasPer JPEG support not enabled" $tempDump
+fi
+
# Clean up
-rm -f $tempFilt $tempGrib
+rm -f $tempFilt $tempGrib $tempDump
diff --git a/tests/grib_ls.sh b/tests/grib_ls.sh
index 2a6f6c5ab..1101d4d52 100755
--- a/tests/grib_ls.sh
+++ b/tests/grib_ls.sh
@@ -225,6 +225,8 @@ grib_check_key_equals $file 'expver:s' '0001'
${tools_dir}/grib_ls -j -l0,0 -p referenceValue:d $data_dir/sample.grib2
${tools_dir}/grib_ls -j -l0,0 -p referenceValue:i $data_dir/sample.grib2
+${tools_dir}/grib_get -l0,0,4 $data_dir/sample.grib2
+
set +e
${tools_dir}/grib_ls -l0,0,666 $data_dir/sample.grib2 > $tempText 2>&1
status=$?
@@ -233,5 +235,13 @@ set -e
grep -q "Wrong mode given" $tempText
+set +e
+${tools_dir}/grib_ls -l0,0,1,nonexistingmask $data_dir/sample.grib2 > $tempText 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+grep -q "unable to open mask file" $tempText
+
+
# Clean up
rm -f $temp1 $temp2 $tempText $tempLog
diff --git a/tests/grib_padding.sh b/tests/grib_padding.sh
index daa64fe8f..6aeb757ec 100755
--- a/tests/grib_padding.sh
+++ b/tests/grib_padding.sh
@@ -15,6 +15,11 @@ REDIRECT=/dev/null
tempGrib=temp.local.$label.grib1
tempFilt=temp.local.$label.filt
+if [ $ECCODES_ON_WINDOWS -eq 1 ]; then
+ echo "$0: This test is currently disabled on Windows"
+ exit 0
+fi
+
${tools_dir}/grib_set -s setLocalDefinition=1 ${data_dir}/regular_latlon_surface.grib1 $tempGrib
cat > $tempFilt < $tempErr 2>&1
set -e
-grep -q "unable to set double array codedValues" $tempErr
+grep -q "Unable to set double array 'codedValues'" $tempErr
# Nearest neighbour
# ----------------------
diff --git a/tests/grib_repair.sh b/tests/grib_repair.sh
new file mode 100755
index 000000000..876ebdff0
--- /dev/null
+++ b/tests/grib_repair.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# (C) Copyright 2005- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+#
+
+. ./include.ctest.sh
+
+label="grib_repair_test"
+tempText=temp.$label.txt
+tempGoodGribs=temp.$label.good.grib
+tempBadGribs=temp.$label.bad.grib
+
+if [ -e "${tools_dir}/grib_repair" ]; then
+ export ECCODES_GRIB_REPAIR_MAX_NUM_MESSAGES=3
+ ${tools_dir}/grib_repair $data_dir/bad.grib $tempGoodGribs $tempBadGribs > $tempText 2>&1
+ grep -q "Wrong message length" $tempText
+
+ count=$( ${tools_dir}/grib_count $tempGoodGribs )
+ [ $count -eq 1 ]
+
+ count=$( ${tools_dir}/grib_count $tempBadGribs )
+ [ $count -eq 3 ]
+
+ ${tools_dir}/grib_ls $tempGoodGribs
+ ${tools_dir}/grib_ls $tempBadGribs
+fi
+
+# Clean up
+rm -f $tempText $tempGoodGribs $tempBadGribs
diff --git a/tests/grib_second_order.sh b/tests/grib_second_order.sh
index a50c8f681..37bc89cd5 100755
--- a/tests/grib_second_order.sh
+++ b/tests/grib_second_order.sh
@@ -201,6 +201,13 @@ ${tools_dir}/grib_ls -l46,1 $temp1 > $REDIRECT
${tools_dir}/grib_ls -j -l46,1,1 $temp1 > $REDIRECT
+# Encoding
+input=second_ord_rbr.grib1
+${tools_dir}/grib_set -s scaleValuesBy=1.01 $input $temp1
+${tools_dir}/grib_dump $temp1
+grib_check_key_equals $temp1 packingType grid_second_order
+
+
# Clean up
rm -f $temp_stat1 $temp_stat2
rm -f $temp1 $temp2 $temp3 $sec_ord_bmp
diff --git a/tests/grib_secondary_bitmap.sh b/tests/grib_secondary_bitmap.sh
new file mode 100755
index 000000000..11af77e6b
--- /dev/null
+++ b/tests/grib_secondary_bitmap.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+# (C) Copyright 2005- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+#
+
+. ./include.ctest.sh
+
+label="grib_secondary_bitmap_test"
+tempGribA=temp.$label.A.grib
+tempGribB=temp.$label.B.grib
+tempFilt=temp.$label.filt
+tempLog=temp.$label.log
+tempRef=temp.$label.ref
+
+# Use a GRIB2 input with a bitmap
+input=$data_dir/reduced_latlon_surface.grib2
+grib_check_key_equals $input bitmapPresent 1
+${tools_dir}/grib_set -s packingType=grid_simple_matrix,NC=1,NR=1 $input $tempGribA
+${tools_dir}/grib_set -s matrixBitmapsPresent=1 $tempGribA $tempGribB
+${tools_dir}/grib_dump -O $tempGribB
+${tools_dir}/grib_dump -Dat $tempGribB
+
+# Call pack_double and unpack_double
+cat >$tempFilt<
+#include
+#undef NDEBUG
+#include
+
+#include "eccodes.h"
+
+int main(int argc, char** argv)
+{
+ int err = 0, i = 0, NUM_MISSING = 10;
+ codes_handle* h = NULL;
+ size_t values_len = 0;
+ long Ni = 0, Nj = 0;
+ double* values = NULL;
+ const double missing = 1.0e36;
+ bool use_bitmap = false;
+
+ if (argc == 2 && strcmp(argv[1], "-b")==0) {
+ use_bitmap = true;
+ }
+
+ h = codes_grib_handle_new_from_samples(NULL, "GRIB1");
+ assert(h);
+
+ CODES_CHECK(codes_set_double(h, "missingValue", missing), 0);
+
+ Ni = Nj = 20000;
+ values_len = Ni * Nj;
+
+ values = (double*)calloc(values_len, sizeof(double));
+
+ CODES_CHECK(codes_set_long(h, "Ni", Ni), 0);
+ CODES_CHECK(codes_set_long(h, "Nj", Nj), 0);
+
+ if (use_bitmap) {
+ printf("Adding a bitmap...\n");
+ CODES_CHECK(codes_set_long(h, "bitmapPresent", 1), 0);
+ for (i = 0; i < NUM_MISSING; i++) {
+ values[i] = missing;
+ }
+ } else {
+ printf("Not adding a bitmap...\n");
+ values[0] = 42;
+ values[1] = 52;
+ }
+
+ printf("Setting the values array...\n");
+ err = codes_set_double_array(h, "values", values, values_len);
+ if (err) {
+ printf("codes_set_double_array failed as expected: err=%s\n", codes_get_error_message(err));
+ } else {
+ fprintf(stderr, "Error: codes_set_double_array should have failed!\n");
+ return 1;
+ }
+
+ codes_handle_delete(h);
+ free(values);
+
+ return 0;
+}
diff --git a/tests/grib_set_large_message_fail.sh b/tests/grib_set_large_message_fail.sh
new file mode 100755
index 000000000..9e8a4c775
--- /dev/null
+++ b/tests/grib_set_large_message_fail.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+# (C) Copyright 2005- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+#
+
+. ./include.ctest.sh
+
+label='grib_set_large_message_fail_test'
+temp=temp.$label.txt
+
+$EXEC ${test_dir}/grib_set_large_message_fail > $temp 2>&1
+grep -q "Failed to set GRIB1 message length" $temp
+
+$EXEC ${test_dir}/grib_set_large_message_fail -b > $temp 2>&1
+grep -q "Unable to set double array.*bitmap" $temp
+
+# Clean up
+rm -f $temp
diff --git a/tests/gts_compare.sh b/tests/gts_compare.sh
index 3fd648a1d..0860530c3 100755
--- a/tests/gts_compare.sh
+++ b/tests/gts_compare.sh
@@ -64,7 +64,34 @@ set -e
# Add correct blocklist
${tools_dir}/gts_compare -b GG $gts_file $fGtsTmp
+#----------------------------------------------------
+# Compare using -c
+#----------------------------------------------------
+temp1=temp.$label.1.gts
+temp2=temp.$label.2.gts
+# Pick two messages which do have different contents
+${tools_dir}/gts_copy -w count=1 $gts_file $temp1
+${tools_dir}/gts_copy -w count=4 $gts_file $temp2
+${tools_dir}/gts_compare -c theMessage $temp1 $temp2
+${tools_dir}/gts_compare -c theMessage -a $temp1 $temp2
+
+set +e
+${tools_dir}/gts_compare -c ls:n $temp1 $temp2
+status=$?
+set -e
+[ $status -eq 1 ]
+
+set +e
+${tools_dir}/gts_compare -c ls:n -a $temp1 $temp2
+status=$?
+set -e
+[ $status -eq 1 ]
+
+rm -f $temp1 $temp2
+
+#----------------------------------------------------
# Test with file of the same name in a dir
+#----------------------------------------------------
tempDir=temp.$label.dir
rm -fr $tempDir
mkdir $tempDir
diff --git a/tests/gts_dump.sh b/tests/gts_dump.sh
new file mode 100755
index 000000000..b8c8db2e8
--- /dev/null
+++ b/tests/gts_dump.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# (C) Copyright 2005- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+#
+
+. ./include.ctest.sh
+
+label="gts_dump_test"
+
+fLog=${label}.log
+fTmp=${label}.tmp.txt
+
+# Enter data dir
+cd ${data_dir}/gts
+
+gts_file=EGRR20150317121020_00493212.DAT
+${tools_dir}/gts_dump -w count=1 $gts_file
+${tools_dir}/gts_dump -Dat $gts_file
+${tools_dir}/gts_dump -OH $gts_file
+
+# Clean up
+rm -f $fLog $fTmp
diff --git a/tests/gts_get.sh b/tests/gts_get.sh
index 0bea9b259..2f50f10f6 100755
--- a/tests/gts_get.sh
+++ b/tests/gts_get.sh
@@ -26,6 +26,12 @@ fTmp=${label}".tmp.txt"
gts_file=EGRR20150317121020_00493212.DAT
${tools_dir}/gts_get -p TT,AA,II,CCCC,YY,GG,gg,BBB $gts_file >/dev/null
+#----------------------------------------------
+# Test "-w" switch
+#----------------------------------------------
+${tools_dir}/gts_get -p TT -w count=3 $gts_file >/dev/null
+
+
gts_file=${data_dir}/gts.grib
result=$( ${tools_dir}/grib_get -wcount=1 -p gts_CCCC -g $gts_file )
[ "$result" = "ECMG" ]
diff --git a/tests/gts_ls.sh b/tests/gts_ls.sh
index ca6fbf29e..1cd4cc9fb 100755
--- a/tests/gts_ls.sh
+++ b/tests/gts_ls.sh
@@ -25,15 +25,25 @@ touch $fLog
fTmp=${label}".tmp.txt"
rm -f $fTmp
-#----------------------------------------------
-# Test default "ls" on all the gts data files
-#----------------------------------------------
+#-------------------------------------------
+# Test default "ls" on the gts data file
+#-------------------------------------------
gts_file=EGRR20150317121020_00493212.DAT
f=$gts_file
echo $f >> $fLog
${tools_dir}/gts_ls $f >> $fLog
+#-------------------------------------------
+# Test "-s" switch
+#-------------------------------------------
+${tools_dir}/gts_ls -s YY=abc $f >> $fLog
+
+#-------------------------------------------
+# Test "-w" switch
+#-------------------------------------------
+${tools_dir}/gts_ls -w AA=IY $f >> $fLog
+
#-------------------------------------------
# Test "-p" switch
#-------------------------------------------
@@ -52,10 +62,18 @@ echo 'print "[theMessage]";' | ${tools_dir}/gts_filter - $gts_file
${tools_dir}/gts_ls -wcount=1 -p theMessage $f
-
gts_file=${data_dir}/gts.grib
result=$( ${tools_dir}/grib_ls -wcount=1 -p gts_CCCC -g $gts_file )
+# Bad filter
+set +e
+${tools_dir}/gts_filter a_non_existent_filter_file $gts_file > $fLog 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+grep -q "Cannot include file" $fLog
+
+
# Clean up
rm -f $fLog $res_ls
diff --git a/tests/hdf5.sh b/tests/hdf5.sh
new file mode 100755
index 000000000..c1c41597e
--- /dev/null
+++ b/tests/hdf5.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# (C) Copyright 2005- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+#
+
+. ./include.ctest.sh
+
+label="hdf5_test"
+
+if [ $ECCODES_ON_WINDOWS -eq 1 ]; then
+ echo "$0: This test is currently disabled on Windows"
+ exit 0
+fi
+
+tempOut=temp.${label}.out
+tempTxt=temp.${label}.txt
+tempRef=temp.${label}.ref
+
+input=$ECCODES_SAMPLES_PATH/hdf5.tmpl
+
+${tools_dir}/grib_dump -TA -O $input > $tempTxt
+grep -q "versionNumberOfSuperblock = 2" $tempTxt
+grep -q "endOfFileAddress = 342" $tempTxt
+
+id=`${tools_dir}/grib_get -TA -p identifier $input`
+[ "$id" = "HDF5" ]
+
+# Clean up
+rm -f $tempOut $tempRef $tempTxt
diff --git a/tests/metar_compare.sh b/tests/metar_compare.sh
index 6311e8597..2d43f289c 100755
--- a/tests/metar_compare.sh
+++ b/tests/metar_compare.sh
@@ -65,6 +65,18 @@ grep -q "DIFFERENCE == string.*theMessage" $fLog
# The -d option should have created these files
rm -f error1_1.metar error2_1.metar error1_2.metar error2_2.metar
+#----------------------------------------------------
+# Compare a key of type double
+#----------------------------------------------------
+temp1=temp.$label.metar.1
+temp2=temp.$label.metar.2
+${tools_dir}/metar_copy -w count=1 $metar_file $temp1
+${tools_dir}/metar_copy -w count=2 $metar_file $temp2
+# absolute diff. = 16.53, relative diff. = 0.381315
+${tools_dir}/metar_compare -c latitude -R latitude=0.4 $temp1 $temp2
+${tools_dir}/metar_compare -c latitude -A 17 $temp1 $temp2
+rm -f $temp1 $temp2
+
#----------------------------------------------------
# Test: comparing with and without the -b switch
#----------------------------------------------------
diff --git a/tests/metar_dump.sh b/tests/metar_dump.sh
index 03d73e08e..86389a0e0 100755
--- a/tests/metar_dump.sh
+++ b/tests/metar_dump.sh
@@ -34,11 +34,10 @@ metar_file=metar.txt
f=$metar_file
echo $f >> $fLog
-${tools_dir}/metar_dump $f >> $fLog
+${tools_dir}/metar_dump -w count=1 $f >> $fLog
+${tools_dir}/metar_dump -Dat $f >> $fLog
+${tools_dir}/metar_dump -OH $f >> $fLog
-#-------------------------------------------
-# Test "-p" switch
-#-------------------------------------------
ref_dump=$f".dump.ref"
res_dump=$f".dump.test"
REDIRECT=/dev/null
@@ -47,4 +46,14 @@ ${tools_dir}/metar_dump $f 2> $REDIRECT > $res_dump
diff $ref_dump $res_dump >$REDIRECT 2> $REDIRECT
+# Data
+${tools_dir}/metar_dump -d $f
+
+# JSON
+${tools_dir}/metar_dump -j $f
+
+# Skip
+${tools_dir}/metar_dump -w count=11 $f
+
+# Clean up
rm -f $fLog $res_dump
diff --git a/tests/metar_filter.sh b/tests/metar_filter.sh
new file mode 100755
index 000000000..9699b1ec8
--- /dev/null
+++ b/tests/metar_filter.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# (C) Copyright 2005- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
+# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
+#
+
+. ./include.ctest.sh
+
+label="metar_filter_test"
+
+tempFilt="temp.$label.filt"
+tempMetar="temp.$label.metar"
+tempOut="temp.$label.txt"
+tempRef="temp.$label.ref"
+
+input=${data_dir}/metar/metar.txt
+
+cat > $tempFilt < $tempOut 2>&1
+status=$?
+set -e
+[ $status -ne 0 ]
+grep -q "Cannot include file" $tempOut
+
+
+# Clean up
+rm -f $tempMetar $tempFilt $tempOut $tempRef
diff --git a/tests/metar_get.sh b/tests/metar_get.sh
index 25613ce04..e58ede316 100755
--- a/tests/metar_get.sh
+++ b/tests/metar_get.sh
@@ -25,19 +25,26 @@ touch $fLog
fTmp=${label}".tmp.txt"
rm -f $fTmp
-#----------------------------------------------
-# Test default "ls" on all the metar data files
-#----------------------------------------------
+#-----------------------------------------
+# Test default "ls" on the metar data file
+#-----------------------------------------
metar_file=metar.txt
export METAR_YEAR=2015
export METAR_MONTH=4
${tools_dir}/metar_get -n ls $metar_file >/dev/null
${tools_dir}/metar_get -w count=1/2/3 -p CCCC,latitude,longitude,dateTime,elevation,temperature,dewPointTemperature,qnh $metar_file
+${tools_dir}/metar_get -w count=2 -p CCCC $metar_file
# Decode a 'group' key as int and double
result=$( ${tools_dir}/metar_get -p visibilityInMetres:i,visibilityInMetres:d -w count=1 $metar_file )
[ "$result" = "6000 6000" ]
+# non-alpha keys
+# ----------------
+result=$(${tools_dir}/metar_get -w count=1 -p na:i,na:d $metar_file)
+[ "$result" = "0 0" ]
+
+
# Clean up
rm -f $fLog
diff --git a/tests/metar_ls.sh b/tests/metar_ls.sh
index 8e2cfc14f..779619b8f 100755
--- a/tests/metar_ls.sh
+++ b/tests/metar_ls.sh
@@ -36,6 +36,12 @@ export METAR_MONTH=4
echo $f >> $fLog
${tools_dir}/metar_ls $f >> $fLog
+#-------------------------------------------
+# Test "-w" switch
+#-------------------------------------------
+${tools_dir}/metar_ls -w CCCC=VILK $f >> $fLog
+
+
#-------------------------------------------
# Test "-p" switch
#-------------------------------------------
diff --git a/tools/bufr_compare.cc b/tools/bufr_compare.cc
index 268d7ac8e..9a1905944 100644
--- a/tools/bufr_compare.cc
+++ b/tools/bufr_compare.cc
@@ -24,7 +24,6 @@ grib_option grib_options[] = {
{ "H", 0, "Compare only message headers. Bit-by-bit compare on. Incompatible with -c option.\n", 0, 1, 0 },
{ "R:", 0, 0, 0, 1, 0 },
{ "A:", 0, 0, 0, 1, 0 },
- /* {"P",0,"Compare data values using the packing error as tolerance.\n",0,1,0},*/
{ "t:", "factor", "Compare data values using factor multiplied by the tolerance specified in options -R -A.\n", 0, 1, 0 },
{ "w:", 0, 0, 0, 1, 0 },
{ "f", 0, 0, 0, 1, 0 },
@@ -74,7 +73,6 @@ struct grib_error
static grib_error* error_summary;
static compare_double_proc compare_double;
static double global_tolerance = 0;
-static int packingCompare = 0;
static grib_string_list* blocklist = 0;
static grib_string_list* keys_list = NULL; /* Used to determine rank of key */
static int isLeafKey = 0; /* 0 if key is top-level, 1 if key has no children attributes */
@@ -339,10 +337,6 @@ int grib_tool_init(grib_runtime_options* options)
global_tolerance = atof(grib_options_get_option("A:"));
}
}
- if (grib_options_on("P")) {
- packingCompare = 1;
- compare_double = &compare_double_absolute;
- }
if (grib_options_on("t:"))
tolerance_factor = atof(grib_options_get_option("t:"));
@@ -708,7 +702,6 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
double *dval1 = NULL, *dval2 = NULL;
long *lval1 = NULL, *lval2 = NULL;
double maxdiff = 0;
- double packingError1 = 0, packingError2 = 0;
double value_tolerance = 0;
grib_context* c = handle1->context;
const char* first_str = (handles_swapped == 0 ? "1st" : "2nd");
@@ -721,7 +714,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
if (type1 == GRIB_TYPE_UNDEFINED && (err = grib_get_native_type(handle1, name, &type1)) != GRIB_SUCCESS) {
printInfo(handle1);
- printf("Oops... cannot get type of [%s] in %s field: %s\n", name, first_str, grib_get_error_message(err));
+ printf("Error: cannot get type of [%s] in %s field: %s\n", name, first_str, grib_get_error_message(err));
save_error(c, name);
return err;
}
@@ -734,7 +727,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
return err;
}
printInfo(handle1);
- printf("Oops... cannot get type of [%s] in %s field: %s\n", name, second_str, grib_get_error_message(err));
+ printf("Error: cannot get type of [%s] in %s field: %s\n", name, second_str, grib_get_error_message(err));
save_error(c, name);
return err;
}
@@ -754,7 +747,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
if ((err = grib_get_size(handle1, name, &len1)) != GRIB_SUCCESS) {
printInfo(handle1);
- printf("Oops... cannot get size of [%s] in %s field: %s\n", name, first_str, grib_get_error_message(err));
+ printf("Error: cannot get size of [%s] in %s field: %s\n", name, first_str, grib_get_error_message(err));
save_error(c, name);
return err;
}
@@ -768,7 +761,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
}
printInfo(handle1);
- printf("Oops... cannot get size of [%s] in %s field: %s\n", name, second_str, grib_get_error_message(err));
+ printf("Error: cannot get size of [%s] in %s field: %s\n", name, second_str, grib_get_error_message(err));
save_error(c, name);
return err;
}
@@ -833,13 +826,13 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
sval2 = (char*)grib_context_malloc(handle2->context, slen2 * sizeof(char));
if ((err1 = grib_get_string(handle1, name, sval1, &slen1)) != GRIB_SUCCESS) {
printInfo(handle1);
- printf("Oops... cannot get string value of [%s] in %s field: %s\n",
+ printf("Error: cannot get string value of [%s] in %s field: %s\n",
name, first_str, grib_get_error_message(err1));
save_error(c, name);
}
if ((err2 = grib_get_string(handle2, name, sval2, &slen2)) != GRIB_SUCCESS) {
printInfo(handle1);
- printf("Oops... cannot get string value of [%s] in %s field: %s\n",
+ printf("Error: cannot get string value of [%s] in %s field: %s\n",
name, second_str, grib_get_error_message(err2));
save_error(c, name);
}
@@ -862,13 +855,13 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
if ((err1 = grib_get_string_array(handle1, name, svals1, &len1)) != GRIB_SUCCESS) {
printInfo(handle1);
- printf("Oops... cannot get string value of [%s] in %s field: %s\n",
+ printf("Error: cannot get string value of [%s] in %s field: %s\n",
name, first_str, grib_get_error_message(err1));
save_error(c, name);
}
if ((err2 = grib_get_string_array(handle2, name, svals2, &len2)) != GRIB_SUCCESS) {
printInfo(handle1);
- printf("Oops... cannot get string value of [%s] in %s field: %s\n",
+ printf("Error: cannot get string value of [%s] in %s field: %s\n",
name, second_str, grib_get_error_message(err2));
save_error(c, name);
}
@@ -917,14 +910,14 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
if ((err1 = grib_get_long_array(handle1, name, lval1, &len1)) != GRIB_SUCCESS) {
printInfo(handle1);
- printf("Oops... cannot get long value of [%s] in %s field: %s\n",
+ printf("Error: cannot get long value of [%s] in %s field: %s\n",
name, first_str, grib_get_error_message(err1));
save_error(c, name);
}
if ((err2 = grib_get_long_array(handle2, name, lval2, &len2)) != GRIB_SUCCESS) {
printInfo(handle1);
- printf("Oops... cannot get long value of [%s] in %s field: %s\n",
+ printf("Error: cannot get long value of [%s] in %s field: %s\n",
name, second_str, grib_get_error_message(err2));
save_error(c, name);
}
@@ -1002,14 +995,14 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
if ((err1 = grib_get_double_array(handle1, name, dval1, &len1)) != GRIB_SUCCESS) {
printInfo(handle1);
- printf("Oops... cannot get double value of [%s] in %s field: %s\n",
+ printf("Error: cannot get double value of [%s] in %s field: %s\n",
name, first_str, grib_get_error_message(err1));
save_error(c, name);
}
if ((err2 = grib_get_double_array(handle2, name, dval2, &len2)) != GRIB_SUCCESS) {
printInfo(handle1);
- printf("Oops... cannot get double value of [%s] in %s field: %s\n",
+ printf("Error: cannot get double value of [%s] in %s field: %s\n",
name, second_str, grib_get_error_message(err2));
save_error(c, name);
}
@@ -1020,28 +1013,13 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
save_error(c, name);
}
if (err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS && len1 == len2) {
- int imaxdiff;
+ int imaxdiff = 0;
double diff;
double *pv1, *pv2;
maxdiff = 0;
- imaxdiff = 0;
countdiff = 0;
pv1 = dval1;
pv2 = dval2;
- /* if (isangle) {
- dnew1 = *dval1;
- dnew2 = *dval2;
- pv1 = &dnew1;
- pv2 = &dnew2;
- if (*dval1 < 0)
- dnew1 += 360.0;
- if (*dval2 < 0)
- dnew2 += 360.0;
- if (*dval1 > 360)
- dnew1 -= 360.0;
- if (*dval2 > 360)
- dnew2 -= 360.0;
- } */
value_tolerance *= tolerance_factor;
if (verbose)
printf(" (%d values) tolerance=%g\n", (int)len1, value_tolerance);
@@ -1080,8 +1058,6 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
grib_context_free(c, svalA);
grib_context_free(c, svalB);
}
- if (packingError2 != 0 || packingError1 != 0)
- printf(" packingError: [%g] [%g]", packingError1, packingError2);
printf("\n");
}
@@ -1128,14 +1104,14 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
if ((err1 = grib_get_bytes(handle1, name, uval1, &len1)) != GRIB_SUCCESS) {
printInfo(handle1);
save_error(c, name);
- printf("Oops... cannot get bytes value of [%s] in %s field: %s\n",
+ printf("Error: cannot get bytes value of [%s] in %s field: %s\n",
name, first_str, grib_get_error_message(err1));
}
if ((err2 = grib_get_bytes(handle2, name, uval2, &len2)) != GRIB_SUCCESS) {
printInfo(handle1);
save_error(c, name);
- printf("Oops... cannot get bytes value of [%s] in %s field: %s\n",
+ printf("Error: cannot get bytes value of [%s] in %s field: %s\n",
name, second_str, grib_get_error_message(err2));
}
@@ -1335,12 +1311,11 @@ static int compare_handles(grib_handle* handle1, grib_handle* handle2, grib_runt
if (options->compare[i].type == CODES_NAMESPACE) {
iter = grib_keys_iterator_new(handle1, 0, options->compare[i].name);
if (!iter) {
- grib_context_log(handle1->context, GRIB_LOG_ERROR, "unable to get iterator");
+ grib_context_log(handle1->context, GRIB_LOG_ERROR, "unable to create the BUFR keys iterator");
exit(1);
}
while (grib_keys_iterator_next(iter)) {
name = grib_keys_iterator_get_name(iter);
- /*printf("----- comparing %s\n",name);*/
if (blocklisted(name))
continue;
@@ -1360,7 +1335,6 @@ static int compare_handles(grib_handle* handle1, grib_handle* handle2, grib_runt
const void *msg1 = NULL, *msg2 = NULL;
size_t size1 = 0, size2 = 0;
int memcmp_ret = 0;
- /* int ii=0; */
GRIB_CHECK_NOLINE(grib_get_message(handle1, &msg1, &size1), 0);
GRIB_CHECK_NOLINE(grib_get_message(handle2, &msg2, &size2), 0);
if (size1 == size2 && !(memcmp_ret = memcmp(msg1, msg2, size1))) {
@@ -1396,12 +1370,11 @@ static int compare_handles(grib_handle* handle1, grib_handle* handle2, grib_runt
iter = grib_keys_iterator_new(handle1, 0, options->compare[i].name);
if (!iter) {
grib_context_log(handle1->context, GRIB_LOG_ERROR,
- "ERROR: unable to get keys iterator for %s", options->compare[i].name);
+ "unable to create the BUFR keys iterator for %s", options->compare[i].name);
exit(1);
}
while (grib_keys_iterator_next(iter)) {
name = grib_keys_iterator_get_name(iter);
- /*printf("----- comparing %s\n",name);*/
if (blocklisted(name))
continue;
diff --git a/tools/bufr_set.cc b/tools/bufr_set.cc
index 4bb055fb9..687127987 100644
--- a/tools/bufr_set.cc
+++ b/tools/bufr_set.cc
@@ -13,9 +13,6 @@
grib_option grib_options[] = {
/* {id, args, help}, on, command_line, value*/
{ "s:", 0, 0, 1, 1, 0 },
- /* {"r",0,0,0,1,0}, */
- /* {"d:",0,0,0,1,0},*/
- /* {"n:","noise percentage","\n\t\tAdd noise to the data values. The noise added is the given percentage of the data value.\n",0,1,0},*/
{ "p:", 0, 0, 1, 1, 0 },
{ "P:", 0, 0, 0, 1, 0 },
{ "w:", "key[:{s|d|i}]=value,key[:{s|d|i}]=value,...",
@@ -32,7 +29,6 @@ grib_option grib_options[] = {
{ "U", 0, 0, 1, 0, 0 },
{ "V", 0, 0, 0, 1, 0 },
{ "g", 0, 0, 0, 1, 0 },
- /* {"G",0,0,0,1,0}, */
{ "T:", 0, 0, 1, 0, "B" },
{ "f", 0, 0, 0, 1, 0 },
{ "v", 0, 0, 0, 1, 0 },
@@ -67,15 +63,6 @@ int grib_tool_init(grib_runtime_options* options)
}
if (options->verbose)
options->print_header = 1;
- /*if (grib_options_on("n:")) {
- noise=atof(grib_options_get_option("n:"));
- options->repack=1;
- }*/
-
- if (grib_options_on("n:") && grib_options_on("d:")) {
- fprintf(stderr, "ERROR: -n and -d options are incompatible. Choose one of the two please.\n");
- exit(1);
- }
// if (options->outfile && options->outfile->name) {
// options->outfile->file = fopen(options->outfile->name,"w");
diff --git a/tools/grib_compare.cc b/tools/grib_compare.cc
index a538f2a8c..cace206fe 100644
--- a/tools/grib_compare.cc
+++ b/tools/grib_compare.cc
@@ -383,21 +383,19 @@ int grib_tool_init(grib_runtime_options* options)
}
}
- {
- /* Check for 2nd file being a directory. If so, we assume user is comparing to a file */
- /* with the same name as first file in that directory */
- grib_tools_file* infile = options->infile; /* the 2nd file in comparison */
- if (infile) {
- if (path_is_directory(infile->name)) {
- /* Take the filename of the 1st file and append to dir */
- char bufr[2048] = {0,};
- /* options->infile_extra->name is the 1st file */
- snprintf(bufr, sizeof(bufr), "%s%c%s",
- infile->name,
- get_dir_separator_char(),
- extract_filename(options->infile_extra->name));
- infile->name = strdup(bufr);
- }
+ // Check for 2nd file being a directory. If so, we assume user is comparing to a file
+ // with the same name as first file in that directory
+ grib_tools_file* infile = options->infile; // the 2nd file in comparison
+ if (infile) {
+ if (path_is_directory(infile->name)) {
+ // Take the filename of the 1st file and append to dir
+ char bufr[2048] = {0,};
+ // options->infile_extra->name is the 1st file
+ snprintf(bufr, sizeof(bufr), "%s%c%s",
+ infile->name,
+ get_dir_separator_char(),
+ extract_filename(options->infile_extra->name));
+ infile->name = strdup(bufr);
}
}
@@ -713,7 +711,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
if (type1 == GRIB_TYPE_UNDEFINED && (err = grib_get_native_type(h1, name, &type1)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get type of [%s] in %s field: %s\n", name, first_str, grib_get_error_message(err));
+ printf("Error: cannot get type of [%s] in %s field: %s\n", name, first_str, grib_get_error_message(err));
save_error(c, name);
return err;
}
@@ -726,7 +724,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
return err;
}
printInfo(h1);
- printf("Oops... cannot get type of [%s] in %s field: %s\n", name, second_str, grib_get_error_message(err));
+ printf("Error: cannot get type of [%s] in %s field: %s\n", name, second_str, grib_get_error_message(err));
save_error(c, name);
return err;
}
@@ -748,7 +746,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
if ((err = grib_get_size(h1, name, &len1)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get size of [%s] in %s field: %s\n", name, first_str, grib_get_error_message(err));
+ printf("Error: cannot get size of [%s] in %s field: %s\n", name, first_str, grib_get_error_message(err));
save_error(c, name);
return err;
}
@@ -762,7 +760,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
}
printInfo(h1);
- printf("Oops... cannot get size of [%s] in %s field: %s\n", name, second_str, grib_get_error_message(err));
+ printf("Error: cannot get size of [%s] in %s field: %s\n", name, second_str, grib_get_error_message(err));
save_error(c, name);
return err;
}
@@ -820,14 +818,14 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
if ((err1 = grib_get_string(h1, name, sval1, &len1)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get string value of [%s] in %s field: %s\n",
+ printf("Error: cannot get string value of [%s] in %s field: %s\n",
name, first_str, grib_get_error_message(err1));
save_error(c, name);
}
if ((err2 = grib_get_string(h2, name, sval2, &len2)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get string value of [%s] in %s field: %s\n",
+ printf("Error: cannot get string value of [%s] in %s field: %s\n",
name, second_str, grib_get_error_message(err2));
save_error(c, name);
}
@@ -877,14 +875,14 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
if ((err1 = grib_get_long_array(h1, name, lval1, &len1)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get long value of [%s] in %s field: %s\n",
+ printf("Error: cannot get long value of [%s] in %s field: %s\n",
name, first_str, grib_get_error_message(err1));
save_error(c, name);
}
if ((err2 = grib_get_long_array(h2, name, lval2, &len2)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get long value of [%s] in %s field: %s\n",
+ printf("Error: cannot get long value of [%s] in %s field: %s\n",
name, second_str, grib_get_error_message(err2));
save_error(c, name);
}
@@ -1002,14 +1000,14 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
if ((err1 = grib_get_double_array(h1, name, dval1, &len1)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get double value of [%s] in %s field: %s\n",
+ printf("Error: cannot get double value of [%s] in %s field: %s\n",
name, first_str, grib_get_error_message(err1));
save_error(c, name);
}
if ((err2 = grib_get_double_array(h2, name, dval2, &len2)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get double value of [%s] in %s field: %s\n",
+ printf("Error: cannot get double value of [%s] in %s field: %s\n",
name, second_str, grib_get_error_message(err2));
save_error(c, name);
}
@@ -1123,14 +1121,14 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
if ((err1 = grib_get_bytes(h1, name, uval1, &len1)) != GRIB_SUCCESS) {
printInfo(h1);
save_error(c, name);
- printf("Oops... cannot get bytes value of [%s] in %s field: %s\n",
+ printf("Error: cannot get bytes value of [%s] in %s field: %s\n",
name, first_str, grib_get_error_message(err1));
}
if ((err2 = grib_get_bytes(h2, name, uval2, &len2)) != GRIB_SUCCESS) {
printInfo(h1);
save_error(c, name);
- printf("Oops... cannot get bytes value of [%s] in %s field: %s\n",
+ printf("Error: cannot get bytes value of [%s] in %s field: %s\n",
name, second_str, grib_get_error_message(err2));
}
@@ -1227,7 +1225,6 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option
h22 = grib_handle_new_from_partial_message(h1->context, msg2, size2);
iter = grib_keys_iterator_new(h11, GRIB_KEYS_ITERATOR_SKIP_COMPUTED, NULL);
-
if (!iter) {
grib_context_log(context, GRIB_LOG_ERROR, "unable to create the GRIB keys iterator");
exit(1);
@@ -1235,7 +1232,6 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option
while (grib_keys_iterator_next(iter)) {
name = grib_keys_iterator_get_name(iter);
- /*printf("----- comparing %s\n",name);*/
if (blocklisted(name))
continue;
@@ -1258,7 +1254,7 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option
int num_keys_in_namespace = 0;
iter = grib_keys_iterator_new(h1, 0, options->compare[i].name);
if (!iter) {
- printf("ERROR: unable to get keys iterator for namespace \"%s\".\n", options->compare[i].name);
+ grib_context_log(context, GRIB_LOG_ERROR, "unable to create the GRIB keys iterator for %s", options->compare[i].name);
exit(1);
}
while (grib_keys_iterator_next(iter)) {
@@ -1292,9 +1288,8 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option
return 0;
iter = grib_keys_iterator_new(h1, GRIB_KEYS_ITERATOR_SKIP_COMPUTED, NULL);
-
if (!iter) {
- printf("ERROR: unable to get keys iterator\n");
+ grib_context_log(context, GRIB_LOG_ERROR, "unable to create the GRIB keys iterator");
exit(1);
}
@@ -1318,7 +1313,7 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option
if (options->compare[i].type == CODES_NAMESPACE) {
iter = grib_keys_iterator_new(h1, 0, options->compare[i].name);
if (!iter) {
- printf("ERROR: unable to get iterator for %s\n", options->compare[i].name);
+ fprintf(stderr, "Error: unable to get keys iterator for %s\n", options->compare[i].name);
exit(1);
}
while (grib_keys_iterator_next(iter)) {
diff --git a/tools/grib_get.cc b/tools/grib_get.cc
index 6251c436f..19ae34a3e 100644
--- a/tools/grib_get.cc
+++ b/tools/grib_get.cc
@@ -113,6 +113,7 @@ int grib_tool_init(grib_runtime_options* options)
grib_handle* hh;
FILE* f = fopen(options->latlon_mask, "r");
if (!f) {
+ fprintf(stderr, "%s: unable to open mask file %s\n", tool_name, options->latlon_mask);
perror(options->latlon_mask);
exit(1);
}
diff --git a/tools/grib_ls.cc b/tools/grib_ls.cc
index 2be9333e4..ab53e200f 100644
--- a/tools/grib_ls.cc
+++ b/tools/grib_ls.cc
@@ -137,6 +137,7 @@ int grib_tool_init(grib_runtime_options* options)
int idx_overall = -1;
FILE* f = fopen(options->latlon_mask, "r");
if (!f) {
+ fprintf(stderr, "%s: unable to open mask file %s\n", tool_name, options->latlon_mask);
perror(options->latlon_mask);
exit(1);
}
diff --git a/tools/gts_compare.cc b/tools/gts_compare.cc
index c17e25c3d..b7692f65a 100644
--- a/tools/gts_compare.cc
+++ b/tools/gts_compare.cc
@@ -383,7 +383,7 @@ static void save_error(grib_context* c, const char* key)
}
}
-static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_handle* h2, const char* name, int type)
+static int compare_values(const grib_runtime_options* options, grib_handle* h1, grib_handle* h2, const char* name, int type)
{
size_t len1 = 0;
size_t len2 = 0;
@@ -395,7 +395,6 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
int isMissing1 = 0, isMissing2 = 0;
char *sval1 = NULL, *sval2 = NULL;
- unsigned char *uval1 = NULL, *uval2 = NULL;
long *lval1 = NULL, *lval2 = NULL;
grib_context* c = h1->context;
@@ -406,7 +405,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
if (type1 == GRIB_TYPE_UNDEFINED && (err = grib_get_native_type(h1, name, &type1)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get type of [%s] in 1st field: %s\n", name, grib_get_error_message(err));
+ printf("Error: cannot get type of [%s] in 1st field: %s\n", name, grib_get_error_message(err));
save_error(c, name);
return err;
}
@@ -419,31 +418,20 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
return err;
}
printInfo(h1);
- printf("Oops... cannot get type of [%s] in 2nd field: %s\n", name, grib_get_error_message(err));
+ printf("Error: cannot get type of [%s] in 2nd field: %s\n", name, grib_get_error_message(err));
save_error(c, name);
return err;
}
- /*
- if(type1 != type2)
- {
- printInfo(h1);
- printf("Warning, [%s] has different types: 1st field: [%s], 2nd field: [%s]\n",
- name,grib_get_type_name(type1),grib_get_type_name(type2));
- return GRIB_TYPE_MISMATCH;
- }
- */
-
if (type1 == GRIB_TYPE_LABEL)
return err;
if (type1 == GRIB_TYPE_SECTION)
return err;
-
if ((err = grib_get_size(h1, name, &len1)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get size of [%s] in 1st field: %s\n", name, grib_get_error_message(err));
+ printf("Error: cannot get size of [%s] in 1st field: %s\n", name, grib_get_error_message(err));
save_error(c, name);
return err;
}
@@ -457,21 +445,11 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
}
printInfo(h1);
- printf("Oops... cannot get size of [%s] in 2nd field: %s\n", name, grib_get_error_message(err));
+ printf("Error: cannot get size of [%s] in 2nd field: %s\n", name, grib_get_error_message(err));
save_error(c, name);
return err;
}
- /*
- if(len1 != len2 && type1 != GRIB_TYPE_STRING)
- {
- printInfo(h1);
- printf("[%s] has different size: 1st field: %ld, 2nd field: %ld\n",name,(long)len1,(long)len2);
- save_error(c,name);
- return GRIB_COUNT_MISMATCH;
- }
- */
-
if (options->mode != MODE_GTS) {
/* TODO: Ignore missing values for keys in GTS. Not yet implemented */
isMissing1 = ((grib_is_missing(h1, name, &err1) == 1) && (err1 == 0)) ? 1 : 0;
@@ -485,8 +463,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
}
if (isMissing1 == 1) {
- if (verbose)
- printf(" is set to missing in 1st field\n");
+ if (verbose) printf(" is set to missing in 1st field\n");
printInfo(h1);
printf("%s is set to missing in 1st field but is not missing in 2nd field\n", name);
err1 = GRIB_VALUE_MISMATCH;
@@ -495,8 +472,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
}
if (isMissing2 == 1) {
- if (verbose)
- printf(" is set to missing in 1st field\n");
+ if (verbose) printf(" is set to missing in 1st field\n");
printInfo(h1);
printf("%s is set to missing in 2nd field but is not missing in 1st field\n", name);
err1 = GRIB_VALUE_MISMATCH;
@@ -506,8 +482,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
switch (type1) {
case GRIB_TYPE_STRING:
- if (verbose)
- printf(" as string\n");
+ if (verbose) printf(" as string\n");
grib_get_string_length(h1, name, &len1);
grib_get_string_length(h2, name, &len2);
sval1 = (char*)grib_context_malloc(h1->context, len1 * sizeof(char));
@@ -515,14 +490,14 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
if ((err1 = grib_get_string(h1, name, sval1, &len1)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get string value of [%s] in 1st field: %s\n",
+ printf("Error: cannot get string value of [%s] in 1st field: %s\n",
name, grib_get_error_message(err1));
save_error(c, name);
}
if ((err2 = grib_get_string(h2, name, sval2, &len2)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get string value of [%s] in 2nd field: %s\n",
+ printf("Error: cannot get string value of [%s] in 2nd field: %s\n",
name, grib_get_error_message(err2));
save_error(c, name);
}
@@ -548,22 +523,21 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
break;
case GRIB_TYPE_LONG:
- if (verbose)
- printf(" as long\n");
+ if (verbose) printf(" as long\n");
lval1 = (long*)grib_context_malloc(h1->context, len1 * sizeof(long));
lval2 = (long*)grib_context_malloc(h2->context, len2 * sizeof(long));
if ((err1 = grib_get_long_array(h1, name, lval1, &len1)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get long value of [%s] in 1st field: %s\n",
+ printf("Error: cannot get long value of [%s] in 1st field: %s\n",
name, grib_get_error_message(err1));
save_error(c, name);
}
if ((err2 = grib_get_long_array(h2, name, lval2, &len2)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get long value of [%s] in 2nd field: %s\n",
+ printf("Error: cannot get long value of [%s] in 2nd field: %s\n",
name, grib_get_error_message(err2));
save_error(c, name);
}
@@ -609,69 +583,19 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
break;
case GRIB_TYPE_BYTES:
- if (verbose)
- printf(" as bytes\n");
- if (options->mode == MODE_GTS)
+ if (verbose) printf(" as bytes\n");
+ if (options->mode == MODE_GTS) {
+ // We do not want to compare the message itself
return 0;
- if (len1 < 2)
- len1 = 512;
- if (len2 < 2)
- len2 = 512;
- uval1 = (unsigned char*)grib_context_malloc(h1->context, len1 * sizeof(unsigned char));
- uval2 = (unsigned char*)grib_context_malloc(h2->context, len2 * sizeof(unsigned char));
-
- if ((err1 = grib_get_bytes(h1, name, uval1, &len1)) != GRIB_SUCCESS) {
- printInfo(h1);
- save_error(c, name);
- printf("Oops... cannot get bytes value of [%s] in 1st field: %s\n",
- name, grib_get_error_message(err1));
}
-
- if ((err2 = grib_get_bytes(h2, name, uval2, &len2)) != GRIB_SUCCESS) {
- printInfo(h1);
- save_error(c, name);
- printf("Oops... cannot get bytes value of [%s] in 2nd field: %s\n",
- name, grib_get_error_message(err2));
- }
-
- if (err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS) {
- if (memcmp(uval1, uval2, len1) != 0) {
- size_t i;
- for (i = 0; i < len1; i++)
- if (uval1[i] != uval2[i]) {
- printInfo(h1);
- save_error(c, name);
- if (len1 == 1)
- printf("[%s] byte values are different: [%02x] and [%02x]\n",
- name, uval1[i], uval2[i]);
- else
- printf("[%s] byte value %zu of %ld are different: [%02x] and [%02x]\n",
- name, i, (long)len1, uval1[i], uval2[i]);
-
- err1 = GRIB_VALUE_MISMATCH;
- break;
- }
- err1 = GRIB_VALUE_MISMATCH;
- }
- }
-
- grib_context_free(h1->context, uval1);
- grib_context_free(h2->context, uval2);
-
- if (err1)
- return err1;
- if (err2)
- return err2;
break;
case GRIB_TYPE_LABEL:
- if (verbose)
- printf(" as label\n");
+ if (verbose) printf(" as label\n");
break;
default:
- if (verbose)
- printf("\n");
+ if (verbose) printf("\n");
printInfo(h1);
save_error(c, name);
printf("Cannot compare [%s], unsupported type %d\n", name, type1);
@@ -690,14 +614,13 @@ static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_
iter = grib_keys_iterator_new(h1, 0, NULL);
if (!iter) {
- printf("ERROR: unable to get iterator\n");
+ fprintf(stderr, "Error: unable to get keys iterator\n");
exit(1);
}
while (grib_keys_iterator_next(iter)) {
grib_accessor* xa = grib_keys_iterator_get_accessor(iter);
name = grib_keys_iterator_get_name(iter);
- /* printf("----- comparing %s\n",name); */
if (blocklisted(name))
continue;
@@ -728,12 +651,11 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option
if (options->compare[i].type == CODES_NAMESPACE) {
iter = grib_keys_iterator_new(h1, 0, options->compare[i].name);
if (!iter) {
- printf("ERROR: unable to get iterator\n");
+ fprintf(stderr, "Error: unable to get iterator\n");
exit(1);
}
while (grib_keys_iterator_next(iter)) {
name = grib_keys_iterator_get_name(iter);
- /*printf("----- comparing %s\n",name);*/
if (blocklisted(name))
continue;
@@ -789,12 +711,11 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option
if (options->compare[i].type == CODES_NAMESPACE) {
iter = grib_keys_iterator_new(h1, 0, options->compare[i].name);
if (!iter) {
- printf("ERROR: unable to get iterator for %s\n", options->compare[i].name);
+ fprintf(stderr, "Error: unable to get iterator for %s\n", options->compare[i].name);
exit(1);
}
while (grib_keys_iterator_next(iter)) {
name = grib_keys_iterator_get_name(iter);
- /*printf("----- comparing %s\n",name);*/
if (blocklisted(name))
continue;
diff --git a/tools/gts_dump.cc b/tools/gts_dump.cc
index 0f297393b..eff44c548 100644
--- a/tools/gts_dump.cc
+++ b/tools/gts_dump.cc
@@ -8,12 +8,6 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
-/*
- * Implementation: gts_dump
- *
- *
- */
-
#include "grib_tools.h"
grib_option grib_options[] = {
@@ -41,7 +35,6 @@ const char* tool_usage = "[options] file file ...";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
/**
-* gts_dump
* Dump the content of a GTS file
*
*/
@@ -57,11 +50,10 @@ int grib_tool_before_getopt(grib_runtime_options* options)
int grib_tool_init(grib_runtime_options* options)
{
- int opt = grib_options_on("C") + grib_options_on("O") + grib_options_on("D");
+ int opt = grib_options_on("O") + grib_options_on("D");
options->dump_mode = (char*)"default";
-
if (opt > 1) {
printf("%s: simultaneous O/D options not allowed\n", tool_name);
exit(1);
diff --git a/tools/metar_compare.cc b/tools/metar_compare.cc
index 4a9024483..48db23534 100644
--- a/tools/metar_compare.cc
+++ b/tools/metar_compare.cc
@@ -21,8 +21,6 @@ grib_option grib_options[] = {
{ "a", 0, "-c option modifier. The keys listed with the option -c will be added to the list of keys compared without -c.\n", 0, 1, 0 },
{ "R:", 0, 0, 0, 1, 0 },
{ "A:", 0, 0, 0, 1, 0 },
- { "P", 0, "Compare data values using the packing error as tolerance.\n", 0, 1, 0 },
- { "t:", "factor", "Compare data values using factor multiplied by the tolerance specified in options -P -R -A.\n", 0, 1, 0 },
{ "w:", 0, 0, 0, 1, 0 },
{ "f", 0, 0, 0, 1, 0 },
{ "F", 0, 0, 1, 0, 0 },
@@ -38,7 +36,7 @@ int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
const char* tool_description =
"Compare METAR messages contained in two files."
"\n\tIf some differences are found it fails returning an error code."
- "\n\tFloating-point values are compared exactly by default, different tolerance can be defined see -P -A -R."
+ "\n\tFloating-point values are compared exactly by default, different tolerance can be defined see -A -R."
"\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files.";
const char* tool_name = "metar_compare";
@@ -70,7 +68,6 @@ struct grib_error
static grib_error* error_summary;
static compare_double_proc compare_double;
static double global_tolerance = 0;
-static int packingCompare = 0;
static grib_string_list* blocklist = 0;
static int compareAbsolute = 1;
@@ -278,29 +275,33 @@ int grib_tool_init(grib_runtime_options* options)
global_tolerance = atof(grib_options_get_option("A:"));
}
}
- if (grib_options_on("P")) {
- packingCompare = 1;
- compare_double = &compare_double_absolute;
- }
if (grib_options_on("t:"))
tolerance_factor = atof(grib_options_get_option("t:"));
- {
- /* Check for 2nd file being a directory. If so, we assume user is comparing to a file */
- /* with the same name as first file in that directory */
- grib_tools_file* infile = options->infile; /* the 2nd file in comparison */
- if (infile) {
- if (path_is_directory(infile->name)) {
- /* Take the filename of the 1st file and append to dir */
- char bufr[2048] = {0,};
- /* options->infile_extra->name is the 1st file */
- snprintf(bufr, 2048, "%s%c%s",
- infile->name,
- get_dir_separator_char(),
- extract_filename(options->infile_extra->name));
- infile->name = strdup(bufr);
- }
+ if (grib_options_on("R:")) {
+ char* sarg = grib_options_get_option("R:");
+ options->tolerance_count = MAX_KEYS;
+ int err = parse_keyval_string(tool_name, sarg, 1, GRIB_TYPE_DOUBLE, options->tolerance, &(options->tolerance_count));
+ if (err == GRIB_INVALID_ARGUMENT) {
+ usage();
+ exit(1);
+ }
+ }
+
+ // Check for 2nd file being a directory. If so, we assume user is comparing to a file
+ // with the same name as first file in that directory
+ grib_tools_file* infile = options->infile; // the 2nd file in comparison
+ if (infile) {
+ if (path_is_directory(infile->name)) {
+ // Take the filename of the 1st file and append to dir
+ char bufr[2048] = {0,};
+ // options->infile_extra->name is the 1st file
+ snprintf(bufr, 2048, "%s%c%s",
+ infile->name,
+ get_dir_separator_char(),
+ extract_filename(options->infile_extra->name));
+ infile->name = strdup(bufr);
}
}
@@ -451,7 +452,7 @@ static void save_error(grib_context* c, const char* key)
}
}
-static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_handle* h2, const char* name, int type)
+static int compare_values(const grib_runtime_options* options, grib_handle* h1, grib_handle* h2, const char* name, int type)
{
size_t len1 = 0;
size_t len2 = 0;
@@ -463,11 +464,9 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
int isMissing1 = 0, isMissing2 = 0;
char *sval1 = NULL, *sval2 = NULL;
- unsigned char *uval1 = NULL, *uval2 = NULL;
double *dval1 = NULL, *dval2 = NULL;
long *lval1 = NULL, *lval2 = NULL;
double maxdiff = 0;
- double packingError1 = 0, packingError2 = 0;
double value_tolerance = 0;
grib_context* c = h1->context;
@@ -478,7 +477,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
if (type1 == GRIB_TYPE_UNDEFINED && (err = grib_get_native_type(h1, name, &type1)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get type of [%s] in 1st field: %s\n", name, grib_get_error_message(err));
+ printf("Error: cannot get type of [%s] in 1st field: %s\n", name, grib_get_error_message(err));
save_error(c, name);
return err;
}
@@ -491,7 +490,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
return err;
}
printInfo(h1);
- printf("Oops... cannot get type of [%s] in 2nd field: %s\n", name, grib_get_error_message(err));
+ printf("Error: cannot get type of [%s] in 2nd field: %s\n", name, grib_get_error_message(err));
save_error(c, name);
return err;
}
@@ -505,7 +504,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
if ((err = grib_get_size(h1, name, &len1)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get size of [%s] in 1st field: %s\n", name, grib_get_error_message(err));
+ printf("Error: cannot get size of [%s] in 1st field: %s\n", name, grib_get_error_message(err));
save_error(c, name);
return err;
}
@@ -519,7 +518,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
}
printInfo(h1);
- printf("Oops... cannot get size of [%s] in 2nd field: %s\n", name, grib_get_error_message(err));
+ printf("Error: cannot get size of [%s] in 2nd field: %s\n", name, grib_get_error_message(err));
save_error(c, name);
return err;
}
@@ -567,14 +566,14 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
if ((err1 = grib_get_string(h1, name, sval1, &len1)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get string value of [%s] in 1st field: %s\n",
+ printf("Error: cannot get string value of [%s] in 1st field: %s\n",
name, grib_get_error_message(err1));
save_error(c, name);
}
if ((err2 = grib_get_string(h2, name, sval2, &len2)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get string value of [%s] in 2nd field: %s\n",
+ printf("Error: cannot get string value of [%s] in 2nd field: %s\n",
name, grib_get_error_message(err2));
save_error(c, name);
}
@@ -608,14 +607,14 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
if ((err1 = grib_get_long_array(h1, name, lval1, &len1)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get long value of [%s] in 1st field: %s\n",
+ printf("Error: cannot get long value of [%s] in 1st field: %s\n",
name, grib_get_error_message(err1));
save_error(c, name);
}
if ((err2 = grib_get_long_array(h2, name, lval2, &len2)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get long value of [%s] in 2nd field: %s\n",
+ printf("Error: cannot get long value of [%s] in 2nd field: %s\n",
name, grib_get_error_message(err2));
save_error(c, name);
}
@@ -662,37 +661,6 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
dval2 = (double*)grib_context_malloc(h2->context, len2 * sizeof(double));
value_tolerance = global_tolerance;
- if (!grib_inline_strcmp(name, "packedValues") || !grib_inline_strcmp(name, "values") || !grib_inline_strcmp(name, "codedValues")) {
- packingError1 = 0;
- packingError2 = 0;
- err1 = grib_get_double(h1, "packingError", &packingError1);
- err2 = grib_get_double(h2, "packingError", &packingError2);
- if (packingCompare && !err1 && !err2) {
- value_tolerance = packingError1 > packingError2 ? packingError1 : packingError2;
- compare_double = &compare_double_absolute;
- compareAbsolute = 1;
- }
- }
- else if (!grib_inline_strcmp(name, "unpackedValues")) {
- packingError1 = 0;
- packingError2 = 0;
- err1 = grib_get_double(h1, "unpackedError", &packingError1);
- err2 = grib_get_double(h2, "unpackedError", &packingError2);
- if (packingCompare && !err1 && !err2) {
- value_tolerance = packingError1 > packingError2 ? packingError1 : packingError2;
- compare_double = &compare_double_absolute;
- compareAbsolute = 1;
- }
- }
- else if (!grib_inline_strcmp(name, "referenceValue")) {
- packingError1 = 0;
- packingError2 = 0;
- err1 = grib_get_double(h1, "referenceValueError", &packingError1);
- err2 = grib_get_double(h2, "referenceValueError", &packingError2);
- if (!err1 && !err2) {
- value_tolerance = packingError1 > packingError2 ? packingError1 : packingError2;
- }
- }
if (!compareAbsolute) {
for (i = 0; i < options->tolerance_count; i++) {
@@ -705,14 +673,14 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
if ((err1 = grib_get_double_array(h1, name, dval1, &len1)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get double value of [%s] in 1st field: %s\n",
+ printf("Error: cannot get double value of [%s] in 1st field: %s\n",
name, grib_get_error_message(err1));
save_error(c, name);
}
if ((err2 = grib_get_double_array(h2, name, dval2, &len2)) != GRIB_SUCCESS) {
printInfo(h1);
- printf("Oops... cannot get double value of [%s] in 2nd field: %s\n",
+ printf("Error: cannot get double value of [%s] in 2nd field: %s\n",
name, grib_get_error_message(err2));
save_error(c, name);
}
@@ -732,8 +700,14 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
pv1 = dval1;
pv2 = dval2;
value_tolerance *= tolerance_factor;
- if (verbose)
- printf(" (%d values) tolerance=%g\n", (int)len1, value_tolerance);
+ if (verbose) {
+ printf(" (%d values) tolerance=%g \t", (int)len1, value_tolerance);
+ if (compare_double == &compare_double_absolute)
+ printf("using compare_double_absolute");
+ if (compare_double == &compare_double_relative)
+ printf("using compare_double_relative");
+ printf("\n");
+ }
for (i = 0; i < len1; i++) {
if ((diff = compare_double(pv1++, pv2++, &value_tolerance)) != 0) {
countdiff++;
@@ -759,17 +733,6 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
printf("\n\tmax diff. element %d: %.20e %.20e",
imaxdiff, dval1[imaxdiff], dval2[imaxdiff]);
printf("\n\ttolerance=%.16e", value_tolerance);
- if (packingError2 != 0 || packingError1 != 0)
- printf(" packingError: [%g] [%g]", packingError1, packingError2);
-
- if (!grib_inline_strcmp(name, "packedValues") || !grib_inline_strcmp(name, "values") || !grib_inline_strcmp(name, "codedValues")) {
- double max1, min1, max2, min2;
- grib_get_double(h1, "max", &max1);
- grib_get_double(h1, "min", &min1);
- grib_get_double(h2, "max", &max2);
- grib_get_double(h2, "min", &min2);
- printf("\n\tvalues max= [%g] [%g] min= [%g] [%g]", max1, max2, min1, min2);
- }
printf("\n");
}
else {
@@ -796,54 +759,6 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
printf(" as bytes\n");
if (options->mode == MODE_METAR)
return 0;
- if (len1 < 2)
- len1 = 512;
- if (len2 < 2)
- len2 = 512;
- uval1 = (unsigned char*)grib_context_malloc(h1->context, len1 * sizeof(unsigned char));
- uval2 = (unsigned char*)grib_context_malloc(h2->context, len2 * sizeof(unsigned char));
-
- if ((err1 = grib_get_bytes(h1, name, uval1, &len1)) != GRIB_SUCCESS) {
- printInfo(h1);
- save_error(c, name);
- printf("Oops... cannot get bytes value of [%s] in 1st field: %s\n",
- name, grib_get_error_message(err1));
- }
-
- if ((err2 = grib_get_bytes(h2, name, uval2, &len2)) != GRIB_SUCCESS) {
- printInfo(h1);
- save_error(c, name);
- printf("Oops... cannot get bytes value of [%s] in 2nd field: %s\n",
- name, grib_get_error_message(err2));
- }
-
- if (err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS) {
- if (memcmp(uval1, uval2, len1) != 0) {
- for (i = 0; i < len1; i++)
- if (uval1[i] != uval2[i]) {
- printInfo(h1);
- save_error(c, name);
- if (len1 == 1)
- printf("[%s] byte values are different: [%02x] and [%02x]\n",
- name, uval1[i], uval2[i]);
- else
- printf("[%s] byte value %d of %ld are different: [%02x] and [%02x]\n",
- name, i, (long)len1, uval1[i], uval2[i]);
-
- err1 = GRIB_VALUE_MISMATCH;
- break;
- }
- err1 = GRIB_VALUE_MISMATCH;
- }
- }
-
- grib_context_free(h1->context, uval1);
- grib_context_free(h2->context, uval2);
-
- if (err1)
- return err1;
- if (err2)
- return err2;
break;
case GRIB_TYPE_LABEL:
@@ -871,14 +786,13 @@ static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_
grib_keys_iterator* iter = grib_keys_iterator_new(h1, 0, NULL);
if (!iter) {
- printf("ERROR: unable to get iterator\n");
+ fprintf(stderr, "Error: unable to get keys iterator\n");
exit(1);
}
while (grib_keys_iterator_next(iter)) {
grib_accessor* xa = grib_keys_iterator_get_accessor(iter);
name = grib_keys_iterator_get_name(iter);
- /* printf("----- comparing %s\n",name); */
if (blocklisted(name))
continue;
@@ -909,12 +823,11 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option
if (options->compare[i].type == CODES_NAMESPACE) {
iter = grib_keys_iterator_new(h1, 0, options->compare[i].name);
if (!iter) {
- printf("ERROR: unable to get iterator\n");
+ fprintf(stderr, "Error: unable to get keys iterator\n");
exit(1);
}
while (grib_keys_iterator_next(iter)) {
name = grib_keys_iterator_get_name(iter);
- /*printf("----- comparing %s\n",name);*/
if (blocklisted(name))
continue;
@@ -936,7 +849,6 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option
const void *msg1 = NULL, *msg2 = NULL;
size_t size1 = 0, size2 = 0;
int memcmp_ret = 0;
- /* int ii=0; */
GRIB_CHECK_NOLINE(grib_get_message(h1, &msg1, &size1), 0);
GRIB_CHECK_NOLINE(grib_get_message(h2, &msg2, &size2), 0);
if (size1 == size2 && !(memcmp_ret = memcmp(msg1, msg2, size1))) {
@@ -950,12 +862,11 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option
if (options->compare[i].type == CODES_NAMESPACE) {
iter = grib_keys_iterator_new(h1, 0, options->compare[i].name);
if (!iter) {
- printf("ERROR: unable to get iterator for %s\n", options->compare[i].name);
+ fprintf(stderr, "Error: unable to get keys iterator for %s\n", options->compare[i].name);
exit(1);
}
while (grib_keys_iterator_next(iter)) {
name = grib_keys_iterator_get_name(iter);
- /*printf("----- comparing %s\n",name);*/
if (blocklisted(name))
continue;
diff --git a/tools/metar_dump.cc b/tools/metar_dump.cc
index 66bf48959..f992d1f36 100644
--- a/tools/metar_dump.cc
+++ b/tools/metar_dump.cc
@@ -47,7 +47,7 @@ int grib_tool_before_getopt(grib_runtime_options* options)
int grib_tool_init(grib_runtime_options* options)
{
- int opt = grib_options_on("C") + grib_options_on("O") + grib_options_on("D");
+ int opt = grib_options_on("O") + grib_options_on("D");
options->dump_mode = (char*)"default";
@@ -66,16 +66,11 @@ int grib_tool_init(grib_runtime_options* options)
options->dump_flags = GRIB_DUMP_FLAG_VALUES | GRIB_DUMP_FLAG_READ_ONLY;
}
- if (grib_options_on("J")) {
+ if (grib_options_on("j")) {
options->dump_mode = (char*)"json";
options->dump_flags = GRIB_DUMP_FLAG_VALUES | GRIB_DUMP_FLAG_READ_ONLY;
}
- if (grib_options_on("X")) {
- options->dump_mode = (char*)"xml";
- options->dump_flags = GRIB_DUMP_FLAG_VALUES | GRIB_DUMP_FLAG_READ_ONLY;
- }
-
if (grib_options_on("a"))
options->dump_flags |= GRIB_DUMP_FLAG_ALIASES;
@@ -104,7 +99,7 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi
if (!options->current_infile->name)
return 0;
snprintf(tmp, 1024, "FILE: %s ", options->current_infile->name);
- if (!grib_options_on("C") && !grib_options_on("J") && !grib_options_on("X"))
+ if ( !grib_options_on("C") && !grib_options_on("j") )
fprintf(stdout, "***** %s\n", tmp);
return 0;
}
@@ -123,7 +118,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
grib_set_flag(h, options->print_keys[i].name, GRIB_ACCESSOR_FLAG_DUMP);
snprintf(tmp, 1024, "MESSAGE %d ( length=%ld )", options->handle_count, length);
- if (!grib_options_on("C") && !grib_options_on("X") && !grib_options_on("J"))
+ if (!grib_options_on("C") && !grib_options_on("j"))
fprintf(stdout, "#============== %-38s ==============\n", tmp);
if (!strcmp(options->dump_mode, "default")) {
GRIB_CHECK_NOLINE(grib_get_string(h, "identifier", identifier, &idlen), 0);