replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - error 474 - Invalid expression in array constructor
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

error 474 - Invalid expression in array constructor

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Kenneth_Smith



Joined: 18 May 2012
Posts: 759
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Thu Jan 09, 2025 3:22 am    Post subject: error 474 - Invalid expression in array constructor Reply with quote

I think the error reported by the compiler in this case is not correct.

I don't understand how an implied do loop / array constructor can reference an intrinsic function, but not a function defined elsewhere in the code.

Any ideas/explanations welcome.

Ken

Code:
module demo_problem2
implicit none
contains
  elemental function squareD (x) result (returnval)
  real*8, intent(in) :: x
  real*8 :: returnval
    returnval = x*x
  end function squareD
end module demo_problem2

program p2
use demo_problem2
implicit none
integer, parameter :: n = 5
integer :: i
real*8 :: a(n)

!  forall (i = 1:n:1)               ! This works with FTN95, for elemental squareD
!    a(i) = squareD(dble(i))
!  end forall

!  do i = 1, n                      ! This works with FTN95
!    a(i) = squareD(dble(i))
!  end do

!   a = [(sin(dble(i)),i=1,n,1)]    ! This works with FTN95 - when referencing an intrinsic function

  a = [(squareD(dble(i)),i=1,n,1)] ! This does not work with FTN95 - when referencing an non-intrinsic function
                                   ! error 474 - Invalid expression in array constructor
  do i = 1, size(a)
    print*, i, a(i)
  end do
 
end program p2
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8093
Location: Salford, UK

PostPosted: Thu Jan 09, 2025 8:17 am    Post subject: Reply with quote

Ken

Thank you for the feedback. This looks like a bug that needs fixing.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group