Re: Array subsetting



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.

.



Relevant Pages

  • Array subsetting
    ... threshold to a real array of dimension. ... Lets call this array1. ... all the arrays in the where statement must be of the same type?) ... important that array1 actually sits in a global data module, ...
    (comp.lang.fortran)
  • Re: Array subsetting
    ... Michel Olagnon wrote: ... threshold to a real array of dimension. ... all the arrays in the where statement must be of the same type?) ... get rid of the temporaries. ...
    (comp.lang.fortran)
  • Re: Any way to do this faster?
    ... I need to know if there is a match between elements in array1 and array2 and then when there is a match I need to copy the row of the matching element in array2 to a row with the same number as the matching row in array1 to a third array, ... Dim colNumbers As VBA.Collection ... Dim lngNum As Long ... Both arrays are variant arrays and I found I needed to do ...
    (microsoft.public.excel.programming)
  • RE: Cross Function when array crosses above another
    ... The essential concept is for the array1 to be ... their respective arrays and then compared, and not stored on the worksheet ... Sub Crossfunction() ... 'Add the following arrays that are sourced from the worksheet: ...
    (microsoft.public.excel.programming)
  • Re: Fuzzy Matching-Algorithmus in VBA
    ... Array2 = Mü ün nc ch he en ... Array3 = Mün ünc nch che hen ... in einem der Arrays in den anderen Arrays vorkommt. ... stimmen in Array1 zu 100 Prozent überein. ...
    (microsoft.public.de.word.vba)