Commit d1f84617 authored by Roy Fabrice's avatar Roy Fabrice
Browse files

add read and write

parent 0f862c83
......@@ -66,7 +66,9 @@ module halos_array_m
procedure, private :: Build_halo_file_list_and_ids
procedure, private :: Build_halo_ids_from_file_names
procedure :: Init => Init_halos_array
procedure :: Read => Read_halos_array
procedure, private :: Share => Share_halos_array
procedure :: Write => Write_halos_array
end type halos_array_t
contains
......@@ -362,6 +364,54 @@ contains
end subroutine Init_halos_array
!------------------------------------------------------------------------------------------------------------------------------------
subroutine Read_halos_array(this)
use fortran_hdf5_constants_m
use fortran_hdf5_manage_files_m
use fortran_hdf5_manage_groups_m
use hdf5
class(halos_array_t), intent(inout) :: this
integer :: current_file
integer(HID_T) :: group_id
character(H5_STR_LEN) :: group_name
integer :: ihalo
integer(HID_T) :: input_file_id
character(H5_FILENAME_LEN) :: input_file_name
#ifdef DEBUG
write(ERROR_UNIT,'(a,i0)') 'Read_halos_array begins on process', mpi_process%rank
#endif
current_file = this%parameters%halo_file_ids(this%first_halo_index)
input_file_name = trim(this%parameters%halos_data_directory)//trim(this%parameters%halos_file_names(current_file))
call hdf5_open_file(input_file_name, input_file_id)
group_name = 'data'
call hdf5_open_group(input_file_id, group_name, group_id)
! loop over halos to compute centers and radius
do ihalo = this%first_halo_index, this%last_halo_index
if (this%parameters%halo_file_ids(ihalo) /= current_file) then
call hdf5_close_group(group_id)
call hdf5_close_file(input_file_id)
current_file = this%parameters%halo_file_ids(ihalo)
input_file_name = trim(this%parameters%halos_data_directory)//trim(this%parameters%halos_file_names(current_file))
call hdf5_open_file(input_file_name, input_file_id)
group_name = 'data'
call hdf5_open_group(input_file_id, group_name, group_id)
end if
! read halo
call this%halos(ihalo)%Read_hdf5(group_id, this%properties)
end do
#ifdef DEBUG
write(ERROR_UNIT,'(a,i0)') 'Read_halos_array ends on process', mpi_process%rank
#endif
end subroutine Read_halos_array
!------------------------------------------------------------------------------------------------------------------------------------
subroutine Share_halos_array(this)
......@@ -396,4 +446,20 @@ contains
end subroutine Share_halos_array
!------------------------------------------------------------------------------------------------------------------------------------
subroutine Write_halos_array(this)
class(halos_array_t), intent(inout) :: this
#ifdef DEBUG
write(ERROR_UNIT,'(a,i0)') 'Write_halos_array begins on process', mpi_process%rank
#endif
#ifdef DEBUG
write(ERROR_UNIT,'(a,i0)') 'Write_halos_array ends on process', mpi_process%rank
#endif
end subroutine Write_halos_array
end module halos_array_m
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment