get_arrays Subroutine

public subroutine get_arrays(list, data_1, data_2, data_3, data_4, i_selected)

Get all arrays contained in list

Arguments

Type IntentOptional Attributes Name
type(array_list), intent(in) :: list
integer, intent(out), optional, ALLOCATABLE, DIMENSION(:) :: data_1

arrays 1 and 2

integer, intent(out), optional, ALLOCATABLE, DIMENSION(:) :: data_2

arrays 1 and 2

integer, intent(out), optional, ALLOCATABLE, DIMENSION(:) :: data_3

arrays 1 and 2

integer, intent(out), optional, ALLOCATABLE, DIMENSION(:) :: data_4

arrays 1 and 2

integer, intent(in), optional, DIMENSION(:) :: i_selected

array numbers to retrieve (if not present, all arrays are returned)


Source Code

   SUBROUTINE get_arrays(list, data_1, data_2, data_3, data_4, i_selected)
      !! Get all arrays contained in list
      TYPE(array_list), INTENT(IN)                       :: list
      INTEGER, ALLOCATABLE, DIMENSION(:), INTENT(OUT), &
         OPTIONAL                                        :: data_1, data_2, data_3, data_4
         !! arrays 1 and 2
      INTEGER, DIMENSION(:), INTENT(IN), &
         OPTIONAL                                        :: i_selected
         !! array numbers to retrieve (if not present, all arrays are returned)
      INTEGER                                            :: i, ndata
      INTEGER, DIMENSION(number_of_arrays(list))         :: o

      o(:) = 0
      IF (PRESENT(i_selected)) THEN
         ndata = SIZE(i_selected)
         o(1:ndata) = i_selected(:)
      ELSE
         ndata = number_of_arrays(list)
         o(1:ndata) = (/(i, i=1, ndata)/)
      END IF

      ASSOCIATE (ptr => list%ptr, col_data => list%col_data)
# 174 "/__w/dbcsr/dbcsr/src/tensors/dbcsr_array_list_methods.F"
            IF (ndata > 0) THEN
               CALL allocate_any(data_1, source=col_data(ptr(o(1)):ptr(o(1) + 1) - 1))
            END IF
# 174 "/__w/dbcsr/dbcsr/src/tensors/dbcsr_array_list_methods.F"
            IF (ndata > 1) THEN
               CALL allocate_any(data_2, source=col_data(ptr(o(2)):ptr(o(2) + 1) - 1))
            END IF
# 174 "/__w/dbcsr/dbcsr/src/tensors/dbcsr_array_list_methods.F"
            IF (ndata > 2) THEN
               CALL allocate_any(data_3, source=col_data(ptr(o(3)):ptr(o(3) + 1) - 1))
            END IF
# 174 "/__w/dbcsr/dbcsr/src/tensors/dbcsr_array_list_methods.F"
            IF (ndata > 3) THEN
               CALL allocate_any(data_4, source=col_data(ptr(o(4)):ptr(o(4) + 1) - 1))
            END IF
# 178 "/__w/dbcsr/dbcsr/src/tensors/dbcsr_array_list_methods.F"
      END ASSOCIATE

   END SUBROUTINE get_arrays