fixed missing test/testf.F90

This commit is contained in:
Marc Howison
2010-02-11 17:42:56 +00:00
parent ec7184bf2d
commit f671d1ab9f
2 changed files with 75 additions and 0 deletions
+1
View File
@@ -77,6 +77,7 @@ test/Makefile.am -text
test/params.h -text
test/read.c -text
test/test.c -text
test/testf.F90 -text
test/testframe.c -text
test/testframe.h -text
test/write.c -text
+74
View File
@@ -0,0 +1,74 @@
program H5PartTest
implicit none
#ifdef PARALLEL_IO
include 'mpif.h'
#endif
include 'H5PartF.h'
#ifdef PARALLEL_IO
integer :: comm, ierr, i
integer*8 :: file_id, status, npoints
#endif
real*8, allocatable :: x(:),y(:),z(:),px(:),py(:),pz(:)
integer*8, allocatable :: id(:)
#ifdef PARALLEL_IO
call MPI_INIT(ierr)
comm = MPI_COMM_WORLD
#endif
! this enables level 3 ("info") messages to be
! printed by the H5Part library
! (3_8 is the literal for an integer*8 with value 3)
status = h5pt_set_verbosity_level (3_8)
! open the a file called 'test.h5' in parallel for writing
#ifdef PARALLEL_IO
file_id = h5pt_openw_par ('test.h5', comm)
#else
file_id = h5pt_openw ('test.h5')
#endif
! in the Fortran API, steps start at 1
status = h5pt_setstep (file_id, 1_8)
! write an attribute to the file
status = h5pt_writefileattrib_string (file_id, 'desc', 'This is a test.')
! set the size of the data array
npoints = 99
status = h5pt_setnpoints (file_id, npoints)
! create fake data
allocate( x(npoints), y(npoints), z(npoints) )
allocate( px(npoints), py(npoints), pz(npoints) )
allocate( id(npoints) )
do i=1,int(npoints)
x(i) = 0.0 + real(i)
y(i) = 0.1 + real(i)
z(i) = 0.2 + real(i)
px(i) = 0.3 + real(i)
py(i) = 0.4 + real(i)
pz(i) = 0.5 + real(i)
id(i) = i
enddo
! write the data
status = h5pt_writedata_r8 (file_id, "x", x)
status = h5pt_writedata_r8 (file_id, "y", y)
status = h5pt_writedata_r8 (file_id, "z", z)
status = h5pt_writedata_r8 (file_id, "px", px)
status = h5pt_writedata_r8 (file_id, "py", py)
status = h5pt_writedata_r8 (file_id, "pz", pz)
status = h5pt_writedata_i8 (file_id, "id", id)
! close the file
status = h5pt_close (file_id)
#ifdef PARALLEL_IO
call MPI_FINALIZE(ierr)
#endif
end program H5PartTest