Write marker data to file in parallel using HDF5.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(marker_set), | intent(inout) | :: | this |
A collection of tessellation elements |
||
| integer, | intent(in) | :: | iter |
Iteration at write |
||
| real(kind=wp), | intent(in) | :: | time |
Time at write |
impure subroutine marker_set_WriteHDF5(this,iter,time) !> Write marker data to file in parallel using HDF5. use leapUtils, only: stringtool_obj, sysutils_obj implicit none class(marker_set), intent(inout) :: this !! A collection of tessellation elements integer, intent(in) :: iter !! Iteration at write real(wp), intent(in) :: time !! Time at write ! Work variables type(sysutils_obj) :: sysutils type(stringtool_obj) :: stringtool character(len=:), & allocatable :: filename character(len=str64) :: tmpC type(hdf5_obj) :: hdf5 integer, allocatable :: buffi(:) integer(leapI8), allocatable :: buffi8(:) real(wp), allocatable :: buffr(:) ! Nothing to write, if empty call this%UpdateCount() if (this%count.eq.0) return ! Create directory if (this%parallel%RankIsRoot()) & call sysutils%CreateDirectory('Hdf5') filename = 'Hdf5/'//stringtool%RemoveExtension(this%write_file) ! Initialize HDF5 call hdf5%Initialize(this%parallel) ! Open the file if (this%overwrite) then write(tmpC,'(ES12.4)') time filename = filename//"_"//trim(adjustl(tmpC)) call hdf5%Open(filename,"W") else call hdf5%Open(filename,"RW") end if ! Write attributes call hdf5%WriteAttributes("/","Time", time) call hdf5%WriteAttributes("/","Iter", iter) call hdf5%WriteAttributes("/","Count",this%count) ! Allocate buffers allocate(buffi8(this%count_),buffi(this%count_),buffr(this%count_)) ! Write the marker data if (this%count_.eq.0) then call hdf5%Write("/","id",buffi8) call hdf5%Write("/","x", buffr ) call hdf5%Write("/","y", buffr ) call hdf5%Write("/","z", buffr ) call hdf5%Write("/","i", buffi ) call hdf5%Write("/","j", buffi ) call hdf5%Write("/","k", buffi ) call hdf5%Write("/","s", buffi ) call hdf5%Write("/","SA",buffr ) call hdf5%Write("/","nx",buffr ) call hdf5%Write("/","ny",buffr ) call hdf5%Write("/","nz",buffr ) call hdf5%Write("/","vx",buffr ) call hdf5%Write("/","vy",buffr ) call hdf5%Write("/","vz",buffr ) call hdf5%Write("/","fx",buffr ) call hdf5%Write("/","fy",buffr ) call hdf5%Write("/","fz",buffr ) else select type (markers=>this%p) type is (marker_obj) buffi8=markers(1:this%count_)%id ; call hdf5%Write("/","id",buffi8) buffr =markers(1:this%count_)%p(1) ; call hdf5%Write("/","x", buffr ) buffr =markers(1:this%count_)%p(2) ; call hdf5%Write("/","y", buffr ) buffr =markers(1:this%count_)%p(3) ; call hdf5%Write("/","z", buffr ) buffi =markers(1:this%count_)%c(1) ; call hdf5%Write("/","i", buffi ) buffi =markers(1:this%count_)%c(2) ; call hdf5%Write("/","j", buffi ) buffi =markers(1:this%count_)%c(3) ; call hdf5%Write("/","k", buffi ) buffi =markers(1:this%count_)%s ; call hdf5%Write("/","s", buffi ) buffr =markers(1:this%count_)%SA ; call hdf5%Write("/","SA",buffr ) buffr =markers(1:this%count_)%n(1) ; call hdf5%Write("/","nx",buffr ) buffr =markers(1:this%count_)%n(2) ; call hdf5%Write("/","ny",buffr ) buffr =markers(1:this%count_)%n(3) ; call hdf5%Write("/","nz",buffr ) buffr =markers(1:this%count_)%v(1) ; call hdf5%Write("/","vx",buffr ) buffr =markers(1:this%count_)%v(2) ; call hdf5%Write("/","vy",buffr ) buffr =markers(1:this%count_)%v(3) ; call hdf5%Write("/","vz",buffr ) buffr =markers(1:this%count_)%f(1) ; call hdf5%Write("/","fx",buffr ) buffr =markers(1:this%count_)%f(2) ; call hdf5%Write("/","fy",buffr ) buffr =markers(1:this%count_)%f(3) ; call hdf5%Write("/","fz",buffr ) end select end if ! Deallocate buffers deallocate(buffi8,buffi,buffr) ! Close file call hdf5%Close() ! Finalize HDF5 call hdf5%Finalize() return end subroutine marker_set_WriteHDF5