send coordinates of atoms to client codes (sends a flattened array)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mimic_communicator), | intent(inout) | :: | this | |||
type(subsystem_type), | intent(in), | dimension(:) | :: | subsystems | subsystem_type belonging to each code |
subroutine send_coords(this, subsystems)
class(mimic_communicator), intent(inout) :: this
!> subsystem_type belonging to each code
type(subsystem_type), dimension(:), intent(in) :: subsystems
real(kind=dp), dimension(:), allocatable, target :: coordinates
integer :: code_atoms
integer :: n_code, n_atom
integer :: offset
do n_code = 1, this%num_clients
code_atoms = subsystems(n_code)%num_atoms
allocate(coordinates(code_atoms * 3))
!$OMP PARALLEL DO PRIVATE(n_atom, offset)
do n_atom = 1, size(subsystems(n_code)%atoms)
offset = (subsystems(n_code)%atoms(n_atom)%id - 1) * 3 + 1
coordinates(offset : offset + 2) = subsystems(n_code)%atoms(n_atom)%coordinate
! offset = offset + 3
end do ! n_atom
!$OMP END PARALLEL DO
call this%send_command(MCL_RECV_ATOM_COORDS, n_code)
call mcl_send(coordinates, code_atoms * 3, MCL_DATA, n_code)
deallocate(coordinates)
end do ! n_code
end subroutine send_coords