isave_1d_array_to_hdf5 Subroutine

private subroutine isave_1d_array_to_hdf5(h5file_id, dset, idata, attr)

Arguments

Type IntentOptional AttributesName
integer(kind=HID_T), intent(in) :: h5file_id
character(len=MAX_STRING_LENGTH), intent(in) :: dset
integer, intent(in), DIMENSION(:):: idata
character(len=MAX_STRING_LENGTH), intent(in), optional DIMENSION(:), ALLOCATABLE:: attr

Calls

proc~~isave_1d_array_to_hdf5~~CallsGraph proc~isave_1d_array_to_hdf5 isave_1d_array_to_hdf5 h5tset_size_f h5tset_size_f proc~isave_1d_array_to_hdf5->h5tset_size_f h5dclose_f h5dclose_f proc~isave_1d_array_to_hdf5->h5dclose_f h5aclose_f h5aclose_f proc~isave_1d_array_to_hdf5->h5aclose_f h5tcopy_f h5tcopy_f proc~isave_1d_array_to_hdf5->h5tcopy_f h5screate_simple_f h5screate_simple_f proc~isave_1d_array_to_hdf5->h5screate_simple_f h5awrite_f h5awrite_f proc~isave_1d_array_to_hdf5->h5awrite_f h5dwrite_f h5dwrite_f proc~isave_1d_array_to_hdf5->h5dwrite_f h5sclose_f h5sclose_f proc~isave_1d_array_to_hdf5->h5sclose_f h5acreate_f h5acreate_f proc~isave_1d_array_to_hdf5->h5acreate_f

Called by

proc~~isave_1d_array_to_hdf5~~CalledByGraph proc~isave_1d_array_to_hdf5 isave_1d_array_to_hdf5 interface~save_array_to_hdf5 save_array_to_hdf5 interface~save_array_to_hdf5->proc~isave_1d_array_to_hdf5 interface~save_1d_array_to_hdf5 save_1d_array_to_hdf5 interface~save_1d_array_to_hdf5->proc~isave_1d_array_to_hdf5 proc~save_simulation_outputs save_simulation_outputs proc~save_simulation_outputs->interface~save_1d_array_to_hdf5 proc~save_params_ms save_params_ms proc~save_params_ms->interface~save_1d_array_to_hdf5 proc~save_simulation_parameters save_simulation_parameters proc~save_simulation_parameters->interface~save_1d_array_to_hdf5 proc~save_restart_variables save_restart_variables proc~save_restart_variables->interface~save_1d_array_to_hdf5 program~main main program~main->proc~save_simulation_outputs program~main->proc~save_simulation_parameters program~main->proc~save_restart_variables proc~save_collision_params save_collision_params program~main->proc~save_collision_params proc~save_collision_params->proc~save_params_ms

Contents


Source Code

  subroutine isave_1d_array_to_hdf5(h5file_id,dset,idata,attr)
    INTEGER(HID_T), INTENT(IN) 														:: h5file_id
    CHARACTER(MAX_STRING_LENGTH), INTENT(IN) 										:: dset
    INTEGER, DIMENSION(:), INTENT(IN) 												:: idata
    CHARACTER(MAX_STRING_LENGTH), OPTIONAL, DIMENSION(:), ALLOCATABLE, INTENT(IN) 	:: attr
    CHARACTER(4) 																	:: aname = "Info"
    INTEGER(HID_T) 																	:: dset_id
    INTEGER(HID_T) 																	:: dspace_id
    INTEGER(HID_T) 																	:: aspace_id
    INTEGER(HID_T) 																	:: attr_id
    INTEGER(HID_T) 																	:: atype_id
    INTEGER(HSIZE_T), DIMENSION(:), ALLOCATABLE 									:: dims
    INTEGER(HSIZE_T), DIMENSION(:), ALLOCATABLE 									:: adims
    INTEGER 																		:: rank
    INTEGER 																		:: arank
    INTEGER(SIZE_T) 																:: attrlen
    INTEGER(SIZE_T) 																:: tmplen
    INTEGER 																		:: h5error
    INTEGER 																		:: rr,dd

    rank = size(shape(idata))
    ALLOCATE(dims(rank))
    dims = shape(idata)

    ! * * * Write data to file * * *
    call h5screate_simple_f(rank,dims,dspace_id,h5error)
    call h5dcreate_f(h5file_id, TRIM(dset), H5T_NATIVE_INTEGER, dspace_id, dset_id, h5error)
    call h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, idata, dims, h5error)

    if (PRESENT(attr)) then
       arank = size(shape(attr))
       ALLOCATE(adims(arank))
       adims = shape(attr)

       ! * * * Write attribute of data to file * * *
       tmplen = 0
       attrlen = 0
       do rr=1_idef,arank
          do dd=1_idef,adims(rr)
             tmplen = LEN_TRIM(attr(dd))
             if ( tmplen .GT. attrlen) then
                attrlen = tmplen
             end if
          end do
       end do

       call h5screate_simple_f(arank,adims,aspace_id,h5error)
       call h5tcopy_f(H5T_NATIVE_CHARACTER, atype_id, h5error)
       call h5tset_size_f(atype_id, attrlen, h5error)
       call h5acreate_f(dset_id, aname, atype_id, aspace_id, attr_id, h5error)
       call h5awrite_f(attr_id, atype_id, attr, adims, h5error)

       call h5aclose_f(attr_id, h5error)
       call h5sclose_f(aspace_id, h5error)
       ! * * * Write attribute of data to file * * *

       DEALLOCATE(adims)
    end if

    call h5sclose_f(dspace_id, h5error)
    call h5dclose_f(dset_id, h5error)
    ! * * * Write data to file * * *

    DEALLOCATE(dims)
  end subroutine isave_1d_array_to_hdf5