Debian Codegraph @

src/H5Part/H5PartF.c

raw
1 /*
2 * This is my modified H5PartF.c for use in SPLASH
3 * Main changes are that the strings are now passed
4 * directly from Fortran, already with the null character appended
5 *
6 * Modified from the original H5Part Fortran interface
7 * by Daniel Price 08/04/10
8 */
9 #include "H5Part.h"
10 #include <string.h>
11
12 char
13 _H5Part_flagsfor2c (
14 char * flags
15 ) {
16
17 char fbits = 0x00;
18
19 flags = strtok ( flags, "," );
20 while ( flags != NULL ) {
21 if ( strcmp ( flags, "vfd_mpiposix" ) == 0 )
22 fbits |= H5PART_VFD_MPIPOSIX;
23 else if ( strcmp ( flags, "fs_lustre" ) == 0 )
24 fbits |= H5PART_FS_LUSTRE;
25 flags = strtok ( NULL, "," );
26 }
27
28 return fbits;
29 }
30
31 /* open/close interface */
32 h5part_int64_t
33 h5ptc_openr (
34 const char *file_name
35 ) {
36
37 H5PartFile* f = H5PartOpenFile ( file_name, H5PART_READ );
38
39 return (h5part_int64_t)(size_t)f;
40 }
41
42 h5part_int64_t
43 h5ptc_openw (
44 const char *file_name
45 ) {
46
47 H5PartFile* f = H5PartOpenFile ( file_name, H5PART_WRITE );
48
49 return (h5part_int64_t)(size_t)f;
50 }
51
52 h5part_int64_t
53 h5ptc_opena (
54 const char *file_name
55 ) {
56
57 H5PartFile* f = H5PartOpenFile ( file_name, H5PART_APPEND );
58
59 return (h5part_int64_t)(size_t)f;
60 }
61
62 h5part_int64_t
63 h5ptc_openr_align (
64 const char *file_name,
65 const h5part_int64_t *align
66 ) {
67
68 H5PartFile* f = H5PartOpenFileAlign ( file_name, H5PART_READ, *align );
69
70 return (h5part_int64_t)(size_t)f;
71 }
72
73 h5part_int64_t
74 h5ptc_openw_align (
75 const char *file_name,
76 const h5part_int64_t *align
77 ) {
78
79 H5PartFile* f = H5PartOpenFileAlign ( file_name, H5PART_WRITE, *align );
80
81 return (h5part_int64_t)(size_t)f;
82 }
83
84 h5part_int64_t
85 h5ptc_opena_align (
86 const char *file_name,
87 const h5part_int64_t *align
88 ) {
89
90 H5PartFile* f = H5PartOpenFileAlign ( file_name, H5PART_APPEND, *align );
91
92 return (h5part_int64_t)(size_t)f;
93 }
94
95 #ifdef PARALLEL_IO
96 h5part_int64_t
97 h5ptc_openr_par (
98 const char *file_name,
99 MPI_Fint *fcomm
100 ) {
101
102 MPI_Comm ccomm = MPI_Comm_f2c (*fcomm);
103
104 H5PartFile* f = H5PartOpenFileParallel (
105 file_name, H5PART_READ, ccomm );
106
107 return (h5part_int64_t)(size_t)f;
108 }
109
110 h5part_int64_t
111 h5ptc_openw_par (
112 const char *file_name,
113 MPI_Fint *fcomm
114 ) {
115
116 MPI_Comm ccomm = MPI_Comm_f2c (*fcomm);
117
118 H5PartFile* f = H5PartOpenFileParallel (
119 file_name, H5PART_WRITE, ccomm );
120
121 return (h5part_int64_t)(size_t)f;
122 }
123
124 h5part_int64_t
125 h5ptc_opena_par (
126 const char *file_name,
127 MPI_Fint *fcomm
128 ) {
129
130 MPI_Comm ccomm = MPI_Comm_f2c (*fcomm);
131
132 H5PartFile* f = H5PartOpenFileParallel (
133 file_name, H5PART_APPEND, ccomm );
134
135 return (h5part_int64_t)(size_t)f;
136 }
137
138 h5part_int64_t
139 h5ptc_openr_par_align (
140 const char *file_name,
141 MPI_Fint *fcomm,
142 const h5part_int64_t *align
143 ) {
144
145 MPI_Comm ccomm = MPI_Comm_f2c (*fcomm);
146
147 H5PartFile* f = H5PartOpenFileParallelAlign (
148 file_name, H5PART_READ, ccomm, *align );
149
150 return (h5part_int64_t)(size_t)f;
151 }
152
153 h5part_int64_t
154 h5ptc_openw_par_align (
155 const char *file_name,
156 MPI_Fint *fcomm,
157 const h5part_int64_t *align,
158 const char *flags
159 ) {
160
161 MPI_Comm ccomm = MPI_Comm_f2c (*fcomm);
162
163 char fbits = H5PART_WRITE | _H5Part_flagsfor2c ( flags );
164
165 H5PartFile* f = H5PartOpenFileParallelAlign (
166 file_name, fbits, ccomm, *align );
167
168 return (h5part_int64_t)(size_t)f;
169 }
170
171 h5part_int64_t
172 h5ptc_opena_par_align (
173 const char *file_name,
174 MPI_Fint *fcomm,
175 const h5part_int64_t *align,
176 const char *flags
177 ) {
178
179 MPI_Comm ccomm = MPI_Comm_f2c (*fcomm);
180
181 char fbits = H5PART_APPEND | _H5Part_flagsfor2c ( flags );
182
183 H5PartFile* f = H5PartOpenFileParallelAlign (
184 file_name, fbits, ccomm, *align );
185
186 return (h5part_int64_t)(size_t)f;
187 }
188 #endif
189
190 h5part_int64_t
191 h5ptc_close (
192 const h5part_int64_t *f
193 ) {
194 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
195
196 return H5PartCloseFile ( filehandle );
197 }
198
199 /*==============Writing and Setting Dataset info========*/
200
201 h5part_int64_t
202 h5ptc_readstep (
203 const h5part_int64_t *f,
204 const h5part_int64_t *step,
205 h5part_float64_t *x,
206 h5part_float64_t *y,
207 h5part_float64_t *z,
208 h5part_float64_t *px,
209 h5part_float64_t *py,
210 h5part_float64_t *pz,
211 h5part_int64_t *id
212 ) {
213
214 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
215
216 return H5PartReadParticleStep (
217 filehandle,(*step)-1,x,y,z,px,py,pz,id);
218 }
219
220
221 h5part_int64_t
222 h5ptc_setnpoints (
223 const h5part_int64_t *f,
224 h5part_int64_t *np
225 ) {
226
227 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
228
229 return H5PartSetNumParticles ( filehandle, *np );
230 }
231
232 h5part_int64_t
233 h5ptc_setnpoints_strided (
234 const h5part_int64_t *f,
235 h5part_int64_t *np,
236 h5part_int64_t *stride
237 ) {
238
239 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
240
241 return H5PartSetNumParticlesStrided ( filehandle, *np, *stride );
242 }
243
244 h5part_int64_t
245 h5ptc_setstep (
246 const h5part_int64_t *f,
247 h5part_int64_t *step ) {
248
249 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
250
251 return H5PartSetStep ( filehandle, (*step)-1 );
252 }
253
254 h5part_int64_t
255 h5ptc_writedata_r8 (
256 const h5part_int64_t *f,
257 const char *name,
258 const h5part_float64_t *data ) {
259
260 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
261
262 h5part_int64_t herr = H5PartWriteDataFloat64 (
263 filehandle, name, data );
264
265 return herr;
266 }
267
268 h5part_int64_t
269 h5ptc_writedata_r4 (
270 const h5part_int64_t *f,
271 const char *name,
272 const h5part_float32_t *data ) {
273
274 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
275
276 h5part_int64_t herr = H5PartWriteDataFloat32 (
277 filehandle, name, data );
278
279 return herr;
280 }
281
282 h5part_int64_t
283 h5ptc_writedata_i8 (
284 const h5part_int64_t *f,
285 const char *name,
286 const h5part_int64_t *data ) {
287
288 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
289
290 h5part_int64_t herr = H5PartWriteDataInt64 (
291 filehandle, name, data );
292
293 return herr;
294 }
295
296 h5part_int64_t
297 h5ptc_writedata_i4 (
298 const h5part_int64_t *f,
299 const char *name,
300 const h5part_int32_t *data ) {
301
302 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
303
304 h5part_int64_t herr = H5PartWriteDataInt32 (
305 filehandle, name, data );
306
307 return herr;
308 }
309
310 /*==============Reading Data Characteristics============*/
311
312 h5part_int64_t
313 h5ptc_getnsteps (
314 const h5part_int64_t *f
315 ) {
316
317 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
318
319 return H5PartGetNumSteps ( filehandle );
320 }
321
322 h5part_int64_t
323 h5ptc_getndatasets (
324 const h5part_int64_t *f
325 ) {
326
327 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
328
329 return H5PartGetNumDatasets ( filehandle );
330 }
331
332 h5part_int64_t
333 h5ptc_getnpoints (
334 const h5part_int64_t *f
335 ) {
336
337 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
338
339 return H5PartGetNumParticles ( filehandle );
340 }
341
342 h5part_int64_t
343 h5ptc_getdatasetname (
344 const h5part_int64_t *f,
345 const h5part_int64_t *index,
346 char *name,
347 const int l_name
348 ) {
349
350 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
351
352 h5part_int64_t herr = H5PartGetDatasetName (
353 filehandle, *index, name, l_name );
354
355 return herr;
356 }
357
358 h5part_int64_t
359 h5ptc_getdatasetinfo (
360 const h5part_int64_t *f,
361 const h5part_int64_t *index,
362 char *name,
363 h5part_int64_t *type,
364 h5part_int64_t *nelem,
365 const h5part_int64_t *l_name
366 ) {
367
368 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
369 h5part_int64_t type_tmp;
370 h5part_int64_t herr = H5PartGetDatasetInfo (
371 filehandle, *index, name, *l_name, &type_tmp, nelem );
372
373 if (type_tmp == H5PART_INT64)
374 {
375 *type = 1;
376 }
377 else if (type_tmp == H5PART_INT32)
378 {
379 *type = 2;
380 }
381 else if (type_tmp == H5PART_FLOAT64)
382 {
383 *type = 3;
384 }
385 else if (type_tmp == H5PART_FLOAT32)
386 {
387 *type = 4;
388 }
389 else if (type_tmp == H5PART_CHAR)
390 {
391 *type = 5;
392 }
393 else if (type_tmp == H5PART_STRING)
394 {
395 *type = 6;
396 }
397 else
398 {
399 *type = 0;
400 }
401
402 return herr;
403 }
404
405 /*=============Setting and getting views================*/
406
407 h5part_int64_t
408 h5ptc_setview (
409 const h5part_int64_t *f,
410 const h5part_int64_t *start,
411 const h5part_int64_t *end
412 ) {
413
414 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
415
416 return H5PartSetView ( filehandle, *start, *end );
417 }
418
419 h5part_int64_t
420 h5ptc_setview_indices (
421 const h5part_int64_t *f,
422 const h5part_int64_t *indices,
423 const h5part_int64_t *nelem
424 ) {
425
426 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
427
428 return H5PartSetViewIndices ( filehandle, indices, *nelem );
429 }
430
431 h5part_int64_t
432 h5ptc_resetview (
433 const h5part_int64_t *f
434 ) {
435
436 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
437
438 return H5PartResetView ( filehandle );
439 }
440
441 h5part_int64_t
442 h5ptc_hasview (
443 const h5part_int64_t *f
444 ) {
445
446 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
447
448 return H5PartHasView ( filehandle );
449 }
450
451 h5part_int64_t
452 h5ptc_getview (
453 const h5part_int64_t *f,
454 h5part_int64_t *start,
455 h5part_int64_t *end
456 ) {
457
458 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
459
460 return H5PartGetView ( filehandle, start, end);
461 }
462 /*==================Reading data ============*/
463 h5part_int64_t
464 h5ptc_readdata_r8 (
465 const h5part_int64_t *f,
466 const char *name,
467 h5part_float64_t *array
468 ) {
469
470 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
471
472 h5part_int64_t herr = H5PartReadDataFloat64 (
473 filehandle, name, array );
474
475 return herr;
476 }
477
478 h5part_int64_t
479 h5ptc_readdata_r4 (
480 const h5part_int64_t *f,
481 const char *name,
482 h5part_float32_t *array
483 ) {
484
485 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
486
487 h5part_int64_t herr = H5PartReadDataFloat32 (
488 filehandle, name, array );
489
490 return herr;
491 }
492
493 h5part_int64_t
494 h5ptc_readdata_i8 (
495 const h5part_int64_t *f,
496 const char *name,
497 h5part_int64_t *array
498 ) {
499
500 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
501
502 h5part_int64_t herr = H5PartReadDataInt64 (
503 filehandle, name, array );
504
505 return herr;
506 }
507
508 h5part_int64_t
509 h5ptc_readdata_i4 (
510 const h5part_int64_t *f,
511 const char *name,
512 h5part_int32_t *array
513 ) {
514
515 H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
516
517 h5part_int64_t herr = H5PartReadDataInt32 (
518 filehandle, name, array );
519
520 return herr;
521 }
522
523 /*
524 h5part_int64_t
525 h5ptc_set_verbosity_level (
526 const h5part_int64_t *level
527 ) {
528 return H5PartSetVerbosityLevel ( *level );
529 }
530 */