H5PartF.c 19.1 KB
Newer Older
gsell's avatar
gsell committed
1 2
#include "H5Part.h"
#include "Underscore.h"
3
#include <string.h>
gsell's avatar
gsell committed
4 5
#include <hdf5.h>

gsell's avatar
gsell committed
6 7
#if defined(F77_SINGLE_UNDERSCORE)
#define F77NAME(a,b) a
gsell's avatar
gsell committed
8
#elif defined(F77_CRAY_UNDERSCORE)
gsell's avatar
gsell committed
9 10
#define F77NAME(a,b) b
#elif defined(F77_NO_UNDERSCORE)
gsell's avatar
gsell committed
11 12 13 14
#else
#error Error, no way to determine how to construct fortran bindings
#endif

gsell's avatar
gsell committed
15
#if ! defined(F77_NO_UNDERSCORE)
gsell's avatar
gsell committed
16

gsell's avatar
gsell committed
17 18 19 20 21 22 23
/* open/close interface */
#define h5pt_openr F77NAME (						\
					h5pt_openr_,			\
					H5PT_OPENR )
#define h5pt_openw F77NAME (						\
					h5pt_openw_,			\
					H5PT_OPENW )
gsell's avatar
gsell committed
24 25 26
#define h5pt_opena F77NAME (						\
					h5pt_opena_,			\
					H5PT_OPENA )
gsell's avatar
gsell committed
27 28 29 30 31 32
#define h5pt_openr_par F77NAME (					\
					h5pt_openr_par_,		\
					H5PT_OPENR_PAR )
#define h5pt_openw_par F77NAME (					\
					h5pt_openw_par_,		\
					H5PT_OPENW_PAR )
gsell's avatar
gsell committed
33 34 35
#define h5pt_opena_par F77NAME (					\
					h5pt_opena_par_,		\
					H5PT_OPENA_PAR )
36 37 38 39 40 41 42 43 44 45
#define h5pt_openr_align F77NAME (					\
					h5pt_openr_align_,		\
					H5PT_OPENR_ALIGN )
#define h5pt_openw_align F77NAME (					\
					h5pt_openw_align_,		\
					H5PT_OPENW_ALIGN )
#define h5pt_opena_align F77NAME (					\
					h5pt_opena_align_,		\
					H5PT_OPENA_ALIGN )
#define h5pt_openr_par_align F77NAME (					\
46
					h5pt_openr_par_align_,		\
47 48 49 50 51 52 53 54
					H5PT_OPENR_PAR_ALIGN )
#define h5pt_openw_par_align F77NAME (					\
					h5pt_openw_par_align_,		\
					H5PT_OPENW_PAR_ALIGN )
#define h5pt_opena_par_align F77NAME (					\
					h5pt_opena_par_align_,		\
					H5PT_OPENA_PAR_ALIGN )

gsell's avatar
gsell committed
55 56 57
#define h5pt_close F77NAME (						\
					h5pt_close_,			\
					H5PT_CLOSE) 
gsell's avatar
gsell committed
58 59

/* writing interface */
gsell's avatar
gsell committed
60 61 62
#define h5pt_setnpoints F77NAME (					\
					h5pt_setnpoints_,		\
					H5PT_SETNPOINTS )
63 64 65
#define h5pt_setnpoints_strided F77NAME (					\
					h5pt_setnpoints_strided_,		\
					H5PT_SETNPOINTS_STRIDED )
gsell's avatar
gsell committed
66 67 68 69 70 71
#define h5pt_setstep F77NAME (						\
					h5pt_setstep_,			\
					H5PT_SETSTEP )
#define h5pt_writedata_r8 F77NAME (					\
					h5pt_writedata_r8_,		\
					H5PT_WRITEDATA_R8 )
72 73 74
#define h5pt_writedata_r4 F77NAME (					\
					h5pt_writedata_r4_,		\
					H5PT_WRITEDATA_R4 )
gsell's avatar
gsell committed
75 76 77
#define h5pt_writedata_i8 F77NAME (					\
					h5pt_writedata_i8_,		\
					H5PT_WRITEDATA_I8 )
78 79 80
#define h5pt_writedata_i4 F77NAME (					\
					h5pt_writedata_i4_,		\
					H5PT_WRITEDATA_I4 )
gsell's avatar
gsell committed
81 82

/* Reading interface  (define dataset, step, particles, attributes) */
gsell's avatar
gsell committed
83 84 85 86 87 88 89 90 91 92 93 94
#define h5pt_getnsteps F77NAME (					\
					h5pt_getnsteps_,		\
					H5PT_GETNSTEPS )
#define h5pt_getndatasets F77NAME (					\
					h5pt_getndatasets_,		\
					H5PT_GETNDATASETS )
#define h5pt_getnpoints F77NAME (					\
					h5pt_getnpoints_,		\
					H5PT_GETNPOINTS )
#define h5pt_getdatasetname F77NAME (					\
					h5pt_getdatasetname_,		\
					H5PT_GETDATASETNAME )
gsell's avatar
gsell committed
95 96

/* Views and parallelism */
gsell's avatar
gsell committed
97 98 99
#define h5pt_setview F77NAME (						\
					h5pt_setview_,			\
					H5PT_SETVIEW )
100 101 102
#define h5pt_setview_indices F77NAME (					\
					h5pt_setview_indices_,		\
					H5PT_SETVIEW_INDICES )
gsell's avatar
gsell committed
103 104 105 106 107 108 109 110 111
#define h5pt_resetview F77NAME (					\
					h5pt_resetview_,		\
					H5PT_RESETVIEW )
#define h5pt_hasview F77NAME (						\
					h5pt_hasview_,			\
					H5PT_HASVIEW )
#define h5pt_getview F77NAME (						\
					h5pt_getview_,			\
					H5PT_GETVIEW )
gsell's avatar
gsell committed
112 113

/* Reading data */
gsell's avatar
gsell committed
114 115 116
#define h5pt_readdata_r8 F77NAME (					\
					h5pt_readdata_r8_,		\
					H5PT_READDATA_R8 )
117 118 119
#define h5pt_readdata_r4 F77NAME (					\
					h5pt_readdata_r4_,		\
					H5PT_READDATA_R4 )
gsell's avatar
gsell committed
120 121 122
#define h5pt_readdata_i8 F77NAME (					\
					h5pt_readdata_i8_,		\
					H5PT_READDATA_I8 )
123 124 125
#define h5pt_readdata_i4 F77NAME (					\
					h5pt_readdata_i4_,		\
					H5PT_READDATA_I4 )
gsell's avatar
gsell committed
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

/* Writing attributes */
#define h5pt_writefileattrib_string F77NAME (				\
					h5pt_writefileattrib_string_,	\
					H5PT_writefileattrib_string )
#define h5pt_writestepattrib_string F77NAME (				\
					h5pt_writestepattrib_string_,	\
					H5PT_WRITESTEPATTRIB_STRING )

/* Reading attributes */
#define h5pt_getnstepattribs F77NAME (					\
					h5pt_getnstepattribs_,		\
					H5PT_GETNSTEPATTRIBS )
#define h5pt_getnfileattribs F77NAME (					\
					h5pt_getnfileattribs_,		\
					H5PT_GETNFILEATTRIBS )
#define h5pt_getstepattribinfo F77NAME (				\
					h5pt_getstepattribinfo_,	\
					H5PT_GETSTEPATTRIBINFO )
#define h5pt_getfileattribinfo F77NAME (				\
					h5pt_getfileattribinfo_,	\
					H5PT_GETFILEATTRIBINFO )
#define h5pt_readstepattrib_string F77NAME (				\
					h5pt_readstepattrib_string_,	\
					H5PT_READSTEPATTRIB_STRING )
#define h5pt_readfileattrib_string F77NAME (				\
					h5pt_readfileattrib_string_,	\
					H5PT_READFILEATTRIB_STRING )
gsell's avatar
gsell committed
154

gsell's avatar
gsell committed
155
/* error handling */
gsell's avatar
gsell committed
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
#define h5pt_set_verbosity_level F77NAME (				\
					h5pt_set_verbosity_level_,	\
					H5PT_SET_VERBOSITY_LEVEL )

#endif

char *
_H5Part_strdupfor2c (
	const char *s,
	const ssize_t len
	) {

	char *dup = (char*)malloc ( len + 1 );
	strncpy ( dup, s, len );
	char *p = dup + len;
	do {
		*p-- = '\0';
	} while ( *p == ' ' );
	return dup;
}

char *
_H5Part_strc2for (
	char * const str,
	const ssize_t l_str
	) {

	size_t len = strlen ( str );
	memset ( str+len, ' ', l_str-len );

	return str;
}
gsell's avatar
gsell committed
188

189 190 191 192 193 194 195
char
_H5Part_flagsfor2c (
	char * flags
	) {

	char fbits = 0x00;

196
	flags = strtok ( flags, "," );
197 198 199
	while ( flags != NULL ) {
		if ( strcmp ( flags, "vfd_mpiposix" ) == 0 )
				fbits |= H5PART_VFD_MPIPOSIX;
200 201
		else if ( strcmp ( flags, "vfd_core" ) == 0 )
				fbits |= H5PART_VFD_CORE;
202 203
		else if ( strcmp ( flags, "vfd_mpio_ind" ) == 0 )
				fbits |= H5PART_VFD_MPIIO_IND;
204 205
		else if ( strcmp ( flags, "fs_lustre" ) == 0 )
		    		fbits |= H5PART_FS_LUSTRE;
206
		flags = strtok ( NULL, "," );
207 208 209 210 211
	}

	return fbits;
}

gsell's avatar
gsell committed
212
/* open/close interface */
gsell's avatar
gsell committed
213
h5part_int64_t
gsell's avatar
gsell committed
214 215 216 217
h5pt_openr (
	const char *file_name,
	const int l_file_name
	) {
gsell's avatar
gsell committed
218

gsell's avatar
gsell committed
219
	char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );
gsell's avatar
gsell committed
220

gsell's avatar
gsell committed
221
	H5PartFile* f = H5PartOpenFile ( file_name2, H5PART_READ );
gsell's avatar
gsell committed
222

gsell's avatar
gsell committed
223 224
	free ( file_name2 );
	return (h5part_int64_t)(size_t)f; 
gsell's avatar
gsell committed
225 226
}

gsell's avatar
gsell committed
227 228 229 230 231 232 233
h5part_int64_t
h5pt_openw (
	const char *file_name,
	const int l_file_name
	) {

	char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );
gsell's avatar
gsell committed
234

gsell's avatar
gsell committed
235
	H5PartFile* f = H5PartOpenFile ( file_name2, H5PART_WRITE );
gsell's avatar
gsell committed
236

gsell's avatar
gsell committed
237 238
	free ( file_name2 );
	return (h5part_int64_t)(size_t)f; 
gsell's avatar
gsell committed
239 240
}

gsell's avatar
gsell committed
241 242 243 244 245 246 247 248 249 250 251 252 253 254
h5part_int64_t
h5pt_opena (
	const char *file_name,
	const int l_file_name
	) {
	
	char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );

	H5PartFile* f = H5PartOpenFile ( file_name2, H5PART_APPEND );

	free ( file_name2 );
	return (h5part_int64_t)(size_t)f;
}

255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
h5part_int64_t
h5pt_openr_align (
	const char *file_name,
	const h5part_int64_t *align,
	const int l_file_name
	) {

	char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );

	H5PartFile* f = H5PartOpenFileAlign ( file_name2, H5PART_READ, *align );

	free ( file_name2 );
	return (h5part_int64_t)(size_t)f; 
}

h5part_int64_t
h5pt_openw_align (
	const char *file_name,
	const h5part_int64_t *align,
	const int l_file_name
	) {

	char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );

	H5PartFile* f = H5PartOpenFileAlign ( file_name2, H5PART_WRITE, *align );

	free ( file_name2 );
	return (h5part_int64_t)(size_t)f; 
}

h5part_int64_t
h5pt_opena_align (
	const char *file_name,
	const h5part_int64_t *align,
	const int l_file_name
	) {
	
	char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );

	H5PartFile* f = H5PartOpenFileAlign ( file_name2, H5PART_APPEND, *align );

	free ( file_name2 );
	return (h5part_int64_t)(size_t)f;
}

gsell's avatar
gsell committed
300
#ifdef PARALLEL_IO
gsell's avatar
gsell committed
301 302 303
h5part_int64_t
h5pt_openr_par (
	const char *file_name,
304
	MPI_Fint *fcomm,
gsell's avatar
gsell committed
305 306 307
	const int l_file_name
	) {

308 309
	MPI_Comm ccomm = MPI_Comm_f2c (*fcomm);

gsell's avatar
gsell committed
310
	char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );
gsell's avatar
gsell committed
311

gsell's avatar
gsell committed
312
	H5PartFile* f = H5PartOpenFileParallel (
313
		file_name2, H5PART_READ, ccomm );
gsell's avatar
gsell committed
314

gsell's avatar
gsell committed
315 316
	free ( file_name2 );
	return (h5part_int64_t)(size_t)f; 
gsell's avatar
gsell committed
317 318
}

gsell's avatar
gsell committed
319
h5part_int64_t
gsell's avatar
gsell committed
320 321
h5pt_openw_par (
	const char *file_name,
322
	MPI_Fint *fcomm,
gsell's avatar
gsell committed
323 324 325
	const int l_file_name
	) {

326
	MPI_Comm ccomm = MPI_Comm_f2c (*fcomm);
gsell's avatar
gsell committed
327 328 329
	char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );

	H5PartFile* f = H5PartOpenFileParallel (
330
		file_name2, H5PART_WRITE, ccomm );
gsell's avatar
gsell committed
331 332 333

	free ( file_name2 );
	return (h5part_int64_t)(size_t)f; 
gsell's avatar
gsell committed
334
}
gsell's avatar
gsell committed
335 336 337 338

h5part_int64_t
h5pt_opena_par (
	const char *file_name,
339
	MPI_Fint *fcomm,
gsell's avatar
gsell committed
340 341 342
	const int l_file_name
	) {
	
343
	MPI_Comm ccomm = MPI_Comm_f2c (*fcomm);
gsell's avatar
gsell committed
344 345
	char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );
       
346 347
	H5PartFile* f = H5PartOpenFileParallel (
	       file_name2, H5PART_APPEND, ccomm );
gsell's avatar
gsell committed
348
       
349 350
	free ( file_name2 );
	return (h5part_int64_t)(size_t)f;
gsell's avatar
gsell committed
351
}
352 353 354 355

h5part_int64_t
h5pt_openr_par_align (
	const char *file_name,
356
	MPI_Fint *fcomm,
357
	const h5part_int64_t *align,
358 359 360
	const char *flags,
	const int l_file_name,
	const int l_flags
361 362
	) {

363
	MPI_Comm ccomm = MPI_Comm_f2c (*fcomm);
364
	char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );
365 366 367
	char *flags2 = _H5Part_strdupfor2c ( flags, l_flags );

	char fbits = H5PART_READ | _H5Part_flagsfor2c ( flags2 );
368 369

	H5PartFile* f = H5PartOpenFileParallelAlign (
370
		file_name2, fbits, ccomm, *align );
371 372

	free ( file_name2 );
373
	free ( flags2 );
374 375 376 377 378 379
	return (h5part_int64_t)(size_t)f; 
}

h5part_int64_t
h5pt_openw_par_align (
	const char *file_name,
380
	MPI_Fint *fcomm,
381
	const h5part_int64_t *align,
382 383 384
	const char *flags,
	const int l_file_name,
	const int l_flags
385 386
	) {

387
	MPI_Comm ccomm = MPI_Comm_f2c (*fcomm);
388
	char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );
389 390 391
	char *flags2 = _H5Part_strdupfor2c ( flags, l_flags );

	char fbits = H5PART_WRITE | _H5Part_flagsfor2c ( flags2 );
392 393

	H5PartFile* f = H5PartOpenFileParallelAlign (
394
		file_name2, fbits, ccomm, *align );
395 396

	free ( file_name2 );
397
	free ( flags2 );
398 399 400 401 402 403
	return (h5part_int64_t)(size_t)f; 
}

h5part_int64_t
h5pt_opena_par_align (
	const char *file_name,
404
	MPI_Fint *fcomm,
405
	const h5part_int64_t *align,
406 407 408
	const char *flags,
	const int l_file_name,
	const int l_flags
409 410
	) {
	
411
	MPI_Comm ccomm = MPI_Comm_f2c (*fcomm);
412
	char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );
413
	char *flags2 = _H5Part_strdupfor2c ( flags, l_flags );
414
       
415 416 417
	char fbits = H5PART_APPEND | _H5Part_flagsfor2c ( flags2 );

	H5PartFile* f = H5PartOpenFileParallelAlign (
418
		file_name2, fbits, ccomm, *align );
419 420

	free ( file_name2 );
421
	free ( flags2 );
422
	return (h5part_int64_t)(size_t)f;
423
}
gsell's avatar
gsell committed
424 425 426
#endif

h5part_int64_t
gsell's avatar
gsell committed
427 428
h5pt_close (
	const h5part_int64_t *f
gsell's avatar
gsell committed
429
	) {
gsell's avatar
gsell committed
430 431 432
	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	return H5PartCloseFile ( filehandle );
gsell's avatar
gsell committed
433 434 435
}

/*==============Writing and Setting Dataset info========*/
gsell's avatar
gsell committed
436

gsell's avatar
gsell committed
437
h5part_int64_t
gsell's avatar
gsell committed
438 439 440
h5pt_readstep (
	const h5part_int64_t *f,
	const h5part_int64_t *step,
gsell's avatar
gsell committed
441 442 443 444 445 446 447 448 449
	h5part_float64_t *x,
	h5part_float64_t *y,
	h5part_float64_t *z,
	h5part_float64_t *px,
	h5part_float64_t *py,
	h5part_float64_t *pz,
	h5part_int64_t *id
	) {

gsell's avatar
gsell committed
450 451 452 453
	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	return H5PartReadParticleStep (
		filehandle,(*step)-1,x,y,z,px,py,pz,id);
gsell's avatar
gsell committed
454
}
gsell's avatar
gsell committed
455

gsell's avatar
gsell committed
456 457

h5part_int64_t
gsell's avatar
gsell committed
458 459
h5pt_setnpoints (
	const h5part_int64_t *f,
gsell's avatar
gsell committed
460 461 462
	h5part_int64_t *np
	) {

gsell's avatar
gsell committed
463 464 465
	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	return H5PartSetNumParticles ( filehandle, *np );
gsell's avatar
gsell committed
466 467
}

468 469 470 471 472 473 474 475 476 477 478 479
h5part_int64_t
h5pt_setnpoints_strided (
	const h5part_int64_t *f,
	h5part_int64_t *np,
        h5part_int64_t *stride
	) {

	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	return H5PartSetNumParticlesStrided ( filehandle, *np, *stride );
}

gsell's avatar
gsell committed
480
h5part_int64_t
gsell's avatar
gsell committed
481 482
h5pt_setstep (
	const h5part_int64_t *f,
gsell's avatar
gsell committed
483 484
	h5part_int64_t *step ) {

gsell's avatar
gsell committed
485 486 487
	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	return H5PartSetStep ( filehandle, (*step)-1 );
gsell's avatar
gsell committed
488 489 490
}

h5part_int64_t
gsell's avatar
gsell committed
491 492 493 494 495 496 497 498 499
h5pt_writedata_r8 (
	const h5part_int64_t *f,
	const char *name,
	const h5part_float64_t *data,
	const int l_name ) {

	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	char *name2 = _H5Part_strdupfor2c ( name, l_name );
gsell's avatar
gsell committed
500

gsell's avatar
gsell committed
501 502
	h5part_int64_t herr = H5PartWriteDataFloat64 (
		filehandle, name2, data );
gsell's avatar
gsell committed
503

gsell's avatar
gsell committed
504
	free ( name2 );
gsell's avatar
gsell committed
505

gsell's avatar
gsell committed
506
	return herr;
gsell's avatar
gsell committed
507 508
}

509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527
h5part_int64_t
h5pt_writedata_r4 (
	const h5part_int64_t *f,
	const char *name,
	const h5part_float32_t *data,
	const int l_name ) {

	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	char *name2 = _H5Part_strdupfor2c ( name, l_name );

	h5part_int64_t herr = H5PartWriteDataFloat32 (
		filehandle, name2, data );

	free ( name2 );

	return herr;
}

gsell's avatar
gsell committed
528
h5part_int64_t
gsell's avatar
gsell committed
529 530 531 532 533 534 535 536 537
h5pt_writedata_i8 (
	const h5part_int64_t *f,
	const char *name,
	const h5part_int64_t *data,
	const int l_name ) {

	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	char *name2 = _H5Part_strdupfor2c ( name, l_name );
gsell's avatar
gsell committed
538

gsell's avatar
gsell committed
539 540
	h5part_int64_t herr = H5PartWriteDataInt64 (
		filehandle, name2, data );
gsell's avatar
gsell committed
541

gsell's avatar
gsell committed
542
	free ( name2 );
gsell's avatar
gsell committed
543

gsell's avatar
gsell committed
544
	return herr;
gsell's avatar
gsell committed
545 546
}

547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
h5part_int64_t
h5pt_writedata_i4 (
	const h5part_int64_t *f,
	const char *name,
	const h5part_int32_t *data,
	const int l_name ) {

	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	char *name2 = _H5Part_strdupfor2c ( name, l_name );

	h5part_int64_t herr = H5PartWriteDataInt32 (
		filehandle, name2, data );

	free ( name2 );

	return herr;
}

gsell's avatar
gsell committed
566 567 568
/*==============Reading Data Characteristics============*/

h5part_int64_t
gsell's avatar
gsell committed
569 570
h5pt_getnsteps (
	const h5part_int64_t *f
gsell's avatar
gsell committed
571 572
	) {

gsell's avatar
gsell committed
573 574 575
	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	return H5PartGetNumSteps ( filehandle );
gsell's avatar
gsell committed
576 577 578
}

h5part_int64_t
gsell's avatar
gsell committed
579 580
h5pt_getndatasets (
	const h5part_int64_t *f
gsell's avatar
gsell committed
581
	) {
gsell's avatar
gsell committed
582 583 584 585

	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	return H5PartGetNumDatasets ( filehandle );
gsell's avatar
gsell committed
586 587 588
}

h5part_int64_t
gsell's avatar
gsell committed
589 590
h5pt_getnpoints (
	const h5part_int64_t *f
gsell's avatar
gsell committed
591
	) {
gsell's avatar
gsell committed
592 593 594 595

	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	return H5PartGetNumParticles ( filehandle );
gsell's avatar
gsell committed
596 597 598
}

h5part_int64_t
gsell's avatar
gsell committed
599 600 601
h5pt_getdatasetname ( 
	const h5part_int64_t *f,
	const h5part_int64_t *index,
gsell's avatar
gsell committed
602
	char *name,
gsell's avatar
gsell committed
603 604 605 606
	const int l_name
	) {

	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
gsell's avatar
gsell committed
607

gsell's avatar
gsell committed
608 609 610 611 612
	h5part_int64_t herr =  H5PartGetDatasetName (
		filehandle, *index, name, l_name );

	_H5Part_strc2for ( name, l_name );
	return herr;
gsell's avatar
gsell committed
613 614
}

615 616
/*=============Setting and getting views================*/

gsell's avatar
gsell committed
617
h5part_int64_t
618 619 620 621
h5pt_setview (
	const h5part_int64_t *f,
	const h5part_int64_t *start,
	const h5part_int64_t *end
gsell's avatar
gsell committed
622 623 624
	) {

	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
gsell's avatar
gsell committed
625

626
	return H5PartSetView ( filehandle, *start, *end );
gsell's avatar
gsell committed
627 628 629
}

h5part_int64_t
630
h5pt_setview_indices (
gsell's avatar
gsell committed
631
	const h5part_int64_t *f,
632 633
	const h5part_int64_t *indices,
	const h5part_int64_t *nelem
gsell's avatar
gsell committed
634
	) {
gsell's avatar
gsell committed
635

gsell's avatar
gsell committed
636 637
	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

638
	return H5PartSetViewIndices ( filehandle, indices, *nelem );
gsell's avatar
gsell committed
639 640 641
}

h5part_int64_t
gsell's avatar
gsell committed
642 643
h5pt_resetview (
	const h5part_int64_t *f
gsell's avatar
gsell committed
644 645
	) {

gsell's avatar
gsell committed
646 647 648
	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	return H5PartResetView ( filehandle );
gsell's avatar
gsell committed
649 650 651
}

h5part_int64_t
gsell's avatar
gsell committed
652 653
h5pt_hasview (
	const h5part_int64_t *f
gsell's avatar
gsell committed
654 655
	) {

gsell's avatar
gsell committed
656 657 658
	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	return H5PartHasView ( filehandle );
gsell's avatar
gsell committed
659 660 661
}

h5part_int64_t
gsell's avatar
gsell committed
662 663
h5pt_getview (
	const h5part_int64_t *f,
gsell's avatar
gsell committed
664 665 666 667
	h5part_int64_t *start,
	h5part_int64_t *end
	) {

gsell's avatar
gsell committed
668 669 670
	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	return H5PartGetView ( filehandle, start, end);
gsell's avatar
gsell committed
671 672 673
}
/*==================Reading data ============*/
h5part_int64_t
gsell's avatar
gsell committed
674 675 676
h5pt_readdata_r8 (
	const h5part_int64_t *f,
	const char *name,
gsell's avatar
gsell committed
677
	h5part_float64_t *array,
gsell's avatar
gsell committed
678
	const int l_name
gsell's avatar
gsell committed
679 680
	) {

gsell's avatar
gsell committed
681 682 683 684 685 686 687 688 689
	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	char *name2 = _H5Part_strdupfor2c ( name, l_name );

	h5part_int64_t herr = H5PartReadDataFloat64 (
		filehandle, name2, array );

	free ( name2 );
	return herr;
gsell's avatar
gsell committed
690
}
gsell's avatar
gsell committed
691

692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710
h5part_int64_t
h5pt_readdata_r4 (
	const h5part_int64_t *f,
	const char *name,
	h5part_float32_t *array,
	const int l_name
	) {

	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	char *name2 = _H5Part_strdupfor2c ( name, l_name );

	h5part_int64_t herr = H5PartReadDataFloat32 (
		filehandle, name2, array );

	free ( name2 );
	return herr;
}

gsell's avatar
gsell committed
711
h5part_int64_t
gsell's avatar
gsell committed
712 713 714
h5pt_readdata_i8 (
	const h5part_int64_t *f,
	const char *name,
gsell's avatar
gsell committed
715
	h5part_int64_t *array,
gsell's avatar
gsell committed
716 717 718 719 720 721
	const int l_name
	) {

	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	char *name2 = _H5Part_strdupfor2c ( name, l_name );
gsell's avatar
gsell committed
722

gsell's avatar
gsell committed
723 724 725 726 727
	h5part_int64_t herr = H5PartReadDataInt64 (
		filehandle, name2, array );

	free ( name2 );
	return herr;
gsell's avatar
gsell committed
728 729
}

730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748
h5part_int64_t
h5pt_readdata_i4 (
	const h5part_int64_t *f,
	const char *name,
	h5part_int32_t *array,
	const int l_name
	) {

	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	char *name2 = _H5Part_strdupfor2c ( name, l_name );

	h5part_int64_t herr = H5PartReadDataInt32 (
		filehandle, name2, array );

	free ( name2 );
	return herr;
}

gsell's avatar
gsell committed
749 750 751
/*=================== Attributes ================*/

h5part_int64_t
gsell's avatar
gsell committed
752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772
h5pt_writefileattrib_string (
	const h5part_int64_t *f,
	const char *attrib_name,
	const char *attrib_value,
	const int l_attrib_name,
	const int l_attrib_value
	) {

	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	char *attrib_name2 = _H5Part_strdupfor2c (attrib_name,l_attrib_name);
	char *attrib_value2= _H5Part_strdupfor2c (attrib_value,l_attrib_value);

	h5part_int64_t herr = H5PartWriteFileAttribString (
		filehandle, attrib_name2, attrib_value2 );

	free ( attrib_name2 );
	free ( attrib_value2 );
	return herr;
}

gsell's avatar
gsell committed
773
h5part_int64_t
gsell's avatar
gsell committed
774 775 776 777 778 779 780
h5pt_writestepattrib_string (
	const h5part_int64_t *f,
	const char *attrib_name,
	const char *attrib_value,
	const int l_attrib_name,
	const int l_attrib_value
	) {
gsell's avatar
gsell committed
781

gsell's avatar
gsell committed
782 783 784 785 786 787 788 789 790 791 792
	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	char *attrib_name2 = _H5Part_strdupfor2c (attrib_name,l_attrib_name);
	char *attrib_value2= _H5Part_strdupfor2c (attrib_value,l_attrib_value);

	h5part_int64_t herr = H5PartWriteStepAttribString (
		filehandle, attrib_name2, attrib_value2 );

	free ( attrib_name2 );
	free ( attrib_value2 );
	return herr;
gsell's avatar
gsell committed
793 794
}

gsell's avatar
gsell committed
795 796
/* Reading attributes ************************* */

gsell's avatar
gsell committed
797
h5part_int64_t
gsell's avatar
gsell committed
798 799
h5pt_getnstepattribs (
	const h5part_int64_t *f
gsell's avatar
gsell committed
800 801
	) {

gsell's avatar
gsell committed
802 803 804
	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	return H5PartGetNumStepAttribs ( filehandle );
gsell's avatar
gsell committed
805 806 807
}

h5part_int64_t
gsell's avatar
gsell committed
808 809
h5pt_getnfileattribs (
	const h5part_int64_t *f
gsell's avatar
gsell committed
810 811
	) {

gsell's avatar
gsell committed
812 813 814
	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	return H5PartGetNumFileAttribs ( filehandle );
gsell's avatar
gsell committed
815 816 817
}

h5part_int64_t
gsell's avatar
gsell committed
818 819 820
h5pt_getstepattribinfo (
	const h5part_int64_t *f,
	const h5part_int64_t *idx,
gsell's avatar
gsell committed
821 822
	char *name,
	h5part_int64_t *nelem,
gsell's avatar
gsell committed
823
	const int l_name
gsell's avatar
gsell committed
824 825
	) {

gsell's avatar
gsell committed
826
	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
gsell's avatar
gsell committed
827
	h5part_int64_t type;
gsell's avatar
gsell committed
828 829 830 831 832 833

	h5part_int64_t herr = H5PartGetStepAttribInfo ( 
		filehandle, *idx, name, l_name, &type, nelem);

	_H5Part_strc2for( name, l_name );
	return herr;
gsell's avatar
gsell committed
834 835 836
}

h5part_int64_t
gsell's avatar
gsell committed
837 838 839
h5pt_getfileattribinfo (
	const h5part_int64_t *f,
	const h5part_int64_t *idx,
gsell's avatar
gsell committed
840 841
	char *name,
	h5part_int64_t *nelem,
gsell's avatar
gsell committed
842
	const int l_name ) {
gsell's avatar
gsell committed
843

gsell's avatar
gsell committed
844
	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
gsell's avatar
gsell committed
845
	h5part_int64_t type;
gsell's avatar
gsell committed
846 847 848 849 850 851

	h5part_int64_t herr = H5PartGetFileAttribInfo ( 
		filehandle, *idx, name, l_name, &type, nelem);

	_H5Part_strc2for( name, l_name );
	return herr;
gsell's avatar
gsell committed
852 853
}

gsell's avatar
gsell committed
854 855 856 857 858 859 860 861 862 863 864 865 866
h5part_int64_t
h5pt_readstepattrib_string (
	const h5part_int64_t *f,
	const char *attrib_name,
	char *attrib_value,
	const int l_attrib_name,
	const int l_attrib_value
	) {

	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
	
	char * attrib_name2 = _H5Part_strdupfor2c (attrib_name,l_attrib_name);

867
	h5part_int64_t herr = H5PartReadStepAttrib (
gsell's avatar
gsell committed
868 869
		filehandle, attrib_name2, attrib_value );

870 871
	_H5Part_strc2for ( attrib_value, l_attrib_value );

gsell's avatar
gsell committed
872 873 874 875 876 877 878 879 880 881 882 883
	free ( attrib_name2 );
	return herr;
}

h5part_int64_t
h5pt_readfileattrib_string (
	const h5part_int64_t *f,
	const char *attrib_name,
	char *attrib_value,
	const int l_attrib_name,
	const int l_attrib_value
	) {
884 885 886 887 888 889 890
		
	H5PartFile *filehandle = (H5PartFile*)(size_t)*f;

	char * attrib_name2 = _H5Part_strdupfor2c (attrib_name,l_attrib_name);

	h5part_int64_t herr = H5PartReadFileAttrib (
		filehandle, attrib_name2, attrib_value );
gsell's avatar
gsell committed
891 892

	_H5Part_strc2for ( attrib_value, l_attrib_value );
893 894

	free ( attrib_name2 );
gsell's avatar
gsell committed
895
	return herr;
gsell's avatar
gsell committed
896
}
gsell's avatar
gsell committed
897 898

h5part_int64_t
gsell's avatar
gsell committed
899
h5pt_set_verbosity_level (
gsell's avatar
gsell committed
900
	const h5part_int64_t *level
gsell's avatar
gsell committed
901
	) {
gsell's avatar
gsell committed
902
	return H5PartSetVerbosityLevel ( *level );
gsell's avatar
gsell committed
903
}