add an entry to the maps collection
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(maps_type), | intent(inout) | :: | this | |||
integer, | intent(in) | :: | original_atom_id | id of an atom within its original code |
||
integer, | intent(in) | :: | target_code_id | id of the code which is going to treat this atom |
||
integer, | intent(in) | :: | target_atom_id | id of an atom within the target code |
subroutine add_maps_entry(this, original_atom_id, target_code_id, target_atom_id)
class(maps_type), intent(inout) :: this
!> id of the code which is going to treat this atom
integer, intent(in) :: target_code_id
!> id of an atom within the target code
integer, intent(in) :: target_atom_id
!> id of an atom within its original code
integer, intent(in) :: original_atom_id
type(map_type), dimension(:), allocatable :: temp_maps
integer :: num_map
if (.not. (allocated(this%maps))) then
allocate(this%maps(1))
this%maps(1)%id = original_atom_id
call this%maps(1)%add_entry(target_code_id, target_atom_id)
return
end if
do num_map = 1, size(this%maps)
if (this%maps(num_map)%id == original_atom_id) then
call this%maps(num_map)%add_entry(target_code_id, target_atom_id)
return
end if
end do
call move_alloc(this%maps, temp_maps)
allocate(this%maps(size(temp_maps) + 1))
this%maps(1:size(temp_maps)) = temp_maps
do num_map = 1, size(temp_maps)
this%maps(num_map) = temp_maps(num_map)
end do
this%maps(size(this%maps))%id = original_atom_id
call this%maps(size(this%maps))%add_entry(target_code_id, target_atom_id)
end subroutine add_maps_entry