Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
S
src
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Code Review
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
H5hut
src
Commits
b69aa9b9
Commit
b69aa9b9
authored
Apr 07, 2016
by
gsell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
example/H5Block
- write_field added
parent
99699d4b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
4 deletions
+84
-4
.gitignore
.gitignore
+2
-2
examples/H5Block/Makefile.am
examples/H5Block/Makefile.am
+3
-2
examples/H5Block/write_field.c
examples/H5Block/write_field.c
+79
-0
No files found.
.gitignore
View file @
b69aa9b9
...
...
@@ -38,8 +38,7 @@ examples/H5/write_file_attribsf
examples/H5/write_step_attribs
examples/H5/write_step_attribsf
examples/H5Block/H5BlockExampleF
examples/H5Block/blockfile1.h5
examples/H5Block/blockfile8.h5
examples/H5Block/*.h5
examples/H5Block/fields
examples/H5Block/read_write
examples/H5Part/Bench
...
...
@@ -90,6 +89,7 @@ examples/H5Fed/trimesh_read
examples/H5Fed/trimesh_write
examples/H5Fed/trimesh_write_dunetest
tetmesh_write_tags
write_field
*.gch
ReferencePages
vtk2h5grid
examples/H5Block/Makefile.am
View file @
b69aa9b9
...
...
@@ -26,7 +26,8 @@ noinst_PROGRAMS =
if
ENABLE_C
noinst_PROGRAMS
+=
\
fields
\
read_write_scalar_field
read_write_scalar_field
\
write_field
endif
if
ENABLE_FORTRAN
...
...
@@ -38,7 +39,7 @@ endif
fields_SOURCES
=
fields.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
...
...
examples/H5Block/write_field.c
0 → 100644
View file @
b69aa9b9
/*
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"
// 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
ssize_t
dim_x
=
32
;
const
ssize_t
dim_y
=
8
;
const
ssize_t
dim_z
=
8
;
#define idx(i, j, k) (i + j*dim_y + k*dim_x*dim_y)
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
);
// slice field in X direction
ssize_t
n_slices
=
dim_x
/
comm_size
;
ssize_t
remaining_slices
=
dim_x
%
comm_size
;
ssize_t
i_start
=
comm_rank
*
n_slices
;
if
(
comm_rank
<
remaining_slices
)
{
n_slices
++
;
i_start
+=
comm_rank
;
}
else
{
i_start
+=
remaining_slices
;
}
ssize_t
i_end
=
i_start
+
n_slices
;
// create fake data
h5_int64_t
data
[(
i_end
-
i_start
+
1
)
*
dim_y
*
dim_z
];
for
(
int
k
=
0
;
k
<
dim_z
;
k
++
)
{
for
(
int
j
=
0
;
j
<
dim_y
;
j
++
)
{
for
(
int
i
=
i_start
;
i
<
i_end
;
i
++
)
{
data
[
idx
(
i
-
i_start
,
j
,
k
)]
=
(
h5_int64_t
)
idx
(
i
,
j
,
k
);
}
}
}
// open file and create first step
h5_file_t
file
=
H5OpenFile
(
fname
,
H5_O_WRONLY
,
H5_PROP_DEFAULT
);
H5SetStep
(
file
,
0
);
H5Block3dSetView
(
file
,
i_start
,
i_end
,
0
,
dim_y
-
1
,
0
,
dim_z
-
1
);
// write data
H5Block3dWriteScalarFieldInt64
(
file
,
"data"
,
data
);
// done
H5CloseFile
(
file
);
MPI_Finalize
();
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment