diff options
author | Elena Pourmal <epourmal@hdfgroup.org> | 2002-05-31 14:36:35 (GMT) |
---|---|---|
committer | Elena Pourmal <epourmal@hdfgroup.org> | 2002-05-31 14:36:35 (GMT) |
commit | f4d1614943e3cfcb74dfea218f8297e9f595d197 (patch) | |
tree | 79d11790f34aee28c4e085af8a19efd1f59e34f3 /fortran/src | |
parent | 96f0b001a039e1281de8deefb0ad7360f09b0c81 (diff) | |
download | hdf5-f4d1614943e3cfcb74dfea218f8297e9f595d197.zip hdf5-f4d1614943e3cfcb74dfea218f8297e9f595d197.tar.gz hdf5-f4d1614943e3cfcb74dfea218f8297e9f595d197.tar.bz2 |
[svn-r5490] Purpose:
Code cleanup
Description:
While working on the "External test" failure I restructured and
cleaned up some C stub code.
Platforms tested:
dangermouse (Linux 2.4)
Diffstat (limited to 'fortran/src')
-rw-r--r-- | fortran/src/H5Af.c | 147 | ||||
-rw-r--r-- | fortran/src/H5Df.c | 454 | ||||
-rw-r--r-- | fortran/src/H5Ef.c | 12 | ||||
-rw-r--r-- | fortran/src/H5Gf.c | 153 | ||||
-rw-r--r-- | fortran/src/H5Pf.c | 197 |
5 files changed, 739 insertions, 224 deletions
diff --git a/fortran/src/H5Af.c b/fortran/src/H5Af.c index 5b58244..5d35e0e 100644 --- a/fortran/src/H5Af.c +++ b/fortran/src/H5Af.c @@ -50,10 +50,12 @@ nh5acreate_c (hid_t_f *obj_id, _fcd name, int_f *namelen, hid_t_f *type_id, hid_ c_attr_id = H5Acreate(c_obj_id, c_name, c_type_id, c_space_id, c_crt_prp); - if (c_attr_id < 0) return ret_value; + if (c_attr_id < 0) goto DONE; *attr_id = (hid_t_f)c_attr_id; - HDfree(c_name); ret_value = 0; + +DONE: + HDfree(c_name); return ret_value; } @@ -90,10 +92,12 @@ nh5aopen_name_c (hid_t_f *obj_id, _fcd name, int_f *namelen, hid_t_f *attr_id) c_obj_id = *obj_id; c_attr_id = H5Aopen_name(c_obj_id, c_name); - if (c_attr_id < 0) return ret_value; + if (c_attr_id < 0) goto DONE; *attr_id = (hid_t_f)c_attr_id; - HDfree(c_name); ret_value = 0; + +DONE: + HDfree(c_name); return ret_value; } @@ -158,6 +162,68 @@ nh5awrite_c (hid_t_f *attr_id, hid_t_f *mem_type_id, void *buf, int_f *dims) return ret_value; } +/*---------------------------------------------------------------------------- + * Name: h5awritec_c_b + * Purpose: Call h5awrite_c_b to write a character attribute + * Inputs: attr_id - dataset identifier + * mem_type_id - memory datatype identifier + * buf - character data buffer + * dims - array to store dimensions sizes of buf; used only + * by Fortran routine. + * Returns: 0 on success, -1 on failure + * Programmer: Elena Pourmal + * Tuesday, May 14, 2002 + * Modifications: This function was added to accomodate h5awrite_f call with + * dims buffer being of INTEGER(HSIZE_T) type + *---------------------------------------------------------------------------*/ +int_f +nh5awritec_c_b (hid_t_f *attr_id, hid_t_f *mem_type_id, _fcd buf, hsize_t_f *dims) +{ + int ret_value = -1; + + /* + * Call h5awrite_c function. + */ + ret_value = nh5awrite_c_b(attr_id, mem_type_id, _fcdtocp(buf), dims); + + return ret_value; +} + +/*---------------------------------------------------------------------------- + * Name: h5awrite_c_b + * Purpose: Call H5Awrite to write a attribute + * Inputs: attr_id - attribute identifier + * mem_type_id - memory datatype identifier + * buf - data buffer + * dims - array to store dimensions sizes of buf; used only + * by Fortran routine. + * Returns: 0 on success, -1 on failure + * Programmer: Elena Pourmal + * Tuesday, May 14, 2002 + * Modifications: This function was added to accomodate h5awrite_f call with + * dims buffer being of INTEGER(HSIZE_T) type + *---------------------------------------------------------------------------*/ +int_f +nh5awrite_c_b (hid_t_f *attr_id, hid_t_f *mem_type_id, void *buf, hsize_t_f *dims) +{ + int ret_value = -1; + herr_t ret; + hid_t c_attr_id; + hid_t c_mem_type_id; + + /* + * Call H5Awrite function. + */ + c_attr_id = *attr_id; + c_mem_type_id = *mem_type_id; + ret = H5Awrite(c_attr_id, c_mem_type_id, buf); + + if (ret < 0) return ret_value; + ret_value = 0; + return ret_value; +} + + /*---------------------------------------------------------------------------- * Name: h5areadc_c @@ -219,6 +285,67 @@ nh5aread_c (hid_t_f *attr_id, hid_t_f *mem_type_id, void *buf, int_f *dims) ret_value = 0; return ret_value; } +/*---------------------------------------------------------------------------- + * Name: h5areadc_c_b + * Purpose: Call h5aread_c_b to read character attribute + * Inputs: dset_id - dataset identifier + * mem_type_id - memory datatype identifier + * dims - array to store dimensions sizes of buf; used only + * by Fortran routine. + * Outputs: buf - character data buffer + * Returns: 0 on success, -1 on failure + * Programmer: Elena Pourmal + * Tuesday, May 14, 2002 + * Modifications: This function was added to accomodate h5aread_f call with + * dims buffer being of INTEGER(HSIZE_T) type + *---------------------------------------------------------------------------*/ +int_f +nh5areadc_c_b (hid_t_f *attr_id, hid_t_f *mem_type_id, _fcd buf, hsize_t_f *dims) +{ + int ret_value = -1; + + /* + * Call h5aread_c function. + */ + ret_value = nh5aread_c_b(attr_id, mem_type_id, (_fcdtocp(buf)), dims); + + return ret_value; +} + +/*---------------------------------------------------------------------------- + * Name: h5aread_c_b + * Purpose: Call H5Aread to read an attribute + * Inputs: dset_id - dataset identifier + * mem_type_id - memory datatype identifier + * dims - array to store dimensions sizes of buf; used only + * by Fortran routine. + * Outputs: buf - data buffer + * Returns: 0 on success, -1 on failure + * Programmer: Elena Pourmal + * Tuesday, May 14, 2002 + * Modifications: This function was added to accomodate h5awrite_f call with + * dims buffer being of INTEGER(HSIZE_T) type + *---------------------------------------------------------------------------*/ +int_f +nh5aread_c_b (hid_t_f *attr_id, hid_t_f *mem_type_id, void *buf, hsize_t_f *dims) +{ + int ret_value = -1; + herr_t ret; + hid_t c_attr_id; + hid_t c_mem_type_id; + + /* + * Call H5Aread function. + */ + c_attr_id = *attr_id; + c_mem_type_id = *mem_type_id; + ret = H5Aread(c_attr_id, c_mem_type_id, buf); + + if (ret < 0) return ret_value; + ret_value = 0; + return ret_value; +} + /*---------------------------------------------------------------------------- * Name: h5aclose_c @@ -273,9 +400,11 @@ nh5adelete_c (hid_t_f *obj_id, _fcd name, int_f *namelen) c_obj_id = *obj_id; status = H5Adelete(c_obj_id, c_name); - if (status < 0) return ret_value; - HDfree(c_name); + if (status < 0) goto DONE; ret_value = 0; + +DONE: + HDfree(c_name); return ret_value; } @@ -434,13 +563,15 @@ nh5aget_name_c(hid_t_f *attr_id, size_t_f *bufsize, _fcd buf) */ c_attr_id = *attr_id; c_size = H5Aget_name(c_attr_id, c_bufsize, c_buf); - if (c_size < 0) return ret_value; + if (c_size < 0) goto DONE; /* * Convert C name to FORTRAN and place it in the given buffer */ HD5packFstring(c_buf, _fcdtocp(buf), (int)c_bufsize); - HDfree(c_buf); ret_value = (int_f)c_size; + +DONE: + HDfree(c_buf); return ret_value; } diff --git a/fortran/src/H5Df.c b/fortran/src/H5Df.c index 888ede5..8870565 100644 --- a/fortran/src/H5Df.c +++ b/fortran/src/H5Df.c @@ -31,9 +31,6 @@ nh5dcreate_c (hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *type_id, hid_ * Define creation property */ c_crt_prp = (hid_t)*crt_prp; -/* - if ( H5P_DEFAULT_F == c_crt_prp ) c_crt_prp = H5P_DEFAULT; -*/ /* * Convert FORTRAN name to C name @@ -45,14 +42,16 @@ nh5dcreate_c (hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *type_id, hid_ /* * Call H5Dcreate function. */ - c_loc_id = *loc_id; - c_type_id = *type_id; - c_space_id = *space_id; + c_loc_id = (hid_t)*loc_id; + c_type_id = (hid_t)*type_id; + c_space_id = (hid_t)*space_id; c_dset_id = H5Dcreate(c_loc_id, c_name, c_type_id, c_space_id, c_crt_prp); - if (c_dset_id < 0) return ret_value; + if (c_dset_id < 0) goto DONE; *dset_id = (hid_t_f)c_dset_id; - HDfree(c_name); ret_value = 0; + +DONE: + HDfree(c_name); return ret_value; } @@ -87,13 +86,15 @@ nh5dopen_c (hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *dset_id) /* * Call H5Dopen function. */ - c_loc_id = *loc_id; + c_loc_id = (hid_t)*loc_id; c_dset_id = H5Dopen(c_loc_id, c_name); - if (c_dset_id < 0) return ret_value; + if (c_dset_id < 0) goto DONE; *dset_id = (hid_t_f)c_dset_id; - HDfree(c_name); ret_value = 0; + +DONE: + HDfree(c_name); return ret_value; } @@ -153,23 +154,93 @@ nh5dwrite_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_ * Define transfer property */ c_xfer_prp = (hid_t)*xfer_prp; -/* - if ( H5P_DEFAULT_F == c_xfer_prp ) c_xfer_prp = H5P_DEFAULT; -*/ /* * Call H5Dwrite function. */ - c_dset_id = *dset_id; - c_mem_type_id = *mem_type_id; - c_mem_space_id = *mem_space_id; - c_file_space_id = *file_space_id; + c_dset_id = (hid_t)*dset_id; + c_mem_type_id = (hid_t)*mem_type_id; + c_mem_space_id = (hid_t)*mem_space_id; + c_file_space_id = (hid_t)*file_space_id; ret = H5Dwrite(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf); if (ret < 0) return ret_value; ret_value = 0; return ret_value; } +/*---------------------------------------------------------------------------- + * Name: h5dwritec_c_b + * Purpose: Call h5dwrite_c_b to write a dataset of characters + * Inputs: dset_id - dataset identifier + * mem_type_id - memory datatype identifier + * mem_space_id - memory dataspace identifier + * file_space_id - memory dataspace identifier + * xfer_pr - identifier of transfer property list + * buf - character data buffer + * Returns: 0 on success, -1 on failure + * Programmer: Elena Pourmal + * Tuesday, May 14, 2002 + * Modifications: This function is added to accomodate oveloaded h5dwrite_f + * with the dims argument being of INTEGER(HSIZE_T) type + *---------------------------------------------------------------------------*/ +int_f +nh5dwritec_c_b (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, _fcd buf, hsize_t_f *dims) +{ + int ret_value = -1; + + /* + * Call h5dwrite_c function. + */ + ret_value = nh5dwrite_c_b(dset_id, mem_type_id, mem_space_id, file_space_id, xfer_prp, _fcdtocp(buf), dims); + + return ret_value; +} + +/*---------------------------------------------------------------------------- + * Name: h5dwrite_c_b + * Purpose: Call H5Dwrite to write a dataset + * Inputs: dset_id - dataset identifier + * mem_type_id - memory datatype identifier + * mem_space_id - memory dataspace identifier + * file_space_id - memory dataspace identifier + * xfer_pr - identifier of transfer property list + * buf - data buffer + * Returns: 0 on success, -1 on failure + * Programmer: Elena Pourmal + * Tuesday, May 14, 2002 + * Modifications: This function is added to accomodate oveloaded h5dwrite_f + * with the dims argument being of INTEGER(HSIZE_T) type + *---------------------------------------------------------------------------*/ +int_f +nh5dwrite_c_b (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, void *buf, hsize_t_f *dims) +{ + int ret_value = -1; + herr_t ret; + hid_t c_dset_id; + hid_t c_mem_type_id; + hid_t c_mem_space_id; + hid_t c_file_space_id; + hid_t c_xfer_prp; + + /* + * Define transfer property + */ + c_xfer_prp = (hid_t)*xfer_prp; + + /* + * Call H5Dwrite function. + */ + c_dset_id = (hid_t)*dset_id; + c_mem_type_id = (hid_t)*mem_type_id; + c_mem_space_id = (hid_t)*mem_space_id; + c_file_space_id = (hid_t)*file_space_id; + ret = H5Dwrite(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf); + + if (ret < 0) return ret_value; + ret_value = 0; + return ret_value; +} + /*---------------------------------------------------------------------------- * Name: h5dwrite_ref_obj_c @@ -204,9 +275,6 @@ nh5dwrite_ref_obj_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_ * Define transfer property */ c_xfer_prp = (hid_t)*xfer_prp; -/* - if ( H5P_DEFAULT_F == c_xfer_prp ) c_xfer_prp = H5P_DEFAULT; -*/ /* * Allocate temporary buffer and copy references from Fortran. @@ -233,7 +301,67 @@ nh5dwrite_ref_obj_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_ ret_value = 0; return ret_value; } +/*---------------------------------------------------------------------------- + * Name: h5dwrite_ref_obj_c_b + * Purpose: Call H5Dwrite to write a dataset of object references + * Inputs: dset_id - dataset identifier + * mem_type_id - memory datatype identifier + * mem_space_id - memory dataspace identifier + * file_space_id - memory dataspace identifier + * xfer_pr - identifier of transfer property list + * buf - data buffer with references to the objects. + * n - number of references to be stored. + * Returns: 0 on success,e-1 on failure + * Programmer: Elena Pourmal + * Tuesday, May 14, 2002 + * Modifications: This function was added to accomodate h5dwrite_f with the + * dims argumnet being of INTEGER(HSIZE_T) type. + *---------------------------------------------------------------------------*/ +int_f +nh5dwrite_ref_obj_c_b (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, int_f *buf, hsize_t_f *dims) +{ + int ret_value = -1; + herr_t ret; + hid_t c_dset_id; + hid_t c_mem_type_id; + hid_t c_mem_space_id; + hid_t c_file_space_id; + hid_t c_xfer_prp; + hobj_ref_t *buf_c; + int i, n; + n = (int)*dims; + + /* + * Define transfer property + */ + c_xfer_prp = (hid_t)*xfer_prp; + + /* + * Allocate temporary buffer and copy references from Fortran. + */ + buf_c = (hobj_ref_t*)HDmalloc(sizeof(hobj_ref_t)*(n)); + if ( buf_c != NULL ) { + for (i = 0; i < n; i++) { + HDmemcpy(buf_c[i].oid, buf, H5R_OBJ_REF_BUF_SIZE); + buf = buf + REF_OBJ_BUF_LEN_F; + } + } + else return ret_value; + + /* + * Call H5Dwrite function. + */ + c_dset_id = (hid_t)*dset_id; + c_mem_type_id = (hid_t)*mem_type_id; + c_mem_space_id = (hid_t)*mem_space_id; + c_file_space_id = (hid_t)*file_space_id; + ret = H5Dwrite(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf_c); + HDfree(buf_c); + if (ret < 0) return ret_value; + ret_value = 0; + return ret_value; +} /*---------------------------------------------------------------------------- * Name: h5dwrite_ref_reg_c * Purpose: Call H5Dwrite to write a dataset of dataset region references @@ -267,9 +395,6 @@ nh5dwrite_ref_reg_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_ * Define transfer property */ c_xfer_prp = (hid_t)*xfer_prp; -/* - if ( H5P_DEFAULT_F == c_xfer_prp ) c_xfer_prp = H5P_DEFAULT; -*/ /* * Allocate temporary buffer and copy references from Fortran. @@ -297,6 +422,68 @@ nh5dwrite_ref_reg_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_ ret_value = 0; return ret_value; } +/*---------------------------------------------------------------------------- + * Name: h5dwrite_ref_reg_c_b + * Purpose: Call H5Dwrite to write a dataset of dataset region references + * Inputs: dset_id - dataset identifier + * mem_type_id - memory datatype identifier + * mem_space_id - memory dataspace identifier + * file_space_id - memory dataspace identifier + * xfer_pr - identifier of transfer property list + * buf - data buffer with references to the objects. + * n - number of references to be stored. + * Returns: 0 on success, -1 on failure + * Programmer: Elena Pourmal + * Tuesday, May 14, 2002 + * Modifications: This function was added to accomodate h5dwrite_f with the + * dims argument being of INTEGER(HSIZE_T) type + *---------------------------------------------------------------------------*/ +int_f +nh5dwrite_ref_reg_c_b (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, int_f *buf, hsize_t_f *dims) +{ + int ret_value = -1; + herr_t ret; + hid_t c_dset_id; + hid_t c_mem_type_id; + hid_t c_mem_space_id; + hid_t c_file_space_id; + hid_t c_xfer_prp; + hdset_reg_ref_t *buf_c; + int i, n; + + n = (int)*dims; + /* + * Define transfer property + */ + c_xfer_prp = (hid_t)*xfer_prp; + + /* + * Allocate temporary buffer and copy references from Fortran. + */ + buf_c = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t)*(n)); + if ( buf_c != NULL ) { + for (i = 0; i < n; i++) { + HDmemcpy(buf_c[i].heapid, buf, H5R_DSET_REG_REF_BUF_SIZE); + buf = buf + REF_REG_BUF_LEN_F; + } + } + else return ret_value; + + + /* + * Call H5Dwrite function. + */ + c_dset_id = (hid_t)*dset_id; + c_mem_type_id = (hid_t)*mem_type_id; + c_mem_space_id = (hid_t)*mem_space_id; + c_file_space_id = (hid_t)*file_space_id; + ret = H5Dwrite(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf_c); + HDfree(buf_c); + if (ret < 0) return ret_value; + ret_value = 0; + return ret_value; +} + /*---------------------------------------------------------------------------- @@ -355,23 +542,93 @@ nh5dread_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t * Define transfer property */ c_xfer_prp = (hid_t)*xfer_prp; -/* - if ( H5P_DEFAULT_F == c_xfer_prp ) c_xfer_prp = H5P_DEFAULT; -*/ /* * Call H5Dread function. */ - c_dset_id = *dset_id; - c_mem_type_id = *mem_type_id; - c_mem_space_id = *mem_space_id; - c_file_space_id = *file_space_id; + c_dset_id = (hid_t)*dset_id; + c_mem_type_id = (hid_t)*mem_type_id; + c_mem_space_id = (hid_t)*mem_space_id; + c_file_space_id = (hid_t)*file_space_id; ret = H5Dread(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf); if (ret < 0) return ret_value; ret_value = 0; return ret_value; } +/*---------------------------------------------------------------------------- + * Name: h5dreadc_c_b + * Purpose: Call h5dread_c_b to read a dataset of characters + * Inputs: dset_id - dataset identifier + * mem_type_id - memory datatype identifier + * mem_space_id - memory dataspace identifier + * file_space_id - memory dataspace identifier + * xfer_pr - identifier of transfer property list + * Outputs: buf - character data buffer + * Returns: 0 on success, -1 on failure + * Programmer: Elena Pourmal + * Wednesday, May 15, 2002 + * Modifications: This function was added to accomodate h5dread_f subroutine + * with the dims parameter being of INTEGER(HSIZE_T_F) size. + *---------------------------------------------------------------------------*/ +int_f +nh5dreadc_c_b (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, _fcd buf, hsize_t_f *dims) +{ + int ret_value = -1; + + /* + * Call h5dread_c function. + */ + ret_value = nh5dread_c_b(dset_id, mem_type_id, mem_space_id, file_space_id, xfer_prp, _fcdtocp(buf), dims); + + return ret_value; +} + +/*---------------------------------------------------------------------------- + * Name: h5dread_c + * Purpose: Call H5Draed to read a dataset + * Inputs: dset_id - dataset identifier + * mem_type_id - memory datatype identifier + * mem_space_id - memory dataspace identifier + * file_space_id - memory dataspace identifier + * xfer_pr - identifier of transfer property list + * Outputs: buf - data buffer + * Returns: 0 on success, -1 on failure + * Programmer: Elena Pourmal + * Wednesday, May 15, 2002 + * Modifications: This function was added to accomodate h5dread_f subroutine + * with the dims parameter being of INTEGER(HSIZE_T_F) size. + *---------------------------------------------------------------------------*/ +int_f +nh5dread_c_b (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, void *buf, hsize_t_f *dims) +{ + int ret_value = -1; + herr_t ret; + hid_t c_dset_id; + hid_t c_mem_type_id; + hid_t c_mem_space_id; + hid_t c_file_space_id; + hid_t c_xfer_prp; + + /* + * Define transfer property + */ + c_xfer_prp = (hid_t)*xfer_prp; + + /* + * Call H5Dread function. + */ + c_dset_id = (hid_t)*dset_id; + c_mem_type_id = (hid_t)*mem_type_id; + c_mem_space_id = (hid_t)*mem_space_id; + c_file_space_id = (hid_t)*file_space_id; + ret = H5Dread(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf); + + if (ret < 0) return ret_value; + ret_value = 0; + return ret_value; +} + /*---------------------------------------------------------------------------- * Name: h5dread_ref_obj_c @@ -405,9 +662,6 @@ nh5dread_ref_obj_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_i * Define transfer property */ c_xfer_prp = (hid_t)*xfer_prp; -/* - if ( H5P_DEFAULT_F == c_xfer_prp ) c_xfer_prp = H5P_DEFAULT; -*/ /* * Allocate temporary buffer. @@ -434,6 +688,65 @@ nh5dread_ref_obj_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_i ret_value = 0; return ret_value; } +/*---------------------------------------------------------------------------- + * Name: h5dread_ref_obj_c_b + * Purpose: Call H5Dread to read a dataset of object references + * Inputs: dset_id - dataset identifier + * mem_type_id - memory datatype identifier + * mem_space_id - memory dataspace identifier + * file_space_id - memory dataspace identifier + * xfer_pr - identifier of transfer property list + * buf - data buffer to store references to the objects. + * n - number of references to be stored. + * Returns: 0 on success, -1 on failure + * Programmer: Elena Pourmal + * Wednesday, May 15, 2002 + * Modifications: This function was added to accomodate h5dread_f subroutine + * with the dims parameter being of INTEGER(HSIZE_T_F) size. + *---------------------------------------------------------------------------*/ +int_f +nh5dread_ref_obj_c_b (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, int_f * buf, hsize_t_f *dims) +{ + int ret_value = -1; + herr_t ret; + hid_t c_dset_id; + hid_t c_mem_type_id; + hid_t c_mem_space_id; + hid_t c_file_space_id; + hid_t c_xfer_prp; + hobj_ref_t *buf_c; + hsize_t i,n; + n = (hsize_t)*dims; + /* + * Define transfer property + */ + c_xfer_prp = (hid_t)*xfer_prp; + + /* + * Allocate temporary buffer. + */ + buf_c = (hobj_ref_t*)HDmalloc(sizeof(hobj_ref_t)*(n)); + if ( buf_c != NULL ) { + /* + * Call H5Dread function. + */ + c_dset_id = (hid_t)*dset_id; + c_mem_type_id = (hid_t)*mem_type_id; + c_mem_space_id = (hid_t)*mem_space_id; + c_file_space_id = (hid_t)*file_space_id; + ret = H5Dread(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf_c); + if (ret >=0) { + for (i = 0; i < n; i++) { + HDmemcpy(buf, buf_c[i].oid, H5R_OBJ_REF_BUF_SIZE); + buf = buf + REF_OBJ_BUF_LEN_F; + } + } + if ( buf_c != NULL ) HDfree(buf_c); + } + if (ret < 0) return ret_value; + ret_value = 0; + return ret_value; +} /*---------------------------------------------------------------------------- * Name: h5dread_ref_reg_c @@ -467,9 +780,6 @@ nh5dread_ref_reg_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_i * Define transfer property */ c_xfer_prp = (hid_t)*xfer_prp; -/* - if ( H5P_DEFAULT_F == c_xfer_prp ) c_xfer_prp = H5P_DEFAULT; -*/ /* * Allocate temporary buffer. @@ -496,6 +806,66 @@ nh5dread_ref_reg_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_i ret_value = 0; return ret_value; } +/*---------------------------------------------------------------------------- + * Name: h5dread_ref_reg_c_b + * Purpose: Call H5Dread to read a dataset of dataset region references + * Inputs: dset_id - dataset identifier + * mem_type_id - memory datatype identifier + * mem_space_id - memory dataspace identifier + * file_space_id - memory dataspace identifier + * xfer_pr - identifier of transfer property list + * buf - data buffer to store references to the objects. + * n - number of references to be stored. + * Returns: 0 on success, -1 on failure + * Programmer: Elena Pourmal + * Wednesday, May 15, 2002 + * Modifications: This function was added to accomodate h5dread_f subroutine + * with the dims parameter being of INTEGER(HSIZE_T_F) size. + *---------------------------------------------------------------------------*/ +int_f +nh5dread_ref_reg_c_b (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, int_f * buf, hsize_t_f *dims) +{ + int ret_value = -1; + herr_t ret; + hid_t c_dset_id; + hid_t c_mem_type_id; + hid_t c_mem_space_id; + hid_t c_file_space_id; + hid_t c_xfer_prp; + hdset_reg_ref_t *buf_c; + hsize_t i, n; + n = (hsize_t)*dims; + /* + * Define transfer property + */ + c_xfer_prp = (hid_t)*xfer_prp; + + /* + * Allocate temporary buffer. + */ + buf_c = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t)*(n)); + if ( buf_c != NULL ) { + /* + * Call H5Dread function. + */ + c_dset_id = (hid_t)*dset_id; + c_mem_type_id = (hid_t)*mem_type_id; + c_mem_space_id = (hid_t)*mem_space_id; + c_file_space_id = (hid_t)*file_space_id; + ret = H5Dread(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf_c); + if (ret >=0) { + for (i = 0; i < n; i++) { + HDmemcpy(buf, buf_c[i].heapid, H5R_DSET_REG_REF_BUF_SIZE); + buf = buf + REF_REG_BUF_LEN_F; + } + } + if ( buf_c != NULL ) HDfree(buf_c); + } + if (ret < 0) return ret_value; + ret_value = 0; + return ret_value; +} + /*---------------------------------------------------------------------------- @@ -513,7 +883,7 @@ nh5dclose_c ( hid_t_f *dset_id ) { int ret_value = 0; hid_t c_dset_id; - c_dset_id = *dset_id; + c_dset_id = (hid_t)*dset_id; if ( H5Dclose(c_dset_id) < 0 ) ret_value = -1; return ret_value; } @@ -536,7 +906,7 @@ nh5dget_space_c ( hid_t_f *dset_id , hid_t_f *space_id) hid_t c_dset_id; hid_t c_space_id; - c_dset_id = *dset_id; + c_dset_id = (hid_t)*dset_id; c_space_id = H5Dget_space(c_dset_id); if(c_space_id < 0 ) return ret_value; ret_value = 0; @@ -562,7 +932,7 @@ nh5dget_type_c ( hid_t_f *dset_id , hid_t_f *type_id) hid_t c_dset_id; hid_t c_type_id; - c_dset_id = *dset_id; + c_dset_id = (hid_t)*dset_id; c_type_id = H5Dget_type(c_dset_id); if(c_type_id < 0 ) return ret_value; @@ -591,7 +961,7 @@ nh5dget_create_plist_c ( hid_t_f *dset_id , hid_t_f *plist_id) hid_t c_dset_id; hid_t c_plist_id; - c_dset_id = *dset_id; + c_dset_id = (hid_t)*dset_id; c_plist_id = H5Dget_create_plist(c_dset_id); if(c_plist_id < 0 ) return ret_value; @@ -624,7 +994,7 @@ nh5dextend_c ( hid_t_f *dset_id , hsize_t_f *dims) hid_t c_dset_id; hid_t c_space_id; - c_dset_id = *dset_id; + c_dset_id = (hid_t)*dset_id; c_space_id = H5Dget_space(c_dset_id); if (c_space_id < 0) return ret_value; diff --git a/fortran/src/H5Ef.c b/fortran/src/H5Ef.c index 47fac00..84bf50f 100644 --- a/fortran/src/H5Ef.c +++ b/fortran/src/H5Ef.c @@ -51,17 +51,16 @@ nh5eprint_c1(_fcd name, int_f* namelen) c_name = (char*)HD5f2cstring(name, c_namelen); if(c_name == NULL) return ret_val; file = fopen(c_name, "a"); - if(!file) { HDfree(c_name); - return ret_val; - } + if(!file) goto DONE; /* * Call H5Eprint function. */ status = H5Eprint(file); + if (status >=0 ) ret_val = 0; fclose(file); + +DONE: HDfree(c_name); - if(status < 0) return ret_val; - ret_val = 0; return ret_val; } @@ -87,8 +86,7 @@ nh5eprint_c2() * Call H5Eprint function. */ status = H5Eprint(NULL); - if(status < 0) return ret_val; - ret_val = 0; + if(status >= 0) ret_val = 0; return ret_val; } diff --git a/fortran/src/H5Gf.c b/fortran/src/H5Gf.c index 40a6bfa..e00fd0c 100644 --- a/fortran/src/H5Gf.c +++ b/fortran/src/H5Gf.c @@ -36,13 +36,15 @@ nh5gcreate_c (hid_t_f *loc_id, _fcd name, int_f *namelen, size_t_f *size_hint, if ( *size_hint == OBJECT_NAMELEN_DEFAULT_F ) c_grp_id = H5Gcreate(c_loc_id, c_name, NULL); else { - c_size_hint = *size_hint; + c_size_hint = (size_t)*size_hint; c_grp_id = H5Gcreate(c_loc_id, c_name, c_size_hint); } - if (c_grp_id < 0) return ret_value; + if (c_grp_id < 0) goto DONE; *grp_id = (hid_t_f)c_grp_id; - HDfree(c_name); ret_value = 0; + +DONE: + HDfree(c_name); return ret_value; } @@ -80,10 +82,12 @@ nh5gopen_c (hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *grp_id) c_loc_id = *loc_id; c_grp_id = H5Gopen(c_loc_id, c_name); - HDfree(c_name); - if (c_grp_id < 0) return ret_value; - *grp_id = (hid_t_f)c_grp_id; + if (c_grp_id < 0) goto DONE; ret_value = 0; + *grp_id = (hid_t_f)c_grp_id; + +DONE: + HDfree(c_name); return ret_value; } @@ -127,7 +131,9 @@ nh5gget_obj_info_idx_c * Allocate buffer to hold name of the object */ if (*obj_namelen) c_obj_name = (char *)HDmalloc(*obj_namelen + 1); - if (c_obj_name == NULL) return ret_value; + if (c_obj_name == NULL) { HDfree(c_name); + return ret_value; + } /* * Call H5Gget_obj_info_idx function. */ @@ -135,41 +141,19 @@ nh5gget_obj_info_idx_c c_idx = *idx; c_ret_value = H5Gget_obj_info_idx(c_loc_id, c_name, c_idx, &c_obj_name, (size_t)*obj_namelen, &type); - if (c_ret_value < 0) { - HDfree(c_obj_name); - return ret_value; - } + if (c_ret_value < 0) goto DONE; + *obj_type = type; -/* - switch (type) { - case H5G_LINK: - *obj_type = H5G_LINK_F; - break; - - case H5G_GROUP: - *obj_type = H5G_GROUP_F; - break; - - case H5G_DATASET: - *obj_type = H5G_DATASET_F; - break; - - case H5G_TYPE: - *obj_type = H5G_TYPE_F; - break; - default: - return ret_value; - } -*/ /* * Convert C name to FORTRAN and place it in the given buffer */ c_obj_namelen = *obj_namelen; HD5packFstring(c_obj_name, _fcdtocp(obj_name), c_obj_namelen); - if (c_obj_name) HDfree(c_obj_name); - if (c_name) HDfree(c_name); - ret_value = 0; + +DONE: + HDfree(c_obj_name); + HDfree(c_name); return ret_value; } @@ -204,13 +188,15 @@ nh5gn_members_c (hid_t_f *loc_id, _fcd name, int_f *namelen, int_f *nmembers) /* * Call H5Gn_members function. */ - c_loc_id = *loc_id; + c_loc_id = (hid_t)*loc_id; c_nmembers = H5Gn_members(c_loc_id, c_name); - HDfree(c_name); - if (c_nmembers < 0) return ret_value; + if (c_nmembers < 0) goto DONE; *nmembers = (int_f)c_nmembers; ret_value = 0; + +DONE: + HDfree(c_name); return ret_value; } /*---------------------------------------------------------------------------- @@ -229,7 +215,7 @@ nh5gclose_c ( hid_t_f *grp_id ) int ret_value = 0; hid_t c_grp_id; - c_grp_id = *grp_id; + c_grp_id = (hid_t)*grp_id; if ( H5Gclose(c_grp_id) < 0 ) ret_value = -1; return ret_value; } @@ -266,20 +252,25 @@ nh5glink_c(hid_t_f *loc_id, int_f *link_type, _fcd current_name, int_f *current_ c_current_namelen =*current_namelen; c_new_namelen =*new_namelen; c_current_name = (char *)HD5f2cstring(current_name, c_current_namelen); + if (c_current_name == NULL) return ret_value; + c_new_name = (char *)HD5f2cstring(new_name, c_new_namelen); - if((c_current_name == NULL)||(c_new_name == NULL)) - return ret_value; + if(c_new_name == NULL) { HDfree(c_current_name); + return ret_value; + } /* * Call H5Glink function */ c_loc_id = *loc_id; c_link_type = (H5G_link_t)*link_type; c_ret_value = H5Glink(c_loc_id, c_link_type, c_current_name, c_new_name); - if(c_current_name) HDfree(c_current_name); - if(c_new_name) HDfree(c_new_name); - if(c_ret_value < 0) return ret_value; + if(c_ret_value < 0) goto DONE; ret_value = 0; + +DONE: + HDfree(c_current_name); + HDfree(c_new_name); return ret_value ; } @@ -311,11 +302,13 @@ nh5gunlink_c(hid_t_f *loc_id, _fcd name, int_f *namelen) /* * Call H5Gunlink function */ - c_loc_id = *loc_id; + c_loc_id = (hid_t)*loc_id; c_ret_value = H5Gunlink(c_loc_id, c_name); - if(c_name) HDfree(c_name); - if(c_ret_value < 0) return ret_value; + if(c_ret_value < 0) goto DONE; ret_value = 0; + +DONE: + HDfree(c_name); return ret_value ; } @@ -347,19 +340,24 @@ nh5gmove_c(hid_t_f *loc_id, _fcd src_name, int_f *src_namelen, _fcd dst_name, in c_src_namelen = *src_namelen; c_dst_namelen = *dst_namelen; c_src_name = (char *)HD5f2cstring(src_name, c_src_namelen); + if(c_src_name == NULL) return ret_value; + c_dst_name = (char *)HD5f2cstring(dst_name, c_dst_namelen); - if((c_src_name == NULL)||(c_dst_name == NULL)) - return ret_value; + if(c_dst_name == NULL) { HDfree(c_src_name); + return ret_value; + } /* * Call H5Gmove function */ - c_loc_id = *loc_id; + c_loc_id = (hid_t)*loc_id; c_ret_value = H5Gmove(c_loc_id, c_src_name, c_dst_name); - if(c_src_name) HDfree(c_src_name); - if(c_dst_name) HDfree(c_dst_name); - if(c_ret_value < 0) return ret_value; + if(c_ret_value < 0) goto DONE; ret_value = 0; + +DONE: + HDfree(c_src_name); + HDfree(c_dst_name); return ret_value ; } @@ -408,23 +406,20 @@ nh5gget_linkval_c(hid_t_f *loc_id, _fcd name, int_f *namelen, size_t_f *size, _f */ c_size = (size_t)*size; - c_loc_id = *loc_id; + c_loc_id = (hid_t)*loc_id; c_ret_value = H5Gget_linkval(c_loc_id, c_name, c_size, c_value); - if(c_ret_value < 0) { - if(c_value) HDfree(c_value); - if(c_name) HDfree(c_name); - return ret_value; - } + if(c_ret_value < 0) goto DONE; + /* * Convert C name to FORTRAN and place it in the given buffer */ HD5packFstring(c_value, _fcdtocp(value), (int)*size); - - if(c_value) HDfree(c_value); - if(c_name) HDfree(c_name); - ret_value = 0; + +DONE: + HDfree(c_value); + HDfree(c_name); return ret_value ; } @@ -456,19 +451,23 @@ nh5gset_comment_c(hid_t_f *loc_id, _fcd name, int_f *namelen, _fcd comment, int_ c_namelen = *namelen; c_commentlen =*commentlen; c_name = (char *)HD5f2cstring(name, c_namelen); + if(c_name == NULL) return ret_value; + c_comment = (char *)HD5f2cstring(comment, c_commentlen); - if((c_name == NULL)||(c_comment == NULL)) - return ret_value; + if(c_comment == NULL) { HDfree (c_name); + return ret_value; + } /* * Call H5Gset_comment function */ - c_loc_id = *loc_id; + c_loc_id = (hid_t)*loc_id; c_ret_value = H5Gset_comment(c_loc_id, c_name, c_comment); - if(c_name) HDfree(c_name); - if(c_comment) HDfree(c_comment); - if(c_ret_value < 0) return ret_value; - + if(c_ret_value < 0) goto DONE; ret_value = 0; + +DONE: + HDfree(c_name); + HDfree(c_comment); return ret_value ; } @@ -520,20 +519,16 @@ nh5gget_comment_c(hid_t_f *loc_id, _fcd name, int_f *namelen, size_t_f *bufsize, */ c_loc_id = *loc_id; c_ret_value = H5Gget_comment(c_loc_id, c_name, c_bufsize, c_comment); - if(c_ret_value < 0) { - HDfree(c_name); - HDfree(c_comment); - return ret_value; - } + if(c_ret_value < 0) goto DONE; /* * Convert C name to FORTRAN and place it in the given buffer */ HD5packFstring(c_comment, _fcdtocp(comment), (int)*bufsize); - - if(c_name) HDfree(c_name); - if(c_comment) HDfree(c_comment); - ret_value = 0; + +DONE: + HDfree(c_name); + HDfree(c_comment); return ret_value ; } diff --git a/fortran/src/H5Pf.c b/fortran/src/H5Pf.c index 2ea4e5e..51b9b71 100644 --- a/fortran/src/H5Pf.c +++ b/fortran/src/H5Pf.c @@ -161,7 +161,7 @@ nh5pset_preserve_c ( hid_t_f *prp_id , int_f *flag) hbool_t c_flag = 0; if (*flag > 0) c_flag = 1; - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; status = H5Pset_preserve(c_prp_id, c_flag); if ( status < 0 ) ret_value = -1; return ret_value; @@ -188,7 +188,7 @@ nh5pget_preserve_c ( hid_t_f *prp_id , int_f *flag) herr_t status; int c_flag; - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; c_flag = H5Pget_preserve(c_prp_id); if ( c_flag < 0 ) ret_value = -1; *flag = (int_f)c_flag; @@ -214,8 +214,8 @@ nh5pset_deflate_c ( hid_t_f *prp_id , int_f *level) int c_level; herr_t status; - c_prp_id = *prp_id; - c_level = *level; + c_prp_id = (hid_t)*prp_id; + c_level = (int)*level; status = H5Pset_deflate(c_prp_id, c_level); if ( status < 0 ) ret_value = -1; return ret_value; @@ -256,11 +256,13 @@ nh5pset_chunk_c ( hid_t_f *prp_id, int_f *rank, hsize_t_f *dims ) c_dims[i] = dims[*rank - i - 1]; } - c_prp_id = *prp_id; - c_rank = *rank; + c_prp_id = (hid_t)*prp_id; + c_rank = (int)*rank; status = H5Pset_chunk(c_prp_id, c_rank, c_dims); - if (status < 0) return ret_value; + if (status < 0) goto DONE; ret_value = 0; + +DONE: HDfree (c_dims); return ret_value; } @@ -292,8 +294,8 @@ nh5pget_chunk_c ( hid_t_f *prp_id, int_f *max_rank, hsize_t_f *dims ) c_dims = malloc(sizeof(hsize_t) * (*max_rank )); if (!c_dims) return ret_value; - c_prp_id = *prp_id; - c_max_rank = *max_rank; + c_prp_id = (hid_t)*prp_id; + c_max_rank = (int)*max_rank; rank = H5Pget_chunk(c_prp_id, c_max_rank, c_dims); /* @@ -356,8 +358,8 @@ nh5pset_fill_value_c (hid_t_f *prp_id, hid_t_f *type_id, void *fillvalue) /* * Call H5Pset_fill_value function. */ - c_prp_id = *prp_id; - c_type_id = *type_id; + c_prp_id = (hid_t)*prp_id; + c_type_id = (int)*type_id; ret = H5Pset_fill_value(c_prp_id, c_type_id, fillvalue); if (ret < 0) return ret_value; @@ -412,8 +414,8 @@ nh5pget_fill_value_c (hid_t_f *prp_id, hid_t_f *type_id, void *fillvalue) /* * Call H5Pget_fill_value function. */ - c_prp_id = *prp_id; - c_type_id = *type_id; + c_prp_id = (hid_t)*prp_id; + c_type_id = (int)*type_id; ret = H5Pget_fill_value(c_prp_id, c_type_id, fillvalue); if (ret < 0) return ret_value; @@ -452,12 +454,14 @@ nh5pget_version_c (hid_t_f *prp_id, int_f * boot,int_f * freelist, int_f * stab, */ c_prp_id = *prp_id; ret = H5Pget_version(c_prp_id, &c_boot, &c_freelist, &c_stab, &c_shhdr); - *boot = (int_f)c_boot; - *freelist = (int_f)c_freelist; - *stab = (int_f)c_stab; - *shhdr = (int_f)c_shhdr; if (ret < 0) return ret_value; + + *boot = (int_f)c_boot; + *freelist = (int_f)c_freelist; + *stab = (int_f)c_stab; + *shhdr = (int_f)c_shhdr; ret_value = 0; + return ret_value; } @@ -484,12 +488,13 @@ nh5pget_userblock_c (hid_t_f *prp_id, hsize_t_f * size) /* * Call H5Pget_userblock function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pget_userblock(c_prp_id, &c_size); - - *size = (hsize_t_f)c_size; if (ret < 0) return ret_value; + + *size = (hsize_t_f)c_size; ret_value = 0; + return ret_value; } @@ -516,7 +521,7 @@ nh5pset_userblock_c (hid_t_f *prp_id, hsize_t_f * size) /* * Call H5Pset_userblock function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pset_userblock(c_prp_id, c_size); if (ret < 0) return ret_value; @@ -549,13 +554,14 @@ nh5pget_sizes_c (hid_t_f *prp_id, size_t_f * sizeof_addr, size_t_f * sizeof_size /* * Call H5Pget_sizes function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pget_sizes(c_prp_id, &c_sizeof_addr, &c_sizeof_size); - - *sizeof_addr = (size_t_f)c_sizeof_addr; - *sizeof_size = (size_t_f)c_sizeof_size; if (ret < 0) return ret_value; + + *sizeof_addr = (size_t_f)c_sizeof_addr; + *sizeof_size = (size_t_f)c_sizeof_size; ret_value = 0; + return ret_value; } @@ -583,7 +589,7 @@ nh5pset_sizes_c (hid_t_f *prp_id, size_t_f * sizeof_addr, size_t_f * sizeof_size /* * Call H5Pset_sizes function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pset_sizes(c_prp_id, c_addr, c_size); if (ret < 0) return ret_value; @@ -615,9 +621,9 @@ nh5pset_sym_k_c (hid_t_f *prp_id, int_f* ik, int_f* lk) /* * Call H5Pset_sym_k function. */ - c_prp_id = *prp_id; - c_ik = *ik; - c_lk = *lk; + c_prp_id = (hid_t)*prp_id; + c_ik = (int)*ik; + c_lk = (int)*lk; ret = H5Pset_sym_k(c_prp_id, c_ik, c_lk); if (ret < 0) return ret_value; @@ -654,7 +660,7 @@ nh5pget_sym_k_c (hid_t_f *prp_id, int_f* ik, int_f* lk) /* * Call H5Pget_sym_k function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pget_sym_k(c_prp_id, &c_ik, &c_lk); *ik = (int_f)c_ik; *lk = (int_f)c_lk; @@ -685,8 +691,8 @@ nh5pset_istore_k_c (hid_t_f *prp_id, int_f* ik) /* * Call H5Pset_istore_k function. */ - c_prp_id = *prp_id; - c_ik = *ik; + c_prp_id = (hid_t)*prp_id; + c_ik = (int)*ik; ret = H5Pset_istore_k(c_prp_id, c_ik); if (ret < 0) return ret_value; @@ -716,7 +722,7 @@ nh5pget_istore_k_c (hid_t_f *prp_id, int_f* ik) /* * Call H5Pget_istore_k function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pget_istore_k(c_prp_id, &c_ik); *ik = (int_f)c_ik; if (ret < 0) return ret_value; @@ -775,7 +781,7 @@ nh5pset_fapl_stdio_c (hid_t_f *prp_id) /* * Call H5Pset_fapl_stdio function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pset_fapl_stdio(c_prp_id); if (ret < 0) return ret_value; ret_value = 0; @@ -832,7 +838,7 @@ nh5pset_fapl_sec2_c (hid_t_f *prp_id) /* * Call H5Pset_fapl_sec2 function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pset_fapl_sec2(c_prp_id); if (ret < 0) return ret_value; ret_value = 0; @@ -861,7 +867,7 @@ nh5pget_fapl_sec2_c (hid_t_f *prp_id, int_f* sec2) /* * Call H5Pget_fapl_sec2 function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pget_fapl_sec2(c_prp_id); if (ret < 0) return ret_value; *sec2 = (int_f)ret; @@ -960,7 +966,7 @@ nh5pset_fapl_core_c (hid_t_f *prp_id, size_t_f* increment, int_f *flag) /* * Call H5Pset_fapl_core function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pset_fapl_core(c_prp_id, c_increment, c_backing_store); if (ret < 0) return ret_value; ret_value = 0; @@ -990,7 +996,7 @@ nh5pget_fapl_core_c (hid_t_f *prp_id, size_t_f* increment, int_f *flag) /* * Call H5Pset_fapl_core function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pget_fapl_core(c_prp_id, &c_increment, &c_backing_store); if (ret < 0) return ret_value; *increment = (size_t_f)c_increment; @@ -1025,7 +1031,7 @@ nh5pset_fapl_family_c(hid_t_f *prp_id, hsize_t_f* memb_size, hid_t_f* memb_plist /* * Call H5Pset_fapl_family function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pset_fapl_family(c_prp_id, c_memb_size, c_memb_plist); if (ret < 0) return ret_value; ret_value = 0; @@ -1056,7 +1062,7 @@ nh5pget_fapl_family_c(hid_t_f *prp_id, hsize_t_f* memb_size, hid_t_f* memb_plist /* * Call H5Pget_fapl_family function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pget_fapl_family(c_prp_id, &c_memb_size, &c_memb_plist); if (ret < 0) return ret_value; *memb_size = (hsize_t_f)c_memb_size; @@ -1098,9 +1104,9 @@ nh5pset_cache_c(hid_t_f *prp_id, int_f* mdc_nelmts, int_f* rdcc_nelmts, size_t_ /* * Call H5Pset_cache function. */ - c_prp_id = *prp_id; - c_mdc_nelmts = *mdc_nelmts; - c_rdcc_nelmts = *rdcc_nelmts; + c_prp_id = (hid_t)*prp_id; + c_mdc_nelmts = (int)*mdc_nelmts; + c_rdcc_nelmts = (int)*rdcc_nelmts; ret = H5Pset_cache(c_prp_id, c_mdc_nelmts, c_rdcc_nelmts, c_rdcc_nbytes, c_rdcc_w0 ); if (ret < 0) return ret_value; ret_value = 0; @@ -1137,7 +1143,7 @@ nh5pget_cache_c(hid_t_f *prp_id, int_f* mdc_nelmts, size_t_f* rdcc_nelmts, size_ /* * Call H5Pget_cache function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pget_cache(c_prp_id, &c_mdc_nelmts, &c_rdcc_nelmts, &c_rdcc_nbytes, &c_rdcc_w0); if (ret < 0) return ret_value; *mdc_nelmts = (int_f)c_mdc_nelmts; @@ -1175,22 +1181,28 @@ nh5pset_fapl_split_c(hid_t_f *prp_id, int_f* meta_len, _fcd meta_ext, hid_t_f* m herr_t ret = -1; char* c_meta_ext; char* c_raw_ext; + c_meta_ext = (char *)HD5f2cstring(meta_ext, (int)*meta_len); if (c_meta_ext == NULL) return ret_value; c_raw_ext = (char *)HD5f2cstring(raw_ext, (int)*raw_len); - if (c_raw_ext == NULL) return ret_value; + if (c_raw_ext == NULL) { HDfree(c_meta_ext); + return ret_value; + } /* * Call H5Pset_fapl_split function. */ - c_prp_id = *prp_id; - c_meta_plist = *meta_plist; - c_raw_plist = *raw_plist; + c_prp_id = (hid_t)*prp_id; + c_meta_plist = (hid_t)*meta_plist; + c_raw_plist = (hid_t)*raw_plist; ret = H5Pset_fapl_split(c_prp_id, c_meta_ext, c_meta_plist, c_raw_ext, c_raw_plist ); + + if (ret < 0) goto DONE; + ret_value = 0; + +DONE: HDfree(c_meta_ext); HDfree(c_raw_ext); - if (ret < 0) return ret_value; - ret_value = 0; return ret_value; } @@ -1304,7 +1316,7 @@ nh5pget_gc_references_c (hid_t_f *prp_id, int_f* gc_references) /* * Call H5Pget_gc_references function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pget_gc_references(c_prp_id, &c_gc_references); if (ret < 0) return ret_value; *gc_references = (int_f)c_gc_references; @@ -1334,7 +1346,7 @@ nh5pset_layout_c (hid_t_f *prp_id, int_f* layout) /* * Call H5Pset_layout function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pset_layout(c_prp_id, c_layout); if (ret < 0) return ret_value; @@ -1362,7 +1374,7 @@ nh5pget_layout_c (hid_t_f *prp_id, int_f* layout) /* * Call H5Pget_layout function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; c_layout = H5Pget_layout(c_prp_id); if (c_layout < 0) return ret_value; *layout = (int_f)c_layout; @@ -1407,12 +1419,14 @@ nh5pset_filter_c (hid_t_f *prp_id, int_f* filter, int_f* flags, size_t_f* cd_nel /* * Call H5Pset_filter function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pset_filter(c_prp_id, c_filter, c_flags, c_cd_nelmts,c_cd_values ); - if (ret < 0) return ret_value; + if (ret < 0) goto DONE; ret_value = 0; - free(c_cd_values); + +DONE: + HDfree(c_cd_values); return ret_value; } @@ -1436,11 +1450,13 @@ nh5pget_nfilters_c (hid_t_f *prp_id, int_f* nfilters) /* * Call H5Pget_nfilters function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; c_nfilters = H5Pget_nfilters(c_prp_id); if (c_nfilters < 0) return ret_value; + *nfilters = (int_f)c_nfilters; ret_value = 0; + return ret_value; } @@ -1483,28 +1499,33 @@ nh5pget_filter_c(hid_t_f *prp_id, int_f* filter_number, int_f* flags, size_t_f* if (!c_name) return ret_value; c_cd_values = (unsigned int*)malloc(sizeof(unsigned int)*((int)c_cd_nelmts)); - if (!c_cd_values) return ret_value; + if (!c_cd_values) {HDfree(c_name); + return ret_value; + } + /* * Call H5Pget_filter function. */ - c_prp_id = *prp_id; - c_filter_number = *filter_number; + c_prp_id = (hid_t)*prp_id; + c_filter_number = (int)*filter_number; c_filter = H5Pget_filter(c_prp_id, c_filter_number, &c_flags, &c_cd_nelmts, c_cd_values, c_namelen, c_name); - if (c_filter < 0) return ret_value; + if (c_filter < 0) goto DONE; - *filter_id = c_filter; - *cd_nelmts = c_cd_nelmts; - *flags = c_flags; + *filter_id = (int_f)c_filter; + *cd_nelmts = (size_t_f)c_cd_nelmts; + *flags = (int_f)c_flags; HD5packFstring(c_name, _fcdtocp(name), strlen(c_name)); for (i = 0; i < c_cd_nelmts; i++) cd_values[i] = (int_f)c_cd_values[i]; + ret_value = 0; + +DONE: HDfree(c_name); HDfree(c_cd_values); - ret_value = 0; return ret_value; } @@ -1530,26 +1551,28 @@ nh5pset_external_c (hid_t_f *prp_id, _fcd name, int_f* namelen, int_f* offset, h hid_t c_prp_id; herr_t ret; hsize_t c_bytes; - char* c_name; + const char* c_name; int c_namelen; off_t c_offset; - c_bytes = (hsize_t) *bytes; - c_offset = (off_t)*offset; + c_offset = (off_t) *offset; - c_namelen = *namelen; + + c_namelen = (int)*namelen; c_name = (char *)HD5f2cstring(name, c_namelen); if (c_name == NULL) return ret_value; /* * Call H5Pset_external function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pset_external(c_prp_id, c_name, c_offset, c_bytes); - HDfree(c_name); - if (ret < 0) return ret_value; + if (ret < 0) goto DONE; ret_value = 0; + +DONE: + HDfree(c_name); return ret_value; } @@ -1573,7 +1596,7 @@ nh5pget_external_count_c (hid_t_f *prp_id, int_f* count) /* * Call H5Pget_external_count function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; c_count = H5Pget_external_count(c_prp_id); if (c_count < 0) return ret_value; *count = (int_f)c_count; @@ -1597,7 +1620,7 @@ nh5pget_external_count_c (hid_t_f *prp_id, int_f* count) * Modifications: *---------------------------------------------------------------------------*/ int_f -nh5pget_external_c(hid_t_f *prp_id,int*idx, size_t_f* name_size, _fcd name, int_f* offset, hsize_t_f*bytes) +nh5pget_external_c(hid_t_f *prp_id,int_f *idx, size_t_f* name_size, _fcd name, int_f* offset, hsize_t_f*bytes) { int ret_value = -1; hid_t c_prp_id; @@ -1618,21 +1641,19 @@ nh5pget_external_c(hid_t_f *prp_id,int*idx, size_t_f* name_size, _fcd name, int_ /* * Call H5Pget_external function. */ - c_prp_id = *prp_id; - c_idx = *idx; + c_prp_id = (hid_t)*prp_id; + c_idx = (int)*idx; status = H5Pget_external(c_prp_id, c_idx, c_namelen, c_name, &c_offset, &size ); - if (status < 0) { - HDfree(c_name); - return ret_value; - } + if (status < 0) goto DONE; *offset = (int_f)c_offset; *bytes = (hsize_t_f)size; HD5packFstring(c_name, _fcdtocp(name), strlen(c_name)); - - HDfree(c_name); ret_value = 0; + +DONE: + HDfree(c_name); return ret_value; } @@ -1653,7 +1674,6 @@ int_f nh5pset_hyper_cache_c(hid_t_f *prp_id, int_f * cache, int_f * limit) { int ret_value = -1; -#ifdef H5_WANT_H5_V1_4_COMPAT hid_t c_prp_id; herr_t ret; unsigned c_cache, c_limit; @@ -1664,7 +1684,8 @@ nh5pset_hyper_cache_c(hid_t_f *prp_id, int_f * cache, int_f * limit) /* * Call H5Pset_hyper_cache function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; +#ifdef H5_WANT_H5_V1_4_COMPAT ret = H5Pset_hyper_cache(c_prp_id, c_cache, c_limit); if (ret < 0) return ret_value; #endif /* H5_WANT_H5_V1_4_COMPAT */ @@ -1689,14 +1710,14 @@ int_f nh5pget_hyper_cache_c(hid_t_f *prp_id, int_f * cache, int_f * limit) { int ret_value = -1; -#ifdef H5_WANT_H5_V1_4_COMPAT hid_t c_prp_id; herr_t ret; unsigned c_cache, c_limit; /* * Call H5Pget__hyper_cache function. */ - c_prp_id = *prp_id; +#ifdef H5_WANT_H5_V1_4_COMPAT + c_prp_id = (hid_t)*prp_id; ret = H5Pget_hyper_cache(c_prp_id, &c_cache, &c_limit); if (ret < 0) return ret_value; *cache = (int_f)c_cache; @@ -1736,7 +1757,7 @@ nh5pset_btree_ratios_c(hid_t_f *prp_id, real_f* left, real_f* middle, real_f* ri /* * Call H5Pset_btree_ratios function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pset_btree_ratios(c_prp_id, c_left, c_middle, c_right); if (ret < 0) return ret_value; ret_value = 0; @@ -1768,7 +1789,7 @@ nh5pget_btree_ratios_c(hid_t_f *prp_id, real_f* left, real_f* middle, real_f* ri /* * Call H5Pget_btree_ratios function. */ - c_prp_id = *prp_id; + c_prp_id = (hid_t)*prp_id; ret = H5Pget_btree_ratios(c_prp_id, &c_left, &c_middle, &c_right); *left = (real_f)c_left; *middle = (real_f)c_middle; |