pos_relation Function

private elemental function pos_relation(row1, col1, row2, col2) result(relation)

Determines the relation between two matrix positions.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: row1
integer, intent(in) :: col1
integer, intent(in) :: row2
integer, intent(in) :: col2

Return Value integer

Relation between positions 1 and 2. 0: same -1: pos1 < pos2 1: pos1 > pos2


Source Code

   ELEMENTAL FUNCTION pos_relation(row1, col1, row2, col2) RESULT(relation)
      !! Determines the relation between two matrix positions.

      INTEGER, INTENT(IN)                                :: row1, col1, row2, col2
      INTEGER                                            :: relation
         !! Relation between positions 1 and 2. 0: same -1: pos1 < pos2 1: pos1 > pos2

      IF (row1 .LT. row2) THEN
         relation = -1
      ELSEIF (row1 .GT. row2) THEN
         relation = 1
      ELSE ! rows are equal, check column
         IF (col1 .LT. col2) THEN
            relation = -1
         ELSEIF (col1 .GT. col2) THEN
            relation = 1
         ELSE
            relation = 0
         END IF
      END IF
   END FUNCTION pos_relation