subroutine aptmnmx (x, ibeg, iend, int, imin, imax, & xmin, xmax, nerr) ccbeg. cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c SUBROUTINE APTMNMX c c call aptmnmx (x, ibeg, iend, int, imin, imax, xmin, xmax, nerr) c c Version: aptmnmx Updated 1993 May 15 15:40. c aptmnmx Originated 1993 May 15 15:40. c c Author: Arthur L. Edwards, LLNL, L-298, Telephone (925) 422-4123. c c c Purpose: To find the minimum and maximum values xmin and xmax, in array c x, starting at x(ibeg) and testing every int'th value of x up c to x(iend), and the indices imin and imax at which the occur. c Note that ibeg, iend, imin and imax are based on the input c argument x being x(1). For example, if the dimension of c x is (-10:40), call aptmnmx with x(1), ibeg = -10, iend = 40, c int = 1, to search the entire array, and to get the correct c absolute indices for imin and imax. c Flag nerr indicates any input errors. c c Input: x, ibeg, iend, int. c c Output: imin, imax, xmin, xmax, nerr. c c Glossary: c c nerr Output Indicates an input error, if not 0. c 1 if int is zero, or does not have the same sign c as iend - ibeg. c c ibeg Input The index of the first value of x to be tested. c c iend Input The index of the last value of x to be tested. c Must be within the range of indices of x. c c imax Output The index in x at which xmax occurs. c xmax = x(imax) c c imin Output The index in x at which xmin occurs. c xmin = x(imin) c c int Input The interval between the indices of x to be tested. c I.e., the indices ibeg, ibeg + int, ibeg + 2*int, c etc, up to ibeg + n*int =< iend will be tested. c c x Input Word x(1), in the array to be tested, from x(ibeg) to c x(iend), at intervals int, to find minimum xmin, and c maximum xmax, and the indices imin and imax of xmin c and xmax. c c xmax Output Maximum value of x found. c c xmin Output Minimum value of x found. c cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc ccend. c.... Dimensioned arguments. c---- Array to be tested to find minimum and maximum. dimension x (1) c.... Local variables. c---- A big number common /laptmnmx/ big c---- Index in array x. common /laptmnmx/ n c---- Index in array x. common /laptmnmx/ nn c---- Temporary value of x. common /laptmnmx/ xtemp cbugc***DEBUG begins. cbug 9901 format (/ 'aptmnmx finding minimum and maximum.' / cbug & 'ibeg=',i8,' iend=',i8,' int=',i8) cbug write ( 3, 9901) ibeg, iend, int cbugc***DEBUG ends. c.... initialize. big = 1.e99 xmin = big xmax = -big nerr = 0 c.... Test for input errors. if (iend .ge. ibeg) then if (int .le. 0) then nerr = 1 go to 210 endif else if (int .ge. 0) then nerr = 1 go to 210 endif endif cbugc***DEBUG begins. cbug 9902 format (i8,' x=',1pe22.14) cbug write ( 3, 9902) (n, x(n), n = ibeg, iend, int) cbugc***DEBUG ends. c.... Find the minimum and maximum values of x. c---- Loop over array x. do 110 n = ibeg, iend, int if (x(n) .lt. xmin) then imin = n xmin = x(n) endif if (x(n) .gt. xmax) then imax = n xmax = x(n) endif c---- End of loop over array x. 110 continue 210 continue cbugc***DEBUG begins. cbug 9903 format (/ 'aptmnmx results: nerr=',i3 / cbug & 'imin=',i8,' xmin=',1pe22.14 / cbug & 'imax=',i8,' xmax=',1pe22.14) cbug write ( 3, 9903) nerr, imin, xmin, imax, xmax cbugc***DEBUG ends. return c.... End of subroutine aptmnmx. (+1 line.) end UCRL-WEB-209832