Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
logical(kind=logical64), | intent(inout), | allocatable | :: | array(:) | ||
integer(kind=int32), | intent(in), | optional | :: | length | ||
integer(kind=int32), | intent(in), | optional | :: | bounds(:) |
subroutine allocate_rank1_logical8(array, length, bounds) implicit none logical(logical64), intent(inout), allocatable :: array(:) integer(int32), intent(in), optional :: length integer(int32), intent(in), optional :: bounds(:) integer(int32) :: stat logical(logical32) :: length_present, bounds_present integer(int64) :: requested_size integer(int32) :: first, last length_present = present(length) bounds_present = present(bounds) ! --- Argument validation --- if (length_present .and. bounds_present) call error_message(956) if (.not. length_present .and. .not. bounds_present) call error_message(957) if (bounds_present) then if (size(bounds) /= 2) call error_message(958) end if ! --- Main logic --- if (allocated(array)) call error_message(951) if (length_present) then ! Allocate by length if (length <= 0) call error_message(952) if (int(length, kind=int64) > huge(0_int32)) call error_message(953) allocate (array(length), stat=stat) else if (bounds_present) then ! Allocate by bounds first = bounds(1) last = bounds(2) if (first > last) call error_message(954) requested_size = int(last, kind=int64) - int(first, kind=int64) + 1_int64 if (requested_size > huge(0_int64) / 4) call error_message(953) allocate (array(first:last), stat=stat) end if if (stat /= 0) call error_message(955) end subroutine allocate_rank1_logical8