How to select a subset of an array in Fortran 90



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


.



Relevant Pages

  • Re: Loading matrix from file? [fortran 77]
    ... > Is there any way to load matrix (array) from file, ... You need to allocate enough space for the largest possible matrix at ... You had to know at least the first dimension of the matrix before you ... subroutine sub ...
    (comp.lang.fortran)
  • Re: dimension question
    ... dimension a ... If the subroutine DIMENSION statement is athe array ...
    (comp.lang.fortran)
  • Re: Neq Max Limit
    ... you are passing incorrect arguments to a subroutine. ... One may be the array size and another an array. ... dimension y,dy ... PRINT *,i at the top of the outer loop may tell you if the program is ...
    (comp.lang.fortran)
  • Re: g95 wish list
    ... (big snip on dimension of (1) ... > have a bounds check which fails if the subroutine references X. ... allowing the full dimension information to be ... > the possibility of a check as to whether you passed an array of size 2 ...
    (comp.lang.fortran)
  • Re: VB .Net and Intel Visual Fortran 9
    ... having is that the VB program cannot load the DLL. ... subroutine) to accept an array from VB - in my case a 2D array. ... Declare Sub mmult Lib "test.dll" (ByRef i As Double, ByRef j As Double, ...
    (comp.lang.fortran)