Writes Eulerian data using LEAP's HDF5.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(eulerian_set), | intent(inout) | :: | this |
An Eulerian Set |
||
| integer, | intent(in) | :: | iter |
Iteration at write |
||
| real(kind=wp), | intent(in) | :: | time |
Time at write |
||
| character(len=str8), | intent(in), | optional | :: | list(:) |
Names of fields to write |
impure subroutine eulerian_set_WriteHDF5(this,iter,time,list) !> Writes Eulerian data using LEAP's HDF5. use leapUtils, only: stringtool_obj implicit none class(eulerian_set), intent(inout):: this !! An Eulerian Set integer, intent(in) :: iter !! Iteration at write real(wp), intent(in) :: time !! Time at write character(str8), intent(in), & optional :: list(:) !! Names of fields to write ! Work variables type(sysutils_obj) :: sysutils type(stringtool_obj):: stringtool character(len=:), & allocatable :: filename type(hdf5_obj) :: hdf5 integer :: n,ind type(xdmf_obj) :: xdmf integer :: maxhi(3) integer :: minlo(3) ! Nothing to write, if empty if (.not.allocated(this%field)) return if (.not.this%overwrite.and.this%parallel%RankIsRoot()) & call sysutils%CreateDirectory(HDF5dir) ! Initialize HDF5 call hdf5%Initialize(this%parallel) ! Open the file if (this%overwrite) then filename = stringtool%RemoveExtension(this%write_file) call hdf5%Open(filename,"W") else ! Add time info and remove extension filename = stringtool%RemoveExtension(this%write_file)//"_"//stringtool%FormatTime(time) ! Prepend Hdf5 folder path filename=HDF5dir//'/'//stringtool%RemovePath(filename) call hdf5%Open(filename,"RW") end if ! Write time call hdf5%WriteAttributes("/","time",time) call hdf5%WriteAttributes("/","iter",iter) if (.not.present(list)) then ! Write all fields do n=1,size(this%field) call this%WriteSingle(hdf5,n) end do else do n=1,size(list) ! Get index of this Eulerian_obj ind = this%GetIndex(list(n)) if (ind.lt.1) call this%parallel%Stop('Unable to find '//list(n)//' in Eulerian_set') call this%WriteSingle(hdf5,ind) end do end if ! Close file call hdf5%Close() ! Finalize HDF5 call hdf5%Finalize() ! Determine max and min grid extents call this%parallel%Min(this%block%lo,minlo) call this%parallel%Max(this%block%hi,maxhi) ! Write companion XDMF file if (this%parallel%RankIsRoot()) then ! Intialize XDMF object call xdmf%Initialize() ! Add grid info to XDMF object if (this%overwrite) then call xdmf%AddGrid('mesh',maxhi-minlo+1, 'block'//HDF5_EXTENSION,'x1','x2','x3') else call xdmf%AddGrid('mesh',maxhi-minlo+1, '../block'//HDF5_EXTENSION,'x1','x2','x3') end if ! Add field info to XDMF object if (.not.present(list)) then do n=1,size(this%field) select type (my_field => this%field(n)%p) type is (eulerian_obj_r) if (wp.eq.leapSP) & call xdmf%AddField(my_field%name,'Float','4',stringtool%RemovePath(filename)//HDF5_EXTENSION) if (wp.eq.leapDP) & call xdmf%AddField(my_field%name,'Float','8',stringtool%RemovePath(filename)//HDF5_EXTENSION) type is (eulerian_obj_i) call xdmf%AddField(my_field%name,'Int', '4',stringtool%RemovePath(filename)//HDF5_EXTENSION) end select end do else do n=1,size(list) ! Get index of this Eulerian_obj ind = this%GetIndex(list(n)) if (ind.lt.1) call this%parallel%Stop('Unable to find '//list(n)//' in Eulerian_set') select type (my_field => this%field(ind)%p) type is (eulerian_obj_r) if (wp.eq.leapSP) & call xdmf%AddField(my_field%name,'Float','4',stringtool%RemovePath(filename)//HDF5_EXTENSION) if (wp.eq.leapDP) & call xdmf%AddField(my_field%name,'Float','8',stringtool%RemovePath(filename)//HDF5_EXTENSION) type is (eulerian_obj_i) call xdmf%AddField(my_field%name,'Int', '4',stringtool%RemovePath(filename)//HDF5_EXTENSION) end select end do end if ! Write XDMF file call xdmf%Write(filename//XDMF_EXTENSION) ! Finalize XDMF object call xdmf%Finalize() end if return end subroutine eulerian_set_WriteHDF5