summaryrefslogtreecommitdiffstats
path: root/hl/fortran/src/H5TBfc.c
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2016-04-06 18:07:17 (GMT)
committerScot Breitenfeld <brtnfld@hdfgroup.org>2016-04-06 18:07:17 (GMT)
commit01f479abb49d378b44648e1c0f353839b18b548c (patch)
treed13cb521e6120708eb788c6e47bb9c95a2cab2ce /hl/fortran/src/H5TBfc.c
parent54d598aa44c2bbdc8d575faaec80a1348e19ce88 (diff)
downloadhdf5-01f479abb49d378b44648e1c0f353839b18b548c.zip
hdf5-01f479abb49d378b44648e1c0f353839b18b548c.tar.gz
hdf5-01f479abb49d378b44648e1c0f353839b18b548c.tar.bz2
[svn-r29648] FIX: HDFFV-8486
h5tbmake_table_f is missing the fill_data parameter (which is in the C counterpart) ADDED NEW API: h5tbread_table_f Tested: platypus, ostrich
Diffstat (limited to 'hl/fortran/src/H5TBfc.c')
-rw-r--r--hl/fortran/src/H5TBfc.c276
1 files changed, 197 insertions, 79 deletions
diff --git a/hl/fortran/src/H5TBfc.c b/hl/fortran/src/H5TBfc.c
index 99a7800..2bb7c3b 100644
--- a/hl/fortran/src/H5TBfc.c
+++ b/hl/fortran/src/H5TBfc.c
@@ -37,21 +37,12 @@
*-------------------------------------------------------------------------
*/
int_f
-h5tbmake_table_c(size_t_f *namelen1,
- _fcd name1,
- hid_t_f *loc_id,
- size_t_f *namelen,
- _fcd name,
- hsize_t_f *nfields,
- hsize_t_f *nrecords,
- size_t_f *type_size,
- size_t_f *field_offset,
- hid_t_f *field_types,
- hsize_t_f *chunk_size,
- int_f *compress,
- size_t_f *char_len_field_names, /* field_names lenghts */
- size_t_f *max_char_size_field_names, /* char len of fields */
- char *field_names) /* field_names */
+h5tbmake_table_c(size_t_f *namelen1, _fcd name1, hid_t_f *loc_id, size_t_f *namelen, _fcd name,
+ hsize_t_f *nfields, hsize_t_f *nrecords, size_t_f *type_size, size_t_f *field_offset,
+ hid_t_f *field_types, hsize_t_f *chunk_size, int_f *compress,
+ size_t_f *char_len_field_names, /* field_names lenghts */
+ size_t_f *max_char_size_field_names, /* char len of fields */
+ char *field_names) /* field_names */
{
char *c_name = NULL;
char *c_name1 = NULL;
@@ -101,7 +92,6 @@ h5tbmake_table_c(size_t_f *namelen1,
HGOTO_DONE(FAIL)
HDmemcpy(c_field_names[i], tmp_p, (size_t)char_len_field_names[i]);
c_field_names[i][char_len_field_names[i]] = '\0';
-
tmp_p = tmp_p + *max_char_size_field_names;
} /* end for */
@@ -136,6 +126,177 @@ done:
} /* end h5tbmake_table_c() */
/*-------------------------------------------------------------------------
+* Function: h5tbmake_table_ptr_c
+*
+* Purpose: Call H5TBmake_table using F2003 features
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: M. Scot Breitenfeld
+*
+* Date: Sept. 10, 2015
+*
+* Comments:
+*
+*-------------------------------------------------------------------------
+*/
+int_f
+h5tbmake_table_ptr_c(size_t_f *namelen1, _fcd name1, hid_t_f *loc_id, size_t_f *namelen,
+ _fcd name, hsize_t_f *nfields, hsize_t_f *nrecords, size_t_f *type_size,
+ size_t_f *field_offset, hid_t_f *field_types, hsize_t_f *chunk_size,
+ void *fill_data, int_f *compress,
+ size_t_f *char_len_field_names, /* field_names lenghts */
+ size_t_f *max_char_size_field_names, /* char len of fields */
+ char *field_names,
+ void *data) /* field_names */
+{
+ char *c_name = NULL;
+ char *c_name1 = NULL;
+ hsize_t num_elem;
+ hsize_t i;
+ hsize_t c_nfields = (hsize_t)*nfields;
+ size_t *c_field_offset = NULL;
+ hid_t *c_field_types = NULL;
+ char **c_field_names = NULL;
+ char *tmp = NULL, *tmp_p;
+ int_f ret_value = 0;
+
+ num_elem = (hsize_t)*nfields;
+
+ /*
+ * convert FORTRAN name to C name
+ */
+ if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
+ HGOTO_DONE(FAIL)
+ if(NULL == (c_name1 = (char *)HD5f2cstring(name1, (size_t)*namelen1)))
+ HGOTO_DONE(FAIL)
+ if(NULL == (c_field_offset = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields)))
+ HGOTO_DONE(FAIL)
+ if(NULL == (c_field_types = (hid_t *)HDmalloc(sizeof(hid_t) * (size_t)c_nfields)))
+ HGOTO_DONE(FAIL)
+
+ for(i = 0; i < num_elem; i++) {
+ c_field_offset[i] = (size_t)field_offset[i];
+ c_field_types[i] = field_types[i];
+ } /* end for */
+
+ /*
+ * allocate array of character pointers
+ */
+ if(NULL == (c_field_names = (char **)HDcalloc((size_t)num_elem, sizeof(char *))))
+ HGOTO_DONE(FAIL)
+
+ /* copy data to long C string */
+ if(NULL == (tmp = (char *)HD5f2cstring(field_names, (size_t)*(max_char_size_field_names)*(size_t)num_elem)))
+ HGOTO_DONE(FAIL)
+ /*
+ * move data from temorary buffer
+ */
+ tmp_p = tmp;
+ for(i = 0; i < num_elem; i++) {
+ if(NULL == (c_field_names[i] = (char *)HDmalloc((size_t)char_len_field_names[i] + 1)))
+ HGOTO_DONE(FAIL)
+ HDmemcpy(c_field_names[i], tmp_p, (size_t)char_len_field_names[i]);
+ c_field_names[i][char_len_field_names[i]] = '\0';
+ tmp_p = tmp_p + *max_char_size_field_names;
+ } /* end for */
+
+ /*
+ * call H5TBmake_table function.
+ */
+ if(H5TBmake_table(c_name1, (hid_t)*loc_id, c_name, c_nfields, (hsize_t)*nrecords,
+ (size_t)*type_size, (const char **)c_field_names, c_field_offset, c_field_types,
+ (hsize_t)*chunk_size, fill_data, *compress, data) < 0)
+ HGOTO_DONE(FAIL)
+
+done:
+ if(c_name)
+ HDfree(c_name);
+ if(c_name1)
+ HDfree(c_name1);
+ if(c_field_names) {
+ for(i = 0; i < num_elem; i++) {
+ if(c_field_names[i])
+ HDfree(c_field_names[i]);
+ } /* end for */
+ HDfree(c_field_names);
+ } /* end if */
+ if(tmp)
+ HDfree(tmp);
+ if(c_field_offset)
+ HDfree(c_field_offset);
+ if(c_field_types)
+ HDfree(c_field_types);
+
+ return ret_value;
+} /* end h5tbmake_table_c() */
+
+
+/*-------------------------------------------------------------------------
+* Function: h5tbread_table_c
+*
+* Purpose: Call H5TBread_table using F2003 features
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: M. Scot Breitenfeld
+*
+* Date: Sept. 14, 2015
+*
+* Comments:
+*
+*-------------------------------------------------------------------------
+*/
+int_f
+h5tbread_table_c(hid_t_f *loc_id, _fcd name, size_t_f *namelen, hsize_t_f *nfields,
+ size_t_f *dst_size, size_t_f *dst_offset, size_t_f *dst_sizes, void *dst_buf)
+{
+ char *c_name = NULL;
+ size_t *c_dst_offset = NULL;
+ size_t *c_dst_sizes = NULL;
+ hsize_t c_nfields = (hsize_t)*nfields;
+ int_f ret_value = 0;
+ hsize_t i;
+
+ /*
+ * convert FORTRAN name to C name
+ */
+ if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
+ HGOTO_DONE(FAIL)
+
+ if(NULL == (c_dst_offset = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields)))
+ HGOTO_DONE(FAIL)
+ if(NULL == (c_dst_sizes = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields)))
+ HGOTO_DONE(FAIL)
+
+ for(i = 0; i < c_nfields; i++) {
+ c_dst_offset[i] = (size_t)dst_offset[i];
+ c_dst_sizes[i] = (size_t)dst_sizes[i];
+ } /* end for */
+
+ /*
+ * call H5TBread_table function.
+ */
+ if(H5TBread_table( (hid_t)*loc_id, c_name, (size_t)*dst_size, c_dst_offset,
+ c_dst_sizes, dst_buf) < 0)
+ HGOTO_DONE(FAIL)
+
+done:
+ if(c_name)
+ HDfree(c_name);
+
+ if(c_dst_offset)
+ HDfree(c_dst_offset);
+ if(c_dst_sizes)
+ HDfree(c_dst_sizes);
+
+ return ret_value;
+} /* end h5tbmake_table_c() */
+
+
+
+
+/*-------------------------------------------------------------------------
* Function: h5tbwrite_field_name_c
*
* Purpose: Call H5TBwrite_fields_name
@@ -151,15 +312,8 @@ done:
*-------------------------------------------------------------------------
*/
int_f
-h5tbwrite_field_name_c(hid_t_f *loc_id,
- size_t_f *namelen,
- _fcd name,
- size_t_f *namelen1,
- _fcd field_name,
- hsize_t_f *start,
- hsize_t_f *nrecords,
- size_t_f *type_size,
- void *buf)
+h5tbwrite_field_name_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *namelen1, _fcd field_name,
+ hsize_t_f *start, hsize_t_f *nrecords, size_t_f *type_size, void *buf)
{
char *c_name = NULL;
char *c_name1 = NULL;
@@ -207,15 +361,8 @@ done:
*-------------------------------------------------------------------------
*/
int_f
-h5tbread_field_name_c(hid_t_f *loc_id,
- size_t_f *namelen,
- _fcd name,
- size_t_f *namelen1,
- _fcd field_name,
- hsize_t_f *start,
- hsize_t_f *nrecords,
- size_t_f *type_size,
- void *buf)
+h5tbread_field_name_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *namelen1, _fcd field_name,
+ hsize_t_f *start, hsize_t_f *nrecords, size_t_f *type_size, void *buf)
{
char *c_name = NULL;
char *c_name1 = NULL;
@@ -262,14 +409,8 @@ done:
*-------------------------------------------------------------------------
*/
int_f
-h5tbwrite_field_index_c(hid_t_f *loc_id,
- size_t_f *namelen,
- _fcd name,
- int_f *field_index,
- hsize_t_f *start,
- hsize_t_f *nrecords,
- size_t_f *type_size,
- void *buf)
+h5tbwrite_field_index_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *field_index, hsize_t_f *start,
+ hsize_t_f *nrecords, size_t_f *type_size, void *buf)
{
char *c_name = NULL;
size_t c_type_size = *type_size;
@@ -313,14 +454,8 @@ done:
*-------------------------------------------------------------------------
*/
int_f
-h5tbread_field_index_c(hid_t_f *loc_id,
- size_t_f *namelen,
- _fcd name,
- int_f *field_index,
- hsize_t_f *start,
- hsize_t_f *nrecords,
- size_t_f *type_size,
- void *buf)
+h5tbread_field_index_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *field_index, hsize_t_f *start,
+ hsize_t_f *nrecords, size_t_f *type_size, void *buf)
{
char *c_name = NULL;
size_t c_type_size = *type_size;
@@ -363,14 +498,8 @@ done:
*-------------------------------------------------------------------------
*/
int_f
-h5tbinsert_field_c(hid_t_f *loc_id,
- size_t_f *namelen,
- _fcd name,
- size_t_f *namelen1,
- _fcd field_name,
- hid_t_f *field_type,
- int_f *position,
- void *buf)
+h5tbinsert_field_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *namelen1,
+ _fcd field_name, hid_t_f *field_type, int_f *position, void *buf)
{
char *c_name = NULL;
char *c_name1 = NULL;
@@ -416,11 +545,8 @@ done:
*-------------------------------------------------------------------------
*/
int_f
-h5tbdelete_field_c(hid_t_f *loc_id,
- size_t_f *namelen,
- _fcd name,
- size_t_f *namelen1,
- _fcd field_name)
+h5tbdelete_field_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name,
+ size_t_f *namelen1, _fcd field_name)
{
char *c_name = NULL;
char *c_name1 = NULL;
@@ -465,11 +591,8 @@ done:
*-------------------------------------------------------------------------
*/
int_f
-h5tbget_table_info_c(hid_t_f *loc_id,
- size_t_f *namelen,
- _fcd name,
- hsize_t_f *nfields,
- hsize_t_f *nrecords)
+h5tbget_table_info_c(hid_t_f *loc_id, size_t_f *namelen,
+ _fcd name, hsize_t_f *nfields, hsize_t_f *nrecords)
{
char *c_name = NULL;
hsize_t c_nfields;
@@ -515,17 +638,12 @@ done:
*-------------------------------------------------------------------------
*/
int_f
-h5tbget_field_info_c(hid_t_f *loc_id,
- size_t_f *namelen,
- _fcd name,
- hsize_t_f *nfields,
- size_t_f *field_sizes,
- size_t_f *field_offsets,
- size_t_f *type_size,
- size_t_f *namelen2, /* field_names lenghts */
- size_t_f *lenmax, /* character len max */
- _fcd field_names, /* field_names */
- size_t_f *maxlen_out)
+h5tbget_field_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *nfields,
+ size_t_f *field_sizes, size_t_f *field_offsets, size_t_f *type_size,
+ size_t_f *namelen2, /* field_names lenghts */
+ size_t_f *lenmax, /* character len max */
+ _fcd field_names, /* field_names */
+ size_t_f *maxlen_out)
{
char *c_name = NULL;