Yes, I see what you mean! Putting the LOC function in shows that the data locations are NOT the same, so the EQUIVALENCE is not actually working as one would have expected. It would appear you have found a bug, but I hesitate to say what kind of bug (error not given when it should, or bad code generation are two possibilities).
Also, the program (as written) would NOT run properly in /CHECKMATE mode at all because the uninitialized data is still a problem (due to the addresses not being properly equivalenced.
However, by declaring the array sizes as a static size and accommodating the read of the character buffer with an implied DO-loop for idata, the program works fine. See the code posting of the changes after this next section.
Non-working version:
!-----------------------------------------------------------------------
PROGRAM cTest
IMPLICIT NONE
CHARACTER*400 inString
INTEGER iLength
inString = ' 32 202020060103092042676F46756C6C20'
READ (inString, '(BN,I5)') iLength
CALL Calculate (iLength, inString)
!++ CALL Calculate (inString)
END PROGRAM cTest
!-----------------------------------------------------------------------
SUBROUTINE Calculate (iLength, inString)
!++ SUBROUTINE Calculate (inString)
IMPLICIT NONE
CHARACTER*400 inString
INTEGER iLength
!++ INTEGER, PARAMETER :: iLength = 32
INTEGER iOK, LTX, I
CHARACTER*(iLength) cBuffer
INTEGER*1 i1Data(iLength)
CHARACTER*(iLength) c1Data
EQUIVALENCE (c1Data, i1Data)
INTEGER, EXTERNAL :: CallTest
print *,'Location of character data =',loc(c1data)
print *,'Location of integer data =',loc(i1Data)
READ (inString, '(BN,I5,A)') iLength, cBuffer
!++ READ (inString, '(BN,5X,A)') cBuffer
READ (cBuffer, '(BN,160Z2)') i1Data ! Read string to crypt
!** DO I= 1, iLength
!** c1Data(I:I) = CHAR (i1Data(I))
!** ENDDO
LTX = iLength / 2
WRITE (*, *) ' '
WRITE (*, '(''String lenghth > '', I12)') iLength
WRITE (*, '(''Input in HEX > '',160Z2.2)') (i1Data(I), I=1,LTX)
WRITE (*, '(''Input in Int*1 > '', 16i4)') (i1Data(I), I=1,LTX)
iOK = CallTest (c1Data, iLength)
WRITE (*, *) ' '
WRITE (*, '(''Input in HEX > '',160Z2.2)') (i1Data(I), I=1,LTX)
WRITE (*, '(''Input in Int*1 > '', 16i4)') (i1Data(I), I=1,LTX)
RETURN
END SUBROUTINE Calculate
!-----------------------------------------------------------------------
INTEGER FUNCTION CallTest (c1Data, iLength)
IMPLICIT NONE
INTEGER iLength
CHARACTER*32 c1Data
INTEGER*1 i1Data(32)
INTEGER I, LTX
print *,'Location of input data=',loc(c1data)
DO I= 1, iLength
write(*,*)'At Index=',i,' Char date=',ichar(c1data(i:i))
i1Data(I) = ICHAR (c1Data(I:I))
ENDDO
LTX = iLength / 2
WRITE (*, *) ' '
WRITE (*, '(''Parameter HEX > '',160Z2.2)') (i1Data(I), I=1,LTX)
WRITE (*, '(''Parameter Int*1 > '', 16i4)') (i1Data(I), I=1,LTX)
CallTest = 0
RETURN
END FUNCTION CallTest
!-----------------------------------------------------------------------
This works:
CHARACTER*(400) cBuffer
INTEGER*1 i1Data(400)
CHARACTER*(400) c1Data
EQUIVALENCE (c1Data, i1Data)
INTEGER, EXTERNAL :: CallTest
print *,'Location of character data =',loc(c1data)
print *,'Location of integer data =',loc(i1Data)
READ (inString, '(BN,I5,A)') iLength, cBuffer
!++ READ (inString, '(BN,5X,A)') cBuffer
READ (trim(cBuffer), '(BN,160Z2)') (i1Data(i),i=1,ilength) ! Read string to crypt