c Copyright (C) 2008-2014 Vincent Eymet c c KDISTRIBUTION is free software; you can redistribute it and/or modify c it under the terms of the GNU General Public License as published by c the Free Software Foundation; either version 3, or (at your option) c any later version. c KDISTRIBUTION is distributed in the hope that it will be useful, c but WITHOUT ANY WARRANTY; without even the implied warranty of c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the c GNU General Public License for more details. c You should have received a copy of the GNU General Public License c along with KDISTRIBUTION; if not, see c subroutine minmax(n,tab,min,max) implicit none include 'max.inc' c c Purpose: to compute the minimum and maximum values in a given array c c Inputs: c + n: number of elements in the array (maximum value: kmax) c + tab: array of "n" values c c Outputs: c + min: minimum value in the array c + max: maximum value in the array c integer n,i double precision tab(1:kmax) double precision min,max c label integer strlen character*(Nchar_mx) label label='subroutine minmax' if (n.gt.kmax) then write(*,*) 'Error from routine ',label(1:strlen(label)),' :' write(*,*) 'value of parameter n=',n write(*,*) 'exceeds the value of kmax=',kmax write(*,*) 'please increase the value of kmax' write(*,*) 'in file "includes/max.inc"' write(*,*) 'and the recompile using command "make clean all"' stop endif min=tab(1) max=0.0D+0 do i=1,n if (tab(i).lt.min) then min=tab(i) endif if (tab(i).gt.max) then max=tab(i) endif enddo return end