Writes block data using HDF5.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(block_obj), | intent(in) | :: | this |
A block object |
||
| character(len=*), | intent(in) | :: | name |
Name of file to write |
impure subroutine block_obj_Write(this,name) !> Writes block data using HDF5. implicit none class(block_obj), intent(in) :: this !! A block object character(len=*), intent(in) :: name !! Name of file to write ! Work variables type(hdf5_obj), & pointer :: hdf5 type(hdf5_obj), & target :: hdf5t integer :: Ng(3) integer :: maxhi(3) integer :: minlo(3) character(len=2):: label integer :: nsize integer :: dir integer :: Nblock(3) real(wp), & allocatable :: xg(:) real(wp), & allocatable :: buff(:) ! Use internal pointer, if associated. ! Otherwise, use a new object. if (associated(this%hdf5)) then hdf5 => this%hdf5 else call hdf5t%Initialize(this%parallel) hdf5 => hdf5t end if ! Open file call hdf5%Open(trim(adjustl(name)),'W') associate (lo => this%lo, hi => this%hi, x => this%x, y => this%y, & z =>this%z, periods => this%periods, rank => this%parallel%rank,& np => this%parallel%np ) ! Get number of grid points in each direction call this%parallel%Max(hi,maxhi) call this%parallel%Min(lo,minlo) ! Total number of grid points Ng = maxhi-minlo+1 ! Write header info call hdf5%WriteAttributes('/','Periodicity',periods) call hdf5%WriteAttributes('/','Ng', Ng ) do dir=1,3 ! Build global coordinate array allocate(xg (minlo(dir):maxhi(dir)+1)) allocate(buff(Ng(dir)+1)) xg = 0.0_wp xg(lo(dir):hi(dir)) = this%axis(dir)%x(lo(dir):hi(dir)) if (rank%dir(dir).eq.np(dir)) xg(hi(dir)+1) = this%axis(dir)%x(hi(dir)+1) Nblock = np Nblock(dir) = 1 nsize = Nblock(1)*Nblock(2)*Nblock(3) call this%parallel%Sum(xg,buff); xg=buff/nsize ! Form label for this axis: x1, x2, x3 write(label,fmt='(a,i1)') 'x',dir ! Write coordinates along this axis call hdf5%WriteCoord('/', label, xg) deallocate(xg) deallocate(buff) end do end associate ! Close file call hdf5%Close() ! Free data if (associated(this%hdf5)) then hdf5 => null() else call hdf5t%Finalize() hdf5 => null() end if return end subroutine block_obj_Write