title: Using Fortran IF construct to find matching values between two arrays
body: <p>I need to use an <code>IF</code> condition to determine whether an integer in an array (<code>A</code>) matches with an integer in another array (<code>B</code>) before proceeding with the code. The arrays are of unequal length and contain unique values which are all positive. </p>
  
  <p>I know I can find matching values using:</p>
  
  <pre><code>DO I = 1,SIZE(A)
  Match(J)=(ANY(A(I)==B))
  </code></pre>
  
  <p>However this format isn't accepted by the <code>IF...THEN</code> construct. I've not yet found a way to implement it looking online and general testing. What am I missing here?</p>
  
  <p>EDIT: 
  As as an alternative I tried the below code:</p>
  
  <pre><code>   INTEGER :: I , K, B(900),C(900),I1,ID3, IP
     INTEGER, INTENT(IN)           :: A, N
  
         OPEN(12,FILE='../B.dat')
         DO I=1,817
            READ(12,*)B(I),C(I)
         END DO
  
         DO I = 1,SIZE(A)
          DO K = 1,SIZE(B)
           IF (I.EQ.K) THEN
               DO IP = N-9,N
                  ID3 = I1 +A*(IP-1)
           END DO
           END DO
           END DO
  </code></pre>
  
  <p>However K changes throughout the loop, and so the code doesn't work for matching. I then tried:</p>
  
  <pre><code>DO I = 1, SIZE(A)
    I1 =ID(I)
      DO IP = N-9,N
        ID3 = I1 +A*(IP-1)
      END DO
  </code></pre>
  
  <p>However I received a segmentation error:</p>
  
  <blockquote>
    <p>_____________ runcode::main: :    |runCode: Fail to run    |C:\TELEMAC\VEG\May\PRIVEtest.cas_2018-05-02-16h57min04s\out_testMedit.exe
    |~~~~~~~~~~~~~~~~~~    |Program received signal SIGSEGV: Segmentation
    fault - invalid memory referen ce.    |    |Backtrace for this error: 
    |#0  ffffffffffffffff    |~~~~~~~~~~~~~~~~~~</p>
  </blockquote>