summaryrefslogtreecommitdiffstats
path: root/fortran/src/H5Rf.c
diff options
context:
space:
mode:
authorBill Wendling <wendling@ncsa.uiuc.edu>2000-09-19 20:06:49 (GMT)
committerBill Wendling <wendling@ncsa.uiuc.edu>2000-09-19 20:06:49 (GMT)
commit8055378bcecfc77af85b2bb07e7904edc9492789 (patch)
tree01c100c34cd727b9dc15ae21c89b6e0dfa361303 /fortran/src/H5Rf.c
parent8272da0b67a9ef3a7299fd10cc5f3ccbf80cbeae (diff)
downloadhdf5-8055378bcecfc77af85b2bb07e7904edc9492789.zip
hdf5-8055378bcecfc77af85b2bb07e7904edc9492789.tar.gz
hdf5-8055378bcecfc77af85b2bb07e7904edc9492789.tar.bz2
[svn-r2576] Purpose:
Adding the Fortran interface to the HDF5 library Description: Fortran is now a subdirectory of the HDF5 library tree. Platforms tested: Solaris and IRIX (O2K)
Diffstat (limited to 'fortran/src/H5Rf.c')
-rw-r--r--fortran/src/H5Rf.c267
1 files changed, 267 insertions, 0 deletions
diff --git a/fortran/src/H5Rf.c b/fortran/src/H5Rf.c
new file mode 100644
index 0000000..16e0f4a
--- /dev/null
+++ b/fortran/src/H5Rf.c
@@ -0,0 +1,267 @@
+#include "H5f90.h"
+
+/*----------------------------------------------------------------------------
+ * Name: h5rcreate_object_c
+ * Purpose: Call H5Rcreate to create a reference to an object
+ * Inputs: loc_id - file or group identifier
+ * name - name of the dataset
+ * namelen - name length
+ * Outputs: ref - reference to the object
+ * Returns: 0 on success, -1 on failure
+ * Programmer: Elena Pourmal
+ * Wednesday, December 1, 1999
+ * Modifications:
+ *---------------------------------------------------------------------------*/
+int_f
+nh5rcreate_object_c (_fcd 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;
+ int c_namelen;
+ hobj_ref_t ref_c;
+ int i;
+
+ /*
+ * Convert FORTRAN name to C name
+ */
+ c_namelen = *namelen;
+ c_name = (char *)HD5f2cstring(name, c_namelen);
+ if (c_name == NULL) return ret_value;
+
+ /*
+ * Call H5Rcreate function.
+ */
+ c_loc_id = *loc_id;
+ ret_value_c = H5Rcreate(&ref_c, c_loc_id, c_name, H5R_OBJECT, -1);
+ HDfree(c_name);
+ if (ret_value_c >= 0) {
+ for(i=0; i < H5R_OBJ_REF_BUF_SIZE; i++)
+ {
+#if defined(_UNICOS)
+ ref.c_pointer[i]=ref_c.oid[i];
+#else
+ ref[i]=ref_c.oid[i];
+#endif
+ }
+ ret_value = 0;
+ }
+ return ret_value;
+}
+
+/*----------------------------------------------------------------------------
+ * Name: h5rcreate_region_c
+ * Purpose: Call H5Rcreate to create a reference to dataset region
+ * region
+ * Inputs: loc_id - file or group identifier
+ * name - name of the dataset
+ * namelen - name length
+ * space_id - dataset space identifier
+ * Outputs: ref - reference to the dataset region
+ * Returns: 0 on success, -1 on failure
+ * Programmer: Elena Pourmal
+ * Wednesday, December 1, 1999
+ * Modifications:
+ *---------------------------------------------------------------------------*/
+int_f
+nh5rcreate_region_c (_fcd 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;
+ int c_namelen;
+ hdset_reg_ref_t ref_c;
+ int i;
+
+ /*
+ * Convert FORTRAN name to C name
+ */
+ c_namelen = *namelen;
+ c_name = (char *)HD5f2cstring(name, c_namelen);
+ if (c_name == NULL) return ret_value;
+
+ /*
+ * 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) {
+ for(i=0; i < H5R_DSET_REG_REF_BUF_SIZE; i++)
+ {
+#if defined(_UNICOS)
+ ref.c_pointer[i]=ref_c.heapid[i];
+#else
+ ref[i]=ref_c.heapid[i];
+#endif
+ }
+ ret_value = 0;
+ }
+ return ret_value;
+}
+
+/*----------------------------------------------------------------------------
+ * Name: h5rdereference_region_c
+ * Purpose: Call H5Rdereference to dereference to dataset region
+ * Inputs: dset_id - dataset identifier
+ * ref - reference to the dataset region
+ * Outputs: obj_id - dereferenced dataset identifier
+ * 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, _fcd 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 i;
+
+ for(i=0; i < H5R_DSET_REG_REF_BUF_SIZE; i++) {
+
+#if defined(_UNICOS)
+ ref_c.heapid[i]=ref.c_pointer[i];
+#else
+ ref_c.heapid[i]=ref[i];
+#endif
+ }
+
+ /*
+ * 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;
+ *obj_id = (hid_t_f)c_obj_id;
+ ret_value = 0;
+ return ret_value;
+}
+
+
+/*----------------------------------------------------------------------------
+ * Name: h5rdereference_object_c
+ * Purpose: Call H5Rdereference to dereference an object
+ * Inputs: dset_id - dataset identifier
+ * ref - reference to an object
+ * Outputs: obj_id - dereferenced object identifier
+ * 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, _fcd 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;
+ int i;
+
+ for(i=0; i < H5R_OBJ_REF_BUF_SIZE; i++) {
+
+#if defined(_UNICOS)
+ ref_c.oid[i]=ref.c_pointer[i];
+#else
+ ref_c.oid[i]=ref[i];
+#endif
+ }
+
+ /*
+ * 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;
+ *obj_id = (hid_t_f)c_obj_id;
+ ret_value = 0;
+ return ret_value;
+}
+
+/*----------------------------------------------------------------------------
+ * Name: h5rget_region_region_object_c
+ * Purpose: Call H5Rget_region to dereference dataspace region
+ * Inputs: dset_id - dataset identifier
+ * ref - reference to the dataset region
+ * Outputs: space_id - dereferenced dataset dataspace identifier
+ * 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, _fcd 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 i;
+
+ for(i=0; i < H5R_DSET_REG_REF_BUF_SIZE; i++) {
+
+#if defined(_UNICOS)
+ ref_c.heapid[i]=ref.c_pointer[i];
+#else
+ ref_c.heapid[i]=ref[i];
+#endif
+ }
+
+ /*
+ * 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;
+ *space_id = (hid_t_f)c_space_id;
+ ret_value = 0;
+ return ret_value;
+}
+
+/*----------------------------------------------------------------------------
+ * Name: h5rget_object_type_obj_c
+ * Purpose: Call H5Rget_object_type to retrieve the type of the object reference points
+ * to
+ * Inputs: dset_id - dataset identifier
+ * ref - reference to the dataset region
+ * Outputs: obj_type - type of dereferenced object
+ * 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, _fcd ref, int_f *obj_type)
+{
+ int ret_value = -1;
+ hid_t c_dset_id;
+ int c_obj_type;
+ hobj_ref_t ref_c;
+ int i;
+
+ for(i=0; i < H5R_OBJ_REF_BUF_SIZE; i++) {
+
+#if defined(_UNICOS)
+ ref_c.oid[i]=ref.c_pointer[i];
+#else
+ ref_c.oid[i]=ref[i];
+#endif
+ }
+
+ /*
+ * Call H5Rget_object_type function.
+ */
+ c_dset_id = *dset_id;
+ c_obj_type = H5Rget_object_type(c_dset_id, &ref_c);
+ if(c_obj_type < 0) return ret_value;
+ *obj_type = (int_f)c_obj_type;
+ ret_value = 0;
+ return ret_value;
+}