Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TurTLE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TurTLE
TurTLE
Commits
bd36aacb
Commit
bd36aacb
authored
7 years ago
by
Chichi Lalescu
Browse files
Options
Downloads
Patches
Plain Diff
add broken field::write_filtered
parent
09760fd7
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!23
WIP: Feature/use cmake
Pipeline
#36278
passed
7 years ago
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
bfps/cpp/field.cpp
+132
-0
132 additions, 0 deletions
bfps/cpp/field.cpp
bfps/cpp/field.hpp
+5
-0
5 additions, 0 deletions
bfps/cpp/field.hpp
with
137 additions
and
0 deletions
bfps/cpp/field.cpp
+
132
−
0
View file @
bd36aacb
...
@@ -612,6 +612,138 @@ int field<rnumber, be, fc>::write_0slice(
...
@@ -612,6 +612,138 @@ int field<rnumber, be, fc>::write_0slice(
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
template
<
typename
rnumber
,
field_backend
be
,
field_components
fc
>
int
field
<
rnumber
,
be
,
fc
>::
write_filtered
(
const
std
::
string
fname
,
const
std
::
string
field_name
,
const
int
iteration
,
int
nx
)
{
/* file dataset has same dimensions as field */
TIMEZONE
(
"field::write_filtered"
);
// only works in Fourier representation
assert
(
!
this
->
real_space_representation
);
assert
(
nx
<=
this
->
rlayout
->
sizes
[
2
]);
hid_t
file_id
,
dset_id
,
plist_id
;
dset_id
=
H5I_BADID
;
std
::
string
dset_name
=
(
"/"
+
field_name
+
"/complex"
+
"/"
+
std
::
to_string
(
iteration
));
/* open/create file */
plist_id
=
H5Pcreate
(
H5P_FILE_ACCESS
);
H5Pset_fapl_mpio
(
plist_id
,
this
->
comm
,
MPI_INFO_NULL
);
bool
file_exists
=
false
;
struct
stat
file_buffer
;
file_exists
=
(
stat
(
fname
.
c_str
(),
&
file_buffer
)
==
0
);
if
(
file_exists
)
file_id
=
H5Fopen
(
fname
.
c_str
(),
H5F_ACC_RDWR
,
plist_id
);
else
file_id
=
H5Fcreate
(
fname
.
c_str
(),
H5F_ACC_EXCL
,
H5P_DEFAULT
,
plist_id
);
assert
(
file_id
>=
0
);
H5Pclose
(
plist_id
);
/* generic space initialization */
hid_t
fspace
,
mspace
;
hsize_t
count
[
ndim
(
fc
)],
offset
[
ndim
(
fc
)],
dims
[
ndim
(
fc
)],
fdims
[
ndim
(
fc
)];
hsize_t
memoffset
[
ndim
(
fc
)],
memshape
[
ndim
(
fc
)];
// set up dimensions
for
(
unsigned
int
i
=
3
;
i
<
ndim
(
fc
);
i
++
)
{
count
[
i
]
=
this
->
clayout
->
subsizes
[
i
];
offset
[
i
]
=
this
->
clayout
->
starts
[
i
];
dims
[
i
]
=
this
->
clayout
->
sizes
[
i
];
memshape
[
i
]
=
count
[
i
];
memoffset
[
i
]
=
0
;
}
// set up smaller dimensions
unsigned
int
ii
=
0
;
count
[
ii
]
=
this
->
clayout
->
subsizes
[
ii
];
offset
[
ii
]
=
this
->
clayout
->
starts
[
ii
];
dims
[
ii
]
=
this
->
clayout
->
sizes
[
ii
];
memshape
[
ii
]
=
count
[
ii
];
memoffset
[
ii
]
=
0
;
ii
=
1
;
count
[
ii
]
=
this
->
clayout
->
subsizes
[
ii
];
offset
[
ii
]
=
this
->
clayout
->
starts
[
ii
];
dims
[
ii
]
=
this
->
clayout
->
sizes
[
ii
];
memshape
[
ii
]
=
count
[
ii
];
memoffset
[
ii
]
=
0
;
ii
=
2
;
count
[
ii
]
=
nx
/
2
+
1
;
offset
[
ii
]
=
0
;
dims
[
ii
]
=
nx
/
2
+
1
;
memshape
[
ii
]
=
this
->
clayout
->
subsizes
[
ii
];
memoffset
[
ii
]
=
0
;
mspace
=
H5Screate_simple
(
ndim
(
fc
),
memshape
,
NULL
);
H5Sselect_hyperslab
(
mspace
,
H5S_SELECT_SET
,
memoffset
,
NULL
,
count
,
NULL
);
/* open/create data set */
if
(
!
H5Lexists
(
file_id
,
field_name
.
c_str
(),
H5P_DEFAULT
))
{
hid_t
gid_tmp
=
H5Gcreate
(
file_id
,
field_name
.
c_str
(),
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
H5Gclose
(
gid_tmp
);
}
if
(
!
H5Lexists
(
file_id
,
(
field_name
+
"/complex"
).
c_str
(),
H5P_DEFAULT
))
{
hid_t
gid_tmp
=
H5Gcreate
(
file_id
,
(
"/"
+
field_name
+
"/complex"
).
c_str
(),
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
H5Gclose
(
gid_tmp
);
}
if
(
H5Lexists
(
file_id
,
dset_name
.
c_str
(),
H5P_DEFAULT
))
{
dset_id
=
H5Dopen
(
file_id
,
dset_name
.
c_str
(),
H5P_DEFAULT
);
fspace
=
H5Dget_space
(
dset_id
);
}
else
{
fspace
=
H5Screate_simple
(
ndim
(
fc
),
dims
,
NULL
);
/* chunking needs to go in here */
dset_id
=
H5Dcreate
(
file_id
,
dset_name
.
c_str
(),
this
->
cnumber_H5T
,
fspace
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
}
/* both dset_id and fspace now have sane values */
/* check file space */
int
ndims_fspace
=
H5Sget_simple_extent_dims
(
fspace
,
fdims
,
NULL
);
assert
(((
unsigned
int
)(
ndims_fspace
))
==
ndim
(
fc
));
for
(
unsigned
int
i
=
0
;
i
<
ndim
(
fc
);
i
++
)
{
offset
[
i
]
=
this
->
clayout
->
starts
[
i
];
assert
(
dims
[
i
]
==
fdims
[
i
]);
}
H5Sselect_hyperslab
(
fspace
,
H5S_SELECT_SET
,
offset
,
NULL
,
count
,
NULL
);
H5Dwrite
(
dset_id
,
this
->
cnumber_H5T
,
mspace
,
fspace
,
H5P_DEFAULT
,
this
->
data
);
H5Sclose
(
mspace
);
/* close file data space */
H5Sclose
(
fspace
);
/* close data set */
H5Dclose
(
dset_id
);
/* close file */
H5Fclose
(
file_id
);
return
EXIT_SUCCESS
;
}
template
<
typename
rnumber
,
template
<
typename
rnumber
,
field_backend
be
,
field_backend
be
,
...
...
This diff is collapsed.
Click to expand it.
bfps/cpp/field.hpp
+
5
−
0
View file @
bd36aacb
...
@@ -103,6 +103,11 @@ class field
...
@@ -103,6 +103,11 @@ class field
const
hid_t
group
,
const
hid_t
group
,
const
std
::
string
field_name
,
const
std
::
string
field_name
,
const
int
iteration
);
const
int
iteration
);
int
write_filtered
(
const
std
::
string
fname
,
const
std
::
string
field_name
,
const
int
iteration
,
const
int
nx
);
int
io_binary
(
int
io_binary
(
const
std
::
string
fname
,
const
std
::
string
fname
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment