00001 00002 c 00003 c Copyright (c) 1986,1987,1988,1989,1990,1991,1992,1993, 00004 c by Steve McMillan, Drexel University, Philadelphia, PA. 00005 c 00006 c All rights reserved. 00007 c 00008 c Redistribution and use in source and binary forms are permitted 00009 c provided that the above copyright notice and this paragraph are 00010 c duplicated in all such forms and that any documentation, 00011 c advertising materials, and other materials related to such 00012 c distribution and use acknowledge that the software was developed 00013 c by the author named above. 00014 c 00015 c THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 00016 c IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 00017 c WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00018 c 00019 00020 subroutine rebin(string,array,nmax,narr,istat,iout,temp,list) 00021 save 00022 c 00023 c Rebin an array, carrying the others along (if same length). 00024 c 00025 character*(*) string 00026 dimension array(nmax,3),narr(3),temp(nmax),list(nmax) 00027 character*40 token(2) 00028 c 00029 call gettokens(string,token,nt) 00030 if (nt.ne.2) go to 1001 00031 c 00032 call sdecode(token(1),1,iarr,*1001) 00033 if (narr(iarr).le.0) go to 1001 00034 c 00035 call readrtoken(token(2),dx,0.) 00036 if (dx.eq.0.) go to 1001 00037 c 00038 if (array(narr(iarr),iarr).lt.array(1,iarr)) then 00039 dx = -abs(dx) 00040 else 00041 dx = abs(dx) 00042 end if 00043 c 00044 c Linearly rebin the specified array. Assume the elements are 00045 c ordered, and make a list of elements to save. 00046 c 00047 nl = 1 00048 list(1) = 1 00049 xfirst = array(1,iarr) 00050 x = xfirst 00051 xnext = xfirst + dx 00052 do 100 i=2,narr(iarr) 00053 xprev = x 00054 x = array(i,iarr) 00055 if ((x-xfirst)*(x-xprev).lt.0.) then 00056 if (iout.eq.1) write(6,*)'Array not ordered' 00057 go to 1001 00058 end if 00059 if ((x-xnext)*(x-xfirst).ge.0.) then 00060 nl = nl + 1 00061 if (nl.gt.nmax) go to 1001 00062 list(nl) = i 00063 90 xnext = xnext + dx 00064 if ((x-xnext)*(x-xfirst).ge.0.) go to 90 00065 end if 00066 100 continue 00067 c 00068 if (list(nl).ne.narr(iarr)) then 00069 nl = nl + 1 00070 list(nl) = narr(iarr) 00071 end if 00072 c 00073 c Rebin the array(s). 00074 c 00075 nold = narr(iarr) 00076 do 200 k=1,3 00077 if (narr(k).eq.nold) then 00078 do 150 i=1,nl 00079 150 temp(i) = array(list(i),k) 00080 do 160 i=1,nl 00081 160 array(i,k) = temp(i) 00082 narr(k) = nl 00083 end if 00084 200 continue 00085 c 00086 if (iout.eq.1) write(6,*)'New number of points = ',nl 00087 return 00088 c 00089 1001 istat = 3 00090 end