summaryrefslogtreecommitdiffstats
path: root/fortran/src/H5Rf.c
blob: e45699b2865624995deba5b1b1d390decf8e2357 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#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 (int_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;
     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)  {
         HDmemcpy(ref, ref_c.oid, H5R_OBJ_REF_BUF_SIZE);
         ret_value = 0;
     }
       
     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 (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;
     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) {
         HDmemcpy (ref, ref_c.heapid, H5R_DSET_REG_REF_BUF_SIZE);
         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, 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 i;

     HDmemcpy (ref_c.heapid, 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;
     *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, int_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;
     int i;

     HDmemcpy (ref_c.oid, ref, H5R_OBJ_REF_BUF_SIZE);

     /*
      * 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, 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 i;

     HDmemcpy (ref_c.heapid, 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;
     *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, int_f *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;

     HDmemcpy (ref_c.oid, ref, H5R_OBJ_REF_BUF_SIZE);

     /*
      * Call H5Rget_object_type function.
      */
     c_dset_id = *dset_id;
     c_obj_type = H5Rget_obj_type(c_dset_id, H5R_OBJECT, &ref_c);
     if(c_obj_type < 0) return ret_value;
     *obj_type = (int_f)c_obj_type;
     ret_value = 0;     
     return ret_value;
}