title: Fortran: Set operations
body: <p><strong>Fortran:</strong> There are two large arrays of integers, the goal is to find out if they have any number in common or not, <strong>how?</strong><br>
  You may consider that both are in the same size (case 1) or in different sizes (case 2). It is possible also that they have many common numbers repeated, so this should be handled to avoid unnecessary search or operators.
  The simplest way is to do Brute-Force search which is not appropriate. We are thinking about <code>SET</code> operations similar to <strong>Python</strong> as the following:  </p>
  
  <pre><code>
  a = set([integers])
  b = set([integers])
  incommon = len(a.intersection(b)) > 0    #True if so, otherwise False
  
  </code></pre>
  
  <p>So for example:</p>
  
  <pre><code>
  a = [1,2,3,4,5]
  b = [0,6,7,8,9]
  sa = set(a)
  sb = set(b)
  incommon = len(sa.intersection(sb)) > 0
  >>> incommon: False
  b = [0,6,7,8,1]
  incommon = len(sa.intersection(sb)) > 0
  >>> incommon: True
  
  </code></pre>
  
  <p><strong>How to implement this in Fortran?</strong> note that arrays are of large size (>10000) and the operation would repeat for million times!</p>
  
  <p><strong>Updates:</strong>
  [regarding the comment for the question] We absolutely have tried many ways that we knew. As mentioned BFS method, for example. It works but is not efficient for two reasons: 1) the nature of the method which requires large iterations, 2) the code we could implement. The accepted answer (by yamajun) was very informative to us much more than the question itself. How easy implementation of Quick-Sort, Shrink and Isin all are very nicely thought and elegantly implemented. Our appreciation goes for such prompt and perfect solution.</p>