! TITLE: arry_max_val.mac (MANAGEMENT) ! ! ! OBJECTIVE: ! ! This sub-macro retrieves the maximum numerical value from a set ! of elements in an array. ! ! ! COMMAND SYNTAX: ! ! (1) (2) (3) (4) (5) (6) (7) ! ARRY_MAX_VAL, 'arrynam', ri, rf, ci, cf, pi, pf ! ! ! ARGUMENTS: ! ! (1) arrynam = the character name of the array (in single quotes) ! ! (2,3) ri/rf = initial/final row index: ! -If both are 0 (or blank) or out-of-range, all rows are ! queried. ! -If either one is 0 (or blank), or out-of-range, and the ! other is in-range, then only that row (in-range value) ! is queried. ! -If both are in-range and not equal, then the range is ! from lowest to highest (independent of order). ! ! (4,5) ci/cf = initial/final column index: ! -If both are 0 (or blank) or out-of-range, all columns ! are queried. ! -If either one is 0 (or blank), or out-of-range, and the ! other is in-range, then only that column (in-range value) ! is queried. ! -If both are in-range and not equal, then the range is ! from lowest to highest (independent of order). ! ! (6,7) pi/pf = initial/final plane index: ! -If both are 0 (or blank) or out-of-range, all planes ! are queried. ! -If either one is 0 (or blank), or out-of-range, and the ! other is in-range, then only that plane (in-range value) ! is queried. ! -If both are in-range and not equal, then the range is ! from lowest to highest (independent of order). ! ! ! DESCRIPTION: ! ! This macro will return the maximum value, and index location, of all ! elements in the specified array. The parameter names of these values ! is shown below. ! ! The maximum value of a subset of all elements in an array may be ! queried by specifying the row, column and plane range-values in which ! to check. These may be specified in arguments 2 through 7. ! ! ---------------- OUTPUT OF THIS MACRO ------------------------- ! ! 1.) max_val = the maximum value of all elements in the array. ! ! 2.) max_ir = the row index of the maximum value element. ! ! 3.) max_ic = the column index of the maximum value element. ! ! 4.) max_ip = the plane index of the maximum value element. ! ! *get,prkey_,active,0,prkey /nopr ! arrynam_=arg1 rinit_=arg2 rfin_=arg3 cinit_=arg4 cfin_=arg5 pinit_=arg6 pfin_=arg7 ! *get,rsiz_,parm,%arrynam_%,dim,1 *get,csiz_,parm,%arrynam_%,dim,2 *get,psiz_,parm,%arrynam_%,dim,3 ! *do,indx_,1,3,1 *if,indx_,eq,1,then init_='rinit_' fin_='rfin_' siz_='rsiz_' *elseif,indx_,eq,2,then init_='cinit_' fin_='cfin_' siz_='csiz_' *elseif,indx_,eq,3,then init_='pinit_' fin_='pfin_' siz_='psiz_' *endif ! *if,%init_%,le,0,or,%init_%,gt,%siz_%,then *if,%init_%,eq,0,xor,%fin_%,eq,0,then *if,%init_%,eq,0,then *if,%fin_%,gt,0,and,%fin_%,le,%siz_%,then %init_%=%fin_% bypass_=1 *elseif,%fin_%,lt,0,and,%fin_%,gt,%siz_%,then %init_%=1 %fin_%=%siz_% bypass_=1 *endif *else *if,%init_%,gt,0,and,%init_%,le,%siz_%,then %fin_%=%init_% bypass_=1 *elseif,%init_%,lt,0,or,%init_%,gt,%siz_%,then %init_%=1 %fin_%=%siz_% bypass_=1 *endif *endif *elseif,%init_%,eq,0,and,%fin_%,eq,0,then %init_%=1 %fin_%=%siz_% bypass_=1 *endif ! *if,bypass_,ne,1,then *if,%fin_%,lt,0,or,%fin_%,gt,%siz_%,then %init_%=1 %fin_%=%siz_% *elseif,%fin_%,gt,0,and,%fin_%,le,%siz_%,then %init_%=%fin_% *endif *else *set,bypass_, *endif *elseif,%init_%,gt,0,and,%init_%,le,%siz_%,then *if,%fin_%,gt,0,and,%fin_%,le,%siz_%,then *if,%init_%,gt,%fin_%,then rhld_=%init_% %init_%=%fin_% %fin_%=rhld_ *endif *else %fin_%=%init_% *endif *endif *enddo ! max_val=%arrynam_%(rinit_,cinit_,pinit_) max_ir=rinit_ max_ic=cinit_ max_ip=pinit_ ! *do,riter_,rinit_,rfin_,1 *do,citer_,cinit_,cfin_,1 *do,piter_,pinit_,pfin_,1 *if,max_val,lt,%arrynam_%(riter_,citer_,piter_),then max_val=%arrynam_%(riter_,citer_,piter_) max_ir=riter_ max_ic=citer_ max_ip=piter_ *endif *enddo *enddo *enddo ! *set,arrynam_, *set,rinit_, *set,cinit_, *set,pinit_, *set,rfin_, *set,cfin_, *set,pfin_, *set,riter_, *set,citer_, *set,piter_, *set,rsiz_, *set,csiz_, *set,psiz_, *set,bypass_, ! *if,prkey_,eq,1,then /go *endif