Merge branch 'eccodes' of ssh://software.ecmwf.int:7999/GRIB/grib_api into eccodes

This commit is contained in:
Shahram Najm 2015-05-28 09:59:02 +01:00
commit ebcbbdb6d7
7 changed files with 4124 additions and 33 deletions

View File

@ -70,17 +70,9 @@ meta unexpandedDescriptors unexpanded_descriptors(numberOfUnexpandedDescriptors)
meta elementsTable bufr_elements_table("element.table",tablesMasterDir,tablesLocalDir) : hidden;
#transient elementCode="000000";
#elementAbbreviation=dict_search("element.table",elementCode,1,tablesMasterDir,tablesLocalDir) : string_type,hidden ;
#elementType=dict_search("element.table",elementCode,2,tablesMasterDir,tablesLocalDir) : string_type,hidden ;
#elementName=dict_search("element.table",elementCode,3,tablesMasterDir,tablesLocalDir) : string_type,hidden ;
#elementUnit=dict_search("element.table",elementCode,4,tablesMasterDir,tablesLocalDir) : string_type,hidden ;
#elementScale=dict_search("element.table",elementCode,5,tablesMasterDir,tablesLocalDir) : string_type,hidden ;
#elementReference=dict_search("element.table",elementCode,6,tablesMasterDir,tablesLocalDir) : string_type,hidden ;
#elementWidth=dict_search("element.table",elementCode,7,tablesMasterDir,tablesLocalDir) : string_type,hidden ;
meta expandedCodes expanded_descriptors(elementsTable,expandedCodes,0,unexpandedDescriptors,sequences);
#meta expandedScales expanded_descriptors(elemetsTable,expandedCodes,1);
alias expandedDescriptors=expandedCodes;
#meta expandedReferences expanded_descriptors(elemetsTable,expandedCodes,2);
#meta expandedWidths expanded_descriptors(elemetsTable,expandedCodes,3);
#meta expandedType expanded_descriptors(elemetsTable,expandedCodes,4);

View File

@ -24,8 +24,9 @@ integer :: ifile
integer :: iret
integer :: ibufr
integer :: i, count=0
integer(kind=4) :: numObs
integer(kind=4) :: numObs,ii
real(kind=8), dimension(:), allocatable :: latVal,lonVal,bscatterVal
real(kind=8), dimension(:), allocatable :: year
call codes_open_file(ifile,'../../data/bufr/asca_139.bufr','r')
@ -59,6 +60,12 @@ real(kind=8), dimension(:), allocatable :: latVal,lonVal,bscatterVal
!Get longitude (for all the subsets)
call codes_get(ibufr,'latitude',lonVal);
allocate(year(numObs))
call codes_get(ibufr,'year',year);
do ii= 1, size(year)
write(*,*) 'year(',ii,')=',year(ii)
enddo
!Get backScatter for beam two. We use an access by condition for this key.
!(for all the subsets)
call codes_get(ibufr,'/beamIdentifier=2/backscatter',bscatterVal);

File diff suppressed because it is too large Load Diff

View File

@ -832,7 +832,7 @@ end subroutine codes_get_string
subroutine codes_get_int_array ( gribid, key, value, status )
integer(kind=kindOfInt), intent(in) :: gribid
character(len=*), intent(in) :: key
integer(kind=kindOfInt), dimension(:),allocatable,intent(out) :: value
integer(kind=kindOfInt), dimension(:),allocatable,intent(inout) :: value
integer(kind=kindOfInt),optional, intent(out) :: status
integer(kind=kindOfInt) :: iret
integer(kind=kindOfInt) :: nb_values
@ -844,7 +844,7 @@ end subroutine codes_get_int_array
subroutine codes_get_long_array ( gribid, key, value, status )
integer(kind=kindOfInt), intent(in) :: gribid
character(len=*), intent(in) :: key
integer(kind=kindOfLong), dimension(:),allocatable,intent(out) :: value
integer(kind=kindOfLong), dimension(:),allocatable,intent(inout) :: value
integer(kind=kindOfInt),optional, intent(out) :: status
integer(kind=kindOfInt) :: iret
integer(kind=kindOfInt) :: nb_values
@ -856,7 +856,7 @@ end subroutine codes_get_long_array
subroutine codes_get_byte_array ( gribid, key, value, length, status )
integer(kind=kindOfInt), intent(in) :: gribid
character(len=*), intent(in) :: key
character(len=1), dimension(:), intent(out) :: value
character(len=1), dimension(:), intent(inout) :: value
integer(kind=kindOfInt), optional, intent(out) :: length
integer(kind=kindOfInt), optional, intent(out) :: status
integer(kind=kindOfInt) :: iret
@ -870,7 +870,7 @@ end subroutine codes_get_byte_array
subroutine codes_get_real4_array ( gribid, key, value, status)
integer(kind=kindOfInt), intent(in) :: gribid
character(len=*), intent(in) :: key
real(kind = kindOfFloat), dimension(:),allocatable, intent(out) :: value
real(kind = kindOfFloat), dimension(:),allocatable, intent(inout) :: value
integer(kind=kindOfInt),optional, intent(out) :: status
integer(kind=kindOfInt) :: iret
integer(kind=kindOfInt) :: nb_values
@ -882,7 +882,7 @@ end subroutine codes_get_real4_array
subroutine codes_get_real8_array ( gribid, key, value, status )
integer(kind=kindOfInt), intent(in) :: gribid
character(len=*), intent(in) :: key
real(kind = kindOfDouble), dimension(:),allocatable, intent(out) :: value
real(kind = kindOfDouble), dimension(:),allocatable, intent(inout) :: value
integer(kind=kindOfInt),optional, intent(out) :: status
integer(kind=kindOfInt) :: iret
integer(kind=kindOfInt) :: nb_values

View File

@ -2232,7 +2232,7 @@
subroutine grib_get_real8_array ( gribid, key, value, status )
integer(kind=kindOfInt), intent(in) :: gribid
character(len=*), intent(in) :: key
real(kind = kindOfDouble),dimension(:),allocatable,intent(out) :: value
real(kind = kindOfDouble),dimension(:),allocatable,intent(inout) :: value
integer(kind=kindOfInt),optional, intent(out) :: status
integer(kind=kindOfInt) :: iret
integer(kind=kindOfInt) :: nb_values
@ -2249,7 +2249,9 @@
endif
return
endif
if (.not.allocated(value)) allocate(value(nb_values))
if (allocated(value) .eqv. .false.) then
allocate(value(nb_values))
end if
size_value=size(value)
iret=grib_f_get_real8_array ( gribid, key, value, nb_values )
if (iret==0 .and. nb_values==1 .and. size_value/=1) then

View File

@ -209,21 +209,28 @@ static int unpack_long (grib_accessor* a, long* val, size_t *len)
static int pack_long (grib_accessor* a, const long* val, size_t *len)
{
int ret=0,i;
long pos = a->offset*8;
unsigned long f,x,y;
int ret=0,i;
long pos = 0;
unsigned long f,x,y;
unsigned char* buf = NULL;
size_t buflen=*len*2;
for (i=0;i<*len;i++) {
f=val[i]/100000;
x=(val[i]%100000)/1000;
y=(val[i]%100000)%1000;
printf("f=%ld x=%ld y=%ld new=%ld\n",f,x,y,*val);
grib_encode_unsigned_longb(a->parent->h->buffer->data,f,&pos,2);
grib_encode_unsigned_longb(a->parent->h->buffer->data,x,&pos,6);
grib_encode_unsigned_longb(a->parent->h->buffer->data,y,&pos,8);
}
buf=grib_context_malloc_clear(a->parent->h->context,buflen);
return ret;
for (i=0;i<*len;i++) {
f=val[i]/100000;
x=(val[i]%100000)/1000;
y=(val[i]%100000)%1000;
grib_encode_unsigned_longb(buf,f,&pos,2);
grib_encode_unsigned_longb(buf,x,&pos,6);
grib_encode_unsigned_longb(buf,y,&pos,8);
}
grib_buffer_replace(a,buf,buflen,1,1);
/* update_size(a,buflen); */
return ret;
}

View File

@ -646,6 +646,49 @@ diff ${f}.ref ${f}.log
rm -f ${f}.ref ${f}.log
#-----------------------------------------------------------
# Test: set unexpandedDescriptors
#-----------------------------------------------------------
cat > $fRules <<EOF
print "== unexpandedDescriptors ==";
print "[unexpandedDescriptors!16]";
print "== setting unexpandedDescriptors ==";
print "309007 104000 31001 7004 8001 11061 11062 222000 101000 31002 31031 1031 1032 101000 31002 33007";
set unexpandedDescriptors={309007, 104000, 31001, 7004, 8001, 11061, 11062, 222000, 101000, 31002, 31031, 1031, 1032, 101000, 31002, 33007 };
write "mytemp.bufr";
print "== unexpandedDescriptors ==";
print "[unexpandedDescriptors!16]";
print "== expandedDescriptors ==";
print "[expandedDescriptors]";
EOF
f="syno_1.bufr"
echo "Test: set unexpandedDescriptors" >> $fLog
echo "file: $f" >> $fLog
${tools_dir}/bufr_filter $fRules $f 2>> $fLog 1>> $fLog
${tools_dir}/bufr_filter $fRules $f 2> ${f}.log 1> ${f}.log
cat > ${f}.ref <<EOF
== unexpandedDescriptors ==
307005 13023 13013 222000 101049 31031 1031 1032 101049 33007
== setting unexpandedDescriptors ==
309007 104000 31001 7004 8001 11061 11062 222000 101000 31002 31031 1031 1032 101000 31002 33007
== unexpandedDescriptors ==
309007 104000 31001 7004 8001 11061 11062 222000 101000 31002 31031 1031 1032 101000 31002 33007
== expandedDescriptors ==
1001 1002 2011 2012 4001 4002 4003 4004
4005 5001 6001 7001 20010 8002 20011 20013
20012 20012 20012 107000 31001 7004 8001 10003
12001 12003 11001 11002 104000 31001 7004 8001
11061 11062 222000 101000 31002 31031 1031 1032
101000 31002 33007
EOF
diff ${f}.ref ${f}.log
rm -f ${f}.ref ${f}.log
#-----------------------------------------------------------
# Test: get string
#-----------------------------------------------------------