eulerian_set_WriteHDF5 Subroutine

private impure subroutine eulerian_set_WriteHDF5(this, iter, time, list)

Uses

  • proc~~eulerian_set_writehdf5~~UsesGraph proc~eulerian_set_writehdf5 eulerian_set%eulerian_set_WriteHDF5 module~leaputils leapUtils proc~eulerian_set_writehdf5->module~leaputils module~leapkinds leapKinds module~leaputils->module~leapkinds iso_fortran_env iso_fortran_env module~leapkinds->iso_fortran_env

Writes Eulerian data using LEAP's HDF5.

Type Bound

eulerian_set

Arguments

Type IntentOptional 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


Calls

proc~~eulerian_set_writehdf5~~CallsGraph proc~eulerian_set_writehdf5 eulerian_set%eulerian_set_WriteHDF5 none~writeattributes hdf5_obj%WriteAttributes proc~eulerian_set_writehdf5->none~writeattributes none~writesingle eulerian_set%WriteSingle proc~eulerian_set_writehdf5->none~writesingle proc~eulerian_set_getindex eulerian_set%eulerian_set_GetIndex proc~eulerian_set_writehdf5->proc~eulerian_set_getindex proc~hdf5_obj_final hdf5_obj%hdf5_obj_Final proc~eulerian_set_writehdf5->proc~hdf5_obj_final proc~hdf5_obj_init hdf5_obj%hdf5_obj_Init proc~eulerian_set_writehdf5->proc~hdf5_obj_init proc~parallel_obj_rankisroot parallel_obj%parallel_obj_RankIsRoot proc~eulerian_set_writehdf5->proc~parallel_obj_rankisroot proc~stringtool_obj_formattime stringtool_obj%stringtool_obj_FormatTime proc~eulerian_set_writehdf5->proc~stringtool_obj_formattime proc~stringtool_obj_removeextension stringtool_obj%stringtool_obj_RemoveExtension proc~eulerian_set_writehdf5->proc~stringtool_obj_removeextension proc~stringtool_obj_removepath stringtool_obj%stringtool_obj_RemovePath proc~eulerian_set_writehdf5->proc~stringtool_obj_removepath proc~sysutils_obj_createdirectory sysutils_obj%sysutils_obj_CreateDirectory proc~eulerian_set_writehdf5->proc~sysutils_obj_createdirectory proc~xdmf_obj_addfield xdmf_obj%xdmf_obj_AddField proc~eulerian_set_writehdf5->proc~xdmf_obj_addfield proc~xdmf_obj_addgrid xdmf_obj%xdmf_obj_AddGrid proc~eulerian_set_writehdf5->proc~xdmf_obj_addgrid proc~hdf5_obj_writeattributes0d hdf5_obj%hdf5_obj_WriteAttributes0D none~writeattributes->proc~hdf5_obj_writeattributes0d proc~hdf5_obj_writeattributes1d hdf5_obj%hdf5_obj_WriteAttributes1D none~writeattributes->proc~hdf5_obj_writeattributes1d proc~eulerian_set_writesingleh5hut eulerian_set%eulerian_set_WriteSingleH5HUT none~writesingle->proc~eulerian_set_writesingleh5hut proc~eulerian_set_writesinglehdf5 eulerian_set%eulerian_set_WriteSingleHDF5 none~writesingle->proc~eulerian_set_writesinglehdf5 proc~eulerian_set_writesinglesilo eulerian_set%eulerian_set_WriteSingleSILO none~writesingle->proc~eulerian_set_writesinglesilo none~get~4 hashtbl_obj%Get proc~eulerian_set_getindex->none~get~4 proc~hashtbl_obj_hashstring hashtbl_obj%hashtbl_obj_HashString proc~eulerian_set_getindex->proc~hashtbl_obj_hashstring 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 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 proc~xdmf_obj_resize xdmf_obj%xdmf_obj_Resize proc~xdmf_obj_addfield->proc~xdmf_obj_resize 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 cell cell proc~eulerian_set_writesingleh5hut->cell proc~h5hut_obj_writegrid h5hut_obj%h5hut_obj_WriteGrid proc~eulerian_set_writesingleh5hut->proc~h5hut_obj_writegrid proc~eulerian_set_writesinglehdf5->cell proc~eulerian_set_writesinglesilo->cell h5aclose_f h5aclose_f proc~hdf5_obj_writeattributes0d->h5aclose_f h5acreate_f h5acreate_f proc~hdf5_obj_writeattributes0d->h5acreate_f h5awrite_f h5awrite_f proc~hdf5_obj_writeattributes0d->h5awrite_f h5sclose_f h5sclose_f proc~hdf5_obj_writeattributes0d->h5sclose_f h5screate_simple_f h5screate_simple_f proc~hdf5_obj_writeattributes0d->h5screate_simple_f proc~hdf5_obj_closegroup hdf5_obj%hdf5_obj_CloseGroup proc~hdf5_obj_writeattributes0d->proc~hdf5_obj_closegroup proc~hdf5_obj_getgroupobject hdf5_obj%hdf5_obj_GetGroupObject proc~hdf5_obj_writeattributes0d->proc~hdf5_obj_getgroupobject proc~hdf5_obj_opengroup hdf5_obj%hdf5_obj_OpenGroup proc~hdf5_obj_writeattributes0d->proc~hdf5_obj_opengroup proc~hdf5_obj_writeattributes1d->h5aclose_f proc~hdf5_obj_writeattributes1d->h5acreate_f proc~hdf5_obj_writeattributes1d->h5awrite_f proc~hdf5_obj_writeattributes1d->h5sclose_f proc~hdf5_obj_writeattributes1d->h5screate_simple_f proc~hdf5_obj_writeattributes1d->proc~hdf5_obj_closegroup proc~hdf5_obj_writeattributes1d->proc~hdf5_obj_getgroupobject proc~hdf5_obj_writeattributes1d->proc~hdf5_obj_opengroup proc~h5hut_obj_writegrid->none~writeattributes proc~hdf5_obj_creategroup hdf5_obj%hdf5_obj_CreateGroup proc~h5hut_obj_writegrid->proc~hdf5_obj_creategroup 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~hdf5_obj_closegroup->proc~hashtbl_obj_hashstring proc~hdf5_obj_closegroup->proc~hdf5_obj_getgroupobject h5gclose_f h5gclose_f proc~hdf5_obj_closegroup->h5gclose_f proc~hashtbl_obj_remove hashtbl_obj%hashtbl_obj_Remove proc~hdf5_obj_closegroup->proc~hashtbl_obj_remove proc~hdf5_obj_fixgroupname hdf5_obj%hdf5_obj_FixGroupName proc~hdf5_obj_closegroup->proc~hdf5_obj_fixgroupname proc~hdf5_obj_getgroupobject->none~get~4 proc~hdf5_obj_getgroupobject->proc~hashtbl_obj_hashstring proc~hdf5_obj_getgroupobject->proc~hdf5_obj_fixgroupname proc~hdf5_obj_opengroup->proc~hashtbl_obj_hashstring proc~hdf5_obj_opengroup->proc~hdf5_obj_getgroupobject h5oopen_f h5oopen_f proc~hdf5_obj_opengroup->h5oopen_f proc~hashtbl_obj_put hashtbl_obj%hashtbl_obj_Put proc~hdf5_obj_opengroup->proc~hashtbl_obj_put proc~hdf5_obj_opengroup->proc~hdf5_obj_fixgroupname 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_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 proc~hdf5_obj_creategroup->proc~hashtbl_obj_hashstring proc~hdf5_obj_creategroup->proc~hdf5_obj_closegroup proc~hdf5_obj_creategroup->proc~hashtbl_obj_put proc~hdf5_obj_creategroup->proc~hdf5_obj_fixgroupname h5gcreate_f h5gcreate_f proc~hdf5_obj_creategroup->h5gcreate_f 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 proc~sllist_obj_put->proc~sllist_obj_put

Source Code

    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