Repoints a pointer into a part of a data area
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dbcsr_data_obj), | intent(inout) | :: | new_area |
repoints this encapsulated pointer |
||
type(dbcsr_data_obj), | intent(in) | :: | area |
area to point into |
||
integer, | intent(in) | :: | offset |
point to this offset in area |
||
integer, | intent(in), | optional | :: | len |
length of data area to point to |
copy of new_area
FUNCTION pointer_view_a(new_area, area, offset, len) RESULT(narea2)
!! Repoints a pointer into a part of a data area
TYPE(dbcsr_data_obj), INTENT(INOUT) :: new_area
!! repoints this encapsulated pointer
TYPE(dbcsr_data_obj), INTENT(IN) :: area
!! area to point into
INTEGER, INTENT(IN) :: offset
!! point to this offset in area
INTEGER, INTENT(IN), OPTIONAL :: len
!! length of data area to point to
TYPE(dbcsr_data_obj) :: narea2
!! copy of new_area
IF (area%d%data_type /= new_area%d%data_type) &
DBCSR_ABORT("Incompatible data types.")
IF (PRESENT(len)) THEN
SELECT CASE (area%d%data_type)
CASE (dbcsr_type_real_4)
new_area%d%r_sp => area%d%r_sp(offset:offset + len - 1)
CASE (dbcsr_type_real_8)
new_area%d%r_dp => area%d%r_dp(offset:offset + len - 1)
CASE (dbcsr_type_complex_4)
new_area%d%c_sp => area%d%c_sp(offset:offset + len - 1)
CASE (dbcsr_type_complex_8)
new_area%d%c_dp => area%d%c_dp(offset:offset + len - 1)
CASE default
DBCSR_ABORT("Invalid data type.")
END SELECT
ELSE
SELECT CASE (area%d%data_type)
CASE (dbcsr_type_real_4)
new_area%d%r_sp => area%d%r_sp(offset:)
CASE (dbcsr_type_real_8)
new_area%d%r_dp => area%d%r_dp(offset:)
CASE (dbcsr_type_complex_4)
new_area%d%c_sp => area%d%c_sp(offset:)
CASE (dbcsr_type_complex_8)
new_area%d%c_dp => area%d%c_dp(offset:)
CASE default
DBCSR_ABORT("Invalid data type.")
END SELECT
END IF
narea2 = new_area
END FUNCTION pointer_view_a