Skip to content

Commit

Permalink
character versions of fill_vector
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwilliams committed Aug 6, 2022
1 parent f9aa38f commit f8de93d
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion src/vector_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ module vector_module
public :: angle_between_vectors

interface fill_vector
module procedure :: fill_vector_with_vector, fill_vector_with_scalar
module procedure :: fill_vector_with_vector, fill_vector_with_scalar, &
fill_char_vector_with_vector, fill_char_vector_with_scalar
end interface
public :: fill_vector

Expand Down Expand Up @@ -518,6 +519,46 @@ subroutine fill_vector_with_scalar(x, val, i)
end subroutine fill_vector_with_scalar
!*****************************************************************************************

!*****************************************************************************************
!>
! Put the vector in the vector and update the index (character version)

subroutine fill_char_vector_with_vector(x, vals, i)

implicit none

character(len=*),dimension(:),intent(inout) :: x
character(len=*),dimension(:),intent(in) :: vals
integer,intent(inout) :: i !! should be initialized to 0 before the first call

integer :: j !! counter

do j = 1, size(vals)
call fill_vector(x,vals(j),i)
end do

end subroutine fill_char_vector_with_vector
!*****************************************************************************************

!*****************************************************************************************
!>
! Put the value in the vector and update the index (character version)

subroutine fill_char_vector_with_scalar(x, val, i)

implicit none

character(len=*),dimension(:),intent(inout) :: x
character(len=*),intent(in) :: val
integer,intent(inout) :: i !! should be initialized to 0 before the first call

i = i + 1
if (i>size(x)) error stop 'error in fill_vector: x is not large enough.'
x(i) = val

end subroutine fill_char_vector_with_scalar
!*****************************************************************************************

!*****************************************************************************************
!>
! Extract a vector from the vector and update the index
Expand Down

0 comments on commit f8de93d

Please sign in to comment.