Re: Array subsetting
- From: Michel Olagnon <molagnon@xxxxxxxxxxxxxxxxx>
- Date: Thu, 31 Aug 2006 13:32:07 +0200
L.Spadavecchia@xxxxxxxxxxxxxx wrote:
Hello all,
I am running into difficulties using the WHERE function to subset
arrays. I am currently writing a program which needs to apply a
threshold to a real array of dimension (nx,ny). Lets call this array1.
I then have a second real array - lets call that array2- (I understand
all the arrays in the where statement must be of the same type?) which
will store the result as a binary value. It too has dimension (nx,ny).
Heres the way it appears in the program.
INTEGER,PARAMETER :: nx,ny
REAL :: threshold
REAL,DIMENSION(:,:),ALLOCATABLE :: array1,array2
ALLOCATE(array1(nx,ny))
ALLOCATE(array2(nx,ny))
WHERE (array1 > threshold)
array2 = 1.0
ELSE WHERE
array2 = 0.0
END WHERE
On trying to run this, I always get a stack overflow. I can't figure it
out, because the arrays are of the same rank, size and type. It may be
important that array1 actually sits in a global data module, whereas
array2 is local to the subroutine which thresholds the data.
It is not really a Fortran issue. Increase stack size when you run
it (something like "limit stacksize unlimited" on Unix), the program
is probably using temporary arrays to carry out the WHERE assignment.
You might also try to use a higher level of optimization, that might
get rid of the temporaries.
.
- Follow-Ups:
- Re: Array subsetting
- From: Tim Prince
- Re: Array subsetting
- References:
- Array subsetting
- From: L . Spadavecchia
- Array subsetting
- Prev by Date: Array puzzle
- Next by Date: Re: Array subsetting
- Previous by thread: Array subsetting
- Next by thread: Re: Array subsetting
- Index(es):
Relevant Pages
|