convert_offsets_to_sizes Subroutine

public pure subroutine convert_offsets_to_sizes(offsets_start, sizes, offsets_stop)

Converts offsets to sizes If the offsets of ends are not given, then the array of sizes is assumed to be one greater than the desired sizes.

Arguments

TypeIntentOptionalAttributesName
integer, intent(in), DIMENSION(:):: offsets_start

offsets of starts

integer, intent(out), DIMENSION(:):: sizes

array with sizes

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

offsets of ends


Contents


Source Code

   PURE SUBROUTINE convert_offsets_to_sizes(offsets_start, sizes, offsets_stop)
      !! Converts offsets to sizes
      !! If the offsets of ends are not given, then the array of sizes is assumed
      !! to be one greater than the desired sizes.

      INTEGER, DIMENSION(:), INTENT(IN)                  :: offsets_start
         !! offsets of starts
      INTEGER, DIMENSION(:), INTENT(OUT)                 :: sizes
         !! array with sizes
      INTEGER, DIMENSION(:), INTENT(IN), OPTIONAL        :: offsets_stop
         !! offsets of ends

      INTEGER                                            :: i, n

!   ---------------------------------------------------------------------------

      n = SIZE(offsets_start)
      IF (PRESENT(offsets_stop)) THEN
         sizes(:) = offsets_stop(:) - offsets_start(:) + 1
      ELSE
         IF (n .GT. 1) THEN
            DO i = 1, n - 1
               sizes(i) = sizes(i + 1) - sizes(i)
            END DO
         END IF
      END IF
   END SUBROUTINE convert_offsets_to_sizes