find_proper_row Subroutine

private pure subroutine find_proper_row(pos, row, maxrows, row_p)

Finds the row to which the current block belongs If there is no valid block, pos is set to 0

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: pos

current position

integer, intent(inout) :: row

input: current row; output: the row corresponding to the position

integer, intent(in) :: maxrows

maxmimum row

integer, intent(in), DIMENSION(:) :: row_p

row pointers


Source Code

   PURE SUBROUTINE find_proper_row(pos, row, maxrows, row_p)
      !! Finds the row to which the current block belongs
      !! If there is no valid block, pos is set to 0

      INTEGER, INTENT(IN)                                :: pos
         !! current position
      INTEGER, INTENT(INOUT)                             :: row
         !! input: current row; output: the row corresponding to the position
      INTEGER, INTENT(IN)                                :: maxrows
         !! maxmimum row
      INTEGER, DIMENSION(:), INTENT(IN)                  :: row_p
         !! row pointers

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

      IF (pos .GT. 0) THEN
         IF (row .LT. 1) THEN
            row = 1
         ELSEIF (row .GT. maxrows) THEN
            row = maxrows
         END IF
         DO WHILE (row_p(row + 1) .LT. pos)
            row = row + 1
            IF (row .GT. maxrows) THEN
               row = 0
               EXIT
            END IF
         END DO
      ELSE
         row = 0
      END IF
   END SUBROUTINE find_proper_row