Debian Codegraph @

packages/seacas/libraries/suplib/locrea.f

raw
1 C Copyright(C) 1999-2020, 2023 National Technology & Engineering Solutions
2 C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 C NTESS, the U.S. Government retains certain rights in this software.
4 C
5 C See packages/seacas/LICENSE for details
6
7 C=======================================================================
8 INTEGER FUNCTION LOCREA (VALUE, NVALUES, VALUES)
9 C=======================================================================
10
11 C --*** LOCREA *** (ETCLIB) Find closest real value
12 C -- Written by Amy Gilkey - revised 11/03/87
13 C --
14 C --LOCREA returns the closest real value to the given value in a list of
15 C --real values (which may not be ordered).
16 C --
17 C --Parameters:
18 C -- VALUE - the value to be searched for
19 C -- NVALUES - the number of values in the list
20 C -- VALUES - the list of values
21
22 REAL VALUES(*)
23
24 DIF = ABS (VALUES(1) - VALUE)
25 IX = 1
26 DO 10 I = 2, NVALUES
27 DIFI = ABS (VALUES(I) - VALUE)
28 IF (DIF .GT. DIFI) THEN
29 DIF = DIFI
30 IX = I
31 END IF
32 10 CONTINUE
33
34 LOCREA = IX
35
36 RETURN
37 END