mirror of https://github.com/ecmwf/eccodes.git
Merge branch 'develop' into feature/ECC-1620_sub-hourly
This commit is contained in:
commit
f7bccb5537
|
@ -1,6 +1,5 @@
|
|||
# (C) Copyright 2005- ECMWF.
|
||||
|
||||
#
|
||||
# Description Octet Code Ksec1 Count
|
||||
# ----------- ----- ---- ----- -----
|
||||
#localDefinitionNumber 41 I1 37 -
|
||||
|
|
|
@ -61,6 +61,16 @@
|
|||
scaledValueOfFirstFixedSurface = 15 ;
|
||||
scaleFactorOfFirstFixedSurface = 1 ;
|
||||
}
|
||||
#2 metre temperature
|
||||
't2m' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 0 ;
|
||||
typeOfFirstFixedSurface = 103 ;
|
||||
scaledValueOfFirstFixedSurface = 2 ;
|
||||
scaleFactorOfFirstFixedSurface = 0 ;
|
||||
typeOfStatisticalProcessing = 0 ;
|
||||
}
|
||||
#Surface roughness (climatological)
|
||||
'sr' = {
|
||||
discipline = 2 ;
|
||||
|
|
|
@ -61,6 +61,16 @@
|
|||
scaledValueOfFirstFixedSurface = 15 ;
|
||||
scaleFactorOfFirstFixedSurface = 1 ;
|
||||
}
|
||||
#2 metre temperature
|
||||
'2 metre temperature' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 0 ;
|
||||
typeOfFirstFixedSurface = 103 ;
|
||||
scaledValueOfFirstFixedSurface = 2 ;
|
||||
scaleFactorOfFirstFixedSurface = 0 ;
|
||||
typeOfStatisticalProcessing = 0 ;
|
||||
}
|
||||
#Surface roughness (climatological)
|
||||
'Surface roughness (climatological)' = {
|
||||
discipline = 2 ;
|
||||
|
|
|
@ -61,6 +61,16 @@
|
|||
scaledValueOfFirstFixedSurface = 15 ;
|
||||
scaleFactorOfFirstFixedSurface = 1 ;
|
||||
}
|
||||
#2 metre temperature
|
||||
'167' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 0 ;
|
||||
typeOfFirstFixedSurface = 103 ;
|
||||
scaledValueOfFirstFixedSurface = 2 ;
|
||||
scaleFactorOfFirstFixedSurface = 0 ;
|
||||
typeOfStatisticalProcessing = 0 ;
|
||||
}
|
||||
#Surface roughness (climatological)
|
||||
'173' = {
|
||||
discipline = 2 ;
|
||||
|
|
|
@ -61,6 +61,16 @@
|
|||
scaledValueOfFirstFixedSurface = 15 ;
|
||||
scaleFactorOfFirstFixedSurface = 1 ;
|
||||
}
|
||||
#2 metre temperature
|
||||
'2t' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 0 ;
|
||||
typeOfFirstFixedSurface = 103 ;
|
||||
scaledValueOfFirstFixedSurface = 2 ;
|
||||
scaleFactorOfFirstFixedSurface = 0 ;
|
||||
typeOfStatisticalProcessing = 0 ;
|
||||
}
|
||||
#Surface roughness (climatological)
|
||||
'sr' = {
|
||||
discipline = 2 ;
|
||||
|
|
|
@ -61,6 +61,16 @@
|
|||
scaledValueOfFirstFixedSurface = 15 ;
|
||||
scaleFactorOfFirstFixedSurface = 1 ;
|
||||
}
|
||||
#2 metre temperature
|
||||
'K' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 0 ;
|
||||
parameterNumber = 0 ;
|
||||
typeOfFirstFixedSurface = 103 ;
|
||||
scaledValueOfFirstFixedSurface = 2 ;
|
||||
scaleFactorOfFirstFixedSurface = 0 ;
|
||||
typeOfStatisticalProcessing = 0 ;
|
||||
}
|
||||
#Surface roughness (climatological)
|
||||
'm' = {
|
||||
discipline = 2 ;
|
||||
|
|
|
@ -79,7 +79,8 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
/* write multi-field handle to output file */
|
||||
codes_grib_multi_handle_write(mh, of);
|
||||
err = codes_grib_multi_handle_write(mh, of);
|
||||
if (err) return 1;
|
||||
fclose(of);
|
||||
|
||||
/* release memory */
|
||||
|
|
|
@ -11,6 +11,7 @@ if( HAVE_BUILD_TOOLS )
|
|||
codes_ecc-1392
|
||||
codes_datetime_julian
|
||||
codes_set_paths
|
||||
codes_f90_misc
|
||||
grib_set_pv
|
||||
grib_set_data
|
||||
bufr_ecc-1284
|
||||
|
@ -67,6 +68,7 @@ else()
|
|||
grib_set_pv
|
||||
grib_set_data
|
||||
codes_set_paths
|
||||
codes_f90_misc
|
||||
get_native_type
|
||||
grib_ecc-671 )
|
||||
list( APPEND tests_extra
|
||||
|
|
|
@ -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 codes_f90_misc
|
||||
use eccodes
|
||||
implicit none
|
||||
|
||||
integer :: array_of_error_codes(8), i, code
|
||||
character(len=64) :: error_message = ''
|
||||
|
||||
call codes_gribex_mode_on()
|
||||
call codes_gribex_mode_off()
|
||||
|
||||
call codes_bufr_multi_element_constant_arrays_on()
|
||||
call codes_bufr_multi_element_constant_arrays_off()
|
||||
|
||||
array_of_error_codes = [0, -2, -14, -16, -26, -28, -38, -41]
|
||||
do i = 1, size(array_of_error_codes)
|
||||
error_message = ''
|
||||
code = array_of_error_codes(i)
|
||||
call codes_get_error_string(code, error_message)
|
||||
write (*, *) 'error message: <', adjustl(trim(error_message)), '>'
|
||||
end do
|
||||
|
||||
end program
|
|
@ -0,0 +1,13 @@
|
|||
#!/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
|
||||
|
||||
# export ECCODES_DEBUG=1
|
||||
${examples_dir}/eccodes_f_codes_f90_misc
|
|
@ -16,7 +16,7 @@ program multi
|
|||
use eccodes
|
||||
implicit none
|
||||
|
||||
integer :: iret, counter
|
||||
integer :: iret, counter=0
|
||||
integer(kind=4) :: step
|
||||
integer :: ifile, igrib
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ integer, external :: grib_f_skip_computed, &
|
|||
integer, external :: grib_f_keys_iterator_get_name, &
|
||||
grib_f_keys_iterator_rewind
|
||||
integer, external :: grib_f_new_from_message, &
|
||||
grib_f_new_from_message_int, &
|
||||
grib_f_new_from_message_copy, &
|
||||
grib_f_new_from_samples, &
|
||||
codes_bufr_f_new_from_samples, &
|
||||
|
|
|
@ -1365,7 +1365,7 @@
|
|||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
call grib_check(iret, 'new_from_message', '')
|
||||
call grib_check(iret, 'new_from_message_char', '')
|
||||
end if
|
||||
|
||||
end subroutine grib_new_from_message_char
|
||||
|
@ -1394,11 +1394,13 @@
|
|||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
size_bytes = size(message, dim=1)*sizeOfInteger4
|
||||
iret = grib_f_new_from_message(gribid, message, size_bytes)
|
||||
! See SUP-3893
|
||||
!iret = grib_f_new_from_message(gribid, message, size_bytes)
|
||||
iret = grib_f_new_from_message_int(gribid, message, size_bytes)
|
||||
if (present(status)) then
|
||||
status = iret
|
||||
else
|
||||
call grib_check(iret, 'new_from_message', '')
|
||||
call grib_check(iret, 'new_from_message_int4', '')
|
||||
end if
|
||||
|
||||
end subroutine grib_new_from_message_int4
|
||||
|
|
|
@ -981,10 +981,10 @@ 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);
|
||||
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);
|
||||
return grib_f_open_file_(fid, name, op, lname, lop);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1494,87 +1494,90 @@ int codes_f_bufr_keys_iterator_delete(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) {
|
||||
grib_handle *h = NULL;
|
||||
h = grib_handle_new_from_message_copy(0, buffer, *bufsize);
|
||||
if (h){
|
||||
push_handle(h,gid);
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
*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;
|
||||
h = grib_handle_new_from_message_copy(0, buffer, *bufsize);
|
||||
if(h){
|
||||
push_handle(h,gid);
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
*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_copy__(int* gid, void* buffer, size_t* bufsize){
|
||||
return grib_f_new_from_message_copy_(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);
|
||||
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){
|
||||
grib_handle *h = NULL;
|
||||
h = grib_handle_new_from_message_copy(0, buffer, *bufsize);
|
||||
if(h){
|
||||
push_handle(h,gid);
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
*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){
|
||||
int grib_f_new_from_samples_(int* gid, char* name, int lname){
|
||||
char fname[1024];
|
||||
grib_handle *h = NULL;
|
||||
|
||||
h = grib_handle_new_from_samples(NULL,cast_char(fname,name,lname));
|
||||
grib_handle *h = grib_handle_new_from_samples(NULL,cast_char(fname,name,lname));
|
||||
/* grib_context_set_debug(h->context,1);*/
|
||||
|
||||
if(h){
|
||||
push_handle(h,gid);
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
*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);
|
||||
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);
|
||||
return grib_f_new_from_samples_(gid, name, lname);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int codes_bufr_f_new_from_samples_(int* gid, char* name, int lname){
|
||||
char fname[1024];
|
||||
grib_handle *h = NULL;
|
||||
|
||||
h = codes_bufr_handle_new_from_samples(NULL,cast_char(fname,name,lname));
|
||||
grib_handle* h = codes_bufr_handle_new_from_samples(NULL,cast_char(fname,name,lname));
|
||||
/* grib_context_set_debug(h->context,1);*/
|
||||
|
||||
if(h){
|
||||
push_handle(h,gid);
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
*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);
|
||||
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);
|
||||
return codes_bufr_f_new_from_samples_(gid, name, lname);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1699,6 +1702,7 @@ 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)
|
||||
{
|
||||
grib_handle *h = NULL;
|
||||
|
@ -1728,7 +1732,6 @@ int any_f_new_from_scanned_file(int* fid,int* msgid,int* gid)
|
|||
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);
|
||||
}
|
||||
|
@ -1773,6 +1776,7 @@ 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)
|
||||
{
|
||||
grib_handle *h = NULL;
|
||||
|
@ -1802,6 +1806,7 @@ 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();
|
||||
/* grib_oarray_delete_content(c,binary_messages); */
|
||||
|
@ -2015,7 +2020,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);
|
||||
}
|
||||
|
@ -2093,7 +2097,6 @@ 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);
|
||||
}
|
||||
|
@ -3189,7 +3192,6 @@ int grib_f_set_force_real8_array_(int* gid, char* key, double*val, int* size, in
|
|||
if(!h) return GRIB_INVALID_GRIB;
|
||||
|
||||
return grib_set_force_double_array(h, cast_char(buf,key,len), val, lsize);
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3239,7 +3241,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);
|
||||
}
|
||||
|
@ -3268,7 +3269,6 @@ 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,7 +3301,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);
|
||||
}
|
||||
|
@ -3327,7 +3326,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);
|
||||
}
|
||||
|
@ -3343,6 +3341,8 @@ static int is_all_spaces(const char *s)
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int grib_f_set_string_(int* gid, char* key, char* val, int len, int len2){
|
||||
|
||||
grib_handle *h = get_handle(*gid);
|
||||
|
@ -3363,7 +3363,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);
|
||||
}
|
||||
|
@ -3401,7 +3400,6 @@ int grib_f_get_data_real4_(int* gid,float* lats, float* lons,float* values,size_
|
|||
grib_context_free(h->context,lon8);
|
||||
|
||||
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);
|
||||
|
@ -3410,8 +3408,8 @@ int grib_f_get_data_real4(int* gid,float* lats, float* lons,float* values,size_t
|
|||
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) {
|
||||
|
||||
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);
|
||||
|
||||
|
@ -3427,10 +3425,8 @@ int grib_f_get_data_real8(int* gid,double* lats, double* lons,double* values,siz
|
|||
int grib_f_get_message_size_(int* gid, size_t *len){
|
||||
grib_handle *h = get_handle(*gid);
|
||||
if(!h) return GRIB_INVALID_GRIB;
|
||||
|
||||
*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);
|
||||
|
@ -3451,13 +3447,10 @@ int grib_f_copy_message_(int* gid, void* mess,size_t* len){
|
|||
return GRIB_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
|
||||
memcpy(mess,h->buffer->data,h->buffer->ulength);
|
||||
*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);
|
||||
}
|
||||
|
@ -3479,7 +3472,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);
|
||||
}
|
||||
|
@ -3508,7 +3500,6 @@ int grib_f_write_(int* gid, int* fid) {
|
|||
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);
|
||||
}
|
||||
|
@ -3523,16 +3514,14 @@ 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);
|
||||
grib_multi_handle *mh = get_multi_handle(*mgid);
|
||||
|
@ -3546,16 +3535,13 @@ 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);
|
||||
|
@ -3595,6 +3581,7 @@ int grib_f_set_definitions_path(char* path, int len){
|
|||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
int grib_f_set_samples_path_(char* path, int len){
|
||||
grib_context* c = grib_context_get_default();
|
||||
char buf[1024];
|
||||
|
@ -3608,6 +3595,8 @@ 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);
|
||||
}
|
||||
|
@ -3618,6 +3607,8 @@ int grib_f_julian_to_datetime__(double* jd,long* year,long* month,long* day,long
|
|||
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);
|
||||
}
|
||||
|
@ -3627,4 +3618,3 @@ int grib_f_datetime_to_julian_(long* year,long* month,long* day, long* hour,long
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,15 +16,15 @@ extern "C" {
|
|||
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_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);
|
||||
|
@ -99,12 +99,17 @@ 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_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_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);
|
||||
|
@ -353,9 +358,9 @@ int grib_f_get_data_real8(int *gid, double *lats, double *lons, double *values,
|
|||
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);
|
||||
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);
|
||||
|
|
|
@ -175,6 +175,11 @@ grib_handle* codes_handle_clone(const grib_handle* h)
|
|||
{
|
||||
return grib_handle_clone(h);
|
||||
}
|
||||
grib_handle* codes_handle_clone_headers_only(const grib_handle* h)
|
||||
{
|
||||
return grib_handle_clone_headers_only(h);
|
||||
}
|
||||
|
||||
int codes_handle_delete(grib_handle* h)
|
||||
{
|
||||
return grib_handle_delete(h);
|
||||
|
@ -461,6 +466,11 @@ void codes_gts_header_off(grib_context* c)
|
|||
{
|
||||
grib_gts_header_off(c);
|
||||
}
|
||||
void codes_gts_header_on(grib_context* c)
|
||||
{
|
||||
grib_gts_header_on(c);
|
||||
}
|
||||
|
||||
void codes_gribex_mode_on(grib_context* c)
|
||||
{
|
||||
grib_gribex_mode_on(c);
|
||||
|
|
|
@ -495,6 +495,7 @@ codes_handle* codes_handle_new_from_samples(codes_context* c, const char* sample
|
|||
* @return the new handle, NULL if the message is invalid or a problem is encountered
|
||||
*/
|
||||
codes_handle* codes_handle_clone(const codes_handle* h);
|
||||
codes_handle* codes_handle_clone_headers_only(const codes_handle* h);
|
||||
|
||||
/**
|
||||
* Frees a handle, also frees the message if it is not a user message
|
||||
|
@ -1527,7 +1528,7 @@ Error codes returned by the eccodes functions.
|
|||
#define CODES_WRONG_STEP_UNIT GRIB_WRONG_STEP_UNIT
|
||||
/** Invalid file id */
|
||||
#define CODES_INVALID_FILE GRIB_INVALID_FILE
|
||||
/** Invalid grib id */
|
||||
/** Invalid GRIB id */
|
||||
#define CODES_INVALID_GRIB GRIB_INVALID_GRIB
|
||||
/** Invalid index id */
|
||||
#define CODES_INVALID_INDEX GRIB_INVALID_INDEX
|
||||
|
|
|
@ -727,6 +727,12 @@ static bool is_number(const char* s)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool strings_equal(const char* s1, const char* s2, bool case_sensitive)
|
||||
{
|
||||
if (case_sensitive) return (strcmp(s1, s2) == 0);
|
||||
return (strcmp_nocase(s1, s2) == 0);
|
||||
}
|
||||
|
||||
static int pack_string(grib_accessor* a, const char* buffer, size_t* len)
|
||||
{
|
||||
long lValue = 0;
|
||||
|
@ -742,14 +748,10 @@ static int pack_string(grib_accessor* a, const char* buffer, size_t* len)
|
|||
}
|
||||
|
||||
grib_accessor_codetable* self = (grib_accessor_codetable*)a;
|
||||
grib_codetable* table;
|
||||
long i;
|
||||
grib_codetable* table = NULL;
|
||||
long i = 0;
|
||||
size_t size = 1;
|
||||
|
||||
typedef int (*cmpproc)(const char*, const char*);
|
||||
|
||||
cmpproc cmp = (a->flags & GRIB_ACCESSOR_FLAG_LOWERCASE) ? strcmp_nocase : strcmp;
|
||||
|
||||
if (!self->table_loaded) {
|
||||
self->table = load_table(a); /* may return NULL */
|
||||
self->table_loaded = 1;
|
||||
|
@ -765,10 +767,18 @@ static int pack_string(grib_accessor* a, const char* buffer, size_t* len)
|
|||
return err;
|
||||
}
|
||||
|
||||
for (i = 0; i < table->size; i++)
|
||||
if (table->entries[i].abbreviation)
|
||||
if (cmp(table->entries[i].abbreviation, buffer) == 0)
|
||||
// If the key has the "lowercase" flag set, then the string comparison
|
||||
// should ignore the case
|
||||
bool case_sensitive = true;
|
||||
if (a->flags & GRIB_ACCESSOR_FLAG_LOWERCASE) case_sensitive = false;
|
||||
|
||||
for (i = 0; i < table->size; i++) {
|
||||
if (table->entries[i].abbreviation) {
|
||||
if (strings_equal(table->entries[i].abbreviation, buffer, case_sensitive)) {
|
||||
return grib_pack_long(a, &i, &size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (a->flags & GRIB_ACCESSOR_FLAG_NO_FAIL) {
|
||||
grib_action* act = (grib_action*)(a->creator);
|
||||
|
|
|
@ -446,7 +446,7 @@ static int get_native_type(grib_accessor* a)
|
|||
|
||||
static int compare(grib_accessor* a, grib_accessor* b)
|
||||
{
|
||||
int retval = 0;
|
||||
int retval = GRIB_SUCCESS;
|
||||
double* aval = 0;
|
||||
double* bval = 0;
|
||||
|
||||
|
@ -475,10 +475,8 @@ static int compare(grib_accessor* a, grib_accessor* b)
|
|||
grib_unpack_double(b, bval, &blen);
|
||||
|
||||
retval = GRIB_SUCCESS;
|
||||
while (alen != 0) {
|
||||
if (*bval != *aval)
|
||||
retval = GRIB_DOUBLE_VALUE_MISMATCH;
|
||||
alen--;
|
||||
for (size_t i=0; i<alen && retval == GRIB_SUCCESS; ++i) {
|
||||
if (aval[i] != bval[i]) retval = GRIB_DOUBLE_VALUE_MISMATCH;
|
||||
}
|
||||
|
||||
grib_context_free(a->context, aval);
|
||||
|
|
|
@ -117,8 +117,7 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
|
|||
a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN;
|
||||
|
||||
self->number_of_elements = 6;
|
||||
self->v = (double*)grib_context_malloc(a->context,
|
||||
sizeof(double) * self->number_of_elements);
|
||||
self->v = (double*)grib_context_malloc(a->context, sizeof(double) * self->number_of_elements);
|
||||
|
||||
a->length = 0;
|
||||
a->dirty = 1;
|
||||
|
@ -144,6 +143,9 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
|||
return ret;
|
||||
|
||||
date = atoi(verifyingMonth);
|
||||
if (date < 0) {
|
||||
return GRIB_INVALID_ARGUMENT;
|
||||
}
|
||||
year = date / 100;
|
||||
month = date - year * 100;
|
||||
if (month == 2) {
|
||||
|
@ -151,9 +153,10 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
|||
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
|
||||
days = 29;
|
||||
}
|
||||
else
|
||||
else {
|
||||
if (month < 1 || month > 12) return GRIB_INVALID_ARGUMENT;
|
||||
days = mdays[month - 1];
|
||||
|
||||
}
|
||||
self->v[0] = year;
|
||||
self->v[1] = month;
|
||||
|
||||
|
@ -217,13 +220,11 @@ static int compare(grib_accessor* a, grib_accessor* b)
|
|||
b->dirty = 1;
|
||||
a->dirty = 1;
|
||||
|
||||
grib_unpack_double(a, aval, &alen);
|
||||
grib_unpack_double(b, bval, &blen);
|
||||
err = grib_unpack_double(a, aval, &alen); if(err) return err;
|
||||
err = grib_unpack_double(b, bval, &blen); if(err) return err;
|
||||
|
||||
while (alen != 0) {
|
||||
if (*bval != *aval)
|
||||
retval = GRIB_DOUBLE_VALUE_MISMATCH;
|
||||
alen--;
|
||||
for(size_t i=0; i<alen && retval == GRIB_SUCCESS; ++i) {
|
||||
if (aval[i] != bval[i]) retval = GRIB_DOUBLE_VALUE_MISMATCH;
|
||||
}
|
||||
|
||||
grib_context_free(a->context, aval);
|
||||
|
|
|
@ -241,10 +241,8 @@ static int compare(grib_accessor* a, grib_accessor* b)
|
|||
grib_unpack_long(b, bval, &blen);
|
||||
|
||||
retval = GRIB_SUCCESS;
|
||||
while (alen != 0) {
|
||||
if (*bval != *aval)
|
||||
retval = GRIB_LONG_VALUE_MISMATCH;
|
||||
alen--;
|
||||
for (size_t i=0; i<alen && retval == GRIB_SUCCESS; ++i) {
|
||||
if (aval[i] != bval[i]) retval = GRIB_LONG_VALUE_MISMATCH;
|
||||
}
|
||||
|
||||
grib_context_free(a->context, aval);
|
||||
|
|
|
@ -313,10 +313,9 @@ static int compare(grib_accessor* a, grib_accessor* b)
|
|||
grib_unpack_double(a, aval, &alen);
|
||||
grib_unpack_double(b, bval, &blen);
|
||||
|
||||
while (alen != 0) {
|
||||
if (*bval != *aval)
|
||||
retval = GRIB_DOUBLE_VALUE_MISMATCH;
|
||||
alen--;
|
||||
retval = GRIB_SUCCESS;
|
||||
for (size_t i=0; i<alen && retval == GRIB_SUCCESS; ++i) {
|
||||
if (aval[i] != bval[i]) retval = GRIB_DOUBLE_VALUE_MISMATCH;
|
||||
}
|
||||
|
||||
grib_context_free(a->context, aval);
|
||||
|
|
|
@ -266,10 +266,8 @@ static int compare(grib_accessor* a, grib_accessor* b)
|
|||
grib_unpack_double(b, bval, &blen);
|
||||
|
||||
retval = GRIB_SUCCESS;
|
||||
while (alen != 0) {
|
||||
if (*bval != *aval)
|
||||
retval = GRIB_DOUBLE_VALUE_MISMATCH;
|
||||
alen--;
|
||||
for (size_t i=0; i<alen && retval == GRIB_SUCCESS; ++i) {
|
||||
if (aval[i] != bval[i]) retval = GRIB_DOUBLE_VALUE_MISMATCH;
|
||||
}
|
||||
|
||||
grib_context_free(a->context, aval);
|
||||
|
|
|
@ -507,6 +507,7 @@ grib_handle* grib_handle_new_from_samples(grib_context* c, const char* sample_na
|
|||
* @return the new handle, NULL if the message is invalid or a problem is encountered
|
||||
*/
|
||||
grib_handle* grib_handle_clone(const grib_handle* h);
|
||||
grib_handle* grib_handle_clone_headers_only(const grib_handle* h);
|
||||
|
||||
/**
|
||||
* Frees a handle, also frees the message if it is not a user message
|
||||
|
@ -1658,7 +1659,7 @@ Error codes returned by the grib_api functions.
|
|||
#define GRIB_WRONG_STEP_UNIT -26
|
||||
/** Invalid file id */
|
||||
#define GRIB_INVALID_FILE -27
|
||||
/** Invalid grib id */
|
||||
/** Invalid GRIB id */
|
||||
#define GRIB_INVALID_GRIB -28
|
||||
/** Invalid index id */
|
||||
#define GRIB_INVALID_INDEX -29
|
||||
|
|
|
@ -950,7 +950,7 @@ struct grib_multi_support
|
|||
unsigned char* sections[8];
|
||||
unsigned char* bitmap_section;
|
||||
size_t bitmap_section_length;
|
||||
size_t sections_length[9];
|
||||
size_t sections_length[9]; /* GRIB2 has 9 sections */
|
||||
int section_number;
|
||||
grib_multi_support* next;
|
||||
};
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
static void grib_get_buffer_ownership(const grib_context* c, grib_buffer* b)
|
||||
{
|
||||
unsigned char* newdata;
|
||||
unsigned char* newdata = NULL;
|
||||
if (b->property == CODES_MY_BUFFER)
|
||||
return;
|
||||
|
||||
|
@ -78,11 +78,9 @@ void grib_buffer_delete(const grib_context* c, grib_buffer* b)
|
|||
|
||||
static void grib_grow_buffer_to(const grib_context* c, grib_buffer* b, size_t ns)
|
||||
{
|
||||
unsigned char* newdata;
|
||||
|
||||
if (ns > b->length) {
|
||||
grib_get_buffer_ownership(c, b);
|
||||
newdata = (unsigned char*)grib_context_malloc_clear(c, ns);
|
||||
unsigned char* newdata = (unsigned char*)grib_context_malloc_clear(c, ns);
|
||||
memcpy(newdata, b->data, b->length);
|
||||
grib_context_free(c, b->data);
|
||||
b->data = newdata;
|
||||
|
|
|
@ -40,7 +40,7 @@ static const char *errors[] = {
|
|||
"Unable to set step", /* -25 GRIB_WRONG_STEP */
|
||||
"Wrong units for step (step must be integer)", /* -26 GRIB_WRONG_STEP_UNIT */
|
||||
"Invalid file id", /* -27 GRIB_INVALID_FILE */
|
||||
"Invalid grib id", /* -28 GRIB_INVALID_GRIB */
|
||||
"Invalid GRIB id", /* -28 GRIB_INVALID_GRIB */
|
||||
"Invalid index id", /* -29 GRIB_INVALID_INDEX */
|
||||
"Invalid iterator id", /* -30 GRIB_INVALID_ITERATOR */
|
||||
"Invalid keys iterator id", /* -31 GRIB_INVALID_KEYS_ITERATOR */
|
||||
|
|
|
@ -29,7 +29,7 @@ GRIB_WRONG_STEP Unable to set step
|
|||
GRIB_WRONG_STEP_UNIT Wrong units for step (step must be integer)
|
||||
/* some errors for the fortran interface */
|
||||
GRIB_INVALID_FILE Invalid file id
|
||||
GRIB_INVALID_GRIB Invalid grib id
|
||||
GRIB_INVALID_GRIB Invalid GRIB id
|
||||
GRIB_INVALID_INDEX Invalid index id
|
||||
GRIB_INVALID_ITERATOR Invalid iterator id
|
||||
GRIB_INVALID_KEYS_ITERATOR Invalid keys iterator id
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
static grib_handle* grib_handle_new_from_file_no_multi(grib_context* c, FILE* f, int headers_only, int* error);
|
||||
static grib_handle* grib_handle_new_from_file_multi(grib_context* c, FILE* f, int* error);
|
||||
static int grib2_get_next_section(unsigned char* msgbegin, size_t msglen, unsigned char** secbegin, size_t* seclen, int* secnum, int* err);
|
||||
static int grib2_has_next_section(unsigned char* msgbegin, size_t msglen, unsigned char* secbegin, size_t seclen, int* err);
|
||||
static bool grib2_get_next_section(unsigned char* msgbegin, size_t msglen, unsigned char** secbegin, size_t* seclen, int* secnum, int* err);
|
||||
static bool grib2_has_next_section(unsigned char* msgbegin, size_t msglen, unsigned char* secbegin, size_t seclen, int* err);
|
||||
static void grib2_build_message(grib_context* context, unsigned char* sections[], size_t sections_len[], void** data, size_t* msglen);
|
||||
static grib_multi_support* grib_get_multi_support(grib_context* c, FILE* f);
|
||||
static grib_multi_support* grib_multi_support_new(grib_context* c);
|
||||
|
@ -326,6 +326,98 @@ grib_handle* grib_handle_clone(const grib_handle* h)
|
|||
return result;
|
||||
}
|
||||
|
||||
static bool can_create_clone_headers_only(const grib_handle* h)
|
||||
{
|
||||
// Only for GRIB, not BUFR etc
|
||||
if (h->product_kind != PRODUCT_GRIB) return false;
|
||||
|
||||
// Spectral data does not have constant fields!
|
||||
long isGridded = 0;
|
||||
int err = grib_get_long(h, "isGridded", &isGridded);
|
||||
if (err || !isGridded) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Clone the message but not its Bitmap and Data sections (only the meta-data)
|
||||
grib_handle* grib_handle_clone_headers_only(const grib_handle* h)
|
||||
{
|
||||
int err = 0;
|
||||
grib_handle* result = NULL;
|
||||
grib_context* c = h->context;
|
||||
|
||||
if (!can_create_clone_headers_only(h)) {
|
||||
// Headers-only clone not possible. Do a normal clone
|
||||
return grib_handle_clone(h);
|
||||
}
|
||||
|
||||
char sample_name[1024];
|
||||
long edition = 0;
|
||||
grib_get_long(h, "edition", &edition);
|
||||
snprintf(sample_name, sizeof(sample_name), "GRIB%ld", edition);
|
||||
grib_handle* h_sample = grib_handle_new_from_samples(c, sample_name);
|
||||
if (!h_sample) {
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "Failed to create headers_only clone using sample %s", sample_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Must preserve the packingType
|
||||
char input_packing_type[100];
|
||||
size_t len = sizeof(input_packing_type);
|
||||
err = grib_get_string(h, "packingType", input_packing_type, &len);
|
||||
if (!err) {
|
||||
grib_set_string(h_sample, "packingType", input_packing_type, &len);
|
||||
}
|
||||
|
||||
// Copy all sections except Bitmap and Data from h to h_sample
|
||||
const int sections_to_copy = GRIB_SECTION_PRODUCT | GRIB_SECTION_LOCAL | GRIB_SECTION_GRID;
|
||||
result = grib_util_sections_copy((grib_handle*)h, h_sample, sections_to_copy, &err);
|
||||
if (!result || err) {
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "Failed to create headers_only clone: Unable to copy sections");
|
||||
grib_handle_delete(h_sample);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
grib_handle_delete(h_sample);
|
||||
return result;
|
||||
}
|
||||
|
||||
// grib_handle* grib_handle_clone_headers_only(const grib_handle* h)
|
||||
// {
|
||||
// int err = 0;
|
||||
// size_t size1 = 0;
|
||||
// const void* msg1 = NULL;
|
||||
// long edition = 0;
|
||||
// // Only for GRIB, not BUFR etc
|
||||
// if (h->product_kind != PRODUCT_GRIB) {
|
||||
// grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Only supported for %s",
|
||||
// __func__, codes_get_product_name(PRODUCT_GRIB));
|
||||
// return NULL;
|
||||
// }
|
||||
// err = grib_get_long(h, "edition", &edition);
|
||||
// if (!err && edition == 1) {
|
||||
// grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Edition not supported", __func__);
|
||||
// return NULL;
|
||||
// }
|
||||
// err = grib_get_message_headers(h, &msg1, &size1);
|
||||
// if (err) return NULL;
|
||||
// size1 += 4;
|
||||
// grib_handle* result = grib_handle_new_from_partial_message_copy(h->context, msg1, size1);
|
||||
// result->buffer->data[ size1 - 4 ] = '7';
|
||||
// result->buffer->data[ size1 - 3 ] = '7';
|
||||
// result->buffer->data[ size1 - 2 ] = '7';
|
||||
// result->buffer->data[ size1 - 1 ] = '7';
|
||||
// result->buffer->ulength = size1;
|
||||
// result->product_kind = h->product_kind;
|
||||
// long off = 64; // This is only true for GRIB edition 2
|
||||
// err = grib_encode_unsigned_long( result->buffer->data, (unsigned long)size1, &off, 64);
|
||||
// if (err) {
|
||||
// printf("err=%s\n", grib_get_error_message(err));
|
||||
// return NULL;
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
grib_handle* codes_handle_new_from_file(grib_context* c, FILE* f, ProductKind product, int* error)
|
||||
{
|
||||
if (product == PRODUCT_GRIB)
|
||||
|
@ -1161,11 +1253,10 @@ grib_multi_handle* grib_multi_handle_new(grib_context* c)
|
|||
|
||||
int grib_multi_handle_delete(grib_multi_handle* h)
|
||||
{
|
||||
if (h == NULL)
|
||||
return GRIB_SUCCESS;
|
||||
|
||||
if (h != NULL) {
|
||||
grib_buffer_delete(h->context, h->buffer);
|
||||
grib_context_free(h->context, h);
|
||||
}
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1227,11 +1318,11 @@ int grib_multi_handle_write(grib_multi_handle* h, FILE* f)
|
|||
return GRIB_INVALID_GRIB;
|
||||
|
||||
if (fwrite(h->buffer->data, 1, h->buffer->ulength, f) != h->buffer->ulength) {
|
||||
grib_context_log(h->context, GRIB_LOG_PERROR, "grib_multi_handle_write writing on file");
|
||||
grib_context_log(h->context, GRIB_LOG_PERROR, "%s failed", __func__);
|
||||
return GRIB_IO_PROBLEM;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
int grib_get_partial_message(grib_handle* h, const void** msg, size_t* len, int start_section)
|
||||
|
@ -1295,9 +1386,9 @@ int grib_get_message_offset(const grib_handle* h, off_t* offset)
|
|||
if (h)
|
||||
*offset = h->offset;
|
||||
else
|
||||
return GRIB_INTERNAL_ERROR;
|
||||
return GRIB_NULL_HANDLE;
|
||||
|
||||
return 0;
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
int codes_get_product_kind(const grib_handle* h, ProductKind* product_kind)
|
||||
|
@ -1468,10 +1559,10 @@ int grib_handle_apply_action(grib_handle* h, grib_action* a)
|
|||
// return GRIB_SUCCESS;
|
||||
// }
|
||||
|
||||
static int grib2_get_next_section(unsigned char* msgbegin, size_t msglen, unsigned char** secbegin, size_t* seclen, int* secnum, int* err)
|
||||
static bool grib2_get_next_section(unsigned char* msgbegin, size_t msglen, unsigned char** secbegin, size_t* seclen, int* secnum, int* err)
|
||||
{
|
||||
if (!grib2_has_next_section(msgbegin, msglen, *secbegin, *seclen, err))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
*secbegin += *seclen;
|
||||
*seclen = grib_decode_unsigned_byte_long(*secbegin, 0, 4);
|
||||
|
@ -1479,12 +1570,12 @@ static int grib2_get_next_section(unsigned char* msgbegin, size_t msglen, unsign
|
|||
|
||||
if (*secnum < 1 || *secnum > 7) {
|
||||
*err = GRIB_INVALID_SECTION_NUMBER;
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int grib2_has_next_section(unsigned char* msgbegin, size_t msglen, unsigned char* secbegin, size_t seclen, int* err)
|
||||
static bool grib2_has_next_section(unsigned char* msgbegin, size_t msglen, unsigned char* secbegin, size_t seclen, int* err)
|
||||
{
|
||||
long next_seclen;
|
||||
*err = 0;
|
||||
|
@ -1496,12 +1587,12 @@ static int grib2_has_next_section(unsigned char* msgbegin, size_t msglen, unsign
|
|||
*err = GRIB_SUCCESS;
|
||||
else
|
||||
*err = GRIB_7777_NOT_FOUND;
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*secbegin += seclen;*/
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void grib2_build_message(grib_context* context, unsigned char* sections[], size_t sections_len[], void** data, size_t* len)
|
||||
|
@ -1616,6 +1707,8 @@ void grib_multi_support_reset(grib_context* c)
|
|||
|
||||
static grib_multi_support* grib_multi_support_new(grib_context* c)
|
||||
{
|
||||
// GRIB edition 2 has 9 sections ( 0 to 8 )
|
||||
const int GRIB2_END_SECTION = 8;
|
||||
int i = 0;
|
||||
grib_multi_support* gm =
|
||||
(grib_multi_support*)grib_context_malloc_clear(c, sizeof(grib_multi_support));
|
||||
|
@ -1627,9 +1720,10 @@ static grib_multi_support* grib_multi_support_new(grib_context* c)
|
|||
gm->section_number = 0;
|
||||
gm->next = 0;
|
||||
gm->sections_length[0] = 16;
|
||||
for (i = 1; i < 8; i++)
|
||||
|
||||
for (i = 1; i < GRIB2_END_SECTION; i++)
|
||||
gm->sections_length[i] = 0;
|
||||
gm->sections_length[8] = 4;
|
||||
gm->sections_length[GRIB2_END_SECTION] = 4; // The 7777
|
||||
|
||||
return gm;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ list(APPEND test_c_bins
|
|||
grib_indexing
|
||||
grib_fieldset
|
||||
grib_multi_from_message
|
||||
grib_clone_headers_only
|
||||
grib_read_index
|
||||
unit_tests
|
||||
bufr_keys_iter
|
||||
|
@ -171,6 +172,7 @@ if( HAVE_BUILD_TOOLS )
|
|||
grib_headers_only
|
||||
grib_unpack_subarray
|
||||
grib_count
|
||||
grib_clone_headers_only
|
||||
bufr_templates
|
||||
bufr_dump_data
|
||||
bufr_dump_descriptors
|
||||
|
@ -293,6 +295,7 @@ if( HAVE_BUILD_TOOLS )
|
|||
grib_local
|
||||
grib_step
|
||||
grib_set
|
||||
grib_set_fail
|
||||
grib_iterator
|
||||
grib_proj_string
|
||||
grib_compare
|
||||
|
|
|
@ -52,6 +52,17 @@ if [ $? -eq 0 ]; then
|
|||
fi
|
||||
set -e
|
||||
|
||||
# Namespace options
|
||||
set +e
|
||||
${tools_dir}/bufr_compare -c ls:n $f1 $f2 >> $fLog
|
||||
statusA=$?
|
||||
${tools_dir}/bufr_compare -a -c ls:n $f1 $f2 >> $fLog
|
||||
statusB=$?
|
||||
set -e
|
||||
[ $statusA -ne 0 ]
|
||||
[ $statusB -ne 0 ]
|
||||
|
||||
|
||||
#----------------------------------------------------
|
||||
# Test: comparing with and without the -b switch
|
||||
#----------------------------------------------------
|
||||
|
|
|
@ -16,6 +16,8 @@ cd ${data_dir}/bufr
|
|||
# Define a common label for all the tmp files
|
||||
label="bufr_filter_misc_test"
|
||||
|
||||
tempErr=temp.$label.err
|
||||
|
||||
# Create log file
|
||||
fLog=${label}".log"
|
||||
rm -f $fLog
|
||||
|
@ -1337,5 +1339,16 @@ EOF
|
|||
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
|
||||
rm -f $tempErr
|
||||
|
|
|
@ -71,5 +71,19 @@ ${tools_dir}/codes_bufr_filter $fRules $f
|
|||
f="$ECCODES_SAMPLES_PATH/BUFR4.tmpl"
|
||||
echo 'print "[expandedOriginalReferences:i]";' | ${tools_dir}/codes_bufr_filter - $f
|
||||
|
||||
# Error decoding 'pack'
|
||||
# ----------------------
|
||||
f="$ECCODES_SAMPLES_PATH/BUFR4.tmpl"
|
||||
set +e
|
||||
echo 'print "[pack]";' | ${tools_dir}/codes_bufr_filter - $f 2>$temp
|
||||
status=$?
|
||||
set -e
|
||||
grep -q "Function not yet implemented" $temp
|
||||
|
||||
# Pack using a double
|
||||
f=nos6_208.bufr
|
||||
${tools_dir}/bufr_set -s unpack=1,satelliteIdentifier=666,pack:d=1 $f $temp
|
||||
${tools_dir}/bufr_compare -b satelliteIdentifier $f $temp
|
||||
|
||||
# Clean up
|
||||
rm -f $fRules $fLog $temp
|
||||
|
|
|
@ -183,6 +183,22 @@ ${tools_dir}/bufr_set -s messageLength:s=333 $ECCODES_SAMPLES_PATH/BUFR4_local.t
|
|||
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
|
||||
set +e
|
||||
${tools_dir}/bufr_dump -p $fBufrTmp 2>>$fLog 1>>$fLog
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "bufr_dump should have failed" >&2
|
||||
exit 1
|
||||
fi
|
||||
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
|
||||
|
||||
|
||||
# Clean up
|
||||
rm -f $fLog
|
||||
rm -f $fBufrTmp
|
||||
|
|
|
@ -17,13 +17,19 @@ int main(int argc, char* argv[])
|
|||
grib_handle* h1 = NULL;
|
||||
grib_handle* h2 = NULL;
|
||||
int err = 0;
|
||||
size_t count = 0;
|
||||
size_t num_diffs = 0, i = 0;
|
||||
char** list_provided_keys = NULL;
|
||||
|
||||
Assert(argc == 3);
|
||||
f1 = fopen(argv[1], "rb");
|
||||
f2 = fopen(argv[2], "rb");
|
||||
Assert(f1 && f2);
|
||||
|
||||
if (argc == 4) {
|
||||
// List of keys is also given on the command line
|
||||
char* input = argv[3];
|
||||
list_provided_keys = string_split(input, ",");
|
||||
}
|
||||
|
||||
while ((h1 = grib_handle_new_from_file(0, f1, &err)) != NULL && (h2 = grib_handle_new_from_file(0, f2, &err)) != NULL) {
|
||||
grib_keys_iterator* kiter = NULL;
|
||||
|
||||
|
@ -39,7 +45,7 @@ int main(int argc, char* argv[])
|
|||
err = codes_compare_key(h1, h2, name, 0);
|
||||
if (err) {
|
||||
fprintf(stderr, "key: %s (%s)\n", name, grib_get_error_message(err));
|
||||
++count;
|
||||
++num_diffs;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,14 +55,33 @@ int main(int argc, char* argv[])
|
|||
codes_compare_key(h1, h2, "paramId", 0); // concept
|
||||
codes_compare_key(h1, h2, "identifier", 0); // ascii
|
||||
|
||||
if (list_provided_keys) {
|
||||
for (i = 0; list_provided_keys[i] != NULL; ++i) {
|
||||
const char* pkey = list_provided_keys[i];
|
||||
//printf("Comparing provided key %s ...\n", list_provided_keys[i]);
|
||||
err = codes_compare_key(h1, h2, pkey, 0);
|
||||
if (err) {
|
||||
fprintf(stderr, "key: %s (%s)\n", pkey, grib_get_error_message(err));
|
||||
++num_diffs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
grib_keys_iterator_delete(kiter);
|
||||
grib_handle_delete(h1);
|
||||
grib_handle_delete(h2);
|
||||
}
|
||||
|
||||
fclose(f1);
|
||||
fclose(f2);
|
||||
if (count > 0) {
|
||||
fprintf(stderr, "\nComparison failed: %zu differences\n", count);
|
||||
|
||||
if (list_provided_keys) {
|
||||
for (i = 0; list_provided_keys[i] != NULL; ++i) free(list_provided_keys[i]);
|
||||
free(list_provided_keys);
|
||||
}
|
||||
|
||||
if (num_diffs > 0) {
|
||||
fprintf(stderr, "\nComparison failed: %zu differences\n", num_diffs);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -63,5 +63,27 @@ EOF
|
|||
|
||||
diff $tempRef $tempLog
|
||||
|
||||
# Spectral
|
||||
# ----------
|
||||
sample_spectral=$ECCODES_SAMPLES_PATH/sh_ml_grib2.tmpl
|
||||
${test_dir}/codes_compare_keys $sample_spectral $sample_spectral enorm,avg
|
||||
|
||||
|
||||
# Local definitions
|
||||
# ----------------------
|
||||
sample1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
|
||||
tempGribA=temp.${label}.A.grib
|
||||
tempGribB=temp.${label}.B.grib
|
||||
${tools_dir}/grib_set -s localDefinitionNumber=16,verifyingMonth=6 $sample1 $tempGribA
|
||||
${tools_dir}/grib_set -s localDefinitionNumber=16,verifyingMonth=5 $sample1 $tempGribB
|
||||
set +e
|
||||
${test_dir}/codes_compare_keys $tempGribA $tempGribB endOfInterval > $tempLog 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "2 differences" $tempLog
|
||||
rm -f $tempGribA $tempGribB
|
||||
|
||||
|
||||
# Clean up
|
||||
rm -f $tempLog $tempRef $tempGrib
|
||||
|
|
|
@ -13,11 +13,18 @@
|
|||
label="codes_dump_content_test"
|
||||
temp=temp.$label.txt
|
||||
|
||||
infile=$data_dir/sample.grib2
|
||||
infiles="
|
||||
sample.grib2
|
||||
test_uuid.grib2
|
||||
"
|
||||
|
||||
modes="default wmo json serialize debug grib_encode_C"
|
||||
for mode in $modes; do
|
||||
$EXEC ${test_dir}/codes_dump_content $mode $infile
|
||||
for gf in $infiles; do
|
||||
echo Doing $gf
|
||||
infile=$data_dir/$gf
|
||||
$EXEC ${test_dir}/codes_dump_content $mode $infile > $temp
|
||||
done
|
||||
done
|
||||
|
||||
${test_dir}/codes_dump_content rubbish $infile > $temp 2>&1
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* (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 <stdio.h>
|
||||
#include "eccodes.h"
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
static void usage(const char* app)
|
||||
{
|
||||
fprintf(stderr, "Usage is: %s input_file ouput_file\n", app);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
FILE* in = NULL;
|
||||
FILE* out = NULL;
|
||||
codes_handle* source_handle = NULL;
|
||||
const void* buffer = NULL;
|
||||
int err = 0;
|
||||
|
||||
long totalLength_src = 0, totalLength_dst = 0;
|
||||
long edition = 0, isGridded = 0, bitmapPresent = 0;
|
||||
long isConstant_src = 0, isConstant_dst = 0;
|
||||
long dataSectionLength_src = 0, dataSectionLength_dst = 0;
|
||||
size_t messageLength_src = 0, messageLength_dst = 0;
|
||||
|
||||
if (argc != 3) {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in = fopen(argv[1], "rb");
|
||||
assert(in);
|
||||
out = fopen(argv[2], "wb");
|
||||
assert(out);
|
||||
|
||||
while ((source_handle = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err)) != NULL) {
|
||||
codes_handle* clone_handle = codes_handle_clone_headers_only(source_handle);
|
||||
assert(clone_handle);
|
||||
|
||||
codes_get_long(source_handle, "isConstant", &isConstant_src);
|
||||
codes_get_long(source_handle, "isGridded", &isGridded);
|
||||
if (isGridded && !isConstant_src) {
|
||||
|
||||
CODES_CHECK(codes_get_message(source_handle, &buffer, &messageLength_src), 0);
|
||||
CODES_CHECK(codes_get_message(clone_handle, &buffer, &messageLength_dst), 0);
|
||||
assert( messageLength_src > messageLength_dst );
|
||||
|
||||
CODES_CHECK(codes_get_long(source_handle, "totalLength", &totalLength_src), 0);
|
||||
CODES_CHECK(codes_get_long(clone_handle, "totalLength", &totalLength_dst), 0);
|
||||
assert(totalLength_src > totalLength_dst);
|
||||
|
||||
CODES_CHECK(codes_get_long(source_handle, "edition", &edition), 0);
|
||||
if (edition == 1) {
|
||||
CODES_CHECK(codes_get_long(source_handle, "section4Length", &dataSectionLength_src), 0);
|
||||
CODES_CHECK(codes_get_long(clone_handle, "section4Length", &dataSectionLength_dst), 0);
|
||||
} else if (edition == 2) {
|
||||
CODES_CHECK(codes_get_long(source_handle, "section7Length", &dataSectionLength_src), 0);
|
||||
CODES_CHECK(codes_get_long(clone_handle, "section7Length", &dataSectionLength_dst), 0);
|
||||
}
|
||||
assert( dataSectionLength_src > dataSectionLength_dst );
|
||||
|
||||
codes_get_long(clone_handle, "bitmapPresent", &bitmapPresent);
|
||||
assert(bitmapPresent == 0);
|
||||
codes_get_long(clone_handle, "isConstant", &isConstant_dst);
|
||||
assert(isConstant_dst == 1);
|
||||
}
|
||||
|
||||
/* write out the cloned buffer */
|
||||
if (fwrite(buffer, 1, messageLength_dst, out) != messageLength_dst) {
|
||||
perror(argv[1]);
|
||||
return 1;
|
||||
}
|
||||
codes_handle_delete(clone_handle);
|
||||
codes_handle_delete(source_handle);
|
||||
}
|
||||
|
||||
fclose(out);
|
||||
fclose(in);
|
||||
|
||||
printf("All OK\n");
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
#!/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_clone_headers_only_test"
|
||||
temp=temp.$label.grib
|
||||
|
||||
inputs="
|
||||
sst_globus0083.grib
|
||||
sample.grib2
|
||||
mixed.grib
|
||||
"
|
||||
|
||||
for f in $inputs; do
|
||||
infile=$data_dir/$f
|
||||
rm -f $temp
|
||||
$EXEC ${test_dir}/grib_clone_headers_only $infile $temp
|
||||
${tools_dir}/grib_compare -H -b totalLength $infile $temp
|
||||
done
|
||||
|
||||
# Clean up
|
||||
rm -f $temp
|
|
@ -30,7 +30,11 @@ set -e
|
|||
infile1=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl
|
||||
${tools_dir}/grib_set -s year=2019 $infile1 $outfile
|
||||
${tools_dir}/grib_compare -c data:n $infile1 $outfile
|
||||
|
||||
set +e
|
||||
${tools_dir}/grib_compare -a -c data:n $infile1 $outfile
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -eq 1 ]
|
||||
|
||||
# Header (meta-data) keys
|
||||
infile=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl
|
||||
|
|
|
@ -106,6 +106,7 @@ grep -q "dataDate = 19090206" $temp
|
|||
# Skip handle
|
||||
${tools_dir}/grib_dump -w count=4 $file > $temp 2>&1
|
||||
|
||||
ECCODES_DEBUG=1 ${tools_dir}/grib_dump $data_dir/sample.grib2
|
||||
|
||||
# Clean up
|
||||
rm -f $temp
|
||||
|
|
|
@ -406,6 +406,15 @@ EOF
|
|||
${tools_dir}/grib_filter $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
||||
|
||||
|
||||
# Bad filter
|
||||
set +e
|
||||
${tools_dir}/grib_filter a_non_existent_filter_file $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "Cannot include file" $tempOut
|
||||
|
||||
|
||||
# Clean up
|
||||
rm -f $tempGrib $tempFilt $tempOut $tempRef
|
||||
rm -f ${data_dir}/formatint.rules ${data_dir}/binop.rules
|
||||
|
|
|
@ -9,22 +9,23 @@
|
|||
|
||||
. ./include.ctest.sh
|
||||
|
||||
label="grib_grid_lamb_az_eq_area_test"
|
||||
|
||||
GRIB_INFILE=${data_dir}/regular_gaussian_pressure_level_constant.grib2
|
||||
REF_FILE=grib_lamb_az_eq_area.ref
|
||||
|
||||
# Temporary files created for this test
|
||||
FILTER_FILE=lamb_az_eq_area.filter
|
||||
GRIB_OUTFILE=lamb_az_eq_area.grib2
|
||||
DATA_OUTFILE=lamb_data.txt
|
||||
FILTER_FILE=temp.$label.filter
|
||||
GRIB_OUTFILE=temp.$label.grib2
|
||||
DATA_OUTFILE=temp.$label.txt
|
||||
rm -f $FILTER_FILE $GRIB_OUTFILE $DATA_OUTFILE
|
||||
|
||||
# --------------------
|
||||
# Spherical Earth
|
||||
# ----------------
|
||||
# --------------------
|
||||
|
||||
# Create a filter
|
||||
cat > $FILTER_FILE<<EOF
|
||||
set edition = 2;
|
||||
set gridType = "lambert_azimuthal_equal_area";
|
||||
set Nx = 10;
|
||||
set Ny = 10;
|
||||
|
@ -53,7 +54,7 @@ ${tools_dir}/grib_filter -o $GRIB_OUTFILE $FILTER_FILE $GRIB_INFILE
|
|||
${tools_dir}/grib_get_data $GRIB_OUTFILE > $DATA_OUTFILE
|
||||
|
||||
# Compare output with reference. If the diff fails, script will immediately exit with status 1
|
||||
diff $DATA_OUTFILE $REF_FILE
|
||||
diff $REF_FILE $DATA_OUTFILE
|
||||
|
||||
grib_check_key_equals $GRIB_OUTFILE standardParallelInDegrees,centralLongitudeInDegrees '48 9'
|
||||
grib_check_key_equals $GRIB_OUTFILE xDirectionGridLengthInMetres,yDirectionGridLengthInMetres '5000 5000'
|
||||
|
@ -62,8 +63,20 @@ grib_check_key_equals $GRIB_OUTFILE xDirectionGridLengthInMetres,yDirectionGridL
|
|||
${tools_dir}/grib_ls -l 67,-33,1 $GRIB_OUTFILE
|
||||
|
||||
# jPointsAreConsecutive
|
||||
${tools_dir}/grib_get_data -s jPointsAreConsecutive=1 $GRIB_OUTFILE > $DATA_OUTFILE
|
||||
tempOutA=temp.$label.A.txt
|
||||
tempOutB=temp.$label.B.txt
|
||||
${tools_dir}/grib_get_data -s jPointsAreConsecutive=0 $GRIB_OUTFILE > $tempOutA
|
||||
${tools_dir}/grib_get_data -s jPointsAreConsecutive=1 $GRIB_OUTFILE > $tempOutB
|
||||
# Results should be different.
|
||||
set +e
|
||||
diff $tempOutA $tempOutB > /dev/null
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
rm -f $tempOutA $tempOutB
|
||||
|
||||
|
||||
# --------------------
|
||||
# Oblate spheroid
|
||||
# --------------------
|
||||
|
||||
|
|
|
@ -13,8 +13,16 @@
|
|||
label="grib_mars_keys2_test"
|
||||
tempGrib=temp.${label}.grib
|
||||
|
||||
grib1_sample=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
|
||||
grib2_sample=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl
|
||||
|
||||
|
||||
# Check lowercase/uppercase
|
||||
${tools_dir}/grib_set -s class=YT,type=EM,stream=DCWV $grib1_sample $tempGrib
|
||||
grib_check_key_equals $tempGrib mars.class,mars.type,mars.stream 'yt em dcwv'
|
||||
grib_check_key_equals $tempGrib marsClass:i,marsType:i,marsStream:i '18 17 1029'
|
||||
|
||||
|
||||
# Check all combinations
|
||||
# ------------------------
|
||||
i=0
|
||||
|
@ -31,4 +39,5 @@ for cfg in $ECCODES_DEFINITION_PATH/mars/grib.*.*.def; do
|
|||
done
|
||||
echo "Checked $i files"
|
||||
|
||||
# Clean up
|
||||
rm -f $tempGrib
|
||||
|
|
|
@ -10,11 +10,12 @@
|
|||
|
||||
. ./include.ctest.sh
|
||||
|
||||
label="grib_set_test"
|
||||
REDIRECT=/dev/null
|
||||
|
||||
infile=${data_dir}/regular_gaussian_surface.grib1
|
||||
outfile=${data_dir}/temp.grib_set.grib
|
||||
temp=temp.grib_set.out
|
||||
outfile=${data_dir}/temp.$label.grib
|
||||
temp=${data_dir}/temp.$label.out
|
||||
|
||||
rm -f $outfile
|
||||
|
||||
|
@ -49,73 +50,6 @@ centre=`${tools_dir}/grib_get -p centre $outfile`
|
|||
centre=`${tools_dir}/grib_get -p centre:l $outfile`
|
||||
[ $centre -eq 80 ]
|
||||
|
||||
# Set without -s. Expected to fail
|
||||
# ----------------------------------------------------
|
||||
set +e
|
||||
${tools_dir}/grib_set -p levtype $infile $outfile > $temp 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "provide some keys to set" $temp
|
||||
|
||||
# Set with empty -s. Expected to fail
|
||||
# ----------------------------------------------------
|
||||
set +e
|
||||
${tools_dir}/grib_set -s '' $infile $outfile > $temp 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "provide some keys to set" $temp
|
||||
|
||||
# Out-of-bounds value. Expected to fail
|
||||
# ----------------------------------------------------
|
||||
input=${data_dir}/reduced_gaussian_sub_area.grib2
|
||||
set +e
|
||||
${tools_dir}/grib_set -s perturbationNumber=1000 $input $outfile 2>$temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "Trying to encode value of 1000 but the maximum allowable value is 255 (number of bits=8)" $temp
|
||||
|
||||
# Negative value for an unsigned key. Expected to fail
|
||||
# ----------------------------------------------------
|
||||
input=${data_dir}/reduced_gaussian_sub_area.grib2
|
||||
set +e
|
||||
${tools_dir}/grib_set -s perturbationNumber=-1 $input $outfile 2>$temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "Trying to encode a negative value of -1 for key of type unsigned" $temp
|
||||
|
||||
# Bad value for -d
|
||||
# ----------------
|
||||
input=${data_dir}/reduced_gaussian_sub_area.grib2
|
||||
set +e
|
||||
${tools_dir}/grib_set -d hello $input $outfile 2>$temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "Invalid number" $temp
|
||||
|
||||
|
||||
# ECC-1605: Out-of-bounds value for signed keys
|
||||
# ----------------------------------------------------
|
||||
if [ $ECCODES_ON_WINDOWS -eq 0 ]; then
|
||||
input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
||||
set +e
|
||||
${tools_dir}/grib_set -s forecastTime=2147483648 $input $outfile 2>$temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "Trying to encode value of 2147483648 but the allowable range is -2147483647 to 2147483647" $temp
|
||||
|
||||
set +e
|
||||
${tools_dir}/grib_set -s forecastTime=-2147483650 $input $outfile 2>$temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
fi
|
||||
|
||||
# GRIB-941: encoding of GRIB2 angles
|
||||
# -----------------------------------
|
||||
angleInDegrees=130.9989
|
||||
|
@ -133,14 +67,6 @@ ${tools_dir}/grib_set -s centre=289 $ECCODES_SAMPLES_PATH/GRIB2.tmpl $outfile
|
|||
${tools_dir}/grib_dump -O $outfile > $temp
|
||||
grep -q 'centre = 289.*Zambia' $temp
|
||||
|
||||
# ECC-539: avoid output being the same as input
|
||||
# -----------------------------------------------
|
||||
set +e
|
||||
${tools_dir}/grib_set -s centre=0 $outfile $outfile
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
|
||||
# offsetValuesBy
|
||||
# ------------------
|
||||
input=${data_dir}/reduced_latlon_surface.grib2
|
||||
|
@ -151,48 +77,6 @@ max=`${tools_dir}/grib_get -F%.3f -p max $input`
|
|||
max=`${tools_dir}/grib_get -F%.3f -p max $outfile`
|
||||
[ "$max" = "13.097" ]
|
||||
|
||||
# ECC-1359: string that can be converted to an integer
|
||||
# ---------------------------------------------------
|
||||
${tools_dir}/grib_set -s month:s=6 $ECCODES_SAMPLES_PATH/GRIB2.tmpl $outfile
|
||||
grib_check_key_equals $outfile month 6
|
||||
# Now try an illegal value: a string that cannot be converted to an integer
|
||||
set +e
|
||||
${tools_dir}/grib_set -s month=BAD $ECCODES_SAMPLES_PATH/GRIB2.tmpl $outfile 2> $temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "String cannot be converted to an integer" $temp
|
||||
|
||||
|
||||
# ECC-1363: Does not fail for invalid value for key of type 'double'
|
||||
# ------------------------------------------------------------------
|
||||
${tools_dir}/grib_set -s angleOfRotation:s=10.66 $ECCODES_SAMPLES_PATH/rotated_ll_sfc_grib2.tmpl $outfile
|
||||
grib_check_key_equals $outfile angleOfRotation 10.66
|
||||
# Now try an illegal value: a string that cannot be converted to an integer
|
||||
set +e
|
||||
${tools_dir}/grib_set -s angleOfRotation=BAD $ECCODES_SAMPLES_PATH/rotated_ll_sfc_grib2.tmpl $outfile 2>$temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "String cannot be converted to a double" $temp
|
||||
|
||||
|
||||
# Set ascii key via double or long
|
||||
# --------------------------------
|
||||
${tools_dir}/grib_set -s setLocalDefinition=1,localDefinitionNumber=21 $ECCODES_SAMPLES_PATH/GRIB2.tmpl $outfile
|
||||
${tools_dir}/grib_set -s marsDomain=x $outfile $temp
|
||||
grib_check_key_equals $temp 'marsDomain' 'x'
|
||||
set +e
|
||||
${tools_dir}/grib_set -s marsDomain=9 $outfile $temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
|
||||
set +e
|
||||
${tools_dir}/grib_set -s marsDomain=1.2 $outfile $temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
|
||||
# Strict option
|
||||
# ---------------
|
||||
|
@ -215,27 +99,6 @@ grib_check_key_equals $input 'typeOfProcessedData:i' '2'
|
|||
${tools_dir}/grib_set -s typeOfProcessedData=rubbish $input $outfile
|
||||
grib_check_key_equals $outfile 'typeOfProcessedData:i' '255' # set to default
|
||||
|
||||
# Codetable mismatch
|
||||
# ------------------------
|
||||
input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
||||
set +e
|
||||
${tools_dir}/grib_set -s stepUnits=d $input $outfile > $temp 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "Invalid unit:.*(Unit not found). Available units are:.*" $temp
|
||||
|
||||
# ------------------------
|
||||
# Unreadable message
|
||||
# ------------------------
|
||||
echo GRIB > $outfile
|
||||
set +e
|
||||
${tools_dir}/grib_set -s edition=2 $outfile /dev/null > $temp 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "unreadable message" $temp
|
||||
|
||||
|
||||
# Clean up
|
||||
rm -f $outfile $temp
|
||||
|
|
|
@ -0,0 +1,173 @@
|
|||
#!/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_fail_test"
|
||||
REDIRECT=/dev/null
|
||||
|
||||
outfile=${data_dir}/temp.$label.grib
|
||||
temp=${data_dir}/temp.$label.out
|
||||
|
||||
infile=${data_dir}/regular_gaussian_surface.grib2
|
||||
|
||||
|
||||
# Set without -s. Expected to fail
|
||||
# ----------------------------------------------------
|
||||
set +e
|
||||
${tools_dir}/grib_set -p levtype $infile $outfile > $temp 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "provide some keys to set" $temp
|
||||
|
||||
# Set with empty -s. Expected to fail
|
||||
# ----------------------------------------------------
|
||||
set +e
|
||||
${tools_dir}/grib_set -s '' $infile $outfile > $temp 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "provide some keys to set" $temp
|
||||
|
||||
# Out-of-bounds value. Expected to fail
|
||||
# ----------------------------------------------------
|
||||
input=${data_dir}/reduced_gaussian_sub_area.grib2
|
||||
set +e
|
||||
${tools_dir}/grib_set -s perturbationNumber=1000 $input $outfile 2>$temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "Trying to encode value of 1000 but the maximum allowable value is 255 (number of bits=8)" $temp
|
||||
|
||||
# Negative value for an unsigned key. Expected to fail
|
||||
# ----------------------------------------------------
|
||||
input=${data_dir}/reduced_gaussian_sub_area.grib2
|
||||
set +e
|
||||
${tools_dir}/grib_set -s perturbationNumber=-1 $input $outfile 2>$temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "Trying to encode a negative value of -1 for key of type unsigned" $temp
|
||||
|
||||
# Bad value for -d
|
||||
# ----------------
|
||||
input=${data_dir}/reduced_gaussian_sub_area.grib2
|
||||
set +e
|
||||
${tools_dir}/grib_set -d hello $input $outfile 2>$temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "Invalid number" $temp
|
||||
|
||||
|
||||
# ECC-1605: Out-of-bounds value for signed keys
|
||||
# ----------------------------------------------------
|
||||
if [ $ECCODES_ON_WINDOWS -eq 0 ]; then
|
||||
input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
||||
set +e
|
||||
${tools_dir}/grib_set -s forecastTime=2147483648 $input $outfile 2>$temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "Trying to encode value of 2147483648 but the allowable range is -2147483647 to 2147483647" $temp
|
||||
|
||||
set +e
|
||||
${tools_dir}/grib_set -s forecastTime=-2147483650 $input $outfile 2>$temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
fi
|
||||
|
||||
|
||||
# ECC-539: avoid output being the same as input
|
||||
# -----------------------------------------------
|
||||
set +e
|
||||
${tools_dir}/grib_set -s centre=0 $outfile $outfile
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
|
||||
# ECC-1359: string that can be converted to an integer
|
||||
# ---------------------------------------------------
|
||||
${tools_dir}/grib_set -s month:s=6 $ECCODES_SAMPLES_PATH/GRIB2.tmpl $outfile
|
||||
grib_check_key_equals $outfile month 6
|
||||
# Now try an illegal value: a string that cannot be converted to an integer
|
||||
set +e
|
||||
${tools_dir}/grib_set -s month=BAD $ECCODES_SAMPLES_PATH/GRIB2.tmpl $outfile 2> $temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "String cannot be converted to an integer" $temp
|
||||
|
||||
|
||||
# ECC-1363: Does not fail for invalid value for key of type 'double'
|
||||
# ------------------------------------------------------------------
|
||||
${tools_dir}/grib_set -s angleOfRotation:s=10.66 $ECCODES_SAMPLES_PATH/rotated_ll_sfc_grib2.tmpl $outfile
|
||||
grib_check_key_equals $outfile angleOfRotation 10.66
|
||||
# Now try an illegal value: a string that cannot be converted to an integer
|
||||
set +e
|
||||
${tools_dir}/grib_set -s angleOfRotation=BAD $ECCODES_SAMPLES_PATH/rotated_ll_sfc_grib2.tmpl $outfile 2>$temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "String cannot be converted to a double" $temp
|
||||
|
||||
|
||||
# Set ascii key via double or long
|
||||
# --------------------------------
|
||||
${tools_dir}/grib_set -s setLocalDefinition=1,localDefinitionNumber=21 $ECCODES_SAMPLES_PATH/GRIB2.tmpl $outfile
|
||||
${tools_dir}/grib_set -s marsDomain=x $outfile $temp
|
||||
grib_check_key_equals $temp 'marsDomain' 'x'
|
||||
set +e
|
||||
${tools_dir}/grib_set -s marsDomain=9 $outfile $temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
|
||||
set +e
|
||||
${tools_dir}/grib_set -s marsDomain=1.2 $outfile $temp
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
|
||||
|
||||
# Codetable mismatch
|
||||
# ------------------------
|
||||
input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
||||
set +e
|
||||
${tools_dir}/grib_set -s stepUnits=d $input $outfile > $temp 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "Unit not found" $temp
|
||||
|
||||
set +e
|
||||
${tools_dir}/grib_set -s centre=ECMF $input $outfile > $temp 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "centre: No such code table entry.*Did you mean.*ecmf" $temp
|
||||
|
||||
|
||||
# ------------------------
|
||||
# Unreadable message
|
||||
# ------------------------
|
||||
echo GRIB > $outfile
|
||||
set +e
|
||||
${tools_dir}/grib_set -s edition=2 $outfile /dev/null > $temp 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "unreadable message" $temp
|
||||
|
||||
|
||||
# Clean up
|
||||
rm -f $outfile $temp
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
#include "eccodes.h"
|
||||
|
||||
#define EPSILON 1e-12
|
||||
#define DBL_EQUAL(a, b) (fabs((a) - (b)) <= (EPSILON)*fabs((a)))
|
||||
|
@ -34,10 +35,10 @@ static void TestDateTime(const long year, const long month, const long day, cons
|
|||
long jdlong1, jdlong2, date;
|
||||
|
||||
/* Convert the input values to a double */
|
||||
grib_datetime_to_julian(year, month, day, hour, min, sec, &jd);
|
||||
codes_datetime_to_julian(year, month, day, hour, min, sec, &jd);
|
||||
|
||||
/* Convert the double back to the input values and compare */
|
||||
grib_julian_to_datetime(jd, &year1, &month1, &day1, &hour1, &min1, &sec1);
|
||||
codes_julian_to_datetime(jd, &year1, &month1, &day1, &hour1, &min1, &sec1);
|
||||
|
||||
if (!Check(year, month, day, hour, min, sec, year1, month1, day1, hour1, min1, sec1)) {
|
||||
fprintf(stderr,
|
||||
|
@ -73,7 +74,7 @@ static void Test0()
|
|||
min = 26;
|
||||
sec = 24;
|
||||
|
||||
grib_datetime_to_julian(year, month, day, hour, min, sec, &jd);
|
||||
codes_datetime_to_julian(year, month, day, hour, min, sec, &jd);
|
||||
Assert(DBL_EQUAL(jd, 2378891.268333));
|
||||
printf("%ld %ld %ld %ld:%ld:%ld -> %f\n", year, month, day, hour, min, sec, jd);
|
||||
|
||||
|
@ -153,9 +154,9 @@ static void Test2()
|
|||
}
|
||||
|
||||
jdl = (long)(jd + 0.5);
|
||||
date = grib_julian_to_date(jdl);
|
||||
date = codes_julian_to_date(jdl);
|
||||
printf("+ %ld -> %ld\n", date, jdl);
|
||||
jdl = grib_date_to_julian(date);
|
||||
jdl = codes_date_to_julian(date);
|
||||
printf("- %ld -> %ld\n", date, jdl);
|
||||
printf("\n");
|
||||
}
|
||||
|
|
|
@ -45,6 +45,23 @@ if [ $status -eq 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Compare using a namespace
|
||||
set +e
|
||||
${tools_dir}/metar_compare -c ls:n $metar_file $fMetarTmp > $fLog 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "DIFFERENCE == string.*dateTime" $fLog
|
||||
|
||||
set +e
|
||||
${tools_dir}/metar_compare -a -c ls:n $metar_file $fMetarTmp > $fLog 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "DIFFERENCE == string.*dateTime" $fLog
|
||||
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
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
#include "eccodes.h"
|
||||
|
||||
#define NUMBER(x) (sizeof(x) / sizeof(x[0]))
|
||||
|
||||
|
@ -91,7 +92,7 @@ static void test_gaussian_latitudes(int order)
|
|||
double lat1 = 0, lat2 = 0;
|
||||
double* lats = (double*)malloc(sizeof(double) * num);
|
||||
|
||||
ret = grib_get_gaussian_latitudes(order, lats);
|
||||
ret = codes_get_gaussian_latitudes(order, lats);
|
||||
Assert(ret == GRIB_SUCCESS);
|
||||
|
||||
lat1 = lats[0];
|
||||
|
@ -112,7 +113,7 @@ static void test_gaussian_latitude_640()
|
|||
int ret = 0;
|
||||
const double tolerance = 1e-6;
|
||||
double* lats = (double*)malloc(sizeof(double) * num);
|
||||
ret = grib_get_gaussian_latitudes(order, lats);
|
||||
ret = codes_get_gaussian_latitudes(order, lats);
|
||||
Assert(ret == GRIB_SUCCESS);
|
||||
|
||||
compare_doubles(lats[0], 89.892396, tolerance);
|
||||
|
@ -378,9 +379,34 @@ static void test_gribex_mode()
|
|||
|
||||
Assert( grib_get_gribex_mode(c) == 0 ); /* default is OFF */
|
||||
grib_gribex_mode_on(c);
|
||||
codes_gribex_mode_on(c);
|
||||
Assert( grib_get_gribex_mode(c) == 1 );
|
||||
grib_gribex_mode_off(c);
|
||||
codes_gribex_mode_off(c);
|
||||
Assert( grib_get_gribex_mode(c) == 0 );
|
||||
Assert( codes_get_gribex_mode(c) == 0 );
|
||||
}
|
||||
|
||||
static void test_gts_header_mode()
|
||||
{
|
||||
grib_context* c = grib_context_get_default();
|
||||
printf("Running %s ...\n", __func__);
|
||||
|
||||
grib_gts_header_on(c);
|
||||
codes_gts_header_on(c);
|
||||
Assert(c->gts_header_on == 1);
|
||||
grib_gts_header_off(c);
|
||||
codes_gts_header_off(c);
|
||||
Assert(c->gts_header_on == 0);
|
||||
}
|
||||
|
||||
static void test_bufr_multi_element_constant_arrays()
|
||||
{
|
||||
grib_context* c = grib_context_get_default();
|
||||
printf("Running %s ...\n", __func__);
|
||||
|
||||
codes_bufr_multi_element_constant_arrays_on(c);
|
||||
codes_bufr_multi_element_constant_arrays_off(c);
|
||||
}
|
||||
|
||||
static void test_grib_binary_search()
|
||||
|
@ -649,6 +675,8 @@ int main(int argc, char** argv)
|
|||
test_get_git_sha1();
|
||||
test_get_build_date();
|
||||
test_gribex_mode();
|
||||
test_gts_header_mode();
|
||||
test_bufr_multi_element_constant_arrays();
|
||||
|
||||
test_concept_condition_strings();
|
||||
|
||||
|
|
Loading…
Reference in New Issue