Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
H5hut
src
Commits
6d3014ba
Commit
6d3014ba
authored
Jun 23, 2017
by
gsell
Browse files
Fortran examples:
- adapted for serial compilation, closing
#8
parent
20424235
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
201 additions
and
62 deletions
+201
-62
examples/H5/Makefile.am
examples/H5/Makefile.am
+5
-2
examples/H5/openclosef.f90
examples/H5/openclosef.f90
+16
-5
examples/H5/queryf.f90
examples/H5/queryf.f90
+10
-5
examples/H5/read_file_attribsf.f90
examples/H5/read_file_attribsf.f90
+9
-4
examples/H5/read_step_attribsf.f90
examples/H5/read_step_attribsf.f90
+12
-6
examples/H5/write_file_attribsf.f90
examples/H5/write_file_attribsf.f90
+11
-4
examples/H5/write_step_attribsf.f90
examples/H5/write_step_attribsf.f90
+11
-4
examples/H5Block/Makefile.am
examples/H5Block/Makefile.am
+1
-2
examples/H5Block/read_write_scalar_fieldf.f90
examples/H5Block/read_write_scalar_fieldf.f90
+15
-2
examples/H5Part/Makefile.am
examples/H5Part/Makefile.am
+2
-3
examples/H5Part/read_canonicalviewf.f90
examples/H5Part/read_canonicalviewf.f90
+10
-2
examples/H5Part/read_core_vfdf.f90
examples/H5Part/read_core_vfdf.f90
+10
-3
examples/H5Part/read_setnparticlesf.f90
examples/H5Part/read_setnparticlesf.f90
+11
-1
examples/H5Part/read_setviewf.f90
examples/H5Part/read_setviewf.f90
+13
-3
examples/H5Part/read_stridedf.f90
examples/H5Part/read_stridedf.f90
+13
-2
examples/H5Part/write_core_vfdf.f90
examples/H5Part/write_core_vfdf.f90
+13
-4
examples/H5Part/write_setnparticlesf.f90
examples/H5Part/write_setnparticlesf.f90
+12
-4
examples/H5Part/write_setviewf.f90
examples/H5Part/write_setviewf.f90
+13
-4
examples/H5Part/write_stridedf.f90
examples/H5Part/write_stridedf.f90
+11
-2
examples/include/examples.f90
examples/include/examples.f90
+3
-0
No files found.
examples/H5/Makefile.am
View file @
6d3014ba
...
...
@@ -8,6 +8,7 @@
#
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
...
...
@@ -39,7 +40,7 @@ noinst_PROGRAMS += \
endif
if
ENABLE_FORTRAN
if
ENABLE_PARALLEL
#
if ENABLE_PARALLEL
noinst_PROGRAMS
+=
\
openclosef
\
queryf
\
...
...
@@ -54,9 +55,11 @@ 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
endif
endif
all
:
${noinst_PROGRAMS}
%.o
:
%.f90
$(FC)
$(FFLAGS)
-c
$<
examples/H5/openclosef.f90
View file @
6d3014ba
...
...
@@ -14,22 +14,33 @@ program openclose
implicit
none
#if defined(PARALLEL_IO)
include
'mpif.h'
integer
::
comm
,
rank
,
ierr
#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
examples/H5/queryf.f90
View file @
6d3014ba
!
! Copyright (c) 2006-201
3
, The Regents of the University of California,
! Copyright (c) 2006-201
7
, 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.!
...
...
@@ -7,15 +7,17 @@
! 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"
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
...
...
@@ -23,7 +25,9 @@
! 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
()
...
...
@@ -33,8 +37,9 @@
call
query_file
(
FNAME1
);
call
query_file
(
FNAME2
);
#if defined(PARALLEL_IO)
call
mpi_finalize
(
ierr
)
#endif
call
exit
(
ierr
)
contains
...
...
examples/H5/read_file_attribsf.f90
View file @
6d3014ba
...
...
@@ -11,7 +11,9 @@
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"
...
...
@@ -40,9 +42,6 @@
real
*
4
,
allocatable
::
r4_value
(:)
real
*
8
,
allocatable
::
r8_value
(:)
! used for mpi error return
integer
::
ierr
! H5hut file id
integer
*
8
::
file_id
...
...
@@ -58,7 +57,12 @@
! 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
()
...
...
@@ -109,6 +113,7 @@
! cleanup
status
=
h5_closefile
(
file_id
)
#if defined(PARALLEL_IO)
call
mpi_finalize
(
ierr
)
#endif
end
program
read_file_attribs
examples/H5/read_step_attribsf.f90
View file @
6d3014ba
...
...
@@ -11,8 +11,11 @@
program
read_step_attribs
use
H5hut
implicit
none
include
'mpif.h'
#if defined(PARALLEL_IO)
include
'mpif.h'
#endif
! the file name we want to read
character
(
len
=*
),
parameter
::
FNAME
=
"example_file_attribs.h5"
...
...
@@ -36,9 +39,6 @@
real
*
4
,
allocatable
::
r4_value
(:)
real
*
8
,
allocatable
::
r8_value
(:)
! used for mpi error return
integer
::
ierr
! H5hut file id
integer
*
8
::
file_id
...
...
@@ -54,8 +54,13 @@
! loop index
integer
*
8
i
call
mpi_init
(
ierr
)
#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
()
...
...
@@ -108,6 +113,7 @@
! cleanup
status
=
h5_closefile
(
file_id
)
#if defined(PARALLEL_IO)
call
mpi_finalize
(
ierr
)
#endif
end
program
read_step_attribs
examples/H5/write_file_attribsf.f90
View file @
6d3014ba
...
...
@@ -11,8 +11,11 @@
program
write_file_attribs
use
H5hut
implicit
none
include
'mpif.h'
#if defined(PARALLEL_IO)
include
'mpif.h'
#endif
integer
*
8
,
parameter
::
verbosity_level
=
1
character
(
len
=*
),
parameter
::
FNAME
=
"example_file_attribs.h5"
...
...
@@ -29,11 +32,13 @@
real
*
4
,
parameter
,
dimension
(
*
)
::
r4_value
=
(/
2.71828
/)
real
*
8
,
parameter
,
dimension
(
*
)
::
r8_value
=
(/
3.141592653589793238462643383279502884197169
/)
integer
::
ierr
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
()
...
...
@@ -51,6 +56,8 @@
! cleanup
status
=
h5_closefile
(
file_id
)
call
mpi_finalize
(
ierr
)
#if defined(PARALLEL_IO)
call
mpi_finalize
(
ierr
)
#endif
end
program
write_file_attribs
examples/H5/write_step_attribsf.f90
View file @
6d3014ba
...
...
@@ -11,8 +11,11 @@
program
write_step_attribs
use
H5hut
implicit
none
include
'mpif.h'
#if defined(PARALLEL_IO)
include
'mpif.h'
#endif
integer
*
8
,
parameter
::
verbosity_level
=
1
character
(
len
=*
),
parameter
::
FNAME
=
"example_step_attribs.h5"
...
...
@@ -29,11 +32,13 @@
real
*
4
,
parameter
,
dimension
(
*
)
::
r4_value
=
(/
2.71828
/)
real
*
8
,
parameter
,
dimension
(
*
)
::
r8_value
=
(/
3.141592653589793238462643383279502884197169
/)
integer
::
ierr
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
()
...
...
@@ -54,6 +59,8 @@
! cleanup
status
=
h5_closefile
(
file_id
)
call
mpi_finalize
(
ierr
)
#if defined(PARALLEL_IO)
call
mpi_finalize
(
ierr
)
#endif
end
program
write_step_attribs
examples/H5Block/Makefile.am
View file @
6d3014ba
...
...
@@ -8,6 +8,7 @@
#
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
...
...
@@ -34,10 +35,8 @@ noinst_PROGRAMS += \
endif
if
ENABLE_FORTRAN
if
ENABLE_PARALLEL
noinst_PROGRAMS
+=
read_write_scalar_fieldf
endif
endif
attach_field_attributes_SOURCES
=
attach_field_attributes.c
dump_field_attributes_SOURCES
=
dump_field_attributes.c
...
...
examples/H5Block/read_write_scalar_fieldf.f90
View file @
6d3014ba
...
...
@@ -11,13 +11,17 @@ 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
::
comm
=
0
integer
::
mpi_err
integer
*
8
::
h5_err
integer
::
i
character
(
len
=
32
)
::
arg_str
...
...
@@ -174,10 +178,15 @@ program read_write_scalar_field
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
)
...
...
@@ -215,7 +224,9 @@ program read_write_scalar_field
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
...
...
@@ -233,7 +244,9 @@ program read_write_scalar_field
endif
print
"('[proc ', I3, ']: Cleanup.')"
,
comm_rank
#if defined(PARALLEL_IO)
call
mpi_finalize
#endif
print
"('[proc ', I3, ']: Done.')"
,
comm_rank
call
exit
(
0
)
...
...
examples/H5Part/Makefile.am
View file @
6d3014ba
#
# Copyright (c) 2006-201
5
, The Regents of the University of California,
# Copyright (c) 2006-201
7
, 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,6 +8,7 @@
#
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
...
...
@@ -42,7 +43,6 @@ noinst_PROGRAMS += \
endif
if
ENABLE_FORTRAN
if
ENABLE_PARALLEL
noinst_PROGRAMS
+=
\
read_core_vfdf
\
read_canonicalviewf
\
...
...
@@ -54,7 +54,6 @@ noinst_PROGRAMS += \
write_setviewf
\
write_stridedf
endif
endif
EXTRA_PROGRAMS
=
...
...
examples/H5Part/read_canonicalviewf.f90
View file @
6d3014ba
...
...
@@ -11,7 +11,10 @@ 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"
...
...
@@ -19,17 +22,19 @@ program read_canonicalview
! H5hut verbosity level
integer
*
8
,
parameter
::
h5_verbosity
=
H5_VERBOSE_DEFAULT
integer
::
comm
,
comm_size
,
comm_rank
,
mpi_ierror
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_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
)
...
...
@@ -53,6 +58,9 @@ program read_canonicalview
! cleanup
deallocate
(
data
)
h5_ierror
=
h5_closefile
(
file
)
#if defined(PARALLEL_IO)
call
mpi_finalize
(
mpi_ierror
)
#endif
end
program
read_canonicalview
examples/H5Part/read_core_vfdf.f90
View file @
6d3014ba
...
...
@@ -11,7 +11,10 @@ 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"
...
...
@@ -19,8 +22,6 @@ program read_core_vfd
! H5hut verbosity level
integer
*
8
,
parameter
::
h5_verbosity
=
H5_VERBOSE_DEFAULT
integer
::
comm
,
comm_size
,
comm_rank
,
mpi_ierror
integer
*
8
::
file
,
h5_ierror
integer
*
8
::
prop
integer
*
8
::
num_particles
...
...
@@ -28,10 +29,13 @@ program read_core_vfd
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_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
)
...
...
@@ -57,6 +61,9 @@ program read_core_vfd
! cleanup
deallocate
(
data
)
h5_ierror
=
h5_closefile
(
file
)
#if defined(PARALLEL_IO)
call
mpi_finalize
(
mpi_ierror
)
#endif
end
program
read_core_vfd
examples/H5Part/read_setnparticlesf.f90
View file @
6d3014ba
...
...
@@ -11,7 +11,10 @@ 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"
...
...
@@ -19,17 +22,21 @@ program read_setnparticles
! H5hut verbosity level
integer
*
8
,
parameter
::
h5_verbosity
=
H5_VERBOSE_DEFAULT
integer
::
comm
,
comm_size
,
comm_rank
,
mpi_ierror
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
)
...
...
@@ -61,6 +68,9 @@ program read_setnparticles
! cleanup
deallocate
(
data
)
h5_ierror
=
h5_closefile
(
file
)
#if defined(PARALLEL_IO)
call
mpi_finalize
(
mpi_ierror
)
#endif
end
program
read_setnparticles
examples/H5Part/read_setviewf.f90
View file @
6d3014ba
...
...
@@ -11,25 +11,32 @@ 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
,
comm_size
,
comm_rank
,
mpi_ierror
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
)
...
...
@@ -78,6 +85,9 @@ program read_setviewf
! cleanup
deallocate
(
data
)
h5_ierror
=
h5_closefile
(
file
)
call
mpi_finalize
(
mpi_ierror
)
#if defined(PARALLEL_IO)
call
mpi_finalize
(
mpi_ierror
)
#endif
end
program
read_setviewf
examples/H5Part/read_stridedf.f90
View file @
6d3014ba
...
...
@@ -11,24 +11,32 @@ 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
::
comm
,
comm_size
,
comm_rank
,
mpi_ierror
integer
::
comm_size
=
1
integer
::
comm_rank
=
0
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
)
#endif
call
h5_abort_on_error
()
call
h5_set_verbosity_level
(
h5_verbosity
)
...
...
@@ -68,6 +76,9 @@ program read_stridedf
! cleanup
deallocate
(
data
)
h5_ierror
=
h5_closefile
(
file
)
call
mpi_finalize
(
mpi_ierror
)
#if defined(PARALLEL_IO)
call
mpi_finalize
(
mpi_ierror
)
#endif
end
program
read_stridedf
examples/H5Part/write_core_vfdf.f90
View file @
6d3014ba
...
...
@@ -11,8 +11,11 @@ include 'H5hut.f90'
program
write_core_vfd
use
H5hut
implicit
none
include
'mpif.h'
#if defined(PARALLEL_IO)
include
'mpif.h'
#endif
! name of output file
character
(
len
=*
),
parameter
::
fname
=
"example_core_vfd.h5"