High-level XH5F API
Single unified object that coordinates HDF5 data files and XDMF metadata in one call. MPI master/worker branching is handled transparently β no explicit rank checks in your code.
A pure Fortran 2003+ library providing a simple, agnostic API for parallel HDF5/XDMF IO in MPI-based HPC applications.
Let us consider a very simple numerical domain discretized by a collection of cartesian, uniform grids with the fields of pressure, density and temperature integrated at cell center. The generation of output files in HDF5/XDMF form can be conveniently done by means of the motion class xh5f_file_object by something like the following:
call xh5f%open_file(filename_hdf5='simple-mpi_'//trim(strz(myrank,2))//'.h5', &
filename_xdmf='simple-mpi_procs_'//trim(strz(domain%procs_number,2))//'.xdmf')
call xh5f%open_grid(grid_name='blocks', grid_type=XDMF_PARAMETERS%XDMF_GRID_TYPE_COLLECTION_ASYNC)
call xh5f%open_grid(grid_name='mpi_'//trim(strz(myrank,2)), grid_type=XDMF_PARAMETERS%XDMF_GRID_TYPE_COLLECTION)
do b=1, domain%nb_proc
call xh5f%open_block(block_type = XH5F_PARAMETERS%XH5F_BLOCK_CARTESIAN_UNIFORM, &
block_name = 'block_'//trim(strz(mynb(1)-1+b,2)), & ! global block numeration
nijk = nijk, &
emin = domain%emin(:,b), &
dxyz = domain%dxyz, &
time = domain%time)
call xh5f%save_block_field(xdmf_field_name = 'Time', &
field = domain%time, &
field_center = XDMF_PARAMETERS%XDMF_ATTR_CENTER_GRID, &
field_format = XDMF_PARAMETERS%XDMF_DATAITEM_NUMBER_FORMAT_XML)
do v=1, domain%nv
call xh5f%save_block_field(xdmf_field_name = field_name(v)%chars(), &
nijk = nijk, &
field = field(v,1:nijk(1),1:nijk(2),1:nijk(3),b), &
field_center = XDMF_PARAMETERS%XDMF_ATTR_CENTER_CELL, &
field_format = XDMF_PARAMETERS%XDMF_DATAITEM_NUMBER_FORMAT_HDF, &
hdf5_field_name = 'block_'//trim(strz(mynb(1)-1+b,2))//'-'//field_name(v)%chars())
enddo
call xh5f%close_block
enddo
call xh5f%close_grid
call xh5f%close_grid(grid_type=XDMF_PARAMETERS%XDMF_GRID_TYPE_COLLECTION_ASYNC)
call xh5f%close_fileIn the above (incomplete) example (see the full source here) a set of HDF5 files are created, one for each MPI processes used, as well as one XDMF file describing the data contained into all HDF5 files. Each MPI process generates its own HDF5 file (in parallel and asyncronously) containing the data of the grids/fields assigned to it. Also, each MPI process generates its own XDMF file structure, but only the master process (myrank=0) creates a real XDMF file into witch it writes the description of its data and also the descritpion of the data of the other processes: as a matter of facts, MOTIOn objects (files classes) are able to automatically understand which is the master process that must gather the informations from other processes, committing a MPI_GATHERV only when all processes have created their own XDMF structure. The creation of HDF5 files and XDMF structures happens asyncronously, and the gathering of data for the final XDMF file happens only on the last instructions.
The above example also shows some MOTIOn features:
XDMF_ATTR_CENTER_GRID, XDMF_DATAITEM_NUMBER_FORMAT_XML, ecc...; these parameters simplify the handling of HDF5/XDMF syntax;xh5f_file_object class provides an high level API with a simple, reduced set of methods, e.g. to save a scalar 0D field and a 3D one the same save_block_field method is used, without the necessity to use specialized API.Contributions are welcome β see the Contributing page.
FOSSIL is distributed under a multi-licensing system:
| Use case | License |
|---|---|
| FOSS projects | GPL v3 |
| Closed source / commercial | BSD 2-Clause |
| Closed source / commercial | BSD 3-Clause |
| Closed source / commercial | MIT |
Anyone interested in using, developing, or contributing to FOSSIL is welcome β pick the license that best fits your needs.