Re: How to select a subset of an array in Fortran 90





Leonard W. Howell, Jr. wrote:
I'm trying to do the following but w/o any success:

I need a subroutine - call it SELECT - this is passed an array A, say of
dimension N, and I would like SELECT to return an array B of dimension M<=N
where B is a subset of A constructed according to some criteria. For
example, I might have

SUBROUTINE SELECT(A,N, RANGE, B, M)

and B could be the elements of A between Range(1) and Range(2).

I thought I could define B like

WHERE (A<=Range(2).AND.A >= Range(1))
  B=A
Endwhere

I am having trouble with the variable dimension of B in the subroutine so
any help would be appreciated, Leonard



B = PACK (A, Mask=(A<=Range(2).AND.A >= Range(1))) M = COUNT (A<=Range(2).AND.A >= Range(1))

.... and pray that your optimizing compiler is smart enough
to detect the repetition.

.



Relevant Pages

  • Re: The Fifth Dimension
    ... >> realized there was still another dimension that should be taken into ... Color travels at the speed of ... You don't expect Leonard to understand this, ... Leonard was propounding his philosophy of deeper understanding of physics ...
    (sci.physics)
  • Re: The Fifth Dimension
    ... >> realized there was still another dimension that should be taken into ... Color travels at the speed of ... You don't expect Leonard to understand this, ... Leonard was propounding his philosophy of deeper understanding of physics ...
    (sci.physics.relativity)
  • Re: How to select a subset of an array in Fortran 90
    ... Leonard W. Howell, Jr. ... > dimension N, and I would like SELECT to return an array B of dimension M<=N ... > SUBROUTINE SELECT ...
    (comp.lang.fortran)
  • Re: Error on UBound with Dynamic Array
    ... ReDim Preserve arrSplit+ 1) ... is that arrSplit has not yet been dimmed as having any dimension. ... need to use a dynamic array and may be checking the boundries, ... Public Function Split(csvString As String) As Variant ...
    (microsoft.public.access.modulesdaovba)
  • Re: Array of pointer Vs Pointer to Array
    ... that points to an array. ... Now 'pa' is a pointer form of accessing the values in 'matrix'. ... that depends on a variety of things - the size of the other dimension, ... the regular indexing style is a good first guess, ...
    (comp.lang.c)