PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Course

Fortran array subscript ranges

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



Joined: 16 Feb 2011
Posts: 1

PostPosted: Wed Feb 16, 2011 5:45 pm    Post subject: Fortran array subscript ranges Reply with quote

Hi,

I have a local array variable in my cuda kernel that is size 5. Since the array variable is inside the kernel, it will be the same size for each thread. However, I want to access the array with a different subscript range in each thread based on the thread's id. For example, one thread might access it with 1:5 while another might use -2:2. Is this possible to implement or is there an easy workaround for this? Thanks in advance.
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6660
Location: The Portland Group Inc.

PostPosted: Thu Feb 17, 2011 11:00 am    Post subject: Reply with quote

Hi jmark3,

Negative index are fine in Fortran, provided that the array was defined with a negative lower bound. Though, if you do not give a lower bound, the default value of 1 is used and a negative index would give you an out-of-bounds error.

You could make your array's bounds from -2 to 5. "REAL, dimension(-2:5) :: myarray". to make it fit your algorithm. You would just
be wasting a bit of space if you only used 5 elements.

Hope this helps,
Mat
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