00001 #include "H5Part.h"
00002 #include "Underscore.h"
00003 #include <hdf5.h>
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifdef F77_SINGLE_UNDERSCORE
00020 #define F77NAME(a,b,c) a
00021 #elif defined(F77_NO_UNDERSCORE)
00022 #define F77NAME(a,b,c) b
00023 #elif defined(F77_CRAY_UNDERSCORE)
00024 #define F77NAME(a,b,c) c
00025 #else
00026 #error Error, no way to determine how to construct fortran bindings
00027 #endif
00028
00029 #if 0
00030 #define f_h5pt_openr F77NAME(h5prt_openr_,h5prt_openr,H5PRT_OPENR)
00031 #define f_h5pt_openw F77NAME(h5prt_openw_,h5prt_openw,H5PRT_OPENW)
00032 #define f_h5pt_close F77NAME(h5prt_close_,h5prt_close,H5PRT_CLOSE)
00033 #define f_h5pt_npoints F77NAME(h5prt_npoints_,h5prt_npoints,H5PRT_NPOINTS)
00034 #define f_h5pt_ndata F77NAME(h5prt_ndata_,h5prt_ndata,H5PRT_NDATA)
00035 #define f_h5pt_nstep F77NAME(h5prt_nstep_,h5prt_nstep,H5PRT_NSTEP)
00036 #define f_h5pt_readstep F77NAME(h5prt_readstep_,h5prt_readstep,H5PRT_READSTEP)
00037 #define f_h5pt_step F77NAME(h5prt_step_,h5prt_step,H5PRT_STEP)
00038 #define f_h5pt_wreal8 F77NAME(h5prt_wreal8_,h5prt_wreal8,H5PRT_WREAL8)
00039 #define f_h5pt_wint8 F77NAME(h5prt_wint8_,h5prt_wint8,H5PRT_WINT8)
00040 #endif
00041
00042
00043 #define f_h5pt_openr F77NAME(h5pt_openr_,h5pt_openr,H5PT_OPENR)
00044 #define f_h5pt_openw F77NAME(h5pt_openw_,h5pt_openw,H5PT_OPENW)
00045
00046 #define f_h5pt_openr_par F77NAME(h5pt_openr_par_,h5pt_openr_par,H5PT_OPENR_PAR)
00047 #define f_h5pt_openw_par F77NAME(h5pt_openw_par_,h5pt_openw_par,H5PT_OPENW_PAR)
00048 #define f_h5pt_close F77NAME(h5pt_close_,h5pt_close,H5PT_CLOSE)
00049 #define f_h5pt_isvalid F77NAME(h5pt_isvalid_,h5pt_isvalid,H5PT_ISVALID)
00050
00051
00052 #define f_h5pt_setnpoints F77NAME(h5pt_setnpoints_,h5pt_setnpoints,H5PT_SETNPOINTS)
00053 #define f_h5pt_setstep F77NAME(h5pt_setstep_,h5pt_setstep,H5PT_SETSTEP)
00054 #define f_h5pt_writedata_r8 F77NAME(h5pt_writedata_r8_,h5pt_writedata_r8,H5PT_WRITEDATA_R8)
00055 #define f_h5pt_writedata_i8 F77NAME(h5pt_writedata_i8_,h5pt_writedata_i8,H5PT_WRITEDATA_I8)
00056
00057
00058 #define f_h5pt_getnsteps F77NAME(h5pt_getnsteps_,h5pt_getnsteps,H5PT_GETNSTEPS)
00059 #define f_h5pt_getndatasets F77NAME(h5pt_getndatasets_,h5pt_getndatasets,H5PT_GETNDATASETS)
00060 #define f_h5pt_getnpoints F77NAME(h5pt_getnpoints_,h5pt_getnpoints,H5PT_GETNPOINTS)
00061 #define f_h5pt_getdatasetname F77NAME(h5pt_getdatasetname_,h5pt_getdatasetname,H5PT_GETDATASETNAME)
00062
00063
00064 #define f_h5pt_setview F77NAME(h5pt_setview_,h5pt_setview,H5PT_SETVIEW)
00065 #define f_h5pt_resetview F77NAME(h5pt_resetview_,h5pt_resetview,H5PT_RESETVIEW)
00066 #define f_h5pt_hasview F77NAME(h5pt_hasview_,h5pt_hasview,H5PT_HASVIEW)
00067
00068
00069 #define f_h5pt_readdata_r8 F77NAME(h5pt_readdata_r8_,h5pt_readdata_r8,H5PT_READDATA_R8)
00070 #define f_h5pt_readdata_i8 F77NAME(h5pt_readdata_i8_,h5pt_readdata_i8,H5PT_READDATA_I8)
00071 #define f_h5pt_readdata F77NAME(h5pt_readdata_,h5pt_readdata,H5PT_READDATA)
00072
00073
00074
00075 #define f_h5pt_writefileattrib_r8 F77NAME(h5pt_writefileattrib_r8_,h5pt_writefileattrib_r8,H5PT_WRITEFILEATTRIB_R8)
00076 #define f_h5pt_writefileattrib_i8 F77NAME(h5pt_writefileattrib_i8_,h5pt_writefileattrib_i8,H5PT_WRITEFILEATTRIB_I8)
00077 #define f_h5pt_writefileattrib_string F77NAME(h5pt_writefileattrib_string_,h5pt_writefileattrib_string,H5PT_writefileattrib_string)
00078 #define f_h5pt_writestepattrib_r8 F77NAME(h5pt_writestepattrib_r8_,h5pt_writestepattrib_r8,H5PT_WRITESTEPATTRIB_R8)
00079 #define f_h5pt_writestepattrib_i8 F77NAME(h5pt_writestepattrib_i8_,h5pt_writestepattrib_i8,H5PT_WRITESTEPATTRIB_I8)
00080 #define f_h5pt_writestepattrib_string F77NAME(h5pt_writestepattrib_string_,h5pt_writestepattrib_string,H5PT_WRITESTEPATTRIB_STRING)
00081
00082 #define f_h5pt_getnstepattribs F77NAME(h5pt_getnstepattribs_,h5pt_getnstepattribs,H5PT_GETNSTEPATTRIBS)
00083 #define f_h5pt_getnfileattribs F77NAME(h5pt_getnfileattribs_,h5pt_getnfileattribs,H5PT_GETNFILEATTRIBS)
00084 #define f_h5pt_getstepattribinfo F77NAME(h5pt_getstepattribinfo_,h5pt_getstepattribinfo,H5PT_GETSTEPATTRIBINFO)
00085 #define f_h5pt_getfileattribinfo F77NAME(h5pt_getfileattribinfo_,h5pt_getfileattribinfo,H5PT_GETFILEATTRIBINFO)
00086 #define f_h5pt_readstepattrib F77NAME(h5pt_readstepattrib_,h5pt_readstepattrib,H5PT_READSTEPATTRIB)
00087 #define f_h5pt_readfileattrib F77NAME(h5pt_readfileattrib_,h5pt_readfileattrib,H5PT_READFILEATTRIB)
00088
00089
00090
00091 haddr_t f_h5pt_openr(char *file,int flen){
00092 haddr_t fh;
00093 H5PartFile* f;
00094 file[flen]='\0';
00095 f = (H5PartOpenFile(file,H5PART_READ));
00096
00097 fh = (haddr_t)f;
00098
00099 return fh;
00100 }
00101
00102 haddr_t f_h5pt_openw(char *file,int flen){
00103 haddr_t fh;
00104 H5PartFile* f;
00105 file[flen]='\0';
00106 f = (H5PartOpenFile(file,H5PART_WRITE));
00107
00108 fh = (haddr_t)f;
00109
00110 return fh;
00111 }
00112
00113 #ifdef PARALLEL_IO
00114 haddr_t f_h5pt_openr_par(char *file,void *c,int flen){
00115 haddr_t fh;
00116 H5PartFile* f;
00117 file[flen]='\0';
00118 #ifdef PARALLEL_IO
00119 f = H5PartOpenFileParallel(file,H5PART_READ,*((MPI_Comm*)c));
00120
00121 #else
00122 f=H5PartOpenFile(file,H5PART_READ);
00123 #endif
00124 fh = (haddr_t)f;
00125
00126 return fh;
00127 }
00128 haddr_t f_h5pt_openw_par(char *file,MPI_Comm *c,int flen){
00129 haddr_t fh;
00130 H5PartFile* f;
00131 file[flen]='\0';
00132 #ifdef PARALLEL_IO
00133 f = H5PartOpenFileParallel(file,H5PART_WRITE,*((MPI_Comm*)c));
00134
00135 #else
00136 f=H5PartOpenFile(file,H5PART_WRITE);
00137 #endif
00138 fh = (haddr_t)f;
00139
00140 return fh;
00141 }
00142 #endif
00143
00144 void f_h5pt_close(haddr_t *file){
00145 H5PartCloseFile((H5PartFile*)*file);
00146 }
00147
00148 int f_h5pt_isvalid(haddr_t *file){
00149 return H5PartFileIsValid((H5PartFile*)*file);
00150 }
00151
00152
00153 #if 0
00154 void f_h5pt_readstep(haddr_t *file,int *step,
00155 double *x,double *y,double *z,
00156 double *px,double *py,double *pz,
00157 void *id){
00158 H5PartReadParticleStep((H5PartFile*)*file,(*step)-1,x,y,z,px,py,pz,(long long*)id);
00159 }
00160 #endif
00161
00162 void f_h5pt_setnpoints(haddr_t *file,uint64_t *np){
00163 H5PartSetNumParticles((H5PartFile*)*file,*np);
00164 }
00165
00166 void f_h5pt_setstep(haddr_t *file,int *step){
00167 H5PartSetStep((H5PartFile*)*file,(*step)-1);
00168 }
00169
00170 void f_h5pt_writedata_r8(haddr_t *file,
00171 char *name,void *data,int flen){
00172 name[flen]='\0';
00173 H5PartWriteDataFloat64((H5PartFile*)*file,name,(double*)data);
00174 }
00175
00176 void f_h5pt_writedata_i8(haddr_t *file,
00177 char *name,void *data,int flen){
00178 name[flen]='\0';
00179 H5PartWriteDataInt64((H5PartFile*)*file,name,(long long*)data);
00180 }
00181
00182
00183
00184 int f_h5pt_getnsteps(haddr_t *file){
00185
00186 return H5PartGetNumSteps((H5PartFile*)*file);
00187 }
00188
00189 int f_h5pt_getndatasets(haddr_t *file){
00190
00191 return H5PartGetNumDatasets((H5PartFile*)*file);
00192 }
00193
00194 haddr_t f_h5pt_getnpoints(haddr_t *file){
00195
00196 return H5PartGetNumParticles((H5PartFile*)*file);
00197 }
00198
00199
00200 int f_h5pt_getdatasetname(haddr_t *file,int *index,char *name,int namelen){
00201 return H5PartGetDatasetName((H5PartFile *)*file,*index,name,namelen);
00202 }
00203
00204 uint64_t f_h5pt_getnumpoints(haddr_t *file){
00205 return H5PartGetNumParticles((H5PartFile*)*file);
00206 }
00207
00208
00209
00210 void f_h5pt_setview(haddr_t *file,int64_t *start,int64_t *end){
00211 H5PartSetView((H5PartFile*)*file,*start,*end);
00212 }
00213
00214 void f_h5pt_resetview(haddr_t *file){
00215 H5PartResetView((H5PartFile*)*file);
00216 }
00217
00218 int f_h5pt_hasview(haddr_t *file){
00219 return H5PartHasView(((H5PartFile*)*file));
00220 }
00221
00222 void f_h5pt_getview(haddr_t *file,int64_t *start,int64_t *end){
00223 H5PartGetView((H5PartFile*)*file,start,end);
00224 }
00225
00226 int f_h5pt_readdata_r8(haddr_t *file,char *name,void *array,int namelen){
00227 int r;
00228 char *newname = (char*)malloc(namelen+1);
00229 strncpy(newname,name,namelen);
00230 newname[namelen]='\0';
00231 r=H5PartReadDataFloat64((H5PartFile*)*file,newname,array);
00232 free(newname);
00233 return r;
00234 }
00235 int f_h5pt_readdata_i8(haddr_t *file,char *name,void *array,int namelen){
00236 int r;
00237 char *newname = (char*)malloc(namelen+1);
00238 strncpy(newname,name,namelen);
00239 newname[namelen]='\0';
00240 r=H5PartReadDataInt64((H5PartFile*)*file,newname,array);
00241 free(newname);
00242 return r;
00243 }
00244
00245
00246
00247
00248
00249 int f_h5pt_writefileattrib_r8(haddr_t *f,char *name,
00250 void *attrib,int *nelem,int namelen){
00251 int r;
00252 char *newname = (char*)malloc(namelen+1);
00253 strncpy(newname,name,namelen);
00254 newname[namelen]='\0';
00255 r=H5PartWriteFileAttrib((H5PartFile *)*f,newname,
00256 H5T_NATIVE_DOUBLE,attrib,*nelem);
00257 free(newname);
00258 return r;
00259 }
00260
00261 int f_h5pt_writefileattrib_i8(haddr_t *f,char *name,
00262 void *attrib,int *nelem,int namelen){
00263 int r;
00264 char *newname = (char*)malloc(namelen+1);
00265 strncpy(newname,name,namelen);
00266 newname[namelen]='\0';
00267 r=H5PartWriteFileAttrib((H5PartFile *)*f,newname,
00268 H5T_NATIVE_INT64,attrib,*nelem);
00269 free(newname);
00270 return r;
00271 }
00272
00273 int f_h5pt_writefileattrib_string(haddr_t *f,char *name,
00274 char *attrib,int namelen,int attriblen){
00275 int r;
00276 char *newattrib;
00277 char *newname;
00278 newname = (char*)malloc(namelen+1);
00279 strncpy(newname,name,namelen);
00280 newname[namelen]='\0';
00281 newattrib = (char*)malloc(attriblen+1);
00282 strncpy(newattrib,attrib,attriblen);
00283 newattrib[attriblen]='\0';
00284 r=H5PartWriteFileAttribString((H5PartFile *)*f,newname,newattrib);
00285 free(newname);
00286 free(newattrib);
00287 return r;
00288 }
00289
00290 int f_h5pt_writestepattrib_r8(haddr_t *f,char *name,
00291 void *attrib,int *nelem,int namelen){
00292 int r;
00293 char *newname = (char*)malloc(namelen+1);
00294 strncpy(newname,name,namelen);
00295 newname[namelen]='\0';
00296 r=H5PartWriteStepAttrib((H5PartFile *)*f,newname,
00297 H5T_NATIVE_DOUBLE,attrib,*nelem);
00298 free(newname);
00299 return r;
00300 }
00301
00302 int f_h5pt_writestepattrib_i8(haddr_t *f,char *name,
00303 void *attrib,int *nelem,int namelen){
00304 int r;
00305 char *newname = (char*)malloc(namelen+1);
00306 strncpy(newname,name,namelen);
00307 newname[namelen]='\0';
00308 r=H5PartWriteStepAttrib((H5PartFile *)*f,newname,
00309 H5T_NATIVE_INT64,attrib,*nelem);
00310 free(newname);
00311 return r;
00312 }
00313
00314 int f_h5pt_writestepattrib_string(haddr_t *f,char *name,
00315 char *attrib,int namelen,int attriblen){
00316 int r;
00317 char *newattrib;
00318 char *newname;
00319 newname = (char*)malloc(namelen+1);
00320 strncpy(newname,name,namelen);
00321 newname[namelen]='\0';
00322 newattrib = (char*)malloc(attriblen+1);
00323 strncpy(newattrib,attrib,attriblen);
00324 newattrib[attriblen]='\0';
00325 r=H5PartWriteStepAttribString((H5PartFile *)*f,newname,newattrib);
00326 free(newname);
00327 free(newattrib);
00328 return r;
00329 }
00330
00331
00332 int f_h5pt_getnstepattribs(haddr_t *f){
00333 return H5PartGetNumStepAttribs((H5PartFile*)*f);
00334 }
00335
00336 int f_h5pt_getnfileattribs(haddr_t *f){
00337 return H5PartGetNumFileAttribs((H5PartFile*)*f);
00338 }
00339
00340 int f_h5pt_getstepattribinfo(haddr_t *f,int *idx,char *name,
00341 int *nelem,int maxnamelen){
00342 hid_t type;
00343 H5PartGetStepAttribInfo((H5PartFile*)*f,*idx,name,maxnamelen,&type,nelem);
00344 return 1;
00345 }
00346
00347 int f_h5pt_getfileattribinfo(haddr_t *f,int *idx,char *name,
00348 int *nelem,int maxnamelen){
00349 hid_t type;
00350 H5PartGetFileAttribInfo((H5PartFile*)*f,*idx,name,maxnamelen,&type,nelem);
00351 return 1;
00352 }
00353
00354 int f_h5pt_readstepattrib(haddr_t *f,char *name,void *data,int namelen){
00355 int r;
00356 char *newname = (char*)malloc(namelen+1);
00357 strncpy(newname,name,namelen);
00358 newname[namelen]='\0';
00359 H5PartReadStepAttrib((H5PartFile*)*f,newname,data);
00360 }
00361
00362 int f_h5pt_readfileattrib(haddr_t *f,char *name,void *data,int namelen){
00363 int r;
00364 char *newname = (char*)malloc(namelen+1);
00365 strncpy(newname,name,namelen);
00366 newname[namelen]='\0';
00367 H5PartReadFileAttrib((H5PartFile*)*f,newname,data);
00368 }