summaryrefslogtreecommitdiffstats
path: root/hl
diff options
context:
space:
mode:
Diffstat (limited to 'hl')
-rw-r--r--hl/fortran/test/tsttable.f9021
-rw-r--r--hl/src/H5TB.c6
-rw-r--r--hl/test/test_table.c9
3 files changed, 30 insertions, 6 deletions
diff --git a/hl/fortran/test/tsttable.f90 b/hl/fortran/test/tsttable.f90
index 66ec5c6..bb88abf 100644
--- a/hl/fortran/test/tsttable.f90
+++ b/hl/fortran/test/tsttable.f90
@@ -175,13 +175,30 @@ SUBROUTINE test_table1()
CALL h5tbwrite_field_name_f(file_id,dsetname1,field_names(4),start,nrecords,type_sizer,&
bufr,errcode)
-
!-------------------------------------------------------------------------
! read field
!-------------------------------------------------------------------------
+ ! Read an invalid field, should fail
+ CALL h5tbread_field_name_f(file_id,dsetname1,'DoesNotExist',start,nrecords,type_sizec,&
+ bufsr,errcode)
+
+ IF(errcode.GE.0)THEN
+ PRINT *, 'error in h5tbread_field_name_f'
+ CALL h5fclose_f(file_id, errcode)
+ CALL h5close_f(errcode)
+ STOP
+ ENDIF
+
+ ! Read a valid field, should pass
CALL h5tbread_field_name_f(file_id,dsetname1,field_names(1),start,nrecords,type_sizec,&
bufsr,errcode)
+ IF(errcode.LT.0)THEN
+ PRINT *, 'error in h5tbread_field_name_f'
+ CALL h5fclose_f(file_id, errcode)
+ CALL h5close_f(errcode)
+ STOP
+ ENDIF
!
! compare read and write buffers.
@@ -329,8 +346,6 @@ SUBROUTINE test_table1()
! we insert a field callsed "field5" with the same type and buffer as field 4 (Real)
!-------------------------------------------------------------------------
-
-
CALL test_begin(' Insert field ')
CALL h5tbinsert_field_f(file_id,dsetname1,"field5",field_types(4),4,bufr,errcode)
diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c
index 7856d5f..1ca41a8 100644
--- a/hl/src/H5TB.c
+++ b/hl/src/H5TB.c
@@ -982,7 +982,7 @@ herr_t H5TBread_fields_name(hid_t loc_id,
if((mem_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0)
goto out;
- /* iterate tru the members */
+ /* iterate through the members */
for(i = 0, j = 0; i < nfields; i++) {
/* get the member name */
if(NULL == (member_name = H5Tget_member_name(ftype_id, (unsigned)i)))
@@ -1028,6 +1028,10 @@ herr_t H5TBread_fields_name(hid_t loc_id,
member_name = NULL;
} /* end for */
+ /* check to make sure field was found, no reason to continue if it does not exist */
+ if(j == 0)
+ goto out;
+
/* get the dataspace handle */
if((sid = H5Dget_space(did)) < 0)
goto out;
diff --git a/hl/test/test_table.c b/hl/test/test_table.c
index 488cbe2..c312296 100644
--- a/hl/test/test_table.c
+++ b/hl/test/test_table.c
@@ -1186,14 +1186,19 @@ static int test_table(hid_t fid, int do_write)
goto out;
}
- /* read the "Pressure" field */
start = 0;
nrecords = NRECORDS;
+
+ /* read an invalid field, should fail */
+ if ( H5TBread_fields_name(fid,"table10","DoesNotExist",start,nrecords,
+ sizeof(float),0,field_sizes_pre,pressure_out) >=0)
+ goto out;
+
+ /* read the "Pressure" field */
if ( H5TBread_fields_name(fid,"table10","Pressure",start,nrecords,
sizeof(float),0,field_sizes_pre,pressure_out)<0)
goto out;
-
/* Compare the extracted table with the initial values */
for( i = 0; i < NRECORDS; i++ )
{