Merged changes from LBL, including:

* read/write call variants for different datatypes
* HDF5 properties tuned for lustre filesystems and the Cray XT (enabled using flags passed during file open)
* HDF5 chunking for field data
* HDF5 alignment (set during file open)
* support for both HDF5 1.6 and 1.8 using #if statements
* a new error reporting level: debug_detail (HDF5 errors are now printed at debug level 1 by default)

These changes have undergone limited testing.
I will begin using this version for my H5Part projects so that I can test it more thoroughly.

~Mark
This commit is contained in:
Marc Howison
2009-06-18 20:29:02 +00:00
parent a2d2a02cd2
commit 122e913f08
30 changed files with 3763 additions and 1065 deletions
+7 -1
View File
@@ -1,8 +1,9 @@
* text=auto !eol
/AUTHORS -text
/COPYRIGHT -text
/COPYING -text
/ChangeLog -text
/GNUmakefile.orig -text
/INSTALL -text
/Makefile.am -text
/Makefile.orig -text
/NEWS -text
@@ -27,6 +28,10 @@ src/H5BlockErrors.h -text
src/H5BlockF.c -text
src/H5BlockF90.inc -text
src/H5BlockPrivate.h -text
src/H5BlockReadWrite.c -text
src/H5BlockReadWrite.h -text
src/H5BlockReadWriteF.c -text
src/H5BlockReadWriteF90.inc -text
src/H5BlockTypes.h -text
src/H5Part.c -text
src/H5Part.h -text
@@ -38,6 +43,7 @@ src/H5PartTypes.h -text
src/Makefile.am -text
src/TestUnderscore.f -text
src/TestUnderscoreC.c -text
src/generate-h5bl-readwrite.py -text
test/Bench.c -text
test/BlockTestSpecs.txt -text
test/H5BlockDissolveGhosts.c -text
+1
View File
@@ -6,5 +6,6 @@ Benedikt Oswald (PSI)
Wes Bethel (NERSC/LBNL)
John Shalf (NERSC/LBNL)
Cristina Siegerist (NERSC/LBNL)
Mark Howison (NERSC/LBNL)
Please use h5part@lists.psi.ch for communicaion.
+71
View File
@@ -0,0 +1,71 @@
*** Copyright Notice ***
H5Part Copyright (c) 2006-2009, The Regents of the University of California,
through Lawrence Berkeley National Laboratory (subject to receipt of any
required approvals from the U.S. Dept. of Energy) and the Paul Scherrer
Institut (Switzerland). All rights reserved.
If you have questions about your rights to use or distribute this
software, please contact Berkeley Lab's Technology Transfer Department
at TTD@lbl.gov referring to "H5Part (LBNL Ref CR-2255)"
NOTICE. This software was developed under partial funding from the U.S.
Department of Energy. As such, the U.S. Government has been granted for
itself and others acting on its behalf a paid-up, nonexclusive,
irrevocable, worldwide license in the Software to reproduce, prepare
derivative works, and perform publicly and display publicly. Beginning
five (5) years after the date permission to assert copyright is obtained
from the U.S. Department of Energy, and subject to any subsequent five
(5) year renewals, the U.S. Government is granted for itself and others
acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide
license in the Software to reproduce, prepare derivative works,
distribute copies to the public, perform publicly and display publicly,
and to permit others to do so.
*** License agreement ***
H5Part Copyright (c) 2006-2009, The Regents of the University of California,
through Lawrence Berkeley National Laboratory (subject to receipt of any
required approvals from the U.S. Dept. of Energy) and the Paul Scherrer
Institut (Switzerland). All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
(1) Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
(2) Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
(3) Neither the name of the University of California, Lawrence Berkeley
National Laboratory, U.S. Dept. of Energy, Paul Scherrer Institut
(Switzerland) nor the names of its contributors may be used to endorse
or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
You are under no obligation whatsoever to provide any bug fixes,
patches, or upgrades to the features, functionality or performance of
the source code ("Enhancements") to anyone; however, if you choose to
make your Enhancements available either publicly, or directly to
Lawrence Berkeley National Laboratory, without imposing a separate
written license agreement for such Enhancements, then you hereby grant
the following license: a non-exclusive, royalty-free perpetual license
to install, use, modify, prepare derivative works, incorporate into
other computer software, distribute, and sublicense such enhancements or
derivative works thereof, in binary and source code form.
-7
View File
@@ -1,7 +0,0 @@
*** Copyright Notice ***
H5Part Copyright (c) 2006, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy) and the Paul Scherrer Institut (Switzerland). All rights reserved.
If you have questions about your rights to use or distribute this software, please contact Berkeley Lab's Technology Transfer Department at TTD@lbl.gov referring to "H5Part (LBNL Ref CR-2255)"
NOTICE. This software was developed under partial funding from the U.S. Department of Energy. As such, the U.S. Government has been granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide license in the Software to reproduce, prepare derivative works, and perform publicly and display publicly. Beginning five (5) years after the date permission to assert copyright is obtained from the U.S. Department of Energy, and subject to any subsequent five (5) year renewals, the U.S. Government is granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide license in the Software to reproduce, prepare derivative works, distribute copies to the public, perform publicly and display publicly, and to permit others to do so.
+437
View File
@@ -0,0 +1,437 @@
==============================================================================
README file for H5Part configure
==============================================================================
+ 0. HDF5 library
-----------------
Make sure you have a working version of the HDF5 library installed. If you plan
to use parallel I/O you need to use a parallel HDF5 version. Source files and
installation instructions are available from the HDF5 website:
http://www.hdfgroup.org/HDF5/
+ 1. Quick start (If you feel lucky...)
----------------------------------------
For many platforms, where compilers are installed in the "default" location
and all the environment variables are set correctly, it should be sufficient
to type:
./configure [OPTIONS] && make [install]
to have the libraries and test program compiled.
+ 2. Configure line options
----------------------------
To view a full list of configure option, use:
./configure --help
(1) Enable options
--enable-fortran
--enable-parallel
--enable-tools
--enable-python
--enable-64 (only for AIX and Irix)
(2) Setting compilers related variables manually
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE before running configure. For example, if you are using the bash
shell, you might type:
export CC=gcc
to set the default C compiler. See below for descriptions of some useful
variables.
Compiler environment variables:
CC C compiler command
CXX C++ compiler command
FC Fortran compiler command
MPICC MPI-enabled C compiler command
MPICXX MPI-enabled C++ compiler command
MPIFC MPI-enabled Fortran compiler command
CFLAGS flags to append when invoking the C compiler
Library environment variables:
LDFLAGS flags to append when invoking the linker
(3) Setting prefix for installation manually (by default, the package will
install itself in the 'build' subdirectory of your source directory)
--prefix=PREFIX install files in PREFIX
+ 3. Platform specific settings for compiling libraries & test programs
------------------------------------------------------------------------
Building
make : builds the libraries and test programs
make install: builds and installs
make clean : removes extraneous object files
make distclean : returns configuration to unconfigured state
As tested on hosts:
(0) Franklin <franklin.nersc.gov> (CNL - Cray XT4)
--------------------------------------------------
module add hdf5_par
module add zlib
module add szip
export CC=cc CXX=CC FC=ftn MPICC=cc MPICXX=CC MPIFC=ftn
export LDFLAGS=$HDF5
./configure --enable-fortran --enable-parallel --with-hdf5path=$HDF5_PAR_DIR --with-mpiposix
make install
(1) Davinci <davinci.nersc.gov> (Linux"SUSE"-ia64)
---------------------------------------------------
FIRST THING FIRST!! Type:
module load intel
to have the proper compilers set up for use.
module load hdf5_par
[NOTE: module load hdf5 does not work at this moment.
Possible installation error of HDF5 on Davinci.]
Brief profile:
CC = icc
CXX = icc
FC = ifort
MPICC = icc
MPICXX = icc
MPIFC = ifort
If default doesn't work, try:
For C shell:
env CC=icc CXX=icc FC=ifort MPICC=icc MPICXX=icc MPIFC=ifort ./configure && make install
For Korn or Bourne shell:
CC=icc CXX=icc FC=ifort MPICC=icc MPICXX=icc MPIFC=ifort ./configure && make install
And, of course, you should add configure options, such as --enable-fortran --enable-parallel.
On this host, executing:
For C shell:
env CC=icc CXX=icc FC=ifort MPICC=icc MPICXX=icc MPIFC=ifort ./configure --enable-fortran --enable-parallel && make install
For Korn or Bourne shell:
CC=icc CXX=icc FC=ifort MPICC=icc MPICXX=icc MPIFC=ifort ./configure --enable-fortran --enable-parallel && make install
has functioned correctly.
To run test program, go to test directory:
(i) Serial test
run:
./H5testF
./H5PartTest
(ii) Parallel test
run:
mpirun 2 H5testFpar
mpirun 2 H5PartTestP
NOTE: Number 2 above is a arbitrary number that indicates the number of processes.
(2) Jacquard <jacquard.nersc.gov> (Linux"SUSE"-x86_64)
-------------------------------------------------------
Brief profile:
CC = pathcc
CXX = pathCC
FC = pathf90
MPICC = mpicc
MPICXX = mpicxx
MPIFC = mpif90
If default doesn't work, try:
For C shell:
env CC=pathcc CXX=pathCC FC=pathf90 MPICC=mpicc MPICXX=mpicxx MPIFC=mpif90 ./configure && make install
For Korn or Bourne shell:
CC=pathcc CXX=pathCC FC=pathf90 MPICC=mpicc MPICXX=mpicxx MPIFC=mpif90 ./configure && make install
And, of course, you should add configure options, such as --enable-fortran --enable-parallel.
On this host, executing:
For C shell:
env CC=pathcc CXX=pathCC FC=pathf90 MPICC=mpicc MPICXX=mpicxx MPIFC=mpif90 ./configure --enable-fortran --enable-parallel && make install
For Korn or Bourne shell:
CC=pathcc CXX=pathCC FC=pathf90 MPICC=mpicc MPICXX=mpicxx MPIFC=mpif90 ./configure --enable-fortran --enable-parallel && make install
has functioned correctly.
To run test program, go to test directory:
(i) Serial test
run:
./H5testF
./H5PartTest
(ii) Parallel test
In Jacquard, we need a script to run parallel programs, since Jacquard does not support interactive parallel processing. Instead, we need to submit the task to a queue. A sample script (run_H5testFpar.scr) may look like below:
+++++++++++++++++++++++++++++++++++++++
#!/bin/csh
#PBS -l nodes=1:ppn=2,walltime=00:05:00
#PBS -N H5testFpar
#PBS -o H5testFpar.out
#PBS -e H5testFpar.err
#PBS -q debug
#PBS -A mpccc
#PBS -V
setenv PBS_OWORKDIR /home/H5Part/test
cd $PBS_O_WORKDIR
mpirun -np 2 ./H5testFpar
+++++++++++++++++++++++++++++++++++++++
Then, we need to submit the task to a queue by running:
qsub run_H5testFpar.scr
After processed, the result will appear in H5testFpar.out, and error messages will appear in H5testFpar.err.
(3) Bassi <bassi.nersc.ogv> (AIX5.3.0.0-Power 3)
-------------------------------------------------
FIRST THING FIRST!! Type:
module load gcc
to have the proper compilers set up for use.
Brief profile:
CC = cc_r
CXX = cc_r
FC = xlf_r
MPICC = mpcc_r
MPICXX = mpcc_r
MPIFC = mpxlf_r
If default doesn't work, try:
For C shell:
env CC=cc_r CXX=cc_r FC=xlf_r MPICC=mpcc_r MPICXX=mpcc_r MPIFC=mpxlf_r ./configure && make install
For Korn or Bourne shell:
CC=cc_r CXX=cc_r FC=xlf_r MPICC=mpcc_r MPICXX=mpcc_r MPIFC=mpxlf_r ./configure && make install
And, of course, you should add configure options, such as --enable-fortran --enable-parallel.
On this host, executing:
For C shell:
env CC=cc_r CXX=cc_r FC=xlf_r MPICC=mpcc_r MPICXX=mpcc_r MPIFC=mpxlf_r ./configure --enable-fortran --enable-parallel && make install
For Korn or Bourne shell:
CC=cc_r CXX=cc_r FC=xlf_r MPICC=mpcc_r MPICXX=mpcc_r MPIFC=mpxlf_r ./configure --enable-fortran --enable-parallel && make install
has functioned correctly.
To run test program, go to test directory:
(i) Serial test
run:
./H5testF
./H5PartTest
(ii) Parallel test
run:
unsetenv MP_SINGLE_THREAD
poe ./H5PartTestP -procs 2 -nodes 1
poe ./H5testFpar -procs 2 -nodes 1
For more details on how to run parallel programs on Bassi, go to:
http://www.nersc.gov/nusers/resources/bassi/running_jobs/
(4) Starsky <starsky.lbl.gov> (Darwin8.5.0-PowerPC)
----------------------------------------------------
FIRST THING FIRST!! Set environment variables: (in tcsh)
setenv LD_LIBRARY_PATH /usr/local/g95/lib/gcc-lib/powerpc-apple-darwin8.5.0/4.0.3/
setenv PATH ${PATH}:/usr/local/g95/bin
NOTE: This environment variable setting is specifit to Starsky. It is to make configure find the fortran compiler.
Brief profile:
CC = gcc
CXX = g++
FC = g95
If default doesn't work, try:
For C shell:
env CC=gcc CXX=g++ FC=g95 ./configure && make install
For Korn or Bourne shell:
CC=gcc CXX=g++ FC=g95 ./configure && make install
And, of course, you should add configure options, such as --enable-fortran --enable-parallel.
On this host, executing:
For C shell:
env CC=gcc CXX=g++ FC=g95 ./configure --enable-fortran && make install
For Korn or Bourne shell:
CC=gcc CXX=g++ FC=g95 ./configure --enable-fortran && make install
has functioned correctly.
To run test program, go to test directory:
(i) Serial test
run:
./H5testF
./H5PartTest
(5) Linux AMD64 Visualization group workstations (Linux"SUSE"-x86_64)
---------------------------------------------------------
Brief profile:
CC = gcc
CXX = g++
FC = g95
If default doesn't work, try:
For C shell:
env CC=gcc CXX=g++ FC=g95 ./configure && make install
For Korn or Bourne shell:
CC=gcc CXX=g++ FC=g95 ./configure && make install
And, of course, you should add configure options, such as --enable-fortran --enable-parallel.
On this host, executing:
For C shell:
env CC=gcc CXX=g++ FC=g95 ./configure --enable-fortran && make install
For Korn or Bourne shell:
CC=gcc CXX=g++ FC=g95 ./configure --enable-fortran && make install
has functioned correctly.
To run test program, go to test directory:
(i) Serial test
run:
./H5testF
./H5PartTest
(6) Cray XT3 @ CSCS gele
1) modules/3.1.6 9) PrgEnv-pgi/1.4.26 17) xt-lustre-ss/1.4.26
2) MySQL/4.0.26 10) xt-pbs/5.3.4 18) Base-opts/1.4.26
3) acml/3.0 11) xt-service/1.4.26 19) subversion/1.3.2
4) pgi/6.1.4 12) xt-libc/1.4.26 20) zlib/1.2.3
5) totalview/7.2.0 13) xt-os/1.4.26 21) szip/2.0
6) xt-libsci/1.4.26 14) xt-catamount/1.4.26 22) hdf5/1.6.5
7) xt-mpt/1.4.26 15) xt-boot/1.4.26
8) xt-pe/1.4.26 16) xt-crms/1.4.26
CFLAGS="-I$H5HOME/include -DF77_SINGLE_UNDERSCORE" LDFLAGS="-L$H5HOME/lib -L$ZHOME/lib" ./configure --enable-parallel --enable-fortran
(7) merlin00 / merlin3
Currently Loaded Modulefiles:
1) hdf5/hdf5-1.6.5 2) root/root-5.10.00 3) mpi/mpich2-1.0.3-pgi-6.1 4) pgi/pgi_64-6.1
FC=mpif90 ./configure --enable-parallel --enable-fortran
==============================================================================
+ 4. Trouble shooting (Things to check for...)
--------------------------------------------
(0) Have you set the LD_LIBRARY_PATH?
---Some systems require the user to manually set the environment variable, LD_LIBRARY_PATH. To do so:
set the environment variable HDF5ROOT or PHDF5ROOT to point to your installation of HDF5 (serial and/or parallel respectively).
For Korn or Bourne shell:
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${HDF5ROOT}/lib;export LD_LIBRARY_PATH
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:{PHDF5ROOT}/lib;export LD_LIBRARY_PATH
For C shell:
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${HDF5ROOT}/lib
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${PHDF5ROOT}/lib
Note that the values of HDF5ROOT & PHDF5ROOT will be in the "summary" section when you run configure.
Not properly set LD_LIBRARY_PATH value may result in a runtime error:
./H5PartTest: error while loading shared libraries: libhdf5.so.0: cannot open shared object file: No such file or directory
(1) Are the compilers set correctly?
---Check with: which COMPILER
(2) Have you installed HDF5?
---You can get it at: http://vis.lbl.gov/Research/AcceleratorSAPP/index.html
(3) Have you loaded the proper modules?
---It is necessary in Davinci & Bassi, and configure && make install may not work without it.
+28 -417
View File
@@ -1,418 +1,29 @@
==============================================================================
README file for H5Part configure
==============================================================================
+ 0. HDF5 library
-----------------
Make sure you have a working version of the HDF5 library in your computer. If you plan
to use parallel I/O you need to use a parallel HDF5 version. If you don't have the
library download the sources from http://hdf.ncsa.uiuc.edu/HDF5/
+ 1. Quick start (If you feel lucky...)
----------------------------------------
For many platforms, where compilers are installed in the "default" location
and all the environment variables are set correctly, it should be sufficient
to type:
./configure [OPTIONS] && make [install]
to have the libraries and test program compiled.
==============================================================================
+ 2. configure line options
----------------------------
(1) Enable options
--enable-fortran
--enable-parallel
--enable-tools
--enable-python
--enable-64 (only for AIX and Irix)
(2) Setting compilers related variables manually
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Compiler environment variables:
CC C compiler command
CXX C++ compiler command
FC Fortran compiler command
(3) Setting prefix for installation manually
--prefix=PREFIX install files in PREFIX
For more information, type:
./configure --help
==============================================================================
+ 3. Platform specific settings for compiling libraries & test programs
------------------------------------------------------------------------
Building
make : builds the libraries and test programs
make install: builds and installs
make clean : removes extraneous object files
make distclean : returns configuration to unconfigured state
As tested on hosts:
(1) Davinci <davinci.nersc.gov> (Linux"SUSE"-ia64)
---------------------------------------------------
FIRST THING FIRST!! Type:
module load intel
to have the proper compilers set up for use.
module load hdf5_par
[NOTE: module load hdf5 does not work at this moment.
Possible installation error of HDF5 on Davinci.]
Brief profile:
CC = icc
CXX = icc
FC = ifort
MPICC = icc
MPICXX = icc
MPIFC = ifort
If default doesn't work, try:
For C shell:
env CC=icc CXX=icc FC=ifort MPICC=icc MPICXX=icc MPIFC=ifort ./configure && make install
For Korn or Bourne shell:
CC=icc CXX=icc FC=ifort MPICC=icc MPICXX=icc MPIFC=ifort ./configure && make install
And, of course, you should add configure options, such as --enable-fortran --enable-parallel.
On this host, executing:
For C shell:
env CC=icc CXX=icc FC=ifort MPICC=icc MPICXX=icc MPIFC=ifort ./configure --enable-fortran --enable-parallel && make install
For Korn or Bourne shell:
CC=icc CXX=icc FC=ifort MPICC=icc MPICXX=icc MPIFC=ifort ./configure --enable-fortran --enable-parallel && make install
has functioned correctly.
To run test program, go to test directory:
(i) Serial test
run:
./H5testF
./H5PartTest
(ii) Parallel test
run:
mpirun 2 H5testFpar
mpirun 2 H5PartTestP
NOTE: Number 2 above is a arbitrary number that indicates the number of processes.
(2) Jacquard <jacquard.nersc.gov> (Linux"SUSE"-x86_64)
-------------------------------------------------------
Brief profile:
CC = pathcc
CXX = pathCC
FC = pathf90
MPICC = mpicc
MPICXX = mpicxx
MPIFC = mpif90
If default doesn't work, try:
For C shell:
env CC=pathcc CXX=pathCC FC=pathf90 MPICC=mpicc MPICXX=mpicxx MPIFC=mpif90 ./configure && make install
For Korn or Bourne shell:
CC=pathcc CXX=pathCC FC=pathf90 MPICC=mpicc MPICXX=mpicxx MPIFC=mpif90 ./configure && make install
And, of course, you should add configure options, such as --enable-fortran --enable-parallel.
On this host, executing:
For C shell:
env CC=pathcc CXX=pathCC FC=pathf90 MPICC=mpicc MPICXX=mpicxx MPIFC=mpif90 ./configure --enable-fortran --enable-parallel && make install
For Korn or Bourne shell:
CC=pathcc CXX=pathCC FC=pathf90 MPICC=mpicc MPICXX=mpicxx MPIFC=mpif90 ./configure --enable-fortran --enable-parallel && make install
has functioned correctly.
To run test program, go to test directory:
(i) Serial test
run:
./H5testF
./H5PartTest
(ii) Parallel test
In Jacquard, we need a script to run parallel programs, since Jacquard does not support interactive parallel processing. Instead, we need to submit the task to a queue. A sample script (run_H5testFpar.scr) may look like below:
+++++++++++++++++++++++++++++++++++++++
#!/bin/csh
#PBS -l nodes=1:ppn=2,walltime=00:05:00
#PBS -N H5testFpar
#PBS -o H5testFpar.out
#PBS -e H5testFpar.err
#PBS -q debug
#PBS -A mpccc
#PBS -V
setenv PBS_OWORKDIR /home/H5Part/test
cd $PBS_O_WORKDIR
mpirun -np 2 ./H5testFpar
+++++++++++++++++++++++++++++++++++++++
Then, we need to submit the task to a queue by running:
qsub run_H5testFpar.scr
After processed, the result will appear in H5testFpar.out, and error messages will appear in H5testFpar.err.
(3) Bassi <bassi.nersc.ogv> (AIX5.3.0.0-Power 3)
-------------------------------------------------
FIRST THING FIRST!! Type:
module load gcc
to have the proper compilers set up for use.
Brief profile:
CC = cc_r
CXX = cc_r
FC = xlf_r
MPICC = mpcc_r
MPICXX = mpcc_r
MPIFC = mpxlf_r
If default doesn't work, try:
For C shell:
env CC=cc_r CXX=cc_r FC=xlf_r MPICC=mpcc_r MPICXX=mpcc_r MPIFC=mpxlf_r ./configure && make install
For Korn or Bourne shell:
CC=cc_r CXX=cc_r FC=xlf_r MPICC=mpcc_r MPICXX=mpcc_r MPIFC=mpxlf_r ./configure && make install
And, of course, you should add configure options, such as --enable-fortran --enable-parallel.
On this host, executing:
For C shell:
env CC=cc_r CXX=cc_r FC=xlf_r MPICC=mpcc_r MPICXX=mpcc_r MPIFC=mpxlf_r ./configure --enable-fortran --enable-parallel && make install
For Korn or Bourne shell:
CC=cc_r CXX=cc_r FC=xlf_r MPICC=mpcc_r MPICXX=mpcc_r MPIFC=mpxlf_r ./configure --enable-fortran --enable-parallel && make install
has functioned correctly.
To run test program, go to test directory:
(i) Serial test
run:
./H5testF
./H5PartTest
(ii) Parallel test
run:
unsetenv MP_SINGLE_THREAD
poe ./H5PartTestP -procs 2 -nodes 1
poe ./H5testFpar -procs 2 -nodes 1
For more details on how to run parallel programs on Bassi, go to:
http://www.nersc.gov/nusers/resources/bassi/running_jobs/
(4) Starsky <starsky.lbl.gov> (Darwin8.5.0-PowerPC)
----------------------------------------------------
FIRST THING FIRST!! Set environment variables: (in tcsh)
setenv LD_LIBRARY_PATH /usr/local/g95/lib/gcc-lib/powerpc-apple-darwin8.5.0/4.0.3/
setenv PATH ${PATH}:/usr/local/g95/bin
NOTE: This environment variable setting is specifit to Starsky. It is to make configure find the fortran compiler.
Brief profile:
CC = gcc
CXX = g++
FC = g95
If default doesn't work, try:
For C shell:
env CC=gcc CXX=g++ FC=g95 ./configure && make install
For Korn or Bourne shell:
CC=gcc CXX=g++ FC=g95 ./configure && make install
And, of course, you should add configure options, such as --enable-fortran --enable-parallel.
On this host, executing:
For C shell:
env CC=gcc CXX=g++ FC=g95 ./configure --enable-fortran && make install
For Korn or Bourne shell:
CC=gcc CXX=g++ FC=g95 ./configure --enable-fortran && make install
has functioned correctly.
To run test program, go to test directory:
(i) Serial test
run:
./H5testF
./H5PartTest
(5) Linux AMD64 Visualization group workstations (Linux"SUSE"-x86_64)
---------------------------------------------------------
Brief profile:
CC = gcc
CXX = g++
FC = g95
If default doesn't work, try:
For C shell:
env CC=gcc CXX=g++ FC=g95 ./configure && make install
For Korn or Bourne shell:
CC=gcc CXX=g++ FC=g95 ./configure && make install
And, of course, you should add configure options, such as --enable-fortran --enable-parallel.
On this host, executing:
For C shell:
env CC=gcc CXX=g++ FC=g95 ./configure --enable-fortran && make install
For Korn or Bourne shell:
CC=gcc CXX=g++ FC=g95 ./configure --enable-fortran && make install
has functioned correctly.
To run test program, go to test directory:
(i) Serial test
run:
./H5testF
./H5PartTest
(6) Cray XT3 @ CSCS gele
1) modules/3.1.6 9) PrgEnv-pgi/1.4.26 17) xt-lustre-ss/1.4.26
2) MySQL/4.0.26 10) xt-pbs/5.3.4 18) Base-opts/1.4.26
3) acml/3.0 11) xt-service/1.4.26 19) subversion/1.3.2
4) pgi/6.1.4 12) xt-libc/1.4.26 20) zlib/1.2.3
5) totalview/7.2.0 13) xt-os/1.4.26 21) szip/2.0
6) xt-libsci/1.4.26 14) xt-catamount/1.4.26 22) hdf5/1.6.5
7) xt-mpt/1.4.26 15) xt-boot/1.4.26
8) xt-pe/1.4.26 16) xt-crms/1.4.26
CFLAGS="-I$H5HOME/include -DF77_SINGLE_UNDERSCORE" LDFLAGS="-L$H5HOME/lib -L$ZHOME/lib" ./configure --enable-parallel --enable-fortran
(7) merlin00 / merlin3
Currently Loaded Modulefiles:
1) hdf5/hdf5-1.6.5 2) root/root-5.10.00 3) mpi/mpich2-1.0.3-pgi-6.1 4) pgi/pgi_64-6.1
FC=mpif90 ./configure --enable-parallel --enable-fortran
==============================================================================
+ 4. Trouble shooting (Things to check for...)
--------------------------------------------
(0) Have you set the LD_LIBRARY_PATH?
---Some systems require the user to manually set the environment variable, LD_LIBRARY_PATH. To do so:
set the environment variable HDF5ROOT or PHDF5ROOT to point to your installation of HDF5 (serial and/or parallel respectively).
For Korn or Bourne shell:
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${HDF5ROOT}/lib;export LD_LIBRARY_PATH
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:{PHDF5ROOT}/lib;export LD_LIBRARY_PATH
For C shell:
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${HDF5ROOT}/lib
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${PHDF5ROOT}/lib
Note that the values of HDF5ROOT & PHDF5ROOT will be in the "summary" section when you run configure.
Not properly set LD_LIBRARY_PATH value may result in a runtime error:
./H5PartTest: error while loading shared libraries: libhdf5.so.0: cannot open shared object file: No such file or directory
(1) Are the compilers set correctly?
---Check with: which COMPILER
(2) Have you installed HDF5?
---You can get it at: http://vis.lbl.gov/Research/AcceleratorSAPP/index.html
(3) Have you loaded the proper modules?
---It is necessary in Davinci & Bassi, and configure && make install may not work without it.
Website:
http://vis.lbl.gov/Research/AcceleratorSAPP/
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.
H5Part is a very simple data storage schema and provides an API that simplifies
the reading/writing of the data to the HDF5 file format. An important
foundation for a stable visualization and data analysis environment is a stable
and portable file storage format and its associated APIs. The presence of a
"common file storage format," including associated APIs, will help foster a
fundamental level of interoperability across the project's software
infrastructure. It will also help ensure that key data analysis capabilities
are present during the earliest phases of the software development effort.
H5Part is built on top of the HDF5 (Hierarchical Data Format). HDF5 offers a
self-describing machine-independent binary file format that supports scalable
parallel I/O performance for MPI codes on a variety of supercomputing systems,
and works equally well on laptop computers. The API is available for C, C++, and
Fortran codes. The H5Part file format and APIs enable disparate research groups
with different simulation implementations to transparently share datasets and
data analysis tools. For instance, the common file format will enable groups
that depend on completely different simulation implementations to share data
analysis tools.
+10 -2
View File
@@ -1,6 +1,6 @@
# Every configure script must call AC_INIT before doing anything else.
# AC_INIT (package, version, [bug-report], [tarname])
AC_INIT([H5Part], [1.4.0], [h5part@lists.psi.ch], H5Part)
AC_INIT([H5Part], [1.5], [h5part@lists.psi.ch], H5Part)
# Ensure that a recent enough version of Autoconf is being used.
@@ -245,7 +245,15 @@ if test "X$USE_FORTRAN" = "Xyes"; then
fi
if test ! $uname = "AIX"; then
FFLAGS="${FFLAGS} -fPIC -fno-second-underscore"
FFLAGS="${FFLAGS} -fPIC"
fi
if test $FC = "g90"; then
FFLAGS="${FFLAGS} -fno-second-underscore"
fi
if test $FC = "g95"; then
FFLAGS="${FFLAGS} -fno-second-underscore"
fi
AC_MSG_CHECKING([symbol convention in object files])
+246 -247
View File
@@ -52,17 +52,8 @@
#include "H5BlockPrivate.h"
#include "H5BlockErrors.h"
#define INIT( f ) { \
h5part_int64_t herr = _init ( f ); \
if ( herr < 0 ) return herr; \
}
/********************** declarations *****************************************/
static h5part_int64_t
_close (
H5PartFile *f
);
/********************** misc *************************************************/
@@ -102,10 +93,11 @@ _file_is_valid (
\return H5PART_SUCCESS or error code
*/
static h5part_int64_t
_init (
h5part_int64_t
_H5Block_init (
H5PartFile *f /*!< IN: file handle */
) {
h5part_int64_t herr;
struct H5BlockStruct *b;
@@ -141,9 +133,13 @@ _init (
b->diskshape = -1;
b->memshape = -1;
b->field_group_id = -1;
b->create_prop = H5P_DEFAULT;
b->have_layout = 0;
b->chunk[0] = 0;
b->chunk[1] = 0;
b->chunk[2] = 0;
f->close_block = _close;
f->close_block = _H5Block_close;
return H5PART_SUCCESS;
}
@@ -158,8 +154,8 @@ _init (
\return H5PART_SUCCESS or error code
*/
static h5part_int64_t
_close (
h5part_int64_t
_H5Block_close (
H5PartFile *f /*!< IN: file handle */
) {
@@ -260,7 +256,7 @@ _allgather (
size_t n = sizeof (struct H5BlockPartition) / sizeof (h5part_int64_t);
MPI_Type_contiguous ( n, MPI_LONG_LONG, &partition_m );
MPI_Type_commit ( &partition_m );
MPI_Type_commit ( &partition_m );
MPI_Allgather ( partition, 1, partition_m, layout, 1, partition_m,
f->comm );
@@ -305,8 +301,8 @@ _get_dimension_sizes (
}
#define _NO_GHOSTZONE(p,q) ( (p->i_end < q->i_start) \
|| (p->j_end < q->j_start) \
|| (p->k_end < q->k_start) )
|| (p->j_end < q->j_start) \
|| (p->k_end < q->k_start) )
/*!
@@ -577,11 +573,11 @@ _dissolve_ghostzones (
memset ( p_begin, 0, sizeof ( *p_begin ) );
for ( proc_p = 0, p = b->write_layout;
proc_p < f->nprocs-1;
proc_p++, p++ ) {
proc_p < f->nprocs-1;
proc_p++, p++ ) {
for ( proc_q = proc_p+1, q = &b->write_layout[proc_q];
proc_q < f->nprocs;
proc_q++, q++ ) {
proc_q < f->nprocs;
proc_q++, q++ ) {
if ( _have_ghostzone ( p, q ) ) {
p_el = (struct list*) malloc ( sizeof ( *p_el ) );
@@ -630,24 +626,40 @@ _dissolve_ghostzones (
}
free ( p_begin );
_H5Part_print_debug ("Layout defined by user:");
p = b->user_layout;
_H5Part_print_debug (
"PROC[%d]: User layout: %lld:%lld, %lld:%lld, %lld:%lld",
f->myproc,
(long long)p->i_start, (long long)p->i_end,
(long long)p->j_start, (long long)p->j_end,
(long long)p->k_start, (long long)p->k_end );
/* more detailed debug output: all procs report their view
of all other procs */
for ( proc_p = 0, p = b->user_layout;
proc_p < f->nprocs;
proc_p++, p++ ) {
_H5Part_print_debug (
"PROC[%d]: proc[%d]: %lld:%lld, %lld:%lld, %lld:%lld ",
proc_p < f->nprocs;
proc_p++, p++ ) {
_H5Part_print_debug_detail (
"PROC[%d]: proc[%d]: User layout: %lld:%lld, %lld:%lld, %lld:%lld ",
f->myproc, proc_p,
(long long)p->i_start, (long long)p->i_end,
(long long)p->j_start, (long long)p->j_end,
(long long)p->k_start, (long long)p->k_end );
}
_H5Part_print_debug ("Layout after dissolving ghost-zones:");
p = b->write_layout;
_H5Part_print_debug (
"PROC[%d]: Ghost-zone layout: %lld:%lld, %lld:%lld, %lld:%lld",
f->myproc,
(long long)p->i_start, (long long)p->i_end,
(long long)p->j_start, (long long)p->j_end,
(long long)p->k_start, (long long)p->k_end );
/* more detailed debug output: all procs report their view
of all other procs */
for ( proc_p = 0, p = b->write_layout;
proc_p < f->nprocs;
proc_p++, p++ ) {
_H5Part_print_debug (
"PROC[%d]: proc[%d]: %lld:%lld, %lld:%lld, %lld:%lld ",
proc_p < f->nprocs;
proc_p++, p++ ) {
_H5Part_print_debug_detail (
"PROC[%d]: proc[%d]: Ghost-zone layout: %lld:%lld, %lld:%lld, %lld:%lld ",
f->myproc, proc_p,
(long long)p->i_start, (long long)p->i_end,
(long long)p->j_start, (long long)p->j_end,
@@ -658,7 +670,7 @@ _dissolve_ghostzones (
/*!
\ingroup h5block_private
1
\internal
*/
@@ -699,12 +711,12 @@ _release_hyperslab (
h5part_int64_t
H5BlockDefine3DFieldLayout(
H5PartFile *f, /*!< IN: File handle */
const h5part_int64_t i_start, /*!< OUT: start index of \c i */
const h5part_int64_t i_end, /*!< OUT: end index of \c i */
const h5part_int64_t j_start, /*!< OUT: start index of \c j */
const h5part_int64_t j_end, /*!< OUT: end index of \c j */
const h5part_int64_t k_start, /*!< OUT: start index of \c j */
const h5part_int64_t k_end /*!< OUT: end index of \c j */
const h5part_int64_t i_start, /*!< IN: start index of \c i */
const h5part_int64_t i_end, /*!< IN: end index of \c i */
const h5part_int64_t j_start, /*!< IN: start index of \c j */
const h5part_int64_t j_end, /*!< IN: end index of \c j */
const h5part_int64_t k_start, /*!< IN: start index of \c k */
const h5part_int64_t k_end /*!< IN: end index of \c k */
) {
SET_FNAME ( "H5BlockDefine3DFieldLayout" );
@@ -737,6 +749,104 @@ H5BlockDefine3DFieldLayout(
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
Define the chunk dimensions and enable chunking in the underlying
HDF5 dataset.
\return \c H5PART_SUCCESS on success
*/
h5part_int64_t
H5BlockDefine3DChunkDims(
H5PartFile *f, /*!< IN: File handle */
const h5part_int64_t i, /*!< IN: size of \c i */
const h5part_int64_t j, /*!< IN: size of \c j */
const h5part_int64_t k /*!< IN: size of \c k */
) {
SET_FNAME ( "H5BlockDefine3DChunkDims" );
INIT( f );
struct H5BlockStruct *b = f->block;
b->chunk[0] = (hsize_t)k;
b->chunk[1] = (hsize_t)j;
b->chunk[2] = (hsize_t)i;
_H5Part_print_debug (
"PROC[%d]: Chunk dimensions: (%lld,%lld,%lld)",
f->myproc,
(long long)b->chunk[2],
(long long)b->chunk[1],
(long long)b->chunk[0] );
b->create_prop = H5Pcreate (H5P_DATASET_CREATE);
herr_t herr = H5Pset_chunk ( b->create_prop, 3, b->chunk );
if ( herr < 0 ) return HANDLE_H5P_SET_CHUNK_ERR;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
Lookup the chunk dimensions of the underlying HDF5 dataset.
\return \c H5PART_SUCCESS on success
*/
h5part_int64_t
H5BlockGet3DChunkDims(
H5PartFile *f, /*!< IN: File handle */
const char *field_name, /*!< IN: name of dataset */
h5part_int64_t *dims /*!< OUT: array containing
the chunk dimensions */
) {
SET_FNAME ( "H5BlockGet3DChunkDims" );
INIT( f );
struct H5BlockStruct *b = f->block;
CHECK_TIMEGROUP ( f );
h5part_int64_t herr = _H5Block_open_field_group ( f, field_name );
if ( herr < 0 ) return herr;
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
hid_t dataset_id = H5Dopen2 ( b->field_group_id, "0", H5P_DEFAULT );
#else
hid_t dataset_id = H5Dopen ( b->field_group_id, "0" );
#endif
if ( dataset_id < 0 ) return HANDLE_H5D_OPEN_ERR ( field_name );
hid_t plist_id = H5Dget_create_plist (dataset_id);
if ( plist_id < 0 ) return HANDLE_H5D_GET_PLIST_ERR;
hsize_t cdims[3];
int ndim = H5Pget_chunk ( plist_id, 3, cdims );
if ( ndim != 3 ) return HANDLE_H5P_GET_CHUNK_ERR;
H5Dclose (dataset_id);
H5Pclose (plist_id);
_H5Part_print_debug (
"PROC[%d]: Chunk dimensions: (%lld,%lld,%lld)",
f->myproc,
(long long)cdims[2],
(long long)cdims[1],
(long long)cdims[0] );
dims[0] = cdims[2];
dims[1] = cdims[1];
dims[2] = cdims[0];
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
@@ -874,7 +984,14 @@ _open_block_group (
}
if ( b->blockgroup < 0 ) {
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
hid_t herr = H5Gopen2 (
f->timegroup,
H5BLOCK_GROUPNAME_BLOCK,
H5P_DEFAULT );
#else
hid_t herr = H5Gopen ( f->timegroup, H5BLOCK_GROUPNAME_BLOCK );
#endif
if ( herr < 0 ) return HANDLE_H5G_OPEN_ERR ( H5BLOCK_GROUPNAME_BLOCK );
b->blockgroup = herr;
}
@@ -885,20 +1002,6 @@ _open_block_group (
/********************** functions for reading ********************************/
/*!
\ingroup h5block_private
\internal
*/
static h5part_int64_t
_have_object (
const hid_t id,
const char *name
) {
return (H5Gget_objinfo( id, name, 1, NULL ) >= 0 ? 1 : 0);
}
/*!
\ingroup h5block_private
@@ -906,8 +1009,8 @@ _have_object (
\return \c H5PART_SUCCESS or error code
*/
static h5part_int64_t
_open_field_group (
h5part_int64_t
_H5Block_open_field_group (
H5PartFile *f, /*!< IN: file handle */
const char *name
) {
@@ -917,10 +1020,14 @@ _open_field_group (
h5part_int64_t h5err = _open_block_group ( f );
if ( h5err < 0 ) return h5err;
if ( ! _have_object ( b->blockgroup, name ) )
if ( ! _H5Part_have_group ( b->blockgroup, name ) )
return HANDLE_H5PART_NOENT_ERR ( name );
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
herr_t herr = H5Gopen2 ( b->blockgroup, name, H5P_DEFAULT );
#else
herr_t herr = H5Gopen ( b->blockgroup, name );
#endif
if ( herr < 0 ) return HANDLE_H5G_OPEN_ERR ( name );
b->field_group_id = herr;
@@ -936,7 +1043,7 @@ _open_field_group (
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
_close_field_group (
_H5Block_close_field_group (
H5PartFile *f /*!< IN: file handle */
) {
@@ -991,8 +1098,7 @@ _select_hyperslab_for_reading (
(field_dims[2] < (hsize_t)b->i_max) ) return HANDLE_H5PART_LAYOUT_ERR;
_H5Part_print_debug (
"PROC[%d]: \n"
"\tfield_dims: (%lld,%lld,%lld)",
"PROC[%d]: field_dims: (%lld,%lld,%lld)",
f->myproc,
(long long)field_dims[2],
(long long)field_dims[1],
@@ -1042,15 +1148,20 @@ _select_hyperslab_for_reading (
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
_read_data (
_H5Block_read_data (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to read */
h5part_float64_t *data /*!< OUT: ptr to read buffer */
void *data, /*!< OUT: ptr to read buffer */
hid_t type /*!< IN: data type */
) {
struct H5BlockStruct *b = f->block;
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
hid_t dataset_id = H5Dopen2 ( b->field_group_id, name, H5P_DEFAULT );
#else
hid_t dataset_id = H5Dopen ( b->field_group_id, name );
#endif
if ( dataset_id < 0 ) return HANDLE_H5D_OPEN_ERR ( name );
h5part_int64_t herr = _select_hyperslab_for_reading ( f, dataset_id );
@@ -1058,7 +1169,7 @@ _read_data (
herr = H5Dread (
dataset_id,
H5T_NATIVE_DOUBLE,
type,
f->block->memshape,
f->block->diskshape,
H5P_DEFAULT,
@@ -1071,83 +1182,6 @@ _read_data (
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
Read a 3-dimensional field \c name into the buffer starting at \c data from
the current time-step using the defined field layout. Values are real valued
scalars.
You must use the FORTRAN indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dReadScalarField (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to read */
h5part_float64_t *data /*!< OUT: ptr to read buffer */
) {
SET_FNAME ( "H5Block3dReadScalarField" );
INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _open_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _read_data ( f, "0", data );
if ( herr < 0 ) return herr;
herr = _close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
Read a 3-dimensional field \c name with 3-dimensional vectors as values
into the buffers starting at \c x_data, \c y_data and \c z_data from the
current time-step using the defined field layout. Values are 3-dimensional
vectors with real values.
You must use the FORTRAN indexing scheme to access items in the buffers.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dRead3dVectorField (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to read */
h5part_float64_t *x_data, /*!< OUT: ptr to read buffer X axis */
h5part_float64_t *y_data, /*!< OUT: ptr to read buffer Y axis */
h5part_float64_t *z_data /*!< OUT: ptr to read buffer Z axis */
) {
SET_FNAME ( "H5Block3dRead3dVectorField" );
INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _open_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _read_data ( f, "0", x_data );
if ( herr < 0 ) return herr;
herr = _read_data ( f, "1", y_data );
if ( herr < 0 ) return herr;
herr = _read_data ( f, "2", z_data );
if ( herr < 0 ) return herr;
herr = _close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/********************** functions for writing ********************************/
/*!
@@ -1287,7 +1321,16 @@ _create_block_group (
f->block->blockgroup = -1;
}
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
herr = H5Gcreate2 (
f->timegroup,
H5BLOCK_GROUPNAME_BLOCK,
H5P_DEFAULT,
H5P_DEFAULT,
H5P_DEFAULT );
#else
herr = H5Gcreate ( f->timegroup, H5BLOCK_GROUPNAME_BLOCK, 0 );
#endif
if ( herr < 0 ) return HANDLE_H5G_CREATE_ERR ( H5BLOCK_GROUPNAME_BLOCK );
f->block->blockgroup = herr;
@@ -1301,8 +1344,8 @@ _create_block_group (
\return \c H5PART_SUCCESS or error code
*/
static h5part_int64_t
_create_field_group (
h5part_int64_t
_H5Block_create_field_group (
H5PartFile *f, /*!< IN: file handle */
const char *name /*!< IN: name of field group to create */
) {
@@ -1311,7 +1354,7 @@ _create_field_group (
struct H5BlockStruct *b = f->block;
if ( ! _have_object ( f->timegroup, H5BLOCK_GROUPNAME_BLOCK ) ) {
if ( ! _H5Part_have_group ( f->timegroup, H5BLOCK_GROUPNAME_BLOCK ) ) {
h5err = _create_block_group ( f );
} else {
h5err = _open_block_group ( f );
@@ -1321,10 +1364,19 @@ _create_field_group (
h5err = _select_hyperslab_for_writing ( f );
if ( h5err < 0 ) return h5err;
if ( _have_object ( b->blockgroup, name ) )
if ( _H5Part_have_group ( b->blockgroup, name ) )
return HANDLE_H5PART_GROUP_EXISTS_ERR ( name );
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
herr_t herr = H5Gcreate2 (
b->blockgroup,
name,
H5P_DEFAULT,
H5P_DEFAULT,
H5P_DEFAULT );
#else
herr_t herr = H5Gcreate ( b->blockgroup, name, 0 );
#endif
if ( herr < 0 ) return HANDLE_H5G_CREATE_ERR ( name );
b->field_group_id = herr;
@@ -1339,115 +1391,54 @@ _create_field_group (
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
_write_data (
_H5Block_write_data (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
const h5part_float64_t *data /*!< IN: data to write */
const void *data, /*!< IN: data to write */
const hid_t type /*!< IN: data type */
) {
herr_t herr;
hid_t dataset;
hid_t create_prop = H5P_DEFAULT;
struct H5BlockStruct *b = f->block;
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
dataset = H5Dcreate2 (
b->field_group_id,
name,
type,
b->shape,
H5P_DEFAULT,
b->create_prop,
H5P_DEFAULT );
#else
dataset = H5Dcreate (
b->field_group_id,
name,
H5T_NATIVE_DOUBLE,
type,
b->shape,
H5P_DEFAULT );
b->create_prop );
#endif
if ( dataset < 0 ) return HANDLE_H5D_CREATE_ERR ( name, f->timestep );
herr = H5Dwrite (
dataset,
H5T_NATIVE_DOUBLE,
type,
b->memshape,
b->diskshape,
H5P_DEFAULT,
f->xfer_prop,
data );
if ( herr < 0 ) return HANDLE_H5D_WRITE_ERR ( name, f->timestep );
herr = H5Dclose ( dataset );
if ( herr < 0 ) return HANDLE_H5D_CLOSE_ERR;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
Write a 3-dimensional field \c name from the buffer starting at \c data
to the current time-step using the defined field layout. Values are real
valued scalars.
You must use the FORTRAN indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dWriteScalarField (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
const h5part_float64_t *data /*!< IN: scalar data to write */
) {
SET_FNAME ( "H5Block3dWriteScalarField" );
INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _create_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _write_data ( f, "0", data );
if ( herr < 0 ) return herr;
herr = _close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
*/
/*!
Write a 3-dimensional field \c name with 3-dimensional vectors as values
from the buffers starting at \c x_data, \c y_data and \c z_data to the
current time-step using the defined field layout. Values are 3-dimensional
vectors with real values.
You must use the FORTRAN indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dWrite3dVectorField (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
const h5part_float64_t *x_data, /*!< IN: X axis data */
const h5part_float64_t *y_data, /*!< IN: Y axis data */
const h5part_float64_t *z_data /*!< IN: Z axis data */
) {
SET_FNAME ( "H5Block3dWrite3dVectorField" );
INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _create_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _write_data ( f, "0", x_data );
if ( herr < 0 ) return herr;
herr = _write_data ( f, "1", y_data );
if ( herr < 0 ) return herr;
herr = _write_data ( f, "2", z_data );
if ( herr < 0 ) return herr;
herr = _close_field_group ( f );
if ( herr < 0 ) return herr;
if ( create_prop != H5P_DEFAULT ) {
herr = H5Pclose ( create_prop );
if ( herr < 0 ) return HANDLE_H5P_CLOSE_ERR ( "create_prop" );
}
return H5PART_SUCCESS;
}
@@ -1470,7 +1461,7 @@ H5BlockGetNumFields (
INIT ( f );
CHECK_TIMEGROUP( f );
if ( ! _have_object ( f->timegroup, H5BLOCK_GROUPNAME_BLOCK ) )
if ( ! _H5Part_have_group ( f->timegroup, H5BLOCK_GROUPNAME_BLOCK ) )
return 0;
return _H5Part_get_num_objects ( f->timegroup, H5BLOCK_GROUPNAME_BLOCK, H5G_GROUP );
@@ -1489,7 +1480,7 @@ _get_field_info (
const char *field_name, /*!< IN: field name to get info about */
h5part_int64_t *grid_rank, /*!< OUT: rank of grid */
h5part_int64_t *grid_dims, /*!< OUT: dimensions of grid */
h5part_int64_t *field_dims /*!< OUT: rank of field (1 or 3) */
h5part_int64_t *field_rank /*!< OUT: rank of field (1 or 3) */
) {
hsize_t dims[16];
@@ -1498,10 +1489,21 @@ _get_field_info (
h5part_int64_t herr = _open_block_group ( f );
if ( herr < 0 ) return herr;
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
hid_t group_id = H5Gopen2 (
f->block->blockgroup,
field_name,
H5P_DEFAULT );
#else
hid_t group_id = H5Gopen ( f->block->blockgroup, field_name );
#endif
if ( group_id < 0 ) return HANDLE_H5G_OPEN_ERR ( field_name );
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
hid_t dataset_id = H5Dopen2 ( group_id, "0", H5P_DEFAULT );
#else
hid_t dataset_id = H5Dopen ( group_id, "0" );
#endif
if ( dataset_id < 0 ) return HANDLE_H5D_OPEN_ERR ( "0" );
hid_t dataspace_id = H5Dget_space ( dataset_id );
@@ -1513,11 +1515,11 @@ _get_field_info (
for ( i = 0, j = *grid_rank-1; i < *grid_rank; i++, j-- )
grid_dims[i] = (h5part_int64_t)dims[j];
*field_dims = _H5Part_get_num_objects (
*field_rank = _H5Part_get_num_objects (
f->block->blockgroup,
field_name,
H5G_DATASET );
if ( *field_dims < 0 ) return *field_dims;
if ( *field_rank < 0 ) return *field_rank;
herr = H5Sclose ( dataspace_id );
if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR;
@@ -1552,7 +1554,7 @@ H5BlockGetFieldInfo (
const h5part_int64_t len_field_name, /*!< IN: buffer size */
h5part_int64_t *grid_rank, /*!< OUT: grid rank */
h5part_int64_t *grid_dims, /*!< OUT: grid dimensions */
h5part_int64_t *field_dims /*!< OUT: field rank */
h5part_int64_t *field_rank /*!< OUT: field rank */
) {
SET_FNAME ( "H5BlockGetFieldInfo" );
@@ -1569,7 +1571,7 @@ H5BlockGetFieldInfo (
if ( herr < 0 ) return herr;
return _get_field_info (
f, field_name, grid_rank, grid_dims, field_dims );
f, field_name, grid_rank, grid_dims, field_rank );
}
/*!
@@ -1585,7 +1587,7 @@ H5BlockGetFieldInfoByName (
const char *field_name, /*!< IN: field name */
h5part_int64_t *grid_rank, /*!< OUT: grid rank */
h5part_int64_t *grid_dims, /*!< OUT: grid dimensions */
h5part_int64_t *field_dims /*!< OUT: field rank */
h5part_int64_t *field_rank /*!< OUT: field rank */
) {
SET_FNAME ( "H5BlockGetFieldInfo" );
@@ -1593,7 +1595,7 @@ H5BlockGetFieldInfoByName (
CHECK_TIMEGROUP( f );
return _get_field_info (
f, field_name, grid_rank, grid_dims, field_dims );
f, field_name, grid_rank, grid_dims, field_rank );
}
/********************** reading and writing attribute ************************/
@@ -1615,7 +1617,7 @@ _write_field_attrib (
const h5part_int64_t attrib_nelem /*!< IN: number of elements */
) {
h5part_int64_t herr = _open_field_group ( f, field_name );
h5part_int64_t herr = _H5Block_open_field_group ( f, field_name );
if ( herr < 0 ) return herr;
_H5Part_write_attrib (
@@ -1626,7 +1628,7 @@ _write_field_attrib (
attrib_nelem );
if ( herr < 0 ) return herr;
herr = _close_field_group ( f );
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
@@ -1707,14 +1709,14 @@ H5BlockGetNumFieldAttribs (
INIT ( f );
CHECK_TIMEGROUP( f );
h5part_int64_t herr = _open_field_group ( f, field_name );
h5part_int64_t herr = _H5Block_open_field_group ( f, field_name );
if ( herr < 0 ) return herr;
h5part_int64_t nattribs = H5Aget_num_attrs (
f->block->field_group_id );
if ( nattribs < 0 ) HANDLE_H5A_GET_NUM_ATTRS_ERR;
herr = _close_field_group ( f );
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return nattribs;
@@ -1745,7 +1747,7 @@ H5BlockGetFieldAttribInfo (
INIT ( f );
CHECK_TIMEGROUP( f );
h5part_int64_t herr = _open_field_group ( f, field_name );
h5part_int64_t herr = _H5Block_open_field_group ( f, field_name );
if ( herr < 0 ) return herr;
herr = _H5Part_get_attrib_info (
@@ -1757,7 +1759,7 @@ H5BlockGetFieldAttribInfo (
attrib_nelem );
if ( herr < 0 ) return herr;
herr = _close_field_group ( f );
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
@@ -1782,7 +1784,7 @@ _read_field_attrib (
struct H5BlockStruct *b = f->block;
h5part_int64_t herr = _open_field_group ( f, field_name );
h5part_int64_t herr = _H5Block_open_field_group ( f, field_name );
if ( herr < 0 ) return herr;
herr = _H5Part_read_attrib (
@@ -1791,7 +1793,7 @@ _read_field_attrib (
attrib_value );
if ( herr < 0 ) return herr;
herr = _close_field_group ( f );
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
@@ -1821,9 +1823,6 @@ H5BlockReadFieldAttrib (
}
#define H5BLOCK_FIELD_ORIGIN_NAME "__Origin__"
#define H5BLOCK_FIELD_SPACING_NAME "__Spacing__"
/*!
\ingroup h5block_c_api
@@ -1974,7 +1973,7 @@ H5BlockHasFieldData (
INIT ( f );
CHECK_TIMEGROUP( f );
if ( ! _have_object ( f->timegroup, H5BLOCK_GROUPNAME_BLOCK ) ) {
if ( ! _H5Part_have_group ( f->timegroup, H5BLOCK_GROUPNAME_BLOCK ) ) {
return H5PART_ERR_NOENTRY;
}
return H5PART_SUCCESS;
+27 -39
View File
@@ -5,11 +5,18 @@
extern "C" {
#endif
/*!
Interface for block structured field data
/*!
Include read/write call variants for different data types and
field dimensions.
*/
#include "H5BlockReadWrite.h"
#define H5BLOCK_FIELD_ORIGIN_NAME "__Origin__"
#define H5BLOCK_FIELD_SPACING_NAME "__Spacing__"
/*!
Interface for block structured field data.
*/
h5part_int64_t
H5BlockDefine3DFieldLayout (
H5PartFile *f,
@@ -21,6 +28,21 @@ H5BlockDefine3DFieldLayout (
const h5part_int64_t k_end
);
h5part_int64_t
H5BlockDefine3DChunkDims (
H5PartFile *f,
const h5part_int64_t i,
const h5part_int64_t j,
const h5part_int64_t k
);
h5part_int64_t
H5BlockGet3DChunkDims(
H5PartFile *f,
const char *field_name,
h5part_int64_t *dims
);
h5part_int64_t
H5Block3dGetPartitionOfProc (
H5PartFile *f,
@@ -53,20 +75,6 @@ H5Block3dGetProcOf (
h5part_int64_t 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
@@ -80,7 +88,7 @@ H5BlockGetFieldInfo (
const h5part_int64_t len_name,
h5part_int64_t *grid_rank,
h5part_int64_t *grid_dims,
h5part_int64_t *field_dims
h5part_int64_t *field_rank
);
h5part_int64_t
@@ -89,7 +97,7 @@ H5BlockGetFieldInfoByName (
const char *field_name,
h5part_int64_t *grid_rank,
h5part_int64_t *grid_dims,
h5part_int64_t *field_dims
h5part_int64_t *field_rank
);
h5part_int64_t
@@ -128,26 +136,6 @@ H5Block3dSetFieldSpacing (
const h5part_float64_t z_spacing
);
h5part_int64_t
H5Block3dWrite3dVectorField (
H5PartFile *f,
const char *name,
const h5part_float64_t *xval,
const h5part_float64_t *yval,
const h5part_float64_t *zval
);
h5part_int64_t
H5Block3dRead3dVectorField (
H5PartFile *f,
const char *name,
h5part_float64_t *xval,
h5part_float64_t *yval,
h5part_float64_t *zval
);
h5part_int64_t
H5BlockWriteFieldAttrib (
H5PartFile *f,
+16 -92
View File
@@ -17,6 +17,9 @@
#define h5bl_define3dlayout F77NAME ( \
h5bl_define3dlayout_, \
H5BL_DEFINE3DLAYOUT )
#define h5bl_define3dchunkdims F77NAME ( \
h5bl_define3dchunkdims_, \
H5BL_DEFINE3DCHUNKDIMS )
#define h5bl_get_partition_of_proc F77NAME ( \
h5bl_get_partition_of_proc_, \
H5BL_GET_PARTITION_OF_PROC )
@@ -26,18 +29,6 @@
#define h5bl_get_proc_of F77NAME ( \
h5bl_get_proc_of_, \
H5BL_GET_PROC_OF )
#define h5bl_3d_read_scalar_field F77NAME ( \
h5bl_3d_read_scalar_field_, \
H5BL_3D_READ_SCALAR_FIELD )
#define h5bl_3d_write_scalar_field F77NAME ( \
h5bl_3d_write_scalar_field_, \
H5BL_3D_WRITE_SCALAR_FIELD )
#define h5bl_3d_read_3dvector_field F77NAME ( \
h5bl_3d_read_3dvector_field_, \
H5BL_3D_READ_3DVECTOR_FIELD )
#define h5bl_3d_write_3dvector_field F77NAME ( \
h5bl_3d_write_3dvector_field_, \
H5BL_3D_WRITE_3DVECTOR_FIELD )
#define h5bl_getnumfields F77NAME ( \
h5bl_getnumfields_, \
H5BL_GETNUMFIELDS )
@@ -105,6 +96,19 @@ h5bl_define3dlayout (
*k_start-1, *k_end-1 );
}
h5part_int64_t
h5bl_define3dchunkdims (
h5part_int64_t *f,
const h5part_int64_t i,
const h5part_int64_t j,
const h5part_int64_t k
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
return H5BlockDefine3DChunkDims ( filehandle, i, j, k );
}
h5part_int64_t
h5bl_get_partition_of_proc (
h5part_int64_t *f, /*!< file handle */
@@ -178,86 +182,6 @@ h5bl_get_proc_of (
return H5Block3dGetProcOf ( filehandle, (*i)-1, (*j)-1, (*k)-1 );
}
h5part_int64_t
h5bl_3d_read_scalar_field (
h5part_int64_t *f,
const char *field_name,
h5part_float64_t *data,
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dReadScalarField (
filehandle, field_name2, data );
free ( field_name2 );
return herr;
}
h5part_int64_t
h5bl_3d_write_scalar_field (
h5part_int64_t *f,
const char *field_name,
const h5part_float64_t *data,
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dWriteScalarField (
filehandle, field_name2, data );
free ( field_name2 );
return herr;
}
h5part_int64_t
h5bl_3d_read_3dvector_field (
h5part_int64_t *f, /*!< file handle */
const char *field_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 */
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dRead3dVectorField (
filehandle, field_name2, xval, yval, zval );
free ( field_name2 );
return herr;
}
h5part_int64_t
h5bl_3d_write_3dvector_field (
h5part_int64_t *f, /*!< file handle */
const char *field_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 */
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dWrite3dVectorField (
filehandle, field_name2, xval, yval, zval );
free ( field_name2 );
return herr;
}
h5part_int64_t
h5bl_getnumfields (
h5part_int64_t *f /*!< file handle */
+137 -154
View File
@@ -1,176 +1,159 @@
INTERFACE
INTEGER*8 FUNCTION h5bl_define3dlayout ( 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_get_partition_of_proc ( filehandle, proc, i_start, i_end, j_start, j_end, k_start, k_end )
INTEGER*8, INTENT(IN) :: filehandle
INTEGER*8, INTENT(OUT) :: proc
INTEGER*8, INTENT(OUT) :: i_start
INTEGER*8, INTENT(OUT) :: i_end
INTEGER*8, INTENT(OUT) :: j_start
INTEGER*8, INTENT(OUT) :: j_end
INTEGER*8, INTENT(OUT) :: k_start
INTEGER*8, INTENT(OUT) :: k_end
END FUNCTION
INCLUDE 'H5BlockReadWriteF90.inc'
INTEGER*8 FUNCTION h5bl_get_reduced_partition_of_proc ( filehandle, proc, i_start, i_end, j_start, j_end, k_start, k_end )
INTEGER*8, INTENT(IN) :: filehandle
INTEGER*8, INTENT(OUT) :: proc
INTEGER*8, INTENT(OUT) :: i_start
INTEGER*8, INTENT(OUT) :: i_end
INTEGER*8, INTENT(OUT) :: j_start
INTEGER*8, INTENT(OUT) :: j_end
INTEGER*8, INTENT(OUT) :: k_start
INTEGER*8, INTENT(OUT) :: k_end
END FUNCTION
INTERFACE
INTEGER*8 FUNCTION h5bl_get_proc_of ( filehandle, i, j, k )
INTEGER*8, INTENT(IN) :: filehandle
INTEGER*8, INTENT(IN) :: i
INTEGER*8, INTENT(IN) :: j
INTEGER*8, INTENT(IN) :: k
END FUNCTION
INTEGER*8 FUNCTION h5bl_define3dlayout ( 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_field ( filehandle, name, data )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*8, INTENT(OUT) :: data(*)
END FUNCTION
INTEGER*8 FUNCTION h5bl_define3dchunkdims ( filehandle, i, j, k )
INTEGER*8, INTENT(IN) :: filehandle
INTEGER*8, INTENT(IN) :: i
INTEGER*8, INTENT(IN) :: j
INTEGER*8, INTENT(IN) :: k
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_write_scalar_field ( filehandle, name, data )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*8, INTENT(IN) :: data(*)
END FUNCTION
INTEGER*8 FUNCTION h5bl_get_partition_of_proc ( filehandle, proc, i_start, i_end, j_start, j_end, k_start, k_end )
INTEGER*8, INTENT(IN) :: filehandle
INTEGER*8, INTENT(OUT) :: proc
INTEGER*8, INTENT(OUT) :: i_start
INTEGER*8, INTENT(OUT) :: i_end
INTEGER*8, INTENT(OUT) :: j_start
INTEGER*8, INTENT(OUT) :: j_end
INTEGER*8, INTENT(OUT) :: k_start
INTEGER*8, INTENT(OUT) :: k_end
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_read_3dvector_field ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*8, INTENT(OUT) :: x(*)
REAL*8, INTENT(OUT) :: y(*)
REAL*8, INTENT(OUT) :: z(*)
END FUNCTION
INTEGER*8 FUNCTION h5bl_get_reduced_partition_of_proc ( filehandle, proc, i_start, i_end, j_start, j_end, k_start, k_end )
INTEGER*8, INTENT(IN) :: filehandle
INTEGER*8, INTENT(OUT) :: proc
INTEGER*8, INTENT(OUT) :: i_start
INTEGER*8, INTENT(OUT) :: i_end
INTEGER*8, INTENT(OUT) :: j_start
INTEGER*8, INTENT(OUT) :: j_end
INTEGER*8, INTENT(OUT) :: k_start
INTEGER*8, INTENT(OUT) :: k_end
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_write_3dvector_field ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*8, INTENT(IN) :: x(*)
REAL*8, INTENT(IN) :: y(*)
REAL*8, INTENT(IN) :: z(*)
END FUNCTION
INTEGER*8 FUNCTION h5bl_getnumfields ( filehandle )
INTEGER*8, INTENT(IN) :: filehandle
END FUNCTION
INTEGER*8 FUNCTION h5bl_get_proc_of ( filehandle, i, j, k )
INTEGER*8, INTENT(IN) :: filehandle
INTEGER*8, INTENT(IN) :: i
INTEGER*8, INTENT(IN) :: j
INTEGER*8, INTENT(IN) :: k
END FUNCTION
INTEGER*8 FUNCTION h5bl_getfieldinfo ( filehandle, idx, 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(OUT) :: grid_rank
INTEGER*8, INTENT(OUT) :: grid_dims(*)
INTEGER*8, INTENT(OUT) :: field_dims
END FUNCTION
INTEGER*8 FUNCTION h5bl_getnumfields ( filehandle )
INTEGER*8, INTENT(IN) :: filehandle
END FUNCTION
INTEGER*8 FUNCTION h5bl_writefieldattrib_r8 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
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 h5bl_getfieldinfo ( filehandle, idx, 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(OUT) :: grid_rank
INTEGER*8, INTENT(OUT) :: grid_dims(*)
INTEGER*8, INTENT(OUT) :: field_dims
END FUNCTION
INTEGER*8 FUNCTION h5bl_writefieldattrib_i8 (filehandle, field_name, attrib_name,attrib_value,attrib_nelem)
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
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 h5bl_writefieldattrib_r8 ( filehandle, field_name, attrib_name, attrib_value, attrib_nelem)
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
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 h5bl_writefieldattrib_i8 (filehandle, field_name, attrib_name,attrib_value,attrib_nelem)
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
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 h5bl_writefieldattrib_string ( filehandle, field_name, attrib_name, attrib_value )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
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 h5bl_writefieldattrib_string ( filehandle, field_name, attrib_name, attrib_value )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
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 h5bl_getnfieldattribs ( filehandle, field_name )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
END FUNCTION
INTEGER*8 FUNCTION h5bl_getnfieldattribs ( filehandle, field_name )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
END FUNCTION
INTEGER*8 FUNCTION h5bl_getfieldattribinfo ( filehandle, field_name, idx, attrib_name, attrib_nelem)
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
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 h5bl_getfieldattribinfo ( filehandle, field_name, idx, attrib_name, attrib_nelem)
INTEGER*8,INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
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 h5bl_readfieldattrib_i8 ( filehandle, field_name, attrib_name, attrib_value )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
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 h5bl_readfieldattrib_i8 ( filehandle, field_name, attrib_name, attrib_value )
INTEGER*8,INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
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 h5bl_readfieldattrib_r8 ( filehandle, field_name, attrib_name, attrib_value )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
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 h5bl_readfieldattrib_r8 ( filehandle, field_name, attrib_name, attrib_value )
INTEGER*8,INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
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 h5bl_readfieldattrib_string ( filehandle, field_name, attrib_name, attrib_value )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! name of the attribute to read
CHARACTER(LEN=*), INTENT(IN) :: attrib_value ! The array of data to write into the attribute
END FUNCTION
INTEGER*8 FUNCTION h5bl_readfieldattrib_string ( filehandle, field_name, attrib_name, attrib_value )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: field_name ! The name of the field
CHARACTER(LEN=*), INTENT(IN) :: attrib_name ! name of the attribute to read
CHARACTER(LEN=*), INTENT(IN) :: attrib_value ! The array of data to write into the attribute
END FUNCTION
INTEGER*8 FUNCTION h5bl_has_fielddata ( filehandle )
INTEGER*8, INTENT(IN) :: filehandle
END FUNCTION
INTEGER*8 FUNCTION h5bl_has_fielddata ( filehandle )
INTEGER*8, INTENT(IN) :: filehandle
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_get_field_spacing ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*8, INTENT(OUT) :: x
REAL*8, INTENT(OUT) :: y
REAL*8, INTENT(OUT) :: z
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_get_field_spacing ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*8, INTENT(OUT) :: x
REAL*8, INTENT(OUT) :: y
REAL*8, INTENT(OUT) :: z
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_set_field_spacing ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*8, INTENT(IN) :: x
REAL*8, INTENT(IN) :: y
REAL*8, INTENT(IN) :: z
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_set_field_spacing ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*8, INTENT(IN) :: x
REAL*8, INTENT(IN) :: y
REAL*8, INTENT(IN) :: z
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_get_field_origin ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*8, INTENT(OUT) :: x
REAL*8, INTENT(OUT) :: y
REAL*8, INTENT(OUT) :: z
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_get_field_origin ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*8, INTENT(OUT) :: x
REAL*8, INTENT(OUT) :: y
REAL*8, INTENT(OUT) :: z
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_set_field_origin ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*8, INTENT(IN) :: x
REAL*8, INTENT(IN) :: y
REAL*8, INTENT(IN) :: z
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_set_field_origin ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*8, INTENT(IN) :: x
REAL*8, INTENT(IN) :: y
REAL*8, INTENT(IN) :: z
END FUNCTION
END INTERFACE
END INTERFACE
+48
View File
@@ -3,4 +3,52 @@
#define H5BLOCK_GROUPNAME_BLOCK "Block"
#define INIT( f ) { \
h5part_int64_t herr = _H5Block_init ( f ); \
if ( herr < 0 ) return herr; \
}
h5part_int64_t
_H5Block_init (
H5PartFile *f
);
h5part_int64_t
_H5Block_close (
H5PartFile *f
);
h5part_int64_t
_H5Block_open_field_group (
H5PartFile *f,
const char *name
);
h5part_int64_t
_H5Block_close_field_group (
H5PartFile *f
);
h5part_int64_t
_H5Block_create_field_group (
H5PartFile *f,
const char *name
);
h5part_int64_t
_H5Block_write_data (
H5PartFile *f,
const char *name,
const void *data,
const hid_t type
);
h5part_int64_t
_H5Block_read_data (
H5PartFile *f,
const char *name,
void *data,
hid_t type
);
#endif
+645
View File
@@ -0,0 +1,645 @@
#include <stdlib.h>
#include <string.h>
#include <hdf5.h>
#include "H5Part.h"
#include "H5PartErrors.h"
#include "H5PartPrivate.h"
#include "H5BlockTypes.h"
#include "H5Block.h"
#include "H5BlockPrivate.h"
#include "H5BlockErrors.h"
/*!
\ingroup h5block_c_api
Write a 3-dimensional field \c name from the buffer starting at \c data
to the current time-step using the defined field layout. Values are
floating points (64-bit).
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dWriteScalarFieldFloat64 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
const h5part_float64_t *data /*!< IN: scalar data to write */
) {
SET_FNAME ( "H5Block3dWriteScalarFieldFloat64" );
INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_create_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "0", data, H5T_NATIVE_DOUBLE );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
Read a 3-dimensional field \c name into the buffer starting at \c data from
the current time-step using the defined field layout. Values are
floating points (64-bit).
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dReadScalarFieldFloat64 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to read */
h5part_float64_t *data /*!< OUT: ptr to read buffer */
) {
SET_FNAME ( "H5Block3dReadScalarFieldFloat64" );
INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_open_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "0", data, H5T_NATIVE_DOUBLE );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
*/
/*!
Write a 3-dimensional field \c name with 3-dimensional vectors as values
from the buffers starting at \c x_data, \c y_data and \c z_data to the
current time-step using the defined field layout. Values are 3-dimensional
vectors with floating points (64-bit) values.
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dWrite3dVectorFieldFloat64 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
const h5part_float64_t *x_data, /*!< IN: X axis data */
const h5part_float64_t *y_data, /*!< IN: Y axis data */
const h5part_float64_t *z_data /*!< IN: Z axis data */
) {
SET_FNAME ( "H5Block3dWrite3dVectorFieldFloat64" );
INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_create_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "0", x_data, H5T_NATIVE_DOUBLE );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "1", y_data, H5T_NATIVE_DOUBLE );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "2", z_data, H5T_NATIVE_DOUBLE );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
*/
/*!
Read a 3-dimensional field \c name with 3-dimensional vectors as values
from the buffers starting at \c x_data, \c y_data and \c z_data to the
current time-step using the defined field layout. Values are 3-dimensional
vectors with floating points (64-bit) values.
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dRead3dVectorFieldFloat64 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
h5part_float64_t *x_data, /*!< OUT: X axis data */
h5part_float64_t *y_data, /*!< OUT: Y axis data */
h5part_float64_t *z_data /*!< OUT: Z axis data */
) {
SET_FNAME ( "H5Block3dRead3dVectorFieldFloat64" );
INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_open_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "0", x_data, H5T_NATIVE_DOUBLE );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "1", y_data, H5T_NATIVE_DOUBLE );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "2", z_data, H5T_NATIVE_DOUBLE );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
Write a 3-dimensional field \c name from the buffer starting at \c data
to the current time-step using the defined field layout. Values are
floating points (32-bit).
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dWriteScalarFieldFloat32 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
const h5part_float32_t *data /*!< IN: scalar data to write */
) {
SET_FNAME ( "H5Block3dWriteScalarFieldFloat32" );
INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_create_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "0", data, H5T_NATIVE_FLOAT );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
Read a 3-dimensional field \c name into the buffer starting at \c data from
the current time-step using the defined field layout. Values are
floating points (32-bit).
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dReadScalarFieldFloat32 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to read */
h5part_float32_t *data /*!< OUT: ptr to read buffer */
) {
SET_FNAME ( "H5Block3dReadScalarFieldFloat32" );
INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_open_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "0", data, H5T_NATIVE_FLOAT );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
*/
/*!
Write a 3-dimensional field \c name with 3-dimensional vectors as values
from the buffers starting at \c x_data, \c y_data and \c z_data to the
current time-step using the defined field layout. Values are 3-dimensional
vectors with floating points (32-bit) values.
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dWrite3dVectorFieldFloat32 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
const h5part_float32_t *x_data, /*!< IN: X axis data */
const h5part_float32_t *y_data, /*!< IN: Y axis data */
const h5part_float32_t *z_data /*!< IN: Z axis data */
) {
SET_FNAME ( "H5Block3dWrite3dVectorFieldFloat32" );
INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_create_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "0", x_data, H5T_NATIVE_FLOAT );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "1", y_data, H5T_NATIVE_FLOAT );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "2", z_data, H5T_NATIVE_FLOAT );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
*/
/*!
Read a 3-dimensional field \c name with 3-dimensional vectors as values
from the buffers starting at \c x_data, \c y_data and \c z_data to the
current time-step using the defined field layout. Values are 3-dimensional
vectors with floating points (32-bit) values.
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dRead3dVectorFieldFloat32 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
h5part_float32_t *x_data, /*!< OUT: X axis data */
h5part_float32_t *y_data, /*!< OUT: Y axis data */
h5part_float32_t *z_data /*!< OUT: Z axis data */
) {
SET_FNAME ( "H5Block3dRead3dVectorFieldFloat32" );
INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_open_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "0", x_data, H5T_NATIVE_FLOAT );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "1", y_data, H5T_NATIVE_FLOAT );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "2", z_data, H5T_NATIVE_FLOAT );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
Write a 3-dimensional field \c name from the buffer starting at \c data
to the current time-step using the defined field layout. Values are
integers (64-bit).
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dWriteScalarFieldInt64 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
const h5part_int64_t *data /*!< IN: scalar data to write */
) {
SET_FNAME ( "H5Block3dWriteScalarFieldInt64" );
INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_create_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "0", data, H5T_NATIVE_INT64 );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
Read a 3-dimensional field \c name into the buffer starting at \c data from
the current time-step using the defined field layout. Values are
integers (64-bit).
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dReadScalarFieldInt64 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to read */
h5part_int64_t *data /*!< OUT: ptr to read buffer */
) {
SET_FNAME ( "H5Block3dReadScalarFieldInt64" );
INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_open_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "0", data, H5T_NATIVE_INT64 );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
*/
/*!
Write a 3-dimensional field \c name with 3-dimensional vectors as values
from the buffers starting at \c x_data, \c y_data and \c z_data to the
current time-step using the defined field layout. Values are 3-dimensional
vectors with integers (64-bit) values.
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dWrite3dVectorFieldInt64 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
const h5part_int64_t *x_data, /*!< IN: X axis data */
const h5part_int64_t *y_data, /*!< IN: Y axis data */
const h5part_int64_t *z_data /*!< IN: Z axis data */
) {
SET_FNAME ( "H5Block3dWrite3dVectorFieldInt64" );
INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_create_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "0", x_data, H5T_NATIVE_INT64 );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "1", y_data, H5T_NATIVE_INT64 );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "2", z_data, H5T_NATIVE_INT64 );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
*/
/*!
Read a 3-dimensional field \c name with 3-dimensional vectors as values
from the buffers starting at \c x_data, \c y_data and \c z_data to the
current time-step using the defined field layout. Values are 3-dimensional
vectors with integers (64-bit) values.
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dRead3dVectorFieldInt64 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
h5part_int64_t *x_data, /*!< OUT: X axis data */
h5part_int64_t *y_data, /*!< OUT: Y axis data */
h5part_int64_t *z_data /*!< OUT: Z axis data */
) {
SET_FNAME ( "H5Block3dRead3dVectorFieldInt64" );
INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_open_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "0", x_data, H5T_NATIVE_INT64 );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "1", y_data, H5T_NATIVE_INT64 );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "2", z_data, H5T_NATIVE_INT64 );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
Write a 3-dimensional field \c name from the buffer starting at \c data
to the current time-step using the defined field layout. Values are
integers (32-bit).
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dWriteScalarFieldInt32 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
const h5part_int32_t *data /*!< IN: scalar data to write */
) {
SET_FNAME ( "H5Block3dWriteScalarFieldInt32" );
INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_create_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "0", data, H5T_NATIVE_INT32 );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
Read a 3-dimensional field \c name into the buffer starting at \c data from
the current time-step using the defined field layout. Values are
integers (32-bit).
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dReadScalarFieldInt32 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to read */
h5part_int32_t *data /*!< OUT: ptr to read buffer */
) {
SET_FNAME ( "H5Block3dReadScalarFieldInt32" );
INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_open_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "0", data, H5T_NATIVE_INT32 );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
*/
/*!
Write a 3-dimensional field \c name with 3-dimensional vectors as values
from the buffers starting at \c x_data, \c y_data and \c z_data to the
current time-step using the defined field layout. Values are 3-dimensional
vectors with integers (32-bit) values.
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dWrite3dVectorFieldInt32 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
const h5part_int32_t *x_data, /*!< IN: X axis data */
const h5part_int32_t *y_data, /*!< IN: Y axis data */
const h5part_int32_t *z_data /*!< IN: Z axis data */
) {
SET_FNAME ( "H5Block3dWrite3dVectorFieldInt32" );
INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_create_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "0", x_data, H5T_NATIVE_INT32 );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "1", y_data, H5T_NATIVE_INT32 );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "2", z_data, H5T_NATIVE_INT32 );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5block_c_api
*/
/*!
Read a 3-dimensional field \c name with 3-dimensional vectors as values
from the buffers starting at \c x_data, \c y_data and \c z_data to the
current time-step using the defined field layout. Values are 3-dimensional
vectors with integers (32-bit) values.
You must use the Fortran indexing scheme to access items in \c data.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block3dRead3dVectorFieldInt32 (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
h5part_int32_t *x_data, /*!< OUT: X axis data */
h5part_int32_t *y_data, /*!< OUT: Y axis data */
h5part_int32_t *z_data /*!< OUT: Z axis data */
) {
SET_FNAME ( "H5Block3dRead3dVectorFieldInt32" );
INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_open_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "0", x_data, H5T_NATIVE_INT32 );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "1", y_data, H5T_NATIVE_INT32 );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "2", z_data, H5T_NATIVE_INT32 );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
+143
View File
@@ -0,0 +1,143 @@
#ifndef __H5BLOCKREADWRITE_H
#define __H5BLOCKREADWRITE_H
#ifdef __cplusplus
extern "C" {
#endif
h5part_int64_t
H5Block3dWriteScalarFieldFloat64 (
H5PartFile *f,
const char *name,
const h5part_float64_t *data
);
h5part_int64_t
H5Block3dReadScalarFieldFloat64 (
H5PartFile *f,
const char *name,
h5part_float64_t *data
);
h5part_int64_t
H5Block3dWrite3dVectorFieldFloat64 (
H5PartFile *f,
const char *name,
const h5part_float64_t *xval,
const h5part_float64_t *yval,
const h5part_float64_t *zval
);
h5part_int64_t
H5Block3dRead3dVectorFieldFloat64 (
H5PartFile *f,
const char *name,
h5part_float64_t *xval,
h5part_float64_t *yval,
h5part_float64_t *zval
);
h5part_int64_t
H5Block3dWriteScalarFieldFloat32 (
H5PartFile *f,
const char *name,
const h5part_float32_t *data
);
h5part_int64_t
H5Block3dReadScalarFieldFloat32 (
H5PartFile *f,
const char *name,
h5part_float32_t *data
);
h5part_int64_t
H5Block3dWrite3dVectorFieldFloat32 (
H5PartFile *f,
const char *name,
const h5part_float32_t *xval,
const h5part_float32_t *yval,
const h5part_float32_t *zval
);
h5part_int64_t
H5Block3dRead3dVectorFieldFloat32 (
H5PartFile *f,
const char *name,
h5part_float32_t *xval,
h5part_float32_t *yval,
h5part_float32_t *zval
);
h5part_int64_t
H5Block3dWriteScalarFieldInt64 (
H5PartFile *f,
const char *name,
const h5part_int64_t *data
);
h5part_int64_t
H5Block3dReadScalarFieldInt64 (
H5PartFile *f,
const char *name,
h5part_int64_t *data
);
h5part_int64_t
H5Block3dWrite3dVectorFieldInt64 (
H5PartFile *f,
const char *name,
const h5part_int64_t *xval,
const h5part_int64_t *yval,
const h5part_int64_t *zval
);
h5part_int64_t
H5Block3dRead3dVectorFieldInt64 (
H5PartFile *f,
const char *name,
h5part_int64_t *xval,
h5part_int64_t *yval,
h5part_int64_t *zval
);
h5part_int64_t
H5Block3dWriteScalarFieldInt32 (
H5PartFile *f,
const char *name,
const h5part_int32_t *data
);
h5part_int64_t
H5Block3dReadScalarFieldInt32 (
H5PartFile *f,
const char *name,
h5part_int32_t *data
);
h5part_int64_t
H5Block3dWrite3dVectorFieldInt32 (
H5PartFile *f,
const char *name,
const h5part_int32_t *xval,
const h5part_int32_t *yval,
const h5part_int32_t *zval
);
h5part_int64_t
H5Block3dRead3dVectorFieldInt32 (
H5PartFile *f,
const char *name,
h5part_int32_t *xval,
h5part_int32_t *yval,
h5part_int32_t *zval
);
#ifdef __cplusplus
}
#endif
#endif
+431
View File
@@ -0,0 +1,431 @@
#include "H5Part.h"
#include "H5PartPrivate.h"
#include "H5Block.h"
#include "H5BlockReadWrite.h"
#include "Underscore.h"
#if defined(F77_SINGLE_UNDERSCORE)
#define F77NAME(a,b) a
#elif defined(F77_CRAY_UNDERSCORE)
#define F77NAME(a,b) b
#elif defined(F77_NO_UNDERSCORE)
#else
#error Error, no way to determine how to construct fortran bindings
#endif
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_3d_write_scalar_field_r8 F77NAME ( \
h5bl_3d_write_scalar_field_r8_, \
H5BL_3D_WRITE_SCALAR_FIELD_R8 )
#endif
h5part_int64_t
h5bl_3d_write_scalar_field_r8 (
h5part_int64_t *f,
const char *field_name,
const h5part_float64_t *data,
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dWriteScalarFieldFloat64 (
filehandle, field_name2, data );
free ( field_name2 );
return herr;
}
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_3d_read_scalar_field_r8 F77NAME ( \
h5bl_3d_read_scalar_field_r8_, \
H5BL_3D_READ_SCALAR_FIELD_R8 )
#endif
h5part_int64_t
h5bl_3d_read_scalar_field_r8 (
h5part_int64_t *f,
const char *field_name,
h5part_float64_t *data,
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dWriteScalarFieldFloat64 (
filehandle, field_name2, data );
free ( field_name2 );
return herr;
}
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_3d_write_3dvector_field_r8 F77NAME ( \
h5bl_3d_write_3dvector_field_r8_, \
H5BL_3D_WRITE_3DVECTOR_FIELD_R8 )
#endif
h5part_int64_t
h5bl_3d_write_3dvector_field_r8 (
h5part_int64_t *f, /*!< file handle */
const char *field_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 */
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dWrite3dVectorFieldFloat64 (
filehandle, field_name2, xval, yval, zval );
free ( field_name2 );
return herr;
}
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_3d_read_3dvector_field_r8 F77NAME ( \
h5bl_3d_read_3dvector_field_r8_, \
H5BL_3D_READ_3DVECTOR_FIELD_R8 )
#endif
h5part_int64_t
h5bl_3d_read_3dvector_field_r8 (
h5part_int64_t *f, /*!< file handle */
const char *field_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 */
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dRead3dVectorFieldFloat64 (
filehandle, field_name2, xval, yval, zval );
free ( field_name2 );
return herr;
}
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_3d_write_scalar_field_r4 F77NAME ( \
h5bl_3d_write_scalar_field_r4_, \
H5BL_3D_WRITE_SCALAR_FIELD_R4 )
#endif
h5part_int64_t
h5bl_3d_write_scalar_field_r4 (
h5part_int64_t *f,
const char *field_name,
const h5part_float32_t *data,
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dWriteScalarFieldFloat32 (
filehandle, field_name2, data );
free ( field_name2 );
return herr;
}
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_3d_read_scalar_field_r4 F77NAME ( \
h5bl_3d_read_scalar_field_r4_, \
H5BL_3D_READ_SCALAR_FIELD_R4 )
#endif
h5part_int64_t
h5bl_3d_read_scalar_field_r4 (
h5part_int64_t *f,
const char *field_name,
h5part_float32_t *data,
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dWriteScalarFieldFloat32 (
filehandle, field_name2, data );
free ( field_name2 );
return herr;
}
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_3d_write_3dvector_field_r4 F77NAME ( \
h5bl_3d_write_3dvector_field_r4_, \
H5BL_3D_WRITE_3DVECTOR_FIELD_R4 )
#endif
h5part_int64_t
h5bl_3d_write_3dvector_field_r4 (
h5part_int64_t *f, /*!< file handle */
const char *field_name, /*!< name of the data set */
const h5part_float32_t *xval, /*!< array of x component data */
const h5part_float32_t *yval, /*!< array of y component data */
const h5part_float32_t *zval, /*!< array of z component data */
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dWrite3dVectorFieldFloat32 (
filehandle, field_name2, xval, yval, zval );
free ( field_name2 );
return herr;
}
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_3d_read_3dvector_field_r4 F77NAME ( \
h5bl_3d_read_3dvector_field_r4_, \
H5BL_3D_READ_3DVECTOR_FIELD_R4 )
#endif
h5part_int64_t
h5bl_3d_read_3dvector_field_r4 (
h5part_int64_t *f, /*!< file handle */
const char *field_name, /*!< name of the data set */
h5part_float32_t *xval, /*!< array of x component data */
h5part_float32_t *yval, /*!< array of y component data */
h5part_float32_t *zval, /*!< array of z component data */
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dRead3dVectorFieldFloat32 (
filehandle, field_name2, xval, yval, zval );
free ( field_name2 );
return herr;
}
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_3d_write_scalar_field_i8 F77NAME ( \
h5bl_3d_write_scalar_field_i8_, \
H5BL_3D_WRITE_SCALAR_FIELD_I8 )
#endif
h5part_int64_t
h5bl_3d_write_scalar_field_i8 (
h5part_int64_t *f,
const char *field_name,
const h5part_int64_t *data,
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dWriteScalarFieldInt64 (
filehandle, field_name2, data );
free ( field_name2 );
return herr;
}
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_3d_read_scalar_field_i8 F77NAME ( \
h5bl_3d_read_scalar_field_i8_, \
H5BL_3D_READ_SCALAR_FIELD_I8 )
#endif
h5part_int64_t
h5bl_3d_read_scalar_field_i8 (
h5part_int64_t *f,
const char *field_name,
h5part_int64_t *data,
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dWriteScalarFieldInt64 (
filehandle, field_name2, data );
free ( field_name2 );
return herr;
}
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_3d_write_3dvector_field_i8 F77NAME ( \
h5bl_3d_write_3dvector_field_i8_, \
H5BL_3D_WRITE_3DVECTOR_FIELD_I8 )
#endif
h5part_int64_t
h5bl_3d_write_3dvector_field_i8 (
h5part_int64_t *f, /*!< file handle */
const char *field_name, /*!< name of the data set */
const h5part_int64_t *xval, /*!< array of x component data */
const h5part_int64_t *yval, /*!< array of y component data */
const h5part_int64_t *zval, /*!< array of z component data */
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dWrite3dVectorFieldInt64 (
filehandle, field_name2, xval, yval, zval );
free ( field_name2 );
return herr;
}
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_3d_read_3dvector_field_i8 F77NAME ( \
h5bl_3d_read_3dvector_field_i8_, \
H5BL_3D_READ_3DVECTOR_FIELD_I8 )
#endif
h5part_int64_t
h5bl_3d_read_3dvector_field_i8 (
h5part_int64_t *f, /*!< file handle */
const char *field_name, /*!< name of the data set */
h5part_int64_t *xval, /*!< array of x component data */
h5part_int64_t *yval, /*!< array of y component data */
h5part_int64_t *zval, /*!< array of z component data */
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dRead3dVectorFieldInt64 (
filehandle, field_name2, xval, yval, zval );
free ( field_name2 );
return herr;
}
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_3d_write_scalar_field_i4 F77NAME ( \
h5bl_3d_write_scalar_field_i4_, \
H5BL_3D_WRITE_SCALAR_FIELD_I4 )
#endif
h5part_int64_t
h5bl_3d_write_scalar_field_i4 (
h5part_int64_t *f,
const char *field_name,
const h5part_int32_t *data,
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dWriteScalarFieldInt32 (
filehandle, field_name2, data );
free ( field_name2 );
return herr;
}
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_3d_read_scalar_field_i4 F77NAME ( \
h5bl_3d_read_scalar_field_i4_, \
H5BL_3D_READ_SCALAR_FIELD_I4 )
#endif
h5part_int64_t
h5bl_3d_read_scalar_field_i4 (
h5part_int64_t *f,
const char *field_name,
h5part_int32_t *data,
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dWriteScalarFieldInt32 (
filehandle, field_name2, data );
free ( field_name2 );
return herr;
}
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_3d_write_3dvector_field_i4 F77NAME ( \
h5bl_3d_write_3dvector_field_i4_, \
H5BL_3D_WRITE_3DVECTOR_FIELD_I4 )
#endif
h5part_int64_t
h5bl_3d_write_3dvector_field_i4 (
h5part_int64_t *f, /*!< file handle */
const char *field_name, /*!< name of the data set */
const h5part_int32_t *xval, /*!< array of x component data */
const h5part_int32_t *yval, /*!< array of y component data */
const h5part_int32_t *zval, /*!< array of z component data */
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dWrite3dVectorFieldInt32 (
filehandle, field_name2, xval, yval, zval );
free ( field_name2 );
return herr;
}
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_3d_read_3dvector_field_i4 F77NAME ( \
h5bl_3d_read_3dvector_field_i4_, \
H5BL_3D_READ_3DVECTOR_FIELD_I4 )
#endif
h5part_int64_t
h5bl_3d_read_3dvector_field_i4 (
h5part_int64_t *f, /*!< file handle */
const char *field_name, /*!< name of the data set */
h5part_int32_t *xval, /*!< array of x component data */
h5part_int32_t *yval, /*!< array of y component data */
h5part_int32_t *zval, /*!< array of z component data */
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block3dRead3dVectorFieldInt32 (
filehandle, field_name2, xval, yval, zval );
free ( field_name2 );
return herr;
}
+116
View File
@@ -0,0 +1,116 @@
INTERFACE
INTEGER*8 FUNCTION h5bl_3d_write_scalar_field_r8 ( filehandle, name, data )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*8, INTENT(IN) :: data(*)
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_read_scalar_field_r8 ( filehandle, name, data )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*8, INTENT(OUT) :: data(*)
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_write_3dvector_field_r8 ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*8, INTENT(IN) :: x(*)
REAL*8, INTENT(IN) :: y(*)
REAL*8, INTENT(IN) :: z(*)
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_read_3dvector_field_r8 ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*8, INTENT(OUT) :: x(*)
REAL*8, INTENT(OUT) :: y(*)
REAL*8, INTENT(OUT) :: z(*)
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_write_scalar_field_r4 ( filehandle, name, data )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*4, INTENT(IN) :: data(*)
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_read_scalar_field_r4 ( filehandle, name, data )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*4, INTENT(OUT) :: data(*)
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_write_3dvector_field_r4 ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*4, INTENT(IN) :: x(*)
REAL*4, INTENT(IN) :: y(*)
REAL*4, INTENT(IN) :: z(*)
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_read_3dvector_field_r4 ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
REAL*4, INTENT(OUT) :: x(*)
REAL*4, INTENT(OUT) :: y(*)
REAL*4, INTENT(OUT) :: z(*)
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_write_scalar_field_i8 ( 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_read_scalar_field_i8 ( 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_write_3dvector_field_i8 ( 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_3d_read_3dvector_field_i8 ( 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_field_i4 ( filehandle, name, data )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
INTEGER*4, INTENT(IN) :: data(*)
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_read_scalar_field_i4 ( filehandle, name, data )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
INTEGER*4, INTENT(OUT) :: data(*)
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_write_3dvector_field_i4 ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
INTEGER*4, INTENT(IN) :: x(*)
INTEGER*4, INTENT(IN) :: y(*)
INTEGER*4, INTENT(IN) :: z(*)
END FUNCTION
INTEGER*8 FUNCTION h5bl_3d_read_3dvector_field_i4 ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
INTEGER*4, INTENT(OUT) :: x(*)
INTEGER*4, INTENT(OUT) :: y(*)
INTEGER*4, INTENT(OUT) :: z(*)
END FUNCTION
END INTERFACE
+2
View File
@@ -18,12 +18,14 @@ struct H5BlockStruct {
struct H5BlockPartition *user_layout;
struct H5BlockPartition *write_layout;
int have_layout;
hsize_t chunk[3];
hid_t shape;
hid_t memshape;
hid_t diskshape;
hid_t blockgroup;
hid_t field_group_id;
hid_t create_prop;
};
#define H5PART_ERR_LAYOUT -100
+539 -81
View File
@@ -119,6 +119,9 @@ _file_is_valid (
*/
static herr_t
_h5_error_handler (
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
hid_t,
#endif
void *
);
@@ -129,7 +132,10 @@ _H5Part_open_file (
const char *filename, /*!< [in] The name of the data file to open. */
unsigned flags, /*!< [in] The access mode for the file. */
MPI_Comm comm, /*!< [in] MPI communicator */
int f_parallel /*!< [in] 0 for serial io otherwise parallel */
int f_parallel, /*!< [in] 0 for serial io otherwise parallel */
h5part_int64_t align /*!< [in] Number of bytes for setting alignment,
metadata block size, etc.
Set to 0 to disable. */
) {
if ( _init() < 0 ) {
HANDLE_H5PART_INIT_ERR;
@@ -152,16 +158,18 @@ _H5Part_open_file (
}
f->stepno_width = 0;
f->xfer_prop = f->create_prop = f->access_prop = H5P_DEFAULT;
f->xfer_prop = f->create_prop = H5P_DEFAULT;
f->access_prop = H5Pcreate (H5P_FILE_ACCESS);
if (f->access_prop < 0) {
HANDLE_H5P_CREATE_ERR;
goto error_cleanup;
}
if ( f_parallel ) {
#ifdef PARALLEL_IO
/* for the SP2... perhaps different for linux */
MPI_Info info = MPI_INFO_NULL;
/* ks: IBM_large_block_io */
MPI_Info_create(&info);
MPI_Info_set(info, "IBM_largeblock_io", "true" );
if (MPI_Comm_size (comm, &f->nprocs) != MPI_SUCCESS) {
HANDLE_MPI_COMM_SIZE_ERR;
@@ -178,38 +186,73 @@ _H5Part_open_file (
HANDLE_H5PART_NOMEM_ERR;
goto error_cleanup;
}
f->access_prop = H5Pcreate (H5P_FILE_ACCESS);
if (f->access_prop < 0) {
HANDLE_H5P_CREATE_ERR;
goto error_cleanup;
/* set IBM_largeblock_io for GPFS filesystems */
if (flags & H5PART_FS_GPFS) {
if (f->myproc == 0) {
_H5Part_print_info ( "Setting IBM_largeblock_io hint." );
}
MPI_Info_set ( info, "IBM_largeblock_io", "true" );
}
if (H5Pset_fapl_mpio (f->access_prop, comm, info) < 0) {
HANDLE_H5P_SET_FAPL_MPIO_ERR;
goto error_cleanup;
/* select the HDF5 VFD */
if (flags & H5PART_VFD_MPIPOSIX) {
if (f->myproc == 0) {
_H5Part_print_info ( "Selecting MPI-POSIX VFD" );
}
if (H5Pset_fapl_mpiposix ( f->access_prop, comm, 0 ) < 0) {
HANDLE_H5P_SET_FAPL_ERR;
goto error_cleanup;
}
}
/* f->create_prop = H5Pcreate(H5P_FILE_CREATE); */
f->create_prop = H5P_DEFAULT;
/* currently create_prop is empty */
/* xfer_prop: also used for parallel I/O, during actual writes
rather than the access_prop which is for file creation. */
f->xfer_prop = H5Pcreate (H5P_DATASET_XFER);
if (f->xfer_prop < 0) {
HANDLE_H5P_CREATE_ERR;
goto error_cleanup;
else {
if (f->myproc == 0) {
_H5Part_print_info ( "Selecting MPI-IO VFD" );
}
if (H5Pset_fapl_mpio ( f->access_prop, comm, info ) < 0) {
HANDLE_H5P_SET_FAPL_ERR;
goto error_cleanup;
}
f->xfer_prop = H5Pcreate (H5P_DATASET_XFER);
if (f->xfer_prop < 0) {
HANDLE_H5P_CREATE_ERR;
goto error_cleanup;
}
if (H5Pset_dxpl_mpio ( f->xfer_prop, H5FD_MPIO_COLLECTIVE ) < 0) {
HANDLE_H5P_SET_DXPL_MPIO_ERR;
goto error_cleanup;
}
}
if (H5Pset_dxpl_mpio (f->xfer_prop,H5FD_MPIO_COLLECTIVE) < 0) {
HANDLE_H5P_SET_DXPL_MPIO_ERR;
goto error_cleanup;
if (flags & H5PART_FS_LUSTRE) {
/* extend the btree size so that metadata pieces are
* close to the 1MB stripe width */
if (f->myproc == 0) {
_H5Part_print_info (
"Setting HDF5 btree parameter to %d",
H5PART_BTREE_IK );
_H5Part_print_info (
"Extending HDF5 btree size to %d bytes at rank 3",
24+16*H5PART_BTREE_IK+40*(2*H5PART_BTREE_IK + 1) );
}
f->create_prop = H5Pcreate(H5P_FILE_CREATE);
H5Pset_istore_k (f->create_prop, H5PART_BTREE_IK);
/* defer metadata cache flushing until file close */
H5AC_cache_config_t cache_config;
cache_config.version = H5AC__CURR_CACHE_CONFIG_VERSION;
H5Pget_mdc_config (f->access_prop, &cache_config);
cache_config.set_initial_size = 1;
cache_config.initial_size = 16 * 1024 * 1024;
cache_config.evictions_enabled = 0;
cache_config.incr_mode = H5C_incr__off;
cache_config.flash_incr_mode = H5C_flash_incr__off;
cache_config.decr_mode = H5C_decr__off;
H5Pset_mdc_config (f->access_prop, &cache_config);
}
f->comm = comm;
MPI_Info_free(&info);
f->comm = comm;
#endif
} else {
f->comm = 0;
@@ -218,15 +261,40 @@ _H5Part_open_file (
f->pnparticles =
(h5part_int64_t*) malloc (f->nprocs * sizeof (h5part_int64_t));
}
if ( flags == H5PART_READ ) {
if ( align != 0 ) {
if (f->myproc == 0) {
_H5Part_print_info ( "Setting HDF5 alignment to %ld bytes", align );
}
if (H5Pset_alignment ( f->access_prop, 0, align ) < 0) {
HANDLE_H5P_SET_FAPL_ERR;
goto error_cleanup;
}
if (f->myproc == 0) {
_H5Part_print_info ( "Setting HDF5 meta block to %ld bytes", align );
}
if (H5Pset_meta_block_size ( f->access_prop, align ) < 0) {
HANDLE_H5P_SET_FAPL_ERR;
goto error_cleanup;
}
/*if (f->myproc == 0) {
_H5Part_print_info ( "Setting HDF5 sieve buffer to %ld bytes", align );
}
if (H5Pset_sieve_buf_size ( f->access_prop, align ) < 0) {
HANDLE_H5P_SET_FAPL_ERR;
goto error_cleanup;
}*/
}
if ( flags & H5PART_READ ) {
f->file = H5Fopen (filename, H5F_ACC_RDONLY, f->access_prop);
}
else if ( flags == H5PART_WRITE ){
else if ( flags & H5PART_WRITE ){
f->file = H5Fcreate (filename, H5F_ACC_TRUNC, f->create_prop,
f->access_prop);
f->empty = 1;
}
else if ( flags == H5PART_APPEND ) {
else if ( flags & H5PART_APPEND ) {
int fd = open (filename, O_RDONLY, 0);
if ( (fd == -1) && (errno == ENOENT) ) {
f->file = H5Fcreate(filename, H5F_ACC_TRUNC,
@@ -310,10 +378,37 @@ H5PartOpenFileParallel (
const char *filename, /*!< [in] The name of the data file to open. */
unsigned flags, /*!< [in] The access mode for the file. */
MPI_Comm comm /*!< [in] MPI communicator */
) {
) {
SET_FNAME ( "H5PartOpenFileParallel" );
int f_parallel = 1; /* parallel i/o */
int align = 0; /* no tuning parameters */
return _H5Part_open_file ( filename, flags, comm, f_parallel, align );
}
/*!
\ingroup h5part_openclose
Opens file with specified filename, and also specifices an alignment
value used for HDF5 tuning parameters.
\return File handle or \c NULL
*/
H5PartFile*
H5PartOpenFileParallelAlign (
const char *filename, /*!< [in] The name of the data file to open. */
unsigned flags, /*!< [in] The access mode for the file. */
MPI_Comm comm, /*!< [in] MPI communicator */
h5part_int64_t align /*!< [in] Alignment size in bytes. */
) {
SET_FNAME ( "H5PartOpenFileParallel" );
int f_parallel = 1; /* parallel i/o */
return _H5Part_open_file ( filename, flags, comm, f_parallel );
return _H5Part_open_file ( filename, flags, comm, f_parallel, align );
}
#endif
@@ -348,8 +443,31 @@ H5PartOpenFile (
MPI_Comm comm = 0; /* dummy */
int f_parallel = 0; /* serial open */
int align = 0; /* no tuning parameters */
return _H5Part_open_file ( filename, flags, comm, f_parallel );
return _H5Part_open_file ( filename, flags, comm, f_parallel, align );
}
/*!
\ingroup h5part_openclose
Opens file with specified filename, and also specifices an alignment
value used for HDF5 tuning parameters.
\return File handle or \c NULL
*/
H5PartFile*
H5PartOpenFileAlign (
const char *filename, /*!< [in] The name of the data file to open. */
unsigned flags, /*!< [in] The access mode for the file. */
h5part_int64_t align /*!< [in] Alignment size in bytes. */
) {
SET_FNAME ( "H5PartOpenFile" );
MPI_Comm comm = 0; /* dummy */
int f_parallel = 0; /* serial open */
return _H5Part_open_file ( filename, flags, comm, f_parallel, align );
}
/*!
@@ -565,7 +683,7 @@ H5PartSetNumParticles (
start[0] += f->pnparticles[i];
}
/* compute total nparticles */
/* compute total nparticles */
total = 0;
for (i=0; i < f->nprocs; i++) {
total += f->pnparticles[i];
@@ -617,12 +735,23 @@ _write_data (
"timestep %lld",
name, (long long)f->timestep );
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
dataset_id = H5Dcreate2 (
f->timegroup,
name,
type,
f->shape,
H5P_DEFAULT,
H5P_DEFAULT,
H5P_DEFAULT );
#else
dataset_id = H5Dcreate (
f->timegroup,
name,
type,
f->shape,
H5P_DEFAULT );
#endif
if ( dataset_id < 0 )
return HANDLE_H5D_CREATE_ERR ( name, f->timestep );
@@ -700,6 +829,52 @@ H5PartWriteDataFloat64 (
return H5PART_SUCCESS;
}
/*!
\ingroup h5part_write
Write array of 32 bit floating point data to file.
After setting the number of particles with \c H5PartSetNumParticles() and
the current timestep using \c H5PartSetStep(), you can start writing datasets
into the file. Each dataset has a name associated with it (chosen by the
user) in order to facilitate later retrieval. The name of the dataset is
specified in the parameter \c name, which must be a null-terminated string.
There are no restrictions on naming of datasets, but it is useful to arrive
at some common naming convention when sharing data with other groups.
The writing routines also implicitly store the datatype of the array so that
the array can be reconstructed properly on other systems with incompatible
type representations.
All data that is written after setting the timestep is associated with that
timestep. While the number of particles can change for each timestep, you
cannot change the number of particles in the middle of a given timestep.
The data is committed to disk before the routine returns.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5PartWriteDataFloat32 (
H5PartFile *f, /*!< [in] Handle to open file */
const char *name, /*!< [in] Name to associate array with */
const h5part_float32_t *array /*!< [in] Array to commit to disk */
) {
SET_FNAME ( "H5PartWriteDataFloat32" );
h5part_int64_t herr;
CHECK_FILEHANDLE ( f );
CHECK_WRITABLE_MODE( f );
CHECK_TIMEGROUP( f );
herr = _write_data ( f, name, (void*)array, H5T_NATIVE_FLOAT );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5part_write
@@ -733,7 +908,7 @@ H5PartWriteDataInt64 (
const h5part_int64_t *array /*!< [in] Array to commit to disk */
) {
SET_FNAME ( "H5PartOpenWriteDataInt64" );
SET_FNAME ( "H5PartWriteDataInt64" );
h5part_int64_t herr;
@@ -747,6 +922,53 @@ H5PartWriteDataInt64 (
return H5PART_SUCCESS;
}
/*!
\ingroup h5part_write
Write array of 32 bit integer data to file.
After setting the number of particles with \c H5PartSetNumParticles() and
the current timestep using \c H5PartSetStep(), you can start writing datasets
into the file. Each dataset has a name associated with it (chosen by the
user) in order to facilitate later retrieval. The name of the dataset is
specified in the parameter \c name, which must be a null-terminated string.
There are no restrictions on naming of datasets, but it is useful to arrive
at some common naming convention when sharing data with other groups.
The writing routines also implicitly store the datatype of the array so that
the array can be reconstructed properly on other systems with incompatible
type representations.
All data that is written after setting the timestep is associated with that
timestep. While the number of particles can change for each timestep, you
cannot change the number of particles in the middle of a given timestep.
The data is committed to disk before the routine returns.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5PartWriteDataInt32 (
H5PartFile *f, /*!< [in] Handle to open file */
const char *name, /*!< [in] Name to associate array with */
const h5part_int32_t *array /*!< [in] Array to commit to disk */
) {
SET_FNAME ( "H5PartWriteDataInt32" );
h5part_int64_t herr;
CHECK_FILEHANDLE ( f );
CHECK_WRITABLE_MODE( f );
CHECK_TIMEGROUP( f );
herr = _write_data ( f, name, (void*)array, H5T_NATIVE_INT32 );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/********************** reading and writing attribute ************************/
/********************** private functions to handle attributes ***************/
@@ -768,20 +990,26 @@ _H5Part_normalize_h5_type (
switch ( tclass ){
case H5T_INTEGER:
if ( size==8 ) {
return H5T_NATIVE_INT64;
}
else if ( size==1 ) {
return H5T_NATIVE_CHAR;
}
break;
if ( size==8 ) {
return H5T_NATIVE_INT64;
}
else if ( size==1 ) {
return H5T_NATIVE_CHAR;
}
break;
case H5T_FLOAT:
return H5T_NATIVE_DOUBLE;
if ( size==8 ) {
return H5T_NATIVE_DOUBLE;
}
else if ( size==4 ) {
return H5T_NATIVE_FLOAT;
}
break;
default:
; /* NOP */
; /* NOP */
}
_H5Part_print_warn ( "Unknown type %d", (int)type );
return -1;
}
@@ -799,7 +1027,14 @@ _H5Part_read_attrib (
hid_t mytype;
hsize_t nelem;
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
if (! H5Aexists ( id, attrib_name )) {
_H5Part_print_warn ( "Attribute does not exist!" );
}
attrib_id = H5Aopen ( id, attrib_name, H5P_DEFAULT );
#else
attrib_id = H5Aopen_name ( id, attrib_name );
#endif
if ( attrib_id <= 0 ) return HANDLE_H5A_OPEN_NAME_ERR( attrib_name );
mytype = H5Aget_type ( attrib_id );
@@ -845,12 +1080,22 @@ _H5Part_write_attrib (
if ( space_id < 0 )
return HANDLE_H5S_CREATE_SIMPLE_ERR ( attrib_nelem );
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
attrib_id = H5Acreate2 (
id,
attrib_name,
attrib_type,
space_id,
H5P_DEFAULT,
H5P_DEFAULT );
#else
attrib_id = H5Acreate (
id,
attrib_name,
attrib_type,
space_id,
H5P_DEFAULT );
#endif
if ( attrib_id < 0 ) return HANDLE_H5A_CREATE_ERR ( attrib_name );
herr = H5Awrite ( attrib_id, attrib_type, attrib_value);
@@ -944,7 +1189,11 @@ H5PartWriteFileAttribString (
CHECK_FILEHANDLE ( f );
CHECK_WRITABLE_MODE( f );
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
hid_t group_id = H5Gopen2(f->file,"/",H5P_DEFAULT);
#else
hid_t group_id = H5Gopen(f->file,"/");
#endif
if ( group_id < 0 ) return HANDLE_H5G_OPEN_ERR( "/" );
h5part_int64_t herr = _H5Part_write_attrib (
@@ -1083,7 +1332,11 @@ H5PartWriteFileAttrib (
CHECK_FILEHANDLE ( f );
CHECK_WRITABLE_MODE ( f );
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
group_id = H5Gopen2(f->file,"/",H5P_DEFAULT);
#else
group_id = H5Gopen(f->file,"/");
#endif
if ( group_id < 0 ) return HANDLE_H5G_OPEN_ERR( "/" );
herr = _H5Part_write_attrib (
@@ -1141,7 +1394,11 @@ H5PartGetNumFileAttribs (
CHECK_FILEHANDLE ( f );
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
hid_t group_id = H5Gopen2 ( f->file, "/", H5P_DEFAULT );
#else
hid_t group_id = H5Gopen ( f->file, "/" );
#endif
if ( group_id < 0 ) HANDLE_H5G_OPEN_ERR ( "/" );
nattribs = H5Aget_num_attrs ( group_id );
@@ -1170,7 +1427,7 @@ h5part_int64_t
H5PartGetStepAttribInfo (
H5PartFile *f, /*!< [in] Handle to open file */
const h5part_int64_t attrib_idx,/*!< [in] Index of attribute to
get infos about */
get infos about */
char *attrib_name, /*!< [out] Name of attribute */
const h5part_int64_t len_of_attrib_name,
/*!< [in] length of buffer \c name */
@@ -1213,7 +1470,7 @@ h5part_int64_t
H5PartGetFileAttribInfo (
H5PartFile *f, /*!< [in] Handle to open file */
const h5part_int64_t attrib_idx,/*!< [in] Index of attribute to get
infos about */
infos about */
char *attrib_name, /*!< [out] Name of attribute */
const h5part_int64_t len_of_attrib_name,
/*!< [in] length of buffer \c name */
@@ -1227,7 +1484,11 @@ H5PartGetFileAttribInfo (
CHECK_FILEHANDLE( f );
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
group_id = H5Gopen2(f->file,"/",H5P_DEFAULT);
#else
group_id = H5Gopen(f->file,"/");
#endif
if ( group_id < 0 ) return HANDLE_H5G_OPEN_ERR( "/" );
herr = _H5Part_get_attrib_info (
@@ -1292,7 +1553,11 @@ H5PartReadFileAttrib (
CHECK_FILEHANDLE( f );
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
group_id = H5Gopen2(f->file,"/",H5P_DEFAULT);
#else
group_id = H5Gopen(f->file,"/");
#endif
if ( group_id < 0 ) return HANDLE_H5G_OPEN_ERR( "/" );
herr = _H5Part_read_attrib ( group_id, attrib_name, attrib_value );
@@ -1325,17 +1590,25 @@ _H5Part_set_step (
char name[128];
sprintf (
name,
"%s#%0*lld",
f->groupname_step, f->stepno_width, (long long) step );
herr_t herr = H5Gget_objinfo( f->file, name, 1, NULL );
if ( (f->mode != H5PART_READ) && ( herr >= 0 ) ) {
/* Work around sprintf bug on older systems */
if (f->stepno_width == 0 && step == 0) {
sprintf (
name,
"%s#%0*lld",
f->groupname_step, 1, (long long) step );
}
else {
sprintf (
name,
"%s#%0*lld",
f->groupname_step, f->stepno_width, (long long) step );
}
if ( (f->mode != H5PART_READ) && _H5Part_have_group ( f->file, name ) ) {
return HANDLE_H5PART_STEP_EXISTS_ERR ( step );
}
if ( f->timegroup >= 0 ) {
herr = H5Gclose ( f->timegroup );
herr_t herr = H5Gclose ( f->timegroup );
if ( herr < 0 ) return HANDLE_H5G_CLOSE_ERR;
}
f->timegroup = -1;
@@ -1348,7 +1621,11 @@ _H5Part_set_step (
(long long)step,
(long long)(size_t) f );
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
f->timegroup = H5Gopen2 ( f->file, name, H5P_DEFAULT );
#else
f->timegroup = H5Gopen ( f->file, name );
#endif
if ( f->timegroup < 0 ) return HANDLE_H5G_OPEN_ERR( name );
}
else {
@@ -1358,7 +1635,16 @@ _H5Part_set_step (
(long long)step,
(long long)(size_t) f );
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
f->timegroup = H5Gcreate2 (
f->file,
name,
0,
H5P_DEFAULT,
H5P_DEFAULT );
#else
f->timegroup = H5Gcreate ( f->file, name, 0 );
#endif
if ( f->timegroup < 0 ) return HANDLE_H5G_CREATE_ERR ( name );
}
@@ -1396,6 +1682,23 @@ H5PartSetStep (
/********************** query file structure *********************************/
/*!
\ingroup h5part_kernel
Test whether a group named \c name exists at location \c id.
*/
h5part_int64_t
_H5Part_have_group (
const hid_t id,
const char *name
) {
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
return (H5Lexists( id, name, H5P_DEFAULT ) ? 1 : 0);
#else
return (H5Gget_objinfo( id, name, 1, NULL ) >= 0 ? 1 : 0);
#endif
}
/*!
\ingroup h5part_kernel
@@ -1410,12 +1713,20 @@ _H5Part_iteration_operator (
struct _iter_op_data *data = (struct _iter_op_data*)operator_data;
herr_t herr;
H5G_stat_t objinfo;
if ( data->type != H5G_UNKNOWN ) {
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
H5O_info_t objinfo;
hid_t member_id;
member_id = H5Gopen2 ( group_id, member_name, H5P_DEFAULT );
herr = H5Oget_info ( member_id, &objinfo );
if ( herr < 0 ) return (herr_t)HANDLE_H5G_GET_OBJINFO_ERR ( member_name );
H5Gclose (member_id);
#else
H5G_stat_t objinfo;
herr = H5Gget_objinfo ( group_id, member_name, 1, &objinfo );
if ( herr < 0 ) return (herr_t)HANDLE_H5G_GET_OBJINFO_ERR ( member_name );
#endif
if ( objinfo.type != data->type )
return 0;/* don't count, continue iteration */
}
@@ -1541,10 +1852,14 @@ H5PartHasStep (
CHECK_FILEHANDLE( f );
char name[128];
sprintf ( name, "%s#%0*lld", f->groupname_step, f->stepno_width, (long long) step );
herr_t herr = H5Gget_objinfo( f->file, name, 1, NULL );
return ( herr >= 0 );
/* Work around sprintf bug on older systems */
if (f->stepno_width == 0 && step == 0) {
sprintf ( name, "%s#%0*lld", f->groupname_step, 1, (long long) step );
}
else {
sprintf ( name, "%s#%0*lld", f->groupname_step, f->stepno_width, (long long) step );
}
return _H5Part_have_group ( f->file, name );
}
@@ -1594,10 +1909,19 @@ H5PartGetNumDatasets (
CHECK_FILEHANDLE( f );
sprintf (
stepname,
"%s#%0*lld",
f->groupname_step, f->stepno_width, (long long) f->timestep );
/* Work around sprintf bug on older systems */
if (f->stepno_width == 0 && f->timestep == 0) {
sprintf (
stepname,
"%s#%0*lld",
f->groupname_step, 1, (long long) f->timestep );
}
else {
sprintf (
stepname,
"%s#%0*lld",
f->groupname_step, f->stepno_width, (long long) f->timestep );
}
return _H5Part_get_num_objects ( f->file, stepname, H5G_DATASET );
}
@@ -1627,10 +1951,19 @@ H5PartGetDatasetName (
CHECK_FILEHANDLE ( f );
CHECK_TIMEGROUP ( f );
sprintf (
stepname,
"%s#%0*lld",
f->groupname_step, f->stepno_width, (long long) f->timestep );
/* Work around sprintf bug on older systems */
if (f->stepno_width == 0 && f->timestep == 0) {
sprintf (
stepname,
"%s#%0*lld",
f->groupname_step, 1, (long long) f->timestep );
}
else {
sprintf (
stepname,
"%s#%0*lld",
f->groupname_step, f->stepno_width, (long long) f->timestep );
}
return _H5Part_get_object_name (
f->file,
@@ -1672,10 +2005,19 @@ H5PartGetDatasetInfo (
CHECK_FILEHANDLE ( f );
CHECK_TIMEGROUP ( f );
sprintf (
step_name,
"%s#%0*lld",
f->groupname_step, f->stepno_width, (long long) f->timestep );
/* Work around sprintf bug on older systems */
if (f->stepno_width == 0 && f->timestep == 0) {
sprintf (
step_name,
"%s#%0*lld",
f->groupname_step, 1, (long long) f->timestep );
}
else {
sprintf (
step_name,
"%s#%0*lld",
f->groupname_step, f->stepno_width, (long long) f->timestep );
}
herr = _H5Part_get_object_name (
f->file,
@@ -1689,7 +2031,11 @@ H5PartGetDatasetInfo (
*nelem = _H5Part_get_num_particles ( f );
if ( *nelem < 0 ) return *nelem;
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
dataset_id = H5Dopen2 ( f->timegroup, dataset_name, H5P_DEFAULT );
#else
dataset_id = H5Dopen ( f->timegroup, dataset_name );
#endif
if ( dataset_id < 0 ) HANDLE_H5D_OPEN_ERR ( dataset_name );
mytype = H5Dget_type ( dataset_id );
@@ -1788,10 +2134,18 @@ _H5Part_get_num_particles (
hsize_t nparticles;
/* Get first dataset in current time-step */
sprintf (
step_name,
"%s#%0*lld",
f->groupname_step, f->stepno_width, (long long) f->timestep );
if (f->stepno_width == 0 && f->timestep == 0) {
sprintf (
step_name,
"%s#%0*lld",
f->groupname_step, 1, (long long) f->timestep );
}
else {
sprintf (
step_name,
"%s#%0*lld",
f->groupname_step, f->stepno_width, (long long) f->timestep );
}
herr = _H5Part_get_object_name (
f->file,
@@ -1801,7 +2155,11 @@ _H5Part_get_num_particles (
dataset_name, sizeof (dataset_name) );
if ( herr < 0 ) return herr;
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
dataset_id = H5Dopen2 ( f->timegroup, dataset_name, H5P_DEFAULT );
#else
dataset_id = H5Dopen ( f->timegroup, dataset_name );
#endif
if ( dataset_id < 0 )
return HANDLE_H5D_OPEN_ERR ( dataset_name );
@@ -2166,7 +2524,11 @@ _read_data (
h5part_int64_t h5err = _H5Part_set_step ( f, f->timestep );
if ( h5err < 0 ) return h5err;
}
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
dataset_id = H5Dopen2 ( f->timegroup, name, H5P_DEFAULT );
#else
dataset_id = H5Dopen ( f->timegroup, name );
#endif
if ( dataset_id < 0 ) return HANDLE_H5D_OPEN_ERR ( name );
space_id = _get_diskshape_for_reading ( f, dataset_id );
@@ -2248,7 +2610,38 @@ H5PartReadDataFloat64 (
/*!
\ingroup h5part_read
Read array of 64 bit floating point data from file.
Read array of 32 bit floating point data from file.
When retrieving datasets from disk, you ask for them
by name. There are no restrictions on naming of arrays,
but it is useful to arrive at some common naming
convention when sharing data with other groups.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5PartReadDataFloat32 (
H5PartFile *f, /*!< [in] Handle to open file */
const char *name, /*!< [in] Name to associate dataset with */
h5part_float32_t *array /*!< [out] Array of data */
) {
SET_FNAME ( "H5PartReadDataFloat32" );
h5part_int64_t herr;
CHECK_FILEHANDLE( f );
herr = _read_data ( f, name, array, H5T_NATIVE_FLOAT );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5part_read
Read array of 64 bit integer data from file.
When retrieving datasets from disk, you ask for them
by name. There are no restrictions on naming of arrays,
@@ -2276,6 +2669,37 @@ H5PartReadDataInt64 (
return H5PART_SUCCESS;
}
/*!
\ingroup h5part_read
Read array of 32 bit integer data from file.
When retrieving datasets from disk, you ask for them
by name. There are no restrictions on naming of arrays,
but it is useful to arrive at some common naming
convention when sharing data with other groups.
\return \c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5PartReadDataInt32 (
H5PartFile *f, /*!< [in] Handle to open file */
const char *name, /*!< [in] Name to associate dataset with */
h5part_int32_t *array /*!< [out] Array of data */
) {
SET_FNAME ( "H5PartReadDataInt64" );
h5part_int64_t herr;
CHECK_FILEHANDLE( f );
herr = _read_data ( f, name, array, H5T_NATIVE_INT32 );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
/*!
\ingroup h5part_read
@@ -2456,7 +2880,11 @@ _init ( void ) {
herr_t r5;
if ( ! __init ) {
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
r5 = H5Eset_auto2 ( H5E_DEFAULT, _h5_error_handler, NULL );
#else
r5 = H5Eset_auto ( _h5_error_handler, NULL );
#endif
if ( r5 < 0 ) return H5PART_ERR_INIT;
}
__init = 1;
@@ -2465,10 +2893,18 @@ _init ( void ) {
/*! @} */
static herr_t
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
_h5_error_handler ( hid_t estack, void* unused ) {
#else
_h5_error_handler ( void* unused ) {
#endif
if ( _debug >= 5 ) {
if ( _debug >= 1 ) {
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
H5Eprint2 (H5E_DEFAULT,stderr);
#else
H5Eprint (stderr);
#endif
}
return 0;
}
@@ -2575,6 +3011,28 @@ _H5Part_print_debug (
va_end ( ap );
}
void
_H5Part_vprint_debug_detail (
const char *fmt,
va_list ap
) {
if ( _debug < 5 ) return;
_vprint ( stdout, "DD", fmt, ap );
}
void
_H5Part_print_debug_detail (
const char *fmt,
...
) {
va_list ap;
va_start ( ap, fmt );
_H5Part_vprint_debug_detail ( fmt, ap );
va_end ( ap );
}
void
_H5Part_set_funcname (
char * const fname
+52 -4
View File
@@ -23,17 +23,21 @@ extern "C" {
#define H5PART_ERR_INIT -200
#define H5PART_ERR_NOENTRY -201
#define H5PART_ERR_MPI -201
#define H5PART_ERR_HDF5 -202
#define H5PART_ERR_MPI -300
#define H5PART_ERR_HDF5 -400
/* flags used during file open */
#define H5PART_READ 0x01
#define H5PART_WRITE 0x02
#define H5PART_APPEND 0x03
#define H5PART_APPEND 0x04
#define H5PART_VFD_MPIPOSIX 0x08
#define H5PART_FS_LUSTRE 0x10
#define H5PART_FS_GPFS 0x20
#define H5PART_INT64 ((h5part_int64_t)H5T_NATIVE_INT64)
#define H5PART_FLOAT64 ((h5part_int64_t)H5T_NATIVE_DOUBLE)
#define H5PART_FLOAT32 ((h5part_int64_t)H5T_NATIVE_FLOAT)
#define H5PART_CHAR ((h5part_int64_t)H5T_NATIVE_CHAR)
/*========== File Opening/Closing ===============*/
@@ -43,7 +47,15 @@ H5PartOpenFile(
const unsigned flags
);
H5PartFile*
H5PartOpenFileAlign(
const char *filename,
const unsigned flags,
h5part_int64_t align
);
#define H5PartOpenFileSerial(x,y) H5PartOpenFile(x,y)
#define H5PartOpenFileSerialAlign(x,y,z) H5PartOpenFileAlign(x,y,z)
#ifdef PARALLEL_IO
H5PartFile*
@@ -52,6 +64,14 @@ H5PartOpenFileParallel (
const unsigned flags,
MPI_Comm communicator
);
H5PartFile*
H5PartOpenFileParallelAlign (
const char *filename,
const unsigned flags,
MPI_Comm communicator,
h5part_int64_t align
);
#endif
@@ -82,6 +102,13 @@ H5PartWriteDataFloat64 (
const h5part_float64_t *array
);
h5part_int64_t
H5PartWriteDataFloat32 (
H5PartFile *f,
const char *name,
const h5part_float32_t *array
);
h5part_int64_t
H5PartWriteDataInt64 (
H5PartFile *f,
@@ -89,6 +116,13 @@ H5PartWriteDataInt64 (
const h5part_int64_t *array
);
h5part_int64_t
H5PartWriteDataInt32 (
H5PartFile *f,
const char *name,
const h5part_int32_t *array
);
/*================== File Reading Routines =================*/
h5part_int64_t
H5PartSetStep (
@@ -172,6 +206,13 @@ H5PartReadDataFloat64(
h5part_float64_t *array
);
h5part_int64_t
H5PartReadDataFloat32(
H5PartFile *f,
const char *name,
h5part_float32_t *array
);
h5part_int64_t
H5PartReadDataInt64 (
H5PartFile *f,
@@ -179,6 +220,13 @@ H5PartReadDataInt64 (
h5part_int64_t *array
);
h5part_int64_t
H5PartReadDataInt32 (
H5PartFile *f,
const char *name,
h5part_int32_t *array
);
h5part_int64_t
H5PartReadParticleStep (
H5PartFile *f,
+21 -3
View File
@@ -38,7 +38,7 @@
"Called with bad filehandle." );
#define HANDLE_H5PART_INIT_ERR \
(*_err_handler) ( \
(*_err_handler) ( \
_H5Part_get_funcname(), \
H5PART_ERR_INIT, \
"Cannot initialize H5Part." );
@@ -171,6 +171,12 @@
H5PART_ERR_HDF5, \
"Cannot get dataspace identifier.");
#define HANDLE_H5D_GET_PLIST_ERR \
(*_err_handler) ( \
_H5Part_get_funcname(), \
H5PART_ERR_HDF5, \
"Cannot get dataspace property list.");
#define HANDLE_H5D_GET_TYPE_ERR \
(*_err_handler) ( \
_H5Part_get_funcname(), \
@@ -258,12 +264,24 @@
"MPI: Cannot set data transfer mode." );
#define HANDLE_H5P_SET_FAPL_MPIO_ERR \
#define HANDLE_H5P_SET_FAPL_ERR \
(*_err_handler) ( \
_H5Part_get_funcname(), \
H5PART_ERR_HDF5, \
"Cannot store IO communicator information to the " \
"file access property list.");
"file access property list." );
#define HANDLE_H5P_SET_CHUNK_ERR \
(*_err_handler) ( \
_H5Part_get_funcname(), \
H5PART_ERR_HDF5, \
"Cannot set chunk dimensions." );
#define HANDLE_H5P_GET_CHUNK_ERR \
(*_err_handler) ( \
_H5Part_get_funcname(), \
H5PART_ERR_HDF5, \
"Cannot get chunk dimensions." );
/* H5S: dataspace */
#define HANDLE_H5S_CREATE_SIMPLE_ERR( n ) \
+204 -3
View File
@@ -1,5 +1,6 @@
#include "H5Part.h"
#include "Underscore.h"
#include <string.h>
#include <hdf5.h>
#if defined(F77_SINGLE_UNDERSCORE)
@@ -32,6 +33,25 @@
#define h5pt_opena_par F77NAME ( \
h5pt_opena_par_, \
H5PT_OPENA_PAR )
#define h5pt_openr_align F77NAME ( \
h5pt_openr_align_, \
H5PT_OPENR_ALIGN )
#define h5pt_openw_align F77NAME ( \
h5pt_openw_align_, \
H5PT_OPENW_ALIGN )
#define h5pt_opena_align F77NAME ( \
h5pt_opena_align_, \
H5PT_OPENA_ALIGN )
#define h5pt_openr_par_align F77NAME ( \
h5pt_openr_par_align, \
H5PT_OPENR_PAR_ALIGN )
#define h5pt_openw_par_align F77NAME ( \
h5pt_openw_par_align_, \
H5PT_OPENW_PAR_ALIGN )
#define h5pt_opena_par_align F77NAME ( \
h5pt_opena_par_align_, \
H5PT_OPENA_PAR_ALIGN )
#define h5pt_close F77NAME ( \
h5pt_close_, \
H5PT_CLOSE)
@@ -46,9 +66,15 @@
#define h5pt_writedata_r8 F77NAME ( \
h5pt_writedata_r8_, \
H5PT_WRITEDATA_R8 )
#define h5pt_writedata_r4 F77NAME ( \
h5pt_writedata_r4_, \
H5PT_WRITEDATA_R4 )
#define h5pt_writedata_i8 F77NAME ( \
h5pt_writedata_i8_, \
H5PT_WRITEDATA_I8 )
#define h5pt_writedata_i4 F77NAME ( \
h5pt_writedata_i4_, \
H5PT_WRITEDATA_I4 )
/* Reading interface (define dataset, step, particles, attributes) */
#define h5pt_getnsteps F77NAME ( \
@@ -85,12 +111,15 @@
#define h5pt_readdata_r8 F77NAME ( \
h5pt_readdata_r8_, \
H5PT_READDATA_R8 )
#define h5pt_readdata_r4 F77NAME ( \
h5pt_readdata_r4_, \
H5PT_READDATA_R4 )
#define h5pt_readdata_i8 F77NAME ( \
h5pt_readdata_i8_, \
H5PT_READDATA_I8 )
#define h5pt_readdata F77NAME ( \
h5pt_readdata_, \
H5PT_READDATA )
#define h5pt_readdata_i4 F77NAME ( \
h5pt_readdata_i4_, \
H5PT_READDATA_I4 )
/* Writing attributes */
#define h5pt_writefileattrib_r8 F77NAME ( \
@@ -227,6 +256,51 @@ h5pt_opena (
return (h5part_int64_t)(size_t)f;
}
h5part_int64_t
h5pt_openr_align (
const char *file_name,
const h5part_int64_t *align,
const int l_file_name
) {
char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );
H5PartFile* f = H5PartOpenFileAlign ( file_name2, H5PART_READ, *align );
free ( file_name2 );
return (h5part_int64_t)(size_t)f;
}
h5part_int64_t
h5pt_openw_align (
const char *file_name,
const h5part_int64_t *align,
const int l_file_name
) {
char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );
H5PartFile* f = H5PartOpenFileAlign ( file_name2, H5PART_WRITE, *align );
free ( file_name2 );
return (h5part_int64_t)(size_t)f;
}
h5part_int64_t
h5pt_opena_align (
const char *file_name,
const h5part_int64_t *align,
const int l_file_name
) {
char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );
H5PartFile* f = H5PartOpenFileAlign ( file_name2, H5PART_APPEND, *align );
free ( file_name2 );
return (h5part_int64_t)(size_t)f;
}
#ifdef PARALLEL_IO
h5part_int64_t
h5pt_openr_par (
@@ -275,6 +349,57 @@ h5pt_opena_par (
free ( file_name2 );
return (h5part_int64_t)(size_t)f;
}
h5part_int64_t
h5pt_openr_par_align (
const char *file_name,
MPI_Comm *comm,
const h5part_int64_t *align,
const int l_file_name
) {
char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );
H5PartFile* f = H5PartOpenFileParallelAlign (
file_name2, H5PART_READ, *comm, *align );
free ( file_name2 );
return (h5part_int64_t)(size_t)f;
}
h5part_int64_t
h5pt_openw_par_align (
const char *file_name,
MPI_Comm *comm,
const h5part_int64_t *align,
const int l_file_name
) {
char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );
H5PartFile* f = H5PartOpenFileParallelAlign (
file_name2, H5PART_WRITE, *comm, *align );
free ( file_name2 );
return (h5part_int64_t)(size_t)f;
}
h5part_int64_t
h5pt_opena_par_align (
const char *file_name,
MPI_Comm *comm,
const h5part_int64_t *align,
const int l_file_name
) {
char *file_name2 = _H5Part_strdupfor2c ( file_name, l_file_name );
H5PartFile* f = H5PartOpenFileParallelAlign (
file_name2, H5PART_APPEND, *comm, *align );
free ( file_name2 );
return (h5part_int64_t)(size_t)f;
}
#endif
h5part_int64_t
@@ -348,6 +473,25 @@ h5pt_writedata_r8 (
return herr;
}
h5part_int64_t
h5pt_writedata_r4 (
const h5part_int64_t *f,
const char *name,
const h5part_float32_t *data,
const int l_name ) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *name2 = _H5Part_strdupfor2c ( name, l_name );
h5part_int64_t herr = H5PartWriteDataFloat32 (
filehandle, name2, data );
free ( name2 );
return herr;
}
h5part_int64_t
h5pt_writedata_i8 (
const h5part_int64_t *f,
@@ -367,6 +511,25 @@ h5pt_writedata_i8 (
return herr;
}
h5part_int64_t
h5pt_writedata_i4 (
const h5part_int64_t *f,
const char *name,
const h5part_int32_t *data,
const int l_name ) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *name2 = _H5Part_strdupfor2c ( name, l_name );
h5part_int64_t herr = H5PartWriteDataInt32 (
filehandle, name2, data );
free ( name2 );
return herr;
}
/*==============Reading Data Characteristics============*/
h5part_int64_t
@@ -491,6 +654,25 @@ h5pt_readdata_r8 (
return herr;
}
h5part_int64_t
h5pt_readdata_r4 (
const h5part_int64_t *f,
const char *name,
h5part_float32_t *array,
const int l_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *name2 = _H5Part_strdupfor2c ( name, l_name );
h5part_int64_t herr = H5PartReadDataFloat32 (
filehandle, name2, array );
free ( name2 );
return herr;
}
h5part_int64_t
h5pt_readdata_i8 (
const h5part_int64_t *f,
@@ -510,6 +692,25 @@ h5pt_readdata_i8 (
return herr;
}
h5part_int64_t
h5pt_readdata_i4 (
const h5part_int64_t *f,
const char *name,
h5part_int32_t *array,
const int l_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *name2 = _H5Part_strdupfor2c ( name, l_name );
h5part_int64_t herr = H5PartReadDataInt32 (
filehandle, name2, array );
free ( name2 );
return herr;
}
/*=================== Attributes ================*/
/* Writeing attributes */
+66
View File
@@ -30,6 +30,40 @@
END FUNCTION
INTEGER*8 FUNCTION h5pt_openr_align ( filename, align )
CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for reading
INTEGER*8, INTENT(IN) :: align ! alignment value in bytes
END FUNCTION
INTEGER*8 FUNCTION h5pt_openw_align ( filename, align )
CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for writing
INTEGER*8, INTENT(IN) :: align ! alignment value in bytes
END FUNCTION
INTEGER*8 FUNCTION h5pt_opena_align ( filename, align )
CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for appending
INTEGER*8, INTENT(IN) :: align ! alignment value in bytes
END FUNCTION
INTEGER*8 FUNCTION h5pt_openr_par_align ( filename, mpi_communicator, align )
CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for reading
INTEGER, INTENT(IN) :: mpi_communicator ! the MPI_Communicator used by the program
INTEGER*8, INTENT(IN) :: align ! alignment value in bytes
END FUNCTION
INTEGER*8 FUNCTION h5pt_openw_par_align ( filename, mpi_communicator, align )
CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for writing
INTEGER, INTENT(IN) :: mpi_communicator ! the MPI_Communicator used by the program
INTEGER*8, INTENT(IN) :: align ! alignment value in bytes
END FUNCTION
INTEGER*8 FUNCTION h5pt_opena_par_align ( filename, mpi_communicator, align )
CHARACTER(LEN=*), INTENT(IN) :: filename ! the filename to open for appending
INTEGER, INTENT(IN) :: mpi_communicator ! the MPI_Communicator used by the program
INTEGER*8, INTENT(IN) :: align ! alignment value in bytes
END FUNCTION
INTEGER*8 FUNCTION h5pt_close ( filehandle )
INTEGER*8, INTENT(IN) :: filehandle ! close this open filehandle
END FUNCTION
@@ -54,12 +88,26 @@
! h5pt_setnpoints(f,npoints)
END FUNCTION
INTEGER*8 FUNCTION h5pt_writedata_r4 ( filehandle, name, data )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name ! The name of the data we are writing
REAL, 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
INTEGER*8 FUNCTION h5pt_writedata_i4 ( filehandle, name, data )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name ! The name of the data we are writing
INTEGER, INTENT(IN) :: data(*)
END FUNCTION
!==============Reading Data Characteristics============
INTEGER*8 FUNCTION h5pt_getnsteps (filehandle)
@@ -116,6 +164,15 @@
! number of particles in the file.
END FUNCTION
INTEGER*8 FUNCTION h5pt_readdata_r4 (filehandle,name,data)
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name ! The name of the data we are writing
REAL, 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
@@ -125,6 +182,15 @@
! number of particles in the file.
END FUNCTION
INTEGER*8 FUNCTION h5pt_readdata_i4 (filehandle,name,data)
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name ! The name of the data we are writing
INTEGER, 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 ================
+24
View File
@@ -3,6 +3,8 @@
#define H5PART_GROUPNAME_STEP "Step"
#define H5PART_BTREE_IK 10000
/*!
The functions declared here are not part of the API, but may be used
in extensions like H5Block. We name these functions "private".
@@ -108,6 +110,12 @@ _H5Part_get_object_name (
const h5part_int64_t len_obj_name
);
h5part_int64_t
_H5Part_have_group (
const hid_t id,
const char *name
);
void
_H5Part_vprint_error (
const char *fmt,
@@ -171,6 +179,22 @@ __attribute__ ((format (printf, 1, 2)))
#endif
;
void
_H5Part_vprint_debug_detail (
const char *fmt,
va_list ap
);
void
_H5Part_print_debug_detail (
const char *fmt,
...
)
#ifdef __GNUC__
__attribute__ ((format (printf, 1, 2)))
#endif
;
char *
_H5Part_strdupfor2c (
const char *s,
+2
View File
@@ -10,7 +10,9 @@ typedef __int64 int64_t;
#endif /* WIN32 */
typedef int64_t h5part_int64_t;
typedef int h5part_int32_t;
typedef double h5part_float64_t;
typedef float h5part_float32_t;
typedef h5part_int64_t (*h5part_error_handler)( const char*, const h5part_int64_t, const char*,...)
#ifdef __GNUC__
__attribute__ ((format (printf, 3, 4)))
+7 -6
View File
@@ -40,14 +40,14 @@ lib_LIBRARIES = @MTARGET@
EXTRA_LIBRARIES = libH5Part.a libH5PartF.a
# Header files that I wish to install in $(prefix)/include
include_HEADERS = H5Part.h H5PartTypes.h H5PartErrors.h H5Block.h H5BlockTypes.h H5BlockErrors.h H5Part.inc H5PartF90.inc H5BlockF90.inc @UNDERSCORE_H@
include_HEADERS = H5Part.h H5PartTypes.h H5PartErrors.h H5Block.h H5BlockReadWrite.h H5BlockTypes.h H5BlockErrors.h H5Part.inc H5PartF90.inc H5BlockF90.inc H5BlockReadWriteF90.inc @UNDERSCORE_H@
# Listing of all possible headers that I may include
EXTRA_HEADERS = H5PartPrivate.h H5BlockPrivate.h
# Listing of sources
libH5Part_a_SOURCES = H5Part.c H5Block.c
libH5PartF_a_SOURCES = H5PartF.c H5BlockF.c
libH5Part_a_SOURCES = H5Part.c H5Block.c H5BlockReadWrite.c
libH5PartF_a_SOURCES = H5PartF.c H5BlockF.c H5BlockReadWriteF.c
H5Part.inc: H5PartF90.inc
@@ -55,10 +55,10 @@ H5Part.inc: H5PartF90.inc
# Specific building instruction (What compilers to use...)
# ------------ Serial Lib build commands ------------
libH5Part.a: H5Part.o H5Block.o
libH5Part.a: H5Part.o H5Block.o H5BlockReadWrite.o
${AR} rucs $@ $^
libH5PartF.a: H5Part.o H5PartF.o H5Block.o H5BlockF.o
libH5PartF.a: H5Part.o H5PartF.o H5Block.o H5BlockF.o H5BlockReadWrite.o H5BlockReadWriteF.o
${AR} rucs $@ $^
%.o : %.c
@@ -68,7 +68,8 @@ H5Part.o: H5Part.c H5Part.h H5PartPrivate.h H5PartTypes.h
H5PartF.o: H5PartF.c Underscore.h H5Part.h
H5Block.o: H5Block.c H5Part.h H5PartPrivate.h H5PartTypes.h H5Block.h H5BlockTypes.h
H5BlockF.o: H5BlockF.c Underscore.h H5Block.h
H5BlockReadWrite.o: H5BlockReadWrite.c H5Part.h H5PartPrivate.h H5PartTypes.h H5Block.h H5BlockPrivate.h H5BlockReadWrite.h H5BlockTypes.h
H5BlockReadWriteF.o: H5BlockF.c Underscore.h H5Block.h H5BlockReadWrite.h
# ----------- Build Parallel H5Part Stuff ------------
+472
View File
@@ -0,0 +1,472 @@
#!/usr/bin/python
c_head = """
#include <stdlib.h>
#include <string.h>
#include <hdf5.h>
#include "H5Part.h"
#include "H5PartErrors.h"
#include "H5PartPrivate.h"
#include "H5BlockTypes.h"
#include "H5Block.h"
#include "H5BlockPrivate.h"
#include "H5BlockErrors.h"
"""
h_head = """
#ifndef __H5BLOCKREADWRITE_H
#define __H5BLOCKREADWRITE_H
#ifdef __cplusplus
extern "C" {
#endif
"""
h_tail = """
#ifdef __cplusplus
}
#endif
#endif
"""
fc_head = """
#include "H5Part.h"
#include "H5PartPrivate.h"
#include "H5Block.h"
#include "H5BlockReadWrite.h"
#include "Underscore.h"
#if defined(F77_SINGLE_UNDERSCORE)
#define F77NAME(a,b) a
#elif defined(F77_CRAY_UNDERSCORE)
#define F77NAME(a,b) b
#elif defined(F77_NO_UNDERSCORE)
#else
#error Error, no way to determine how to construct fortran bindings
#endif
"""
fi_head = """
INTERFACE
"""
fi_tail = """
END INTERFACE
"""
write_scalar_h = """
h5part_int64_t
H5Block#DIM#dWriteScalarField#TYPE_ABV# (
H5PartFile *f,
const char *name,
const h5part_#TYPE_H5P#_t *data
);
"""
read_scalar_h = """
h5part_int64_t
H5Block#DIM#dReadScalarField#TYPE_ABV# (
H5PartFile *f,
const char *name,
h5part_#TYPE_H5P#_t *data
);
"""
write_scalar_c = """
/*!
\\ingroup h5block_c_api
Write a 3-dimensional field \\c name from the buffer starting at \\c data
to the current time-step using the defined field layout. Values are
#TYPE_FULL#.
You must use the Fortran indexing scheme to access items in \\c data.
\\return \\c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block#DIM#dWriteScalarField#TYPE_ABV# (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
const h5part_#TYPE_H5P#_t *data /*!< IN: scalar data to write */
) {
SET_FNAME ( "H5Block#DIM#dWriteScalarField#TYPE_ABV#" );
INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_create_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "0", data, #TYPE_HDF5# );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
"""
read_scalar_c = """
/*!
\\ingroup h5block_c_api
Read a 3-dimensional field \\c name into the buffer starting at \\c data from
the current time-step using the defined field layout. Values are
#TYPE_FULL#.
You must use the Fortran indexing scheme to access items in \\c data.
\\return \\c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block#DIM#dReadScalarField#TYPE_ABV# (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to read */
h5part_#TYPE_H5P#_t *data /*!< OUT: ptr to read buffer */
) {
SET_FNAME ( "H5Block#DIM#dReadScalarField#TYPE_ABV#" );
INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_open_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "0", data, #TYPE_HDF5# );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
"""
write_scalar_fi = """
INTEGER*8 FUNCTION h5bl_#DIM#d_write_scalar_field_#TYPE_F90_ABV# ( filehandle, name, data )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
#TYPE_F90#, INTENT(IN) :: data(*)
END FUNCTION
"""
read_scalar_fi = """
INTEGER*8 FUNCTION h5bl_#DIM#d_read_scalar_field_#TYPE_F90_ABV# ( filehandle, name, data )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
#TYPE_F90#, INTENT(OUT) :: data(*)
END FUNCTION
"""
write_scalar_fc = """
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_#DIM#d_write_scalar_field_#TYPE_F90_ABV# F77NAME ( \\
h5bl_#DIM#d_write_scalar_field_#TYPE_F90_ABV#_, \\
H5BL_#DIM#D_WRITE_SCALAR_FIELD_#TYPE_F90_ABVC# )
#endif
h5part_int64_t
h5bl_#DIM#d_write_scalar_field_#TYPE_F90_ABV# (
h5part_int64_t *f,
const char *field_name,
const h5part_#TYPE_H5P#_t *data,
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block#DIM#dWriteScalarField#TYPE_ABV# (
filehandle, field_name2, data );
free ( field_name2 );
return herr;
}
"""
read_scalar_fc = """
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_3d_read_scalar_field_#TYPE_F90_ABV# F77NAME ( \\
h5bl_3d_read_scalar_field_#TYPE_F90_ABV#_, \\
H5BL_#DIM#D_READ_SCALAR_FIELD_#TYPE_F90_ABVC# )
#endif
h5part_int64_t
h5bl_#DIM#d_read_scalar_field_#TYPE_F90_ABV# (
h5part_int64_t *f,
const char *field_name,
h5part_#TYPE_H5P#_t *data,
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block#DIM#dWriteScalarField#TYPE_ABV# (
filehandle, field_name2, data );
free ( field_name2 );
return herr;
}
"""
write_vector_h = """
h5part_int64_t
H5Block#DIM#dWrite3dVectorField#TYPE_ABV# (
H5PartFile *f,
const char *name,
const h5part_#TYPE_H5P#_t *xval,
const h5part_#TYPE_H5P#_t *yval,
const h5part_#TYPE_H5P#_t *zval
);
"""
read_vector_h = """
h5part_int64_t
H5Block#DIM#dRead3dVectorField#TYPE_ABV# (
H5PartFile *f,
const char *name,
h5part_#TYPE_H5P#_t *xval,
h5part_#TYPE_H5P#_t *yval,
h5part_#TYPE_H5P#_t *zval
);
"""
write_vector_c = """
/*!
\\ingroup h5block_c_api
*/
/*!
Write a 3-dimensional field \\c name with 3-dimensional vectors as values
from the buffers starting at \\c x_data, \\c y_data and \\c z_data to the
current time-step using the defined field layout. Values are 3-dimensional
vectors with #TYPE_FULL# values.
You must use the Fortran indexing scheme to access items in \\c data.
\\return \\c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block#DIM#dWrite3dVectorField#TYPE_ABV# (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
const h5part_#TYPE_H5P#_t *x_data, /*!< IN: X axis data */
const h5part_#TYPE_H5P#_t *y_data, /*!< IN: Y axis data */
const h5part_#TYPE_H5P#_t *z_data /*!< IN: Z axis data */
) {
SET_FNAME ( "H5Block#DIM#dWrite3dVectorField#TYPE_ABV#" );
INIT ( f );
CHECK_WRITABLE_MODE ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_create_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "0", x_data, #TYPE_HDF5# );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "1", y_data, #TYPE_HDF5# );
if ( herr < 0 ) return herr;
herr = _H5Block_write_data ( f, "2", z_data, #TYPE_HDF5# );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
"""
read_vector_c = """
/*!
\\ingroup h5block_c_api
*/
/*!
Read a 3-dimensional field \\c name with 3-dimensional vectors as values
from the buffers starting at \\c x_data, \\c y_data and \\c z_data to the
current time-step using the defined field layout. Values are 3-dimensional
vectors with #TYPE_FULL# values.
You must use the Fortran indexing scheme to access items in \\c data.
\\return \\c H5PART_SUCCESS or error code
*/
h5part_int64_t
H5Block#DIM#dRead3dVectorField#TYPE_ABV# (
H5PartFile *f, /*!< IN: file handle */
const char *name, /*!< IN: name of dataset to write */
h5part_#TYPE_H5P#_t *x_data, /*!< OUT: X axis data */
h5part_#TYPE_H5P#_t *y_data, /*!< OUT: Y axis data */
h5part_#TYPE_H5P#_t *z_data /*!< OUT: Z axis data */
) {
SET_FNAME ( "H5Block#DIM#dRead3dVectorField#TYPE_ABV#" );
INIT ( f );
CHECK_TIMEGROUP ( f );
CHECK_LAYOUT ( f );
h5part_int64_t herr = _H5Block_open_field_group ( f, name );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "0", x_data, #TYPE_HDF5# );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "1", y_data, #TYPE_HDF5# );
if ( herr < 0 ) return herr;
herr = _H5Block_read_data ( f, "2", z_data, #TYPE_HDF5# );
if ( herr < 0 ) return herr;
herr = _H5Block_close_field_group ( f );
if ( herr < 0 ) return herr;
return H5PART_SUCCESS;
}
"""
write_vector_fi = """
INTEGER*8 FUNCTION h5bl_#DIM#d_write_3dvector_field_#TYPE_F90_ABV# ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
#TYPE_F90#, INTENT(IN) :: x(*)
#TYPE_F90#, INTENT(IN) :: y(*)
#TYPE_F90#, INTENT(IN) :: z(*)
END FUNCTION
"""
read_vector_fi = """
INTEGER*8 FUNCTION h5bl_#DIM#d_read_3dvector_field_#TYPE_F90_ABV# ( filehandle, name, x, y, z )
INTEGER*8, INTENT(IN) :: filehandle
CHARACTER(LEN=*), INTENT(IN) :: name
#TYPE_F90#, INTENT(OUT) :: x(*)
#TYPE_F90#, INTENT(OUT) :: y(*)
#TYPE_F90#, INTENT(OUT) :: z(*)
END FUNCTION
"""
write_vector_fc = """
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_#DIM#d_write_3dvector_field_#TYPE_F90_ABV# F77NAME ( \\
h5bl_#DIM#d_write_3dvector_field_#TYPE_F90_ABV#_, \\
H5BL_#DIM#D_WRITE_3DVECTOR_FIELD_#TYPE_F90_ABVC# )
#endif
h5part_int64_t
h5bl_#DIM#d_write_3dvector_field_#TYPE_F90_ABV# (
h5part_int64_t *f, /*!< file handle */
const char *field_name, /*!< name of the data set */
const h5part_#TYPE_H5P#_t *xval, /*!< array of x component data */
const h5part_#TYPE_H5P#_t *yval, /*!< array of y component data */
const h5part_#TYPE_H5P#_t *zval, /*!< array of z component data */
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block#DIM#dWrite3dVectorField#TYPE_ABV# (
filehandle, field_name2, xval, yval, zval );
free ( field_name2 );
return herr;
}
"""
read_vector_fc = """
#if ! defined(F77_NO_UNDERSCORE)
#define h5bl_#DIM#d_read_3dvector_field_#TYPE_F90_ABV# F77NAME ( \\
h5bl_#DIM#d_read_3dvector_field_#TYPE_F90_ABV#_, \\
H5BL_#DIM#D_READ_3DVECTOR_FIELD_#TYPE_F90_ABVC# )
#endif
h5part_int64_t
h5bl_#DIM#d_read_3dvector_field_#TYPE_F90_ABV# (
h5part_int64_t *f, /*!< file handle */
const char *field_name, /*!< name of the data set */
h5part_#TYPE_H5P#_t *xval, /*!< array of x component data */
h5part_#TYPE_H5P#_t *yval, /*!< array of y component data */
h5part_#TYPE_H5P#_t *zval, /*!< array of z component data */
const int l_field_name
) {
H5PartFile *filehandle = (H5PartFile*)(size_t)*f;
char *field_name2 = _H5Part_strdupfor2c ( field_name, l_field_name );
h5part_int64_t herr = H5Block#DIM#dRead3dVectorField#TYPE_ABV# (
filehandle, field_name2, xval, yval, zval );
free ( field_name2 );
return herr;
}
"""
dims = ["3"]
types = [
["floating points (64-bit)", "Float64", "float64", "H5T_NATIVE_DOUBLE", "REAL*8", "r8", "R8"],
["floating points (32-bit)", "Float32", "float32", "H5T_NATIVE_FLOAT", "REAL*4", "r4", "R4"],
["integers (64-bit)", "Int64", "int64", "H5T_NATIVE_INT64", "INTEGER*8", "i8", "I8"],
["integers (32-bit)", "Int32", "int32", "H5T_NATIVE_INT32", "INTEGER*4", "i4", "I4"]
]
def create_call(template, type, dim):
fcn = template
fcn = fcn.replace('#DIM#',dim)\
.replace('#TYPE_FULL#',type[0])\
.replace('#TYPE_ABV#',type[1])\
.replace('#TYPE_H5P#',type[2])\
.replace('#TYPE_HDF5#',type[3])\
.replace('#TYPE_F90#',type[4])\
.replace('#TYPE_F90_ABV#',type[5])\
.replace('#TYPE_F90_ABVC#',type[6])
return fcn
def write_calls():
cfile = file('H5BlockReadWrite.c','w')
cfile.write(c_head)
hfile = file('H5BlockReadWrite.h','w')
hfile.write(h_head)
fcfile = file('H5BlockReadWriteF.c','w')
fcfile.write(fc_head)
fifile = file('H5BlockReadWriteF90.inc','w')
fifile.write(fi_head)
for dim in dims:
for type in types:
cfile.write(create_call(write_scalar_c,type,dim));
cfile.write(create_call(read_scalar_c,type,dim));
hfile.write(create_call(write_scalar_h,type,dim));
hfile.write(create_call(read_scalar_h,type,dim));
fcfile.write(create_call(write_scalar_fc,type,dim));
fcfile.write(create_call(read_scalar_fc,type,dim));
fifile.write(create_call(write_scalar_fi,type,dim));
fifile.write(create_call(read_scalar_fi,type,dim));
cfile.write(create_call(write_vector_c,type,dim));
cfile.write(create_call(read_vector_c,type,dim));
hfile.write(create_call(write_vector_h,type,dim));
hfile.write(create_call(read_vector_h,type,dim));
fcfile.write(create_call(write_vector_fc,type,dim));
fcfile.write(create_call(read_vector_fc,type,dim));
fifile.write(create_call(write_vector_fi,type,dim));
fifile.write(create_call(read_vector_fi,type,dim));
cfile.close()
hfile.write(h_tail)
hfile.close()
fcfile.close()
fifile.write(fi_tail)
fifile.close()
write_calls()
+3 -2
View File
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <hdf5.h>
#include "H5Part.h"
#include "H5Block.h"
@@ -200,7 +201,7 @@ _write_data (
layout->k_start, layout->k_end );
if ( herr < 0 ) return herr;
herr = H5Block3dWriteScalarField ( f, "TestField", data );
herr = H5Block3dWriteScalarFieldFloat64 ( f, "TestField", data );
if ( herr < 0 ) return herr;
free ( data );
@@ -264,7 +265,7 @@ _read_data (
layout->k_start, layout->k_end );
if ( herr < 0 ) return herr;
herr = H5Block3dReadScalarField ( f, "TestField", data );
herr = H5Block3dReadScalarFieldFloat64 ( f, "TestField", data );
if ( herr < 0 ) return herr;
for ( i = 0; i < i_dims; i++ ) {
+4 -4
View File
@@ -243,7 +243,7 @@ PROGRAM H5BlockParTestScalarFieldF
INTEGER*8 :: file
INTEGER*8 :: timestep = 1
PRINT "('PROC[',I,']: Open file ',A,' for writing ...')", myproc, fname
PRINT "('PROC[',I5,']: Open file ',A,' for writing ...')", myproc, fname
file = h5pt_openw_par ( fname, comm )
if ( file == 0 ) THEN
@@ -327,7 +327,7 @@ PROGRAM H5BlockParTestScalarFieldF
END DO
PRINT *, "Writing field ..."
h5pt_err = h5bl_3d_write_scalar_field ( file, "TestField", data )
h5pt_err = h5bl_3d_write_scalar_field_r8 ( file, "TestField", data )
IF ( h5pt_err < 0 ) THEN
write_field = h5pt_err
RETURN
@@ -424,7 +424,7 @@ PROGRAM H5BlockParTestScalarFieldF
END IF
PRINT *, "Reading field ..."
h5pt_err = h5bl_3d_read_scalar_field ( file, "TestField", data )
h5pt_err = h5bl_3d_read_scalar_field_r8 ( file, "TestField", data )
IF ( h5pt_err < 0 ) THEN
read_field = -1
RETURN
@@ -446,7 +446,7 @@ PROGRAM H5BlockParTestScalarFieldF
value = rk + 1000*rj + 100000*ri + 10000000*proc
if ( data(i,j,k) /= value ) THEN
PRINT "('data(',I3,',',I3,',',I3,') = ',F,' /= ',F)", i, j, k, data(i,j,k), value
PRINT "('data(',I3,',',I3,',',I3,') = ',F5.2,' /= ',F5.2)", i, j, k, data(i,j,k), value
PRINT "('proc: ', I2)", proc
PRINT "('i_start: ', I3, ' i_end: ', I3)", i_start, i_end
PRINT "('j_start: ', I3, ' j_end: ', I3)", j_start, j_end
+3 -2
View File
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <hdf5.h>
#include "H5Part.h"
#include "H5Block.h"
@@ -56,7 +57,7 @@ _write_data (
layout->k_start, layout->k_end );
if ( herr < 0 ) return herr;
herr = H5Block3dWriteScalarField ( f, "TestField", data );
herr = H5Block3dWriteScalarFieldFloat64 ( f, "TestField", data );
if ( herr < 0 ) return herr;
free ( data );
@@ -179,7 +180,7 @@ _read_data (
layout->k_start, layout->k_end );
if ( herr < 0 ) return herr;
herr = H5Block3dReadScalarField ( f, "TestField", data );
herr = H5Block3dReadScalarFieldFloat64 ( f, "TestField", data );
if ( herr < 0 ) return herr;
for ( i = 0; i < i_dims; i++ ) {
+1 -1
View File
@@ -216,7 +216,7 @@ int main(int argc,char *argv[]){
if (status != H5PART_SUCCESS) {
perror("Could not retrieve dataset names!");
} else {
printf("datasetName: %s, type: %lld, nElements: %lld ",
printf("datasetName: %s, type: %ld, nElements: %ld ",
datasetName, datasetType, datasetNElems);
if (datasetType == H5PART_INT64) {
printf("H5PPART_INT64 \n");