array_new_i1d Subroutine

private subroutine array_new_i1d(array, DATA, gift)

Arguments

Type IntentOptional Attributes Name
type(array_i1d_obj), intent(out) :: array
integer, DIMENSION(:), POINTER, CONTIGUOUS :: DATA
logical, intent(in), optional :: gift

Source Code

   SUBROUTINE array_new_i1d(array, DATA, gift)
      TYPE(array_i1d_obj), INTENT(OUT)                   :: array
      INTEGER, DIMENSION(:), POINTER, CONTIGUOUS         :: DATA
      LOGICAL, INTENT(IN), OPTIONAL                      :: gift

      INTEGER                                            :: lb, ub
      LOGICAL                                            :: g

      ALLOCATE (array%low)
      array%low%refcount = 1
      g = .FALSE.
      IF (PRESENT(gift)) g = gift
      IF (g) THEN
         array%low%data => DATA
         NULLIFY (DATA)
      ELSE
         lb = LBOUND(DATA, 1)
         ub = UBOUND(DATA, 1)
         ALLOCATE (array%low%data(lb:ub))
         array%low%data(:) = DATA(:)
      END IF
   END SUBROUTINE array_new_i1d