## How to find the highest value in a subset of one column of a two-column array....and more

## How to find the highest value in a subset of one column of a two-column array....and more

(OP)

Hi

I’ve been struggling with this problem for a while, and perhaps somebody can help.

I have a 2-column array, e.g. as follows

3 2

6 4

12 0

- - - -

22 3

23 10

. .

. .

. .

66 4

I need to search column 1 (which is in ascending order) until I find a specified number, e.g. 12, then find the maximum value in column 2

There must be a concise and elegant way to do this, perhaps using intrinsic functions.

I’ve been struggling with this problem for a while, and perhaps somebody can help.

I have a 2-column array, e.g. as follows

3 2

6 4

12 0

- - - -

22 3

23 10

. .

. .

. .

66 4

I need to search column 1 (which is in ascending order) until I find a specified number, e.g. 12, then find the maximum value in column 2

__up to that point__, i.e. 4. I then need to find the number in the first column corresponding to this, i.e. 6. Then continue down the array until we see 4 again in the second column and return the corresponding number in the first column, i.e. 66.There must be a concise and elegant way to do this, perhaps using intrinsic functions.

## RE: How to find the highest value in a subset of one column of a two-column array....and more

## CODE --> Fortran90

## RE: How to find the highest value in a subset of one column of a two-column array....and more