------- Comment #1 from jpr at csc dot fi  2007-09-04 07:49 -------
The code is invalid without explicit interface to SUB().
Modified code:

      REAL X(2,3), Y(2)
      Y=[1.,2.]
      CALL SUB(X,Y)
      DO I = 1, 3
         PRINT*,X(:,I)
      ENDDO

CONTAINS

      SUBROUTINE SUB(A,B)
      REAL A(:,:), B(:)
      A(:,:) = SPREAD(B(:),2,SIZE(A,2))
      END SUBROUTINE SUB
      END

works just fine. Alternatively

      REAL X(2,3), Y(2)
      Y=[1.,2.]
      CALL SUB(X,Y,size(y,1),size(y,2))
      DO I = 1, 3
         PRINT*,X(:,I)
      ENDDO
      END

      SUBROUTINE SUB(A,B,n,m)
      INTEGER n,m
      REAL A(n,m), B(n)
      A(:,:) = SPREAD(B(:),2,SIZE(A,2))
      END

also works as expected.

If the main program and SUB are compiled together, the compiler could
of course diagnose this, as e.g. pathscale does:

      SUBROUTINE SUB(A,B)
                 ^
pathf95-1277 pathf90: ERROR SUB, File = t.f90, Line = 9, Column = 18
  Procedure "SUB" is referenced at line 3 (t.f90).  It must have an explicit
interface specified.

Regards, Juha


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33298

Reply via email to