I need to use an IF condition to determine whether an integer in an array (A) matches with an integer in another array (B) before proceeding with the code. The arrays are of unequal length and contain unique values which are all positive.
I know I can find matching values using:
DO I = 1,SIZE(A)
Match(J)=(ANY(A(I)==B))
However this format isn't accepted by the IF...THEN construct. I've not yet found a way to implement it looking online and general testing. What am I missing here?
EDIT: As as an alternative I tried the below 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
However K changes throughout the loop, and so the code doesn't work for matching. I then tried:
DO I = 1, SIZE(A)
I1 =ID(I)
DO IP = N-9,N
ID3 = I1 +A*(IP-1)
END DO
However I received a segmentation error:
_____________ 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 |~~~~~~~~~~~~~~~~~~