From: ehrlich@cs.psu.edu (Dan Ehrlich)
Subject: Re: Problems with Remote mounted files on 5000/240
Organization: Computer Science Department, Penn State University
Date: Fri, 16 Oct 1992 13:20:05 GMT

In article <1992Oct14.155731.22564@athena.mit.edu> paulc@plume.mit.edu (Paul Cloke) writes:

Paul> We are having problems with files mounted (via NFS) on our
Paul> Dec Station 5000/240. Our systems consists of several SUNs
Paul> a 5000/200 and a 5000/240.

Paul> The problem manisfests itself when a file is stored on a SUN
Paul> and we try to use it on the 5000/240(croquet). 

Sounds more like a CPU floating point bug.  Here is an article posted a
while back by Arthur Smith, <ponder@comet.wustl.edu>, with a test program
that will demonstrate the problem.  We had one 240 that needed to have the
CPU/FPU replaced.

========================== CUT HERE ===========================================
From asmith Fri Jul 24 09:20:08 1992
To: ponder@comet.wustl.edu
Subject: Re: DECstation 240 Problem....
Status: R

Use "sh" to unpack, and "make testr", "make testr2" to compile. The
first program is the one where we see inconsistencies:
run "testr > output" and "testr > output2" and then do a diff of
output and output2 - if they are identical your machine is ok (at
least it doesn't have the problem ours has). If they are different,
try just running testr2 - it should always give the same output. Then
call your DEC hotline.

			Good luck!

			Arthur Smith
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	Makefile
#	random.f
#	randomc.c
#	testr.c
#	testr2.c
# This archive created: Wed Jul 22 16:34:09 1992
export PATH; PATH=/bin:$PATH
if test -f 'Makefile'
then
	echo shar: will not over-write existing file "'Makefile'"
else
cat << \SHAR_EOF > 'Makefile'
LDFLAGS = -s
CFLAGS = -O
FFLAGS = -O
LIBS = -lm
LIBS2 = 

testr: testr.o randomc.o random.o
	f77 $(CFLAGS) testr.o randomc.o random.o -o testr $(LDFLAGS) $(LIBS2)
testr2: testr2.o randomc.o
	cc $(CFLAGS) testr2.o randomc.o -o testr2 $(LDFLAGS) $(LIBS)
SHAR_EOF
fi # end of overwriting check
if test -f 'random.f'
then
	echo shar: will not over-write existing file "'random.f'"
else
cat << \SHAR_EOF > 'random.f'
c  Random Number Generator obtained from R. H. Swendsen
c  To use it, call ran0 at the beginning of your program
c  with an integer seed NEXT.  Then to use the generator
c  call RAN2.

C NEW PROGRAM THAT IS INDEPENDENT OF THE COMPLIER
        SUBROUTINE RAN0(NEXT)
C        IMPLICIT UNDEFINED (a-h,o-z)
        REAL*8 ARAN(4096),X, AMAXIN, RLIST, FACT, FACT2
        INTEGER*4 MAX,NP1,NP2,NP3
        INTEGER TABLE(128),MULTS(5)
        COMMON/RANH/AMAXIN,MAX,N,MULT,TABLE,MULTS,N2
        COMMON/RANSEQ/RLIST(532),NP1,NP2
        MULTS(1)=189
        MULTS(2)=187
        MULTS(3)=195
        MULTS(4)=181
        MULTS(5)=197
        N=483
        WRITE(6,500) NEXT
500        FORMAT(i15)
        IF(NEXT.GE.1.AND.NEXT.LE.32767) THEN
        N=(NEXT/2)*2+1
        ENDIF
        MAX=32768
        AMAXIN=1.0/MAX
        MULT=197
C         MULT=181,187,195,197,189
C        WRITE(6,100) N,MAX,MULT
100        FORMAT(' RANDOM NUMBER PARAMETERS ARE',3I10)
        DO 15 J=1,128
        N=N*MULT
        L=N/32768
        N=N-L*32768        
        TABLE(J)=N
15        CONTINUE
C - INITIALIZE RAN532
        NP1=532
        NP2=37
        FACT=1.0/512.0
        FACT2=FACT*FACT
        NP3=3*NP1
        CALL RAN1(ARAN,NP3)
        DO 50 K=1,NP1
        X=ARAN(K)-ARAN(K+NP1)*FACT-ARAN(K+2*NP1)*FACT2
        IF(X.LE.0.0) X=X+1.0
        RLIST(K)=X
50        CONTINUE
        RETURN
        END

        SUBROUTINE RAN1(ARAN,NRAN)
C        IMPLICIT UNDEFINED (a-h,o-z)
        REAL*8 ARAN(4096), AMAXIN
        INTEGER*4 MAX,NRAN,K
        INTEGER TABLE(128),MULTS(5)
        COMMON/RANH/AMAXIN,MAX,N,MULT,TABLE,MULTS,N2
C      NRAN MUST NOT BE GREATER THAN 4096
        DO 1 K=1,NRAN
        KMULT=K-(K/5)*5+1
        MULT=MULTS(KMULT)
        N=N*MULT
        L=N/32768
        N=N-L*32768
        M=N/256 + 1
        N2=TABLE(M)
        ARAN(K)=N2*AMAXIN
         N2=N2*MULT
        L2=N2/32768
        N2=N2-L2*32768
        TABLE(M)=N2
 1         CONTINUE
        RETURN
        END

        SUBROUTINE RAN2(ARAN,NRAN)
C        IMPLICIT UNDEFINED (a-h,o-z)
        REAL*8 ARAN(4096), X, RLIST
        COMMON/RANSEQ/RLIST(532),NP1,NP2
C -  NRAN MUST NOT BE GREATER THAN 4096
        DO 1 K=1,NRAN
        NP1=NP1-1
        IF(NP1.LE.0) NP1=532
        NP2=NP2-1
        IF(NP2.LE.0) NP2=532
        X=RLIST(NP1)-RLIST(NP2)
        IF(X.LT.0.0) X=X+1.0
        RLIST(NP1)=X 
        ARAN(K)=X
1         CONTINUE
        RETURN
        END


SHAR_EOF
fi # end of overwriting check
if test -f 'randomc.c'
then
	echo shar: will not over-write existing file "'randomc.c'"
else
cat << \SHAR_EOF > 'randomc.c'
/*  Random Number Generator obtained from R. H. Swendsen, translated into  */
/*  C by Shelly Shumway.  */ 
/*  To use it, call ran0 at the beginning of your program with an integer  */
/*  seed 0 < NEXT < 32768.  Then call RAN2[double randoms[nran],int nran]  */
/*  to fill the array "randoms".  */



#define MAX 32768;
void ran0c(), ran1c(), ran2c();
double  rlist[532];

void ran0c(next)
int next;
{
   double aran[4096],x,fact = 1./512, fact2 = 1./(512*512);
   int table[128], np1=532,j,k,l,mult = 197,n;

   if(next < 1) next = 483;
   n = next%MAX;
   n = (next/2)*2+1;

   for(j=0;j<128;j++) 
        n = table[j] = (n*mult)%MAX;

   ran1c(aran,3*np1,mult,n,table);
   
   for(k=0;k<np1;k++) {
      x = aran[k] - aran[k+np1]*fact - aran[k+2*np1]*fact2;
      if(x <= 0.0) x += 1.0;
      rlist[k] = x;
   }
}

void ran1c(aran,nran,mult,n,table)
double *aran;
int nran,mult,n,*table;
{
   int k,l,l2,n2,m,kmult,mults[5];
   mults[0] = 189; mults[1] = 187; mults[2] = 195; mults[3] = 181; mults[4]=197;

   for(k=1;k<=nran;k++) {
     mult = mults[(k%5)];
     n *= mult;
     l = n/MAX;
     n -= l*MAX;
     m = n/256;
     n2 = table[m];
     aran[k-1] = (1.*n2)/MAX;
     n2 *= mult;
     l2 = n2/MAX;
     n2 -= l2*MAX;
     table[m] = n2;
   }
}

void ran2c(aran,nran)
double *aran;
int nran;
{
  double *rlend, x;
  static int np1=530, np2=35;
  int k,nran_mod_532;
  register double *rl1, *rl2, *ar;

  rl1 = rlist + np1;
  rl2 = rlist + np2;
  rlend = rlist + 531;
  ar = aran;
  for(k=0;k<nran;k++, rl1--, rl2--, ar++) {
    if(rl1 < rlist) rl1 = rlend;
    if(rl2 < rlist) rl2 = rlend;
    x = (*rl1) - (*rl2);
    if(x < 0.0) x += 1.0;
    (*rl1) = (*ar) = x;
  }
  nran_mod_532 = nran - (nran/532)*532;
  np1 -= nran_mod_532;
  np2 -= nran_mod_532;
  if(np1 < 0) np1 += 532;
  if(np2 < 0) np2 += 532;
}


SHAR_EOF
fi # end of overwriting check
if test -f 'testr.c'
then
	echo shar: will not over-write existing file "'testr.c'"
else
cat << \SHAR_EOF > 'testr.c'
#include <math.h>
#include <stdio.h>
#define SEED 17595
#define NITER 100
#define NSIZE 20

main()
{
	int i, junk, j;
	double x[NSIZE];
	void ran0c(), ran2c();
	
	junk = SEED;
	ran0c(SEED);
	ran0_(&junk);
	printf("C:");
	for (i=0; i < NITER; i++) {
		ran2c(x, NSIZE);
		for  (j=0; j < NSIZE; j++)
			printf("%18.15g\n", sin(x[j]));
	}
	junk = NSIZE;
	printf("Fortran:");
	for (i=0; i < NITER; i++) {
		ran2_(x, &junk);
		for  (j=0; j < NSIZE; j++)
			printf("%18.15g\n", sin(x[j]));
	}
}
SHAR_EOF
fi # end of overwriting check
if test -f 'testr2.c'
then
	echo shar: will not over-write existing file "'testr2.c'"
else
cat << \SHAR_EOF > 'testr2.c'
#include <math.h>
#include <stdio.h>
#define SEED 17595
#define NITER 100
#define NSIZE 20

main()
{
	int i, junk, j;
	double x[NSIZE];
	void ran0c(), ran2c();
	
	printf("C:\n");
	ran0c(SEED);
	for (i=0; i < NITER; i++) {
		ran2c(x, NSIZE);
		for  (j=0; j < NSIZE; j++)
			printf("%18.15g\n", sin(x[j]));
	}
}
SHAR_EOF
fi # end of overwriting check
#	End of shell archive
exit 0
===============================================================================
--
Dan Ehrlich - Sr. Systems Programmer - Penn State Computer Science
"Universities should be safe havens where ruthless examination of
 realities will not be distorted by the aim to please or inhibited
 by the risk of displeasure." - Kingman Brewster
Newsgroups: comp.unix.ultrix