c     This bug happens if Test and ArrayTest are in separate files and are
c     compiled separately and then linked. It doesn't hapopen if they are
c     compiled together in one file. The bug happens with the Intel Fortran
c     2017 64-bit compiler but not with the 32-bit compiler. It works
c     correctly in the 2016 and earlier 64-bit compilers and so it seems
c     to be something that has changed in the 2017 compiler.

c     If I change the INTEGER*2 lines to INTEGER*4 then it works Ok in the
c     2017 64-bit compiler.

c     This is what gets written in the WRITE statements. Array1D is obviously wrong.

c     Array2D =         1.000000        2.000000        3.000000        4.000000        5.000000        6.000000        7.000000        8.000000        9.000000       10.000000       11.000000       12.000000
c     Array1D =         1.000000        2.000000        1.000000        2.000000        5.000000        6.000000        5.000000        6.000000        9.000000       10.000000        9.000000       10.000000


c     ++++++++++++++++++++++++++++++++++++++++++++++++++++++

      SUBROUTINE Test(LUN)

      IMPLICIT NONE
      INTEGER*2  LUN,I
      REAL*8     Array(12)

      DO I=1,12
         Array(I)=I
      ENDDO
      CALL ArrayTest(LUN,Array,12,1)

      RETURN
      END

c     ++++++++++++++++++++++++++++++++++++++++++++++++++++++

      SUBROUTINE ArrayTest(LUN,Array2D,Rows,Cols)

      IMPLICIT NONE
      INTEGER*2  LUN,Rows,Cols,I,J
      REAL*8     Array2D(Rows,Cols),Array1D(12)

      DO I=1,Cols
         WRITE(LUN,'(A,12(1X,F15.6))') 'Array2D = '
     +                                ,(Array2D(J,I),J=1,Rows)
      ENDDO

      DO I=1,Cols
         DO J=1,Rows
            Array1D(J)=Array2D(J,I)
         ENDDO
         WRITE(LUN,'(A,12(1X,F15.6))') 'Array1D = '
     +                                ,(Array1D(J),J=1,Rows)
      ENDDO
      RETURN
      END

c     ++++++++++++++++++++++++++++++++++++++++++++++++++++++
