From: Cezary Czaplewski Date: Thu, 10 Mar 2016 13:48:29 +0000 (+0100) Subject: cleaning of cluster_wham X-Git-Url: http://mmka.chem.univ.gda.pl/gitweb/?p=unres.git;a=commitdiff_plain;h=6e0e970a22de67a2b33b05989f15f40163a84138 cleaning of cluster_wham --- diff --git a/source/cluster/wham/src-M/bakup/main_clust.F b/source/cluster/wham/src-M/bakup/main_clust.F deleted file mode 100644 index 1f669d4..0000000 --- a/source/cluster/wham/src-M/bakup/main_clust.F +++ /dev/null @@ -1,443 +0,0 @@ -C -C Program to cluster united-residue MCM results. -C - implicit none - include 'DIMENSIONS' - include 'sizesclu.dat' -#ifdef MPI - include "mpif.h" - integer IERROR,ERRCODE,STATUS(MPI_STATUS_SIZE) - include "COMMON.MPI" -#endif - include 'COMMON.TIME1' - include 'COMMON.INTERACT' - include 'COMMON.NAMES' - include 'COMMON.GEO' - include 'COMMON.HEADER' - include 'COMMON.CONTROL' - include 'COMMON.CHAIN' - include 'COMMON.VAR' - include 'COMMON.CLUSTER' - include 'COMMON.IOUNITS' - include 'COMMON.FREE' - logical printang(max_cut) - integer printpdb(max_cut) - integer printmol2(max_cut) - character*240 lineh - REAL CRIT(maxconf),MEMBR(maxconf) - REAL CRITVAL(maxconf-1) - INTEGER IA(maxconf),IB(maxconf) - INTEGER ICLASS(maxconf,maxconf-1),HVALS(maxconf-1) - INTEGER IORDER(maxconf-1),HEIGHT(maxconf-1) - integer nn,ndis - real*4 DISNN - DIMENSION NN(maxconf),DISNN(maxconf) - LOGICAL FLAG(maxconf) - integer i,j,k,l,m,n,len,lev,idum,ii,ind,ioffset,jj,icut,ncon, - & it,ncon_work,ind1 - double precision t1,t2,tcpu,difconf - - double precision varia(maxvar) - double precision hrtime,mintime,sectime - logical eof -#ifdef MPI - call MPI_Init( IERROR ) - call MPI_Comm_rank( MPI_COMM_WORLD, me, IERROR ) - call MPI_Comm_size( MPI_COMM_WORLD, nprocs, IERROR ) - Master = 0 - if (ierror.gt.0) then - write(iout,*) "SEVERE ERROR - Can't initialize MPI." - call mpi_finalize(ierror) - stop - endif - if (nprocs.gt.MaxProcs+1) then - write (2,*) "Error - too many processors", - & nprocs,MaxProcs+1 - write (2,*) "Increase MaxProcs and recompile" - call MPI_Finalize(IERROR) - stop - endif -#endif - - call initialize - call openunits - call parmread - call read_control - call molread -c if (refstr) call read_ref_structure(*30) - do i=1,nres - phi(i)=0.0D0 - theta(i)=0.0D0 - alph(i)=0.0D0 - omeg(i)=0.0D0 - enddo - write (iout,*) "symetr", symetr - call permut(symetr) - print *,'MAIN: nnt=',nnt,' nct=',nct - - DO I=1,NCUT - PRINTANG(I)=.FALSE. - PRINTPDB(I)=0 - printmol2(i)=0 - IF (RCUTOFF(I).LT.0.0) THEN - RCUTOFF(I)=ABS(RCUTOFF(I)) - PRINTANG(I)=.TRUE. - PRINTPDB(I)=outpdb - printmol2(i)=outmol2 - ENDIF - ENDDO - write (iout,*) 'Number of cutoffs:',NCUT - write (iout,*) 'Cutoff values:' - DO ICUT=1,NCUT - WRITE(IOUT,'(8HRCUTOFF(,I2,2H)=,F8.1,2i2)')ICUT,RCUTOFF(ICUT), - & printpdb(icut),printmol2(icut) - ENDDO - DO I=1,NRES-3 - MULT(I)=1 - ENDDO - do i=1,maxconf - list_conf(i)=i - enddo - call read_coords(ncon,*20) - write (iout,*) 'from read_coords: ncon',ncon - - write (iout,*) "nT",nT - do iT=1,nT - write (iout,*) "iT",iT -#ifdef MPI - call work_partition(.true.,ncon) -#endif - - call probabl(iT,ncon_work,ncon,*20) - - if (ncon_work.lt.2) then - write (iout,*) "Too few conformations; clustering skipped" - exit - endif -#ifdef MPI - ndis=ncon_work*(ncon_work-1)/2 - call work_partition(.true.,ndis) -#endif - - DO I=1,NCON_work - ICC(I)=I - ENDDO - WRITE (iout,'(A80)') TITEL - t1=tcpu() -C -C CALCULATE DISTANCES -C - call daread_ccoords(1,ncon_work) - ind1=0 - DO I=1,NCON_work-1 - if (mod(i,100).eq.0) print *,'Calculating RMS i=',i - do k=1,2*nres - do l=1,3 - c(l,k)=allcart(l,k,i) - enddo - enddo - do k=1,nres - do l=1,3 - cref(l,k)=c(l,k) - enddo - enddo - DO J=I+1,NCON_work - IND=IOFFSET(NCON_work,I,J) -#ifdef MPI - if (ind.ge.indstart(me) .and. ind.le.indend(me)) then -#endif - ind1=ind1+1 - DISS(IND1)=DIFCONF(I,J) -c write (iout,'(2i4,i10,f10.5)') i,j,ind,DISS(IND) -#ifdef MPI - endif -#endif - ENDDO - ENDDO - t2=tcpu() - WRITE (iout,'(/a,1pe14.5,a/)') - & 'Time for distance calculation:',T2-T1,' sec.' - t1=tcpu() - PRINT '(a)','End of distance computation' - -#ifdef MPI - call MPI_Gatherv(diss(1),scount(me),MPI_REAL,diss(1), - & scount(0),idispl(0),MPI_REAL,Master,MPI_COMM_WORLD, IERROR) - if (me.eq.master) then -#endif - open(80,file='/tmp/distance',form='unformatted') - do i=1,ndis - write(80) diss(i) - enddo - if (punch_dist) then - do i=1,ncon_work-1 - do j=i+1,ncon_work - IND=IOFFSET(NCON,I,J) - write (jrms,'(2i5,2f10.5)') i,j,diss(IND), - & energy(j)-energy(i) - enddo - enddo - endif -C -C Print out the RMS deviation matrix. -C - if (print_dist) CALL DISTOUT(NCON_work) -C -C call hierarchical clustering HC from F. Murtagh -C - N=NCON_work - LEN = (N*(N-1))/2 - write(iout,*) "-------------------------------------------" - write(iout,*) "HIERARCHICAL CLUSTERING using" - if (iopt.eq.1) then - write(iout,*) "WARD'S MINIMUM VARIANCE METHOD" - elseif (iopt.eq.2) then - write(iout,*) "SINGLE LINK METHOD" - elseif (iopt.eq.3) then - write(iout,*) "COMPLETE LINK METHOD" - elseif (iopt.eq.4) then - write(iout,*) "AVERAGE LINK (OR GROUP AVERAGE) METHOD" - elseif (iopt.eq.5) then - write(iout,*) "MCQUITTY'S METHOD" - elseif (iopt.eq.6) then - write(iout,*) "MEDIAN (GOWER'S) METHOD" - elseif (iopt.eq.7) then - write(iout,*) "CENTROID METHOD" - else - write(iout,*) "IOPT=",iopt," IS INVALID, use 1-7" - write(*,*) "IOPT=",iopt," IS INVALID, use 1-7" - stop - endif - write(iout,*) - write(iout,*) "hc.f by F. Murtagh, ESA/ESO/STECF, Garching" - write(iout,*) "February 1986" - write(iout,*) "References:" - write(iout,*) "1. Multidimensional clustering algorithms" - write(iout,*) " Fionn Murtagh" - write(iout,*) " Vienna : Physica-Verlag, 1985." - write(iout,*) "2. Multivariate data analysis" - write(iout,*) " Fionn Murtagh and Andre Heck" - write(iout,*) " Kluwer Academic Publishers, 1987" - write(iout,*) "-------------------------------------------" - write(iout,*) - -#ifdef DEBUG - write (iout,*) "The TOTFREE array" - do i=1,ncon_work - write (iout,'(2i5,f10.5)') i,list_conf(i),totfree(i) - enddo -#endif - call flush(iout) - CALL HC(N,M,LEN,IOPT,IA,IB,CRIT,MEMBR,NN,DISNN,FLAG,DISS) - LEV = N-1 - write (iout,*) "n",n," ncon_work",ncon_work," lev",lev - if (lev.lt.2) then - write (iout,*) "Too few conformations to cluster." - goto 192 - endif - CALL HCASS(N,IA,IB,CRIT,LEV,ICLASS,HVALS,IORDER,CRITVAL,HEIGHT) -c CALL HCDEN(LEV,IORDER,HEIGHT,CRITVAL) - - do i=1,maxgr - licz(i)=0 - enddo - icut=1 - i=1 - NGR=i+1 - do j=1,n - licz(iclass(j,i))=licz(iclass(j,i))+1 - nconf(iclass(j,i),licz(iclass(j,i)))=j -c write (iout,*) i,j,iclass(j,i),licz(iclass(j,i)), -c & nconf(iclass(j,i),licz(iclass(j,i))) - enddo - do i=1,lev-1 - - idum=lev-i - DO L=1,LEV - IF (HEIGHT(L).EQ.IDUM) GOTO 190 - ENDDO - 190 IDUM=L - write(IOUT,*) "i+1",i+1," idum",idum," critval",CRITVAL(IDUM), - & " icut",icut," cutoff",rcutoff(icut) - IF (CRITVAL(IDUM).LT. RCUTOFF(ICUT)) THEN - WRITE (iout,'(/a,f10.5)') 'AT CUTOFF:',rcutoff(icut) - write (iout,'(a,f8.2)') 'Maximum distance found:', - & CRITVAL(IDUM) - CALL SRTCLUST(ICUT,ncon_work,iT) - CALL TRACK(ICUT) - CALL WRTCLUST(ncon_work,ICUT,PRINTANG,PRINTPDB,PRINTMOL2,iT) - icut=icut+1 - if (icut.gt.ncut) goto 191 - ENDIF - NGR=i+1 - do l=1,maxgr - licz(l)=0 - enddo - do j=1,n - licz(iclass(j,i))=licz(iclass(j,i))+1 - nconf(iclass(j,i),licz(iclass(j,i)))=j -c write (iout,*) i,j,iclass(j,i),licz(iclass(j,i)), -c & nconf(iclass(j,i),licz(iclass(j,i))) -cd print *,j,iclass(j,i), -cd & licz(iclass(j,i)),nconf(iclass(j,i),licz(iclass(j,i))) - enddo - enddo - 191 continue -C - if (plot_tree) then - CALL WRITRACK - CALL PLOTREE - endif -C - t2=tcpu() - WRITE (iout,'(/a,1pe14.5,a/)') - & 'Total time for clustering:',T2-T1,' sec.' - -#ifdef MPI - endif -#endif - 192 continue - enddo -C - close(icbase,status="delete") -#ifdef MPI - call MPI_Finalize(MPI_COMM_WORLD,IERROR) -#endif - stop '********** Program terminated normally.' - 20 write (iout,*) "Error reading coordinates" -#ifdef MPI - call MPI_Finalize(MPI_COMM_WORLD,IERROR) -#endif - stop - 30 write (iout,*) "Error reading reference structure" -#ifdef MPI - call MPI_Finalize(MPI_COMM_WORLD,IERROR) -#endif - stop - end -c--------------------------------------------------------------------------- - double precision function difconf(icon,jcon) - implicit none - include 'DIMENSIONS' - include 'sizesclu.dat' - include 'COMMON.CONTROL' - include 'COMMON.CLUSTER' - include 'COMMON.CHAIN' - include 'COMMON.INTERACT' - include 'COMMON.VAR' - include 'COMMON.IOUNITS' - logical non_conv - double precision przes(3),obrot(3,3) - double precision xx(3,maxres2),yy(3,maxres2) - integer i,ii,j,icon,jcon,kkk,nperm,chalen,zzz - integer iaperm,ibezperm,run - double precision rms,rmsmina -c write (iout,*) "tu dochodze" - rmsmina=10d10 - nperm=1 - do i=1,symetr - nperm=i*nperm - enddo -c write (iout,*) "nperm",nperm - call permut(symetr) -c write (iout,*) "tabperm", tabperm(1,1) - do kkk=1,nperm - if (lside) then - ii=0 - chalen=int((nend-nstart+2)/symetr) - do run=1,symetr - do i=nstart,(nstart+chalen-1) - zzz=tabperm(kkk,run) -c write (iout,*) "tutaj",zzz - ii=ii+1 - iaperm=(zzz-1)*chalen+i - ibezperm=(run-1)*chalen+i - do j=1,3 - xx(j,ii)=allcart(j,iaperm,jcon) - yy(j,ii)=cref(j,ibezperm) - enddo - enddo - enddo - do run=1,symetr - do i=nstart,(nstart+chalen-1) - zzz=tabperm(kkk,run) - ii=ii+1 - iaperm=(zzz-1)*chalen+i - ibezperm=(run-1)*chalen+i -c if (itype(i).ne.10) then - ii=ii+1 - do j=1,3 - xx(j,ii)=allcart(j,iaperm+nres,jcon) - yy(j,ii)=cref(j,ibezperm+nres) - enddo - enddo -c endif - enddo - call fitsq(rms,xx(1,1),yy(1,1),ii,przes,obrot,non_conv) - else - chalen=int((nct-nnt+2)/symetr) - do run=1,symetr - do i=nnt,(nnt+chalen-1) - zzz=tabperm(kkk,run) -c write (iout,*) "tu szukaj", zzz,run,kkk - iaperm=(zzz-1)*chalen+i - ibezperm=(run-1)*chalen+i -c do i=nnt,nct - do j=1,3 - c(j,i)=allcart(j,iaperm,jcon) - enddo - enddo - enddo - call fitsq(rms,c(1,nstart),cref(1,nstart),nend-nstart+1,przes, - & obrot,non_conv) - endif - if (rms.lt.0.0) then - print *,'error, rms^2 = ',rms,icon,jcon - stop - endif - if (non_conv) print *,non_conv,icon,jcon - if (rmsmina.gt.rms) rmsmina=rms - enddo - difconf=dsqrt(rmsmina) - RETURN - END -C------------------------------------------------------------------------------ - subroutine distout(ncon) - implicit none - include 'DIMENSIONS' - include 'sizesclu.dat' - integer ncol,ncon - parameter (ncol=10) - include 'COMMON.IOUNITS' - include 'COMMON.CLUSTER' - integer i,j,k,jlim,jlim1,nlim,ind,ioffset - real*4 b - dimension b(ncol) - write (iout,'(a)') 'The distance matrix' - do 1 i=1,ncon,ncol - nlim=min0(i+ncol-1,ncon) - write (iout,1000) (k,k=i,nlim) - write (iout,'(8h--------,10a)') ('-------',k=i,nlim) - 1000 format (/8x,10(i4,3x)) - 1020 format (/1x,80(1h-)/) - do 2 j=i,ncon - jlim=min0(j,nlim) - if (jlim.eq.j) then - b(jlim-i+1)=0.0d0 - jlim1=jlim-1 - else - jlim1=jlim - endif - do 3 k=i,jlim1 - if (j.lt.k) then - IND=IOFFSET(NCON,j,k) - else - IND=IOFFSET(NCON,k,j) - endif - 3 b(k-i+1)=diss(IND) - write (iout,1010) j,(b(k),k=1,jlim-i+1) - 2 continue - 1 continue - 1010 format (i5,3x,10(f6.2,1x)) - return - end diff --git a/source/cluster/wham/src-M/bakup/permut.f b/source/cluster/wham/src-M/bakup/permut.f deleted file mode 100644 index 40cdccb..0000000 --- a/source/cluster/wham/src-M/bakup/permut.f +++ /dev/null @@ -1,60 +0,0 @@ - subroutine permut(isym) - implicit real*8 (a-h,o-z) - include 'DIMENSIONS' - include 'COMMON.LOCAL' - include 'COMMON.VAR' - include 'COMMON.CHAIN' - include 'COMMON.INTERACT' - include 'COMMON.IOUNITS' - include 'COMMON.GEO' - include 'COMMON.NAMES' - include 'COMMON.CONTROL' -c include 'COMMON.DISTFIT' -c include 'COMMON.SETUP' - integer n,a - logical nextp - external nextp - dimension a(isym) -c parameter(n=symetr) - n=isym - kkk=0 - do i=1,n - a(i)=i - enddo - 10 print *,(a(i),i=1,n) - kkk=kkk+1 - do i=1,n - tabperm(kkk,i)=a(i) -c write (iout,*) "tututu", kkk - enddo - if(nextp(n,a)) go to 10 - end - - function nextp(n,a) - integer n,a,i,j,k,t - logical nextp - dimension a(n) - i=n-1 - 10 if(a(i).lt.a(i+1)) go to 20 - i=i-1 - if(i.eq.0) go to 20 - go to 10 - 20 j=i+1 - k=n - 30 t=a(j) - a(j)=a(k) - a(k)=t - j=j+1 - k=k-1 - if(j.lt.k) go to 30 - j=i - if(j.ne.0) go to 40 - nextp=.false. - return - 40 j=j+1 - if(a(j).lt.a(i)) go to 40 - t=a(i) - a(i)=a(j) - a(j)=t - nextp=.true. - end diff --git a/source/cluster/wham/src-M/bakup/probabl.F b/source/cluster/wham/src-M/bakup/probabl.F deleted file mode 100644 index 12bf0a0..0000000 --- a/source/cluster/wham/src-M/bakup/probabl.F +++ /dev/null @@ -1,308 +0,0 @@ - subroutine probabl(ib,nlist,ncon,*) -! construct the conformational ensembles at REMD temperatures - implicit none - include "DIMENSIONS" - include "sizesclu.dat" -#ifdef MPI - include "mpif.h" - include "COMMON.MPI" - integer ierror,errcode,status(MPI_STATUS_SIZE) -#endif - include "COMMON.IOUNITS" - include "COMMON.FREE" - include "COMMON.FFIELD" - include "COMMON.INTERACT" - include "COMMON.SBRIDGE" - include "COMMON.CHAIN" - include "COMMON.CLUSTER" - real*4 csingle(3,maxres2) - double precision fT(6),fTprim(6),fTbis(6),quot,quotl1,quotl,kfacl, - & eprim,ebis,temper,kfac/2.4d0/,T0/300.0d0/ - double precision etot,evdw,evdw2,ees,evdw1,ebe,etors,escloc, - & ehpb,ecorr,ecorr5,ecorr6,eello_turn4,eello_turn3, - & eturn6,eel_loc,edihcnstr,etors_d,estr,evdw2_14,esccor, - & evdw_t - integer i,ii,ik,iproc,iscor,j,k,l,ib,nlist,ncon - double precision qfree,sumprob,eini,efree,rmsdev - character*80 bxname - character*2 licz1 - character*5 ctemper - integer ilen - external ilen - real*4 Fdimless(maxconf) - double precision energia(0:max_ene) - do i=1,ncon - list_conf(i)=i - enddo -c do i=1,ncon -c write (iout,*) i,list_conf(i) -c enddo -#ifdef MPI - write (iout,*) me," indstart",indstart(me)," indend",indend(me) - call daread_ccoords(indstart(me),indend(me)) -#endif -c write (iout,*) "ncon",ncon - temper=1.0d0/(beta_h(ib)*1.987D-3) -c write (iout,*) "ib",ib," beta_h",beta_h(ib)," temper",temper -c quot=1.0d0/(T0*beta_h(ib)*1.987D-3) -c quotl=1.0d0 -c kfacl=1.0d0 -c do l=1,5 -c quotl1=quotl -c quotl=quotl*quot -c kfacl=kfacl*kfac -c fT(l)=kfacl/(kfacl-1.0d0+quotl) -c enddo - if (rescale_mode.eq.1) then - quot=1.0d0/(T0*beta_h(ib)*1.987D-3) - quotl=1.0d0 - kfacl=1.0d0 - do l=1,5 - quotl1=quotl - quotl=quotl*quot - kfacl=kfacl*kfac - fT(l)=kfacl/(kfacl-1.0d0+quotl) - enddo -#if defined(FUNCTH) - ft(6)=(320.0d0+80.0d0*dtanh((betaT-320.0d0)/80.0d0))/ - & 320.0d0 - ftprim(6)=1.0d0/(320.0d0*dcosh((betaT-320.0d0)/80.0d0)**2) - ftbis(6)=-2.0d0*dtanh((betaT-320.0d0)/80.0d0) - & /(320.0d0*80.0d0*dcosh((betaT-320.0d0)/80.0d0)**3) -#elif defined(FUNCT) - fT(6)=betaT/T0 - ftprim(6)=1.0d0/T0 - ftbis(6)=0.0d0 -#else - fT(6)=1.0d0 - ftprim(6)=0.0d0 - ftbis(6)=0.0d0 -#endif - - else if (rescale_mode.eq.2) then - quot=1.0d0/(T0*beta_h(ib)*1.987D-3) - quotl=1.0d0 - do l=1,5 - quotl=quotl*quot - fT(l)=1.12692801104297249644d0/ - & dlog(dexp(quotl)+dexp(-quotl)) - enddo -c write (iout,*) 1.0d0/(beta_h(ib)*1.987D-3),ft - call flush(iout) -#if defined(FUNCTH) - ft(6)=(320.0d0+80.0d0*dtanh((betaT-320.0d0)/80.0d0))/ - & 320.0d0 - ftprim(6)=1.0d0/(320.0d0*dcosh((betaT-320.0d0)/80.0d0)**2) - ftbis(6)=-2.0d0*dtanh((betaT-320.0d0)/80.0d0) - & /(320.0d0*80.0d0*dcosh((betaT-320.0d0)/80.0d0)**3) -#elif defined(FUNCT) - fT(6)=betaT/T0 - ftprim(6)=1.0d0/T0 - ftbis(6)=0.0d0 -#else - fT(6)=1.0d0 - ftprim(6)=0.0d0 - ftbis(6)=0.0d0 -#endif - endif - -#ifdef MPI - do i=1,scount(me) - ii=i+indstart(me)-1 -#else - do i=1,ncon - ii=i -#endif -c write (iout,*) "i",i," ii",ii - call flush(iout) - if (ib.eq.1) then - do j=1,nres - do k=1,3 - c(k,j)=allcart(k,j,i) - c(k,j+nres)=allcart(k,j+nres,i) - enddo - enddo - do k=1,3 - c(k,nres+1)=c(k,1) - c(k,nres+nres)=c(k,nres) - enddo - nss=nss_all(i) - do j=1,nss - ihpb(j)=ihpb_all(j,i) - jhpb(j)=jhpb_all(j,i) - enddo - call int_from_cart1(.false.) - call etotal(energia(0),fT) - totfree(i)=energia(0) -c write (iout,'(8f10.5)') ((c(l,k),l=1,3),k=1,nres) -c write (iout,'(8f10.5)') ((c(l,k+nres),l=1,3),k=nnt,nct) -c call enerprint(energia(0),fT) -c call pdbout(totfree(i),16,i) -#ifdef DEBUG - write (iout,*) i," energia",(energia(j),j=0,19) - write (iout,*) "etot", etot - write (iout,*) "ft(6)", ft(6) -#endif - do k=1,max_ene - enetb(k,i)=energia(k) - enddo - endif - evdw=enetb(1,i) - write (iout,*) evdw - etot=energia(0) -#ifdef SCP14 - evdw2_14=enetb(17,i) - evdw2=enetb(2,i)+evdw2_14 -#else - evdw2=enetb(2,i) - evdw2_14=0.0d0 -#endif -#ifdef SPLITELE - ees=enetb(3,i) - evdw1=enetb(16,i) -#else - ees=enetb(3,i) - evdw1=0.0d0 -#endif - ecorr=enetb(4,i) - ecorr5=enetb(5,i) - ecorr6=enetb(6,i) - eel_loc=enetb(7,i) - eello_turn3=enetb(8,i) - eello_turn4=enetb(9,i) - eturn6=enetb(10,i) - ebe=enetb(11,i) - escloc=enetb(12,i) - etors=enetb(13,i) - etors_d=enetb(14,i) - ehpb=enetb(15,i) - estr=enetb(18,i) - esccor=enetb(19,i) - edihcnstr=enetb(20,i) -c#ifdef SPLITELE -c etot=wsc*(evdw+ft(6)*evdw_t)+wscp*evdw2+ -c &ft(1)*welec*ees+wvdwpp*evdw1 -c & +wang*ebe+ft(1)*wtor*etors+wscloc*escloc -c & +wstrain*ehpb+nss*ebr+ft(3)*wcorr*ecorr+ft(4)*wcorr5*ecorr5 -c & +ft(5)*wcorr6*ecorr6+ft(3)*wturn4*eello_turn4 -c & +ft(2)*wturn3*eello_turn3 -c & +ft(5)*wturn6*eturn6+ft(2)*wel_loc*eel_loc -c & +edihcnstr+ft(2)*wtor_d*etors_d+ft(1)*wsccor*esccor -c & +wbond*estr -c#else -c etot=wsc*(evdw+ft(6)*evdw_t)+wscp*evdw2+ft(1)*welec*(ees+evdw1) -c & +wang*ebe+ft(1)*wtor*etors+wscloc*escloc -c & +wstrain*ehpb+nss*ebr+ft(3)*wcorr*ecorr+ft(4)*wcorr5*ecorr5 -c & +ft(5)*wcorr6*ecorr6+ft(3)*wturn4*eello_turn4 -c & +ft(2)*wturn3*eello_turn3 -c & +ft(5)*wturn6*eturn6+ft(2)*wel_loc*eel_loc+edihcnstr -c & +ft(2)*wtor_d*etors_d+ft(1)*wsccor*esccor -c & +wbond*estr -c#endif -#ifdef DEBUG - write (iout,*) "etot2", etot - write (iout,*) "evdw", wsc, evdw,evdw_t - write (iout,*) "evdw2", wscp, evdw2 - write (iout,*) "welec", ft(1),welec,ees - write (iout,*) "evdw1", wvdwpp,evdw1 - write (iout,*) "ebe" ebe,wang -#endif - Fdimless(i)=beta_h(ib)*etot+entfac(ii) - totfree(i)=etot -#ifdef DEBUG - write (iout,*) "fdim calc", i,ii,ib, - & 1.0d0/(1.987d-3*beta_h(ib)),totfree(i), - & entfac(ii),Fdimless(i) -#endif - enddo ! i -#ifdef MPI - call MPI_Gatherv(Fdimless(1),scount(me), - & MPI_REAL,Fdimless(1), - & scount(0),idispl(0),MPI_REAL,Master, - & MPI_COMM_WORLD, IERROR) - call MPI_Gatherv(totfree(1),scount(me), - & MPI_DOUBLE_PRECISION,totfree(1), - & scount(0),idispl(0),MPI_DOUBLE_PRECISION,Master, - & MPI_COMM_WORLD, IERROR) - call MPI_Gatherv(entfac(indstart(me)+1),scount(me), - & MPI_DOUBLE_PRECISION,entfac(1), - & scount(0),idispl(0),MPI_DOUBLE_PRECISION,Master, - & MPI_COMM_WORLD, IERROR) - if (me.eq.Master) then -#endif -#ifdef DEBUG - write (iout,*) "The FDIMLESS array before sorting" - do i=1,ncon - write (iout,*) i,fdimless(i) - enddo -#endif - call mysort1(ncon,Fdimless,list_conf) -#ifdef DEBUG - write (iout,*) "The FDIMLESS array after sorting" - do i=1,ncon - write (iout,*) i,list_conf(i),fdimless(i) - enddo -#endif - do i=1,ncon - totfree(i)=fdimless(i) - enddo - qfree=0.0d0 - do i=1,ncon - qfree=qfree+exp(-fdimless(i)+fdimless(1)) - write (iout,*) "fdimless", fdimless(i) - enddo - write (iout,*) "qfree",qfree - nlist=1 - sumprob=0.0 - write (iout,*) "ncon", ncon,maxstr_proc - do i=1,min0(ncon,maxstr_proc)-1 - sumprob=sumprob+exp(-fdimless(i)+fdimless(1))/qfree -#ifdef DEBUG - write (iout,*) i,ib,beta_h(ib), - & 1.0d0/(1.987d-3*beta_h(ib)),list_conf(i), - & totfree(list_conf(i)), - & -entfac(list_conf(i)),fdimless(i),sumprob -#endif - if (sumprob.gt.prob_limit) goto 122 -c if (sumprob.gt.1.00d0) goto 122 - nlist=nlist+1 - enddo - 122 continue -#ifdef MPI - endif - call MPI_Bcast(nlist, 1, MPI_INTEGER, Master, MPI_COMM_WORLD, - & IERROR) - call MPI_Bcast(list_conf,nlist,MPI_INTEGER,Master,MPI_COMM_WORLD, - & IERROR) -c do iproc=0,nprocs -c write (iout,*) "iproc",iproc," indstart",indstart(iproc), -c & " indend",indend(iproc) -c enddo - write (iout,*) "nlist",nlist -#endif - return - end -!-------------------------------------------------- - subroutine mysort1(n, x, ipermut) - implicit none - integer i,j,imax,ipm,n - real x(n) - integer ipermut(n) - real xtemp - do i=1,n - xtemp=x(i) - imax=i - do j=i+1,n - if (x(j).lt.xtemp) then - imax=j - xtemp=x(j) - endif - enddo - x(imax)=x(i) - x(i)=xtemp - ipm=ipermut(imax) - ipermut(imax)=ipermut(i) - ipermut(i)=ipm - enddo - return - end diff --git a/source/cluster/wham/src-M/bakup/read_coords.F b/source/cluster/wham/src-M/bakup/read_coords.F deleted file mode 100644 index f177ab1..0000000 --- a/source/cluster/wham/src-M/bakup/read_coords.F +++ /dev/null @@ -1,721 +0,0 @@ - subroutine read_coords(ncon,*) - implicit none - include "DIMENSIONS" - include "sizesclu.dat" -#ifdef MPI - include "mpif.h" - integer IERROR,ERRCODE,STATUS(MPI_STATUS_SIZE) - include "COMMON.MPI" -#endif - include "COMMON.CONTROL" - include "COMMON.CHAIN" - include "COMMON.INTERACT" - include "COMMON.IOUNITS" - include "COMMON.VAR" - include "COMMON.SBRIDGE" - include "COMMON.GEO" - include "COMMON.CLUSTER" - character*3 liczba - integer ncon - integer i,j,jj,jjj,jj_old,icount,k,kk,l,ii,if,ib, - & nn,nn1,inan - integer ixdrf,iret,itmp - real*4 prec,reini,refree,rmsdev - integer nrec,nlines,iscor,lenrec,lenrec_in - double precision energ,t_acq,tcpu - integer ilen,iroof - external ilen,iroof - double precision rjunk - integer ntot_all(0:maxprocs-1) - logical lerr - double precision energia(0:max_ene),etot - real*4 csingle(3,maxres2+2) - integer Previous,Next - character*256 bprotfiles -c print *,"Processor",me," calls read_protein_data" -#ifdef MPI - if (me.eq.master) then - Previous=MPI_PROC_NULL - else - Previous=me-1 - endif - if (me.eq.nprocs-1) then - Next=MPI_PROC_NULL - else - Next=me+1 - endif -c Set the scratchfile names - write (liczba,'(bz,i3.3)') me -#endif -c 1/27/05 AL Change stored coordinates to single precision and don't store -c energy components in the binary databases. - lenrec=12*(nres+nct-nnt+1)+4*(2*nss+2)+16 - lenrec_in=12*(nres+nct-nnt+1)+4*(2*nss+2)+24 -#ifdef DEBUG - write (iout,*) "nres",nres," nnt",nnt," nct",nct," nss", nss - write (iout,*) "lenrec_in",lenrec_in -#endif - bprotfiles=scratchdir(:ilen(scratchdir))// - & "/"//prefix(:ilen(prefix))//liczba//".xbin" - -#ifdef CHUJ - ICON=1 - 123 continue - if (from_cart .and. .not. from_bx .and. .not. from_cx) then - if (efree) then - read (intin,*,end=13,err=11) energy(icon),totfree(icon), - & rmstb(icon), - & nss_all(icon),(ihpb_all(ii,icon),jhpb_all(i,icon), - & i=1,nss_all(icon)),iscore(icon) - else - read (intin,*,end=13,err=11) energy(icon),rmstb(icon), - & nss_all(icon),(ihpb_all(ii,icon),jhpb_all(i,icon), - & i=1,nss_all(icon)),iscore(icon) - endif - read (intin,'(8f10.5)',end=13,err=10) - & ((allcart(j,i,icon),j=1,3),i=1,nres), - & ((allcart(j,i+nres,icon),j=1,3),i=nnt,nct) - print *,icon,energy(icon),nss_all(icon),rmstb(icon) - else - read(intin,'(a80)',end=13,err=12) lineh - read(lineh(:5),*,err=8) ic - if (efree) then - read(lineh(6:),*,err=8) energy(icon) - else - read(lineh(6:),*,err=8) energy(icon) - endif - goto 9 - 8 ic=1 - print *,'error, assuming e=1d10',lineh - energy(icon)=1d10 - nss=0 - 9 continue -cold read(lineh(18:),*,end=13,err=11) nss_all(icon) - ii = index(lineh(15:)," ")+15 - read(lineh(ii:),*,end=13,err=11) nss_all(icon) - IF (NSS_all(icon).LT.9) THEN - read (lineh(20:),*,end=102) - & (IHPB_all(I,icon),JHPB_all(I,icon),I=1,NSS_all(icon)), - & iscore(icon) - ELSE - read (lineh(20:),*,end=102) - & (IHPB_all(I,icon),JHPB_all(I,icon),I=1,8) - read (intin,*) (IHPB_all(I,icon),JHPB_all(I,icon), - & I=9,NSS_all(icon)),iscore(icon) - ENDIF - - 102 continue - - PRINT *,'IC:',IC,' ENERGY:',ENERGY(ICON) - call read_angles(intin,*13) - do i=1,nres - phiall(i,icon)=phi(i) - thetall(i,icon)=theta(i) - alphall(i,icon)=alph(i) - omall(i,icon)=omeg(i) - enddo - endif - ICON=ICON+1 - GOTO 123 -C -C CALCULATE DISTANCES -C - 10 print *,'something wrong with angles' - goto 13 - 11 print *,'something wrong with NSS',nss - goto 13 - 12 print *,'something wrong with header' - - 13 NCON=ICON-1 - -#endif - call flush(iout) - jj_old=1 - open (icbase,file=bprotfiles,status="unknown", - & form="unformatted",access="direct",recl=lenrec) -c Read conformations from binary DA files (one per batch) and write them to -c a binary DA scratchfile. - jj=0 - jjj=0 -#ifdef MPI - write (liczba,'(bz,i3.3)') me - IF (ME.EQ.MASTER) THEN -c Only the master reads the database; it'll send it to the other procs -c through a ring. -#endif - t_acq = tcpu() - icount=0 - - if (from_bx) then - - open (intin,file=intinname,status="old",form="unformatted", - & access="direct",recl=lenrec_in) - - else if (from_cx) then -#if (defined(AIX) && !defined(JUBL)) - call xdrfopen_(ixdrf,intinname, "r", iret) -#else - call xdrfopen(ixdrf,intinname, "r", iret) -#endif - prec=10000.0 - write (iout,*) "xdrfopen: iret",iret - if (iret.eq.0) then - write (iout,*) "Error: coordinate file ", - & intinname(:ilen(intinname))," does not exist." - call flush(iout) -#ifdef MPI - call MPI_ABORT(MPI_COMM_WORLD,IERROR,ERRCODE) -#endif - stop - endif - else - write (iout,*) "Error: coordinate format not specified" - call flush(iout) -#ifdef MPI - call MPI_ABORT(MPI_COMM_WORLD,IERROR,ERRCODE) -#else - stop -#endif - endif - -#define DEBUG -#ifdef DEBUG - write (iout,*) "Opening file ",intinname(:ilen(intinname)) - write (iout,*) "lenrec",lenrec_in - call flush(iout) -#endif -#undef DEBUG -c write (iout,*) "maxconf",maxconf - i=0 - do while (.true.) - i=i+1 - if (i.gt.maxconf) then - write (iout,*) "Error: too many conformations ", - & "(",maxconf,") maximum." -#ifdef MPI - call MPI_Abort(MPI_COMM_WORLD,errcode,ierror) -#endif - stop - endif -c write (iout,*) "i",i -c call flush(iout) - if (from_bx) then - read(intin,err=101,end=101) - & ((csingle(l,k),l=1,3),k=1,nres), - & ((csingle(l,k+nres),l=1,3),k=nnt,nct), - & nss,(ihpb(k),jhpb(k),k=1,nss), - & energy(jj+1), - & entfac(jj+1),rmstb(jj+1),iscor - do j=1,2*nres - do k=1,3 - c(k,j)=csingle(k,j) - enddo - enddo - else -#if (defined(AIX) && !defined(JUBL)) - call xdrf3dfcoord_(ixdrf, csingle, itmp, prec, iret) - if (iret.eq.0) goto 101 - call xdrfint_(ixdrf, nss, iret) - if (iret.eq.0) goto 101 - do j=1,nss - call xdrfint_(ixdrf, ihpb(j), iret) - if (iret.eq.0) goto 101 - call xdrfint_(ixdrf, jhpb(j), iret) - if (iret.eq.0) goto 101 - enddo - call xdrffloat_(ixdrf,reini,iret) - if (iret.eq.0) goto 101 - call xdrffloat_(ixdrf,refree,iret) - if (iret.eq.0) goto 101 - call xdrffloat_(ixdrf,rmsdev,iret) - if (iret.eq.0) goto 101 - call xdrfint_(ixdrf,iscor,iret) - if (iret.eq.0) goto 101 -#else - write (iout,*) "calling xdrf3dfcoord" - call xdrf3dfcoord(ixdrf, csingle, itmp, prec, iret) - write (iout,*) "iret",iret -c call flush(iout) - if (iret.eq.0) goto 101 - call xdrfint(ixdrf, nss, iret) -c write (iout,*) "iret",iret -c write (iout,*) "nss",nss - call flush(iout) - if (iret.eq.0) goto 101 - do k=1,nss - call xdrfint(ixdrf, ihpb(k), iret) - if (iret.eq.0) goto 101 - call xdrfint(ixdrf, jhpb(k), iret) - if (iret.eq.0) goto 101 - enddo - call xdrffloat(ixdrf,reini,iret) - if (iret.eq.0) goto 101 - call xdrffloat(ixdrf,refree,iret) - if (iret.eq.0) goto 101 - call xdrffloat(ixdrf,rmsdev,iret) - if (iret.eq.0) goto 101 - call xdrfint(ixdrf,iscor,iret) - if (iret.eq.0) goto 101 -#endif - energy(jj+1)=reini - entfac(jj+1)=refree - rmstb(jj+1)=rmsdev - do k=1,nres - do l=1,3 - c(l,k)=csingle(l,k) - enddo - enddo - do k=nnt,nct - do l=1,3 - c(l,nres+k)=csingle(l,nres+k-nnt+1) - enddo - enddo - endif -#ifdef DEBUG - write (iout,'(5hREAD ,i5,3f15.4,i10)') - & jj+1,energy(jj+1),entfac(jj+1), - & rmstb(jj+1),iscor - write (iout,*) "Conformation",jjj+1,jj+1 - write (iout,'(8f10.5)') ((c(j,i),j=1,3),i=1,nres) - write (iout,'(8f10.5)') ((c(j,i+nres),j=1,3),i=nnt,nct) - call flush(iout) -#endif - call add_new_cconf(jjj,jj,jj_old,icount,Next) - enddo - 101 continue - write (iout,*) i-1," conformations read from DA file ", - & intinname(:ilen(intinname)) - write (iout,*) jj," conformations read so far" - if (from_bx) then - close(intin) - else -#if (defined(AIX) && !defined(JUBL)) - call xdrfclose_(ixdrf, iret) -#else - call xdrfclose(ixdrf, iret) -#endif - endif -#ifdef MPI -c#ifdef DEBUG - write (iout,*) "jj_old",jj_old," jj",jj -c#endif - call write_and_send_cconf(icount,jj_old,jj,Next) - call MPI_Send(0,1,MPI_INTEGER,Next,570, - & MPI_COMM_WORLD,IERROR) - jj_old=jj+1 -#else - call write_and_send_cconf(icount,jj_old,jj,Next) -#endif - t_acq = tcpu() - t_acq -#ifdef MPI - write (iout,*) "Processor",me, - & " time for conformation read/send",t_acq - ELSE -c A worker gets the confs from the master and sends them to its neighbor - t_acq = tcpu() - call receive_and_pass_cconf(icount,jj_old,jj, - & Previous,Next) - t_acq = tcpu() - t_acq - ENDIF -#endif - ncon=jj -c close(icbase) - close(intin) - - write(iout,*)"A total of",ncon," conformations read." - -#ifdef MPI -c Check if everyone has the same number of conformations - call MPI_Allgather(ncon,1,MPI_INTEGER, - & ntot_all(0),1,MPI_INTEGER,MPI_Comm_World,IERROR) - lerr=.false. - do i=0,nprocs-1 - if (i.ne.me) then - if (ncon.ne.ntot_all(i)) then - write (iout,*) "Number of conformations at processor",i, - & " differs from that at processor",me, - & ncon,ntot_all(i) - lerr = .true. - endif - endif - enddo - if (lerr) then - write (iout,*) - write (iout,*) "Number of conformations read by processors" - write (iout,*) - do i=0,nprocs-1 - write (iout,'(8i10)') i,ntot_all(i) - enddo - write (iout,*) "Calculation terminated." - call flush(iout) - return1 - endif - return -#endif - 1111 write(iout,*) "Error opening coordinate file ", - & intinname(:ilen(intinname)) - call flush(iout) - return1 - end -c------------------------------------------------------------------------------ - subroutine add_new_cconf(jjj,jj,jj_old,icount,Next) - implicit none - include "DIMENSIONS" - include "sizesclu.dat" - include "COMMON.CLUSTER" - include "COMMON.CONTROL" - include "COMMON.CHAIN" - include "COMMON.INTERACT" - include "COMMON.LOCAL" - include "COMMON.IOUNITS" - include "COMMON.NAMES" - include "COMMON.VAR" - include "COMMON.SBRIDGE" - include "COMMON.GEO" - integer i,j,jj,jjj,jj_old,icount,k,kk,l,ii,ib - & nn,nn1,inan,Next,itj,chalen - double precision etot,energia(0:max_ene) - jjj=jjj+1 - chalen=int((nct-nnt+2)/symetr) - call int_from_cart1(.false.) - do j=nnt+1,nct - if (vbld(j).lt.2.0d0 .or. vbld(j).gt.5.0d0) then - if (j.gt.2) then - if (itel(j).ne.0 .and. itel(j-1).ne.0) then - write (iout,*) "Conformation",jjj,jj+1 - write (iout,*) "Bad CA-CA bond length",j," ",vbld(j),itel(j), - & chalen - write (iout,*) "The Cartesian geometry is:" - write (iout,'(8f10.5)') ((c(l,k),l=1,3),k=1,nres) - write (iout,'(8f10.5)') ((c(l,k+nres),l=1,3),k=nnt,nct) - write (iout,*) "The internal geometry is:" - write (iout,'(8f10.4)') (vbld(k),k=nnt+1,nct) - write (iout,'(8f10.4)') (vbld(k),k=nres+nnt,nres+nct) - write (iout,'(8f10.4)') (rad2deg*theta(k),k=3,nres) - write (iout,'(8f10.4)') (rad2deg*phi(k),k=4,nres) - write (iout,'(8f10.4)') (rad2deg*alph(k),k=2,nres-1) - write (iout,'(8f10.4)') (rad2deg*omeg(k),k=2,nres-1) - write (iout,*) - & "This conformation WILL NOT be added to the database." - return - endif - endif - endif - enddo - do j=nnt,nct - itj=itype(j) - if (itype(j).ne.10 .and. (vbld(nres+j)-dsc(itj)).gt.2.0d0) then - write (iout,*) "Conformation",jjj,jj+1 - write (iout,*) "Bad CA-SC bond length",j," ",vbld(nres+j) - write (iout,*) "The Cartesian geometry is:" - write (iout,'(8f10.5)') ((c(l,k),l=1,3),k=1,nres) - write (iout,'(8f10.5)') ((c(l,k+nres),l=1,3),k=nnt,nct) - write (iout,*) "The internal geometry is:" - write (iout,'(8f10.4)') (vbld(k),k=nnt+1,nct) - write (iout,'(8f10.4)') (vbld(k),k=nres+nnt,nres+nct) - write (iout,'(8f10.4)') (rad2deg*theta(k),k=3,nres) - write (iout,'(8f10.4)') (rad2deg*phi(k),k=4,nres) - write (iout,'(8f10.4)') (rad2deg*alph(k),k=2,nres-1) - write (iout,'(8f10.4)') (rad2deg*omeg(k),k=2,nres-1) - write (iout,*) - & "This conformation WILL NOT be added to the database." - return - endif - enddo - do j=3,nres - if (theta(j).le.0.0d0) then - write (iout,*) - & "Zero theta angle(s) in conformation",jjj,jj+1 - write (iout,*) "The Cartesian geometry is:" - write (iout,'(8f10.5)') ((c(l,k),l=1,3),k=1,nres) - write (iout,'(8f10.5)') ((c(l,k+nres),l=1,3),k=nnt,nct) - write (iout,*) "The internal geometry is:" - write (iout,'(8f10.4)') (vbld(k),k=nnt+1,nct) - write (iout,'(8f10.4)') (vbld(k),k=nres+nnt,nres+nct) - write (iout,'(8f10.4)') (rad2deg*theta(k),k=3,nres) - write (iout,'(8f10.4)') (rad2deg*phi(k),k=4,nres) - write (iout,'(8f10.4)') (rad2deg*alph(k),k=2,nres-1) - write (iout,'(8f10.4)') (rad2deg*omeg(k),k=2,nres-1) - write (iout,*) - & "This conformation WILL NOT be added to the database." - return - endif - if (theta(j).gt.179.97*deg2rad) theta(j)=179.97*deg2rad - enddo - jj=jj+1 -#ifdef DEBUG - write (iout,*) "Conformation",jjj,jj - write (iout,'(8f10.5)') ((c(j,i),j=1,3),i=1,nres) - write (iout,'(8f10.5)') ((c(j,i+nres),j=1,3),i=nnt,nct) - write (iout,'(8f10.4)') (vbld(k),k=nnt+1,nct) - write (iout,'(8f10.4)') (vbld(k),k=nres+nnt,nres+nct) - write (iout,'(8f10.4)') (rad2deg*theta(k),k=3,nres) - write (iout,'(8f10.4)') (rad2deg*phi(k),k=4,nres) - write (iout,'(8f10.4)') (vbld(k+nres),k=nnt,nct) - write (iout,'(8f10.4)') (rad2deg*alph(k),k=2,nres-1) - write (iout,'(8f10.4)') (rad2deg*omeg(k),k=2,nres-1) - write (iout,'(16i5)') nss,(ihpb(k),jhpb(k),k=1,nss) - write (iout,'(e15.5,16i5)') entfac(icount+1) -c & iscore(icount+1,0) -#endif - icount=icount+1 - call store_cconf_from_file(jj,icount) - if (icount.eq.maxstr_proc) then -#ifdef DEBUG - write (iout,* ) "jj_old",jj_old," jj",jj -#endif - call write_and_send_cconf(icount,jj_old,jj,Next) - jj_old=jj+1 - icount=0 - endif - return - end -c------------------------------------------------------------------------------ - subroutine store_cconf_from_file(jj,icount) - implicit none - include "DIMENSIONS" - include "sizesclu.dat" - include "COMMON.CLUSTER" - include "COMMON.CHAIN" - include "COMMON.SBRIDGE" - include "COMMON.INTERACT" - include "COMMON.IOUNITS" - include "COMMON.VAR" - integer i,j,jj,icount -c Store the conformation that has been read in - do i=1,2*nres - do j=1,3 - allcart(j,i,icount)=c(j,i) - enddo - enddo - nss_all(icount)=nss - do i=1,nss - ihpb_all(i,icount)=ihpb(i) - jhpb_all(i,icount)=jhpb(i) - enddo - return - end -c------------------------------------------------------------------------------ - subroutine write_and_send_cconf(icount,jj_old,jj,Next) - implicit none - include "DIMENSIONS" - include "sizesclu.dat" -#ifdef MPI - include "mpif.h" - integer IERROR - include "COMMON.MPI" -#endif - include "COMMON.CHAIN" - include "COMMON.SBRIDGE" - include "COMMON.INTERACT" - include "COMMON.IOUNITS" - include "COMMON.CLUSTER" - include "COMMON.VAR" - integer icount,jj_old,jj,Next -c Write the structures to a scratch file -#ifdef MPI -c Master sends the portion of conformations that have been read in to the neighbor -#ifdef DEBUG - write (iout,*) "Processor",me," entered WRITE_AND_SEND_CONF" - call flush(iout) -#endif - call MPI_Send(icount,1,MPI_INTEGER,Next,570,MPI_COMM_WORLD,IERROR) - call MPI_Send(nss_all(1),icount,MPI_INTEGER, - & Next,571,MPI_COMM_WORLD,IERROR) - call MPI_Send(ihpb_all(1,1),icount,MPI_INTEGER, - & Next,572,MPI_COMM_WORLD,IERROR) - call MPI_Send(jhpb_all(1,1),icount,MPI_INTEGER, - & Next,573,MPI_COMM_WORLD,IERROR) - call MPI_Send(rmstb(jj_old),icount,MPI_DOUBLE_PRECISION, - & Next,577,MPI_COMM_WORLD,IERROR) - call MPI_Send(entfac(jj_old),icount,MPI_DOUBLE_PRECISION, - & Next,579,MPI_COMM_WORLD,IERROR) - call MPI_Send(allcart(1,1,1),3*icount*maxres2, - & MPI_REAL,Next,580,MPI_COMM_WORLD,IERROR) -#endif - call dawrite_ccoords(jj_old,jj,icbase) - return - end -c------------------------------------------------------------------------------ -#ifdef MPI - subroutine receive_and_pass_cconf(icount,jj_old,jj,Previous, - & Next) - implicit none - include "DIMENSIONS" - include "sizesclu.dat" - include "mpif.h" - integer IERROR,STATUS(MPI_STATUS_SIZE) - include "COMMON.MPI" - include "COMMON.CHAIN" - include "COMMON.SBRIDGE" - include "COMMON.INTERACT" - include "COMMON.IOUNITS" - include "COMMON.VAR" - include "COMMON.GEO" - include "COMMON.CLUSTER" - integer i,j,k,icount,jj_old,jj,Previous,Next - icount=1 -#ifdef DEBUG - write (iout,*) "Processor",me," entered RECEIVE_AND_PASS_CONF" - call flush(iout) -#endif - do while (icount.gt.0) - call MPI_Recv(icount,1,MPI_INTEGER,Previous,570,MPI_COMM_WORLD, - & STATUS,IERROR) - call MPI_Send(icount,1,MPI_INTEGER,Next,570,MPI_COMM_WORLD, - & IERROR) -#ifdef DEBUG - write (iout,*) "Processor",me," icount",icount -#endif - if (icount.eq.0) return - call MPI_Recv(nss_all(1),icount,MPI_INTEGER, - & Previous,571,MPI_COMM_WORLD,STATUS,IERROR) - call MPI_Send(nss_all(1),icount,MPI_INTEGER, - & Next,571,MPI_COMM_WORLD,IERROR) - call MPI_Recv(ihpb_all(1,1),icount,MPI_INTEGER, - & Previous,572,MPI_COMM_WORLD,STATUS,IERROR) - call MPI_Send(ihpb_all(1,1),icount,MPI_INTEGER, - & Next,572,MPI_COMM_WORLD,IERROR) - call MPI_Recv(jhpb_all(1,1),icount,MPI_INTEGER, - & Previous,573,MPI_COMM_WORLD,STATUS,IERROR) - call MPI_Send(jhpb_all(1,1),icount,MPI_INTEGER, - & Next,573,MPI_COMM_WORLD,IERROR) - call MPI_Recv(rmstb(jj_old),icount,MPI_DOUBLE_PRECISION, - & Previous,577,MPI_COMM_WORLD,STATUS,IERROR) - call MPI_Send(rmstb(jj_old),icount,MPI_DOUBLE_PRECISION, - & Next,577,MPI_COMM_WORLD,IERROR) - call MPI_Recv(entfac(jj_old),icount,MPI_DOUBLE_PRECISION, - & Previous,579,MPI_COMM_WORLD,STATUS,IERROR) - call MPI_Send(entfac(jj_old),icount,MPI_DOUBLE_PRECISION, - & Next,579,MPI_COMM_WORLD,IERROR) - call MPI_Recv(allcart(1,1,1),3*icount*maxres2, - & MPI_REAL,Previous,580,MPI_COMM_WORLD,STATUS,IERROR) - call MPI_Send(allcart(1,1,1),3*icount*maxres2, - & MPI_REAL,Next,580,MPI_COMM_WORLD,IERROR) - jj=jj_old+icount-1 - call dawrite_ccoords(jj_old,jj,icbase) - jj_old=jj+1 -#ifdef DEBUG - write (iout,*) "Processor",me," received",icount," conformations" - do i=1,icount - write (iout,'(8f10.4)') (allcart(l,k,i),l=1,3,k=1,nres) - write (iout,'(8f10.4)')((allcart(l,k,i+nres),l=1,3,k=nnt,nct) - write (iout,'(e15.5,16i5)') entfac(i) - enddo -#endif - enddo - return - end -#endif -c------------------------------------------------------------------------------ - subroutine daread_ccoords(istart_conf,iend_conf) - implicit none - include "DIMENSIONS" - include "sizesclu.dat" -#ifdef MPI - include "mpif.h" - include "COMMON.MPI" -#endif - include "COMMON.CHAIN" - include "COMMON.CLUSTER" - include "COMMON.IOUNITS" - include "COMMON.INTERACT" - include "COMMON.VAR" - include "COMMON.SBRIDGE" - include "COMMON.GEO" - integer istart_conf,iend_conf - integer i,j,ij,ii,iii - integer len - character*16 form,acc - character*32 nam -c -c Read conformations off a DA scratchfile. -c -#ifdef DEBUG - write (iout,*) "DAREAD_COORDS" - write (iout,*) "istart_conf",istart_conf," iend_conf",iend_conf - inquire(unit=icbase,name=nam,recl=len,form=form,access=acc) - write (iout,*) "len=",len," form=",form," acc=",acc - write (iout,*) "nam=",nam - call flush(iout) -#endif - do ii=istart_conf,iend_conf - ij = ii - istart_conf + 1 - iii=list_conf(ii) -#ifdef DEBUG - write (iout,*) "Reading binary file, record",iii," ii",ii - call flush(iout) -#endif - read(icbase,rec=iii) ((allcart(j,i,ij),j=1,3),i=1,nres), - & ((allcart(j,i,ij),j=1,3),i=nnt+nres,nct+nres), - & nss_all(ij),(ihpb_all(i,ij),jhpb_all(i,ij),i=1,nss), - & entfac(ii),rmstb(ii) -#ifdef DEBUG - write (iout,*) ii,iii,ij,entfac(ii) - write (iout,'(8f10.5)') ((allcart(j,i,ij),j=1,3),i=1,nres) - write (iout,'(8f10.4)') ((allcart(j,i,ij),j=1,3), - & i=nnt+nres,nct+nres) - write (iout,'(2e15.5)') entfac(ij) - write (iout,'(16i5)') nss_all(ij),(ihpb_all(i,ij), - & jhpb_all(i,ij),i=1,nss) - call flush(iout) -#endif - enddo - return - end -c------------------------------------------------------------------------------ - subroutine dawrite_ccoords(istart_conf,iend_conf,unit_out) - implicit none - include "DIMENSIONS" - include "sizesclu.dat" -#ifdef MPI - include "mpif.h" - include "COMMON.MPI" -#endif - include "COMMON.CHAIN" - include "COMMON.INTERACT" - include "COMMON.IOUNITS" - include "COMMON.VAR" - include "COMMON.SBRIDGE" - include "COMMON.GEO" - include "COMMON.CLUSTER" - integer istart_conf,iend_conf - integer i,j,ii,ij,iii,unit_out - integer len - character*16 form,acc - character*32 nam -c -c Write conformations to a DA scratchfile. -c -#ifdef DEBUG - write (iout,*) "DAWRITE_COORDS" - write (iout,*) "istart_conf",istart_conf," iend_conf",iend_conf - write (iout,*) "lenrec",lenrec - inquire(unit=unit_out,name=nam,recl=len,form=form,access=acc) - write (iout,*) "len=",len," form=",form," acc=",acc - write (iout,*) "nam=",nam - call flush(iout) -#endif - do ii=istart_conf,iend_conf - iii=list_conf(ii) - ij = ii - istart_conf + 1 -#ifdef DEBUG - write (iout,*) "Writing binary file, record",iii," ii",ii - call flush(iout) -#endif - write(unit_out,rec=iii) ((allcart(j,i,ij),j=1,3),i=1,nres), - & ((allcart(j,i,ij),j=1,3),i=nnt+nres,nct+nres), - & nss_all(ij),(ihpb_all(i,ij),jhpb_all(i,ij),i=1,nss_all(ij)), - & entfac(ii),rmstb(ii) -#ifdef DEBUG - write (iout,'(8f10.5)') ((allcart(j,i,ij),j=1,3),i=1,nres) - write (iout,'(8f10.4)') ((allcart(j,i,ij),j=1,3),i=nnt+nres, - & nct+nres) - write (iout,'(2e15.5)') entfac(ij) - write (iout,'(16i5)') nss_all(ij),(ihpb(i,ij),jhpb(i,ij),i=1, - & nss_all(ij)) - call flush(iout) -#endif - enddo - return - end diff --git a/source/cluster/wham/src-M/obackup/arcos.o b/source/cluster/wham/src-M/obackup/arcos.o deleted file mode 100644 index 21307c7..0000000 Binary files a/source/cluster/wham/src-M/obackup/arcos.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/cartprint.o b/source/cluster/wham/src-M/obackup/cartprint.o deleted file mode 100644 index 8804591..0000000 Binary files a/source/cluster/wham/src-M/obackup/cartprint.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/chainbuild.o b/source/cluster/wham/src-M/obackup/chainbuild.o deleted file mode 100644 index 0fb02c4..0000000 Binary files a/source/cluster/wham/src-M/obackup/chainbuild.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/contact.o b/source/cluster/wham/src-M/obackup/contact.o deleted file mode 100644 index 154457a..0000000 Binary files a/source/cluster/wham/src-M/obackup/contact.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/convert.o b/source/cluster/wham/src-M/obackup/convert.o deleted file mode 100644 index 601e80d..0000000 Binary files a/source/cluster/wham/src-M/obackup/convert.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/energy_p_new.o b/source/cluster/wham/src-M/obackup/energy_p_new.o deleted file mode 100644 index ed59fa4..0000000 Binary files a/source/cluster/wham/src-M/obackup/energy_p_new.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/fitsq.o b/source/cluster/wham/src-M/obackup/fitsq.o deleted file mode 100644 index a451d83..0000000 Binary files a/source/cluster/wham/src-M/obackup/fitsq.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/geomout.o b/source/cluster/wham/src-M/obackup/geomout.o deleted file mode 100644 index af495ba..0000000 Binary files a/source/cluster/wham/src-M/obackup/geomout.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/gnmr1.o b/source/cluster/wham/src-M/obackup/gnmr1.o deleted file mode 100644 index a931348..0000000 Binary files a/source/cluster/wham/src-M/obackup/gnmr1.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/hc.o b/source/cluster/wham/src-M/obackup/hc.o deleted file mode 100644 index d736832..0000000 Binary files a/source/cluster/wham/src-M/obackup/hc.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/icant.o b/source/cluster/wham/src-M/obackup/icant.o deleted file mode 100644 index e8ca025..0000000 Binary files a/source/cluster/wham/src-M/obackup/icant.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/initialize_p.o b/source/cluster/wham/src-M/obackup/initialize_p.o deleted file mode 100644 index 0bd33c0..0000000 Binary files a/source/cluster/wham/src-M/obackup/initialize_p.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/int_from_cart1.o b/source/cluster/wham/src-M/obackup/int_from_cart1.o deleted file mode 100644 index a758a94..0000000 Binary files a/source/cluster/wham/src-M/obackup/int_from_cart1.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/intcor.o b/source/cluster/wham/src-M/obackup/intcor.o deleted file mode 100644 index 05845fb..0000000 Binary files a/source/cluster/wham/src-M/obackup/intcor.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/main_clust.o b/source/cluster/wham/src-M/obackup/main_clust.o deleted file mode 100644 index 6f4ebbc..0000000 Binary files a/source/cluster/wham/src-M/obackup/main_clust.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/matmult.o b/source/cluster/wham/src-M/obackup/matmult.o deleted file mode 100644 index 54ba28b..0000000 Binary files a/source/cluster/wham/src-M/obackup/matmult.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/misc.o b/source/cluster/wham/src-M/obackup/misc.o deleted file mode 100644 index 49c7279..0000000 Binary files a/source/cluster/wham/src-M/obackup/misc.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/noyes.o b/source/cluster/wham/src-M/obackup/noyes.o deleted file mode 100644 index 9e7e13b..0000000 Binary files a/source/cluster/wham/src-M/obackup/noyes.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/parmread.o b/source/cluster/wham/src-M/obackup/parmread.o deleted file mode 100644 index 1d7dfa0..0000000 Binary files a/source/cluster/wham/src-M/obackup/parmread.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/permut.o b/source/cluster/wham/src-M/obackup/permut.o deleted file mode 100644 index d14482c..0000000 Binary files a/source/cluster/wham/src-M/obackup/permut.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/pinorm.o b/source/cluster/wham/src-M/obackup/pinorm.o deleted file mode 100644 index 8ed7f7d..0000000 Binary files a/source/cluster/wham/src-M/obackup/pinorm.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/printmat.o b/source/cluster/wham/src-M/obackup/printmat.o deleted file mode 100644 index bb6d25e..0000000 Binary files a/source/cluster/wham/src-M/obackup/printmat.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/probabl.o b/source/cluster/wham/src-M/obackup/probabl.o deleted file mode 100644 index 51910ea..0000000 Binary files a/source/cluster/wham/src-M/obackup/probabl.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/proc_proc.o b/source/cluster/wham/src-M/obackup/proc_proc.o deleted file mode 100644 index a38ab2d..0000000 Binary files a/source/cluster/wham/src-M/obackup/proc_proc.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/read_coords.o b/source/cluster/wham/src-M/obackup/read_coords.o deleted file mode 100644 index c27b487..0000000 Binary files a/source/cluster/wham/src-M/obackup/read_coords.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/read_ref_str.o b/source/cluster/wham/src-M/obackup/read_ref_str.o deleted file mode 100644 index 07f1195..0000000 Binary files a/source/cluster/wham/src-M/obackup/read_ref_str.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/readpdb.o b/source/cluster/wham/src-M/obackup/readpdb.o deleted file mode 100644 index 8a18195..0000000 Binary files a/source/cluster/wham/src-M/obackup/readpdb.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/readrtns.o b/source/cluster/wham/src-M/obackup/readrtns.o deleted file mode 100644 index 88a19b1..0000000 Binary files a/source/cluster/wham/src-M/obackup/readrtns.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/rescode.o b/source/cluster/wham/src-M/obackup/rescode.o deleted file mode 100644 index 5fa41bf..0000000 Binary files a/source/cluster/wham/src-M/obackup/rescode.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/setup_var.o b/source/cluster/wham/src-M/obackup/setup_var.o deleted file mode 100644 index eec1329..0000000 Binary files a/source/cluster/wham/src-M/obackup/setup_var.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/srtclust.o b/source/cluster/wham/src-M/obackup/srtclust.o deleted file mode 100644 index 2ef4ed5..0000000 Binary files a/source/cluster/wham/src-M/obackup/srtclust.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/timing.o b/source/cluster/wham/src-M/obackup/timing.o deleted file mode 100644 index d186b87..0000000 Binary files a/source/cluster/wham/src-M/obackup/timing.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/track.o b/source/cluster/wham/src-M/obackup/track.o deleted file mode 100644 index 9ab0a26..0000000 Binary files a/source/cluster/wham/src-M/obackup/track.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/work_partition.o b/source/cluster/wham/src-M/obackup/work_partition.o deleted file mode 100644 index 856098e..0000000 Binary files a/source/cluster/wham/src-M/obackup/work_partition.o and /dev/null differ diff --git a/source/cluster/wham/src-M/obackup/wrtclust.o b/source/cluster/wham/src-M/obackup/wrtclust.o deleted file mode 100644 index 2edbf09..0000000 Binary files a/source/cluster/wham/src-M/obackup/wrtclust.o and /dev/null differ diff --git a/source/cluster/wham/src-M/xdrf b/source/cluster/wham/src-M/xdrf new file mode 120000 index 0000000..b320ac0 --- /dev/null +++ b/source/cluster/wham/src-M/xdrf @@ -0,0 +1 @@ +../../../lib/xdrf \ No newline at end of file diff --git a/source/cluster/wham/src-M/xdrf/Makefile b/source/cluster/wham/src-M/xdrf/Makefile deleted file mode 100644 index 02c29f6..0000000 --- a/source/cluster/wham/src-M/xdrf/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# This make file is part of the xdrf package. -# -# (C) 1995 Frans van Hoesel, hoesel@chem.rug.nl -# -# 2006 modified by Cezary Czaplewski - -# Set C compiler and flags for ARCH -CC = gcc -CFLAGS = -O - -M4 = m4 -M4FILE = underscore.m4 - -libxdrf.a: libxdrf.o ftocstr.o - ar cr libxdrf.a $? - -clean: - rm -f libxdrf.o ftocstr.o libxdrf.a - -ftocstr.o: ftocstr.c - $(CC) $(CFLAGS) -c ftocstr.c - -libxdrf.o: libxdrf.m4 $(M4FILE) - $(M4) $(M4FILE) libxdrf.m4 > libxdrf.c - $(CC) $(CFLAGS) -c libxdrf.c - rm -f libxdrf.c - diff --git a/source/cluster/wham/src-M/xdrf/Makefile_jubl b/source/cluster/wham/src-M/xdrf/Makefile_jubl deleted file mode 100644 index 8dc35cf..0000000 --- a/source/cluster/wham/src-M/xdrf/Makefile_jubl +++ /dev/null @@ -1,31 +0,0 @@ -# This make file is part of the xdrf package. -# -# (C) 1995 Frans van Hoesel, hoesel@chem.rug.nl -# -# 2006 modified by Cezary Czaplewski - -# Set C compiler and flags for ARCH -BGLSYS = /bgl/BlueLight/ppcfloor/bglsys - -CC = /usr/bin/blrts_xlc -CPPC = /usr/bin/blrts_xlc - -CFLAGS= -O2 -I$(BGLSYS)/include -L$(BGLSYS)/lib -qarch=440d -qtune=440 - -M4 = m4 -M4FILE = RS6K.m4 - -libxdrf.a: libxdrf.o ftocstr.o xdr_array.o xdr.o xdr_float.o xdr_stdio.o - ar cr libxdrf.a $? - -clean: - rm -f *.o libxdrf.a - -ftocstr.o: ftocstr.c - $(CC) $(CFLAGS) -c ftocstr.c - -libxdrf.o: libxdrf.m4 $(M4FILE) - $(M4) $(M4FILE) libxdrf.m4 > libxdrf.c - $(CC) $(CFLAGS) -c libxdrf.c -# rm -f libxdrf.c - diff --git a/source/cluster/wham/src-M/xdrf/Makefile_linux b/source/cluster/wham/src-M/xdrf/Makefile_linux deleted file mode 100644 index f03276e..0000000 --- a/source/cluster/wham/src-M/xdrf/Makefile_linux +++ /dev/null @@ -1,27 +0,0 @@ -# This make file is part of the xdrf package. -# -# (C) 1995 Frans van Hoesel, hoesel@chem.rug.nl -# -# 2006 modified by Cezary Czaplewski - -# Set C compiler and flags for ARCH -CC = cc -CFLAGS = -O - -M4 = m4 -M4FILE = underscore.m4 - -libxdrf.a: libxdrf.o ftocstr.o - ar cr libxdrf.a $? - -clean: - rm -f libxdrf.o ftocstr.o libxdrf.a - -ftocstr.o: ftocstr.c - $(CC) $(CFLAGS) -c ftocstr.c - -libxdrf.o: libxdrf.m4 $(M4FILE) - $(M4) $(M4FILE) libxdrf.m4 > libxdrf.c - $(CC) $(CFLAGS) -c libxdrf.c - rm -f libxdrf.c - diff --git a/source/cluster/wham/src-M/xdrf/RS6K.m4 b/source/cluster/wham/src-M/xdrf/RS6K.m4 deleted file mode 100644 index 0331d97..0000000 --- a/source/cluster/wham/src-M/xdrf/RS6K.m4 +++ /dev/null @@ -1,20 +0,0 @@ -divert(-1) -undefine(`len') -# -# do nothing special to FORTRAN function names -# -define(`FUNCTION',`$1') -# -# FORTRAN character strings are passed as follows: -# a pointer to the base of the string is passed in the normal -# argument list, and the length is passed by value as an extra -# argument, after all of the other arguments. -# -define(`ARGS',`($1`'undivert(1))') -define(`SAVE',`divert(1)$1`'divert(0)') -define(`STRING_ARG',`$1_ptr`'SAVE(`, $1_len')') -define(`STRING_ARG_DECL',`char * $1_ptr; int $1_len') -define(`STRING_LEN',`$1_len') -define(`STRING_PTR',`$1_ptr') -divert(0) - diff --git a/source/cluster/wham/src-M/xdrf/ftocstr.c b/source/cluster/wham/src-M/xdrf/ftocstr.c deleted file mode 100644 index ed2113f..0000000 --- a/source/cluster/wham/src-M/xdrf/ftocstr.c +++ /dev/null @@ -1,35 +0,0 @@ - - -int ftocstr(ds, dl, ss, sl) - char *ds, *ss; /* dst, src ptrs */ - int dl; /* dst max len */ - int sl; /* src len */ -{ - char *p; - - for (p = ss + sl; --p >= ss && *p == ' '; ) ; - sl = p - ss + 1; - dl--; - ds[0] = 0; - if (sl > dl) - return 1; - while (sl--) - (*ds++ = *ss++); - *ds = '\0'; - return 0; -} - - -int ctofstr(ds, dl, ss) - char *ds; /* dest space */ - int dl; /* max dest length */ - char *ss; /* src string (0-term) */ -{ - while (dl && *ss) { - *ds++ = *ss++; - dl--; - } - while (dl--) - *ds++ = ' '; - return 0; -} diff --git a/source/cluster/wham/src-M/xdrf/libxdrf.a b/source/cluster/wham/src-M/xdrf/libxdrf.a deleted file mode 100644 index 5da5163..0000000 Binary files a/source/cluster/wham/src-M/xdrf/libxdrf.a and /dev/null differ diff --git a/source/cluster/wham/src-M/xdrf/libxdrf.m4 b/source/cluster/wham/src-M/xdrf/libxdrf.m4 deleted file mode 100644 index a6da458..0000000 --- a/source/cluster/wham/src-M/xdrf/libxdrf.m4 +++ /dev/null @@ -1,1238 +0,0 @@ -/*____________________________________________________________________________ - | - | libxdrf - portable fortran interface to xdr. some xdr routines - | are C routines for compressed coordinates - | - | version 1.1 - | - | This collection of routines is intended to write and read - | data in a portable way to a file, so data written on one type - | of machine can be read back on a different type. - | - | all fortran routines use an integer 'xdrid', which is an id to the - | current xdr file, and is set by xdrfopen. - | most routines have in integer 'ret' which is the return value. - | The value of 'ret' is zero on failure, and most of the time one - | on succes. - | - | There are three routines useful for C users: - | xdropen(), xdrclose(), xdr3dfcoord(). - | The first two replace xdrstdio_create and xdr_destroy, and *must* be - | used when you plan to use xdr3dfcoord(). (they are also a bit - | easier to interface). For writing data other than compressed coordinates - | you should use the standard C xdr routines (see xdr man page) - | - | xdrfopen(xdrid, filename, mode, ret) - | character *(*) filename - | character *(*) mode - | - | this will open the file with the given filename (string) - | and the given mode, it returns an id in xdrid, which is - | to be used in all other calls to xdrf routines. - | mode is 'w' to create, or update an file, for all other - | values of mode the file is opened for reading - | - | you need to call xdrfclose to flush the output and close - | the file. - | Note that you should not use xdrstdio_create, which comes with the - | standard xdr library - | - | xdrfclose(xdrid, ret) - | flush the data to the file, and closes the file; - | You should not use xdr_destroy (which comes standard with - | the xdr libraries. - | - | xdrfbool(xdrid, bp, ret) - | integer pb - | - | This filter produces values of either 1 or 0 - | - | xdrfchar(xdrid, cp, ret) - | character cp - | - | filter that translate between characters and their xdr representation - | Note that the characters in not compressed and occupies 4 bytes. - | - | xdrfdouble(xdrid, dp, ret) - | double dp - | - | read/write a double. - | - | xdrffloat(xdrid, fp, ret) - | float fp - | - | read/write a float. - | - | xdrfint(xdrid, ip, ret) - | integer ip - | - | read/write integer. - | - | xdrflong(xdrid, lp, ret) - | integer lp - | - | this routine has a possible portablility problem due to 64 bits longs. - | - | xdrfshort(xdrid, sp, ret) - | integer *2 sp - | - | xdrfstring(xdrid, sp, maxsize, ret) - | character *(*) - | integer maxsize - | - | read/write a string, with maximum length given by maxsize - | - | xdrfwrapstring(xdris, sp, ret) - | character *(*) - | - | read/write a string (it is the same as xdrfstring accept that it finds - | the stringlength itself. - | - | xdrfvector(xdrid, cp, size, xdrfproc, ret) - | character *(*) - | integer size - | external xdrfproc - | - | read/write an array pointed to by cp, with number of elements - | defined by 'size'. the routine 'xdrfproc' is the name - | of one of the above routines to read/write data (like xdrfdouble) - | In contrast with the c-version you don't need to specify the - | byte size of an element. - | xdrfstring is not allowed here (it is in the c version) - | - | xdrf3dfcoord(xdrid, fp, size, precision, ret) - | real (*) fp - | real precision - | integer size - | - | this is *NOT* a standard xdr routine. I named it this way, because - | it invites people to use the other xdr routines. - | It is introduced to store specifically 3d coordinates of molecules - | (as found in molecular dynamics) and it writes it in a compressed way. - | It starts by multiplying all numbers by precision and - | rounding the result to integer. effectively converting - | all floating point numbers to fixed point. - | it uses an algorithm for compression that is optimized for - | molecular data, but could be used for other 3d coordinates - | as well. There is subtantial overhead involved, so call this - | routine only if you have a large number of coordinates to read/write - | - | ________________________________________________________________________ - | - | Below are the routines to be used by C programmers. Use the 'normal' - | xdr routines to write integers, floats, etc (see man xdr) - | - | int xdropen(XDR *xdrs, const char *filename, const char *type) - | This will open the file with the given filename and the - | given mode. You should pass it an allocated XDR struct - | in xdrs, to be used in all other calls to xdr routines. - | Mode is 'w' to create, or update an file, and for all - | other values of mode the file is opened for reading. - | You need to call xdrclose to flush the output and close - | the file. - | - | Note that you should not use xdrstdio_create, which - | comes with the standard xdr library. - | - | int xdrclose(XDR *xdrs) - | Flush the data to the file, and close the file; - | You should not use xdr_destroy (which comes standard - | with the xdr libraries). - | - | int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) - | This is \fInot\fR a standard xdr routine. I named it this - | way, because it invites people to use the other xdr - | routines. - | - | (c) 1995 Frans van Hoesel, hoesel@chem.rug.nl -*/ - - -#include -#include -#include -/* #include -#include */ -#include "xdr.h" -#include -#include -#include "xdrf.h" - -int ftocstr(char *, int, char *, int); -int ctofstr(char *, int, char *); - -#define MAXID 20 -static FILE *xdrfiles[MAXID]; -static XDR *xdridptr[MAXID]; -static char xdrmodes[MAXID]; -static unsigned int cnt; - -typedef void (* FUNCTION(xdrfproc)) (int *, void *, int *); - -void -FUNCTION(xdrfbool) ARGS(`xdrid, pb, ret') -int *xdrid, *ret; -int *pb; -{ - *ret = xdr_bool(xdridptr[*xdrid], (bool_t *) pb); - cnt += sizeof(int); -} - -void -FUNCTION(xdrfchar) ARGS(`xdrid, cp, ret') -int *xdrid, *ret; -char *cp; -{ - *ret = xdr_char(xdridptr[*xdrid], cp); - cnt += sizeof(char); -} - -void -FUNCTION(xdrfdouble) ARGS(`xdrid, dp, ret') -int *xdrid, *ret; -double *dp; -{ - *ret = xdr_double(xdridptr[*xdrid], dp); - cnt += sizeof(double); -} - -void -FUNCTION(xdrffloat) ARGS(`xdrid, fp, ret') -int *xdrid, *ret; -float *fp; -{ - *ret = xdr_float(xdridptr[*xdrid], fp); - cnt += sizeof(float); -} - -void -FUNCTION(xdrfint) ARGS(`xdrid, ip, ret') -int *xdrid, *ret; -int *ip; -{ - *ret = xdr_int(xdridptr[*xdrid], ip); - cnt += sizeof(int); -} - -void -FUNCTION(xdrflong) ARGS(`xdrid, lp, ret') -int *xdrid, *ret; -long *lp; -{ - *ret = xdr_long(xdridptr[*xdrid], lp); - cnt += sizeof(long); -} - -void -FUNCTION(xdrfshort) ARGS(`xdrid, sp, ret') -int *xdrid, *ret; -short *sp; -{ - *ret = xdr_short(xdridptr[*xdrid], sp); - cnt += sizeof(sp); -} - -void -FUNCTION(xdrfuchar) ARGS(`xdrid, ucp, ret') -int *xdrid, *ret; -char *ucp; -{ - *ret = xdr_u_char(xdridptr[*xdrid], ucp); - cnt += sizeof(char); -} - -void -FUNCTION(xdrfulong) ARGS(`xdrid, ulp, ret') -int *xdrid, *ret; -unsigned long *ulp; -{ - *ret = xdr_u_long(xdridptr[*xdrid], ulp); - cnt += sizeof(unsigned long); -} - -void -FUNCTION(xdrfushort) ARGS(`xdrid, usp, ret') -int *xdrid, *ret; -unsigned short *usp; -{ - *ret = xdr_u_short(xdridptr[*xdrid], usp); - cnt += sizeof(unsigned short); -} - -void -FUNCTION(xdrf3dfcoord) ARGS(`xdrid, fp, size, precision, ret') -int *xdrid, *ret; -float *fp; -int *size; -float *precision; -{ - *ret = xdr3dfcoord(xdridptr[*xdrid], fp, size, precision); -} - -void -FUNCTION(xdrfstring) ARGS(`xdrid, STRING_ARG(sp), maxsize, ret') -int *xdrid, *ret; -STRING_ARG_DECL(sp); -int *maxsize; -{ - char *tsp; - - tsp = (char*) malloc(((STRING_LEN(sp)) + 1) * sizeof(char)); - if (tsp == NULL) { - *ret = -1; - return; - } - if (ftocstr(tsp, *maxsize+1, STRING_PTR(sp), STRING_LEN(sp))) { - *ret = -1; - free(tsp); - return; - } - *ret = xdr_string(xdridptr[*xdrid], (char **) &tsp, (u_int) *maxsize); - ctofstr( STRING_PTR(sp), STRING_LEN(sp), tsp); - cnt += *maxsize; - free(tsp); -} - -void -FUNCTION(xdrfwrapstring) ARGS(`xdrid, STRING_ARG(sp), ret') -int *xdrid, *ret; -STRING_ARG_DECL(sp); -{ - char *tsp; - int maxsize; - maxsize = (STRING_LEN(sp)) + 1; - tsp = (char*) malloc(maxsize * sizeof(char)); - if (tsp == NULL) { - *ret = -1; - return; - } - if (ftocstr(tsp, maxsize, STRING_PTR(sp), STRING_LEN(sp))) { - *ret = -1; - free(tsp); - return; - } - *ret = xdr_string(xdridptr[*xdrid], (char **) &tsp, (u_int)maxsize); - ctofstr( STRING_PTR(sp), STRING_LEN(sp), tsp); - cnt += maxsize; - free(tsp); -} - -void -FUNCTION(xdrfopaque) ARGS(`xdrid, cp, ccnt, ret') -int *xdrid, *ret; -caddr_t *cp; -int *ccnt; -{ - *ret = xdr_opaque(xdridptr[*xdrid], (caddr_t)*cp, (u_int)*ccnt); - cnt += *ccnt; -} - -void -FUNCTION(xdrfsetpos) ARGS(`xdrid, pos, ret') -int *xdrid, *ret; -int *pos; -{ - *ret = xdr_setpos(xdridptr[*xdrid], (u_int) *pos); -} - -void -FUNCTION(xdrf) ARGS(`xdrid, pos') -int *xdrid, *pos; -{ - *pos = xdr_getpos(xdridptr[*xdrid]); -} - -void -FUNCTION(xdrfvector) ARGS(`xdrid, cp, size, elproc, ret') -int *xdrid, *ret; -char *cp; -int *size; -FUNCTION(xdrfproc) elproc; -{ - int lcnt; - cnt = 0; - for (lcnt = 0; lcnt < *size; lcnt++) { - elproc(xdrid, (cp+cnt) , ret); - } -} - - -void -FUNCTION(xdrfclose) ARGS(`xdrid, ret') -int *xdrid; -int *ret; -{ - *ret = xdrclose(xdridptr[*xdrid]); - cnt = 0; -} - -void -FUNCTION(xdrfopen) ARGS(`xdrid, STRING_ARG(fp), STRING_ARG(mode), ret') -int *xdrid; -STRING_ARG_DECL(fp); -STRING_ARG_DECL(mode); -int *ret; -{ - char fname[512]; - char fmode[3]; - - if (ftocstr(fname, sizeof(fname), STRING_PTR(fp), STRING_LEN(fp))) { - *ret = 0; - } - if (ftocstr(fmode, sizeof(fmode), STRING_PTR(mode), - STRING_LEN(mode))) { - *ret = 0; - } - - *xdrid = xdropen(NULL, fname, fmode); - if (*xdrid == 0) - *ret = 0; - else - *ret = 1; -} - -/*___________________________________________________________________________ - | - | what follows are the C routines for opening, closing xdr streams - | and the routine to read/write compressed coordinates together - | with some routines to assist in this task (those are marked - | static and cannot be called from user programs) -*/ -#define MAXABS INT_MAX-2 - -#ifndef MIN -#define MIN(x,y) ((x) < (y) ? (x):(y)) -#endif -#ifndef MAX -#define MAX(x,y) ((x) > (y) ? (x):(y)) -#endif -#ifndef SQR -#define SQR(x) ((x)*(x)) -#endif -static int magicints[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8, 10, 12, 16, 20, 25, 32, 40, 50, 64, - 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, - 812, 1024, 1290, 1625, 2048, 2580, 3250, 4096, 5060, 6501, - 8192, 10321, 13003, 16384, 20642, 26007, 32768, 41285, 52015, 65536, - 82570, 104031, 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561, - 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021, 4194304, 5284491, 6658042, - 8388607, 10568983, 13316085, 16777216 }; - -#define FIRSTIDX 9 -/* note that magicints[FIRSTIDX-1] == 0 */ -#define LASTIDX (sizeof(magicints) / sizeof(*magicints)) - - -/*__________________________________________________________________________ - | - | xdropen - open xdr file - | - | This versions differs from xdrstdio_create, because I need to know - | the state of the file (read or write) so I can use xdr3dfcoord - | in eigther read or write mode, and the file descriptor - | so I can close the file (something xdr_destroy doesn't do). - | -*/ - -int xdropen(XDR *xdrs, const char *filename, const char *type) { - static int init_done = 0; - enum xdr_op lmode; - const char *type1; - int xdrid; - - if (init_done == 0) { - for (xdrid = 1; xdrid < MAXID; xdrid++) { - xdridptr[xdrid] = NULL; - } - init_done = 1; - } - xdrid = 1; - while (xdrid < MAXID && xdridptr[xdrid] != NULL) { - xdrid++; - } - if (xdrid == MAXID) { - return 0; - } - if (*type == 'w' || *type == 'W') { - type = "w+"; - type1 = "w+"; - lmode = XDR_ENCODE; - } else if (*type == 'a' || *type == 'A') { - type = "w+"; - type1 = "a+"; - lmode = XDR_ENCODE; - } else { - type = "r"; - type1 = "r"; - lmode = XDR_DECODE; - } - xdrfiles[xdrid] = fopen(filename, type1); - if (xdrfiles[xdrid] == NULL) { - xdrs = NULL; - return 0; - } - xdrmodes[xdrid] = *type; - /* next test isn't usefull in the case of C language - * but is used for the Fortran interface - * (C users are expected to pass the address of an already allocated - * XDR staructure) - */ - if (xdrs == NULL) { - xdridptr[xdrid] = (XDR *) malloc(sizeof(XDR)); - xdrstdio_create(xdridptr[xdrid], xdrfiles[xdrid], lmode); - } else { - xdridptr[xdrid] = xdrs; - xdrstdio_create(xdrs, xdrfiles[xdrid], lmode); - } - return xdrid; -} - -/*_________________________________________________________________________ - | - | xdrclose - close a xdr file - | - | This will flush the xdr buffers, and destroy the xdr stream. - | It also closes the associated file descriptor (this is *not* - | done by xdr_destroy). - | -*/ - -int xdrclose(XDR *xdrs) { - int xdrid; - - if (xdrs == NULL) { - fprintf(stderr, "xdrclose: passed a NULL pointer\n"); - exit(1); - } - for (xdrid = 1; xdrid < MAXID; xdrid++) { - if (xdridptr[xdrid] == xdrs) { - - xdr_destroy(xdrs); - fclose(xdrfiles[xdrid]); - xdridptr[xdrid] = NULL; - return 1; - } - } - fprintf(stderr, "xdrclose: no such open xdr file\n"); - exit(1); - -} - -/*____________________________________________________________________________ - | - | sendbits - encode num into buf using the specified number of bits - | - | This routines appends the value of num to the bits already present in - | the array buf. You need to give it the number of bits to use and you - | better make sure that this number of bits is enough to hold the value - | Also num must be positive. - | -*/ - -static void sendbits(int buf[], int num_of_bits, int num) { - - unsigned int cnt, lastbyte; - int lastbits; - unsigned char * cbuf; - - cbuf = ((unsigned char *)buf) + 3 * sizeof(*buf); - cnt = (unsigned int) buf[0]; - lastbits = buf[1]; - lastbyte =(unsigned int) buf[2]; - while (num_of_bits >= 8) { - lastbyte = (lastbyte << 8) | ((num >> (num_of_bits -8)) /* & 0xff*/); - cbuf[cnt++] = lastbyte >> lastbits; - num_of_bits -= 8; - } - if (num_of_bits > 0) { - lastbyte = (lastbyte << num_of_bits) | num; - lastbits += num_of_bits; - if (lastbits >= 8) { - lastbits -= 8; - cbuf[cnt++] = lastbyte >> lastbits; - } - } - buf[0] = cnt; - buf[1] = lastbits; - buf[2] = lastbyte; - if (lastbits>0) { - cbuf[cnt] = lastbyte << (8 - lastbits); - } -} - -/*_________________________________________________________________________ - | - | sizeofint - calculate bitsize of an integer - | - | return the number of bits needed to store an integer with given max size - | -*/ - -static int sizeofint(const int size) { - unsigned int num = 1; - int num_of_bits = 0; - - while (size >= num && num_of_bits < 32) { - num_of_bits++; - num <<= 1; - } - return num_of_bits; -} - -/*___________________________________________________________________________ - | - | sizeofints - calculate 'bitsize' of compressed ints - | - | given the number of small unsigned integers and the maximum value - | return the number of bits needed to read or write them with the - | routines receiveints and sendints. You need this parameter when - | calling these routines. Note that for many calls I can use - | the variable 'smallidx' which is exactly the number of bits, and - | So I don't need to call 'sizeofints for those calls. -*/ - -static int sizeofints( const int num_of_ints, unsigned int sizes[]) { - int i, num; - unsigned int num_of_bytes, num_of_bits, bytes[32], bytecnt, tmp; - num_of_bytes = 1; - bytes[0] = 1; - num_of_bits = 0; - for (i=0; i < num_of_ints; i++) { - tmp = 0; - for (bytecnt = 0; bytecnt < num_of_bytes; bytecnt++) { - tmp = bytes[bytecnt] * sizes[i] + tmp; - bytes[bytecnt] = tmp & 0xff; - tmp >>= 8; - } - while (tmp != 0) { - bytes[bytecnt++] = tmp & 0xff; - tmp >>= 8; - } - num_of_bytes = bytecnt; - } - num = 1; - num_of_bytes--; - while (bytes[num_of_bytes] >= num) { - num_of_bits++; - num *= 2; - } - return num_of_bits + num_of_bytes * 8; - -} - -/*____________________________________________________________________________ - | - | sendints - send a small set of small integers in compressed format - | - | this routine is used internally by xdr3dfcoord, to send a set of - | small integers to the buffer. - | Multiplication with fixed (specified maximum ) sizes is used to get - | to one big, multibyte integer. Allthough the routine could be - | modified to handle sizes bigger than 16777216, or more than just - | a few integers, this is not done, because the gain in compression - | isn't worth the effort. Note that overflowing the multiplication - | or the byte buffer (32 bytes) is unchecked and causes bad results. - | - */ - -static void sendints(int buf[], const int num_of_ints, const int num_of_bits, - unsigned int sizes[], unsigned int nums[]) { - - int i; - unsigned int bytes[32], num_of_bytes, bytecnt, tmp; - - tmp = nums[0]; - num_of_bytes = 0; - do { - bytes[num_of_bytes++] = tmp & 0xff; - tmp >>= 8; - } while (tmp != 0); - - for (i = 1; i < num_of_ints; i++) { - if (nums[i] >= sizes[i]) { - fprintf(stderr,"major breakdown in sendints num %d doesn't " - "match size %d\n", nums[i], sizes[i]); - exit(1); - } - /* use one step multiply */ - tmp = nums[i]; - for (bytecnt = 0; bytecnt < num_of_bytes; bytecnt++) { - tmp = bytes[bytecnt] * sizes[i] + tmp; - bytes[bytecnt] = tmp & 0xff; - tmp >>= 8; - } - while (tmp != 0) { - bytes[bytecnt++] = tmp & 0xff; - tmp >>= 8; - } - num_of_bytes = bytecnt; - } - if (num_of_bits >= num_of_bytes * 8) { - for (i = 0; i < num_of_bytes; i++) { - sendbits(buf, 8, bytes[i]); - } - sendbits(buf, num_of_bits - num_of_bytes * 8, 0); - } else { - for (i = 0; i < num_of_bytes-1; i++) { - sendbits(buf, 8, bytes[i]); - } - sendbits(buf, num_of_bits- (num_of_bytes -1) * 8, bytes[i]); - } -} - - -/*___________________________________________________________________________ - | - | receivebits - decode number from buf using specified number of bits - | - | extract the number of bits from the array buf and construct an integer - | from it. Return that value. - | -*/ - -static int receivebits(int buf[], int num_of_bits) { - - int cnt, num; - unsigned int lastbits, lastbyte; - unsigned char * cbuf; - int mask = (1 << num_of_bits) -1; - - cbuf = ((unsigned char *)buf) + 3 * sizeof(*buf); - cnt = buf[0]; - lastbits = (unsigned int) buf[1]; - lastbyte = (unsigned int) buf[2]; - - num = 0; - while (num_of_bits >= 8) { - lastbyte = ( lastbyte << 8 ) | cbuf[cnt++]; - num |= (lastbyte >> lastbits) << (num_of_bits - 8); - num_of_bits -=8; - } - if (num_of_bits > 0) { - if (lastbits < num_of_bits) { - lastbits += 8; - lastbyte = (lastbyte << 8) | cbuf[cnt++]; - } - lastbits -= num_of_bits; - num |= (lastbyte >> lastbits) & ((1 << num_of_bits) -1); - } - num &= mask; - buf[0] = cnt; - buf[1] = lastbits; - buf[2] = lastbyte; - return num; -} - -/*____________________________________________________________________________ - | - | receiveints - decode 'small' integers from the buf array - | - | this routine is the inverse from sendints() and decodes the small integers - | written to buf by calculating the remainder and doing divisions with - | the given sizes[]. You need to specify the total number of bits to be - | used from buf in num_of_bits. - | -*/ - -static void receiveints(int buf[], const int num_of_ints, int num_of_bits, - unsigned int sizes[], int nums[]) { - int bytes[32]; - int i, j, num_of_bytes, p, num; - - bytes[1] = bytes[2] = bytes[3] = 0; - num_of_bytes = 0; - while (num_of_bits > 8) { - bytes[num_of_bytes++] = receivebits(buf, 8); - num_of_bits -= 8; - } - if (num_of_bits > 0) { - bytes[num_of_bytes++] = receivebits(buf, num_of_bits); - } - for (i = num_of_ints-1; i > 0; i--) { - num = 0; - for (j = num_of_bytes-1; j >=0; j--) { - num = (num << 8) | bytes[j]; - p = num / sizes[i]; - bytes[j] = p; - num = num - p * sizes[i]; - } - nums[i] = num; - } - nums[0] = bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24); -} - -/*____________________________________________________________________________ - | - | xdr3dfcoord - read or write compressed 3d coordinates to xdr file. - | - | this routine reads or writes (depending on how you opened the file with - | xdropen() ) a large number of 3d coordinates (stored in *fp). - | The number of coordinates triplets to write is given by *size. On - | read this number may be zero, in which case it reads as many as were written - | or it may specify the number if triplets to read (which should match the - | number written). - | Compression is achieved by first converting all floating numbers to integer - | using multiplication by *precision and rounding to the nearest integer. - | Then the minimum and maximum value are calculated to determine the range. - | The limited range of integers so found, is used to compress the coordinates. - | In addition the differences between succesive coordinates is calculated. - | If the difference happens to be 'small' then only the difference is saved, - | compressing the data even more. The notion of 'small' is changed dynamically - | and is enlarged or reduced whenever needed or possible. - | Extra compression is achieved in the case of GROMOS and coordinates of - | water molecules. GROMOS first writes out the Oxygen position, followed by - | the two hydrogens. In order to make the differences smaller (and thereby - | compression the data better) the order is changed into first one hydrogen - | then the oxygen, followed by the other hydrogen. This is rather special, but - | it shouldn't harm in the general case. - | - */ - -int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) { - - - static int *ip = NULL; - static int oldsize; - static int *buf; - - int minint[3], maxint[3], mindiff, *lip, diff; - int lint1, lint2, lint3, oldlint1, oldlint2, oldlint3, smallidx; - int minidx, maxidx; - unsigned sizeint[3], sizesmall[3], bitsizeint[3], size3, *luip; - int flag, k; - int small, smaller, larger, i, is_small, is_smaller, run, prevrun; - float *lfp, lf; - int tmp, *thiscoord, prevcoord[3]; - unsigned int tmpcoord[30]; - - int bufsize, xdrid, lsize; - unsigned int bitsize; - float inv_precision; - int errval = 1; - - /* find out if xdrs is opened for reading or for writing */ - xdrid = 0; - while (xdridptr[xdrid] != xdrs) { - xdrid++; - if (xdrid >= MAXID) { - fprintf(stderr, "xdr error. no open xdr stream\n"); - exit (1); - } - } - if (xdrmodes[xdrid] == 'w') { - - /* xdrs is open for writing */ - - if (xdr_int(xdrs, size) == 0) - return 0; - size3 = *size * 3; - /* when the number of coordinates is small, don't try to compress; just - * write them as floats using xdr_vector - */ - if (*size <= 9 ) { - return (xdr_vector(xdrs, (char *) fp, size3, sizeof(*fp), - (xdrproc_t)xdr_float)); - } - - xdr_float(xdrs, precision); - if (ip == NULL) { - ip = (int *)malloc(size3 * sizeof(*ip)); - if (ip == NULL) { - fprintf(stderr,"malloc failed\n"); - exit(1); - } - bufsize = size3 * 1.2; - buf = (int *)malloc(bufsize * sizeof(*buf)); - if (buf == NULL) { - fprintf(stderr,"malloc failed\n"); - exit(1); - } - oldsize = *size; - } else if (*size > oldsize) { - ip = (int *)realloc(ip, size3 * sizeof(*ip)); - if (ip == NULL) { - fprintf(stderr,"malloc failed\n"); - exit(1); - } - bufsize = size3 * 1.2; - buf = (int *)realloc(buf, bufsize * sizeof(*buf)); - if (buf == NULL) { - fprintf(stderr,"malloc failed\n"); - exit(1); - } - oldsize = *size; - } - /* buf[0-2] are special and do not contain actual data */ - buf[0] = buf[1] = buf[2] = 0; - minint[0] = minint[1] = minint[2] = INT_MAX; - maxint[0] = maxint[1] = maxint[2] = INT_MIN; - prevrun = -1; - lfp = fp; - lip = ip; - mindiff = INT_MAX; - oldlint1 = oldlint2 = oldlint3 = 0; - while(lfp < fp + size3 ) { - /* find nearest integer */ - if (*lfp >= 0.0) - lf = *lfp * *precision + 0.5; - else - lf = *lfp * *precision - 0.5; - if (fabs(lf) > MAXABS) { - /* scaling would cause overflow */ - errval = 0; - } - lint1 = lf; - if (lint1 < minint[0]) minint[0] = lint1; - if (lint1 > maxint[0]) maxint[0] = lint1; - *lip++ = lint1; - lfp++; - if (*lfp >= 0.0) - lf = *lfp * *precision + 0.5; - else - lf = *lfp * *precision - 0.5; - if (fabs(lf) > MAXABS) { - /* scaling would cause overflow */ - errval = 0; - } - lint2 = lf; - if (lint2 < minint[1]) minint[1] = lint2; - if (lint2 > maxint[1]) maxint[1] = lint2; - *lip++ = lint2; - lfp++; - if (*lfp >= 0.0) - lf = *lfp * *precision + 0.5; - else - lf = *lfp * *precision - 0.5; - if (fabs(lf) > MAXABS) { - /* scaling would cause overflow */ - errval = 0; - } - lint3 = lf; - if (lint3 < minint[2]) minint[2] = lint3; - if (lint3 > maxint[2]) maxint[2] = lint3; - *lip++ = lint3; - lfp++; - diff = abs(oldlint1-lint1)+abs(oldlint2-lint2)+abs(oldlint3-lint3); - if (diff < mindiff && lfp > fp + 3) - mindiff = diff; - oldlint1 = lint1; - oldlint2 = lint2; - oldlint3 = lint3; - } - xdr_int(xdrs, &(minint[0])); - xdr_int(xdrs, &(minint[1])); - xdr_int(xdrs, &(minint[2])); - - xdr_int(xdrs, &(maxint[0])); - xdr_int(xdrs, &(maxint[1])); - xdr_int(xdrs, &(maxint[2])); - - if ((float)maxint[0] - (float)minint[0] >= MAXABS || - (float)maxint[1] - (float)minint[1] >= MAXABS || - (float)maxint[2] - (float)minint[2] >= MAXABS) { - /* turning value in unsigned by subtracting minint - * would cause overflow - */ - errval = 0; - } - sizeint[0] = maxint[0] - minint[0]+1; - sizeint[1] = maxint[1] - minint[1]+1; - sizeint[2] = maxint[2] - minint[2]+1; - - /* check if one of the sizes is to big to be multiplied */ - if ((sizeint[0] | sizeint[1] | sizeint[2] ) > 0xffffff) { - bitsizeint[0] = sizeofint(sizeint[0]); - bitsizeint[1] = sizeofint(sizeint[1]); - bitsizeint[2] = sizeofint(sizeint[2]); - bitsize = 0; /* flag the use of large sizes */ - } else { - bitsize = sizeofints(3, sizeint); - } - lip = ip; - luip = (unsigned int *) ip; - smallidx = FIRSTIDX; - while (smallidx < LASTIDX && magicints[smallidx] < mindiff) { - smallidx++; - } - xdr_int(xdrs, &smallidx); - maxidx = MIN(LASTIDX, smallidx + 8) ; - minidx = maxidx - 8; /* often this equal smallidx */ - smaller = magicints[MAX(FIRSTIDX, smallidx-1)] / 2; - small = magicints[smallidx] / 2; - sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx]; - larger = magicints[maxidx] / 2; - i = 0; - while (i < *size) { - is_small = 0; - thiscoord = (int *)(luip) + i * 3; - if (smallidx < maxidx && i >= 1 && - abs(thiscoord[0] - prevcoord[0]) < larger && - abs(thiscoord[1] - prevcoord[1]) < larger && - abs(thiscoord[2] - prevcoord[2]) < larger) { - is_smaller = 1; - } else if (smallidx > minidx) { - is_smaller = -1; - } else { - is_smaller = 0; - } - if (i + 1 < *size) { - if (abs(thiscoord[0] - thiscoord[3]) < small && - abs(thiscoord[1] - thiscoord[4]) < small && - abs(thiscoord[2] - thiscoord[5]) < small) { - /* interchange first with second atom for better - * compression of water molecules - */ - tmp = thiscoord[0]; thiscoord[0] = thiscoord[3]; - thiscoord[3] = tmp; - tmp = thiscoord[1]; thiscoord[1] = thiscoord[4]; - thiscoord[4] = tmp; - tmp = thiscoord[2]; thiscoord[2] = thiscoord[5]; - thiscoord[5] = tmp; - is_small = 1; - } - - } - tmpcoord[0] = thiscoord[0] - minint[0]; - tmpcoord[1] = thiscoord[1] - minint[1]; - tmpcoord[2] = thiscoord[2] - minint[2]; - if (bitsize == 0) { - sendbits(buf, bitsizeint[0], tmpcoord[0]); - sendbits(buf, bitsizeint[1], tmpcoord[1]); - sendbits(buf, bitsizeint[2], tmpcoord[2]); - } else { - sendints(buf, 3, bitsize, sizeint, tmpcoord); - } - prevcoord[0] = thiscoord[0]; - prevcoord[1] = thiscoord[1]; - prevcoord[2] = thiscoord[2]; - thiscoord = thiscoord + 3; - i++; - - run = 0; - if (is_small == 0 && is_smaller == -1) - is_smaller = 0; - while (is_small && run < 8*3) { - if (is_smaller == -1 && ( - SQR(thiscoord[0] - prevcoord[0]) + - SQR(thiscoord[1] - prevcoord[1]) + - SQR(thiscoord[2] - prevcoord[2]) >= smaller * smaller)) { - is_smaller = 0; - } - - tmpcoord[run++] = thiscoord[0] - prevcoord[0] + small; - tmpcoord[run++] = thiscoord[1] - prevcoord[1] + small; - tmpcoord[run++] = thiscoord[2] - prevcoord[2] + small; - - prevcoord[0] = thiscoord[0]; - prevcoord[1] = thiscoord[1]; - prevcoord[2] = thiscoord[2]; - - i++; - thiscoord = thiscoord + 3; - is_small = 0; - if (i < *size && - abs(thiscoord[0] - prevcoord[0]) < small && - abs(thiscoord[1] - prevcoord[1]) < small && - abs(thiscoord[2] - prevcoord[2]) < small) { - is_small = 1; - } - } - if (run != prevrun || is_smaller != 0) { - prevrun = run; - sendbits(buf, 1, 1); /* flag the change in run-length */ - sendbits(buf, 5, run+is_smaller+1); - } else { - sendbits(buf, 1, 0); /* flag the fact that runlength did not change */ - } - for (k=0; k < run; k+=3) { - sendints(buf, 3, smallidx, sizesmall, &tmpcoord[k]); - } - if (is_smaller != 0) { - smallidx += is_smaller; - if (is_smaller < 0) { - small = smaller; - smaller = magicints[smallidx-1] / 2; - } else { - smaller = small; - small = magicints[smallidx] / 2; - } - sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx]; - } - } - if (buf[1] != 0) buf[0]++;; - xdr_int(xdrs, &(buf[0])); /* buf[0] holds the length in bytes */ - return errval * (xdr_opaque(xdrs, (caddr_t)&(buf[3]), (u_int)buf[0])); - } else { - - /* xdrs is open for reading */ - - if (xdr_int(xdrs, &lsize) == 0) - return 0; - if (*size != 0 && lsize != *size) { - fprintf(stderr, "wrong number of coordinates in xdr3dfcoor; " - "%d arg vs %d in file", *size, lsize); - } - *size = lsize; - size3 = *size * 3; - if (*size <= 9) { - return (xdr_vector(xdrs, (char *) fp, size3, sizeof(*fp), - (xdrproc_t)xdr_float)); - } - xdr_float(xdrs, precision); - if (ip == NULL) { - ip = (int *)malloc(size3 * sizeof(*ip)); - if (ip == NULL) { - fprintf(stderr,"malloc failed\n"); - exit(1); - } - bufsize = size3 * 1.2; - buf = (int *)malloc(bufsize * sizeof(*buf)); - if (buf == NULL) { - fprintf(stderr,"malloc failed\n"); - exit(1); - } - oldsize = *size; - } else if (*size > oldsize) { - ip = (int *)realloc(ip, size3 * sizeof(*ip)); - if (ip == NULL) { - fprintf(stderr,"malloc failed\n"); - exit(1); - } - bufsize = size3 * 1.2; - buf = (int *)realloc(buf, bufsize * sizeof(*buf)); - if (buf == NULL) { - fprintf(stderr,"malloc failed\n"); - exit(1); - } - oldsize = *size; - } - buf[0] = buf[1] = buf[2] = 0; - - xdr_int(xdrs, &(minint[0])); - xdr_int(xdrs, &(minint[1])); - xdr_int(xdrs, &(minint[2])); - - xdr_int(xdrs, &(maxint[0])); - xdr_int(xdrs, &(maxint[1])); - xdr_int(xdrs, &(maxint[2])); - - sizeint[0] = maxint[0] - minint[0]+1; - sizeint[1] = maxint[1] - minint[1]+1; - sizeint[2] = maxint[2] - minint[2]+1; - - /* check if one of the sizes is to big to be multiplied */ - if ((sizeint[0] | sizeint[1] | sizeint[2] ) > 0xffffff) { - bitsizeint[0] = sizeofint(sizeint[0]); - bitsizeint[1] = sizeofint(sizeint[1]); - bitsizeint[2] = sizeofint(sizeint[2]); - bitsize = 0; /* flag the use of large sizes */ - } else { - bitsize = sizeofints(3, sizeint); - } - - xdr_int(xdrs, &smallidx); - maxidx = MIN(LASTIDX, smallidx + 8) ; - minidx = maxidx - 8; /* often this equal smallidx */ - smaller = magicints[MAX(FIRSTIDX, smallidx-1)] / 2; - small = magicints[smallidx] / 2; - sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx] ; - larger = magicints[maxidx]; - - /* buf[0] holds the length in bytes */ - - if (xdr_int(xdrs, &(buf[0])) == 0) - return 0; - if (xdr_opaque(xdrs, (caddr_t)&(buf[3]), (u_int)buf[0]) == 0) - return 0; - buf[0] = buf[1] = buf[2] = 0; - - lfp = fp; - inv_precision = 1.0 / * precision; - run = 0; - i = 0; - lip = ip; - while ( i < lsize ) { - thiscoord = (int *)(lip) + i * 3; - - if (bitsize == 0) { - thiscoord[0] = receivebits(buf, bitsizeint[0]); - thiscoord[1] = receivebits(buf, bitsizeint[1]); - thiscoord[2] = receivebits(buf, bitsizeint[2]); - } else { - receiveints(buf, 3, bitsize, sizeint, thiscoord); - } - - i++; - thiscoord[0] += minint[0]; - thiscoord[1] += minint[1]; - thiscoord[2] += minint[2]; - - prevcoord[0] = thiscoord[0]; - prevcoord[1] = thiscoord[1]; - prevcoord[2] = thiscoord[2]; - - - flag = receivebits(buf, 1); - is_smaller = 0; - if (flag == 1) { - run = receivebits(buf, 5); - is_smaller = run % 3; - run -= is_smaller; - is_smaller--; - } - if (run > 0) { - thiscoord += 3; - for (k = 0; k < run; k+=3) { - receiveints(buf, 3, smallidx, sizesmall, thiscoord); - i++; - thiscoord[0] += prevcoord[0] - small; - thiscoord[1] += prevcoord[1] - small; - thiscoord[2] += prevcoord[2] - small; - if (k == 0) { - /* interchange first with second atom for better - * compression of water molecules - */ - tmp = thiscoord[0]; thiscoord[0] = prevcoord[0]; - prevcoord[0] = tmp; - tmp = thiscoord[1]; thiscoord[1] = prevcoord[1]; - prevcoord[1] = tmp; - tmp = thiscoord[2]; thiscoord[2] = prevcoord[2]; - prevcoord[2] = tmp; - *lfp++ = prevcoord[0] * inv_precision; - *lfp++ = prevcoord[1] * inv_precision; - *lfp++ = prevcoord[2] * inv_precision; - } else { - prevcoord[0] = thiscoord[0]; - prevcoord[1] = thiscoord[1]; - prevcoord[2] = thiscoord[2]; - } - *lfp++ = thiscoord[0] * inv_precision; - *lfp++ = thiscoord[1] * inv_precision; - *lfp++ = thiscoord[2] * inv_precision; - } - } else { - *lfp++ = thiscoord[0] * inv_precision; - *lfp++ = thiscoord[1] * inv_precision; - *lfp++ = thiscoord[2] * inv_precision; - } - smallidx += is_smaller; - if (is_smaller < 0) { - small = smaller; - if (smallidx > FIRSTIDX) { - smaller = magicints[smallidx - 1] /2; - } else { - smaller = 0; - } - } else if (is_smaller > 0) { - smaller = small; - small = magicints[smallidx] / 2; - } - sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx] ; - } - } - return 1; -} - - - diff --git a/source/cluster/wham/src-M/xdrf/types.h b/source/cluster/wham/src-M/xdrf/types.h deleted file mode 100644 index 871f3fd..0000000 --- a/source/cluster/wham/src-M/xdrf/types.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* fixincludes should not add extern "C" to this file */ -/* - * Rpc additions to - */ -#ifndef _RPC_TYPES_H -#define _RPC_TYPES_H 1 - -typedef int bool_t; -typedef int enum_t; -/* This needs to be changed to uint32_t in the future */ -typedef unsigned long rpcprog_t; -typedef unsigned long rpcvers_t; -typedef unsigned long rpcproc_t; -typedef unsigned long rpcprot_t; -typedef unsigned long rpcport_t; - -#define __dontcare__ -1 - -#ifndef FALSE -# define FALSE (0) -#endif - -#ifndef TRUE -# define TRUE (1) -#endif - -#ifndef NULL -# define NULL 0 -#endif - -#include /* For malloc decl. */ -#define mem_alloc(bsize) malloc(bsize) -/* - * XXX: This must not use the second argument, or code in xdr_array.c needs - * to be modified. - */ -#define mem_free(ptr, bsize) free(ptr) - -#ifndef makedev /* ie, we haven't already included it */ -#include -#endif - -#ifndef __u_char_defined -typedef __u_char u_char; -typedef __u_short u_short; -typedef __u_int u_int; -typedef __u_long u_long; -typedef __quad_t quad_t; -typedef __u_quad_t u_quad_t; -typedef __fsid_t fsid_t; -# define __u_char_defined -#endif -#ifndef __daddr_t_defined -typedef __daddr_t daddr_t; -typedef __caddr_t caddr_t; -# define __daddr_t_defined -#endif - -#include -#include - -#include - -#ifndef INADDR_LOOPBACK -#define INADDR_LOOPBACK (u_long)0x7F000001 -#endif -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 64 -#endif - -#endif /* rpc/types.h */ diff --git a/source/cluster/wham/src-M/xdrf/underscore.m4 b/source/cluster/wham/src-M/xdrf/underscore.m4 deleted file mode 100644 index 4d620a0..0000000 --- a/source/cluster/wham/src-M/xdrf/underscore.m4 +++ /dev/null @@ -1,19 +0,0 @@ -divert(-1) -undefine(`len') -# -# append an underscore to FORTRAN function names -# -define(`FUNCTION',`$1_') -# -# FORTRAN character strings are passed as follows: -# a pointer to the base of the string is passed in the normal -# argument list, and the length is passed by value as an extra -# argument, after all of the other arguments. -# -define(`ARGS',`($1`'undivert(1))') -define(`SAVE',`divert(1)$1`'divert(0)') -define(`STRING_ARG',`$1_ptr`'SAVE(`, $1_len')') -define(`STRING_ARG_DECL',`char * $1_ptr; int $1_len') -define(`STRING_LEN',`$1_len') -define(`STRING_PTR',`$1_ptr') -divert(0) diff --git a/source/cluster/wham/src-M/xdrf/xdr.c b/source/cluster/wham/src-M/xdrf/xdr.c deleted file mode 100644 index 33b8544..0000000 --- a/source/cluster/wham/src-M/xdrf/xdr.c +++ /dev/null @@ -1,752 +0,0 @@ -# define INTUSE(name) name -# define INTDEF(name) -/* @(#)xdr.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)xdr.c 1.35 87/08/12"; -#endif - -/* - * xdr.c, Generic XDR routines implementation. - * - * Copyright (C) 1986, Sun Microsystems, Inc. - * - * These are the "generic" xdr routines used to serialize and de-serialize - * most common data items. See xdr.h for more info on the interface to - * xdr. - */ - -#include -#include -#include -#include - -#include "types.h" -#include "xdr.h" - -#ifdef USE_IN_LIBIO -# include -#endif - -/* - * constants specific to the xdr "protocol" - */ -#define XDR_FALSE ((long) 0) -#define XDR_TRUE ((long) 1) -#define LASTUNSIGNED ((u_int) 0-1) - -/* - * for unit alignment - */ -static const char xdr_zero[BYTES_PER_XDR_UNIT] = {0, 0, 0, 0}; - -/* - * Free a data structure using XDR - * Not a filter, but a convenient utility nonetheless - */ -void -xdr_free (xdrproc_t proc, char *objp) -{ - XDR x; - - x.x_op = XDR_FREE; - (*proc) (&x, objp); -} - -/* - * XDR nothing - */ -bool_t -xdr_void (void) -{ - return TRUE; -} -INTDEF(xdr_void) - -/* - * XDR integers - */ -bool_t -xdr_int (XDR *xdrs, int *ip) -{ - -#if INT_MAX < LONG_MAX - long l; - - switch (xdrs->x_op) - { - case XDR_ENCODE: - l = (long) *ip; - return XDR_PUTLONG (xdrs, &l); - - case XDR_DECODE: - if (!XDR_GETLONG (xdrs, &l)) - { - return FALSE; - } - *ip = (int) l; - case XDR_FREE: - return TRUE; - } - return FALSE; -#elif INT_MAX == LONG_MAX - return INTUSE(xdr_long) (xdrs, (long *) ip); -#elif INT_MAX == SHRT_MAX - return INTUSE(xdr_short) (xdrs, (short *) ip); -#else -#error unexpected integer sizes in_xdr_int() -#endif -} -INTDEF(xdr_int) - -/* - * XDR unsigned integers - */ -bool_t -xdr_u_int (XDR *xdrs, u_int *up) -{ -#if UINT_MAX < ULONG_MAX - long l; - - switch (xdrs->x_op) - { - case XDR_ENCODE: - l = (u_long) * up; - return XDR_PUTLONG (xdrs, &l); - - case XDR_DECODE: - if (!XDR_GETLONG (xdrs, &l)) - { - return FALSE; - } - *up = (u_int) (u_long) l; - case XDR_FREE: - return TRUE; - } - return FALSE; -#elif UINT_MAX == ULONG_MAX - return INTUSE(xdr_u_long) (xdrs, (u_long *) up); -#elif UINT_MAX == USHRT_MAX - return INTUSE(xdr_short) (xdrs, (short *) up); -#else -#error unexpected integer sizes in_xdr_u_int() -#endif -} -INTDEF(xdr_u_int) - -/* - * XDR long integers - * The definition of xdr_long() is kept for backward - * compatibility. Instead xdr_int() should be used. - */ -bool_t -xdr_long (XDR *xdrs, long *lp) -{ - - if (xdrs->x_op == XDR_ENCODE - && (sizeof (int32_t) == sizeof (long) - || (int32_t) *lp == *lp)) - return XDR_PUTLONG (xdrs, lp); - - if (xdrs->x_op == XDR_DECODE) - return XDR_GETLONG (xdrs, lp); - - if (xdrs->x_op == XDR_FREE) - return TRUE; - - return FALSE; -} -INTDEF(xdr_long) - -/* - * XDR unsigned long integers - * The definition of xdr_u_long() is kept for backward - * compatibility. Instead xdr_u_int() should be used. - */ -bool_t -xdr_u_long (XDR *xdrs, u_long *ulp) -{ - switch (xdrs->x_op) - { - case XDR_DECODE: - { - long int tmp; - - if (XDR_GETLONG (xdrs, &tmp) == FALSE) - return FALSE; - - *ulp = (uint32_t) tmp; - return TRUE; - } - - case XDR_ENCODE: - if (sizeof (uint32_t) != sizeof (u_long) - && (uint32_t) *ulp != *ulp) - return FALSE; - - return XDR_PUTLONG (xdrs, (long *) ulp); - - case XDR_FREE: - return TRUE; - } - return FALSE; -} -INTDEF(xdr_u_long) - -/* - * XDR hyper integers - * same as xdr_u_hyper - open coded to save a proc call! - */ -bool_t -xdr_hyper (XDR *xdrs, quad_t *llp) -{ - long int t1, t2; - - if (xdrs->x_op == XDR_ENCODE) - { - t1 = (long) ((*llp) >> 32); - t2 = (long) (*llp); - return (XDR_PUTLONG(xdrs, &t1) && XDR_PUTLONG(xdrs, &t2)); - } - - if (xdrs->x_op == XDR_DECODE) - { - if (!XDR_GETLONG(xdrs, &t1) || !XDR_GETLONG(xdrs, &t2)) - return FALSE; - *llp = ((quad_t) t1) << 32; - *llp |= (uint32_t) t2; - return TRUE; - } - - if (xdrs->x_op == XDR_FREE) - return TRUE; - - return FALSE; -} -INTDEF(xdr_hyper) - - -/* - * XDR hyper integers - * same as xdr_hyper - open coded to save a proc call! - */ -bool_t -xdr_u_hyper (XDR *xdrs, u_quad_t *ullp) -{ - long int t1, t2; - - if (xdrs->x_op == XDR_ENCODE) - { - t1 = (unsigned long) ((*ullp) >> 32); - t2 = (unsigned long) (*ullp); - return (XDR_PUTLONG(xdrs, &t1) && XDR_PUTLONG(xdrs, &t2)); - } - - if (xdrs->x_op == XDR_DECODE) - { - if (!XDR_GETLONG(xdrs, &t1) || !XDR_GETLONG(xdrs, &t2)) - return FALSE; - *ullp = ((u_quad_t) t1) << 32; - *ullp |= (uint32_t) t2; - return TRUE; - } - - if (xdrs->x_op == XDR_FREE) - return TRUE; - - return FALSE; -} -INTDEF(xdr_u_hyper) - -bool_t -xdr_longlong_t (XDR *xdrs, quad_t *llp) -{ - return INTUSE(xdr_hyper) (xdrs, llp); -} - -bool_t -xdr_u_longlong_t (XDR *xdrs, u_quad_t *ullp) -{ - return INTUSE(xdr_u_hyper) (xdrs, ullp); -} - -/* - * XDR short integers - */ -bool_t -xdr_short (XDR *xdrs, short *sp) -{ - long l; - - switch (xdrs->x_op) - { - case XDR_ENCODE: - l = (long) *sp; - return XDR_PUTLONG (xdrs, &l); - - case XDR_DECODE: - if (!XDR_GETLONG (xdrs, &l)) - { - return FALSE; - } - *sp = (short) l; - return TRUE; - - case XDR_FREE: - return TRUE; - } - return FALSE; -} -INTDEF(xdr_short) - -/* - * XDR unsigned short integers - */ -bool_t -xdr_u_short (XDR *xdrs, u_short *usp) -{ - long l; - - switch (xdrs->x_op) - { - case XDR_ENCODE: - l = (u_long) * usp; - return XDR_PUTLONG (xdrs, &l); - - case XDR_DECODE: - if (!XDR_GETLONG (xdrs, &l)) - { - return FALSE; - } - *usp = (u_short) (u_long) l; - return TRUE; - - case XDR_FREE: - return TRUE; - } - return FALSE; -} -INTDEF(xdr_u_short) - - -/* - * XDR a char - */ -bool_t -xdr_char (XDR *xdrs, char *cp) -{ - int i; - - i = (*cp); - if (!INTUSE(xdr_int) (xdrs, &i)) - { - return FALSE; - } - *cp = i; - return TRUE; -} - -/* - * XDR an unsigned char - */ -bool_t -xdr_u_char (XDR *xdrs, u_char *cp) -{ - u_int u; - - u = (*cp); - if (!INTUSE(xdr_u_int) (xdrs, &u)) - { - return FALSE; - } - *cp = u; - return TRUE; -} - -/* - * XDR booleans - */ -bool_t -xdr_bool (XDR *xdrs, bool_t *bp) -{ - long lb; - - switch (xdrs->x_op) - { - case XDR_ENCODE: - lb = *bp ? XDR_TRUE : XDR_FALSE; - return XDR_PUTLONG (xdrs, &lb); - - case XDR_DECODE: - if (!XDR_GETLONG (xdrs, &lb)) - { - return FALSE; - } - *bp = (lb == XDR_FALSE) ? FALSE : TRUE; - return TRUE; - - case XDR_FREE: - return TRUE; - } - return FALSE; -} -INTDEF(xdr_bool) - -/* - * XDR enumerations - */ -bool_t -xdr_enum (XDR *xdrs, enum_t *ep) -{ - enum sizecheck - { - SIZEVAL - }; /* used to find the size of an enum */ - - /* - * enums are treated as ints - */ - if (sizeof (enum sizecheck) == 4) - { -#if INT_MAX < LONG_MAX - long l; - - switch (xdrs->x_op) - { - case XDR_ENCODE: - l = *ep; - return XDR_PUTLONG (xdrs, &l); - - case XDR_DECODE: - if (!XDR_GETLONG (xdrs, &l)) - { - return FALSE; - } - *ep = l; - case XDR_FREE: - return TRUE; - - } - return FALSE; -#else - return INTUSE(xdr_long) (xdrs, (long *) ep); -#endif - } - else if (sizeof (enum sizecheck) == sizeof (short)) - { - return INTUSE(xdr_short) (xdrs, (short *) ep); - } - else - { - return FALSE; - } -} -INTDEF(xdr_enum) - -/* - * XDR opaque data - * Allows the specification of a fixed size sequence of opaque bytes. - * cp points to the opaque object and cnt gives the byte length. - */ -bool_t -xdr_opaque (XDR *xdrs, caddr_t cp, u_int cnt) -{ - u_int rndup; - static char crud[BYTES_PER_XDR_UNIT]; - - /* - * if no data we are done - */ - if (cnt == 0) - return TRUE; - - /* - * round byte count to full xdr units - */ - rndup = cnt % BYTES_PER_XDR_UNIT; - if (rndup > 0) - rndup = BYTES_PER_XDR_UNIT - rndup; - - switch (xdrs->x_op) - { - case XDR_DECODE: - if (!XDR_GETBYTES (xdrs, cp, cnt)) - { - return FALSE; - } - if (rndup == 0) - return TRUE; - return XDR_GETBYTES (xdrs, (caddr_t)crud, rndup); - - case XDR_ENCODE: - if (!XDR_PUTBYTES (xdrs, cp, cnt)) - { - return FALSE; - } - if (rndup == 0) - return TRUE; - return XDR_PUTBYTES (xdrs, xdr_zero, rndup); - - case XDR_FREE: - return TRUE; - } - return FALSE; -} -INTDEF(xdr_opaque) - -/* - * XDR counted bytes - * *cpp is a pointer to the bytes, *sizep is the count. - * If *cpp is NULL maxsize bytes are allocated - */ -bool_t -xdr_bytes (xdrs, cpp, sizep, maxsize) - XDR *xdrs; - char **cpp; - u_int *sizep; - u_int maxsize; -{ - char *sp = *cpp; /* sp is the actual string pointer */ - u_int nodesize; - - /* - * first deal with the length since xdr bytes are counted - */ - if (!INTUSE(xdr_u_int) (xdrs, sizep)) - { - return FALSE; - } - nodesize = *sizep; - if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) - { - return FALSE; - } - - /* - * now deal with the actual bytes - */ - switch (xdrs->x_op) - { - case XDR_DECODE: - if (nodesize == 0) - { - return TRUE; - } - if (sp == NULL) - { - *cpp = sp = (char *) mem_alloc (nodesize); - } - if (sp == NULL) - { - fprintf (NULL, "%s", "xdr_bytes: out of memory\n"); - return FALSE; - } - /* fall into ... */ - - case XDR_ENCODE: - return INTUSE(xdr_opaque) (xdrs, sp, nodesize); - - case XDR_FREE: - if (sp != NULL) - { - mem_free (sp, nodesize); - *cpp = NULL; - } - return TRUE; - } - return FALSE; -} -INTDEF(xdr_bytes) - -/* - * Implemented here due to commonality of the object. - */ -bool_t -xdr_netobj (xdrs, np) - XDR *xdrs; - struct netobj *np; -{ - - return INTUSE(xdr_bytes) (xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ); -} -INTDEF(xdr_netobj) - -/* - * XDR a discriminated union - * Support routine for discriminated unions. - * You create an array of xdrdiscrim structures, terminated with - * an entry with a null procedure pointer. The routine gets - * the discriminant value and then searches the array of xdrdiscrims - * looking for that value. It calls the procedure given in the xdrdiscrim - * to handle the discriminant. If there is no specific routine a default - * routine may be called. - * If there is no specific or default routine an error is returned. - */ -bool_t -xdr_union (xdrs, dscmp, unp, choices, dfault) - XDR *xdrs; - enum_t *dscmp; /* enum to decide which arm to work on */ - char *unp; /* the union itself */ - const struct xdr_discrim *choices; /* [value, xdr proc] for each arm */ - xdrproc_t dfault; /* default xdr routine */ -{ - enum_t dscm; - - /* - * we deal with the discriminator; it's an enum - */ - if (!INTUSE(xdr_enum) (xdrs, dscmp)) - { - return FALSE; - } - dscm = *dscmp; - - /* - * search choices for a value that matches the discriminator. - * if we find one, execute the xdr routine for that value. - */ - for (; choices->proc != NULL_xdrproc_t; choices++) - { - if (choices->value == dscm) - return (*(choices->proc)) (xdrs, unp, LASTUNSIGNED); - } - - /* - * no match - execute the default xdr routine if there is one - */ - return ((dfault == NULL_xdrproc_t) ? FALSE : - (*dfault) (xdrs, unp, LASTUNSIGNED)); -} -INTDEF(xdr_union) - - -/* - * Non-portable xdr primitives. - * Care should be taken when moving these routines to new architectures. - */ - - -/* - * XDR null terminated ASCII strings - * xdr_string deals with "C strings" - arrays of bytes that are - * terminated by a NULL character. The parameter cpp references a - * pointer to storage; If the pointer is null, then the necessary - * storage is allocated. The last parameter is the max allowed length - * of the string as specified by a protocol. - */ -bool_t -xdr_string (xdrs, cpp, maxsize) - XDR *xdrs; - char **cpp; - u_int maxsize; -{ - char *sp = *cpp; /* sp is the actual string pointer */ - u_int size; - u_int nodesize; - - /* - * first deal with the length since xdr strings are counted-strings - */ - switch (xdrs->x_op) - { - case XDR_FREE: - if (sp == NULL) - { - return TRUE; /* already free */ - } - /* fall through... */ - case XDR_ENCODE: - if (sp == NULL) - return FALSE; - size = strlen (sp); - break; - case XDR_DECODE: - break; - } - if (!INTUSE(xdr_u_int) (xdrs, &size)) - { - return FALSE; - } - if (size > maxsize) - { - return FALSE; - } - nodesize = size + 1; - if (nodesize == 0) - { - /* This means an overflow. It a bug in the caller which - provided a too large maxsize but nevertheless catch it - here. */ - return FALSE; - } - - /* - * now deal with the actual bytes - */ - switch (xdrs->x_op) - { - case XDR_DECODE: - if (sp == NULL) - *cpp = sp = (char *) mem_alloc (nodesize); - if (sp == NULL) - { - fprintf (NULL, "%s", "xdr_string: out of memory\n"); - return FALSE; - } - sp[size] = 0; - /* fall into ... */ - - case XDR_ENCODE: - return INTUSE(xdr_opaque) (xdrs, sp, size); - - case XDR_FREE: - mem_free (sp, nodesize); - *cpp = NULL; - return TRUE; - } - return FALSE; -} -INTDEF(xdr_string) - -/* - * Wrapper for xdr_string that can be called directly from - * routines like clnt_call - */ -bool_t -xdr_wrapstring (xdrs, cpp) - XDR *xdrs; - char **cpp; -{ - if (INTUSE(xdr_string) (xdrs, cpp, LASTUNSIGNED)) - { - return TRUE; - } - return FALSE; -} diff --git a/source/cluster/wham/src-M/xdrf/xdr.h b/source/cluster/wham/src-M/xdrf/xdr.h deleted file mode 100644 index 2602ad9..0000000 --- a/source/cluster/wham/src-M/xdrf/xdr.h +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * xdr.h, External Data Representation Serialization Routines. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#ifndef _RPC_XDR_H -#define _RPC_XDR_H 1 - -#include -#include -#include "types.h" - -/* We need FILE. */ -#include - -__BEGIN_DECLS - -/* - * XDR provides a conventional way for converting between C data - * types and an external bit-string representation. Library supplied - * routines provide for the conversion on built-in C data types. These - * routines and utility routines defined here are used to help implement - * a type encode/decode routine for each user-defined type. - * - * Each data type provides a single procedure which takes two arguments: - * - * bool_t - * xdrproc(xdrs, argresp) - * XDR *xdrs; - * *argresp; - * - * xdrs is an instance of a XDR handle, to which or from which the data - * type is to be converted. argresp is a pointer to the structure to be - * converted. The XDR handle contains an operation field which indicates - * which of the operations (ENCODE, DECODE * or FREE) is to be performed. - * - * XDR_DECODE may allocate space if the pointer argresp is null. This - * data can be freed with the XDR_FREE operation. - * - * We write only one procedure per data type to make it easy - * to keep the encode and decode procedures for a data type consistent. - * In many cases the same code performs all operations on a user defined type, - * because all the hard work is done in the component type routines. - * decode as a series of calls on the nested data types. - */ - -/* - * Xdr operations. XDR_ENCODE causes the type to be encoded into the - * stream. XDR_DECODE causes the type to be extracted from the stream. - * XDR_FREE can be used to release the space allocated by an XDR_DECODE - * request. - */ -enum xdr_op { - XDR_ENCODE = 0, - XDR_DECODE = 1, - XDR_FREE = 2 -}; - -/* - * This is the number of bytes per unit of external data. - */ -#define BYTES_PER_XDR_UNIT (4) -/* - * This only works if the above is a power of 2. But it's defined to be - * 4 by the appropriate RFCs. So it will work. And it's normally quicker - * than the old routine. - */ -#if 1 -#define RNDUP(x) (((x) + BYTES_PER_XDR_UNIT - 1) & ~(BYTES_PER_XDR_UNIT - 1)) -#else /* this is the old routine */ -#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ - * BYTES_PER_XDR_UNIT) -#endif - -/* - * The XDR handle. - * Contains operation which is being applied to the stream, - * an operations vector for the particular implementation (e.g. see xdr_mem.c), - * and two private fields for the use of the particular implementation. - */ -typedef struct XDR XDR; -struct XDR - { - enum xdr_op x_op; /* operation; fast additional param */ - struct xdr_ops - { - bool_t (*x_getlong) (XDR *__xdrs, long *__lp); - /* get a long from underlying stream */ - bool_t (*x_putlong) (XDR *__xdrs, __const long *__lp); - /* put a long to " */ - bool_t (*x_getbytes) (XDR *__xdrs, caddr_t __addr, u_int __len); - /* get some bytes from " */ - bool_t (*x_putbytes) (XDR *__xdrs, __const char *__addr, u_int __len); - /* put some bytes to " */ - u_int (*x_getpostn) (__const XDR *__xdrs); - /* returns bytes off from beginning */ - bool_t (*x_setpostn) (XDR *__xdrs, u_int __pos); - /* lets you reposition the stream */ - int32_t *(*x_inline) (XDR *__xdrs, u_int __len); - /* buf quick ptr to buffered data */ - void (*x_destroy) (XDR *__xdrs); - /* free privates of this xdr_stream */ - bool_t (*x_getint32) (XDR *__xdrs, int32_t *__ip); - /* get a int from underlying stream */ - bool_t (*x_putint32) (XDR *__xdrs, __const int32_t *__ip); - /* put a int to " */ - } - *x_ops; - caddr_t x_public; /* users' data */ - caddr_t x_private; /* pointer to private data */ - caddr_t x_base; /* private used for position info */ - u_int x_handy; /* extra private word */ - }; - -/* - * A xdrproc_t exists for each data type which is to be encoded or decoded. - * - * The second argument to the xdrproc_t is a pointer to an opaque pointer. - * The opaque pointer generally points to a structure of the data type - * to be decoded. If this pointer is 0, then the type routines should - * allocate dynamic storage of the appropriate size and return it. - * bool_t (*xdrproc_t)(XDR *, caddr_t *); - */ -typedef bool_t (*xdrproc_t) (XDR *, void *,...); - - -/* - * Operations defined on a XDR handle - * - * XDR *xdrs; - * int32_t *int32p; - * long *longp; - * caddr_t addr; - * u_int len; - * u_int pos; - */ -#define XDR_GETINT32(xdrs, int32p) \ - (*(xdrs)->x_ops->x_getint32)(xdrs, int32p) -#define xdr_getint32(xdrs, int32p) \ - (*(xdrs)->x_ops->x_getint32)(xdrs, int32p) - -#define XDR_PUTINT32(xdrs, int32p) \ - (*(xdrs)->x_ops->x_putint32)(xdrs, int32p) -#define xdr_putint32(xdrs, int32p) \ - (*(xdrs)->x_ops->x_putint32)(xdrs, int32p) - -#define XDR_GETLONG(xdrs, longp) \ - (*(xdrs)->x_ops->x_getlong)(xdrs, longp) -#define xdr_getlong(xdrs, longp) \ - (*(xdrs)->x_ops->x_getlong)(xdrs, longp) - -#define XDR_PUTLONG(xdrs, longp) \ - (*(xdrs)->x_ops->x_putlong)(xdrs, longp) -#define xdr_putlong(xdrs, longp) \ - (*(xdrs)->x_ops->x_putlong)(xdrs, longp) - -#define XDR_GETBYTES(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) -#define xdr_getbytes(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) - -#define XDR_PUTBYTES(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) -#define xdr_putbytes(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) - -#define XDR_GETPOS(xdrs) \ - (*(xdrs)->x_ops->x_getpostn)(xdrs) -#define xdr_getpos(xdrs) \ - (*(xdrs)->x_ops->x_getpostn)(xdrs) - -#define XDR_SETPOS(xdrs, pos) \ - (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) -#define xdr_setpos(xdrs, pos) \ - (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) - -#define XDR_INLINE(xdrs, len) \ - (*(xdrs)->x_ops->x_inline)(xdrs, len) -#define xdr_inline(xdrs, len) \ - (*(xdrs)->x_ops->x_inline)(xdrs, len) - -#define XDR_DESTROY(xdrs) \ - do { \ - if ((xdrs)->x_ops->x_destroy) \ - (*(xdrs)->x_ops->x_destroy)(xdrs); \ - } while (0) -#define xdr_destroy(xdrs) \ - do { \ - if ((xdrs)->x_ops->x_destroy) \ - (*(xdrs)->x_ops->x_destroy)(xdrs); \ - } while (0) - -/* - * Support struct for discriminated unions. - * You create an array of xdrdiscrim structures, terminated with - * a entry with a null procedure pointer. The xdr_union routine gets - * the discriminant value and then searches the array of structures - * for a matching value. If a match is found the associated xdr routine - * is called to handle that part of the union. If there is - * no match, then a default routine may be called. - * If there is no match and no default routine it is an error. - */ -#define NULL_xdrproc_t ((xdrproc_t)0) -struct xdr_discrim -{ - int value; - xdrproc_t proc; -}; - -/* - * Inline routines for fast encode/decode of primitive data types. - * Caveat emptor: these use single memory cycles to get the - * data from the underlying buffer, and will fail to operate - * properly if the data is not aligned. The standard way to use these - * is to say: - * if ((buf = XDR_INLINE(xdrs, count)) == NULL) - * return (FALSE); - * <<< macro calls >>> - * where ``count'' is the number of bytes of data occupied - * by the primitive data types. - * - * N.B. and frozen for all time: each data type here uses 4 bytes - * of external representation. - */ - -#define IXDR_GET_INT32(buf) ((int32_t)ntohl((uint32_t)*(buf)++)) -#define IXDR_PUT_INT32(buf, v) (*(buf)++ = (int32_t)htonl((uint32_t)(v))) -#define IXDR_GET_U_INT32(buf) ((uint32_t)IXDR_GET_INT32(buf)) -#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32(buf, (int32_t)(v)) - -/* WARNING: The IXDR_*_LONG defines are removed by Sun for new platforms - * and shouldn't be used any longer. Code which use this defines or longs - * in the RPC code will not work on 64bit Solaris platforms ! - */ -#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf)) -#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v))) -#define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf)) -#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG(buf, (long)(v)) - - -#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) -#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) -#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) -#define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf)) - -#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG(buf, (long)(v)) -#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG(buf, (long)(v)) -#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG(buf, (long)(v)) -#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG(buf, (long)(v)) - -/* - * These are the "generic" xdr routines. - * None of these can have const applied because it's not possible to - * know whether the call is a read or a write to the passed parameter - * also, the XDR structure is always updated by some of these calls. - */ -extern bool_t xdr_void (void) __THROW; -extern bool_t xdr_short (XDR *__xdrs, short *__sp) __THROW; -extern bool_t xdr_u_short (XDR *__xdrs, u_short *__usp) __THROW; -extern bool_t xdr_int (XDR *__xdrs, int *__ip) __THROW; -extern bool_t xdr_u_int (XDR *__xdrs, u_int *__up) __THROW; -extern bool_t xdr_long (XDR *__xdrs, long *__lp) __THROW; -extern bool_t xdr_u_long (XDR *__xdrs, u_long *__ulp) __THROW; -extern bool_t xdr_hyper (XDR *__xdrs, quad_t *__llp) __THROW; -extern bool_t xdr_u_hyper (XDR *__xdrs, u_quad_t *__ullp) __THROW; -extern bool_t xdr_longlong_t (XDR *__xdrs, quad_t *__llp) __THROW; -extern bool_t xdr_u_longlong_t (XDR *__xdrs, u_quad_t *__ullp) __THROW; -extern bool_t xdr_int8_t (XDR *__xdrs, int8_t *__ip) __THROW; -extern bool_t xdr_uint8_t (XDR *__xdrs, uint8_t *__up) __THROW; -extern bool_t xdr_int16_t (XDR *__xdrs, int16_t *__ip) __THROW; -extern bool_t xdr_uint16_t (XDR *__xdrs, uint16_t *__up) __THROW; -extern bool_t xdr_int32_t (XDR *__xdrs, int32_t *__ip) __THROW; -extern bool_t xdr_uint32_t (XDR *__xdrs, uint32_t *__up) __THROW; -extern bool_t xdr_int64_t (XDR *__xdrs, int64_t *__ip) __THROW; -extern bool_t xdr_uint64_t (XDR *__xdrs, uint64_t *__up) __THROW; -extern bool_t xdr_quad_t (XDR *__xdrs, quad_t *__ip) __THROW; -extern bool_t xdr_u_quad_t (XDR *__xdrs, u_quad_t *__up) __THROW; -extern bool_t xdr_bool (XDR *__xdrs, bool_t *__bp) __THROW; -extern bool_t xdr_enum (XDR *__xdrs, enum_t *__ep) __THROW; -extern bool_t xdr_array (XDR * _xdrs, caddr_t *__addrp, u_int *__sizep, - u_int __maxsize, u_int __elsize, xdrproc_t __elproc) - __THROW; -extern bool_t xdr_bytes (XDR *__xdrs, char **__cpp, u_int *__sizep, - u_int __maxsize) __THROW; -extern bool_t xdr_opaque (XDR *__xdrs, caddr_t __cp, u_int __cnt) __THROW; -extern bool_t xdr_string (XDR *__xdrs, char **__cpp, u_int __maxsize) __THROW; -extern bool_t xdr_union (XDR *__xdrs, enum_t *__dscmp, char *__unp, - __const struct xdr_discrim *__choices, - xdrproc_t dfault) __THROW; -extern bool_t xdr_char (XDR *__xdrs, char *__cp) __THROW; -extern bool_t xdr_u_char (XDR *__xdrs, u_char *__cp) __THROW; -extern bool_t xdr_vector (XDR *__xdrs, char *__basep, u_int __nelem, - u_int __elemsize, xdrproc_t __xdr_elem) __THROW; -extern bool_t xdr_float (XDR *__xdrs, float *__fp) __THROW; -extern bool_t xdr_double (XDR *__xdrs, double *__dp) __THROW; -extern bool_t xdr_reference (XDR *__xdrs, caddr_t *__xpp, u_int __size, - xdrproc_t __proc) __THROW; -extern bool_t xdr_pointer (XDR *__xdrs, char **__objpp, - u_int __obj_size, xdrproc_t __xdr_obj) __THROW; -extern bool_t xdr_wrapstring (XDR *__xdrs, char **__cpp) __THROW; -extern u_long xdr_sizeof (xdrproc_t, void *) __THROW; - -/* - * Common opaque bytes objects used by many rpc protocols; - * declared here due to commonality. - */ -#define MAX_NETOBJ_SZ 1024 -struct netobj -{ - u_int n_len; - char *n_bytes; -}; -typedef struct netobj netobj; -extern bool_t xdr_netobj (XDR *__xdrs, struct netobj *__np) __THROW; - -/* - * These are the public routines for the various implementations of - * xdr streams. - */ - -/* XDR using memory buffers */ -extern void xdrmem_create (XDR *__xdrs, __const caddr_t __addr, - u_int __size, enum xdr_op __xop) __THROW; - -/* XDR using stdio library */ -extern void xdrstdio_create (XDR *__xdrs, FILE *__file, enum xdr_op __xop) - __THROW; - -/* XDR pseudo records for tcp */ -extern void xdrrec_create (XDR *__xdrs, u_int __sendsize, - u_int __recvsize, caddr_t __tcp_handle, - int (*__readit) (char *, char *, int), - int (*__writeit) (char *, char *, int)) __THROW; - -/* make end of xdr record */ -extern bool_t xdrrec_endofrecord (XDR *__xdrs, bool_t __sendnow) __THROW; - -/* move to beginning of next record */ -extern bool_t xdrrec_skiprecord (XDR *__xdrs) __THROW; - -/* true if no more input */ -extern bool_t xdrrec_eof (XDR *__xdrs) __THROW; - -/* free memory buffers for xdr */ -extern void xdr_free (xdrproc_t __proc, char *__objp) __THROW; - -__END_DECLS - -#endif /* rpc/xdr.h */ diff --git a/source/cluster/wham/src-M/xdrf/xdr_array.c b/source/cluster/wham/src-M/xdrf/xdr_array.c deleted file mode 100644 index 836405c..0000000 --- a/source/cluster/wham/src-M/xdrf/xdr_array.c +++ /dev/null @@ -1,174 +0,0 @@ -# define INTUSE(name) name -# define INTDEF(name) -/* @(#)xdr_array.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * xdr_array.c, Generic XDR routines implementation. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * These are the "non-trivial" xdr primitives used to serialize and de-serialize - * arrays. See xdr.h for more info on the interface to xdr. - */ - -#include -#include -#include "types.h" -#include "xdr.h" -#include -#include - -#ifdef USE_IN_LIBIO -# include -#endif - -#define LASTUNSIGNED ((u_int)0-1) - - -/* - * XDR an array of arbitrary elements - * *addrp is a pointer to the array, *sizep is the number of elements. - * If addrp is NULL (*sizep * elsize) bytes are allocated. - * elsize is the size (in bytes) of each element, and elproc is the - * xdr procedure to call to handle each element of the array. - */ -bool_t -xdr_array (xdrs, addrp, sizep, maxsize, elsize, elproc) - XDR *xdrs; - caddr_t *addrp; /* array pointer */ - u_int *sizep; /* number of elements */ - u_int maxsize; /* max numberof elements */ - u_int elsize; /* size in bytes of each element */ - xdrproc_t elproc; /* xdr routine to handle each element */ -{ - u_int i; - caddr_t target = *addrp; - u_int c; /* the actual element count */ - bool_t stat = TRUE; - u_int nodesize; - - /* like strings, arrays are really counted arrays */ - if (!INTUSE(xdr_u_int) (xdrs, sizep)) - { - return FALSE; - } - c = *sizep; - /* - * XXX: Let the overflow possibly happen with XDR_FREE because mem_free() - * doesn't actually use its second argument anyway. - */ - if ((c > maxsize || c > UINT_MAX / elsize) && (xdrs->x_op != XDR_FREE)) - { - return FALSE; - } - nodesize = c * elsize; - - /* - * if we are deserializing, we may need to allocate an array. - * We also save time by checking for a null array if we are freeing. - */ - if (target == NULL) - switch (xdrs->x_op) - { - case XDR_DECODE: - if (c == 0) - return TRUE; - *addrp = target = mem_alloc (nodesize); - if (target == NULL) - { - fprintf (stderr, "%s", "xdr_array: out of memory\n"); - return FALSE; - } - __bzero (target, nodesize); - break; - - case XDR_FREE: - return TRUE; - default: - break; - } - - /* - * now we xdr each element of array - */ - for (i = 0; (i < c) && stat; i++) - { - stat = (*elproc) (xdrs, target, LASTUNSIGNED); - target += elsize; - } - - /* - * the array may need freeing - */ - if (xdrs->x_op == XDR_FREE) - { - mem_free (*addrp, nodesize); - *addrp = NULL; - } - return stat; -} -INTDEF(xdr_array) - -/* - * xdr_vector(): - * - * XDR a fixed length array. Unlike variable-length arrays, - * the storage of fixed length arrays is static and unfreeable. - * > basep: base of the array - * > size: size of the array - * > elemsize: size of each element - * > xdr_elem: routine to XDR each element - */ -bool_t -xdr_vector (xdrs, basep, nelem, elemsize, xdr_elem) - XDR *xdrs; - char *basep; - u_int nelem; - u_int elemsize; - xdrproc_t xdr_elem; -{ - u_int i; - char *elptr; - - elptr = basep; - for (i = 0; i < nelem; i++) - { - if (!(*xdr_elem) (xdrs, elptr, LASTUNSIGNED)) - { - return FALSE; - } - elptr += elemsize; - } - return TRUE; -} diff --git a/source/cluster/wham/src-M/xdrf/xdr_float.c b/source/cluster/wham/src-M/xdrf/xdr_float.c deleted file mode 100644 index 15d3c88..0000000 --- a/source/cluster/wham/src-M/xdrf/xdr_float.c +++ /dev/null @@ -1,307 +0,0 @@ -/* @(#)xdr_float.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * xdr_float.c, Generic XDR routines implementation. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * These are the "floating point" xdr routines used to (de)serialize - * most common data items. See xdr.h for more info on the interface to - * xdr. - */ - -#include -#include - -#include "types.h" -#include "xdr.h" - -/* - * NB: Not portable. - * This routine works on Suns (Sky / 68000's) and Vaxen. - */ - -#define LSW (__FLOAT_WORD_ORDER == __BIG_ENDIAN) - -#ifdef vax - -/* What IEEE single precision floating point looks like on a Vax */ -struct ieee_single { - unsigned int mantissa: 23; - unsigned int exp : 8; - unsigned int sign : 1; -}; - -/* Vax single precision floating point */ -struct vax_single { - unsigned int mantissa1 : 7; - unsigned int exp : 8; - unsigned int sign : 1; - unsigned int mantissa2 : 16; -}; - -#define VAX_SNG_BIAS 0x81 -#define IEEE_SNG_BIAS 0x7f - -static struct sgl_limits { - struct vax_single s; - struct ieee_single ieee; -} sgl_limits[2] = { - {{ 0x7f, 0xff, 0x0, 0xffff }, /* Max Vax */ - { 0x0, 0xff, 0x0 }}, /* Max IEEE */ - {{ 0x0, 0x0, 0x0, 0x0 }, /* Min Vax */ - { 0x0, 0x0, 0x0 }} /* Min IEEE */ -}; -#endif /* vax */ - -bool_t -xdr_float(xdrs, fp) - XDR *xdrs; - float *fp; -{ -#ifdef vax - struct ieee_single is; - struct vax_single vs, *vsp; - struct sgl_limits *lim; - int i; -#endif - switch (xdrs->x_op) { - - case XDR_ENCODE: -#ifdef vax - vs = *((struct vax_single *)fp); - for (i = 0, lim = sgl_limits; - i < sizeof(sgl_limits)/sizeof(struct sgl_limits); - i++, lim++) { - if ((vs.mantissa2 == lim->s.mantissa2) && - (vs.exp == lim->s.exp) && - (vs.mantissa1 == lim->s.mantissa1)) { - is = lim->ieee; - goto shipit; - } - } - is.exp = vs.exp - VAX_SNG_BIAS + IEEE_SNG_BIAS; - is.mantissa = (vs.mantissa1 << 16) | vs.mantissa2; - shipit: - is.sign = vs.sign; - return (XDR_PUTLONG(xdrs, (long *)&is)); -#else - if (sizeof(float) == sizeof(long)) - return (XDR_PUTLONG(xdrs, (long *)fp)); - else if (sizeof(float) == sizeof(int)) { - long tmp = *(int *)fp; - return (XDR_PUTLONG(xdrs, &tmp)); - } - break; -#endif - - case XDR_DECODE: -#ifdef vax - vsp = (struct vax_single *)fp; - if (!XDR_GETLONG(xdrs, (long *)&is)) - return (FALSE); - for (i = 0, lim = sgl_limits; - i < sizeof(sgl_limits)/sizeof(struct sgl_limits); - i++, lim++) { - if ((is.exp == lim->ieee.exp) && - (is.mantissa == lim->ieee.mantissa)) { - *vsp = lim->s; - goto doneit; - } - } - vsp->exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS; - vsp->mantissa2 = is.mantissa; - vsp->mantissa1 = (is.mantissa >> 16); - doneit: - vsp->sign = is.sign; - return (TRUE); -#else - if (sizeof(float) == sizeof(long)) - return (XDR_GETLONG(xdrs, (long *)fp)); - else if (sizeof(float) == sizeof(int)) { - long tmp; - if (XDR_GETLONG(xdrs, &tmp)) { - *(int *)fp = tmp; - return (TRUE); - } - } - break; -#endif - - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} - -/* - * This routine works on Suns (Sky / 68000's) and Vaxen. - */ - -#ifdef vax -/* What IEEE double precision floating point looks like on a Vax */ -struct ieee_double { - unsigned int mantissa1 : 20; - unsigned int exp : 11; - unsigned int sign : 1; - unsigned int mantissa2 : 32; -}; - -/* Vax double precision floating point */ -struct vax_double { - unsigned int mantissa1 : 7; - unsigned int exp : 8; - unsigned int sign : 1; - unsigned int mantissa2 : 16; - unsigned int mantissa3 : 16; - unsigned int mantissa4 : 16; -}; - -#define VAX_DBL_BIAS 0x81 -#define IEEE_DBL_BIAS 0x3ff -#define MASK(nbits) ((1 << nbits) - 1) - -static struct dbl_limits { - struct vax_double d; - struct ieee_double ieee; -} dbl_limits[2] = { - {{ 0x7f, 0xff, 0x0, 0xffff, 0xffff, 0xffff }, /* Max Vax */ - { 0x0, 0x7ff, 0x0, 0x0 }}, /* Max IEEE */ - {{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* Min Vax */ - { 0x0, 0x0, 0x0, 0x0 }} /* Min IEEE */ -}; - -#endif /* vax */ - - -bool_t -xdr_double(xdrs, dp) - XDR *xdrs; - double *dp; -{ -#ifdef vax - struct ieee_double id; - struct vax_double vd; - register struct dbl_limits *lim; - int i; -#endif - - switch (xdrs->x_op) { - - case XDR_ENCODE: -#ifdef vax - vd = *((struct vax_double *)dp); - for (i = 0, lim = dbl_limits; - i < sizeof(dbl_limits)/sizeof(struct dbl_limits); - i++, lim++) { - if ((vd.mantissa4 == lim->d.mantissa4) && - (vd.mantissa3 == lim->d.mantissa3) && - (vd.mantissa2 == lim->d.mantissa2) && - (vd.mantissa1 == lim->d.mantissa1) && - (vd.exp == lim->d.exp)) { - id = lim->ieee; - goto shipit; - } - } - id.exp = vd.exp - VAX_DBL_BIAS + IEEE_DBL_BIAS; - id.mantissa1 = (vd.mantissa1 << 13) | (vd.mantissa2 >> 3); - id.mantissa2 = ((vd.mantissa2 & MASK(3)) << 29) | - (vd.mantissa3 << 13) | - ((vd.mantissa4 >> 3) & MASK(13)); - shipit: - id.sign = vd.sign; - dp = (double *)&id; -#endif - if (2*sizeof(long) == sizeof(double)) { - long *lp = (long *)dp; - return (XDR_PUTLONG(xdrs, lp+!LSW) && - XDR_PUTLONG(xdrs, lp+LSW)); - } else if (2*sizeof(int) == sizeof(double)) { - int *ip = (int *)dp; - long tmp[2]; - tmp[0] = ip[!LSW]; - tmp[1] = ip[LSW]; - return (XDR_PUTLONG(xdrs, tmp) && - XDR_PUTLONG(xdrs, tmp+1)); - } - break; - - case XDR_DECODE: -#ifdef vax - lp = (long *)&id; - if (!XDR_GETLONG(xdrs, lp++) || !XDR_GETLONG(xdrs, lp)) - return (FALSE); - for (i = 0, lim = dbl_limits; - i < sizeof(dbl_limits)/sizeof(struct dbl_limits); - i++, lim++) { - if ((id.mantissa2 == lim->ieee.mantissa2) && - (id.mantissa1 == lim->ieee.mantissa1) && - (id.exp == lim->ieee.exp)) { - vd = lim->d; - goto doneit; - } - } - vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS; - vd.mantissa1 = (id.mantissa1 >> 13); - vd.mantissa2 = ((id.mantissa1 & MASK(13)) << 3) | - (id.mantissa2 >> 29); - vd.mantissa3 = (id.mantissa2 >> 13); - vd.mantissa4 = (id.mantissa2 << 3); - doneit: - vd.sign = id.sign; - *dp = *((double *)&vd); - return (TRUE); -#else - if (2*sizeof(long) == sizeof(double)) { - long *lp = (long *)dp; - return (XDR_GETLONG(xdrs, lp+!LSW) && - XDR_GETLONG(xdrs, lp+LSW)); - } else if (2*sizeof(int) == sizeof(double)) { - int *ip = (int *)dp; - long tmp[2]; - if (XDR_GETLONG(xdrs, tmp+!LSW) && - XDR_GETLONG(xdrs, tmp+LSW)) { - ip[0] = tmp[0]; - ip[1] = tmp[1]; - return (TRUE); - } - } - break; -#endif - - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} diff --git a/source/cluster/wham/src-M/xdrf/xdr_stdio.c b/source/cluster/wham/src-M/xdrf/xdr_stdio.c deleted file mode 100644 index 12b1709..0000000 --- a/source/cluster/wham/src-M/xdrf/xdr_stdio.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * xdr_stdio.c, XDR implementation on standard i/o file. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * This set of routines implements a XDR on a stdio stream. - * XDR_ENCODE serializes onto the stream, XDR_DECODE de-serializes - * from the stream. - */ - -#include "types.h" -#include -#include "xdr.h" - -#ifdef USE_IN_LIBIO -# include -# define fflush(s) INTUSE(_IO_fflush) (s) -# define fread(p, m, n, s) INTUSE(_IO_fread) (p, m, n, s) -# define ftell(s) INTUSE(_IO_ftell) (s) -# define fwrite(p, m, n, s) INTUSE(_IO_fwrite) (p, m, n, s) -#endif - -static bool_t xdrstdio_getlong (XDR *, long *); -static bool_t xdrstdio_putlong (XDR *, const long *); -static bool_t xdrstdio_getbytes (XDR *, caddr_t, u_int); -static bool_t xdrstdio_putbytes (XDR *, const char *, u_int); -static u_int xdrstdio_getpos (const XDR *); -static bool_t xdrstdio_setpos (XDR *, u_int); -static int32_t *xdrstdio_inline (XDR *, u_int); -static void xdrstdio_destroy (XDR *); -static bool_t xdrstdio_getint32 (XDR *, int32_t *); -static bool_t xdrstdio_putint32 (XDR *, const int32_t *); - -/* - * Ops vector for stdio type XDR - */ -static const struct xdr_ops xdrstdio_ops = -{ - xdrstdio_getlong, /* deserialize a long int */ - xdrstdio_putlong, /* serialize a long int */ - xdrstdio_getbytes, /* deserialize counted bytes */ - xdrstdio_putbytes, /* serialize counted bytes */ - xdrstdio_getpos, /* get offset in the stream */ - xdrstdio_setpos, /* set offset in the stream */ - xdrstdio_inline, /* prime stream for inline macros */ - xdrstdio_destroy, /* destroy stream */ - xdrstdio_getint32, /* deserialize a int */ - xdrstdio_putint32 /* serialize a int */ -}; - -/* - * Initialize a stdio xdr stream. - * Sets the xdr stream handle xdrs for use on the stream file. - * Operation flag is set to op. - */ -void -xdrstdio_create (XDR *xdrs, FILE *file, enum xdr_op op) -{ - xdrs->x_op = op; - /* We have to add the const since the `struct xdr_ops' in `struct XDR' - is not `const'. */ - xdrs->x_ops = (struct xdr_ops *) &xdrstdio_ops; - xdrs->x_private = (caddr_t) file; - xdrs->x_handy = 0; - xdrs->x_base = 0; -} - -/* - * Destroy a stdio xdr stream. - * Cleans up the xdr stream handle xdrs previously set up by xdrstdio_create. - */ -static void -xdrstdio_destroy (XDR *xdrs) -{ - (void) fflush ((FILE *) xdrs->x_private); - /* xx should we close the file ?? */ -}; - -static bool_t -xdrstdio_getlong (XDR *xdrs, long *lp) -{ - u_int32_t mycopy; - - if (fread ((caddr_t) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1) - return FALSE; - *lp = (long) ntohl (mycopy); - return TRUE; -} - -static bool_t -xdrstdio_putlong (XDR *xdrs, const long *lp) -{ - int32_t mycopy = htonl ((u_int32_t) *lp); - - if (fwrite ((caddr_t) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1) - return FALSE; - return TRUE; -} - -static bool_t -xdrstdio_getbytes (XDR *xdrs, const caddr_t addr, u_int len) -{ - if ((len != 0) && (fread (addr, (int) len, 1, - (FILE *) xdrs->x_private) != 1)) - return FALSE; - return TRUE; -} - -static bool_t -xdrstdio_putbytes (XDR *xdrs, const char *addr, u_int len) -{ - if ((len != 0) && (fwrite (addr, (int) len, 1, - (FILE *) xdrs->x_private) != 1)) - return FALSE; - return TRUE; -} - -static u_int -xdrstdio_getpos (const XDR *xdrs) -{ - return (u_int) ftell ((FILE *) xdrs->x_private); -} - -static bool_t -xdrstdio_setpos (XDR *xdrs, u_int pos) -{ - return fseek ((FILE *) xdrs->x_private, (long) pos, 0) < 0 ? FALSE : TRUE; -} - -static int32_t * -xdrstdio_inline (XDR *xdrs, u_int len) -{ - /* - * Must do some work to implement this: must insure - * enough data in the underlying stdio buffer, - * that the buffer is aligned so that we can indirect through a - * long *, and stuff this pointer in xdrs->x_buf. Doing - * a fread or fwrite to a scratch buffer would defeat - * most of the gains to be had here and require storage - * management on this buffer, so we don't do this. - */ - return NULL; -} - -static bool_t -xdrstdio_getint32 (XDR *xdrs, int32_t *ip) -{ - int32_t mycopy; - - if (fread ((caddr_t) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1) - return FALSE; - *ip = ntohl (mycopy); - return TRUE; -} - -static bool_t -xdrstdio_putint32 (XDR *xdrs, const int32_t *ip) -{ - int32_t mycopy = htonl (*ip); - - ip = &mycopy; - if (fwrite ((caddr_t) ip, 4, 1, (FILE *) xdrs->x_private) != 1) - return FALSE; - return TRUE; -} - -/* libc_hidden_def (xdrstdio_create) */ diff --git a/source/cluster/wham/src-M/xdrf/xdrf.h b/source/cluster/wham/src-M/xdrf/xdrf.h deleted file mode 100644 index dedf5a2..0000000 --- a/source/cluster/wham/src-M/xdrf/xdrf.h +++ /dev/null @@ -1,10 +0,0 @@ -/*_________________________________________________________________ - | - | xdrf.h - include file for C routines that want to use the - | functions below. -*/ - -int xdropen(XDR *xdrs, const char *filename, const char *type); -int xdrclose(XDR *xdrs) ; -int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) ; - diff --git a/source/cluster/wham/src/xdrf b/source/cluster/wham/src/xdrf new file mode 120000 index 0000000..b320ac0 --- /dev/null +++ b/source/cluster/wham/src/xdrf @@ -0,0 +1 @@ +../../../lib/xdrf \ No newline at end of file diff --git a/source/cluster/wham/src/xdrf/Makefile b/source/cluster/wham/src/xdrf/Makefile deleted file mode 100644 index 02c29f6..0000000 --- a/source/cluster/wham/src/xdrf/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# This make file is part of the xdrf package. -# -# (C) 1995 Frans van Hoesel, hoesel@chem.rug.nl -# -# 2006 modified by Cezary Czaplewski - -# Set C compiler and flags for ARCH -CC = gcc -CFLAGS = -O - -M4 = m4 -M4FILE = underscore.m4 - -libxdrf.a: libxdrf.o ftocstr.o - ar cr libxdrf.a $? - -clean: - rm -f libxdrf.o ftocstr.o libxdrf.a - -ftocstr.o: ftocstr.c - $(CC) $(CFLAGS) -c ftocstr.c - -libxdrf.o: libxdrf.m4 $(M4FILE) - $(M4) $(M4FILE) libxdrf.m4 > libxdrf.c - $(CC) $(CFLAGS) -c libxdrf.c - rm -f libxdrf.c - diff --git a/source/cluster/wham/src/xdrf/Makefile_jubl b/source/cluster/wham/src/xdrf/Makefile_jubl deleted file mode 100644 index 8dc35cf..0000000 --- a/source/cluster/wham/src/xdrf/Makefile_jubl +++ /dev/null @@ -1,31 +0,0 @@ -# This make file is part of the xdrf package. -# -# (C) 1995 Frans van Hoesel, hoesel@chem.rug.nl -# -# 2006 modified by Cezary Czaplewski - -# Set C compiler and flags for ARCH -BGLSYS = /bgl/BlueLight/ppcfloor/bglsys - -CC = /usr/bin/blrts_xlc -CPPC = /usr/bin/blrts_xlc - -CFLAGS= -O2 -I$(BGLSYS)/include -L$(BGLSYS)/lib -qarch=440d -qtune=440 - -M4 = m4 -M4FILE = RS6K.m4 - -libxdrf.a: libxdrf.o ftocstr.o xdr_array.o xdr.o xdr_float.o xdr_stdio.o - ar cr libxdrf.a $? - -clean: - rm -f *.o libxdrf.a - -ftocstr.o: ftocstr.c - $(CC) $(CFLAGS) -c ftocstr.c - -libxdrf.o: libxdrf.m4 $(M4FILE) - $(M4) $(M4FILE) libxdrf.m4 > libxdrf.c - $(CC) $(CFLAGS) -c libxdrf.c -# rm -f libxdrf.c - diff --git a/source/cluster/wham/src/xdrf/Makefile_linux b/source/cluster/wham/src/xdrf/Makefile_linux deleted file mode 100644 index f03276e..0000000 --- a/source/cluster/wham/src/xdrf/Makefile_linux +++ /dev/null @@ -1,27 +0,0 @@ -# This make file is part of the xdrf package. -# -# (C) 1995 Frans van Hoesel, hoesel@chem.rug.nl -# -# 2006 modified by Cezary Czaplewski - -# Set C compiler and flags for ARCH -CC = cc -CFLAGS = -O - -M4 = m4 -M4FILE = underscore.m4 - -libxdrf.a: libxdrf.o ftocstr.o - ar cr libxdrf.a $? - -clean: - rm -f libxdrf.o ftocstr.o libxdrf.a - -ftocstr.o: ftocstr.c - $(CC) $(CFLAGS) -c ftocstr.c - -libxdrf.o: libxdrf.m4 $(M4FILE) - $(M4) $(M4FILE) libxdrf.m4 > libxdrf.c - $(CC) $(CFLAGS) -c libxdrf.c - rm -f libxdrf.c - diff --git a/source/cluster/wham/src/xdrf/RS6K.m4 b/source/cluster/wham/src/xdrf/RS6K.m4 deleted file mode 100644 index 0331d97..0000000 --- a/source/cluster/wham/src/xdrf/RS6K.m4 +++ /dev/null @@ -1,20 +0,0 @@ -divert(-1) -undefine(`len') -# -# do nothing special to FORTRAN function names -# -define(`FUNCTION',`$1') -# -# FORTRAN character strings are passed as follows: -# a pointer to the base of the string is passed in the normal -# argument list, and the length is passed by value as an extra -# argument, after all of the other arguments. -# -define(`ARGS',`($1`'undivert(1))') -define(`SAVE',`divert(1)$1`'divert(0)') -define(`STRING_ARG',`$1_ptr`'SAVE(`, $1_len')') -define(`STRING_ARG_DECL',`char * $1_ptr; int $1_len') -define(`STRING_LEN',`$1_len') -define(`STRING_PTR',`$1_ptr') -divert(0) - diff --git a/source/cluster/wham/src/xdrf/ftocstr.c b/source/cluster/wham/src/xdrf/ftocstr.c deleted file mode 100644 index ed2113f..0000000 --- a/source/cluster/wham/src/xdrf/ftocstr.c +++ /dev/null @@ -1,35 +0,0 @@ - - -int ftocstr(ds, dl, ss, sl) - char *ds, *ss; /* dst, src ptrs */ - int dl; /* dst max len */ - int sl; /* src len */ -{ - char *p; - - for (p = ss + sl; --p >= ss && *p == ' '; ) ; - sl = p - ss + 1; - dl--; - ds[0] = 0; - if (sl > dl) - return 1; - while (sl--) - (*ds++ = *ss++); - *ds = '\0'; - return 0; -} - - -int ctofstr(ds, dl, ss) - char *ds; /* dest space */ - int dl; /* max dest length */ - char *ss; /* src string (0-term) */ -{ - while (dl && *ss) { - *ds++ = *ss++; - dl--; - } - while (dl--) - *ds++ = ' '; - return 0; -} diff --git a/source/cluster/wham/src/xdrf/libxdrf.m4 b/source/cluster/wham/src/xdrf/libxdrf.m4 deleted file mode 100644 index a6da458..0000000 --- a/source/cluster/wham/src/xdrf/libxdrf.m4 +++ /dev/null @@ -1,1238 +0,0 @@ -/*____________________________________________________________________________ - | - | libxdrf - portable fortran interface to xdr. some xdr routines - | are C routines for compressed coordinates - | - | version 1.1 - | - | This collection of routines is intended to write and read - | data in a portable way to a file, so data written on one type - | of machine can be read back on a different type. - | - | all fortran routines use an integer 'xdrid', which is an id to the - | current xdr file, and is set by xdrfopen. - | most routines have in integer 'ret' which is the return value. - | The value of 'ret' is zero on failure, and most of the time one - | on succes. - | - | There are three routines useful for C users: - | xdropen(), xdrclose(), xdr3dfcoord(). - | The first two replace xdrstdio_create and xdr_destroy, and *must* be - | used when you plan to use xdr3dfcoord(). (they are also a bit - | easier to interface). For writing data other than compressed coordinates - | you should use the standard C xdr routines (see xdr man page) - | - | xdrfopen(xdrid, filename, mode, ret) - | character *(*) filename - | character *(*) mode - | - | this will open the file with the given filename (string) - | and the given mode, it returns an id in xdrid, which is - | to be used in all other calls to xdrf routines. - | mode is 'w' to create, or update an file, for all other - | values of mode the file is opened for reading - | - | you need to call xdrfclose to flush the output and close - | the file. - | Note that you should not use xdrstdio_create, which comes with the - | standard xdr library - | - | xdrfclose(xdrid, ret) - | flush the data to the file, and closes the file; - | You should not use xdr_destroy (which comes standard with - | the xdr libraries. - | - | xdrfbool(xdrid, bp, ret) - | integer pb - | - | This filter produces values of either 1 or 0 - | - | xdrfchar(xdrid, cp, ret) - | character cp - | - | filter that translate between characters and their xdr representation - | Note that the characters in not compressed and occupies 4 bytes. - | - | xdrfdouble(xdrid, dp, ret) - | double dp - | - | read/write a double. - | - | xdrffloat(xdrid, fp, ret) - | float fp - | - | read/write a float. - | - | xdrfint(xdrid, ip, ret) - | integer ip - | - | read/write integer. - | - | xdrflong(xdrid, lp, ret) - | integer lp - | - | this routine has a possible portablility problem due to 64 bits longs. - | - | xdrfshort(xdrid, sp, ret) - | integer *2 sp - | - | xdrfstring(xdrid, sp, maxsize, ret) - | character *(*) - | integer maxsize - | - | read/write a string, with maximum length given by maxsize - | - | xdrfwrapstring(xdris, sp, ret) - | character *(*) - | - | read/write a string (it is the same as xdrfstring accept that it finds - | the stringlength itself. - | - | xdrfvector(xdrid, cp, size, xdrfproc, ret) - | character *(*) - | integer size - | external xdrfproc - | - | read/write an array pointed to by cp, with number of elements - | defined by 'size'. the routine 'xdrfproc' is the name - | of one of the above routines to read/write data (like xdrfdouble) - | In contrast with the c-version you don't need to specify the - | byte size of an element. - | xdrfstring is not allowed here (it is in the c version) - | - | xdrf3dfcoord(xdrid, fp, size, precision, ret) - | real (*) fp - | real precision - | integer size - | - | this is *NOT* a standard xdr routine. I named it this way, because - | it invites people to use the other xdr routines. - | It is introduced to store specifically 3d coordinates of molecules - | (as found in molecular dynamics) and it writes it in a compressed way. - | It starts by multiplying all numbers by precision and - | rounding the result to integer. effectively converting - | all floating point numbers to fixed point. - | it uses an algorithm for compression that is optimized for - | molecular data, but could be used for other 3d coordinates - | as well. There is subtantial overhead involved, so call this - | routine only if you have a large number of coordinates to read/write - | - | ________________________________________________________________________ - | - | Below are the routines to be used by C programmers. Use the 'normal' - | xdr routines to write integers, floats, etc (see man xdr) - | - | int xdropen(XDR *xdrs, const char *filename, const char *type) - | This will open the file with the given filename and the - | given mode. You should pass it an allocated XDR struct - | in xdrs, to be used in all other calls to xdr routines. - | Mode is 'w' to create, or update an file, and for all - | other values of mode the file is opened for reading. - | You need to call xdrclose to flush the output and close - | the file. - | - | Note that you should not use xdrstdio_create, which - | comes with the standard xdr library. - | - | int xdrclose(XDR *xdrs) - | Flush the data to the file, and close the file; - | You should not use xdr_destroy (which comes standard - | with the xdr libraries). - | - | int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) - | This is \fInot\fR a standard xdr routine. I named it this - | way, because it invites people to use the other xdr - | routines. - | - | (c) 1995 Frans van Hoesel, hoesel@chem.rug.nl -*/ - - -#include -#include -#include -/* #include -#include */ -#include "xdr.h" -#include -#include -#include "xdrf.h" - -int ftocstr(char *, int, char *, int); -int ctofstr(char *, int, char *); - -#define MAXID 20 -static FILE *xdrfiles[MAXID]; -static XDR *xdridptr[MAXID]; -static char xdrmodes[MAXID]; -static unsigned int cnt; - -typedef void (* FUNCTION(xdrfproc)) (int *, void *, int *); - -void -FUNCTION(xdrfbool) ARGS(`xdrid, pb, ret') -int *xdrid, *ret; -int *pb; -{ - *ret = xdr_bool(xdridptr[*xdrid], (bool_t *) pb); - cnt += sizeof(int); -} - -void -FUNCTION(xdrfchar) ARGS(`xdrid, cp, ret') -int *xdrid, *ret; -char *cp; -{ - *ret = xdr_char(xdridptr[*xdrid], cp); - cnt += sizeof(char); -} - -void -FUNCTION(xdrfdouble) ARGS(`xdrid, dp, ret') -int *xdrid, *ret; -double *dp; -{ - *ret = xdr_double(xdridptr[*xdrid], dp); - cnt += sizeof(double); -} - -void -FUNCTION(xdrffloat) ARGS(`xdrid, fp, ret') -int *xdrid, *ret; -float *fp; -{ - *ret = xdr_float(xdridptr[*xdrid], fp); - cnt += sizeof(float); -} - -void -FUNCTION(xdrfint) ARGS(`xdrid, ip, ret') -int *xdrid, *ret; -int *ip; -{ - *ret = xdr_int(xdridptr[*xdrid], ip); - cnt += sizeof(int); -} - -void -FUNCTION(xdrflong) ARGS(`xdrid, lp, ret') -int *xdrid, *ret; -long *lp; -{ - *ret = xdr_long(xdridptr[*xdrid], lp); - cnt += sizeof(long); -} - -void -FUNCTION(xdrfshort) ARGS(`xdrid, sp, ret') -int *xdrid, *ret; -short *sp; -{ - *ret = xdr_short(xdridptr[*xdrid], sp); - cnt += sizeof(sp); -} - -void -FUNCTION(xdrfuchar) ARGS(`xdrid, ucp, ret') -int *xdrid, *ret; -char *ucp; -{ - *ret = xdr_u_char(xdridptr[*xdrid], ucp); - cnt += sizeof(char); -} - -void -FUNCTION(xdrfulong) ARGS(`xdrid, ulp, ret') -int *xdrid, *ret; -unsigned long *ulp; -{ - *ret = xdr_u_long(xdridptr[*xdrid], ulp); - cnt += sizeof(unsigned long); -} - -void -FUNCTION(xdrfushort) ARGS(`xdrid, usp, ret') -int *xdrid, *ret; -unsigned short *usp; -{ - *ret = xdr_u_short(xdridptr[*xdrid], usp); - cnt += sizeof(unsigned short); -} - -void -FUNCTION(xdrf3dfcoord) ARGS(`xdrid, fp, size, precision, ret') -int *xdrid, *ret; -float *fp; -int *size; -float *precision; -{ - *ret = xdr3dfcoord(xdridptr[*xdrid], fp, size, precision); -} - -void -FUNCTION(xdrfstring) ARGS(`xdrid, STRING_ARG(sp), maxsize, ret') -int *xdrid, *ret; -STRING_ARG_DECL(sp); -int *maxsize; -{ - char *tsp; - - tsp = (char*) malloc(((STRING_LEN(sp)) + 1) * sizeof(char)); - if (tsp == NULL) { - *ret = -1; - return; - } - if (ftocstr(tsp, *maxsize+1, STRING_PTR(sp), STRING_LEN(sp))) { - *ret = -1; - free(tsp); - return; - } - *ret = xdr_string(xdridptr[*xdrid], (char **) &tsp, (u_int) *maxsize); - ctofstr( STRING_PTR(sp), STRING_LEN(sp), tsp); - cnt += *maxsize; - free(tsp); -} - -void -FUNCTION(xdrfwrapstring) ARGS(`xdrid, STRING_ARG(sp), ret') -int *xdrid, *ret; -STRING_ARG_DECL(sp); -{ - char *tsp; - int maxsize; - maxsize = (STRING_LEN(sp)) + 1; - tsp = (char*) malloc(maxsize * sizeof(char)); - if (tsp == NULL) { - *ret = -1; - return; - } - if (ftocstr(tsp, maxsize, STRING_PTR(sp), STRING_LEN(sp))) { - *ret = -1; - free(tsp); - return; - } - *ret = xdr_string(xdridptr[*xdrid], (char **) &tsp, (u_int)maxsize); - ctofstr( STRING_PTR(sp), STRING_LEN(sp), tsp); - cnt += maxsize; - free(tsp); -} - -void -FUNCTION(xdrfopaque) ARGS(`xdrid, cp, ccnt, ret') -int *xdrid, *ret; -caddr_t *cp; -int *ccnt; -{ - *ret = xdr_opaque(xdridptr[*xdrid], (caddr_t)*cp, (u_int)*ccnt); - cnt += *ccnt; -} - -void -FUNCTION(xdrfsetpos) ARGS(`xdrid, pos, ret') -int *xdrid, *ret; -int *pos; -{ - *ret = xdr_setpos(xdridptr[*xdrid], (u_int) *pos); -} - -void -FUNCTION(xdrf) ARGS(`xdrid, pos') -int *xdrid, *pos; -{ - *pos = xdr_getpos(xdridptr[*xdrid]); -} - -void -FUNCTION(xdrfvector) ARGS(`xdrid, cp, size, elproc, ret') -int *xdrid, *ret; -char *cp; -int *size; -FUNCTION(xdrfproc) elproc; -{ - int lcnt; - cnt = 0; - for (lcnt = 0; lcnt < *size; lcnt++) { - elproc(xdrid, (cp+cnt) , ret); - } -} - - -void -FUNCTION(xdrfclose) ARGS(`xdrid, ret') -int *xdrid; -int *ret; -{ - *ret = xdrclose(xdridptr[*xdrid]); - cnt = 0; -} - -void -FUNCTION(xdrfopen) ARGS(`xdrid, STRING_ARG(fp), STRING_ARG(mode), ret') -int *xdrid; -STRING_ARG_DECL(fp); -STRING_ARG_DECL(mode); -int *ret; -{ - char fname[512]; - char fmode[3]; - - if (ftocstr(fname, sizeof(fname), STRING_PTR(fp), STRING_LEN(fp))) { - *ret = 0; - } - if (ftocstr(fmode, sizeof(fmode), STRING_PTR(mode), - STRING_LEN(mode))) { - *ret = 0; - } - - *xdrid = xdropen(NULL, fname, fmode); - if (*xdrid == 0) - *ret = 0; - else - *ret = 1; -} - -/*___________________________________________________________________________ - | - | what follows are the C routines for opening, closing xdr streams - | and the routine to read/write compressed coordinates together - | with some routines to assist in this task (those are marked - | static and cannot be called from user programs) -*/ -#define MAXABS INT_MAX-2 - -#ifndef MIN -#define MIN(x,y) ((x) < (y) ? (x):(y)) -#endif -#ifndef MAX -#define MAX(x,y) ((x) > (y) ? (x):(y)) -#endif -#ifndef SQR -#define SQR(x) ((x)*(x)) -#endif -static int magicints[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8, 10, 12, 16, 20, 25, 32, 40, 50, 64, - 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, - 812, 1024, 1290, 1625, 2048, 2580, 3250, 4096, 5060, 6501, - 8192, 10321, 13003, 16384, 20642, 26007, 32768, 41285, 52015, 65536, - 82570, 104031, 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561, - 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021, 4194304, 5284491, 6658042, - 8388607, 10568983, 13316085, 16777216 }; - -#define FIRSTIDX 9 -/* note that magicints[FIRSTIDX-1] == 0 */ -#define LASTIDX (sizeof(magicints) / sizeof(*magicints)) - - -/*__________________________________________________________________________ - | - | xdropen - open xdr file - | - | This versions differs from xdrstdio_create, because I need to know - | the state of the file (read or write) so I can use xdr3dfcoord - | in eigther read or write mode, and the file descriptor - | so I can close the file (something xdr_destroy doesn't do). - | -*/ - -int xdropen(XDR *xdrs, const char *filename, const char *type) { - static int init_done = 0; - enum xdr_op lmode; - const char *type1; - int xdrid; - - if (init_done == 0) { - for (xdrid = 1; xdrid < MAXID; xdrid++) { - xdridptr[xdrid] = NULL; - } - init_done = 1; - } - xdrid = 1; - while (xdrid < MAXID && xdridptr[xdrid] != NULL) { - xdrid++; - } - if (xdrid == MAXID) { - return 0; - } - if (*type == 'w' || *type == 'W') { - type = "w+"; - type1 = "w+"; - lmode = XDR_ENCODE; - } else if (*type == 'a' || *type == 'A') { - type = "w+"; - type1 = "a+"; - lmode = XDR_ENCODE; - } else { - type = "r"; - type1 = "r"; - lmode = XDR_DECODE; - } - xdrfiles[xdrid] = fopen(filename, type1); - if (xdrfiles[xdrid] == NULL) { - xdrs = NULL; - return 0; - } - xdrmodes[xdrid] = *type; - /* next test isn't usefull in the case of C language - * but is used for the Fortran interface - * (C users are expected to pass the address of an already allocated - * XDR staructure) - */ - if (xdrs == NULL) { - xdridptr[xdrid] = (XDR *) malloc(sizeof(XDR)); - xdrstdio_create(xdridptr[xdrid], xdrfiles[xdrid], lmode); - } else { - xdridptr[xdrid] = xdrs; - xdrstdio_create(xdrs, xdrfiles[xdrid], lmode); - } - return xdrid; -} - -/*_________________________________________________________________________ - | - | xdrclose - close a xdr file - | - | This will flush the xdr buffers, and destroy the xdr stream. - | It also closes the associated file descriptor (this is *not* - | done by xdr_destroy). - | -*/ - -int xdrclose(XDR *xdrs) { - int xdrid; - - if (xdrs == NULL) { - fprintf(stderr, "xdrclose: passed a NULL pointer\n"); - exit(1); - } - for (xdrid = 1; xdrid < MAXID; xdrid++) { - if (xdridptr[xdrid] == xdrs) { - - xdr_destroy(xdrs); - fclose(xdrfiles[xdrid]); - xdridptr[xdrid] = NULL; - return 1; - } - } - fprintf(stderr, "xdrclose: no such open xdr file\n"); - exit(1); - -} - -/*____________________________________________________________________________ - | - | sendbits - encode num into buf using the specified number of bits - | - | This routines appends the value of num to the bits already present in - | the array buf. You need to give it the number of bits to use and you - | better make sure that this number of bits is enough to hold the value - | Also num must be positive. - | -*/ - -static void sendbits(int buf[], int num_of_bits, int num) { - - unsigned int cnt, lastbyte; - int lastbits; - unsigned char * cbuf; - - cbuf = ((unsigned char *)buf) + 3 * sizeof(*buf); - cnt = (unsigned int) buf[0]; - lastbits = buf[1]; - lastbyte =(unsigned int) buf[2]; - while (num_of_bits >= 8) { - lastbyte = (lastbyte << 8) | ((num >> (num_of_bits -8)) /* & 0xff*/); - cbuf[cnt++] = lastbyte >> lastbits; - num_of_bits -= 8; - } - if (num_of_bits > 0) { - lastbyte = (lastbyte << num_of_bits) | num; - lastbits += num_of_bits; - if (lastbits >= 8) { - lastbits -= 8; - cbuf[cnt++] = lastbyte >> lastbits; - } - } - buf[0] = cnt; - buf[1] = lastbits; - buf[2] = lastbyte; - if (lastbits>0) { - cbuf[cnt] = lastbyte << (8 - lastbits); - } -} - -/*_________________________________________________________________________ - | - | sizeofint - calculate bitsize of an integer - | - | return the number of bits needed to store an integer with given max size - | -*/ - -static int sizeofint(const int size) { - unsigned int num = 1; - int num_of_bits = 0; - - while (size >= num && num_of_bits < 32) { - num_of_bits++; - num <<= 1; - } - return num_of_bits; -} - -/*___________________________________________________________________________ - | - | sizeofints - calculate 'bitsize' of compressed ints - | - | given the number of small unsigned integers and the maximum value - | return the number of bits needed to read or write them with the - | routines receiveints and sendints. You need this parameter when - | calling these routines. Note that for many calls I can use - | the variable 'smallidx' which is exactly the number of bits, and - | So I don't need to call 'sizeofints for those calls. -*/ - -static int sizeofints( const int num_of_ints, unsigned int sizes[]) { - int i, num; - unsigned int num_of_bytes, num_of_bits, bytes[32], bytecnt, tmp; - num_of_bytes = 1; - bytes[0] = 1; - num_of_bits = 0; - for (i=0; i < num_of_ints; i++) { - tmp = 0; - for (bytecnt = 0; bytecnt < num_of_bytes; bytecnt++) { - tmp = bytes[bytecnt] * sizes[i] + tmp; - bytes[bytecnt] = tmp & 0xff; - tmp >>= 8; - } - while (tmp != 0) { - bytes[bytecnt++] = tmp & 0xff; - tmp >>= 8; - } - num_of_bytes = bytecnt; - } - num = 1; - num_of_bytes--; - while (bytes[num_of_bytes] >= num) { - num_of_bits++; - num *= 2; - } - return num_of_bits + num_of_bytes * 8; - -} - -/*____________________________________________________________________________ - | - | sendints - send a small set of small integers in compressed format - | - | this routine is used internally by xdr3dfcoord, to send a set of - | small integers to the buffer. - | Multiplication with fixed (specified maximum ) sizes is used to get - | to one big, multibyte integer. Allthough the routine could be - | modified to handle sizes bigger than 16777216, or more than just - | a few integers, this is not done, because the gain in compression - | isn't worth the effort. Note that overflowing the multiplication - | or the byte buffer (32 bytes) is unchecked and causes bad results. - | - */ - -static void sendints(int buf[], const int num_of_ints, const int num_of_bits, - unsigned int sizes[], unsigned int nums[]) { - - int i; - unsigned int bytes[32], num_of_bytes, bytecnt, tmp; - - tmp = nums[0]; - num_of_bytes = 0; - do { - bytes[num_of_bytes++] = tmp & 0xff; - tmp >>= 8; - } while (tmp != 0); - - for (i = 1; i < num_of_ints; i++) { - if (nums[i] >= sizes[i]) { - fprintf(stderr,"major breakdown in sendints num %d doesn't " - "match size %d\n", nums[i], sizes[i]); - exit(1); - } - /* use one step multiply */ - tmp = nums[i]; - for (bytecnt = 0; bytecnt < num_of_bytes; bytecnt++) { - tmp = bytes[bytecnt] * sizes[i] + tmp; - bytes[bytecnt] = tmp & 0xff; - tmp >>= 8; - } - while (tmp != 0) { - bytes[bytecnt++] = tmp & 0xff; - tmp >>= 8; - } - num_of_bytes = bytecnt; - } - if (num_of_bits >= num_of_bytes * 8) { - for (i = 0; i < num_of_bytes; i++) { - sendbits(buf, 8, bytes[i]); - } - sendbits(buf, num_of_bits - num_of_bytes * 8, 0); - } else { - for (i = 0; i < num_of_bytes-1; i++) { - sendbits(buf, 8, bytes[i]); - } - sendbits(buf, num_of_bits- (num_of_bytes -1) * 8, bytes[i]); - } -} - - -/*___________________________________________________________________________ - | - | receivebits - decode number from buf using specified number of bits - | - | extract the number of bits from the array buf and construct an integer - | from it. Return that value. - | -*/ - -static int receivebits(int buf[], int num_of_bits) { - - int cnt, num; - unsigned int lastbits, lastbyte; - unsigned char * cbuf; - int mask = (1 << num_of_bits) -1; - - cbuf = ((unsigned char *)buf) + 3 * sizeof(*buf); - cnt = buf[0]; - lastbits = (unsigned int) buf[1]; - lastbyte = (unsigned int) buf[2]; - - num = 0; - while (num_of_bits >= 8) { - lastbyte = ( lastbyte << 8 ) | cbuf[cnt++]; - num |= (lastbyte >> lastbits) << (num_of_bits - 8); - num_of_bits -=8; - } - if (num_of_bits > 0) { - if (lastbits < num_of_bits) { - lastbits += 8; - lastbyte = (lastbyte << 8) | cbuf[cnt++]; - } - lastbits -= num_of_bits; - num |= (lastbyte >> lastbits) & ((1 << num_of_bits) -1); - } - num &= mask; - buf[0] = cnt; - buf[1] = lastbits; - buf[2] = lastbyte; - return num; -} - -/*____________________________________________________________________________ - | - | receiveints - decode 'small' integers from the buf array - | - | this routine is the inverse from sendints() and decodes the small integers - | written to buf by calculating the remainder and doing divisions with - | the given sizes[]. You need to specify the total number of bits to be - | used from buf in num_of_bits. - | -*/ - -static void receiveints(int buf[], const int num_of_ints, int num_of_bits, - unsigned int sizes[], int nums[]) { - int bytes[32]; - int i, j, num_of_bytes, p, num; - - bytes[1] = bytes[2] = bytes[3] = 0; - num_of_bytes = 0; - while (num_of_bits > 8) { - bytes[num_of_bytes++] = receivebits(buf, 8); - num_of_bits -= 8; - } - if (num_of_bits > 0) { - bytes[num_of_bytes++] = receivebits(buf, num_of_bits); - } - for (i = num_of_ints-1; i > 0; i--) { - num = 0; - for (j = num_of_bytes-1; j >=0; j--) { - num = (num << 8) | bytes[j]; - p = num / sizes[i]; - bytes[j] = p; - num = num - p * sizes[i]; - } - nums[i] = num; - } - nums[0] = bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24); -} - -/*____________________________________________________________________________ - | - | xdr3dfcoord - read or write compressed 3d coordinates to xdr file. - | - | this routine reads or writes (depending on how you opened the file with - | xdropen() ) a large number of 3d coordinates (stored in *fp). - | The number of coordinates triplets to write is given by *size. On - | read this number may be zero, in which case it reads as many as were written - | or it may specify the number if triplets to read (which should match the - | number written). - | Compression is achieved by first converting all floating numbers to integer - | using multiplication by *precision and rounding to the nearest integer. - | Then the minimum and maximum value are calculated to determine the range. - | The limited range of integers so found, is used to compress the coordinates. - | In addition the differences between succesive coordinates is calculated. - | If the difference happens to be 'small' then only the difference is saved, - | compressing the data even more. The notion of 'small' is changed dynamically - | and is enlarged or reduced whenever needed or possible. - | Extra compression is achieved in the case of GROMOS and coordinates of - | water molecules. GROMOS first writes out the Oxygen position, followed by - | the two hydrogens. In order to make the differences smaller (and thereby - | compression the data better) the order is changed into first one hydrogen - | then the oxygen, followed by the other hydrogen. This is rather special, but - | it shouldn't harm in the general case. - | - */ - -int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) { - - - static int *ip = NULL; - static int oldsize; - static int *buf; - - int minint[3], maxint[3], mindiff, *lip, diff; - int lint1, lint2, lint3, oldlint1, oldlint2, oldlint3, smallidx; - int minidx, maxidx; - unsigned sizeint[3], sizesmall[3], bitsizeint[3], size3, *luip; - int flag, k; - int small, smaller, larger, i, is_small, is_smaller, run, prevrun; - float *lfp, lf; - int tmp, *thiscoord, prevcoord[3]; - unsigned int tmpcoord[30]; - - int bufsize, xdrid, lsize; - unsigned int bitsize; - float inv_precision; - int errval = 1; - - /* find out if xdrs is opened for reading or for writing */ - xdrid = 0; - while (xdridptr[xdrid] != xdrs) { - xdrid++; - if (xdrid >= MAXID) { - fprintf(stderr, "xdr error. no open xdr stream\n"); - exit (1); - } - } - if (xdrmodes[xdrid] == 'w') { - - /* xdrs is open for writing */ - - if (xdr_int(xdrs, size) == 0) - return 0; - size3 = *size * 3; - /* when the number of coordinates is small, don't try to compress; just - * write them as floats using xdr_vector - */ - if (*size <= 9 ) { - return (xdr_vector(xdrs, (char *) fp, size3, sizeof(*fp), - (xdrproc_t)xdr_float)); - } - - xdr_float(xdrs, precision); - if (ip == NULL) { - ip = (int *)malloc(size3 * sizeof(*ip)); - if (ip == NULL) { - fprintf(stderr,"malloc failed\n"); - exit(1); - } - bufsize = size3 * 1.2; - buf = (int *)malloc(bufsize * sizeof(*buf)); - if (buf == NULL) { - fprintf(stderr,"malloc failed\n"); - exit(1); - } - oldsize = *size; - } else if (*size > oldsize) { - ip = (int *)realloc(ip, size3 * sizeof(*ip)); - if (ip == NULL) { - fprintf(stderr,"malloc failed\n"); - exit(1); - } - bufsize = size3 * 1.2; - buf = (int *)realloc(buf, bufsize * sizeof(*buf)); - if (buf == NULL) { - fprintf(stderr,"malloc failed\n"); - exit(1); - } - oldsize = *size; - } - /* buf[0-2] are special and do not contain actual data */ - buf[0] = buf[1] = buf[2] = 0; - minint[0] = minint[1] = minint[2] = INT_MAX; - maxint[0] = maxint[1] = maxint[2] = INT_MIN; - prevrun = -1; - lfp = fp; - lip = ip; - mindiff = INT_MAX; - oldlint1 = oldlint2 = oldlint3 = 0; - while(lfp < fp + size3 ) { - /* find nearest integer */ - if (*lfp >= 0.0) - lf = *lfp * *precision + 0.5; - else - lf = *lfp * *precision - 0.5; - if (fabs(lf) > MAXABS) { - /* scaling would cause overflow */ - errval = 0; - } - lint1 = lf; - if (lint1 < minint[0]) minint[0] = lint1; - if (lint1 > maxint[0]) maxint[0] = lint1; - *lip++ = lint1; - lfp++; - if (*lfp >= 0.0) - lf = *lfp * *precision + 0.5; - else - lf = *lfp * *precision - 0.5; - if (fabs(lf) > MAXABS) { - /* scaling would cause overflow */ - errval = 0; - } - lint2 = lf; - if (lint2 < minint[1]) minint[1] = lint2; - if (lint2 > maxint[1]) maxint[1] = lint2; - *lip++ = lint2; - lfp++; - if (*lfp >= 0.0) - lf = *lfp * *precision + 0.5; - else - lf = *lfp * *precision - 0.5; - if (fabs(lf) > MAXABS) { - /* scaling would cause overflow */ - errval = 0; - } - lint3 = lf; - if (lint3 < minint[2]) minint[2] = lint3; - if (lint3 > maxint[2]) maxint[2] = lint3; - *lip++ = lint3; - lfp++; - diff = abs(oldlint1-lint1)+abs(oldlint2-lint2)+abs(oldlint3-lint3); - if (diff < mindiff && lfp > fp + 3) - mindiff = diff; - oldlint1 = lint1; - oldlint2 = lint2; - oldlint3 = lint3; - } - xdr_int(xdrs, &(minint[0])); - xdr_int(xdrs, &(minint[1])); - xdr_int(xdrs, &(minint[2])); - - xdr_int(xdrs, &(maxint[0])); - xdr_int(xdrs, &(maxint[1])); - xdr_int(xdrs, &(maxint[2])); - - if ((float)maxint[0] - (float)minint[0] >= MAXABS || - (float)maxint[1] - (float)minint[1] >= MAXABS || - (float)maxint[2] - (float)minint[2] >= MAXABS) { - /* turning value in unsigned by subtracting minint - * would cause overflow - */ - errval = 0; - } - sizeint[0] = maxint[0] - minint[0]+1; - sizeint[1] = maxint[1] - minint[1]+1; - sizeint[2] = maxint[2] - minint[2]+1; - - /* check if one of the sizes is to big to be multiplied */ - if ((sizeint[0] | sizeint[1] | sizeint[2] ) > 0xffffff) { - bitsizeint[0] = sizeofint(sizeint[0]); - bitsizeint[1] = sizeofint(sizeint[1]); - bitsizeint[2] = sizeofint(sizeint[2]); - bitsize = 0; /* flag the use of large sizes */ - } else { - bitsize = sizeofints(3, sizeint); - } - lip = ip; - luip = (unsigned int *) ip; - smallidx = FIRSTIDX; - while (smallidx < LASTIDX && magicints[smallidx] < mindiff) { - smallidx++; - } - xdr_int(xdrs, &smallidx); - maxidx = MIN(LASTIDX, smallidx + 8) ; - minidx = maxidx - 8; /* often this equal smallidx */ - smaller = magicints[MAX(FIRSTIDX, smallidx-1)] / 2; - small = magicints[smallidx] / 2; - sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx]; - larger = magicints[maxidx] / 2; - i = 0; - while (i < *size) { - is_small = 0; - thiscoord = (int *)(luip) + i * 3; - if (smallidx < maxidx && i >= 1 && - abs(thiscoord[0] - prevcoord[0]) < larger && - abs(thiscoord[1] - prevcoord[1]) < larger && - abs(thiscoord[2] - prevcoord[2]) < larger) { - is_smaller = 1; - } else if (smallidx > minidx) { - is_smaller = -1; - } else { - is_smaller = 0; - } - if (i + 1 < *size) { - if (abs(thiscoord[0] - thiscoord[3]) < small && - abs(thiscoord[1] - thiscoord[4]) < small && - abs(thiscoord[2] - thiscoord[5]) < small) { - /* interchange first with second atom for better - * compression of water molecules - */ - tmp = thiscoord[0]; thiscoord[0] = thiscoord[3]; - thiscoord[3] = tmp; - tmp = thiscoord[1]; thiscoord[1] = thiscoord[4]; - thiscoord[4] = tmp; - tmp = thiscoord[2]; thiscoord[2] = thiscoord[5]; - thiscoord[5] = tmp; - is_small = 1; - } - - } - tmpcoord[0] = thiscoord[0] - minint[0]; - tmpcoord[1] = thiscoord[1] - minint[1]; - tmpcoord[2] = thiscoord[2] - minint[2]; - if (bitsize == 0) { - sendbits(buf, bitsizeint[0], tmpcoord[0]); - sendbits(buf, bitsizeint[1], tmpcoord[1]); - sendbits(buf, bitsizeint[2], tmpcoord[2]); - } else { - sendints(buf, 3, bitsize, sizeint, tmpcoord); - } - prevcoord[0] = thiscoord[0]; - prevcoord[1] = thiscoord[1]; - prevcoord[2] = thiscoord[2]; - thiscoord = thiscoord + 3; - i++; - - run = 0; - if (is_small == 0 && is_smaller == -1) - is_smaller = 0; - while (is_small && run < 8*3) { - if (is_smaller == -1 && ( - SQR(thiscoord[0] - prevcoord[0]) + - SQR(thiscoord[1] - prevcoord[1]) + - SQR(thiscoord[2] - prevcoord[2]) >= smaller * smaller)) { - is_smaller = 0; - } - - tmpcoord[run++] = thiscoord[0] - prevcoord[0] + small; - tmpcoord[run++] = thiscoord[1] - prevcoord[1] + small; - tmpcoord[run++] = thiscoord[2] - prevcoord[2] + small; - - prevcoord[0] = thiscoord[0]; - prevcoord[1] = thiscoord[1]; - prevcoord[2] = thiscoord[2]; - - i++; - thiscoord = thiscoord + 3; - is_small = 0; - if (i < *size && - abs(thiscoord[0] - prevcoord[0]) < small && - abs(thiscoord[1] - prevcoord[1]) < small && - abs(thiscoord[2] - prevcoord[2]) < small) { - is_small = 1; - } - } - if (run != prevrun || is_smaller != 0) { - prevrun = run; - sendbits(buf, 1, 1); /* flag the change in run-length */ - sendbits(buf, 5, run+is_smaller+1); - } else { - sendbits(buf, 1, 0); /* flag the fact that runlength did not change */ - } - for (k=0; k < run; k+=3) { - sendints(buf, 3, smallidx, sizesmall, &tmpcoord[k]); - } - if (is_smaller != 0) { - smallidx += is_smaller; - if (is_smaller < 0) { - small = smaller; - smaller = magicints[smallidx-1] / 2; - } else { - smaller = small; - small = magicints[smallidx] / 2; - } - sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx]; - } - } - if (buf[1] != 0) buf[0]++;; - xdr_int(xdrs, &(buf[0])); /* buf[0] holds the length in bytes */ - return errval * (xdr_opaque(xdrs, (caddr_t)&(buf[3]), (u_int)buf[0])); - } else { - - /* xdrs is open for reading */ - - if (xdr_int(xdrs, &lsize) == 0) - return 0; - if (*size != 0 && lsize != *size) { - fprintf(stderr, "wrong number of coordinates in xdr3dfcoor; " - "%d arg vs %d in file", *size, lsize); - } - *size = lsize; - size3 = *size * 3; - if (*size <= 9) { - return (xdr_vector(xdrs, (char *) fp, size3, sizeof(*fp), - (xdrproc_t)xdr_float)); - } - xdr_float(xdrs, precision); - if (ip == NULL) { - ip = (int *)malloc(size3 * sizeof(*ip)); - if (ip == NULL) { - fprintf(stderr,"malloc failed\n"); - exit(1); - } - bufsize = size3 * 1.2; - buf = (int *)malloc(bufsize * sizeof(*buf)); - if (buf == NULL) { - fprintf(stderr,"malloc failed\n"); - exit(1); - } - oldsize = *size; - } else if (*size > oldsize) { - ip = (int *)realloc(ip, size3 * sizeof(*ip)); - if (ip == NULL) { - fprintf(stderr,"malloc failed\n"); - exit(1); - } - bufsize = size3 * 1.2; - buf = (int *)realloc(buf, bufsize * sizeof(*buf)); - if (buf == NULL) { - fprintf(stderr,"malloc failed\n"); - exit(1); - } - oldsize = *size; - } - buf[0] = buf[1] = buf[2] = 0; - - xdr_int(xdrs, &(minint[0])); - xdr_int(xdrs, &(minint[1])); - xdr_int(xdrs, &(minint[2])); - - xdr_int(xdrs, &(maxint[0])); - xdr_int(xdrs, &(maxint[1])); - xdr_int(xdrs, &(maxint[2])); - - sizeint[0] = maxint[0] - minint[0]+1; - sizeint[1] = maxint[1] - minint[1]+1; - sizeint[2] = maxint[2] - minint[2]+1; - - /* check if one of the sizes is to big to be multiplied */ - if ((sizeint[0] | sizeint[1] | sizeint[2] ) > 0xffffff) { - bitsizeint[0] = sizeofint(sizeint[0]); - bitsizeint[1] = sizeofint(sizeint[1]); - bitsizeint[2] = sizeofint(sizeint[2]); - bitsize = 0; /* flag the use of large sizes */ - } else { - bitsize = sizeofints(3, sizeint); - } - - xdr_int(xdrs, &smallidx); - maxidx = MIN(LASTIDX, smallidx + 8) ; - minidx = maxidx - 8; /* often this equal smallidx */ - smaller = magicints[MAX(FIRSTIDX, smallidx-1)] / 2; - small = magicints[smallidx] / 2; - sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx] ; - larger = magicints[maxidx]; - - /* buf[0] holds the length in bytes */ - - if (xdr_int(xdrs, &(buf[0])) == 0) - return 0; - if (xdr_opaque(xdrs, (caddr_t)&(buf[3]), (u_int)buf[0]) == 0) - return 0; - buf[0] = buf[1] = buf[2] = 0; - - lfp = fp; - inv_precision = 1.0 / * precision; - run = 0; - i = 0; - lip = ip; - while ( i < lsize ) { - thiscoord = (int *)(lip) + i * 3; - - if (bitsize == 0) { - thiscoord[0] = receivebits(buf, bitsizeint[0]); - thiscoord[1] = receivebits(buf, bitsizeint[1]); - thiscoord[2] = receivebits(buf, bitsizeint[2]); - } else { - receiveints(buf, 3, bitsize, sizeint, thiscoord); - } - - i++; - thiscoord[0] += minint[0]; - thiscoord[1] += minint[1]; - thiscoord[2] += minint[2]; - - prevcoord[0] = thiscoord[0]; - prevcoord[1] = thiscoord[1]; - prevcoord[2] = thiscoord[2]; - - - flag = receivebits(buf, 1); - is_smaller = 0; - if (flag == 1) { - run = receivebits(buf, 5); - is_smaller = run % 3; - run -= is_smaller; - is_smaller--; - } - if (run > 0) { - thiscoord += 3; - for (k = 0; k < run; k+=3) { - receiveints(buf, 3, smallidx, sizesmall, thiscoord); - i++; - thiscoord[0] += prevcoord[0] - small; - thiscoord[1] += prevcoord[1] - small; - thiscoord[2] += prevcoord[2] - small; - if (k == 0) { - /* interchange first with second atom for better - * compression of water molecules - */ - tmp = thiscoord[0]; thiscoord[0] = prevcoord[0]; - prevcoord[0] = tmp; - tmp = thiscoord[1]; thiscoord[1] = prevcoord[1]; - prevcoord[1] = tmp; - tmp = thiscoord[2]; thiscoord[2] = prevcoord[2]; - prevcoord[2] = tmp; - *lfp++ = prevcoord[0] * inv_precision; - *lfp++ = prevcoord[1] * inv_precision; - *lfp++ = prevcoord[2] * inv_precision; - } else { - prevcoord[0] = thiscoord[0]; - prevcoord[1] = thiscoord[1]; - prevcoord[2] = thiscoord[2]; - } - *lfp++ = thiscoord[0] * inv_precision; - *lfp++ = thiscoord[1] * inv_precision; - *lfp++ = thiscoord[2] * inv_precision; - } - } else { - *lfp++ = thiscoord[0] * inv_precision; - *lfp++ = thiscoord[1] * inv_precision; - *lfp++ = thiscoord[2] * inv_precision; - } - smallidx += is_smaller; - if (is_smaller < 0) { - small = smaller; - if (smallidx > FIRSTIDX) { - smaller = magicints[smallidx - 1] /2; - } else { - smaller = 0; - } - } else if (is_smaller > 0) { - smaller = small; - small = magicints[smallidx] / 2; - } - sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx] ; - } - } - return 1; -} - - - diff --git a/source/cluster/wham/src/xdrf/types.h b/source/cluster/wham/src/xdrf/types.h deleted file mode 100644 index 871f3fd..0000000 --- a/source/cluster/wham/src/xdrf/types.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* fixincludes should not add extern "C" to this file */ -/* - * Rpc additions to - */ -#ifndef _RPC_TYPES_H -#define _RPC_TYPES_H 1 - -typedef int bool_t; -typedef int enum_t; -/* This needs to be changed to uint32_t in the future */ -typedef unsigned long rpcprog_t; -typedef unsigned long rpcvers_t; -typedef unsigned long rpcproc_t; -typedef unsigned long rpcprot_t; -typedef unsigned long rpcport_t; - -#define __dontcare__ -1 - -#ifndef FALSE -# define FALSE (0) -#endif - -#ifndef TRUE -# define TRUE (1) -#endif - -#ifndef NULL -# define NULL 0 -#endif - -#include /* For malloc decl. */ -#define mem_alloc(bsize) malloc(bsize) -/* - * XXX: This must not use the second argument, or code in xdr_array.c needs - * to be modified. - */ -#define mem_free(ptr, bsize) free(ptr) - -#ifndef makedev /* ie, we haven't already included it */ -#include -#endif - -#ifndef __u_char_defined -typedef __u_char u_char; -typedef __u_short u_short; -typedef __u_int u_int; -typedef __u_long u_long; -typedef __quad_t quad_t; -typedef __u_quad_t u_quad_t; -typedef __fsid_t fsid_t; -# define __u_char_defined -#endif -#ifndef __daddr_t_defined -typedef __daddr_t daddr_t; -typedef __caddr_t caddr_t; -# define __daddr_t_defined -#endif - -#include -#include - -#include - -#ifndef INADDR_LOOPBACK -#define INADDR_LOOPBACK (u_long)0x7F000001 -#endif -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 64 -#endif - -#endif /* rpc/types.h */ diff --git a/source/cluster/wham/src/xdrf/underscore.m4 b/source/cluster/wham/src/xdrf/underscore.m4 deleted file mode 100644 index 4d620a0..0000000 --- a/source/cluster/wham/src/xdrf/underscore.m4 +++ /dev/null @@ -1,19 +0,0 @@ -divert(-1) -undefine(`len') -# -# append an underscore to FORTRAN function names -# -define(`FUNCTION',`$1_') -# -# FORTRAN character strings are passed as follows: -# a pointer to the base of the string is passed in the normal -# argument list, and the length is passed by value as an extra -# argument, after all of the other arguments. -# -define(`ARGS',`($1`'undivert(1))') -define(`SAVE',`divert(1)$1`'divert(0)') -define(`STRING_ARG',`$1_ptr`'SAVE(`, $1_len')') -define(`STRING_ARG_DECL',`char * $1_ptr; int $1_len') -define(`STRING_LEN',`$1_len') -define(`STRING_PTR',`$1_ptr') -divert(0) diff --git a/source/cluster/wham/src/xdrf/xdr.c b/source/cluster/wham/src/xdrf/xdr.c deleted file mode 100644 index 33b8544..0000000 --- a/source/cluster/wham/src/xdrf/xdr.c +++ /dev/null @@ -1,752 +0,0 @@ -# define INTUSE(name) name -# define INTDEF(name) -/* @(#)xdr.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)xdr.c 1.35 87/08/12"; -#endif - -/* - * xdr.c, Generic XDR routines implementation. - * - * Copyright (C) 1986, Sun Microsystems, Inc. - * - * These are the "generic" xdr routines used to serialize and de-serialize - * most common data items. See xdr.h for more info on the interface to - * xdr. - */ - -#include -#include -#include -#include - -#include "types.h" -#include "xdr.h" - -#ifdef USE_IN_LIBIO -# include -#endif - -/* - * constants specific to the xdr "protocol" - */ -#define XDR_FALSE ((long) 0) -#define XDR_TRUE ((long) 1) -#define LASTUNSIGNED ((u_int) 0-1) - -/* - * for unit alignment - */ -static const char xdr_zero[BYTES_PER_XDR_UNIT] = {0, 0, 0, 0}; - -/* - * Free a data structure using XDR - * Not a filter, but a convenient utility nonetheless - */ -void -xdr_free (xdrproc_t proc, char *objp) -{ - XDR x; - - x.x_op = XDR_FREE; - (*proc) (&x, objp); -} - -/* - * XDR nothing - */ -bool_t -xdr_void (void) -{ - return TRUE; -} -INTDEF(xdr_void) - -/* - * XDR integers - */ -bool_t -xdr_int (XDR *xdrs, int *ip) -{ - -#if INT_MAX < LONG_MAX - long l; - - switch (xdrs->x_op) - { - case XDR_ENCODE: - l = (long) *ip; - return XDR_PUTLONG (xdrs, &l); - - case XDR_DECODE: - if (!XDR_GETLONG (xdrs, &l)) - { - return FALSE; - } - *ip = (int) l; - case XDR_FREE: - return TRUE; - } - return FALSE; -#elif INT_MAX == LONG_MAX - return INTUSE(xdr_long) (xdrs, (long *) ip); -#elif INT_MAX == SHRT_MAX - return INTUSE(xdr_short) (xdrs, (short *) ip); -#else -#error unexpected integer sizes in_xdr_int() -#endif -} -INTDEF(xdr_int) - -/* - * XDR unsigned integers - */ -bool_t -xdr_u_int (XDR *xdrs, u_int *up) -{ -#if UINT_MAX < ULONG_MAX - long l; - - switch (xdrs->x_op) - { - case XDR_ENCODE: - l = (u_long) * up; - return XDR_PUTLONG (xdrs, &l); - - case XDR_DECODE: - if (!XDR_GETLONG (xdrs, &l)) - { - return FALSE; - } - *up = (u_int) (u_long) l; - case XDR_FREE: - return TRUE; - } - return FALSE; -#elif UINT_MAX == ULONG_MAX - return INTUSE(xdr_u_long) (xdrs, (u_long *) up); -#elif UINT_MAX == USHRT_MAX - return INTUSE(xdr_short) (xdrs, (short *) up); -#else -#error unexpected integer sizes in_xdr_u_int() -#endif -} -INTDEF(xdr_u_int) - -/* - * XDR long integers - * The definition of xdr_long() is kept for backward - * compatibility. Instead xdr_int() should be used. - */ -bool_t -xdr_long (XDR *xdrs, long *lp) -{ - - if (xdrs->x_op == XDR_ENCODE - && (sizeof (int32_t) == sizeof (long) - || (int32_t) *lp == *lp)) - return XDR_PUTLONG (xdrs, lp); - - if (xdrs->x_op == XDR_DECODE) - return XDR_GETLONG (xdrs, lp); - - if (xdrs->x_op == XDR_FREE) - return TRUE; - - return FALSE; -} -INTDEF(xdr_long) - -/* - * XDR unsigned long integers - * The definition of xdr_u_long() is kept for backward - * compatibility. Instead xdr_u_int() should be used. - */ -bool_t -xdr_u_long (XDR *xdrs, u_long *ulp) -{ - switch (xdrs->x_op) - { - case XDR_DECODE: - { - long int tmp; - - if (XDR_GETLONG (xdrs, &tmp) == FALSE) - return FALSE; - - *ulp = (uint32_t) tmp; - return TRUE; - } - - case XDR_ENCODE: - if (sizeof (uint32_t) != sizeof (u_long) - && (uint32_t) *ulp != *ulp) - return FALSE; - - return XDR_PUTLONG (xdrs, (long *) ulp); - - case XDR_FREE: - return TRUE; - } - return FALSE; -} -INTDEF(xdr_u_long) - -/* - * XDR hyper integers - * same as xdr_u_hyper - open coded to save a proc call! - */ -bool_t -xdr_hyper (XDR *xdrs, quad_t *llp) -{ - long int t1, t2; - - if (xdrs->x_op == XDR_ENCODE) - { - t1 = (long) ((*llp) >> 32); - t2 = (long) (*llp); - return (XDR_PUTLONG(xdrs, &t1) && XDR_PUTLONG(xdrs, &t2)); - } - - if (xdrs->x_op == XDR_DECODE) - { - if (!XDR_GETLONG(xdrs, &t1) || !XDR_GETLONG(xdrs, &t2)) - return FALSE; - *llp = ((quad_t) t1) << 32; - *llp |= (uint32_t) t2; - return TRUE; - } - - if (xdrs->x_op == XDR_FREE) - return TRUE; - - return FALSE; -} -INTDEF(xdr_hyper) - - -/* - * XDR hyper integers - * same as xdr_hyper - open coded to save a proc call! - */ -bool_t -xdr_u_hyper (XDR *xdrs, u_quad_t *ullp) -{ - long int t1, t2; - - if (xdrs->x_op == XDR_ENCODE) - { - t1 = (unsigned long) ((*ullp) >> 32); - t2 = (unsigned long) (*ullp); - return (XDR_PUTLONG(xdrs, &t1) && XDR_PUTLONG(xdrs, &t2)); - } - - if (xdrs->x_op == XDR_DECODE) - { - if (!XDR_GETLONG(xdrs, &t1) || !XDR_GETLONG(xdrs, &t2)) - return FALSE; - *ullp = ((u_quad_t) t1) << 32; - *ullp |= (uint32_t) t2; - return TRUE; - } - - if (xdrs->x_op == XDR_FREE) - return TRUE; - - return FALSE; -} -INTDEF(xdr_u_hyper) - -bool_t -xdr_longlong_t (XDR *xdrs, quad_t *llp) -{ - return INTUSE(xdr_hyper) (xdrs, llp); -} - -bool_t -xdr_u_longlong_t (XDR *xdrs, u_quad_t *ullp) -{ - return INTUSE(xdr_u_hyper) (xdrs, ullp); -} - -/* - * XDR short integers - */ -bool_t -xdr_short (XDR *xdrs, short *sp) -{ - long l; - - switch (xdrs->x_op) - { - case XDR_ENCODE: - l = (long) *sp; - return XDR_PUTLONG (xdrs, &l); - - case XDR_DECODE: - if (!XDR_GETLONG (xdrs, &l)) - { - return FALSE; - } - *sp = (short) l; - return TRUE; - - case XDR_FREE: - return TRUE; - } - return FALSE; -} -INTDEF(xdr_short) - -/* - * XDR unsigned short integers - */ -bool_t -xdr_u_short (XDR *xdrs, u_short *usp) -{ - long l; - - switch (xdrs->x_op) - { - case XDR_ENCODE: - l = (u_long) * usp; - return XDR_PUTLONG (xdrs, &l); - - case XDR_DECODE: - if (!XDR_GETLONG (xdrs, &l)) - { - return FALSE; - } - *usp = (u_short) (u_long) l; - return TRUE; - - case XDR_FREE: - return TRUE; - } - return FALSE; -} -INTDEF(xdr_u_short) - - -/* - * XDR a char - */ -bool_t -xdr_char (XDR *xdrs, char *cp) -{ - int i; - - i = (*cp); - if (!INTUSE(xdr_int) (xdrs, &i)) - { - return FALSE; - } - *cp = i; - return TRUE; -} - -/* - * XDR an unsigned char - */ -bool_t -xdr_u_char (XDR *xdrs, u_char *cp) -{ - u_int u; - - u = (*cp); - if (!INTUSE(xdr_u_int) (xdrs, &u)) - { - return FALSE; - } - *cp = u; - return TRUE; -} - -/* - * XDR booleans - */ -bool_t -xdr_bool (XDR *xdrs, bool_t *bp) -{ - long lb; - - switch (xdrs->x_op) - { - case XDR_ENCODE: - lb = *bp ? XDR_TRUE : XDR_FALSE; - return XDR_PUTLONG (xdrs, &lb); - - case XDR_DECODE: - if (!XDR_GETLONG (xdrs, &lb)) - { - return FALSE; - } - *bp = (lb == XDR_FALSE) ? FALSE : TRUE; - return TRUE; - - case XDR_FREE: - return TRUE; - } - return FALSE; -} -INTDEF(xdr_bool) - -/* - * XDR enumerations - */ -bool_t -xdr_enum (XDR *xdrs, enum_t *ep) -{ - enum sizecheck - { - SIZEVAL - }; /* used to find the size of an enum */ - - /* - * enums are treated as ints - */ - if (sizeof (enum sizecheck) == 4) - { -#if INT_MAX < LONG_MAX - long l; - - switch (xdrs->x_op) - { - case XDR_ENCODE: - l = *ep; - return XDR_PUTLONG (xdrs, &l); - - case XDR_DECODE: - if (!XDR_GETLONG (xdrs, &l)) - { - return FALSE; - } - *ep = l; - case XDR_FREE: - return TRUE; - - } - return FALSE; -#else - return INTUSE(xdr_long) (xdrs, (long *) ep); -#endif - } - else if (sizeof (enum sizecheck) == sizeof (short)) - { - return INTUSE(xdr_short) (xdrs, (short *) ep); - } - else - { - return FALSE; - } -} -INTDEF(xdr_enum) - -/* - * XDR opaque data - * Allows the specification of a fixed size sequence of opaque bytes. - * cp points to the opaque object and cnt gives the byte length. - */ -bool_t -xdr_opaque (XDR *xdrs, caddr_t cp, u_int cnt) -{ - u_int rndup; - static char crud[BYTES_PER_XDR_UNIT]; - - /* - * if no data we are done - */ - if (cnt == 0) - return TRUE; - - /* - * round byte count to full xdr units - */ - rndup = cnt % BYTES_PER_XDR_UNIT; - if (rndup > 0) - rndup = BYTES_PER_XDR_UNIT - rndup; - - switch (xdrs->x_op) - { - case XDR_DECODE: - if (!XDR_GETBYTES (xdrs, cp, cnt)) - { - return FALSE; - } - if (rndup == 0) - return TRUE; - return XDR_GETBYTES (xdrs, (caddr_t)crud, rndup); - - case XDR_ENCODE: - if (!XDR_PUTBYTES (xdrs, cp, cnt)) - { - return FALSE; - } - if (rndup == 0) - return TRUE; - return XDR_PUTBYTES (xdrs, xdr_zero, rndup); - - case XDR_FREE: - return TRUE; - } - return FALSE; -} -INTDEF(xdr_opaque) - -/* - * XDR counted bytes - * *cpp is a pointer to the bytes, *sizep is the count. - * If *cpp is NULL maxsize bytes are allocated - */ -bool_t -xdr_bytes (xdrs, cpp, sizep, maxsize) - XDR *xdrs; - char **cpp; - u_int *sizep; - u_int maxsize; -{ - char *sp = *cpp; /* sp is the actual string pointer */ - u_int nodesize; - - /* - * first deal with the length since xdr bytes are counted - */ - if (!INTUSE(xdr_u_int) (xdrs, sizep)) - { - return FALSE; - } - nodesize = *sizep; - if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) - { - return FALSE; - } - - /* - * now deal with the actual bytes - */ - switch (xdrs->x_op) - { - case XDR_DECODE: - if (nodesize == 0) - { - return TRUE; - } - if (sp == NULL) - { - *cpp = sp = (char *) mem_alloc (nodesize); - } - if (sp == NULL) - { - fprintf (NULL, "%s", "xdr_bytes: out of memory\n"); - return FALSE; - } - /* fall into ... */ - - case XDR_ENCODE: - return INTUSE(xdr_opaque) (xdrs, sp, nodesize); - - case XDR_FREE: - if (sp != NULL) - { - mem_free (sp, nodesize); - *cpp = NULL; - } - return TRUE; - } - return FALSE; -} -INTDEF(xdr_bytes) - -/* - * Implemented here due to commonality of the object. - */ -bool_t -xdr_netobj (xdrs, np) - XDR *xdrs; - struct netobj *np; -{ - - return INTUSE(xdr_bytes) (xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ); -} -INTDEF(xdr_netobj) - -/* - * XDR a discriminated union - * Support routine for discriminated unions. - * You create an array of xdrdiscrim structures, terminated with - * an entry with a null procedure pointer. The routine gets - * the discriminant value and then searches the array of xdrdiscrims - * looking for that value. It calls the procedure given in the xdrdiscrim - * to handle the discriminant. If there is no specific routine a default - * routine may be called. - * If there is no specific or default routine an error is returned. - */ -bool_t -xdr_union (xdrs, dscmp, unp, choices, dfault) - XDR *xdrs; - enum_t *dscmp; /* enum to decide which arm to work on */ - char *unp; /* the union itself */ - const struct xdr_discrim *choices; /* [value, xdr proc] for each arm */ - xdrproc_t dfault; /* default xdr routine */ -{ - enum_t dscm; - - /* - * we deal with the discriminator; it's an enum - */ - if (!INTUSE(xdr_enum) (xdrs, dscmp)) - { - return FALSE; - } - dscm = *dscmp; - - /* - * search choices for a value that matches the discriminator. - * if we find one, execute the xdr routine for that value. - */ - for (; choices->proc != NULL_xdrproc_t; choices++) - { - if (choices->value == dscm) - return (*(choices->proc)) (xdrs, unp, LASTUNSIGNED); - } - - /* - * no match - execute the default xdr routine if there is one - */ - return ((dfault == NULL_xdrproc_t) ? FALSE : - (*dfault) (xdrs, unp, LASTUNSIGNED)); -} -INTDEF(xdr_union) - - -/* - * Non-portable xdr primitives. - * Care should be taken when moving these routines to new architectures. - */ - - -/* - * XDR null terminated ASCII strings - * xdr_string deals with "C strings" - arrays of bytes that are - * terminated by a NULL character. The parameter cpp references a - * pointer to storage; If the pointer is null, then the necessary - * storage is allocated. The last parameter is the max allowed length - * of the string as specified by a protocol. - */ -bool_t -xdr_string (xdrs, cpp, maxsize) - XDR *xdrs; - char **cpp; - u_int maxsize; -{ - char *sp = *cpp; /* sp is the actual string pointer */ - u_int size; - u_int nodesize; - - /* - * first deal with the length since xdr strings are counted-strings - */ - switch (xdrs->x_op) - { - case XDR_FREE: - if (sp == NULL) - { - return TRUE; /* already free */ - } - /* fall through... */ - case XDR_ENCODE: - if (sp == NULL) - return FALSE; - size = strlen (sp); - break; - case XDR_DECODE: - break; - } - if (!INTUSE(xdr_u_int) (xdrs, &size)) - { - return FALSE; - } - if (size > maxsize) - { - return FALSE; - } - nodesize = size + 1; - if (nodesize == 0) - { - /* This means an overflow. It a bug in the caller which - provided a too large maxsize but nevertheless catch it - here. */ - return FALSE; - } - - /* - * now deal with the actual bytes - */ - switch (xdrs->x_op) - { - case XDR_DECODE: - if (sp == NULL) - *cpp = sp = (char *) mem_alloc (nodesize); - if (sp == NULL) - { - fprintf (NULL, "%s", "xdr_string: out of memory\n"); - return FALSE; - } - sp[size] = 0; - /* fall into ... */ - - case XDR_ENCODE: - return INTUSE(xdr_opaque) (xdrs, sp, size); - - case XDR_FREE: - mem_free (sp, nodesize); - *cpp = NULL; - return TRUE; - } - return FALSE; -} -INTDEF(xdr_string) - -/* - * Wrapper for xdr_string that can be called directly from - * routines like clnt_call - */ -bool_t -xdr_wrapstring (xdrs, cpp) - XDR *xdrs; - char **cpp; -{ - if (INTUSE(xdr_string) (xdrs, cpp, LASTUNSIGNED)) - { - return TRUE; - } - return FALSE; -} diff --git a/source/cluster/wham/src/xdrf/xdr.h b/source/cluster/wham/src/xdrf/xdr.h deleted file mode 100644 index 2602ad9..0000000 --- a/source/cluster/wham/src/xdrf/xdr.h +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * xdr.h, External Data Representation Serialization Routines. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#ifndef _RPC_XDR_H -#define _RPC_XDR_H 1 - -#include -#include -#include "types.h" - -/* We need FILE. */ -#include - -__BEGIN_DECLS - -/* - * XDR provides a conventional way for converting between C data - * types and an external bit-string representation. Library supplied - * routines provide for the conversion on built-in C data types. These - * routines and utility routines defined here are used to help implement - * a type encode/decode routine for each user-defined type. - * - * Each data type provides a single procedure which takes two arguments: - * - * bool_t - * xdrproc(xdrs, argresp) - * XDR *xdrs; - * *argresp; - * - * xdrs is an instance of a XDR handle, to which or from which the data - * type is to be converted. argresp is a pointer to the structure to be - * converted. The XDR handle contains an operation field which indicates - * which of the operations (ENCODE, DECODE * or FREE) is to be performed. - * - * XDR_DECODE may allocate space if the pointer argresp is null. This - * data can be freed with the XDR_FREE operation. - * - * We write only one procedure per data type to make it easy - * to keep the encode and decode procedures for a data type consistent. - * In many cases the same code performs all operations on a user defined type, - * because all the hard work is done in the component type routines. - * decode as a series of calls on the nested data types. - */ - -/* - * Xdr operations. XDR_ENCODE causes the type to be encoded into the - * stream. XDR_DECODE causes the type to be extracted from the stream. - * XDR_FREE can be used to release the space allocated by an XDR_DECODE - * request. - */ -enum xdr_op { - XDR_ENCODE = 0, - XDR_DECODE = 1, - XDR_FREE = 2 -}; - -/* - * This is the number of bytes per unit of external data. - */ -#define BYTES_PER_XDR_UNIT (4) -/* - * This only works if the above is a power of 2. But it's defined to be - * 4 by the appropriate RFCs. So it will work. And it's normally quicker - * than the old routine. - */ -#if 1 -#define RNDUP(x) (((x) + BYTES_PER_XDR_UNIT - 1) & ~(BYTES_PER_XDR_UNIT - 1)) -#else /* this is the old routine */ -#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ - * BYTES_PER_XDR_UNIT) -#endif - -/* - * The XDR handle. - * Contains operation which is being applied to the stream, - * an operations vector for the particular implementation (e.g. see xdr_mem.c), - * and two private fields for the use of the particular implementation. - */ -typedef struct XDR XDR; -struct XDR - { - enum xdr_op x_op; /* operation; fast additional param */ - struct xdr_ops - { - bool_t (*x_getlong) (XDR *__xdrs, long *__lp); - /* get a long from underlying stream */ - bool_t (*x_putlong) (XDR *__xdrs, __const long *__lp); - /* put a long to " */ - bool_t (*x_getbytes) (XDR *__xdrs, caddr_t __addr, u_int __len); - /* get some bytes from " */ - bool_t (*x_putbytes) (XDR *__xdrs, __const char *__addr, u_int __len); - /* put some bytes to " */ - u_int (*x_getpostn) (__const XDR *__xdrs); - /* returns bytes off from beginning */ - bool_t (*x_setpostn) (XDR *__xdrs, u_int __pos); - /* lets you reposition the stream */ - int32_t *(*x_inline) (XDR *__xdrs, u_int __len); - /* buf quick ptr to buffered data */ - void (*x_destroy) (XDR *__xdrs); - /* free privates of this xdr_stream */ - bool_t (*x_getint32) (XDR *__xdrs, int32_t *__ip); - /* get a int from underlying stream */ - bool_t (*x_putint32) (XDR *__xdrs, __const int32_t *__ip); - /* put a int to " */ - } - *x_ops; - caddr_t x_public; /* users' data */ - caddr_t x_private; /* pointer to private data */ - caddr_t x_base; /* private used for position info */ - u_int x_handy; /* extra private word */ - }; - -/* - * A xdrproc_t exists for each data type which is to be encoded or decoded. - * - * The second argument to the xdrproc_t is a pointer to an opaque pointer. - * The opaque pointer generally points to a structure of the data type - * to be decoded. If this pointer is 0, then the type routines should - * allocate dynamic storage of the appropriate size and return it. - * bool_t (*xdrproc_t)(XDR *, caddr_t *); - */ -typedef bool_t (*xdrproc_t) (XDR *, void *,...); - - -/* - * Operations defined on a XDR handle - * - * XDR *xdrs; - * int32_t *int32p; - * long *longp; - * caddr_t addr; - * u_int len; - * u_int pos; - */ -#define XDR_GETINT32(xdrs, int32p) \ - (*(xdrs)->x_ops->x_getint32)(xdrs, int32p) -#define xdr_getint32(xdrs, int32p) \ - (*(xdrs)->x_ops->x_getint32)(xdrs, int32p) - -#define XDR_PUTINT32(xdrs, int32p) \ - (*(xdrs)->x_ops->x_putint32)(xdrs, int32p) -#define xdr_putint32(xdrs, int32p) \ - (*(xdrs)->x_ops->x_putint32)(xdrs, int32p) - -#define XDR_GETLONG(xdrs, longp) \ - (*(xdrs)->x_ops->x_getlong)(xdrs, longp) -#define xdr_getlong(xdrs, longp) \ - (*(xdrs)->x_ops->x_getlong)(xdrs, longp) - -#define XDR_PUTLONG(xdrs, longp) \ - (*(xdrs)->x_ops->x_putlong)(xdrs, longp) -#define xdr_putlong(xdrs, longp) \ - (*(xdrs)->x_ops->x_putlong)(xdrs, longp) - -#define XDR_GETBYTES(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) -#define xdr_getbytes(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) - -#define XDR_PUTBYTES(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) -#define xdr_putbytes(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) - -#define XDR_GETPOS(xdrs) \ - (*(xdrs)->x_ops->x_getpostn)(xdrs) -#define xdr_getpos(xdrs) \ - (*(xdrs)->x_ops->x_getpostn)(xdrs) - -#define XDR_SETPOS(xdrs, pos) \ - (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) -#define xdr_setpos(xdrs, pos) \ - (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) - -#define XDR_INLINE(xdrs, len) \ - (*(xdrs)->x_ops->x_inline)(xdrs, len) -#define xdr_inline(xdrs, len) \ - (*(xdrs)->x_ops->x_inline)(xdrs, len) - -#define XDR_DESTROY(xdrs) \ - do { \ - if ((xdrs)->x_ops->x_destroy) \ - (*(xdrs)->x_ops->x_destroy)(xdrs); \ - } while (0) -#define xdr_destroy(xdrs) \ - do { \ - if ((xdrs)->x_ops->x_destroy) \ - (*(xdrs)->x_ops->x_destroy)(xdrs); \ - } while (0) - -/* - * Support struct for discriminated unions. - * You create an array of xdrdiscrim structures, terminated with - * a entry with a null procedure pointer. The xdr_union routine gets - * the discriminant value and then searches the array of structures - * for a matching value. If a match is found the associated xdr routine - * is called to handle that part of the union. If there is - * no match, then a default routine may be called. - * If there is no match and no default routine it is an error. - */ -#define NULL_xdrproc_t ((xdrproc_t)0) -struct xdr_discrim -{ - int value; - xdrproc_t proc; -}; - -/* - * Inline routines for fast encode/decode of primitive data types. - * Caveat emptor: these use single memory cycles to get the - * data from the underlying buffer, and will fail to operate - * properly if the data is not aligned. The standard way to use these - * is to say: - * if ((buf = XDR_INLINE(xdrs, count)) == NULL) - * return (FALSE); - * <<< macro calls >>> - * where ``count'' is the number of bytes of data occupied - * by the primitive data types. - * - * N.B. and frozen for all time: each data type here uses 4 bytes - * of external representation. - */ - -#define IXDR_GET_INT32(buf) ((int32_t)ntohl((uint32_t)*(buf)++)) -#define IXDR_PUT_INT32(buf, v) (*(buf)++ = (int32_t)htonl((uint32_t)(v))) -#define IXDR_GET_U_INT32(buf) ((uint32_t)IXDR_GET_INT32(buf)) -#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32(buf, (int32_t)(v)) - -/* WARNING: The IXDR_*_LONG defines are removed by Sun for new platforms - * and shouldn't be used any longer. Code which use this defines or longs - * in the RPC code will not work on 64bit Solaris platforms ! - */ -#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf)) -#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v))) -#define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf)) -#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG(buf, (long)(v)) - - -#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) -#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) -#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) -#define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf)) - -#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG(buf, (long)(v)) -#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG(buf, (long)(v)) -#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG(buf, (long)(v)) -#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG(buf, (long)(v)) - -/* - * These are the "generic" xdr routines. - * None of these can have const applied because it's not possible to - * know whether the call is a read or a write to the passed parameter - * also, the XDR structure is always updated by some of these calls. - */ -extern bool_t xdr_void (void) __THROW; -extern bool_t xdr_short (XDR *__xdrs, short *__sp) __THROW; -extern bool_t xdr_u_short (XDR *__xdrs, u_short *__usp) __THROW; -extern bool_t xdr_int (XDR *__xdrs, int *__ip) __THROW; -extern bool_t xdr_u_int (XDR *__xdrs, u_int *__up) __THROW; -extern bool_t xdr_long (XDR *__xdrs, long *__lp) __THROW; -extern bool_t xdr_u_long (XDR *__xdrs, u_long *__ulp) __THROW; -extern bool_t xdr_hyper (XDR *__xdrs, quad_t *__llp) __THROW; -extern bool_t xdr_u_hyper (XDR *__xdrs, u_quad_t *__ullp) __THROW; -extern bool_t xdr_longlong_t (XDR *__xdrs, quad_t *__llp) __THROW; -extern bool_t xdr_u_longlong_t (XDR *__xdrs, u_quad_t *__ullp) __THROW; -extern bool_t xdr_int8_t (XDR *__xdrs, int8_t *__ip) __THROW; -extern bool_t xdr_uint8_t (XDR *__xdrs, uint8_t *__up) __THROW; -extern bool_t xdr_int16_t (XDR *__xdrs, int16_t *__ip) __THROW; -extern bool_t xdr_uint16_t (XDR *__xdrs, uint16_t *__up) __THROW; -extern bool_t xdr_int32_t (XDR *__xdrs, int32_t *__ip) __THROW; -extern bool_t xdr_uint32_t (XDR *__xdrs, uint32_t *__up) __THROW; -extern bool_t xdr_int64_t (XDR *__xdrs, int64_t *__ip) __THROW; -extern bool_t xdr_uint64_t (XDR *__xdrs, uint64_t *__up) __THROW; -extern bool_t xdr_quad_t (XDR *__xdrs, quad_t *__ip) __THROW; -extern bool_t xdr_u_quad_t (XDR *__xdrs, u_quad_t *__up) __THROW; -extern bool_t xdr_bool (XDR *__xdrs, bool_t *__bp) __THROW; -extern bool_t xdr_enum (XDR *__xdrs, enum_t *__ep) __THROW; -extern bool_t xdr_array (XDR * _xdrs, caddr_t *__addrp, u_int *__sizep, - u_int __maxsize, u_int __elsize, xdrproc_t __elproc) - __THROW; -extern bool_t xdr_bytes (XDR *__xdrs, char **__cpp, u_int *__sizep, - u_int __maxsize) __THROW; -extern bool_t xdr_opaque (XDR *__xdrs, caddr_t __cp, u_int __cnt) __THROW; -extern bool_t xdr_string (XDR *__xdrs, char **__cpp, u_int __maxsize) __THROW; -extern bool_t xdr_union (XDR *__xdrs, enum_t *__dscmp, char *__unp, - __const struct xdr_discrim *__choices, - xdrproc_t dfault) __THROW; -extern bool_t xdr_char (XDR *__xdrs, char *__cp) __THROW; -extern bool_t xdr_u_char (XDR *__xdrs, u_char *__cp) __THROW; -extern bool_t xdr_vector (XDR *__xdrs, char *__basep, u_int __nelem, - u_int __elemsize, xdrproc_t __xdr_elem) __THROW; -extern bool_t xdr_float (XDR *__xdrs, float *__fp) __THROW; -extern bool_t xdr_double (XDR *__xdrs, double *__dp) __THROW; -extern bool_t xdr_reference (XDR *__xdrs, caddr_t *__xpp, u_int __size, - xdrproc_t __proc) __THROW; -extern bool_t xdr_pointer (XDR *__xdrs, char **__objpp, - u_int __obj_size, xdrproc_t __xdr_obj) __THROW; -extern bool_t xdr_wrapstring (XDR *__xdrs, char **__cpp) __THROW; -extern u_long xdr_sizeof (xdrproc_t, void *) __THROW; - -/* - * Common opaque bytes objects used by many rpc protocols; - * declared here due to commonality. - */ -#define MAX_NETOBJ_SZ 1024 -struct netobj -{ - u_int n_len; - char *n_bytes; -}; -typedef struct netobj netobj; -extern bool_t xdr_netobj (XDR *__xdrs, struct netobj *__np) __THROW; - -/* - * These are the public routines for the various implementations of - * xdr streams. - */ - -/* XDR using memory buffers */ -extern void xdrmem_create (XDR *__xdrs, __const caddr_t __addr, - u_int __size, enum xdr_op __xop) __THROW; - -/* XDR using stdio library */ -extern void xdrstdio_create (XDR *__xdrs, FILE *__file, enum xdr_op __xop) - __THROW; - -/* XDR pseudo records for tcp */ -extern void xdrrec_create (XDR *__xdrs, u_int __sendsize, - u_int __recvsize, caddr_t __tcp_handle, - int (*__readit) (char *, char *, int), - int (*__writeit) (char *, char *, int)) __THROW; - -/* make end of xdr record */ -extern bool_t xdrrec_endofrecord (XDR *__xdrs, bool_t __sendnow) __THROW; - -/* move to beginning of next record */ -extern bool_t xdrrec_skiprecord (XDR *__xdrs) __THROW; - -/* true if no more input */ -extern bool_t xdrrec_eof (XDR *__xdrs) __THROW; - -/* free memory buffers for xdr */ -extern void xdr_free (xdrproc_t __proc, char *__objp) __THROW; - -__END_DECLS - -#endif /* rpc/xdr.h */ diff --git a/source/cluster/wham/src/xdrf/xdr_array.c b/source/cluster/wham/src/xdrf/xdr_array.c deleted file mode 100644 index 836405c..0000000 --- a/source/cluster/wham/src/xdrf/xdr_array.c +++ /dev/null @@ -1,174 +0,0 @@ -# define INTUSE(name) name -# define INTDEF(name) -/* @(#)xdr_array.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * xdr_array.c, Generic XDR routines implementation. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * These are the "non-trivial" xdr primitives used to serialize and de-serialize - * arrays. See xdr.h for more info on the interface to xdr. - */ - -#include -#include -#include "types.h" -#include "xdr.h" -#include -#include - -#ifdef USE_IN_LIBIO -# include -#endif - -#define LASTUNSIGNED ((u_int)0-1) - - -/* - * XDR an array of arbitrary elements - * *addrp is a pointer to the array, *sizep is the number of elements. - * If addrp is NULL (*sizep * elsize) bytes are allocated. - * elsize is the size (in bytes) of each element, and elproc is the - * xdr procedure to call to handle each element of the array. - */ -bool_t -xdr_array (xdrs, addrp, sizep, maxsize, elsize, elproc) - XDR *xdrs; - caddr_t *addrp; /* array pointer */ - u_int *sizep; /* number of elements */ - u_int maxsize; /* max numberof elements */ - u_int elsize; /* size in bytes of each element */ - xdrproc_t elproc; /* xdr routine to handle each element */ -{ - u_int i; - caddr_t target = *addrp; - u_int c; /* the actual element count */ - bool_t stat = TRUE; - u_int nodesize; - - /* like strings, arrays are really counted arrays */ - if (!INTUSE(xdr_u_int) (xdrs, sizep)) - { - return FALSE; - } - c = *sizep; - /* - * XXX: Let the overflow possibly happen with XDR_FREE because mem_free() - * doesn't actually use its second argument anyway. - */ - if ((c > maxsize || c > UINT_MAX / elsize) && (xdrs->x_op != XDR_FREE)) - { - return FALSE; - } - nodesize = c * elsize; - - /* - * if we are deserializing, we may need to allocate an array. - * We also save time by checking for a null array if we are freeing. - */ - if (target == NULL) - switch (xdrs->x_op) - { - case XDR_DECODE: - if (c == 0) - return TRUE; - *addrp = target = mem_alloc (nodesize); - if (target == NULL) - { - fprintf (stderr, "%s", "xdr_array: out of memory\n"); - return FALSE; - } - __bzero (target, nodesize); - break; - - case XDR_FREE: - return TRUE; - default: - break; - } - - /* - * now we xdr each element of array - */ - for (i = 0; (i < c) && stat; i++) - { - stat = (*elproc) (xdrs, target, LASTUNSIGNED); - target += elsize; - } - - /* - * the array may need freeing - */ - if (xdrs->x_op == XDR_FREE) - { - mem_free (*addrp, nodesize); - *addrp = NULL; - } - return stat; -} -INTDEF(xdr_array) - -/* - * xdr_vector(): - * - * XDR a fixed length array. Unlike variable-length arrays, - * the storage of fixed length arrays is static and unfreeable. - * > basep: base of the array - * > size: size of the array - * > elemsize: size of each element - * > xdr_elem: routine to XDR each element - */ -bool_t -xdr_vector (xdrs, basep, nelem, elemsize, xdr_elem) - XDR *xdrs; - char *basep; - u_int nelem; - u_int elemsize; - xdrproc_t xdr_elem; -{ - u_int i; - char *elptr; - - elptr = basep; - for (i = 0; i < nelem; i++) - { - if (!(*xdr_elem) (xdrs, elptr, LASTUNSIGNED)) - { - return FALSE; - } - elptr += elemsize; - } - return TRUE; -} diff --git a/source/cluster/wham/src/xdrf/xdr_float.c b/source/cluster/wham/src/xdrf/xdr_float.c deleted file mode 100644 index 15d3c88..0000000 --- a/source/cluster/wham/src/xdrf/xdr_float.c +++ /dev/null @@ -1,307 +0,0 @@ -/* @(#)xdr_float.c 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro"; -#endif - -/* - * xdr_float.c, Generic XDR routines implementation. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * These are the "floating point" xdr routines used to (de)serialize - * most common data items. See xdr.h for more info on the interface to - * xdr. - */ - -#include -#include - -#include "types.h" -#include "xdr.h" - -/* - * NB: Not portable. - * This routine works on Suns (Sky / 68000's) and Vaxen. - */ - -#define LSW (__FLOAT_WORD_ORDER == __BIG_ENDIAN) - -#ifdef vax - -/* What IEEE single precision floating point looks like on a Vax */ -struct ieee_single { - unsigned int mantissa: 23; - unsigned int exp : 8; - unsigned int sign : 1; -}; - -/* Vax single precision floating point */ -struct vax_single { - unsigned int mantissa1 : 7; - unsigned int exp : 8; - unsigned int sign : 1; - unsigned int mantissa2 : 16; -}; - -#define VAX_SNG_BIAS 0x81 -#define IEEE_SNG_BIAS 0x7f - -static struct sgl_limits { - struct vax_single s; - struct ieee_single ieee; -} sgl_limits[2] = { - {{ 0x7f, 0xff, 0x0, 0xffff }, /* Max Vax */ - { 0x0, 0xff, 0x0 }}, /* Max IEEE */ - {{ 0x0, 0x0, 0x0, 0x0 }, /* Min Vax */ - { 0x0, 0x0, 0x0 }} /* Min IEEE */ -}; -#endif /* vax */ - -bool_t -xdr_float(xdrs, fp) - XDR *xdrs; - float *fp; -{ -#ifdef vax - struct ieee_single is; - struct vax_single vs, *vsp; - struct sgl_limits *lim; - int i; -#endif - switch (xdrs->x_op) { - - case XDR_ENCODE: -#ifdef vax - vs = *((struct vax_single *)fp); - for (i = 0, lim = sgl_limits; - i < sizeof(sgl_limits)/sizeof(struct sgl_limits); - i++, lim++) { - if ((vs.mantissa2 == lim->s.mantissa2) && - (vs.exp == lim->s.exp) && - (vs.mantissa1 == lim->s.mantissa1)) { - is = lim->ieee; - goto shipit; - } - } - is.exp = vs.exp - VAX_SNG_BIAS + IEEE_SNG_BIAS; - is.mantissa = (vs.mantissa1 << 16) | vs.mantissa2; - shipit: - is.sign = vs.sign; - return (XDR_PUTLONG(xdrs, (long *)&is)); -#else - if (sizeof(float) == sizeof(long)) - return (XDR_PUTLONG(xdrs, (long *)fp)); - else if (sizeof(float) == sizeof(int)) { - long tmp = *(int *)fp; - return (XDR_PUTLONG(xdrs, &tmp)); - } - break; -#endif - - case XDR_DECODE: -#ifdef vax - vsp = (struct vax_single *)fp; - if (!XDR_GETLONG(xdrs, (long *)&is)) - return (FALSE); - for (i = 0, lim = sgl_limits; - i < sizeof(sgl_limits)/sizeof(struct sgl_limits); - i++, lim++) { - if ((is.exp == lim->ieee.exp) && - (is.mantissa == lim->ieee.mantissa)) { - *vsp = lim->s; - goto doneit; - } - } - vsp->exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS; - vsp->mantissa2 = is.mantissa; - vsp->mantissa1 = (is.mantissa >> 16); - doneit: - vsp->sign = is.sign; - return (TRUE); -#else - if (sizeof(float) == sizeof(long)) - return (XDR_GETLONG(xdrs, (long *)fp)); - else if (sizeof(float) == sizeof(int)) { - long tmp; - if (XDR_GETLONG(xdrs, &tmp)) { - *(int *)fp = tmp; - return (TRUE); - } - } - break; -#endif - - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} - -/* - * This routine works on Suns (Sky / 68000's) and Vaxen. - */ - -#ifdef vax -/* What IEEE double precision floating point looks like on a Vax */ -struct ieee_double { - unsigned int mantissa1 : 20; - unsigned int exp : 11; - unsigned int sign : 1; - unsigned int mantissa2 : 32; -}; - -/* Vax double precision floating point */ -struct vax_double { - unsigned int mantissa1 : 7; - unsigned int exp : 8; - unsigned int sign : 1; - unsigned int mantissa2 : 16; - unsigned int mantissa3 : 16; - unsigned int mantissa4 : 16; -}; - -#define VAX_DBL_BIAS 0x81 -#define IEEE_DBL_BIAS 0x3ff -#define MASK(nbits) ((1 << nbits) - 1) - -static struct dbl_limits { - struct vax_double d; - struct ieee_double ieee; -} dbl_limits[2] = { - {{ 0x7f, 0xff, 0x0, 0xffff, 0xffff, 0xffff }, /* Max Vax */ - { 0x0, 0x7ff, 0x0, 0x0 }}, /* Max IEEE */ - {{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* Min Vax */ - { 0x0, 0x0, 0x0, 0x0 }} /* Min IEEE */ -}; - -#endif /* vax */ - - -bool_t -xdr_double(xdrs, dp) - XDR *xdrs; - double *dp; -{ -#ifdef vax - struct ieee_double id; - struct vax_double vd; - register struct dbl_limits *lim; - int i; -#endif - - switch (xdrs->x_op) { - - case XDR_ENCODE: -#ifdef vax - vd = *((struct vax_double *)dp); - for (i = 0, lim = dbl_limits; - i < sizeof(dbl_limits)/sizeof(struct dbl_limits); - i++, lim++) { - if ((vd.mantissa4 == lim->d.mantissa4) && - (vd.mantissa3 == lim->d.mantissa3) && - (vd.mantissa2 == lim->d.mantissa2) && - (vd.mantissa1 == lim->d.mantissa1) && - (vd.exp == lim->d.exp)) { - id = lim->ieee; - goto shipit; - } - } - id.exp = vd.exp - VAX_DBL_BIAS + IEEE_DBL_BIAS; - id.mantissa1 = (vd.mantissa1 << 13) | (vd.mantissa2 >> 3); - id.mantissa2 = ((vd.mantissa2 & MASK(3)) << 29) | - (vd.mantissa3 << 13) | - ((vd.mantissa4 >> 3) & MASK(13)); - shipit: - id.sign = vd.sign; - dp = (double *)&id; -#endif - if (2*sizeof(long) == sizeof(double)) { - long *lp = (long *)dp; - return (XDR_PUTLONG(xdrs, lp+!LSW) && - XDR_PUTLONG(xdrs, lp+LSW)); - } else if (2*sizeof(int) == sizeof(double)) { - int *ip = (int *)dp; - long tmp[2]; - tmp[0] = ip[!LSW]; - tmp[1] = ip[LSW]; - return (XDR_PUTLONG(xdrs, tmp) && - XDR_PUTLONG(xdrs, tmp+1)); - } - break; - - case XDR_DECODE: -#ifdef vax - lp = (long *)&id; - if (!XDR_GETLONG(xdrs, lp++) || !XDR_GETLONG(xdrs, lp)) - return (FALSE); - for (i = 0, lim = dbl_limits; - i < sizeof(dbl_limits)/sizeof(struct dbl_limits); - i++, lim++) { - if ((id.mantissa2 == lim->ieee.mantissa2) && - (id.mantissa1 == lim->ieee.mantissa1) && - (id.exp == lim->ieee.exp)) { - vd = lim->d; - goto doneit; - } - } - vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS; - vd.mantissa1 = (id.mantissa1 >> 13); - vd.mantissa2 = ((id.mantissa1 & MASK(13)) << 3) | - (id.mantissa2 >> 29); - vd.mantissa3 = (id.mantissa2 >> 13); - vd.mantissa4 = (id.mantissa2 << 3); - doneit: - vd.sign = id.sign; - *dp = *((double *)&vd); - return (TRUE); -#else - if (2*sizeof(long) == sizeof(double)) { - long *lp = (long *)dp; - return (XDR_GETLONG(xdrs, lp+!LSW) && - XDR_GETLONG(xdrs, lp+LSW)); - } else if (2*sizeof(int) == sizeof(double)) { - int *ip = (int *)dp; - long tmp[2]; - if (XDR_GETLONG(xdrs, tmp+!LSW) && - XDR_GETLONG(xdrs, tmp+LSW)) { - ip[0] = tmp[0]; - ip[1] = tmp[1]; - return (TRUE); - } - } - break; -#endif - - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} diff --git a/source/cluster/wham/src/xdrf/xdr_stdio.c b/source/cluster/wham/src/xdrf/xdr_stdio.c deleted file mode 100644 index 12b1709..0000000 --- a/source/cluster/wham/src/xdrf/xdr_stdio.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * xdr_stdio.c, XDR implementation on standard i/o file. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * This set of routines implements a XDR on a stdio stream. - * XDR_ENCODE serializes onto the stream, XDR_DECODE de-serializes - * from the stream. - */ - -#include "types.h" -#include -#include "xdr.h" - -#ifdef USE_IN_LIBIO -# include -# define fflush(s) INTUSE(_IO_fflush) (s) -# define fread(p, m, n, s) INTUSE(_IO_fread) (p, m, n, s) -# define ftell(s) INTUSE(_IO_ftell) (s) -# define fwrite(p, m, n, s) INTUSE(_IO_fwrite) (p, m, n, s) -#endif - -static bool_t xdrstdio_getlong (XDR *, long *); -static bool_t xdrstdio_putlong (XDR *, const long *); -static bool_t xdrstdio_getbytes (XDR *, caddr_t, u_int); -static bool_t xdrstdio_putbytes (XDR *, const char *, u_int); -static u_int xdrstdio_getpos (const XDR *); -static bool_t xdrstdio_setpos (XDR *, u_int); -static int32_t *xdrstdio_inline (XDR *, u_int); -static void xdrstdio_destroy (XDR *); -static bool_t xdrstdio_getint32 (XDR *, int32_t *); -static bool_t xdrstdio_putint32 (XDR *, const int32_t *); - -/* - * Ops vector for stdio type XDR - */ -static const struct xdr_ops xdrstdio_ops = -{ - xdrstdio_getlong, /* deserialize a long int */ - xdrstdio_putlong, /* serialize a long int */ - xdrstdio_getbytes, /* deserialize counted bytes */ - xdrstdio_putbytes, /* serialize counted bytes */ - xdrstdio_getpos, /* get offset in the stream */ - xdrstdio_setpos, /* set offset in the stream */ - xdrstdio_inline, /* prime stream for inline macros */ - xdrstdio_destroy, /* destroy stream */ - xdrstdio_getint32, /* deserialize a int */ - xdrstdio_putint32 /* serialize a int */ -}; - -/* - * Initialize a stdio xdr stream. - * Sets the xdr stream handle xdrs for use on the stream file. - * Operation flag is set to op. - */ -void -xdrstdio_create (XDR *xdrs, FILE *file, enum xdr_op op) -{ - xdrs->x_op = op; - /* We have to add the const since the `struct xdr_ops' in `struct XDR' - is not `const'. */ - xdrs->x_ops = (struct xdr_ops *) &xdrstdio_ops; - xdrs->x_private = (caddr_t) file; - xdrs->x_handy = 0; - xdrs->x_base = 0; -} - -/* - * Destroy a stdio xdr stream. - * Cleans up the xdr stream handle xdrs previously set up by xdrstdio_create. - */ -static void -xdrstdio_destroy (XDR *xdrs) -{ - (void) fflush ((FILE *) xdrs->x_private); - /* xx should we close the file ?? */ -}; - -static bool_t -xdrstdio_getlong (XDR *xdrs, long *lp) -{ - u_int32_t mycopy; - - if (fread ((caddr_t) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1) - return FALSE; - *lp = (long) ntohl (mycopy); - return TRUE; -} - -static bool_t -xdrstdio_putlong (XDR *xdrs, const long *lp) -{ - int32_t mycopy = htonl ((u_int32_t) *lp); - - if (fwrite ((caddr_t) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1) - return FALSE; - return TRUE; -} - -static bool_t -xdrstdio_getbytes (XDR *xdrs, const caddr_t addr, u_int len) -{ - if ((len != 0) && (fread (addr, (int) len, 1, - (FILE *) xdrs->x_private) != 1)) - return FALSE; - return TRUE; -} - -static bool_t -xdrstdio_putbytes (XDR *xdrs, const char *addr, u_int len) -{ - if ((len != 0) && (fwrite (addr, (int) len, 1, - (FILE *) xdrs->x_private) != 1)) - return FALSE; - return TRUE; -} - -static u_int -xdrstdio_getpos (const XDR *xdrs) -{ - return (u_int) ftell ((FILE *) xdrs->x_private); -} - -static bool_t -xdrstdio_setpos (XDR *xdrs, u_int pos) -{ - return fseek ((FILE *) xdrs->x_private, (long) pos, 0) < 0 ? FALSE : TRUE; -} - -static int32_t * -xdrstdio_inline (XDR *xdrs, u_int len) -{ - /* - * Must do some work to implement this: must insure - * enough data in the underlying stdio buffer, - * that the buffer is aligned so that we can indirect through a - * long *, and stuff this pointer in xdrs->x_buf. Doing - * a fread or fwrite to a scratch buffer would defeat - * most of the gains to be had here and require storage - * management on this buffer, so we don't do this. - */ - return NULL; -} - -static bool_t -xdrstdio_getint32 (XDR *xdrs, int32_t *ip) -{ - int32_t mycopy; - - if (fread ((caddr_t) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1) - return FALSE; - *ip = ntohl (mycopy); - return TRUE; -} - -static bool_t -xdrstdio_putint32 (XDR *xdrs, const int32_t *ip) -{ - int32_t mycopy = htonl (*ip); - - ip = &mycopy; - if (fwrite ((caddr_t) ip, 4, 1, (FILE *) xdrs->x_private) != 1) - return FALSE; - return TRUE; -} - -/* libc_hidden_def (xdrstdio_create) */ diff --git a/source/cluster/wham/src/xdrf/xdrf.h b/source/cluster/wham/src/xdrf/xdrf.h deleted file mode 100644 index dedf5a2..0000000 --- a/source/cluster/wham/src/xdrf/xdrf.h +++ /dev/null @@ -1,10 +0,0 @@ -/*_________________________________________________________________ - | - | xdrf.h - include file for C routines that want to use the - | functions below. -*/ - -int xdropen(XDR *xdrs, const char *filename, const char *type); -int xdrclose(XDR *xdrs) ; -int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) ; -