Я создал подпрограмму write_3dreal, которая записывает данные, распределенные в 3D, коллективно.
subroutine write_3dreal(file,data,dimsf,dname)
implicit none
integer, parameter :: ndims=3
integer, parameter :: halo = 2
double precision, intent(in) :: data(:,:,:)
character(*), intent(in) :: dname
type(datafile), intent(in) :: file
integer(HSIZE_T), dimension(ndims), intent(in) :: dimsf
integer(kind=hid_t) :: x_id, d_id, group_id
integer(kind=hid_t) :: memspace, filespace
! Local hyper slab info
integer(kind=hsize_t) :: d_size(ndims), s_size(ndims), h_size(ndims), &
stride(ndims), block(ndims)
! Global hyper slab info
integer(kind=hsize_t) :: g_size(ndims), g_start(ndims)
integer :: s,e,siz
group_id = file%current_group
if (bottom) then
s = sz-1
if(ez==nz) then
e = ez+1
siz = e-s+1
d_size(3) = siz +2*halo -2
else
e = ez
siz = e-s+1
d_size(3) = siz +2*halo -1
end if
h_size(3) = halo-1
!print*,'Entered Bottom'
!print*,myid,s,e,siz,h_size(3),d_size(3),s_size(3),g_start(3),'Bottom'
end if
if (top) then
e = ez+1
if(sz==1) then
s = sz-1
siz = e-s+1
h_size(3) = halo-1
d_size(3) = siz + 2*halo -2
else
s = sz
siz = e-s+1
h_size(3) = halo
d_size(3) = siz + 2*halo -1
end if
!print*,'Entered Top'
!print*,myid,s,e,siz,h_size(3),d_size(3),s_size(3),g_start(3),'Top'
end if
if (.not.(bottom .or. top)) then
s = sz
e = ez
siz=e-s+1
h_size(3) = halo
d_size(3) = siz +2*halo
!print*,'Entered Middle'
!print*,myid,s,e,siz,h_size(3),d_size(3),s_size(3),g_start(3),'Middle'
end if
! Create the local memory space and hyperslab
d_size(1) = ex-sx+1+2*halo
d_size(2) = ey-sy+1+2*halo
s_size(1) = d_size(1)-2*halo
s_size(2) = d_size(2)-2*halo
s_size(3) = siz
h_size(1) = halo
h_size(2) = halo
stride(1) = 1
stride(2) = 1
stride(3) = 1
block(1) = 1
block(2) = 1
block(3) = 1
call h5screate_simple_f(ndims, d_size, memspace, ierr)
call h5sselect_hyperslab_f(memspace, H5S_SELECT_SET_F, &
h_size, s_size, ierr, &
stride, block)
! Create the global file space and hyperslab
g_size(1) = nx
g_size(2) = ny
g_size(3) = nz+2
g_start(1) = s_size(1)*coords(1)
g_start(2) = s_size(2)*coords(2)
g_start(3) = s
call h5screate_simple_f(ndims, g_size, filespace, ierr)
call h5sselect_hyperslab_f(filespace, H5S_SELECT_SET_F, &
g_start, s_size, ierr, &
stride, block)
call h5dcreate_f(group_id, dname, H5T_IEEE_F64LE, filespace, d_id, &
ierr)
! Create a data transfer property
call h5pcreate_f(H5P_DATASET_XFER_F, x_id, ierr)
call h5pset_dxpl_mpio_f(x_id, H5FD_MPIO_COLLECTIVE_F, ierr)
! Write the data
call h5dwrite_f(d_id, H5T_IEEE_F64LE, data, s_size, ierr, &
file_space_id=filespace, mem_space_id=memspace, &
xfer_prp=x_id)
! Close everything and exit
call h5dclose_f(d_id, ierr)
call h5sclose_f(filespace, ierr)
call h5sclose_f(memspace, ierr)
call h5pclose_f(x_id, ierr)
end subroutine write_3dreal
Теперь я хочу создать еще одну подпрограмму, которая может читать данные коллективно всеми процессами. По сути, я хочу использовать определенный файл для перезапуска симуляции.
Я застрял в том, как прочитать этот файл в определенном макете памяти.