subroutine Read_DGModel3D_t(this,fileName)
implicit none
class(DGModel3D_t),intent(inout) :: this
character(*),intent(in) :: fileName
! Local
integer(HID_T) :: fileId
integer(HID_T) :: solOffset(1:4)
integer :: firstElem,ivar
character(LEN=:),allocatable :: dsetName
if(this%mesh%decomp%mpiEnabled) then
call Open_HDF5(fileName,H5F_ACC_RDWR_F,fileId, &
this%mesh%decomp%mpiComm)
else
call Open_HDF5(fileName,H5F_ACC_RDWR_F,fileId)
endif
if(this%mesh%decomp%mpiEnabled) then
firstElem = this%mesh%decomp%offsetElem(this%mesh%decomp%rankId+1)
solOffset(1:4) = (/0,0,0,firstElem/)
endif
! A variable whose dataset is absent keeps the value it was initialized
! with; see Read_DGModel2D_t for why the check is here.
do ivar = 1,this%solution%nvar
dsetName = '/controlgrid/solution/'//trim(this%solution%meta(ivar)%name)
if(.not. DatasetExists_HDF5(fileId,dsetName)) then
print*,__FILE__," : Pickup file holds no ",trim(dsetName), &
" - keeping the initialized value for this variable."
cycle
endif
if(this%mesh%decomp%mpiEnabled) then
call ReadArray_HDF5(fileId,dsetName, &
this%solution%interior(:,:,:,:,ivar),solOffset)
else
call ReadArray_HDF5(fileId,dsetName, &
this%solution%interior(:,:,:,:,ivar))
endif
enddo
call Close_HDF5(fileId)
! Publish the restored solution to the device. Read_DGModel1D_t has always
! done this; without it a GPU build restarts from whatever the device
! happened to hold (zeros, after Init) and silently discards the pickup
! file - the first device-to-host copy of the run, in CalculateEntropy or
! the first tendency evaluation, overwrites everything just read. This is
! the counterpart of the UpdateHost() that Write_DGModel3D_t performs before
! writing, and is a no-op on a CPU build.
call this%solution%UpdateDevice()
endsubroutine Read_DGModel3D_t