|
|
= File handling and attributes
|
|
|
:TOC:
|
|
|
:numbered:
|
|
|
|
|
|
== Open file in collective mode
|
|
|
C implementation
|
|
|
|
|
|
----
|
|
|
#include "H5hut.h"
|
|
|
|
|
|
int
|
|
|
main (
|
|
|
int argc,
|
|
|
char** argv
|
|
|
) {
|
|
|
MPI_Init (&argc, &argv);
|
|
|
MPI_Comm comm = MPI_COMM_WORLD;
|
|
|
|
|
|
h5_prop_t prop = H5CreateFileProp ();
|
|
|
H5SetPropFileMPIOCollective (prop, &comm);
|
|
|
h5_file_t f = H5OpenFile ("testfile.h5", H5_O_WRONLY, prop);
|
|
|
H5CloseProp (prop);
|
|
|
H5CloseFile (f);
|
|
|
|
|
|
MPI_Finalize ();
|
|
|
return 0;
|
|
|
}
|
|
|
----
|
|
|
|
|
|
Fortran90 implementation
|
|
|
----
|
|
|
include 'H5hut.f90'
|
|
|
|
|
|
program openclose
|
|
|
|
|
|
use H5hut
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
include 'mpif.h'
|
|
|
|
|
|
integer :: comm, rank, ierr
|
|
|
integer*8 :: file_id, status
|
|
|
integer*8 :: props
|
|
|
|
|
|
comm = MPI_COMM_WORLD
|
|
|
call mpi_init(ierr)
|
|
|
call mpi_comm_rank(comm, rank, ierr)
|
|
|
|
|
|
props = h5_createprop_file ()
|
|
|
status = h5_setprop_file_mpio_collective (props, comm)
|
|
|
file_id = h5_openfile ("testfile.h5", H5_O_WRONLY, props)
|
|
|
status = h5_closeprop (props)
|
|
|
status = h5_closefile (file_id);
|
|
|
|
|
|
call mpi_finalize(ierr)
|
|
|
|
|
|
end program openclose
|
|
|
---- |
|
|
\ No newline at end of file |