resize_sign Subroutine

private subroutine resize_sign(out_sgn, in_sgn)

Arguments

Type IntentOptional Attributes Name
integer(kind=hsize_t), intent(out) :: out_sgn(:)
integer(kind=hsize_t), intent(in) :: in_sgn(:)

Contents

Source Code


Source Code

    subroutine resize_sign(out_sgn, in_sgn)
        ! Copy data between two arrays of different size
        ! Input: in_sgn - array to copy from
        !        out_sgn - on return, contains the data from in_sgn
        !                  if out_sgn is larger than in_sgn, the last entry is
        !                  multiplied, if it is smaller, the last entries are left out
        implicit none

        integer(hsize_t), intent(out) :: out_sgn(:)
        integer(hsize_t), intent(in) :: in_sgn(:)

        integer :: out_size, in_size

        out_size = size(out_sgn)
        in_size = size(in_sgn)

        if (out_size < in_size) then
            ! remove the last entries from the input
            out_sgn(1:out_size) = in_sgn(1:out_size)
        else
            ! copy the last replicas to fill up to the desired number
            out_sgn(1:in_size) = in_sgn(1:in_size)
            out_sgn(in_size + 1:out_size) = in_sgn(in_size)
        end if
    end subroutine resize_sign