summaryrefslogtreecommitdiffstats
path: root/fortran/src/H5Rf.c
diff options
context:
space:
mode:
Diffstat (limited to 'fortran/src/H5Rf.c')
-rw-r--r--fortran/src/H5Rf.c215
1 files changed, 100 insertions, 115 deletions
diff --git a/fortran/src/H5Rf.c b/fortran/src/H5Rf.c
index ba5d273..51a775f 100644
--- a/fortran/src/H5Rf.c
+++ b/fortran/src/H5Rf.c
@@ -16,6 +16,7 @@
/* This files contains C stubs for H5R Fortran APIs */
#include "H5f90.h"
+#include "H5Eprivate.h"
/*----------------------------------------------------------------------------
* Name: h5rcreate_object_c
@@ -27,39 +28,34 @@
* Returns: 0 on success, -1 on failure
* Programmer: Elena Pourmal
* Wednesday, December 1, 1999
- * Modifications:
*---------------------------------------------------------------------------*/
int_f
-nh5rcreate_object_c (haddr_t_f *ref, hid_t_f *loc_id, _fcd name, int_f *namelen)
+nh5rcreate_object_c(haddr_t_f *ref, hid_t_f *loc_id, _fcd name, int_f *namelen)
{
- int ret_value = -1;
- hid_t c_loc_id;
- int ret_value_c;
- char *c_name;
- size_t c_namelen;
+ char *c_name = NULL;
hobj_ref_t ref_c;
+ int_f ret_value = 0;
/*
* Convert FORTRAN name to C name
*/
- c_namelen = *namelen;
- c_name = (char *)HD5f2cstring(name, c_namelen);
- if (c_name == NULL) return ret_value;
+ if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
+ HGOTO_DONE(FAIL)
/*
* Call H5Rcreate function.
*/
- c_loc_id = *loc_id;
- ret_value_c = H5Rcreate(&ref_c, c_loc_id, c_name, H5R_OBJECT, -1);
+ if(H5Rcreate(&ref_c, *loc_id, c_name, H5R_OBJECT, -1) < 0)
+ HGOTO_DONE(FAIL)
- HDfree(c_name);
- if (ret_value_c >= 0) {
- *ref=(haddr_t_f)ref_c;
- ret_value = 0;
- }
+ /* Copy the reference created */
+ *ref = (haddr_t_f)ref_c;
+done:
+ if(c_name)
+ HDfree(c_name);
return ret_value;
-}
+} /* nh5rcreate_object_c() */
/*----------------------------------------------------------------------------
* Name: h5rcreate_region_c
@@ -73,40 +69,34 @@ nh5rcreate_object_c (haddr_t_f *ref, hid_t_f *loc_id, _fcd name, int_f *namelen)
* Returns: 0 on success, -1 on failure
* Programmer: Elena Pourmal
* Wednesday, December 1, 1999
- * Modifications:
*---------------------------------------------------------------------------*/
int_f
-nh5rcreate_region_c (int_f *ref, hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *space_id)
+nh5rcreate_region_c(int_f *ref, hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *space_id)
{
- int ret_value = -1;
- hid_t c_loc_id;
- hid_t c_space_id;
- int ret_value_c;
- char *c_name;
- size_t c_namelen;
+ char *c_name = NULL;
hdset_reg_ref_t ref_c;
+ int_f ret_value = 0;
/*
* Convert FORTRAN name to C name
*/
- c_namelen = *namelen;
- c_name = (char *)HD5f2cstring(name, c_namelen);
- if (c_name == NULL) return ret_value;
+ if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
+ HGOTO_DONE(FAIL)
/*
* Call H5Rcreate function.
*/
- c_loc_id = *loc_id;
- c_space_id = *space_id;
- ret_value_c = H5Rcreate(&ref_c, c_loc_id, c_name, H5R_DATASET_REGION, c_space_id);
-
- HDfree(c_name);
- if (ret_value_c >= 0) {
- HDmemcpy (ref, &ref_c, H5R_DSET_REG_REF_BUF_SIZE);
- ret_value = 0;
- }
+ if(H5Rcreate(&ref_c, (hid_t)*loc_id, c_name, H5R_DATASET_REGION, (hid_t)*space_id) < 0)
+ HGOTO_DONE(FAIL)
+
+ /* Copy the reference created */
+ HDmemcpy(ref, &ref_c, H5R_DSET_REG_REF_BUF_SIZE);
+
+done:
+ if(c_name)
+ HDfree(c_name);
return ret_value;
-}
+} /* end nh5rcreate_region_c() */
/*----------------------------------------------------------------------------
* Name: h5rdereference_region_c
@@ -117,29 +107,29 @@ nh5rcreate_region_c (int_f *ref, hid_t_f *loc_id, _fcd name, int_f *namelen, hid
* Returns: 0 on success, -1 on failure
* Programmer: Elena Pourmal
* Wednesday, December 1, 1999
- * Modifications:
*---------------------------------------------------------------------------*/
int_f
-nh5rdereference_region_c (hid_t_f *dset_id, int_f *ref, hid_t_f *obj_id)
+nh5rdereference_region_c(hid_t_f *dset_id, int_f *ref, hid_t_f *obj_id)
{
- int ret_value = -1;
- hid_t c_dset_id;
hdset_reg_ref_t ref_c;
hid_t c_obj_id;
+ int_f ret_value = 0;
- HDmemcpy (&ref_c, ref, H5R_DSET_REG_REF_BUF_SIZE);
+ /* Copy the reference to dereference */
+ HDmemcpy(&ref_c, ref, H5R_DSET_REG_REF_BUF_SIZE);
/*
* Call H5Rdereference function.
*/
- c_dset_id = *dset_id;
- c_obj_id = H5Rdereference(c_dset_id, H5R_DATASET_REGION, &ref_c);
- if(c_obj_id < 0) return ret_value;
+ if((c_obj_id = H5Rdereference((hid_t)*dset_id, H5R_DATASET_REGION, &ref_c)) < 0)
+ HGOTO_DONE(FAIL)
+
+ /* Copy the object's ID */
*obj_id = (hid_t_f)c_obj_id;
- ret_value = 0;
- return ret_value;
-}
+done:
+ return ret_value;
+} /* end nh5rdereference_region_c() */
/*----------------------------------------------------------------------------
* Name: h5rdereference_object_c
@@ -150,28 +140,26 @@ nh5rdereference_region_c (hid_t_f *dset_id, int_f *ref, hid_t_f *obj_id)
* Returns: 0 on success, -1 on failure
* Programmer: Elena Pourmal
* Wednesday, December 1, 1999
- * Modifications:
*---------------------------------------------------------------------------*/
int_f
-nh5rdereference_object_c (hid_t_f *dset_id, haddr_t_f *ref, hid_t_f *obj_id)
+nh5rdereference_object_c(hid_t_f *dset_id, haddr_t_f *ref, hid_t_f *obj_id)
{
- int ret_value = -1;
- hid_t c_dset_id;
hid_t c_obj_id;
- hobj_ref_t ref_c;
-
- ref_c=*ref;
+ hobj_ref_t ref_c = (hobj_ref_t)*ref;
+ int_f ret_value = 0;
/*
* Call H5Rdereference function.
*/
- c_dset_id = *dset_id;
- c_obj_id = H5Rdereference(c_dset_id, H5R_OBJECT, &ref_c);
- if(c_obj_id < 0) return ret_value;
+ if((c_obj_id = H5Rdereference((hid_t)*dset_id, H5R_OBJECT, &ref_c)) < 0)
+ HGOTO_DONE(FAIL)
+
+ /* Copy the object's ID */
*obj_id = (hid_t_f)c_obj_id;
- ret_value = 0;
+
+done:
return ret_value;
-}
+} /* end nh5rdereference_object_c() */
/*----------------------------------------------------------------------------
* Name: h5rget_region_region_object_c
@@ -182,28 +170,29 @@ nh5rdereference_object_c (hid_t_f *dset_id, haddr_t_f *ref, hid_t_f *obj_id)
* Returns: 0 on success, -1 on failure
* Programmer: Elena Pourmal
* Wednesday, December 1, 1999
- * Modifications:
*---------------------------------------------------------------------------*/
int_f
-nh5rget_region_region_c (hid_t_f *dset_id, int_f *ref, hid_t_f *space_id)
+nh5rget_region_region_c(hid_t_f *dset_id, int_f *ref, hid_t_f *space_id)
{
- int ret_value = -1;
- hid_t c_dset_id;
hid_t c_space_id;
hdset_reg_ref_t ref_c;
+ int_f ret_value = 0;
- HDmemcpy (&ref_c, ref, H5R_DSET_REG_REF_BUF_SIZE);
+ /* Copy the reference to dereference */
+ HDmemcpy(&ref_c, ref, H5R_DSET_REG_REF_BUF_SIZE);
/*
* Call H5Rget_region function.
*/
- c_dset_id = *dset_id;
- c_space_id = H5Rget_region(c_dset_id, H5R_DATASET_REGION, &ref_c);
- if(c_space_id < 0) return ret_value;
+ if((c_space_id = H5Rget_region((hid_t)*dset_id, H5R_DATASET_REGION, &ref_c)) < 0)
+ HGOTO_DONE(FAIL)
+
+ /* Copy the dataspace ID */
*space_id = (hid_t_f)c_space_id;
- ret_value = 0;
+
+done:
return ret_value;
-}
+} /* end nh5rget_region_region_c() */
/*----------------------------------------------------------------------------
* Name: h5rget_object_type_obj_c
@@ -215,29 +204,26 @@ nh5rget_region_region_c (hid_t_f *dset_id, int_f *ref, hid_t_f *space_id)
* Returns: 0 on success, -1 on failure
* Programmer: Elena Pourmal
* Wednesday, December 1, 1999
- * Modifications:
*---------------------------------------------------------------------------*/
int_f
-nh5rget_object_type_obj_c (hid_t_f *dset_id, haddr_t_f *ref, int_f *obj_type)
+nh5rget_object_type_obj_c(hid_t_f *dset_id, haddr_t_f *ref, int_f *obj_type)
{
H5O_type_t c_obj_type;
- hobj_ref_t ref_c;
- int_f ret_value = -1;
-
- ref_c = *ref;
+ hobj_ref_t ref_c = (hobj_ref_t)*ref;
+ int_f ret_value = 0;
/*
* Call H5Rget_object_type function.
*/
if(H5Rget_obj_type2((hid_t)*dset_id, H5R_OBJECT, &ref_c, &c_obj_type) < 0)
- return ret_value;
+ HGOTO_DONE(FAIL)
+ /* Copy the object type */
*obj_type = (int_f)c_obj_type;
- ret_value = 0;
-
+done:
return ret_value;
-}
+} /* end nh5rget_object_type_obj_c() */
/*----------------------------------------------------------------------------
* Name: h5rget_name_object_c
@@ -252,42 +238,40 @@ nh5rget_object_type_obj_c (hid_t_f *dset_id, haddr_t_f *ref, int_f *obj_type)
* Returns: 0 on success, -1 on failure
* Programmer: M.S. Breitenfeld
* March 31, 2008
- * Modifications:
*---------------------------------------------------------------------------*/
int_f
-nh5rget_name_object_c (hid_t_f *loc_id, haddr_t_f *ref, _fcd name, size_t_f *name_len, size_t_f *size_default)
+nh5rget_name_object_c(hid_t_f *loc_id, haddr_t_f *ref, _fcd name, size_t_f *name_len, size_t_f *size_default)
{
- hobj_ref_t ref_c;
- int_f ret_value = -1;
+ hobj_ref_t ref_c = (hobj_ref_t)*ref;
ssize_t c_size;
- size_t c_bufsize;
- char *c_buf= NULL; /* Buffer to hold C string */
+ size_t c_bufsize = (size_t)*name_len + 1;
+ char *c_buf = NULL; /* Buffer to hold C string */
+ int_f ret_value = 0;
- ref_c = *ref;
- c_bufsize = (size_t)*name_len+1;
/*
* Allocate buffer to hold name of an attribute
*/
- if ((c_buf = HDmalloc(c_bufsize)) == NULL)
- return ret_value;
-
+ if(NULL == (c_buf = (char *)HDmalloc(c_bufsize)))
+ HGOTO_DONE(FAIL)
+
/*
* Call H5Rget_name function.
*/
- if((c_size=H5Rget_name((hid_t)*loc_id, H5R_OBJECT, &ref_c, c_buf, c_bufsize)) < 0)
- return ret_value;
+ if((c_size = H5Rget_name((hid_t)*loc_id, H5R_OBJECT, &ref_c, c_buf, c_bufsize)) < 0)
+ HGOTO_DONE(FAIL)
+
/*
* Convert C name to FORTRAN and place it in the given buffer
*/
HD5packFstring(c_buf, _fcdtocp(name), c_bufsize-1);
-
*size_default = (size_t_f)c_size;
- ret_value = 0;
- if(c_buf) HDfree(c_buf);
+done:
+ if(c_buf)
+ HDfree(c_buf);
return ret_value;
-}
+} /* end nh5rget_name_object_c() */
/*----------------------------------------------------------------------------
* Name: h5rget_name_region_c
@@ -302,39 +286,40 @@ nh5rget_name_object_c (hid_t_f *loc_id, haddr_t_f *ref, _fcd name, size_t_f *nam
* Returns: 0 on success, -1 on failure
* Programmer: M.S. Breitenfeld
* March 31, 2008
- * Modifications:
*---------------------------------------------------------------------------*/
int_f
-nh5rget_name_region_c (hid_t_f *loc_id, int_f *ref, _fcd name, size_t_f *name_len, size_t_f *size_default)
+nh5rget_name_region_c(hid_t_f *loc_id, int_f *ref, _fcd name, size_t_f *name_len, size_t_f *size_default)
{
hdset_reg_ref_t ref_c;
- int_f ret_value = -1;
ssize_t c_size;
- size_t c_bufsize;
- char *c_buf= NULL; /* Buffer to hold C string */
+ size_t c_bufsize = (size_t)*name_len + 1;
+ char *c_buf = NULL; /* Buffer to hold C string */
+ int_f ret_value = 0;
- HDmemcpy (&ref_c, ref, H5R_DSET_REG_REF_BUF_SIZE);
+ /* Copy the reference to query */
+ HDmemcpy(&ref_c, ref, H5R_DSET_REG_REF_BUF_SIZE);
- c_bufsize = (size_t)*name_len+1;
/*
* Allocate buffer to hold name of an attribute
*/
- if ((c_buf = HDmalloc(c_bufsize)) == NULL)
- return ret_value;
+ if(NULL == (c_buf = (char *)HDmalloc(c_bufsize)))
+ HGOTO_DONE(FAIL)
/*
* Call H5Rget_name function.
*/
- if((c_size=H5Rget_name((hid_t)*loc_id, H5R_DATASET_REGION, &ref_c, c_buf, c_bufsize)) < 0)
- return ret_value;
+ if((c_size = H5Rget_name((hid_t)*loc_id, H5R_DATASET_REGION, &ref_c, c_buf, c_bufsize)) < 0)
+ HGOTO_DONE(FAIL)
+
/*
* Convert C name to FORTRAN and place it in the given buffer
*/
- HD5packFstring(c_buf, _fcdtocp(name), c_bufsize-1);
-
+ HD5packFstring(c_buf, _fcdtocp(name), c_bufsize - 1);
*size_default = (size_t_f)c_size;
- ret_value = 0;
- if(c_buf) HDfree(c_buf);
+done:
+ if(c_buf)
+ HDfree(c_buf);
return ret_value;
-}
+} /* end nh5rget_name_region_c() */
+