PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Course

Unusual segmentation fault with RESHAPE

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



Joined: 11 Jun 2009
Posts: 233

PostPosted: Sun Jan 09, 2011 12:43 pm    Post subject: Unusual segmentation fault with RESHAPE Reply with quote

This is the sample code that i'm trying to map from 3D to 1D.

Code:


PROGRAM test
  INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(P=13, r=200)
  REAL(KIND=dp), DIMENSION(608, 64, 64) :: tmp_ca1, tmp_Ca2
  REAL(KIND=dp) :: ca1, Ca2
  REAL(KIND=dp), DIMENSION(608*64*64) :: sca1, sca2
  INTEGER :: stencil_radius = 4
  INTEGER :: maxx = 608, maxy = 64, maxz = 64
 
  ca1 = 0.1d0
  Ca2 = 1d3
 
  tmp_ca1(STENCIL_RADIUS+1:MAXX+STENCIL_RADIUS, STENCIL_RADIUS+1:MAXY+STENCIL_RADIUS, &
        STENCIL_RADIUS+1:MAXZ+STENCIL_RADIUS) = ca1

  tmp_Ca2(STENCIL_RADIUS+1:MAXX+STENCIL_RADIUS, STENCIL_RADIUS+1:MAXY+STENCIL_RADIUS, &
        STENCIL_RADIUS+1:MAXZ+STENCIL_RADIUS) = Ca2

  sca1 = RESHAPE(tmp_ca1, (/ 608*64*64 /) )
  sca2 = RESHAPE(tmp_Ca2, (/ 608*64*64 /) )

END PROGRAM test


I'm using FOrtran 10.9.

Tuan
Back to top
View user's profile
mkcolg



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

PostPosted: Mon Jan 10, 2011 3:01 pm    Post subject: Reply with quote

Hi Tuan,

The reshape is fine. You have an out of bounds error when initializing tmp_cal.

Code:
% pgf90 reshape.f90 -V10.9 -g -Mbounds
% a.out
0: Subscript out of range for array tmp_ca1 (reshape.f90: 12)
    subscript=609, lower bound=1, upper bound=608, dimension=1


Hope this helps and Go Ducks,
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