repo migration
This commit is contained in:
+1150
File diff suppressed because it is too large
Load Diff
+285
@@ -0,0 +1,285 @@
|
||||
#ifndef __H5BLOCK_H
|
||||
#define __H5BLOCK_H
|
||||
|
||||
/*!
|
||||
Interface for block structured field data
|
||||
|
||||
This is used to store and retrieve scalar or vector valued field data.
|
||||
With \f$ \Omega\ \f$ ....
|
||||
|
||||
Basic items are blocks (\f$ \Omaga_i \f$ ), cartesian subdomains of
|
||||
\f$ \Omega \f$ . If a \f$ \Omega_i \f$ is refined we view this
|
||||
\f$ \Omaga_i \f$ as a patch.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
Define the field layout (FL) given the dense index space at the actual
|
||||
time step.
|
||||
|
||||
\return \c H5PART_SUCCESS or error code
|
||||
|
||||
\note
|
||||
This defines \f$ \Omega \f$ and the view for HDF5
|
||||
*/
|
||||
h5part_int64_t
|
||||
H5BlockDefine3DFieldLayout (
|
||||
H5PartFile *f, /*!< file handle */
|
||||
const h5part_int64_t i_start, /*!< start index of i */
|
||||
const h5part_int64_t i_end, /*!< end index of i */
|
||||
const h5part_int64_t j_start, /*!< start index of j */
|
||||
const h5part_int64_t j_end, /*!< end index of j */
|
||||
const h5part_int64_t k_start, /*!< start index of k */
|
||||
const h5part_int64_t k_end /*!< end index of k */
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5Block3dWriteScalarField (
|
||||
H5PartFile *f,
|
||||
const char *name,
|
||||
const h5part_float64_t *data
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5Block3dReadScalarField (
|
||||
H5PartFile *f,
|
||||
const char *name,
|
||||
h5part_float64_t *data
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5BlockGetNumFields (
|
||||
H5PartFile *f
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5BlockGetFieldInfo (
|
||||
H5PartFile *f,
|
||||
const h5part_int64_t idx,
|
||||
char *name,
|
||||
const h5part_int64_t len_name,
|
||||
h5part_int64_t *grid_rank,
|
||||
h5part_int64_t *grid_dims,
|
||||
h5part_int64_t *field_dims
|
||||
);
|
||||
|
||||
/*!
|
||||
Write a 3D real valued vector field using the defined FL for this block
|
||||
|
||||
\return \c H5PART_SUCCESS or error code
|
||||
|
||||
\note we have to make a 1D and 2D version
|
||||
|
||||
\note Q: what about a dimension independent version?
|
||||
|
||||
*/
|
||||
h5part_int64_t
|
||||
H5Block3dWrite3dVectorField (
|
||||
H5PartFile *f, /*!< file handle */
|
||||
const char *name, /*!< name of the data set */
|
||||
const h5part_float64_t *xval, /*!< array of x component data */
|
||||
const h5part_float64_t *yval, /*!< array of y component data */
|
||||
const h5part_float64_t *zval /*!< array of z component data */
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5Block3dRead3dVectorField (
|
||||
H5PartFile *f, /*!< file handle */
|
||||
const char *name, /*!< name of the data set */
|
||||
h5part_float64_t *xval, /*!< array of x component data */
|
||||
h5part_float64_t *yval, /*!< array of y component data */
|
||||
h5part_float64_t *zval /*!< array of z component data */
|
||||
);
|
||||
|
||||
|
||||
|
||||
h5part_int64_t
|
||||
H5BlockWriteFieldAttrib (
|
||||
H5PartFile *f,
|
||||
const char *field_name,
|
||||
const char *attrib_name,
|
||||
const h5part_int64_t attrib_type,
|
||||
const void *attrib_value,
|
||||
const h5part_int64_t attrib_nelem
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5BlockWriteFieldAttribString (
|
||||
H5PartFile *f,
|
||||
const char *field_name,
|
||||
const char *attrib_name,
|
||||
const char *attrib_value
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5BlockGetNumFieldAttribs (
|
||||
H5PartFile *f,
|
||||
const char *field_name
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5BlockGetFieldAttribInfo (
|
||||
H5PartFile *f,
|
||||
const char *field_name,
|
||||
const h5part_int64_t attrib_idx,
|
||||
char *attrib_name,
|
||||
const h5part_int64_t len_of_attrib_name,
|
||||
h5part_int64_t *attrib_type,
|
||||
h5part_int64_t *attrib_nelem
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartReadFieldAttrib (
|
||||
H5PartFile *f,
|
||||
const char *field_name,
|
||||
const char *attrib_name,
|
||||
void *attrib_value
|
||||
);
|
||||
|
||||
/*!
|
||||
Checks if the block of the actual time step is refined i.e. if we
|
||||
have a patch
|
||||
|
||||
\return \c 1 if we have a patch, otherwise \c 0
|
||||
*/
|
||||
h5part_int64_t
|
||||
H5BlockIsPatch (
|
||||
H5PartFile *f, /*!< file handle */
|
||||
const char *name /*!< name of the data set */
|
||||
);
|
||||
|
||||
/*!
|
||||
return the maximum level refinement of refinement at the current
|
||||
time step
|
||||
|
||||
\return number or error code
|
||||
*/
|
||||
h5part_int64_t
|
||||
H5BlockGetMaxRefinementLevel (
|
||||
H5PartFile *f, /*!< file handle */
|
||||
const char *name /*!< name of the data set */
|
||||
);
|
||||
|
||||
/*!
|
||||
Write the mesh spacing for the active (current) block
|
||||
|
||||
\return \c H5PART_SUCCESS or error code
|
||||
*/
|
||||
h5part_int64_t
|
||||
H5BlockSetMeshSpacing (
|
||||
H5PartFile *f, /*!< file handle */
|
||||
char *name, /*!< name of the data set */
|
||||
h5part_float64_t dx, /*!< mesh spacing in x */
|
||||
h5part_float64_t dy, /*!< mesh spacing in y */
|
||||
h5part_float64_t dz /*!< mesh spacing in z */
|
||||
);
|
||||
|
||||
/*==========================================================================*/
|
||||
/*
|
||||
The following reflects the fact that we have fields which are decomposed
|
||||
into modes.
|
||||
|
||||
Augment the field name with the mode number and use this name to store
|
||||
the field. For the mode freqency use the same procedure.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Read the number of stored modes at actual timestep
|
||||
|
||||
\return \c H5PART_SUCCESS or error code
|
||||
*/
|
||||
h5part_int64_t
|
||||
H5BlockGetNumberOfModes (
|
||||
H5PartFile *f, /*!< file handle */
|
||||
char *name /*!< name of the data set */
|
||||
);
|
||||
|
||||
/*!
|
||||
Set the number of stored modes at actual timestep
|
||||
|
||||
\return \c H5PART_SUCCESS or error code
|
||||
*/
|
||||
h5part_int64_t
|
||||
H5BlockSetNumberOfModes (
|
||||
H5PartFile *f, /*!< file handle */
|
||||
char *name, /*!< name of the data set */
|
||||
int modes /*!< the number of modes */
|
||||
);
|
||||
|
||||
/*!
|
||||
Write a 3D real valued vector field using the defined FL for this block
|
||||
|
||||
\return \c H5PART_SUCCESS or error code
|
||||
|
||||
\note we have to make a 1D and 2D version
|
||||
|
||||
\note Q: what about a dimension independent version?
|
||||
|
||||
\note We need another name for this function!
|
||||
*/
|
||||
h5part_int64_t
|
||||
H5BlockWrite3DVField_ (
|
||||
H5PartFile *f, /*!< file handle */
|
||||
char *name, /*!< name of the data set */
|
||||
int modeNumber, /*!< the mode number of the field */
|
||||
h5part_float64_t omega, /*!< the eigenmode of the field */
|
||||
h5part_float64_t *xval, /*!< array of x component data */
|
||||
h5part_float64_t *yval, /*!< array of y component data */
|
||||
h5part_float64_t *zval /*!< array of z component data */
|
||||
);
|
||||
|
||||
/*!
|
||||
Write the quality factor for a given mode
|
||||
|
||||
\return \c H5PART_SUCCESS or error code
|
||||
*/
|
||||
h5part_int64_t
|
||||
H5BlockSetQFactor (
|
||||
H5PartFile *f, /*!< file handle */
|
||||
char *name, /*!< name of the data set */
|
||||
int mode, /*!< the mode number of the field */
|
||||
h5part_float64_t Q /*!< the quality factor */
|
||||
);
|
||||
|
||||
/*!
|
||||
Write the S-parameters for a given mode
|
||||
|
||||
\return \c H5PART_SUCCESS or error code
|
||||
*/
|
||||
h5part_int64_t
|
||||
H5BlockSetSParams (
|
||||
H5PartFile *f, /*!< file handle */
|
||||
char *name, /*!< name of the data set */
|
||||
int mode, /*!< the mode number of the field */
|
||||
h5part_float64_t **s /*!< S-parameters */
|
||||
);
|
||||
|
||||
/*!
|
||||
Read the quality factor for a given mode
|
||||
|
||||
\return \c H5PART_SUCCESS or error code
|
||||
*/
|
||||
h5part_int64_t
|
||||
H5BlockGetQFactor (
|
||||
H5PartFile *f, /*!< file handle */
|
||||
char *name, /*!< name of the data set */
|
||||
int mode, /*!< the mode number of the field */
|
||||
h5part_float64_t *Q /*!< the quality factor */
|
||||
);
|
||||
|
||||
/*!
|
||||
Read the S-parameters for a given mode
|
||||
|
||||
\return \c H5PART_SUCCESS or error code
|
||||
*/
|
||||
h5part_int64_t
|
||||
H5BlockGetSParams (
|
||||
H5PartFile *f, /*!< file handle */
|
||||
char *name, /*!< name of the data set */
|
||||
int mode, /*!< the mode number of the field */
|
||||
h5part_float64_t **s /*!< S-parameters */
|
||||
);
|
||||
|
||||
#endif // H5BLOCK_H
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef __H5BLOCKERRORS_H
|
||||
#define __H5BLOCKERRORS_H
|
||||
|
||||
#define _err_handler H5PartGetErrorHandler()
|
||||
|
||||
#define HANDLE_H5PART_LAYOUT_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_LAYOUT, \
|
||||
"Bad layout." );
|
||||
|
||||
#define HANDLE_H5PART_NOENT_ERR( name ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_NOENT, \
|
||||
"Object \"%s\" doesn't exists.", name );
|
||||
|
||||
#define HANDLE_H5PART_DATASET_RANK_ERR( m, n ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_INVAL, \
|
||||
"Wrong rank of dataset: Is %d, but should be %d", \
|
||||
m, n );
|
||||
|
||||
#define HANDLE_H5PART_GROUP_EXISTS_ERR( name ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_INVAL, \
|
||||
"Group \"%s\" already exists", name )
|
||||
#define HANDLE_H5S_CREATE_SIMPLE_3D_ERR( dims ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot create 3d dataspace with dimension sizes " \
|
||||
"\"(%lld,%lld,%lld)\".", \
|
||||
(long long)dims[0], (long long)dims[1], (long long)dims[2] );
|
||||
|
||||
#define HANDLE_H5S_GET_SIMPLE_EXTENT_DIMS_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot get dimension sizes of dataset" );
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
INTERFACE
|
||||
INTEGER*8 FUNCTION h5bl_define_3d_layout ( filehandle, i_start, i_end, j_start, j_end, k_start, k_end )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
INTEGER*8, INTENT(IN) :: i_start
|
||||
INTEGER*8, INTENT(IN) :: i_end
|
||||
INTEGER*8, INTENT(IN) :: j_start
|
||||
INTEGER*8, INTENT(IN) :: j_end
|
||||
INTEGER*8, INTENT(IN) :: k_start
|
||||
INTEGER*8, INTENT(IN) :: k_end
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5bl_3d_read_scalar ( filehandle, name, data )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: name
|
||||
INTEGER*8, INTENT(OUT) :: data(:,:,:)
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5bl_3d_read_3dvector ( filehandle, name, x, y, z )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: name
|
||||
INTEGER*8, INTENT(OUT) :: x(:,:,:)
|
||||
INTEGER*8, INTENT(OUT) :: y(:,:,:)
|
||||
INTEGER*8, INTENT(OUT) :: z(:,:,:)
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5bl_3d_write_scalar ( filehandle, name, data )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: name
|
||||
INTEGER*8, INTENT(IN) :: data(:,:,:)
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5bl_3d_write_3dvector ( filehandle, name, x, y, z )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: name
|
||||
INTEGER*8, INTENT(IN) :: x(:,:,:)
|
||||
INTEGER*8, INTENT(IN) :: y(:,:,:)
|
||||
INTEGER*8, INTENT(IN) :: z(:,:,:)
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5bl_getnumfields ( filehandle )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5bl_getfieldinfo ( filehandle, idx, field_name, len_field_name, grid_rank, grid_dims, field_dims )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
INTEGER*8, INTENT(IN) :: idx,
|
||||
CHARACTER(LEN=*), INTENT(OUT) :: field_name
|
||||
INTEGER*8, INTENT(IN) :: len_field_name
|
||||
INTEGER*8, INTENT(OUT) :: grid_rank
|
||||
INTEGER*8, INTENT(OUT) :: grid_dims(:)
|
||||
INTEGER*8, INTENT(OUT) :: field_dims
|
||||
END FUNCTION
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
#ifndef __H5BLOCKPRIVATE_H
|
||||
#define __H5BLOCKPRIVATE_H
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef __H5BLOCKTYPES_H
|
||||
#define __H5BLOCKTYPES_H
|
||||
|
||||
struct H5BlockPartition {
|
||||
h5part_int64_t i_start;
|
||||
h5part_int64_t i_end;
|
||||
h5part_int64_t j_start;
|
||||
h5part_int64_t j_end;
|
||||
h5part_int64_t k_start;
|
||||
h5part_int64_t k_end;
|
||||
};
|
||||
|
||||
struct H5BlockStruct {
|
||||
h5part_int64_t timestep;
|
||||
h5part_int64_t i_max;
|
||||
h5part_int64_t j_max;
|
||||
h5part_int64_t k_max;
|
||||
struct H5BlockPartition *user_layout;
|
||||
struct H5BlockPartition *write_layout;
|
||||
|
||||
hid_t shape;
|
||||
hid_t memshape;
|
||||
hid_t diskshape;
|
||||
hid_t blockgroup;
|
||||
hid_t field_group_id;
|
||||
};
|
||||
|
||||
#define H5PART_ERR_LAYOUT -100
|
||||
#define H5PART_ERR_NOENT -101
|
||||
|
||||
#endif
|
||||
Executable
+234
@@ -0,0 +1,234 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <hdf5.h>
|
||||
#include "H5Part++.hh"
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
#ifdef READTEST
|
||||
|
||||
/*
|
||||
A simple regression test that shows how you use this API
|
||||
to write and read multi-timestep files of particle data.
|
||||
*/
|
||||
#ifdef PARALLEL_IO
|
||||
|
||||
|
||||
#else
|
||||
|
||||
int main(int argc,char **argv){
|
||||
const int sz=5;
|
||||
double x[sz],y[sz],z[sz];
|
||||
long long id[sz];
|
||||
char name[64];
|
||||
H5PartFile *file;
|
||||
int i,t,nt,nds,myproc;
|
||||
int nfattribs,nsattribs;
|
||||
|
||||
const string fn = string(argv[1]);
|
||||
|
||||
cout << "Open " << fn << endl;
|
||||
|
||||
|
||||
file= H5PartOpenFile(fn.c_str(),H5PART_READ);
|
||||
nt=H5PartGetNumSteps(file); /* get number of steps in file */
|
||||
H5PartSetStep(file,0);
|
||||
nds=H5PartGetNumDatasets(file); /* get number of datasets in timestep 0 */
|
||||
|
||||
|
||||
|
||||
puts("\n\n===============================");
|
||||
for(i=0;i<nds;i++){ /* and print out those names */
|
||||
H5PartGetDatasetName(file,i,name,64);
|
||||
printf("\tDataset[%u] name=[%s]\n",
|
||||
i,name);
|
||||
}
|
||||
puts("===============================\n\n");
|
||||
|
||||
nfattribs=H5PartGetNumFileAttribs(file);
|
||||
printf("Number of datasteps in file is %u num file attribs=%d\n",
|
||||
nt,nfattribs);
|
||||
|
||||
H5PartCloseFile(file);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef REGRESSIONTEST
|
||||
|
||||
/*
|
||||
A simple regression test that shows how you use this API
|
||||
to write and read multi-timestep files of particle data.
|
||||
*/
|
||||
#ifdef PARALLEL_IO
|
||||
|
||||
int main(int argc,char *argv[]){
|
||||
int sz=5;
|
||||
double *x,*y,*z;
|
||||
long long *id;
|
||||
char name[64];
|
||||
H5PartFile *file;
|
||||
int i,t,nt,nds;
|
||||
int nprocs,myproc;
|
||||
hid_t gid;
|
||||
MPI_Comm comm=MPI_COMM_WORLD;
|
||||
|
||||
MPI_Init(&argc,&argv);
|
||||
MPI_Comm_size(comm,&nprocs);
|
||||
MPI_Comm_rank(comm,&myproc);
|
||||
|
||||
x=(double*)malloc(sz*nprocs*sizeof(double));
|
||||
y=(double*)malloc(sz*nprocs*sizeof(double));
|
||||
z=(double*)malloc(sz*nprocs*sizeof(double));
|
||||
id=(long long*)malloc(sz*nprocs*sizeof(long long));
|
||||
/* parallel file creation */
|
||||
file=H5PartOpenFileParallel("parttest.h5",H5PART_WRITE,comm);
|
||||
if(!file) {
|
||||
perror("File open failed: exiting!");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for(t=0;t<5;t++){
|
||||
MPI_Barrier(comm);
|
||||
for(i=0;i<sz;i++) {
|
||||
x[i]=(double)(i+t)+10.0*(double)myproc;
|
||||
y[i]=0.1 + (double)(i+t);
|
||||
z[i]=0.2 + (double)(i+t*10);
|
||||
id[i]=i+sz*myproc;
|
||||
}
|
||||
printf("Proc[%u] Writing timestep %u file=%u\n",myproc,t,file->file);
|
||||
H5PartSetStep(file,t); /* must set the current timestep in file */
|
||||
H5PartSetNumParticles(file,sz); /* then set number of particles to store */
|
||||
/* now write different tuples of data into this timestep of the file */
|
||||
H5PartWriteDataFloat64(file,"x",x);
|
||||
H5PartWriteDataFloat64(file,"y",y);
|
||||
H5PartWriteDataFloat64(file,"z",z);
|
||||
H5PartWriteDataInt64(file,"id",id);
|
||||
}
|
||||
printf("AllDone p[%u]\n",myproc);
|
||||
H5PartCloseFile(file);
|
||||
MPI_Barrier(comm);
|
||||
printf("p[%u:%u] : OK, close file and reopen for reading \n",myproc,nprocs);
|
||||
if(myproc==0){ /* now only proc 0 reads the file serially */
|
||||
file= H5PartOpenFileSerial("parttest.h5",H5PART_READ);
|
||||
nt=H5PartGetNumSteps(file); /* get number of steps in file */
|
||||
H5PartSetStep(file,0);
|
||||
nds=H5PartGetNumDatasets(file); /* get number of datasets in timestep 0 */
|
||||
|
||||
puts("\n\n===============================");
|
||||
for(i=0;i<nds;i++){ /* and print out those names */
|
||||
H5PartGetDatasetName(file,i,name,64);
|
||||
printf("\tDataset[%u] name=[%s]\n",
|
||||
i,name);
|
||||
}
|
||||
puts("===============================\n\n");
|
||||
printf("Number of datasteps in file is %u\n",nt);
|
||||
for(t=0;t<nt;t++){
|
||||
int nparticles;
|
||||
H5PartSetStep(file,t); /* select a timestep */
|
||||
nparticles=(int)H5PartGetNumParticles(file);
|
||||
printf("Step[%u] nparticles this step=%u\n",
|
||||
t,nparticles); /* get num particles this step *
|
||||
H5PartReadParticleStep(file,t,/* do a mongo read of all data this step */
|
||||
x,y,z,id);
|
||||
printf("\tid\t\tx\t\ty\t\tz\n");
|
||||
puts("\t----------------------------------------------------");
|
||||
for(i=0;i<nparticles;i++) {
|
||||
printf("\t%llu\t%f\t%f\t%f\n\n",id[i],x[i],y[i],z[i]);
|
||||
}
|
||||
}
|
||||
H5PartCloseFile(file);
|
||||
}
|
||||
if(x) free(x);
|
||||
if(y) free(y);
|
||||
if(z) free(z);
|
||||
if(id) free(id);
|
||||
MPI_Barrier(comm);
|
||||
fprintf(stderr,"proc[%u]: done\n",myproc);
|
||||
return MPI_Finalize();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main(int argc,char *argv){
|
||||
const int sz=5;
|
||||
double x[sz],y[sz],z[sz];
|
||||
long long id[sz];
|
||||
char name[64];
|
||||
H5PartFile *file;
|
||||
int i,t,nt,nds,myproc;
|
||||
int nfattribs,nsattribs;
|
||||
|
||||
file=H5PartOpenFile("parttest.h5",H5PART_WRITE);
|
||||
if(!file) {
|
||||
perror("File open failed: exiting!");
|
||||
exit(0);
|
||||
}
|
||||
for(t=0;t<5;t++){
|
||||
long long step=t;
|
||||
printf("Writing timestep %u\n",t);
|
||||
for(i=0;i<sz;i++) {
|
||||
x[i]=(double)(i+t);
|
||||
y[i]=0.1 + (double)(i+t);
|
||||
z[i]=0.2 + (double)(i+t);
|
||||
id[i]=i;
|
||||
}
|
||||
H5PartSetStep(file,t); /* must set the current timestep in file */
|
||||
H5PartSetNumParticles(file,sz); /* then set number of particles to store */
|
||||
/* now write different tuples of data into this timestep of the file */
|
||||
H5PartWriteDataFloat64(file,"x",x);
|
||||
H5PartWriteDataFloat64(file,"y",y);
|
||||
H5PartWriteDataFloat64(file,"z",z);
|
||||
H5PartWriteDataInt64(file,"id",id);
|
||||
H5PartWriteStepAttrib(file,"Step",H5T_NATIVE_INT64,&step,1);
|
||||
}
|
||||
H5PartCloseFile(file);
|
||||
printf("OK, close file and reopen for reading\n");
|
||||
file= H5PartOpenFile("parttest.h5",H5PART_READ);
|
||||
nt=H5PartGetNumSteps(file); /* get number of steps in file */
|
||||
H5PartSetStep(file,0);
|
||||
nds=H5PartGetNumDatasets(file); /* get number of datasets in timestep 0 */
|
||||
|
||||
puts("\n\n===============================");
|
||||
for(i=0;i<nds;i++){ /* and print out those names */
|
||||
H5PartGetDatasetName(file,i,name,64);
|
||||
printf("\tDataset[%u] name=[%s]\n",
|
||||
i,name);
|
||||
}
|
||||
puts("===============================\n\n");
|
||||
|
||||
nfattribs=H5PartGetNumFileAttribs(file);
|
||||
printf("Number of datasteps in file is %u num file attribs=%d\n",
|
||||
nt,nfattribs);
|
||||
for(t=0;t<nt;t++){
|
||||
int nparticles;
|
||||
H5PartSetStep(file,t); /* select a timestep */
|
||||
nparticles=(int)H5PartGetNumParticles(file);
|
||||
nsattribs=H5PartGetNumStepAttribs(file);
|
||||
printf("Step[%u] nparticles this step=%u stepattribs=%u\n",
|
||||
t,nparticles,nsattribs); /* get num particles this step */
|
||||
if(nsattribs>0){
|
||||
char attrname[32];
|
||||
H5PartGetStepAttribInfo(file,0,attrname,32,0,0);
|
||||
printf("First Attrib name is [%s]\n",attrname);
|
||||
}
|
||||
H5PartReadParticleStep(file,t,/* do a mongo read of all data this step */
|
||||
x,y,z,id);
|
||||
printf("\tid\t\tx\t\ty\t\tz\n");
|
||||
puts("\t----------------------------------------------------");
|
||||
for(i=0;i<sz;i++) {
|
||||
printf("\t%llu\t%f\t%f\t%f\n\n",id[i],x[i],y[i],z[i]);
|
||||
}
|
||||
}
|
||||
H5PartCloseFile(file);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Executable
+219
@@ -0,0 +1,219 @@
|
||||
#ifndef _H5Part_HH_
|
||||
#define _H5Part_HH_
|
||||
|
||||
extern "C" {
|
||||
#include "H5Part.h"
|
||||
#ifdef PARALLEL_IO
|
||||
#include <mpi.h>
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Add any C++ specific extensions/implementations/wrappers here */
|
||||
|
||||
/* here is a sample class wrapping of H5Part for C++ usage */
|
||||
|
||||
class H5ParticleFile {
|
||||
H5PartFile *file;
|
||||
long long np;
|
||||
public:
|
||||
H5ParticleFile(const char *filename,const int flags):np(0){
|
||||
this->file=H5PartOpenFile(filename,flags);
|
||||
}
|
||||
|
||||
// H5ParticleFile(const std::string fn,const int flags):np(0){
|
||||
// this->file=H5PartOpenFile(fn.cstr(),flags);
|
||||
//}
|
||||
|
||||
#ifdef PARALLEL_IO
|
||||
H5ParticleFile(const char *filename,const int flags,const MPI_Comm comm):np(0){
|
||||
this->file=H5PartOpenFileParallel(filename,flags,comm);
|
||||
}
|
||||
// H5ParticleFile(const string fn,const int flags,const MPI_Comm comm):np(0){
|
||||
// this->file=H5PartOpenFile(fn.cstr(),flags,comm);
|
||||
//}
|
||||
#endif
|
||||
inline int isValid() { return H5PartFileIsValid(this->file);}
|
||||
|
||||
~H5ParticleFile(){H5PartCloseFile(this->file);}
|
||||
|
||||
inline void setNumParticles(long long nparticles){
|
||||
np=nparticles;
|
||||
H5PartSetNumParticles(file,nparticles);
|
||||
}
|
||||
// get the current step (-1 means step is invalid)
|
||||
inline int step(){ return file->timestep; }
|
||||
// set the current step
|
||||
inline int step(int s){ H5PartSetStep(this->file,s); return file->timestep; }
|
||||
inline int nSteps(){ return H5PartGetNumSteps(this->file);}
|
||||
inline int nFields(){ return H5PartGetNumDatasets(file);}
|
||||
inline int fieldName(int index,char *name,int maxlen){H5PartGetDatasetName(file,index,name,maxlen);}
|
||||
inline long long nParticles(){return H5PartGetNumParticles(file);}
|
||||
inline int write(char *name,double *array){
|
||||
return H5PartWriteDataFloat64(this->file,name,array);
|
||||
}
|
||||
inline int write(char *name,long long *array){
|
||||
return H5PartWriteDataInt64(this->file,name,array);
|
||||
}
|
||||
inline int read(char *name,double *array){
|
||||
return H5PartReadDataFloat64(this->file,name,array);
|
||||
}
|
||||
inline int read(char *name,long long *array){
|
||||
return H5PartReadDataInt64(this->file,name,array);
|
||||
}
|
||||
inline int readStep(int step,
|
||||
double *x,double *y,double *z,
|
||||
double *px,double *py,double *pz,
|
||||
long long *id){
|
||||
return H5PartReadParticleStep(file,step,
|
||||
x,y,z,
|
||||
px,py,pz,
|
||||
id);
|
||||
}
|
||||
|
||||
// Attribute stuff
|
||||
// Info on attributes
|
||||
inline int nStepAttribs(){ return H5PartGetNumStepAttribs(file);}
|
||||
inline void getStepAttribInfo(int idx,char *name,size_t maxsize,
|
||||
hid_t &type,int &nelem){
|
||||
H5PartGetStepAttribInfo(file,idx,name,maxsize,&type,&nelem);
|
||||
}
|
||||
inline int nFileAttribs(){ return H5PartGetNumFileAttribs(file);}
|
||||
inline void getFileAttribInfo(int idx,char *name,size_t maxsize,
|
||||
hid_t &type,int &nelem){
|
||||
H5PartGetFileAttribInfo(file,idx,name,maxsize,&type,&nelem);
|
||||
}
|
||||
// step attribs
|
||||
// int writeStepAttrib(char *key,string *valuestring){
|
||||
// return H5PartWriteStepAttribString(file,key,valuestring.c_str());
|
||||
//}
|
||||
inline int writeStepAttrib(char *key,char *valuestring){
|
||||
return H5PartWriteStepAttribString(file,key,valuestring);
|
||||
}
|
||||
inline int writeStepAttrib(char *key,double *value,int nelem=1){
|
||||
return H5PartWriteStepAttrib(file,key,H5T_NATIVE_DOUBLE,value,nelem);
|
||||
}
|
||||
inline int writeStepAttrib(char *key,float *value,int nelem=1){
|
||||
return H5PartWriteStepAttrib(file,key,H5T_NATIVE_FLOAT,value,nelem);}
|
||||
inline int writeStepAttrib(char *key,int *value,int nelem=1){
|
||||
return H5PartWriteStepAttrib(file,key,H5T_NATIVE_INT,value,nelem);}
|
||||
inline int writeStepAttrib(char *key,long long *value,int nelem=1){
|
||||
return H5PartWriteStepAttrib(file,key,H5T_NATIVE_INT64,value,nelem);}
|
||||
inline void readStepAttrib(char *key,void *value){
|
||||
H5PartReadStepAttrib(file,key,value);
|
||||
}
|
||||
// FileAttribs
|
||||
// Attribute stuff
|
||||
// int writeFileAttrib(char *key,string *valuestring){
|
||||
// return H5PartWriteFileAttribString(file,key,valuestring.c_str());
|
||||
//}
|
||||
inline int writeFileAttrib(char *key,char *valuestring){
|
||||
return H5PartWriteFileAttribString(file,key,valuestring);
|
||||
}
|
||||
inline int writeFileAttrib(char *key,double *value,int nelem=1){
|
||||
return H5PartWriteFileAttrib(file,key,H5T_NATIVE_DOUBLE,value,nelem);
|
||||
}
|
||||
inline int writeFileAttrib(char *key,float *value,int nelem=1){
|
||||
return H5PartWriteFileAttrib(file,key,H5T_NATIVE_FLOAT,value,nelem);}
|
||||
inline int writeFileAttrib(char *key,int *value,int nelem=1){
|
||||
return H5PartWriteFileAttrib(file,key,H5T_NATIVE_INT,value,nelem);}
|
||||
inline int writeFileAttrib(char *key,long long *value,int nelem=1){
|
||||
return H5PartWriteFileAttrib(file,key,H5T_NATIVE_INT64,value,nelem);}
|
||||
// read file attribs
|
||||
inline int readFileAttrib(char *key,void *valuestring){
|
||||
H5PartReadFileAttrib(file,key,valuestring);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
An even wackier idea
|
||||
file.datasets[0:ndatasets-1]
|
||||
file.attributes[0:nfileattribs-1]
|
||||
file.datasets.attributes[0:ndatasetattribs-1]
|
||||
file.datasets.size()
|
||||
|
||||
operators
|
||||
.size()
|
||||
.name()
|
||||
[idx]
|
||||
["name" or "keyname"]
|
||||
|
||||
*/
|
||||
#if 0
|
||||
|
||||
class H5Dataset {
|
||||
const hid_t dataset;
|
||||
char *n; // return as const
|
||||
int d[5]; // simple start
|
||||
int nd;
|
||||
public:
|
||||
H5Dataset(const hid_t ds_handle):dataset(ds_handle){}
|
||||
const char *name() {return n;}
|
||||
int nDims(){ return nd; }
|
||||
const int *dims(){return d;}
|
||||
};
|
||||
|
||||
class H5Attribute{
|
||||
char *n;
|
||||
int sz;
|
||||
public:
|
||||
const char *name(){return n;}
|
||||
int size(){return sz;}
|
||||
}
|
||||
|
||||
|
||||
class H5Group {
|
||||
hid_t gid;
|
||||
int sz;
|
||||
protected:
|
||||
virtual int computesize(){}
|
||||
void setGroup(gid_t g){
|
||||
if(gid>0) H5close(gid);
|
||||
gid=g;
|
||||
// must compute size if available
|
||||
if(gid>0) computesize();
|
||||
else sz=0;
|
||||
}
|
||||
public:
|
||||
// const hid_t gid;
|
||||
H5Group(hid_t g):gid(g){}
|
||||
H5Group():gid(-1){}
|
||||
~H5Group(){if(gid>0) H5Gclose(gid);}
|
||||
int size(){return sz;}
|
||||
};
|
||||
|
||||
class H5AttribGroup : public H5Group{
|
||||
int size;
|
||||
virtual void computesize(){
|
||||
// compute the number of items in this group
|
||||
}
|
||||
public:
|
||||
const H5Attribute &operator[](char *name);
|
||||
const H5Attribute &operator[](int idx);
|
||||
};
|
||||
|
||||
class H5DataGroup : public H5Group {
|
||||
int size;
|
||||
public:
|
||||
const H5Dataset &operator[](int idx);
|
||||
const H5Dataset &operator[](char *name);
|
||||
// no name here??
|
||||
};
|
||||
|
||||
class H5FancyParticles {
|
||||
char *n;
|
||||
hid_t file;
|
||||
public:
|
||||
hid_t mygroup;
|
||||
const H5AttribGroup attributes;
|
||||
const H5DataGroup datasets;
|
||||
H5FancyParticles(char *filename,int readwriteflag);
|
||||
~H5FancyParticles();
|
||||
// int size();// return the number of datasets in file
|
||||
// const char *name(); // return the name of the file?
|
||||
// const H5Dataset &operator[](int idx); // index dataset by integer
|
||||
// const H5Dataset &operator[](char *n); // index dataset by name
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+2286
File diff suppressed because it is too large
Load Diff
Executable
+234
@@ -0,0 +1,234 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <hdf5.h>
|
||||
#include "H5Part.hh"
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
#ifdef READTEST
|
||||
|
||||
/*
|
||||
A simple regression test that shows how you use this API
|
||||
to write and read multi-timestep files of particle data.
|
||||
*/
|
||||
#ifdef PARALLEL_IO
|
||||
|
||||
|
||||
#else
|
||||
|
||||
int main(int argc,char **argv){
|
||||
const int sz=5;
|
||||
double x[sz],y[sz],z[sz];
|
||||
long long id[sz];
|
||||
char name[64];
|
||||
H5PartFile *file;
|
||||
int i,t,nt,nds,myproc;
|
||||
int nfattribs,nsattribs;
|
||||
|
||||
const string fn = string(argv[1]);
|
||||
|
||||
cout << "Open " << fn << endl;
|
||||
|
||||
|
||||
file= H5PartOpenFile(fn.c_str(),H5PART_READ);
|
||||
nt=H5PartGetNumSteps(file); /* get number of steps in file */
|
||||
H5PartSetStep(file,0);
|
||||
nds=H5PartGetNumDatasets(file); /* get number of datasets in timestep 0 */
|
||||
|
||||
|
||||
|
||||
puts("\n\n===============================");
|
||||
for(i=0;i<nds;i++){ /* and print out those names */
|
||||
H5PartGetDatasetName(file,i,name,64);
|
||||
printf("\tDataset[%u] name=[%s]\n",
|
||||
i,name);
|
||||
}
|
||||
puts("===============================\n\n");
|
||||
|
||||
nfattribs=H5PartGetNumFileAttribs(file);
|
||||
printf("Number of datasteps in file is %u num file attribs=%d\n",
|
||||
nt,nfattribs);
|
||||
|
||||
H5PartCloseFile(file);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef REGRESSIONTEST
|
||||
|
||||
/*
|
||||
A simple regression test that shows how you use this API
|
||||
to write and read multi-timestep files of particle data.
|
||||
*/
|
||||
#ifdef PARALLEL_IO
|
||||
|
||||
int main(int argc,char *argv[]){
|
||||
int sz=5;
|
||||
double *x,*y,*z;
|
||||
long long *id;
|
||||
char name[64];
|
||||
H5PartFile *file;
|
||||
int i,t,nt,nds;
|
||||
int nprocs,myproc;
|
||||
hid_t gid;
|
||||
MPI_Comm comm=MPI_COMM_WORLD;
|
||||
|
||||
MPI_Init(&argc,&argv);
|
||||
MPI_Comm_size(comm,&nprocs);
|
||||
MPI_Comm_rank(comm,&myproc);
|
||||
|
||||
x=(double*)malloc(sz*nprocs*sizeof(double));
|
||||
y=(double*)malloc(sz*nprocs*sizeof(double));
|
||||
z=(double*)malloc(sz*nprocs*sizeof(double));
|
||||
id=(long long*)malloc(sz*nprocs*sizeof(long long));
|
||||
/* parallel file creation */
|
||||
file=H5PartOpenFileParallel("parttest.h5",H5PART_WRITE,comm);
|
||||
if(!file) {
|
||||
perror("File open failed: exiting!");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for(t=0;t<5;t++){
|
||||
MPI_Barrier(comm);
|
||||
for(i=0;i<sz;i++) {
|
||||
x[i]=(double)(i+t)+10.0*(double)myproc;
|
||||
y[i]=0.1 + (double)(i+t);
|
||||
z[i]=0.2 + (double)(i+t*10);
|
||||
id[i]=i+sz*myproc;
|
||||
}
|
||||
printf("Proc[%u] Writing timestep %u file=%u\n",myproc,t,file->file);
|
||||
H5PartSetStep(file,t); /* must set the current timestep in file */
|
||||
H5PartSetNumParticles(file,sz); /* then set number of particles to store */
|
||||
/* now write different tuples of data into this timestep of the file */
|
||||
H5PartWriteDataFloat64(file,"x",x);
|
||||
H5PartWriteDataFloat64(file,"y",y);
|
||||
H5PartWriteDataFloat64(file,"z",z);
|
||||
H5PartWriteDataInt64(file,"id",id);
|
||||
}
|
||||
printf("AllDone p[%u]\n",myproc);
|
||||
H5PartCloseFile(file);
|
||||
MPI_Barrier(comm);
|
||||
printf("p[%u:%u] : OK, close file and reopen for reading \n",myproc,nprocs);
|
||||
if(myproc==0){ /* now only proc 0 reads the file serially */
|
||||
file= H5PartOpenFileSerial("parttest.h5",H5PART_READ);
|
||||
nt=H5PartGetNumSteps(file); /* get number of steps in file */
|
||||
H5PartSetStep(file,0);
|
||||
nds=H5PartGetNumDatasets(file); /* get number of datasets in timestep 0 */
|
||||
|
||||
puts("\n\n===============================");
|
||||
for(i=0;i<nds;i++){ /* and print out those names */
|
||||
H5PartGetDatasetName(file,i,name,64);
|
||||
printf("\tDataset[%u] name=[%s]\n",
|
||||
i,name);
|
||||
}
|
||||
puts("===============================\n\n");
|
||||
printf("Number of datasteps in file is %u\n",nt);
|
||||
for(t=0;t<nt;t++){
|
||||
int nparticles;
|
||||
H5PartSetStep(file,t); /* select a timestep */
|
||||
nparticles=(int)H5PartGetNumParticles(file);
|
||||
printf("Step[%u] nparticles this step=%u\n",
|
||||
t,nparticles); /* get num particles this step */
|
||||
H5PartReadParticleStep(file,t, /* do a mongo read of all data this step */
|
||||
x,y,z,x,y,z,id);
|
||||
printf("\tid\t\tx\t\ty\t\tz\n");
|
||||
puts("\t----------------------------------------------------");
|
||||
for(i=0;i<nparticles;i++) {
|
||||
printf("\t%llu\t%f\t%f\t%f\n\n",id[i],x[i],y[i],z[i]);
|
||||
}
|
||||
}
|
||||
H5PartCloseFile(file);
|
||||
}
|
||||
if(x) free(x);
|
||||
if(y) free(y);
|
||||
if(z) free(z);
|
||||
if(id) free(id);
|
||||
MPI_Barrier(comm);
|
||||
fprintf(stderr,"proc[%u]: done\n",myproc);
|
||||
return MPI_Finalize();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main(int argc,char *argv){
|
||||
const int sz=5;
|
||||
double x[sz],y[sz],z[sz];
|
||||
long long id[sz];
|
||||
char name[64];
|
||||
H5PartFile *file;
|
||||
int i,t,nt,nds,myproc;
|
||||
int nfattribs,nsattribs;
|
||||
|
||||
file=H5PartOpenFile("parttest.h5",H5PART_WRITE);
|
||||
if(!file) {
|
||||
perror("File open failed: exiting!");
|
||||
exit(0);
|
||||
}
|
||||
for(t=0;t<5;t++){
|
||||
long long step=t;
|
||||
printf("Writing timestep %u\n",t);
|
||||
for(i=0;i<sz;i++) {
|
||||
x[i]=(double)(i+t);
|
||||
y[i]=0.1 + (double)(i+t);
|
||||
z[i]=0.2 + (double)(i+t);
|
||||
id[i]=i;
|
||||
}
|
||||
H5PartSetStep(file,t); /* must set the current timestep in file */
|
||||
H5PartSetNumParticles(file,sz); /* then set number of particles to store */
|
||||
/* now write different tuples of data into this timestep of the file */
|
||||
H5PartWriteDataFloat64(file,"x",x);
|
||||
H5PartWriteDataFloat64(file,"y",y);
|
||||
H5PartWriteDataFloat64(file,"z",z);
|
||||
H5PartWriteDataInt64(file,"id",id);
|
||||
H5PartWriteStepAttrib(file,"Step",H5T_NATIVE_INT64,&step,1);
|
||||
}
|
||||
H5PartCloseFile(file);
|
||||
printf("OK, close file and reopen for reading\n");
|
||||
file= H5PartOpenFile("parttest.h5",H5PART_READ);
|
||||
nt=H5PartGetNumSteps(file); /* get number of steps in file */
|
||||
H5PartSetStep(file,0);
|
||||
nds=H5PartGetNumDatasets(file); /* get number of datasets in timestep 0 */
|
||||
|
||||
puts("\n\n===============================");
|
||||
for(i=0;i<nds;i++){ /* and print out those names */
|
||||
H5PartGetDatasetName(file,i,name,64);
|
||||
printf("\tDataset[%u] name=[%s]\n",
|
||||
i,name);
|
||||
}
|
||||
puts("===============================\n\n");
|
||||
|
||||
nfattribs=H5PartGetNumFileAttribs(file);
|
||||
printf("Number of datasteps in file is %u num file attribs=%d\n",
|
||||
nt,nfattribs);
|
||||
for(t=0;t<nt;t++){
|
||||
int nparticles;
|
||||
H5PartSetStep(file,t); /* select a timestep */
|
||||
nparticles=(int)H5PartGetNumParticles(file);
|
||||
nsattribs=H5PartGetNumStepAttribs(file);
|
||||
printf("Step[%u] nparticles this step=%u stepattribs=%u\n",
|
||||
t,nparticles,nsattribs); /* get num particles this step */
|
||||
if(nsattribs>0){
|
||||
char attrname[32];
|
||||
H5PartGetStepAttribInfo(file,0,attrname,32,0,0);
|
||||
printf("First Attrib name is [%s]\n",attrname);
|
||||
}
|
||||
H5PartReadParticleStep(file,t,/* do a mongo read of all data this step */
|
||||
x,y,z,x,y,z,id);
|
||||
printf("\tid\t\tx\t\ty\t\tz\n");
|
||||
puts("\t----------------------------------------------------");
|
||||
for(i=0;i<sz;i++) {
|
||||
printf("\t%llu\t%f\t%f\t%f\n\n",id[i],x[i],y[i],z[i]);
|
||||
}
|
||||
}
|
||||
H5PartCloseFile(file);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+296
@@ -0,0 +1,296 @@
|
||||
#ifndef _H5Part_H_
|
||||
#define _H5Part_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <hdf5.h>
|
||||
#ifdef PARALLEL_IO
|
||||
#include <mpi.h>
|
||||
#endif
|
||||
#include "H5PartTypes.h"
|
||||
|
||||
|
||||
#define H5PART_SUCCESS 0
|
||||
#define H5PART_ERR_NOMEM -12
|
||||
#define H5PART_ERR_INVAL -22
|
||||
#define H5PART_ERR_BADFD -77
|
||||
|
||||
#define H5PART_ERR_INIT -200
|
||||
#define H5PART_ERR_NOENTRY -201
|
||||
|
||||
#define H5PART_ERR_MPI -201
|
||||
#define H5PART_ERR_HDF5 -202
|
||||
|
||||
|
||||
#define H5PART_READ 0x01
|
||||
#define H5PART_WRITE 0x02
|
||||
#define H5PART_APPEND 0x03
|
||||
|
||||
|
||||
#define H5PART_INT64 ((h5part_int64_t)H5T_NATIVE_INT64)
|
||||
#define H5PART_FLOAT64 ((h5part_int64_t)H5T_NATIVE_DOUBLE)
|
||||
#define H5PART_CHAR ((h5part_int64_t)H5T_NATIVE_CHAR)
|
||||
|
||||
/*========== File Opening/Closing ===============*/
|
||||
H5PartFile*
|
||||
H5PartOpenFile(
|
||||
const char *filename,
|
||||
unsigned flags
|
||||
);
|
||||
|
||||
#define H5PartOpenFileSerial(x,y) H5PartOpenFile(x,y)
|
||||
|
||||
#ifdef PARALLEL_IO
|
||||
H5PartFile*
|
||||
H5PartOpenFileParallel (
|
||||
const char *filename,
|
||||
unsigned flags,
|
||||
MPI_Comm communicator
|
||||
);
|
||||
#endif
|
||||
|
||||
|
||||
h5part_int64_t
|
||||
H5PartCloseFile (
|
||||
H5PartFile *f
|
||||
);
|
||||
|
||||
|
||||
/*============== File Writing Functions ==================== */
|
||||
h5part_int64_t
|
||||
H5PartSetNumParticles (
|
||||
H5PartFile *f,
|
||||
h5part_int64_t nparticles
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartWriteDataFloat64 (
|
||||
H5PartFile *f,
|
||||
char *name,
|
||||
h5part_float64_t *array
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartWriteDataInt64 (
|
||||
H5PartFile *f,
|
||||
char *name,
|
||||
h5part_int64_t *array
|
||||
);
|
||||
|
||||
/*================== File Reading Routines =================*/
|
||||
h5part_int64_t
|
||||
H5PartSetStep (
|
||||
H5PartFile *f,
|
||||
h5part_int64_t step
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartGetNumSteps (
|
||||
H5PartFile *f
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartGetNumDatasets (
|
||||
H5PartFile *f
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartGetDatasetName (
|
||||
H5PartFile *f,
|
||||
const h5part_int64_t idx,
|
||||
char *name,
|
||||
const h5part_int64_t maxlen
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartGetDatasetInfo (
|
||||
H5PartFile *f,
|
||||
const h5part_int64_t idx,
|
||||
char *name,
|
||||
const h5part_int64_t maxlen,
|
||||
h5part_int64_t *type,
|
||||
h5part_int64_t *nelem);
|
||||
|
||||
|
||||
h5part_int64_t
|
||||
H5PartGetNumParticles (
|
||||
H5PartFile *f
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartSetView (
|
||||
H5PartFile *f,
|
||||
h5part_int64_t start,
|
||||
h5part_int64_t end
|
||||
);
|
||||
|
||||
#define H5PartResetView(f) H5PartSetView(f,-1,-1)
|
||||
#define H5PartHasView(f) ((f->viewstart<0||f->viewend<0)?0:1)
|
||||
|
||||
h5part_int64_t
|
||||
H5PartGetView (
|
||||
H5PartFile *f,
|
||||
h5part_int64_t *start,
|
||||
h5part_int64_t *end
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartSetCanonicalView (
|
||||
H5PartFile *f
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartReadDataFloat64(
|
||||
H5PartFile *f,
|
||||
char *name,
|
||||
h5part_float64_t *array
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartReadDataInt64 (
|
||||
H5PartFile *f,
|
||||
char *name,
|
||||
h5part_int64_t *array
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartReadParticleStep (
|
||||
H5PartFile *f,
|
||||
h5part_int64_t step,
|
||||
h5part_float64_t *x, /* particle positions */
|
||||
h5part_float64_t *y,
|
||||
h5part_float64_t *z,
|
||||
h5part_float64_t *px, /* particle momenta */
|
||||
h5part_float64_t *py,
|
||||
h5part_float64_t *pz,
|
||||
h5part_int64_t *id /* and phase */
|
||||
);
|
||||
|
||||
/**********==============Attributes Interface============***************/
|
||||
/* currently there is file attributes: Attributes bound to the file
|
||||
and step attributes which are bound to the current timestep. You
|
||||
must set the timestep explicitly before writing the attributes (just
|
||||
as you must do when you write a new dataset. Currently there are no
|
||||
attributes that are bound to a particular data array, but this could
|
||||
easily be done if required.
|
||||
*/
|
||||
h5part_int64_t
|
||||
H5PartWriteStepAttrib (
|
||||
H5PartFile *f,
|
||||
const char *attrib_name,
|
||||
const h5part_int64_t attrib_type,
|
||||
const void *attrib_value,
|
||||
const h5part_int64_t attrib_nelem
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartWriteFileAttrib (
|
||||
H5PartFile *f,
|
||||
const char *attrib_name,
|
||||
const h5part_int64_t attrib_type,
|
||||
const void *attrib_value,
|
||||
const h5part_int64_t attrib_nelem
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartWriteFileAttribString (
|
||||
H5PartFile *f,
|
||||
const char *name,
|
||||
const char *attrib
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartWriteStepAttribString (
|
||||
H5PartFile *f,
|
||||
const char *name,
|
||||
const char *attrib
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartGetNumStepAttribs ( /* for current filestep */
|
||||
H5PartFile *f
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartGetNumFileAttribs (
|
||||
H5PartFile *f
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartGetStepAttribInfo (
|
||||
H5PartFile *f,
|
||||
const h5part_int64_t attrib_idx,
|
||||
char *attrib_name,
|
||||
const h5part_int64_t len_of_attrib_name,
|
||||
h5part_int64_t *attrib_type,
|
||||
h5part_int64_t *attrib_nelem
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartGetFileAttribInfo (
|
||||
H5PartFile *f,
|
||||
const h5part_int64_t idx,
|
||||
char *name,
|
||||
const h5part_int64_t maxnamelen,
|
||||
h5part_int64_t *type,
|
||||
h5part_int64_t *nelem
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartReadStepAttrib (
|
||||
H5PartFile *f,
|
||||
char *name,
|
||||
void *data
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartReadAttrib (
|
||||
H5PartFile *f,
|
||||
char *name,
|
||||
void *data
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartReadFileAttrib (
|
||||
H5PartFile *f,
|
||||
char *name,
|
||||
void *data
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartSetVerbosityLevel (
|
||||
unsigned int
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartSetErrorHandler (
|
||||
h5part_error_handler handler
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartGetErrno (
|
||||
void
|
||||
);
|
||||
|
||||
h5part_error_handler
|
||||
H5PartGetErrorHandler (
|
||||
void
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartDefaultErrorHandler (
|
||||
const char *funcname,
|
||||
const h5part_int64_t eno,
|
||||
const char *fmt,
|
||||
...
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartAbortErrorHandler (
|
||||
const char *funcname,
|
||||
const h5part_int64_t eno,
|
||||
const char *fmt,
|
||||
...
|
||||
);
|
||||
|
||||
#endif
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#ifndef _H5Part_HH_
|
||||
#define _H5Part_HH_
|
||||
|
||||
extern "C" {
|
||||
#include "H5PartTypes.h"
|
||||
#include "H5Part.h"
|
||||
}
|
||||
|
||||
/* Add any C++ specific extensions/implementations/wrappers here */
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,318 @@
|
||||
#ifndef __H5PARTERRORS_H
|
||||
#define __H5PARTERRORS_H
|
||||
|
||||
|
||||
/***************** Error Handling ***************/
|
||||
|
||||
#define CHECK_FILEHANDLE( f ) \
|
||||
if ( _file_is_valid ( f ) != H5PART_SUCCESS ) \
|
||||
return HANDLE_H5PART_BADFD_ERR;
|
||||
|
||||
#define CHECK_WRITABLE_MODE( f ) \
|
||||
if ( f->mode==H5PART_READ ) \
|
||||
return (*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_INVAL, \
|
||||
"Attempting to write to read-only file" );
|
||||
|
||||
#define CHECK_TIMEGROUP( f ) \
|
||||
if ( f->timegroup <= 0 ) \
|
||||
return (*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_INVAL, \
|
||||
"Timegroup <= 0.");
|
||||
|
||||
/**************** H5Part *********************/
|
||||
|
||||
#define HANDLE_H5PART_BADFD_ERR \
|
||||
(*_err_handler)( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_BADFD, \
|
||||
"Called with bad filehandle." );
|
||||
|
||||
#define HANDLE_H5PART_INIT_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_INIT, \
|
||||
"Cannot initialize H5Part." );
|
||||
|
||||
#define HANDLE_H5PART_NOMEM_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_NOMEM, \
|
||||
"Out of memory." );
|
||||
|
||||
#define HANDLE_H5PART_SETSTEP_ERR( rc, step ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
rc, \
|
||||
"Cannont set time-step to %lld.", (long long)step );
|
||||
|
||||
#define HANDLE_H5PART_FILE_ACCESS_TYPE_ERR( flags ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_INVAL, \
|
||||
"Invalid file access type \"%d\".", flags);
|
||||
|
||||
#define HANDLE_H5PART_STEP_EXISTS_ERR( step ) \
|
||||
(*_err_handler)( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_INVAL, \
|
||||
"Step #%lld already exists, step cannot be set to an existing" \
|
||||
" step in write and append mode", (long long)step );
|
||||
|
||||
#define HANDLE_H5PART_SET_VIEW_ERR( rc, start, end ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
rc, \
|
||||
"Cannot set view to (%d, %d).", start, end );
|
||||
|
||||
#define HANDLE_H5PART_GET_NUM_PARTICLES_ERR( rc ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
rc, \
|
||||
"Cannot get number of particles." );
|
||||
|
||||
#define HANDLE_H5PART_NOENTRY_ERR( group_name, type, idx ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_NOENTRY, \
|
||||
"No entry with index %lld and type %d in group %s!", \
|
||||
(long long)idx, type, group_name );
|
||||
|
||||
/**************** HDF5 *********************/
|
||||
/* H5A: Attribute */
|
||||
#define HANDLE_H5A_CLOSE_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot terminate access to attribute." );
|
||||
|
||||
#define HANDLE_H5A_CREATE_ERR( s ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot create attribute \"%s\".", s );
|
||||
|
||||
#define HANDLE_H5A_GET_NAME_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot get attribute name." );
|
||||
|
||||
#define HANDLE_H5A_GET_NUM_ATTRS_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot get number of attributes." );
|
||||
|
||||
#define HANDLE_H5A_GET_SPACE_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot get a copy of dataspace for attribute." );
|
||||
|
||||
#define HANDLE_H5A_GET_TYPE_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot get attribute datatype." );
|
||||
|
||||
#define HANDLE_H5A_OPEN_IDX_ERR( n ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot open attribute specified by index \"%lld\".", \
|
||||
(long long)n );
|
||||
|
||||
#define HANDLE_H5A_OPEN_NAME_ERR( s ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot open attribute specified by name \"%s\".", s );
|
||||
|
||||
#define HANDLE_H5A_READ_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot read attribute" );
|
||||
|
||||
#define HANDLE_H5A_WRITE_ERR( s ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot write attribute \"%s\".", s );
|
||||
|
||||
/* H5D: Dataset */
|
||||
#define HANDLE_H5D_CLOSE_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Close of dataset failed." );
|
||||
|
||||
#define HANDLE_H5D_CREATE_ERR( s, n ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot create dataset for name \"%s\", step \"%lld\".", \
|
||||
s, (long long) n );
|
||||
|
||||
#define HANDLE_H5D_GET_SPACE_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot get dataspace identifier.");
|
||||
|
||||
#define HANDLE_H5D_GET_TYPE_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot determine dataset type.");
|
||||
|
||||
#define HANDLE_H5D_OPEN_ERR( s ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot open dataset \"%s\".", s );
|
||||
|
||||
#define HANDLE_H5D_READ_ERR( s, n ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Read from dataset \"%s\" failed, step \"%lld\".", \
|
||||
s, (long long) n );
|
||||
|
||||
#define HANDLE_H5D_WRITE_ERR( s, n ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Write to dataset \"%s\" failed, step \"%lld\".", \
|
||||
s, (long long)n );
|
||||
|
||||
/* H5F: file */
|
||||
#define HANDLE_H5F_CLOSE_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot terminate access to file." );
|
||||
|
||||
#define HANDLE_H5F_OPEN_ERR( filename, flags ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot open file \"%s\" with mode \"%d\"", filename, flags );
|
||||
|
||||
|
||||
|
||||
/* H5G: group */
|
||||
#define HANDLE_H5G_CLOSE_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot terminate access to datagroup." );
|
||||
|
||||
#define HANDLE_H5G_CREATE_ERR( s ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot create datagroup \"%s\".", s );
|
||||
|
||||
#define HANDLE_H5G_GET_OBJINFO_ERR( s ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot get information about object \"%s\".", s );
|
||||
|
||||
#define HANDLE_H5G_OPEN_ERR( s ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot open group \"%s\".", s );
|
||||
|
||||
|
||||
/* H5P: property */
|
||||
#define HANDLE_H5P_CLOSE_ERR( s ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot terminate access to property list \"%s\".", s );
|
||||
|
||||
#define HANDLE_H5P_CREATE_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot create property list." );
|
||||
|
||||
#define HANDLE_H5P_SET_DXPL_MPIO_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"MPI: Cannot set data transfer mode." );
|
||||
|
||||
|
||||
#define HANDLE_H5P_SET_FAPL_MPIO_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot store IO communicator information to the " \
|
||||
"file access property list.");
|
||||
|
||||
/* H5S: dataspace */
|
||||
#define HANDLE_H5S_CREATE_SIMPLE_ERR( n ) \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot create dataspace with len \"%lld\".", (long long) n );
|
||||
|
||||
#define HANDLE_H5S_CLOSE_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot terminate access to dataspace." );
|
||||
|
||||
#define HANDLE_H5S_GET_SELECT_NPOINTS_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot determine the number of elements in dataspace selection." );
|
||||
|
||||
#define HANDLE_H5S_GET_SIMPLE_EXTENT_NPOINTS_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot determine number of elements in dataspace." );
|
||||
|
||||
#define HANDLE_H5S_SELECT_HYPERSLAB_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot set select hyperslap region or add the specified region" );
|
||||
|
||||
/* H5T: type */
|
||||
#define HANDLE_H5T_CLOSE_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_HDF5, \
|
||||
"Cannot release datatype." );
|
||||
|
||||
|
||||
/* MPI */
|
||||
#define HANDLE_MPI_ALLGATHER_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_MPI, \
|
||||
"Cannot gather data." );
|
||||
|
||||
#define HANDLE_MPI_COMM_SIZE_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_MPI, \
|
||||
"Cannot get number of processes in my group." );
|
||||
|
||||
#define HANDLE_MPI_COMM_RANK_ERR \
|
||||
(*_err_handler) ( \
|
||||
_H5Part_get_funcname(), \
|
||||
H5PART_ERR_MPI, \
|
||||
"Cannot get rank of the calling process in my group." );
|
||||
|
||||
#endif
|
||||
Executable
+561
@@ -0,0 +1,561 @@
|
||||
#include "H5Part.h"
|
||||
#include "Underscore.h"
|
||||
#include <hdf5.h>
|
||||
/*
|
||||
|
||||
********* Perhaps call this pfile **********
|
||||
|
||||
Determine underscores using perl and then send through one stage of preprocessing
|
||||
to get the F77NAME fixed up. Otherwise, must include correct flag each time.
|
||||
|
||||
Or just don't declare F77NAME in the header (only in source as symbols).
|
||||
|
||||
|
||||
All pointers are cast to haddr_t (a unint64_t) within the C/C++ code
|
||||
In fortran, these pointers (handles) are carried as INTEGER*8
|
||||
|
||||
*/
|
||||
|
||||
#ifdef F77_SINGLE_UNDERSCORE
|
||||
#define F77NAME(a,b,c) a
|
||||
#elif defined(F77_NO_UNDERSCORE)
|
||||
#define F77NAME(a,b,c) b
|
||||
#elif defined(F77_CRAY_UNDERSCORE)
|
||||
#define F77NAME(a,b,c) c
|
||||
#else
|
||||
#error Error, no way to determine how to construct fortran bindings
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define f_h5pt_openr F77NAME(h5prt_openr_,h5prt_openr,H5PRT_OPENR)
|
||||
#define f_h5pt_openw F77NAME(h5prt_openw_,h5prt_openw,H5PRT_OPENW)
|
||||
#define f_h5pt_close F77NAME(h5prt_close_,h5prt_close,H5PRT_CLOSE)
|
||||
#define f_h5pt_npoints F77NAME(h5prt_npoints_,h5prt_npoints,H5PRT_NPOINTS)
|
||||
#define f_h5pt_ndata F77NAME(h5prt_ndata_,h5prt_ndata,H5PRT_NDATA)
|
||||
#define f_h5pt_nstep F77NAME(h5prt_nstep_,h5prt_nstep,H5PRT_NSTEP)
|
||||
#define f_h5pt_readstep F77NAME(h5prt_readstep_,h5prt_readstep,H5PRT_READSTEP)
|
||||
#define f_h5pt_step F77NAME(h5prt_step_,h5prt_step,H5PRT_STEP)
|
||||
#define f_h5pt_wreal8 F77NAME(h5prt_wreal8_,h5prt_wreal8,H5PRT_WREAL8)
|
||||
#define f_h5pt_wint8 F77NAME(h5prt_wint8_,h5prt_wint8,H5PRT_WINT8)
|
||||
#endif
|
||||
|
||||
/* open/close interface */
|
||||
#define f_h5pt_openr F77NAME(h5pt_openr_,h5pt_openr,H5PT_OPENR) /* func returns INT8 */
|
||||
#define f_h5pt_openw F77NAME(h5pt_openw_,h5pt_openw,H5PT_OPENW) /* func returns INT8 */
|
||||
|
||||
#define f_h5pt_openr_par F77NAME(h5pt_openr_par_,h5pt_openr_par,H5PT_OPENR_PAR) /* func returns INT8 */
|
||||
#define f_h5pt_openw_par F77NAME(h5pt_openw_par_,h5pt_openw_par,H5PT_OPENW_PAR) /* func returns INT8 */
|
||||
#define f_h5pt_close F77NAME(h5pt_close_,h5pt_close,H5PT_CLOSE)
|
||||
|
||||
/* writing interface */
|
||||
#define f_h5pt_setnpoints F77NAME(h5pt_setnpoints_,h5pt_setnpoints,H5PT_SETNPOINTS)
|
||||
#define f_h5pt_setstep F77NAME(h5pt_setstep_,h5pt_setstep,H5PT_SETSTEP)
|
||||
#define f_h5pt_writedata_r8 F77NAME(h5pt_writedata_r8_,h5pt_writedata_r8,H5PT_WRITEDATA_R8)
|
||||
#define f_h5pt_writedata_i8 F77NAME(h5pt_writedata_i8_,h5pt_writedata_i8,H5PT_WRITEDATA_I8)
|
||||
|
||||
/* Reading interface (define dataset, step, particles, attributes) */
|
||||
#define f_h5pt_getnsteps F77NAME(h5pt_getnsteps_,h5pt_getnsteps,H5PT_GETNSTEPS)
|
||||
#define f_h5pt_getndatasets F77NAME(h5pt_getndatasets_,h5pt_getndatasets,H5PT_GETNDATASETS)
|
||||
#define f_h5pt_getnpoints F77NAME(h5pt_getnpoints_,h5pt_getnpoints,H5PT_GETNPOINTS)
|
||||
#define f_h5pt_getdatasetname F77NAME(h5pt_getdatasetname_,h5pt_getdatasetname,H5PT_GETDATASETNAME)
|
||||
#define f_h5pt_getnumpoints F77NAME(h5pt_getnumpoints_,h5pt_getnumpoints,H5PT_GETNUMPOINTS)
|
||||
|
||||
/* Views and parallelism */
|
||||
#define f_h5pt_setview F77NAME(h5pt_setview_,h5pt_setview,H5PT_SETVIEW)
|
||||
#define f_h5pt_resetview F77NAME(h5pt_resetview_,h5pt_resetview,H5PT_RESETVIEW)
|
||||
#define f_h5pt_hasview F77NAME(h5pt_hasview_,h5pt_hasview,H5PT_HASVIEW)
|
||||
#define f_h5pt_getview F77NAME(h5pt_getview_,h5pt_getview,H5PT_GETVIEW)
|
||||
|
||||
/* Reading data */
|
||||
#define f_h5pt_readdata_r8 F77NAME(h5pt_readdata_r8_,h5pt_readdata_r8,H5PT_READDATA_R8)
|
||||
#define f_h5pt_readdata_i8 F77NAME(h5pt_readdata_i8_,h5pt_readdata_i8,H5PT_READDATA_I8)
|
||||
#define f_h5pt_readdata F77NAME(h5pt_readdata_,h5pt_readdata,H5PT_READDATA)
|
||||
|
||||
/* Attributes */
|
||||
/* writing */
|
||||
#define f_h5pt_writefileattrib_r8 F77NAME(h5pt_writefileattrib_r8_,h5pt_writefileattrib_r8,H5PT_WRITEFILEATTRIB_R8)
|
||||
#define f_h5pt_writefileattrib_i8 F77NAME(h5pt_writefileattrib_i8_,h5pt_writefileattrib_i8,H5PT_WRITEFILEATTRIB_I8)
|
||||
#define f_h5pt_writefileattrib_string F77NAME(h5pt_writefileattrib_string_,h5pt_writefileattrib_string,H5PT_writefileattrib_string)
|
||||
#define f_h5pt_writestepattrib_r8 F77NAME(h5pt_writestepattrib_r8_,h5pt_writestepattrib_r8,H5PT_WRITESTEPATTRIB_R8)
|
||||
#define f_h5pt_writestepattrib_i8 F77NAME(h5pt_writestepattrib_i8_,h5pt_writestepattrib_i8,H5PT_WRITESTEPATTRIB_I8)
|
||||
#define f_h5pt_writestepattrib_string F77NAME(h5pt_writestepattrib_string_,h5pt_writestepattrib_string,H5PT_WRITESTEPATTRIB_STRING)
|
||||
/* reading */
|
||||
#define f_h5pt_getnstepattribs F77NAME(h5pt_getnstepattribs_,h5pt_getnstepattribs,H5PT_GETNSTEPATTRIBS)
|
||||
#define f_h5pt_getnfileattribs F77NAME(h5pt_getnfileattribs_,h5pt_getnfileattribs,H5PT_GETNFILEATTRIBS)
|
||||
#define f_h5pt_getstepattribinfo F77NAME(h5pt_getstepattribinfo_,h5pt_getstepattribinfo,H5PT_GETSTEPATTRIBINFO)
|
||||
#define f_h5pt_getfileattribinfo F77NAME(h5pt_getfileattribinfo_,h5pt_getfileattribinfo,H5PT_GETFILEATTRIBINFO)
|
||||
#define f_h5pt_readstepattrib F77NAME(h5pt_readstepattrib_,h5pt_readstepattrib,H5PT_READSTEPATTRIB)
|
||||
#define f_h5pt_readfileattrib F77NAME(h5pt_readfileattrib_,h5pt_readfileattrib,H5PT_READFILEATTRIB)
|
||||
|
||||
|
||||
/* open/close interface */
|
||||
haddr_t
|
||||
f_h5pt_openr (
|
||||
char *file,
|
||||
int flen
|
||||
) { /* func returns INT8 */
|
||||
|
||||
haddr_t fh;
|
||||
H5PartFile* f;
|
||||
char *newname = (char*)malloc(flen+1); /* be safe? */
|
||||
strncpy(newname,file,flen);
|
||||
newname[flen]='\0';
|
||||
f = (H5PartOpenFile(newname,H5PART_READ));
|
||||
/* printf("openr file=[%s] flen=%u haddr=%u\n",file,flen,f); */
|
||||
fh = (haddr_t)f;
|
||||
/* printf("FileHandle=%llu\n",fh); */
|
||||
|
||||
return fh;
|
||||
}
|
||||
|
||||
haddr_t
|
||||
f_h5pt_openw (
|
||||
char *file,
|
||||
int flen) { /* func returns INT8 */
|
||||
|
||||
haddr_t fh;
|
||||
H5PartFile* f;
|
||||
char *newname = (char*)malloc(flen+1); /* be safe? */
|
||||
strncpy(newname,file,flen);
|
||||
newname[flen]='\0';
|
||||
f = (H5PartOpenFile(newname,H5PART_WRITE));
|
||||
/* printf("openr file=[%s] flen=%u haddr=%u\n",file,flen,f); */
|
||||
fh = (haddr_t)f;
|
||||
/* printf("FileHandle=%llu\n",fh); */
|
||||
|
||||
return fh;
|
||||
}
|
||||
|
||||
#ifdef PARALLEL_IO
|
||||
haddr_t
|
||||
f_h5pt_openr_par (
|
||||
char *file,
|
||||
MPI_Comm *c,
|
||||
int flen ) { /* func returns INT8 */
|
||||
|
||||
haddr_t fh;
|
||||
H5PartFile* f;
|
||||
char *newname = (char*)malloc(flen+1); /* be safe? */
|
||||
strncpy(newname,file,flen);
|
||||
newname[flen]='\0';
|
||||
f = H5PartOpenFileParallel(newname,H5PART_READ,*((MPI_Comm*)c));
|
||||
/* printf("openr file=[%s] flen=%u haddr=%u\n",file,flen,f); */
|
||||
fh = (haddr_t)f;
|
||||
/* printf("FileHandle=%llu\n",fh); */
|
||||
|
||||
return fh;
|
||||
}
|
||||
|
||||
haddr_t
|
||||
f_h5pt_openw_par (
|
||||
char *file,
|
||||
MPI_Comm *c,
|
||||
int flen ) { /* func returns INT8 */
|
||||
|
||||
haddr_t fh;
|
||||
H5PartFile* f;
|
||||
char *newname = (char*)malloc(flen+1); /* be safe? */
|
||||
strncpy(newname,file,flen);
|
||||
newname[flen]='\0';
|
||||
f = H5PartOpenFileParallel(newname,H5PART_WRITE,*((MPI_Comm*)c));
|
||||
/* printf("openr file=[%s] flen=%u haddr=%u\n",file,flen,f); */
|
||||
fh = (haddr_t)f;
|
||||
/* printf("FileHandle=%llu\n",fh); */
|
||||
|
||||
return fh;
|
||||
}
|
||||
#endif
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_close (
|
||||
haddr_t *file
|
||||
) {
|
||||
return H5PartCloseFile((H5PartFile*)*file);
|
||||
}
|
||||
|
||||
/*==============Writing and Setting Dataset info========*/
|
||||
#if 0
|
||||
h5part_int64_t
|
||||
f_h5pt_readstep (
|
||||
haddr_t *file,
|
||||
h5part_int64_t *step,
|
||||
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
|
||||
) {
|
||||
|
||||
return H5PartReadParticleStep((H5PartFile*)*file,(*step)-1,x,y,z,px,py,pz,id);
|
||||
}
|
||||
#endif
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_setnpoints (
|
||||
haddr_t *file,
|
||||
h5part_int64_t *np
|
||||
) {
|
||||
|
||||
return H5PartSetNumParticles((H5PartFile*)*file,*np);
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_setstep (
|
||||
haddr_t *file,
|
||||
h5part_int64_t *step ) {
|
||||
|
||||
return H5PartSetStep((H5PartFile*)*file,(*step)-1);
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_writedata_r8 (
|
||||
haddr_t *file,
|
||||
char *name,
|
||||
h5part_float64_t *data,
|
||||
int flen ) {
|
||||
|
||||
h5part_int64_t rc;
|
||||
|
||||
char *newname = (char*)malloc(flen+1); /* be safe? */
|
||||
strncpy(newname,name,flen);
|
||||
newname[flen]='\0';
|
||||
rc = H5PartWriteDataFloat64((H5PartFile*)*file,newname, data);
|
||||
free(newname);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_writedata_i8 (
|
||||
haddr_t *file,
|
||||
char *name,
|
||||
h5part_int64_t *data,
|
||||
int flen ) {
|
||||
|
||||
h5part_int64_t rc;
|
||||
|
||||
char *newname = (char*)malloc(flen+1); /* be safe? */
|
||||
strncpy(newname,name,flen);
|
||||
newname[flen]='\0';
|
||||
rc = H5PartWriteDataInt64((H5PartFile*)*file,newname,data);
|
||||
free(newname);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*==============Reading Data Characteristics============*/
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_getnsteps (
|
||||
haddr_t *file
|
||||
) {
|
||||
|
||||
/* printf("nstep Haddr=%llu\n",file); */
|
||||
return H5PartGetNumSteps((H5PartFile*)*file);
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_getndatasets (
|
||||
haddr_t *file
|
||||
) {
|
||||
/* printf("ndata Haddr=%llu\n",file); */
|
||||
return H5PartGetNumDatasets((H5PartFile*)*file);
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_getnpoints (
|
||||
haddr_t *file
|
||||
) {
|
||||
/* printf("nprt Haddr=%llu\n",file); */
|
||||
return H5PartGetNumParticles((H5PartFile*)*file);
|
||||
}
|
||||
|
||||
/* probably should get index from name */
|
||||
h5part_int64_t
|
||||
f_h5pt_getdatasetname (
|
||||
haddr_t *file,
|
||||
h5part_int64_t *index,
|
||||
char *name,
|
||||
int namelen){
|
||||
|
||||
return H5PartGetDatasetName((H5PartFile *)*file,*index,name,namelen);
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_getnumpoints (
|
||||
haddr_t *file) {
|
||||
|
||||
return H5PartGetNumParticles((H5PartFile*)*file);
|
||||
}
|
||||
|
||||
/*=============Setting and getting views================*/
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_setview (
|
||||
haddr_t *file,
|
||||
h5part_int64_t *start,
|
||||
h5part_int64_t *end ) {
|
||||
|
||||
return H5PartSetView((H5PartFile*)*file,*start,*end);
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_resetview (
|
||||
haddr_t *file
|
||||
) {
|
||||
|
||||
return H5PartResetView((H5PartFile*)*file);
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_hasview (
|
||||
haddr_t *file
|
||||
) {
|
||||
|
||||
return H5PartHasView(((H5PartFile*)*file));
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_getview (
|
||||
haddr_t *file,
|
||||
h5part_int64_t *start,
|
||||
h5part_int64_t *end
|
||||
) {
|
||||
|
||||
return H5PartGetView((H5PartFile*)*file, start, end);
|
||||
}
|
||||
/*==================Reading data ============*/
|
||||
h5part_int64_t
|
||||
f_h5pt_readdata_r8 (
|
||||
haddr_t *file,
|
||||
char *name,
|
||||
h5part_float64_t *array,
|
||||
int namelen
|
||||
) {
|
||||
|
||||
h5part_int64_t rc;
|
||||
char *newname = (char*)malloc(namelen+1); /* be safe? */
|
||||
strncpy(newname,name,namelen);
|
||||
newname[namelen]='\0';
|
||||
rc = H5PartReadDataFloat64((H5PartFile*)*file,newname, array);
|
||||
free(newname);
|
||||
return rc;
|
||||
}
|
||||
h5part_int64_t
|
||||
f_h5pt_readdata_i8 (
|
||||
haddr_t *file,
|
||||
char *name,
|
||||
h5part_int64_t *array,
|
||||
int namelen ) {
|
||||
|
||||
h5part_int64_t rc;
|
||||
char *newname = (char*)malloc(namelen+1); /* be safe? */
|
||||
strncpy(newname,name,namelen);
|
||||
newname[namelen]='\0';
|
||||
rc = H5PartReadDataInt64((H5PartFile*)*file,newname, array);
|
||||
free(newname);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*=================== Attributes ================*/
|
||||
|
||||
/* Attributes */
|
||||
/* writing */
|
||||
h5part_int64_t
|
||||
f_h5pt_writefileattrib_r8 (
|
||||
haddr_t *f,
|
||||
char *name,
|
||||
void *attrib,
|
||||
h5part_int64_t *nelem,
|
||||
int namelen ) {
|
||||
|
||||
h5part_int64_t rc;
|
||||
char *newname = (char*)malloc(namelen+1); /* be safe? */
|
||||
strncpy(newname,name,namelen);
|
||||
newname[namelen]='\0';
|
||||
rc = H5PartWriteFileAttrib((H5PartFile *)*f,newname,
|
||||
H5T_NATIVE_DOUBLE,attrib,*nelem);
|
||||
free(newname);
|
||||
return rc;
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_writefileattrib_i8 (
|
||||
haddr_t *f,
|
||||
char *name,
|
||||
void *attrib,
|
||||
h5part_int64_t *nelem,
|
||||
int namelen
|
||||
) {
|
||||
|
||||
h5part_int64_t rc;
|
||||
char *newname = (char*)malloc(namelen+1); /* be safe? */
|
||||
strncpy(newname,name,namelen);
|
||||
newname[namelen]='\0';
|
||||
rc = H5PartWriteFileAttrib((H5PartFile *)*f,newname,
|
||||
H5T_NATIVE_INT64,attrib,*nelem);
|
||||
free(newname);
|
||||
return rc;
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_writefileattrib_string (
|
||||
haddr_t *f,
|
||||
char *name,
|
||||
char *attrib,
|
||||
int namelen,
|
||||
int attriblen
|
||||
) {
|
||||
|
||||
h5part_int64_t rc;
|
||||
char *newattrib;
|
||||
char *newname;
|
||||
newname = (char*)malloc(namelen+1); /* be safe? */
|
||||
strncpy(newname,name,namelen);
|
||||
newname[namelen]='\0';
|
||||
newattrib = (char*)malloc(attriblen+1); /* be safe? */
|
||||
strncpy(newattrib,attrib,attriblen);
|
||||
newattrib[attriblen]='\0';
|
||||
rc = H5PartWriteFileAttribString((H5PartFile *)*f,newname,newattrib);
|
||||
free(newname);
|
||||
free(newattrib);
|
||||
return rc;
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_writestepattrib_r8 (
|
||||
haddr_t *f,
|
||||
char *name,
|
||||
void *attrib,
|
||||
h5part_int64_t *nelem,
|
||||
int namelen){
|
||||
|
||||
h5part_int64_t rc;
|
||||
char *newname = (char*)malloc(namelen+1); /* be safe? */
|
||||
strncpy(newname,name,namelen);
|
||||
newname[namelen]='\0';
|
||||
rc = H5PartWriteStepAttrib((H5PartFile *)*f,newname,
|
||||
H5T_NATIVE_DOUBLE,attrib,*nelem);
|
||||
free(newname);
|
||||
return rc;
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_writestepattrib_i8 (
|
||||
haddr_t *f,
|
||||
char *name,
|
||||
void *attrib,
|
||||
h5part_int64_t *nelem,
|
||||
int namelen
|
||||
) {
|
||||
|
||||
h5part_int64_t rc;
|
||||
char *newname = (char*)malloc(namelen+1); /* be safe? */
|
||||
strncpy(newname,name,namelen);
|
||||
newname[namelen]='\0';
|
||||
rc = H5PartWriteStepAttrib((H5PartFile *)*f,newname,
|
||||
H5T_NATIVE_INT64,attrib,*nelem);
|
||||
free(newname);
|
||||
return rc;
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_writestepattrib_string (
|
||||
haddr_t *f,
|
||||
char *name,
|
||||
char *attrib,
|
||||
int namelen,
|
||||
int attriblen ) {
|
||||
|
||||
h5part_int64_t rc;
|
||||
char *newattrib;
|
||||
char *newname;
|
||||
newname = (char*)malloc(namelen+1); /* be safe? */
|
||||
strncpy(newname,name,namelen);
|
||||
newname[namelen]='\0';
|
||||
newattrib = (char*)malloc(attriblen+1); /* be safe? */
|
||||
strncpy(newattrib,attrib,attriblen);
|
||||
newattrib[attriblen]='\0';
|
||||
rc = H5PartWriteStepAttribString((H5PartFile *)*f,newname,newattrib);
|
||||
free(newname);
|
||||
free(newattrib);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* reading attributes ************************* */
|
||||
h5part_int64_t
|
||||
f_h5pt_getnstepattribs (
|
||||
haddr_t *f
|
||||
) {
|
||||
|
||||
return H5PartGetNumStepAttribs((H5PartFile*)*f);
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_getnfileattribs (
|
||||
haddr_t *f
|
||||
) {
|
||||
|
||||
return H5PartGetNumFileAttribs((H5PartFile*)*f);
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_getstepattribinfo (
|
||||
haddr_t *f,
|
||||
h5part_int64_t *idx,
|
||||
char *name,
|
||||
h5part_int64_t *nelem,
|
||||
int maxnamelen
|
||||
) {
|
||||
|
||||
hid_t type;
|
||||
return H5PartGetStepAttribInfo((H5PartFile*)*f,*idx,name,maxnamelen,&type,nelem);
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_getfileattribinfo (
|
||||
haddr_t *f,
|
||||
h5part_int64_t *idx,
|
||||
char *name,
|
||||
h5part_int64_t *nelem,
|
||||
int maxnamelen ) {
|
||||
|
||||
hid_t type;
|
||||
return H5PartGetFileAttribInfo((H5PartFile*)*f,*idx,name,maxnamelen,&type,nelem);
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_readstepattrib (
|
||||
haddr_t *f,
|
||||
char *name,
|
||||
void *data,
|
||||
int namelen
|
||||
) {
|
||||
|
||||
h5part_int64_t rc;
|
||||
char *newname = (char*)malloc(namelen+1); /* be safe? */
|
||||
strncpy(newname,name,namelen);
|
||||
newname[namelen]='\0';
|
||||
rc = H5PartReadStepAttrib((H5PartFile*)*f,newname,data);
|
||||
free( newname );
|
||||
return rc;
|
||||
}
|
||||
|
||||
h5part_int64_t
|
||||
f_h5pt_readfileattrib (
|
||||
haddr_t *f,
|
||||
char *name,
|
||||
void *data,
|
||||
int namelen
|
||||
) {
|
||||
|
||||
int rc;
|
||||
char *newname = (char*)malloc(namelen+1); /* be safe? */
|
||||
strncpy(newname,name,namelen);
|
||||
newname[namelen]='\0';
|
||||
rc = H5PartReadFileAttrib((H5PartFile*)*f,newname,data);
|
||||
free( newname );
|
||||
return rc;
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
! Declaration of subroutines for Fortran Bindings
|
||||
! open/close interface
|
||||
|
||||
INTERFACE
|
||||
INTEGER*8 FUNCTION h5pt_openr ( filename )
|
||||
CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for reading
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_openw ( filename )
|
||||
CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for writing
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_openr_par ( filename, mpi_communicator )
|
||||
CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for writing
|
||||
INTEGER, INTENT(IN) :: mpi_communicator ! the MPI_Communicator used by the program
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_openw_par ( filename, mpi_communicator )
|
||||
CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for writing
|
||||
INTEGER, INTENT(IN) :: mpi_communicator ! the MPI_Communicator used by the program
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_close ( filehandle )
|
||||
INTEGER*8, INTENT(IN) :: filehandle ! close this open filehandle
|
||||
END FUNCTION
|
||||
|
||||
!==============Writing and Setting Dataset info========
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_setnpoints ( filehandle, npoints )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
INTEGER*8, INTENT(IN) :: npoints ! The number of particles on *this* processor
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_setstep (filehandle,step)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
INTEGER*8, INTENT(IN) :: step ! Set the current timestep in the file to this
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_writedata_r8 ( filehandle, name, data )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: name ! The name of the data we are writing
|
||||
REAL*8, INTENT(IN) :: data(:) ! The dataarray to write. The number of
|
||||
! elements is presumably set earlier with
|
||||
! h5pt_setnpoints(f,npoints)
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_writedata_i8 ( filehandle, name, data )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: name ! The name of the data we are writing
|
||||
INTEGER*8, INTENT(IN) :: data(:)
|
||||
END FUNCTION
|
||||
|
||||
!==============Reading Data Characteristics============
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_getnsteps (filehandle)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_getndatasets (filehandle)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
END FUNCTION
|
||||
|
||||
! returns total number of points in this timestep
|
||||
! If a "view" has been set using h5pt_setview()
|
||||
! then it returns the number of points that are
|
||||
! in the current view.
|
||||
INTEGER*8 FUNCTION h5pt_getnpoints (filehandle)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_getdatasetname (filehandle,index,name)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
INTEGER*8, INTENT(IN) :: index ! Index for a given dataset name
|
||||
CHARACTER(LEN=*), INTENT(OUT) :: name ! returns the name of the dataset at that index
|
||||
END FUNCTION
|
||||
|
||||
!=============Setting and getting views================
|
||||
INTEGER*8 FUNCTION h5pt_setview (filehandle,start,end)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
INTEGER*8, INTENT(IN) :: start ! offset of the first particle in the view
|
||||
INTEGER*8, INTENT(IN) :: end ! offset of the first particle after the end of the view
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_resetview (filehandle)
|
||||
INTEGER*8, INTENT(IN) :: filehandle ! reset the view on this filehandle to default
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_hasview (filehandle)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_getview (filehandle,start,end)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
INTEGER*8, INTENT(OUT) :: start ! offset of first particle in the view
|
||||
INTEGER*8, INTENT(OUT) :: end ! offset of first particle beyond the current view
|
||||
END FUNCTION
|
||||
|
||||
!==============Reading Data=========================
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_readdata_r8 (filehandle,name,data)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: name ! The name of the data we are writing
|
||||
REAL*8, INTENT(OUT) :: data(:) ! The dataarray to read. Number of points
|
||||
! read is either the number within the view set
|
||||
! by h5pt_setview() or the default (the total
|
||||
! number of particles in the file.
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_readdata_i8 (filehandle,name,data)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: name ! The name of the data we are writing
|
||||
INTEGER*8, INTENT(OUT) :: data(:) ! The dataarray to read. Number of points
|
||||
! read is either the number within the view set
|
||||
! by h5pt_setview() or the default (the total
|
||||
! number of particles in the file.
|
||||
END FUNCTION
|
||||
|
||||
|
||||
!=================== Attributes ================
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_writefileattrib_r8 (filehandle,attrib_name,attrib_value,attrib_nelem)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
|
||||
REAL*8, INTENT(IN) :: attrib_value(:) ! The array of data to write into the attribute
|
||||
INTEGER*8, INTENT(IN) :: attrib_nelem ! Number of elements in the attrib array
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_writefileattrib_i8 (filehandle,attrib_name,attrib_value,attrib_nelem)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
|
||||
INTEGER*8, INTENT(IN) :: attrib_value(:) ! The array of data to write into the attribute
|
||||
INTEGER*8, INTENT(IN) :: attrib_nelem ! Number of elements in the attrib array
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_writefileattrib_string (filehandle,attrib_name,attrib_value)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
|
||||
CHARACTER(LEN=*), INTENT(IN) :: attrib_value ! The array of data to write into the attribute
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_writestepattrib_r8 (filehandle,attrib_name,attrib_value,attrib_nelem)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
|
||||
REAL*8, INTENT(IN) :: attrib_value(:) ! The array of data to write into the attribute
|
||||
INTEGER*8, INTENT(IN) :: attrib_nelem ! Number of elements in the attrib array
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_writestepattrib_i8 (filehandle,attrib_name,attrib_value,attrib_nelem)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
|
||||
INTEGER*8, INTENT(IN) :: attrib_value(:) ! The array of data to write into the attribute
|
||||
INTEGER*8, INTENT(IN) :: attrib_nelem ! Number of elements in the attrib array
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_writestepattrib_string (filehandle,attrib_name,attrib_value)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! The name of the attribute
|
||||
CHARACTER(LEN=*), INTENT(IN) :: attrib_value ! The array of data to write into the attribute
|
||||
END FUNCTION
|
||||
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_getnstepattribs (filehandle)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_getnfileattribs (filehandle)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_getstepattribinfo (filehandle,idx,attrib_name,attrib_nelem)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
INTEGER*8, INTENT(IN) :: idx ! index of the attribute being queried
|
||||
CHARACTER(LEN=*), INTENT(OUT) :: attrib_name ! The name of the attribute
|
||||
INTEGER*8, INTENT(OUT) :: attrib_nelem ! Number of elements in the attrib array
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_getfileattribinfo (filehandle,idx,attrib_name,attrib_nelem)
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
INTEGER*8, INTENT(IN) :: idx ! index of the attribute being queried
|
||||
CHARACTER(LEN=*), INTENT(OUT) :: attrib_name ! The name of the attribute
|
||||
INTEGER*8, INTENT(OUT) :: attrib_nelem ! Number of elements in the attrib array
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_readstepattrib_i8 ( filehandle, attrib_name, attrib_value )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! name of the attribute to read
|
||||
INTEGER*8, INTENT(OUT) :: attrib_value(:) ! the attribute data will be read into this array
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_readstepattrib_r8 ( filehandle, attrib_name, attrib_value )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! name of the attribute to read
|
||||
REAL*8, INTENT(OUT) :: attrib_value(:) ! the attribute data will be read into this array
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_readfileattrib_i8 (filehandle, attrib_name, attrib_value )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! name of the attribute to read
|
||||
INTEGER*8, INTENT(OUT) :: attrib_value(:) ! the attribute data will be read into this array
|
||||
END FUNCTION
|
||||
|
||||
INTEGER*8 FUNCTION h5pt_readfileattrib_r8 (filehandle, attrib_name, attrib_value )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! name of the attribute to read
|
||||
REAL*8, INTENT(OUT) :: attrib_value(:) ! the attribute data will be read into this array
|
||||
END FUNCTION
|
||||
|
||||
END INTERFACE
|
||||
@@ -0,0 +1,163 @@
|
||||
#ifndef __H5PARTPRIVATE_H
|
||||
#define __H5PARTPRIVATE_H
|
||||
|
||||
|
||||
/*!
|
||||
The functions declared here are not part of the API, but may be used
|
||||
in extensions like H5Block. We name these functions "private".
|
||||
|
||||
\note
|
||||
Private function may change there interface even in stable versions.
|
||||
Don't use them in applications!
|
||||
*/
|
||||
|
||||
struct _iter_op_data {
|
||||
int stop_idx;
|
||||
int count;
|
||||
int type;
|
||||
char *name;
|
||||
size_t len;
|
||||
char *pattern;
|
||||
};
|
||||
|
||||
herr_t
|
||||
_H5Part_iteration_operator (
|
||||
hid_t group_id,
|
||||
const char *member_name,
|
||||
void *operator_data
|
||||
);
|
||||
|
||||
|
||||
void
|
||||
_H5Part_set_funcname (
|
||||
char * const fname
|
||||
);
|
||||
|
||||
const char *
|
||||
_H5Part_get_funcname (
|
||||
void
|
||||
);
|
||||
|
||||
#define SET_FNAME( fname ) _H5Part_set_funcname( fname );
|
||||
|
||||
hid_t
|
||||
_H5Part_normalize_h5_type (
|
||||
hid_t type
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
_H5Part_read_attrib (
|
||||
hid_t id,
|
||||
const char *attrib_name,
|
||||
void *attrib_value
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
_H5Part_write_attrib (
|
||||
hid_t id,
|
||||
const char *attrib_name,
|
||||
const hid_t attrib_type,
|
||||
const void *attrib_value,
|
||||
const hsize_t attrib_nelem
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
_H5Part_get_attrib_info (
|
||||
hid_t id,
|
||||
const h5part_int64_t attrib_idx,
|
||||
char *attrib_name,
|
||||
const h5part_int64_t len_attrib_name,
|
||||
h5part_int64_t *attrib_type,
|
||||
h5part_int64_t *attrib_nelem
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
_H5Part_get_num_objects (
|
||||
hid_t group_id,
|
||||
const char *group_name,
|
||||
const hid_t type
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
_H5Part_get_num_objects_matching_pattern (
|
||||
hid_t group_id,
|
||||
const char *group_name,
|
||||
const hid_t type,
|
||||
char * const pattern
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
_H5Part_get_object_name (
|
||||
hid_t group_id,
|
||||
const char *group_name,
|
||||
const hid_t type,
|
||||
const h5part_int64_t idx,
|
||||
char *obj_name,
|
||||
const h5part_int64_t len_obj_name
|
||||
);
|
||||
|
||||
void
|
||||
_H5Part_vprint_error (
|
||||
const char *fmt,
|
||||
va_list ap
|
||||
);
|
||||
|
||||
void
|
||||
_H5Part_print_error (
|
||||
const char *fmt,
|
||||
... )
|
||||
#ifdef __GNUC__
|
||||
__attribute__ ((format (printf, 1, 2)))
|
||||
#endif
|
||||
;
|
||||
|
||||
void
|
||||
_H5Part_vprint_warn (
|
||||
const char *fmt,
|
||||
va_list ap
|
||||
);
|
||||
|
||||
void
|
||||
_H5Part_print_warn (
|
||||
const char *fmt,
|
||||
...
|
||||
)
|
||||
#ifdef __GNUC__
|
||||
__attribute__ ((format (printf, 1, 2)))
|
||||
#endif
|
||||
;
|
||||
|
||||
void
|
||||
_H5Part_vprint_info (
|
||||
const char *fmt,
|
||||
va_list ap
|
||||
);
|
||||
|
||||
void
|
||||
_H5Part_print_info (
|
||||
const char *fmt,
|
||||
...
|
||||
)
|
||||
#ifdef __GNUC__
|
||||
__attribute__ ((format (printf, 1, 2)))
|
||||
#endif
|
||||
;
|
||||
|
||||
void
|
||||
_H5Part_vprint_debug (
|
||||
const char *fmt,
|
||||
va_list ap
|
||||
);
|
||||
|
||||
void
|
||||
_H5Part_print_debug (
|
||||
const char *fmt,
|
||||
...
|
||||
)
|
||||
#ifdef __GNUC__
|
||||
__attribute__ ((format (printf, 1, 2)))
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
System dependend definitions
|
||||
*/
|
||||
|
||||
#ifndef _H5PARTTYPES_H_
|
||||
#define _H5PARTTYPES_H_
|
||||
|
||||
|
||||
typedef int64_t h5part_int64_t;
|
||||
typedef double h5part_float64_t;
|
||||
typedef h5part_int64_t (*h5part_error_handler)( const char*, const h5part_int64_t, const char*,...)
|
||||
#ifdef __GNUC__
|
||||
__attribute__ ((format (printf, 3, 4)))
|
||||
#endif
|
||||
;
|
||||
|
||||
struct H5BlockFile;
|
||||
|
||||
/**
|
||||
\struct H5PartFile
|
||||
|
||||
This is an essentially opaque datastructure that
|
||||
acts as the filehandle for all practical purposes.
|
||||
It is created by H5PartOpenFile<xx>() and destroyed by
|
||||
H5PartCloseFile().
|
||||
*/
|
||||
struct H5PartFile {
|
||||
hid_t file;
|
||||
h5part_int64_t timestep;
|
||||
hsize_t nparticles;
|
||||
|
||||
hid_t timegroup;
|
||||
hid_t shape;
|
||||
unsigned mode;
|
||||
hid_t xfer_prop;
|
||||
hid_t create_prop;
|
||||
hid_t access_prop;
|
||||
hid_t diskshape;
|
||||
hid_t memshape; /* for parallel I/O (this is on-disk) H5S_ALL
|
||||
if serial I/O */
|
||||
h5part_int64_t viewstart; /* -1 if no view is available: A "view" looks */
|
||||
h5part_int64_t viewend; /* at a subset of the data. */
|
||||
|
||||
/**
|
||||
the number of particles in each processor.
|
||||
With respect to the "VIEW", these numbers
|
||||
can be regarded as non-overlapping subsections
|
||||
of the particle array stored in the file.
|
||||
So they can be used to compute the offset of
|
||||
the view for each processor
|
||||
*/
|
||||
h5part_int64_t *pnparticles;
|
||||
|
||||
/**
|
||||
Number of processors
|
||||
*/
|
||||
int nprocs;
|
||||
|
||||
/**
|
||||
The index of the processor this process is running on.
|
||||
*/
|
||||
int myproc;
|
||||
#ifdef PARALLEL_IO
|
||||
/**
|
||||
MPI comnunicator
|
||||
*/
|
||||
MPI_Comm comm;
|
||||
#endif
|
||||
struct H5BlockStruct *block;
|
||||
h5part_int64_t (*close_block)(struct H5PartFile *f);
|
||||
};
|
||||
|
||||
typedef struct H5PartFile H5PartFile;
|
||||
|
||||
#ifdef IPL_XT3
|
||||
# define SEEK_END 2
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
+303
@@ -0,0 +1,303 @@
|
||||
#ifndef _H5UNITS_H_
|
||||
#define _H5UNITS_H_
|
||||
/*!
|
||||
Defines Units and conversion factors
|
||||
|
||||
\note Derived from GEANT 4 header files G4SIunits.hh
|
||||
|
||||
The basic units are those of the International System:
|
||||
|
||||
meter
|
||||
second
|
||||
kilogram
|
||||
ampere
|
||||
degree kelvin
|
||||
the amount of substance (mole)
|
||||
luminous intensity (candela)
|
||||
radian
|
||||
steradian
|
||||
|
||||
We also define some accelerator specific units
|
||||
|
||||
MeV
|
||||
beta
|
||||
|
||||
Idea of usage: For each attribute (for example x) we have two additional
|
||||
informations, namely the attributes unit and the attributes conversion factor,
|
||||
which is the factor to convert the attributes unit into SI units.
|
||||
|
||||
Example:
|
||||
|
||||
We have a lenght attribute x and the values in x are stored in mm we then would
|
||||
have to add the following information to the attribute x: METER, 1000
|
||||
|
||||
Using the following prototypes
|
||||
|
||||
H5PartWriteUnit (H5PartFile *f, char *name, const int unit );
|
||||
H5PartWriteUnitConversionFac (H5PartFile *f, char *name, const double fac);
|
||||
|
||||
one would write
|
||||
|
||||
H5PartWriteUnit (fp,"x", METER );
|
||||
H5PartWriteUnitConversionFac (fp, "x", 1000);
|
||||
|
||||
Note: in case of BETA and GAMMA one has the know the particles mass
|
||||
not sure if that is the best solution
|
||||
|
||||
Author: Andreas Adelmann (PSI)
|
||||
Date: 15.8.2006
|
||||
|
||||
*/
|
||||
|
||||
// Define SI units
|
||||
// \note enum type would be much better, have to check f77 implications
|
||||
|
||||
#define METER 1
|
||||
#define SECOND 2
|
||||
#define KILOGRAM 3
|
||||
#define AMPERE 4
|
||||
#define DEGREE_KELVIN 5
|
||||
#define MOLE 6
|
||||
#define CANDELA 7
|
||||
#define RADIAN 8
|
||||
#define STERADIAN 9
|
||||
|
||||
// Define some accelerator specific units
|
||||
|
||||
#define MEV 10
|
||||
#define BETA 11
|
||||
#define GAMMA 12
|
||||
|
||||
//
|
||||
// Length [L]
|
||||
//
|
||||
static const double meter = 1.;
|
||||
static const double meter2 = meter*meter;
|
||||
static const double meter3 = meter*meter*meter;
|
||||
|
||||
static const double millimeter = 0.001*meter;
|
||||
static const double millimeter2 = millimeter*millimeter;
|
||||
static const double millimeter3 = millimeter*millimeter*millimeter;
|
||||
|
||||
static const double centimeter = 10.*millimeter;
|
||||
static const double centimeter2 = centimeter*centimeter;
|
||||
static const double centimeter3 = centimeter*centimeter*centimeter;
|
||||
|
||||
static const double kilometer = 1000.*meter;
|
||||
static const double kilometer2 = kilometer*kilometer;
|
||||
static const double kilometer3 = kilometer*kilometer*kilometer;
|
||||
|
||||
static const double parsec = 3.0856775807e+16*meter;
|
||||
|
||||
static const double micrometer = 1.e-6 *meter;
|
||||
static const double nanometer = 1.e-9 *meter;
|
||||
static const double angstrom = 1.e-10*meter;
|
||||
static const double fermi = 1.e-15*meter;
|
||||
|
||||
static const double barn = 1.e-28*meter2;
|
||||
static const double millibarn = 1.e-3 *barn;
|
||||
static const double microbarn = 1.e-6 *barn;
|
||||
static const double nanobarn = 1.e-9 *barn;
|
||||
static const double picobarn = 1.e-12*barn;
|
||||
|
||||
// symbols
|
||||
static const double mm = millimeter;
|
||||
static const double mm2 = millimeter2;
|
||||
static const double mm3 = millimeter3;
|
||||
|
||||
static const double cm = centimeter;
|
||||
static const double cm2 = centimeter2;
|
||||
static const double cm3 = centimeter3;
|
||||
|
||||
static const double m = meter;
|
||||
static const double m2 = meter2;
|
||||
static const double m3 = meter3;
|
||||
|
||||
static const double km = kilometer;
|
||||
static const double km2 = kilometer2;
|
||||
static const double km3 = kilometer3;
|
||||
|
||||
static const double pc = parsec;
|
||||
|
||||
//
|
||||
// Angle
|
||||
//
|
||||
static const double radian = 1.;
|
||||
static const double milliradian = 1.e-3*radian;
|
||||
static const double degree = (3.14159265358979323846/180.0)*radian;
|
||||
|
||||
static const double steradian = 1.;
|
||||
|
||||
// symbols
|
||||
static const double rad = radian;
|
||||
static const double mrad = milliradian;
|
||||
static const double sr = steradian;
|
||||
static const double deg = degree;
|
||||
|
||||
//
|
||||
// Time [T]
|
||||
//
|
||||
static const double second = 1.;
|
||||
static const double nanosecond = 1.e-9 *second;
|
||||
static const double millisecond = 1.e-3 *second;
|
||||
static const double microsecond = 1.e-6 *second;
|
||||
static const double picosecond = 1.e-12*second;
|
||||
|
||||
static const double hertz = 1./second;
|
||||
static const double kilohertz = 1.e+3*hertz;
|
||||
static const double megahertz = 1.e+6*hertz;
|
||||
|
||||
// symbols
|
||||
static const double ns = nanosecond;
|
||||
static const double s = second;
|
||||
static const double ms = millisecond;
|
||||
|
||||
//
|
||||
// Mass [E][T^2][L^-2]
|
||||
//
|
||||
static const double kilogram = 1.;
|
||||
static const double gram = 1.e-3*kilogram;
|
||||
static const double milligram = 1.e-3*gram;
|
||||
|
||||
// symbols
|
||||
static const double kg = kilogram;
|
||||
static const double g = gram;
|
||||
static const double mg = milligram;
|
||||
|
||||
//
|
||||
// Electric current [Q][T^-1]
|
||||
//
|
||||
static const double ampere = 1.;
|
||||
static const double milliampere = 1.e-3*ampere;
|
||||
static const double microampere = 1.e-6*ampere;
|
||||
static const double nanoampere = 1.e-9*ampere;
|
||||
|
||||
//
|
||||
// Electric charge [Q]
|
||||
//
|
||||
static const double coulomb = ampere*second;
|
||||
static const double e_SI = 1.60217733e-19; // positron charge in coulomb
|
||||
static const double eplus = e_SI*coulomb ; // positron charge
|
||||
|
||||
//
|
||||
// Energy [E]
|
||||
//
|
||||
static const double joule = kg*m*m/(s*s);
|
||||
|
||||
static const double electronvolt = e_SI*joule;
|
||||
static const double kiloelectronvolt = 1.e+3*electronvolt;
|
||||
static const double megaelectronvolt = 1.e+6*electronvolt;
|
||||
static const double gigaelectronvolt = 1.e+9*electronvolt;
|
||||
static const double teraelectronvolt = 1.e+12*electronvolt;
|
||||
static const double petaelectronvolt = 1.e+15*electronvolt;
|
||||
|
||||
// symbols
|
||||
static const double MeV = megaelectronvolt;
|
||||
static const double eV = electronvolt;
|
||||
static const double keV = kiloelectronvolt;
|
||||
static const double GeV = gigaelectronvolt;
|
||||
static const double TeV = teraelectronvolt;
|
||||
static const double PeV = petaelectronvolt;
|
||||
|
||||
//
|
||||
// Power [E][T^-1]
|
||||
//
|
||||
static const double watt = joule/second; // watt = 6.24150 e+3 * MeV/ns
|
||||
|
||||
//
|
||||
// Force [E][L^-1]
|
||||
//
|
||||
static const double newton = joule/meter; // newton = 6.24150 e+9 * MeV/mm
|
||||
|
||||
//
|
||||
// Pressure [E][L^-3]
|
||||
//
|
||||
#define pascal hep_pascal // a trick to avoid warnings
|
||||
static const double hep_pascal = newton/m2; // pascal = 6.24150 e+3 * MeV/mm3
|
||||
static const double bar = 100000*pascal; // bar = 6.24150 e+8 * MeV/mm3
|
||||
static const double atmosphere = 101325*pascal; // atm = 6.32420 e+8 * MeV/mm3
|
||||
|
||||
//
|
||||
// Electric potential [E][Q^-1]
|
||||
//
|
||||
static const double megavolt = megaelectronvolt/eplus;
|
||||
static const double kilovolt = 1.e-3*megavolt;
|
||||
static const double volt = 1.e-6*megavolt;
|
||||
|
||||
//
|
||||
// Electric resistance [E][T][Q^-2]
|
||||
//
|
||||
static const double ohm = volt/ampere; // ohm = 1.60217e-16*(MeV/eplus)/(eplus/ns)
|
||||
|
||||
//
|
||||
// Electric capacitance [Q^2][E^-1]
|
||||
//
|
||||
static const double farad = coulomb/volt; // farad = 6.24150e+24 * eplus/Megavolt
|
||||
static const double millifarad = 1.e-3*farad;
|
||||
static const double microfarad = 1.e-6*farad;
|
||||
static const double nanofarad = 1.e-9*farad;
|
||||
static const double picofarad = 1.e-12*farad;
|
||||
|
||||
//
|
||||
// Magnetic Flux [T][E][Q^-1]
|
||||
//
|
||||
static const double weber = volt*second; // weber = 1000*megavolt*ns
|
||||
|
||||
//
|
||||
// Magnetic Field [T][E][Q^-1][L^-2]
|
||||
//
|
||||
static const double tesla = volt*second/meter2; // tesla =0.001*megavolt*ns/mm2
|
||||
|
||||
static const double gauss = 1.e-4*tesla;
|
||||
static const double kilogauss = 1.e-1*tesla;
|
||||
|
||||
//
|
||||
// Inductance [T^2][E][Q^-2]
|
||||
//
|
||||
static const double henry = weber/ampere; // henry = 1.60217e-7*MeV*(ns/eplus)**2
|
||||
|
||||
//
|
||||
// Temperature
|
||||
//
|
||||
static const double kelvin = 1.;
|
||||
|
||||
//
|
||||
// Amount of substance
|
||||
//
|
||||
static const double mole = 1.;
|
||||
|
||||
//
|
||||
// Activity [T^-1]
|
||||
//
|
||||
static const double becquerel = 1./second ;
|
||||
static const double curie = 3.7e+10 * becquerel;
|
||||
|
||||
//
|
||||
// Absorbed dose [L^2][T^-2]
|
||||
//
|
||||
static const double gray = joule/kilogram ;
|
||||
|
||||
//
|
||||
// Luminous intensity [I]
|
||||
//
|
||||
static const double candela = 1.;
|
||||
|
||||
//
|
||||
// Luminous flux [I]
|
||||
//
|
||||
static const double lumen = candela*steradian;
|
||||
|
||||
//
|
||||
// Illuminance [I][L^-2]
|
||||
//
|
||||
static const double lux = lumen/meter2;
|
||||
|
||||
//
|
||||
// Miscellaneous
|
||||
//
|
||||
static const double perCent = 0.01 ;
|
||||
static const double perThousand = 0.001;
|
||||
static const double perMillion = 0.000001;
|
||||
|
||||
|
||||
#endif
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
# src level Makefile.am
|
||||
|
||||
# PATH SETTING (IMPORTED FROM CONFIGURE)
|
||||
HDF5ROOT = @HDF5ROOT@
|
||||
PHDF5ROOT = @PHDF5ROOT@
|
||||
|
||||
# COMPILERS
|
||||
CC = @CC@
|
||||
MPICC = @MPICC@
|
||||
|
||||
# COMPILER FLAGS
|
||||
CFLAGS = @CFLAGS@
|
||||
PCFLAGS = $(CFLAGS) -DPARALLEL_IO -DH5_HAVE_PARALLEL -DMPICH_IGNORE_CXX_SEEK
|
||||
|
||||
#INCLUDES
|
||||
HDFINC = -I$(HDF5ROOT)/include
|
||||
PHDFINC = -I$(PHDF5ROOT)/include
|
||||
PINC = $(PHDFINC) $(MPIINC)
|
||||
INC = $(HDFINC)
|
||||
MPIINC = @MPIINC@
|
||||
|
||||
# H5Part header file location
|
||||
H5PINC = -I@prefix@/include
|
||||
|
||||
# H5Part compiled library location
|
||||
H5PLIB = -L@prefix@/lib
|
||||
|
||||
# HDF5 LIBRARY
|
||||
HDFLIB = -L$(HDF5ROOT)/lib -lhdf5 -lz $(SZLIB) @LDFLAGS@
|
||||
|
||||
# SZ LIBRARY
|
||||
SZLIB = @SZLIB@
|
||||
|
||||
# Extra files that I wish to include in the dist tar ball.
|
||||
EXTRA_DIST = H5Part.cc H5Part++.cc H5Part++.hh TestUnderscoreC.c TestUnderscore.f COPYRIGHT
|
||||
|
||||
# Files that I don't want to include in the dist tar ball
|
||||
nodist_include_HEADERS = @UNDERSCORE_H@
|
||||
|
||||
# What to build... Will be determined by configure script.
|
||||
lib_LIBRARIES = @MTARGET@
|
||||
|
||||
# Listing of all possible targets that I may build.
|
||||
EXTRA_LIBRARIES = libH5Part.a libH5PartF.a libpH5Part.a libpH5PartF.a
|
||||
|
||||
# Header files that I wish to install in $(prefix)/include
|
||||
include_HEADERS = H5Part.inc H5Part.h H5Part.hh @UNDERSCORE_H@
|
||||
|
||||
# Listing of all possible headers that I may include
|
||||
EXTRA_HEADERS = H5Part.inc H5Part.h H5Part.hh Underscore.h
|
||||
|
||||
# Listing of sources
|
||||
libH5Part_a_SOURCES = H5Part.c H5Block.c
|
||||
|
||||
libH5PartF_a_SOURCES = H5Part.c H5PartF.c H5Block.c
|
||||
|
||||
libpH5Part_a_SOURCES = H5Part.c H5Block.c
|
||||
|
||||
libpH5PartF_a_SOURCES = H5Part.c H5PartF.c H5Block.c
|
||||
|
||||
|
||||
H5Part.inc: H5PartF90.inc
|
||||
grep "INTEGER.* FUNCTION" $< | while read type func name rest; do echo " $$type $$name"; done > $@
|
||||
|
||||
# Specific building instruction (What compilers to use...)
|
||||
# ------------ Serial Lib build commands ------------
|
||||
libH5Part.a: H5Part.o H5Block.o
|
||||
${AR} rucs $@ $^
|
||||
|
||||
libH5PartF.a: H5Part.o H5PartF.o H5Block.o
|
||||
${AR} rucs $@ $^
|
||||
|
||||
H5Part.o: H5Part.c H5Part.h H5PartPrivate.h H5PartTypes.h
|
||||
$(CC) $(CFLAGS) $(INC) -c $<
|
||||
|
||||
H5Block.o: H5Block.c H5Part.h H5PartPrivate.h H5PartTypes.h H5Block.h H5BlockTypes.h
|
||||
$(CC) $(CFLAGS) $(INC) -c $<
|
||||
|
||||
H5PartF.o: H5PartF.c Underscore.h H5Part.h
|
||||
$(CC) $(CFLAGS) $(INC) -w -c $<
|
||||
|
||||
|
||||
# ----------- Build Parallel H5Part Stuff ------------
|
||||
|
||||
libpH5Part.a: pH5Part.o pH5Block.o
|
||||
${AR} rucs $@ $^
|
||||
|
||||
libpH5PartF.a: pH5Part.o pH5PartF.o pH5Block.o
|
||||
${AR} rucs $@ $^
|
||||
|
||||
pH5Part.o: H5Part.c H5Part.h H5PartPrivate.h H5PartTypes.h
|
||||
$(MPICC) $(CFLAGS) $(INC) -c $< -o $@
|
||||
|
||||
pH5Block.o: H5Block.c H5Part.h H5PartPrivate.h H5PartTypes.h H5Block.h H5BlockTypes.h
|
||||
$(MPICC) $(CFLAGS) $(INC) -c $< -o $@
|
||||
|
||||
|
||||
pH5PartF.o: H5PartF.c Underscore.h H5Part.h
|
||||
$(MPICC) $(PCFLAGS) $(PINC) -w -c $< -o $@
|
||||
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o *.a *.so
|
||||
|
||||
distclean: clean
|
||||
rm -f *.a
|
||||
rm -rf .deps
|
||||
rm -rf .libs
|
||||
rm -f Underscore.h
|
||||
rm -f H5Part_py_wrap.c
|
||||
rm -f H5Part.py
|
||||
rm -f Makefile
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
c ==============
|
||||
c
|
||||
c Simple Fortran program works in conjunction with C program
|
||||
c to determine how many underscores are generated
|
||||
c by the fortran compiler
|
||||
c
|
||||
c ==============
|
||||
|
||||
program TestUnderscoreF
|
||||
implicit none
|
||||
call FindUnderscores
|
||||
end
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void findunderscores(void){
|
||||
printf("#ifndef F77_NO_UNDERSCORE\n");
|
||||
printf("#define F77_NO_UNDERSCORE\n");
|
||||
printf("#endif\n");
|
||||
printf("#ifndef F77_NO_CAPS\n");
|
||||
printf("#define F77_NO_CAPS\n");
|
||||
printf("#endif\n");
|
||||
}
|
||||
|
||||
void FindUnderscores(void){
|
||||
printf("#ifndef F77_NO_UNDERSCORE\n");
|
||||
printf("#define F77_NO_UNDERSCORE\n");
|
||||
printf("#endif\n");
|
||||
}
|
||||
|
||||
void FindUnderscores_(void){
|
||||
printf("#ifndef F77_SINGLE_UNDERSCORE\n");
|
||||
printf("#define F77_SINGLE_UNDERSCORE\n");
|
||||
printf("#endif\n");
|
||||
}
|
||||
|
||||
void findunderscores_(void){
|
||||
printf("#ifndef F77_SINGLE_UNDERSCORE\n");
|
||||
printf("#define F77_SINGLE_UNDERSCORE\n");
|
||||
printf("#endif\n");
|
||||
printf("#ifndef F77_NO_CAPS\n");
|
||||
printf("#define F77_NO_CAPS\n");
|
||||
printf("#endif\n");
|
||||
}
|
||||
void FINDUNDERSCORES(void){
|
||||
printf("#ifndef F77_CRAY_UNDERSCORE\n");
|
||||
printf("#define F77_CRAY_UNDERSCORE\n");
|
||||
printf("#endif\n");
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*! \mainpage
|
||||
<H1>H5Part: a Portable High Performance Parallel Data Interface to HDF5
|
||||
</H1>
|
||||
<P>
|
||||
<B>
|
||||
Particle based simulations of accelerator beam-lines, especially in six dimensional phase space, generate vast amounts of data.
|
||||
Even though a subset of statistical information regarding phase space or analysis needs to be preserved, reading and writing such enormous restart
|
||||
files on massively parallel supercomputing systems remains challenging.
|
||||
<P>
|
||||
H5Part consists of Particles, Block structured Fields and unstructured data (Topo). <P>
|
||||
Developed by .
|
||||
</B>
|
||||
<P>
|
||||
For further information contact: <a href="mailto:xxxxx">xxxxxx</a> -
|
||||
xxxx xxxxx, (xxx) xxx.
|
||||
<P>
|
||||
Last modified on xxx xx, 2006.
|
||||
<p>
|
||||
Papers:
|
||||
<P>
|
||||
<a href="http://www-vis.lbl.gov/Research/AcceleratorSAPP/index.html">LBNL Vis Group </a><br>
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user