Compare commits
309 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ecc4618bd4 | |||
| 8bdebd0c55 | |||
| 5baed631b7 | |||
| 65109b73a9 | |||
| 792e86e01e | |||
| 11ab169164 | |||
| 7c899f99ce | |||
| 12ef028ed2 | |||
| 094117a631 | |||
| acc8b75ad9 | |||
| 078a51d60d | |||
| 06a941eb2c | |||
| 269c5efbde | |||
| e7a60fbe9f | |||
| 2ed8ad093c | |||
| 3a9e0e4153 | |||
| aa1f4eacc8 | |||
| c33ef6d390 | |||
| 9a32a0b7f1 | |||
| 22d6893770 | |||
| 6e0f0eeedd | |||
| 542daf7fc2 | |||
| f79c808e8d | |||
| b6e482f56a | |||
| 6d3014bad5 | |||
| 20424235e8 | |||
| 7d73439b10 | |||
| e447d536a3 | |||
| 74df1bc676 | |||
| 9e4c8bd5a4 | |||
| bb1cd9c860 | |||
| ad52833022 | |||
| 3425a30068 | |||
| 9f3a677ea6 | |||
| 23807ff972 | |||
| 93d4f60116 | |||
| 20cd5aae98 | |||
| cae3b00855 | |||
| 2a462733ca | |||
| 6fb8b77baa | |||
| c26d6a84e3 | |||
| 54ccc3b576 | |||
| 8ffe944519 | |||
| 2bb3d688ae | |||
| 647af5847e | |||
| aa4f40ee3d | |||
| f1daa56cb8 | |||
| 2ea8245bba | |||
| 04fe7fdd9e | |||
| 075b2f39da | |||
| 7b05c32ad9 | |||
| 825ee8ac5f | |||
| 9d70c07476 | |||
| 03986b00ac | |||
| ad83c3841b | |||
| 73fabd043b | |||
| 0aa44727c6 | |||
| babd19ddd4 | |||
| c80f6f5679 | |||
| 7b1079ae5f | |||
| ecd2723419 | |||
| c9044d8e1b | |||
| 5b57bedade | |||
| 222789a1cf | |||
| 21dd57c9c6 | |||
| fc29f7b6f0 | |||
| e56872ce92 | |||
| 85ecf4c387 | |||
| 6979a358ae | |||
| 9fc3b233bc | |||
| f5eb26d2ec | |||
| 6af129b338 | |||
| 215d1a7d79 | |||
| 8bb22e4400 | |||
| caad81996a | |||
| f97e3c8f2d | |||
| fba78db1c0 | |||
| 291328b997 | |||
| 2c1bca01aa | |||
| a633b362a6 | |||
| a12908ed90 | |||
| b83d9cc8a7 | |||
| 6ad9ae50e0 | |||
| 9ac7e09423 | |||
| 66452a274b | |||
| d947f51c2d | |||
| f5729f6f07 | |||
| a64f2ce03a | |||
| b880bd397f | |||
| cd2c9031b9 | |||
| fb5e55990f | |||
| 25dff9257c | |||
| ac37d5fc2f | |||
| 983496104b | |||
| aaeca8b6b7 | |||
| 0182d60835 | |||
| f75ef09cf9 | |||
| c831a90a2e | |||
| bdcc8f2089 | |||
| bbbaa6a21b | |||
| 4c5b16169d | |||
| cc46b433e1 | |||
| a8e209a7d3 | |||
| 80cf35e807 | |||
| d53c5b3171 | |||
| 8edb48aff8 | |||
| 24af2ae2a3 | |||
| 7fbd5c5de1 | |||
| 18611991a5 | |||
| 603366bcd6 | |||
| 17317bb261 | |||
| 52d44e3b3c | |||
| 3d6230629c | |||
| 44ffea4fd5 | |||
| 97516866c7 | |||
| 1dfcd9f876 | |||
| 2dd2c625b7 | |||
| 3137063d22 | |||
| 9a16fa090a | |||
| df0750df4c | |||
| b69aa9b92d | |||
| 99699d4bf7 | |||
| 9df1a57778 | |||
| 1ed4f3985b | |||
| 2c850612ab | |||
| bc528f27e6 | |||
| 5444b0e0ef | |||
| ae9e4cee01 | |||
| 7490eed535 | |||
| 84fa4a0b0a | |||
| 718ef785f8 | |||
| 7002b73e82 | |||
| 2a8a43af39 | |||
| f0c2f29091 | |||
| 5362498a95 | |||
| 851905361d | |||
| 3c8b11f9eb | |||
| 4dde2b61d2 | |||
| d980f4d2b9 | |||
| 3f7c84dbf5 | |||
| c5a05a1261 | |||
| 230f9a7b90 | |||
| 2cd718b7a1 | |||
| c73d10ffb7 | |||
| 6209bc6cf9 | |||
| a013d43075 | |||
| f151a24796 | |||
| 9d37783868 | |||
| a8444e041b | |||
| dc9723dfe2 | |||
| 91e7ed8c5b | |||
| b284ad9776 | |||
| f965ed4f18 | |||
| 91316f314d | |||
| 538c9cdd76 | |||
| 28fc118118 | |||
| 59fd8ea6c6 | |||
| 1273baf99e | |||
| befaccddaf | |||
| 5204cb532b | |||
| 9917f12d96 | |||
| 4b1d719d6c | |||
| 43bc72b7d0 | |||
| 64b4a3be09 | |||
| f4e7defffa | |||
| 320fd77398 | |||
| 5714c390ec | |||
| a07d4101a2 | |||
| 56787866fb | |||
| fb3b876f78 | |||
| e4ebb0f453 | |||
| 51f2210ff1 | |||
| 511fbb89de | |||
| 87fcc4930b | |||
| 49460b62c3 | |||
| 8ae12f7ee9 | |||
| ca7dd3b99c | |||
| 6efdfce033 | |||
| 55cc6bb7d0 | |||
| 4fcc1ed3b3 | |||
| 23bb1ced99 | |||
| 1f629ee7f8 | |||
| 3c825fc71d | |||
| 089dc3e1ba | |||
| 158fc17a2b | |||
| 149c144eee | |||
| 4e42972ebb | |||
| 73c07240c2 | |||
| e637522073 | |||
| ec9626a0e5 | |||
| 86755932d9 | |||
| 95e21118e4 | |||
| 3fe0cc74be | |||
| 40c2c7d498 | |||
| cf067f7c56 | |||
| 33129a4793 | |||
| 41f2e87fc7 | |||
| 347a447302 | |||
| 03531ab4af | |||
| 3d8ce28609 | |||
| cc719d116c | |||
| 748eb1b3ab | |||
| f430c71d06 | |||
| 4a1d4d2d10 | |||
| 937d3f9c0e | |||
| 4d9d3dc879 | |||
| 106be817d9 | |||
| ec3a29d7e4 | |||
| c5ce2f06ac | |||
| 992e8cf58e | |||
| a618acf686 | |||
| 47bee153ba | |||
| 390a4296b4 | |||
| 4f7c666b1f | |||
| a620715ccc | |||
| 37bf9b35a6 | |||
| 2a7628c1e2 | |||
| 5a588415d0 | |||
| d5fce5b2a0 | |||
| 7bf3985219 | |||
| d939354990 | |||
| 8fb9834d3b | |||
| 2fd5d52125 | |||
| a1226feafd | |||
| cc7c558065 | |||
| 51f90df374 | |||
| 62c2d53324 | |||
| 8e9e0d84f3 | |||
| d9daf9f0c7 | |||
| 559f2d8d9c | |||
| 403e535a50 | |||
| 14aa4fbd15 | |||
| 319d7b4324 | |||
| 4511fde9d1 | |||
| 707cafb2d8 | |||
| 877b611758 | |||
| 9fb11ca838 | |||
| 7c2a315760 | |||
| cc0135b4fc | |||
| f47fbbf075 | |||
| fd8c1e37b1 | |||
| 4d770f8c84 | |||
| 1f79b924df | |||
| b1f143a5d7 | |||
| d6718bb866 | |||
| 9deeacff51 | |||
| 5dbe8fb161 | |||
| c3add7dde4 | |||
| 9d49361c43 | |||
| 1a1878402c | |||
| 069f9b64fc | |||
| ca6b4cc52d | |||
| 60df95b10a | |||
| d508f9e591 | |||
| 36702c6207 | |||
| fa091cc2ab | |||
| 1121a22956 | |||
| d5b8a4c0c8 | |||
| 1cc3614c74 | |||
| ca5f4abc7c | |||
| 9d3c006409 | |||
| d79d0ddf1a | |||
| a1ad62bc74 | |||
| 950bcef057 | |||
| 468a5d6871 | |||
| cf09862f4b | |||
| 6b6f290ebb | |||
| c8eecb51ae | |||
| 23c2bdd189 | |||
| 3e69059afc | |||
| a6f81be2cd | |||
| 89b91d6b46 | |||
| 4975de7a74 | |||
| 3fe4c39e5e | |||
| 89bb9ef48c | |||
| d15993ecdc | |||
| da723dda5e | |||
| 0dcc666e5e | |||
| 61d17a352f | |||
| 006e1cda4a | |||
| 11e399b6c7 | |||
| e839226f2b | |||
| 2702f846cb | |||
| ee23c8cc4b | |||
| c3a74c8ed4 | |||
| 969acd3642 | |||
| ee07f01abd | |||
| 06f0a8b4e7 | |||
| 205a1a5c37 | |||
| 7174b36a20 | |||
| 273b1831d9 | |||
| 83c5a66814 | |||
| db81cb3d33 | |||
| 4a8eedd31e | |||
| 11a1cc7c1e | |||
| a509000711 | |||
| a65ee3bbb7 | |||
| f69ee003f6 | |||
| 0b18373f8c | |||
| 311cdad1c8 | |||
| 6f84edd791 | |||
| 1614f9519b | |||
| 65757c1974 | |||
| 80523c6df7 | |||
| f17f1d028c | |||
| 78078c322e | |||
| 1284d545e1 | |||
| 96af35450a | |||
| 5abb40125b |
+48
-46
@@ -8,6 +8,7 @@
|
||||
/autogen.sh -text
|
||||
/configure.ac -text
|
||||
doc/Doxyfile -text
|
||||
doc/DoxygenLayout.xml -text
|
||||
doc/Examples/meshexample.dxf -text
|
||||
doc/Examples/meshexample.txt -text
|
||||
doc/Examples/simple_tet.vtk -text
|
||||
@@ -28,10 +29,13 @@ doc/Examples/trimesh_level1.metis.part.2 -text
|
||||
doc/H5.dox -text
|
||||
doc/H5X_File_Format.txt -text
|
||||
doc/Makefile.am -text
|
||||
doc/TracFooter.html -text
|
||||
doc/TracHeader.html -text
|
||||
doc/doxyfooter -text
|
||||
doc/doxyheader -text
|
||||
doc/html2twiki -text
|
||||
doc/meshexample.dxf -text
|
||||
doc/postprocess.py -text
|
||||
doc/tetrahedron_refinements/1-edge/edge_01_refined/01.png -text
|
||||
doc/tetrahedron_refinements/1-edge/edge_01_refined/01.pvsm -text
|
||||
doc/tetrahedron_refinements/1-edge/edge_01_refined/01.txt -text
|
||||
@@ -359,14 +363,16 @@ doc/tetrahedron_refinements/6-edges/edge_01-12-20-23-30-31_refined/buildlatex.ba
|
||||
doc/tetrahedron_refinements/6-edges/edge_01-12-20-23-30-31_refined/output_file.jpg -text
|
||||
doc/tetrahedron_refinements/README -text
|
||||
doc/tetrahedron_refinements/text2vtk.py -text
|
||||
examples/H5Block/BlockTestSpecs.txt -text
|
||||
examples/H5Block/H5BlockDissolveGhosts.c -text
|
||||
examples/H5Block/H5BlockParTestScalarField.c -text
|
||||
examples/H5Block/H5BlockParTestScalarField.pbs -text
|
||||
examples/H5Block/H5BlockParTestScalarFieldF.f90 -text
|
||||
examples/H5Block/H5BlockTestAttributes.c -text
|
||||
examples/H5Block/H5BlockTestAttributesF.f90 -text
|
||||
examples/H5/Makefile.am -text
|
||||
examples/H5/attach_file.c -text
|
||||
examples/H5/file_attribs.c -text
|
||||
examples/H5/openclose.c -text
|
||||
examples/H5Block/H5BlockExample.pbs -text
|
||||
examples/H5Block/H5BlockExampleF.f90 -text
|
||||
examples/H5Block/Makefile.am -text
|
||||
examples/H5Block/README -text
|
||||
examples/H5Block/fields.c -text
|
||||
examples/H5Block/read_write.c -text
|
||||
examples/H5Fed/Makefile.am -text
|
||||
examples/H5Fed/map_tet2globalid.c -text
|
||||
examples/H5Fed/map_triangle2globalid.c -text
|
||||
@@ -384,52 +390,48 @@ examples/H5Fed/trimesh_write.c -text
|
||||
examples/H5Fed/trimesh_write_dunetest.c -text
|
||||
examples/H5Fed/write_boundary.c -text
|
||||
examples/H5Part/Bench.c -text
|
||||
examples/H5Part/H5ParallelTest.cc -text
|
||||
examples/H5Part/H5PartAndreasTest.cc -text
|
||||
examples/H5Part/H5PartTest.cc -text
|
||||
examples/H5Part/H5PartTestParallel.cc -text
|
||||
examples/H5Part/H5test.cc -text
|
||||
examples/H5Part/H5testF.f -text
|
||||
examples/H5Part/H5testFpar.f90 -text
|
||||
examples/H5Part/H5test.c -text
|
||||
examples/H5Part/H5testF.f90 -text
|
||||
examples/H5Part/Makefile.am -text
|
||||
examples/H5Part/core_vfd.c -text
|
||||
examples/H5Part/particles.c -text
|
||||
examples/H5Part/read_canonicalview.c -text
|
||||
examples/H5Part/simplef.f90 -text
|
||||
examples/H5Part/stridedf.f90 -text
|
||||
examples/H5Part/write_setnumparticles.c -text
|
||||
examples/H5Part/write_setview.c -text
|
||||
/license.txt -text
|
||||
src/C/Makefile.am -text
|
||||
src/Fortran/H5.c -text
|
||||
src/Fortran/H5.f90 -text
|
||||
src/Fortran/H5Block.c -text
|
||||
src/Fortran/H5Block.f90 -text
|
||||
src/Fortran/H5BlockF.f90 -text
|
||||
src/Fortran/H5Block_F.c -text
|
||||
src/Fortran/H5Block_attribs.c -text
|
||||
src/Fortran/H5Block_attribsF.f90 -text
|
||||
src/Fortran/H5Block_io.c -text
|
||||
src/Fortran/H5Block_ioF.f90 -text
|
||||
src/Fortran/H5Block_readwrite.f90 -text
|
||||
src/Fortran/H5Block_readwrite_F.c -text
|
||||
src/Fortran/H5F.f90 -text
|
||||
src/Fortran/H5Part.c -text
|
||||
src/Fortran/H5Part.f90 -text
|
||||
src/Fortran/H5PartF.f90 -text
|
||||
src/Fortran/H5Part_F.c -text
|
||||
src/Fortran/H5Part_io.c -text
|
||||
src/Fortran/H5Part_ioF.f90 -text
|
||||
src/Fortran/H5_F.c -text
|
||||
src/Fortran/H5_attribs.c -text
|
||||
src/Fortran/H5_attribs.f90 -text
|
||||
src/Fortran/H5_attribsF.f90 -text
|
||||
src/Fortran/H5_attribs_F.c -text
|
||||
src/Fortran/H5_constF.f90 -text
|
||||
src/Fortran/Makefile.am -text
|
||||
src/Fortran/TestUnderscore.f -text
|
||||
src/Fortran/TestUnderscoreC.c -text
|
||||
src/Fortran/generate-h5-attribs-f.py -text
|
||||
src/Fortran/h5_private.h -text
|
||||
src/Makefile.am -text
|
||||
src/h5core/Makefile.am -text
|
||||
src/h5core/h5_attach.c -text
|
||||
src/h5core/h5_attribs.c -text
|
||||
src/h5core/h5_attribs_private.h -text
|
||||
src/h5core/h5_core_private.h -text
|
||||
src/h5core/h5_debug_private.h -text
|
||||
src/h5core/h5_errorhandling.c -text
|
||||
src/h5core/h5_errorhandling_private.h -text
|
||||
src/h5core/h5_fcmp.c -text
|
||||
@@ -438,14 +440,18 @@ src/h5core/h5_hdf5.c -text
|
||||
src/h5core/h5_hdf5_private.h -text
|
||||
src/h5core/h5_hsearch.c -text
|
||||
src/h5core/h5_hsearch_private.h -text
|
||||
src/h5core/h5_init.c -text
|
||||
src/h5core/h5_init_private.h -text
|
||||
src/h5core/h5_lustre.c -text
|
||||
src/h5core/h5_lustre_private.h -text
|
||||
src/h5core/h5_maps.c -text
|
||||
src/h5core/h5_maps_private.h -text
|
||||
src/h5core/h5_model.c -text
|
||||
src/h5core/h5_model_private.h -text
|
||||
src/h5core/h5_mpi.c -text
|
||||
src/h5core/h5_mpi_private.h -text
|
||||
src/h5core/h5_openclose.c -text
|
||||
src/h5core/h5_private.h -text
|
||||
src/h5core/h5_qsort.c -text
|
||||
src/h5core/h5_qsort_private.h -text
|
||||
src/h5core/h5_qsort_r.c -text
|
||||
@@ -456,10 +462,10 @@ src/h5core/h5_syscall_private.h -text
|
||||
src/h5core/h5_types_private.h -text
|
||||
src/h5core/h5_va_macros.h -text
|
||||
src/h5core/h5b_attribs.c -text
|
||||
src/h5core/h5b_errorhandling_private.h -text
|
||||
src/h5core/h5b_model.c -text
|
||||
src/h5core/h5b_model_private.h -text
|
||||
src/h5core/h5b_readwrite.c -text
|
||||
src/h5core/h5b_readwrite_private.h -text
|
||||
src/h5core/h5b_types_private.h -text
|
||||
src/h5core/h5t_access_private.h -text
|
||||
src/h5core/h5t_access_tetm.c -text
|
||||
@@ -468,17 +474,19 @@ src/h5core/h5t_adjacencies.c -text
|
||||
src/h5core/h5t_adjacencies_private.h -text
|
||||
src/h5core/h5t_adjacencies_tetm.c -text
|
||||
src/h5core/h5t_adjacencies_trim.c -text
|
||||
src/h5core/h5t_core.c -text
|
||||
src/h5core/h5t_core_private.h -text
|
||||
src/h5core/h5t_core_tetm.c -text
|
||||
src/h5core/h5t_core_trim.c -text
|
||||
src/h5core/h5t_errorhandling_private.h -text
|
||||
src/h5core/h5t_hsearch.c -text
|
||||
src/h5core/h5t_hsearch_private.h -text
|
||||
src/h5core/h5t_inquiry.c -text
|
||||
src/h5core/h5t_map.c -text
|
||||
src/h5core/h5t_map_private.h -text
|
||||
src/h5core/h5t_model.c -text
|
||||
src/h5core/h5t_model_private.h -text
|
||||
src/h5core/h5t_model_tetm.c -text
|
||||
src/h5core/h5t_model_trim.c -text
|
||||
src/h5core/h5t_octree.c -text
|
||||
src/h5core/h5t_octree_private.h -text
|
||||
src/h5core/h5t_readwrite.c -text
|
||||
src/h5core/h5t_readwrite_private.h -text
|
||||
src/h5core/h5t_readwrite_tetm.c -text
|
||||
@@ -493,58 +501,53 @@ src/h5core/h5t_store.c -text
|
||||
src/h5core/h5t_store_private.h -text
|
||||
src/h5core/h5t_store_tetm.c -text
|
||||
src/h5core/h5t_store_trim.c -text
|
||||
src/h5core/h5t_store_trim_private.h -text
|
||||
src/h5core/h5t_tags.c -text
|
||||
src/h5core/h5t_tags_private.h -text
|
||||
src/h5core/h5t_types_private.h -text
|
||||
src/h5core/h5u_errorhandling_private.h -text
|
||||
src/h5core/h5u_model.c -text
|
||||
src/h5core/h5u_readwrite.c -text
|
||||
src/h5core/h5u_readwrite_private.h -text
|
||||
src/h5core/h5u_types_private.h -text
|
||||
src/include/H5.h -text
|
||||
src/include/H5Block.h -text
|
||||
src/include/H5Block_readwrite.h -text
|
||||
src/include/H5Block_attribs.h -text
|
||||
src/include/H5Block_io.h -text
|
||||
src/include/H5Block_model.h -text
|
||||
src/include/H5Fed.h -text
|
||||
src/include/H5Fed_adjacency.h -text
|
||||
src/include/H5Fed_inquiry.h -text
|
||||
src/include/H5Fed_model.h -text
|
||||
src/include/H5Fed_retrieve.h -text
|
||||
src/include/H5Fed_store.h -text
|
||||
src/include/H5Fed_tags.h -text
|
||||
src/include/H5Part.h -text
|
||||
src/include/H5_attachments.h -text
|
||||
src/include/H5Part_io.h -text
|
||||
src/include/H5Part_model.h -text
|
||||
src/include/H5_attribs.h -text
|
||||
src/include/H5_model.h -text
|
||||
src/include/H5hut.h -text
|
||||
src/include/Makefile.am -text
|
||||
src/include/grephdr -text
|
||||
src/include/h5core/Makefile.am -text
|
||||
src/include/h5core/h5_attach.h -text
|
||||
src/include/h5core/h5.h -text
|
||||
src/include/h5core/h5_attribs.h -text
|
||||
src/include/h5core/h5_core.h -text
|
||||
src/include/h5core/h5_errno.h -text
|
||||
src/include/h5core/h5_debug.h -text
|
||||
src/include/h5core/h5_errorhandling.h -text
|
||||
src/include/h5core/h5_hdf5.h -text
|
||||
src/include/h5core/h5_maps.h -text
|
||||
src/include/h5core/h5_openclose.h -text
|
||||
src/include/h5core/h5_readwrite.h -text
|
||||
src/include/h5core/h5_model.h -text
|
||||
src/include/h5core/h5_syscall.h -text
|
||||
src/include/h5core/h5_types.h -text
|
||||
src/include/h5core/h5b_attribs.h -text
|
||||
src/include/h5core/h5b_io.h -text
|
||||
src/include/h5core/h5b_model.h -text
|
||||
src/include/h5core/h5b_readwrite.h -text
|
||||
src/include/h5core/h5t_adjacencies.h -text
|
||||
src/include/h5core/h5t_core.h -text
|
||||
src/include/h5core/h5t_inquiry.h -text
|
||||
src/include/h5core/h5t_map.h -text
|
||||
src/include/h5core/h5t_model.h -text
|
||||
src/include/h5core/h5t_readwrite.h -text
|
||||
src/include/h5core/h5t_ref_elements.h -text
|
||||
src/include/h5core/h5t_octree.h -text
|
||||
src/include/h5core/h5t_retrieve.h -text
|
||||
src/include/h5core/h5t_storemesh.h -text
|
||||
src/include/h5core/h5t_store.h -text
|
||||
src/include/h5core/h5t_tags.h -text
|
||||
src/include/h5core/h5u_io.h -text
|
||||
src/include/h5core/h5u_model.h -text
|
||||
src/include/h5core/h5u_readwrite.h -text
|
||||
test/Makefile.am -text
|
||||
test/h5_attach_test.c -text
|
||||
test/h5b_read.c -text
|
||||
test/h5b_test.c -text
|
||||
test/h5b_write.c -text
|
||||
@@ -573,7 +576,6 @@ tools/h5PartSurfaceToVtk.cc -text
|
||||
tools/h5hutcc.in -text
|
||||
tools/h5pAttrib.cc -text
|
||||
tools/h5pToGNUplot.cc -text
|
||||
tools/homdynToH5p.cc -text
|
||||
tools/vtk2h5grid/Makefile.am -text
|
||||
tools/vtk2h5grid/vtk2h5grid.cc -text
|
||||
visit_plugins/databases/H5Part/.depend -text
|
||||
|
||||
+85
-92
@@ -1,102 +1,95 @@
|
||||
*.o
|
||||
*.lo
|
||||
*.tar.gz
|
||||
*.[oa]
|
||||
*.la
|
||||
*.lo
|
||||
*.so
|
||||
*.dSYM
|
||||
*~
|
||||
*.h5
|
||||
*.vtk
|
||||
.deps
|
||||
.dirstamp
|
||||
.libs
|
||||
/H5hut
|
||||
/INSTALL
|
||||
/Makefile
|
||||
/Makefile.in
|
||||
/aclocal.m4
|
||||
/autom4te.cache
|
||||
/build
|
||||
/compile
|
||||
/config.guess
|
||||
/config.h
|
||||
/config.h.in
|
||||
/config.log
|
||||
/config.status
|
||||
/config.sub
|
||||
/configure
|
||||
/depcomp
|
||||
doc/Makefile
|
||||
doc/Makefile.in
|
||||
examples/H5Block/H5BlockParTestScalarField
|
||||
examples/H5Block/H5BlockTestAttributes
|
||||
examples/H5Block/Makefile
|
||||
examples/H5Block/Makefile.in
|
||||
examples/H5Fed/.deps
|
||||
examples/H5Fed/Makefile
|
||||
examples/H5Fed/Makefile.in
|
||||
examples/H5Fed/large_tet.h5
|
||||
examples/H5Fed/simple_tet.h5
|
||||
examples/H5Fed/simple_triangle.h5
|
||||
examples/H5Fed/small_tet.h5
|
||||
examples/H5Fed/tetmesh_adjacencies
|
||||
examples/H5Fed/tetmesh_read
|
||||
examples/H5Fed/tetmesh_read_tags
|
||||
examples/H5Fed/tetmesh_write
|
||||
CMakeFiles
|
||||
INSTALL
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
attach_field_attributes
|
||||
dump_field_attributes
|
||||
autom4te.cache/
|
||||
compile
|
||||
config.guess
|
||||
config.h
|
||||
config.h.in
|
||||
config.log
|
||||
config.status
|
||||
config.sub
|
||||
configure
|
||||
depcomp
|
||||
py-compile
|
||||
examples/H5/attach_file
|
||||
examples/H5/examples.h
|
||||
examples/H5/h5hut.mod
|
||||
examples/H5/openclose
|
||||
examples/H5/openclosef
|
||||
examples/H5/query
|
||||
examples/H5/queryf
|
||||
examples/H5/read_file_attribs
|
||||
examples/H5/read_file_attribsf
|
||||
examples/H5/read_step_attribs
|
||||
examples/H5/read_step_attribsf
|
||||
examples/H5/write_file_attribs
|
||||
examples/H5/write_file_attribsf
|
||||
examples/H5/write_step_attribs
|
||||
examples/H5/write_step_attribsf
|
||||
examples/H5Block/H5BlockExampleF
|
||||
examples/H5Block/fields
|
||||
examples/H5Block/read_write
|
||||
examples/H5Part/Bench
|
||||
examples/H5Part/H5test
|
||||
examples/H5Part/H5testF
|
||||
examples/H5Part/core_vfd
|
||||
examples/H5Part/examples.h
|
||||
examples/H5Part/h5hut.mod
|
||||
examples/H5Part/particles
|
||||
examples/H5Part/read_canonicalview
|
||||
examples/H5Part/read_setnparticles
|
||||
examples/H5Part/read_setview
|
||||
examples/H5Part/read_strided
|
||||
examples/H5Part/write_core_vfd
|
||||
examples/H5Part/write_setnparticles
|
||||
examples/H5Part/write_setnumparticles
|
||||
examples/H5Part/write_setview
|
||||
examples/H5Part/write_setviewf
|
||||
examples/H5Part/write_strided
|
||||
has_field
|
||||
install-sh
|
||||
libtool
|
||||
ltmain.sh
|
||||
m4/
|
||||
missing
|
||||
src/Fortran/TestUnderscore
|
||||
src/Fortran/Underscore.h
|
||||
src/include/H5hut.f
|
||||
src/include/H5hutF.h
|
||||
stamp-h1
|
||||
test/h5b_test
|
||||
test/h5u_test
|
||||
test/h5_attach_test
|
||||
tools/h5hutcc
|
||||
tetmesh_adjacencies
|
||||
tetmesh_read
|
||||
tetmesh_read_tags
|
||||
tetmesh_write
|
||||
tetmesh_write1
|
||||
examples/H5Fed/tetmesh_write2
|
||||
examples/H5Fed/tetmesh_write_tags
|
||||
examples/H5Fed/trimesh_2gnuplot
|
||||
examples/H5Fed/trimesh_adjacencies
|
||||
examples/H5Fed/trimesh_read
|
||||
examples/H5Fed/trimesh_write
|
||||
examples/H5Fed/trimesh_write_dunetest
|
||||
examples/H5Part/Bench
|
||||
examples/H5Part/H5PartAndreasTest
|
||||
examples/H5Part/H5PartTestP
|
||||
examples/H5Part/H5test
|
||||
examples/H5Part/Makefile
|
||||
examples/H5Part/Makefile.in
|
||||
/install-sh
|
||||
/libtool
|
||||
/ltmain.sh
|
||||
/m4
|
||||
/missing
|
||||
src/.deps
|
||||
src/C/.deps
|
||||
src/C/Makefile
|
||||
src/C/Makefile.in
|
||||
src/C/libH5hutC.a
|
||||
src/Fortran/.deps
|
||||
src/Fortran/Makefile
|
||||
src/Fortran/Makefile.in
|
||||
src/Fortran/TestUnderscore
|
||||
src/Fortran/Underscore.h
|
||||
src/Makefile
|
||||
src/Makefile.in
|
||||
src/h5core/.deps
|
||||
src/h5core/Makefile
|
||||
src/h5core/Makefile.in
|
||||
src/h5core/libH5hut.a
|
||||
src/include/H5hutF.h
|
||||
src/include/Makefile
|
||||
src/include/Makefile.in
|
||||
src/include/h5core/Makefile
|
||||
src/include/h5core/Makefile.in
|
||||
src/lib
|
||||
/stamp-h1
|
||||
/svn-prop.tmp
|
||||
/test-driver
|
||||
test/.deps
|
||||
test/Makefile
|
||||
test/Makefile.in
|
||||
test/h5_attach.h5
|
||||
test/h5_attach_test
|
||||
test/h5b_test
|
||||
test/h5u_test
|
||||
tools/.deps
|
||||
tools/Makefile
|
||||
tools/Makefile.in
|
||||
tools/h5PartDcToVtk
|
||||
tools/h5PartSurfaceToVtk
|
||||
tools/h5hutcc
|
||||
tools/vtk2h5grid/.deps
|
||||
tools/vtk2h5grid/Makefile
|
||||
tools/vtk2h5grid/Makefile.in
|
||||
tools/vtk2h5grid/cgun_full.h5
|
||||
tools/vtk2h5grid/cgun_full.vtk
|
||||
tools/vtk2h5grid/vtk2h5grid
|
||||
tetmesh_write_tags
|
||||
write_field
|
||||
*.gch
|
||||
ReferencePages
|
||||
vtk2h5grid
|
||||
|
||||
@@ -7,4 +7,4 @@ Wes Bethel (NERSC/LBNL)
|
||||
John Shalf (NERSC/LBNL)
|
||||
Cristina Siegerist (NERSC/LBNL)
|
||||
|
||||
Please use h5part@lists.psi.ch for communicaion.
|
||||
Please use h5part@lists.psi.ch for communication.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
*** Copyright Notice ***
|
||||
|
||||
H5hut Copyright (c) 2006-2010, The Regents of the University of California,
|
||||
H5hut Copyright (c) 2006-2016, 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.
|
||||
@@ -25,7 +25,7 @@ and to permit others to do so.
|
||||
|
||||
*** License agreement ***
|
||||
|
||||
H5Part Copyright (c) 2006-2009, The Regents of the University of California,
|
||||
H5hut Copyright (c) 2006-2016, 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.
|
||||
|
||||
+17
-11
@@ -1,15 +1,21 @@
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
EXTRA_DIST = autogen.sh
|
||||
EXTRA_DIST = \
|
||||
autogen.sh \
|
||||
ax_pkg_swig.m4
|
||||
|
||||
SUBDIRS = \
|
||||
src \
|
||||
test \
|
||||
tools \
|
||||
doc
|
||||
SUBDIRS = \
|
||||
src \
|
||||
test \
|
||||
tools \
|
||||
doc \
|
||||
examples/H5 \
|
||||
examples/H5Part \
|
||||
examples/H5Block \
|
||||
examples/H5Fed
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
config.h \
|
||||
config.log \
|
||||
config.status \
|
||||
stamp-h.in \
|
||||
MAINTAINERCLEANFILES = \
|
||||
config.h \
|
||||
config.log \
|
||||
config.status \
|
||||
stamp-h.in \
|
||||
stamp-h1
|
||||
|
||||
@@ -1,42 +1,36 @@
|
||||
#### H5PART 1.99.10 ###########################################################
|
||||
#### H5PART trunk ############################################################
|
||||
|
||||
Bugfixes in the malloc wrappers
|
||||
* h5_file_t is now uintptr_t
|
||||
* experimental version of parallel H5Fed
|
||||
* new API function for file open using properties (similiar to hdf5 properties)
|
||||
|
||||
Converter from vtk to H5hut added.
|
||||
#### H5PART 1.99.10 ############################################################
|
||||
|
||||
Bugfixes in the autotools files.
|
||||
|
||||
#### H5PART 1.99.9 ############################################################
|
||||
|
||||
Bugfix in option parsing in tools/h5PartDcToVtk and tools/h5PartSurfaceToVtk
|
||||
|
||||
tools/h5PartDcToVtk and tools/h5PartSurfaceToVtk removed from list of tools
|
||||
to be compiled. These tools should be moved to another repository anyway.
|
||||
|
||||
#### H5PART 1.99.8 ############################################################
|
||||
|
||||
Bugfixes
|
||||
|
||||
#### H5PART 1.99.7 ############################################################
|
||||
|
||||
Linking problem on Linux fixed
|
||||
|
||||
#### H5PART 1.99.6 ############################################################
|
||||
* C99 compiler required
|
||||
* C API with inline functions
|
||||
|
||||
|
||||
#### H5PART 1.99.5 ############################################################
|
||||
#### H5PART 1.99.4 ############################################################
|
||||
#### H5PART 1.99.3 ############################################################
|
||||
#### H5PART 1.99.2 ############################################################
|
||||
#### H5PART 1.99.1 ############################################################
|
||||
#### H5PART 1.99 ############################################################
|
||||
#### H5PART 1.99.0 ############################################################
|
||||
|
||||
Renamed type:
|
||||
rudimental implementation of a grid manager
|
||||
|
||||
Important changes from version 1.6 to 1.99.0
|
||||
|
||||
Renamed type:
|
||||
H5PartFile -> h5_file_t
|
||||
h5part_int64_t -> h5_int64_t
|
||||
h5part_float64_t -> h5_float_t
|
||||
|
||||
Renamed functions:
|
||||
|
||||
All function not related to a specific data model have been renamed from
|
||||
H5PartFunction() to H5Function().
|
||||
|
||||
Example:
|
||||
H5PartOpenFile() -> H5OpenFile()
|
||||
|
||||
Removed functions:
|
||||
To simplify the API, there is just one function to open a file. It's the
|
||||
same function for serial and parallel code.
|
||||
|
||||
#### H5PART 1.6.6 ############################################################
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# Run this to generate all the initial makefiles, etc.
|
||||
|
||||
ACLOCAL_FLAGS="-I m4 $ACLOCAL_FLAGS"
|
||||
ACLOCAL_FLAGS="-I m4 -I . $ACLOCAL_FLAGS"
|
||||
LIBTOOLIZE_FLAGS="--force $LIBTOOLIZE_FLAGS"
|
||||
AUTOMAKE_FLAGS="--add-missing --copy --foreign $AUTOMAKE_FLAGS"
|
||||
|
||||
|
||||
@@ -0,0 +1,982 @@
|
||||
# ===========================================================================
|
||||
# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Check for baseline language coverage in the compiler for the specified
|
||||
# version of the C++ standard. If necessary, add switches to CXX and
|
||||
# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard)
|
||||
# or '14' (for the C++14 standard).
|
||||
#
|
||||
# The second argument, if specified, indicates whether you insist on an
|
||||
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
|
||||
# -std=c++11). If neither is specified, you get whatever works, with
|
||||
# preference for an extended mode.
|
||||
#
|
||||
# The third argument, if specified 'mandatory' or if left unspecified,
|
||||
# indicates that baseline support for the specified C++ standard is
|
||||
# required and that the macro should error out if no mode with that
|
||||
# support is found. If specified 'optional', then configuration proceeds
|
||||
# regardless, after defining HAVE_CXX${VERSION} if and only if a
|
||||
# supporting mode is found.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
|
||||
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
|
||||
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
|
||||
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
|
||||
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
|
||||
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
|
||||
# Copyright (c) 2016 Krzesimir Nowak <qdlacz@gmail.com>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 7
|
||||
|
||||
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
|
||||
dnl (serial version number 13).
|
||||
|
||||
AX_REQUIRE_DEFINED([AC_MSG_WARN])
|
||||
AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
|
||||
m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
|
||||
[$1], [14], [ax_cxx_compile_alternatives="14 1y"],
|
||||
[$1], [17], [ax_cxx_compile_alternatives="17 1z"],
|
||||
[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
|
||||
m4_if([$2], [], [],
|
||||
[$2], [ext], [],
|
||||
[$2], [noext], [],
|
||||
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl
|
||||
m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true],
|
||||
[$3], [mandatory], [ax_cxx_compile_cxx$1_required=true],
|
||||
[$3], [optional], [ax_cxx_compile_cxx$1_required=false],
|
||||
[m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])])
|
||||
AC_LANG_PUSH([C++])dnl
|
||||
ac_success=no
|
||||
AC_CACHE_CHECK(whether $CXX supports C++$1 features by default,
|
||||
ax_cv_cxx_compile_cxx$1,
|
||||
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
|
||||
[ax_cv_cxx_compile_cxx$1=yes],
|
||||
[ax_cv_cxx_compile_cxx$1=no])])
|
||||
if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
|
||||
ac_success=yes
|
||||
fi
|
||||
|
||||
m4_if([$2], [noext], [], [dnl
|
||||
if test x$ac_success = xno; then
|
||||
for alternative in ${ax_cxx_compile_alternatives}; do
|
||||
switch="-std=gnu++${alternative}"
|
||||
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
|
||||
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
|
||||
$cachevar,
|
||||
[ac_save_CXX="$CXX"
|
||||
CXX="$CXX $switch"
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
|
||||
[eval $cachevar=yes],
|
||||
[eval $cachevar=no])
|
||||
CXX="$ac_save_CXX"])
|
||||
if eval test x\$$cachevar = xyes; then
|
||||
CXX="$CXX $switch"
|
||||
if test -n "$CXXCPP" ; then
|
||||
CXXCPP="$CXXCPP $switch"
|
||||
fi
|
||||
ac_success=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi])
|
||||
|
||||
m4_if([$2], [ext], [], [dnl
|
||||
if test x$ac_success = xno; then
|
||||
dnl HP's aCC needs +std=c++11 according to:
|
||||
dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
|
||||
dnl Cray's crayCC needs "-h std=c++11"
|
||||
for alternative in ${ax_cxx_compile_alternatives}; do
|
||||
for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
|
||||
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
|
||||
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
|
||||
$cachevar,
|
||||
[ac_save_CXX="$CXX"
|
||||
CXX="$CXX $switch"
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
|
||||
[eval $cachevar=yes],
|
||||
[eval $cachevar=no])
|
||||
CXX="$ac_save_CXX"])
|
||||
if eval test x\$$cachevar = xyes; then
|
||||
CXX="$CXX $switch"
|
||||
if test -n "$CXXCPP" ; then
|
||||
CXXCPP="$CXXCPP $switch"
|
||||
fi
|
||||
ac_success=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test x$ac_success = xyes; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi])
|
||||
AC_LANG_POP([C++])
|
||||
if test x$ax_cxx_compile_cxx$1_required = xtrue; then
|
||||
if test x$ac_success = xno; then
|
||||
AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.])
|
||||
fi
|
||||
fi
|
||||
if test x$ac_success = xno; then
|
||||
HAVE_CXX$1=0
|
||||
AC_MSG_NOTICE([No compiler with C++$1 support was found])
|
||||
else
|
||||
HAVE_CXX$1=1
|
||||
AC_DEFINE(HAVE_CXX$1,1,
|
||||
[define if the compiler supports basic C++$1 syntax])
|
||||
fi
|
||||
AC_SUBST(HAVE_CXX$1)
|
||||
m4_if([$1], [17], [AC_MSG_WARN([C++17 is not yet standardized, so the checks may change in incompatible ways anytime])])
|
||||
])
|
||||
|
||||
|
||||
dnl Test body for checking C++11 support
|
||||
|
||||
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
|
||||
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
|
||||
)
|
||||
|
||||
|
||||
dnl Test body for checking C++14 support
|
||||
|
||||
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
|
||||
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
|
||||
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
|
||||
)
|
||||
|
||||
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
|
||||
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
|
||||
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
|
||||
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
|
||||
)
|
||||
|
||||
dnl Tests for new features in C++11
|
||||
|
||||
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
|
||||
|
||||
// If the compiler admits that it is not ready for C++11, why torture it?
|
||||
// Hopefully, this will speed up the test.
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
||||
#error "This is not a C++ compiler"
|
||||
|
||||
#elif __cplusplus < 201103L
|
||||
|
||||
#error "This is not a C++11 compiler"
|
||||
|
||||
#else
|
||||
|
||||
namespace cxx11
|
||||
{
|
||||
|
||||
namespace test_static_assert
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
struct check
|
||||
{
|
||||
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace test_final_override
|
||||
{
|
||||
|
||||
struct Base
|
||||
{
|
||||
virtual void f() {}
|
||||
};
|
||||
|
||||
struct Derived : public Base
|
||||
{
|
||||
virtual void f() override {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace test_double_right_angle_brackets
|
||||
{
|
||||
|
||||
template < typename T >
|
||||
struct check {};
|
||||
|
||||
typedef check<void> single_type;
|
||||
typedef check<check<void>> double_type;
|
||||
typedef check<check<check<void>>> triple_type;
|
||||
typedef check<check<check<check<void>>>> quadruple_type;
|
||||
|
||||
}
|
||||
|
||||
namespace test_decltype
|
||||
{
|
||||
|
||||
int
|
||||
f()
|
||||
{
|
||||
int a = 1;
|
||||
decltype(a) b = 2;
|
||||
return a + b;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_type_deduction
|
||||
{
|
||||
|
||||
template < typename T1, typename T2 >
|
||||
struct is_same
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template < typename T >
|
||||
struct is_same<T, T>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template < typename T1, typename T2 >
|
||||
auto
|
||||
add(T1 a1, T2 a2) -> decltype(a1 + a2)
|
||||
{
|
||||
return a1 + a2;
|
||||
}
|
||||
|
||||
int
|
||||
test(const int c, volatile int v)
|
||||
{
|
||||
static_assert(is_same<int, decltype(0)>::value == true, "");
|
||||
static_assert(is_same<int, decltype(c)>::value == false, "");
|
||||
static_assert(is_same<int, decltype(v)>::value == false, "");
|
||||
auto ac = c;
|
||||
auto av = v;
|
||||
auto sumi = ac + av + 'x';
|
||||
auto sumf = ac + av + 1.0;
|
||||
static_assert(is_same<int, decltype(ac)>::value == true, "");
|
||||
static_assert(is_same<int, decltype(av)>::value == true, "");
|
||||
static_assert(is_same<int, decltype(sumi)>::value == true, "");
|
||||
static_assert(is_same<int, decltype(sumf)>::value == false, "");
|
||||
static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
|
||||
return (sumf > 0.0) ? sumi : add(c, v);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_noexcept
|
||||
{
|
||||
|
||||
int f() { return 0; }
|
||||
int g() noexcept { return 0; }
|
||||
|
||||
static_assert(noexcept(f()) == false, "");
|
||||
static_assert(noexcept(g()) == true, "");
|
||||
|
||||
}
|
||||
|
||||
namespace test_constexpr
|
||||
{
|
||||
|
||||
template < typename CharT >
|
||||
unsigned long constexpr
|
||||
strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
|
||||
{
|
||||
return *s ? strlen_c_r(s + 1, acc + 1) : acc;
|
||||
}
|
||||
|
||||
template < typename CharT >
|
||||
unsigned long constexpr
|
||||
strlen_c(const CharT *const s) noexcept
|
||||
{
|
||||
return strlen_c_r(s, 0UL);
|
||||
}
|
||||
|
||||
static_assert(strlen_c("") == 0UL, "");
|
||||
static_assert(strlen_c("1") == 1UL, "");
|
||||
static_assert(strlen_c("example") == 7UL, "");
|
||||
static_assert(strlen_c("another\0example") == 7UL, "");
|
||||
|
||||
}
|
||||
|
||||
namespace test_rvalue_references
|
||||
{
|
||||
|
||||
template < int N >
|
||||
struct answer
|
||||
{
|
||||
static constexpr int value = N;
|
||||
};
|
||||
|
||||
answer<1> f(int&) { return answer<1>(); }
|
||||
answer<2> f(const int&) { return answer<2>(); }
|
||||
answer<3> f(int&&) { return answer<3>(); }
|
||||
|
||||
void
|
||||
test()
|
||||
{
|
||||
int i = 0;
|
||||
const int c = 0;
|
||||
static_assert(decltype(f(i))::value == 1, "");
|
||||
static_assert(decltype(f(c))::value == 2, "");
|
||||
static_assert(decltype(f(0))::value == 3, "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_uniform_initialization
|
||||
{
|
||||
|
||||
struct test
|
||||
{
|
||||
static const int zero {};
|
||||
static const int one {1};
|
||||
};
|
||||
|
||||
static_assert(test::zero == 0, "");
|
||||
static_assert(test::one == 1, "");
|
||||
|
||||
}
|
||||
|
||||
namespace test_lambdas
|
||||
{
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
auto lambda1 = [](){};
|
||||
auto lambda2 = lambda1;
|
||||
lambda1();
|
||||
lambda2();
|
||||
}
|
||||
|
||||
int
|
||||
test2()
|
||||
{
|
||||
auto a = [](int i, int j){ return i + j; }(1, 2);
|
||||
auto b = []() -> int { return '0'; }();
|
||||
auto c = [=](){ return a + b; }();
|
||||
auto d = [&](){ return c; }();
|
||||
auto e = [a, &b](int x) mutable {
|
||||
const auto identity = [](int y){ return y; };
|
||||
for (auto i = 0; i < a; ++i)
|
||||
a += b--;
|
||||
return x + identity(a + b);
|
||||
}(0);
|
||||
return a + b + c + d + e;
|
||||
}
|
||||
|
||||
int
|
||||
test3()
|
||||
{
|
||||
const auto nullary = [](){ return 0; };
|
||||
const auto unary = [](int x){ return x; };
|
||||
using nullary_t = decltype(nullary);
|
||||
using unary_t = decltype(unary);
|
||||
const auto higher1st = [](nullary_t f){ return f(); };
|
||||
const auto higher2nd = [unary](nullary_t f1){
|
||||
return [unary, f1](unary_t f2){ return f2(unary(f1())); };
|
||||
};
|
||||
return higher1st(nullary) + higher2nd(nullary)(unary);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_variadic_templates
|
||||
{
|
||||
|
||||
template <int...>
|
||||
struct sum;
|
||||
|
||||
template <int N0, int... N1toN>
|
||||
struct sum<N0, N1toN...>
|
||||
{
|
||||
static constexpr auto value = N0 + sum<N1toN...>::value;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct sum<>
|
||||
{
|
||||
static constexpr auto value = 0;
|
||||
};
|
||||
|
||||
static_assert(sum<>::value == 0, "");
|
||||
static_assert(sum<1>::value == 1, "");
|
||||
static_assert(sum<23>::value == 23, "");
|
||||
static_assert(sum<1, 2>::value == 3, "");
|
||||
static_assert(sum<5, 5, 11>::value == 21, "");
|
||||
static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
|
||||
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
|
||||
// Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
|
||||
// because of this.
|
||||
namespace test_template_alias_sfinae
|
||||
{
|
||||
|
||||
struct foo {};
|
||||
|
||||
template<typename T>
|
||||
using member = typename T::member_type;
|
||||
|
||||
template<typename T>
|
||||
void func(...) {}
|
||||
|
||||
template<typename T>
|
||||
void func(member<T>*) {}
|
||||
|
||||
void test();
|
||||
|
||||
void test() { func<foo>(0); }
|
||||
|
||||
}
|
||||
|
||||
} // namespace cxx11
|
||||
|
||||
#endif // __cplusplus >= 201103L
|
||||
|
||||
]])
|
||||
|
||||
|
||||
dnl Tests for new features in C++14
|
||||
|
||||
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
|
||||
|
||||
// If the compiler admits that it is not ready for C++14, why torture it?
|
||||
// Hopefully, this will speed up the test.
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
||||
#error "This is not a C++ compiler"
|
||||
|
||||
#elif __cplusplus < 201402L
|
||||
|
||||
#error "This is not a C++14 compiler"
|
||||
|
||||
#else
|
||||
|
||||
namespace cxx14
|
||||
{
|
||||
|
||||
namespace test_polymorphic_lambdas
|
||||
{
|
||||
|
||||
int
|
||||
test()
|
||||
{
|
||||
const auto lambda = [](auto&&... args){
|
||||
const auto istiny = [](auto x){
|
||||
return (sizeof(x) == 1UL) ? 1 : 0;
|
||||
};
|
||||
const int aretiny[] = { istiny(args)... };
|
||||
return aretiny[0];
|
||||
};
|
||||
return lambda(1, 1L, 1.0f, '1');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_binary_literals
|
||||
{
|
||||
|
||||
constexpr auto ivii = 0b0000000000101010;
|
||||
static_assert(ivii == 42, "wrong value");
|
||||
|
||||
}
|
||||
|
||||
namespace test_generalized_constexpr
|
||||
{
|
||||
|
||||
template < typename CharT >
|
||||
constexpr unsigned long
|
||||
strlen_c(const CharT *const s) noexcept
|
||||
{
|
||||
auto length = 0UL;
|
||||
for (auto p = s; *p; ++p)
|
||||
++length;
|
||||
return length;
|
||||
}
|
||||
|
||||
static_assert(strlen_c("") == 0UL, "");
|
||||
static_assert(strlen_c("x") == 1UL, "");
|
||||
static_assert(strlen_c("test") == 4UL, "");
|
||||
static_assert(strlen_c("another\0test") == 7UL, "");
|
||||
|
||||
}
|
||||
|
||||
namespace test_lambda_init_capture
|
||||
{
|
||||
|
||||
int
|
||||
test()
|
||||
{
|
||||
auto x = 0;
|
||||
const auto lambda1 = [a = x](int b){ return a + b; };
|
||||
const auto lambda2 = [a = lambda1(x)](){ return a; };
|
||||
return lambda2();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_digit_separators
|
||||
{
|
||||
|
||||
constexpr auto ten_million = 100'000'000;
|
||||
static_assert(ten_million == 100000000, "");
|
||||
|
||||
}
|
||||
|
||||
namespace test_return_type_deduction
|
||||
{
|
||||
|
||||
auto f(int& x) { return x; }
|
||||
decltype(auto) g(int& x) { return x; }
|
||||
|
||||
template < typename T1, typename T2 >
|
||||
struct is_same
|
||||
{
|
||||
static constexpr auto value = false;
|
||||
};
|
||||
|
||||
template < typename T >
|
||||
struct is_same<T, T>
|
||||
{
|
||||
static constexpr auto value = true;
|
||||
};
|
||||
|
||||
int
|
||||
test()
|
||||
{
|
||||
auto x = 0;
|
||||
static_assert(is_same<int, decltype(f(x))>::value, "");
|
||||
static_assert(is_same<int&, decltype(g(x))>::value, "");
|
||||
return x;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace cxx14
|
||||
|
||||
#endif // __cplusplus >= 201402L
|
||||
|
||||
]])
|
||||
|
||||
|
||||
dnl Tests for new features in C++17
|
||||
|
||||
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
|
||||
|
||||
// If the compiler admits that it is not ready for C++17, why torture it?
|
||||
// Hopefully, this will speed up the test.
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
||||
#error "This is not a C++ compiler"
|
||||
|
||||
#elif __cplusplus <= 201402L
|
||||
|
||||
#error "This is not a C++17 compiler"
|
||||
|
||||
#else
|
||||
|
||||
#if defined(__clang__)
|
||||
#define REALLY_CLANG
|
||||
#else
|
||||
#if defined(__GNUC__)
|
||||
#define REALLY_GCC
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <initializer_list>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
|
||||
namespace cxx17
|
||||
{
|
||||
|
||||
#if !defined(REALLY_CLANG)
|
||||
namespace test_constexpr_lambdas
|
||||
{
|
||||
|
||||
// TODO: test it with clang++ from git
|
||||
|
||||
constexpr int foo = [](){return 42;}();
|
||||
|
||||
}
|
||||
#endif // !defined(REALLY_CLANG)
|
||||
|
||||
namespace test::nested_namespace::definitions
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
namespace test_fold_expression
|
||||
{
|
||||
|
||||
template<typename... Args>
|
||||
int multiply(Args... args)
|
||||
{
|
||||
return (args * ... * 1);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
bool all(Args... args)
|
||||
{
|
||||
return (args && ...);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_extended_static_assert
|
||||
{
|
||||
|
||||
static_assert (true);
|
||||
|
||||
}
|
||||
|
||||
namespace test_auto_brace_init_list
|
||||
{
|
||||
|
||||
auto foo = {5};
|
||||
auto bar {5};
|
||||
|
||||
static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
|
||||
static_assert(std::is_same<int, decltype(bar)>::value);
|
||||
}
|
||||
|
||||
namespace test_typename_in_template_template_parameter
|
||||
{
|
||||
|
||||
template<template<typename> typename X> struct D;
|
||||
|
||||
}
|
||||
|
||||
namespace test_fallthrough_nodiscard_maybe_unused_attributes
|
||||
{
|
||||
|
||||
int f1()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
|
||||
[[nodiscard]] int f2()
|
||||
{
|
||||
[[maybe_unused]] auto unused = f1();
|
||||
|
||||
switch (f1())
|
||||
{
|
||||
case 17:
|
||||
f1();
|
||||
[[fallthrough]];
|
||||
case 42:
|
||||
f1();
|
||||
}
|
||||
return f1();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_extended_aggregate_initialization
|
||||
{
|
||||
|
||||
struct base1
|
||||
{
|
||||
int b1, b2 = 42;
|
||||
};
|
||||
|
||||
struct base2
|
||||
{
|
||||
base2() {
|
||||
b3 = 42;
|
||||
}
|
||||
int b3;
|
||||
};
|
||||
|
||||
struct derived : base1, base2
|
||||
{
|
||||
int d;
|
||||
};
|
||||
|
||||
derived d1 {{1, 2}, {}, 4}; // full initialization
|
||||
derived d2 {{}, {}, 4}; // value-initialized bases
|
||||
|
||||
}
|
||||
|
||||
namespace test_general_range_based_for_loop
|
||||
{
|
||||
|
||||
struct iter
|
||||
{
|
||||
int i;
|
||||
|
||||
int& operator* ()
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
const int& operator* () const
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
iter& operator++()
|
||||
{
|
||||
++i;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct sentinel
|
||||
{
|
||||
int i;
|
||||
};
|
||||
|
||||
bool operator== (const iter& i, const sentinel& s)
|
||||
{
|
||||
return i.i == s.i;
|
||||
}
|
||||
|
||||
bool operator!= (const iter& i, const sentinel& s)
|
||||
{
|
||||
return !(i == s);
|
||||
}
|
||||
|
||||
struct range
|
||||
{
|
||||
iter begin() const
|
||||
{
|
||||
return {0};
|
||||
}
|
||||
|
||||
sentinel end() const
|
||||
{
|
||||
return {5};
|
||||
}
|
||||
};
|
||||
|
||||
void f()
|
||||
{
|
||||
range r {};
|
||||
|
||||
for (auto i : r)
|
||||
{
|
||||
[[maybe_unused]] auto v = i;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_lambda_capture_asterisk_this_by_value
|
||||
{
|
||||
|
||||
struct t
|
||||
{
|
||||
int i;
|
||||
int foo()
|
||||
{
|
||||
return [*this]()
|
||||
{
|
||||
return i;
|
||||
}();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace test_enum_class_construction
|
||||
{
|
||||
|
||||
enum class byte : unsigned char
|
||||
{};
|
||||
|
||||
byte foo {42};
|
||||
|
||||
}
|
||||
|
||||
namespace test_constexpr_if
|
||||
{
|
||||
|
||||
template <bool cond>
|
||||
int f ()
|
||||
{
|
||||
if constexpr(cond)
|
||||
{
|
||||
return 13;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_selection_statement_with_initializer
|
||||
{
|
||||
|
||||
int f()
|
||||
{
|
||||
return 13;
|
||||
}
|
||||
|
||||
int f2()
|
||||
{
|
||||
if (auto i = f(); i > 0)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
switch (auto i = f(); i + 4)
|
||||
{
|
||||
case 17:
|
||||
return 2;
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if !defined(REALLY_CLANG)
|
||||
namespace test_template_argument_deduction_for_class_templates
|
||||
{
|
||||
|
||||
// TODO: test it with clang++ from git
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct pair
|
||||
{
|
||||
pair (T1 p1, T2 p2)
|
||||
: m1 {p1},
|
||||
m2 {p2}
|
||||
{}
|
||||
|
||||
T1 m1;
|
||||
T2 m2;
|
||||
};
|
||||
|
||||
void f()
|
||||
{
|
||||
[[maybe_unused]] auto p = pair{13, 42u};
|
||||
}
|
||||
|
||||
}
|
||||
#endif // !defined(REALLY_CLANG)
|
||||
|
||||
namespace test_non_type_auto_template_parameters
|
||||
{
|
||||
|
||||
template <auto n>
|
||||
struct B
|
||||
{};
|
||||
|
||||
B<5> b1;
|
||||
B<'a'> b2;
|
||||
|
||||
}
|
||||
|
||||
#if !defined(REALLY_CLANG)
|
||||
namespace test_structured_bindings
|
||||
{
|
||||
|
||||
// TODO: test it with clang++ from git
|
||||
|
||||
int arr[2] = { 1, 2 };
|
||||
std::pair<int, int> pr = { 1, 2 };
|
||||
|
||||
auto f1() -> int(&)[2]
|
||||
{
|
||||
return arr;
|
||||
}
|
||||
|
||||
auto f2() -> std::pair<int, int>&
|
||||
{
|
||||
return pr;
|
||||
}
|
||||
|
||||
struct S
|
||||
{
|
||||
int x1 : 2;
|
||||
volatile double y1;
|
||||
};
|
||||
|
||||
S f3()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
auto [ x1, y1 ] = f1();
|
||||
auto& [ xr1, yr1 ] = f1();
|
||||
auto [ x2, y2 ] = f2();
|
||||
auto& [ xr2, yr2 ] = f2();
|
||||
const auto [ x3, y3 ] = f3();
|
||||
|
||||
}
|
||||
#endif // !defined(REALLY_CLANG)
|
||||
|
||||
#if !defined(REALLY_CLANG)
|
||||
namespace test_exception_spec_type_system
|
||||
{
|
||||
|
||||
// TODO: test it with clang++ from git
|
||||
|
||||
struct Good {};
|
||||
struct Bad {};
|
||||
|
||||
void g1() noexcept;
|
||||
void g2();
|
||||
|
||||
template<typename T>
|
||||
Bad
|
||||
f(T*, T*);
|
||||
|
||||
template<typename T1, typename T2>
|
||||
Good
|
||||
f(T1*, T2*);
|
||||
|
||||
static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
|
||||
|
||||
}
|
||||
#endif // !defined(REALLY_CLANG)
|
||||
|
||||
namespace test_inline_variables
|
||||
{
|
||||
|
||||
template<class T> void f(T)
|
||||
{}
|
||||
|
||||
template<class T> inline T g(T)
|
||||
{
|
||||
return T{};
|
||||
}
|
||||
|
||||
template<> inline void f<>(int)
|
||||
{}
|
||||
|
||||
template<> int g<>(int)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace cxx17
|
||||
|
||||
#endif // __cplusplus <= 201402L
|
||||
|
||||
]])
|
||||
@@ -0,0 +1,39 @@
|
||||
# =============================================================================
|
||||
# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
|
||||
# =============================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_CXX_COMPILE_STDCXX_11([ext|noext], [mandatory|optional])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Check for baseline language coverage in the compiler for the C++11
|
||||
# standard; if necessary, add switches to CXX and CXXCPP to enable
|
||||
# support.
|
||||
#
|
||||
# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
|
||||
# macro with the version set to C++11. The two optional arguments are
|
||||
# forwarded literally as the second and third argument respectively.
|
||||
# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
|
||||
# more information. If you want to use this macro, you also need to
|
||||
# download the ax_cxx_compile_stdcxx.m4 file.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
|
||||
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
|
||||
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
|
||||
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
|
||||
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
|
||||
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 18
|
||||
|
||||
AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
|
||||
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX([11], [$1], [$2])])
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
# ===========================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_PKG_SWIG([major.minor.micro], [action-if-found], [action-if-not-found])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This macro searches for a SWIG installation on your system. If found,
|
||||
# then SWIG is AC_SUBST'd; if not found, then $SWIG is empty. If SWIG is
|
||||
# found, then SWIG_LIB is set to the SWIG library path, and AC_SUBST'd.
|
||||
#
|
||||
# You can use the optional first argument to check if the version of the
|
||||
# available SWIG is greater than or equal to the value of the argument. It
|
||||
# should have the format: N[.N[.N]] (N is a number between 0 and 999. Only
|
||||
# the first N is mandatory.) If the version argument is given (e.g.
|
||||
# 1.3.17), AX_PKG_SWIG checks that the swig package is this version number
|
||||
# or higher.
|
||||
#
|
||||
# As usual, action-if-found is executed if SWIG is found, otherwise
|
||||
# action-if-not-found is executed.
|
||||
#
|
||||
# In configure.in, use as:
|
||||
#
|
||||
# AX_PKG_SWIG(1.3.17, [], [ AC_MSG_ERROR([SWIG is required to build..]) ])
|
||||
# AX_SWIG_ENABLE_CXX
|
||||
# AX_SWIG_MULTI_MODULE_SUPPORT
|
||||
# AX_SWIG_PYTHON
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Sebastian Huber <sebastian-huber@web.de>
|
||||
# Copyright (c) 2008 Alan W. Irwin
|
||||
# Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net>
|
||||
# Copyright (c) 2008 Andrew Collier
|
||||
# Copyright (c) 2011 Murray Cumming <murrayc@openismus.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation; either version 2 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
# Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||
# gives unlimited permission to copy, distribute and modify the configure
|
||||
# scripts that are the output of Autoconf when processing the Macro. You
|
||||
# need not follow the terms of the GNU General Public License when using
|
||||
# or distributing such scripts, even though portions of the text of the
|
||||
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||
# all other use of the material that constitutes the Autoconf Macro.
|
||||
#
|
||||
# This special exception to the GPL applies to versions of the Autoconf
|
||||
# Macro released by the Autoconf Archive. When you make and distribute a
|
||||
# modified version of the Autoconf Macro, you may extend this special
|
||||
# exception to the GPL to apply to your modified version as well.
|
||||
|
||||
#serial 11
|
||||
|
||||
AC_DEFUN([AX_PKG_SWIG],[
|
||||
# Ubuntu has swig 2.0 as /usr/bin/swig2.0
|
||||
AC_PATH_PROGS([SWIG],[swig swig2.0])
|
||||
if test -z "$SWIG" ; then
|
||||
m4_ifval([$3],[$3],[:])
|
||||
elif test -n "$1" ; then
|
||||
AC_MSG_CHECKING([SWIG version])
|
||||
[swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`]
|
||||
AC_MSG_RESULT([$swig_version])
|
||||
if test -n "$swig_version" ; then
|
||||
# Calculate the required version number components
|
||||
[required=$1]
|
||||
[required_major=`echo $required | sed 's/[^0-9].*//'`]
|
||||
if test -z "$required_major" ; then
|
||||
[required_major=0]
|
||||
fi
|
||||
[required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
|
||||
[required_minor=`echo $required | sed 's/[^0-9].*//'`]
|
||||
if test -z "$required_minor" ; then
|
||||
[required_minor=0]
|
||||
fi
|
||||
[required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
|
||||
[required_patch=`echo $required | sed 's/[^0-9].*//'`]
|
||||
if test -z "$required_patch" ; then
|
||||
[required_patch=0]
|
||||
fi
|
||||
# Calculate the available version number components
|
||||
[available=$swig_version]
|
||||
[available_major=`echo $available | sed 's/[^0-9].*//'`]
|
||||
if test -z "$available_major" ; then
|
||||
[available_major=0]
|
||||
fi
|
||||
[available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
|
||||
[available_minor=`echo $available | sed 's/[^0-9].*//'`]
|
||||
if test -z "$available_minor" ; then
|
||||
[available_minor=0]
|
||||
fi
|
||||
[available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
|
||||
[available_patch=`echo $available | sed 's/[^0-9].*//'`]
|
||||
if test -z "$available_patch" ; then
|
||||
[available_patch=0]
|
||||
fi
|
||||
# Convert the version tuple into a single number for easier comparison.
|
||||
# Using base 100 should be safe since SWIG internally uses BCD values
|
||||
# to encode its version number.
|
||||
required_swig_vernum=`expr $required_major \* 10000 \
|
||||
\+ $required_minor \* 100 \+ $required_patch`
|
||||
available_swig_vernum=`expr $available_major \* 10000 \
|
||||
\+ $available_minor \* 100 \+ $available_patch`
|
||||
|
||||
if test $available_swig_vernum -lt $required_swig_vernum; then
|
||||
AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version.])
|
||||
SWIG=''
|
||||
m4_ifval([$3],[$3],[])
|
||||
else
|
||||
AC_MSG_CHECKING([for SWIG library])
|
||||
SWIG_LIB=`$SWIG -swiglib`
|
||||
AC_MSG_RESULT([$SWIG_LIB])
|
||||
m4_ifval([$2],[$2],[])
|
||||
fi
|
||||
else
|
||||
AC_MSG_WARN([cannot determine SWIG version])
|
||||
SWIG=''
|
||||
m4_ifval([$3],[$3],[])
|
||||
fi
|
||||
fi
|
||||
AC_SUBST([SWIG_LIB])
|
||||
])
|
||||
+301
-118
@@ -1,4 +1,12 @@
|
||||
AC_INIT([H5hut], [1.99.14], [h5part@lists.psi.ch], H5hut)
|
||||
#
|
||||
# Copyright (c) 2006-2017, 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.
|
||||
#
|
||||
# License: see file COPYING in top level of source distribution.
|
||||
#
|
||||
AC_INIT([H5hut], [2.0.0rc4], [h5part@lists.psi.ch], H5hut)
|
||||
AC_PREREQ(2.60)
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
@@ -8,6 +16,7 @@ ENABLE_DEBUG='no'
|
||||
ENABLE_C='yes'
|
||||
ENABLE_FORTRAN='no'
|
||||
ENABLE_PARALLEL='no'
|
||||
ENABLE_PYTHON='no'
|
||||
|
||||
###############################################################################
|
||||
# --enable-xxx and --with-xxx Arguments
|
||||
@@ -31,6 +40,13 @@ AC_ARG_ENABLE(
|
||||
[ENABLE_FORTRAN=$enableval])
|
||||
AM_CONDITIONAL([ENABLE_FORTRAN], [test "$ENABLE_FORTRAN" = "yes"])
|
||||
|
||||
AC_ARG_ENABLE(
|
||||
[python],
|
||||
[AS_HELP_STRING([--enable-python],
|
||||
[Compile the Python interface [default=no]])],
|
||||
[ENABLE_PYTHON=$enableval])
|
||||
AM_CONDITIONAL([ENABLE_PYTHON], [test "$ENABLE_PYTHON" = "yes"])
|
||||
|
||||
AC_ARG_ENABLE(
|
||||
[parallel],
|
||||
[AS_HELP_STRING([--enable-parallel],
|
||||
@@ -58,6 +74,13 @@ AC_ARG_ENABLE(
|
||||
[ENABLE_VTKCONVERTER=$enableval])
|
||||
AM_CONDITIONAL([ENABLE_VTKCONVERTER], [test "$ENABLE_VTKCONVERTER" = "yes"])
|
||||
|
||||
AC_ARG_ENABLE(
|
||||
[examples],
|
||||
[AS_HELP_STRING([--enable-examples],
|
||||
[Compile the H5hut examples [default=no]])],
|
||||
[ENABLE_EXAMPLES=$enableval])
|
||||
AM_CONDITIONAL([ENABLE_EXAMPLES], [test "$ENABLE_EXAMPLES" = "yes"])
|
||||
|
||||
AC_ARG_WITH(
|
||||
[hdf5],
|
||||
[AS_HELP_STRING([--with-hdf5],
|
||||
@@ -80,7 +103,64 @@ AC_ARG_WITH(
|
||||
[parmetis],
|
||||
[AC_HELP_STRING([--with-parmetis],
|
||||
[path to ParMETIS API [default=""]])],
|
||||
[PARMETISPATH=$withval], [PARMETISPATH=""])
|
||||
[PARMETIS_PREFIX=$withval], [])
|
||||
|
||||
AC_ARG_WITH(
|
||||
[vtk],
|
||||
[AC_HELP_STRING([--with-vtk],
|
||||
[VTK installation path [default=""]])],
|
||||
[VTK_PREFIX=$withval], [])
|
||||
|
||||
# Determine a C/C++ compiler to use.
|
||||
if test "x$ENABLE_PARALLEL" = "xyes"; then
|
||||
if test "x$MPICC" != "x"; then
|
||||
CC=$MPICC
|
||||
fi
|
||||
if test "x$MPICXX" != "x"; then
|
||||
CXX=$MPICXX
|
||||
fi
|
||||
if test "x$MPIFC" != "x"; then
|
||||
FC=$MPIFC
|
||||
else
|
||||
FC=''
|
||||
F77=''
|
||||
F90=''
|
||||
fi
|
||||
c_compilers="mpicc cc"
|
||||
cxx_compilers="mpic++ CC"
|
||||
fc_compiler="mpif90 mpif77 mpifort"
|
||||
else
|
||||
c_compilers="pgcc pathcc icc gcc cc_r cc"
|
||||
cxx_compilers="pgcc pathcc icc g++ cc_r c++"
|
||||
fc_compiler="pgf90 ifort xlf_r pathf90 g95 g90 ftn gfortran"
|
||||
fi
|
||||
|
||||
AC_PROG_CC($c_compilers)
|
||||
if test "x$ac_cv_prog_cc_c89" = "xno"; then
|
||||
AC_MSG_ERROR([C compiler not found!])
|
||||
exit 1
|
||||
fi
|
||||
|
||||
AC_PROG_CXX($cxx_compilers)
|
||||
|
||||
if test "X$ENABLE_FORTRAN" = "Xyes"; then
|
||||
AC_PROG_FC($fc_compiler)
|
||||
if test "x$FC" = "x"; then
|
||||
AC_MSG_ERROR([Fortran compiler not found!])
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
CC=`which $CC`
|
||||
CXX=`which $CXX`
|
||||
FC=`which $FC`
|
||||
|
||||
AX_CXX_COMPILE_STDCXX_11
|
||||
AC_PROG_CC_C99
|
||||
if test "x$ac_cv_prog_cc_c99" = "xno"; then
|
||||
AC_MSG_ERROR([Cannot set C compiler to use C99 standard!])
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
###############################################################################
|
||||
@@ -119,37 +199,25 @@ PATH_Search() {
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
CFLAGS="$CFLAGS -Wall"
|
||||
CXXFLAGS="$CFLAGS -Wall"
|
||||
FFLAGS="$FFLAGS -Wall"
|
||||
|
||||
# debug enabled?
|
||||
AC_MSG_CHECKING([if debug is enabled])
|
||||
if test "X$ENABLE_DEBUG" = "Xyes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
CFLAGS="$CFLAGS -g -Wall"
|
||||
CXXFLAGS="$CFLAGS -g -Wall"
|
||||
FFLAGS="$FFLAGS -g"
|
||||
AC_MSG_RESULT([yes])
|
||||
CFLAGS="$CFLAGS -g3 -O0"
|
||||
CXXFLAGS="$CFLAGS -g3 -O0"
|
||||
FFLAGS="$FFLAGS -g3 -O0"
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_RESULT([no])
|
||||
CFLAGS="$CFLAGS -O3"
|
||||
CXXFLAGS="$CFLAGS -O3"
|
||||
FFLAGS="$FFLAGS -O3"
|
||||
fi
|
||||
|
||||
# Determine a C/C++ compiler to use.
|
||||
if test "x$ENABLE_PARALLEL" = "xyes"; then
|
||||
CCOMPILERS="mpicc"
|
||||
CXXCOMPILERS="mpic++"
|
||||
else
|
||||
CCOMPILERS="pgcc pathcc icc gcc cc_r cc"
|
||||
CXXCOMPILERS="pgcc pathcc icc g++ cc_r c++"
|
||||
fi
|
||||
|
||||
AC_PROG_CC($CCOMPILERS)
|
||||
CC=`which $CC`
|
||||
AC_PROG_CXX($CXXCOMPILERS)
|
||||
CXX=`which $CXX`
|
||||
|
||||
AC_PROG_CC_C99
|
||||
if test "x$ac_cv_prog_cc_c99" = "xno"; then
|
||||
AC_MSG_ERROR([Cannot set C compiler to use C99 standard!])
|
||||
exit 1
|
||||
fi
|
||||
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_AWK
|
||||
@@ -195,95 +263,12 @@ AC_DEFINE_UNQUOTED(MY_UNAME, "$uname", "")
|
||||
###############################################################################
|
||||
# PROCESS ARGUMENTS
|
||||
|
||||
# C enabled?
|
||||
AC_MSG_CHECKING([if C interface enabled])
|
||||
if test "X$ENABLE_C" = "Xyes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
# fortran enabled?
|
||||
AC_MSG_CHECKING([if fortran interface enabled])
|
||||
if test "X$ENABLE_FORTRAN" = "Xyes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
|
||||
if test "X$ENABLE_PARALLEL" = "Xyes"; then
|
||||
AC_PROG_FC(mpif90 mpif77)
|
||||
else
|
||||
AC_PROG_FC(pgf90 ifort xlf_r pathf90 g95 g90 ftn gfortran)
|
||||
fi
|
||||
FC=`which $FC`
|
||||
if test -z "$FC" ; then
|
||||
AC_MSG_ERROR([Cannot find a Fortran compiler!])
|
||||
exit 1
|
||||
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])
|
||||
`cd src/Fortran && rm -f TestUnderscore.o TestUnderscoreC.o TestUnderscore`
|
||||
`cd src/Fortran && ${FC} ${FFLAGS} -c TestUnderscore.f`
|
||||
`cd src/Fortran && ${CC} ${CFLAGS} -c TestUnderscoreC.c`
|
||||
`cd src/Fortran && ${FC} ${FFLAGS} -o TestUnderscore TestUnderscore.o TestUnderscoreC.o`
|
||||
|
||||
if test -f src/Fortran/TestUnderscore ; then
|
||||
`cd src/Fortran && ./TestUnderscore > Underscore.h`
|
||||
AC_MSG_RESULT([ok])
|
||||
else
|
||||
AC_MSG_RESULT([nok])
|
||||
AC_MSG_ERROR([Cannot determine the symbol convention for Fortran object files!])
|
||||
exit 1
|
||||
fi
|
||||
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
######################## large indices enabled ###########################
|
||||
AC_MSG_CHECKING([if large indices are enabled])
|
||||
if test "X$USE_LARGE_INDICES" = "Xyes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
CFLAGS="${CFLAGS} -DUSE_LARGE_INDICES"
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
######################## parallel interface enabled ###########################
|
||||
AC_MSG_CHECKING([if parallel interface enabled])
|
||||
if test "X$ENABLE_PARALLEL" = "Xyes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
CPPFLAGS="${CPPFLAGS} -DPARALLEL_IO -DMPICH_IGNORE_CXX_SEEK"
|
||||
|
||||
if test "X$ENABLE_EXPERIMENTAL" = "Xyes"; then
|
||||
AC_MSG_CHECKING([for ParMETIS])
|
||||
if test "X$PARMETISPATH" != "X"; then
|
||||
CPPFLAGS="$CPPFLAGS -I$PARMETISPATH/include"
|
||||
LDFLAGS="$LDFLAGS -L$PARMETISPATH/lib"
|
||||
fi
|
||||
|
||||
LIBS="$LIBS -lparmetis -lmetis"
|
||||
AC_TRY_LINK([#include <parmetis.h>], [
|
||||
ParMETIS_V3_PartGeom (NULL, NULL, NULL, NULL, NULL);],
|
||||
[AC_MSG_RESULT([yes]); r='yes'], [AC_MSG_RESULT([no]); r='no'] )
|
||||
|
||||
if test "X$r" = "Xno"; then
|
||||
AC_MSG_ERROR([ParMETIS])
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
else # --enable-parallel=no
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
###############################################################################
|
||||
# LIBRARY PATHS
|
||||
# check libraries
|
||||
|
||||
AC_CHECK_LIB([z], [compress2])
|
||||
|
||||
# hdf5
|
||||
if test -z "${HDF5_PREFIX}"; then
|
||||
# alternatives to HDF5_PREFIX
|
||||
if test -n "${HDF5_DIR}"; then
|
||||
@@ -294,13 +279,20 @@ if test -n "${HDF5_PREFIX}"; then
|
||||
CPPFLAGS="$CPPFLAGS -I$HDF5_PREFIX/include"
|
||||
LDFLAGS="$LDFLAGS -L$HDF5_PREFIX/lib"
|
||||
fi
|
||||
AC_CHECK_LIB([z], [compress2])
|
||||
AC_CHECK_LIB([hdf5], [H5open])
|
||||
AS_IF([test "x$ac_cv_lib_hdf5_H5open" != xyes],
|
||||
[AC_MSG_ERROR([Cannot compile and link a HDF5 program]);
|
||||
exit 1])
|
||||
AC_MSG_CHECKING([checking whether hdf5 lib supports parallel IO])
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||
#include "hdf5.h"
|
||||
#ifndef H5_HAVE_PARALLEL
|
||||
# error macro not defined
|
||||
#endif
|
||||
]])], [H5_HAVE_PARALLEL="yes"], [H5_HAVE_PARALLEL="no"])
|
||||
AC_MSG_RESULT([$H5_HAVE_PARALLEL])
|
||||
|
||||
|
||||
# lustre
|
||||
AC_MSG_CHECKING([for lustre API ])
|
||||
AC_MSG_RESULT([])
|
||||
if test -n "${LUSTREPATH}"; then
|
||||
@@ -330,12 +322,188 @@ fi
|
||||
|
||||
LIBS="$LIBS -lm"
|
||||
|
||||
|
||||
|
||||
############################ enabled bindings ###############################
|
||||
|
||||
# C enabled?
|
||||
AC_MSG_CHECKING([if C interface enabled])
|
||||
if test "X$ENABLE_C" = "Xyes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
# fortran enabled?
|
||||
AC_MSG_CHECKING([if fortran interface enabled])
|
||||
if test "X$ENABLE_FORTRAN" = "Xyes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_LANG_PUSH(Fortran)
|
||||
|
||||
# Query Fortran symbol mangling. __AC_FC_NAME_MANGLING sets
|
||||
# ac_cv_{f77,fc}_mangling. The value contains three fields, separated
|
||||
# by commas:
|
||||
#
|
||||
# lower case / upper case:
|
||||
# case translation of the Fortran symbols
|
||||
# underscore / no underscore:
|
||||
# whether the compiler appends "_" to symbol names
|
||||
# extra underscore / no extra underscore:
|
||||
# whether the compiler appends an extra "_" to symbol names already
|
||||
# containing at least one underscore
|
||||
__AC_FC_NAME_MANGLING
|
||||
if test "X${ac_cv_fc_mangling}" == "Xlower case, no underscore, no extra underscore"; then
|
||||
CPPFLAGS+=" -DFC_MANGLING_LOWERCASE_NO_UNDERSCORE"
|
||||
elif test "X${ac_cv_fc_mangling}" == "Xlower case, underscore, no extra underscore"; then
|
||||
CPPFLAGS+=" -DFC_MANGLING_LOWERCASE_SINGLE_UNDERSCORE"
|
||||
elif test "X${ac_cv_fc_mangling}" == "Xlower case, underscore, extra underscore"; then
|
||||
CPPFLAGS+=" -DFC_MANGLING_LOWERCASE_DOUBLE_UNDERSCORE"
|
||||
elif test "X${ac_cv_fc_mangling}" == "Xupper case, no underscore, no extra underscore"; then
|
||||
CPPFLAGS+=" -DFC_MANGLING_UPPERCASE_NO_UNDERSCORE"
|
||||
elif test "X${ac_cv_fc_mangling}" == "Xupper case, underscore, no extra underscore"; then
|
||||
CPPFLAGS+=" -DFC_MANGLING_UPPERCASE_SINGLE_UNDERSCORE"
|
||||
elif test "X${ac_cv_fc_mangling}" == "Xupper case, underscore, extra underscore"; then
|
||||
CPPFLAGS+=" -DFC_MANGLING_UPPERCASE_DOUBLE_UNDERSCORE"
|
||||
fi
|
||||
AC_LANG_POP(Fortran)
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
# python enabled?
|
||||
if test "X$ENABLE_PYTHON" = "Xyes"; then
|
||||
|
||||
AM_PATH_PYTHON([2.5])
|
||||
AX_PKG_SWIG([1.3], [], [ AC_MSG_ERROR([SWIG is required to build..]) ])
|
||||
#SWIG_ENABLE_CXX
|
||||
#SWIG_PYTHON
|
||||
|
||||
PYTHON_PREFIX=`python-config --prefix`
|
||||
PYTHON_EXEC_PREFIX=`python-config --exec-prefix`
|
||||
|
||||
# make sure numpy is available..
|
||||
AC_MSG_CHECKING([for numpy support])
|
||||
NUMPY_INCLUDE=`${PYTHON} -c 'import numpy; print numpy.get_include()'`
|
||||
|
||||
if test "X$?" = "X0" ; then
|
||||
AC_MSG_RESULT([$NUMPY_INCLUDE])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
exit 1
|
||||
fi
|
||||
AC_SUBST([NUMPY_INCLUDE])
|
||||
|
||||
#check for parallel support
|
||||
if test "X$ENABLE_PARALLEL" = "Xyes"; then
|
||||
AC_MSG_CHECKING([for mpi4py support])
|
||||
MPI4PY_INCLUDE=`${PYTHON} -c 'import mpi4py; print mpi4py.get_include()'`
|
||||
|
||||
if test "X$?" = "X0" ; then
|
||||
AC_MSG_RESULT([$MPI4PY_INCLUDE])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
exit 1
|
||||
fi
|
||||
AC_SUBST([MPI4PY_INCLUDE])
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT([ok])
|
||||
|
||||
else
|
||||
AC_MSG_CHECKING([if python interface is enabled])
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
######################## large indices enabled ###########################
|
||||
AC_MSG_CHECKING([if large indices are enabled])
|
||||
if test "X$USE_LARGE_INDICES" = "Xyes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
CFLAGS="${CFLAGS} -DUSE_LARGE_INDICES"
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
######################## parallel interface enabled ###########################
|
||||
AC_MSG_CHECKING([if parallel interface enabled])
|
||||
if test "X$ENABLE_PARALLEL" = "Xyes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
|
||||
AS_IF([test "x$H5_HAVE_PARALLEL" = "xno"],
|
||||
[AC_MSG_ERROR([hdf5 does not support parallel IO!]);
|
||||
exit 1])
|
||||
|
||||
if test "X$ENABLE_VTKCONVERTER" = "Xyes"; then
|
||||
AC_MSG_ERROR([VTK to H5hut grid converter cannot be compiled parallel!])
|
||||
exit 1
|
||||
fi
|
||||
CPPFLAGS="${CPPFLAGS} -DPARALLEL_IO -DMPICH_IGNORE_CXX_SEEK"
|
||||
|
||||
if test "X$ENABLE_EXPERIMENTAL" = "Xyes"; then
|
||||
CPPFLAGS="$CPPFLAGS -DWITH_PARALLEL_H5GRID"
|
||||
AC_MSG_CHECKING([for ParMETIS])
|
||||
if test "X$PARMETIS_PREFIX" != "X"; then
|
||||
CPPFLAGS="$CPPFLAGS -I$PARMETIS_PREFIX/include"
|
||||
LDFLAGS="$LDFLAGS -L$PARMETIS_PREFIX/lib"
|
||||
fi
|
||||
|
||||
LIBS="$LIBS -lparmetis -lmetis"
|
||||
AC_TRY_LINK([#include <parmetis.h>], [
|
||||
ParMETIS_V3_PartGeom (NULL, NULL, NULL, NULL, NULL);],
|
||||
[AC_MSG_RESULT([yes]); r='yes'], [AC_MSG_RESULT([no]); r='no'] )
|
||||
|
||||
if test "X$r" = "Xno"; then
|
||||
AC_MSG_ERROR([ParMETIS])
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
else # --enable-parallel=no
|
||||
AC_MSG_RESULT([no])
|
||||
AS_IF([test "x$H5_HAVE_PARALLEL" = "xyes"],
|
||||
[AC_MSG_ERROR([hdf5 with support for parallel IO cannot be used for non-parallel H5hut!]);
|
||||
exit 1])
|
||||
fi
|
||||
|
||||
###############################################################################
|
||||
# TOOLS
|
||||
AC_MSG_CHECKING([if we have to compile the VTK to H5hut grid converter])
|
||||
if test "X$ENABLE_VTKCONVERTER" = "Xyes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
# :TODO: add test whether we can compile/link a prog with vtk
|
||||
if test -n "$VTK_PREFIX"; then
|
||||
SAVE_C_INCLUDE_PATH="$C_INCLUDE_PATH"
|
||||
SAVE_CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH"
|
||||
SAVE_LIBRARY_PATH="$LIBRARY_PATH"
|
||||
C_INCLUDE_PATH="$C_INCLUDE_PATH $VTK_PREFIX/include"
|
||||
CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH $VTK_PREFIX/include"
|
||||
LIBRARY_PATH="$LIBRARY_PATH $VTK_PREFIX/lib"
|
||||
fi
|
||||
AC_MSG_CHECKING([VTK inlcude files])
|
||||
VTK_INCLUDES=`cmake --find-package -DNAME=VTK -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=COMPILE 2>/dev/null`
|
||||
if test "X$?" != "X0"; then
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([Cannot compile VTK to H5hut converter])
|
||||
exit 1
|
||||
else
|
||||
AC_MSG_RESULT([yes])
|
||||
fi
|
||||
AC_MSG_CHECKING([VTK libraries])
|
||||
VTK_LIBS=`cmake --find-package -DNAME=VTK -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=LINK 2>/dev/null`
|
||||
if test "X$?" != "X0"; then
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([Cannot compile VTK to H5hut converter]);
|
||||
exit 1
|
||||
else
|
||||
AC_MSG_RESULT([yes])
|
||||
fi
|
||||
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
###############################################################################
|
||||
# EXAMPLES
|
||||
AC_MSG_CHECKING([if we have to compile the H5hut examples])
|
||||
if test "X$ENABLE_EXAMPLES" = "Xyes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
@@ -350,7 +518,8 @@ AC_SUBST(CFLAGS)
|
||||
AC_SUBST(FFLAGS)
|
||||
AC_SUBST(AM_CPPFLAGS)
|
||||
AC_SUBST(AM_LDFLAGS)
|
||||
|
||||
AC_SUBST(VTK_INCLUDES)
|
||||
AC_SUBST(VTK_LIBS)
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
src/Makefile
|
||||
@@ -359,11 +528,16 @@ AC_CONFIG_FILES([
|
||||
src/include/h5core/Makefile
|
||||
src/C/Makefile
|
||||
src/Fortran/Makefile
|
||||
src/Python/Makefile
|
||||
test/Makefile
|
||||
doc/Makefile
|
||||
tools/Makefile
|
||||
tools/h5hutcc
|
||||
tools/vtk2h5grid/Makefile
|
||||
examples/H5/Makefile
|
||||
examples/H5Part/Makefile
|
||||
examples/H5Block/Makefile
|
||||
examples/H5Fed/Makefile
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
@@ -386,4 +560,13 @@ AC_MSG_RESULT([AM_LDFLAGS = $AM_LDFLAGS])
|
||||
AC_MSG_RESULT([LIBS = $LIBS])
|
||||
AC_MSG_RESULT([HDF5_PREFIX = $HDF5_PREFIX])
|
||||
AC_MSG_RESULT([LUSTREROOT = $LUSTREROOT])
|
||||
|
||||
if test "x$ENABLE_PYTHON" = "xyes"; then
|
||||
AC_MSG_RESULT([PYTHON = $PYTHON])
|
||||
AC_MSG_RESULT([SWIG = $SWIG])
|
||||
AC_MSG_RESULT([NUMPY_INCLUDE = $NUMPY_INCLUDE])
|
||||
if test "x$ENABLE_PARALLEL" = "xyes"; then
|
||||
AC_MSG_RESULT([MPI4PY_INCLUDE = $MPI4PY_INCLUDE])
|
||||
fi
|
||||
fi
|
||||
AC_MSG_RESULT([ ])
|
||||
|
||||
+2303
-143
File diff suppressed because it is too large
Load Diff
+136
-104
@@ -16,7 +16,6 @@ Developers:
|
||||
<UL>
|
||||
<LI> Andreas Adelmann (PSI) </LI>
|
||||
<LI> Achim Gsell (PSI) </LI>
|
||||
<LI> Benedikt Oswald (PSI) </LI>
|
||||
<LI> Mark Howison (NERSC/LBNL) </LI>
|
||||
<LI> Prabhat (NERSC/LBNL) </LI>
|
||||
<LI> Wes Bethel (NERSC/LBNL) </LI>
|
||||
@@ -25,115 +24,148 @@ Developers:
|
||||
Previous developers:
|
||||
|
||||
<UL>
|
||||
<LI> John Shalf (NERSC/LBNL)</LI>
|
||||
<LI> Benedikt Oswald (PSI) </LI>
|
||||
<LI> Cristina Siegerist (NERSC/LBNL)</LI>
|
||||
<LI> John Shalf (NERSC/LBNL)</LI>
|
||||
</UL>
|
||||
|
||||
For more information, please contact the <a href="mailto:h5part@lists.psi.ch">h5part</a> mailing list.
|
||||
For more information, please contact the
|
||||
<a href="mailto:h5part@lists.psi.ch">h5part</a> mailing list.
|
||||
|
||||
\defgroup c_api C API
|
||||
@{
|
||||
\note The C API is implemented with '\c static \c inline' functions to minimize overhead.
|
||||
\defgroup h5_c_api H5
|
||||
@{
|
||||
\defgroup h5_file File interface
|
||||
|
||||
In this section we document the interface for accessing H5hut files.
|
||||
|
||||
\defgroup h5_model Setting up the data model
|
||||
|
||||
The fundamental data model of H5hut is pretty simple. There
|
||||
are (time-)steps to group data, that's it. In this section we
|
||||
document the interface to these (time-)steps.
|
||||
|
||||
\defgroup h5_file_attribs File attributes interface
|
||||
|
||||
File attributes are small datasets that can be used to
|
||||
describe specific properties of a file. The H5hut API provides
|
||||
functions to attach (write), read and inquire file attributes.
|
||||
|
||||
\defgroup h5_step_attribs Step attributes interface
|
||||
|
||||
Step attributes are similar to file attributes but are
|
||||
attached to (time-)steps. They can be used to describe
|
||||
specific properties of a specific step. The H5hut API provides
|
||||
functions to attach (write), read and inquire step attributes.
|
||||
|
||||
\defgroup h5_attach Attaching files
|
||||
|
||||
Sometimes it is required (or at least useful) to attach
|
||||
additional information to H5hut files. H5hut provides
|
||||
functions to attach other files to H5hut files. The attached
|
||||
files can be of any type.
|
||||
|
||||
\defgroup h5_log Controlling verbosity level
|
||||
|
||||
Controlling the verbosity level of H5hut. By default only
|
||||
error messages are printed. For debugging it might be helpful
|
||||
to increase the verbosity level.
|
||||
|
||||
\defgroup h5_debug Controlling debug output
|
||||
|
||||
Debug output mainly intended for developers.
|
||||
|
||||
\defgroup h5_error Error handling interface
|
||||
|
||||
H5hut comes with two error handler. The default error handler
|
||||
prints an error message (which can be suppressed by setting
|
||||
the verbosity level to \c 0), sets an internal error number
|
||||
and returns to the calling program with the value \c
|
||||
H5_FAILURE. It is up to the programmer to handle the error
|
||||
properly. In certain use-cases it make sense just to abort the
|
||||
program, so no additional error handling is needed. H5hut
|
||||
provides an abort error-handler for this use-cases-
|
||||
|
||||
@}
|
||||
\defgroup h5part_c_api H5Part
|
||||
@{
|
||||
\defgroup h5part_model Setting up the data model
|
||||
|
||||
The H5Part data model interface provides functions to set and
|
||||
inquire (per core) views on datasets.
|
||||
|
||||
\defgroup h5part_io Dataset interface
|
||||
|
||||
The dataset interface provides functions to read and write
|
||||
datasets. The following data types are supported:
|
||||
|
||||
- 64-bit floating point numbers (\c h5_float64_t)
|
||||
- 32-bit floating point numbers (\c h5_float32_t)
|
||||
- 64-bit integers (\c h5_int64_t)
|
||||
- 32-bit integers (\c h5_int32_t)
|
||||
|
||||
\note Before you can write or read a dataset, you have to
|
||||
define a "view" on the dataset for each core.
|
||||
|
||||
@}
|
||||
\defgroup h5block_c_api H5Block
|
||||
@{
|
||||
\defgroup h5block_model Setting up the data model
|
||||
|
||||
The H5Block data model interface provides functions to set and
|
||||
inquire (per core) views on fields.
|
||||
|
||||
\defgroup h5block_io Interface to block structured data
|
||||
|
||||
H5Block provides functions to store and retrieve
|
||||
|
||||
- 3-dimensional fields with scalar values
|
||||
- 3-dimensional fields with 3-dimensional vectors as values
|
||||
|
||||
The following datatypes are supported:
|
||||
|
||||
- 64-bit floating point numbers (\c h5_float64_t)
|
||||
- 32-bit floating point numbers (\c h5_float32_t)
|
||||
- 64-bit integers (\c h5_int64_t)
|
||||
- 32-bit integers (\c h5_int32_t)
|
||||
|
||||
\defgroup h5block_attrib Attaching attributes to field data
|
||||
|
||||
Field attributes are small datasets that can be used to
|
||||
describe specific properties of a field like origin, spacing
|
||||
or coordinates. The H5hut API provides functions to attach
|
||||
(write), read and inquire file attributes.
|
||||
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\defgroup h5hut_c_api H5hut C API
|
||||
*/
|
||||
/*!
|
||||
\ingroup h5hut_c_api
|
||||
\defgroup h5hut_file File Handling
|
||||
*/
|
||||
/*!
|
||||
\ingroup h5hut_c_api
|
||||
\defgroup h5hut_error Error Handling
|
||||
*/
|
||||
/*!
|
||||
\ingroup h5hut_c_api
|
||||
\defgroup h5hut_model Setting up the Data Model
|
||||
*/
|
||||
/*!
|
||||
\ingroup h5hut_c_api
|
||||
\defgroup h5hut_attrib Reading and Writing Attributes
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\defgroup h5part_c_api H5Part C API
|
||||
*/
|
||||
/*!
|
||||
\ingroup h5part_c_api
|
||||
\defgroup h5part_model Setting up the Data Model
|
||||
*/
|
||||
/*!
|
||||
\ingroup h5part_c_api
|
||||
\defgroup h5part_data Reading and Writing Datasets
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\defgroup h5block_c_api H5Block C API
|
||||
*/
|
||||
*/!
|
||||
\ingroup h5block_c_api
|
||||
\defgroup h5block_model Setting up the Data Model
|
||||
*/
|
||||
\ingroup h5block_c_api
|
||||
\defgroup h5block_data Reading and Writing Datasets
|
||||
*/
|
||||
\ingroup h5block_c_api
|
||||
\defgroup h5block_attrib Reading and Writing Attributes
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
\defgroup h5fed_c_api H5Fed C API
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\defgroup h5hut_f90_api H5hut F90 API
|
||||
*/
|
||||
|
||||
/*!
|
||||
\ingroup h5hut_f90_api
|
||||
\defgroup h5hut_file_f File Handling
|
||||
*/
|
||||
|
||||
/*!
|
||||
\ingroup h5hut_f90_api
|
||||
\defgroup h5hut_model_f Setting up the Data Model
|
||||
*/
|
||||
|
||||
/*!
|
||||
\ingroup h5hut_f90_api
|
||||
\defgroup h5hut_attrib_f Reading and Writing Attributes
|
||||
!<
|
||||
|
||||
|
||||
/*!
|
||||
\defgroup h5part_f90_api H5Part F90 API
|
||||
*/
|
||||
/*!
|
||||
\ingroup h5part_f90_api
|
||||
\defgroup h5part_model_f Setting up the Data Model
|
||||
*/
|
||||
/*!
|
||||
\ingroup h5part_f90_api
|
||||
\defgroup h5part_data_f Reading and Writing Datasets
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\defgroup h5block_f90_api H5Block F90 API
|
||||
*/
|
||||
/*!
|
||||
\ingroup h5block_f90_api
|
||||
\defgroup h5block_model_f Setting up the Data Model
|
||||
*/
|
||||
/*!
|
||||
\ingroup h5block_f90_api
|
||||
\defgroup h5block_data_f Reading and Writing Datasets
|
||||
*/
|
||||
/*!
|
||||
\ingroup h5block_f90_api
|
||||
\defgroup h5block_attrib_f Reading and Writing Attributes
|
||||
\defgroup f90_api Fortran90 API
|
||||
@{
|
||||
\defgroup h5_f90_api H5
|
||||
@{
|
||||
\defgroup h5_file_f file interface
|
||||
\defgroup h5_model_f setting up the data model
|
||||
\defgroup h5_file_attribs_f reading and writing file attributes
|
||||
\defgroup h5_step_attribs_f reading and writing step attributes
|
||||
\defgroup h5_log_f control verbosity level
|
||||
\defgroup h5_debug_f control debug output
|
||||
\defgroup h5_error_f error handling interface
|
||||
@}
|
||||
\defgroup h5part_f90_api H5Part
|
||||
@{
|
||||
\defgroup h5part_model_f setting up the data model
|
||||
\defgroup h5part_io_f reading and writing datasets
|
||||
@}
|
||||
\defgroup h5block_f90_api H5Block
|
||||
@{
|
||||
\defgroup h5block_model_f setting up the data model
|
||||
\defgroup h5block_io_f reading and writing datasets
|
||||
\defgroup h5block_attrib_f reading and writing attributes
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
||||
|
||||
+6
-6
@@ -1,7 +1,6 @@
|
||||
EXTRA_DIST = \
|
||||
Doxyfile \
|
||||
H5.dox \
|
||||
Makefile.in
|
||||
EXTRA_DIST = \
|
||||
Doxyfile \
|
||||
H5.dox
|
||||
|
||||
all:
|
||||
|
||||
@@ -10,5 +9,6 @@ doc:
|
||||
doxydoc:
|
||||
doxygen
|
||||
|
||||
clean:
|
||||
${RM} -rf ReferencePages TWiki
|
||||
clean-local:
|
||||
$(RM) -r ReferencePages TWiki
|
||||
$(RM) *~
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<style type="text/css">
|
||||
h1 { text-align: center; }
|
||||
</style>
|
||||
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from lxml import etree
|
||||
from lxml.html import builder as E
|
||||
import os
|
||||
import re
|
||||
|
||||
tree = etree.parse('tagfile')
|
||||
tags = tree.xpath ('//member[@kind="function"]')
|
||||
tags_per_files = {}
|
||||
for tag in tags:
|
||||
name = tag.find("name").text
|
||||
anchor = tag.find("anchor").text
|
||||
anchorfile = tag.find("anchorfile").text
|
||||
if anchorfile in tags_per_files:
|
||||
tags_per_files[anchorfile].append([name, anchor])
|
||||
else:
|
||||
tags_per_files[anchorfile] = [[name, anchor]]
|
||||
|
||||
|
||||
prefix = None
|
||||
for line in open("Doxyfile", "r"):
|
||||
if re.search ("^OUTPUT_DIRECTORY", line):
|
||||
prefix = line.split("=")[-1].strip()
|
||||
|
||||
if not prefix:
|
||||
prefix = "."
|
||||
|
||||
parser = etree.HTMLParser()
|
||||
for filename,anchors in tags_per_files.items():
|
||||
print "Processing file: %s/%s" % (prefix, filename)
|
||||
tree = etree.parse ("%s/%s" % (prefix, filename), parser)
|
||||
for name,id in anchors:
|
||||
anchor = tree.xpath ('//a[@id="%s"]' % id)
|
||||
el = E.A(id="%s" % name)
|
||||
anchor[0].addnext (el)
|
||||
|
||||
f = open ("%s/%s" % (prefix, filename), "w")
|
||||
f.write (etree.tostring (tree))
|
||||
@@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright (c) 2006-2015, 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.!
|
||||
#
|
||||
# License: see file COPYING in top level of source distribution.
|
||||
#
|
||||
|
||||
AM_CPPFLAGS += -I${abs_top_srcdir}/src/include
|
||||
AM_CPPFLAGS += -I${abs_top_srcdir}/examples/include
|
||||
FFLAGS += -cpp $(AM_CPPFLAGS)
|
||||
AM_LDFLAGS += -L${abs_top_builddir}/src/h5core/.libs
|
||||
|
||||
LDADD =
|
||||
|
||||
if ENABLE_FORTRAN
|
||||
LDADD += -lH5hutF
|
||||
AM_LDFLAGS += -L${abs_top_builddir}/src/Fortran/.libs
|
||||
endif
|
||||
|
||||
if ENABLE_DEBUG
|
||||
AM_LDFLAGS += -static
|
||||
endif
|
||||
|
||||
LDADD += -lH5hut
|
||||
|
||||
noinst_PROGRAMS =
|
||||
|
||||
if ENABLE_EXAMPLES
|
||||
if ENABLE_C
|
||||
noinst_PROGRAMS += \
|
||||
attach_file \
|
||||
openclose \
|
||||
query \
|
||||
read_file_attribs \
|
||||
read_step_attribs \
|
||||
write_file_attribs \
|
||||
write_step_attribs
|
||||
endif
|
||||
|
||||
if ENABLE_FORTRAN
|
||||
noinst_PROGRAMS += \
|
||||
openclosef \
|
||||
queryf \
|
||||
read_file_attribsf \
|
||||
read_step_attribsf \
|
||||
write_file_attribsf \
|
||||
write_step_attribsf
|
||||
|
||||
openclosef_SOURCES = openclosef.f90
|
||||
queryf_SOURCES = queryf.f90
|
||||
read_file_attribsf_SOURCES = read_file_attribsf.f90
|
||||
read_step_attribsf_SOURCES = read_step_attribsf.f90
|
||||
write_file_attribsf_SOURCES = write_file_attribsf.f90
|
||||
write_step_attribsf_SOURCES = write_step_attribsf.f90
|
||||
endif
|
||||
endif
|
||||
|
||||
all: ${noinst_PROGRAMS}
|
||||
|
||||
.f90.o:
|
||||
$(FC) $(FFLAGS) -c $<
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include <H5hut.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define FNAME "attach_file.h5"
|
||||
#define ATTACHMENT "attach_file"
|
||||
#define VERBOSITY H5_VERBOSE_ERROR
|
||||
#define DEBUG_MSK H5_DEBUG_ALL
|
||||
|
||||
#include "examples.h"
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char* argv[]
|
||||
) {
|
||||
MPI_Init (&argc, &argv);
|
||||
|
||||
H5SetErrorHandler (H5AbortErrorhandler);
|
||||
H5SetVerbosityLevel (VERBOSITY);
|
||||
H5SetDebugMask (DEBUG_MSK);
|
||||
|
||||
h5_file_t f = H5OpenFile (FNAME, H5_O_WRONLY, H5_PROP_DEFAULT);
|
||||
H5AddAttachment (f, ATTACHMENT);
|
||||
H5CloseFile (f);
|
||||
f = H5OpenFile (FNAME, H5_O_RDWR, H5_PROP_DEFAULT);
|
||||
h5_ssize_t num_attachments = H5GetNumAttachments (f);
|
||||
printf ("Number of attachments: %lld\n", (long long int)num_attachments);
|
||||
int i;
|
||||
char fname[FILENAME_MAX];
|
||||
h5_size_t fsize;
|
||||
for (i=0; i < num_attachments; i++) {
|
||||
H5GetAttachmentInfoByIdx (f, i, fname, sizeof(fname), &fsize);
|
||||
printf (
|
||||
"Attachment %d: Name: %s, Size: %llu\n",
|
||||
i, fname, (long long unsigned)fsize);
|
||||
H5GetAttachment (f, fname);
|
||||
H5DeleteAttachment (f, fname);
|
||||
}
|
||||
H5CloseFile (f);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright (c) 2006-2018, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
|
||||
#include "examples.h"
|
||||
|
||||
#if !defined(VERBOSITY)
|
||||
#define VERBOSITY H5_VERBOSE_ERROR
|
||||
#endif
|
||||
|
||||
/*
|
||||
Use H5_DEBUG_ALL to get full debug output
|
||||
*/
|
||||
#if !defined(DEBUGMASK)
|
||||
#define DEBUGMASK H5_DEBUG_NONE
|
||||
//#define DEBUGMASK H5_DEBUG_ALL
|
||||
#endif
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char** argv
|
||||
) {
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
|
||||
MPI_Init (&argc, &argv);
|
||||
H5SetVerbosityLevel (VERBOSITY);
|
||||
H5SetDebugMask (DEBUGMASK);
|
||||
h5_prop_t prop = H5CreateFileProp ();
|
||||
H5SetPropFileMPIOCollective (prop, &comm);
|
||||
h5_file_t f = H5OpenFile ("testfile.h5", H5_O_WRONLY, prop);
|
||||
H5CloseProp (prop);
|
||||
H5CloseFile (f);
|
||||
H5Finalize ();
|
||||
MPI_Finalize ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
!
|
||||
! Copyright (c) 2006-2015, 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.!
|
||||
!
|
||||
! License: see file COPYING in top level of source distribution.
|
||||
!
|
||||
include 'H5hut.f90'
|
||||
|
||||
program openclose
|
||||
|
||||
use H5hut
|
||||
|
||||
implicit none
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
include 'mpif.h'
|
||||
#endif
|
||||
integer :: comm, rank
|
||||
integer*8 :: file_id, status
|
||||
integer*8 :: props
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
integer :: ierr
|
||||
comm = MPI_COMM_WORLD
|
||||
call mpi_init(ierr)
|
||||
call mpi_comm_rank(comm, rank, ierr)
|
||||
#else
|
||||
comm = 0
|
||||
rank = 1
|
||||
#endif
|
||||
|
||||
props = h5_createprop_file ()
|
||||
#if defined(PARALLEL_IO)
|
||||
status = h5_setprop_file_mpio_collective (props, comm)
|
||||
#endif
|
||||
file_id = h5_openfile ("testfile.h5", H5_O_WRONLY, props)
|
||||
status = h5_closeprop (props)
|
||||
status = h5_closefile (file_id);
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_finalize(ierr)
|
||||
#endif
|
||||
|
||||
end program openclose
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
|
||||
#include "examples.h"
|
||||
|
||||
#define FNAME1 "example_file_attribs.h5"
|
||||
#define FNAME2 "example_step_attribs.h5"
|
||||
|
||||
/*
|
||||
Due to the way types are defined in H5hut, we cannot use "switch() {}"
|
||||
*/
|
||||
const char*
|
||||
type2string (
|
||||
h5_int64_t type
|
||||
) {
|
||||
if (type == H5_FLOAT64_T)
|
||||
return "H5_FLOAT64_T";
|
||||
if (type == H5_FLOAT32_T)
|
||||
return "H5_FLOAT32_T";
|
||||
if (type == H5_INT64_T)
|
||||
return "H5_INT64_T";
|
||||
if (type == H5_INT32_T)
|
||||
return "H5_INT32_T";
|
||||
if (type == H5_STRING_T)
|
||||
return "H5_STRING_T";
|
||||
return "unknown type";
|
||||
}
|
||||
|
||||
static inline void
|
||||
print_header (
|
||||
h5_int64_t n
|
||||
) {
|
||||
if (n > 0) {
|
||||
printf ("\t%-6s %-30s %-15s %-10s\n", "idx", "name", "type", "dim");
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
print_query_result (
|
||||
h5_int64_t i,
|
||||
const char* const name,
|
||||
h5_int64_t type,
|
||||
h5_int64_t dim
|
||||
) {
|
||||
printf ("\t%-6lld %-30s %-15s %-10lld\n", (long long)i, name, type2string(type), (long long)dim);
|
||||
}
|
||||
|
||||
void
|
||||
query_file_attribs (
|
||||
h5_int64_t f
|
||||
) {
|
||||
char name[H5_MAX_NAME_LEN];
|
||||
h5_int64_t type;
|
||||
h5_size_t dim;
|
||||
|
||||
// query # of file attributes
|
||||
h5_int64_t n = H5GetNumFileAttribs (f);
|
||||
printf ("\tNumber of file attributes: %lld\n", (long long)n);
|
||||
|
||||
// output name and type of all file attribute
|
||||
print_header (n);
|
||||
for (h5_int64_t i = 0; i < n; i++) {
|
||||
H5GetFileAttribInfo (f, i, name, sizeof(name), &type, &dim);
|
||||
print_query_result (i, name, type, dim);
|
||||
}
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
void
|
||||
query_step_attribs (
|
||||
h5_int64_t f,
|
||||
h5_int64_t step
|
||||
) {
|
||||
char name[H5_MAX_NAME_LEN];
|
||||
h5_int64_t type;
|
||||
h5_size_t dim;
|
||||
|
||||
H5SetStep (f, step);
|
||||
|
||||
// query # of step attributes
|
||||
h5_int64_t n = H5GetNumStepAttribs (f);
|
||||
printf ("\tNumber of step attributes: %lld\n", (long long)n);
|
||||
|
||||
// output name and type of all step attribute
|
||||
print_header (n);
|
||||
for (h5_int64_t i = 0; i < n; i++) {
|
||||
H5GetStepAttribInfo (f, i, name, sizeof(name), &type, &dim);
|
||||
print_query_result (i, name, type, dim);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
query_file (
|
||||
const char* const fname
|
||||
) {
|
||||
printf ("\nFile: %s\n", fname);
|
||||
// if file properties is set to default, MPI_COMM_WORLD will be used
|
||||
h5_file_t f = H5OpenFile (fname, H5_O_RDONLY, H5_PROP_DEFAULT);
|
||||
|
||||
// query and output file attribs
|
||||
query_file_attribs (f);
|
||||
|
||||
// query # of steps, if > 0: go to first step, query and output step attribs
|
||||
h5_int64_t n = H5GetNumSteps (f);
|
||||
printf ("\tNumber of steps: %lld\n", (long long)n);
|
||||
|
||||
if (n > 0) {
|
||||
// go to first step
|
||||
h5_int64_t i = -1;
|
||||
while (!H5HasStep (f, ++i));
|
||||
|
||||
query_step_attribs (f, i);
|
||||
}
|
||||
H5CloseFile (f);
|
||||
}
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char** argv
|
||||
) {
|
||||
MPI_Init (&argc, &argv);
|
||||
H5AbortOnError ();
|
||||
|
||||
query_file (FNAME1);
|
||||
query_file (FNAME2);
|
||||
|
||||
MPI_Finalize ();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
!
|
||||
! Copyright (c) 2006-2017, 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.!
|
||||
!
|
||||
! License: see file COPYING in top level of source distribution.
|
||||
!
|
||||
include 'H5hut.f90'
|
||||
|
||||
program query
|
||||
use H5hut
|
||||
implicit none
|
||||
#if defined(PARALLEL_IO)
|
||||
include 'mpif.h'
|
||||
#endif
|
||||
|
||||
! the file name we want to read
|
||||
character (len=*), parameter :: FNAME1 = "example_file_attribs.h5"
|
||||
character (len=*), parameter :: FNAME2 = "example_step_attribs.h5"
|
||||
|
||||
! verbosity level: set it to a power of 2 minus one or zero
|
||||
integer*8, parameter :: verbosity_level = 1
|
||||
|
||||
! used for mpi error return
|
||||
integer :: ierr
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_init (ierr)
|
||||
#endif
|
||||
|
||||
! abort program on any H5hut error
|
||||
call h5_abort_on_error ()
|
||||
|
||||
call h5_set_verbosity_level (verbosity_level)
|
||||
|
||||
call query_file (FNAME1);
|
||||
call query_file (FNAME2);
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_finalize(ierr)
|
||||
#endif
|
||||
call exit (ierr)
|
||||
|
||||
contains
|
||||
|
||||
subroutine query_file (fname)
|
||||
character(len=*), intent(in):: fname
|
||||
|
||||
integer*8 file_id
|
||||
integer*8 i, n, status
|
||||
|
||||
write (*, '("File: ", a)') fname
|
||||
|
||||
! if file properties is set to default, MPI_COMM_WORLD will be used
|
||||
file_id = h5_openfile (fname, H5_O_RDONLY, H5_PROP_DEFAULT)
|
||||
|
||||
! query and output file attribs
|
||||
call query_file_attribs (file_id);
|
||||
|
||||
! query # of steps, if > 0: go to first step, query and output step attribs
|
||||
n = h5_getnsteps (file_id);
|
||||
write (*, '(T8, "Number of steps: ", I0)') n
|
||||
|
||||
if (n > 0) then
|
||||
! go to first step
|
||||
i = 0;
|
||||
do
|
||||
if (h5_hasstep (file_id, i)) exit
|
||||
i = i+1
|
||||
end do
|
||||
call query_step_attribs (file_id, i);
|
||||
end if
|
||||
status = h5_closefile (file_id)
|
||||
end subroutine query_file
|
||||
|
||||
! print header for attribute metadata table
|
||||
subroutine print_header (n)
|
||||
integer*8, intent(in):: n
|
||||
|
||||
character(len=6), parameter :: idx = "idx"
|
||||
character(len=30), parameter :: name = "name"
|
||||
character(len=15), parameter :: type = "type"
|
||||
character(len=10), parameter :: dim = "dim"
|
||||
|
||||
if (n > 0) then
|
||||
write (*, '(T8, A, 1X, A, 1X, A, 1X, A)') idx, name, type, dim
|
||||
end if
|
||||
|
||||
end subroutine print_header
|
||||
|
||||
! output attribute metadata
|
||||
subroutine print_query_result (i, name, type, dim)
|
||||
integer*8, intent(in):: i
|
||||
character(len=*), intent(in):: name
|
||||
integer*8, intent(in):: type
|
||||
integer*8, intent(in):: dim
|
||||
|
||||
character(len=30) name_
|
||||
character(len=15) type_, type_char
|
||||
character(len=6) i_
|
||||
character(len=10) dim_
|
||||
|
||||
if (type == H5_FLOAT64_T) then
|
||||
type_char = "H5_FLOAT64_T"
|
||||
else if (type == H5_FLOAT32_T) then
|
||||
type_char = "H5_FLOAT32_T"
|
||||
else if (type == H5_INT64_T) then
|
||||
type_char = "H5_INT64_T"
|
||||
else if (type == H5_INT32_T) then
|
||||
type_char = "H5_INT32_T"
|
||||
else if (type == H5_STRING_T) then
|
||||
type_char = "H5_STRING_T"
|
||||
else
|
||||
type_char = "unknown type"
|
||||
end if
|
||||
|
||||
write (i_, '(I6)') i
|
||||
write (name_, '(A30)') name
|
||||
write (type_, '(A15)') type_char
|
||||
write (dim_, '(I10)') dim
|
||||
|
||||
write (*, '(T8, A6, 1X, A30, 1X, A15, 1X, A10)') adjustl(i_), adjustl(name_), adjustl(type_), adjustl(dim_)
|
||||
end subroutine print_query_result
|
||||
|
||||
subroutine query_file_attribs (file_id)
|
||||
integer*8, intent(in):: file_id
|
||||
|
||||
integer*8 status
|
||||
integer*8 i, n
|
||||
character(len=H5_MAX_NAME_LEN) name
|
||||
integer*8 type, dim
|
||||
|
||||
! query # of file attributes
|
||||
n = h5_getnfileattribs (file_id);
|
||||
write (*, '(T8, "Number of file attributes: ", I0)') n
|
||||
|
||||
! output name and type of all file attribute
|
||||
call print_header (n);
|
||||
do i = 1, n
|
||||
status = h5_getfileattribinfo (file_id, i, name, type, dim);
|
||||
call print_query_result (i, name, type, dim);
|
||||
end do
|
||||
write (*,*)
|
||||
|
||||
end subroutine query_file_attribs
|
||||
|
||||
subroutine query_step_attribs (file_id, stepno)
|
||||
integer*8, intent(in):: file_id
|
||||
integer*8, intent(in):: stepno
|
||||
|
||||
integer*8 status
|
||||
integer*8 i, n
|
||||
character(len=H5_MAX_NAME_LEN) name
|
||||
integer*8 type, dim
|
||||
|
||||
! Go to step #1
|
||||
status = h5_setstep (file_id, stepno);
|
||||
|
||||
! query # of step attributes
|
||||
n = h5_getnstepattribs (file_id)
|
||||
write (*, '(T8, "Number of step attributes: ", i0)') n
|
||||
|
||||
! output name and type of all step attribute
|
||||
call print_header (n)
|
||||
do i = 1, n
|
||||
status = h5_getstepattribinfo (file_id, i, name, type, dim)
|
||||
call print_query_result (i, name, type, dim)
|
||||
end do
|
||||
|
||||
end subroutine query_step_attribs
|
||||
end program query
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
Copyright (c) 2006-2016, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FNAME "example_file_attribs.h5"
|
||||
#define VERBOSITY H5_VERBOSE_ERROR
|
||||
#define DEBUG_MSK 0
|
||||
|
||||
#define ATTR_STRING "FileAttrString"
|
||||
#define ATTR_INT32 "FileAttrInt32"
|
||||
#define ATTR_INT64 "FileAttrInt64"
|
||||
#define ATTR_FLOAT32 "FileAttrFloat32"
|
||||
#define ATTR_FLOAT64 "FileAttrFloat64"
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char** argv
|
||||
) {
|
||||
MPI_Init (&argc, &argv);
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (VERBOSITY);
|
||||
H5SetDebugMask (DEBUG_MSK);
|
||||
|
||||
// if file properties is set to default, MPI_COMM_WORLD will be used
|
||||
h5_file_t f = H5OpenFile (FNAME, H5_O_RDONLY, H5_PROP_DEFAULT);
|
||||
h5_size_t len;
|
||||
|
||||
H5GetFileAttribInfoByName (f, ATTR_STRING, NULL, &len);
|
||||
char* attr_string = (char*)malloc (len+1);
|
||||
H5ReadFileAttribString (f, ATTR_STRING, attr_string);
|
||||
printf ("%s: %s\n", ATTR_STRING, attr_string);
|
||||
free (attr_string);
|
||||
|
||||
H5GetFileAttribInfoByName (f, ATTR_INT32, NULL, &len);
|
||||
int32_t* attr_int32 = (int32_t*)malloc (sizeof(*attr_int32)*len);
|
||||
H5ReadFileAttribInt32 (f, ATTR_INT32, attr_int32);
|
||||
printf ("%s:", ATTR_INT32);
|
||||
for (int i = 0; i < len; i++) {
|
||||
printf (" %d", attr_int32[i]);
|
||||
}
|
||||
printf ("\n");
|
||||
free (attr_int32);
|
||||
|
||||
H5GetFileAttribInfoByName (f, ATTR_INT64, NULL, &len);
|
||||
int64_t* attr_int64 = (int64_t*)malloc (sizeof(*attr_int64)*len);
|
||||
H5ReadFileAttribInt64 (f, ATTR_INT64, attr_int64);
|
||||
printf ("%s:", ATTR_INT64);
|
||||
for (int i = 0; i < len; i++) {
|
||||
printf (" %lld", (long long int)attr_int64[i]);
|
||||
}
|
||||
printf ("\n");
|
||||
free (attr_int64);
|
||||
|
||||
H5GetFileAttribInfoByName (f, ATTR_FLOAT32, NULL, &len);
|
||||
h5_float32_t* attr_float32 = (h5_float32_t*)malloc (sizeof(*attr_float32)*len);
|
||||
H5ReadFileAttribFloat32 (f, ATTR_FLOAT32, attr_float32);
|
||||
printf ("%s:", ATTR_FLOAT32);
|
||||
for (int i = 0; i < len; i++) {
|
||||
printf (" %f", attr_float32[i]);
|
||||
}
|
||||
printf ("\n");
|
||||
free (attr_float32);
|
||||
|
||||
H5GetFileAttribInfoByName (f, ATTR_FLOAT64, NULL, &len);
|
||||
h5_float64_t* attr_float64 = (h5_float64_t*)malloc (sizeof(*attr_float64)*len);
|
||||
H5ReadFileAttribFloat64 (f, ATTR_FLOAT64, attr_float64);
|
||||
printf ("%s:", ATTR_FLOAT64);
|
||||
for (int i = 0; i < len; i++) {
|
||||
printf (" %f", attr_float64[i]);
|
||||
}
|
||||
printf ("\n");
|
||||
free (attr_float64);
|
||||
|
||||
// cleanup
|
||||
H5CloseFile (f);
|
||||
MPI_Finalize ();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
!
|
||||
! Copyright (c) 2006-2015, 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.!
|
||||
!
|
||||
! License: see file COPYING in top level of source distribution.
|
||||
!
|
||||
include 'H5hut.f90'
|
||||
|
||||
program read_file_attribs
|
||||
use H5hut
|
||||
implicit none
|
||||
#if defined(PARALLEL_IO)
|
||||
include 'mpif.h'
|
||||
#endif
|
||||
|
||||
! the file name we want to read
|
||||
character (len=*), parameter :: FNAME = "example_file_attribs.h5"
|
||||
|
||||
! verbosity level: set it to
|
||||
! - 1 to see error messages, if something goes wrong
|
||||
! - 0 to get no output
|
||||
! - a power of 2 minus one to get lot of output
|
||||
! zeror zero
|
||||
integer*8, parameter :: verbosity_level = 1
|
||||
|
||||
! we know the attribute names!
|
||||
character (len=*), parameter :: ATTR_STRING = "FileAttrString"
|
||||
character (len=*), parameter :: ATTR_I4 = "FileAttrInt32"
|
||||
character (len=*), parameter :: ATTR_I8 = "FileAttrInt64"
|
||||
character (len=*), parameter :: ATTR_R4 = "FileAttrFloat32"
|
||||
character (len=*), parameter :: ATTR_R8 = "FileAttrFloat64"
|
||||
|
||||
! for formated output
|
||||
character (len=128) :: fmt
|
||||
|
||||
! attribute values. Note: allocatable strings aren't supported in Fortran90
|
||||
character (len=256) :: string_value
|
||||
integer*4, allocatable :: i4_value (:)
|
||||
integer*8, allocatable :: i8_value (:)
|
||||
real*4, allocatable :: r4_value (:)
|
||||
real*8, allocatable :: r8_value (:)
|
||||
|
||||
! H5hut file id
|
||||
integer*8 :: file_id
|
||||
|
||||
! H5hut API status return
|
||||
integer*8 status
|
||||
|
||||
! type of attribute
|
||||
integer*8 type
|
||||
|
||||
! len of attribute
|
||||
integer*8 len
|
||||
|
||||
! loop index
|
||||
integer*8 i
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
! used for mpi error return
|
||||
integer :: ierr
|
||||
|
||||
call mpi_init (ierr)
|
||||
#endif
|
||||
|
||||
! abort program on any H5hut error
|
||||
call h5_abort_on_error ()
|
||||
|
||||
call h5_set_verbosity_level (verbosity_level)
|
||||
|
||||
! MPI_COMM_WORLD is used, if file is opened with default properties
|
||||
file_id = h5_openfile (FNAME, H5_O_RDONLY, H5_PROP_DEFAULT)
|
||||
|
||||
! read and output string attribute
|
||||
status = h5_getfileattribinfo_by_name (file_id, ATTR_STRING, type, len)
|
||||
status = h5_readfileattrib_string (file_id, ATTR_STRING, string_value)
|
||||
write (fmt, "(a, i0, a)") '(a', len, ')'
|
||||
write (*, "(a, ' = ')", advance='no') ATTR_STRING
|
||||
write (*, fmt) string_value
|
||||
|
||||
! read and output 32bit integer attribute
|
||||
status = h5_getfileattribinfo_by_name (file_id, ATTR_I4, type, len)
|
||||
allocate (i4_value(len))
|
||||
status = h5_readfileattrib_i4 (file_id, ATTR_I4, i4_value)
|
||||
write (fmt, "(a, i0, a)") '(', len, 'i4)'
|
||||
write (*, "(a, ' =')", advance='no') ATTR_I4
|
||||
write (*, fmt) (i4_value(i), i = 1, len)
|
||||
|
||||
! read and output 64bit integer attribute
|
||||
status = h5_getfileattribinfo_by_name (file_id, ATTR_I8, type, len)
|
||||
allocate (i8_value(len))
|
||||
status = h5_readfileattrib_i8 (file_id, ATTR_I8, i8_value)
|
||||
write (fmt, "(a, i0, a)") '(', len, 'i4)'
|
||||
write (*, "(a, ' =')", advance='no') ATTR_I8
|
||||
write (*, fmt) (i8_value(i), i = 1, len)
|
||||
|
||||
! read and output 32bit floating point attribute
|
||||
status = h5_getfileattribinfo_by_name (file_id, ATTR_R4, type, len)
|
||||
allocate (r4_value(len))
|
||||
status = h5_readfileattrib_r4 (file_id, ATTR_R4, r4_value)
|
||||
write (fmt, "(a, i0, a)") '(', len, 'f10.5)'
|
||||
write (*, "(a, ' =')", advance='no') ATTR_R4
|
||||
write (*, fmt) (r4_value(i), i = 1, len)
|
||||
|
||||
! read and output 64bit floating point attribute
|
||||
status = h5_getfileattribinfo_by_name (file_id, ATTR_R8, type, len)
|
||||
allocate (r8_value(len))
|
||||
status = h5_readfileattrib_r8 (file_id, ATTR_R8, r8_value)
|
||||
write (fmt, "(a, i0, a)") '(', len, 'f10.5)'
|
||||
write (*, "(a, ' =')", advance='no') ATTR_R8
|
||||
write (*, fmt) (r8_value(i), i = 1, len)
|
||||
|
||||
! cleanup
|
||||
status = h5_closefile (file_id)
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_finalize(ierr)
|
||||
#endif
|
||||
end program read_file_attribs
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FNAME "example_step_attribs.h5"
|
||||
|
||||
#define ATTR_STRING "StepAttrString"
|
||||
#define ATTR_INT32 "StepAttrInt32"
|
||||
#define ATTR_INT64 "StepAttrInt64"
|
||||
#define ATTR_FLOAT32 "StepAttrFloat32"
|
||||
#define ATTR_FLOAT64 "StepAttrFloat64"
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char** argv
|
||||
) {
|
||||
h5_size_t len;
|
||||
|
||||
MPI_Init (&argc, &argv);
|
||||
H5AbortOnError ();
|
||||
// if file properties is set to default, MPI_COMM_WORLD will be used
|
||||
h5_file_t f = H5OpenFile (FNAME, H5_O_RDONLY, H5_PROP_DEFAULT);
|
||||
|
||||
H5SetStep (f, 1);
|
||||
|
||||
H5GetStepAttribInfoByName (f, ATTR_STRING, NULL, &len);
|
||||
char* attr_string = (char*)malloc (len+1);
|
||||
H5ReadStepAttribString (f, ATTR_STRING, attr_string);
|
||||
printf ("%s: %s\n", ATTR_STRING, attr_string);
|
||||
free (attr_string);
|
||||
|
||||
H5GetStepAttribInfoByName (f, ATTR_INT32, NULL, &len);
|
||||
int32_t* attr_int32 = (int32_t*)malloc (sizeof(*attr_int32)*len);
|
||||
H5ReadStepAttribInt32 (f, ATTR_INT32, attr_int32);
|
||||
printf ("%s:", ATTR_INT32);
|
||||
for (int i = 0; i < len; i++) {
|
||||
printf (" %d", attr_int32[i]);
|
||||
}
|
||||
printf ("\n");
|
||||
free (attr_int32);
|
||||
|
||||
H5GetStepAttribInfoByName (f, ATTR_INT64, NULL, &len);
|
||||
int64_t* attr_int64 = (int64_t*)malloc (sizeof(*attr_int64)*len);
|
||||
H5ReadStepAttribInt64 (f, ATTR_INT64, attr_int64);
|
||||
printf ("%s:", ATTR_INT64);
|
||||
for (int i = 0; i < len; i++) {
|
||||
printf (" %lld", (long long int)attr_int64[i]);
|
||||
}
|
||||
printf ("\n");
|
||||
free (attr_int64);
|
||||
|
||||
H5GetStepAttribInfoByName (f, ATTR_FLOAT32, NULL, &len);
|
||||
h5_float32_t* attr_float32 = (h5_float32_t*)malloc (sizeof(*attr_float32)*len);
|
||||
H5ReadStepAttribFloat32 (f, ATTR_FLOAT32, attr_float32);
|
||||
printf ("%s:", ATTR_FLOAT32);
|
||||
for (int i = 0; i < len; i++) {
|
||||
printf (" %f", attr_float32[i]);
|
||||
}
|
||||
printf ("\n");
|
||||
free (attr_float32);
|
||||
|
||||
H5GetStepAttribInfoByName (f, ATTR_FLOAT64, NULL, &len);
|
||||
h5_float64_t* attr_float64 = (h5_float64_t*)malloc (sizeof(*attr_float64)*len);
|
||||
H5ReadStepAttribFloat64 (f, ATTR_FLOAT64, attr_float64);
|
||||
printf ("%s:", ATTR_FLOAT64);
|
||||
for (int i = 0; i < len; i++) {
|
||||
printf (" %f", attr_float64[i]);
|
||||
}
|
||||
printf ("\n");
|
||||
free (attr_float64);
|
||||
|
||||
|
||||
H5CloseFile (f);
|
||||
MPI_Finalize ();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
!
|
||||
! Copyright (c) 2006-2015, 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.!
|
||||
!
|
||||
! License: see file COPYING in top level of source distribution.
|
||||
!
|
||||
include 'H5hut.f90'
|
||||
|
||||
program read_step_attribs
|
||||
use H5hut
|
||||
implicit none
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
include 'mpif.h'
|
||||
#endif
|
||||
|
||||
! the file name we want to read
|
||||
character (len=*), parameter :: FNAME = "example_file_attribs.h5"
|
||||
|
||||
! verbosity level: set it to a power of 2 minus one or zero
|
||||
integer*8, parameter :: verbosity_level = 1
|
||||
|
||||
! we know the attribute names!
|
||||
character (len=*), parameter :: ATTR_STRING = "StepAttrString"
|
||||
character (len=*), parameter :: ATTR_I4 = "StepAttrInt32"
|
||||
character (len=*), parameter :: ATTR_I8 = "StepAttrInt64"
|
||||
character (len=*), parameter :: ATTR_R4 = "StepAttrFloat32"
|
||||
character (len=*), parameter :: ATTR_R8 = "StepAttrFloat64"
|
||||
|
||||
! for formated output
|
||||
character (len=128) :: fmt
|
||||
|
||||
! attribute values. Note: allocatable strings aren't supported in Fortran90
|
||||
character (len=256) :: string_value
|
||||
integer*4, allocatable :: i4_value (:)
|
||||
integer*8, allocatable :: i8_value (:)
|
||||
real*4, allocatable :: r4_value (:)
|
||||
real*8, allocatable :: r8_value (:)
|
||||
|
||||
! H5hut file id
|
||||
integer*8 :: file_id
|
||||
|
||||
! H5hut API status return
|
||||
integer*8 status
|
||||
|
||||
! type of attribute
|
||||
integer*8 type
|
||||
|
||||
! len of attribute
|
||||
integer*8 len
|
||||
|
||||
! loop index
|
||||
integer*8 i
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
! used for mpi error return
|
||||
integer :: ierr
|
||||
|
||||
call mpi_init (ierr)
|
||||
#endif
|
||||
|
||||
! abort program on any H5hut error
|
||||
call h5_abort_on_error ()
|
||||
|
||||
call h5_set_verbosity_level (verbosity_level)
|
||||
|
||||
! MPI_COMM_WORLD is used, if file is opened with default properties
|
||||
file_id = h5_openfile (FNAME, H5_O_RDONLY, H5_PROP_DEFAULT)
|
||||
|
||||
! open step 1
|
||||
status = h5_setstep (file_id, int8(1))
|
||||
|
||||
! read and output string attribute
|
||||
status = h5_getstepattribinfo_by_name (file_id, ATTR_STRING, type, len)
|
||||
status = h5_readstepattrib_string (file_id, ATTR_STRING, string_value)
|
||||
write (fmt, "(a, i0, a)") '(a', len, ')'
|
||||
write (*, "(a, ' = ')", advance='no') ATTR_STRING
|
||||
write (*, fmt) string_value
|
||||
|
||||
! read and output 32bit integer attribute
|
||||
status = h5_getstepattribinfo_by_name (file_id, ATTR_I4, type, len)
|
||||
allocate (i4_value(len))
|
||||
status = h5_readstepattrib_i4 (file_id, ATTR_I4, i4_value)
|
||||
write (fmt, "(a, i0, a)") '(', len, 'i4)'
|
||||
write (*, "(a, ' =')", advance='no') ATTR_I4
|
||||
write (*, fmt) (i4_value(i), i = 1, len)
|
||||
|
||||
! read and output 64bit integer attribute
|
||||
status = h5_getstepattribinfo_by_name (file_id, ATTR_I8, type, len)
|
||||
allocate (i8_value(len))
|
||||
status = h5_readstepattrib_i8 (file_id, ATTR_I8, i8_value)
|
||||
write (fmt, "(a, i0, a)") '(', len, 'i4)'
|
||||
write (*, "(a, ' =')", advance='no') ATTR_I8
|
||||
write (*, fmt) (i8_value(i), i = 1, len)
|
||||
|
||||
! read and output 32bit floating point attribute
|
||||
status = h5_getstepattribinfo_by_name (file_id, ATTR_R4, type, len)
|
||||
allocate (r4_value(len))
|
||||
status = h5_readstepattrib_r4 (file_id, ATTR_R4, r4_value)
|
||||
write (fmt, "(a, i0, a)") '(', len, 'f10.5)'
|
||||
write (*, "(a, ' =')", advance='no') ATTR_R4
|
||||
write (*, fmt) (r4_value(i), i = 1, len)
|
||||
|
||||
! read and output 64bit floating point attribute
|
||||
status = h5_getstepattribinfo_by_name (file_id, ATTR_R8, type, len)
|
||||
allocate (r8_value(len))
|
||||
status = h5_readstepattrib_r8 (file_id, ATTR_R8, r8_value)
|
||||
write (fmt, "(a, i0, a)") '(', len, 'f10.5)'
|
||||
write (*, "(a, ' =')", advance='no') ATTR_R8
|
||||
write (*, fmt) (r8_value(i), i = 1, len)
|
||||
|
||||
! cleanup
|
||||
status = h5_closefile (file_id)
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_finalize(ierr)
|
||||
#endif
|
||||
end program read_step_attribs
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
#define FNAME "example_file_attribs.h5"
|
||||
|
||||
#define ATTR_STRING "FileAttrString"
|
||||
#define ATTR_INT32 "FileAttrInt32"
|
||||
#define ATTR_INT64 "FileAttrInt64"
|
||||
#define ATTR_FLOAT32 "FileAttrFloat32"
|
||||
#define ATTR_FLOAT64 "FileAttrFloat64"
|
||||
|
||||
#define asize(array) (sizeof(array)/sizeof(array[0]))
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char** argv
|
||||
) {
|
||||
char* string_value = "This is a string attribute bound to the file.";
|
||||
int32_t int32_value[] = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144};
|
||||
int64_t int64_value[] = {42, 43, 44, 45};
|
||||
h5_float32_t float32_value[] = {2.71828};
|
||||
h5_float64_t float64_value[] = {3.14159265358979323846264338327950288419716939937510};
|
||||
|
||||
MPI_Init (&argc, &argv);
|
||||
|
||||
H5AbortOnError ();
|
||||
|
||||
// if file properties is set to default, MPI_COMM_WORLD will be used
|
||||
h5_file_t f = H5OpenFile (FNAME, H5_O_WRONLY, H5_PROP_DEFAULT);
|
||||
H5WriteFileAttribString (f, ATTR_STRING, string_value);
|
||||
H5WriteFileAttribInt32 (f, ATTR_INT32, int32_value, asize(int32_value));
|
||||
H5WriteFileAttribInt64 (f, ATTR_INT64, int64_value, asize(int64_value));
|
||||
H5WriteFileAttribFloat32 (f, ATTR_FLOAT32, float32_value, asize(float32_value));
|
||||
H5WriteFileAttribFloat64 (f, ATTR_FLOAT64, float64_value, asize(float32_value));
|
||||
|
||||
H5CloseFile (f);
|
||||
MPI_Finalize ();
|
||||
return 0;
|
||||
}
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from H5hut import *
|
||||
import numpy as np
|
||||
|
||||
FNAME = "example_file_attribs.h5"
|
||||
|
||||
ATTR_STRING = "FileAttrString"
|
||||
ATTR_INT32 = "FileAttrInt32"
|
||||
ATTR_INT64 = "FileAttrInt64"
|
||||
ATTR_FLOAT32 = "FileAttrFloat32"
|
||||
ATTR_FLOAT64 = "FileAttrFloat64"
|
||||
|
||||
string_value = "This is a string attribute attached to the file."
|
||||
int32_value = np.array ([0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144], dtype='int32')
|
||||
int64_value = np.array ([42, 43, 44, 45], dtype='int64')
|
||||
float32_value = np.array ([2.71828, ], dtype='float32')
|
||||
float64_value = np.array ([3.14159265358979323846264338327950288419716939937510,],
|
||||
dtype='float64')
|
||||
|
||||
f = H5OpenFile (FNAME, H5_O_WRONLY, H5_PROP_DEFAULT)
|
||||
|
||||
H5WriteFileAttrib (f, ATTR_STRING, string_value)
|
||||
H5WriteFileAttrib (f, ATTR_INT32, int32_value)
|
||||
H5WriteFileAttrib (f, ATTR_INT64, int64_value)
|
||||
H5WriteFileAttrib (f, ATTR_FLOAT32, float32_value)
|
||||
H5WriteFileAttrib (f, ATTR_FLOAT64, float64_value)
|
||||
|
||||
H5CloseFile (f)
|
||||
@@ -0,0 +1,63 @@
|
||||
!
|
||||
! Copyright (c) 2006-2015, 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.!
|
||||
!
|
||||
! License: see file COPYING in top level of source distribution.
|
||||
!
|
||||
include 'H5hut.f90'
|
||||
|
||||
program write_file_attribs
|
||||
use H5hut
|
||||
implicit none
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
include 'mpif.h'
|
||||
#endif
|
||||
|
||||
integer*8, parameter :: verbosity_level = 1
|
||||
|
||||
character (len=*), parameter :: FNAME = "example_file_attribs.h5"
|
||||
character (len=*), parameter :: ATTR_STRING = "FileAttrString"
|
||||
character (len=*), parameter :: ATTR_I4 = "FileAttrInt32"
|
||||
character (len=*), parameter :: ATTR_I8 = "FileAttrInt64"
|
||||
character (len=*), parameter :: ATTR_R4 = "FileAttrFloat32"
|
||||
character (len=*), parameter :: ATTR_R8 = "FileAttrFloat64"
|
||||
|
||||
character (len=*),parameter :: string_value = "This is a string attribute bound to the file."
|
||||
|
||||
integer*4, parameter, dimension(*) :: i4_value = (/0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144/)
|
||||
integer*8, parameter, dimension(*) :: i8_value = (/42, 43, 44, 45/)
|
||||
real*4, parameter, dimension(*) :: r4_value = (/2.71828/)
|
||||
real*8, parameter, dimension(*) :: r8_value = (/3.141592653589793238462643383279502884197169/)
|
||||
|
||||
integer*8 :: file_id, status
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
integer :: ierr
|
||||
call mpi_init(ierr)
|
||||
#endif
|
||||
|
||||
! abort program on any H5hut error
|
||||
call h5_abort_on_error()
|
||||
|
||||
call h5_set_verbosity_level (verbosity_level)
|
||||
|
||||
! MPI_COMM_WORLD is used, if file is opened with default properties
|
||||
file_id = h5_openfile (FNAME, H5_O_WRONLY, H5_PROP_DEFAULT)
|
||||
|
||||
! write attributes
|
||||
status = h5_writefileattrib_string (file_id, ATTR_STRING, string_value)
|
||||
status = h5_writefileattrib_i4 (file_id, ATTR_I4, i4_value, int8(size(i4_value, 1)))
|
||||
status = h5_writefileattrib_i8 (file_id, ATTR_I8, i8_value, int8(size(i8_value, 1)))
|
||||
status = h5_writefileattrib_r4 (file_id, ATTR_R4, r4_value, int8(size(r4_value, 1)))
|
||||
status = h5_writefileattrib_r8 (file_id, ATTR_R8, r8_value, int8(size(r8_value, 1)))
|
||||
|
||||
! cleanup
|
||||
status = h5_closefile (file_id)
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_finalize(ierr)
|
||||
#endif
|
||||
end program write_file_attribs
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
#define FNAME "example_step_attribs.h5"
|
||||
|
||||
#define ATTR_STRING "StepAttrString"
|
||||
#define ATTR_INT32 "StepAttrInt32"
|
||||
#define ATTR_INT64 "StepAttrInt64"
|
||||
#define ATTR_FLOAT32 "StepAttrFloat32"
|
||||
#define ATTR_FLOAT64 "StepAttrFloat64"
|
||||
|
||||
#define asize(array) (sizeof(array)/sizeof(array[0]))
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char** argv
|
||||
) {
|
||||
char* string_value = "This is a string attribute bound to this step.";
|
||||
int32_t int32_value[] = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144};
|
||||
int64_t int64_value[] = {42, 43, 44, 45};
|
||||
h5_float32_t float32_value[] = {2.71828};
|
||||
h5_float64_t float64_value[] = {3.14159265358979323846264338327950288419716939937510};
|
||||
|
||||
MPI_Init (&argc, &argv);
|
||||
|
||||
H5AbortOnError ();
|
||||
|
||||
// if file properties is set to default, MPI_COMM_WORLD will be used
|
||||
h5_file_t f = H5OpenFile (FNAME, H5_O_WRONLY, H5_PROP_DEFAULT);
|
||||
H5SetStep (f, 1);
|
||||
H5WriteStepAttribString (f, ATTR_STRING, string_value);
|
||||
H5WriteStepAttribInt32 (f, ATTR_INT32, int32_value, asize(int32_value));
|
||||
H5WriteStepAttribInt64 (f, ATTR_INT64, int64_value, asize(int64_value));
|
||||
H5WriteStepAttribFloat32 (f, ATTR_FLOAT32, float32_value, asize(float32_value));
|
||||
H5WriteStepAttribFloat64 (f, ATTR_FLOAT64, float64_value, asize(float32_value));
|
||||
|
||||
H5CloseFile (f);
|
||||
MPI_Finalize ();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
!
|
||||
! Copyright (c) 2006-2015, 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.!
|
||||
!
|
||||
! License: see file COPYING in top level of source distribution.
|
||||
!
|
||||
include 'H5hut.f90'
|
||||
|
||||
program write_step_attribs
|
||||
use H5hut
|
||||
implicit none
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
include 'mpif.h'
|
||||
#endif
|
||||
|
||||
integer*8, parameter :: verbosity_level = 1
|
||||
character (len=*), parameter :: FNAME = "example_step_attribs.h5"
|
||||
|
||||
character (len=*), parameter :: ATTR_STRING = "StepAttrString"
|
||||
character (len=*), parameter :: ATTR_I4 = "StepAttrInt32"
|
||||
character (len=*), parameter :: ATTR_I8 = "StepAttrInt64"
|
||||
character (len=*), parameter :: ATTR_R4 = "StepAttrFloat32"
|
||||
character (len=*), parameter :: ATTR_R8 = "StepAttrFloat64"
|
||||
|
||||
character (len=*),parameter :: string_value = "This is a string attribute bound to this step."
|
||||
|
||||
integer*4, parameter, dimension(*) :: i4_value = (/0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144/)
|
||||
integer*8, parameter, dimension(*) :: i8_value = (/42, 43, 44, 45/)
|
||||
real*4, parameter, dimension(*) :: r4_value = (/2.71828/)
|
||||
real*8, parameter, dimension(*) :: r8_value = (/3.141592653589793238462643383279502884197169/)
|
||||
|
||||
integer*8 :: file_id, status
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
integer :: ierr
|
||||
call mpi_init(ierr)
|
||||
#endif
|
||||
|
||||
! abort program on any H5hut error
|
||||
call h5_abort_on_error()
|
||||
|
||||
call h5_set_verbosity_level (verbosity_level)
|
||||
|
||||
! MPI_COMM_WORLD is used, if file is opened with default properties
|
||||
file_id = h5_openfile (FNAME, H5_O_WRONLY, H5_PROP_DEFAULT)
|
||||
|
||||
! open step 1
|
||||
status = h5_setstep (file_id, int8(1))
|
||||
|
||||
! write attributes
|
||||
status = h5_writestepattrib_string (file_id, ATTR_STRING, string_value)
|
||||
status = h5_writestepattrib_i4 (file_id, ATTR_I4, i4_value, int8(size(i4_value, 1)))
|
||||
status = h5_writestepattrib_i8 (file_id, ATTR_I8, i8_value, int8(size(i8_value, 1)))
|
||||
status = h5_writestepattrib_r4 (file_id, ATTR_R4, r4_value, int8(size(r4_value, 1)))
|
||||
status = h5_writestepattrib_r8 (file_id, ATTR_R8, r8_value, int8(size(r8_value, 1)))
|
||||
|
||||
! cleanup
|
||||
status = h5_closefile (file_id)
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_finalize(ierr)
|
||||
#endif
|
||||
end program write_step_attribs
|
||||
@@ -0,0 +1,3 @@
|
||||
h5hut.mod
|
||||
read_write_scalar_field
|
||||
read_write_scalar_fieldf
|
||||
@@ -1,716 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <hdf5.h>
|
||||
#include "H5Part.h"
|
||||
#include "H5Block.h"
|
||||
#include "H5BlockTypes.h"
|
||||
|
||||
static int _debug = 4;
|
||||
|
||||
void
|
||||
_H5Part_vprint_error (
|
||||
const char *fmt,
|
||||
va_list ap
|
||||
) {
|
||||
|
||||
if ( _debug < 1 ) return;
|
||||
vfprintf ( stderr, fmt, ap );
|
||||
fprintf ( stderr, "\n" );
|
||||
}
|
||||
|
||||
void
|
||||
_H5Part_print_error (
|
||||
const char *fmt,
|
||||
...
|
||||
) {
|
||||
|
||||
va_list ap;
|
||||
va_start ( ap, fmt );
|
||||
_H5Part_vprint_error ( fmt, ap );
|
||||
va_end ( ap );
|
||||
}
|
||||
|
||||
void
|
||||
_H5Part_vprint_warn (
|
||||
const char *fmt,
|
||||
va_list ap
|
||||
) {
|
||||
|
||||
if ( _debug < 2 ) return;
|
||||
vfprintf ( stderr, fmt, ap );
|
||||
fprintf ( stderr, "\n" );
|
||||
}
|
||||
|
||||
void
|
||||
_H5Part_print_warn (
|
||||
const char *fmt,
|
||||
...
|
||||
) {
|
||||
|
||||
va_list ap;
|
||||
va_start ( ap, fmt );
|
||||
_H5Part_vprint_warn ( fmt, ap );
|
||||
va_end ( ap );
|
||||
}
|
||||
|
||||
void
|
||||
_H5Part_vprint_info (
|
||||
const char *fmt,
|
||||
va_list ap
|
||||
) {
|
||||
|
||||
if ( _debug < 3 ) return;
|
||||
vfprintf ( stdout, fmt, ap );
|
||||
fprintf ( stdout, "\n" );
|
||||
}
|
||||
|
||||
void
|
||||
_H5Part_print_info (
|
||||
const char *fmt,
|
||||
...
|
||||
) {
|
||||
|
||||
va_list ap;
|
||||
va_start ( ap, fmt );
|
||||
_H5Part_vprint_info ( fmt, ap );
|
||||
va_end ( ap );
|
||||
}
|
||||
|
||||
void
|
||||
_H5Part_vprint_debug (
|
||||
const char *fmt,
|
||||
va_list ap
|
||||
) {
|
||||
|
||||
if ( _debug < 4 ) return;
|
||||
vfprintf ( stdout, fmt, ap );
|
||||
fprintf ( stdout, "\n" );
|
||||
}
|
||||
|
||||
void
|
||||
_H5Part_print_debug (
|
||||
const char *fmt,
|
||||
...
|
||||
) {
|
||||
|
||||
va_list ap;
|
||||
va_start ( ap, fmt );
|
||||
_H5Part_vprint_debug ( fmt, ap );
|
||||
va_end ( ap );
|
||||
}
|
||||
|
||||
|
||||
struct H5BlockPartition Layout1[1] = {
|
||||
{ 0, 63, 0, 63, 0, 511 }
|
||||
};
|
||||
|
||||
struct H5BlockPartition Layout8[8] = {
|
||||
{ 0,63, 0,63, 0, 63},
|
||||
{ 0,63, 0,63, 64,127},
|
||||
{ 0,63, 0,63, 128,191},
|
||||
{ 0,63, 0,63, 192,255},
|
||||
{ 0,63, 0,63, 256,319},
|
||||
{ 0,63, 0,63, 320,383},
|
||||
{ 0,63, 0,63, 384,447},
|
||||
{ 0,63, 0,63, 448,511}
|
||||
};
|
||||
|
||||
struct H5BlockPartition Layout8G[8] = {
|
||||
{ 0,63, 0,63, 0, 64},
|
||||
{ 0,63, 0,63, 63,128},
|
||||
{ 0,63, 0,63, 127,192},
|
||||
{ 0,63, 0,63, 191,256},
|
||||
{ 0,63, 0,63, 255,320},
|
||||
{ 0,63, 0,63, 319,384},
|
||||
{ 0,63, 0,63, 383,448},
|
||||
{ 0,63, 0,63, 447,511}
|
||||
};
|
||||
|
||||
struct H5BlockPartition Layout16[16] = {
|
||||
{ 0,63, 0,31, 0, 63},
|
||||
{ 0,63, 32,63, 0, 63},
|
||||
{ 0,63, 0,31, 64,127},
|
||||
{ 0,63, 32,63, 64,127},
|
||||
{ 0,63, 0,31, 128,191},
|
||||
{ 0,63, 32,63, 128,191},
|
||||
{ 0,63, 0,31, 192,255},
|
||||
{ 0,63, 32,63, 192,255},
|
||||
{ 0,63, 0,31, 256,319},
|
||||
{ 0,63, 32,63, 256,319},
|
||||
{ 0,63, 0,31, 320,383},
|
||||
{ 0,63, 32,63, 320,383},
|
||||
{ 0,63, 0,31, 384,447},
|
||||
{ 0,63, 32,63, 384,447},
|
||||
{ 0,63, 0,31, 448,511},
|
||||
{ 0,63, 32,63, 448,511}
|
||||
};
|
||||
|
||||
struct H5BlockPartition Layout16G[16] = {
|
||||
{ 0,63, 0,32, 0, 64},
|
||||
{ 0,63, 31,63, 0, 64},
|
||||
{ 0,63, 0,32, 63,128},
|
||||
{ 0,63, 31,63, 63,128},
|
||||
{ 0,63, 0,32, 127,192},
|
||||
{ 0,63, 31,63, 127,192},
|
||||
{ 0,63, 0,32, 191,256},
|
||||
{ 0,63, 31,63, 191,256},
|
||||
{ 0,63, 0,32, 255,320},
|
||||
{ 0,63, 31,63, 255,320},
|
||||
{ 0,63, 0,32, 319,384},
|
||||
{ 0,63, 31,63, 319,384},
|
||||
{ 0,63, 0,32, 383,448},
|
||||
{ 0,63, 31,63, 383,448},
|
||||
{ 0,63, 0,32, 447,511},
|
||||
{ 0,63, 31,63, 447,511}
|
||||
};
|
||||
|
||||
|
||||
struct H5BlockPartition Layout32[32] = {
|
||||
{ 0,31, 0,31, 0, 63},
|
||||
{ 0,31, 32,63, 0, 63},
|
||||
{ 32,63, 0,31, 0, 63},
|
||||
{ 32,63, 32,63, 0, 63},
|
||||
{ 0,31, 0,31, 64,127},
|
||||
{ 0,31, 32,63, 64,127},
|
||||
{ 32,63, 0,31, 64,127},
|
||||
{ 32,63, 32,63, 64,127},
|
||||
{ 0,31, 0,31, 128,191},
|
||||
{ 0,31, 32,63, 128,191},
|
||||
{ 32,63, 0,31, 128,191},
|
||||
{ 32,63, 32,63, 128,191},
|
||||
{ 0,31, 0,31, 192,255},
|
||||
{ 0,31, 32,63, 192,255},
|
||||
{ 32,63, 0,31, 192,255},
|
||||
{ 32,63, 32,63, 192,255},
|
||||
{ 0,31, 0,31, 256,319},
|
||||
{ 0,31, 32,63, 256,319},
|
||||
{ 32,63, 0,31, 256,319},
|
||||
{ 32,63, 32,63, 256,319},
|
||||
{ 0,31, 0,31, 320,383},
|
||||
{ 0,31, 32,63, 320,383},
|
||||
{ 32,63, 0,31, 320,383},
|
||||
{ 32,63, 32,63, 320,383},
|
||||
{ 0,31, 0,31, 384,447},
|
||||
{ 0,31, 32,63, 384,447},
|
||||
{ 32,63, 0,31, 384,447},
|
||||
{ 32,63, 32,63, 384,447},
|
||||
{ 0,31, 0,31, 448,511},
|
||||
{ 0,31, 32,63, 448,511},
|
||||
{ 32,63, 0,31, 448,511},
|
||||
{ 32,63, 32,63, 448,511}
|
||||
};
|
||||
|
||||
struct H5BlockPartition Layout32G[32] = {
|
||||
{ 0,32, 0,32, 0, 64},
|
||||
{ 0,32, 31,63, 0, 64},
|
||||
{ 31,63, 0,32, 0, 64},
|
||||
{ 31,63, 31,63, 0, 64},
|
||||
{ 0,32, 0,32, 63,128},
|
||||
{ 0,32, 31,63, 63,128},
|
||||
{ 31,63, 0,32, 63,128},
|
||||
{ 31,63, 31,63, 63,128},
|
||||
{ 0,32, 0,32, 127,192},
|
||||
{ 0,32, 31,63, 127,192},
|
||||
{ 31,63, 0,32, 127,192},
|
||||
{ 31,63, 31,63, 127,192},
|
||||
{ 0,32, 0,32, 191,256},
|
||||
{ 0,32, 31,63, 191,256},
|
||||
{ 31,63, 0,32, 191,256},
|
||||
{ 31,63, 31,63, 191,256},
|
||||
{ 0,32, 0,32, 255,320},
|
||||
{ 0,32, 31,63, 255,320},
|
||||
{ 31,63, 0,32, 255,320},
|
||||
{ 31,63, 31,63, 255,320},
|
||||
{ 0,32, 0,32, 319,384},
|
||||
{ 0,32, 31,63, 319,384},
|
||||
{ 31,63, 0,32, 319,384},
|
||||
{ 31,63, 31,63, 319,384},
|
||||
{ 0,31, 0,31, 383,448},
|
||||
{ 0,31, 31,63, 383,448},
|
||||
{ 31,63, 0,31, 383,448},
|
||||
{ 31,63, 31,63, 383,448},
|
||||
{ 0,32, 0,32, 447,511},
|
||||
{ 0,32, 31,63, 447,511},
|
||||
{ 31,63, 0,32, 447,511},
|
||||
{ 31,63, 31,63, 447,511}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define _NO_GHOSTZONE(p,q) ( (p->i_end < q->i_start) \
|
||||
|| (p->j_end < q->j_start) \
|
||||
|| (p->k_end < q->k_start) )
|
||||
|
||||
/*
|
||||
#define _HAVE_GHOSTZONE(p,q) ( (p->i_end >= q->i_start) \
|
||||
&& (p->j_end >= q->j_start) \
|
||||
&& (p->k_end >= q->k_start) \
|
||||
&& (q->i_end >= p->i_start) \
|
||||
&& (q->j_end >= p->j_start) \
|
||||
&& (q->k_end >= p->k_start) )
|
||||
*/
|
||||
|
||||
static int
|
||||
_have_ghostzone (
|
||||
const struct H5BlockPartition *p,
|
||||
const struct H5BlockPartition *q
|
||||
) {
|
||||
return ( ! ( _NO_GHOSTZONE ( p, q ) || _NO_GHOSTZONE ( q, p ) ) );
|
||||
}
|
||||
|
||||
static h5part_int64_t
|
||||
_volume_of_partition (
|
||||
const struct H5BlockPartition *p
|
||||
) {
|
||||
return (p->i_end - p->i_start)
|
||||
* (p->j_end - p->j_start)
|
||||
* (p->k_end - p->k_start);
|
||||
}
|
||||
|
||||
#define MIN( x, y ) ( (x) <= (y) ? (x) : (y) )
|
||||
#define MAX( x, y ) ( (x) >= (y) ? (x) : (y) )
|
||||
|
||||
static h5part_int64_t
|
||||
_volume_of_ghostzone (
|
||||
const struct H5BlockPartition *p,
|
||||
const struct H5BlockPartition *q
|
||||
) {
|
||||
|
||||
h5part_int64_t dx = MIN ( p->i_end, q->i_end )
|
||||
- MAX ( p->i_start, q->i_start ) + 1;
|
||||
h5part_int64_t dy = MIN ( p->j_end, q->j_end )
|
||||
- MAX ( p->j_start, q->j_start ) + 1;
|
||||
h5part_int64_t dz = MIN ( p->k_end, q->k_end )
|
||||
- MAX ( p->k_start, q->k_start ) + 1;
|
||||
|
||||
return dx * dy * dz;
|
||||
}
|
||||
|
||||
static h5part_int64_t
|
||||
_dissolve_X_ghostzone (
|
||||
struct H5BlockPartition *p,
|
||||
struct H5BlockPartition *q
|
||||
) {
|
||||
|
||||
if ( p->i_start > q->i_start )
|
||||
return _dissolve_X_ghostzone( q, p );
|
||||
|
||||
if ( q->i_end <= p->i_end ) /* no dissolving */
|
||||
return -1;
|
||||
|
||||
p->i_end = ( p->i_end + q->i_start ) >> 1;
|
||||
q->i_start = p->i_end + 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static h5part_int64_t
|
||||
_dissolve_Y_ghostzone (
|
||||
struct H5BlockPartition *p,
|
||||
struct H5BlockPartition *q
|
||||
) {
|
||||
|
||||
if ( p->j_start > q->j_start )
|
||||
return _dissolve_Y_ghostzone( q, p );
|
||||
|
||||
if ( q->j_end <= p->j_end ) /* no dissolving */
|
||||
return -1;
|
||||
|
||||
p->j_end = ( p->j_end + q->j_start ) >> 1;
|
||||
q->j_start = p->j_end + 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static h5part_int64_t
|
||||
_dissolve_Z_ghostzone (
|
||||
struct H5BlockPartition *p,
|
||||
struct H5BlockPartition *q
|
||||
) {
|
||||
|
||||
if ( p->k_start > q->k_start )
|
||||
return _dissolve_Z_ghostzone( q, p );
|
||||
|
||||
if ( q->k_end <= p->k_end ) /* no dissolving */
|
||||
return -1;
|
||||
|
||||
p->k_end = ( p->k_end + q->k_start ) >> 1;
|
||||
q->k_start = p->k_end + 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static h5part_int64_t
|
||||
_dissolve_ghostzone_max_volume_of_dissolved_partitions (
|
||||
struct H5BlockPartition *p,
|
||||
struct H5BlockPartition *q
|
||||
) {
|
||||
|
||||
struct H5BlockPartition p_;
|
||||
struct H5BlockPartition q_;
|
||||
struct H5BlockPartition p_best;
|
||||
struct H5BlockPartition q_best;
|
||||
h5part_int64_t vol;
|
||||
h5part_int64_t max_vol = 0;
|
||||
|
||||
p_ = *p;
|
||||
q_ = *q;
|
||||
if ( _dissolve_X_ghostzone ( &p_, &q_ ) == 0 ) {
|
||||
vol = _volume_of_partition ( &p_ ) + _volume_of_partition ( &q_ );
|
||||
if ( vol > max_vol ) {
|
||||
max_vol = vol;
|
||||
p_best = p_;
|
||||
q_best = q_;
|
||||
}
|
||||
}
|
||||
|
||||
p_ = *p;
|
||||
q_ = *q;
|
||||
if ( _dissolve_Y_ghostzone ( &p_, &q_ ) == 0 ) {
|
||||
vol = _volume_of_partition ( &p_ ) + _volume_of_partition ( &q_ );
|
||||
if ( vol > max_vol ) {
|
||||
max_vol = vol;
|
||||
p_best = p_;
|
||||
q_best = q_;
|
||||
}
|
||||
}
|
||||
p_ = *p;
|
||||
q_ = *q;
|
||||
|
||||
if ( _dissolve_Z_ghostzone ( &p_, &q_ ) == 0 ) {
|
||||
vol = _volume_of_partition ( &p_ ) + _volume_of_partition ( &q_ );
|
||||
if ( vol > max_vol ) {
|
||||
max_vol = vol;
|
||||
p_best = p_;
|
||||
q_best = q_;
|
||||
}
|
||||
}
|
||||
if ( max_vol <= 0 ) {
|
||||
return H5PART_ERR_LAYOUT;
|
||||
}
|
||||
*p = p_best;
|
||||
*q = q_best;
|
||||
|
||||
return H5PART_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static h5part_int64_t
|
||||
_dissolve_ghostzones_max_volume_of_dissolved_partitions (
|
||||
H5PartFile *f
|
||||
) {
|
||||
|
||||
h5part_int64_t herr;
|
||||
struct H5BlockStruct *b = f->block;
|
||||
struct H5BlockPartition *part1;
|
||||
struct H5BlockPartition *part2;
|
||||
int proc1, proc2;
|
||||
|
||||
memcpy ( b->write_layout, b->user_layout,
|
||||
f->nprocs * sizeof (*f->block->user_layout) );
|
||||
|
||||
for ( proc1 = 0, part1 = b->write_layout;
|
||||
proc1 < f->nprocs-1;
|
||||
proc1++, part1++ ) {
|
||||
for ( proc2 = proc1+1, part2 = &b->write_layout[proc2];
|
||||
proc2 < f->nprocs;
|
||||
proc2++, part2++ ) {
|
||||
|
||||
if ( ! _have_ghostzone ( part1, part2 ) )
|
||||
continue;
|
||||
|
||||
herr = _dissolve_ghostzone_max_volume_of_dissolved_partitions (
|
||||
part1, part2 );
|
||||
if ( herr < 0 ) return herr;
|
||||
}
|
||||
}
|
||||
_H5Part_print_debug ("Layout after dissolving ghost-zones:");
|
||||
for ( proc1 = 0, part1 = b->write_layout;
|
||||
proc1 < f->nprocs;
|
||||
proc1++, part1++ ) {
|
||||
_H5Part_print_debug (
|
||||
"PROC[%d]: proc[%d]: %lld:%lld, %lld:%lld, %lld:%lld ",
|
||||
f->myproc, proc1,
|
||||
(long long)part1->i_start,
|
||||
(long long)part1->i_end,
|
||||
(long long)part1->j_start,
|
||||
(long long)part1->j_end,
|
||||
(long long)part1->k_start,
|
||||
(long long)part1->k_end );
|
||||
}
|
||||
return H5PART_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
static h5part_int64_t
|
||||
_dissolve_ghostzone (
|
||||
struct H5BlockPartition *p,
|
||||
struct H5BlockPartition *q
|
||||
) {
|
||||
|
||||
struct H5BlockPartition p_;
|
||||
struct H5BlockPartition q_;
|
||||
struct H5BlockPartition p_best;
|
||||
struct H5BlockPartition q_best;
|
||||
h5part_int64_t vol;
|
||||
h5part_int64_t max_vol = 0;
|
||||
|
||||
p_ = *p;
|
||||
q_ = *q;
|
||||
if ( _dissolve_X_ghostzone ( &p_, &q_ ) == 0 ) {
|
||||
vol = _volume_of_partition ( &p_ ) + _volume_of_partition ( &q_ );
|
||||
if ( vol > max_vol ) {
|
||||
max_vol = vol;
|
||||
p_best = p_;
|
||||
q_best = q_;
|
||||
}
|
||||
}
|
||||
|
||||
p_ = *p;
|
||||
q_ = *q;
|
||||
if ( _dissolve_Y_ghostzone ( &p_, &q_ ) == 0 ) {
|
||||
vol = _volume_of_partition ( &p_ ) + _volume_of_partition ( &q_ );
|
||||
if ( vol > max_vol ) {
|
||||
max_vol = vol;
|
||||
p_best = p_;
|
||||
q_best = q_;
|
||||
}
|
||||
}
|
||||
p_ = *p;
|
||||
q_ = *q;
|
||||
|
||||
if ( _dissolve_Z_ghostzone ( &p_, &q_ ) == 0 ) {
|
||||
vol = _volume_of_partition ( &p_ ) + _volume_of_partition ( &q_ );
|
||||
if ( vol > max_vol ) {
|
||||
max_vol = vol;
|
||||
p_best = p_;
|
||||
q_best = q_;
|
||||
}
|
||||
}
|
||||
if ( max_vol <= 0 ) {
|
||||
return H5PART_ERR_LAYOUT;
|
||||
}
|
||||
*p = p_best;
|
||||
*q = q_best;
|
||||
|
||||
return H5PART_SUCCESS;
|
||||
}
|
||||
#if 0
|
||||
static h5part_int64_t
|
||||
_dissolve_ghostzones (
|
||||
H5PartFile *f
|
||||
) {
|
||||
|
||||
struct H5BlockStruct *b = f->block;
|
||||
struct H5BlockPartition *p, *max_p;
|
||||
struct H5BlockPartition *q, *max_q;
|
||||
int proc_p, proc_q;
|
||||
h5part_int64_t vol, max_vol;
|
||||
int max_proc_p, max_proc_q;
|
||||
|
||||
memcpy ( b->write_layout, b->user_layout,
|
||||
f->nprocs * sizeof (*f->block->user_layout) );
|
||||
|
||||
while ( 1 ) {
|
||||
max_vol = 0;
|
||||
for ( proc_p = 0, p = b->write_layout;
|
||||
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++ ) {
|
||||
|
||||
if ( ! _have_ghostzone ( p, q ) )
|
||||
continue;
|
||||
vol = _volume_of_ghostzone ( p, q );
|
||||
if ( vol > max_vol ) {
|
||||
max_vol = vol;
|
||||
max_proc_p = proc_p;
|
||||
max_proc_q = proc_q;
|
||||
max_p = p;
|
||||
max_q = q;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( max_vol == 0 )
|
||||
break;
|
||||
|
||||
_dissolve_ghostzone ( max_p, max_q );
|
||||
}
|
||||
|
||||
_H5Part_print_debug ("Layout after dissolving ghost-zones:");
|
||||
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 ",
|
||||
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 );
|
||||
}
|
||||
return H5PART_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static h5part_int64_t
|
||||
_dissolve_ghostzones (
|
||||
H5PartFile *f
|
||||
) {
|
||||
|
||||
struct H5BlockStruct *b = f->block;
|
||||
struct H5BlockPartition *p;
|
||||
struct H5BlockPartition *q;
|
||||
int proc_p, proc_q;
|
||||
|
||||
struct list {
|
||||
struct list *prev;
|
||||
struct list *next;
|
||||
struct H5BlockPartition *p;
|
||||
struct H5BlockPartition *q;
|
||||
h5part_int64_t vol;
|
||||
} *p_begin, *p_el, *p_max, *p_end, *p_save;
|
||||
|
||||
memcpy ( b->write_layout, b->user_layout,
|
||||
f->nprocs * sizeof (*f->block->user_layout) );
|
||||
|
||||
/*
|
||||
build a list of all ghost-zones, save procs and volume remember max volume
|
||||
while list not empty
|
||||
take element with max volume from list and dissolve ghost-zones for this
|
||||
recalculate volumes for remaining list elements remember max volume
|
||||
remove list element if volume is zero
|
||||
*/
|
||||
|
||||
p_begin = p_max = p_end = malloc ( sizeof ( *p_begin ) );
|
||||
memset ( p_begin, 0, sizeof ( *p_begin ) );
|
||||
|
||||
for ( proc_p = 0, p = b->write_layout;
|
||||
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++ ) {
|
||||
|
||||
if ( _have_ghostzone ( p, q ) ) {
|
||||
p_el = malloc ( sizeof ( *p_el ) );
|
||||
|
||||
p_el->p = p;
|
||||
p_el->q = q;
|
||||
p_el->vol = _volume_of_ghostzone ( p, q );
|
||||
p_el->prev = p_end;
|
||||
p_el->next = NULL;
|
||||
|
||||
if ( p_el->vol > p_max->vol )
|
||||
p_max = p_el;
|
||||
|
||||
p_end->next = p_el;
|
||||
p_end = p_el;
|
||||
}
|
||||
}
|
||||
}
|
||||
while ( p_begin->next ) {
|
||||
if ( p_max->next ) p_max->next->prev = p_max->prev;
|
||||
p_max->prev->next = p_max->next;
|
||||
|
||||
_dissolve_ghostzone ( p_max->p, p_max->q );
|
||||
|
||||
free ( p_max );
|
||||
p_el = p_max = p_begin->next;
|
||||
|
||||
while ( p_el ) {
|
||||
if ( _have_ghostzone ( p_el->p, p_el->q ) ) {
|
||||
p_el->vol = _volume_of_ghostzone ( p_el->p, p_el->q );
|
||||
if ( p_el->vol > p_max->vol )
|
||||
p_max = p_el;
|
||||
p_el = p_el->next;
|
||||
} else {
|
||||
if ( p_el->next )
|
||||
p_el->next->prev = p_el->prev;
|
||||
p_el->prev->next = p_el->next;
|
||||
p_save = p_el->next;
|
||||
free ( p_el );
|
||||
p_el = p_save;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
free ( p_begin );
|
||||
|
||||
|
||||
_H5Part_print_debug ("Layout after dissolving ghost-zones:");
|
||||
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 ",
|
||||
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 );
|
||||
}
|
||||
return H5PART_SUCCESS;
|
||||
}
|
||||
|
||||
static H5PartFile*
|
||||
_init (
|
||||
void
|
||||
) {
|
||||
|
||||
H5PartFile *f;
|
||||
struct H5BlockStruct *b;
|
||||
|
||||
|
||||
f = (H5PartFile*) malloc( sizeof (H5PartFile) );
|
||||
if( f == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
memset (f, 0, sizeof (H5PartFile));
|
||||
f->nprocs = 32;
|
||||
|
||||
f->block = malloc( sizeof (*f->block) );
|
||||
if ( f->block == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
b = f->block;
|
||||
memset ( b, 0, sizeof (*b) );
|
||||
b->user_layout = malloc ( f->nprocs * sizeof (b->user_layout[0]) );
|
||||
if ( b->user_layout == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
b->write_layout = malloc ( f->nprocs * sizeof (b->write_layout[0]) );
|
||||
if ( b->write_layout == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
b->timestep = -1;
|
||||
b->blockgroup = -1;
|
||||
b->shape = -1;
|
||||
b->diskshape = -1;
|
||||
b->memshape = -1;
|
||||
b->field_group_id = -1;
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char *argv[]
|
||||
) {
|
||||
|
||||
H5PartFile *f = _init ();
|
||||
|
||||
memcpy ( f->block->user_layout, Layout32G,
|
||||
f->nprocs * sizeof (*f->block->user_layout) );
|
||||
|
||||
_dissolve_ghostzones ( f );
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,472 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <hdf5.h>
|
||||
#include "H5Part.h"
|
||||
#include "H5Block.h"
|
||||
|
||||
#define NPROCS 8
|
||||
|
||||
struct H5BlockPartition {
|
||||
h5_int64_t i_start;
|
||||
h5_int64_t i_end;
|
||||
h5_int64_t j_start;
|
||||
h5_int64_t j_end;
|
||||
h5_int64_t k_start;
|
||||
h5_int64_t k_end;
|
||||
};
|
||||
|
||||
struct H5BlockPartition Layout1[1] = {
|
||||
{ 0, 63, 0, 63, 0, 511 }
|
||||
};
|
||||
|
||||
struct H5BlockPartition Layout8[8] = {
|
||||
{ 0,63, 0,63, 0, 63},
|
||||
{ 0,63, 0,63, 64,127},
|
||||
{ 0,63, 0,63, 128,191},
|
||||
{ 0,63, 0,63, 192,255},
|
||||
{ 0,63, 0,63, 256,319},
|
||||
{ 0,63, 0,63, 320,383},
|
||||
{ 0,63, 0,63, 384,447},
|
||||
{ 0,63, 0,63, 448,511}
|
||||
};
|
||||
|
||||
struct H5BlockPartition Layout8G[8] = {
|
||||
{ 0,63, 0,63, 0, 64},
|
||||
{ 0,63, 0,63, 63,128},
|
||||
{ 0,63, 0,63, 127,192},
|
||||
{ 0,63, 0,63, 191,256},
|
||||
{ 0,63, 0,63, 255,320},
|
||||
{ 0,63, 0,63, 319,384},
|
||||
{ 0,63, 0,63, 383,448},
|
||||
{ 0,63, 0,63, 447,511}
|
||||
};
|
||||
|
||||
struct H5BlockPartition Layout16[16] = {
|
||||
{ 0,63, 0,31, 0, 63},
|
||||
{ 0,63, 32,63, 0, 63},
|
||||
{ 0,63, 0,31, 64,127},
|
||||
{ 0,63, 32,63, 64,127},
|
||||
{ 0,63, 0,31, 128,191},
|
||||
{ 0,63, 32,63, 128,191},
|
||||
{ 0,63, 0,31, 192,255},
|
||||
{ 0,63, 32,63, 192,255},
|
||||
{ 0,63, 0,31, 256,319},
|
||||
{ 0,63, 32,63, 256,319},
|
||||
{ 0,63, 0,31, 320,383},
|
||||
{ 0,63, 32,63, 320,383},
|
||||
{ 0,63, 0,31, 384,447},
|
||||
{ 0,63, 32,63, 384,447},
|
||||
{ 0,63, 0,31, 448,511},
|
||||
{ 0,63, 32,63, 448,511}
|
||||
};
|
||||
|
||||
struct H5BlockPartition Layout16G[16] = {
|
||||
{ 0,63, 0,32, 0, 64},
|
||||
{ 0,63, 31,63, 0, 64},
|
||||
{ 0,63, 0,32, 63,128},
|
||||
{ 0,63, 31,63, 63,128},
|
||||
{ 0,63, 0,32, 127,192},
|
||||
{ 0,63, 31,63, 127,192},
|
||||
{ 0,63, 0,32, 191,256},
|
||||
{ 0,63, 31,63, 191,256},
|
||||
{ 0,63, 0,32, 255,320},
|
||||
{ 0,63, 31,63, 255,320},
|
||||
{ 0,63, 0,32, 319,384},
|
||||
{ 0,63, 31,63, 319,384},
|
||||
{ 0,63, 0,32, 383,448},
|
||||
{ 0,63, 31,63, 383,448},
|
||||
{ 0,63, 0,32, 447,511},
|
||||
{ 0,63, 31,63, 447,511}
|
||||
};
|
||||
|
||||
|
||||
struct H5BlockPartition Layout32[32] = {
|
||||
{ 0,31, 0,31, 0, 63},
|
||||
{ 0,31, 32,63, 0, 63},
|
||||
{ 32,63, 0,31, 0, 63},
|
||||
{ 32,63, 32,63, 0, 63},
|
||||
{ 0,31, 0,31, 64,127},
|
||||
{ 0,31, 32,63, 64,127},
|
||||
{ 32,63, 0,31, 64,127},
|
||||
{ 32,63, 32,63, 64,127},
|
||||
{ 0,31, 0,31, 128,191},
|
||||
{ 0,31, 32,63, 128,191},
|
||||
{ 32,63, 0,31, 128,191},
|
||||
{ 32,63, 32,63, 128,191},
|
||||
{ 0,31, 0,31, 192,255},
|
||||
{ 0,31, 32,63, 192,255},
|
||||
{ 32,63, 0,31, 192,255},
|
||||
{ 32,63, 32,63, 192,255},
|
||||
{ 0,31, 0,31, 256,319},
|
||||
{ 0,31, 32,63, 256,319},
|
||||
{ 32,63, 0,31, 256,319},
|
||||
{ 32,63, 32,63, 256,319},
|
||||
{ 0,31, 0,31, 320,383},
|
||||
{ 0,31, 32,63, 320,383},
|
||||
{ 32,63, 0,31, 320,383},
|
||||
{ 32,63, 32,63, 320,383},
|
||||
{ 0,31, 0,31, 384,447},
|
||||
{ 0,31, 32,63, 384,447},
|
||||
{ 32,63, 0,31, 384,447},
|
||||
{ 32,63, 32,63, 384,447},
|
||||
{ 0,31, 0,31, 448,511},
|
||||
{ 0,31, 32,63, 448,511},
|
||||
{ 32,63, 0,31, 448,511},
|
||||
{ 32,63, 32,63, 448,511}
|
||||
};
|
||||
|
||||
struct H5BlockPartition Layout32G[32] = {
|
||||
{ 0,32, 0,32, 0, 64},
|
||||
{ 0,32, 31,63, 0, 64},
|
||||
{ 31,63, 0,32, 0, 64},
|
||||
{ 31,63, 31,63, 0, 64},
|
||||
{ 0,32, 0,32, 63,128},
|
||||
{ 0,32, 31,63, 63,128},
|
||||
{ 31,63, 0,32, 63,128},
|
||||
{ 31,63, 31,63, 63,128},
|
||||
{ 0,32, 0,32, 127,192},
|
||||
{ 0,32, 31,63, 127,192},
|
||||
{ 31,63, 0,32, 127,192},
|
||||
{ 31,63, 31,63, 127,192},
|
||||
{ 0,32, 0,32, 191,256},
|
||||
{ 0,32, 31,63, 191,256},
|
||||
{ 31,63, 0,32, 191,256},
|
||||
{ 31,63, 31,63, 191,256},
|
||||
{ 0,32, 0,32, 255,320},
|
||||
{ 0,32, 31,63, 255,320},
|
||||
{ 31,63, 0,32, 255,320},
|
||||
{ 31,63, 31,63, 255,320},
|
||||
{ 0,32, 0,32, 319,384},
|
||||
{ 0,32, 31,63, 319,384},
|
||||
{ 31,63, 0,32, 319,384},
|
||||
{ 31,63, 31,63, 319,384},
|
||||
{ 0,31, 0,31, 383,448},
|
||||
{ 0,31, 31,63, 383,448},
|
||||
{ 31,63, 0,31, 383,448},
|
||||
{ 31,63, 31,63, 383,448},
|
||||
{ 0,32, 0,32, 447,511},
|
||||
{ 0,32, 31,63, 447,511},
|
||||
{ 31,63, 0,32, 447,511},
|
||||
{ 31,63, 31,63, 447,511}
|
||||
};
|
||||
|
||||
#if 0
|
||||
static h5_int64_t
|
||||
_calc_index_KJI (
|
||||
int myproc,
|
||||
h5_int64_t i,
|
||||
h5_int64_t i_dims,
|
||||
h5_int64_t j,
|
||||
h5_int64_t j_dims,
|
||||
h5_int64_t k,
|
||||
h5_int64_t k_dims
|
||||
) {
|
||||
|
||||
return i + j*i_dims + k*i_dims*j_dims;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define _calc_index( i, i_dims, j, j_dims, k, k_dims ) \
|
||||
(i + j*i_dims + k*i_dims*j_dims)
|
||||
|
||||
static h5_int64_t
|
||||
_write_data (
|
||||
h5_file_t *f,
|
||||
int myproc,
|
||||
struct H5BlockPartition *layout
|
||||
) {
|
||||
|
||||
h5_int64_t i, j, k, idx;
|
||||
h5_int64_t herr;
|
||||
h5_float64_t *data;
|
||||
h5_int64_t i_dims = layout->i_end - layout->i_start + 1;
|
||||
h5_int64_t j_dims = layout->j_end - layout->j_start + 1;
|
||||
h5_int64_t k_dims = layout->k_end - layout->k_start + 1;
|
||||
|
||||
printf ( "Writing Step #%lld\n", (long long)f->step_idx );
|
||||
|
||||
data = malloc ( i_dims * j_dims * k_dims * sizeof ( *data ) );
|
||||
for ( i = 0; i < i_dims; i++ ) {
|
||||
for ( j = 0; j < j_dims; j++ ) {
|
||||
for ( k = 0; k < k_dims; k++ ) {
|
||||
idx = _calc_index (
|
||||
i, i_dims,
|
||||
j, j_dims,
|
||||
k, k_dims );
|
||||
*(data + idx) = k
|
||||
+ 1000*j
|
||||
+ 100000*i
|
||||
+ 10000000*myproc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
herr = H5BlockDefine3DFieldLayout (
|
||||
f,
|
||||
layout->i_start, layout->i_end,
|
||||
layout->j_start, layout->j_end,
|
||||
layout->k_start, layout->k_end );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
herr = H5Block3dWriteScalarFieldFloat64 ( f, "TestField", data );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
free ( data );
|
||||
return 1;
|
||||
}
|
||||
|
||||
static h5_int64_t
|
||||
_write_file (
|
||||
const char *fname,
|
||||
const int myproc,
|
||||
MPI_Comm comm,
|
||||
struct H5BlockPartition *layout
|
||||
) {
|
||||
|
||||
h5_file_t *f;
|
||||
h5_int64_t timestep = 0;
|
||||
h5_int64_t herr;
|
||||
|
||||
printf ("PROC[%d]: Open file \"%s\" for writing ...\n",
|
||||
myproc, fname );
|
||||
|
||||
f = H5PartOpenFileParallel ( fname, H5PART_WRITE, comm );
|
||||
if ( f == NULL ) return -1;
|
||||
|
||||
herr = H5PartSetStep ( f, timestep );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
if ( _write_data ( f, myproc, layout ) < 0 ) {
|
||||
printf ("Failed to write file \"%s\"\n", fname );
|
||||
return 2;
|
||||
}
|
||||
|
||||
herr = H5PartCloseFile ( f );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static h5_int64_t
|
||||
_read_data (
|
||||
h5_file_t *f,
|
||||
int myproc,
|
||||
struct H5BlockPartition *layout
|
||||
) {
|
||||
|
||||
h5_int64_t i, j, k, idx;
|
||||
h5_int64_t herr;
|
||||
h5_float64_t *data;
|
||||
h5_int64_t i_dims = layout->i_end - layout->i_start + 1;
|
||||
h5_int64_t j_dims = layout->j_end - layout->j_start + 1;
|
||||
h5_int64_t k_dims = layout->k_end - layout->k_start + 1;
|
||||
|
||||
printf ( "Reading Step #%lld\n", (long long)f->step_idx );
|
||||
|
||||
data = malloc ( i_dims * j_dims * k_dims * sizeof ( *data ) );
|
||||
|
||||
herr = H5BlockDefine3DFieldLayout (
|
||||
f,
|
||||
layout->i_start, layout->i_end,
|
||||
layout->j_start, layout->j_end,
|
||||
layout->k_start, layout->k_end );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
herr = H5Block3dReadScalarFieldFloat64 ( f, "TestField", data );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
for ( i = 0; i < i_dims; i++ ) {
|
||||
for ( j = 0; j < j_dims; j++ ) {
|
||||
for ( k = 0; k < k_dims; k++ ) {
|
||||
idx = _calc_index (
|
||||
i, i_dims,
|
||||
j, j_dims,
|
||||
k, k_dims );
|
||||
|
||||
/*
|
||||
what do I need to calculate the value?
|
||||
proc which has the item written
|
||||
i, j, k relative to proc
|
||||
*/
|
||||
|
||||
h5_int64_t ri = i + layout->i_start;
|
||||
h5_int64_t rj = j + layout->j_start;
|
||||
h5_int64_t rk = k + layout->k_start;
|
||||
int proc = (int) H5Block3dGetProcOf ( f, ri, rj, rk );
|
||||
|
||||
h5_size_t i_start, i_end;
|
||||
h5_size_t j_start, j_end;
|
||||
h5_size_t k_start, k_end;
|
||||
|
||||
H5Block3dGetPartitionOfProc (
|
||||
f,
|
||||
proc,
|
||||
&i_start, &i_end,
|
||||
&j_start, &j_end,
|
||||
&k_start, &k_end );
|
||||
ri -= i_start;
|
||||
rj -= j_start;
|
||||
rk -= k_start;
|
||||
h5_float64_t value = rk
|
||||
+ 1000*rj
|
||||
+ 100000*ri
|
||||
+ 10000000*proc;
|
||||
if ( *(data + idx) != value ) {
|
||||
printf (
|
||||
"PROC[%d]: "
|
||||
"value missmatch for (%lld,%lld,%lld); is: %f;"
|
||||
" should be: %f\n",
|
||||
myproc,
|
||||
(long long)i, (long long)j, (long long)k,
|
||||
*( data + idx ), value );
|
||||
printf (
|
||||
"PROC[%d]: "
|
||||
"My partition is: "
|
||||
"%lld:%lld, %lld:%lld, %lld:%lld\n",
|
||||
myproc,
|
||||
(long long)layout->i_start, (long long)layout->i_end,
|
||||
(long long)layout->j_start, (long long)layout->j_end,
|
||||
(long long)layout->k_start, (long long)layout->k_end );
|
||||
printf (
|
||||
"PROC[%d]: "
|
||||
"Value has been written by proc %d\n",
|
||||
myproc, proc );
|
||||
printf (
|
||||
"PROC[%d]: "
|
||||
"The partition for this proc was: "
|
||||
"%lld:%lld, %lld:%lld, %lld:%lld\n",
|
||||
myproc,
|
||||
(long long)i_start, (long long)i_end,
|
||||
(long long)j_start, (long long)j_end,
|
||||
(long long)k_start, (long long)k_end );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free ( data );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static h5_int64_t
|
||||
_read_file (
|
||||
const char *fname,
|
||||
const int myproc,
|
||||
MPI_Comm comm,
|
||||
struct H5BlockPartition *layout
|
||||
) {
|
||||
|
||||
h5_file_t *f;
|
||||
h5_int64_t timestep = 0;
|
||||
h5_int64_t herr;
|
||||
|
||||
printf ("PROC[%d]: Open file \"%s\" for reading ...\n",
|
||||
myproc, fname );
|
||||
|
||||
f = H5PartOpenFileParallel ( fname, H5PART_READ, comm );
|
||||
if ( f == NULL ) return -1;
|
||||
|
||||
herr = H5PartSetStep ( f, timestep );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
if ( _read_data ( f, myproc, layout ) < 0 ) {
|
||||
printf ("Failed to read file \"%s\"\n", fname );
|
||||
return 2;
|
||||
}
|
||||
|
||||
herr = H5PartCloseFile ( f );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char **argv
|
||||
) {
|
||||
char *fname;
|
||||
int myproc;
|
||||
int nprocs;
|
||||
int opt_with_ghosts = 0;
|
||||
int opt_read = 0;
|
||||
int opt_write = 0;
|
||||
struct H5BlockPartition *layout;
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
|
||||
MPI_Init( &argc, &argv );
|
||||
MPI_Comm_size ( comm, &nprocs );
|
||||
MPI_Comm_rank( comm, &myproc );
|
||||
|
||||
while ( --argc ) {
|
||||
if ( strcmp ( argv[argc], "-r" ) == 0 )
|
||||
opt_read = 1;
|
||||
else if ( strcmp ( argv[argc], "-w" ) == 0 )
|
||||
opt_write = 1;
|
||||
else if ( strcmp ( argv[argc], "-g" ) == 0 )
|
||||
opt_with_ghosts = 1;
|
||||
else {
|
||||
fprintf ( stderr,
|
||||
"Illegal option %s\n\n"
|
||||
"Usage: %s -w -r -g\n",
|
||||
argv[argc], argv[0] );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
switch ( nprocs ) {
|
||||
case 1:
|
||||
fname = "blockfile1.h5";
|
||||
layout = &Layout1[myproc];
|
||||
break;
|
||||
case 8:
|
||||
if ( opt_with_ghosts ) {
|
||||
fname = "blockfile8G.h5";
|
||||
layout = &Layout8G[myproc];
|
||||
} else {
|
||||
fname = "blockfile8.h5";
|
||||
layout = &Layout8[myproc];
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
if ( opt_with_ghosts ) {
|
||||
fname = "blockfile16G.h5";
|
||||
layout = &Layout16G[myproc];
|
||||
} else {
|
||||
fname = "blockfile16.h5";
|
||||
layout = &Layout16[myproc];
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
if ( opt_with_ghosts ) {
|
||||
fname = "blockfile32G.h5";
|
||||
layout = &Layout32G[myproc];
|
||||
} else {
|
||||
fname = "blockfile32.h5";
|
||||
layout = &Layout32[myproc];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf ( "Run this test on %d processor(s)!\n", NPROCS );
|
||||
return 1;
|
||||
}
|
||||
|
||||
H5SetVerbosityLevel ( 4 );
|
||||
|
||||
if ( opt_write ) {
|
||||
if ( _write_file ( fname, myproc, comm, layout ) < 0 ) {
|
||||
printf ("Failed to write file \"%s\"\n", fname );
|
||||
}
|
||||
} else if ( opt_read ) {
|
||||
if ( _read_file ( fname, myproc, comm, layout ) < 0 ) {
|
||||
printf ("Failed to read file \"%s\"\n", fname );
|
||||
}
|
||||
}
|
||||
|
||||
MPI_Finalize();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,462 +0,0 @@
|
||||
PROGRAM H5BlockParTestScalarFieldF
|
||||
IMPLICIT NONE
|
||||
|
||||
INCLUDE 'mpif.h'
|
||||
INCLUDE 'H5PartF90.inc'
|
||||
INCLUDE 'H5BlockF90.inc'
|
||||
|
||||
INTERFACE
|
||||
INTEGER FUNCTION IARGC ()
|
||||
END FUNCTION IARGC
|
||||
END INTERFACE
|
||||
|
||||
INTEGER :: myproc = 0
|
||||
INTEGER :: nprocs = 1
|
||||
INTEGER :: comm = MPI_COMM_WORLD
|
||||
INTEGER :: mpi_err
|
||||
INTEGER*8 :: h5pt_err
|
||||
INTEGER :: i
|
||||
CHARACTER(LEN=32) :: arg_str
|
||||
INTEGER :: opt_read = 0
|
||||
INTEGER :: opt_write = 0
|
||||
INTEGER :: opt_with_ghosts = 0
|
||||
CHARACTER(LEN=128) :: fname
|
||||
INTEGER*8 :: layout (6)
|
||||
INTEGER*8 :: layout1 (6,1)
|
||||
INTEGER*8 :: layout8 (6,8)
|
||||
INTEGER*8 :: layout8g (6,8)
|
||||
INTEGER*8 :: layout16 (6,16)
|
||||
INTEGER*8 :: layout16g(6,16)
|
||||
INTEGER*8 :: layout32 (6,32)
|
||||
INTEGER*8 :: layout32g(6,32)
|
||||
|
||||
DATA layout1 / 1,64, 1,64, 1,512 /
|
||||
DATA layout8 / 1,64, 1,64, 1, 64, &
|
||||
1,64, 1,64, 65,128, &
|
||||
1,64, 1,64, 129,192, &
|
||||
1,64, 1,64, 193,256, &
|
||||
1,64, 1,64, 257,320, &
|
||||
1,64, 1,64, 321,384, &
|
||||
1,64, 1,64, 385,448, &
|
||||
1,64, 1,64, 449,512 /
|
||||
|
||||
DATA layout8g / 1,64, 1,64, 1, 65, &
|
||||
1,64, 1,64, 64,129, &
|
||||
1,64, 1,64, 128,193, &
|
||||
1,64, 1,64, 192,257, &
|
||||
1,64, 1,64, 256,321, &
|
||||
1,64, 1,64, 320,385, &
|
||||
1,64, 1,64, 384,449, &
|
||||
1,64, 1,64, 448,512 /
|
||||
|
||||
DATA layout16 / 1,64, 1,32, 1, 64, &
|
||||
1,64, 33,64, 1, 64, &
|
||||
1,64, 1,32, 65,128, &
|
||||
1,64, 33,64, 65,128, &
|
||||
1,64, 1,32, 129,192, &
|
||||
1,64, 33,64, 129,192, &
|
||||
1,64, 1,32, 193,256, &
|
||||
1,64, 33,64, 193,256, &
|
||||
1,64, 1,32, 257,320, &
|
||||
1,64, 33,64, 257,320, &
|
||||
1,64, 1,32, 321,384, &
|
||||
1,64, 33,64, 321,384, &
|
||||
1,64, 1,32, 385,448, &
|
||||
1,64, 33,64, 385,448, &
|
||||
1,64, 1,32, 449,512, &
|
||||
1,64, 33,64, 449,512 /
|
||||
|
||||
DATA layout16g/ 1,64, 1,33, 1, 65, &
|
||||
1,64, 32,64, 1, 65, &
|
||||
1,64, 1,33, 64,129, &
|
||||
1,64, 32,64, 64,129, &
|
||||
1,64, 1,33, 128,193, &
|
||||
1,64, 32,64, 128,193, &
|
||||
1,64, 1,33, 192,257, &
|
||||
1,64, 32,64, 192,257, &
|
||||
1,64, 1,33, 256,321, &
|
||||
1,64, 32,64, 256,321, &
|
||||
1,64, 1,33, 320,385, &
|
||||
1,64, 32,64, 320,385, &
|
||||
1,64, 1,33, 384,449, &
|
||||
1,64, 32,64, 384,449, &
|
||||
1,64, 1,33, 448,512, &
|
||||
1,64, 32,64, 448,512 /
|
||||
|
||||
DATA layout32 / 1,32, 1,32, 1, 64, &
|
||||
1,32, 33,64, 1, 64, &
|
||||
33,64, 1,32, 1, 64, &
|
||||
33,64, 33,64, 1, 64, &
|
||||
1,32, 1,32, 65,128, &
|
||||
1,32, 33,64, 65,128, &
|
||||
33,64, 1,32, 65,128, &
|
||||
33,64, 33,64, 65,128, &
|
||||
1,32, 1,32, 129,192, &
|
||||
1,32, 33,64, 129,192, &
|
||||
33,64, 1,32, 129,192, &
|
||||
33,64, 33,64, 129,192, &
|
||||
1,32, 1,32, 193,256, &
|
||||
1,32, 33,64, 193,256, &
|
||||
33,64, 1,32, 193,256, &
|
||||
33,64, 33,64, 193,256, &
|
||||
1,32, 1,32, 257,320, &
|
||||
1,32, 33,64, 257,320, &
|
||||
33,64, 1,32, 257,320, &
|
||||
33,64, 33,64, 257,320, &
|
||||
1,32, 1,32, 321,384, &
|
||||
1,32, 33,64, 321,384, &
|
||||
33,64, 1,32, 321,384, &
|
||||
33,64, 33,64, 321,384, &
|
||||
1,32, 1,32, 385,448, &
|
||||
1,32, 33,64, 385,448, &
|
||||
33,64, 1,32, 385,448, &
|
||||
33,64, 33,64, 385,448, &
|
||||
1,32, 1,32, 449,512, &
|
||||
1,32, 33,64, 449,512, &
|
||||
33,64, 1,32, 449,512, &
|
||||
33,64, 33,64, 449,512 /
|
||||
|
||||
DATA layout32G/ 1,33, 1,33, 1, 65, &
|
||||
1,33, 32,64, 1, 65, &
|
||||
32,64, 1,33, 1, 65, &
|
||||
32,64, 32,64, 1, 65, &
|
||||
1,33, 1,33, 64,129, &
|
||||
1,33, 32,64, 64,129, &
|
||||
32,64, 1,33, 64,129, &
|
||||
32,64, 32,64, 64,129, &
|
||||
1,33, 1,33, 128,193, &
|
||||
1,33, 32,64, 128,193, &
|
||||
32,64, 1,33, 128,193, &
|
||||
32,64, 32,64, 128,193, &
|
||||
1,33, 1,33, 192,257, &
|
||||
1,33, 32,64, 192,257, &
|
||||
32,64, 1,33, 192,257, &
|
||||
32,64, 32,64, 192,257, &
|
||||
1,33, 1,33, 256,321, &
|
||||
1,33, 32,64, 256,321, &
|
||||
32,64, 1,33, 256,321, &
|
||||
32,64, 32,64, 256,321, &
|
||||
1,33, 1,33, 320,385, &
|
||||
1,33, 32,64, 320,385, &
|
||||
32,64, 1,33, 320,385, &
|
||||
32,64, 32,64, 320,385, &
|
||||
1,33, 1,33, 384,449, &
|
||||
1,33, 32,64, 384,449, &
|
||||
32,64, 1,33, 384,449, &
|
||||
32,64, 32,64, 384,449, &
|
||||
1,33, 1,33, 448,512, &
|
||||
1,33, 32,64, 448,512, &
|
||||
32,64, 1,33, 448,512, &
|
||||
32,64, 32,64, 448,512 /
|
||||
|
||||
CALL MPI_Init ( mpi_err )
|
||||
comm = MPI_COMM_WORLD
|
||||
CALL MPI_Comm_rank ( comm, myproc, mpi_err)
|
||||
CALL MPI_Comm_size ( comm, nprocs, mpi_err)
|
||||
|
||||
DO i = 1, IARGC ()
|
||||
CALL GETARG ( i, arg_str )
|
||||
PRINT *, arg_str
|
||||
IF ( arg_str == "-r" ) THEN
|
||||
PRINT *, "Reading file"
|
||||
opt_read = 1
|
||||
ELSE IF ( arg_str == "-w" ) THEN
|
||||
opt_write = 1
|
||||
ELSE IF ( arg_str == "-g" ) THEN
|
||||
opt_with_ghosts = 1
|
||||
ELSE
|
||||
PRINT *, "Illegal option ", arg_str, "\n"
|
||||
PRINT *, "Usage: H5BlockTestAttributesF -w | -r [-g]"
|
||||
END IF
|
||||
|
||||
END DO
|
||||
|
||||
SELECTCASE ( nprocs )
|
||||
CASE ( 1 )
|
||||
fname = "Fblockfile1.h5"
|
||||
layout = layout1 ( :, myproc+1 )
|
||||
|
||||
CASE ( 8 )
|
||||
IF ( opt_with_ghosts == 1 ) THEN
|
||||
fname = "Fblockfile8G.h5"
|
||||
layout = layout8g ( :, myproc+1 )
|
||||
ELSE
|
||||
fname = "Fblockfile8.h5"
|
||||
layout = layout8 ( :, myproc+1 )
|
||||
END IF
|
||||
|
||||
CASE ( 16 )
|
||||
IF ( opt_with_ghosts == 1 ) THEN
|
||||
fname = "Fblockfile16G.h5"
|
||||
layout = layout16g ( :, myproc+1 )
|
||||
ELSE
|
||||
fname = "Fblockfile16.h5"
|
||||
layout = layout16 ( :, myproc+1 )
|
||||
END IF
|
||||
|
||||
CASE ( 32 )
|
||||
IF ( opt_with_ghosts == 1 ) THEN
|
||||
fname = "Fblockfile32G.h5"
|
||||
layout = layout32g ( :, myproc+1 )
|
||||
ELSE
|
||||
fname = "Fblockfile32.h5"
|
||||
layout = layout32 ( :, myproc+1 )
|
||||
END IF
|
||||
|
||||
CASE DEFAULT
|
||||
print *, "Run this test with 1, 8, 16 or 32 procs!"
|
||||
|
||||
END SELECT
|
||||
|
||||
h5pt_err = h5pt_set_verbosity_level ( 4_8 )
|
||||
|
||||
IF ( opt_write == 1 ) THEN
|
||||
h5pt_err = write_file ( fname, myproc, comm, layout )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
PRINT *, "Faild to write file ", fname, "!"
|
||||
END IF
|
||||
|
||||
ELSE IF ( opt_read == 1 ) THEN
|
||||
h5pt_err = read_file ( fname, myproc, comm, layout )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
PRINT *, "Faild to write file ", fname, "!"
|
||||
END IF
|
||||
|
||||
ENDIF
|
||||
|
||||
CALL MPI_Finalize
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!!
|
||||
CONTAINS
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!!
|
||||
INTEGER*8 FUNCTION write_file ( fname, myproc, comm, layout )
|
||||
IMPLICIT NONE
|
||||
|
||||
CHARACTER(LEN=*), INTENT(IN) :: fname
|
||||
INTEGER, INTENT(IN) :: myproc
|
||||
INTEGER, INTENT(IN) :: comm
|
||||
INTEGER*8, INTENT(IN) :: layout(6)
|
||||
|
||||
INTEGER*8 :: file
|
||||
INTEGER*8 :: timestep = 1
|
||||
|
||||
PRINT "('PROC[',I,']: Open file ',A,' for writing ...')", myproc, fname
|
||||
|
||||
file = h5pt_openw_par ( fname, comm )
|
||||
if ( file == 0 ) THEN
|
||||
write_file = -1
|
||||
RETURN
|
||||
ENDIF
|
||||
PRINT *, "file: ", file
|
||||
|
||||
h5pt_err = h5pt_setstep ( file, timestep )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
write_file = h5pt_err
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
h5pt_err = write_field ( file, myproc, layout )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
write_file = h5pt_err
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
h5pt_err = h5pt_close ( file )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
write_file = h5pt_err
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
write_file = 0
|
||||
END FUNCTION write_file
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!!
|
||||
INTEGER*8 FUNCTION write_field ( file, myproc, layout )
|
||||
IMPLICIT NONE
|
||||
|
||||
INTEGER*8, INTENT(IN) :: file
|
||||
INTEGER, INTENT(IN) :: myproc
|
||||
INTEGER*8, INTENT(IN) :: layout(6)
|
||||
|
||||
INTEGER*8 :: i, j, k
|
||||
INTEGER*8 :: i_start
|
||||
INTEGER*8 :: i_end
|
||||
INTEGER*8 :: j_start
|
||||
INTEGER*8 :: j_end
|
||||
INTEGER*8 :: k_start
|
||||
INTEGER*8 :: k_end
|
||||
INTEGER*8 :: i_dims
|
||||
INTEGER*8 :: j_dims
|
||||
INTEGER*8 :: k_dims
|
||||
REAL*8 :: value
|
||||
|
||||
REAL*8, DIMENSION(:,:,:), ALLOCATABLE :: data
|
||||
|
||||
PRINT *, "Reading field ..."
|
||||
i_start = layout(1)
|
||||
i_end = layout(2)
|
||||
j_start = layout(3)
|
||||
j_end = layout(4)
|
||||
k_start = layout(5)
|
||||
k_end = layout(6)
|
||||
i_dims = i_end - i_start + 1
|
||||
j_dims = j_end - j_start + 1
|
||||
k_dims = k_end - k_start + 1
|
||||
|
||||
PRINT "('dims: (',I2,I2,I2,')')", i_dims, j_dims, k_dims
|
||||
ALLOCATE ( data (i_dims,j_dims, k_dims) )
|
||||
|
||||
PRINT *, "Defining Layout ..."
|
||||
h5pt_err = h5bl_define3dlayout ( file, i_start, i_end, j_start, j_end, k_start, k_end )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
write_field = h5pt_err
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
DO i = 1, i_dims
|
||||
DO j = 1, j_dims
|
||||
DO k = 1, k_dims
|
||||
value = (k-1) + 1000*(j-1) + 100000*(i-1) + 10000000*myproc
|
||||
data(i,j,k) = value
|
||||
END DO
|
||||
END DO
|
||||
END DO
|
||||
|
||||
PRINT *, "Writing field ..."
|
||||
h5pt_err = h5bl_3d_write_scalar_field ( file, "TestField", data )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
write_field = h5pt_err
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
write_field = 0
|
||||
END FUNCTION write_field
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!!
|
||||
INTEGER*8 FUNCTION read_file ( fname, myproc, comm, layout )
|
||||
IMPLICIT NONE
|
||||
|
||||
CHARACTER(LEN=*), INTENT(IN) :: fname
|
||||
INTEGER, INTENT(IN) :: myproc
|
||||
INTEGER, INTENT(IN) :: comm
|
||||
INTEGER*8, INTENT(IN) :: layout(6)
|
||||
|
||||
INTEGER*8 :: file
|
||||
INTEGER*8 :: timestep = 1
|
||||
|
||||
PRINT *, "PROC[",myproc,"]: Open file ",fname," for reading ..."
|
||||
|
||||
file = h5pt_openr_par ( fname, comm )
|
||||
if ( file == 0 ) THEN
|
||||
read_file = -1
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
h5pt_err = h5pt_setstep ( file, timestep )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
read_file = -1
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
h5pt_err = read_field ( file, myproc, layout )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
read_file = -1
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
h5pt_err = h5pt_close ( file )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
read_file = -1
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
read_file = 0
|
||||
END FUNCTION read_file
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!!
|
||||
INTEGER*8 FUNCTION read_field ( file, myproc, layout )
|
||||
IMPLICIT NONE
|
||||
|
||||
INTEGER*8, INTENT(IN) :: file
|
||||
INTEGER, INTENT(IN) :: myproc
|
||||
INTEGER*8, INTENT(IN) :: layout(6)
|
||||
|
||||
INTEGER*8 :: i, j, k
|
||||
INTEGER*8 :: i_start, i_start2
|
||||
INTEGER*8 :: i_end, i_end2
|
||||
INTEGER*8 :: j_start, j_start2
|
||||
INTEGER*8 :: j_end, j_end2
|
||||
INTEGER*8 :: k_start, k_start2
|
||||
INTEGER*8 :: k_end, k_end2
|
||||
INTEGER*8 :: i_dims
|
||||
INTEGER*8 :: j_dims
|
||||
INTEGER*8 :: k_dims
|
||||
INTEGER*8 :: ri, rj, rk, proc
|
||||
REAL*8 :: value
|
||||
|
||||
REAL*8, DIMENSION(:,:,:), ALLOCATABLE :: data
|
||||
|
||||
PRINT *, "Reading field ..."
|
||||
i_start = layout(1)
|
||||
i_end = layout(2)
|
||||
j_start = layout(3)
|
||||
j_end = layout(4)
|
||||
k_start = layout(5)
|
||||
k_end = layout(6)
|
||||
i_dims = i_end - i_start + 1
|
||||
j_dims = j_end - j_start + 1
|
||||
k_dims = k_end - k_start + 1
|
||||
|
||||
PRINT "('dims: (',I3,',',I3,',',I3,')')", i_dims, j_dims, k_dims
|
||||
ALLOCATE ( data (i_dims,j_dims, k_dims) )
|
||||
|
||||
PRINT *, "Defining Layout ..."
|
||||
h5pt_err = h5bl_define3dlayout ( file, i_start, i_end, j_start, j_end, k_start, k_end )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
read_field = -1
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
PRINT *, "Reading field ..."
|
||||
h5pt_err = h5bl_3d_read_scalar_field ( file, "TestField", data )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
read_field = -1
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
DO i = 1, i_dims
|
||||
DO j = 1, j_dims
|
||||
DO k = 1, k_dims
|
||||
ri = i + i_start - 1
|
||||
rj = j + j_start - 1
|
||||
rk = k + k_start - 1
|
||||
|
||||
proc = h5bl_get_proc_of ( file, ri, rj, rk )
|
||||
h5pt_err = h5bl_get_partition_of_proc ( file, proc, i_start2, i_end2, j_start2, j_end2, k_start2, k_end2 )
|
||||
|
||||
ri = ri - i_start2
|
||||
rj = rj - j_start2
|
||||
rk = rk - k_start2
|
||||
|
||||
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 "('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
|
||||
PRINT "('k_start: ', I3, ' k_end: ', I3)", k_start, k_end
|
||||
END IF
|
||||
END DO
|
||||
END DO
|
||||
END DO
|
||||
read_field = 0
|
||||
END FUNCTION read_field
|
||||
|
||||
|
||||
END PROGRAM
|
||||
@@ -1,480 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "H5Part.h"
|
||||
#include "H5Block.h"
|
||||
#ifndef PARALLEL_IO
|
||||
#ifndef MPI_COMM_WORLD
|
||||
#define MPI_COMM_WORLD 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct h5b_partition {
|
||||
h5_int64_t i_start;
|
||||
h5_int64_t i_end;
|
||||
h5_int64_t j_start;
|
||||
h5_int64_t j_end;
|
||||
h5_int64_t k_start;
|
||||
h5_int64_t k_end;
|
||||
};
|
||||
|
||||
typedef struct h5b_partition h5b_partition_t;
|
||||
|
||||
h5b_partition_t Layout1[1] = {
|
||||
{ 0, 63, 0, 63, 0, 511 }
|
||||
};
|
||||
|
||||
#define _calc_index( i, i_dims, j, j_dims, k, k_dims ) \
|
||||
(i + j*i_dims + k*i_dims*j_dims)
|
||||
|
||||
static h5_int64_t
|
||||
_write_data (
|
||||
h5_file_t *f,
|
||||
int myproc,
|
||||
h5b_partition_t *layout
|
||||
) {
|
||||
|
||||
h5_int64_t i, j, k, idx;
|
||||
h5_int64_t herr;
|
||||
h5_float64_t *data;
|
||||
h5_int64_t i_dims = layout->i_end - layout->i_start + 1;
|
||||
h5_int64_t j_dims = layout->j_end - layout->j_start + 1;
|
||||
h5_int64_t k_dims = layout->k_end - layout->k_start + 1;
|
||||
|
||||
//printf ( "Writing Step #%lld\n", (long long)f->step_idx );
|
||||
|
||||
data = malloc ( i_dims * j_dims * k_dims * sizeof ( *data ) );
|
||||
for ( i = 0; i < i_dims; i++ ) {
|
||||
for ( j = 0; j < j_dims; j++ ) {
|
||||
for ( k = 0; k < k_dims; k++ ) {
|
||||
idx = _calc_index (
|
||||
i, i_dims,
|
||||
j, j_dims,
|
||||
k, k_dims );
|
||||
*(data + idx) = k
|
||||
+ 1000*j
|
||||
+ 100000*i
|
||||
+ 10000000*myproc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
herr = H5BlockDefine3DFieldLayout (
|
||||
f,
|
||||
layout->i_start, layout->i_end,
|
||||
layout->j_start, layout->j_end,
|
||||
layout->k_start, layout->k_end );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
herr = H5Block3dWriteScalarFieldFloat64 ( f, "TestField", data );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
free ( data );
|
||||
return 1;
|
||||
}
|
||||
|
||||
static h5_int64_t
|
||||
_write_attributes (
|
||||
h5_file_t *f,
|
||||
const int myproc
|
||||
) {
|
||||
|
||||
h5_int64_t herr = H5BlockWriteFieldAttribString (
|
||||
f,
|
||||
"TestField",
|
||||
"TestString",
|
||||
"42" );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
h5_int64_t ival[1] = { 42 };
|
||||
h5_float64_t rval[1] = { 42.0 };
|
||||
herr = H5BlockWriteFieldAttrib (
|
||||
f,
|
||||
"TestField",
|
||||
"TestInt64",
|
||||
H5_INT64_T,
|
||||
ival, 1 );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
herr = H5BlockWriteFieldAttrib (
|
||||
f,
|
||||
"TestField",
|
||||
"TestFloat64",
|
||||
H5_FLOAT64_T,
|
||||
rval, 1 );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
herr = H5Block3dSetFieldOrigin ( f, "TestField", 1.0, 2.0, 3.0 );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
herr = H5Block3dSetFieldSpacing ( f, "TestField", 2.0, 3.0, 4.0 );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
static h5_int64_t
|
||||
_write_file (
|
||||
const char *fname,
|
||||
const int myproc,
|
||||
MPI_Comm comm,
|
||||
h5b_partition_t *layout
|
||||
) {
|
||||
|
||||
h5_file_t *f;
|
||||
h5_int64_t timestep = 0;
|
||||
h5_int64_t herr;
|
||||
|
||||
printf ("PROC[%d]: Open file \"%s\" for writing ...\n",
|
||||
myproc, fname );
|
||||
|
||||
#ifdef PARALLEL_IO
|
||||
f = H5OpenFile (
|
||||
fname,
|
||||
H5_O_WRONLY,
|
||||
comm
|
||||
);
|
||||
#else
|
||||
f = H5OpenFile (
|
||||
fname,
|
||||
H5_O_WRONLY,
|
||||
0
|
||||
);
|
||||
|
||||
#endif
|
||||
if ( f == NULL ) return -1;
|
||||
|
||||
herr = H5SetStep ( f, timestep );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
if ( _write_data ( f, myproc, layout ) < 0 ) {
|
||||
printf ("Failed to write file \"%s\"\n", fname );
|
||||
return 2;
|
||||
}
|
||||
|
||||
if ( _write_attributes ( f, myproc ) < 0 ) {
|
||||
printf ("Failed to write attributes \"%s\"\n", fname );
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
herr = H5PartCloseFile ( f );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static h5_int64_t
|
||||
_read_data (
|
||||
h5_file_t *f,
|
||||
int myproc,
|
||||
h5b_partition_t *layout
|
||||
) {
|
||||
|
||||
h5_int64_t i, j, k, idx;
|
||||
h5_int64_t herr;
|
||||
h5_float64_t *data;
|
||||
h5_int64_t i_dims = layout->i_end - layout->i_start + 1;
|
||||
h5_int64_t j_dims = layout->j_end - layout->j_start + 1;
|
||||
h5_int64_t k_dims = layout->k_end - layout->k_start + 1;
|
||||
|
||||
//printf ( "Reading Step #%lld\n", (long long)f->step_idx );
|
||||
|
||||
data = malloc ( i_dims * j_dims * k_dims * sizeof ( *data ) );
|
||||
|
||||
herr = H5BlockDefine3DFieldLayout (
|
||||
f,
|
||||
layout->i_start, layout->i_end,
|
||||
layout->j_start, layout->j_end,
|
||||
layout->k_start, layout->k_end );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
herr = H5Block3dReadScalarFieldFloat64 ( f, "TestField", data );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
for ( i = 0; i < i_dims; i++ ) {
|
||||
for ( j = 0; j < j_dims; j++ ) {
|
||||
for ( k = 0; k < k_dims; k++ ) {
|
||||
idx = _calc_index (
|
||||
i, i_dims,
|
||||
j, j_dims,
|
||||
k, k_dims );
|
||||
|
||||
/*
|
||||
what do I need to calculate the value?
|
||||
proc which has the item written
|
||||
i, j, k relative to proc
|
||||
*/
|
||||
|
||||
h5_int64_t ri = i + layout->i_start;
|
||||
h5_int64_t rj = j + layout->j_start;
|
||||
h5_int64_t rk = k + layout->k_start;
|
||||
int proc = (int) H5Block3dGetProcOf ( f, ri, rj, rk );
|
||||
|
||||
h5_size_t i_start, i_end;
|
||||
h5_size_t j_start, j_end;
|
||||
h5_size_t k_start, k_end;
|
||||
|
||||
H5Block3dGetPartitionOfProc (
|
||||
f,
|
||||
proc,
|
||||
&i_start, &i_end,
|
||||
&j_start, &j_end,
|
||||
&k_start, &k_end );
|
||||
ri -= i_start;
|
||||
rj -= j_start;
|
||||
rk -= k_start;
|
||||
h5_float64_t value = rk
|
||||
+ 1000*rj
|
||||
+ 100000*ri
|
||||
+ 10000000*proc;
|
||||
if ( *(data + idx) != value ) {
|
||||
printf (
|
||||
"PROC[%d]: "
|
||||
"value missmatch for (%lld,%lld,%lld); is: %f;"
|
||||
" should be: %f\n",
|
||||
myproc,
|
||||
(long long)i, (long long)j, (long long)k,
|
||||
*( data + idx ), value );
|
||||
printf (
|
||||
"PROC[%d]: "
|
||||
"My partition is: "
|
||||
"%lld:%lld, %lld:%lld, %lld:%lld\n",
|
||||
myproc,
|
||||
(long long)layout->i_start, (long long)layout->i_end,
|
||||
(long long)layout->j_start, (long long)layout->j_end,
|
||||
(long long)layout->k_start, (long long)layout->k_end );
|
||||
printf (
|
||||
"PROC[%d]: "
|
||||
"Value has been written by proc %d\n",
|
||||
myproc, proc );
|
||||
printf (
|
||||
"PROC[%d]: "
|
||||
"The partition for this proc was: "
|
||||
"%lld:%lld, %lld:%lld, %lld:%lld\n",
|
||||
myproc,
|
||||
(long long)i_start, (long long)i_end,
|
||||
(long long)j_start, (long long)j_end,
|
||||
(long long)k_start, (long long)k_end );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free ( data );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static h5_int64_t
|
||||
_read_file (
|
||||
const char *fname,
|
||||
const int myproc,
|
||||
MPI_Comm comm,
|
||||
h5b_partition_t *layout
|
||||
) {
|
||||
|
||||
h5_file_t *f;
|
||||
h5_int64_t timestep = 0;
|
||||
h5_int64_t herr;
|
||||
|
||||
printf ("PROC[%d]: Open file \"%s\" for reading ...\n",
|
||||
myproc, fname );
|
||||
#ifdef PARALLEL_IO
|
||||
f = H5PartOpenFileParallel (
|
||||
fname,
|
||||
H5_O_RDONLY,
|
||||
comm
|
||||
);
|
||||
#else
|
||||
f = H5PartOpenFile (
|
||||
fname,
|
||||
H5_O_RDONLY
|
||||
);
|
||||
#endif
|
||||
if ( f == NULL ) return -1;
|
||||
|
||||
herr = H5PartSetStep ( f, timestep );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
if ( _read_data ( f, myproc, layout ) < 0 ) {
|
||||
printf ("Failed to read file \"%s\"\n", fname );
|
||||
return 2;
|
||||
}
|
||||
|
||||
herr = H5PartCloseFile ( f );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static h5_int64_t
|
||||
_read_attributes (
|
||||
const char *fname,
|
||||
const int myproc,
|
||||
MPI_Comm comm
|
||||
) {
|
||||
h5_int64_t timestep = 0;
|
||||
|
||||
|
||||
printf ("PROC[%d]: Open file \"%s\" for reading ...\n",
|
||||
myproc, fname );
|
||||
|
||||
#ifdef PARALLEL_IO
|
||||
h5_file_t *f = H5PartOpenFileParallel (
|
||||
fname,
|
||||
H5_O_RDONLY,
|
||||
comm
|
||||
);
|
||||
#else
|
||||
h5_file_t *f = H5PartOpenFile (
|
||||
fname,
|
||||
H5_O_RDONLY
|
||||
);
|
||||
#endif
|
||||
if ( f == NULL ) return -1;
|
||||
|
||||
h5_int64_t herr = H5PartSetStep ( f, timestep );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
char sval[16];
|
||||
herr = H5BlockReadFieldAttrib (
|
||||
f,
|
||||
"TestField",
|
||||
"TestString",
|
||||
sval );
|
||||
if ( herr < 0 ) return -1;
|
||||
if ( strcmp ( sval, "42" ) != 0 ) {
|
||||
printf ( "Error reading string attribute: "
|
||||
"Value is \"%s\" and should be \"42\"\n", sval );
|
||||
}
|
||||
|
||||
h5_int64_t ival[1];
|
||||
h5_float64_t rval[1];
|
||||
herr = H5BlockReadFieldAttrib (
|
||||
f,
|
||||
"TestField",
|
||||
"TestInt64",
|
||||
ival );
|
||||
if ( herr < 0 ) return -1;
|
||||
if ( ival[0] != 42 ) {
|
||||
printf ( "Error reading int64 attribute: "
|
||||
"Value is %lld and should be 42\n",
|
||||
(long long) ival[0] );
|
||||
}
|
||||
|
||||
herr = H5BlockReadFieldAttrib (
|
||||
f,
|
||||
"TestField",
|
||||
"TestFloat64",
|
||||
rval );
|
||||
if ( herr < 0 ) return -1;
|
||||
if ( rval[0] != 42.0 ) {
|
||||
printf ( "Error reading float64 attribute: "
|
||||
"Value is %f and should be 42.0\n",
|
||||
rval[0] );
|
||||
}
|
||||
|
||||
h5_float64_t x_origin;
|
||||
h5_float64_t y_origin;
|
||||
h5_float64_t z_origin;
|
||||
h5_float64_t x_spacing;
|
||||
h5_float64_t y_spacing;
|
||||
h5_float64_t z_spacing;
|
||||
|
||||
herr = H5Block3dGetFieldOrigin (
|
||||
f, "TestField",
|
||||
&x_origin,
|
||||
&y_origin,
|
||||
&z_origin );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
if ( x_origin != 1.0 || y_origin != 2.0 || z_origin != 3.0 ) {
|
||||
printf (
|
||||
"Error reading field origin: Read values (%f,%f,%f)\n",
|
||||
x_origin, y_origin, z_origin );
|
||||
}
|
||||
herr = H5Block3dGetFieldSpacing (
|
||||
f, "TestField",
|
||||
&x_spacing,
|
||||
&y_spacing,
|
||||
&z_spacing );
|
||||
if ( herr < 0 ) return -1;
|
||||
if ( x_spacing != 2.0 || y_spacing != 3.0 || z_spacing != 4.0 ) {
|
||||
printf (
|
||||
"Error reading field spacing: Read values (%f,%f,%f)\n",
|
||||
x_spacing, y_spacing, z_spacing );
|
||||
}
|
||||
|
||||
herr = H5PartCloseFile ( f );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char **argv
|
||||
) {
|
||||
char *fname = "blockfile0.h5";
|
||||
int myproc =0;
|
||||
int opt_read = 0;
|
||||
int opt_write = 0;
|
||||
|
||||
int ex = 0;
|
||||
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
#ifdef PARALLEL_IO
|
||||
int nprocs;
|
||||
|
||||
MPI_Init( &argc, &argv );
|
||||
MPI_Comm_size ( comm, &nprocs );
|
||||
MPI_Comm_rank( comm, &myproc );
|
||||
#endif
|
||||
|
||||
while ( --argc ) {
|
||||
if ( strcmp ( argv[argc], "-r" ) == 0 )
|
||||
opt_read = 1;
|
||||
else if ( strcmp ( argv[argc], "-w" ) == 0 )
|
||||
opt_write = 1;
|
||||
else {
|
||||
fprintf ( stderr,
|
||||
"Illegal option %s\n\n"
|
||||
"Usage: %s -w -r\n",
|
||||
argv[argc], argv[0] );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
H5SetVerbosityLevel ( 4 );
|
||||
|
||||
if ( opt_write ) {
|
||||
if ( _write_file ( fname, myproc, comm, Layout1 ) < 0 ) {
|
||||
printf ("Failed to write file \"%s\"\n", fname );
|
||||
ex = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
} else if ( opt_read ) {
|
||||
if ( _read_file ( fname, myproc, comm, Layout1 ) < 0 ) {
|
||||
printf ("Failed to read file \"%s\"\n", fname );
|
||||
ex = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
if ( _read_attributes ( fname, myproc, comm ) < 0 ) {
|
||||
printf ("Failed to read attributes \"%s\"\n", fname );
|
||||
ex = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
#ifdef PARALLEL_IO
|
||||
MPI_Finalize();
|
||||
#endif
|
||||
return ex;
|
||||
}
|
||||
@@ -1,341 +0,0 @@
|
||||
PROGRAM H5BlockTestAttributesF
|
||||
IMPLICIT NONE
|
||||
|
||||
INCLUDE 'H5PartF90.inc'
|
||||
INCLUDE 'H5BlockF90.inc'
|
||||
|
||||
INTEGER :: myproc = 0
|
||||
INTEGER :: nprocs = 1
|
||||
INTEGER*8 :: h5pt_err
|
||||
INTEGER :: i
|
||||
CHARACTER(LEN=32) :: arg_str
|
||||
INTEGER :: opt_read = 0
|
||||
INTEGER :: opt_write = 0
|
||||
INTEGER*8 :: layout(6)
|
||||
DATA layout / 1, 64, 1, 64, 1, 512 /
|
||||
|
||||
DO i = 1, IARGC ()
|
||||
CALL GETARG ( i, arg_str )
|
||||
PRINT *, arg_str
|
||||
IF ( arg_str == "-r" ) THEN
|
||||
PRINT *, "Reading file"
|
||||
opt_read = 1
|
||||
ELSE IF ( arg_str == "-w" ) THEN
|
||||
opt_write = 1
|
||||
ELSE
|
||||
PRINT *, "Illegal option ", arg_str, "\n"
|
||||
PRINT *, "Usage: H5BlockTestAttributesF -w | -r"
|
||||
END IF
|
||||
|
||||
END DO
|
||||
|
||||
h5pt_err = h5pt_set_verbosity_level ( 4_8 )
|
||||
|
||||
IF ( opt_write == 1 ) THEN
|
||||
h5pt_err = write_file ( "blockfile0.h5", myproc, layout )
|
||||
ELSE IF ( opt_read == 1 ) THEN
|
||||
PRINT *, "Calling read_file"
|
||||
h5pt_err = read_file ( "blockfile0.h5", myproc, layout )
|
||||
ENDIF
|
||||
|
||||
|
||||
CONTAINS
|
||||
|
||||
INTEGER*8 FUNCTION write_file ( fname, myproc, layout )
|
||||
CHARACTER(LEN=*), INTENT(IN) :: fname
|
||||
INTEGER, INTENT(IN) :: myproc
|
||||
INTEGER*8, INTENT(IN) :: layout(6)
|
||||
|
||||
INTEGER*8 :: file
|
||||
INTEGER*8 :: timestep = 1
|
||||
|
||||
PRINT *, "PROC[",myproc,"]: Open file ",fname," for writing ..."
|
||||
|
||||
file = h5pt_openw ( fname )
|
||||
if ( file == 0 ) THEN
|
||||
write_file = -1
|
||||
RETURN
|
||||
ENDIF
|
||||
PRINT *, "file: ", file
|
||||
|
||||
h5pt_err = h5pt_setstep ( file, timestep )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
write_file = h5pt_err
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
h5pt_err = write_field ( file, myproc, layout )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
write_file = h5pt_err
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
h5pt_err = write_attributes ( file )
|
||||
|
||||
h5pt_err = h5pt_close ( file )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
write_file = h5pt_err
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
write_file = 0
|
||||
END FUNCTION write_file
|
||||
|
||||
INTEGER*8 FUNCTION write_field ( file, myproc, layout )
|
||||
INTEGER*8, INTENT(IN) :: file
|
||||
INTEGER, INTENT(IN) :: myproc
|
||||
INTEGER*8, INTENT(IN) :: layout(6)
|
||||
|
||||
INTEGER*8 :: i, j, k
|
||||
INTEGER*8 :: i_start
|
||||
INTEGER*8 :: i_end
|
||||
INTEGER*8 :: j_start
|
||||
INTEGER*8 :: j_end
|
||||
INTEGER*8 :: k_start
|
||||
INTEGER*8 :: k_end
|
||||
INTEGER*8 :: i_dims
|
||||
INTEGER*8 :: j_dims
|
||||
INTEGER*8 :: k_dims
|
||||
REAL*8 :: value
|
||||
|
||||
REAL*8, DIMENSION(:,:,:), ALLOCATABLE :: data
|
||||
|
||||
PRINT *, "Reading field ..."
|
||||
i_start = layout(1)
|
||||
i_end = layout(2)
|
||||
j_start = layout(3)
|
||||
j_end = layout(4)
|
||||
k_start = layout(5)
|
||||
k_end = layout(6)
|
||||
i_dims = i_end - i_start + 1
|
||||
j_dims = j_end - j_start + 1
|
||||
k_dims = k_end - k_start + 1
|
||||
|
||||
PRINT *, "dims: (", i_dims, j_dims, k_dims, ")"
|
||||
ALLOCATE ( data (i_dims,j_dims, k_dims) )
|
||||
|
||||
PRINT *, "Defining Layout ..."
|
||||
h5pt_err = h5bl_define3dlayout ( file, i_start, i_end, j_start, j_end, k_start, k_end )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
write_field = h5pt_err
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
DO i = 1, i_dims
|
||||
DO j = 1, j_dims
|
||||
DO k = 1, k_dims
|
||||
value = (k-1) + 1000*(j-1) + 100000*(i-1)
|
||||
data(i,j,k) = value
|
||||
END DO
|
||||
END DO
|
||||
END DO
|
||||
|
||||
PRINT *, "Writing field ..."
|
||||
h5pt_err = h5bl_3d_write_scalar_field ( file, "TestField", data )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
write_field = h5pt_err
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
write_field = 0
|
||||
END FUNCTION write_field
|
||||
|
||||
INTEGER*8 FUNCTION write_attributes ( file )
|
||||
INTEGER*8, INTENT(IN) :: file
|
||||
|
||||
INTEGER*8 :: h5pt_err = 0
|
||||
CHARACTER(LEN=128) :: s_val
|
||||
INTEGER*8 :: i_val(1)
|
||||
REAL*8 :: r_val(1)
|
||||
|
||||
s_val = "42"
|
||||
h5pt_err = h5bl_writefieldattrib_string ( file, "TestField", "TestString", s_val )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
write_attributes = h5pt_err
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
i_val(1) = 42
|
||||
h5pt_err = h5bl_writefieldattrib_i8 ( file, "TestField", "TestInt64", i_val, 1_8 )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
write_attributes = h5pt_err
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
r_val(1) = 42.0
|
||||
h5pt_err = h5bl_writefieldattrib_r8 ( file, "TestField", "TestFloat64", r_val,1_8 )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
write_attributes = h5pt_err
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
END FUNCTION write_attributes
|
||||
|
||||
|
||||
|
||||
INTEGER*8 FUNCTION read_file ( fname, myproc, layout )
|
||||
CHARACTER(LEN=*), INTENT(IN) :: fname
|
||||
INTEGER, INTENT(IN) :: myproc
|
||||
INTEGER*8, INTENT(IN) :: layout(6)
|
||||
|
||||
INTEGER*8 :: file
|
||||
INTEGER*8 :: timestep = 1
|
||||
|
||||
PRINT *, "PROC[",myproc,"]: Open file ",fname," for reading ..."
|
||||
|
||||
file = h5pt_openr ( fname )
|
||||
if ( file == 0 ) THEN
|
||||
read_file = -1
|
||||
RETURN
|
||||
ENDIF
|
||||
PRINT *, "file: ", file
|
||||
|
||||
h5pt_err = h5pt_setstep ( file, timestep )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
read_file = -1
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
h5pt_err = read_field ( file, myproc, layout )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
read_file = -1
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
h5pt_err = h5pt_close ( file )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
read_file = -1
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
PRINT *, "PROC[",myproc,"]: Open file ",fname," for reading ..."
|
||||
|
||||
file = h5pt_openr ( fname )
|
||||
if ( file == 0 ) THEN
|
||||
read_file = -1
|
||||
RETURN
|
||||
ENDIF
|
||||
PRINT *, "file: ", file
|
||||
|
||||
h5pt_err = h5pt_setstep ( file, timestep )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
read_file = -1
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
h5pt_err = read_attributes ( file )
|
||||
|
||||
h5pt_err = h5pt_close ( file )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
read_file = -1
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
|
||||
|
||||
read_file = 0
|
||||
END FUNCTION read_file
|
||||
|
||||
|
||||
INTEGER*8 FUNCTION read_field ( file, myproc, layout )
|
||||
INTEGER*8, INTENT(IN) :: file
|
||||
INTEGER, INTENT(IN) :: myproc
|
||||
INTEGER*8, INTENT(IN) :: layout(6)
|
||||
|
||||
INTEGER*8 :: i, j, k
|
||||
INTEGER*8 :: i_start
|
||||
INTEGER*8 :: i_end
|
||||
INTEGER*8 :: j_start
|
||||
INTEGER*8 :: j_end
|
||||
INTEGER*8 :: k_start
|
||||
INTEGER*8 :: k_end
|
||||
INTEGER*8 :: i_dims
|
||||
INTEGER*8 :: j_dims
|
||||
INTEGER*8 :: k_dims
|
||||
REAL*8 :: value
|
||||
|
||||
REAL*8, DIMENSION(:,:,:), ALLOCATABLE :: data
|
||||
|
||||
PRINT *, "Reading field ..."
|
||||
i_start = layout(1)
|
||||
i_end = layout(2)
|
||||
j_start = layout(3)
|
||||
j_end = layout(4)
|
||||
k_start = layout(5)
|
||||
k_end = layout(6)
|
||||
i_dims = i_end - i_start + 1
|
||||
j_dims = j_end - j_start + 1
|
||||
k_dims = k_end - k_start + 1
|
||||
|
||||
PRINT *, "dims: (", i_dims, j_dims, k_dims, ")"
|
||||
ALLOCATE ( data (i_dims,j_dims, k_dims) )
|
||||
|
||||
PRINT *, "Defining Layout ..."
|
||||
h5pt_err = h5bl_define3dlayout ( file, i_start, i_end, j_start, j_end, k_start, k_end )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
read_field = -1
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
PRINT *, "Reading field ..."
|
||||
h5pt_err = h5bl_3d_read_scalar_field ( file, "TestField", data )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
read_field = -1
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
DO i = 1, i_dims
|
||||
DO j = 1, j_dims
|
||||
DO k = 1, k_dims
|
||||
value = (k-1) + 1000*(j-1) + 100000*(i-1)
|
||||
if ( data(i,j,k) /= value ) THEN
|
||||
PRINT *, "data(",i,",",j,",",k,") = ",data(i,j,k), " /= ",value
|
||||
END IF
|
||||
END DO
|
||||
END DO
|
||||
END DO
|
||||
read_field = 0
|
||||
END FUNCTION read_field
|
||||
|
||||
|
||||
INTEGER*8 FUNCTION read_attributes ( file )
|
||||
INTEGER*8, INTENT(IN) :: file
|
||||
|
||||
INTEGER*8 :: h5pt_err = 0
|
||||
CHARACTER(LEN=128) :: s_val
|
||||
INTEGER*8 :: i_val(1)
|
||||
REAL*8 :: r_val(1)
|
||||
|
||||
h5pt_err = h5bl_readfieldattrib_string ( file, "TestField", "TestString", s_val )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
read_attributes = h5pt_err
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
IF ( s_val /= "42" ) THEN
|
||||
PRINT *, "Error reading string attribute: Value is ", s_val, " and should be 42"
|
||||
END IF
|
||||
|
||||
h5pt_err = h5bl_readfieldattrib_i8 ( file, "TestField", "TestInt64", i_val )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
read_attributes = h5pt_err
|
||||
RETURN
|
||||
END IF
|
||||
IF ( i_val(1) /= 42 ) THEN
|
||||
PRINT *, "Error reading int64 attribute: Value is ", i_val(1), " and should be 42"
|
||||
END IF
|
||||
|
||||
h5pt_err = h5bl_readfieldattrib_r8 ( file, "TestField", "TestFloat64", r_val )
|
||||
IF ( h5pt_err < 0 ) THEN
|
||||
read_attributes = h5pt_err
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
IF ( r_val(1) /= 42.0 ) THEN
|
||||
PRINT *, "Error reading float64 attribute: Value is ", r_val(1), " and should be 42.0"
|
||||
END IF
|
||||
|
||||
|
||||
END FUNCTION read_attributes
|
||||
|
||||
END PROGRAM H5BlockTestAttributesF
|
||||
@@ -1,97 +1,54 @@
|
||||
# test level Makefile.am
|
||||
#
|
||||
# Copyright (c) 2006-2015, 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.!
|
||||
#
|
||||
# License: see file COPYING in top level of source distribution.
|
||||
#
|
||||
|
||||
# PATH SETTING
|
||||
HDF5ROOT = @HDF5ROOT@
|
||||
AM_CPPFLAGS += -I${abs_top_srcdir}/src/include
|
||||
AM_CPPFLAGS += -I${abs_top_srcdir}/examples/include
|
||||
FFLAGS += -cpp $(AM_CPPFLAGS)
|
||||
AM_LDFLAGS += -L${abs_top_builddir}/src/h5core/.libs
|
||||
|
||||
# COMPILER SETTING
|
||||
CXX = @CXX@
|
||||
FC = @FC@
|
||||
MPIFC = @MPIFC@
|
||||
MPICXX = @MPICXX@
|
||||
MPICC = @MPICC@
|
||||
LDADD =
|
||||
|
||||
# COMPILER FLAG SETTING
|
||||
CFLAGS = @CFLAGS@
|
||||
FFLAGS = @FFLAGS@ @MPIINC@
|
||||
if ENABLE_EXAMPLES
|
||||
if ENABLE_FORTRAN
|
||||
LDADD += -lH5hutF
|
||||
AM_LDFLAGS += -L${abs_top_builddir}/src/Fortran/.libs
|
||||
endif
|
||||
|
||||
# LIBRARIES
|
||||
SZLIB = @SZLIB@
|
||||
HDFLIB = -L$(HDF5ROOT)/lib -lhdf5 -lz $(SZLIB) @LDFLAGS@
|
||||
MPILIB = @MPILIB@
|
||||
H5LIB = -L${abs_top_builddir}/src/lib -lH5Core -lH5
|
||||
LDADD += -lH5hut
|
||||
|
||||
LIBS = ${H5LIB} $(HDFLIB) $(MPILIB) -lm @STDCXX@
|
||||
noinst_PROGRAMS =
|
||||
|
||||
# H5Part compiled library location
|
||||
# H5PLIB = -L@prefix@/lib
|
||||
if ENABLE_C
|
||||
noinst_PROGRAMS += \
|
||||
attach_field_attributes \
|
||||
dump_field_attributes \
|
||||
fields \
|
||||
has_field \
|
||||
read_write_scalar_field \
|
||||
write_field
|
||||
endif
|
||||
|
||||
# INCLUDES
|
||||
HDFINC = -I$(HDF5ROOT)/include
|
||||
MPIINC = @MPIINC@
|
||||
H5INC = -I${abs_top_builddir}/src/include
|
||||
if ENABLE_FORTRAN
|
||||
noinst_PROGRAMS += read_write_scalar_fieldf
|
||||
endif
|
||||
|
||||
INC = $(HDFINC) $(MPIINC) $(H5INC)
|
||||
|
||||
# What to build... make install will place these files in the $(prefix)/bin directory.
|
||||
bin_PROGRAMS = @TBTARGET@
|
||||
|
||||
# Some useful scripts that I wish to place in the $(prefix)/bin directory.
|
||||
bin_SCRIPTS =
|
||||
#bin_SCRIPTS = JAC_H5PartTestP_script.scr JAC_H5testFpar_script.scr JAC_RUN_ALL_script.scr
|
||||
|
||||
# Listing of all programs that maybe built. (Has to know statically...)
|
||||
EXTRA_PROGRAMS =
|
||||
|
||||
# Extra files that I wish to include in the dist tar ball.
|
||||
EXTRA_DIST = \
|
||||
H5BlockParTestScalarField.c H5BlockParTestScalarFieldF.f90 \
|
||||
H5BlockTestAttributes.c H5BlockTestAttributesF.f90 \
|
||||
$(bin_SCRIPTS)
|
||||
|
||||
# Specific building instruction (What compilers to use...)
|
||||
# ------------ Build Tests ------------
|
||||
|
||||
###############################################################################
|
||||
|
||||
% : %.o
|
||||
$(CC) -o $@ $< $(H5LIB) $(LIBS)
|
||||
|
||||
%.o : %.c
|
||||
$(CC) $(CFLAGS) $(INC) -g -c $<
|
||||
attach_field_attributes_SOURCES = attach_field_attributes.c
|
||||
dump_field_attributes_SOURCES = dump_field_attributes.c
|
||||
fields_SOURCES = fields.c
|
||||
has_field_SOURCES = has_field.c
|
||||
read_write_scalar_field_SOURCES = read_write_scalar_field.c
|
||||
read_write_scalar_fieldf_SOURCES = read_write_scalar_fieldf.f90
|
||||
write_field_SOURCES = write_field.c
|
||||
endif
|
||||
|
||||
%.o : %.f90
|
||||
${FC} $(FFLAGS) -c $(H5INC) $<
|
||||
|
||||
H5BlockTestAttributes.o: H5BlockTestAttributes.c
|
||||
|
||||
H5BlockTestAttributes: H5BlockTestAttributes.o
|
||||
|
||||
H5BlockTestAttributesF.o: H5BlockTestAttributesF.f90
|
||||
|
||||
H5BlockTestAttributesF: H5BlockTestAttributesF.o
|
||||
$(FC) -o $@ $< $(H5LIB) -lH5PartF -lH5Part $(LIBS)
|
||||
|
||||
H5BlockParTestScalarField.o: H5BlockParTestScalarField.c
|
||||
|
||||
H5BlockParTestScalarField: H5BlockParTestScalarField.o
|
||||
|
||||
H5BlockParTestScalarFieldF.o: H5BlockParTestScalarFieldF.f90
|
||||
|
||||
H5BlockParTestScalarFieldF: H5BlockParTestScalarFieldF.o
|
||||
$(FC) -o $@ $< $(H5LIB) -lH5PartF -lH5Part $(LIBS)
|
||||
|
||||
H5BlockDissolveGhosts.o: H5BlockDissolveGhosts.c
|
||||
|
||||
H5BlockDissolveGhosts: H5BlockDissolveGhosts.o
|
||||
|
||||
|
||||
###############################################################################
|
||||
clean:
|
||||
${RM} -f *~ *.o ${bin_PROGRAMS}
|
||||
|
||||
distclean: clean
|
||||
${RM} -rf .deps
|
||||
${RM} -rf .libs
|
||||
${RM} -f parttest.h5
|
||||
${RM} -rf config.status config.log config.h Makefile
|
||||
$(FC) $(FFLAGS) -c $<
|
||||
|
||||
clean-local:
|
||||
$(RM) *~
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
// name of output file
|
||||
const char* fname = "example_field.h5";
|
||||
|
||||
// H5hut verbosity level
|
||||
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char* argv[]
|
||||
){
|
||||
|
||||
// initialize MPI & H5hut
|
||||
MPI_Init (&argc, &argv);
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (h5_verbosity);
|
||||
//H5SetDebugMask (-1);
|
||||
|
||||
// open file and create first step
|
||||
h5_file_t file = H5OpenFile (fname, H5_O_RDWR, H5_PROP_DEFAULT);
|
||||
H5SetStep (file, 0);
|
||||
|
||||
if (!H5BlockHasField (file, "data")) {
|
||||
printf ("Doesn't have field data with name 'data' in step#0\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
h5_int32_t attrib[1] = { 42 };
|
||||
H5BlockWriteFieldAttribInt32 (
|
||||
file,
|
||||
"data",
|
||||
"The answer",
|
||||
attrib,
|
||||
sizeof (attrib) / sizeof (*attrib));
|
||||
h5_float64_t origin[3] = { 0.0, 0.0, 1.0 };
|
||||
H5Block3dSetFieldOrigin (
|
||||
file,
|
||||
"data",
|
||||
origin[0], origin[1], origin[2]);
|
||||
h5_float64_t spacing[3] = { 1.0, 2.0, 3.0 };
|
||||
H5Block3dSetFieldSpacing (
|
||||
file,
|
||||
"data",
|
||||
spacing[0], spacing[1], spacing[2]);
|
||||
done:
|
||||
// done
|
||||
H5CloseFile(file);
|
||||
MPI_Finalize ();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
/*
|
||||
Copyright (c) 2006-2017, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
// name of output file
|
||||
const char* fname = "example_field.h5";
|
||||
|
||||
// H5hut verbosity level
|
||||
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
|
||||
static inline void
|
||||
dump_int64_attrib (
|
||||
h5_file_t file,
|
||||
const char* const field_name,
|
||||
const char* const attrib_name,
|
||||
h5_size_t attrib_nelems
|
||||
) {
|
||||
h5_int64_t attrib_data[attrib_nelems];
|
||||
H5BlockReadFieldAttribInt64 (
|
||||
file,
|
||||
field_name,
|
||||
attrib_name,
|
||||
attrib_data);
|
||||
printf ("Attribute: '%s'\n", attrib_name);
|
||||
printf (" Type: H5_INT64_T\n");
|
||||
printf (" Data: %" PRId64, attrib_data[0]);
|
||||
for (size_t i = 1; i < attrib_nelems; i++) {
|
||||
printf (", %" PRId64, attrib_data[i]);
|
||||
}
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
static inline void
|
||||
dump_int32_attrib (
|
||||
h5_file_t file,
|
||||
const char* const field_name,
|
||||
const char* const attrib_name,
|
||||
h5_size_t attrib_nelems
|
||||
) {
|
||||
h5_int32_t attrib_data[attrib_nelems];
|
||||
H5BlockReadFieldAttribInt32 (
|
||||
file,
|
||||
field_name,
|
||||
attrib_name,
|
||||
attrib_data);
|
||||
printf ("Attribute: '%s'\n", attrib_name);
|
||||
printf (" Type: H5_INT32_T\n");
|
||||
printf (" Data: %ld", (long)attrib_data[0]);
|
||||
for (size_t i = 1; i < attrib_nelems; i++) {
|
||||
printf (", %ld", (long)attrib_data[i]);
|
||||
}
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
static inline void
|
||||
dump_float64_attrib (
|
||||
h5_file_t file,
|
||||
const char* const field_name,
|
||||
const char* const attrib_name,
|
||||
h5_size_t attrib_nelems
|
||||
) {
|
||||
h5_float64_t attrib_data[attrib_nelems];
|
||||
H5BlockReadFieldAttribFloat64 (
|
||||
file,
|
||||
field_name,
|
||||
attrib_name,
|
||||
attrib_data);
|
||||
printf ("Attribute: '%s'\n", attrib_name);
|
||||
printf (" Type: H5_FLOAT64_T\n");
|
||||
printf (" Data: %2f", attrib_data[0]);
|
||||
for (size_t i = 1; i < attrib_nelems; i++) {
|
||||
printf (", %2f", attrib_data[i]);
|
||||
}
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
static inline void
|
||||
dump_float32_attrib (
|
||||
h5_file_t file,
|
||||
const char* const field_name,
|
||||
const char* const attrib_name,
|
||||
h5_size_t attrib_nelems
|
||||
) {
|
||||
h5_float32_t attrib_data[attrib_nelems];
|
||||
H5BlockReadFieldAttribFloat32 (
|
||||
file,
|
||||
field_name,
|
||||
attrib_name,
|
||||
attrib_data);
|
||||
printf ("Attribute: '%s'\n", attrib_name);
|
||||
printf (" Type: H5_FLOAT32_T\n");
|
||||
printf (" Data: %2f", attrib_data[0]);
|
||||
for (size_t i = 1; i < attrib_nelems; i++) {
|
||||
printf (", %2f", attrib_data[i]);
|
||||
}
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
static inline void
|
||||
dump_string_attrib (
|
||||
h5_file_t file,
|
||||
const char* const field_name,
|
||||
const char* const attrib_name,
|
||||
h5_size_t attrib_nelems
|
||||
) {
|
||||
char attrib_data[attrib_nelems];
|
||||
H5BlockReadFieldAttribString (
|
||||
file,
|
||||
field_name,
|
||||
attrib_name,
|
||||
attrib_data);
|
||||
printf ("Attribute: '%s'\n", attrib_name);
|
||||
printf (" Type: H5_STRING_T\n");
|
||||
printf (" Data: %s", attrib_data);
|
||||
}
|
||||
|
||||
void
|
||||
dump_attrib (
|
||||
h5_file_t file,
|
||||
const char* const field_name,
|
||||
const char* const attrib_name,
|
||||
h5_int64_t attrib_type,
|
||||
h5_size_t attrib_nelems
|
||||
) {
|
||||
if (attrib_type == H5_INT64_T) {
|
||||
dump_int64_attrib (file, field_name, attrib_name, attrib_nelems);
|
||||
} else if (attrib_type == H5_INT32_T) {
|
||||
dump_int32_attrib (file, field_name, attrib_name, attrib_nelems);
|
||||
} else if (attrib_type == H5_FLOAT64_T) {
|
||||
dump_float64_attrib (file, field_name, attrib_name, attrib_nelems);
|
||||
} else if (attrib_type == H5_FLOAT32_T) {
|
||||
dump_float32_attrib (file, field_name, attrib_name, attrib_nelems);
|
||||
} else if (attrib_type == H5_STRING_T) {
|
||||
dump_string_attrib (file, field_name, attrib_name, attrib_nelems);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char* argv[]
|
||||
){
|
||||
|
||||
// initialize MPI & H5hut
|
||||
MPI_Init (&argc, &argv);
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
int comm_size = 1;
|
||||
MPI_Comm_size (comm, &comm_size);
|
||||
int comm_rank = 0;
|
||||
MPI_Comm_rank (comm, &comm_rank);
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (h5_verbosity);
|
||||
//H5SetDebugMask (-1);
|
||||
|
||||
// open file and create first step
|
||||
h5_file_t file = H5OpenFile (fname, H5_O_RDWR, H5_PROP_DEFAULT);
|
||||
H5SetStep (file, 0);
|
||||
|
||||
// test wheter field exists
|
||||
const char field_name[] = "data";
|
||||
if (!H5BlockHasField (file, field_name)) {
|
||||
printf ("Doesn't have field data with name 'data' in step#0\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
// get number of attributes attached to field
|
||||
h5_ssize_t n_attribs = H5BlockGetNumFieldAttribs (
|
||||
file,
|
||||
field_name);
|
||||
printf ("Field has %" PRId64 " attributes attached.\n",
|
||||
n_attribs);
|
||||
|
||||
// dump all attached attributes
|
||||
for (h5_size_t i = 0; i < n_attribs; i++) {
|
||||
char attrib_name[128];
|
||||
h5_size_t sizeof_attrib_name = sizeof (attrib_name);
|
||||
h5_int64_t attrib_type;
|
||||
h5_size_t attrib_nelems;
|
||||
H5BlockGetFieldAttribInfo (
|
||||
file,
|
||||
field_name,
|
||||
i,
|
||||
attrib_name, sizeof_attrib_name,
|
||||
&attrib_type,
|
||||
&attrib_nelems);
|
||||
|
||||
dump_attrib (file,
|
||||
field_name,
|
||||
attrib_name, attrib_type, attrib_nelems);
|
||||
}
|
||||
done:
|
||||
// done
|
||||
H5CloseFile(file);
|
||||
MPI_Finalize ();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
Copyright (c) 2006-2017, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include <H5hut.h>
|
||||
#include "examples.h"
|
||||
|
||||
#define XSIZE 8
|
||||
#define YSIZE 8
|
||||
#define ZSIZE 8
|
||||
#define DATASIZE XSIZE*YSIZE*ZSIZE
|
||||
|
||||
#define VERBOSITY H5_VERBOSE_DEFAULT
|
||||
#define FNAME "example_fields.h5"
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char** argv
|
||||
) {
|
||||
h5_int64_t verbosity = VERBOSITY;
|
||||
|
||||
h5_float64_t ex[DATASIZE];
|
||||
h5_float64_t ey[DATASIZE];
|
||||
h5_float64_t ez[DATASIZE];
|
||||
h5_float64_t q[DATASIZE];
|
||||
|
||||
// initialize MPI & H5hut
|
||||
int comm_rank = 0;
|
||||
int comm_size = 1;
|
||||
MPI_Init (&argc, &argv);
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
MPI_Comm_rank (comm, &comm_rank);
|
||||
MPI_Comm_size (comm, &comm_size);
|
||||
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (verbosity);
|
||||
|
||||
// open file and go to step#0
|
||||
h5_file_t file = H5OpenFile (FNAME, H5_O_RDONLY, H5_PROP_DEFAULT);
|
||||
H5SetStep (file, 0);
|
||||
|
||||
H5Block3dSetView (file,
|
||||
comm_rank*XSIZE, (comm_rank+1)*XSIZE - 1,
|
||||
0, YSIZE - 1,
|
||||
0, ZSIZE - 1);
|
||||
H5Block3dWriteScalarFieldFloat64(file, "Q", q);
|
||||
H5Block3dWriteVector3dFieldFloat64(file, "E", ex, ey, ez);
|
||||
H5CloseFile(file);
|
||||
|
||||
MPI_Finalize();
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
Copyright (c) 2006-2017, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
// name of output file
|
||||
const char* fname = "example_write_field.h5";
|
||||
|
||||
// H5hut verbosity level
|
||||
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char* argv[]
|
||||
){
|
||||
|
||||
// initialize MPI & H5hut
|
||||
MPI_Init (&argc, &argv);
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
int comm_size = 1;
|
||||
MPI_Comm_size (comm, &comm_size);
|
||||
int comm_rank = 0;
|
||||
MPI_Comm_rank (comm, &comm_rank);
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (h5_verbosity);
|
||||
//H5SetDebugMask (-1);
|
||||
|
||||
// open file and create first step
|
||||
h5_file_t file = H5OpenFile (fname, H5_O_RDONLY, H5_PROP_DEFAULT);
|
||||
H5SetStep (file, 0);
|
||||
|
||||
if (!H5BlockHasFieldData (file)) {
|
||||
goto done;
|
||||
}
|
||||
printf ("Has field data in step#0\n");
|
||||
|
||||
if (!H5BlockHasField (file, "data")) {
|
||||
goto done;
|
||||
}
|
||||
printf ("Has field data with name 'data' in step#0\n");
|
||||
|
||||
h5_size_t field_rank;
|
||||
h5_size_t field_dims[3];
|
||||
h5_size_t elem_rank;
|
||||
h5_int64_t type;
|
||||
H5BlockGetFieldInfoByName (
|
||||
file,
|
||||
"data",
|
||||
&field_rank,
|
||||
field_dims,
|
||||
&elem_rank,
|
||||
&type);
|
||||
char* stype = "unknown";
|
||||
if (type == H5_INT64_T) {
|
||||
stype = "H5_INT64_T";
|
||||
} else if (type == H5_INT32_T) {
|
||||
stype = "H5_INT32_T";
|
||||
} else if (type == H5_FLOAT64_T) {
|
||||
stype = "H5_FLOAT64_T";
|
||||
} else if (type == H5_FLOAT32_T) {
|
||||
stype = "H5_FLOAT32_T";
|
||||
} else if (type == H5_STRING_T) {
|
||||
stype = "H5_STRING_T";
|
||||
}
|
||||
printf ("rank of field: %" PRId64 "\n", field_rank);
|
||||
printf ("dims of field: [%" PRId64 ", %" PRId64 ", %" PRId64"]\n",
|
||||
field_dims[0], field_dims[1], field_dims[2]);
|
||||
printf ("rank of field data: %" PRId64 "\n", elem_rank);
|
||||
printf ("type of field data: '%s'\n", stype);
|
||||
done:
|
||||
// done
|
||||
H5CloseFile(file);
|
||||
MPI_Finalize ();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,555 @@
|
||||
/*
|
||||
Copyright (c) 2006-2017, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define NPROCS 8
|
||||
#define DEFAULT_VERBOSITY H5_VERBOSE_DEFAULT
|
||||
|
||||
struct H5BlockPartition {
|
||||
h5_int64_t i_start;
|
||||
h5_int64_t i_end;
|
||||
h5_int64_t j_start;
|
||||
h5_int64_t j_end;
|
||||
h5_int64_t k_start;
|
||||
h5_int64_t k_end;
|
||||
};
|
||||
|
||||
struct H5BlockPartition Layout1[1] = {
|
||||
{ 0, 63, 0, 63, 0, 511 }
|
||||
};
|
||||
|
||||
struct H5BlockPartition Layout8[8] = {
|
||||
{ 0,63, 0,63, 0, 63},
|
||||
{ 0,63, 0,63, 64,127},
|
||||
{ 0,63, 0,63, 128,191},
|
||||
{ 0,63, 0,63, 192,255},
|
||||
{ 0,63, 0,63, 256,319},
|
||||
{ 0,63, 0,63, 320,383},
|
||||
{ 0,63, 0,63, 384,447},
|
||||
{ 0,63, 0,63, 448,511}
|
||||
};
|
||||
|
||||
struct H5BlockPartition Layout8G[8] = {
|
||||
{ 0,63, 0,63, 0, 64},
|
||||
{ 0,63, 0,63, 63,128},
|
||||
{ 0,63, 0,63, 127,192},
|
||||
{ 0,63, 0,63, 191,256},
|
||||
{ 0,63, 0,63, 255,320},
|
||||
{ 0,63, 0,63, 319,384},
|
||||
{ 0,63, 0,63, 383,448},
|
||||
{ 0,63, 0,63, 447,511}
|
||||
};
|
||||
|
||||
struct H5BlockPartition Layout16[16] = {
|
||||
{ 0,63, 0,31, 0, 63},
|
||||
{ 0,63, 32,63, 0, 63},
|
||||
{ 0,63, 0,31, 64,127},
|
||||
{ 0,63, 32,63, 64,127},
|
||||
{ 0,63, 0,31, 128,191},
|
||||
{ 0,63, 32,63, 128,191},
|
||||
{ 0,63, 0,31, 192,255},
|
||||
{ 0,63, 32,63, 192,255},
|
||||
{ 0,63, 0,31, 256,319},
|
||||
{ 0,63, 32,63, 256,319},
|
||||
{ 0,63, 0,31, 320,383},
|
||||
{ 0,63, 32,63, 320,383},
|
||||
{ 0,63, 0,31, 384,447},
|
||||
{ 0,63, 32,63, 384,447},
|
||||
{ 0,63, 0,31, 448,511},
|
||||
{ 0,63, 32,63, 448,511}
|
||||
};
|
||||
|
||||
struct H5BlockPartition Layout16G[16] = {
|
||||
{ 0,63, 0,32, 0, 64},
|
||||
{ 0,63, 31,63, 0, 64},
|
||||
{ 0,63, 0,32, 63,128},
|
||||
{ 0,63, 31,63, 63,128},
|
||||
{ 0,63, 0,32, 127,192},
|
||||
{ 0,63, 31,63, 127,192},
|
||||
{ 0,63, 0,32, 191,256},
|
||||
{ 0,63, 31,63, 191,256},
|
||||
{ 0,63, 0,32, 255,320},
|
||||
{ 0,63, 31,63, 255,320},
|
||||
{ 0,63, 0,32, 319,384},
|
||||
{ 0,63, 31,63, 319,384},
|
||||
{ 0,63, 0,32, 383,448},
|
||||
{ 0,63, 31,63, 383,448},
|
||||
{ 0,63, 0,32, 447,511},
|
||||
{ 0,63, 31,63, 447,511}
|
||||
};
|
||||
|
||||
|
||||
struct H5BlockPartition Layout32[32] = {
|
||||
{ 0,31, 0,31, 0, 63},
|
||||
{ 0,31, 32,63, 0, 63},
|
||||
{ 32,63, 0,31, 0, 63},
|
||||
{ 32,63, 32,63, 0, 63},
|
||||
{ 0,31, 0,31, 64,127},
|
||||
{ 0,31, 32,63, 64,127},
|
||||
{ 32,63, 0,31, 64,127},
|
||||
{ 32,63, 32,63, 64,127},
|
||||
{ 0,31, 0,31, 128,191},
|
||||
{ 0,31, 32,63, 128,191},
|
||||
{ 32,63, 0,31, 128,191},
|
||||
{ 32,63, 32,63, 128,191},
|
||||
{ 0,31, 0,31, 192,255},
|
||||
{ 0,31, 32,63, 192,255},
|
||||
{ 32,63, 0,31, 192,255},
|
||||
{ 32,63, 32,63, 192,255},
|
||||
{ 0,31, 0,31, 256,319},
|
||||
{ 0,31, 32,63, 256,319},
|
||||
{ 32,63, 0,31, 256,319},
|
||||
{ 32,63, 32,63, 256,319},
|
||||
{ 0,31, 0,31, 320,383},
|
||||
{ 0,31, 32,63, 320,383},
|
||||
{ 32,63, 0,31, 320,383},
|
||||
{ 32,63, 32,63, 320,383},
|
||||
{ 0,31, 0,31, 384,447},
|
||||
{ 0,31, 32,63, 384,447},
|
||||
{ 32,63, 0,31, 384,447},
|
||||
{ 32,63, 32,63, 384,447},
|
||||
{ 0,31, 0,31, 448,511},
|
||||
{ 0,31, 32,63, 448,511},
|
||||
{ 32,63, 0,31, 448,511},
|
||||
{ 32,63, 32,63, 448,511}
|
||||
};
|
||||
|
||||
struct H5BlockPartition Layout32G[32] = {
|
||||
{ 0,32, 0,32, 0, 64},
|
||||
{ 0,32, 31,63, 0, 64},
|
||||
{ 31,63, 0,32, 0, 64},
|
||||
{ 31,63, 31,63, 0, 64},
|
||||
{ 0,32, 0,32, 63,128},
|
||||
{ 0,32, 31,63, 63,128},
|
||||
{ 31,63, 0,32, 63,128},
|
||||
{ 31,63, 31,63, 63,128},
|
||||
{ 0,32, 0,32, 127,192},
|
||||
{ 0,32, 31,63, 127,192},
|
||||
{ 31,63, 0,32, 127,192},
|
||||
{ 31,63, 31,63, 127,192},
|
||||
{ 0,32, 0,32, 191,256},
|
||||
{ 0,32, 31,63, 191,256},
|
||||
{ 31,63, 0,32, 191,256},
|
||||
{ 31,63, 31,63, 191,256},
|
||||
{ 0,32, 0,32, 255,320},
|
||||
{ 0,32, 31,63, 255,320},
|
||||
{ 31,63, 0,32, 255,320},
|
||||
{ 31,63, 31,63, 255,320},
|
||||
{ 0,32, 0,32, 319,384},
|
||||
{ 0,32, 31,63, 319,384},
|
||||
{ 31,63, 0,32, 319,384},
|
||||
{ 31,63, 31,63, 319,384},
|
||||
{ 0,31, 0,31, 383,448},
|
||||
{ 0,31, 31,63, 383,448},
|
||||
{ 31,63, 0,31, 383,448},
|
||||
{ 31,63, 31,63, 383,448},
|
||||
{ 0,32, 0,32, 447,511},
|
||||
{ 0,32, 31,63, 447,511},
|
||||
{ 31,63, 0,32, 447,511},
|
||||
{ 31,63, 31,63, 447,511}
|
||||
};
|
||||
|
||||
#define _calc_index( i, i_dims, j, j_dims, k, k_dims ) \
|
||||
(i + j*i_dims + k*i_dims*j_dims)
|
||||
|
||||
static h5_int64_t
|
||||
_write_data (
|
||||
h5_file_t f,
|
||||
int myproc,
|
||||
struct H5BlockPartition* view
|
||||
) {
|
||||
|
||||
h5_int64_t i, j, k, idx;
|
||||
h5_int64_t herr;
|
||||
h5_float64_t *data;
|
||||
h5_int64_t i_dims = view->i_end - view->i_start + 1;
|
||||
h5_int64_t j_dims = view->j_end - view->j_start + 1;
|
||||
h5_int64_t k_dims = view->k_end - view->k_start + 1;
|
||||
|
||||
printf ( "Writing scalar field data to step #%lld\n", (long long)H5GetStep (f));
|
||||
|
||||
data = (h5_float64_t*)malloc ( i_dims * j_dims * k_dims * sizeof (h5_float64_t) );
|
||||
for ( i = 0; i < i_dims; i++ ) {
|
||||
for ( j = 0; j < j_dims; j++ ) {
|
||||
for ( k = 0; k < k_dims; k++ ) {
|
||||
idx = _calc_index (
|
||||
i, i_dims,
|
||||
j, j_dims,
|
||||
k, k_dims );
|
||||
*(data + idx) = k
|
||||
+ 1000*j
|
||||
+ 100000*i
|
||||
+ 10000000*myproc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
herr = H5Block3dSetView (
|
||||
f,
|
||||
view->i_start, view->i_end,
|
||||
view->j_start, view->j_end,
|
||||
view->k_start, view->k_end );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
herr = H5Block3dWriteScalarFieldFloat64 ( f, "TestField", data );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
free ( data );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static h5_int64_t
|
||||
_write_attributes (
|
||||
h5_file_t f,
|
||||
const int myproc
|
||||
) {
|
||||
printf ("Writing attributes to field '%s' in step #%lld\n",
|
||||
"TestField", (long long)H5GetStep (f));
|
||||
h5_int64_t herr = H5BlockWriteFieldAttribString (
|
||||
f,
|
||||
"TestField",
|
||||
"TestString",
|
||||
"42" );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
h5_int32_t i4_val[1] = { 42 };
|
||||
herr = H5BlockWriteFieldAttribInt32 (
|
||||
f,
|
||||
"TestField",
|
||||
"TestInt32",
|
||||
i4_val, 1 );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
h5_int64_t i8_val[1] = { 42 };
|
||||
herr = H5BlockWriteFieldAttribInt64 (
|
||||
f,
|
||||
"TestField",
|
||||
"TestInt64",
|
||||
i8_val, 1 );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
h5_float32_t r4_val[1] = { 42.0 };
|
||||
herr = H5BlockWriteFieldAttribFloat32 (
|
||||
f,
|
||||
"TestField",
|
||||
"TestFloat32",
|
||||
r4_val, 1 );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
h5_float64_t r8_val[1] = { 42.0 };
|
||||
herr = H5BlockWriteFieldAttribFloat64 (
|
||||
f,
|
||||
"TestField",
|
||||
"TestFloat64",
|
||||
r8_val, 1 );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
herr = H5Block3dSetFieldOrigin ( f, "TestField", 1.0, 2.0, 3.0 );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
herr = H5Block3dSetFieldSpacing ( f, "TestField", 2.0, 3.0, 4.0 );
|
||||
if ( herr < 0 ) return -1;
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
static h5_int64_t
|
||||
_write_file (
|
||||
const char *fname,
|
||||
const int myproc,
|
||||
MPI_Comm comm,
|
||||
struct H5BlockPartition *layout
|
||||
) {
|
||||
printf ("PROC[%d]: Open file \"%s\" for writing ...\n",
|
||||
myproc, fname );
|
||||
h5_file_t file = H5OpenFile (fname, H5_O_WRONLY, H5_PROP_DEFAULT);
|
||||
H5SetStep (file, 0);
|
||||
|
||||
_write_data (file, myproc, layout);
|
||||
_write_attributes (file, myproc);
|
||||
|
||||
H5CloseFile (file);
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
static h5_int64_t
|
||||
_read_data (
|
||||
h5_file_t f,
|
||||
int myproc,
|
||||
struct H5BlockPartition *layout
|
||||
) {
|
||||
|
||||
h5_int64_t i, j, k, idx;
|
||||
h5_float64_t *data;
|
||||
h5_int64_t i_dims = layout->i_end - layout->i_start + 1;
|
||||
h5_int64_t j_dims = layout->j_end - layout->j_start + 1;
|
||||
h5_int64_t k_dims = layout->k_end - layout->k_start + 1;
|
||||
|
||||
printf ("Reading Step #%lld\n", (long long)H5GetStep (f));
|
||||
|
||||
data = (h5_float64_t*)malloc (i_dims * j_dims * k_dims * sizeof (*data));
|
||||
|
||||
H5Block3dSetView (
|
||||
f,
|
||||
layout->i_start, layout->i_end,
|
||||
layout->j_start, layout->j_end,
|
||||
layout->k_start, layout->k_end );
|
||||
H5Block3dReadScalarFieldFloat64 ( f, "TestField", data );
|
||||
|
||||
for (i = 0; i < i_dims; i++) {
|
||||
for (j = 0; j < j_dims; j++) {
|
||||
for (k = 0; k < k_dims; k++) {
|
||||
idx = _calc_index (
|
||||
i, i_dims,
|
||||
j, j_dims,
|
||||
k, k_dims );
|
||||
|
||||
h5_float64_t value = k
|
||||
+ 1000 * j
|
||||
+ 100000 * i
|
||||
+ 10000000 * myproc;
|
||||
if (*(data + idx) != value) {
|
||||
printf (
|
||||
"PROC[%d]: "
|
||||
"value missmatch for (%lld,%lld,%lld); is: %f;"
|
||||
" should be: %f\n",
|
||||
myproc,
|
||||
(long long)i, (long long)j, (long long)k,
|
||||
*( data + idx ), value );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free (data);
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
static h5_int64_t
|
||||
_read_attributes (
|
||||
h5_file_t f,
|
||||
const int myproc,
|
||||
MPI_Comm comm
|
||||
) {
|
||||
h5_int64_t timestep = 0;
|
||||
|
||||
H5SetStep (f, timestep);
|
||||
|
||||
char sval[16];
|
||||
H5BlockReadFieldAttribString (
|
||||
f,
|
||||
"TestField",
|
||||
"TestString",
|
||||
sval );
|
||||
if (strcmp (sval, "42") != 0) {
|
||||
printf ("Error reading string attribute: "
|
||||
"Value is \"%s\" and should be \"42\"\n", sval);
|
||||
}
|
||||
|
||||
h5_int32_t i4_val[1];
|
||||
H5BlockReadFieldAttribInt32 (
|
||||
f,
|
||||
"TestField",
|
||||
"TestInt32",
|
||||
i4_val );
|
||||
if (i4_val[0] != 42) {
|
||||
printf ("Error reading int32 attribute: "
|
||||
"Value is %lld and should be 42\n",
|
||||
(long long) i4_val[0]);
|
||||
}
|
||||
|
||||
h5_int64_t i8_val[1];
|
||||
H5BlockReadFieldAttribInt64 (
|
||||
f,
|
||||
"TestField",
|
||||
"TestInt64",
|
||||
i8_val );
|
||||
if (i8_val[0] != 42) {
|
||||
printf ("Error reading int64 attribute: "
|
||||
"Value is %lld and should be 42\n",
|
||||
(long long) i8_val[0]);
|
||||
}
|
||||
|
||||
h5_float32_t r4_val[1];
|
||||
H5BlockReadFieldAttribFloat32 (
|
||||
f,
|
||||
"TestField",
|
||||
"TestFloat32",
|
||||
r4_val );
|
||||
if (r4_val[0] != 42.0) {
|
||||
printf ("Error reading float64 attribute: "
|
||||
"Value is %f and should be 42.0\n",
|
||||
r4_val[0]);
|
||||
}
|
||||
|
||||
h5_float64_t r8_val[1];
|
||||
H5BlockReadFieldAttribFloat64 (
|
||||
f,
|
||||
"TestField",
|
||||
"TestFloat64",
|
||||
r8_val );
|
||||
if (r8_val[0] != 42.0) {
|
||||
printf ("Error reading float64 attribute: "
|
||||
"Value is %f and should be 42.0\n",
|
||||
r8_val[0]);
|
||||
}
|
||||
|
||||
h5_float64_t x_origin;
|
||||
h5_float64_t y_origin;
|
||||
h5_float64_t z_origin;
|
||||
h5_float64_t x_spacing;
|
||||
h5_float64_t y_spacing;
|
||||
h5_float64_t z_spacing;
|
||||
|
||||
H5Block3dGetFieldOrigin (
|
||||
f, "TestField",
|
||||
&x_origin,
|
||||
&y_origin,
|
||||
&z_origin );
|
||||
|
||||
if (x_origin != 1.0 || y_origin != 2.0 || z_origin != 3.0) {
|
||||
printf (
|
||||
"Error reading field origin: Read values (%f,%f,%f)\n",
|
||||
x_origin, y_origin, z_origin);
|
||||
}
|
||||
H5Block3dGetFieldSpacing (
|
||||
f, "TestField",
|
||||
&x_spacing,
|
||||
&y_spacing,
|
||||
&z_spacing );
|
||||
if (x_spacing != 2.0 || y_spacing != 3.0 || z_spacing != 4.0) {
|
||||
printf (
|
||||
"Error reading field spacing: Read values (%f,%f,%f)\n",
|
||||
x_spacing, y_spacing, z_spacing);
|
||||
}
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
static h5_int64_t
|
||||
_read_file (
|
||||
const char *fname,
|
||||
const int myproc,
|
||||
MPI_Comm comm,
|
||||
struct H5BlockPartition *layout
|
||||
) {
|
||||
printf ("PROC[%d]: Open file \"%s\" for reading ...\n",
|
||||
myproc, fname );
|
||||
|
||||
h5_file_t file = H5OpenFile (fname, H5_O_RDONLY, H5_PROP_DEFAULT);
|
||||
H5SetStep (file, 0);
|
||||
|
||||
_read_data (file, myproc, layout);
|
||||
_read_attributes (file, myproc, comm);
|
||||
|
||||
H5CloseFile (file);
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char **argv
|
||||
) {
|
||||
h5_int64_t verbosity = DEFAULT_VERBOSITY;
|
||||
char *fname;
|
||||
int opt_with_ghosts = 0;
|
||||
int opt_read = 0;
|
||||
int opt_write = 0;
|
||||
struct H5BlockPartition *layout;
|
||||
|
||||
if (argc == 1) {
|
||||
fprintf ( stderr,
|
||||
"Usage: %s -w|-r [-g]\n",
|
||||
argv[0] );
|
||||
return 1;
|
||||
}
|
||||
while (--argc) {
|
||||
if (strcmp (argv[argc], "-r") == 0)
|
||||
opt_read = 1;
|
||||
else if (strcmp (argv[argc], "-w") == 0)
|
||||
opt_write = 1;
|
||||
else if (strcmp (argv[argc], "-g") == 0)
|
||||
opt_with_ghosts = 1;
|
||||
else {
|
||||
fprintf (stderr,
|
||||
"Illegal option %s\n\n"
|
||||
"Usage: %s -w -r -g\n",
|
||||
argv[argc], argv[0]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// initialize MPI & H5hut
|
||||
int comm_rank = 0;
|
||||
int comm_size = 1;
|
||||
MPI_Init (&argc, &argv);
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
MPI_Comm_rank (comm, &comm_rank);
|
||||
MPI_Comm_size (comm, &comm_size);
|
||||
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (verbosity);
|
||||
|
||||
switch (comm_size) {
|
||||
case 1:
|
||||
fname = "blockfile1.h5";
|
||||
layout = &Layout1[comm_rank];
|
||||
break;
|
||||
case 8:
|
||||
if (opt_with_ghosts) {
|
||||
fname = "blockfile8G.h5";
|
||||
layout = &Layout8G[comm_rank];
|
||||
} else {
|
||||
fname = "blockfile8.h5";
|
||||
layout = &Layout8[comm_rank];
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
if (opt_with_ghosts) {
|
||||
fname = "blockfile16G.h5";
|
||||
layout = &Layout16G[comm_rank];
|
||||
} else {
|
||||
fname = "blockfile16.h5";
|
||||
layout = &Layout16[comm_rank];
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
if (opt_with_ghosts) {
|
||||
fname = "blockfile32G.h5";
|
||||
layout = &Layout32G[comm_rank];
|
||||
} else {
|
||||
fname = "blockfile32.h5";
|
||||
layout = &Layout32[comm_rank];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf ( "Run this test on %d, %d, %d or %d processor(s)!\n",
|
||||
1, 8, 16, 32);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (opt_write) {
|
||||
_write_file (fname, comm_rank, comm, layout);
|
||||
} else if (opt_read) {
|
||||
_read_file (fname, comm_rank, comm, layout);
|
||||
}
|
||||
|
||||
MPI_Finalize();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,513 @@
|
||||
!
|
||||
! Copyright (c) 2006-2015, 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.!
|
||||
!
|
||||
! License: see file COPYING in top level of source distribution.
|
||||
!
|
||||
include 'H5hut.f90'
|
||||
|
||||
program read_write_scalar_field
|
||||
use H5hut
|
||||
implicit none
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
include 'mpif.h'
|
||||
|
||||
integer :: comm = 0
|
||||
integer :: mpi_err
|
||||
#endif
|
||||
|
||||
integer :: nargs = 0
|
||||
integer :: comm_rank = 0
|
||||
integer :: comm_size = 1
|
||||
integer*8 :: h5_err
|
||||
integer :: i
|
||||
character(len=32) :: arg_str
|
||||
integer :: opt_read = 0
|
||||
integer :: opt_write = 0
|
||||
integer :: opt_with_ghosts = 0
|
||||
character(len=128) :: fname
|
||||
integer*8 :: layout (6)
|
||||
integer*8 :: layout1 (6,1)
|
||||
integer*8 :: layout8 (6,8)
|
||||
integer*8 :: layout8g (6,8)
|
||||
integer*8 :: layout16 (6,16)
|
||||
integer*8 :: layout16g(6,16)
|
||||
integer*8 :: layout32 (6,32)
|
||||
integer*8 :: layout32g(6,32)
|
||||
|
||||
data layout1 / 1,64, 1,64, 1,512 /
|
||||
|
||||
data layout8 / 1,64, 1,64, 1, 64, &
|
||||
1,64, 1,64, 65,128, &
|
||||
1,64, 1,64, 129,192, &
|
||||
1,64, 1,64, 193,256, &
|
||||
1,64, 1,64, 257,320, &
|
||||
1,64, 1,64, 321,384, &
|
||||
1,64, 1,64, 385,448, &
|
||||
1,64, 1,64, 449,512 /
|
||||
|
||||
data layout8g / 1,64, 1,64, 1, 65, &
|
||||
1,64, 1,64, 64,129, &
|
||||
1,64, 1,64, 128,193, &
|
||||
1,64, 1,64, 192,257, &
|
||||
1,64, 1,64, 256,321, &
|
||||
1,64, 1,64, 320,385, &
|
||||
1,64, 1,64, 384,449, &
|
||||
1,64, 1,64, 448,512 /
|
||||
|
||||
data layout16 / 1,64, 1,32, 1, 64, &
|
||||
1,64, 33,64, 1, 64, &
|
||||
1,64, 1,32, 65,128, &
|
||||
1,64, 33,64, 65,128, &
|
||||
1,64, 1,32, 129,192, &
|
||||
1,64, 33,64, 129,192, &
|
||||
1,64, 1,32, 193,256, &
|
||||
1,64, 33,64, 193,256, &
|
||||
1,64, 1,32, 257,320, &
|
||||
1,64, 33,64, 257,320, &
|
||||
1,64, 1,32, 321,384, &
|
||||
1,64, 33,64, 321,384, &
|
||||
1,64, 1,32, 385,448, &
|
||||
1,64, 33,64, 385,448, &
|
||||
1,64, 1,32, 449,512, &
|
||||
1,64, 33,64, 449,512 /
|
||||
|
||||
data layout16g/ 1,64, 1,33, 1, 65, &
|
||||
1,64, 32,64, 1, 65, &
|
||||
1,64, 1,33, 64,129, &
|
||||
1,64, 32,64, 64,129, &
|
||||
1,64, 1,33, 128,193, &
|
||||
1,64, 32,64, 128,193, &
|
||||
1,64, 1,33, 192,257, &
|
||||
1,64, 32,64, 192,257, &
|
||||
1,64, 1,33, 256,321, &
|
||||
1,64, 32,64, 256,321, &
|
||||
1,64, 1,33, 320,385, &
|
||||
1,64, 32,64, 320,385, &
|
||||
1,64, 1,33, 384,449, &
|
||||
1,64, 32,64, 384,449, &
|
||||
1,64, 1,33, 448,512, &
|
||||
1,64, 32,64, 448,512 /
|
||||
|
||||
data layout32 / 1,32, 1,32, 1, 64, &
|
||||
1,32, 33,64, 1, 64, &
|
||||
33,64, 1,32, 1, 64, &
|
||||
33,64, 33,64, 1, 64, &
|
||||
1,32, 1,32, 65,128, &
|
||||
1,32, 33,64, 65,128, &
|
||||
33,64, 1,32, 65,128, &
|
||||
33,64, 33,64, 65,128, &
|
||||
1,32, 1,32, 129,192, &
|
||||
1,32, 33,64, 129,192, &
|
||||
33,64, 1,32, 129,192, &
|
||||
33,64, 33,64, 129,192, &
|
||||
1,32, 1,32, 193,256, &
|
||||
1,32, 33,64, 193,256, &
|
||||
33,64, 1,32, 193,256, &
|
||||
33,64, 33,64, 193,256, &
|
||||
1,32, 1,32, 257,320, &
|
||||
1,32, 33,64, 257,320, &
|
||||
33,64, 1,32, 257,320, &
|
||||
33,64, 33,64, 257,320, &
|
||||
1,32, 1,32, 321,384, &
|
||||
1,32, 33,64, 321,384, &
|
||||
33,64, 1,32, 321,384, &
|
||||
33,64, 33,64, 321,384, &
|
||||
1,32, 1,32, 385,448, &
|
||||
1,32, 33,64, 385,448, &
|
||||
33,64, 1,32, 385,448, &
|
||||
33,64, 33,64, 385,448, &
|
||||
1,32, 1,32, 449,512, &
|
||||
1,32, 33,64, 449,512, &
|
||||
33,64, 1,32, 449,512, &
|
||||
33,64, 33,64, 449,512 /
|
||||
|
||||
data layout32g/ 1,33, 1,33, 1, 65, &
|
||||
1,33, 32,64, 1, 65, &
|
||||
32,64, 1,33, 1, 65, &
|
||||
32,64, 32,64, 1, 65, &
|
||||
1,33, 1,33, 64,129, &
|
||||
1,33, 32,64, 64,129, &
|
||||
32,64, 1,33, 64,129, &
|
||||
32,64, 32,64, 64,129, &
|
||||
1,33, 1,33, 128,193, &
|
||||
1,33, 32,64, 128,193, &
|
||||
32,64, 1,33, 128,193, &
|
||||
32,64, 32,64, 128,193, &
|
||||
1,33, 1,33, 192,257, &
|
||||
1,33, 32,64, 192,257, &
|
||||
32,64, 1,33, 192,257, &
|
||||
32,64, 32,64, 192,257, &
|
||||
1,33, 1,33, 256,321, &
|
||||
1,33, 32,64, 256,321, &
|
||||
32,64, 1,33, 256,321, &
|
||||
32,64, 32,64, 256,321, &
|
||||
1,33, 1,33, 320,385, &
|
||||
1,33, 32,64, 320,385, &
|
||||
32,64, 1,33, 320,385, &
|
||||
32,64, 32,64, 320,385, &
|
||||
1,33, 1,33, 384,449, &
|
||||
1,33, 32,64, 384,449, &
|
||||
32,64, 1,33, 384,449, &
|
||||
32,64, 32,64, 384,449, &
|
||||
1,33, 1,33, 448,512, &
|
||||
1,33, 32,64, 448,512, &
|
||||
32,64, 1,33, 448,512, &
|
||||
32,64, 32,64, 448,512 /
|
||||
nargs = iargc ()
|
||||
if (nargs == 0) then
|
||||
print *, "usage: read_write_scalarfield -w | -r [-g]"
|
||||
call exit (1)
|
||||
end if
|
||||
do i = 1, nargs
|
||||
call getarg (i, arg_str)
|
||||
if (arg_str == "-r") then
|
||||
opt_read = 1
|
||||
else if (arg_str == "-w") then
|
||||
opt_write = 1
|
||||
else if (arg_str == "-g") then
|
||||
opt_with_ghosts = 1
|
||||
else
|
||||
print *, "Illegal option ", arg_str, "\n"
|
||||
print *, "Usage: read_write_scalarfield -w | -r [-g]"
|
||||
call exit (1)
|
||||
end if
|
||||
end do
|
||||
|
||||
! init MPI & H5hut
|
||||
#if defined(PARALLEL_IO)
|
||||
comm = MPI_COMM_WORLD
|
||||
call mpi_init(mpi_err)
|
||||
call mpi_comm_rank(comm, comm_rank, mpi_err)
|
||||
call mpi_comm_size (comm, comm_size, mpi_err)
|
||||
#else
|
||||
comm_size = 1
|
||||
comm_rank = 0
|
||||
#endif
|
||||
call h5_abort_on_error ()
|
||||
call h5_set_verbosity_level (511_8)
|
||||
|
||||
selectcase (comm_size)
|
||||
case (1)
|
||||
fname = "blockfile1.h5"
|
||||
layout = layout1 (:, comm_rank+1)
|
||||
|
||||
case (8)
|
||||
if (opt_with_ghosts == 1) then
|
||||
fname = "blockfile8g.h5"
|
||||
layout = layout8g (:, comm_rank+1)
|
||||
else
|
||||
fname = "blockfile8.h5"
|
||||
layout = layout8 (:, comm_rank+1)
|
||||
end if
|
||||
|
||||
case (16)
|
||||
if (opt_with_ghosts == 1) then
|
||||
fname = "blockfile16g.h5"
|
||||
layout = layout16g (:, comm_rank+1)
|
||||
else
|
||||
fname = "blockfile16.h5"
|
||||
layout = layout16 (:, comm_rank+1)
|
||||
end if
|
||||
|
||||
case (32)
|
||||
if (opt_with_ghosts == 1) then
|
||||
fname = "blockfile32g.h5"
|
||||
layout = layout32g (:, comm_rank+1)
|
||||
else
|
||||
fname = "blockfile32.h5"
|
||||
layout = layout32 (:, comm_rank+1)
|
||||
end if
|
||||
|
||||
case default
|
||||
print *, "Run this test on 1, 8, 16 or 32 cores!"
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_finalize
|
||||
#endif
|
||||
call exit (1)
|
||||
end select
|
||||
|
||||
if (opt_write == 1) then
|
||||
h5_err = write_file (fname, comm_rank, layout)
|
||||
if (h5_err < 0) then
|
||||
print "('[proc ', I3, ']: Faild to write file ', A, '!')", comm_rank, fname
|
||||
end if
|
||||
|
||||
else if (opt_read == 1) then
|
||||
h5_err = read_file (fname, comm_rank, layout)
|
||||
if (h5_err < 0) then
|
||||
print "('[proc ', I3, ']: Faild to read file ', A, '!')", comm_rank, fname
|
||||
end if
|
||||
|
||||
endif
|
||||
print "('[proc ', I3, ']: Cleanup.')", comm_rank
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_finalize
|
||||
#endif
|
||||
print "('[proc ', I3, ']: Done.')", comm_rank
|
||||
call exit (0)
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!!
|
||||
contains
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!!
|
||||
integer*8 function write_file (fname, comm_rank, layout)
|
||||
use H5hut
|
||||
implicit none
|
||||
|
||||
character(len=*), intent(in) :: fname
|
||||
integer, intent(in) :: comm_rank
|
||||
integer*8, intent(in) :: layout(6)
|
||||
|
||||
integer*8 :: file
|
||||
integer*8 :: timestep = 1
|
||||
|
||||
print "('[proc ', I3, ']: Open file for writing ...')", comm_rank
|
||||
file = h5_openfile (fname, H5_O_WRONLY, H5_PROP_DEFAULT)
|
||||
h5_err = h5_setstep (file, timestep)
|
||||
h5_err = write_field (file, comm_rank, layout)
|
||||
h5_err = write_attributes (file)
|
||||
h5_err = h5_closefile (file)
|
||||
|
||||
write_file = H5_SUCCESS
|
||||
end function write_file
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!!
|
||||
integer*8 function write_field (file, comm_rank, layout)
|
||||
use H5hut
|
||||
implicit none
|
||||
|
||||
integer*8, intent(in) :: file
|
||||
integer, intent(in) :: comm_rank
|
||||
integer*8, intent(in) :: layout(6)
|
||||
|
||||
integer*8 :: i, j, k
|
||||
integer*8 :: i_start
|
||||
integer*8 :: i_end
|
||||
integer*8 :: j_start
|
||||
integer*8 :: j_end
|
||||
integer*8 :: k_start
|
||||
integer*8 :: k_end
|
||||
integer*8 :: i_dims
|
||||
integer*8 :: j_dims
|
||||
integer*8 :: k_dims
|
||||
real*8 :: value
|
||||
|
||||
real*8, dimension(:,:,:), allocatable :: data
|
||||
|
||||
i_start = layout(1)
|
||||
i_end = layout(2)
|
||||
j_start = layout(3)
|
||||
j_end = layout(4)
|
||||
k_start = layout(5)
|
||||
k_end = layout(6)
|
||||
i_dims = i_end - i_start + 1
|
||||
j_dims = j_end - j_start + 1
|
||||
k_dims = k_end - k_start + 1
|
||||
|
||||
allocate ( data (i_dims,j_dims, k_dims) )
|
||||
|
||||
print "('[proc ', I3, ']: Defining layout for writing ...')", comm_rank
|
||||
print "('[proc ', I3, ']: ', I3, ':', I3, ', ', I3, ':', I3,', ', I3, ':', I3)", &
|
||||
comm_rank, &
|
||||
i_start, i_end, &
|
||||
j_start, j_end, &
|
||||
k_start, k_end
|
||||
|
||||
h5_err = h5bl_3d_setview (file, i_start, i_end, j_start, j_end, k_start, k_end)
|
||||
|
||||
do i = 1, i_dims
|
||||
do j = 1, j_dims
|
||||
do k = 1, k_dims
|
||||
value = (k-1) + 1000*(j-1) + 100000*(i-1) + 10000000*comm_rank
|
||||
data(i,j,k) = value
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
|
||||
print "('[proc ', I3, ']: Writing field ...')", comm_rank
|
||||
h5_err = h5bl_3d_write_scalar_field_r8 ( file, "TestField", data )
|
||||
|
||||
write_field = 0
|
||||
END FUNCTION write_field
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!!
|
||||
integer*8 function write_attributes (file)
|
||||
use H5hut
|
||||
implicit none
|
||||
integer*8, intent(in) :: file
|
||||
integer*8 :: h5_err = 0
|
||||
character(len=128) :: s_val
|
||||
integer*8 :: i8_val(1)
|
||||
integer*4 :: i4_val(1)
|
||||
real*8 :: r8_val(1)
|
||||
real*4 :: r4_val(1)
|
||||
|
||||
print "('[proc ', I3, ']: Writing string attribute ...')", comm_rank
|
||||
s_val = "42"
|
||||
h5_err = h5bl_writefieldattrib_string ( file, "TestField", "TestString", s_val )
|
||||
|
||||
print "('[proc ', I3, ']: Writing int64 attribute ...')", comm_rank
|
||||
i8_val(1) = 42
|
||||
h5_err = h5bl_writefieldattrib_i8 ( file, "TestField", "TestInt64", i8_val, 1_8 )
|
||||
|
||||
print "('[proc ', I3, ']: Writing int32 attribute ...')", comm_rank
|
||||
i4_val(1) = 42
|
||||
h5_err = h5bl_writefieldattrib_i4 ( file, "TestField", "TestInt32", i4_val, 1_8 )
|
||||
|
||||
print "('[proc ', I3, ']: Writing float64 attribute ...')", comm_rank
|
||||
r8_val(1) = 42.0
|
||||
h5_err = h5bl_writefieldattrib_r8 ( file, "TestField", "TestFloat64", r8_val, 1_8 )
|
||||
|
||||
print "('[proc ', I3, ']: Writing float32 attribute ...')", comm_rank
|
||||
r4_val(1) = 42.0
|
||||
h5_err = h5bl_writefieldattrib_r4 ( file, "TestField", "TestFloat32", r4_val, 1_8 )
|
||||
|
||||
write_attributes = 0
|
||||
end function write_attributes
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!!
|
||||
integer*8 function read_file (fname, comm_rank, layout)
|
||||
use H5hut
|
||||
implicit none
|
||||
|
||||
character(len=*), intent(in) :: fname
|
||||
integer, intent(in) :: comm_rank
|
||||
integer*8, intent(in) :: layout(6)
|
||||
integer*8 :: file
|
||||
integer*8 :: timestep = 1
|
||||
|
||||
print "('[proc ', I3, ']: Open file for reading ...')", comm_rank
|
||||
file = h5_openfile (FNAME, H5_O_RDONLY, H5_PROP_DEFAULT)
|
||||
h5_err = h5_setstep (file, timestep)
|
||||
|
||||
h5_err = read_field (file, comm_rank, layout)
|
||||
h5_err = read_attributes (file)
|
||||
h5_err = h5_closefile (file)
|
||||
|
||||
read_file = 0
|
||||
end function read_file
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!!
|
||||
integer*8 function read_field (file, comm_rank, layout)
|
||||
use H5hut
|
||||
implicit none
|
||||
|
||||
integer*8, intent(in) :: file
|
||||
integer, intent(in) :: comm_rank
|
||||
integer*8, intent(in) :: layout(6)
|
||||
|
||||
integer*8 :: i, j, k
|
||||
integer*8 :: i_start
|
||||
integer*8 :: i_end
|
||||
integer*8 :: j_start
|
||||
integer*8 :: j_end
|
||||
integer*8 :: k_start
|
||||
integer*8 :: k_end
|
||||
integer*8 :: i_dims
|
||||
integer*8 :: j_dims
|
||||
integer*8 :: k_dims
|
||||
real*8 :: value
|
||||
|
||||
real*8, dimension(:,:,:), allocatable :: data
|
||||
|
||||
i_start = layout(1)
|
||||
i_end = layout(2)
|
||||
j_start = layout(3)
|
||||
j_end = layout(4)
|
||||
k_start = layout(5)
|
||||
k_end = layout(6)
|
||||
i_dims = i_end - i_start + 1
|
||||
j_dims = j_end - j_start + 1
|
||||
k_dims = k_end - k_start + 1
|
||||
|
||||
allocate ( data (i_dims, j_dims, k_dims) )
|
||||
|
||||
print "('[proc ', I3, ']: Defining layout for reading ...')", comm_rank
|
||||
print "('[proc ', I3, ']: ', I3, ':', I3, ', ', I3, ':', I3,', ', I3, ':', I3)", &
|
||||
comm_rank, &
|
||||
i_start, i_end, &
|
||||
j_start, j_end, &
|
||||
k_start, k_end
|
||||
|
||||
h5_err = h5bl_3d_setview ( file, i_start, i_end, j_start, j_end, k_start, k_end )
|
||||
|
||||
print "('[proc ', I3, ']: Reading field ...')", comm_rank
|
||||
h5_err = h5bl_3d_read_scalar_field_r8 ( file, "TestField", data )
|
||||
|
||||
do i = 1, i_dims
|
||||
do j = 1, j_dims
|
||||
do k = 1, k_dims
|
||||
value = (k-1) + 1000*(j-1) + 100000*(i-1) + 10000000*comm_rank
|
||||
if (data(i,j,k) /= value) then
|
||||
print "('[proc ', I3, ']: error: data(',I4,',',I4,',',I4,') = ',F10.2,' /= ',F10.2)", &
|
||||
i, j, k, data(i,j,k), value
|
||||
read_field = -2
|
||||
return
|
||||
end if
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
read_field = 0
|
||||
end function read_field
|
||||
|
||||
integer*8 function read_attributes (file)
|
||||
use H5hut
|
||||
implicit none
|
||||
integer*8, intent(in) :: file
|
||||
|
||||
integer*8 :: h5_err = 0
|
||||
character(len=128) :: s_val
|
||||
integer*8 :: i8_val(1)
|
||||
integer*4 :: i4_val(1)
|
||||
real*8 :: r8_val(1)
|
||||
real*4 :: r4_val(1)
|
||||
|
||||
print "('[proc ', I3, ']: Reading string attribute ...')", comm_rank
|
||||
h5_err = h5bl_readfieldattrib_string ( file, "TestField", "TestString", s_val )
|
||||
IF ( s_val /= "42" ) THEN
|
||||
print "('[proc ', I3, ']: Error reading string attribute: Value is ', A, ' but should be 42')", &
|
||||
comm_rank, s_val
|
||||
end if
|
||||
|
||||
print "('[proc ', I3, ']: Reading int64 attribute ...')", comm_rank
|
||||
h5_err = h5bl_readfieldattrib_i8 ( file, "TestField", "TestInt64", i8_val )
|
||||
if ( i8_val(1) /= 42 ) then
|
||||
print "('[proc ', I3, ']: Error reading int64 attribute: Value is ', I8, ' but should be 42')", &
|
||||
comm_rank, i8_val(1)
|
||||
end if
|
||||
|
||||
print "('[proc ', I3, ']: Reading int32 attribute ...')", comm_rank
|
||||
h5_err = h5bl_readfieldattrib_i4 ( file, "TestField", "TestInt32", i4_val )
|
||||
if ( i4_val(1) /= 42 ) then
|
||||
print "('[proc ', I3, ']: Error reading int32 attribute: Value is ', I8, ' but should be 42')", &
|
||||
comm_rank, i4_val(1)
|
||||
end if
|
||||
|
||||
print "('[proc ', I3, ']: Reading float64 attribute ...')", comm_rank
|
||||
h5_err = h5bl_readfieldattrib_r8 ( file, "TestField", "TestFloat64", r8_val )
|
||||
if ( r8_val(1) /= 42.0 ) then
|
||||
print "('[proc ', I3, ']: Error reading float64 attribute: Value is ', F10.2, ' but should be 42.0')", &
|
||||
comm_rank, r8_val(1)
|
||||
end if
|
||||
|
||||
print "('[proc ', I3, ']: Reading float32 attribute ...')", comm_rank
|
||||
h5_err = h5bl_readfieldattrib_r4 ( file, "TestField", "TestFloat32", r4_val )
|
||||
if ( r4_val(1) /= 42.0 ) then
|
||||
print "('[proc ', I3, ']: Error reading float32 attribute: Value is ', F10.2, ' but should be 42.0')", &
|
||||
comm_rank, r4_val(1)
|
||||
end if
|
||||
|
||||
read_attributes = h5_err
|
||||
end function read_attributes
|
||||
|
||||
end program
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
// name of output file
|
||||
const char* fname = "example_field.h5";
|
||||
|
||||
// H5hut verbosity level
|
||||
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
|
||||
// number of particles we are going to write per core
|
||||
const ssize_t dim_x = 8;
|
||||
const ssize_t dim_y = 8;
|
||||
const ssize_t dim_z = 32;
|
||||
|
||||
|
||||
static inline ssize_t idx (
|
||||
ssize_t i, ssize_t i_dim,
|
||||
ssize_t j, ssize_t j_dim,
|
||||
ssize_t k
|
||||
) {
|
||||
return (i + j*i_dim + k*i_dim*j_dim);
|
||||
}
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char* argv[]
|
||||
){
|
||||
|
||||
// initialize MPI & H5hut
|
||||
MPI_Init (&argc, &argv);
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
int comm_size = 1;
|
||||
MPI_Comm_size (comm, &comm_size);
|
||||
int comm_rank = 0;
|
||||
MPI_Comm_rank (comm, &comm_rank);
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (h5_verbosity);
|
||||
|
||||
// slice field in Z direction
|
||||
ssize_t dim = dim_z;
|
||||
ssize_t n_slices = dim / comm_size;
|
||||
ssize_t remaining_slices = dim % comm_size;
|
||||
ssize_t start;
|
||||
if (comm_rank < remaining_slices) {
|
||||
n_slices++;
|
||||
start = comm_rank * n_slices;
|
||||
} else {
|
||||
start = comm_rank*n_slices + remaining_slices;
|
||||
}
|
||||
ssize_t end = start + n_slices - 1;
|
||||
|
||||
// setting our view
|
||||
ssize_t i_start = 0;
|
||||
ssize_t i_end = dim_x - 1;
|
||||
ssize_t j_start = 0;
|
||||
ssize_t j_end = dim_y - 1;
|
||||
ssize_t k_start = start;
|
||||
ssize_t k_end = end;
|
||||
|
||||
// create fake data
|
||||
ssize_t i_dim = i_end - i_start + 1;
|
||||
ssize_t j_dim = j_end - j_start + 1;
|
||||
h5_int64_t data[(i_end-i_start+1) * (j_end-j_start+1) * (k_end-k_start+1)];
|
||||
for (int k = k_start; k <= k_end; k++) {
|
||||
for (int j = j_start; j <= j_end; j++) {
|
||||
for (int i = i_start; i <= i_end; i++) {
|
||||
ssize_t _idx = idx (i-i_start, i_dim, j-j_start, j_dim, k-k_start);
|
||||
data[_idx] = (h5_int64_t)idx (i, dim_x, j, dim_y, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// open file and create first step
|
||||
h5_file_t file = H5OpenFile (fname, H5_O_WRONLY, H5_PROP_DEFAULT);
|
||||
H5SetStep (file, 0);
|
||||
|
||||
// set view on data for this core
|
||||
H5Block3dSetView (file, i_start, i_end, j_start, j_end, k_start, k_end);
|
||||
|
||||
// write data
|
||||
H5Block3dWriteScalarFieldInt64 (file, "data", data);
|
||||
|
||||
// done
|
||||
H5CloseFile(file);
|
||||
MPI_Finalize ();
|
||||
return 0;
|
||||
}
|
||||
@@ -1,8 +1,23 @@
|
||||
#
|
||||
# Copyright (c) 2006-2016, 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.!
|
||||
#
|
||||
# License: see file COPYING in top level of source distribution.
|
||||
#
|
||||
|
||||
AM_LDFLAGS = -L../../src/lib @LDFLAGS@
|
||||
LIBS = -lH5hutC -lH5hut @LIBS@
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/src/include
|
||||
AM_CPPFLAGS += -I${abs_top_srcdir}/src/include
|
||||
FFLAGS += -cpp $(AM_CPPFLAGS)
|
||||
AM_LDFLAGS += -L${abs_top_builddir}/src/h5core/.libs
|
||||
if ENABLE_DEBUG
|
||||
AM_LDFLAGS += -static
|
||||
endif
|
||||
|
||||
LDADD =
|
||||
LDADD += -lH5hut
|
||||
|
||||
if ENABLE_EXAMPLES
|
||||
noinst_PROGRAMS = \
|
||||
tetmesh_write \
|
||||
tetmesh_write1 \
|
||||
@@ -34,11 +49,12 @@ EXTRA_DIST = \
|
||||
trimesh_write.c \
|
||||
trimesh_2gnuplot.c \
|
||||
trimesh_write_dunetest.c
|
||||
|
||||
# map_tet2globalid.c \
|
||||
# map_triangle2globalid.c \
|
||||
# $(bin_SCRIPTS)
|
||||
|
||||
clean: clean-am
|
||||
rm -f *.h5
|
||||
endif
|
||||
|
||||
clean-local:
|
||||
$(RM) *.h5 *~
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "H5hut.h"
|
||||
|
||||
#ifndef PARALLEL_IO
|
||||
#ifndef H5_HAVE_PARALLEL
|
||||
#ifndef MPI_COMM_WORLD
|
||||
#define MPI_COMM_WORLD 0
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "H5hut.h"
|
||||
|
||||
#ifndef PARALLEL_IO
|
||||
#ifndef H5_HAVE_PARALLEL
|
||||
#ifndef MPI_COMM_WORLD
|
||||
#define MPI_COMM_WORLD 0
|
||||
#endif
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
|
||||
#include "H5hut.h"
|
||||
|
||||
#define PRINT_UPADJACENCIES 1
|
||||
#define PRINT_DOWNADJACENCIES 0
|
||||
|
||||
const h5_oid_t MESH_TYPE = H5_TETRAHEDRAL_MESH;
|
||||
const char* FNAME = "simple_tet.h5";
|
||||
|
||||
typedef struct timer {
|
||||
@@ -27,7 +23,7 @@ static Timer*
|
||||
new (
|
||||
void
|
||||
) {
|
||||
Timer* this = malloc (sizeof (Timer));
|
||||
Timer* this = (Timer*)malloc (sizeof (Timer));
|
||||
*this = Timer_;
|
||||
return this;
|
||||
}
|
||||
@@ -500,7 +496,7 @@ traverse_elems (
|
||||
static h5_err_t
|
||||
traverse_level (
|
||||
h5t_mesh_t* const m,
|
||||
const h5t_lvl_idx_t level_id,
|
||||
const h5_lvl_idx_t level_id,
|
||||
int dumpit,
|
||||
Timer* timer
|
||||
) {
|
||||
@@ -515,7 +511,7 @@ traverse_level (
|
||||
|
||||
static h5_err_t
|
||||
traverse_mesh (
|
||||
h5_file_t* const f,
|
||||
h5_file_t const f,
|
||||
const h5_id_t mesh_id
|
||||
) {
|
||||
h5t_mesh_t* mesh;
|
||||
@@ -523,13 +519,13 @@ traverse_mesh (
|
||||
Timer* timer = Timer_.new();
|
||||
|
||||
/* open mesh and get number of levels */
|
||||
printf (" Opening mesh with id %lld\n", mesh_id);
|
||||
printf (" Opening mesh with id %lld\n", (long long)mesh_id);
|
||||
H5FedOpenTetrahedralMeshByIndex (f, mesh_id, &mesh);
|
||||
h5_size_t num_levels = H5FedGetNumLevels (mesh);
|
||||
printf (" Number of levels in mesh: %lld\n", (long long)num_levels);
|
||||
|
||||
/* loop over all levels */
|
||||
h5t_lvl_idx_t level_id;
|
||||
h5_lvl_idx_t level_id;
|
||||
for (level_id = 0; level_id < num_levels; level_id++) {
|
||||
traverse_level (mesh, level_id, dumpit, timer);
|
||||
}
|
||||
@@ -547,10 +543,11 @@ main (
|
||||
|
||||
/* abort program on error, so we don't have to handle them */
|
||||
H5SetErrorHandler (H5AbortErrorhandler);
|
||||
H5SetVerbosityLevel (2);
|
||||
|
||||
//H5SetVerbosityLevel (H5_DEBUG_ALL);
|
||||
H5SetVerbosityLevel (0);
|
||||
|
||||
/* open file and get number of meshes */
|
||||
h5_file_t *f = H5OpenFile (FNAME, H5_O_RDONLY, 0);
|
||||
h5_file_t f = H5OpenFile (FNAME, H5_O_RDONLY, 0);
|
||||
h5_size_t num_meshes = H5FedGetNumTetrahedralMeshes (f);
|
||||
printf (" Number of meshes: %lld\n", (long long)num_meshes);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ static Timer*
|
||||
new (
|
||||
void
|
||||
) {
|
||||
Timer* this = malloc (sizeof (Timer));
|
||||
Timer* this = (Timer*)malloc (sizeof (Timer));
|
||||
*this = Timer_;
|
||||
return this;
|
||||
}
|
||||
@@ -280,7 +280,7 @@ traverse_elems (
|
||||
static h5_err_t
|
||||
traverse_level (
|
||||
h5t_mesh_t* const m,
|
||||
const h5t_lvl_idx_t level_id,
|
||||
const h5_lvl_idx_t level_id,
|
||||
int dumpit,
|
||||
Timer* timer
|
||||
) {
|
||||
@@ -296,7 +296,7 @@ traverse_level (
|
||||
|
||||
static h5_err_t
|
||||
traverse_mesh (
|
||||
h5_file_t* const f,
|
||||
h5_file_t const f,
|
||||
const h5_id_t mesh_id,
|
||||
int dumpit
|
||||
) {
|
||||
@@ -305,7 +305,7 @@ traverse_mesh (
|
||||
|
||||
timer->start(timer);
|
||||
/* open mesh and get number of levels */
|
||||
printf (" Opening mesh with id %lld\n", mesh_id);
|
||||
printf (" Opening mesh with id %lld\n", (long long)mesh_id);
|
||||
H5FedOpenTetrahedralMeshByIndex (f, mesh_id, &mesh);
|
||||
timer->stop(timer);
|
||||
printf (" %fsec\n", timer->elapsed(timer));
|
||||
@@ -313,7 +313,7 @@ traverse_mesh (
|
||||
printf (" Number of levels in mesh: %lld\n", (long long)num_levels);
|
||||
|
||||
/* loop over all levels */
|
||||
h5t_lvl_idx_t level_id;
|
||||
h5_lvl_idx_t level_id;
|
||||
for (level_id = 0; level_id < num_levels; level_id++) {
|
||||
traverse_level (mesh, level_id, dumpit, timer);
|
||||
}
|
||||
@@ -328,12 +328,13 @@ main (
|
||||
int argc,
|
||||
char* argv[]
|
||||
) {
|
||||
|
||||
/* abort program on error, so we don't have to handle them */
|
||||
H5SetErrorHandler (H5AbortErrorhandler);
|
||||
H5SetVerbosityLevel (2);
|
||||
H5SetVerbosityLevel (0);
|
||||
|
||||
/* open file and get number of meshes */
|
||||
h5_file_t* f = H5OpenFile (FNAME, H5_O_RDONLY, 0);
|
||||
h5_file_t f = H5OpenFile (FNAME, H5_O_RDONLY, H5_PROP_DEFAULT);
|
||||
h5_size_t num_meshes = H5FedGetNumTetrahedralMeshes (f);
|
||||
printf (" Number of meshes: %lld\n", (long long)num_meshes);
|
||||
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
|
||||
#include "H5hut.h"
|
||||
|
||||
// name of input file
|
||||
const char* FNAME = "simple_tet.h5";
|
||||
|
||||
#ifndef PARALLEL_IO
|
||||
#ifndef MPI_COMM_WORLD
|
||||
#define MPI_COMM_WORLD 0
|
||||
#endif
|
||||
#endif
|
||||
// H5hut verbosity/debug level
|
||||
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
const h5_int64_t h5_debugmsk = H5_DEBUG_ALL;
|
||||
|
||||
typedef struct timer {
|
||||
clock_t _start;
|
||||
@@ -27,7 +26,7 @@ static Timer*
|
||||
new (
|
||||
void
|
||||
) {
|
||||
Timer* self = malloc (sizeof (Timer));
|
||||
Timer* self = (Timer*)malloc (sizeof (Timer));
|
||||
*self = Timer_;
|
||||
return self;
|
||||
}
|
||||
@@ -111,7 +110,7 @@ traverse_vertices (
|
||||
}
|
||||
if (dumpit) {
|
||||
printf (" (%llx, %llx, %llx) |",
|
||||
tval[0], tval[1], tval[2]);
|
||||
(long long)tval[0], (long long)tval[1], (long long)tval[2]);
|
||||
}
|
||||
num_entities_tagged++;
|
||||
if (tval[0] != local_id ||
|
||||
@@ -172,7 +171,7 @@ traverse_edges (
|
||||
continue; // not tagged
|
||||
if (dumpit) {
|
||||
printf (" (%llx, %llx, %llx) |",
|
||||
tval[0], tval[1], tval[2]);
|
||||
(long long)tval[0], (long long)tval[1], (long long)tval[2]);
|
||||
}
|
||||
num_entities_tagged++;
|
||||
|
||||
@@ -236,7 +235,7 @@ traverse_triangles (
|
||||
continue; // not tagged
|
||||
if (dumpit) {
|
||||
printf (" (%llx, %llx, %llx) |",
|
||||
tval[0], tval[1], tval[2]);
|
||||
(long long)tval[0], (long long)tval[1], (long long)tval[2]);
|
||||
}
|
||||
num_entities_tagged++;
|
||||
|
||||
@@ -298,7 +297,7 @@ traverse_tets (
|
||||
continue; // not tagged
|
||||
if (dumpit) {
|
||||
printf (" (%llx, %llx, %llx) |",
|
||||
tval[0], tval[1], tval[2]);
|
||||
(long long)tval[0], (long long)tval[1], (long long)tval[2]);
|
||||
}
|
||||
num_entities_tagged++;
|
||||
|
||||
@@ -327,7 +326,7 @@ static h5_err_t
|
||||
traverse_level (
|
||||
h5t_mesh_t* const m,
|
||||
h5t_tagset_t* tagset,
|
||||
const h5t_lvl_idx_t level_id,
|
||||
const h5_lvl_idx_t level_id,
|
||||
int dumpit,
|
||||
Timer* timer
|
||||
) {
|
||||
@@ -342,7 +341,7 @@ traverse_level (
|
||||
|
||||
static h5_err_t
|
||||
traverse_mesh (
|
||||
h5_file_t* const f,
|
||||
const h5_file_t f,
|
||||
const h5_id_t mesh_id,
|
||||
int dumpit
|
||||
) {
|
||||
@@ -350,7 +349,7 @@ traverse_mesh (
|
||||
Timer* timer = Timer_.new();
|
||||
timer->start(timer);
|
||||
/* open mesh and get number of levels */
|
||||
printf (" Opening mesh with id %lld\n", mesh_id);
|
||||
printf (" Opening mesh with id %lld\n", (long long)mesh_id);
|
||||
H5FedOpenTetrahedralMeshByIndex (f, mesh_id, &mesh);
|
||||
timer->stop(timer);
|
||||
printf (" %fsec\n", timer->elapsed(timer));
|
||||
@@ -362,7 +361,7 @@ traverse_mesh (
|
||||
printf (" Number of levels in mesh: %lld\n", (long long)num_levels);
|
||||
|
||||
/* loop over all levels */
|
||||
h5t_lvl_idx_t level_id;
|
||||
h5_lvl_idx_t level_id;
|
||||
for (level_id = 0; level_id < num_levels; level_id++) {
|
||||
traverse_level (mesh, tagset, level_id, dumpit, timer);
|
||||
}
|
||||
@@ -378,12 +377,14 @@ main (
|
||||
int argc,
|
||||
char* argv[]
|
||||
) {
|
||||
|
||||
/* abort program on error, so we don't have to handle them */
|
||||
H5SetErrorHandler (H5AbortErrorhandler);
|
||||
H5SetVerbosityLevel (2);
|
||||
|
||||
H5SetVerbosityLevel (h5_verbosity);
|
||||
H5SetDebugMask (h5_debugmsk);
|
||||
|
||||
/* open file and get number of meshes */
|
||||
h5_file_t* f = H5OpenFile (FNAME, H5_O_RDONLY, 0);
|
||||
h5_file_t f = H5OpenFile (FNAME, H5_O_RDONLY, 0);
|
||||
h5_size_t num_meshes = H5FedGetNumTetrahedralMeshes (f);
|
||||
printf (" Number of meshes: %lld\n", (long long)num_meshes);
|
||||
|
||||
|
||||
@@ -4,12 +4,6 @@
|
||||
|
||||
#include "H5hut.h"
|
||||
|
||||
#ifndef PARALLEL_IO
|
||||
#ifndef MPI_COMM_WORLD
|
||||
#define MPI_COMM_WORLD 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
const char* FNAME = "simple_tet.h5";
|
||||
|
||||
typedef struct vertex {
|
||||
@@ -41,12 +35,13 @@ main (
|
||||
int argc,
|
||||
char* argv[]
|
||||
) {
|
||||
|
||||
/* abort program on errors in library */
|
||||
H5SetErrorHandler (H5AbortErrorhandler);
|
||||
H5SetVerbosityLevel (5);
|
||||
|
||||
/* open file and add mesh */
|
||||
h5_file_t* const f = H5OpenFile (FNAME, H5_O_WRONLY, 0);
|
||||
h5_file_t const f = H5OpenFile (FNAME, H5_O_WRONLY, H5_PROP_DEFAULT);
|
||||
h5t_mesh_t* mesh;
|
||||
H5FedAddTetrahedralMesh (f, "0", &mesh);
|
||||
|
||||
@@ -66,13 +61,11 @@ main (
|
||||
H5FedEndStoreElements (mesh);
|
||||
|
||||
/* add 1. Level */
|
||||
H5FedAddLevel(mesh);
|
||||
H5FedBeginRefineElements (mesh);
|
||||
H5FedRefineElement (mesh, 0);
|
||||
H5FedEndRefineElements (mesh);
|
||||
|
||||
/* add 2. Level */
|
||||
H5FedAddLevel(mesh);
|
||||
H5FedBeginRefineElements (mesh);
|
||||
H5FedRefineElement (mesh, 2);
|
||||
H5FedEndRefineElements (mesh);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "H5hut.h"
|
||||
|
||||
#ifndef PARALLEL_IO
|
||||
#ifndef H5_HAVE_PARALLEL
|
||||
#ifndef MPI_COMM_WORLD
|
||||
#define MPI_COMM_WORLD 0
|
||||
#endif
|
||||
@@ -44,7 +44,7 @@ main (
|
||||
H5SetVerbosityLevel (H5_DEBUG_ALL);
|
||||
|
||||
/* open file and add mesh */
|
||||
h5_file_t* const f = H5OpenFile (FNAME, H5_O_WRONLY, 0);
|
||||
h5_file_t const f = H5OpenFile (FNAME, H5_O_WRONLY, 0);
|
||||
h5t_mesh_t* mesh;
|
||||
H5FedAddTetrahedralMesh (f, "0", &mesh);
|
||||
|
||||
@@ -64,7 +64,6 @@ main (
|
||||
H5FedEndStoreElements (mesh);
|
||||
|
||||
/* add 1. Level */
|
||||
H5FedAddLevel(mesh);
|
||||
H5FedBeginRefineElements (mesh);
|
||||
H5FedRefineElement (mesh, 0);
|
||||
H5FedEndRefineElements (mesh);
|
||||
|
||||
@@ -61,7 +61,7 @@ main (
|
||||
// H5SetVerbosityLevel (H5_DEBUG_ALL);
|
||||
|
||||
/* open file and add mesh */
|
||||
h5_file_t* const f = H5OpenFile (FNAME, H5_O_WRONLY, 0);
|
||||
h5_file_t const f = H5OpenFile (FNAME, H5_O_WRONLY, 0);
|
||||
h5t_mesh_t* mesh;
|
||||
H5FedAddTetrahedralMesh (f, "0", &mesh);
|
||||
|
||||
@@ -81,7 +81,6 @@ main (
|
||||
H5FedEndStoreElements (mesh);
|
||||
|
||||
/* add 1. Level */
|
||||
H5FedAddLevel(mesh);
|
||||
H5FedBeginRefineElements (mesh);
|
||||
H5FedRefineElement (mesh, 0);
|
||||
H5FedEndRefineElements (mesh);
|
||||
@@ -92,7 +91,6 @@ main (
|
||||
for (level_id = 2; level_id < num_levels; level_id++) {
|
||||
|
||||
/* refine 4 to the power of level_id-1 elems */
|
||||
H5FedAddLevel(mesh);
|
||||
h5_int32_t num_elems2refine = power (4, level_id-1);
|
||||
H5FedBeginRefineElements (mesh);
|
||||
for (i = num_elems_last_level;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include "H5hut.h"
|
||||
|
||||
const h5_oid_t MESH_TYPE = H5_TETRAHEDRAL_MESH;
|
||||
const char* FNAME = "simple_tet.h5";
|
||||
|
||||
typedef struct timer {
|
||||
@@ -23,7 +22,7 @@ static Timer*
|
||||
new (
|
||||
void
|
||||
) {
|
||||
Timer* this = malloc (sizeof (Timer));
|
||||
Timer* this = (Timer*)malloc (sizeof (Timer));
|
||||
*this = Timer_;
|
||||
return this;
|
||||
}
|
||||
@@ -188,7 +187,7 @@ main (
|
||||
H5SetVerbosityLevel (3);
|
||||
|
||||
/* open file and get number of meshes */
|
||||
h5_file_t* f = H5OpenFile (FNAME, H5_O_RDWR, 0);
|
||||
h5_file_t f = H5OpenFile (FNAME, H5_O_RDWR, 0);
|
||||
h5t_mesh_t* mesh;
|
||||
Timer* timer = Timer_.new();
|
||||
timer->start(timer);
|
||||
@@ -197,7 +196,7 @@ main (
|
||||
h5_info (" Time to open mesh %fsec", timer->elapsed(timer));
|
||||
|
||||
/* open last level */
|
||||
h5_size_t num_levels = H5FedGetNumLevels (mesh);
|
||||
//h5_size_t num_levels = H5FedGetNumLevels (mesh);
|
||||
//H5FedSetLevel (mesh, num_levels-1);
|
||||
H5FedSetLevel (mesh, 0);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "H5hut.h"
|
||||
#if defined (PARALLEL_IO)
|
||||
#if defined (H5_HAVE_PARALLEL)
|
||||
#include <mpi.h>
|
||||
#endif
|
||||
|
||||
@@ -57,12 +57,6 @@ main (
|
||||
char* argv[]
|
||||
) {
|
||||
|
||||
#if defined (PARALLEL_IO)
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
MPI_Init (&argc, &argv);
|
||||
#else
|
||||
MPI_Comm comm = 0;
|
||||
#endif
|
||||
if (argc < 2 || argc > 3) {
|
||||
fprintf (stderr, "Usage: %s FILE [LEVEL]\n", argv[0]);
|
||||
exit (42);
|
||||
@@ -73,7 +67,7 @@ main (
|
||||
H5SetVerbosityLevel (0);
|
||||
|
||||
/* open file and get number of meshes */
|
||||
h5_file_t* f = H5OpenFile (argv[1], H5_O_RDONLY, comm);
|
||||
h5_file_t f = H5OpenFile (argv[1], H5_O_RDONLY, H5_PROP_DEFAULT);
|
||||
h5t_mesh_t* m;
|
||||
H5FedOpenTriangleMeshByIndex (f, 0, &m);
|
||||
int num_levels = H5FedGetNumLevels (m);
|
||||
@@ -93,7 +87,7 @@ done:
|
||||
H5FedCloseMesh (m);
|
||||
H5CloseFile (f);
|
||||
|
||||
#if defined (PARALLEL_IO)
|
||||
#if defined (H5_HAVE_PARALLEL)
|
||||
MPI_Finalize ();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#define PRINT_UPADJACENCIES 1
|
||||
#define PRINT_DOWNADJACENCIES 0
|
||||
|
||||
const h5_oid_t MESH_TYPE = H5_TRIANGLE_MESH;
|
||||
const char* FNAME = "simple_triangle.h5";
|
||||
|
||||
static h5_err_t
|
||||
@@ -244,7 +243,7 @@ traverse_elems (
|
||||
clock_t t_min = CLOCKS_PER_SEC;
|
||||
clock_t t_max = 0;
|
||||
clock_t t = 0;
|
||||
printf ("\nAdjacencies to tetrahedra\n");
|
||||
printf ("\nAdjacencies to triangles\n");
|
||||
h5t_iterator_t* iter = H5FedBeginTraverseEntities (m, 0);
|
||||
while ((local_id = H5FedTraverseEntities (iter)) >= 0) {
|
||||
print_adjacencies_of_elem (m, local_id, &t);
|
||||
@@ -267,7 +266,7 @@ traverse_elems (
|
||||
static h5_err_t
|
||||
traverse_level (
|
||||
h5t_mesh_t* const m,
|
||||
const h5t_lvl_idx_t level_id
|
||||
const h5_lvl_idx_t level_id
|
||||
) {
|
||||
printf (" Setting level to %d\n", level_id);
|
||||
H5FedSetLevel (m, level_id);
|
||||
@@ -279,18 +278,18 @@ traverse_level (
|
||||
|
||||
static h5_err_t
|
||||
traverse_mesh (
|
||||
h5_file_t* const f,
|
||||
const h5_file_t f,
|
||||
const h5_id_t mesh_id
|
||||
) {
|
||||
h5t_mesh_t* m;
|
||||
/* open mesh and get number of levels */
|
||||
printf (" Opening mesh with id %lld\n", mesh_id);
|
||||
printf (" Opening mesh with id %lld\n", (long long)mesh_id);
|
||||
H5FedOpenTriangleMeshByIndex (f, mesh_id, &m);
|
||||
h5_size_t num_levels = H5FedGetNumLevels (m);
|
||||
printf (" Number of levels in mesh: %lld\n", (long long)num_levels);
|
||||
|
||||
/* loop over all levels */
|
||||
h5t_lvl_idx_t level_id;
|
||||
h5_lvl_idx_t level_id;
|
||||
for (level_id = 0; level_id < num_levels; level_id++) {
|
||||
traverse_level (m, level_id);
|
||||
}
|
||||
@@ -310,7 +309,7 @@ main (
|
||||
H5SetVerbosityLevel (2);
|
||||
|
||||
/* open file and get number of meshes */
|
||||
h5_file_t *f = H5OpenFile (FNAME, H5_O_RDONLY, 0);
|
||||
h5_file_t f = H5OpenFile (FNAME, H5_O_RDONLY, 0);
|
||||
h5_size_t num_meshes = H5FedGetNumTriangleMeshes (f);
|
||||
printf (" Number of meshes: %lld\n", (long long)num_meshes);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "H5hut.h"
|
||||
#if defined (PARALLEL_IO)
|
||||
#if defined (H5_HAVE_PARALLEL)
|
||||
#include <mpi.h>
|
||||
#endif
|
||||
|
||||
@@ -209,18 +209,18 @@ traverse_level (
|
||||
|
||||
static h5_err_t
|
||||
traverse_mesh (
|
||||
h5_file_t* const f,
|
||||
const h5_file_t f,
|
||||
const h5_id_t mesh_id
|
||||
) {
|
||||
h5t_mesh_t* m;
|
||||
/* open mesh and get number of levels */
|
||||
printf (" Opening mesh with id %lld\n", mesh_id);
|
||||
printf (" Opening mesh with id %lld\n", (long long)mesh_id);
|
||||
H5FedOpenTriangleMeshByIndex (f, mesh_id, &m);
|
||||
h5_size_t num_levels = H5FedGetNumLevels (m);
|
||||
printf (" Number of levels in mesh: %lld\n", (long long)num_levels);
|
||||
|
||||
/* loop over all levels */
|
||||
h5t_lvl_idx_t level_id;
|
||||
h5_lvl_idx_t level_id;
|
||||
for (level_id = 0; level_id < num_levels; level_id++) {
|
||||
traverse_level (m, level_id);
|
||||
}
|
||||
@@ -236,19 +236,12 @@ main (
|
||||
char* argv[]
|
||||
) {
|
||||
|
||||
#if defined (PARALLEL_IO)
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
MPI_Init (&argc, &argv);
|
||||
#else
|
||||
MPI_Comm comm = 0;
|
||||
#endif
|
||||
|
||||
/* abort program on error, so we don't have to handle them */
|
||||
H5SetErrorHandler (H5AbortErrorhandler);
|
||||
H5SetVerbosityLevel (0);
|
||||
H5SetVerbosityLevel (H5_DEBUG_ALL);
|
||||
|
||||
/* open file and get number of meshes */
|
||||
h5_file_t* f = H5OpenFile (FNAME, H5_O_RDONLY, comm);
|
||||
h5_file_t f = H5OpenFile (FNAME, H5_O_RDONLY, H5_PROP_DEFAULT);
|
||||
h5_size_t num_meshes = H5FedGetNumTriangleMeshes (f);
|
||||
printf (" Number of meshes: %lld\n", (long long)num_meshes);
|
||||
|
||||
@@ -260,7 +253,7 @@ main (
|
||||
|
||||
/* done */
|
||||
H5CloseFile (f);
|
||||
#if defined (PARALLEL_IO)
|
||||
#if defined (H5_HAVE_PARALLEL)
|
||||
MPI_Finalize ();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ main (
|
||||
H5SetVerbosityLevel (5);
|
||||
|
||||
/* open file and add mesh */
|
||||
h5_file_t* const f = H5OpenFile (FNAME, H5_O_WRONLY, 0);
|
||||
const h5_file_t f = H5OpenFile (FNAME, H5_O_WRONLY, 0);
|
||||
h5t_mesh_t* m;
|
||||
H5FedAddTriangleMesh (f, "0", &m);
|
||||
|
||||
@@ -58,7 +58,6 @@ main (
|
||||
H5FedEndStoreElements (m);
|
||||
|
||||
/* add 1. Level */
|
||||
H5FedAddLevel(m);
|
||||
H5FedBeginRefineElements (m);
|
||||
H5FedRefineElement (m, 0);
|
||||
H5FedEndRefineElements (m);
|
||||
|
||||
@@ -45,7 +45,7 @@ main (
|
||||
H5SetVerbosityLevel (2);
|
||||
|
||||
/* open file and add mesh */
|
||||
h5_file_t* const f = H5OpenFile (FNAME, H5_O_WRONLY, 0);
|
||||
const h5_file_t f = H5OpenFile (FNAME, H5_O_WRONLY, 0);
|
||||
h5t_mesh_t* m;
|
||||
H5FedAddTriangleMesh (f, "0", &m);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "H5hut.h"
|
||||
|
||||
#ifndef PARALLEL_IO
|
||||
#ifndef H5_HAVE_PARALLEL
|
||||
#ifndef MPI_COMM_WORLD
|
||||
#define MPI_COMM_WORLD 0
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
query
|
||||
read_core_vfd
|
||||
read_core_vfdf
|
||||
read_canonicalviewf
|
||||
read_setnparticlesf
|
||||
read_setviewf
|
||||
read_stridedf
|
||||
write_core_vfdf
|
||||
write_setnparticlesf
|
||||
write_stridedf
|
||||
@@ -1,263 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <mpi.h>
|
||||
/* #include <mpio.h> */
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#ifndef PARALLEL_IO
|
||||
#define PARALLEL_IO
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_H5PART
|
||||
#include "H5hut.h"
|
||||
#endif
|
||||
|
||||
#define FILENAME "testio"
|
||||
/* normally 64 steps for real benchmark */
|
||||
/* #define NSTEPS 5 */
|
||||
|
||||
/* normally 51e6 for real benchmark */
|
||||
#define NPARTICLES 51e4
|
||||
#define NTRIALS 3
|
||||
|
||||
/*
|
||||
|
||||
bench <nParticles> <nSteps>
|
||||
|
||||
*/
|
||||
|
||||
|
||||
int main(int argc,char *argv[]){
|
||||
|
||||
if (argc < 3) {
|
||||
printf("Usage: bench <nParticles> <nSteps> \n");
|
||||
exit(-1);
|
||||
}
|
||||
else {
|
||||
printf("nparticles: %d, nsteps: %d \n", atoi(argv[1]), atoi(argv[2]));
|
||||
}
|
||||
|
||||
MPI_Info info;
|
||||
int nprocs,rank;
|
||||
int trial;
|
||||
int i,j,n; /* iteration variables */
|
||||
double starttime,curtime, endtime;
|
||||
|
||||
int nparticles = atoi(argv[1]);
|
||||
int nsteps = atoi(argv[2]);
|
||||
|
||||
double *x,*y,*z,*px,*py,*pz;
|
||||
typedef double *ddouble;
|
||||
ddouble data[6];
|
||||
MPI_Datatype chunktype;
|
||||
int offset;
|
||||
int localnp;
|
||||
char filename[128]; /*= FILENAME; */
|
||||
#ifndef DISABLE_H5PART
|
||||
h5_file_t *f;
|
||||
#endif
|
||||
char newfilename[128];
|
||||
FILE *fd;
|
||||
MPI_File file;
|
||||
MPI_Offset foffset;
|
||||
|
||||
MPI_Comm dcomm = MPI_COMM_WORLD;
|
||||
|
||||
MPI_Init(&argc,&argv);
|
||||
MPI_Comm_rank(dcomm,&rank);
|
||||
MPI_Comm_size(dcomm,&nprocs);
|
||||
|
||||
localnp=nparticles/(int64_t)nprocs;
|
||||
for(offset=0,i=0;i<rank;i++){
|
||||
offset+=localnp;
|
||||
}
|
||||
|
||||
data[0]=x=(double*)malloc(sizeof(double)*(size_t)localnp);
|
||||
data[1]=y=(double*)malloc(sizeof(double)*(size_t)localnp);
|
||||
data[2]=z=(double*)malloc(sizeof(double)*(size_t)localnp);
|
||||
data[3]=px=(double*)malloc(sizeof(double)*(size_t)localnp);
|
||||
data[4]=py=(double*)malloc(sizeof(double)*(size_t)localnp);
|
||||
data[5]=pz=(double*)malloc(sizeof(double)*(size_t)localnp);
|
||||
|
||||
|
||||
/* printf("about to call create subarray with nparticles=%u localnp=%u offset=%u\n",
|
||||
nparticles,localnp,offset); */
|
||||
MPI_Type_create_subarray(1, /* rank */
|
||||
&nparticles, /* size of the global array */
|
||||
&localnp, /* size of my local chunk */
|
||||
&offset, /* offset of this chunk in global */
|
||||
MPI_ORDER_FORTRAN, /* fortran storage order */
|
||||
MPI_DOUBLE,
|
||||
&chunktype);
|
||||
MPI_Type_commit(&chunktype);
|
||||
MPI_Info_create(&info);
|
||||
MPI_Info_set(info, "IBM_largeblock_io", "true" );
|
||||
|
||||
if(rank==0) printf("Nprocs=%u Particles=%u*6attribs*sizeof(double) Particles/proc=%u Nsteps=%u Ntrials=%u\n",
|
||||
nprocs,nparticles,localnp,nsteps,NTRIALS);
|
||||
|
||||
|
||||
for(trial=0;trial<NTRIALS;trial++){
|
||||
if(rank==0) printf("---------------------- Trial %u of %u ---------------------\n",trial+1,NTRIALS);
|
||||
|
||||
|
||||
MPI_Barrier(MPI_COMM_WORLD); /* to prevent unlink from interfering with file open */
|
||||
sprintf(filename,"%s.%u.mpio.dat",FILENAME,nprocs);
|
||||
|
||||
if(rank==0) unlink(filename);
|
||||
MPI_Barrier(MPI_COMM_WORLD); /* to prevent unlink from interfering with file open */
|
||||
|
||||
MPI_File_open(MPI_COMM_WORLD,filename,
|
||||
MPI_MODE_CREATE | MPI_MODE_RDWR,
|
||||
info,&file);
|
||||
|
||||
MPI_File_set_view(file,0,MPI_DOUBLE,chunktype,"native",info);
|
||||
/* now a barrier to get the start timers roughly synced*/
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
curtime = starttime = MPI_Wtime();
|
||||
endtime = starttime+5.0*60.0; /* end in 5 minutes */
|
||||
MPI_Bcast(&endtime,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
|
||||
/* must touch the entire array after each write */
|
||||
/* ensures cache-invalidation */
|
||||
foffset=0;
|
||||
i=0;
|
||||
curtime=starttime;
|
||||
for(i=0;i<nsteps;i++){
|
||||
int n;
|
||||
MPI_Status status;
|
||||
for(j=0;j<6;j++){
|
||||
/* touch data */
|
||||
for(n=0;n<localnp;n++)
|
||||
(data[j])[n]=(double)rank;
|
||||
/* write to that file */
|
||||
/* MPI_File_set_view(file,foffset,MPI_DOUBLE,chunktype,"native",info);*/
|
||||
|
||||
#ifdef COLLECTIVE_IO
|
||||
MPI_File_write_at_all(file,
|
||||
foffset,
|
||||
data[j],
|
||||
localnp,
|
||||
MPI_DOUBLE,&status);
|
||||
#else
|
||||
MPI_File_write_at(file,
|
||||
foffset,
|
||||
data[j],
|
||||
localnp,
|
||||
MPI_DOUBLE,&status);
|
||||
#endif
|
||||
|
||||
foffset+=nparticles/nprocs;
|
||||
}
|
||||
curtime=MPI_Wtime(); /* ensure no race condition by broadcasting time */
|
||||
MPI_Bcast(&curtime,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
|
||||
MPI_File_close(&file);
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
endtime=MPI_Wtime();
|
||||
|
||||
|
||||
/* foffset*=nprocs; if we want total megabytes written */
|
||||
if(rank==0){
|
||||
puts("*");
|
||||
unlink(filename);
|
||||
puts("======================================================");
|
||||
printf("Raw MPI-IO Total Duration %lf seconds, iterations=%u %lf Megabytes written per processor Nprocs= %u \n",
|
||||
(endtime-starttime),i,((double)foffset)/(1024.0*1024.0),nprocs);
|
||||
printf("Raw MPI-IO Effective Data Rate = %lf Megabytes/sec global and %lf Megabytes/sec per task Nprocs= %u \n",
|
||||
(double)(nprocs*localnp*sizeof(double))*((double)nsteps)*6.0/((endtime-starttime)*1024.0*1024.0),
|
||||
(double)(localnp*sizeof(double))*((double)nsteps)*6.0/((endtime-starttime)*1024.0*1024.0),nprocs);
|
||||
puts("======================================================");
|
||||
}
|
||||
|
||||
MPI_Barrier(MPI_COMM_WORLD); /* to prevent unlink from interfering with file open */
|
||||
|
||||
/* OK, now we do this using POSIX IO */
|
||||
sprintf(newfilename,"testio%u.%u.dat",rank,nprocs);
|
||||
unlink(newfilename);
|
||||
MPI_Barrier(MPI_COMM_WORLD); /* to prevent unlink from interfering with file open */
|
||||
fd = fopen(newfilename,"w");
|
||||
/* start the timer */
|
||||
starttime=endtime=MPI_Wtime();
|
||||
for(i=0;i<nsteps;i++){
|
||||
for(j=0;j<6;j++){
|
||||
/* touch data */
|
||||
for(n=0;n<localnp;n++)
|
||||
(data[j])[n]=(double)rank;
|
||||
fwrite(data[j],sizeof(double),localnp,fd);
|
||||
}
|
||||
curtime=MPI_Wtime(); /* ensure no race condition by broadcasting time */
|
||||
MPI_Bcast(&curtime,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
|
||||
}
|
||||
fclose(fd);
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
endtime=MPI_Wtime();
|
||||
if(rank==0) puts("*");
|
||||
MPI_Barrier(MPI_COMM_WORLD); /* to prevent unlink from interfering with file open */
|
||||
unlink(newfilename);
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
if(rank==0){
|
||||
puts("======================================================");
|
||||
printf("Raw 1-file-per-proc Total Duration %lf seconds, iterations=%u %lf Megabytes written Nprocs= %u \n",
|
||||
(endtime-starttime),nsteps,((double)foffset)/(1024.0*1024.0),nprocs);
|
||||
printf("Raw 1-file-per-proc Effective Data Rate = %lf Megabytes/sec global and %lf Megabytes/sec per task Nprocs= %u \n",
|
||||
(double)(nprocs*localnp*sizeof(double))*((double)nsteps)*6.0/((endtime-starttime)*1024.0*1024.0),
|
||||
(double)(localnp*sizeof(double))*((double)nsteps)*6.0/((endtime-starttime)*1024.0*1024.0),nprocs);
|
||||
puts("======================================================");
|
||||
}
|
||||
|
||||
#ifndef DISABLE_H5PART
|
||||
|
||||
MPI_Barrier(MPI_COMM_WORLD); /* to prevent unlink from interfering with file open */
|
||||
/* OK, now we do this using H5Part */
|
||||
|
||||
sprintf(filename,"%s.%u.h5.dat",FILENAME,nprocs);
|
||||
if(rank==0) unlink(filename);
|
||||
MPI_Barrier(MPI_COMM_WORLD); /* to prevent unlink from interfering with file open */
|
||||
|
||||
f = H5OpenFile(filename,H5_O_WRONLY,MPI_COMM_WORLD);
|
||||
MPI_Barrier(MPI_COMM_WORLD); /* to prevent unlink from interfering with file open */
|
||||
/* start the timer */
|
||||
starttime=endtime=MPI_Wtime();
|
||||
H5PartSetNumParticles(f,localnp);
|
||||
for(i=0;i<nsteps;i++){
|
||||
for(j=0;j<6;j++){
|
||||
/* touch data */
|
||||
for(n=0;n<localnp;n++)
|
||||
(data[j])[n]=(double)rank;
|
||||
}
|
||||
H5SetStep(f,i);
|
||||
H5PartWriteDataFloat64(f,"x",x);
|
||||
H5PartWriteDataFloat64(f,"y",y);
|
||||
H5PartWriteDataFloat64(f,"z",z);
|
||||
H5PartWriteDataFloat64(f,"px",px);
|
||||
H5PartWriteDataFloat64(f,"py",py);
|
||||
H5PartWriteDataFloat64(f,"pz",pz);
|
||||
|
||||
curtime=MPI_Wtime(); /* ensure no race condition by broadcasting time */
|
||||
MPI_Bcast(&curtime,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
|
||||
}
|
||||
H5CloseFile(f);
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
endtime=MPI_Wtime();
|
||||
if(rank==0){
|
||||
puts("*");
|
||||
unlink(filename);
|
||||
puts("======================================================");
|
||||
printf("H5Part Total Duration %lf seconds, iterations=%u %lf Megabytes written Nprocs= %u \n",
|
||||
(endtime-starttime),nsteps,((double)foffset)/(1024.0*1024.0),nprocs);
|
||||
printf("H5Part Effective Data Rate = %lf Megabytes/sec global and %lf Megabytes/sec per task Nprocs= %u \n",
|
||||
(double)(nprocs*localnp*sizeof(double))*((double)nsteps)*6.0/((endtime-starttime)*1024.0*1024.0),
|
||||
(double)(localnp*sizeof(double))*((double)nsteps)*6.0/((endtime-starttime)*1024.0*1024.0),nprocs);
|
||||
puts("======================================================");
|
||||
}
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
#endif
|
||||
} /* trials */
|
||||
|
||||
MPI_Finalize();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <hdf5.h>
|
||||
#include "H5Part.hh"
|
||||
|
||||
#ifdef READTEST
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef REGRESSIONTEST
|
||||
|
||||
/*
|
||||
A simple regression test that shows how you use this API
|
||||
to write and read multi-timestep files of particle data.
|
||||
*/
|
||||
#ifdef PARALLEL_IO
|
||||
|
||||
int main(int argc,char *argv[]){
|
||||
int sz=5;
|
||||
double *x,*y,*z;
|
||||
h5part_int64_t *id;
|
||||
char name[64];
|
||||
H5PartFile *file;
|
||||
int i,t,nt,nds;
|
||||
int nprocs,myproc;
|
||||
hid_t gid;
|
||||
MPI_Comm comm=MPI_COMM_WORLD;
|
||||
|
||||
MPI_Init(&argc,&argv);
|
||||
MPI_Comm_size(comm,&nprocs);
|
||||
MPI_Comm_rank(comm,&myproc);
|
||||
|
||||
x=(double*)malloc(sz*nprocs*sizeof(double));
|
||||
y=(double*)malloc(sz*nprocs*sizeof(double));
|
||||
z=(double*)malloc(sz*nprocs*sizeof(double));
|
||||
id=(h5part_int64_t*)malloc(sz*nprocs*sizeof(h5part_int64_t));
|
||||
/* parallel file creation */
|
||||
file=H5PartOpenFileParallel("parttest.h5",H5PART_WRITE,comm);
|
||||
if(!file) {
|
||||
perror("File open failed: exiting!");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for(t=0;t<5;t++){
|
||||
MPI_Barrier(comm);
|
||||
for(i=0;i<sz;i++) {
|
||||
x[i]=(double)(i+t)+10.0*(double)myproc;
|
||||
y[i]=0.1 + (double)(i+t);
|
||||
z[i]=0.2 + (double)(i+t*10);
|
||||
id[i]=i+sz*myproc;
|
||||
}
|
||||
printf("Proc[%u] Writing timestep %u file=%u\n",myproc,t,file->file);
|
||||
H5PartSetStep(file,t); /* must set the current timestep in file */
|
||||
H5PartSetNumParticles(file,sz); /* then set number of particles to store */
|
||||
/* now write different tuples of data into this timestep of the file */
|
||||
H5PartWriteDataFloat64(file,"x",x);
|
||||
H5PartWriteDataFloat64(file,"y",y);
|
||||
H5PartWriteDataFloat64(file,"z",z);
|
||||
|
||||
H5PartWriteDataFloat64(file,"px",x);
|
||||
H5PartWriteDataFloat64(file,"py",y);
|
||||
H5PartWriteDataFloat64(file,"pz",z);
|
||||
|
||||
H5PartWriteDataInt64(file,"id",id);
|
||||
}
|
||||
|
||||
unsigned int idStart = 0+sz*myproc;
|
||||
unsigned int idEnd = (sz-1)+sz*myproc;
|
||||
|
||||
printf("AllDone p[%u]\n",myproc);
|
||||
H5PartCloseFile(file);
|
||||
MPI_Barrier(comm);
|
||||
|
||||
printf("p[%u:%u] : OK, close file and reopen for reading idStart %u idEnd %u \n",myproc,nprocs,idStart,idEnd);
|
||||
|
||||
file=H5PartOpenFileParallel("parttest.h5",H5PART_READ,comm);
|
||||
H5PartSetStep(file,0);
|
||||
unsigned int np = 0;
|
||||
// unsigned int np = (int)H5PartGetNumParticles(file);
|
||||
// nt=H5PartGetNumSteps(file); /* get number of steps in file */
|
||||
|
||||
//nds=H5PartGetNumDatasets(file); /* get number of datasets in timestep 0 */
|
||||
MPI_Barrier(comm);
|
||||
|
||||
// H5PartSetView(file,idStart,idEnd);
|
||||
|
||||
printf("steps= %u datasets= %u particles= %u\n",nt,nds,np);
|
||||
|
||||
if(x)
|
||||
free(x);
|
||||
if(y)
|
||||
free(y);
|
||||
if(z)
|
||||
free(z);
|
||||
if(id)
|
||||
free(id);
|
||||
|
||||
H5PartCloseFile(file);
|
||||
MPI_Barrier(comm);
|
||||
fprintf(stderr,"proc[%u]: done\n",myproc);
|
||||
return MPI_Finalize();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <hdf5.h>
|
||||
#include "H5Part.h"
|
||||
|
||||
|
||||
/*
|
||||
A simple regression test that shows how you use this API
|
||||
to write and read multi-timestep files of particle data.
|
||||
*/
|
||||
#ifdef PARALLEL_IO
|
||||
|
||||
int main(int argc,char *argv[]){
|
||||
int N = 10;
|
||||
int sz=0;
|
||||
double *x,*y,*z;
|
||||
h5_int64_t *id;
|
||||
h5_file_t *file;
|
||||
int i,t,nt,nds;
|
||||
int nprocs,myproc;
|
||||
|
||||
unsigned int np = 0;
|
||||
|
||||
MPI_Comm comm=MPI_COMM_WORLD;
|
||||
|
||||
MPI_Init(&argc,&argv);
|
||||
MPI_Comm_size(comm,&nprocs);
|
||||
MPI_Comm_rank(comm,&myproc);
|
||||
|
||||
/* parallel file creation */
|
||||
file=H5PartOpenFileParallel("parttest.h5",H5PART_WRITE,comm);
|
||||
if(!file) {
|
||||
perror("File open failed: exiting!");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for(t=0;t<5;t++){
|
||||
|
||||
MPI_Barrier(comm);
|
||||
|
||||
sz = myproc*N;
|
||||
// proc[0] sz = 10, (next step N=10), sz=10
|
||||
// proc[1] sz = 20, (next step N=20), sz=40
|
||||
fprintf(stderr,"proc[%u] sz=%u\n",myproc,(unsigned)sz);
|
||||
x =(double*)malloc(1+sz*sizeof(double));
|
||||
y =(double*)malloc(1+sz*sizeof(double));
|
||||
z =(double*)malloc(1+sz*sizeof(double));
|
||||
id=(h5_int64_t*)malloc(1+sz*sizeof(h5_int64_t));
|
||||
|
||||
for(i=0;i<sz;i++) {
|
||||
x[i]=(double)(i+t)+10.0*(double)myproc;
|
||||
y[i]=0.1 + (double)(i+t);
|
||||
z[i]=0.2 + (double)(i+t*10);
|
||||
id[i]=i+sz*myproc;
|
||||
}
|
||||
|
||||
fprintf(stderr,"Proc[%u] Writing timestep %u Np=%u\n",myproc,t,sz);
|
||||
|
||||
H5PartSetStep(file,t); /* must set the current timestep in file */
|
||||
|
||||
fprintf(stderr,"Proc[%u]: setNumParticles start\n",myproc);
|
||||
H5PartSetNumParticles(file,sz); /* then set number of particles to store */
|
||||
fprintf(stderr,"Proc[%u]: setNumParticles done\n",myproc);
|
||||
|
||||
/* now write different tuples of data into this timestep of the file */
|
||||
fprintf(stderr,"Proc[%u]: WriteX start\n",myproc);
|
||||
H5PartWriteDataFloat64(file,"x",x);
|
||||
fprintf(stderr,"Proc[%u]: WriteX done\n",myproc);
|
||||
H5PartWriteDataFloat64(file,"y",y);
|
||||
H5PartWriteDataFloat64(file,"z",z);
|
||||
|
||||
H5PartWriteDataFloat64(file,"px",x);
|
||||
H5PartWriteDataFloat64(file,"py",y);
|
||||
H5PartWriteDataFloat64(file,"pz",z);
|
||||
|
||||
H5PartWriteDataInt64(file,"id",id);
|
||||
|
||||
if(x)
|
||||
free(x);
|
||||
if(y)
|
||||
free(y);
|
||||
if(z)
|
||||
free(z);
|
||||
if(id)
|
||||
free(id);
|
||||
|
||||
// remove the next line and everything is ok
|
||||
N = 1 + sz;
|
||||
}
|
||||
|
||||
printf("AllDone p[%u]\n",myproc);
|
||||
H5PartCloseFile(file);
|
||||
MPI_Barrier(comm);
|
||||
|
||||
unsigned int idStart = 0;
|
||||
unsigned int idEnd = myproc*10;
|
||||
printf("p[%u:%u] : OK, close file and reopen for reading idStart %u idEnd %u \n",myproc,nprocs,idStart,idEnd);
|
||||
|
||||
file=H5PartOpenFileParallel("parttest.h5",H5PART_READ,comm);
|
||||
H5PartSetStep(file,0);
|
||||
|
||||
nt = H5GetNumSteps(file); /* get number of steps in file */
|
||||
nds=H5PartGetNumDatasets(file); /* get number of datasets in timestep 0 */
|
||||
|
||||
MPI_Barrier(comm);
|
||||
|
||||
H5PartSetView(file,idStart,idEnd);
|
||||
np = H5PartGetNumParticles(file);
|
||||
printf("steps= %u datasets= %u particles= %u\n",nt,nds,np);
|
||||
|
||||
H5PartCloseFile(file);
|
||||
MPI_Barrier(comm);
|
||||
fprintf(stderr,"proc[%u]: done\n",myproc);
|
||||
return MPI_Finalize();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,296 +0,0 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "H5hut.h"
|
||||
|
||||
/*
|
||||
A simple regression test that shows how you use this API
|
||||
to write and read multi-timestep files of particle data.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef PARALLEL_IO
|
||||
|
||||
int main(int argc,char *argv[]){
|
||||
int sz=5;
|
||||
double *x,*y,*z;
|
||||
h5_int64_t *id;
|
||||
h5_file_t *file;
|
||||
int i,t,nt,nds;
|
||||
int nprocs,myproc;
|
||||
MPI_Comm comm=MPI_COMM_WORLD;
|
||||
|
||||
MPI_Init(&argc,&argv);
|
||||
MPI_Comm_size(comm,&nprocs);
|
||||
MPI_Comm_rank(comm,&myproc);
|
||||
|
||||
x=(double*)malloc(sz*nprocs*sizeof(double));
|
||||
y=(double*)malloc(sz*nprocs*sizeof(double));
|
||||
z=(double*)malloc(sz*nprocs*sizeof(double));
|
||||
id=(h5_int64_t*)malloc(sz*nprocs*sizeof(h5_int64_t));
|
||||
/* parallel file creation */
|
||||
file=H5OpenFile ("parttest.h5",H5_O_WRONLY,comm);
|
||||
if(!file) {
|
||||
perror("File open failed: exiting!");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for(t=0;t<5;t++){
|
||||
MPI_Barrier(comm);
|
||||
for(i=0;i<sz;i++) {
|
||||
x[i]=(double)(i+t)+10.0*(double)myproc;
|
||||
y[i]=0.1 + (double)(i+t);
|
||||
z[i]=0.2 + (double)(i+t*10);
|
||||
id[i]=i+sz*myproc;
|
||||
}
|
||||
printf("Proc[%u] Writing timestep %u \n",myproc,t);
|
||||
H5SetStep(file,t); /* must set the current timestep in file */
|
||||
H5PartSetNumParticles(file,sz); /* then set number of particles to store */
|
||||
/* now write different tuples of data into this timestep of the file */
|
||||
H5PartWriteDataFloat64(file,"x",x);
|
||||
H5PartWriteDataFloat64(file,"y",y);
|
||||
H5PartWriteDataFloat64(file,"z",z);
|
||||
|
||||
H5PartWriteDataFloat64(file,"px",x);
|
||||
H5PartWriteDataFloat64(file,"py",y);
|
||||
H5PartWriteDataFloat64(file,"pz",z);
|
||||
|
||||
H5PartWriteDataInt64(file,"id",id);
|
||||
}
|
||||
|
||||
unsigned int idStart = 0+sz*myproc;
|
||||
unsigned int idEnd = (sz-1)+sz*myproc;
|
||||
|
||||
printf("AllDone p[%u]\n",myproc);
|
||||
H5CloseFile(file);
|
||||
fprintf(stderr,"Closed files p[%u]\n",myproc);
|
||||
MPI_Barrier(comm);
|
||||
|
||||
fprintf(stderr,"p[%u:%u] : OK, close file and reopen for reading idStart %u idEnd %u \n",myproc,nprocs,idStart,idEnd);
|
||||
|
||||
file=H5OpenFile("parttest.h5",H5_O_RDONLY,comm);
|
||||
H5SetStep(file,0);
|
||||
// unsigned int np = 0;
|
||||
unsigned int np = (int)H5PartGetNumParticles(file);
|
||||
nt=H5GetNumSteps(file); /* get number of steps in file */
|
||||
nds=H5PartGetNumDatasets(file); /* get number of datasets in timestep 0 */
|
||||
|
||||
MPI_Barrier(comm);
|
||||
|
||||
H5PartSetView(file,idStart,idEnd);
|
||||
|
||||
np = (int)H5PartGetNumParticles(file);
|
||||
printf("After SetView(%d,%d): steps= %u datasets= %u particles= %u\n",
|
||||
(int)idStart,(int)idEnd,
|
||||
nt,nds,np);
|
||||
|
||||
if(x)
|
||||
free(x);
|
||||
if(y)
|
||||
free(y);
|
||||
if(z)
|
||||
free(z);
|
||||
if(id)
|
||||
free(id);
|
||||
|
||||
H5CloseFile(file);
|
||||
MPI_Barrier(comm);
|
||||
fprintf(stderr,"proc[%u]: done\n",myproc);
|
||||
return MPI_Finalize();
|
||||
}
|
||||
|
||||
#else
|
||||
int main(int argc,char *argv[]){
|
||||
int sz=10;
|
||||
double *x,*y,*z;
|
||||
h5_int64_t *id;
|
||||
h5_file_t *file;
|
||||
int i,t,nt,nds,np;
|
||||
h5_int64_t idStart = 0;
|
||||
h5_int64_t idEnd = 0;
|
||||
|
||||
|
||||
x=(double*)malloc(sz*sizeof(double));
|
||||
y=(double*)malloc(sz*sizeof(double));
|
||||
z=(double*)malloc(sz*sizeof(double));
|
||||
id=(h5_int64_t*)malloc(sz*sizeof(h5_int64_t));
|
||||
/* parallel file creation */
|
||||
file=H5PartOpenFile("parttest.h5",H5_O_WRONLY);
|
||||
if(!file) {
|
||||
perror("File open failed: exiting!");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
H5PartWriteFileAttribString(file,"File Description", "This file is created by H5PartTest.cc. Simple H5Part file for testing purpose...");
|
||||
char* FileAttrib = "Created by H5PartTest.cc";
|
||||
H5PartWriteFileAttrib(file, "Origin", H5T_NATIVE_CHAR, FileAttrib ,strlen(FileAttrib));
|
||||
|
||||
for(t=0;t<5;t++){
|
||||
fprintf(stdout,"Writing timestep %u\n",t);
|
||||
for(i=0;i<sz;i++) {
|
||||
x[i]=(double)(i+t);
|
||||
y[i]=0.1 + (double)(i+t);
|
||||
z[i]=0.2 + (double)(i+t*10);
|
||||
id[i]=i;
|
||||
fprintf(stdout,"\tp[%u] x=%f y=%f z=%f id=%d\n",
|
||||
i,x[i],y[i],z[i],(int)id[i]);
|
||||
}
|
||||
H5PartSetStep(file,t); /* must set the current timestep in file */
|
||||
|
||||
H5PartSetNumParticles(file,sz); /* then set number of particles to store */
|
||||
/* now write different tuples of data into this timestep of the file */
|
||||
H5PartWriteDataFloat64(file,"x",x);
|
||||
H5PartWriteDataFloat64(file,"y",y);
|
||||
H5PartWriteDataFloat64(file,"z",z);
|
||||
|
||||
H5PartWriteDataFloat64(file,"px",x);
|
||||
H5PartWriteDataFloat64(file,"py",y);
|
||||
H5PartWriteDataFloat64(file,"pz",z);
|
||||
|
||||
H5PartWriteDataInt64(file,"id",id);
|
||||
|
||||
H5PartWriteStepAttribString(file,"Step Description", "STEP STEP STEP");
|
||||
char* StepAttrib = "STEP";
|
||||
H5PartWriteStepAttrib(file, "Step", H5T_NATIVE_CHAR, StepAttrib ,strlen(StepAttrib));
|
||||
}
|
||||
|
||||
|
||||
printf("AllDone writing\n");
|
||||
H5PartCloseFile(file);
|
||||
|
||||
|
||||
/*+++++++++++++ Reopen File for Reading +++H5PartSetStep(h5partFile,0)++++++++*/
|
||||
file=H5PartOpenFile("parttest.h5",H5_O_RDONLY);
|
||||
|
||||
|
||||
/********************************************/
|
||||
H5PartSetStep(file,0);
|
||||
nt=H5GetNumSteps(file); /* get number of steps in file */
|
||||
nds=H5PartGetNumDatasets(file); /* get number of datasets in timestep 0 */
|
||||
np=H5PartGetNumParticles(file);
|
||||
|
||||
|
||||
fprintf(stdout,"OK, close file and reopen for reading\n");
|
||||
fprintf(stdout,"steps= %u\tdatasets=%u\tparticles= %u\n",
|
||||
nt,nds,np);
|
||||
|
||||
// clear the particles
|
||||
for(i=0;i<np;i++){
|
||||
x[i]=y[i]=z[i]=0.0;
|
||||
id[i]=0;
|
||||
}
|
||||
|
||||
H5PartReadDataFloat64(file,"x",x);
|
||||
H5PartReadDataFloat64(file,"y",y);
|
||||
H5PartReadDataFloat64(file,"z",z);
|
||||
H5PartReadDataInt64(file,"id",id);
|
||||
|
||||
for(i=0;i<np;i++){
|
||||
fprintf(stdout,
|
||||
"\tp[%3u] x=%lf y=%lf z=%lf id=%lld\n",
|
||||
i,x[i],y[i],z[i],(long long)(id[i]));
|
||||
}
|
||||
/************************ std::cout << "nParticles: " << nParticles << std::endl;
|
||||
********************/
|
||||
printf("Set to last step and reload data\n");
|
||||
H5PartSetStep(file,nt-1);
|
||||
H5PartReadDataFloat64(file,"x",x);
|
||||
H5PartReadDataFloat64(file,"y",y);
|
||||
H5PartReadDataFloat64(file,"z",z);
|
||||
H5PartReadDataInt64(file,"id",id);
|
||||
for(i=0;i<np;i++){
|
||||
fprintf(stdout,"\tp[%3u] x=%lf y=%lf z=%lf id=%lld\n",
|
||||
i,x[i],y[i],z[i],(long long) (id[i]));
|
||||
}
|
||||
|
||||
/********************************************/
|
||||
idEnd=np;
|
||||
printf("Old View is %d:%d\n",(int)idStart,(int)idEnd);
|
||||
H5PartSetView(file,idStart,idEnd>>1);
|
||||
printf("Set new view = %d:%d\n",(int)idStart,(int)(idEnd>>1));
|
||||
H5PartGetView(file,&idStart,&idEnd);
|
||||
np=H5PartGetNumParticles(file);
|
||||
printf("steps= %u datasets= %u particles= %d with view %d:%d\n",
|
||||
nt,nds,(int)np,(int)idStart,(int)idEnd);
|
||||
H5PartSetStep(file,nt-1); // set to last step
|
||||
printf("Setting to last step = %u\n",nt-1);
|
||||
for(i=0;i<10;i++){ x[i]=y[i]=z[i]=0.0; id[i]=0; } /* clear the arrays */
|
||||
H5PartReadDataFloat64(file,"x",x);
|
||||
H5PartReadDataFloat64(file,"y",y);
|
||||
H5PartReadDataFloat64(file,"z",z);
|
||||
H5PartReadDataInt64(file,"id",id);
|
||||
|
||||
for(i=0;i<np;i++){
|
||||
fprintf(stdout,
|
||||
"\tp[%3u] x=%lf y=%lf z=%lf id=%lld\n",
|
||||
i,x[i],y[i],z[i],(long long)id[i]);
|
||||
}
|
||||
|
||||
/********************************************/
|
||||
printf("Now set the view to the latter half of the data in step #%u\n",nt-1);
|
||||
H5PartResetView(file);
|
||||
H5PartGetView(file,&idStart,&idEnd);
|
||||
printf("Reset view = %d:%d\nSetting to %u:%u\n",
|
||||
(int)idStart,(int)idEnd,
|
||||
(int)idEnd>>1,(int)idEnd);
|
||||
H5PartSetView(file,(idEnd>>1),idEnd);
|
||||
np=H5PartGetNumParticles(file);
|
||||
printf("Now particles in selection are %d\n",np);
|
||||
printf("doubleCheck=%lld\n", (long long)H5PartGetView(file,0,0));
|
||||
|
||||
for(i=0;i<10;i++){ x[i]=y[i]=z[i]=0.0; id[i]=0; } /* clear the arrays */
|
||||
|
||||
H5PartReadDataFloat64(file,"x",x);
|
||||
H5PartReadDataFloat64(file,"y",y);
|
||||
H5PartReadDataFloat64(file,"z",z);
|
||||
H5PartReadDataInt64(file,"id",id);
|
||||
for(i=0;i<np;i++){
|
||||
fprintf(stdout,
|
||||
"\tp[%3u] x=%lf y=%lf z=%lf id=%lld\n",
|
||||
i,x[i],y[i],z[i],(long long)id[i]);
|
||||
}
|
||||
|
||||
// read dataset names
|
||||
h5_int64_t status = H5_SUCCESS;
|
||||
const h5_int64_t lenName = 64;
|
||||
char datasetName[lenName];
|
||||
h5_int64_t datasetType;
|
||||
h5_int64_t datasetNElems;
|
||||
|
||||
H5PartSetStep(file,0);
|
||||
for (h5_int64_t i=0; i < nds; i++) {
|
||||
status = H5PartGetDatasetInfo(file, i, datasetName, lenName,
|
||||
&datasetType, &datasetNElems);
|
||||
|
||||
if (status != H5_SUCCESS) {
|
||||
perror("Could not retrieve dataset names!");
|
||||
}
|
||||
else {
|
||||
printf("datasetName: %s, type: %lld, nElements: %lld ",
|
||||
datasetName, datasetType, datasetNElems);
|
||||
if (datasetType == H5_INT64_T) {
|
||||
printf("H5PPART_INT64 \n");
|
||||
}
|
||||
else {
|
||||
printf("H5PPART_FLOAT64 \n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(x)
|
||||
free(x);
|
||||
if(y)
|
||||
free(y);
|
||||
if(z)
|
||||
free(z);
|
||||
if(id)
|
||||
free(id);
|
||||
|
||||
H5PartCloseFile(file);
|
||||
|
||||
fprintf(stderr,"done\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <hdf5.h>
|
||||
#include "H5Part.h"
|
||||
|
||||
#ifdef PARALLEL_IO
|
||||
|
||||
/*
|
||||
This regression test is used to ensure parallel I/O is
|
||||
working correctly and that Views are working for
|
||||
parallel reads.
|
||||
*/
|
||||
int main(int argc,char *argv[]){
|
||||
const int sz=5000;
|
||||
double *x,*y,*z;
|
||||
h5part_int64_t *id;
|
||||
char name[64];
|
||||
H5PartFile *file;
|
||||
int i,t,nt,nds;
|
||||
int nprocs,myproc;
|
||||
hid_t gid;
|
||||
MPI_Comm comm=MPI_COMM_WORLD;
|
||||
|
||||
MPI_Init(&argc,&argv);
|
||||
MPI_Comm_size(comm,&nprocs);
|
||||
MPI_Comm_rank(comm,&myproc);
|
||||
|
||||
x=(double*)malloc(sz*nprocs*sizeof(double));
|
||||
y=(double*)malloc(sz*nprocs*sizeof(double));
|
||||
z=(double*)malloc(sz*nprocs*sizeof(double));
|
||||
id=(h5part_int64_t*)malloc(sz*nprocs*sizeof(h5part_int64_t));
|
||||
/* parallel file creation */
|
||||
file=H5PartOpenFileParallel("parttest.h5",H5PART_WRITE,comm);
|
||||
if(!file) {
|
||||
perror("File open failed: exiting!");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for(t=0;t<5;t++){
|
||||
MPI_Barrier(comm);
|
||||
for(i=0;i<sz;i++) {
|
||||
x[i]=(double)(i+t)+10.0*(double)myproc;
|
||||
y[i]=0.1 + (double)(i+t);
|
||||
z[i]=0.2 + (double)(i+t*10);
|
||||
id[i]=i+sz*myproc;
|
||||
}
|
||||
printf("Proc[%u] Writing timestep %u\n",myproc,t);
|
||||
if(t==0){
|
||||
printf("Proc[%u]: data values x[first,last]=%f:%f y[%u:%u]=%f:%f z[:]=%f:%f id[:]=%f:%f\n",
|
||||
myproc,x[0],x[sz-1],0,sz-1,y[0],y[sz-1],z[0],z[sz-1],(int)id[0],(int)id[sz-1]);
|
||||
}
|
||||
H5PartSetStep(file,t); /* must set the current timestep in file */
|
||||
H5PartSetNumParticles(file,sz); /* then set number of particles to store */
|
||||
/* now write different tuples of data into this timestep of the file */
|
||||
H5PartWriteDataFloat64(file,"x",x);
|
||||
H5PartWriteDataFloat64(file,"y",y);
|
||||
H5PartWriteDataFloat64(file,"z",z);
|
||||
|
||||
H5PartWriteDataFloat64(file,"px",x);
|
||||
H5PartWriteDataFloat64(file,"py",y);
|
||||
H5PartWriteDataFloat64(file,"pz",z);
|
||||
|
||||
H5PartWriteDataInt64(file,"id",id);
|
||||
}
|
||||
|
||||
printf("AllDone p[%u]\n",myproc);
|
||||
H5PartCloseFile(file);
|
||||
MPI_Barrier(comm);
|
||||
|
||||
printf("p[%u:%u] : OK, close file and reopen for reading\n",myproc,nprocs);
|
||||
|
||||
file=H5PartOpenFileParallel("parttest.h5",H5PART_READ,comm);
|
||||
H5PartSetStep(file,0);
|
||||
unsigned int np,total_np = (int)H5PartGetNumParticles(file);
|
||||
nt=H5PartGetNumSteps(file); /* get number of steps in file */
|
||||
nds = H5PartGetNumDatasets(file);
|
||||
if(myproc==0){
|
||||
fprintf(stdout,"steps= %u\tdatasets=%u\tparticles= %u\n",
|
||||
nt,nds,total_np);
|
||||
}
|
||||
MPI_Barrier(comm);
|
||||
|
||||
/* now lets compute the appropriate idStart and idEnd
|
||||
for this particular processor */
|
||||
|
||||
h5part_int64_t idStart = sz*myproc;
|
||||
h5part_int64_t idEnd = (sz-1)+sz*myproc;
|
||||
H5PartSetView(file,idStart,idEnd);
|
||||
np=H5PartGetNumParticles(file);
|
||||
printf("Proc[%u]: View=%u:%u : particles= %u\n",
|
||||
myproc,(int)idStart,(int)idEnd,H5PartGetNumParticles(file));
|
||||
/* now lets read them and print some out */
|
||||
H5PartReadDataFloat64(file,"x",x);
|
||||
H5PartReadDataFloat64(file,"y",y);
|
||||
H5PartReadDataFloat64(file,"z",z);
|
||||
H5PartReadDataInt64(file,"id",id);
|
||||
printf("Proc[%u]: data values x[first,last]=%f:%f y[%u:%u]=%f:%f z[:]=%f:%f id[:]=%f:%f\n",
|
||||
myproc,x[0],x[sz-1],(int)idStart,(int)idEnd,y[0],y[sz-1],z[0],z[sz-1],(int)id[0],(int)id[sz-1]);
|
||||
|
||||
/* H5PartCloseFile(file); MPI_Finalize(); exit(0); */
|
||||
|
||||
if(x)
|
||||
free(x);
|
||||
if(y)
|
||||
free(y);
|
||||
if(z)
|
||||
free(z);
|
||||
if(id)
|
||||
free(id);
|
||||
|
||||
H5PartCloseFile(file);
|
||||
MPI_Barrier(comm);
|
||||
fprintf(stderr,"proc[%u]: done\n",myproc);
|
||||
return MPI_Finalize();
|
||||
}
|
||||
|
||||
#else
|
||||
#error This file only works when PARALLEL_IO is enabled.
|
||||
#endif
|
||||
@@ -1,147 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <hdf5.h>
|
||||
#include "H5Part.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
|
||||
/*
|
||||
A simple regression test that shows how you use this API
|
||||
to write and read multi-timestep files of particle data.
|
||||
*/
|
||||
|
||||
int ReadFile(const string fn){
|
||||
char name[64];
|
||||
h5_file_t *file;
|
||||
int i,nt,nds;
|
||||
cout << "Open " << fn << endl;
|
||||
|
||||
file= H5PartOpenFile(fn.c_str(),H5_O_RDONLY);
|
||||
|
||||
nt=H5GetNumSteps(file);
|
||||
H5PartSetStep(file,0);
|
||||
nds=H5PartGetNumDatasets(file);
|
||||
|
||||
cout << "Timesteps = " << nt << " dataSets per timestep = " << nds << endl;
|
||||
|
||||
cout << endl << endl << "===============================" << endl;
|
||||
for(i=0;i<nds;i++){
|
||||
H5PartGetDatasetName(file,i,name,64);
|
||||
printf("\tDataset[%u] name=[%s]\n",
|
||||
i,name);
|
||||
}
|
||||
cout << "===============================" << endl << endl;;
|
||||
|
||||
for (int steps=0; steps<nt; steps++) {
|
||||
H5PartSetStep(file,steps);
|
||||
h5_int64_t n = H5PartGetNumParticles(file);
|
||||
cout << "number of particles this step =" << n << endl;
|
||||
double *x=new double[n];
|
||||
double *y=new double[n];
|
||||
double *z=new double[n];
|
||||
double *px=new double[n];
|
||||
double *py=new double[n];
|
||||
double *pz=new double[n];
|
||||
h5_int64_t *id=new h5_int64_t[n];
|
||||
|
||||
H5PartReadParticleStep(file,steps,x,y,z,px,py,pz,id);
|
||||
|
||||
double sumx = 0.0;
|
||||
double sumpz = 0.0;
|
||||
for (h5_int64_t i=0; i<n; i++) {
|
||||
sumx += x[i];
|
||||
sumpz += pz[i];
|
||||
}
|
||||
|
||||
cout << "\tstep= " << steps << " sum(x)= " << sumx << " sum(pz)= " << sumpz << endl;
|
||||
cout << "\tfirst x is " << x[0] << "\tlast x is " << x[n-1] << endl;
|
||||
cout << "\tFor fake data, expect sumx to be =" << x[0]*((double)n)<<endl;
|
||||
delete x;
|
||||
delete y;
|
||||
delete z;
|
||||
delete px;
|
||||
delete py;
|
||||
delete pz;
|
||||
delete id;
|
||||
}
|
||||
H5PartCloseFile(file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int WriteFile(const string fn){
|
||||
h5_file_t *file;
|
||||
int i,t;
|
||||
h5_int64_t n;
|
||||
const int nt = 5;
|
||||
const h5_int64_t np = 1024*1024;
|
||||
cout << "Open " << fn << endl;
|
||||
|
||||
file= H5PartOpenFile(fn.c_str(),H5_O_WRONLY);
|
||||
|
||||
double *x=new double[np];
|
||||
double *y=new double[np];
|
||||
double *z=new double[np];
|
||||
double *px=new double[np];
|
||||
double *py=new double[np];
|
||||
double *pz=new double[np];
|
||||
h5_int64_t *id=new h5_int64_t[np];
|
||||
|
||||
H5PartSetNumParticles(file,np); // sets number of particles in simulation
|
||||
|
||||
for(n=0;n<np;n++) {
|
||||
id[n]=i;
|
||||
x[n]=1.0;
|
||||
y[n]=2.0;
|
||||
z[n]=3.0;
|
||||
px[n]=1.0*((double)i)*((double)(i%10));
|
||||
py[n]=2.0*((double)i)*((double)(i%10));
|
||||
pz[n]=3.0*((double)i)*((double)(i%10));
|
||||
}
|
||||
|
||||
for(t=0;t<nt;t++){
|
||||
// setup the step number
|
||||
H5PartSetStep(file,t);
|
||||
printf("Write Step %u\n",t);
|
||||
// write fake data
|
||||
H5PartWriteDataFloat64(file,"x",x);
|
||||
H5PartWriteDataFloat64(file,"y",y);
|
||||
H5PartWriteDataFloat64(file,"z",z);
|
||||
H5PartWriteDataFloat64(file,"px",px);
|
||||
H5PartWriteDataFloat64(file,"py",py);
|
||||
H5PartWriteDataFloat64(file,"pz",pz);
|
||||
H5PartWriteDataInt64(file,"id",id);
|
||||
}
|
||||
|
||||
H5PartCloseFile(file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc,char **argv){
|
||||
char *str;
|
||||
char dstr[]="testfile.h5";
|
||||
|
||||
if(argc>1) str=argv[1];
|
||||
else str=dstr;
|
||||
const string fn = string(str);
|
||||
/* f=fopen(fn.c_str(),"r");
|
||||
if(f!=NULL) { a poor-man's stat()
|
||||
fclose(f);
|
||||
*/
|
||||
if(!WriteFile(fn)){
|
||||
cerr << "Failed to write file " << fn << endl;
|
||||
exit(0);
|
||||
}
|
||||
/*
|
||||
}
|
||||
else {
|
||||
cout << "File " << fn << " already exists, so we will proceed to reading" << endl;
|
||||
} */
|
||||
if(!ReadFile(fn)){
|
||||
cerr << "Failed to read file " << fn << endl;
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
c ==============
|
||||
c
|
||||
c Sample Fortran program that uses HDF5 bindings
|
||||
c
|
||||
c ==============
|
||||
|
||||
program H5testF
|
||||
implicit none
|
||||
include 'H5Part.inc'
|
||||
INTEGER*8 file
|
||||
INTEGER*8 nstep,ndata
|
||||
INTEGER*8 npoints
|
||||
INTEGER*8 step
|
||||
INTEGER*8 err
|
||||
INTEGER*8 I,J
|
||||
REAL*8,ALLOCATABLE:: X(:),Y(:),Z(:),PX(:),PY(:),PZ(:)
|
||||
INTEGER*8,ALLOCATABLE:: ID(:)
|
||||
REAL*8 REALTIME
|
||||
file = h5pt_openw("testfilef.h5")
|
||||
print *,"Opened file testfilef.h5 for writing"
|
||||
npoints = 1024
|
||||
nstep = 10
|
||||
ALLOCATE(X(npoints),Y(npoints),Z(npoints))
|
||||
ALLOCATE(PX(npoints),PY(npoints),PZ(npoints))
|
||||
ALLOCATE(ID(npoints))
|
||||
print *," Npoints=",npoints," nsteps=",nstep
|
||||
print *," writing X,Y,Z,PX,PY,PZ,ID"
|
||||
print *," ... initialize the data arrays"
|
||||
do I=1,npoints
|
||||
X(I)=0.0
|
||||
Y(I)=1.0+I
|
||||
Z(I)=100.0+I*2.0
|
||||
ID(I)=I
|
||||
enddo
|
||||
print *,"Tell h5pt how many particles are stored in the file"
|
||||
c set the number of points
|
||||
err = h5pt_setnpoints(file,npoints)
|
||||
print *,"write an attribute string"
|
||||
c write an annotation to the file
|
||||
err=h5pt_writefileattrib_string(file,"Annotation","Testing 1 2 3")
|
||||
print *,"and now write the steps"
|
||||
do I=1,nstep
|
||||
c Set the step number
|
||||
print *,"Write Step ",I
|
||||
err = h5pt_setstep(file,I)
|
||||
c Now start writing the data arrays for this step
|
||||
err = h5pt_writedata_r8(file,"x",X)
|
||||
err = h5pt_writedata_r8(file,"y",Y)
|
||||
err = h5pt_writedata_r8(file,"z",Z)
|
||||
err = h5pt_writedata_r8(file,"px",PX)
|
||||
err = h5pt_writedata_r8(file,"py",PY)
|
||||
err = h5pt_writedata_r8(file,"pz",PZ)
|
||||
err = h5pt_writedata_i8(file,"id",ID)
|
||||
do J=1,npoints
|
||||
ID(J)=ID(J)+10
|
||||
enddo
|
||||
c And write a simple floatingpoint attribute associated with this timestep
|
||||
REALTIME = I*0.1
|
||||
err=h5pt_writestepattrib_r8(file,"RealTime",REALTIME,1)
|
||||
enddo
|
||||
print *,"Done writing, now close the file"
|
||||
err = h5pt_close(file)
|
||||
|
||||
c **************** Clean out some variables ***************
|
||||
nstep=0
|
||||
c npoints=0
|
||||
do I=1,npoints
|
||||
X(I)=-1.0
|
||||
Y(I)=-1.0
|
||||
Z(I)=-1.0
|
||||
ID(I)=0
|
||||
enddo
|
||||
|
||||
c *****************Now Reopen for Reading ******************
|
||||
|
||||
|
||||
print *,"Open file for reading"
|
||||
file = h5pt_openr("testfilef.h5")
|
||||
print *," Opened testfilef.h5"
|
||||
nstep = h5pt_getnsteps(file)
|
||||
print *," Nsteps = ",nstep
|
||||
err = h5pt_setstep(file,1_8)
|
||||
print *,"now get the number of datasets"
|
||||
ndata = h5pt_getndatasets(file)
|
||||
print *," Ndata=",ndata
|
||||
npoints = h5pt_getnpoints(file)
|
||||
print *," NP=",npoints
|
||||
|
||||
|
||||
|
||||
do step=1,nstep
|
||||
print *,"Read step ",step
|
||||
c set the current step
|
||||
err = h5pt_setstep(file,step)
|
||||
err=h5pt_readdata_i8(file,"id",ID)
|
||||
c read the Z data from the current step
|
||||
c err = h5prt_readdata(file,step,X,Y,Z,PX,PY,PZ,ID)
|
||||
do J=1,10
|
||||
print *," ID(",J,")==",ID(J)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
err = h5pt_close(file)
|
||||
print *,"done"
|
||||
|
||||
end
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
! ==============
|
||||
!
|
||||
! Sample Fortran program that uses HDF5 bindings
|
||||
!
|
||||
! ==============
|
||||
|
||||
program H5testFpar
|
||||
implicit none
|
||||
include 'mpif.h'
|
||||
include 'H5PartF90.inc'
|
||||
INTEGER*8 file
|
||||
INTEGER*8 nstep
|
||||
INTEGER*8 ndata
|
||||
INTEGER*8 npoints,pointoffset
|
||||
INTEGER*8 I,J,K,step
|
||||
REAL*8,ALLOCATABLE:: X(:),Y(:),Z(:),PX(:),PY(:),PZ(:)
|
||||
INTEGER*8,ALLOCATABLE:: ID(:)
|
||||
REAL*8 REALTIME(1)
|
||||
INTEGER myproc,nprocs
|
||||
INTEGER ierr
|
||||
INTEGER*8 rc
|
||||
INTEGER:: comm
|
||||
|
||||
INTEGER*8:: offset
|
||||
INTEGER*8, allocatable, dimension(:,:) :: Localnum1
|
||||
INTEGER*8, allocatable, dimension(:,:,:) :: Localnum
|
||||
INTEGER nprocrow, nproccol
|
||||
|
||||
call MPI_Init(ierr)
|
||||
comm = MPI_COMM_WORLD
|
||||
call MPI_Comm_rank(comm,myproc,ierr)
|
||||
call MPI_Comm_size(comm,nprocs,ierr)
|
||||
|
||||
file = h5pt_openw_par("testfilef.h5",comm)
|
||||
print *,"Opened file testfilef.h5 for writing"
|
||||
npoints = 1024
|
||||
nstep = 10
|
||||
ALLOCATE(X(npoints),Y(npoints),Z(npoints))
|
||||
ALLOCATE(PX(npoints),PY(npoints),PZ(npoints))
|
||||
ALLOCATE(ID(npoints))
|
||||
print *," Npoints=",npoints," nsteps=",nstep
|
||||
print *," writing X,Y,Z,PX,PY,PZ,ID"
|
||||
print *," ... initialize the data arrays"
|
||||
do I=1,npoints
|
||||
X(INT(I))=0.0
|
||||
Y(I)=1.0+REAL(I)
|
||||
Z(I)=100.0+REAL(I)*2.0
|
||||
ID(I)=I
|
||||
enddo
|
||||
print *,"Tell h5pt how many particles are stored in the file"
|
||||
! set the number of points
|
||||
rc = h5pt_setnpoints(file,npoints)
|
||||
print *,"write an attribute string"
|
||||
! write an annotation to the file
|
||||
rc=h5pt_writefileattrib_string(file,"Annotation","Testing 1 2 3")
|
||||
print *,"and now write the steps"
|
||||
|
||||
do step=1,nstep
|
||||
! Set the step number
|
||||
print *,"Write Step ",step
|
||||
rc = h5pt_setstep(file,step)
|
||||
! Now start writing the data arrays for this step
|
||||
rc = h5pt_writedata_r8(file,"x",X)
|
||||
rc = h5pt_writedata_r8(file,"y",Y)
|
||||
rc = h5pt_writedata_r8(file,"z",Z)
|
||||
rc = h5pt_writedata_r8(file,"px",PX)
|
||||
rc = h5pt_writedata_r8(file,"py",PY)
|
||||
rc = h5pt_writedata_r8(file,"pz",PZ)
|
||||
rc = h5pt_writedata_i8(file,"id",ID)
|
||||
do J=1,npoints
|
||||
ID(J)=ID(J)+10
|
||||
enddo
|
||||
! And write a simple floatingpoint attribute associated with this timestep
|
||||
REALTIME(1) = REAL(I)*0.1
|
||||
rc = h5pt_writestepattrib_r8(file,"RealTime",REALTIME,1_8)
|
||||
print*,'Write REALTIME ',REALTIME
|
||||
!
|
||||
! Test file arrtibutes
|
||||
!
|
||||
nprocrow=2
|
||||
nproccol=2
|
||||
print*,'Write localnum ',Localnum
|
||||
allocate(Localnum1(1,nprocrow*nproccol))
|
||||
allocate(Localnum(2,0:nprocrow-1,0:nproccol-1))
|
||||
!
|
||||
! init testdata
|
||||
!
|
||||
do k = 0, 1
|
||||
do i = 0,(nprocrow-1)
|
||||
do j = 0,(nproccol-1)
|
||||
Localnum(k,i,j) = k+i+j
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!
|
||||
offset=0
|
||||
do i = 0, (nprocrow-1)
|
||||
do j = 0,(nproccol-1)
|
||||
Localnum1(offset) = Localnum(1,i,j)
|
||||
offset = offset + 1
|
||||
enddo
|
||||
enddo
|
||||
rc = h5pt_writestepattrib_i8(file,"Localnum1",Localnum1(:),offset)
|
||||
print*,'rc (Localnum1)= ',rc
|
||||
|
||||
enddo
|
||||
|
||||
print *,"Done writing, now close the file"
|
||||
rc = h5pt_close(file)
|
||||
|
||||
! **************** Clean out some variables ***************
|
||||
nstep=0
|
||||
! npoints=0
|
||||
do I=1,npoints
|
||||
X(I)=-1.0
|
||||
Y(I)=-1.0
|
||||
Z(I)=-1.0
|
||||
ID(I)=0
|
||||
enddo
|
||||
|
||||
do k = 0, 1
|
||||
do i = 0,(nprocrow-1)
|
||||
do j = 0,(nproccol-1)
|
||||
Localnum(k,i,j) = 0
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
REALTIME(1) = 0.0
|
||||
|
||||
! *****************Now Reopen for Reading ******************
|
||||
|
||||
print *,"Open file for reading"
|
||||
file = h5pt_openr_par("testfilef.h5",comm)
|
||||
print *," Opened testfilef.h5"
|
||||
nstep = h5pt_getnsteps(file)
|
||||
print *," Nsteps = ",nstep
|
||||
rc = h5pt_setstep(file,1_8)
|
||||
print *,"now get the number of datasets"
|
||||
ndata = h5pt_getndatasets(file)
|
||||
print *," Ndata=",ndata
|
||||
npoints = h5pt_getnpoints(file)
|
||||
print *," Total NP=",npoints
|
||||
npoints = npoints/nprocs
|
||||
pointoffset = npoints*myproc;
|
||||
rc = h5pt_setview(file,pointoffset,pointoffset+npoints)
|
||||
print *," Pointoffset=",pointoffset," Local NP=",npoints
|
||||
! Now we need to set our view to read correct points
|
||||
|
||||
|
||||
do step=1,nstep
|
||||
print *,"Read step ",step
|
||||
! set the current step
|
||||
rc = h5pt_setstep(file,step)
|
||||
rc = h5pt_readdata_i8(file,"id",ID)
|
||||
rc = h5pt_readstepattrib_r8(file,"RealTime",REALTIME)
|
||||
print*,'Read REALTIME ',REALTIME
|
||||
rc = h5pt_readstepattrib_i8(file,"Localnum1",Localnum1)
|
||||
print*,'Read Localnum ',Localnum1
|
||||
! read the Z data from the current step
|
||||
! rc = h5prt_readdata(file,step,X,Y,Z,PX,PY,PZ,ID)
|
||||
! do J=1,10
|
||||
! print *," ID(",J,")==",ID(J)
|
||||
! enddo
|
||||
enddo
|
||||
|
||||
rc = h5pt_close(file)
|
||||
print *,"done"
|
||||
call MPI_Finalize(ierr)
|
||||
|
||||
end
|
||||
+62
-123
@@ -1,139 +1,78 @@
|
||||
# test level Makefile.am
|
||||
#
|
||||
# Copyright (c) 2006-2017, 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.!
|
||||
#
|
||||
# License: see file COPYING in top level of source distribution.
|
||||
#
|
||||
|
||||
# PATH SETTING
|
||||
HDF5ROOT = @HDF5ROOT@
|
||||
AM_CPPFLAGS += -I${abs_top_srcdir}/src/include
|
||||
AM_CPPFLAGS += -I${abs_top_srcdir}/examples/include
|
||||
FFLAGS += -cpp $(AM_CPPFLAGS)
|
||||
AM_LDFLAGS += -L${abs_top_builddir}/src/h5core/.libs
|
||||
|
||||
# COMPILER SETTING
|
||||
CXX = @CXX@
|
||||
FC = @FC@
|
||||
MPIFC = @MPIFC@
|
||||
MPICXX = @MPICXX@
|
||||
MPICC = @MPICC@
|
||||
LDADD =
|
||||
|
||||
# COMPILER FLAG SETTING
|
||||
CFLAGS = @CFLAGS@
|
||||
FFLAGS = @FFLAGS@ @MPIINC@
|
||||
if ENABLE_EXAMPLES
|
||||
if ENABLE_C
|
||||
LDADD +=
|
||||
endif
|
||||
|
||||
# LIBRARIES
|
||||
SZLIB = @SZLIB@
|
||||
HDFLIB = -L$(HDF5ROOT)/lib -lhdf5 -lz $(SZLIB) @LDFLAGS@
|
||||
MPILIB = @MPILIB@
|
||||
H5LIB = -L${abs_top_builddir}/src/lib -lH5Core -lH5
|
||||
if ENABLE_FORTRAN
|
||||
LDADD += -lH5hutF
|
||||
AM_LDFLAGS += -L${abs_top_builddir}/src/Fortran/.libs
|
||||
endif
|
||||
|
||||
LIBS = ${H5LIB} $(HDFLIB) $(MPILIB) -lm @STDCXX@
|
||||
LDADD += -lH5hut
|
||||
|
||||
# H5Part compiled library location
|
||||
# H5PLIB = -L@prefix@/lib
|
||||
noinst_PROGRAMS =
|
||||
|
||||
# INCLUDES
|
||||
HDFINC = -I$(HDF5ROOT)/include
|
||||
MPIINC = @MPIINC@
|
||||
H5INC = -I${abs_top_builddir}/src/include
|
||||
if ENABLE_C
|
||||
noinst_PROGRAMS += \
|
||||
query \
|
||||
read_core_vfd \
|
||||
read_canonicalview \
|
||||
read_setnparticles \
|
||||
read_setview \
|
||||
read_strided \
|
||||
write_core_vfd \
|
||||
write_setnparticles \
|
||||
write_setview \
|
||||
write_strided
|
||||
endif
|
||||
|
||||
INC = $(HDFINC) $(MPIINC) $(H5INC)
|
||||
if ENABLE_FORTRAN
|
||||
noinst_PROGRAMS += \
|
||||
read_core_vfdf \
|
||||
read_canonicalviewf \
|
||||
read_setnparticlesf \
|
||||
read_setviewf \
|
||||
read_stridedf \
|
||||
write_core_vfdf \
|
||||
write_setnparticlesf \
|
||||
write_setviewf \
|
||||
write_stridedf
|
||||
endif
|
||||
|
||||
EXTRA_PROGRAMS =
|
||||
|
||||
# What to build... make install will place these files in the $(prefix)/bin directory.
|
||||
bin_PROGRAMS = @TPTARGET@
|
||||
read_core_vfdf_SOURCES = read_core_vfdf.f90
|
||||
read_canonicalviewf_SOURCES = read_canonicalviewf.f90
|
||||
read_setnparticlesf_SOURCES = read_setnparticlesf.f90
|
||||
read_setviewf_SOURCES = read_setviewf.f90
|
||||
read_stridedf_SOURCES = read_stridedf.f90
|
||||
write_core_vfdf_SOURCES = write_core_vfdf.f90
|
||||
write_setnparticlesf_SOURCES = write_setnparticlesf.f90
|
||||
write_setviewf_SOURCES = write_setviewf.f90
|
||||
write_stridedf_SOURCES = write_stridedf.f90
|
||||
|
||||
# Some useful scripts that I wish to place in the $(prefix)/bin directory.
|
||||
bin_SCRIPTS =
|
||||
#bin_SCRIPTS = JAC_H5PartTestP_script.scr JAC_H5testFpar_script.scr JAC_RUN_ALL_script.scr
|
||||
|
||||
|
||||
# Listing of all programs that maybe built. (Has to know statically...)
|
||||
EXTRA_PROGRAMS =
|
||||
|
||||
# Extra files that I wish to include in the dist tar ball.
|
||||
EXTRA_DIST = Bench.c \
|
||||
H5ParallelTest.cc \
|
||||
H5PartTest.cc H5PartTestParallel.cc \
|
||||
H5PartAndreasTest.cc \
|
||||
H5test.cc H5testF.f \
|
||||
H5testFpar.f90 \
|
||||
$(bin_SCRIPTS)
|
||||
|
||||
# Specific building instruction (What compilers to use...)
|
||||
# ------------ Build Tests ------------
|
||||
|
||||
Bench: Bench.c
|
||||
$(CC) $(CFLAGS) $(INC) -o $@ $< $(H5PLIB) $(LIBS)
|
||||
|
||||
###############################################################################
|
||||
|
||||
H5PartTest: H5PartTest.o
|
||||
$(CXX) -o $@ $< $(H5PLIB) $(LIBS)
|
||||
|
||||
H5PartTest.o: H5PartTest.cc
|
||||
$(CXX) $(CFLAGS) $(INC) -DREGRESSIONTEST -g -c $<
|
||||
|
||||
###############################################################################
|
||||
|
||||
H5PartTestP: H5PartTestP.o
|
||||
$(CXX) $(INC) -o $@ $< $(H5LIB) $(LIBS)
|
||||
|
||||
H5PartTestP.o: H5PartTest.cc
|
||||
$(CXX) $(CFLAGS) $(INC) -DREGRESSIONTEST -c $< -o $@
|
||||
|
||||
###############################################################################
|
||||
|
||||
H5PartTestParallel: H5PartTestParallel.o
|
||||
$(CXX) -o $@ $< $(H5LIB) $(LIBS)
|
||||
|
||||
H5PartTestParallel.o: H5PartTestParallel.cc
|
||||
$(CXX) $(CFLAGS) $(INC) -c $<
|
||||
|
||||
###############################################################################
|
||||
|
||||
H5PartAndreasTest: H5PartAndreasTest.o
|
||||
$(CXX) -o $@ $< $(H5LIB) $(LIBS)
|
||||
|
||||
H5PartAndreasTest.o: H5PartAndreasTest.cc
|
||||
$(CXX) $(CFLAGS) $(INC) -c $<
|
||||
|
||||
###############################################################################
|
||||
|
||||
H5testF: H5testF.o
|
||||
$(FC) -o $@ $< $(H5LIB) -lH5PartF $(LIBS)
|
||||
|
||||
H5testF.o: H5testF.f
|
||||
$(FC) $(FFLAGS) -c $(H5INC) $<
|
||||
|
||||
###############################################################################
|
||||
|
||||
H5testFpar: H5testFpar.o
|
||||
$(MPIFC) -o $@ $< $(H5LIB) -lpH5PartF $(LIBS)
|
||||
|
||||
H5testFpar.o: H5testFpar.f90
|
||||
$(MPIFC) $(FFLAGS) -c $(H5INC) $<
|
||||
|
||||
###############################################################################
|
||||
|
||||
H5test: H5test.o
|
||||
$(CXX) -o $@ $< $(H5LIB) -lstdc++ $(LIBS)
|
||||
|
||||
H5test.o: H5test.cc
|
||||
$(CXX) $(CFLAGS) $(INC) -DREGRESSIONTEST -g -c $<
|
||||
|
||||
###############################################################################
|
||||
% : %.o
|
||||
$(CC) -o $@ $< $(H5LIB) $(LIBS)
|
||||
|
||||
%.o : %.c
|
||||
$(CC) $(CFLAGS) $(INC) -g -c $<
|
||||
endif
|
||||
|
||||
%.o : %.f90
|
||||
${FC} $(FFLAGS) -c $(H5INC) $<
|
||||
|
||||
###############################################################################
|
||||
clean:
|
||||
${RM} -f *~ *.o ${bin_PROGRAMS}
|
||||
|
||||
distclean: clean
|
||||
${RM} -rf .deps
|
||||
${RM} -rf .libs
|
||||
${RM} -f parttest.h5
|
||||
${RM} -rf config.status config.log config.h Makefile
|
||||
$(FC) $(FFLAGS) -c $<
|
||||
|
||||
clean-local:
|
||||
$(RM) -f *~
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
#define FNAME "example_setview.h5"
|
||||
#define VERBOSITY H5_VERBOSE_ERROR
|
||||
#define DEBUG_MSK 0
|
||||
|
||||
/*
|
||||
Due to the way types are defined in H5hut, we cannot use "switch() {}"
|
||||
*/
|
||||
const char*
|
||||
type2string (
|
||||
h5_int64_t type
|
||||
) {
|
||||
if (type == H5_FLOAT64_T)
|
||||
return "H5_FLOAT64_T";
|
||||
if (type == H5_FLOAT32_T)
|
||||
return "H5_FLOAT32_T";
|
||||
if (type == H5_INT64_T)
|
||||
return "H5_INT64_T";
|
||||
if (type == H5_INT32_T)
|
||||
return "H5_INT32_T";
|
||||
if (type == H5_STRING_T)
|
||||
return "H5_STRING_T";
|
||||
return "unknown type";
|
||||
}
|
||||
|
||||
static inline void
|
||||
print_header (
|
||||
h5_int64_t n
|
||||
) {
|
||||
if (n > 0) {
|
||||
printf ("\t%-6s %-30s %-15s %-10s\n", "idx", "name", "type", "dim");
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
print_query_result (
|
||||
h5_int64_t i,
|
||||
const char* const name,
|
||||
h5_int64_t type,
|
||||
h5_int64_t dim
|
||||
) {
|
||||
printf ("\t%-6lld %-30s %-15s %-10lld\n", (long long)i, name, type2string(type), (long long)dim);
|
||||
}
|
||||
|
||||
void
|
||||
query_step_datasets (
|
||||
h5_int64_t f,
|
||||
h5_int64_t step
|
||||
) {
|
||||
char name[H5_MAX_NAME_LEN];
|
||||
h5_int64_t type;
|
||||
h5_size_t dim;
|
||||
|
||||
H5SetStep (f, step);
|
||||
|
||||
// query # of step attributes
|
||||
h5_int64_t n = H5PartGetNumDatasets (f);
|
||||
printf ("\tNumber of datasets in step %lld: %lld\n", (long long)step, (long long)n);
|
||||
|
||||
// output name and type of all datasets
|
||||
print_header (n);
|
||||
for (h5_int64_t i = 0; i < n; i++) {
|
||||
H5PartGetDatasetInfo (f, i, name, sizeof(name), &type, &dim);
|
||||
print_query_result (i, name, type, dim);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
query_file (
|
||||
const char* const fname
|
||||
) {
|
||||
printf ("\nFile: %s\n", fname);
|
||||
// if file properties is set to default, MPI_COMM_WORLD will be used
|
||||
h5_file_t f = H5OpenFile (fname, H5_O_RDONLY, H5_PROP_DEFAULT);
|
||||
|
||||
// query # of steps, if > 0: go to first step, query and output step attribs
|
||||
h5_int64_t n = H5GetNumSteps (f);
|
||||
printf ("\tNumber of steps: %lld\n", (long long)n);
|
||||
|
||||
if (n > 0) {
|
||||
// go to first step
|
||||
h5_int64_t i = -1;
|
||||
while (!H5HasStep (f, ++i));
|
||||
|
||||
query_step_datasets (f, i);
|
||||
}
|
||||
H5CloseFile (f);
|
||||
}
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char** argv
|
||||
) {
|
||||
MPI_Init (&argc, &argv);
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (VERBOSITY);
|
||||
H5SetDebugMask (H5_DEBUG_ALL);
|
||||
|
||||
query_file (FNAME);
|
||||
|
||||
MPI_Finalize ();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
// name of input file
|
||||
const char* fname = "example_setview.h5";
|
||||
|
||||
// H5hut verbosity level
|
||||
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
|
||||
int
|
||||
main (
|
||||
int argc, char* argv[]
|
||||
){
|
||||
|
||||
// initialize MPI & H5hut
|
||||
MPI_Init (&argc, &argv);
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
int comm_rank = 0;
|
||||
MPI_Comm_rank (comm, &comm_rank);
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (h5_verbosity);
|
||||
|
||||
// open file and go to first step
|
||||
h5_file_t file = H5OpenFile (fname, H5_O_RDONLY, H5_PROP_DEFAULT);
|
||||
H5SetStep (file, 0);
|
||||
|
||||
// set canonical view
|
||||
H5PartSetCanonicalView (file);
|
||||
h5_int64_t num_particles = H5PartGetNumParticles (file);
|
||||
printf ("[proc %d]: particles in view: %lld\n", comm_rank, (long long)num_particles);
|
||||
|
||||
// read and print data
|
||||
h5_int32_t* data = calloc (num_particles, sizeof (*data));
|
||||
H5PartReadDataInt32 (file, "data", data);
|
||||
for (int i = 0; i < num_particles; i++) {
|
||||
printf ("[proc %d]: local index = %d, value = %d\n",
|
||||
comm_rank, i, data[i]);
|
||||
}
|
||||
|
||||
// cleanup
|
||||
free (data);
|
||||
H5CloseFile (file);
|
||||
MPI_Finalize ();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
!
|
||||
! Copyright (c) 2006-2015, 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.!
|
||||
!
|
||||
! License: see file COPYING in top level of source distribution.
|
||||
!
|
||||
include 'H5hut.f90'
|
||||
|
||||
program read_canonicalview
|
||||
use H5hut
|
||||
implicit none
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
include 'mpif.h'
|
||||
#endif
|
||||
|
||||
! name of input file
|
||||
character (len=*), parameter :: fname = "example_setview.h5"
|
||||
|
||||
! H5hut verbosity level
|
||||
integer*8, parameter :: h5_verbosity = H5_VERBOSE_DEFAULT
|
||||
|
||||
integer :: comm_rank = 0
|
||||
integer*8 :: file, h5_ierror
|
||||
integer*8 :: num_particles
|
||||
integer*8 :: i
|
||||
integer*4, allocatable :: data(:)
|
||||
|
||||
! initialize MPI & H5hut
|
||||
#if defined(PARALLEL_IO)
|
||||
integer :: comm, mpi_ierror
|
||||
comm = MPI_COMM_WORLD
|
||||
call mpi_init (mpi_ierror)
|
||||
call mpi_comm_rank (comm, comm_rank, mpi_ierror)
|
||||
#endif
|
||||
call h5_abort_on_error ()
|
||||
call h5_set_verbosity_level (h5_verbosity)
|
||||
|
||||
! open file and go to first step
|
||||
file = h5_openfile (fname, H5_O_RDONLY, H5_PROP_DEFAULT)
|
||||
h5_ierror = h5_setstep(file, 1_8)
|
||||
|
||||
! set canonical view
|
||||
h5_ierror = h5pt_setcanonicalview (file)
|
||||
num_particles = h5pt_getnpoints (file)
|
||||
write (*, "('[proc ', i4, '] particles in view: ', i8)") comm_rank, num_particles
|
||||
|
||||
! read and print data
|
||||
allocate (data (num_particles))
|
||||
h5_ierror = h5pt_readdata_i4 (file, "data", data);
|
||||
do i = 1, num_particles
|
||||
write (*, "('[proc ', i4, ']: local index = ', i4, ', value = ', i4)") &
|
||||
comm_rank, i, data(i)
|
||||
end do
|
||||
|
||||
! cleanup
|
||||
deallocate (data)
|
||||
h5_ierror = h5_closefile (file)
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_finalize (mpi_ierror)
|
||||
#endif
|
||||
|
||||
end program read_canonicalview
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
Note:
|
||||
Running this example on more than one core is possible but the result
|
||||
might not be what you expect. Please read the HDF5 documentation about
|
||||
the VFD core driver.
|
||||
*/
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
// name of input file
|
||||
const char* fname = "example_core_vfd.h5";
|
||||
|
||||
// H5hut verbosity level
|
||||
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char* argv[]
|
||||
){
|
||||
|
||||
// initialize MPI & H5hut
|
||||
MPI_Init (&argc, &argv);
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
int comm_rank = 0;
|
||||
MPI_Comm_rank (comm, &comm_rank);
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (h5_verbosity);
|
||||
|
||||
// open file and create first step
|
||||
h5_prop_t prop = H5CreateFileProp ();
|
||||
H5SetPropFileCoreVFD (prop, 0);
|
||||
h5_file_t file = H5OpenFile (fname, H5_O_RDONLY, prop);
|
||||
H5SetStep (file, 0);
|
||||
|
||||
// with core cfd we read the hole file on all cores!
|
||||
h5_int64_t num_particles = H5PartGetNumParticles (file);
|
||||
printf ("[proc %d]: particles in view: %lld\n", comm_rank, (long long)num_particles);
|
||||
|
||||
// read and print data
|
||||
h5_int32_t* data = calloc (num_particles, sizeof (*data));
|
||||
H5PartReadDataInt32 (file, "data", data);
|
||||
for (int i = 0; i < num_particles; i++) {
|
||||
printf ("[proc %d]: local index = %d, value = %d\n",
|
||||
comm_rank, i, data[i]);
|
||||
}
|
||||
|
||||
// cleanup
|
||||
free (data);
|
||||
H5CloseFile (file);
|
||||
MPI_Finalize ();
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
!
|
||||
! Copyright (c) 2006-2015, 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.!
|
||||
!
|
||||
! License: see file COPYING in top level of source distribution.
|
||||
!
|
||||
include 'H5hut.f90'
|
||||
|
||||
program read_core_vfd
|
||||
use H5hut
|
||||
implicit none
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
include 'mpif.h'
|
||||
#endif
|
||||
|
||||
! name of input file
|
||||
character (len=*), parameter :: fname = "example_core_vfd.h5"
|
||||
|
||||
! H5hut verbosity level
|
||||
integer*8, parameter :: h5_verbosity = H5_VERBOSE_DEFAULT
|
||||
|
||||
integer*8 :: file, h5_ierror
|
||||
integer*8 :: prop
|
||||
integer*8 :: num_particles
|
||||
integer*4 :: i
|
||||
integer*4, allocatable :: data(:)
|
||||
|
||||
! initialize MPI & H5hut
|
||||
integer :: comm_rank = 0
|
||||
#if defined(PARALLEL_IO)
|
||||
integer :: comm, mpi_ierror
|
||||
comm = MPI_COMM_WORLD
|
||||
call mpi_init (mpi_ierror)
|
||||
call mpi_comm_rank (comm, comm_rank, mpi_ierror)
|
||||
#endif
|
||||
call h5_abort_on_error ()
|
||||
call h5_set_verbosity_level (h5_verbosity)
|
||||
|
||||
! open file and create first step
|
||||
prop = h5_createprop_file ()
|
||||
h5_ierror = h5_setprop_file_corevfd (prop);
|
||||
file = h5_openfile (fname, H5_O_RDONLY, prop)
|
||||
h5_ierror = h5_setstep(file, 1_8)
|
||||
|
||||
! with core cfd we read the hole file on all cores!
|
||||
num_particles = h5pt_getnpoints (file)
|
||||
write (*, "('[proc ', i4, ']: particles in view: ', i4)") &
|
||||
comm_rank, num_particles
|
||||
|
||||
! read and print data
|
||||
allocate (data (num_particles))
|
||||
h5_ierror = h5pt_readdata_i4 (file, "data", data)
|
||||
do i = 1, int (num_particles)
|
||||
write (*, "('[proc ', i4, ']: local index = ', i4, ', value = ', i4)") &
|
||||
comm_rank, i, data(i)
|
||||
end do
|
||||
|
||||
! cleanup
|
||||
deallocate (data)
|
||||
h5_ierror = h5_closefile (file)
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_finalize (mpi_ierror)
|
||||
#endif
|
||||
|
||||
end program read_core_vfd
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
// name of input file
|
||||
const char* fname = "example_setnparticles.h5";
|
||||
|
||||
// H5hut verbosity level
|
||||
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
|
||||
int
|
||||
main (
|
||||
int argc, char* argv[]
|
||||
){
|
||||
|
||||
// initialize MPI & H5hut
|
||||
MPI_Init (&argc, &argv);
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
int comm_size = 1;
|
||||
MPI_Comm_size (comm, &comm_size);
|
||||
int comm_rank = 0;
|
||||
MPI_Comm_rank (comm, &comm_rank);
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (h5_verbosity);
|
||||
|
||||
// open file and go to first step
|
||||
h5_file_t file = H5OpenFile (fname, H5_O_RDONLY, H5_PROP_DEFAULT);
|
||||
H5SetStep (file, 0);
|
||||
|
||||
// compute number of particles this process has to read
|
||||
h5_ssize_t num_particles_total = H5PartGetNumParticles (file);
|
||||
h5_ssize_t num_particles = num_particles_total / comm_size;
|
||||
if (comm_rank+1 == comm_size)
|
||||
num_particles += num_particles_total % comm_size;
|
||||
|
||||
printf ("[proc %d]: particles in view: %lld\n", comm_rank, (long long)num_particles);
|
||||
printf ("[proc %d]: total number of particles: %lld\n",
|
||||
comm_rank, (long long unsigned)num_particles_total);
|
||||
|
||||
// set number of particles
|
||||
H5PartSetNumParticles (file, num_particles);
|
||||
|
||||
// read and print data
|
||||
h5_int32_t* data = calloc (num_particles, sizeof (*data));
|
||||
H5PartReadDataInt32 (file, "data", data);
|
||||
for (int i = 0; i < num_particles; i++) {
|
||||
printf ("[proc %d]: local index = %d, value = %d\n",
|
||||
comm_rank, i, data[i]);
|
||||
}
|
||||
|
||||
// cleanup
|
||||
free (data);
|
||||
H5CloseFile (file);
|
||||
MPI_Finalize ();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
!
|
||||
! Copyright (c) 2006-2015, 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.!
|
||||
!
|
||||
! License: see file COPYING in top level of source distribution.
|
||||
!
|
||||
include 'H5hut.f90'
|
||||
|
||||
program read_setnparticles
|
||||
use H5hut
|
||||
implicit none
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
include 'mpif.h'
|
||||
#endif
|
||||
|
||||
! name of input file
|
||||
character (len=*), parameter :: fname = "example_setnparticles.h5"
|
||||
|
||||
! H5hut verbosity level
|
||||
integer*8, parameter :: h5_verbosity = H5_VERBOSE_DEFAULT
|
||||
|
||||
integer :: comm_size = 1
|
||||
integer :: comm_rank = 0
|
||||
integer*8 :: file, h5_ierror
|
||||
integer*8 :: num_particles, num_particles_total
|
||||
integer*8 :: i
|
||||
integer*4, allocatable :: data(:)
|
||||
|
||||
! initialize MPI & H5hut
|
||||
#if defined(PARALLEL_IO)
|
||||
integer :: comm, mpi_ierror
|
||||
comm = MPI_COMM_WORLD
|
||||
call mpi_init (mpi_ierror)
|
||||
call mpi_comm_size (comm, comm_size, mpi_ierror)
|
||||
call mpi_comm_rank (comm, comm_rank, mpi_ierror)
|
||||
#endif
|
||||
call h5_abort_on_error ()
|
||||
call h5_set_verbosity_level (h5_verbosity)
|
||||
|
||||
! open file and go to first step
|
||||
file = h5_openfile (fname, H5_O_RDONLY, H5_PROP_DEFAULT)
|
||||
h5_ierror = h5_setstep (file, 1_8)
|
||||
|
||||
! compute number of particles this process has to read
|
||||
num_particles_total = h5pt_getnpoints (file)
|
||||
num_particles = num_particles_total / comm_size
|
||||
if (comm_rank+1 == comm_size) then
|
||||
num_particles = num_particles + mod (num_particles_total, comm_size)
|
||||
end if
|
||||
|
||||
write (*, "('Total number of particles: ', i8)") num_particles_total
|
||||
write (*, "('Number of particles on this core: ', i8)") num_particles
|
||||
|
||||
! set number of particeles
|
||||
h5_ierror = h5pt_setnpoints (file, num_particles)
|
||||
|
||||
! read and print data
|
||||
allocate (data (num_particles))
|
||||
h5_ierror = h5pt_readdata_i4 (file, "data", data)
|
||||
do i = 1, num_particles
|
||||
write (*, "('[proc ', i4, ']: local index = ', i4, ', value = ', i4)") &
|
||||
comm_rank, i, data(i)
|
||||
end do
|
||||
|
||||
! cleanup
|
||||
deallocate (data)
|
||||
h5_ierror = h5_closefile (file)
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_finalize (mpi_ierror)
|
||||
#endif
|
||||
|
||||
end program read_setnparticles
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
// name of input file
|
||||
const char* fname = "example_setview.h5";
|
||||
|
||||
// H5hut verbosity level
|
||||
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
|
||||
int
|
||||
main (
|
||||
int argc, char* argv[]
|
||||
){
|
||||
|
||||
// initialize MPI & H5hut
|
||||
MPI_Init (&argc, &argv);
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
int comm_size = 1;
|
||||
MPI_Comm_size (comm, &comm_size);
|
||||
int comm_rank = 0;
|
||||
MPI_Comm_rank (comm, &comm_rank);
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (h5_verbosity);
|
||||
|
||||
// open file and go to first step
|
||||
h5_file_t file = H5OpenFile (fname, H5_O_RDONLY, H5_PROP_DEFAULT);
|
||||
H5SetStep (file, 0);
|
||||
|
||||
// compute and set a "canonical" view:
|
||||
// all cores get almost the same number of particles
|
||||
h5_int64_t num_particles_total = H5PartGetNumParticles (file);
|
||||
h5_int64_t num_particles = num_particles_total / comm_size;
|
||||
h5_int64_t remainder = num_particles_total % comm_size;
|
||||
h5_int64_t start = comm_rank * num_particles;
|
||||
|
||||
// adjust number of local particles
|
||||
if (comm_rank < remainder)
|
||||
num_particles++;
|
||||
|
||||
// adjust start
|
||||
if (comm_rank < remainder)
|
||||
start += comm_rank;
|
||||
else
|
||||
start += remainder;
|
||||
|
||||
// Note:
|
||||
// setting end = start - 1 forces the selection of zero particles!
|
||||
h5_int64_t end = start + num_particles - 1;
|
||||
|
||||
printf ("[proc %d]: set view to [%lld..%lld]\n", comm_rank, (long long)start, (long long)end);
|
||||
H5PartSetView (file, start, end);
|
||||
|
||||
// read and print data
|
||||
h5_int32_t* data = calloc (num_particles, sizeof (*data));
|
||||
H5PartReadDataInt32 (file, "data", data);
|
||||
for (int i = 0; i < num_particles; i++) {
|
||||
printf ("[proc %d]: global index = %lld; local index = %d, value = %d\n",
|
||||
comm_rank, (long long)(start+i), i, data[i]);
|
||||
}
|
||||
|
||||
// cleanup
|
||||
free (data);
|
||||
H5CloseFile (file);
|
||||
MPI_Finalize ();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
!
|
||||
! Copyright (c) 2006-2015, 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.!
|
||||
!
|
||||
! License: see file COPYING in top level of source distribution.
|
||||
!
|
||||
include 'H5hut.f90'
|
||||
|
||||
program read_setviewf
|
||||
use H5hut
|
||||
implicit none
|
||||
#if defined(PARALLEL_IO)
|
||||
include 'mpif.h'
|
||||
#endif
|
||||
|
||||
! name of input file
|
||||
character (len=*), parameter :: fname = "example_setview.h5"
|
||||
|
||||
! H5hut verbosity level
|
||||
integer*8, parameter :: h5_verbosity = H5_VERBOSE_DEFAULT
|
||||
|
||||
integer :: comm_size = 1
|
||||
integer :: comm_rank = 0
|
||||
integer*8 :: file, h5_ierror
|
||||
integer*8 :: num_particles, num_particles_total
|
||||
integer*8 :: i, start, end, remainder
|
||||
integer*4, allocatable :: data(:)
|
||||
|
||||
! initialize MPI & H5hut
|
||||
#if defined(PARALLEL_IO)
|
||||
integer :: comm, mpi_ierror
|
||||
comm = MPI_COMM_WORLD
|
||||
call mpi_init (mpi_ierror)
|
||||
call mpi_comm_size (comm, comm_size, mpi_ierror)
|
||||
call mpi_comm_rank (comm, comm_rank, mpi_ierror)
|
||||
#endif
|
||||
|
||||
call h5_abort_on_error ()
|
||||
call h5_set_verbosity_level (h5_verbosity)
|
||||
|
||||
! open file and go to first step
|
||||
file = h5_openfile (fname, H5_O_RDONLY, H5_PROP_DEFAULT)
|
||||
h5_ierror = h5_setstep(file, 1_8)
|
||||
|
||||
! compute a "canonical" view:
|
||||
! all cores get almost the same number of particles
|
||||
num_particles_total = h5pt_getnpoints (file);
|
||||
num_particles = num_particles_total / comm_size;
|
||||
remainder = mod (num_particles_total, comm_size);
|
||||
start = comm_rank * num_particles;
|
||||
|
||||
! adjust number of local particles
|
||||
if (comm_rank < remainder) then
|
||||
num_particles = num_particles + 1
|
||||
end if
|
||||
|
||||
! adjust start
|
||||
if (comm_rank < remainder) then
|
||||
start = start + comm_rank
|
||||
else
|
||||
start = start + remainder
|
||||
end if
|
||||
|
||||
! Note:
|
||||
! setting end = start - 1 forces the selection of zero particles!
|
||||
end = start + num_particles - 1;
|
||||
|
||||
! adjust Fortran indices: in Fortran we start at 1 not 0
|
||||
start = start + 1
|
||||
end = end + 1
|
||||
|
||||
write (*, "('[proc ', i4, ']: set view to [', i4, '..', i4, ']')") comm_rank, start, end
|
||||
h5_ierror = h5pt_setview (file, start, end);
|
||||
|
||||
! read and print data
|
||||
allocate (data (num_particles))
|
||||
h5_ierror = h5pt_readdata_i4 (file, "data", data);
|
||||
do i = 1, num_particles
|
||||
write (*, "('[proc ', i4, ']: global index = ', i4, '; local index = ', i4, ', value = ', i4)") &
|
||||
comm_rank, start+i-1, i, data(i)
|
||||
end do
|
||||
|
||||
! cleanup
|
||||
deallocate (data)
|
||||
h5_ierror = h5_closefile (file)
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_finalize (mpi_ierror)
|
||||
#endif
|
||||
|
||||
end program read_setviewf
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
// name of input file
|
||||
const char* fname = "example_strided.h5";
|
||||
|
||||
// H5hut verbosity level
|
||||
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
//const h5_int64_t h5_verbosity = H5_DEBUG_ALL;
|
||||
|
||||
int
|
||||
main (
|
||||
int argc, char* argv[]
|
||||
){
|
||||
|
||||
// initialize MPI & H5hut
|
||||
MPI_Init (&argc, &argv);
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
int comm_size = 1;
|
||||
MPI_Comm_size (comm, &comm_size);
|
||||
int comm_rank = 0;
|
||||
MPI_Comm_rank (comm, &comm_rank);
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (h5_verbosity);
|
||||
|
||||
// open file and go to first step
|
||||
h5_file_t file = H5OpenFile (fname, H5_O_RDONLY, H5_PROP_DEFAULT);
|
||||
H5SetStep (file, 0);
|
||||
|
||||
// compute number of particles this process has to read
|
||||
h5_ssize_t num_particles_total = H5PartGetNumParticles (file);
|
||||
h5_ssize_t num_particles = num_particles_total / comm_size;
|
||||
if (comm_rank+1 == comm_size)
|
||||
num_particles += num_particles_total % comm_size;
|
||||
|
||||
printf ("[proc %d]: particles in view: %lld\n", comm_rank, (long long)num_particles);
|
||||
printf ("[proc %d]: total number of particles: %lld\n",
|
||||
comm_rank, (long long unsigned)num_particles_total);
|
||||
|
||||
// set number of particles and memory stride
|
||||
H5PartSetNumParticlesStrided (file, num_particles, 6);
|
||||
|
||||
// read data
|
||||
h5_float64_t* data = calloc (6*num_particles, sizeof (*data));
|
||||
H5PartReadDataFloat64 (file, "x", data+0);
|
||||
H5PartReadDataFloat64 (file, "y", data+1);
|
||||
H5PartReadDataFloat64 (file, "z", data+2);
|
||||
H5PartReadDataFloat64 (file, "px", data+3);
|
||||
H5PartReadDataFloat64 (file, "py", data+4);
|
||||
H5PartReadDataFloat64 (file, "pz", data+5);
|
||||
|
||||
// print dataset "x"
|
||||
for (int i = 0; i < num_particles*6; i+=6) {
|
||||
printf ("[proc %d]: local index = %d, value = %6.3f\n",
|
||||
comm_rank, i, data[i]);
|
||||
}
|
||||
|
||||
// cleanup
|
||||
free (data);
|
||||
H5CloseFile (file);
|
||||
MPI_Finalize ();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
!
|
||||
! Copyright (c) 2006-2015, 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.!
|
||||
!
|
||||
! License: see file COPYING in top level of source distribution.
|
||||
!
|
||||
include 'H5hut.f90'
|
||||
|
||||
program read_stridedf
|
||||
use H5hut
|
||||
implicit none
|
||||
#if defined(PARALLEL_IO)
|
||||
include 'mpif.h'
|
||||
#endif
|
||||
|
||||
! name of input file
|
||||
character (len=*), parameter :: fname = "example_strided.h5"
|
||||
|
||||
! H5hut verbosity level
|
||||
integer*8, parameter :: h5_verbosity = H5_VERBOSE_DEFAULT
|
||||
|
||||
integer*8 :: file, h5_ierror
|
||||
integer*8 :: num_particles, num_particles_total
|
||||
real*8, allocatable :: data(:)
|
||||
integer*8 :: i, start
|
||||
|
||||
! initialize MPI & H5hut
|
||||
#if defined(PARALLEL_IO)
|
||||
integer :: comm, comm_size, comm_rank, mpi_ierror
|
||||
comm = MPI_COMM_WORLD
|
||||
call mpi_init (mpi_error)
|
||||
call mpi_comm_size (comm, comm_size, mpi_ierror)
|
||||
call mpi_comm_rank (comm, comm_rank, mpi_ierror)
|
||||
#else
|
||||
integer :: comm_size = 1
|
||||
integer :: comm_rank = 0
|
||||
#endif
|
||||
|
||||
call h5_abort_on_error ()
|
||||
call h5_set_verbosity_level (h5_verbosity)
|
||||
|
||||
! open file and go to first step
|
||||
file = h5_openfile (fname, H5_O_RDONLY, H5_PROP_DEFAULT)
|
||||
h5_ierror = h5_setstep(file, 1_8)
|
||||
|
||||
! compute number of particles this process has to read
|
||||
num_particles_total = h5pt_getnpoints (file)
|
||||
num_particles = num_particles_total / comm_size
|
||||
if (comm_rank+1 == comm_size) then
|
||||
num_particles = num_particles + mod (num_particles_total, comm_size)
|
||||
end if
|
||||
|
||||
write (*, "('Total number of particles: ', i8)") num_particles_total
|
||||
write (*, "('Number of particles on this core: ', i8)") num_particles
|
||||
|
||||
! set number of particeles and memory stride
|
||||
h5_ierror = h5pt_setnpoints_strided (file, num_particles, 6_8)
|
||||
|
||||
! read data
|
||||
allocate (data (6*num_particles))
|
||||
h5_ierror = h5pt_readdata_r8 (file, "x", data(1:))
|
||||
h5_ierror = h5pt_readdata_r8 (file, "y", data(2:))
|
||||
h5_ierror = h5pt_readdata_r8 (file, "z", data(3:))
|
||||
h5_ierror = h5pt_readdata_r8 (file, "px", data(4:))
|
||||
h5_ierror = h5pt_readdata_r8 (file, "py", data(5:))
|
||||
h5_ierror = h5pt_readdata_r8 (file, "pz", data(6:))
|
||||
|
||||
! print dataset "x"
|
||||
start = 1
|
||||
do i = start, num_particles*6, 6
|
||||
write (*, "('[proc ', i4, ']: global index = ', i4, '; local index = ', i4, ', value = ', f10.2)") &
|
||||
comm_rank, start+i-2, i, data(i)
|
||||
end do
|
||||
|
||||
! cleanup
|
||||
deallocate (data)
|
||||
h5_ierror = h5_closefile (file)
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_finalize (mpi_ierror)
|
||||
#endif
|
||||
|
||||
end program read_stridedf
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
Note:
|
||||
Running this example on more than one core is possible but the result
|
||||
might not be what you expect. Please read the HDF5 documentation about
|
||||
the VFD core driver.
|
||||
*/
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
// name of output file
|
||||
const char* fname = "example_core_vfd.h5";
|
||||
|
||||
// H5hut verbosity level
|
||||
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
|
||||
// number of particles we are going to write per core
|
||||
const h5_int64_t num_particles = 32;
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char* argv[]
|
||||
){
|
||||
|
||||
// initialize MPI & H5hut
|
||||
MPI_Init (&argc, &argv);
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
int comm_rank = 0;
|
||||
MPI_Comm_rank (comm, &comm_rank);
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (h5_verbosity);
|
||||
|
||||
// open file and create first step
|
||||
h5_prop_t prop = H5CreateFileProp ();
|
||||
H5SetPropFileCoreVFD (prop, 0);
|
||||
h5_file_t file = H5OpenFile (fname, H5_O_WRONLY, prop);
|
||||
H5SetStep (file, 0);
|
||||
|
||||
// set number of particles this process is going to write
|
||||
H5PartSetNumParticles(file, num_particles);
|
||||
|
||||
// create fake data
|
||||
h5_int32_t data[num_particles];
|
||||
for (int i = 0; i < num_particles; i++) {
|
||||
data[i] = i + comm_rank * num_particles;
|
||||
}
|
||||
|
||||
// write the data
|
||||
H5PartWriteDataInt32 (file, "data", data);
|
||||
|
||||
// cleanup
|
||||
H5CloseFile (file);
|
||||
MPI_Finalize ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
!
|
||||
! Copyright (c) 2006-2015, 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.!
|
||||
!
|
||||
! License: see file COPYING in top level of source distribution.
|
||||
!
|
||||
include 'H5hut.f90'
|
||||
|
||||
program write_core_vfd
|
||||
use H5hut
|
||||
implicit none
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
include 'mpif.h'
|
||||
#endif
|
||||
|
||||
! name of output file
|
||||
character (len=*), parameter :: fname = "example_core_vfd.h5"
|
||||
|
||||
! H5hut verbosity level
|
||||
integer*8, parameter :: h5_verbosity = H5_VERBOSE_DEFAULT
|
||||
|
||||
! number of particles we are going to write per core
|
||||
integer*4, parameter :: num_particles = 32
|
||||
|
||||
integer :: comm_rank = 0
|
||||
integer*8 :: file, h5_ierror
|
||||
integer*8 :: prop
|
||||
integer*4 :: i
|
||||
integer*4, allocatable :: data(:)
|
||||
|
||||
! initialize MPI & H5hut
|
||||
#if defined(PARALLEL_IO)
|
||||
integer :: comm, mpi_ierror
|
||||
comm = MPI_COMM_WORLD
|
||||
call mpi_init (mpi_ierror)
|
||||
call mpi_comm_rank (comm, comm_rank, mpi_ierror)
|
||||
#endif
|
||||
|
||||
call h5_abort_on_error ()
|
||||
call h5_set_verbosity_level (h5_verbosity)
|
||||
|
||||
! open file and create first step
|
||||
prop = h5_createprop_file ()
|
||||
h5_ierror = h5_setprop_file_corevfd (prop);
|
||||
file = h5_openfile (fname, H5_O_WRONLY, prop)
|
||||
h5_ierror = h5_setstep(file, 1_8)
|
||||
|
||||
! set number of particles this process is going to write
|
||||
h5_ierror = h5pt_setnpoints (file, int8 (num_particles))
|
||||
|
||||
! create fake data
|
||||
allocate (data (num_particles))
|
||||
do i = 1, num_particles
|
||||
data (i) = (i-1) + comm_rank * num_particles
|
||||
end do
|
||||
|
||||
! write the data
|
||||
h5_ierror = h5pt_writedata_i4 (file, "data", data);
|
||||
|
||||
! cleanup
|
||||
deallocate (data)
|
||||
h5_ierror = h5_closefile (file)
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_finalize (mpi_ierror)
|
||||
#endif
|
||||
|
||||
end program write_core_vfd
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
// name of output file
|
||||
const char* fname = "example_setnparticles.h5";
|
||||
|
||||
// H5hut verbosity level
|
||||
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
|
||||
// number of particles we are going to write per core
|
||||
const h5_int64_t num_particles = 99;
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char* argv[]
|
||||
){
|
||||
|
||||
// initialize MPI & H5hut
|
||||
MPI_Init (&argc, &argv);
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
int comm_rank = 0;
|
||||
MPI_Comm_rank (comm, &comm_rank);
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (h5_verbosity);
|
||||
|
||||
// open file and create first step
|
||||
h5_file_t file = H5OpenFile (fname, H5_O_WRONLY, H5_PROP_DEFAULT);
|
||||
H5SetStep (file, 0);
|
||||
|
||||
// define number of particles this process will write
|
||||
H5PartSetNumParticles (file, num_particles);
|
||||
|
||||
// create fake data
|
||||
h5_int32_t data[num_particles];
|
||||
for (int i = 0; i < num_particles; i++) {
|
||||
data[i] = i + num_particles * comm_rank;
|
||||
}
|
||||
|
||||
// write data
|
||||
H5PartWriteDataInt32 (file, "data", data);
|
||||
|
||||
// done
|
||||
H5CloseFile(file);
|
||||
MPI_Finalize ();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
!
|
||||
! Copyright (c) 2006-2015, 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.!
|
||||
!
|
||||
! License: see file COPYING in top level of source distribution.
|
||||
!
|
||||
include 'H5hut.f90'
|
||||
|
||||
program write_setnparticles
|
||||
use H5hut
|
||||
implicit none
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
include 'mpif.h'
|
||||
#endif
|
||||
|
||||
! name of output file
|
||||
character (len=*), parameter :: fname = "example_setnparticles.h5"
|
||||
|
||||
! H5hut verbosity level
|
||||
integer*8, parameter :: h5_verbosity = H5_VERBOSE_DEFAULT
|
||||
|
||||
! number of particles we are going to write per core
|
||||
integer*8, parameter :: num_particles = 32
|
||||
|
||||
integer :: comm_rank = 0
|
||||
integer*8 :: file, h5_ierror
|
||||
integer*4 :: i
|
||||
integer*4, allocatable :: data(:)
|
||||
|
||||
! initialize MPI & H5hut
|
||||
#if defined(PARALLEL_IO)
|
||||
integer :: comm, mpi_ierror
|
||||
comm = MPI_COMM_WORLD
|
||||
call mpi_init (mpi_ierror)
|
||||
call mpi_comm_rank (comm, comm_rank, mpi_ierror)
|
||||
#endif
|
||||
|
||||
call h5_abort_on_error ()
|
||||
call h5_set_verbosity_level (h5_verbosity)
|
||||
|
||||
! open file and create first step
|
||||
file = h5_openfile (FNAME, H5_O_WRONLY, H5_PROP_DEFAULT)
|
||||
h5_ierror = h5_setstep(file, 0_8)
|
||||
|
||||
! define number of particles this process will write
|
||||
h5_ierror = h5pt_setnpoints (file, num_particles)
|
||||
|
||||
! create fake data
|
||||
allocate (data (num_particles))
|
||||
do i = 1, num_particles
|
||||
data (i) = i + int(num_particles)*comm_rank
|
||||
enddo
|
||||
|
||||
! write data
|
||||
h5_ierror = h5pt_writedata_i4 (file, "data", data)
|
||||
|
||||
! cleanup
|
||||
deallocate (data)
|
||||
h5_ierror = h5_closefile (file)
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_finalize (mpi_ierror)
|
||||
#endif
|
||||
|
||||
end program write_setnparticles
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
// name of output file
|
||||
const char* fname = "example_setview.h5";
|
||||
|
||||
// H5hut verbosity level
|
||||
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
|
||||
// we are going to write multiple consecutive blocks
|
||||
const h5_int64_t num_blocks = 4;
|
||||
const h5_int64_t num_particles_per_block = 32;
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char* argv[]
|
||||
){
|
||||
|
||||
// initialize MPI & H5hut
|
||||
MPI_Init (&argc, &argv);
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
int comm_rank = 0;
|
||||
MPI_Comm_rank (comm, &comm_rank);
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (h5_verbosity);
|
||||
|
||||
// open file and create first step
|
||||
h5_file_t file = H5OpenFile (fname, H5_O_WRONLY, H5_PROP_DEFAULT);
|
||||
H5SetStep (file, 0);
|
||||
|
||||
/*
|
||||
If we want to write consecutive blocks, the 'view' can be defined
|
||||
with H5PartSetview(). Otherwise we have to define the total number
|
||||
of particles with H5PartSetNumParticles().
|
||||
*/
|
||||
const h5_int64_t offset = comm_rank * num_blocks * num_particles_per_block;
|
||||
H5PartSetView (
|
||||
file,
|
||||
offset,
|
||||
offset + num_blocks*num_particles_per_block -1);
|
||||
|
||||
// write multiple consecutive blocks
|
||||
for (int i = 0; i < num_blocks; i++) {
|
||||
// create fake data
|
||||
h5_int32_t data[num_particles_per_block];
|
||||
for (int j = 0; j < num_particles_per_block; j++) {
|
||||
data[j] = j + i*num_particles_per_block + offset;
|
||||
}
|
||||
|
||||
// set the "view" to select a subset of the dataset
|
||||
H5PartSetView (
|
||||
file,
|
||||
offset + i*num_particles_per_block,
|
||||
offset + (i+1)*num_particles_per_block - 1);
|
||||
// write data
|
||||
H5PartWriteDataInt32 (file, "data", data);
|
||||
}
|
||||
|
||||
// done
|
||||
H5CloseFile(file);
|
||||
MPI_Finalize();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
!
|
||||
! Copyright (c) 2006-2015, 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.!
|
||||
!
|
||||
! License: see file COPYING in top level of source distribution.
|
||||
!
|
||||
include 'H5hut.f90'
|
||||
|
||||
program write_setview
|
||||
use H5hut
|
||||
implicit none
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
include 'mpif.h'
|
||||
#endif
|
||||
|
||||
! name of output file
|
||||
character (len=*), parameter :: fname = "example_setview.h5"
|
||||
|
||||
! H5hut verbosity level
|
||||
integer*8, parameter :: h5_verbosity = H5_VERBOSE_DEFAULT
|
||||
|
||||
! we are going to write multiple consecutive blocks
|
||||
integer*8, parameter :: num_blocks = 4;
|
||||
integer*8, parameter :: num_particles_per_block = 32
|
||||
|
||||
integer :: comm_rank = 0
|
||||
integer*8 :: file, h5_ierror
|
||||
integer*8 :: i, j, offset
|
||||
integer*4, allocatable :: data(:)
|
||||
|
||||
! initialize MPI & H5hut
|
||||
#if defined(PARALLEL_IO)
|
||||
integer :: comm, mpi_ierror
|
||||
comm = MPI_COMM_WORLD
|
||||
call mpi_init (mpi_ierror)
|
||||
call mpi_comm_rank (comm, comm_rank, mpi_ierror)
|
||||
#endif
|
||||
|
||||
call h5_abort_on_error ()
|
||||
call h5_set_verbosity_level (h5_verbosity)
|
||||
|
||||
! open file and create first step
|
||||
file = h5_openfile (FNAME, H5_O_WRONLY, H5_PROP_DEFAULT)
|
||||
h5_ierror = h5_setstep(file, 1_8)
|
||||
|
||||
! If we want to write consecutive blocks, the 'view' can be defined
|
||||
! with H5PartSetview(). Otherwise we have to define the total number
|
||||
! of particles with H5PartSetNumParticles().
|
||||
offset = comm_rank * num_blocks * num_particles_per_block+1
|
||||
h5_ierror = h5pt_setview (file, offset, offset + num_blocks*num_particles_per_block - 1)
|
||||
|
||||
! write multiple consecutive blocks
|
||||
allocate (data (num_particles_per_block))
|
||||
do i = 1, num_blocks
|
||||
! create fake data
|
||||
do j = 1, num_particles_per_block
|
||||
data (j) = int((j-1) + (i-1)*num_particles_per_block + offset - 1)
|
||||
end do
|
||||
h5_ierror = h5pt_setview (file, offset + (i-1)*num_particles_per_block, offset - 1 + i*num_particles_per_block)
|
||||
! write data
|
||||
h5_ierror = h5pt_writedata_i4 (file, "data", data)
|
||||
end do
|
||||
|
||||
! cleanup
|
||||
deallocate (data)
|
||||
h5_ierror = h5_closefile (file)
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_finalize (mpi_ierror)
|
||||
#endif
|
||||
|
||||
end program write_setview
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, 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.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
#include "H5hut.h"
|
||||
#include "examples.h"
|
||||
|
||||
// name of output file
|
||||
const char* fname = "example_strided.h5";
|
||||
|
||||
// H5hut verbosity level
|
||||
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
|
||||
// number of particles we are going to write per core
|
||||
const h5_int64_t num_particles = 99;
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char* argv[]
|
||||
){
|
||||
|
||||
// initialize MPI & H5hut
|
||||
MPI_Init (&argc, &argv);
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
int comm_rank = 0;
|
||||
MPI_Comm_rank (comm, &comm_rank);
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (h5_verbosity);
|
||||
|
||||
// open file and create first step
|
||||
h5_file_t file = H5OpenFile (fname, H5_O_WRONLY, H5_PROP_DEFAULT);
|
||||
H5SetStep (file, 0);
|
||||
|
||||
// create fake data
|
||||
h5_float64_t data[6*num_particles];
|
||||
h5_int64_t id[num_particles];
|
||||
for (int i = 0; i < num_particles; i++) {
|
||||
data [6*i + 0] = 0.0 + i + num_particles * comm_rank;
|
||||
data [6*i + 1] = 0.1 + i + num_particles * comm_rank;
|
||||
data [6*i + 2] = 0.2 + i + num_particles * comm_rank;
|
||||
data [6*i + 3] = 0.3 + i + num_particles * comm_rank;
|
||||
data [6*i + 4] = 0.4 + i + num_particles * comm_rank;
|
||||
data [6*i + 5] = 0.5 + i + num_particles * comm_rank;
|
||||
id [i] = i + num_particles * comm_rank;
|
||||
}
|
||||
|
||||
// define number of items this processor will write and set the
|
||||
// in-memory striding
|
||||
H5PartSetNumParticlesStrided (file, num_particles, 6);
|
||||
|
||||
// write strided data
|
||||
H5PartWriteDataFloat64 (file, "x", data+0);
|
||||
H5PartWriteDataFloat64 (file, "y", data+1);
|
||||
H5PartWriteDataFloat64 (file, "z", data+2);
|
||||
H5PartWriteDataFloat64 (file, "px", data+3);
|
||||
H5PartWriteDataFloat64 (file, "py", data+4);
|
||||
H5PartWriteDataFloat64 (file, "pz", data+5);
|
||||
|
||||
// disable striding to write the ID's
|
||||
H5PartSetNumParticles (file, num_particles);
|
||||
H5PartWriteDataInt64 (file, "id", id);
|
||||
|
||||
// cleanup
|
||||
H5CloseFile (file);
|
||||
MPI_Finalize ();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
!
|
||||
! Copyright (c) 2006-2015, 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.!
|
||||
!
|
||||
! License: see file COPYING in top level of source distribution.
|
||||
!
|
||||
include 'H5hut.f90'
|
||||
|
||||
program write_stridedf
|
||||
use H5hut
|
||||
implicit none
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
include 'mpif.h'
|
||||
#endif
|
||||
|
||||
! the file name we want to read
|
||||
character (len=*), parameter :: FNAME = "example_strided.h5"
|
||||
integer*8, parameter :: NPOINTS = 99
|
||||
|
||||
integer :: rank = 0
|
||||
integer*8 :: file, status
|
||||
integer*4 :: i
|
||||
real*8, allocatable :: particles(:)
|
||||
integer*8, allocatable :: id(:)
|
||||
|
||||
! init MPI & H5hut
|
||||
#if defined(PARALLEL_IO)
|
||||
integer :: comm, ierr
|
||||
comm = MPI_COMM_WORLD
|
||||
call mpi_init(ierr)
|
||||
call mpi_comm_rank(comm, rank, ierr)
|
||||
#endif
|
||||
|
||||
call h5_abort_on_error ()
|
||||
|
||||
! create fake data
|
||||
allocate(particles(6*NPOINTS), id(NPOINTS))
|
||||
do i = 0, NPOINTS-1
|
||||
particles (6*i + 1) = 0.0 + real (i + NPOINTS*rank)
|
||||
particles (6*i + 2) = 0.1 + real (i + NPOINTS*rank)
|
||||
particles (6*i + 3) = 0.2 + real (i + NPOINTS*rank)
|
||||
particles (6*i + 4) = 0.3 + real (i + NPOINTS*rank)
|
||||
particles (6*i + 5) = 0.4 + real (i + NPOINTS*rank)
|
||||
particles (6*i + 6) = 0.5 + real (i + NPOINTS*rank)
|
||||
id(i+1) = i+NPOINTS*rank
|
||||
enddo
|
||||
|
||||
! open the a file for parallel writing and ceate step #0
|
||||
file = h5_openfile (FNAME, H5_O_WRONLY, H5_PROP_DEFAULT)
|
||||
status = h5_setstep(file, 1_8)
|
||||
|
||||
! define number of items this processor will write and set the
|
||||
! in-memory striding
|
||||
status = h5pt_setnpoints_strided (file, NPOINTS, 6_8)
|
||||
|
||||
! write strided data
|
||||
status = h5pt_writedata_r8 (file, "x", particles(1))
|
||||
status = h5pt_writedata_r8 (file, "y", particles(2))
|
||||
status = h5pt_writedata_r8 (file, "z", particles(3))
|
||||
status = h5pt_writedata_r8 (file, "px", particles(4))
|
||||
status = h5pt_writedata_r8 (file, "py", particles(5))
|
||||
status = h5pt_writedata_r8 (file, "pz", particles(6))
|
||||
|
||||
! disable striding to write the ID's
|
||||
status = h5pt_setnpoints(file, NPOINTS)
|
||||
status = h5pt_writedata_i8(file, "id", id)
|
||||
|
||||
! cleanup
|
||||
status = h5_closefile (file)
|
||||
|
||||
deallocate(particles, id)
|
||||
|
||||
#if defined(PARALLEL_IO)
|
||||
call mpi_finalize(ierr)
|
||||
#endif
|
||||
|
||||
end program write_stridedf
|
||||
@@ -0,0 +1,3 @@
|
||||
#ifndef PARALLEL_IO
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef __EXAMPLES_H
|
||||
#define __EXAMPLES_H
|
||||
|
||||
#if !defined (H5_HAVE_PARALLEL)
|
||||
|
||||
#define MPI_COMM_WORLD (0)
|
||||
#define MPI_Init(argc, argv)
|
||||
#define MPI_Comm_size(comm,nprocs) {comm = 0; *nprocs = 1;}
|
||||
#define MPI_Comm_rank(comm,rank) {comm = 0; (void)(comm); *rank = 0;}
|
||||
#define MPI_Finalize()
|
||||
|
||||
#endif
|
||||
#endif
|
||||
+19
-19
@@ -1,27 +1,27 @@
|
||||
|
||||
if ENABLE_C
|
||||
# Header files that I wish to install in $(prefix)/include
|
||||
include_HEADERS = \
|
||||
../include/H5hut.h \
|
||||
../include/H5.h \
|
||||
../include/H5_attribs.h \
|
||||
../include/H5_attachments.h \
|
||||
../include/H5Part.h \
|
||||
../include/H5Block.h \
|
||||
../include/H5Block_readwrite.h \
|
||||
../include/H5Fed.h \
|
||||
../include/H5Fed_adjacency.h \
|
||||
../include/H5Fed_inquiry.h \
|
||||
../include/H5Fed_retrieve.h \
|
||||
../include/H5Fed_store.h \
|
||||
../include/H5Fed_tags.h
|
||||
include_HEADERS = \
|
||||
$(top_srcdir)/src/include/H5Block_attribs.h \
|
||||
$(top_srcdir)/src/include/H5Block_io.h \
|
||||
$(top_srcdir)/src/include/H5Block_model.h \
|
||||
$(top_srcdir)/src/include/H5Fed_adjacency.h \
|
||||
$(top_srcdir)/src/include/H5Fed_model.h \
|
||||
$(top_srcdir)/src/include/H5Fed_retrieve.h \
|
||||
$(top_srcdir)/src/include/H5Fed_store.h \
|
||||
$(top_srcdir)/src/include/H5Fed_tags.h \
|
||||
$(top_srcdir)/src/include/H5Part_io.h \
|
||||
$(top_srcdir)/src/include/H5Part_model.h \
|
||||
$(top_srcdir)/src/include/H5_attachments.h \
|
||||
$(top_srcdir)/src/include/H5_err.h \
|
||||
$(top_srcdir)/src/include/H5_file.h \
|
||||
$(top_srcdir)/src/include/H5_file_attribs.h \
|
||||
$(top_srcdir)/src/include/H5_log.h \
|
||||
$(top_srcdir)/src/include/H5_model.h \
|
||||
$(top_srcdir)/src/include/H5_step_attribs.h \
|
||||
$(top_srcdir)/src/include/H5hut.h
|
||||
|
||||
# Listing of all possible headers that I may include
|
||||
EXTRA_HEADERS =
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = Makefile.in
|
||||
|
||||
clean-local:
|
||||
$(RM) *~
|
||||
|
||||
+220
-340
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2006-2013, The Regents of the University of California,
|
||||
Copyright (c) 2006-2015, 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.
|
||||
@@ -8,381 +8,239 @@
|
||||
*/
|
||||
|
||||
#include "h5_private.h"
|
||||
//#include "h5core/h5_model.h"
|
||||
|
||||
/* file handling interface */
|
||||
static inline h5_int64_t
|
||||
open_file (
|
||||
const char *name,
|
||||
const int l_name,
|
||||
h5_int32_t flags,
|
||||
MPI_Comm ccomm,
|
||||
h5_size_t align
|
||||
#include "h5core/h5_log.h"
|
||||
#include "h5core/h5_file.h"
|
||||
|
||||
#include <hdf5.h>
|
||||
|
||||
#define h5_createprop_file FC_MANGLING( \
|
||||
h5_createprop_file, \
|
||||
H5_CREATEPROP_FILE)
|
||||
h5_int64_t
|
||||
h5_createprop_file (
|
||||
void
|
||||
) {
|
||||
char *name2 = h5_strdupfor2c ( name, l_name );
|
||||
h5_file_t* f = h5_open_file ( name2, flags, ccomm, align );
|
||||
free ( name2 );
|
||||
return (h5_int64_t)f;
|
||||
H5_API_ENTER (h5_int64_t, "%s", "");
|
||||
H5_API_RETURN ((h5_int64_t)h5_create_prop (H5_PROP_FILE));
|
||||
}
|
||||
|
||||
#define h5_openr F77_NAME( \
|
||||
h5_openr, \
|
||||
h5_openr_, \
|
||||
H5_OPENR)
|
||||
#if defined(H5_HAVE_PARALLEL)
|
||||
#define h5_setprop_file_mpio FC_MANGLING( \
|
||||
h5_setprop_file_mpio, \
|
||||
H5_SETPROP_FILE_MPIO)
|
||||
h5_int64_t
|
||||
h5_openr (
|
||||
const char *file_name,
|
||||
const int l_file_name
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t, "file_name='%s'",
|
||||
file_name);
|
||||
H5_API_RETURN (open_file (file_name, l_file_name, H5_O_RDONLY, 0, 0));
|
||||
h5_setprop_file_mpio (
|
||||
h5_int64_t* _prop,
|
||||
MPI_Fint* _comm
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t,
|
||||
"prop=%lld, comm=%lld",
|
||||
(long long int)*_prop, (long long int)*_comm);
|
||||
h5_prop_t prop = (h5_prop_t)*_prop;
|
||||
MPI_Comm comm = MPI_Comm_f2c (*_comm);
|
||||
H5_API_RETURN ((h5_int64_t)h5_set_prop_file_mpio_collective (prop, &comm));
|
||||
}
|
||||
|
||||
#define h5_openw F77_NAME( \
|
||||
h5_openw, \
|
||||
h5_openw_, \
|
||||
H5_OPENW)
|
||||
#define h5_setprop_file_mpio_collective FC_MANGLING( \
|
||||
h5_setprop_file_mpio_collective, \
|
||||
H5_SETPROP_FILE_MPIO_COLLECTIVE)
|
||||
h5_int64_t
|
||||
h5_openw (
|
||||
const char *file_name,
|
||||
const int l_file_name
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t, "file_name='%s'",
|
||||
file_name);
|
||||
H5_API_RETURN (open_file (file_name, l_file_name, H5_O_WRONLY, 0, 0));
|
||||
h5_setprop_file_mpio_collective (
|
||||
h5_int64_t* _prop,
|
||||
MPI_Fint* _comm
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t,
|
||||
"prop=%lld, comm=%lld",
|
||||
(long long int)*_prop, (long long int)*_comm);
|
||||
h5_prop_t prop = (h5_prop_t)*_prop;
|
||||
MPI_Comm comm = MPI_Comm_f2c (*_comm);
|
||||
H5_API_RETURN ((h5_int64_t)h5_set_prop_file_mpio_collective (prop, &comm));
|
||||
}
|
||||
|
||||
#define h5_opena F77_NAME( \
|
||||
h5_opena, \
|
||||
h5_opena_, \
|
||||
H5_OPENA)
|
||||
#define h5_setprop_file_mpio_independent FC_MANGLING( \
|
||||
h5_setprop_file_mpio_independent, \
|
||||
H5_SETPROP_FILE_MPIO_INDEPENDENT)
|
||||
h5_int64_t
|
||||
h5_opena (
|
||||
const char *file_name,
|
||||
const int l_file_name
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t, "file_name='%s'",
|
||||
file_name);
|
||||
H5_API_RETURN (open_file (file_name, l_file_name, H5_O_APPEND, 0, 0));
|
||||
h5_setprop_file_mpio_independent (
|
||||
h5_int64_t* _prop,
|
||||
MPI_Fint* _comm
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t,
|
||||
"prop=%lld, comm=%lld",
|
||||
(long long int)*_prop, (long long int)*_comm);
|
||||
h5_prop_t prop = (h5_prop_t)*_prop;
|
||||
MPI_Comm comm = MPI_Comm_f2c (*_comm);
|
||||
H5_API_RETURN ((h5_int64_t)h5_set_prop_file_mpio_independent (prop, &comm));
|
||||
}
|
||||
|
||||
#define h5_openr_align F77_NAME( \
|
||||
h5_openr_align, \
|
||||
h5_openr_align_, \
|
||||
H5_OPENR_ALIGN)
|
||||
#if H5_VERSION_LE(1,8,12)
|
||||
#define h5_setprop_file_mpio_posix FC_MANGLING( \
|
||||
h5_setprop_file_mpio_posix, \
|
||||
H5_SETPROP_FILE_MPIO_POSIX)
|
||||
h5_int64_t
|
||||
h5_openr_align (
|
||||
const char *file_name,
|
||||
const h5_int64_t *align,
|
||||
const int l_file_name
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t, "file_name='%s', align=%llu",
|
||||
file_name, (long long unsigned)align);
|
||||
H5_API_RETURN (open_file (file_name, l_file_name, H5_O_RDONLY, 0, *align));
|
||||
}
|
||||
|
||||
#define h5_openw_align F77_NAME( \
|
||||
h5_openw_align, \
|
||||
h5_openw_align_, \
|
||||
H5_OPENW_ALIGN)
|
||||
h5_int64_t
|
||||
h5_openw_align (
|
||||
const char *file_name,
|
||||
const h5_int64_t *align,
|
||||
const int l_file_name
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t, "file_name='%s', align=%llu",
|
||||
file_name, (long long unsigned)align);
|
||||
H5_API_RETURN (open_file (file_name, l_file_name, H5_O_WRONLY, 0, *align));
|
||||
}
|
||||
|
||||
#define h5_opena_align F77_NAME( \
|
||||
h5_opena_align, \
|
||||
h5_opena_align_, \
|
||||
H5_OPENA_ALIGN)
|
||||
h5_int64_t
|
||||
h5_opena_align (
|
||||
const char *file_name,
|
||||
const h5_int64_t *align,
|
||||
const int l_file_name
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t, "file_name='%s', align=%llu",
|
||||
file_name, (long long unsigned)align);
|
||||
H5_API_RETURN (open_file (file_name, l_file_name, H5_O_APPEND, 0, *align));
|
||||
}
|
||||
|
||||
#ifdef PARALLEL_IO
|
||||
h5_int32_t
|
||||
flagsfor2c (
|
||||
const char* flags,
|
||||
const int l_flags
|
||||
) {
|
||||
if (flags == NULL)
|
||||
return 0;
|
||||
|
||||
h5_int32_t fbits = 0;
|
||||
char* flags2 = h5_strdupfor2c (flags, l_flags);
|
||||
|
||||
flags2 = strtok (flags2, ",");
|
||||
while (flags != NULL) {
|
||||
if (strcmp (flags2, "vfd_mpiposix") == 0)
|
||||
fbits |= H5_VFD_MPIPOSIX;
|
||||
else if (strcmp (flags2, "vfd_core") == 0)
|
||||
fbits |= H5_VFD_CORE;
|
||||
else if (strcmp (flags2, "vfd_mpio_ind") == 0)
|
||||
fbits |= H5_VFD_MPIIO_IND;
|
||||
else if (strcmp (flags2, "fs_lustre") == 0)
|
||||
fbits |= H5_FS_LUSTRE;
|
||||
else {
|
||||
// :FIXME: ignore unknown strings!?
|
||||
}
|
||||
flags2 = strtok (NULL, ",");
|
||||
}
|
||||
free (flags2);
|
||||
return fbits;
|
||||
}
|
||||
|
||||
static inline h5_int64_t
|
||||
open_file_par (
|
||||
const char* file_name,
|
||||
const int l_file_name,
|
||||
MPI_Fint* fcomm,
|
||||
const h5_int32_t mode,
|
||||
const char* flags,
|
||||
const int l_flags,
|
||||
h5_int64_t align
|
||||
) {
|
||||
return open_file (
|
||||
file_name, l_file_name,
|
||||
mode | flagsfor2c (flags, l_flags),
|
||||
MPI_Comm_f2c (*fcomm),
|
||||
align);
|
||||
}
|
||||
|
||||
#define h5_openr_par F77_NAME( \
|
||||
h5_openr_par, \
|
||||
h5_openr_par_, \
|
||||
H5_OPENR_PAR)
|
||||
h5_int64_t
|
||||
h5_openr_par (
|
||||
const char *file_name,
|
||||
MPI_Fint *fcomm,
|
||||
const int l_file_name
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t, "file_name='%*s', fcomm=%d",
|
||||
l_file_name, file_name, *fcomm);
|
||||
H5_API_RETURN (
|
||||
open_file_par (
|
||||
file_name, l_file_name,
|
||||
fcomm,
|
||||
H5_O_RDONLY,
|
||||
NULL, 0,
|
||||
0));
|
||||
}
|
||||
|
||||
#define h5_openw_par F77_NAME( \
|
||||
h5_openw_par, \
|
||||
h5_openw_par_, \
|
||||
H5_OPENW_PAR)
|
||||
h5_int64_t
|
||||
h5_openw_par (
|
||||
const char* file_name,
|
||||
MPI_Fint* fcomm,
|
||||
const int l_file_name
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t, "file_name='%*s', fcomm=%d",
|
||||
l_file_name, file_name, *fcomm);
|
||||
H5_API_RETURN (
|
||||
open_file_par (
|
||||
file_name, l_file_name,
|
||||
fcomm,
|
||||
H5_O_WRONLY,
|
||||
NULL, 0,
|
||||
0));
|
||||
}
|
||||
|
||||
#define h5_opena_par F77_NAME( \
|
||||
h5_opena_par, \
|
||||
h5_opena_par_, \
|
||||
H5_OPENA_PAR)
|
||||
h5_int64_t
|
||||
h5_opena_par (
|
||||
const char* file_name,
|
||||
MPI_Fint* fcomm,
|
||||
const int l_file_name
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t, "file_name='%*s', fcomm=%d",
|
||||
l_file_name, file_name, *fcomm);
|
||||
H5_API_RETURN (
|
||||
open_file_par (
|
||||
file_name, l_file_name,
|
||||
fcomm,
|
||||
H5_O_APPEND,
|
||||
NULL, 0,
|
||||
0));
|
||||
}
|
||||
|
||||
#define h5_openr_par_align F77_NAME( \
|
||||
h5_openr_par_align, \
|
||||
h5_openr_par_align_, \
|
||||
H5_OPENR_PAR_ALIGN)
|
||||
h5_int64_t
|
||||
h5_openr_par_align (
|
||||
const char *file_name,
|
||||
MPI_Fint *fcomm,
|
||||
const h5_int64_t *align,
|
||||
const char *flags,
|
||||
const int l_file_name,
|
||||
const int l_flags
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t, "file_name='%*s', fcomm=%d, flags=%s, align=%lld",
|
||||
l_file_name, file_name, *fcomm, flags, (long long)align);
|
||||
H5_API_RETURN (
|
||||
open_file_par (
|
||||
file_name, l_file_name,
|
||||
fcomm,
|
||||
H5_O_RDONLY,
|
||||
flags, l_flags,
|
||||
*align));
|
||||
}
|
||||
|
||||
#define h5_openw_par_align F77_NAME( \
|
||||
h5_openw_par_align, \
|
||||
h5_openw_par_align_, \
|
||||
H5_OPENW_PAR_ALIGN)
|
||||
h5_int64_t
|
||||
h5_openw_par_align (
|
||||
const char *file_name,
|
||||
MPI_Fint *fcomm,
|
||||
const h5_int64_t *align,
|
||||
const char *flags,
|
||||
const int l_file_name,
|
||||
const int l_flags
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t, "file_name='%*s', fcomm=%d, flags=%s, align=%lld",
|
||||
l_file_name, file_name, *fcomm, flags, (long long)align);
|
||||
H5_API_RETURN (
|
||||
open_file_par (
|
||||
file_name, l_file_name,
|
||||
fcomm,
|
||||
H5_O_WRONLY,
|
||||
flags, l_flags,
|
||||
*align));
|
||||
}
|
||||
|
||||
#define h5_opena_par_align F77_NAME( \
|
||||
h5_opena_par_align, \
|
||||
h5_opena_par_align_, \
|
||||
H5_OPENA_PAR_ALIGN)
|
||||
h5_int64_t
|
||||
h5_opena_par_align (
|
||||
const char *file_name,
|
||||
MPI_Fint *fcomm,
|
||||
const h5_int64_t *align,
|
||||
const char *flags,
|
||||
const int l_file_name,
|
||||
const int l_flags
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t, "file_name='%*s', fcomm=%d, flags=%s, align=%lld",
|
||||
l_file_name, file_name, *fcomm, flags, (long long)align);
|
||||
H5_API_RETURN (
|
||||
open_file_par (
|
||||
file_name, l_file_name,
|
||||
fcomm,
|
||||
H5_O_APPEND,
|
||||
flags, l_flags,
|
||||
*align));
|
||||
h5_setprop_file_mpio_posix (
|
||||
h5_int64_t* _prop,
|
||||
MPI_Fint* _comm
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t,
|
||||
"prop=%lld, comm=%lld",
|
||||
(long long int)*_prop, (long long int)*_comm);
|
||||
h5_prop_t prop = (h5_prop_t)*_prop;
|
||||
MPI_Comm comm = MPI_Comm_f2c (*_comm);
|
||||
H5_API_RETURN ((h5_int64_t)h5_set_prop_file_mpio_posix (prop, &comm));
|
||||
}
|
||||
#endif
|
||||
|
||||
#define h5_close F77_NAME( \
|
||||
h5_close, \
|
||||
h5_close_, \
|
||||
H5_CLOSE)
|
||||
#endif
|
||||
|
||||
#define h5_setprop_file_corevfd FC_MANGLING( \
|
||||
h5_setprop_file_corevfd, \
|
||||
H5_SETPROP_FILE_COREVFD)
|
||||
h5_int64_t
|
||||
h5_close (
|
||||
h5_setprop_file_corevfd (
|
||||
h5_int64_t* _prop,
|
||||
h5_int64_t* increment
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t,
|
||||
"prop=%lld, increment=%lld",
|
||||
(long long int)*_prop, (long long int)*increment);
|
||||
h5_prop_t prop = (h5_prop_t)*_prop;
|
||||
H5_API_RETURN ((h5_int64_t)h5_set_prop_file_core_vfd (prop, *increment));
|
||||
}
|
||||
|
||||
#define h5_setprop_file_align FC_MANGLING ( \
|
||||
h5_setprop_file_align, \
|
||||
H5_SETPROP_FILE_ALIGN)
|
||||
h5_int64_t
|
||||
h5_setprop_file_align (
|
||||
h5_int64_t* _prop,
|
||||
h5_int64_t* align
|
||||
) {
|
||||
H5_API_ENTER (h5_err_t,
|
||||
"prop=%lld, align=%lld",
|
||||
(long long int)*_prop, (long long int)*align);
|
||||
h5_prop_t prop = (h5_prop_t)*_prop;
|
||||
H5_API_RETURN (h5_set_prop_file_align (prop, *align));
|
||||
}
|
||||
|
||||
#define h5_setprop_file_throttle FC_MANGLING ( \
|
||||
h5_setprop_file_throttle, \
|
||||
H5_SETPROP_FILE_THROTTLE)
|
||||
|
||||
h5_int64_t
|
||||
h5_setprop_file_throttle (
|
||||
h5_int64_t* _prop,
|
||||
h5_int64_t* throttle
|
||||
) {
|
||||
H5_API_ENTER (
|
||||
h5_err_t,
|
||||
"prop=%lld, throttle=%lld",
|
||||
(long long int)*_prop, (long long int)*throttle);
|
||||
h5_prop_t prop = (h5_prop_t)*_prop;
|
||||
H5_API_RETURN (h5_set_prop_file_throttle (prop, *throttle));
|
||||
}
|
||||
|
||||
#define h5_closeprop FC_MANGLING ( \
|
||||
h5_closeprop, \
|
||||
H5_CLOSEPROP)
|
||||
h5_int64_t
|
||||
h5_closeprop (
|
||||
h5_int64_t* _prop
|
||||
) {
|
||||
H5_API_ENTER (h5_err_t,
|
||||
"prop=%lld",
|
||||
(long long int)*_prop);
|
||||
h5_prop_t prop = (h5_prop_t)*_prop;
|
||||
H5_API_RETURN (h5_close_prop (prop));
|
||||
}
|
||||
|
||||
#define h5_openfile FC_MANGLING( \
|
||||
h5_openfile, \
|
||||
H5_OPENFILE)
|
||||
h5_int64_t
|
||||
h5_openfile (
|
||||
const char* _fname,
|
||||
h5_int64_t* _mode,
|
||||
h5_int64_t* _props,
|
||||
const int _len_fname
|
||||
) {
|
||||
int len_fname = strlenf (_fname, _len_fname);
|
||||
H5_API_ENTER (h5_int64_t,
|
||||
"fname = %*s, mode=%lld, props=%lld",
|
||||
len_fname, _fname, (long long int)*_mode, (long long int)*_props);
|
||||
char* fname = h5_strdupfor2c (_fname, _len_fname);
|
||||
h5_int64_t mode = *_mode;
|
||||
h5_prop_t props = (h5_prop_t)*_props;
|
||||
h5_file_t f = h5_open_file2 (fname, mode, props);
|
||||
free (fname);
|
||||
H5_API_RETURN ((h5_int64_t)f);
|
||||
}
|
||||
|
||||
#define h5_closefile FC_MANGLING( \
|
||||
h5_closefile, \
|
||||
H5_CLOSEFILE)
|
||||
h5_int64_t
|
||||
h5_closefile (
|
||||
const h5_int64_t *f
|
||||
) {
|
||||
h5_file_t* fh = h5_filehandlefor2c(f);
|
||||
h5_file_t fh = h5_filehandlefor2c(f);
|
||||
H5_API_ENTER (h5_int64_t, "f=%p", (h5_file_p)fh);
|
||||
H5_API_RETURN (h5_close_file (fh));
|
||||
}
|
||||
|
||||
#define h5_finalize F77_NAME( \
|
||||
#define h5_checkfile FC_MANGLING( \
|
||||
h5_checkfile, \
|
||||
H5_CHECKFILE)
|
||||
h5_int64_t
|
||||
h5_checkfile (
|
||||
const h5_int64_t *f
|
||||
) {
|
||||
h5_file_t fh = h5_filehandlefor2c(f);
|
||||
H5_API_ENTER (h5_int64_t, "f=%p", (h5_file_p)fh);
|
||||
H5_API_RETURN (h5_check_filehandle (fh));
|
||||
}
|
||||
|
||||
#define h5_flushfile FC_MANGLING( \
|
||||
h5_flushfile, \
|
||||
H5_FLUSHFILE)
|
||||
h5_int64_t
|
||||
h5_flushfile (
|
||||
const h5_int64_t* f
|
||||
) {
|
||||
h5_file_t fh = h5_filehandlefor2c(f);
|
||||
H5_API_ENTER (h5_int64_t, "f=%p", (h5_file_p)fh);
|
||||
H5_API_RETURN (h5_flush_file (fh));
|
||||
}
|
||||
|
||||
#define h5_flushstep FC_MANGLING( \
|
||||
h5_flushstep, \
|
||||
H5_FLUSHSTEP)
|
||||
h5_int64_t
|
||||
h5_flushstep (
|
||||
const h5_int64_t* f
|
||||
) {
|
||||
h5_file_t fh = h5_filehandlefor2c(f);
|
||||
H5_API_ENTER (h5_int64_t, "f=%p", (h5_file_p)fh);
|
||||
H5_API_RETURN (h5_flush_step (fh));
|
||||
}
|
||||
|
||||
#define h5_finalize FC_MANGLING( \
|
||||
h5_finalize, \
|
||||
h5_finalize_, \
|
||||
H5_FINALIZE)
|
||||
h5_int64_t
|
||||
h5_finalize (
|
||||
void
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t, "%s", "");
|
||||
H5_API_RETURN (h5_close_hdf5());
|
||||
H5_API_RETURN (h5_close_h5hut ());
|
||||
}
|
||||
|
||||
#define h5_check F77_NAME( \
|
||||
h5_check, \
|
||||
h5_check_, \
|
||||
H5_CHECK)
|
||||
h5_int64_t
|
||||
h5_check (
|
||||
const h5_int64_t *f
|
||||
) {
|
||||
|
||||
h5_file_t* fh = h5_filehandlefor2c(f);
|
||||
H5_API_ENTER (h5_int64_t, "f=%p", (h5_file_p)fh);
|
||||
H5_API_RETURN (h5_check_filehandle (fh));
|
||||
}
|
||||
|
||||
/* H5hut data model */
|
||||
#define h5_setstep F77_NAME( \
|
||||
h5_setstep, \
|
||||
h5_setstep_, \
|
||||
H5_SETSTEP)
|
||||
h5_int64_t
|
||||
h5_setstep (
|
||||
const h5_int64_t *f,
|
||||
h5_int64_t *step ) {
|
||||
|
||||
h5_file_t* fh = h5_filehandlefor2c(f);
|
||||
H5_API_ENTER (h5_int64_t, "f=%p, step=%lld", (h5_file_p)fh, (long long)*step);
|
||||
H5_API_RETURN (h5_set_step (fh, (*step)-1));
|
||||
}
|
||||
|
||||
#define h5_getstep F77_NAME( \
|
||||
h5_getstep, \
|
||||
h5_getstep_, \
|
||||
H5_GETSTEP)
|
||||
h5_int64_t
|
||||
h5_getstep (
|
||||
const h5_int64_t *f
|
||||
) {
|
||||
|
||||
h5_file_t* fh = h5_filehandlefor2c(f);
|
||||
H5_API_ENTER (h5_int64_t, "f=%p", (h5_file_p)fh);
|
||||
H5_API_RETURN (h5_get_step (fh) + 1);
|
||||
}
|
||||
|
||||
#define h5_getnsteps F77_NAME( \
|
||||
h5_getnsteps, \
|
||||
h5_getnsteps_, \
|
||||
H5_GETNSTEPS)
|
||||
h5_int64_t
|
||||
h5_getnsteps (
|
||||
const h5_int64_t *f
|
||||
) {
|
||||
|
||||
h5_file_t* fh = h5_filehandlefor2c(f);
|
||||
H5_API_ENTER (h5_int64_t, "f=%p", (h5_file_p)fh);
|
||||
H5_API_RETURN (h5_get_num_steps (fh));
|
||||
}
|
||||
|
||||
|
||||
/* debug output */
|
||||
#define h5_set_verbosity_level F77_NAME( \
|
||||
#define h5_set_verbosity_level FC_MANGLING( \
|
||||
h5_set_verbosity_level, \
|
||||
h5_set_verbosity_level_, \
|
||||
H5_SET_VERBOSITY_LEVEL)
|
||||
h5_int64_t
|
||||
h5_set_verbosity_level (
|
||||
@@ -390,6 +248,28 @@ h5_set_verbosity_level (
|
||||
) {
|
||||
|
||||
H5_API_ENTER (h5_int64_t, "level=%lld", (long long)*level);
|
||||
H5_API_RETURN(h5_set_debuglevel (*level));
|
||||
H5_API_RETURN(h5_set_loglevel (*level));
|
||||
}
|
||||
|
||||
#define h5_abort_on_error FC_MANGLING( \
|
||||
h5_abort_on_error, \
|
||||
H5_ABORT_ON_ERROR)
|
||||
h5_int64_t
|
||||
h5_abort_on_error (
|
||||
void
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t, "%s", "");
|
||||
h5_set_loglevel (1);
|
||||
H5_API_RETURN (h5_set_errorhandler (h5_abort_errorhandler));
|
||||
}
|
||||
|
||||
#define h5_get_error_number FC_MANGLING( \
|
||||
h5_get_error_number, \
|
||||
H5_GET_ERROR_NUMBER)
|
||||
h5_int64_t
|
||||
h5_get_error_number (
|
||||
void
|
||||
) {
|
||||
H5_API_ENTER (h5_int64_t, "%s", "");
|
||||
H5_API_RETURN (h5_get_errno ());
|
||||
}
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
!!!!!!!! File Opening and Closing !!!!!!!!
|
||||
|
||||
!> \ingroup h5hut_file_f
|
||||
!! Opens a file for reading. See \ref H5OpenFile
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5_openr ( filename )
|
||||
CHARACTER(LEN=*), INTENT(IN) :: filename !< the filename to open for reading
|
||||
END FUNCTION
|
||||
|
||||
!> \ingroup h5hut_file_f
|
||||
!! Opens a file for writing in truncate mode. See \ref H5OpenFile
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5_openw ( filename )
|
||||
CHARACTER(LEN=*), INTENT(IN) :: filename !< the filename to open for writing
|
||||
END FUNCTION
|
||||
|
||||
!> \ingroup h5hut_file_f
|
||||
!! Opens a file for writing in append mode. See \ref H5OpenFile
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5_opena ( filename )
|
||||
CHARACTER(LEN=*), INTENT(IN) :: filename !< the filename to open for appending
|
||||
END FUNCTION
|
||||
|
||||
!> \ingroup h5hut_file_f
|
||||
!! Opens a parallel file for reading.
|
||||
!! See \ref H5OpenFile
|
||||
!!
|
||||
!! Flags are specified as a comma separated string that can include:
|
||||
!!
|
||||
!! - \c vfd_mpiposix - use the HDF5 MPI-POSIX virtual file driver
|
||||
!! - \c vfd_indendent - use MPI-IO in indepedent mode
|
||||
!!
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5_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
|
||||
CHARACTER(LEN=*), INTENT(IN) :: flags !< additional flags
|
||||
END FUNCTION
|
||||
|
||||
!> \ingroup h5hut_file_f
|
||||
!! Opens a parallel file for writing.
|
||||
!! See \ref H5OpenFile
|
||||
!!
|
||||
!! Flags are specified as a comma separated string that can include:
|
||||
!!
|
||||
!! - \c vfd_mpiposix - use the HDF5 MPI-POSIX virtual file driver
|
||||
!! - \c vfd_indendent - use MPI-IO in indepedent mode
|
||||
!!
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5_openw_par_align ( filename, mpi_communicator, align, flags )
|
||||
CHARACTER(LEN=*), INTENT(IN) :: filename !< the filename to open for writing
|
||||
INTEGER, INTENT(IN) :: mpi_communicator !< the MPI_Communicator used by the program
|
||||
CHARACTER(LEN=*), INTENT(IN) :: flags !< additional flags
|
||||
END FUNCTION
|
||||
|
||||
!> \ingroup h5hut_file_f
|
||||
!! Opens a parallel file for writing in append mode.
|
||||
!! See \ref H5OpenFile
|
||||
!!
|
||||
!! Flags are specified as a comma separated string that can include:
|
||||
!!
|
||||
!! - \c vfd_mpiposix - use the HDF5 MPI-POSIX virtual file driver
|
||||
!! - \c vfd_indendent - use MPI-IO in indepedent mode
|
||||
!!
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5_opena_par_align ( filename, mpi_communicator, align, flags )
|
||||
CHARACTER(LEN=*), INTENT(IN) :: filename !< the filename to open for appending
|
||||
INTEGER, INTENT(IN) :: mpi_communicator !< the MPI_Communicator used by the program
|
||||
CHARACTER(LEN=*), INTENT(IN) :: flags !< additional flags
|
||||
END FUNCTION
|
||||
|
||||
!> \ingroup h5hut_file_f
|
||||
!! Closes a file. See \ref H5CloseFile
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5_close ( filehandle )
|
||||
INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
|
||||
END FUNCTION
|
||||
|
||||
!> \ingroup h5hut_file_f
|
||||
!! Checks that a file is valid. See \ref H5CheckFile
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5_check ( filehandle )
|
||||
INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
|
||||
END FUNCTION
|
||||
|
||||
!> \ingroup h5hut_file_f
|
||||
!! See \ref H5SetVerbosityLevel
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5_set_verbosity_level ( level )
|
||||
INTEGER*8, INTENT(IN) :: level !< the level from 0 (no output) to 5 (most detailed)
|
||||
END FUNCTION
|
||||
|
||||
!> \ingroup h5hut_model_f
|
||||
!! See \ref H5SetStep
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5_setstep (filehandle,step)
|
||||
INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
|
||||
INTEGER*8, INTENT(IN) :: step !< a timestep value >= 1
|
||||
END FUNCTION
|
||||
|
||||
!> \ingroup h5hut_model_f
|
||||
!! See \ref H5GetNumSteps
|
||||
!! \return the number of steps or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5_getnsteps (filehandle)
|
||||
INTEGER*8, INTENT(IN) :: filehandle !< the handle returned during file open
|
||||
END FUNCTION
|
||||
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
!!!!!!!! Setting up the Data Model !!!!!!!!
|
||||
|
||||
!> \ingroup h5block_model_f
|
||||
!! See \ref H5Block3dSetView
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5bl_3d_setview ( 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
|
||||
|
||||
!> \ingroup h5block_model_f
|
||||
!! See \ref H5Block3dGetView
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5bl_3d_getview ( filehandle, i_start, i_end, j_start, j_end, k_start, k_end )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
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
|
||||
|
||||
|
||||
!> \ingroup h5block_model_f
|
||||
!! See \ref H5Block3dSetChunk
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5bl_3d_setchunk ( 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
|
||||
|
||||
!> \ingroup h5block_model_f
|
||||
!! See \ref H5Block3dGetReducedView
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5bl_3d_getreducedview ( filehandle, i_start, i_end, j_start, j_end, k_start, k_end )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
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
|
||||
|
||||
!> \ingroup h5block_model_f
|
||||
!! See \ref H5Block3dHasView
|
||||
!! \return rank of processor error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5bl_3d_hasview ( filehandle )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
END FUNCTION
|
||||
|
||||
!> \ingroup h5block_model_f
|
||||
!! See \ref H5BlockGetNumFields
|
||||
!! \return number of fields or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5bl_getnumfields ( filehandle )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
END FUNCTION
|
||||
|
||||
!> \ingroup h5block_model_f
|
||||
!! See \ref H5BlockGetFieldInfo
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
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
|
||||
INTEGER*8, INTENT(OUT) :: type
|
||||
END FUNCTION
|
||||
|
||||
!!!!!!!! Reading and Writing Attributes !!!!!!!!
|
||||
|
||||
!> \ingroup h5block_attrib_f
|
||||
!! See \ref H5BlockWriteFieldAttribString
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
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
|
||||
|
||||
!> \ingroup h5block_attrib_f
|
||||
!! See \ref H5BlockGetNumFieldAttribs
|
||||
!! \return number of attributes or error code
|
||||
!<
|
||||
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
|
||||
|
||||
!> \ingroup h5block_attrib_f
|
||||
!! See \ref H5BlockGetFieldAttribInfo
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
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
|
||||
|
||||
!> \ingroup h5block_attrib_f
|
||||
!! See \ref H5BlockReadFieldAttribString
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
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
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
! _ _ _ _
|
||||
! __| | __ _| |_ __ _ _ __ ___ ___ __| | ___| |
|
||||
! / _` |/ _` | __/ _` | | '_ ` _ \ / _ \ / _` |/ _ \ |
|
||||
! | (_| | (_| | || (_| | | | | | | | (_) | (_| | __/ |
|
||||
! \__,_|\__,_|\__\__,_| |_| |_| |_|\___/ \__,_|\___|_|
|
||||
|
||||
|
||||
!>
|
||||
!! \ingroup h5block_model_f
|
||||
!! See \ref H5Block3dSetView
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5bl_3d_setview ( 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
|
||||
|
||||
!>
|
||||
!! \ingroup h5block_model_f
|
||||
!! See \ref H5Block3dGetView
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5bl_3d_getview ( filehandle, i_start, i_end, j_start, j_end, k_start, k_end )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
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
|
||||
|
||||
!>
|
||||
!! \ingroup h5block_model_f
|
||||
!! See \ref H5Block3dGetReducedView
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5bl_3d_getreducedview ( filehandle, i_start, i_end, j_start, j_end, k_start, k_end )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
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
|
||||
|
||||
!>
|
||||
!! \ingroup h5block_model_f
|
||||
!! See \ref H5Block3dHasView
|
||||
!! \return rank of processor error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5bl_3d_hasview ( filehandle )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
END FUNCTION
|
||||
|
||||
!>
|
||||
!! \ingroup h5block_model_f
|
||||
!! See \ref H5Block3dSetChunk
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5bl_3d_setchunk ( 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
|
||||
|
||||
!>
|
||||
!! \ingroup h5block_model_f
|
||||
!! See \ref H5BlockGetNumFields
|
||||
!! \return number of fields or error code
|
||||
!<
|
||||
INTEGER*8 FUNCTION h5bl_getnumfields ( filehandle )
|
||||
INTEGER*8, INTENT(IN) :: filehandle
|
||||
END FUNCTION
|
||||
|
||||
!>
|
||||
!! \ingroup h5block_model_f
|
||||
!! See \ref H5BlockGetFieldInfo
|
||||
!! \return 0 on success or error code
|
||||
!<
|
||||
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
|
||||
INTEGER*8, INTENT(OUT) :: type
|
||||
END FUNCTION
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user