Re: Array subsetting
- From: Tim Prince <timothyprince@xxxxxxxxxxxxx>
- Date: Thu, 31 Aug 2006 14:00:07 GMT
Michel Olagnon wrote:
L.Spadavecchia@xxxxxxxxxxxxxx wrote:As Michel indicates, WHERE often produces a temporary logical array. If you are using a Windows or similar system, you may need to specify a stack size at link time, or use a utility to modify the stack limit in your .exe.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.
.
- References:
- Array subsetting
- From: L . Spadavecchia
- Re: Array subsetting
- From: Michel Olagnon
- Array subsetting
- Prev by Date: Re: Array puzzle
- Next by Date: Maple to Fortran?
- Previous by thread: Re: Array subsetting
- Next by thread: Re: Array subsetting
- Index(es):
Relevant Pages
|