PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

PGI Fortran 13.10 and array initialization

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
JasonBoisvert92837



Joined: 11 Dec 2013
Posts: 2

PostPosted: Thu Apr 10, 2014 12:52 pm    Post subject: PGI Fortran 13.10 and array initialization Reply with quote

I got a compiler error when trying to initialize an array with the following form:

real*8, dimension(25,11), parameter :: p=&
(/ 4.8610170D+00, 2.4603311D+00, 4.2003577D+01, 1.1525126D-02,&
... /)

The size of the comma-separated list is 275 elements (matching the dimension).

For this code I got the error: "Shape of initializer does not match the shape of p"

This code compiles under Intel Fortran.

I changed to:

real*8, dimension(25,11) :: p
data p/ << the same comma separated list of data >> /

and this worked.

Can someone explain why the PGI compiler won't allow the 'parameter' syntax but it does allow the 'data' syntax?

Thank you.
Back to top
View user's profile
cparrott



Joined: 02 May 2011
Posts: 146

PostPosted: Thu Apr 10, 2014 2:56 pm    Post subject: Reply with quote

Hi Jason,

I've created a simple test case which should reproduce the behavior you reported:

Code:

program arraytest

  real*8, dimension(3,2), parameter :: p = &
       (/ 1, 2, 3, 4, 5, 6 /)

end program arraytest


And I do see the error with PGI 14.3. I'll file a report on it.

Best regards,

+chris
Back to top
View user's profile
mecej4



Joined: 19 Jun 2011
Posts: 55

PostPosted: Fri Apr 11, 2014 6:27 am    Post subject: Re: PGI Fortran 13.10 and array initialization Reply with quote

Here is a work-around:

Replace
Code:

real*8, dimension(25,11), parameter :: p=&
         (/ 4.8610170D+00, 2.4603311D+00, 4.2003577D+01, 1.1525126D-02,&
 ... /)

by
Code:

real*8, dimension(25,11), parameter :: p=&
         reshape( (/ 4.8610170D+00, 2.4603311D+00, 4.2003577D+01, 1.1525126D-02,&
 ... /), (/ 25, 11 )/ )/

[/quote]
Back to top
View user's profile
JasonBoisvert92837



Joined: 11 Dec 2013
Posts: 2

PostPosted: Fri Apr 11, 2014 11:30 am    Post subject: Reply with quote

Thanks cparrot and mecej4.

The 'reshape' work-around is what we are using.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
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 © phpBB Group