mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Sat Oct 13, 2018 1:39 am Post subject: FTN95 incorrectly flags 2-D array as scalar |
|
|
The subroutine code given below has no syntax errors (as checked by Gfortran). The local variable D5V is declared as a 2-dimensional array, and is assigned a rank-2 array expression in a WHERE statement on line 26.
Code: | Subroutine merit (l, m, me, n, r, df, g, dg, v, dphi, active)
!
!*********************************************************************
!
Implicit None
!-----------------------------------------------
! D u m m y A r g u m e n t s
!-----------------------------------------------
Integer, Intent (In) :: l, m, me, n
Real, Intent (In) :: df (n), g (m, l), dg (m, n), v (m), r (m)
Real, Intent (Inout) :: dphi (m + n)
Logical, Intent (Out) :: active (m)
!-----------------------------------------------
! L o c a l V a r i a b l e s
!-----------------------------------------------
Integer :: j1
Real :: d5v (m, n) ! NOTE: Rank = 2
!-----------------------------------------------
!
active = .True.
Where ( (/ (j1, j1=1, m) /) > me .And. &
r * g(:, 1) > v) active = .False.
!
dphi (:n) = df
Where (spread(active, dim=2, ncopies=n)) &
d5v = dg (:, :) * (spread(v, dim=2, ncopies=n) & ! FTN95 says d5v is SCALAR!
- spread(r, dim=2, ncopies=n) &
* spread(g(:, 1), dim=2, ncopies=n))
dphi (:n) = dphi (:n) - sum (d5v, mask= &
spread(active, dim=2, ncopies=n), dim=1)
Where (active)
dphi (n+1:m+n) = - g (:, 1)
Elsewhere
dphi (n+1:m+n) = - v / r
End Where
Return
End Subroutine |
The compiler says
Code: | [FTN95/Win32 Ver. 8.30.279 Copyright (c) Silverfrost Ltd 1993-2018]
0025) Where (spread(active, dim=2, ncopies=n)) &
0026) d5v = dg (:, :) * (spread(v, dim=2, ncopies=n) & ! FTN95 says d5v is SCALAR!
0027) - spread(r, dim=2, ncopies=n) &
0028) * spread(g(:, 1), dim=2, ncopies=n))
*** The test of the enclosing WHERE statement is rank 2, whereas the left hand side of this assignment is a scalar
1 ERROR [<MERIT> FTN95 v8.30.279]
*** Compilation failed |
|
|