I have encountered a bug with ISHFT when used with 2 byte integers (I can't reproduce it with 4 byte integers), it sometimes fails to work giving the result zero. Here is a small test case to demonstrate the problem:
Module TestData
Integer*2, Save :: i2SH
Integer*2, Save :: i2DM
Integer*2, Save :: i2CL
End Module TestData
Module Test
Contains
Subroutine ISHFTTest()
USE TestData
Integer*2 :: i2SI, i2CP
Integer*2 :: i2Test
i2CP = i2CL
i2SI = i2SH + i2DM
i2Test = i2SI
WRITE(*, *) i2SI, i2CP, LS(i2SI, i2CP), ISHFT(260s, 4s) ! 260, 4, 4160, 4160
i2Test = i2SI
WRITE(*, *) ISHFT(i2Test, i2CP) ! This should write 4160
i2Test = i2SI
WRITE(*, *) i2SI, i2CP, ISHFT(i2Test, i2CP) ! This should write 260, 4, 4160
i2SI= LS(i2SI, i2CP)
WRITE(*, *) i2SI ! This should write 4160
End Subroutine ISHFTTest
End Module Test
Program Main
USE TestData
USE Test
i2SH = 160
i2CL = 4
i2DM = 100
Call ISHFTTest()
End Program
The expected output is:
260 4 4160 4160
4160
260 4 4160
4160
I actually get:
260 4 4160 4160
0
260 4 4160
4160
It is strange that the first the two identical ISHFT calls give differt results. This is with FTN95 v6.35 with no switches.