mirror of https://github.com/ecmwf/eccodes.git
ECC-117: Eliminate function codes_is_defined (Part 1)
This commit is contained in:
parent
22e641ba08
commit
5b36903347
|
@ -26,7 +26,7 @@ program grib_get_keys
|
|||
real, dimension(:), allocatable :: values
|
||||
integer :: numberOfValues
|
||||
real :: average,min_val, max_val
|
||||
integer :: is_missing, is_defined
|
||||
integer :: is_missing
|
||||
|
||||
call codes_open_file(ifile, &
|
||||
'../../data/reduced_latlon_surface.grib1','r')
|
||||
|
@ -51,19 +51,6 @@ program grib_get_keys
|
|||
write(*,*) 'numberOfPointsAlongAParallel is missing'
|
||||
endif
|
||||
|
||||
!check for existence of keys
|
||||
is_defined=0;
|
||||
call codes_is_defined(igrib,'edition',is_defined);
|
||||
if ( is_defined == 0 ) then
|
||||
write(0,*) 'ERROR: An expected key was not defined!!'
|
||||
call exit(1)
|
||||
endif
|
||||
call codes_is_defined(igrib,'ThisIsNoLoveSong',is_defined);
|
||||
if ( is_defined == 1 ) then
|
||||
write(0,*) 'ERROR: An unexpected key was defined!!'
|
||||
call exit(1)
|
||||
endif
|
||||
|
||||
! get as a integer
|
||||
call codes_get(igrib,'Nj',numberOfPointsAlongAMeridian)
|
||||
write(*,*) 'numberOfPointsAlongAMeridian=', &
|
||||
|
@ -93,7 +80,6 @@ program grib_get_keys
|
|||
write(*,*) 'longitudeOfLastGridPointInDegrees=', &
|
||||
longitudeOfLastPointInDegrees
|
||||
|
||||
|
||||
! get the size of the values array
|
||||
call codes_get_size(igrib,'values',numberOfValues)
|
||||
write(*,*) 'numberOfValues=',numberOfValues
|
||||
|
|
|
@ -36,8 +36,6 @@ def example():
|
|||
except CodesInternalError,err:
|
||||
print 'Error with key="%s" : %s' % (key,err.msg)
|
||||
|
||||
if codes_is_defined(gid,"A_very_silly_key"): raise Exception("Key was defined")
|
||||
|
||||
print 'There are %d values, average is %f, min is %f, max is %f' % (
|
||||
codes_get_size(gid,'values'),
|
||||
codes_get(gid,'average'),
|
||||
|
|
|
@ -67,8 +67,6 @@
|
|||
external grib_get_string
|
||||
integer grib_is_missing
|
||||
external grib_is_missing
|
||||
integer grib_is_defined
|
||||
external grib_is_defined
|
||||
integer grib_set_string
|
||||
external grib_copy_namespace
|
||||
integer grib_copy_namespace
|
||||
|
|
|
@ -137,11 +137,6 @@ def test():
|
|||
print "Set Ni back to its original value --> ",new_Ni
|
||||
assert Ni == new_Ni
|
||||
|
||||
print "Check some keys to see if they are defined"
|
||||
assert grib_is_defined(gid,"Ni")
|
||||
assert grib_is_defined(gid,"edition")
|
||||
assert not grib_is_defined(gid,"DarkThrone")
|
||||
|
||||
#grib_multi_write(gid,multi)
|
||||
|
||||
|
||||
|
|
|
@ -178,17 +178,14 @@ grib_handle* grib_new_handle ( grib_context* c )
|
|||
static void check_definitions_version(grib_handle* h)
|
||||
{
|
||||
/* Check version of definition files is compatible with the engine */
|
||||
int ret = 0;
|
||||
long defs_file_version = 0;
|
||||
if (grib_is_defined(h, "internalVersion")) {
|
||||
ret = grib_get_long_internal(h, "internalVersion", &defs_file_version);
|
||||
int ret = grib_get_long(h, "internalVersion", &defs_file_version);
|
||||
|
||||
if (ret == GRIB_SUCCESS && (defs_file_version > LATEST_VERSION)) {
|
||||
grib_context_log(h->context, GRIB_LOG_FATAL,
|
||||
"Definition files version (%d) is greater than engine version (%d)!\n"
|
||||
"These definition files are for a later version of the grib api engine.\n",
|
||||
defs_file_version, LATEST_VERSION);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue