Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Submit feedback
  • Sign in
S
src
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 6
    • Issues 6
    • List
    • Boards
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • H5hut
  • src
  • Wiki
    • Documentation
    • Examples
  • H5

H5

Last edited by gsell Nov 10, 2017
Page history

File handling

Table of Contents
  • 1. Open file with default properties, serial version
  • 2. Open file with default properties, parallel version
  • 3. Open file to use MPI independent I/O

1. Open file with default properties, serial version

C implementation

#include "H5hut.h"

int
main (
	int argc,
	char** argv
	) {
        h5_file_t f = H5OpenFile ("testfile.h5", H5_O_WRONLY, H5_PROP_DEFAULT);

	H5CloseFile (f);
	return 0;
}

Fortran90 implementation

include 'H5hut.f90'

program openclose
  use H5hut
  implicit none
  include 'mpif.h'

  integer*8 :: file_id, status

  file_id = h5_openfile ("testfile.h5", H5_O_WRONLY, H5_PROP_DEFAULT)

  status = h5_closefile (file_id);
end program openclose

2. Open file with default properties, parallel version

C implementation

#include "H5hut.h"

int
main (
	int argc,
	char** argv
	) {
	MPI_Init (&argc, &argv);
        h5_file_t f = H5OpenFile ("testfile.h5", H5_O_WRONLY, H5_PROP_DEFAULT);

	H5CloseFile (f);
	MPI_Finalize ();
	return 0;
}

Fortran90 implementation

[app-listing]]
[source,Fortran]
include 'H5hut.f90'

program openclose
  use H5hut
  implicit none
  include 'mpif.h'

  integer :: ierr
  integer*8 :: file_id, status

  call mpi_init(ierr)
  file_id = h5_openfile ("testfile.h5", H5_O_WRONLY, H5_PROP_DEFAULT)

  status = h5_closefile (file_id);
  call mpi_finalize(ierr)
end program openclose

3. Open file to use MPI independent I/O

C implementation

[app-listing]]
[source,C]
#include "H5hut.h"

int
main (
	int argc,
	char** argv
	) {
	MPI_Init (&argc, &argv);
	MPI_Comm comm = MPI_COMM_WORLD;
        h5_prop_t prop = H5CreateFileProp ();
        H5SetPropFileMPIOIndependent (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
Clone repository
  • Home
  • Documentation
    • API Changes
    • Examples
    • Layout
  • Documentation/Examples
    • H5
    • H5 File attributes
    • H5 Steps
  • Installation
    • Download
    • Installation
More Pages

New Wiki Page

Tip: You can specify the full path for the new file. We will automatically create any missing directories.