! TITLE: max_value.mac (MANAGEMENT) ! ! ! ! This sub-macro is used to retrieve the maximum value from a set ! of elements in an array. Input data necessary to run this macro: ! ! anam = character name (use 6 or less) of the array to retrieve ! maximum value from. This macro will return the maximum ! value to a parameter that is the character name of the ! array with the letters 'mn' attached to the end (i.e., the ! maximum value of the array rad(i,1) is returned as 'radmn'; ! the array z(i,j) returned as 'zmn'; etc.) If the returned ! parameter exceeds 8 characters, just use the value ! returned by the parameter 'max_val'. ! ! NOTE: Be cautioned that the value of the parameter ! 'max_val' will be overwritten with each succesive ! use of this macro. ! ! nrow = the number of rows in the array. ! ! ncol = the number of columns if array is 2 or 3 dimensional. ! ! npln = the number of planes if array is 3 dimensional. ! ! dir = the direction of entities in the array in which to find the maximum. ! It is the indical direction in which to iterate to find the ! maximum: ! ! (1,2,3) ====> (row, column, plane) ! ! 1 = [DEFAULT] row iteration direction (the (r,X,Y) positions; iterate ! over r holding X and Y constant) ! ! 2 = column iteration direction (the (X,c,Y) positions; iterate over ! c holding X and Y constant) ! ! 3 = plane iteration direction ( the (X,Y,p) positions; iterate ! over p holding X and Y constant) ! ! pos1 = the row index position of the 1st element to begin iterations ! with in searching for the maximum in the DIR direction. If ! DIR=1, this parameter defaults to 1. ! ! pos2 = the column index position of the 1st element to begin iterations ! with in searching for the maximum in the DIR direction. If ! DIR=2, this parameter defaults to 1. ! ! pos3 = the plane index position of the 1st element to begin iterations ! with in searching for the maximum in the DIR direction. If ! DIR=3, this parameter defaults to 1. ! ! *NOTE: If only a one dimensional array (column array) is queried, then ! arguments 3 through 8 may be ignored. ! ! ! ***** The output of this macro are: ! ! 1.) max_val = the maximum value of the elements ! in the array ! ! 2.) max_indx = the index of the maximum value element ! in the array ! ! ! ! (1) (2) (3) (4) (5) (6) (7) (8) ! MAX_VALUE, anam, nrow, ncol, npln, dir, pos1, pos2, pos3 ! ! ! *get,prkey_,active,0,prkey /nopr _anam=arg1 _nrow=arg2 _ncol=arg3 _npln=arg4 _dir=arg5 _pos1=arg6 _pos2=arg7 _pos3=arg8 ! ! *if,_nrow,eq,0,then ! default # of ROWS value _nrow=1 *endif ! *if,_ncol,eq,0,then ! default # of COLUMNS value _ncol=1 *endif ! *if,_npln,eq,0,then ! default # of PLANES value _npln=1 *endif ! *if,_dir,eq,0,then ! default load direction value _dir=1 *endif ! *if,_pos1,eq,0,then ! default ROW position value _pos1=1 *endif ! *if,_pos2,eq,0,then ! default COLUMN position value _pos2=1 *endif ! *if,_pos3,eq,0,then ! default PLANE position value _pos3=1 *endif ! *if,_dir,eq,1,then _pos1=1 *endif ! *if,_dir,eq,2,then _pos2=1 *endif ! *if,_dir,eq,3,then _pos3=1 *endif ! ! *if,_dir,eq,1,then ! *do,_nnn,1,_nrow,1 *if,_nnn,eq,1,then _yyy=%_anam%(_nnn,_pos2,_pos3) *else *if,_yyy,gt,%_anam%(_nnn,_pos2,_pos3),then _yyy=_yyy *else _yyy=%_anam%(_nnn,_pos2,_pos3) *endif *endif *enddo ! *do,_nnn,1,_nrow,1 *if,%_anam%(_nnn,_pos2,_pos3),eq,_yyy,then max_indx=_nnn *endif *enddo *endif ! ! *if,_dir,eq,2,then ! *do,_nnn,1,_ncol,1 *if,_nnn,eq,1,then _yyy=%_anam%(_pos1,_nnn,_pos3) *else *if,_yyy,gt,%_anam%(_pos1,_nnn,_pos3),then _yyy=_yyy *else _yyy=%_anam%(_pos1,_nnn,_pos3) *endif *endif *enddo ! *do,_nnn,1,_ncol,1 *if,%_anam%(_pos1,_nnn,_pos3),eq,_yyy,then max_indx=_nnn *endif *enddo *endif ! ! *if,_dir,eq,3,then ! *do,_nnn,1,_npln,1 *if,_nnn,eq,1,then _yyy=%_anam%(_pos1,_pos2,_nnn) *else *if,_yyy,gt,%_anam%(_pos1,_pos2,_nnn),then _yyy=_yyy *else _yyy=%_anam%(_pos1,_pos2,_nnn) *endif *endif *enddo ! *do,_nnn,1,_npln,1 *if,%_anam%(_pos1,_pos2,_nnn),eq,_yyy,then max_indx=_nnn *endif *enddo *endif ! ! max_val=_yyy ! ! *set,_yyy, *set,_nnn, *set,_anam, *set,_nrow, *set,_ncol, *set,_npln, *set,_dir, *set,_pos1, *set,_pos2, *set,_pos3, *if,prkey_,eq,1,then /go *endif