particle_set_ReadH5HUT Subroutine

private impure subroutine particle_set_ReadH5HUT(this, iter, time, step)

Reads particle data from file in parallel using H5HUT.

Type Bound

particle_set

Arguments

Type IntentOptional Attributes Name
class(particle_set), intent(inout) :: this

Lagrangian array to dump

integer, intent(out) :: iter

Iteration at write

real(kind=wp), intent(out) :: time

Time at write

integer, intent(in), optional :: step

User supplied step to open


Calls

proc~~particle_set_readh5hut~~CallsGraph proc~particle_set_readh5hut particle_set%particle_set_ReadH5HUT c c proc~particle_set_readh5hut->c fc fc proc~particle_set_readh5hut->fc fh fh proc~particle_set_readh5hut->fh p p proc~particle_set_readh5hut->p particles particles proc~particle_set_readh5hut->particles proc~h5hut_obj_final h5hut_obj%h5hut_obj_Final proc~particle_set_readh5hut->proc~h5hut_obj_final proc~h5hut_obj_getnpoints h5hut_obj%h5hut_obj_GetNPoints proc~particle_set_readh5hut->proc~h5hut_obj_getnpoints proc~h5hut_obj_init h5hut_obj%h5hut_obj_Init proc~particle_set_readh5hut->proc~h5hut_obj_init proc~h5hut_obj_jumptostep h5hut_obj%h5hut_obj_JumpToStep proc~particle_set_readh5hut->proc~h5hut_obj_jumptostep proc~h5hut_obj_lasttimestep h5hut_obj%h5hut_obj_LastTimeStep proc~particle_set_readh5hut->proc~h5hut_obj_lasttimestep proc~lagrangian_set_communicate lagrangian_set%lagrangian_set_Communicate proc~particle_set_readh5hut->proc~lagrangian_set_communicate proc~lagrangian_set_localize lagrangian_set%lagrangian_set_Localize proc~particle_set_readh5hut->proc~lagrangian_set_localize proc~lagrangian_set_resize lagrangian_set%lagrangian_set_Resize proc~particle_set_readh5hut->proc~lagrangian_set_resize tc tc proc~particle_set_readh5hut->tc th th proc~particle_set_readh5hut->th v v proc~particle_set_readh5hut->v w w proc~particle_set_readh5hut->w proc~hdf5_obj_final hdf5_obj%hdf5_obj_Final proc~h5hut_obj_final->proc~hdf5_obj_final proc~hdf5_obj_getnpoints hdf5_obj%hdf5_obj_GetNPoints proc~h5hut_obj_getnpoints->proc~hdf5_obj_getnpoints proc~hdf5_obj_readdatasetnames hdf5_obj%hdf5_obj_ReadDatasetNames proc~h5hut_obj_getnpoints->proc~hdf5_obj_readdatasetnames proc~hdf5_obj_init hdf5_obj%hdf5_obj_Init proc~h5hut_obj_init->proc~hdf5_obj_init none~readattributes hdf5_obj%ReadAttributes proc~h5hut_obj_jumptostep->none~readattributes proc~h5hut_obj_getnsteps h5hut_obj%h5hut_obj_GetNSteps proc~h5hut_obj_jumptostep->proc~h5hut_obj_getnsteps proc~h5hut_obj_setstep h5hut_obj%h5hut_obj_SetStep proc~h5hut_obj_jumptostep->proc~h5hut_obj_setstep proc~h5hut_obj_lasttimestep->none~readattributes proc~h5hut_obj_lasttimestep->proc~h5hut_obj_getnsteps proc~h5hut_obj_lasttimestep->proc~h5hut_obj_setstep proc~lagrangian_set_communicate->proc~lagrangian_set_resize mpi_gather mpi_gather proc~lagrangian_set_communicate->mpi_gather mpi_recv mpi_recv proc~lagrangian_set_communicate->mpi_recv mpi_send mpi_send proc~lagrangian_set_communicate->mpi_send proc~lagrangian_set_recycle lagrangian_set%lagrangian_set_Recycle proc~lagrangian_set_communicate->proc~lagrangian_set_recycle proc~block_obj_getowningcell block_obj%block_obj_GetOwningCell proc~lagrangian_set_localize->proc~block_obj_getowningcell proc~hdf5_obj_readattributes0d hdf5_obj%hdf5_obj_ReadAttributes0D none~readattributes->proc~hdf5_obj_readattributes0d proc~hdf5_obj_readattributes1d hdf5_obj%hdf5_obj_ReadAttributes1D none~readattributes->proc~hdf5_obj_readattributes1d proc~hdf5_obj_readgroupnames hdf5_obj%hdf5_obj_ReadGroupNames proc~h5hut_obj_getnsteps->proc~hdf5_obj_readgroupnames proc~hdf5_obj_creategroup hdf5_obj%hdf5_obj_CreateGroup proc~h5hut_obj_setstep->proc~hdf5_obj_creategroup h5garbage_collect_f h5garbage_collect_f proc~hdf5_obj_final->h5garbage_collect_f proc~hashtbl_obj_final hashtbl_obj%hashtbl_obj_Final proc~hdf5_obj_final->proc~hashtbl_obj_final h5dclose_f h5dclose_f proc~hdf5_obj_getnpoints->h5dclose_f h5dget_space_f h5dget_space_f proc~hdf5_obj_getnpoints->h5dget_space_f h5dopen_f h5dopen_f proc~hdf5_obj_getnpoints->h5dopen_f h5sclose_f h5sclose_f proc~hdf5_obj_getnpoints->h5sclose_f h5sget_simple_extent_npoints_f h5sget_simple_extent_npoints_f proc~hdf5_obj_getnpoints->h5sget_simple_extent_npoints_f proc~hdf5_obj_closegroup hdf5_obj%hdf5_obj_CloseGroup proc~hdf5_obj_getnpoints->proc~hdf5_obj_closegroup proc~hdf5_obj_getgroupobject hdf5_obj%hdf5_obj_GetGroupObject proc~hdf5_obj_getnpoints->proc~hdf5_obj_getgroupobject proc~hdf5_obj_opengroup hdf5_obj%hdf5_obj_OpenGroup proc~hdf5_obj_getnpoints->proc~hdf5_obj_opengroup h5open_f h5open_f proc~hdf5_obj_init->h5open_f proc~hashtbl_obj_init hashtbl_obj%hashtbl_obj_Init proc~hdf5_obj_init->proc~hashtbl_obj_init h5gn_members_f h5gn_members_f proc~hdf5_obj_readdatasetnames->h5gn_members_f h5iget_name_f h5iget_name_f proc~hdf5_obj_readdatasetnames->h5iget_name_f h5oclose_f h5oclose_f proc~hdf5_obj_readdatasetnames->h5oclose_f h5oget_info_f h5oget_info_f proc~hdf5_obj_readdatasetnames->h5oget_info_f h5oopen_by_idx_f h5oopen_by_idx_f proc~hdf5_obj_readdatasetnames->h5oopen_by_idx_f proc~hdf5_obj_fixgroupname hdf5_obj%hdf5_obj_FixGroupName proc~hdf5_obj_readdatasetnames->proc~hdf5_obj_fixgroupname proc~lagrangian_set_recycle->proc~lagrangian_set_resize proc~hdf5_obj_closegroup->proc~hdf5_obj_fixgroupname proc~hdf5_obj_closegroup->proc~hdf5_obj_getgroupobject h5gclose_f h5gclose_f proc~hdf5_obj_closegroup->h5gclose_f proc~hashtbl_obj_hashstring hashtbl_obj%hashtbl_obj_HashString proc~hdf5_obj_closegroup->proc~hashtbl_obj_hashstring proc~hashtbl_obj_remove hashtbl_obj%hashtbl_obj_Remove proc~hdf5_obj_closegroup->proc~hashtbl_obj_remove proc~hdf5_obj_creategroup->proc~hdf5_obj_closegroup proc~hdf5_obj_creategroup->proc~hdf5_obj_fixgroupname h5gcreate_f h5gcreate_f proc~hdf5_obj_creategroup->h5gcreate_f proc~hdf5_obj_creategroup->proc~hashtbl_obj_hashstring proc~hashtbl_obj_put hashtbl_obj%hashtbl_obj_Put proc~hdf5_obj_creategroup->proc~hashtbl_obj_put proc~hdf5_obj_getgroupobject->proc~hdf5_obj_fixgroupname none~get~4 hashtbl_obj%Get proc~hdf5_obj_getgroupobject->none~get~4 proc~hdf5_obj_getgroupobject->proc~hashtbl_obj_hashstring proc~hdf5_obj_opengroup->proc~hdf5_obj_fixgroupname proc~hdf5_obj_opengroup->proc~hdf5_obj_getgroupobject h5oopen_f h5oopen_f proc~hdf5_obj_opengroup->h5oopen_f proc~hdf5_obj_opengroup->proc~hashtbl_obj_hashstring proc~hdf5_obj_opengroup->proc~hashtbl_obj_put proc~hdf5_obj_readattributes0d->h5sclose_f proc~hdf5_obj_readattributes0d->proc~hdf5_obj_closegroup proc~hdf5_obj_readattributes0d->proc~hdf5_obj_getgroupobject proc~hdf5_obj_readattributes0d->proc~hdf5_obj_opengroup h5aclose_f h5aclose_f proc~hdf5_obj_readattributes0d->h5aclose_f h5aget_space_f h5aget_space_f proc~hdf5_obj_readattributes0d->h5aget_space_f h5aget_type_f h5aget_type_f proc~hdf5_obj_readattributes0d->h5aget_type_f h5aopen_f h5aopen_f proc~hdf5_obj_readattributes0d->h5aopen_f h5aread_f h5aread_f proc~hdf5_obj_readattributes0d->h5aread_f h5sget_simple_extent_dims_f h5sget_simple_extent_dims_f proc~hdf5_obj_readattributes0d->h5sget_simple_extent_dims_f proc~hdf5_obj_readattributes1d->h5sclose_f proc~hdf5_obj_readattributes1d->proc~hdf5_obj_closegroup proc~hdf5_obj_readattributes1d->proc~hdf5_obj_getgroupobject proc~hdf5_obj_readattributes1d->proc~hdf5_obj_opengroup proc~hdf5_obj_readattributes1d->h5aclose_f proc~hdf5_obj_readattributes1d->h5aget_space_f proc~hdf5_obj_readattributes1d->h5aget_type_f proc~hdf5_obj_readattributes1d->h5aopen_f proc~hdf5_obj_readattributes1d->h5aread_f proc~hdf5_obj_readattributes1d->h5sget_simple_extent_dims_f proc~hdf5_obj_readgroupnames->h5gn_members_f proc~hdf5_obj_readgroupnames->h5iget_name_f proc~hdf5_obj_readgroupnames->h5oclose_f proc~hdf5_obj_readgroupnames->h5oget_info_f proc~hdf5_obj_readgroupnames->h5oopen_by_idx_f proc~hdf5_obj_readgroupnames->proc~hdf5_obj_fixgroupname proc~hashtbl_obj_get_int4 hashtbl_obj%hashtbl_obj_Get_int4 none~get~4->proc~hashtbl_obj_get_int4 proc~hashtbl_obj_get_int8 hashtbl_obj%hashtbl_obj_Get_int8 none~get~4->proc~hashtbl_obj_get_int8 proc~hashtbl_obj_get_real_dp hashtbl_obj%hashtbl_obj_Get_real_dp none~get~4->proc~hashtbl_obj_get_real_dp proc~hashtbl_obj_get_real_sp hashtbl_obj%hashtbl_obj_Get_real_sp none~get~4->proc~hashtbl_obj_get_real_sp proc~sllist_obj_put sllist_obj%sllist_obj_Put proc~hashtbl_obj_put->proc~sllist_obj_put proc~sllist_obj_remove sllist_obj%sllist_obj_Remove proc~hashtbl_obj_remove->proc~sllist_obj_remove none~get~3 sllist_obj%Get proc~hashtbl_obj_get_int4->none~get~3 proc~hashtbl_obj_get_int8->none~get~3 proc~hashtbl_obj_get_real_dp->none~get~3 proc~hashtbl_obj_get_real_sp->none~get~3 proc~sllist_obj_put->proc~sllist_obj_put proc~sllist_obj_get_int4 sllist_obj%sllist_obj_Get_int4 none~get~3->proc~sllist_obj_get_int4 proc~sllist_obj_get_int8 sllist_obj%sllist_obj_Get_int8 none~get~3->proc~sllist_obj_get_int8 proc~sllist_obj_get_real_dp sllist_obj%sllist_obj_Get_real_dp none~get~3->proc~sllist_obj_get_real_dp proc~sllist_obj_get_real_sp sllist_obj%sllist_obj_Get_real_sp none~get~3->proc~sllist_obj_get_real_sp proc~sllist_obj_get_int4->proc~sllist_obj_get_int4 proc~sllist_obj_get_int8->proc~sllist_obj_get_int8 proc~sllist_obj_get_real_dp->proc~sllist_obj_get_real_dp proc~sllist_obj_get_real_sp->proc~sllist_obj_get_real_sp

Source Code

    impure subroutine particle_set_ReadH5HUT(this,iter,time,step)
      !> Reads particle data from file in parallel using H5HUT.
      implicit none
      class(particle_set), intent(inout) :: this                               !! Lagrangian array to dump
      integer,             intent(out)   :: iter                               !! Iteration at write
      real(wp),            intent(out)   :: time                               !! Time at write
      integer,             intent(in),    &
                                optional :: step                               !! User supplied step to open
      ! Work variables
      type(h5hut_obj)               :: h5                                      !! H5hut structure
      integer,          allocatable :: buffi(:)                                !! Integer buffer
      integer(leapI8),  allocatable :: buffi8(:)                               !! Integer (kind=8) buffer
      real(wp),         allocatable :: buffr(:)                                !! Real buffer
      integer,          allocatable :: size_per_rank(:)                        !! Number of particles per rank
      integer :: max_chunk                                                     !! Max number of chunks on any MPI rank
      integer :: chunk_size                                                    !! Number of particles in chunk
      integer :: goff                                                          !! Global offset
      integer :: loff                                                          !! Local offset
      integer :: n                                                             !! Iterator

      ! Open the file
      call h5%Initialize(trim(adjustl(this%read_file)),"R",this%parallel)

      if (.not.present(step)) then
        ! Jump to last step
        call h5%LastTimeStep(iter,time)
      else
        ! Jump to desired step
        call h5%JumpToStep(step,iter,time)
      end if

      ! Get total number of point objects
      call h5%GetNPoints(this%count)

      ! Distribute equally the data on each mpi rank
      associate(mpi=>this%parallel)
        allocate(size_per_rank(mpi%nproc))

        do n=1,mpi%nproc
          size_per_rank(n) = int(this%count/mpi%nproc)
          if (n.le.mod(this%count,mpi%nproc)) size_per_rank(n)=size_per_rank(n)+1
        end do
      end associate

      ! Allocate buffers
      call this%parallel%Max(ceiling(size_per_rank(this%parallel%rank%mine)/real(this%R_chunk_size,wp)),max_chunk)

      loff  = 0
      chunk_size = 0
      do n=1,max_chunk
        ! Local offset
        loff    = loff + chunk_size

        ! Determine next chunk size
        if (loff.lt.size_per_rank(this%parallel%rank%mine)) then
          chunk_size = min(size_per_rank(this%parallel%rank%mine) - loff,this%R_chunk_size)

          ! Resize the data array to contain read Lagrangian objects
          call this%Resize(this%count_+chunk_size)
        else
          chunk_size = 0
        end if

        ! Global offset
        goff = sum(size_per_rank(1:this%parallel%rank%mine-1)) + loff

        allocate(buffi8(chunk_size),buffi(chunk_size),buffr(chunk_size))

        ! Read the base Lagrangian object structure
        if (chunk_size.eq.0) then
          call h5%Read("id", buffi8,offset=goff)
          call h5%Read("x",  buffr, offset=goff)
          call h5%Read("y",  buffr, offset=goff)
          call h5%Read("z",  buffr, offset=goff)
          call h5%Read("i",  buffi, offset=goff)
          call h5%Read("j",  buffi, offset=goff)
          call h5%Read("k",  buffi, offset=goff)
          call h5%Read("vx", buffr, offset=goff)
          call h5%Read("vy", buffr, offset=goff)
          call h5%Read("vz", buffr, offset=goff)
          call h5%Read("wx", buffr, offset=goff)
          call h5%Read("wy", buffr, offset=goff)
          call h5%Read("wz", buffr, offset=goff)
          call h5%Read("d",  buffr, offset=goff)
          call h5%Read("s",  buffi, offset=goff)
          call h5%Read("rho",buffr, offset=goff)
          call h5%Read("Fhx",buffr, offset=goff)
          call h5%Read("Fhy",buffr, offset=goff)
          call h5%Read("Fhz",buffr, offset=goff)
          call h5%Read("Thx",buffr, offset=goff)
          call h5%Read("Thy",buffr, offset=goff)
          call h5%Read("Thz",buffr, offset=goff)
          call h5%Read("Fcx",buffr, offset=goff)
          call h5%Read("Fcy",buffr, offset=goff)
          call h5%Read("Fcz",buffr, offset=goff)
          call h5%Read("Tcx",buffr, offset=goff)
          call h5%Read("Tcy",buffr, offset=goff)
          call h5%Read("Tcz",buffr, offset=goff)
        else
          select type (particles=>this%p)
          type is (particle_obj)
            call h5%Read("id", buffi8,offset=goff); particles(this%count_-chunk_size+1:this%count_)%id   = buffi8
            call h5%Read("x",  buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%p(1) = buffr
            call h5%Read("y",  buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%p(2) = buffr
            call h5%Read("z",  buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%p(3) = buffr
            call h5%Read("i",  buffi, offset=goff); particles(this%count_-chunk_size+1:this%count_)%c(1) = buffi
            call h5%Read("j",  buffi, offset=goff); particles(this%count_-chunk_size+1:this%count_)%c(2) = buffi
            call h5%Read("k",  buffi, offset=goff); particles(this%count_-chunk_size+1:this%count_)%c(3) = buffi
            call h5%Read("vx", buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%v(1) = buffr
            call h5%Read("vy", buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%v(2) = buffr
            call h5%Read("vz", buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%v(3) = buffr
            call h5%Read("wx", buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%w(1) = buffr
            call h5%Read("wy", buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%w(2) = buffr
            call h5%Read("wz", buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%w(3) = buffr
            call h5%Read("d",  buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%d    = buffr
            call h5%Read("s",  buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%s    = buffi
            call h5%Read("rho",buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%rho  = buffr
            call h5%Read("Fhx",buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%Fh(1)= buffr
            call h5%Read("Fhy",buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%Fh(2)= buffr
            call h5%Read("Fhz",buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%Fh(3)= buffr
            call h5%Read("Thx",buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%Th(1)= buffr
            call h5%Read("Thy",buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%Th(2)= buffr
            call h5%Read("Thz",buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%Th(3)= buffr
            call h5%Read("Fcx",buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%Fc(1)= buffr
            call h5%Read("Fcy",buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%Fc(2)= buffr
            call h5%Read("Fcz",buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%Fc(3)= buffr
            call h5%Read("Tcx",buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%Tc(1)= buffr
            call h5%Read("Tcy",buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%Tc(2)= buffr
            call h5%Read("Tcz",buffr, offset=goff); particles(this%count_-chunk_size+1:this%count_)%Tc(3)= buffr
          end select
        end if

        ! Deallocate buffers
        deallocate(buffi8,buffi,buffr)

        ! Send particles to their mpiranks
        call this%Communicate()
      end do

      ! Free data
      deallocate(size_per_rank)
      call h5%Finalize

      ! Set unread variables to zero
      select type (particles=>this%p)
      class is (particle_obj)
        do n=1,this%count_
          particles(n)%pold  = 0.0_wp
          particles(n)%vold  = 0.0_wp
          particles(n)%wold  = 0.0_wp
          particles(n)%Fhold = 0.0_wp
          particles(n)%Thold = 0.0_wp
          particles(n)%Fcold = 0.0_wp
          particles(n)%Tcold = 0.0_wp
        end do
      end select

      ! Localize particles on the grid
      call this%Localize()

      return
    end subroutine particle_set_ReadH5HUT