Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compilator dependent, intrinsic array manipulation, memory problem

Status
Not open for further replies.

lacek

Technical User
Nov 5, 2011
1
FR
Welcome all,

I have a following code:

Code:
program aaaa
implicit none 

double precision, dimension(:), allocatable :: inp,outp
integer ::n,i

read(*,*) n

allocate(inp(n),outp(n))

write(*,*) allocated(inp), allocated(outp)

write(*,*) inp(1)
inp=cshift(outp,-size(outp)/2)
write(*,*) inp(1)

end program aaaa
It really does nothing - it just applies cyclic rotation of dynamically created array.
But when I use is for large n (in my case - over 10^6) then Segmentation fault occurs. More precisely this is the output:

Code:
T T
  0.000000000000000E+000
Segmentation fault
I also discovered that by increasing the limit for stack memory the segmentation fault can be avoided. Clearly I am using cshift not appropriately.

Additionally the code perform does not exists when the compilation is done with gfortran, but it exists with ifort v12.0.0.

What is going on? I tried to compile with -check all, but it provides no info.
 
if cshift does not cut it...do something else...like, if you want to shift the array elements 9 spaces:

Code:
s=9
inp(1:s)   =outp(n+1-s:n)
inp(s+1:n) =outp(1:n-s)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top