anchor.diff:                                 dref_pop = 'reference population @ t-1', &
                                  dhsref = 'Hilbert space reference determinant'
   
  +    ! HDF5 kinds equivalent to the kinds defined in const.  Set in init_restart_hdf5.
  +    type h5_kinds_t
  +        integer(hid_t) :: i0
  +        integer(hid_t) :: lint
  +        integer(hid_t) :: p
  +    end type h5_kinds_t
  +
       contains
  +
  +        subroutine init_restart_hdf5(ri, write_mode, filename, kinds)
  +
  +            ! Initialise restart functionality:
  +
  +            ! * print information line;
  +            ! * create restart filename;
  +            ! * create HDF5 types.
  +
  +            ! NOTE: HDF5 library must be opened (h5open_f) before init_restart_hdf5 is
  +            ! called and not closed between calling init_restart_hdf5 and operating on
  +            ! the restart file to ensure the HDF5 types match those calculated here.
  +
  +            ! In:
  +            !    ri: restart information. ri%restart_stem and ri%write_id/ri%read_id (as
  +            !        appropriate) are used.
  +            !    write_mode: true for writing out a restart file, false for reading one in.
  +            ! Out:
  +            !    filename: name of the restart file.
  +            !    kinds: derived type containing HDF5 types which correspond to the
  +            !        non-standard integer and real kinds used in HANDE.
  +
  +            use hdf5, only: H5_INTEGER_KIND, H5_REAL_KIND, h5kind_to_type
  +
  +            use const, only: i0, lint, p
  +            use parallel, only: nprocs, iproc, parent
  +            use utils, only: int_fmt, get_unique_filename
  +
  +            type(restart_info_t), intent(in) :: ri
  +            logical, intent(in) :: write_mode
  +            character(*), intent(out) :: filename
  +            type(h5_kinds_t), intent(out) :: kinds
  +
  +            character(10) :: proc_suf
  +            integer :: id, ierr
  +
  +            if (write_mode) then
  +                id = ri%write_id
  +            else
  +                id = ri%read_id
  +            end if
  +
  +! [review] -  AJWT: A comment as to the format of the filename would be helpful.  I'd've written one, but I couldn't immediately figure it out
  +! [review] -  AJWT: Having looked back I saw:   the format is restart_stem.Y.pX, where X is the processor rank and Y is a common integer given by write_id or read_id.
  +! [reply] - JSS: see above also.
  +            ! Figure out filename: restart_stem.Y.pX, where Y is related to id and X is the processor rank.
  +            write (proc_suf,'(".p",'//int_fmt(iproc,0)//')') iproc
  +            if (id < 0) then
  +                call get_unique_filename(trim(ri%restart_stem), trim(proc_suf), write_mode, id, filename)
  +            else
  +                call get_unique_filename(trim(ri%restart_stem), trim(proc_suf), write_mode, 0, filename)
  +            end if
  +
  +            if (parent) then
  +                if (write_mode) then
  +                    write (6,'(1X,"#",1X,"Writing restart file to",1X,a)', advance='no') trim(filename)
  +                else
  +                    write (6,'(1X,"Reading restart file from",1X,a)', advance='no') trim(filename)
  +                end if
  +                if (nprocs > 1) then
  +                    write (6,'(1X, "family.")')
  +                else
  +                    write (6,'(1X, ".")')
  +                end if
  +            end if
  +
  +! [review] -  AJWT: I don't immediately see what these are used for.
  +! [review] -  AJWT: These kinds are used in the write_* functions.
  +! [reply] - JSS:
  +            ! Convert our non-standard kinds to something HDF5 understands.
  +            kinds%i0 = h5kind_to_type(i0, H5_INTEGER_KIND)
  +            kinds%p = h5kind_to_type(p, H5_REAL_KIND)
  +            kinds%lint = h5kind_to_type(lint, H5_INTEGER_KIND)
  +
  +        end subroutine init_restart_hdf5
   
           subroutine dump_restart_hdf5(ri, ncycles, total_population)
   
  
positive.code:             integer :: i0_length_restart
              type(c_ptr) :: ptr
              integer :: ierr
              character(10) :: proc_suf
              real(p), target :: tmp(1)
  
              integer(HSIZE_T) :: dims(size(shape(walker_dets))), maxdims(size(shape(walker_dets)))
  
  ! [review] -  AJWT: This seems like needless duplication of what happens in dump_restart_hdf5 which could be put in a procedure
              ! Figure out filename.
              write (proc_suf,'(".p",'//int_fmt(iproc,0)//')') iproc
              if (ri%read_id < 0) then
                  call get_unique_filename(trim(ri%restart_stem), trim(proc_suf), .false., ri%read_id, restart_file)
              else
                  call get_unique_filename(trim(ri%restart_stem), trim(proc_suf), .false., 0, restart_file)
              end if
  
              if (parent) then
                  if (nprocs > 1) then
                      write (6,'(1X,"Reading restart file from the",1X,a,1X,"family."/)') trim(restart_file)
                  else
                      write (6,'(1X,"Reading restart file from",1X,a,/)') trim(restart_file)//'.'
                  end if
              end if
  
              ! Initialise HDF5 and open file.
              call h5open_f(ierr)
              call h5fopen_f(restart_file, H5F_ACC_RDONLY_F, file_id, ierr)
  
              ! i0 kind?  What a nice interface!
              h5_i0 = h5kind_to_type(i0, H5_INTEGER_KIND)
              h5_p = h5kind_to_type(p, H5_REAL_KIND)
              h5_lint = h5kind_to_type(lint, H5_INTEGER_KIND)
  
  ! [review] -  AJWT: Here endeth the duplication
              ! --- metadata group ---
  
negative.code: 
                  dshape2(1) = size(walker_data, dim=1, kind=HSIZE_T)
                  ptr = c_loc(walker_data)
                  call write_ptr(subgroup_id, ddata, kinds%p, size(shape(walker_data)), dshape2, ptr)
  
                  ! Can't use c_loc on a assumed shape array.  It's small, so just
                  ! copy it.
                  allocate(tmp_pop(size(total_population)))
                  tmp_pop = total_population
                  ptr = c_loc(tmp_pop)
                  call write_ptr(subgroup_id, dtot_pop, kinds%lint, size(shape(tmp_pop)), shape(tmp_pop, HSIZE_T), ptr)
  
                  call h5gclose_f(subgroup_id, ierr)
  
  