Allocates pointers in the data type
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dbcsr_data_area_type), | intent(inout) | :: | area |
internal structure holding array pointers |
||
integer, | intent(in), | DIMENSION(:), CONTIGUOUS | :: | sizes |
sizes to allocate to |
SUBROUTINE internal_data_allocate(area, sizes)
!! Allocates pointers in the data type
TYPE(dbcsr_data_area_type), INTENT(INOUT) :: area
!! internal structure holding array pointers
INTEGER, DIMENSION(:), INTENT(IN), CONTIGUOUS :: sizes
!! sizes to allocate to
CHARACTER(len=*), PARAMETER :: routineN = 'internal_data_allocate'
INTEGER :: error_handle
! ---------------------------------------------------------------------------
IF (careful_mod) &
CALL timeset(routineN, error_handle)
IF (debug_mod) &
WRITE (*, *) routineN//" Setting to sizes", sizes
IF (dbcsr_type_is_2d(area%data_type)) THEN
IF (SIZE(sizes) /= 2) &
DBCSR_ABORT("Sizes must have 2 elements for 2-D data")
ELSE
IF (SIZE(sizes) /= 1) &
DBCSR_ABORT("Sizes must have 1 elements for 1-D data")
END IF
SELECT CASE (area%data_type)
CASE (dbcsr_type_int_4)
CALL memory_allocate(area%i4, n=sizes(1), mem_type=area%memory_type)
CASE (dbcsr_type_int_8)
CALL memory_allocate(area%i8, n=sizes(1), mem_type=area%memory_type)
CASE (dbcsr_type_real_4)
CALL memory_allocate(area%r_sp, n=sizes(1), mem_type=area%memory_type)
CASE (dbcsr_type_real_8)
CALL memory_allocate(area%r_dp, n=sizes(1), mem_type=area%memory_type)
CASE (dbcsr_type_complex_4)
CALL memory_allocate(area%c_sp, n=sizes(1), mem_type=area%memory_type)
CASE (dbcsr_type_complex_8)
CALL memory_allocate(area%c_dp, n=sizes(1), mem_type=area%memory_type)
CASE (dbcsr_type_real_4_2d)
CALL memory_allocate(area%r2_sp, sizes=sizes, mem_type=area%memory_type)
CASE (dbcsr_type_real_8_2d)
CALL memory_allocate(area%r2_dp, sizes=sizes, mem_type=area%memory_type)
CASE (dbcsr_type_complex_4_2d)
CALL memory_allocate(area%c2_sp, sizes=sizes, mem_type=area%memory_type)
CASE (dbcsr_type_complex_8_2d)
CALL memory_allocate(area%c2_dp, sizes=sizes, mem_type=area%memory_type)
CASE default
DBCSR_ABORT("Invalid data type.")
END SELECT
IF (area%memory_type%acc_devalloc) THEN
IF (sizes(1) >= 0) &
CALL acc_devmem_allocate_bytes(area%acc_devmem, dbcsr_datatype_sizeof(area%data_type)*sizes(1))
CALL acc_event_create(area%acc_ready)
END IF
IF (careful_mod) &
CALL timestop(error_handle)
END SUBROUTINE internal_data_allocate